fix: improved error reporting in super; improved draggable block icon padding

This commit is contained in:
Mo
2022-11-18 20:54:03 -06:00
parent e8b758214d
commit 24ff87c306
4 changed files with 13 additions and 8 deletions

View File

@@ -67,8 +67,14 @@ export const BlocksEditor: FunctionComponent<BlocksEditorProps> = ({
});
previewText = truncateString(previewText, previewLength);
const stringifiedEditorState = JSON.stringify(editorState.toJSON());
onChange(stringifiedEditorState, previewText);
try {
const stringifiedEditorState = JSON.stringify(editorState.toJSON());
onChange(stringifiedEditorState, previewText);
} catch (error) {
window.alert(
`An invalid change was made inside the Super editor. Your change was not saved. Please report this error to the team: ${error}`,
);
}
});
},
[onChange, didIgnoreFirstChange],

View File

@@ -25,12 +25,11 @@ import {isHTMLElement} from '../../Utils/guard';
import {Point} from '../../Utils/point';
import {Rect} from '../../Utils/rect';
const SPACE = -16;
const SPACE = 4;
const TARGET_LINE_HALF_HEIGHT = 2;
const DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu';
const DRAG_DATA_FORMAT = 'application/x-lexical-drag-block';
const TEXT_BOX_HORIZONTAL_PADDING = 28;
const TARGET_LINE_SPACE_FROM_LEFT = 0;
const Downward = 1;
const Upward = -1;
@@ -181,7 +180,7 @@ function setTargetLine(
}
const top = lineTop - anchorTop - TARGET_LINE_HALF_HEIGHT;
const left = TARGET_LINE_SPACE_FROM_LEFT;
const left = TEXT_BOX_HORIZONTAL_PADDING - SPACE;
targetLineElem.style.transform = `translate(${left}px, ${top}px)`;
targetLineElem.style.width = `${

View File

@@ -7,7 +7,7 @@
*/
import {isPoint, Point} from './point';
type ContainsPointReturn = {
export type ContainsPointReturn = {
result: boolean;
reason: {
isOnTopSide: boolean;

View File

@@ -90,7 +90,7 @@ export const SuperEditor: FunctionComponent<Props> = ({
}, [controller, controller.item.uuid])
return (
<div className="relative h-full w-full px-5 py-4">
<div className="relative h-full w-full">
<ErrorBoundary>
<LinkingControllerProvider controller={linkingController}>
<FilesControllerProvider controller={filesController}>
@@ -102,7 +102,7 @@ export const SuperEditor: FunctionComponent<Props> = ({
<BlocksEditor
onChange={handleChange}
ignoreFirstChange={true}
className="relative h-full resize-none text-base focus:shadow-none focus:outline-none"
className="relative h-full resize-none px-5 py-4 text-base focus:shadow-none focus:outline-none"
previewLength={NotePreviewCharLimit}
spellcheck={spellcheck}
>