@payloadcms/richtext-lexical 3.0.0-beta.35 → 3.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/index.d.ts +2 -0
- package/dist/cell/index.d.ts.map +1 -1
- package/dist/cell/index.js +24 -15
- package/dist/cell/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +66 -47
- package/dist/field/Field.js.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.js +62 -45
- package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
- package/dist/field/features/blocks/component/index.js +38 -28
- package/dist/field/features/blocks/component/index.js.map +1 -1
- package/dist/field/features/blocks/drawer/index.js +2 -1
- package/dist/field/features/blocks/drawer/index.js.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.js +2 -1
- package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
- package/dist/field/features/blocks/plugin/index.js +2 -1
- package/dist/field/features/blocks/plugin/index.js.map +1 -1
- package/dist/field/features/debug/testRecorder/plugin/index.js +65 -39
- package/dist/field/features/debug/testRecorder/plugin/index.js.map +1 -1
- package/dist/field/features/debug/treeView/plugin/index.js +2 -1
- package/dist/field/features/debug/treeView/plugin/index.js.map +1 -1
- package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.js +2 -1
- package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/field/features/link/drawer/index.js +30 -22
- package/dist/field/features/link/drawer/index.js.map +1 -1
- package/dist/field/features/link/plugins/clickableLink/index.js +2 -1
- package/dist/field/features/link/plugins/clickableLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +88 -70
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.js +2 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/field/features/lists/checklist/plugin/index.js +2 -1
- package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
- package/dist/field/features/lists/plugin/index.js +2 -1
- package/dist/field/features/lists/plugin/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +9 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +9 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/relationship/drawer/index.js +10 -2
- package/dist/field/features/relationship/drawer/index.js.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.js +2 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +64 -44
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/relationship/plugins/index.js +2 -1
- package/dist/field/features/relationship/plugins/index.js.map +1 -1
- package/dist/field/features/toolbars/fixed/Toolbar/index.js +60 -55
- package/dist/field/features/toolbars/fixed/Toolbar/index.js.map +1 -1
- package/dist/field/features/toolbars/fixed/Toolbar/index.scss +16 -2
- package/dist/field/features/toolbars/inline/Toolbar/index.js +57 -49
- package/dist/field/features/toolbars/inline/Toolbar/index.js.map +1 -1
- package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts +1 -1
- package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/field/features/toolbars/shared/ToolbarButton/index.js +5 -3
- package/dist/field/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js +54 -35
- package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts +1 -1
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js +25 -22
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +30 -22
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
- package/dist/field/features/upload/component/index.js +104 -71
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/drawer/index.js +8 -4
- package/dist/field/features/upload/drawer/index.js.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.d.ts +1 -1
- package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.js +2 -1
- package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
- package/dist/field/features/upload/plugin/index.js +2 -1
- package/dist/field/features/upload/plugin/index.js.map +1 -1
- package/dist/field/index.d.ts +2 -0
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +29 -21
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.scss +0 -19
- package/dist/field/lexical/EditorFocusProvider.d.ts +1 -2
- package/dist/field/lexical/EditorFocusProvider.d.ts.map +1 -1
- package/dist/field/lexical/EditorFocusProvider.js +5 -3
- package/dist/field/lexical/EditorFocusProvider.js.map +1 -1
- package/dist/field/lexical/EditorPlugin.js +3 -2
- package/dist/field/lexical/EditorPlugin.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.js +113 -81
- package/dist/field/lexical/LexicalEditor.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.scss +10 -1
- package/dist/field/lexical/LexicalProvider.js +16 -10
- package/dist/field/lexical/LexicalProvider.js.map +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.js +5 -3
- package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/field/lexical/config/client/sanitize.d.ts +2 -1
- package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/client/sanitize.js +2 -1
- package/dist/field/lexical/config/client/sanitize.js.map +1 -1
- package/dist/field/lexical/config/types.d.ts +2 -0
- package/dist/field/lexical/config/types.d.ts.map +1 -1
- package/dist/field/lexical/config/types.js.map +1 -1
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js +2 -1
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +2 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.js +51 -40
- package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts +2 -2
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +38 -119
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +2 -2
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.d.ts +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts +2 -2
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +102 -58
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.scss +12 -3
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts +8 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +73 -25
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts +5 -0
- package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts.map +1 -0
- package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.js +21 -0
- package/dist/field/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.js.map +1 -0
- package/dist/field/lexical/plugins/handles/{DraggableBlockPlugin → utils}/getNodeCloseToPoint.d.ts +4 -0
- package/dist/field/lexical/plugins/handles/utils/getNodeCloseToPoint.d.ts.map +1 -0
- package/dist/field/lexical/plugins/handles/{DraggableBlockPlugin → utils}/getNodeCloseToPoint.js +2 -14
- package/dist/field/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -0
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js +4 -2
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/field/lexical/theme/EditorTheme.scss +5 -0
- package/dist/field/lexical/ui/ContentEditable.d.ts +1 -1
- package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/field/lexical/ui/ContentEditable.js +2 -1
- package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/field/lexical/ui/ContentEditable.scss +50 -2
- package/dist/field/lexical/ui/icons/AI/index.js +26 -17
- package/dist/field/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Add/index.js +14 -9
- package/dist/field/lexical/ui/icons/Add/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Add/light.svg +4 -0
- package/dist/field/lexical/ui/icons/AlignCenter/index.js +21 -15
- package/dist/field/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignJustify/index.js +21 -15
- package/dist/field/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignLeft/index.js +21 -15
- package/dist/field/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignRight/index.js +21 -15
- package/dist/field/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Block/index.js +30 -24
- package/dist/field/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Blockquote/index.js +8 -6
- package/dist/field/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Bold/index.js +8 -6
- package/dist/field/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Checklist/index.js +19 -14
- package/dist/field/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Code/index.js +14 -9
- package/dist/field/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/CodeBlock/index.js +14 -9
- package/dist/field/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/DraggableBlock/light.svg +9 -0
- package/dist/field/lexical/ui/icons/H1/index.js +8 -6
- package/dist/field/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H2/index.js +8 -6
- package/dist/field/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H3/index.js +8 -6
- package/dist/field/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H4/index.js +8 -6
- package/dist/field/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H5/index.js +8 -6
- package/dist/field/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H6/index.js +8 -6
- package/dist/field/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/HorizontalRule/index.js +11 -9
- package/dist/field/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/IndentDecrease/index.js +25 -18
- package/dist/field/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/IndentIncrease/index.js +25 -18
- package/dist/field/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Italic/index.js +8 -6
- package/dist/field/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Link/index.js +26 -17
- package/dist/field/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/OrderedList/index.js +29 -21
- package/dist/field/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Relationship/index.js +26 -17
- package/dist/field/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Strikethrough/index.js +14 -9
- package/dist/field/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Subscript/index.js +8 -6
- package/dist/field/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Superscript/index.js +8 -6
- package/dist/field/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Text/index.js +8 -6
- package/dist/field/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Underline/index.js +14 -9
- package/dist/field/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/UnorderedList/index.js +45 -36
- package/dist/field/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Upload/index.js +24 -18
- package/dist/field/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/generateComponentMap.js +8 -8
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +17 -13
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +0 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +0 -1
package/dist/field/index.scss
CHANGED
|
@@ -23,22 +23,3 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
html[data-theme='light'] {
|
|
27
|
-
.rich-text-lexical {
|
|
28
|
-
&.error {
|
|
29
|
-
.editor-container {
|
|
30
|
-
@include lightInputError;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
html[data-theme='dark'] {
|
|
37
|
-
.rich-text-lexical {
|
|
38
|
-
&.error {
|
|
39
|
-
.editor-container {
|
|
40
|
-
@include darkInputError;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LexicalEditor } from 'lexical';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import type { EditorConfigContextType } from './config/client/EditorConfigProvider.js';
|
|
4
3
|
export type EditorFocusContextType = {
|
|
5
4
|
blurEditor: () => void;
|
|
@@ -16,5 +15,5 @@ export type EditorFocusContextType = {
|
|
|
16
15
|
export declare const useEditorFocus: () => EditorFocusContextType;
|
|
17
16
|
export declare const EditorFocusProvider: ({ children }: {
|
|
18
17
|
children: any;
|
|
19
|
-
}) =>
|
|
18
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
19
|
//# sourceMappingURL=EditorFocusProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorFocusProvider.d.ts","sourceRoot":"","sources":["../../../src/field/lexical/EditorFocusProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"EditorFocusProvider.d.ts","sourceRoot":"","sources":["../../../src/field/lexical/EditorFocusProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAK5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AAItF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,MAAM,EAAE,aAAa,CAAA;IACrB,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,oBAAoB,CAAC,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC9F,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IACnC,0BAA0B,EAAE,uBAAuB,CAAA;IACnD,oBAAoB,EAAE,MAAM,OAAO,CAAA;IACnC,eAAe,EAAE,MAAM,OAAO,CAAA;IAC9B,qBAAqB,EAAE,MAAM,OAAO,CAAA;IACpC,yBAAyB,EAAE,uBAAuB,CAAA;IAClD,iBAAiB,EAAE,sBAAsB,CAAA;CAC1C,CAAA;AAeD,eAAO,MAAM,cAAc,QAAO,sBAEjC,CAAA;AAED,eAAO,MAAM,mBAAmB;;6CA4D/B,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
2
3
|
import React, { createContext, useCallback, useContext, useState } from 'react';
|
|
3
4
|
import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
|
|
@@ -59,7 +60,7 @@ export const EditorFocusProvider = ({ children })=>{
|
|
|
59
60
|
editor,
|
|
60
61
|
focusedEditor
|
|
61
62
|
]);
|
|
62
|
-
return /*#__PURE__*/
|
|
63
|
+
return /*#__PURE__*/ _jsx(EditorFocusContext.Provider, {
|
|
63
64
|
value: {
|
|
64
65
|
blurEditor,
|
|
65
66
|
editor,
|
|
@@ -71,8 +72,9 @@ export const EditorFocusProvider = ({ children })=>{
|
|
|
71
72
|
isParentEditorFocused,
|
|
72
73
|
parentEditorConfigContext,
|
|
73
74
|
parentEditorFocus
|
|
74
|
-
}
|
|
75
|
-
|
|
75
|
+
},
|
|
76
|
+
children: children
|
|
77
|
+
});
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
//# sourceMappingURL=EditorFocusProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/EditorFocusProvider.tsx"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport React, { createContext, useCallback, useContext, useState } from 'react'\n\nimport type { EditorConfigContextType } from './config/client/EditorConfigProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\n\nexport type EditorFocusContextType = {\n blurEditor: () => void\n editor: LexicalEditor\n focusEditor: (_editor?: LexicalEditor, _editorConfigContext?: EditorConfigContextType) => void\n focusedEditor: LexicalEditor | null\n focusedEditorConfigContext: EditorConfigContextType\n isChildEditorFocused: () => boolean\n isEditorFocused: () => boolean\n isParentEditorFocused: () => boolean\n parentEditorConfigContext: EditorConfigContextType\n parentEditorFocus: EditorFocusContextType\n}\n\nconst EditorFocusContext = createContext<EditorFocusContextType>({\n blurEditor: null,\n editor: null,\n focusEditor: null,\n focusedEditor: null,\n focusedEditorConfigContext: null,\n isChildEditorFocused: null,\n isEditorFocused: null,\n isParentEditorFocused: null,\n parentEditorConfigContext: null,\n parentEditorFocus: null,\n})\n\nexport const useEditorFocus = (): EditorFocusContextType => {\n return useContext(EditorFocusContext)\n}\n\nexport const EditorFocusProvider = ({ children }) => {\n const parentEditorFocus = useEditorFocus()\n const parentEditorConfigContext = useEditorConfigContext() // Is parent, as this EditorFocusProvider sits outside the EditorConfigProvider\n const [editor] = useLexicalComposerContext()\n\n const [focusedEditor, setFocusedEditor] = useState<LexicalEditor | null>(null)\n const [focusedEditorConfigContext, setFocusedEditorConfigContext] =\n useState<EditorConfigContextType | null>(null)\n\n const focusEditor = useCallback(\n (_editor: LexicalEditor, _editorConfigContext: EditorConfigContextType) => {\n setFocusedEditor(_editor !== undefined ? _editor : editor)\n setFocusedEditorConfigContext(_editorConfigContext)\n if (parentEditorFocus.focusEditor) {\n parentEditorFocus.focusEditor(\n _editor !== undefined ? _editor : editor,\n _editorConfigContext,\n )\n }\n },\n [editor, parentEditorFocus],\n )\n\n const blurEditor = useCallback(() => {\n if (focusedEditor === editor) {\n setFocusedEditor(null)\n setFocusedEditorConfigContext(null)\n }\n }, [editor, focusedEditor])\n\n const isEditorFocused = useCallback(() => {\n return focusedEditor === editor\n }, [editor, focusedEditor])\n\n const isParentEditorFocused = useCallback(() => {\n return parentEditorFocus?.isEditorFocused ? parentEditorFocus.isEditorFocused() : false\n }, [parentEditorFocus])\n\n const isChildEditorFocused = useCallback(() => {\n return focusedEditor !== editor && !!focusedEditor\n }, [editor, focusedEditor])\n\n return (\n <EditorFocusContext.Provider\n value={{\n blurEditor,\n editor,\n focusEditor,\n focusedEditor,\n focusedEditorConfigContext,\n isChildEditorFocused,\n isEditorFocused,\n isParentEditorFocused,\n parentEditorConfigContext,\n parentEditorFocus,\n }}\n >\n {children}\n </EditorFocusContext.Provider>\n )\n}\n"],"names":["useLexicalComposerContext","React","createContext","useCallback","useContext","useState","useEditorConfigContext","EditorFocusContext","blurEditor","editor","focusEditor","focusedEditor","focusedEditorConfigContext","isChildEditorFocused","isEditorFocused","isParentEditorFocused","parentEditorConfigContext","parentEditorFocus","useEditorFocus","EditorFocusProvider","children","setFocusedEditor","setFocusedEditorConfigContext","_editor","_editorConfigContext","undefined","Provider","value"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/EditorFocusProvider.tsx"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport React, { createContext, useCallback, useContext, useState } from 'react'\n\nimport type { EditorConfigContextType } from './config/client/EditorConfigProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\n\nexport type EditorFocusContextType = {\n blurEditor: () => void\n editor: LexicalEditor\n focusEditor: (_editor?: LexicalEditor, _editorConfigContext?: EditorConfigContextType) => void\n focusedEditor: LexicalEditor | null\n focusedEditorConfigContext: EditorConfigContextType\n isChildEditorFocused: () => boolean\n isEditorFocused: () => boolean\n isParentEditorFocused: () => boolean\n parentEditorConfigContext: EditorConfigContextType\n parentEditorFocus: EditorFocusContextType\n}\n\nconst EditorFocusContext = createContext<EditorFocusContextType>({\n blurEditor: null,\n editor: null,\n focusEditor: null,\n focusedEditor: null,\n focusedEditorConfigContext: null,\n isChildEditorFocused: null,\n isEditorFocused: null,\n isParentEditorFocused: null,\n parentEditorConfigContext: null,\n parentEditorFocus: null,\n})\n\nexport const useEditorFocus = (): EditorFocusContextType => {\n return useContext(EditorFocusContext)\n}\n\nexport const EditorFocusProvider = ({ children }) => {\n const parentEditorFocus = useEditorFocus()\n const parentEditorConfigContext = useEditorConfigContext() // Is parent, as this EditorFocusProvider sits outside the EditorConfigProvider\n const [editor] = useLexicalComposerContext()\n\n const [focusedEditor, setFocusedEditor] = useState<LexicalEditor | null>(null)\n const [focusedEditorConfigContext, setFocusedEditorConfigContext] =\n useState<EditorConfigContextType | null>(null)\n\n const focusEditor = useCallback(\n (_editor: LexicalEditor, _editorConfigContext: EditorConfigContextType) => {\n setFocusedEditor(_editor !== undefined ? _editor : editor)\n setFocusedEditorConfigContext(_editorConfigContext)\n if (parentEditorFocus.focusEditor) {\n parentEditorFocus.focusEditor(\n _editor !== undefined ? _editor : editor,\n _editorConfigContext,\n )\n }\n },\n [editor, parentEditorFocus],\n )\n\n const blurEditor = useCallback(() => {\n if (focusedEditor === editor) {\n setFocusedEditor(null)\n setFocusedEditorConfigContext(null)\n }\n }, [editor, focusedEditor])\n\n const isEditorFocused = useCallback(() => {\n return focusedEditor === editor\n }, [editor, focusedEditor])\n\n const isParentEditorFocused = useCallback(() => {\n return parentEditorFocus?.isEditorFocused ? parentEditorFocus.isEditorFocused() : false\n }, [parentEditorFocus])\n\n const isChildEditorFocused = useCallback(() => {\n return focusedEditor !== editor && !!focusedEditor\n }, [editor, focusedEditor])\n\n return (\n <EditorFocusContext.Provider\n value={{\n blurEditor,\n editor,\n focusEditor,\n focusedEditor,\n focusedEditorConfigContext,\n isChildEditorFocused,\n isEditorFocused,\n isParentEditorFocused,\n parentEditorConfigContext,\n parentEditorFocus,\n }}\n >\n {children}\n </EditorFocusContext.Provider>\n )\n}\n"],"names":["useLexicalComposerContext","React","createContext","useCallback","useContext","useState","useEditorConfigContext","EditorFocusContext","blurEditor","editor","focusEditor","focusedEditor","focusedEditorConfigContext","isChildEditorFocused","isEditorFocused","isParentEditorFocused","parentEditorConfigContext","parentEditorFocus","useEditorFocus","EditorFocusProvider","children","setFocusedEditor","setFocusedEditorConfigContext","_editor","_editorConfigContext","undefined","Provider","value"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,OAAOC,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAI/E,SAASC,sBAAsB,QAAQ,0CAAyC;AAehF,MAAMC,mCAAqBL,cAAsC;IAC/DM,YAAY;IACZC,QAAQ;IACRC,aAAa;IACbC,eAAe;IACfC,4BAA4B;IAC5BC,sBAAsB;IACtBC,iBAAiB;IACjBC,uBAAuB;IACvBC,2BAA2B;IAC3BC,mBAAmB;AACrB;AAEA,OAAO,MAAMC,iBAAiB;IAC5B,OAAOd,WAAWG;AACpB,EAAC;AAED,OAAO,MAAMY,sBAAsB,CAAC,EAAEC,QAAQ,EAAE;IAC9C,MAAMH,oBAAoBC;IAC1B,MAAMF,4BAA4BV,yBAAyB,+EAA+E;;IAC1I,MAAM,CAACG,OAAO,GAAGT;IAEjB,MAAM,CAACW,eAAeU,iBAAiB,GAAGhB,SAA+B;IACzE,MAAM,CAACO,4BAA4BU,8BAA8B,GAC/DjB,SAAyC;IAE3C,MAAMK,cAAcP,YAClB,CAACoB,SAAwBC;QACvBH,iBAAiBE,YAAYE,YAAYF,UAAUd;QACnDa,8BAA8BE;QAC9B,IAAIP,kBAAkBP,WAAW,EAAE;YACjCO,kBAAkBP,WAAW,CAC3Ba,YAAYE,YAAYF,UAAUd,QAClCe;QAEJ;IACF,GACA;QAACf;QAAQQ;KAAkB;IAG7B,MAAMT,aAAaL,YAAY;QAC7B,IAAIQ,kBAAkBF,QAAQ;YAC5BY,iBAAiB;YACjBC,8BAA8B;QAChC;IACF,GAAG;QAACb;QAAQE;KAAc;IAE1B,MAAMG,kBAAkBX,YAAY;QAClC,OAAOQ,kBAAkBF;IAC3B,GAAG;QAACA;QAAQE;KAAc;IAE1B,MAAMI,wBAAwBZ,YAAY;QACxC,OAAOc,mBAAmBH,kBAAkBG,kBAAkBH,eAAe,KAAK;IACpF,GAAG;QAACG;KAAkB;IAEtB,MAAMJ,uBAAuBV,YAAY;QACvC,OAAOQ,kBAAkBF,UAAU,CAAC,CAACE;IACvC,GAAG;QAACF;QAAQE;KAAc;IAE1B,qBACE,KAACJ,mBAAmBmB,QAAQ;QAC1BC,OAAO;YACLnB;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;kBAECG;;AAGP,EAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
export const EditorPlugin = ({ anchorElem, clientProps, plugin })=>{
|
|
3
4
|
if (plugin.position === 'floatingAnchorElem') {
|
|
4
|
-
return plugin.Component && /*#__PURE__*/
|
|
5
|
+
return plugin.Component && /*#__PURE__*/ _jsx(plugin.Component, {
|
|
5
6
|
anchorElem: anchorElem,
|
|
6
7
|
clientProps: clientProps
|
|
7
8
|
});
|
|
8
9
|
}
|
|
9
|
-
return plugin.Component && /*#__PURE__*/
|
|
10
|
+
return plugin.Component && /*#__PURE__*/ _jsx(plugin.Component, {
|
|
10
11
|
clientProps: clientProps
|
|
11
12
|
});
|
|
12
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/EditorPlugin.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { SanitizedPlugin } from '../features/types.js'\n\nexport const EditorPlugin: React.FC<{\n anchorElem?: HTMLDivElement\n clientProps: any\n plugin: SanitizedPlugin\n}> = ({ anchorElem, clientProps, plugin }) => {\n if (plugin.position === 'floatingAnchorElem') {\n return (\n plugin.Component && <plugin.Component anchorElem={anchorElem} clientProps={clientProps} />\n )\n }\n\n return plugin.Component && <plugin.Component clientProps={clientProps} />\n}\n"],"names":["React","EditorPlugin","anchorElem","clientProps","plugin","position","Component"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/EditorPlugin.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { SanitizedPlugin } from '../features/types.js'\n\nexport const EditorPlugin: React.FC<{\n anchorElem?: HTMLDivElement\n clientProps: any\n plugin: SanitizedPlugin\n}> = ({ anchorElem, clientProps, plugin }) => {\n if (plugin.position === 'floatingAnchorElem') {\n return (\n plugin.Component && <plugin.Component anchorElem={anchorElem} clientProps={clientProps} />\n )\n }\n\n return plugin.Component && <plugin.Component clientProps={clientProps} />\n}\n"],"names":["React","EditorPlugin","anchorElem","clientProps","plugin","position","Component"],"rangeMappings":";;;;;;;;;;;;","mappings":";AAAA,YAAYA,WAAW,QAAO;AAI9B,OAAO,MAAMC,eAIR,CAAC,EAAEC,UAAU,EAAEC,WAAW,EAAEC,MAAM,EAAE;IACvC,IAAIA,OAAOC,QAAQ,KAAK,sBAAsB;QAC5C,OACED,OAAOE,SAAS,kBAAI,KAACF,OAAOE,SAAS;YAACJ,YAAYA;YAAYC,aAAaA;;IAE/E;IAEA,OAAOC,OAAOE,SAAS,kBAAI,KAACF,OAAOE,SAAS;QAACH,aAAaA;;AAC5D,EAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
3
4
|
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js';
|
|
4
5
|
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js';
|
|
@@ -60,87 +61,118 @@ export const LexicalEditor = (props)=>{
|
|
|
60
61
|
isSmallWidthViewport
|
|
61
62
|
]);
|
|
62
63
|
const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary;
|
|
63
|
-
return /*#__PURE__*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
64
|
+
return /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
65
|
+
children: [
|
|
66
|
+
editorConfig.features.plugins.map((plugin)=>{
|
|
67
|
+
if (plugin.position === 'aboveContainer') {
|
|
68
|
+
return /*#__PURE__*/ _jsx(EditorPlugin, {
|
|
69
|
+
clientProps: plugin.clientProps,
|
|
70
|
+
plugin: plugin
|
|
71
|
+
}, plugin.key);
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
75
|
+
className: "editor-container",
|
|
76
|
+
children: [
|
|
77
|
+
editorConfig.features.plugins.map((plugin)=>{
|
|
78
|
+
if (plugin.position === 'top') {
|
|
79
|
+
return /*#__PURE__*/ _jsx(EditorPlugin, {
|
|
80
|
+
clientProps: plugin.clientProps,
|
|
81
|
+
plugin: plugin
|
|
82
|
+
}, plugin.key);
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsx(RichTextPlugin, {
|
|
86
|
+
//@ts-expect-error ts being dumb
|
|
87
|
+
ErrorBoundary: ErrorBoundaryComponent,
|
|
88
|
+
contentEditable: /*#__PURE__*/ _jsx("div", {
|
|
89
|
+
className: "editor-scroller",
|
|
90
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
91
|
+
className: "editor",
|
|
92
|
+
ref: onRef,
|
|
93
|
+
children: /*#__PURE__*/ _jsx(LexicalContentEditable, {})
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
placeholder: /*#__PURE__*/ _jsx("p", {
|
|
97
|
+
className: "editor-placeholder",
|
|
98
|
+
children: "Start typing, or press '/' for commands..."
|
|
99
|
+
})
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ _jsx(OnChangePlugin, {
|
|
102
|
+
// Selection changes can be ignored here, reducing the
|
|
103
|
+
// frequency that the FieldComponent and Payload receive updates.
|
|
104
|
+
// Selection changes are only needed if you are saving selection state
|
|
105
|
+
ignoreSelectionChange: true,
|
|
106
|
+
onChange: (editorState, editor, tags)=>{
|
|
107
|
+
// Ignore any onChange event triggered by focus only
|
|
108
|
+
if (!tags.has('focus') || tags.size > 1) {
|
|
109
|
+
if (onChange != null) onChange(editorState, editor, tags);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
floatingAnchorElem && /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
114
|
+
children: [
|
|
115
|
+
!isSmallWidthViewport && editor.isEditable() && /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ _jsx(DraggableBlockPlugin, {
|
|
118
|
+
anchorElem: floatingAnchorElem
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ _jsx(AddBlockHandlePlugin, {
|
|
121
|
+
anchorElem: floatingAnchorElem
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
editorConfig.features.plugins.map((plugin)=>{
|
|
126
|
+
if (plugin.position === 'floatingAnchorElem' && !(plugin.desktopOnly === true && isSmallWidthViewport)) {
|
|
127
|
+
return /*#__PURE__*/ _jsx(EditorPlugin, {
|
|
128
|
+
anchorElem: floatingAnchorElem,
|
|
129
|
+
clientProps: plugin.clientProps,
|
|
130
|
+
plugin: plugin
|
|
131
|
+
}, plugin.key);
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
editor.isEditable() && /*#__PURE__*/ _jsx(React.Fragment, {
|
|
135
|
+
children: /*#__PURE__*/ _jsx(SlashMenuPlugin, {
|
|
136
|
+
anchorElem: floatingAnchorElem
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
}),
|
|
141
|
+
editor.isEditable() && /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
142
|
+
children: [
|
|
143
|
+
/*#__PURE__*/ _jsx(HistoryPlugin, {}),
|
|
144
|
+
editorConfig?.features?.markdownTransformers?.length > 0 && /*#__PURE__*/ _jsx(MarkdownShortcutPlugin, {})
|
|
145
|
+
]
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ _jsx(TabIndentationPlugin, {}),
|
|
148
|
+
editorConfig.features.plugins.map((plugin)=>{
|
|
149
|
+
if (plugin.position === 'normal') {
|
|
150
|
+
return /*#__PURE__*/ _jsx(EditorPlugin, {
|
|
151
|
+
clientProps: plugin.clientProps,
|
|
152
|
+
plugin: plugin
|
|
153
|
+
}, plugin.key);
|
|
154
|
+
}
|
|
155
|
+
}),
|
|
156
|
+
editorConfig.features.plugins.map((plugin)=>{
|
|
157
|
+
if (plugin.position === 'bottom') {
|
|
158
|
+
return /*#__PURE__*/ _jsx(EditorPlugin, {
|
|
159
|
+
clientProps: plugin.clientProps,
|
|
160
|
+
plugin: plugin
|
|
161
|
+
}, plugin.key);
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
166
|
+
editorConfig.features.plugins.map((plugin)=>{
|
|
167
|
+
if (plugin.position === 'belowContainer') {
|
|
168
|
+
return /*#__PURE__*/ _jsx(EditorPlugin, {
|
|
169
|
+
clientProps: plugin.clientProps,
|
|
170
|
+
plugin: plugin
|
|
171
|
+
}, plugin.key);
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
144
176
|
};
|
|
145
177
|
|
|
146
178
|
//# sourceMappingURL=LexicalEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorFocus } from './EditorFocusProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>> = (\n props,\n) => {\n const { editorConfig, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const editorFocus = useEditorFocus()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n editorFocus.focusEditor(editor, editorConfigContext)\n return true\n },\n\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n editorFocus.blurEditor()\n return true\n },\n\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, editorConfig, editorConfigContext, editorFocus])\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\">\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n //@ts-expect-error ts being dumb\n ErrorBoundary={ErrorBoundaryComponent}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n placeholder={\n <p className=\"editor-placeholder\">\n Start typing, or press '/' for commands...\n </p>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) onChange(editorState, editor, tags)\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","mergeRegister","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorFocus","EditorPlugin","useEditorConfigContext","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","onChange","editorConfigContext","editor","editorFocus","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","registerCommand","focusEditor","blurEditor","isSmallWidthViewport","setIsSmallWidthViewport","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","ErrorBoundaryComponent","default","Fragment","features","plugins","map","plugin","position","clientProps","key","div","className","ErrorBoundary","contentEditable","ref","placeholder","p","ignoreSelectionChange","editorState","tags","has","size","isEditable","anchorElem","desktopOnly","markdownTransformers","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,OAAOC,0BAA0B,yCAAwC;AACzE,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ,UAAS;AAC3E,YAAYC,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,OAAO,uBAAsB;AAC7B,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,sBAAsB,QAAQ,0BAAyB;AAEhE,OAAO,MAAMC,gBAAmF,CAC9FC;IAEA,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGF;IAC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ACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBACE,oBAACrC;gBAAasC,aAAaF,OAAOE,WAAW;gBAAEC,KAAKH,OAAOG,GAAG;gBAAEH,QAAQA;;QAE5E;IACF,IACC3B,aAAawB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBACE,oBAACrC;gBAAasC,aAAaF,OAAOE,WAAW;gBAAEC,KAAKH,OAAOG,GAAG;gBAAEH,QAAQA;;QAE5E;IACF,KAED3B,aAAawB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,kBAAkB;YACxC,qBAAO,oBAACrC;gBAAasC,aAAaF,OAAOE,WAAW;gBAAEC,KAAKH,OAAOG,GAAG;gBAAEH,QAAQA;;QACjF;IACF;AAGN,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorFocus } from './EditorFocusProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>> = (\n props,\n) => {\n const { editorConfig, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const editorFocus = useEditorFocus()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n editorFocus.focusEditor(editor, editorConfigContext)\n return true\n },\n\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n editorFocus.blurEditor()\n return true\n },\n\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, editorConfig, editorConfigContext, editorFocus])\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\">\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n //@ts-expect-error ts being dumb\n ErrorBoundary={ErrorBoundaryComponent}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n placeholder={\n <p className=\"editor-placeholder\">\n Start typing, or press '/' for commands...\n </p>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) onChange(editorState, editor, tags)\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","mergeRegister","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorFocus","EditorPlugin","useEditorConfigContext","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","onChange","editorConfigContext","editor","editorFocus","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","registerCommand","focusEditor","blurEditor","isSmallWidthViewport","setIsSmallWidthViewport","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","ErrorBoundaryComponent","default","Fragment","features","plugins","map","plugin","position","clientProps","key","div","className","ErrorBoundary","contentEditable","ref","placeholder","p","ignoreSelectionChange","editorState","tags","has","size","isEditable","anchorElem","desktopOnly","markdownTransformers","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,OAAOC,0BAA0B,y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AAO,KAACrC;wBAAasC,aAAaF,OAAOE,WAAW;wBAAmBF,QAAQA;uBAApBA,OAAOG,GAAG;gBACvE;YACF;;;AAGN,EAAC"}
|
|
@@ -22,10 +22,19 @@
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
&--show-gutter {
|
|
26
|
+
> .rich-text-lexical__wrap > .editor-container > .editor-placeholder {
|
|
27
|
+
left: 3rem;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:not(&--show-gutter) > .rich-text-lexical__wrap > .editor-container > .editor-placeholder {
|
|
32
|
+
left: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
.editor-placeholder {
|
|
26
36
|
position: absolute;
|
|
27
37
|
top: 8px;
|
|
28
|
-
left: 0;
|
|
29
38
|
font-size: 15px;
|
|
30
39
|
color: var(--theme-elevation-500);
|
|
31
40
|
/* Prevent text selection */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { LexicalComposer } from '@lexical/react/LexicalComposer.js';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import { EditorFocusProvider } from './EditorFocusProvider.js';
|
|
@@ -48,18 +49,23 @@ export const LexicalProvider = (props)=>{
|
|
|
48
49
|
throw new Error('You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.');
|
|
49
50
|
}
|
|
50
51
|
if (!initialConfig) {
|
|
51
|
-
return /*#__PURE__*/
|
|
52
|
+
return /*#__PURE__*/ _jsx("p", {
|
|
53
|
+
children: "Loading..."
|
|
54
|
+
});
|
|
52
55
|
}
|
|
53
|
-
return /*#__PURE__*/
|
|
56
|
+
return /*#__PURE__*/ _jsx(LexicalComposer, {
|
|
54
57
|
initialConfig: initialConfig,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
children: /*#__PURE__*/ _jsx(EditorFocusProvider, {
|
|
59
|
+
children: /*#__PURE__*/ _jsx(EditorConfigProvider, {
|
|
60
|
+
editorConfig: editorConfig,
|
|
61
|
+
fieldProps: fieldProps,
|
|
62
|
+
children: /*#__PURE__*/ _jsx(LexicalEditorComponent, {
|
|
63
|
+
editorConfig: editorConfig,
|
|
64
|
+
onChange: onChange
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}, path);
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
//# sourceMappingURL=LexicalProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { EditorFocusProvider } from './EditorFocusProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorFocusProvider>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </EditorConfigProvider>\n </EditorFocusProvider>\n </LexicalComposer>\n )\n}\n"],"names":["LexicalComposer","React","EditorFocusProvider","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isArray","p"
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { EditorFocusProvider } from './EditorFocusProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorFocusProvider>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </EditorConfigProvider>\n </EditorFocusProvider>\n </LexicalComposer>\n )\n}\n"],"names":["LexicalComposer","React","EditorFocusProvider","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isArray","p"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAMA,SAASA,eAAe,QAAQ,oCAAmC;AACnE,YAAYC,WAAW,QAAO;AAI9B,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,iBAAiBC,sBAAsB,QAAQ,qBAAoB;AAC5E,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,mBAAkB;AAclD,OAAO,MAAMC,kB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KAACN;oBAAuBK,cAAcA;oBAAcE,UAAUA;;;;OAHhBC;AAQxD,EAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
4
5
|
// Should always produce a 20 character pseudo-random string
|
|
@@ -26,9 +27,10 @@ export const EditorConfigProvider = ({ children, editorConfig, fieldProps })=>{
|
|
|
26
27
|
fieldProps,
|
|
27
28
|
uuid
|
|
28
29
|
]);
|
|
29
|
-
return /*#__PURE__*/
|
|
30
|
-
value: editorContext
|
|
31
|
-
|
|
30
|
+
return /*#__PURE__*/ _jsx(Context.Provider, {
|
|
31
|
+
value: editorContext,
|
|
32
|
+
children: children
|
|
33
|
+
});
|
|
32
34
|
};
|
|
33
35
|
export const useEditorConfigContext = ()=>{
|
|
34
36
|
const context = useContext(Context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\nimport { createContext, useContext, useEffect, useMemo, useState } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\nexport interface EditorConfigContextType {\n editorConfig: SanitizedClientEditorConfig\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n uuid: string\n}\n\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: generateQuickGuid(),\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n fieldProps,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n}): React.ReactNode => {\n // State to store the UUID\n const [uuid, setUuid] = useState(generateQuickGuid())\n\n // When the component mounts, generate a new UUID only once\n useEffect(() => {\n setUuid(generateQuickGuid())\n }, [])\n\n const editorContext = useMemo(\n () => ({ editorConfig, field: fieldProps, uuid }),\n [editorConfig, fieldProps, uuid],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"names":["React","createContext","useContext","useEffect","useMemo","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","fieldProps","setUuid","editorContext","Provider","value","useEditorConfigContext","context","undefined","Error"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\nimport { createContext, useContext, useEffect, useMemo, useState } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\nexport interface EditorConfigContextType {\n editorConfig: SanitizedClientEditorConfig\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n uuid: string\n}\n\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: generateQuickGuid(),\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n fieldProps,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n}): React.ReactNode => {\n // State to store the UUID\n const [uuid, setUuid] = useState(generateQuickGuid())\n\n // When the component mounts, generate a new UUID only once\n useEffect(() => {\n setUuid(generateQuickGuid())\n }, [])\n\n const editorContext = useMemo(\n () => ({ editorConfig, field: fieldProps, uuid }),\n [editorConfig, fieldProps, uuid],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"names":["React","createContext","useContext","useEffect","useMemo","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","fieldProps","setUuid","editorContext","Provider","value","useEditorConfigContext","context","undefined","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAIA,YAAYA,WAAW,QAAO;AAC9B,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI/E,4DAA4D;AAC5D,SAASC;IACP,OAAOC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG;AAC/F;AAWA,MAAMC,wBAAkDV,cAAc;IACpEW,cAAc;IACdC,OAAO;IACPC,MAAMR;AACR;AAEA,OAAO,MAAMS,uBAAuB,CAAC,EACnCC,QAAQ,EACRJ,YAAY,EACZK,UAAU,EASX;IACC,0BAA0B;IAC1B,MAAM,CAACH,MAAMI,QAAQ,GAAGb,SAASC;IAEjC,2DAA2D;IAC3DH,UAAU;QACRe,QAAQZ;IACV,GAAG,EAAE;IAEL,MAAMa,gBAAgBf,QACpB,IAAO,CAAA;YAAEQ;YAAcC,OAAOI;YAAYH;QAAK,CAAA,GAC/C;QAACF;QAAcK;QAAYH;KAAK;IAGlC,qBAAO,KAACH,QAAQS,QAAQ;QAACC,OAAOF;kBAAgBH;;AAClD,EAAC;AAED,OAAO,MAAMM,yBAAyB;IACpC,MAAMC,UAAUrB,WAAWS;IAC3B,IAAIY,YAAYC,WAAW;QACzB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT,EAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EditorConfig as LexicalEditorConfig } from 'lexical';
|
|
2
|
+
import type { LexicalFieldAdminProps } from '../../../../types.js';
|
|
2
3
|
import type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js';
|
|
3
4
|
import type { SanitizedClientEditorConfig } from '../types.js';
|
|
4
5
|
export declare const sanitizeClientFeatures: (features: ResolvedClientFeatureMap) => SanitizedClientFeatures;
|
|
5
|
-
export declare function sanitizeClientEditorConfig(lexical: LexicalEditorConfig, resolvedClientFeatureMap: ResolvedClientFeatureMap): SanitizedClientEditorConfig;
|
|
6
|
+
export declare function sanitizeClientEditorConfig(lexical: LexicalEditorConfig, resolvedClientFeatureMap: ResolvedClientFeatureMap, admin?: LexicalFieldAdminProps): SanitizedClientEditorConfig;
|
|
6
7
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,0CAEhC,uBAiMF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,0CAEhC,uBAiMF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,EAClD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,2BAA2B,CAO7B"}
|
|
@@ -164,8 +164,9 @@ export const sanitizeClientFeatures = (features)=>{
|
|
|
164
164
|
}
|
|
165
165
|
return sanitized;
|
|
166
166
|
};
|
|
167
|
-
export function sanitizeClientEditorConfig(lexical, resolvedClientFeatureMap) {
|
|
167
|
+
export function sanitizeClientEditorConfig(lexical, resolvedClientFeatureMap, admin) {
|
|
168
168
|
return {
|
|
169
|
+
admin,
|
|
169
170
|
features: sanitizeClientFeatures(resolvedClientFeatureMap),
|
|
170
171
|
lexical,
|
|
171
172
|
resolvedFeatureMap: resolvedClientFeatureMap
|