@payloadcms/richtext-lexical 3.0.0-beta.3 → 3.0.0-beta.31
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 +1 -1
- package/dist/cell/index.d.ts.map +1 -1
- package/dist/cell/index.js +2 -4
- package/dist/cell/index.js.map +1 -1
- package/dist/exports/components.d.ts +8 -2
- package/dist/exports/components.d.ts.map +1 -1
- package/dist/exports/components.js +8 -2
- package/dist/exports/components.js.map +1 -1
- package/dist/field/Field.d.ts +0 -2
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/features/align/feature.client.d.ts +4 -1
- package/dist/field/features/align/feature.client.d.ts.map +1 -1
- package/dist/field/features/align/feature.client.js +127 -54
- package/dist/field/features/align/feature.client.js.map +1 -1
- package/dist/field/features/align/toolbarAlignGroup.d.ts +3 -0
- package/dist/field/features/align/toolbarAlignGroup.d.ts.map +1 -0
- package/dist/field/features/align/toolbarAlignGroup.js +12 -0
- package/dist/field/features/align/toolbarAlignGroup.js.map +1 -0
- package/dist/field/features/blockquote/feature.client.d.ts +4 -1
- package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
- package/dist/field/features/blockquote/feature.client.js +53 -40
- package/dist/field/features/blockquote/feature.client.js.map +1 -1
- package/dist/field/features/blockquote/feature.server.d.ts +1 -1
- package/dist/field/features/blockquote/feature.server.d.ts.map +1 -1
- package/dist/field/features/blockquote/feature.server.js +7 -7
- package/dist/field/features/blockquote/feature.server.js.map +1 -1
- package/dist/field/features/blockquote/markdownTransformer.d.ts.map +1 -1
- package/dist/field/features/blockquote/markdownTransformer.js +2 -4
- package/dist/field/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.js +3 -5
- package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
- package/dist/field/features/blocks/component/index.d.ts.map +1 -1
- package/dist/field/features/blocks/component/index.js +37 -4
- package/dist/field/features/blocks/component/index.js.map +1 -1
- package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
- package/dist/field/features/blocks/drawer/index.js +2 -4
- package/dist/field/features/blocks/drawer/index.js.map +1 -1
- package/dist/field/features/blocks/feature.client.d.ts +4 -1
- package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.client.js +56 -27
- package/dist/field/features/blocks/feature.client.js.map +1 -1
- package/dist/field/features/blocks/feature.server.d.ts +2 -5
- package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.server.js +109 -77
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -3
- package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.js +1 -2
- package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
- package/dist/field/features/blocks/plugin/commands.d.ts.map +1 -1
- package/dist/field/features/blocks/plugin/commands.js +1 -2
- package/dist/field/features/blocks/plugin/commands.js.map +1 -1
- package/dist/field/features/blocks/plugin/index.d.ts +3 -2
- package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
- package/dist/field/features/blocks/plugin/index.js +5 -8
- package/dist/field/features/blocks/plugin/index.js.map +1 -1
- package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
- package/dist/field/features/blocks/populationPromise.js +4 -18
- package/dist/field/features/blocks/populationPromise.js.map +1 -1
- package/dist/field/features/blocks/validate.d.ts.map +1 -1
- package/dist/field/features/blocks/validate.js +22 -36
- package/dist/field/features/blocks/validate.js.map +1 -1
- package/dist/field/features/converters/html/field/index.d.ts +8 -2
- package/dist/field/features/converters/html/field/index.d.ts.map +1 -1
- package/dist/field/features/converters/html/field/index.js +6 -3
- package/dist/field/features/converters/html/field/index.js.map +1 -1
- package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts +4 -1
- package/dist/field/features/debug/testRecorder/feature.client.d.ts.map +1 -0
- package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js.map +1 -1
- package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts.map +1 -1
- package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js +1 -1
- package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js.map +1 -1
- package/dist/field/features/debug/testRecorder/plugin/index.d.ts +5 -0
- package/dist/field/features/debug/testRecorder/plugin/index.d.ts.map +1 -0
- package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js +2 -4
- package/dist/field/features/debug/testRecorder/plugin/index.js.map +1 -0
- package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts +4 -1
- package/dist/field/features/debug/treeView/feature.client.d.ts.map +1 -0
- package/dist/field/features/debug/{treeview → treeView}/feature.client.js.map +1 -1
- package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts.map +1 -1
- package/dist/field/features/debug/{treeview → treeView}/feature.server.js +1 -1
- package/dist/field/features/debug/{treeview → treeView}/feature.server.js.map +1 -1
- package/dist/field/features/debug/treeView/plugin/index.d.ts +4 -0
- package/dist/field/features/debug/treeView/plugin/index.d.ts.map +1 -0
- package/dist/field/features/debug/{treeview → treeView}/plugin/index.js +4 -6
- package/dist/field/features/debug/treeView/plugin/index.js.map +1 -0
- package/dist/field/features/format/bold/feature.client.d.ts +4 -1
- package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/bold/feature.client.js +26 -23
- package/dist/field/features/format/bold/feature.client.js.map +1 -1
- package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.d.ts +4 -1
- package/dist/field/features/format/inlineCode/feature.client.d.ts.map +1 -0
- package/dist/field/features/format/inlineCode/feature.client.js +46 -0
- package/dist/field/features/format/inlineCode/feature.client.js.map +1 -0
- package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts.map +1 -1
- package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js +1 -1
- package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js.map +1 -1
- package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts.map +1 -1
- package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js.map +1 -1
- package/dist/field/features/format/italic/feature.client.d.ts +4 -1
- package/dist/field/features/format/italic/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/italic/feature.client.js +27 -24
- package/dist/field/features/format/italic/feature.client.js.map +1 -1
- package/dist/field/features/format/shared/toolbarFormatGroup.d.ts +3 -0
- package/dist/field/features/format/shared/toolbarFormatGroup.d.ts.map +1 -0
- package/dist/field/features/format/shared/toolbarFormatGroup.js +10 -0
- package/dist/field/features/format/shared/toolbarFormatGroup.js.map +1 -0
- package/dist/field/features/format/strikethrough/feature.client.d.ts +4 -1
- package/dist/field/features/format/strikethrough/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/strikethrough/feature.client.js +27 -24
- package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
- package/dist/field/features/format/subscript/feature.client.d.ts +4 -1
- package/dist/field/features/format/subscript/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/subscript/feature.client.js +25 -22
- package/dist/field/features/format/subscript/feature.client.js.map +1 -1
- package/dist/field/features/format/superscript/feature.client.d.ts +4 -1
- package/dist/field/features/format/superscript/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/superscript/feature.client.js +25 -22
- package/dist/field/features/format/superscript/feature.client.js.map +1 -1
- package/dist/field/features/format/underline/feature.client.d.ts +4 -1
- package/dist/field/features/format/underline/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/underline/feature.client.js +25 -22
- package/dist/field/features/format/underline/feature.client.js.map +1 -1
- package/dist/field/features/heading/feature.client.d.ts +4 -1
- package/dist/field/features/heading/feature.client.d.ts.map +1 -1
- package/dist/field/features/heading/feature.client.js +71 -54
- package/dist/field/features/heading/feature.client.js.map +1 -1
- package/dist/field/features/heading/feature.server.d.ts.map +1 -1
- package/dist/field/features/heading/feature.server.js +5 -5
- package/dist/field/features/heading/feature.server.js.map +1 -1
- package/dist/field/features/heading/markdownTransformer.d.ts.map +1 -1
- package/dist/field/features/heading/markdownTransformer.js +1 -2
- package/dist/field/features/heading/markdownTransformer.js.map +1 -1
- package/dist/field/features/horizontalRule/component/index.d.ts +10 -0
- package/dist/field/features/horizontalRule/component/index.d.ts.map +1 -0
- package/dist/field/features/horizontalRule/component/index.js +62 -0
- package/dist/field/features/horizontalRule/component/index.js.map +1 -0
- package/dist/field/features/horizontalRule/feature.client.d.ts +6 -0
- package/dist/field/features/horizontalRule/feature.client.d.ts.map +1 -0
- package/dist/field/features/horizontalRule/feature.client.js +76 -0
- package/dist/field/features/horizontalRule/feature.client.js.map +1 -0
- package/dist/field/features/horizontalRule/feature.server.d.ts +3 -0
- package/dist/field/features/horizontalRule/feature.server.d.ts.map +1 -0
- package/dist/field/features/horizontalRule/feature.server.js +36 -0
- package/dist/field/features/horizontalRule/feature.server.js.map +1 -0
- package/dist/field/features/horizontalRule/markdownTransformer.d.ts +3 -0
- package/dist/field/features/horizontalRule/markdownTransformer.d.ts.map +1 -0
- package/dist/field/features/horizontalRule/markdownTransformer.js +23 -0
- package/dist/field/features/horizontalRule/markdownTransformer.js.map +1 -0
- package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.d.ts +53 -0
- package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.d.ts.map +1 -0
- package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.js +88 -0
- package/dist/field/features/horizontalRule/nodes/HorizontalRuleNode.js.map +1 -0
- package/dist/field/features/horizontalRule/plugin/index.d.ts +7 -0
- package/dist/field/features/horizontalRule/plugin/index.d.ts.map +1 -0
- package/dist/field/features/horizontalRule/plugin/index.js +31 -0
- package/dist/field/features/horizontalRule/plugin/index.js.map +1 -0
- package/dist/field/features/horizontalRule/plugin/index.scss +20 -0
- package/dist/field/features/indent/feature.client.d.ts +4 -1
- package/dist/field/features/indent/feature.client.d.ts.map +1 -1
- package/dist/field/features/indent/feature.client.js +43 -42
- package/dist/field/features/indent/feature.client.js.map +1 -1
- package/dist/field/features/indent/toolbarIndentGroup.d.ts +3 -0
- package/dist/field/features/indent/toolbarIndentGroup.d.ts.map +1 -0
- package/dist/field/features/indent/toolbarIndentGroup.js +10 -0
- package/dist/field/features/indent/toolbarIndentGroup.js.map +1 -0
- package/dist/field/features/link/drawer/baseFields.d.ts +2 -2
- package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
- package/dist/field/features/link/drawer/baseFields.js +30 -43
- package/dist/field/features/link/drawer/baseFields.js.map +1 -1
- package/dist/field/features/link/drawer/index.js +3 -2
- package/dist/field/features/link/drawer/index.js.map +1 -1
- package/dist/field/features/link/drawer/types.d.ts +4 -2
- package/dist/field/features/link/drawer/types.d.ts.map +1 -1
- package/dist/field/features/link/drawer/types.js.map +1 -1
- package/dist/field/features/link/feature.client.d.ts +13 -1
- package/dist/field/features/link/feature.client.d.ts.map +1 -1
- package/dist/field/features/link/feature.client.js +59 -47
- package/dist/field/features/link/feature.client.js.map +1 -1
- package/dist/field/features/link/feature.server.d.ts +10 -5
- package/dist/field/features/link/feature.server.d.ts.map +1 -1
- package/dist/field/features/link/feature.server.js +48 -9
- package/dist/field/features/link/feature.server.js.map +1 -1
- package/dist/field/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
- package/dist/field/features/link/nodes/AutoLinkNode.js +1 -2
- package/dist/field/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/field/features/link/nodes/LinkNode.d.ts +1 -3
- package/dist/field/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/field/features/link/nodes/LinkNode.js +2 -4
- package/dist/field/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/field/features/link/plugins/autoLink/index.d.ts +3 -2
- package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/autoLink/index.js +5 -8
- package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/clickableLink/index.d.ts +3 -2
- package/dist/field/features/link/plugins/clickableLink/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/clickableLink/index.js +2 -2
- package/dist/field/features/link/plugins/clickableLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js +1 -2
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.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 +93 -69
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.d.ts +3 -4
- package/dist/field/features/link/plugins/floatingLinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +11 -3
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +1 -3
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +12 -30
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
- package/dist/field/features/link/plugins/link/index.d.ts +3 -1
- package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/link/index.js +5 -14
- package/dist/field/features/link/plugins/link/index.js.map +1 -1
- package/dist/field/features/link/populationPromise.d.ts.map +1 -1
- package/dist/field/features/link/populationPromise.js +10 -25
- package/dist/field/features/link/populationPromise.js.map +1 -1
- package/dist/field/features/link/validate.d.ts +5 -0
- package/dist/field/features/link/validate.d.ts.map +1 -0
- package/dist/field/features/link/validate.js +32 -0
- package/dist/field/features/link/validate.js.map +1 -0
- package/dist/field/features/lists/checklist/feature.client.d.ts +4 -1
- package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/feature.client.js +56 -32
- package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.d.ts +1 -1
- package/dist/field/features/lists/checklist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.js +10 -10
- package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
- package/dist/field/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/markdownTransformers.js +2 -3
- package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
- package/dist/field/features/lists/checklist/plugin/index.d.ts +2 -2
- package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/plugin/index.js +3 -4
- package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
- package/dist/field/features/lists/htmlConverter.d.ts.map +1 -1
- package/dist/field/features/lists/htmlConverter.js +13 -6
- package/dist/field/features/lists/htmlConverter.js.map +1 -1
- package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.d.ts +4 -1
- package/dist/field/features/lists/orderedList/feature.client.d.ts.map +1 -0
- package/dist/field/features/lists/orderedList/feature.client.js +96 -0
- package/dist/field/features/lists/orderedList/feature.client.js.map +1 -0
- package/dist/field/features/lists/orderedList/feature.server.d.ts.map +1 -0
- package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js +7 -7
- package/dist/field/features/lists/orderedList/feature.server.js.map +1 -0
- package/dist/field/features/lists/orderedList/markdownTransformer.d.ts.map +1 -0
- package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js +2 -3
- package/dist/field/features/lists/orderedList/markdownTransformer.js.map +1 -0
- package/dist/field/features/lists/plugin/index.d.ts +2 -2
- package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
- package/dist/field/features/lists/plugin/index.js +3 -4
- package/dist/field/features/lists/plugin/index.js.map +1 -1
- package/dist/field/features/lists/{common → shared}/markdown.d.ts.map +1 -1
- package/dist/field/features/lists/{common → shared}/markdown.js +1 -2
- package/dist/field/features/lists/shared/markdown.js.map +1 -0
- package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.client.d.ts +4 -1
- package/dist/field/features/lists/unorderedList/feature.client.d.ts.map +1 -0
- package/dist/field/features/lists/unorderedList/feature.client.js +96 -0
- package/dist/field/features/lists/unorderedList/feature.client.js.map +1 -0
- package/dist/field/features/lists/unorderedList/feature.server.d.ts.map +1 -0
- package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js +7 -7
- package/dist/field/features/lists/unorderedList/feature.server.js.map +1 -0
- package/dist/field/features/lists/unorderedList/markdownTransformer.d.ts.map +1 -0
- package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js +2 -3
- package/dist/field/features/lists/unorderedList/markdownTransformer.js.map +1 -0
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js +2 -4
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/feature.client.d.ts +4 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/feature.client.d.ts.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
- 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 -4
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.d.ts +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js +2 -2
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js +2 -4
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js +2 -4
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.js +2 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/feature.client.d.ts +4 -1
- package/dist/field/features/migrations/slateToLexical/feature.client.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
- 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 -4
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/paragraph/feature.client.d.ts +4 -1
- package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
- package/dist/field/features/paragraph/feature.client.js +45 -33
- package/dist/field/features/paragraph/feature.client.js.map +1 -1
- package/dist/field/features/relationship/drawer/commands.d.ts.map +1 -1
- package/dist/field/features/relationship/drawer/commands.js +1 -2
- package/dist/field/features/relationship/drawer/commands.js.map +1 -1
- package/dist/field/features/relationship/drawer/index.d.ts.map +1 -1
- package/dist/field/features/relationship/drawer/index.js +7 -13
- package/dist/field/features/relationship/drawer/index.js.map +1 -1
- package/dist/field/features/relationship/feature.client.d.ts +17 -2
- package/dist/field/features/relationship/feature.client.d.ts.map +1 -1
- package/dist/field/features/relationship/feature.client.js +37 -15
- package/dist/field/features/relationship/feature.client.js.map +1 -1
- package/dist/field/features/relationship/feature.server.d.ts +10 -1
- package/dist/field/features/relationship/feature.server.d.ts.map +1 -1
- package/dist/field/features/relationship/feature.server.js +5 -4
- package/dist/field/features/relationship/feature.server.js.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +3 -8
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.js +8 -8
- package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +56 -7
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/relationship/plugins/index.d.ts +2 -2
- package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
- package/dist/field/features/relationship/plugins/index.js +9 -12
- package/dist/field/features/relationship/plugins/index.js.map +1 -1
- package/dist/field/features/relationship/populationPromise.d.ts +2 -1
- package/dist/field/features/relationship/populationPromise.d.ts.map +1 -1
- package/dist/field/features/relationship/populationPromise.js +25 -19
- package/dist/field/features/relationship/populationPromise.js.map +1 -1
- package/dist/field/features/shared/toolbar/addDropdownGroup.d.ts +3 -0
- package/dist/field/features/shared/toolbar/addDropdownGroup.d.ts.map +1 -0
- package/dist/field/features/shared/toolbar/addDropdownGroup.js +12 -0
- package/dist/field/features/shared/toolbar/addDropdownGroup.js.map +1 -0
- package/dist/field/features/shared/toolbar/featureButtonsGroup.d.ts +3 -0
- package/dist/field/features/shared/toolbar/featureButtonsGroup.d.ts.map +1 -0
- package/dist/field/features/shared/toolbar/featureButtonsGroup.js +10 -0
- package/dist/field/features/shared/toolbar/featureButtonsGroup.js.map +1 -0
- package/dist/field/features/shared/toolbar/textDropdownGroup.d.ts +3 -0
- package/dist/field/features/shared/toolbar/textDropdownGroup.d.ts.map +1 -0
- package/dist/field/features/shared/toolbar/textDropdownGroup.js +12 -0
- package/dist/field/features/shared/toolbar/textDropdownGroup.js.map +1 -0
- package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts +4 -0
- package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts.map +1 -0
- package/dist/field/features/toolbars/fixed/Toolbar/index.js +152 -0
- package/dist/field/features/toolbars/fixed/Toolbar/index.js.map +1 -0
- package/dist/field/features/toolbars/fixed/Toolbar/index.scss +91 -0
- package/dist/field/features/toolbars/fixed/feature.client.d.ts +6 -0
- package/dist/field/features/toolbars/fixed/feature.client.d.ts.map +1 -0
- package/dist/field/features/toolbars/fixed/feature.client.js +20 -0
- package/dist/field/features/toolbars/fixed/feature.client.js.map +1 -0
- package/dist/field/features/toolbars/fixed/feature.server.d.ts +3 -0
- package/dist/field/features/toolbars/fixed/feature.server.d.ts.map +1 -0
- package/dist/field/features/toolbars/fixed/feature.server.js +15 -0
- package/dist/field/features/toolbars/fixed/feature.server.js.map +1 -0
- package/dist/field/features/toolbars/inline/Toolbar/index.d.ts +4 -0
- package/dist/field/features/toolbars/inline/Toolbar/index.d.ts.map +1 -0
- package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/inline/Toolbar}/index.js +112 -70
- package/dist/field/features/toolbars/inline/Toolbar/index.js.map +1 -0
- package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/inline/Toolbar}/index.scss +7 -11
- package/dist/field/features/toolbars/inline/feature.client.d.ts +6 -0
- package/dist/field/features/toolbars/inline/feature.client.d.ts.map +1 -0
- package/dist/field/features/toolbars/inline/feature.client.js +20 -0
- package/dist/field/features/toolbars/inline/feature.client.js.map +1 -0
- package/dist/field/features/toolbars/inline/feature.server.d.ts +3 -0
- package/dist/field/features/toolbars/inline/feature.server.d.ts.map +1 -0
- package/dist/field/features/toolbars/inline/feature.server.js +15 -0
- package/dist/field/features/toolbars/inline/feature.server.js.map +1 -0
- package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts +10 -0
- package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -0
- package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarButton/index.js +29 -19
- package/dist/field/features/toolbars/shared/ToolbarButton/index.js.map +1 -0
- package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarButton/index.scss +3 -1
- package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +23 -0
- package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -0
- package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarDropdown/DropDown.js +27 -72
- package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -0
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts +23 -0
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -0
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js +139 -0
- package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -0
- package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarDropdown/index.scss +25 -13
- package/dist/field/features/toolbars/types.d.ts +48 -0
- package/dist/field/features/toolbars/types.d.ts.map +1 -0
- package/dist/field/features/toolbars/types.js.map +1 -0
- package/dist/field/features/typeUtilities.d.ts +8 -0
- package/dist/field/features/typeUtilities.d.ts.map +1 -0
- package/dist/field/features/typeUtilities.js +8 -0
- package/dist/field/features/typeUtilities.js.map +1 -0
- package/dist/field/features/types.d.ts +136 -62
- package/dist/field/features/types.d.ts.map +1 -1
- package/dist/field/features/types.js.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +5 -6
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
- package/dist/field/features/upload/component/index.d.ts.map +1 -1
- package/dist/field/features/upload/component/index.js +59 -9
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/drawer/commands.d.ts.map +1 -1
- package/dist/field/features/upload/drawer/commands.js +1 -2
- package/dist/field/features/upload/drawer/commands.js.map +1 -1
- package/dist/field/features/upload/drawer/index.d.ts.map +1 -1
- package/dist/field/features/upload/drawer/index.js +8 -12
- package/dist/field/features/upload/drawer/index.js.map +1 -1
- package/dist/field/features/upload/feature.client.d.ts +4 -1
- package/dist/field/features/upload/feature.client.d.ts.map +1 -1
- package/dist/field/features/upload/feature.client.js +35 -10
- package/dist/field/features/upload/feature.client.js.map +1 -1
- package/dist/field/features/upload/feature.server.d.ts +10 -3
- package/dist/field/features/upload/feature.server.d.ts.map +1 -1
- package/dist/field/features/upload/feature.server.js +39 -11
- package/dist/field/features/upload/feature.server.js.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.d.ts +2 -14
- package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.js +24 -11
- package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
- package/dist/field/features/upload/plugin/index.d.ts +5 -4
- package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
- package/dist/field/features/upload/plugin/index.js +6 -11
- package/dist/field/features/upload/plugin/index.js.map +1 -1
- package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
- package/dist/field/features/upload/populationPromise.js +15 -9
- package/dist/field/features/upload/populationPromise.js.map +1 -1
- package/dist/field/features/upload/validate.d.ts +2 -1
- package/dist/field/features/upload/validate.d.ts.map +1 -1
- package/dist/field/features/upload/validate.js +37 -12
- package/dist/field/features/upload/validate.js.map +1 -1
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.scss +4 -0
- package/dist/field/lexical/EditorFocusProvider.d.ts +20 -0
- package/dist/field/lexical/EditorFocusProvider.d.ts.map +1 -0
- package/dist/field/lexical/EditorFocusProvider.js +78 -0
- package/dist/field/lexical/EditorFocusProvider.js.map +1 -0
- package/dist/field/lexical/EditorPlugin.d.ts +1 -0
- package/dist/field/lexical/EditorPlugin.d.ts.map +1 -1
- package/dist/field/lexical/EditorPlugin.js +6 -3
- package/dist/field/lexical/EditorPlugin.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/field/lexical/LexicalEditor.js +31 -15
- package/dist/field/lexical/LexicalEditor.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.scss +3 -19
- package/dist/field/lexical/LexicalProvider.d.ts +1 -1
- package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/field/lexical/LexicalProvider.js +4 -4
- package/dist/field/lexical/LexicalProvider.js.map +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.d.ts +2 -3
- package/dist/field/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/field/lexical/config/client/default.d.ts +1 -1
- package/dist/field/lexical/config/client/default.d.ts.map +1 -1
- package/dist/field/lexical/config/client/default.js.map +1 -1
- package/dist/field/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/client/sanitize.js +81 -32
- package/dist/field/lexical/config/client/sanitize.js.map +1 -1
- package/dist/field/lexical/config/server/default.d.ts +2 -3
- package/dist/field/lexical/config/server/default.d.ts.map +1 -1
- package/dist/field/lexical/config/server/default.js +12 -10
- package/dist/field/lexical/config/server/default.js.map +1 -1
- package/dist/field/lexical/config/server/loader.d.ts +5 -2
- package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
- package/dist/field/lexical/config/server/loader.js +4 -2
- package/dist/field/lexical/config/server/loader.js.map +1 -1
- package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
- package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/server/sanitize.js +23 -8
- package/dist/field/lexical/config/server/sanitize.js.map +1 -1
- package/dist/field/lexical/config/types.d.ts +1 -1
- 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.d.ts.map +1 -1
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js +1 -2
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +9 -9
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +74 -77
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +4 -4
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +6 -9
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +19 -27
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js +1 -37
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.d.ts +2 -2
- package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.js +72 -67
- package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +13 -10
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +3 -4
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +16 -10
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.scss +8 -0
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +25 -6
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts +9 -0
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -0
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +35 -0
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -0
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js +1 -2
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js +17 -7
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/field/lexical/theme/EditorTheme.scss +13 -14
- package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/field/lexical/ui/ContentEditable.js +1 -2
- package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/field/lexical/ui/icons/Add/index.d.ts +3 -0
- package/dist/field/lexical/ui/icons/Add/index.d.ts.map +1 -0
- package/dist/field/lexical/ui/icons/Add/index.js +16 -0
- package/dist/field/lexical/ui/icons/Add/index.js.map +1 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.d.ts +3 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.d.ts.map +1 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.js +19 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.js.map +1 -0
- package/dist/field/lexical/utils/getSelectedNode.d.ts.map +1 -1
- package/dist/field/lexical/utils/getSelectedNode.js +1 -2
- package/dist/field/lexical/utils/getSelectedNode.js.map +1 -1
- package/dist/field/lexical/utils/nodeFormat.d.ts +2 -1
- package/dist/field/lexical/utils/nodeFormat.d.ts.map +1 -1
- package/dist/field/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +11 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.js +16 -13
- package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/field/lexical/utils/url.d.ts.map +1 -1
- package/dist/field/lexical/utils/url.js +3 -0
- package/dist/field/lexical/utils/url.js.map +1 -1
- package/dist/forEachNodeRecursively.d.ts +10 -0
- package/dist/forEachNodeRecursively.d.ts.map +1 -0
- package/dist/forEachNodeRecursively.js +24 -0
- package/dist/forEachNodeRecursively.js.map +1 -0
- package/dist/generateComponentMap.d.ts.map +1 -1
- package/dist/generateComponentMap.js +16 -22
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +4 -12
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.d.ts +24 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +275 -184
- package/dist/index.js.map +1 -1
- package/dist/populate/defaultValue.d.ts.map +1 -1
- package/dist/populate/defaultValue.js +1 -0
- package/dist/populate/defaultValue.js.map +1 -1
- package/dist/populate/populate.d.ts +5 -4
- package/dist/populate/populate.d.ts.map +1 -1
- package/dist/populate/populate.js +13 -11
- package/dist/populate/populate.js.map +1 -1
- package/dist/populate/populateLexicalPopulationPromises.d.ts +12 -0
- package/dist/populate/populateLexicalPopulationPromises.d.ts.map +1 -0
- package/dist/populate/populateLexicalPopulationPromises.js +36 -0
- package/dist/populate/populateLexicalPopulationPromises.js.map +1 -0
- package/dist/populate/recurseNestedFields.d.ts +8 -4
- package/dist/populate/recurseNestedFields.d.ts.map +1 -1
- package/dist/populate/recurseNestedFields.js +4 -5
- package/dist/populate/recurseNestedFields.js.map +1 -1
- package/dist/scss/app.scss +2 -3
- package/dist/scss/vars.scss +0 -7
- package/dist/types.d.ts +12 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/package.json +48 -47
- package/components.d.ts +0 -6
- package/components.js +0 -7
- package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts +0 -3
- package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts.map +0 -1
- package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js +0 -12
- package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js.map +0 -1
- package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts +0 -3
- package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts.map +0 -1
- package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js +0 -10
- package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js.map +0 -1
- package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts +0 -3
- package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts.map +0 -1
- package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js +0 -12
- package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js.map +0 -1
- package/dist/field/features/debug/testrecorder/feature.client.d.ts.map +0 -1
- package/dist/field/features/debug/testrecorder/plugin/index.d.ts +0 -5
- package/dist/field/features/debug/testrecorder/plugin/index.d.ts.map +0 -1
- package/dist/field/features/debug/testrecorder/plugin/index.js.map +0 -1
- package/dist/field/features/debug/treeview/feature.client.d.ts.map +0 -1
- package/dist/field/features/debug/treeview/plugin/index.d.ts +0 -4
- package/dist/field/features/debug/treeview/plugin/index.d.ts.map +0 -1
- package/dist/field/features/debug/treeview/plugin/index.js.map +0 -1
- package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts +0 -3
- package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts.map +0 -1
- package/dist/field/features/format/common/floatingSelectToolbarSection.js +0 -10
- package/dist/field/features/format/common/floatingSelectToolbarSection.js.map +0 -1
- package/dist/field/features/format/inlinecode/feature.client.d.ts.map +0 -1
- package/dist/field/features/format/inlinecode/feature.client.js +0 -43
- package/dist/field/features/format/inlinecode/feature.client.js.map +0 -1
- package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts +0 -3
- package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts.map +0 -1
- package/dist/field/features/indent/floatingSelectToolbarIndentSection.js +0 -10
- package/dist/field/features/indent/floatingSelectToolbarIndentSection.js.map +0 -1
- package/dist/field/features/indent/index.scss +0 -4
- package/dist/field/features/lists/common/markdown.js.map +0 -1
- package/dist/field/features/lists/orderedlist/feature.client.d.ts.map +0 -1
- package/dist/field/features/lists/orderedlist/feature.client.js +0 -72
- package/dist/field/features/lists/orderedlist/feature.client.js.map +0 -1
- package/dist/field/features/lists/orderedlist/feature.server.d.ts.map +0 -1
- package/dist/field/features/lists/orderedlist/feature.server.js.map +0 -1
- package/dist/field/features/lists/orderedlist/markdownTransformer.d.ts.map +0 -1
- package/dist/field/features/lists/orderedlist/markdownTransformer.js.map +0 -1
- package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +0 -1
- package/dist/field/features/lists/unorderedlist/feature.client.js +0 -72
- package/dist/field/features/lists/unorderedlist/feature.client.js.map +0 -1
- package/dist/field/features/lists/unorderedlist/feature.server.d.ts.map +0 -1
- package/dist/field/features/lists/unorderedlist/feature.server.js.map +0 -1
- package/dist/field/features/lists/unorderedlist/markdownTransformer.d.ts.map +0 -1
- package/dist/field/features/lists/unorderedlist/markdownTransformer.js.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts +0 -8
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts +0 -17
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.d.ts +0 -18
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.d.ts.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js +0 -42
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts +0 -6
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/types.d.ts +0 -40
- package/dist/field/lexical/plugins/FloatingSelectToolbar/types.d.ts.map +0 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/types.js.map +0 -1
- package/dist/populate/richTextRelationshipPromise.d.ts +0 -23
- package/dist/populate/richTextRelationshipPromise.d.ts.map +0 -1
- package/dist/populate/richTextRelationshipPromise.js +0 -68
- package/dist/populate/richTextRelationshipPromise.js.map +0 -1
- package/dist/scss/fonts.scss +0 -75
- package/src/index.ts +0 -423
- /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js +0 -0
- /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts +0 -0
- /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.scss +0 -0
- /package/dist/field/features/debug/{treeview → treeView}/feature.client.js +0 -0
- /package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts +0 -0
- /package/dist/field/features/debug/{treeview → treeView}/plugin/index.scss +0 -0
- /package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts +0 -0
- /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts +0 -0
- /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js +0 -0
- /package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts +0 -0
- /package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts +0 -0
- /package/dist/field/features/lists/{common → shared}/markdown.d.ts +0 -0
- /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts +0 -0
- /package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts +0 -0
- /package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars}/types.js +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { $getNodeByKey } = lexicalImport;
|
|
1
|
+
import { $getNodeByKey } from 'lexical';
|
|
3
2
|
import { Point } from '../../../utils/point.js';
|
|
4
3
|
import { Rect } from '../../../utils/rect.js';
|
|
5
4
|
import { getCollapsedMargins } from '../utils/getCollapsedMargins.js';
|
|
@@ -19,9 +18,9 @@ function isPointClose(previous, current, threshold = 20) {
|
|
|
19
18
|
return dx * dx + dy * dy <= threshold * threshold;
|
|
20
19
|
}
|
|
21
20
|
export function getNodeCloseToPoint(props) {
|
|
22
|
-
const { anchorElem,
|
|
21
|
+
const { anchorElem, cache_threshold = 20, editor, fuzzy = false, horizontalOffset = 0, point: { x, y }, startIndex = 0, useEdgeAsDefault = false, verbose = false } = props;
|
|
23
22
|
// Use cache
|
|
24
|
-
if (
|
|
23
|
+
if (cache_threshold > 0 && cache.props && cache.result && cache.props.fuzzy === props.fuzzy && cache.props.horizontalOffset === props.horizontalOffset && cache.props.useEdgeAsDefault === props.useEdgeAsDefault && isPointClose(cache.props.point, props.point, cache_threshold)) {
|
|
25
24
|
if (verbose) {
|
|
26
25
|
//console.log('Returning cached result')
|
|
27
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode } from 'lexical'\n\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport { Point } from '../../../utils/point.js'\nimport { Rect } from '../../../utils/rect.js'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\n\n// Directions\nconst Downward = 1\nconst Upward = -1\nconst Indeterminate = 0\n\ntype Props = {\n anchorElem: HTMLElement\n cache_treshold?: number\n editor: LexicalEditor\n /** fuzzy makes the search not exact. If no exact match found, find the closes node instead of returning null */\n fuzzy?: boolean\n horizontalOffset?: number\n point: Point\n /**\n * The index to start searching from. It can be a considerable performance optimization to start searching from the index of the\n * previously found node, as the node is likely to be close to the next node.\n */\n startIndex?: number\n useEdgeAsDefault?: boolean\n verbose?: boolean\n}\n\ntype Output = {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n}\n\nconst cache = {\n props: null as Props | null,\n result: null as Output | null,\n}\n\nfunction isPointClose(previous: Point, current: Point, threshold: number = 20): boolean {\n const dx = previous.x - current.x\n const dy = previous.y - current.y\n return dx * dx + dy * dy <= threshold * threshold\n}\n\nexport function getNodeCloseToPoint(props: Props): Output {\n const {\n anchorElem,\n cache_treshold = 20,\n editor,\n fuzzy = false,\n horizontalOffset = 0,\n point: { x, y },\n startIndex = 0,\n useEdgeAsDefault = false,\n verbose = false,\n } = props\n\n // Use cache\n if (\n cache_treshold > 0 &&\n cache.props &&\n cache.result &&\n cache.props.fuzzy === props.fuzzy &&\n cache.props.horizontalOffset === props.horizontalOffset &&\n cache.props.useEdgeAsDefault === props.useEdgeAsDefault &&\n isPointClose(cache.props.point, props.point, cache_treshold)\n ) {\n if (verbose) {\n //console.log('Returning cached result')\n }\n return cache.result\n }\n\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const closestBlockElem: {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n distance: number\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n } = {\n blockElem: null,\n blockNode: null,\n distance: Infinity,\n foundAtIndex: -1,\n isFoundNodeEmptyParagraph: false,\n }\n\n // Return null if matching block element is the first or last node\n editor.getEditorState().read(() => {\n if (useEdgeAsDefault) {\n const [firstNode, lastNode] = [\n editor.getElementByKey(topLevelNodeKeys[0]),\n editor.getElementByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1]),\n ]\n\n const [firstNodeRect, lastNodeRect] = [\n getBoundingClientRectWithoutTransform(firstNode),\n getBoundingClientRectWithoutTransform(lastNode),\n ]\n\n if (firstNodeRect && lastNodeRect) {\n if (y < firstNodeRect.top) {\n closestBlockElem.blockElem = firstNode\n closestBlockElem.distance = firstNodeRect.top - y\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[0])\n closestBlockElem.foundAtIndex = 0\n } else if (y > lastNodeRect.bottom) {\n closestBlockElem.distance = y - lastNodeRect.bottom\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1])\n closestBlockElem.blockElem = lastNode\n closestBlockElem.foundAtIndex = topLevelNodeKeys.length - 1\n }\n\n if (closestBlockElem?.blockElem) {\n if (verbose) {\n //console.log('useEdgeAsDefault', useEdgeAsDefault)\n }\n\n return {\n blockElem: null,\n isFoundNodeEmptyParagraph: false,\n } as Output\n }\n }\n }\n\n // Find matching block element\n let index = startIndex\n let direction = Indeterminate\n\n if (verbose) {\n //console.log('start index', startIndex)\n }\n\n while (index >= 0 && index < topLevelNodeKeys.length) {\n const key = topLevelNodeKeys[index]\n const elem = editor.getElementByKey(key)\n if (elem === null) {\n break\n }\n const point = new Point(x + horizontalOffset, y)\n //const domRect = Rect.fromDOM(elem)\n // Do not consider transform of blocks when calculating distance\n const domRect = Rect.fromDOMRect(getBoundingClientRectWithoutTransform(elem))\n\n const { marginBottom, marginTop } = getCollapsedMargins(elem)\n\n const rect = domRect.generateNewRect({\n bottom: domRect.bottom + marginBottom,\n left: anchorElementRect.left,\n right: anchorElementRect.right,\n top: domRect.top - marginTop,\n })\n\n const { distance, isOnBottomSide, isOnTopSide } = rect.distanceFromPoint(point)\n\n if (verbose) {\n //console.log('distance', distance)\n }\n\n if (distance === 0) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.foundAtIndex = index\n closestBlockElem.distance = distance\n\n // Check if blockNode is an empty text node\n if (\n closestBlockElem.blockNode &&\n closestBlockElem.blockNode.getType() === 'paragraph' &&\n closestBlockElem.blockNode.getTextContent() === ''\n ) {\n if (!fuzzy) {\n closestBlockElem.blockElem = null\n closestBlockElem.blockNode = null\n }\n\n closestBlockElem.isFoundNodeEmptyParagraph = true\n }\n break\n } else if (fuzzy) {\n if (distance < closestBlockElem.distance) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.distance = distance\n closestBlockElem.foundAtIndex = index\n }\n }\n\n if (direction === Indeterminate) {\n if (isOnTopSide) {\n direction = Upward\n } else if (isOnBottomSide) {\n direction = Downward\n } else {\n // stop search block element\n direction = Infinity\n }\n }\n\n index += direction\n }\n })\n\n // Store in cache before returning\n cache.props = props\n cache.result = {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n\n return {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n}\n"],"names":["lexicalImport","$getNodeByKey","Point","Rect","getCollapsedMargins","getTopLevelNodeKeys","getBoundingClientRectWithoutTransform","Downward","Upward","Indeterminate","cache","props","result","isPointClose","previous","current","threshold","dx","x","dy","y","getNodeCloseToPoint","anchorElem","cache_treshold","editor","fuzzy","horizontalOffset","point","startIndex","useEdgeAsDefault","verbose","anchorElementRect","getBoundingClientRect","topLevelNodeKeys","closestBlockElem","blockElem","blockNode","distance","Infinity","foundAtIndex","isFoundNodeEmptyParagraph","getEditorState","read","firstNode","lastNode","getElementByKey","length","firstNodeRect","lastNodeRect","top","bottom","index","direction","key","elem","domRect","fromDOMRect","marginBottom","marginTop","rect","generateNewRect","left","right","isOnBottomSide","isOnTopSide","distanceFromPoint","getType","getTextContent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAASE,KAAK,QAAQ,0BAAyB;AAC/C,SAASC,IAAI,QAAQ,yBAAwB;AAC7C,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,qCAAqC,QAAQ,uCAAsC;AAE5F,aAAa;AACb,MAAMC,WAAW;AACjB,MAAMC,SAAS,CAAC;AAChB,MAAMC,gBAAgB;AA0BtB,MAAMC,QAAQ;IACZC,OAAO;IACPC,QAAQ;AACV;AAEA,SAASC,aAAaC,QAAe,EAAEC,OAAc,EAAEC,YAAoB,EAAE;IAC3E,MAAMC,KAAKH,SAASI,CAAC,GAAGH,QAAQG,CAAC;IACjC,MAAMC,KAAKL,SAASM,CAAC,GAAGL,QAAQK,CAAC;IACjC,OAAOH,KAAKA,KAAKE,KAAKA,MAAMH,YAAYA;AAC1C;AAEA,OAAO,SAASK,oBAAoBV,KAAY;IAC9C,MAAM,EACJW,UAAU,EACVC,iBAAiB,EAAE,EACnBC,MAAM,EACNC,QAAQ,KAAK,EACbC,mBAAmB,CAAC,EACpBC,OAAO,EAAET,CAAC,EAAEE,CAAC,EAAE,EACfQ,aAAa,CAAC,EACdC,mBAAmB,KAAK,EACxBC,UAAU,KAAK,EAChB,GAAGnB;IAEJ,YAAY;IACZ,IACEY,iBAAiB,KACjBb,MAAMC,KAAK,IACXD,MAAME,MAAM,IACZF,MAAMC,KAAK,CAACc,KAAK,KAAK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gBAC3C,IACEH,iBAAiBE,SAAS,IAC1BF,iBAAiBE,SAAS,CAAC8B,OAAO,OAAO,eACzChC,iBAAiBE,SAAS,CAAC+B,cAAc,OAAO,IAChD;oBACA,IAAI,CAAC1C,OAAO;wBACVS,iBAAiBC,SAAS,GAAG;wBAC7BD,iBAAiBE,SAAS,GAAG;oBAC/B;oBAEAF,iBAAiBM,yBAAyB,GAAG;gBAC/C;gBACA;YACF,OAAO,IAAIf,OAAO;gBAChB,IAAIY,WAAWH,iBAAiBG,QAAQ,EAAE;oBACxCH,iBAAiBC,SAAS,GAAGmB;oBAC7BpB,iBAAiBE,SAAS,GAAGnC,cAAcoD;oBAC3CnB,iBAAiBG,QAAQ,GAAGA;oBAC5BH,iBAAiBK,YAAY,GAAGY;gBAClC;YACF;YAEA,IAAIC,cAAc3C,eAAe;gBAC/B,IAAIuD,aAAa;oBACfZ,YAAY5C;gBACd,OAAO,IAAIuD,gBAAgB;oBACzBX,YAAY7C;gBACd,OAAO;oBACL,4BAA4B;oBAC5B6C,YAAYd;gBACd;YACF;YAEAa,SAASC;QACX;IACF;IAEA,kCAAkC;IAClC1C,MAAMC,KAAK,GAAGA;IACdD,MAAME,MAAM,GAAG;QACbuB,WAAWD,iBAAiBC,SAAS;QACrCC,WAAWF,iBAAiBE,SAAS;QACrCG,cAAcL,iBAAiBK,YAAY;QAC3CC,2BAA2BN,iBAAiBM,yBAAyB;IACvE;IAEA,OAAO;QACLL,WAAWD,iBAAiBC,SAAS;QACrCC,WAAWF,iBAAiBE,SAAS;QACrCG,cAAcL,iBAAiBK,YAAY;QAC3CC,2BAA2BN,iBAAiBM,yBAAyB;IACvE;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode } from 'lexical'\n\nimport { $getNodeByKey } from 'lexical'\n\nimport { Point } from '../../../utils/point.js'\nimport { Rect } from '../../../utils/rect.js'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\n\n// Directions\nconst Downward = 1\nconst Upward = -1\nconst Indeterminate = 0\n\ntype Props = {\n anchorElem: HTMLElement\n cache_threshold?: number\n editor: LexicalEditor\n /** fuzzy makes the search not exact. If no exact match found, find the closes node instead of returning null */\n fuzzy?: boolean\n horizontalOffset?: number\n point: Point\n /**\n * The index to start searching from. It can be a considerable performance optimization to start searching from the index of the\n * previously found node, as the node is likely to be close to the next node.\n */\n startIndex?: number\n useEdgeAsDefault?: boolean\n verbose?: boolean\n}\n\ntype Output = {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n}\n\nconst cache = {\n props: null as Props | null,\n result: null as Output | null,\n}\n\nfunction isPointClose(previous: Point, current: Point, threshold: number = 20): boolean {\n const dx = previous.x - current.x\n const dy = previous.y - current.y\n return dx * dx + dy * dy <= threshold * threshold\n}\n\nexport function getNodeCloseToPoint(props: Props): Output {\n const {\n anchorElem,\n cache_threshold = 20,\n editor,\n fuzzy = false,\n horizontalOffset = 0,\n point: { x, y },\n startIndex = 0,\n useEdgeAsDefault = false,\n verbose = false,\n } = props\n\n // Use cache\n if (\n cache_threshold > 0 &&\n cache.props &&\n cache.result &&\n cache.props.fuzzy === props.fuzzy &&\n cache.props.horizontalOffset === props.horizontalOffset &&\n cache.props.useEdgeAsDefault === props.useEdgeAsDefault &&\n isPointClose(cache.props.point, props.point, cache_threshold)\n ) {\n if (verbose) {\n //console.log('Returning cached result')\n }\n return cache.result\n }\n\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const closestBlockElem: {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n distance: number\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n } = {\n blockElem: null,\n blockNode: null,\n distance: Infinity,\n foundAtIndex: -1,\n isFoundNodeEmptyParagraph: false,\n }\n\n // Return null if matching block element is the first or last node\n editor.getEditorState().read(() => {\n if (useEdgeAsDefault) {\n const [firstNode, lastNode] = [\n editor.getElementByKey(topLevelNodeKeys[0]),\n editor.getElementByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1]),\n ]\n\n const [firstNodeRect, lastNodeRect] = [\n getBoundingClientRectWithoutTransform(firstNode),\n getBoundingClientRectWithoutTransform(lastNode),\n ]\n\n if (firstNodeRect && lastNodeRect) {\n if (y < firstNodeRect.top) {\n closestBlockElem.blockElem = firstNode\n closestBlockElem.distance = firstNodeRect.top - y\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[0])\n closestBlockElem.foundAtIndex = 0\n } else if (y > lastNodeRect.bottom) {\n closestBlockElem.distance = y - lastNodeRect.bottom\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1])\n closestBlockElem.blockElem = lastNode\n closestBlockElem.foundAtIndex = topLevelNodeKeys.length - 1\n }\n\n if (closestBlockElem?.blockElem) {\n if (verbose) {\n //console.log('useEdgeAsDefault', useEdgeAsDefault)\n }\n\n return {\n blockElem: null,\n isFoundNodeEmptyParagraph: false,\n } as Output\n }\n }\n }\n\n // Find matching block element\n let index = startIndex\n let direction = Indeterminate\n\n if (verbose) {\n //console.log('start index', startIndex)\n }\n\n while (index >= 0 && index < topLevelNodeKeys.length) {\n const key = topLevelNodeKeys[index]\n const elem = editor.getElementByKey(key)\n if (elem === null) {\n break\n }\n const point = new Point(x + horizontalOffset, y)\n //const domRect = Rect.fromDOM(elem)\n // Do not consider transform of blocks when calculating distance\n const domRect = Rect.fromDOMRect(getBoundingClientRectWithoutTransform(elem))\n\n const { marginBottom, marginTop } = getCollapsedMargins(elem)\n\n const rect = domRect.generateNewRect({\n bottom: domRect.bottom + marginBottom,\n left: anchorElementRect.left,\n right: anchorElementRect.right,\n top: domRect.top - marginTop,\n })\n\n const { distance, isOnBottomSide, isOnTopSide } = rect.distanceFromPoint(point)\n\n if (verbose) {\n //console.log('distance', distance)\n }\n\n if (distance === 0) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.foundAtIndex = index\n closestBlockElem.distance = distance\n\n // Check if blockNode is an empty text node\n if (\n closestBlockElem.blockNode &&\n closestBlockElem.blockNode.getType() === 'paragraph' &&\n closestBlockElem.blockNode.getTextContent() === ''\n ) {\n if (!fuzzy) {\n closestBlockElem.blockElem = null\n closestBlockElem.blockNode = null\n }\n\n closestBlockElem.isFoundNodeEmptyParagraph = true\n }\n break\n } else if (fuzzy) {\n if (distance < closestBlockElem.distance) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.distance = distance\n closestBlockElem.foundAtIndex = index\n }\n }\n\n if (direction === Indeterminate) {\n if (isOnTopSide) {\n direction = Upward\n } else if (isOnBottomSide) {\n direction = Downward\n } else {\n // stop search block element\n direction = Infinity\n }\n }\n\n index += direction\n }\n })\n\n // Store in cache before returning\n cache.props = props\n cache.result = {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n\n return {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n}\n"],"names":["$getNodeByKey","Point","Rect","getCollapsedMargins","getTopLevelNodeKeys","getBoundingClientRectWithoutTransform","Downward","Upward","Indeterminate","cache","props","result","isPointClose","previous","current","threshold","dx","x","dy","y","getNodeCloseToPoint","anchorElem","cache_threshold","editor","fuzzy","horizontalOffset","point","startIndex","useEdgeAsDefault","verbose","anchorElementRect","getBoundingClientRect","topLevelNodeKeys","closestBlockElem","blockElem","blockNode","distance","Infinity","foundAtIndex","isFoundNodeEmptyParagraph","getEditorState","read","firstNode","lastNode","getElementByKey","length","firstNodeRect","lastNodeRect","top","bottom","index","direction","key","elem","domRect","fromDOMRect","marginBottom","marginTop","rect","generateNewRect","left","right","isOnBottomSide","isOnTopSide","distanceFromPoint","getType","getTextContent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,aAAa,QAAQ,UAAS;AAEvC,SAASC,KAAK,QAAQ,0BAAyB;AAC/C,SAASC,IAAI,QAAQ,yBAAwB;AAC7C,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,qCAAqC,QAAQ,uCAAsC;AAE5F,aAAa;AACb,MAAMC,WAAW;AACjB,MAAMC,SAAS,CAAC;AAChB,MAAMC,gBAAgB;AA0BtB,MAAMC,QAAQ;IACZC,OAAO;IACPC,QAAQ;AACV;AAEA,SAASC,aAAaC,QAAe,EAAEC,OAAc,EAAEC,YAAoB,EAAE;IAC3E,MAAMC,KAAKH,SAASI,CAAC,GAAGH,QAAQG,CAAC;IACjC,MAAMC,KAAKL,SAASM,CAAC,GAAGL,QAAQK,CAAC;IACjC,OAAOH,KAAKA,KAAKE,KAAKA,MAAMH,YAAYA;AAC1C;AAEA,OAAO,SAASK,oBAAoBV,KAAY;IAC9C,MAAM,EACJW,UAAU,EACVC,kBAAkB,EAAE,EACpBC,MAAM,EACNC,QAAQ,KAAK,EACbC,mBAAmB,CAAC,EACpBC,OAAO,EAAET,CAAC,EAAEE,CAAC,EAAE,EACfQ,aAAa,CAAC,EACdC,mBAAmB,KAAK,EACxBC,UAAU,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../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":";AAkBA,OAAO,cAAc,CAAA;AAuXrB,wBAAgB,oBAAoB,CAAC,EACnC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,CAGd"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
const { useLexicalComposerContext } = lexicalComposerContextImport;
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
3
|
import { eventFiles } from '@lexical/rich-text';
|
|
5
|
-
import
|
|
6
|
-
const { $getNearestNodeFromDOMNode, $getNodeByKey } = lexicalImport;
|
|
4
|
+
import { $getNearestNodeFromDOMNode, $getNodeByKey } from 'lexical';
|
|
7
5
|
import * as React from 'react';
|
|
8
6
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
7
|
import { createPortal } from 'react-dom';
|
|
@@ -42,8 +40,11 @@ function hideTargetLine(targetLineElem, lastTargetBlockElem) {
|
|
|
42
40
|
targetLineElem.style.opacity = '0';
|
|
43
41
|
}
|
|
44
42
|
if (lastTargetBlockElem) {
|
|
45
|
-
lastTargetBlockElem.style.opacity = '
|
|
46
|
-
lastTargetBlockElem.style.transform = '
|
|
43
|
+
lastTargetBlockElem.style.opacity = '';
|
|
44
|
+
lastTargetBlockElem.style.transform = '';
|
|
45
|
+
// Delete marginBottom and marginTop values we set
|
|
46
|
+
lastTargetBlockElem.style.marginBottom = '';
|
|
47
|
+
lastTargetBlockElem.style.marginTop = '';
|
|
47
48
|
//lastTargetBlockElem.style.border = 'none'
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -91,7 +92,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
91
92
|
const topLevelNodeKeys = getTopLevelNodeKeys(editor);
|
|
92
93
|
const { blockElem: _draggableBlockElem, foundAtIndex, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({
|
|
93
94
|
anchorElem,
|
|
94
|
-
|
|
95
|
+
cache_threshold: 0,
|
|
95
96
|
editor,
|
|
96
97
|
horizontalOffset: -distanceFromScrollerElem,
|
|
97
98
|
point: new Point(event.x, event.y),
|
|
@@ -106,7 +107,9 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
106
107
|
if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
+
if (draggableBlockElem !== _draggableBlockElem) {
|
|
111
|
+
setDraggableBlockElem(_draggableBlockElem);
|
|
112
|
+
}
|
|
110
113
|
}
|
|
111
114
|
// Since the draggableBlockElem is outside the actual editor, we need to listen to the document
|
|
112
115
|
// to be able to detect when the mouse is outside the editor and respect a buffer around the
|
|
@@ -119,7 +122,8 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
119
122
|
scrollerElem,
|
|
120
123
|
anchorElem,
|
|
121
124
|
editor,
|
|
122
|
-
calculateDistanceFromScrollerElem
|
|
125
|
+
calculateDistanceFromScrollerElem,
|
|
126
|
+
draggableBlockElem
|
|
123
127
|
]);
|
|
124
128
|
useEffect(()=>{
|
|
125
129
|
if (menuRef.current) {
|
|
@@ -230,7 +234,9 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
230
234
|
targetNode.insertAfter(draggedNode)
|
|
231
235
|
} else {
|
|
232
236
|
targetNode.insertBefore(draggedNode)
|
|
233
|
-
}*/
|
|
237
|
+
}*/ if (draggableBlockElem !== null) {
|
|
238
|
+
setDraggableBlockElem(null);
|
|
239
|
+
}
|
|
234
240
|
});
|
|
235
241
|
return true;
|
|
236
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport { eventFiles } from '@lexical/rich-text'\nimport lexicalImport from 'lexical'\nconst { $getNearestNodeFromDOMNode, $getNodeByKey } = lexicalImport\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport { getNodeCloseToPoint } from './getNodeCloseToPoint.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst SPACE = -24\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = '1'\n lastTargetBlockElem.style.transform = 'translate(0, 0)'\n //lastTargetBlockElem.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): JSX.Element {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlockElem, setLastTargetBlockElem] = useState<HTMLElement | null>(null)\n\n const calculateDistanceFromScrollerElem = useCallback(\n (\n pageX: number,\n pageY: number,\n target: HTMLElement,\n horizontalBuffer: number = 50,\n verticalBuffer: number = 25,\n ): number => {\n let distanceFromScrollerElem = 0\n // Calculate distance between scrollerElem and target if target is not in scrollerElem\n if (scrollerElem && !scrollerElem.contains(target)) {\n const { bottom, left, right, top } = scrollerElem.getBoundingClientRect()\n\n const adjustedTop = top + window.scrollY\n const adjustedBottom = bottom + window.scrollY\n\n if (\n pageY < adjustedTop - verticalBuffer ||\n pageY > adjustedBottom + verticalBuffer ||\n pageX < left - horizontalBuffer ||\n pageX > right + horizontalBuffer\n ) {\n setDraggableBlockElem(null)\n return distanceFromScrollerElem\n }\n\n // This is used to allow the _draggableBlockElem to be found when the mouse is in the\n // buffer zone around the scrollerElem.\n if (pageX < left || pageX > right) {\n distanceFromScrollerElem = pageX < left ? pageX - left : pageX - right\n }\n }\n return distanceFromScrollerElem\n },\n [scrollerElem],\n )\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n event.pageX,\n event.pageY,\n target,\n )\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_treshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n prevIndex = foundAtIndex\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n setDraggableBlockElem(_draggableBlockElem)\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around the\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, calculateDistanceFromScrollerElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(draggableBlockElem, menuRef.current, anchorElem, SPACE)\n }\n }, [anchorElem, draggableBlockElem])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n setTargetLine(\n SPACE,\n targetLineElem,\n targetBlockElem,\n lastTargetBlockElem,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n } else {\n hideTargetLine(targetLineElem, lastTargetBlockElem)\n }\n\n setLastTargetBlockElem(targetBlockElem)\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n setDraggableBlockElem(null)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n anchorElem,\n editor,\n lastTargetBlockElem,\n calculateDistanceFromScrollerElem,\n draggableBlockElem,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n hideTargetLine(targetLineRef.current, lastTargetBlockElem)\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","eventFiles","lexicalImport","$getNearestNodeFromDOMNode","$getNodeByKey","React","useCallback","useEffect","useRef","useState","createPortal","isHTMLElement","Point","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","getBoundingClientRectWithoutTransform","getNodeCloseToPoint","setTargetLine","SPACE","DRAGGABLE_BLOCK_MENU_CLASSNAME","DRAG_DATA_FORMAT","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","setDragImage","dataTransfer","draggableBlockElem","transform","style","setTimeout","hideTargetLine","targetLineElem","lastTargetBlockElem","opacity","useDraggableBlockMenu","editor","anchorElem","isEditable","scrollerElem","parentElement","menuRef","targetLineRef","debugHighlightRef","isDraggingBlockRef","setDraggableBlockElem","setLastTargetBlockElem","calculateDistanceFromScrollerElem","pageX","pageY","target","horizontalBuffer","verticalBuffer","distanceFromScrollerElem","contains","bottom","left","right","top","getBoundingClientRect","adjustedTop","window","scrollY","adjustedBottom","onDocumentMouseMove","event","topLevelNodeKeys","blockElem","_draggableBlockElem","foundAtIndex","isFoundNodeEmptyParagraph","cache_treshold","horizontalOffset","point","x","y","startIndex","length","useEdgeAsDefault","document","addEventListener","removeEventListener","current","onDragover","isFileTransfer","targetBlockElem","fuzzy","verbose","preventDefault","onDrop","dragData","getData","update","draggedNode","targetNode","height","targetBlockElemHeight","targetBlockElemTop","mouseY","isBelow","insertAfter","insertBefore","remove","onDragStart","nodeKey","node","getKey","setData","onDragEnd","Fragment","div","className","draggable","ref","DraggableBlockPlugin","body","_editable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ASC,gBAAgB,CAAC,QAAQS;QAElC,OAAO;YACLV,SAASE,mBAAmB,CAAC,YAAYE;YACzCJ,SAASE,mBAAmB,CAAC,QAAQQ;QACvC;IACF,GAAG;QACDpD;QACAD;QACAH;QACAc;QACApB;KACD;IAED,SAAS4E,YAAYtC,KAAqC;QACxD,MAAMvC,eAAeuC,MAAMvC,YAAY;QACvC,IAAI,CAACA,gBAAgB,CAACC,oBAAoB;YACxC;QACF;QACAF,aAAaC,cAAcC;QAC3B,IAAI6E,UAAU;QACdpE,OAAOwD,MAAM,CAAC;YACZ,MAAMa,OAAOzG,2BAA2B2B;YACxC,IAAI8E,MAAM;gBACRD,UAAUC,KAAKC,MAAM;YACvB;QACF;QACA9D,mBAAmBsC,OAAO,GAAG;QAC7BxD,aAAaiF,OAAO,CAACzF,kBAAkBsF;IACzC;IAEA,SAASI;QACPhE,mBAAmBsC,OAAO,GAAG;QAC7BnD,eAAeW,cAAcwC,OAAO,EAAEjD;IACxC;IAEA,qBAAO1B,2BACL,oBAACL,MAAM2G,QAAQ,sBACb,oBAACC;QACCC,WAAU;QACVC,WAAAA;QACAJ,WAAWA;QACXL,aAAaA;QACbU,KAAKxE;qBAEL,oBAACqE;QAAIC,WAAWzE,aAAa,SAAS;uBAExC,oBAACwE;QAAIC,WAAU;QAA8BE,KAAKvE;sBAClD,oBAACoE;QAAIC,WAAU;QAAkBE,KAAKtE;SAExCN;AAEJ;AAEA,OAAO,SAAS6E,qBAAqB,EACnC7E,aAAa0C,SAASoC,IAAI,EAG3B;IACC,MAAM,CAAC/E,OAAO,GAAGvC;IACjB,OAAOsC,sBAAsBC,QAAQC,YAAYD,OAAOgF,SAAS;AACnE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport { getNodeCloseToPoint } from './getNodeCloseToPoint.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst SPACE = -24\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n lastTargetBlockElem.style.transform = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlockElem.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): JSX.Element {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlockElem, setLastTargetBlockElem] = useState<HTMLElement | null>(null)\n\n const calculateDistanceFromScrollerElem = useCallback(\n (\n pageX: number,\n pageY: number,\n target: HTMLElement,\n horizontalBuffer: number = 50,\n verticalBuffer: number = 25,\n ): number => {\n let distanceFromScrollerElem = 0\n // Calculate distance between scrollerElem and target if target is not in scrollerElem\n if (scrollerElem && !scrollerElem.contains(target)) {\n const { bottom, left, right, top } = scrollerElem.getBoundingClientRect()\n\n const adjustedTop = top + window.scrollY\n const adjustedBottom = bottom + window.scrollY\n\n if (\n pageY < adjustedTop - verticalBuffer ||\n pageY > adjustedBottom + verticalBuffer ||\n pageX < left - horizontalBuffer ||\n pageX > right + horizontalBuffer\n ) {\n setDraggableBlockElem(null)\n return distanceFromScrollerElem\n }\n\n // This is used to allow the _draggableBlockElem to be found when the mouse is in the\n // buffer zone around the scrollerElem.\n if (pageX < left || pageX > right) {\n distanceFromScrollerElem = pageX < left ? pageX - left : pageX - right\n }\n }\n return distanceFromScrollerElem\n },\n [scrollerElem],\n )\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n event.pageX,\n event.pageY,\n target,\n )\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n prevIndex = foundAtIndex\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around the\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, calculateDistanceFromScrollerElem, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(draggableBlockElem, menuRef.current, anchorElem, SPACE)\n }\n }, [anchorElem, draggableBlockElem])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n setTargetLine(\n SPACE,\n targetLineElem,\n targetBlockElem,\n lastTargetBlockElem,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n } else {\n hideTargetLine(targetLineElem, lastTargetBlockElem)\n }\n\n setLastTargetBlockElem(targetBlockElem)\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n anchorElem,\n editor,\n lastTargetBlockElem,\n calculateDistanceFromScrollerElem,\n draggableBlockElem,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n hideTargetLine(targetLineRef.current, lastTargetBlockElem)\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n"],"names":["useLexicalComposerContext","eventFiles","$getNearestNodeFromDOMNode","$getNodeByKey","React","useCallback","useEffect","useRef","useState","createPortal","isHTMLElement","Point","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","getBoundingClientRectWithoutTransform","getNodeCloseToPoint","setTargetLine","SPACE","DRAGGABLE_BLOCK_MENU_CLASSNAME","DRAG_DATA_FORMAT","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","setDragImage","dataTransfer","draggableBlockElem","transform","style","setTimeout","hideTargetLine","targetLineElem","lastTargetBlockElem","opacity","marginBottom","marginTop","useDraggableBlockMenu","editor","anchorElem","isEditable","scrollerElem","parentElement","menuRef","targetLineRef","debugHighlightRef","isDraggingBlockRef","setDraggableBlockElem","setLastTargetBlockElem","calculateDistanceFromScrollerElem","pageX","pageY","target","horizontalBuffer","verticalBuffer","distanceFromScrollerElem","contains","bottom","left","right","top","getBoundingClientRect","adjustedTop","window","scrollY","adjustedBottom","onDocumentMouseMove","event","topLevelNodeKeys","blockElem","_draggableBlockElem","foundAtIndex","isFoundNodeEmptyParagraph","cache_threshold","horizontalOffset","point","x","y","startIndex","length","useEdgeAsDefault","document","addEventListener","removeEventListener","current","onDragover","isFileTransfer","targetBlockElem","fuzzy","verbose","preventDefault","onDrop","dragData","getData","update","draggedNode","targetNode","height","targetBlockElemHeight","targetBlockElemTop","mouseY","isBelow","insertAfter","insertBefore","remove","onDragStart","nodeKey","node","getKey","setData","onDragEnd","Fragment","div","className","draggable","ref","DraggableBlockPlugin","body","_editable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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J,SAASC,gBAAgB,CAAC,QAAQS;QAElC,OAAO;YACLV,SAASE,mBAAmB,CAAC,YAAYE;YACzCJ,SAASE,mBAAmB,CAAC,QAAQQ;QACvC;IACF,GAAG;QACDpD;QACAD;QACAL;QACAgB;QACAtB;KACD;IAED,SAAS8E,YAAYtC,KAAqC;QACxD,MAAMzC,eAAeyC,MAAMzC,YAAY;QACvC,IAAI,CAACA,gBAAgB,CAACC,oBAAoB;YACxC;QACF;QACAF,aAAaC,cAAcC;QAC3B,IAAI+E,UAAU;QACdpE,OAAOwD,MAAM,CAAC;YACZ,MAAMa,OAAO3G,2BAA2B2B;YACxC,IAAIgF,MAAM;gBACRD,UAAUC,KAAKC,MAAM;YACvB;QACF;QACA9D,mBAAmBsC,OAAO,GAAG;QAC7B1D,aAAamF,OAAO,CAAC3F,kBAAkBwF;IACzC;IAEA,SAASI;QACPhE,mBAAmBsC,OAAO,GAAG;QAC7BrD,eAAea,cAAcwC,OAAO,EAAEnD;IACxC;IAEA,qBAAO1B,2BACL,oBAACL,MAAM6G,QAAQ,sBACb,oBAACC;QACCC,WAAU;QACVC,WAAAA;QACAJ,WAAWA;QACXL,aAAaA;QACbU,KAAKxE;qBAEL,oBAACqE;QAAIC,WAAWzE,aAAa,SAAS;uBAExC,oBAACwE;QAAIC,WAAU;QAA8BE,KAAKvE;sBAClD,oBAACoE;QAAIC,WAAU;QAAkBE,KAAKtE;SAExCN;AAEJ;AAEA,OAAO,SAAS6E,qBAAqB,EACnC7E,aAAa0C,SAASoC,IAAI,EAG3B;IACC,MAAM,CAAC/E,OAAO,GAAGxC;IACjB,OAAOuC,sBAAsBC,QAAQC,YAAYD,OAAOgF,SAAS;AACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTargetLine.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"names":[],"mappings":";AAOA,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,WAAW,EAC5B,mBAAmB,EAAE,WAAW,GAAG,IAAI,EACvC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,EAClD,yBAAyB,GAAE,OAAe,
|
|
1
|
+
{"version":3,"file":"setTargetLine.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"names":[],"mappings":";AAOA,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,WAAW,EAC5B,mBAAmB,EAAE,WAAW,GAAG,IAAI,EACvC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,EAClD,yBAAyB,GAAE,OAAe,QAwE3C"}
|
|
@@ -21,18 +21,34 @@ export function setTargetLine(SPACE, targetLineElem, targetBlockElem, lastTarget
|
|
|
21
21
|
} else {
|
|
22
22
|
lineTop += targetBlockElemHeight / 2;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const targetElemTranslate = 0;
|
|
25
|
+
let targetElemTranslate2 = 0;
|
|
26
|
+
if (!isFoundNodeEmptyParagraph) {
|
|
27
|
+
if (isBelow) {
|
|
28
|
+
targetElemTranslate2 = -TARGET_LINE_HALF_HEIGHT;
|
|
29
|
+
} else {
|
|
30
|
+
targetElemTranslate2 = TARGET_LINE_HALF_HEIGHT;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let top = lineTop - anchorTop + targetElemTranslate2;
|
|
34
|
+
if (!isBelow) {
|
|
35
|
+
top -= TARGET_LINE_HALF_HEIGHT * 2;
|
|
36
|
+
}
|
|
25
37
|
const left = TEXT_BOX_HORIZONTAL_PADDING - SPACE;
|
|
26
38
|
targetLineElem.style.transform = `translate(${left}px, ${top}px)`;
|
|
27
39
|
targetLineElem.style.width = `${anchorWidth - (TEXT_BOX_HORIZONTAL_PADDING - SPACE) * 2}px`;
|
|
28
40
|
targetLineElem.style.opacity = '.4';
|
|
29
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Move around element below or above the line (= the target / targetBlockElem)
|
|
43
|
+
*/ //targetBlockElem.style.opacity = '0.4'
|
|
30
44
|
if (!isFoundNodeEmptyParagraph) {
|
|
31
45
|
// move lastTargetBlockElem down 50px to make space for targetLineElem (which is 50px height)
|
|
46
|
+
targetBlockElem.style.transform = `translate(0, ${targetElemTranslate}px)`;
|
|
32
47
|
if (isBelow) {
|
|
33
|
-
|
|
48
|
+
// add to existing marginBottom plus the height of targetLineElem
|
|
49
|
+
targetBlockElem.style.marginBottom = TARGET_LINE_HALF_HEIGHT * 2 + 'px';
|
|
34
50
|
} else {
|
|
35
|
-
targetBlockElem.style.
|
|
51
|
+
targetBlockElem.style.marginTop = TARGET_LINE_HALF_HEIGHT * 2 + 'px';
|
|
36
52
|
}
|
|
37
53
|
}
|
|
38
54
|
if (DEBUG) {
|
|
@@ -40,8 +56,11 @@ export function setTargetLine(SPACE, targetLineElem, targetBlockElem, lastTarget
|
|
|
40
56
|
highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem);
|
|
41
57
|
}
|
|
42
58
|
if (lastTargetBlockElem && lastTargetBlockElem !== targetBlockElem) {
|
|
43
|
-
lastTargetBlockElem.style.opacity = '
|
|
44
|
-
lastTargetBlockElem.style.transform = '
|
|
59
|
+
lastTargetBlockElem.style.opacity = '';
|
|
60
|
+
lastTargetBlockElem.style.transform = '';
|
|
61
|
+
// Delete marginBottom and marginTop values we set
|
|
62
|
+
lastTargetBlockElem.style.marginBottom = '';
|
|
63
|
+
lastTargetBlockElem.style.marginTop = '';
|
|
45
64
|
//lastTargetBlockElem.style.border = 'none'
|
|
46
65
|
}
|
|
47
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"sourcesContent":["import { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport { highlightElemOriginalPosition } from './highlightElemOriginalPosition.js'\nconst TARGET_LINE_HALF_HEIGHT = 25\nconst TEXT_BOX_HORIZONTAL_PADDING = -24\nconst DEBUG = false\n\nexport function setTargetLine(\n SPACE: number,\n targetLineElem: HTMLElement,\n targetBlockElem: HTMLElement,\n lastTargetBlockElem: HTMLElement | null,\n mouseY: number,\n anchorElem: HTMLElement,\n event: DragEvent,\n debugHighlightRef: React.RefObject<HTMLDivElement>,\n isFoundNodeEmptyParagraph: boolean = false,\n) {\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n const { top: anchorTop, width: anchorWidth } = anchorElem.getBoundingClientRect()\n\n const { marginBottom, marginTop } = getCollapsedMargins(targetBlockElem)\n let lineTop = targetBlockElemTop\n\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n lineTop += targetBlockElemHeight + marginBottom / 2\n } else {\n // above targetBlockElem\n lineTop -= marginTop / 2\n }\n } else {\n lineTop += targetBlockElemHeight / 2\n }\n\n const top = lineTop - anchorTop
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"sourcesContent":["import { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport { highlightElemOriginalPosition } from './highlightElemOriginalPosition.js'\nconst TARGET_LINE_HALF_HEIGHT = 25\nconst TEXT_BOX_HORIZONTAL_PADDING = -24\nconst DEBUG = false\n\nexport function setTargetLine(\n SPACE: number,\n targetLineElem: HTMLElement,\n targetBlockElem: HTMLElement,\n lastTargetBlockElem: HTMLElement | null,\n mouseY: number,\n anchorElem: HTMLElement,\n event: DragEvent,\n debugHighlightRef: React.RefObject<HTMLDivElement>,\n isFoundNodeEmptyParagraph: boolean = false,\n) {\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n const { top: anchorTop, width: anchorWidth } = anchorElem.getBoundingClientRect()\n\n const { marginBottom, marginTop } = getCollapsedMargins(targetBlockElem)\n let lineTop = targetBlockElemTop\n\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n lineTop += targetBlockElemHeight + marginBottom / 2\n } else {\n // above targetBlockElem\n lineTop -= marginTop / 2\n }\n } else {\n lineTop += targetBlockElemHeight / 2\n }\n\n const targetElemTranslate = 0\n let targetElemTranslate2 = 0\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n targetElemTranslate2 = -TARGET_LINE_HALF_HEIGHT\n } else {\n targetElemTranslate2 = TARGET_LINE_HALF_HEIGHT\n }\n }\n\n let top = lineTop - anchorTop + targetElemTranslate2\n if (!isBelow) {\n top -= TARGET_LINE_HALF_HEIGHT * 2\n }\n const left = TEXT_BOX_HORIZONTAL_PADDING - SPACE\n\n targetLineElem.style.transform = `translate(${left}px, ${top}px)`\n targetLineElem.style.width = `${anchorWidth - (TEXT_BOX_HORIZONTAL_PADDING - SPACE) * 2}px`\n targetLineElem.style.opacity = '.4'\n\n /**\n * Move around element below or above the line (= the target / targetBlockElem)\n */\n //targetBlockElem.style.opacity = '0.4'\n if (!isFoundNodeEmptyParagraph) {\n // move lastTargetBlockElem down 50px to make space for targetLineElem (which is 50px height)\n targetBlockElem.style.transform = `translate(0, ${targetElemTranslate}px)`\n if (isBelow) {\n // add to existing marginBottom plus the height of targetLineElem\n targetBlockElem.style.marginBottom = TARGET_LINE_HALF_HEIGHT * 2 + 'px'\n } else {\n targetBlockElem.style.marginTop = TARGET_LINE_HALF_HEIGHT * 2 + 'px'\n }\n }\n\n if (DEBUG) {\n //targetBlockElem.style.border = '3px solid red'\n highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem)\n }\n\n if (lastTargetBlockElem && lastTargetBlockElem !== targetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n lastTargetBlockElem.style.transform = ''\n\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlockElem.style.border = 'none'\n }\n}\n"],"names":["getCollapsedMargins","getBoundingClientRectWithoutTransform","highlightElemOriginalPosition","TARGET_LINE_HALF_HEIGHT","TEXT_BOX_HORIZONTAL_PADDING","DEBUG","setTargetLine","SPACE","targetLineElem","targetBlockElem","lastTargetBlockElem","mouseY","anchorElem","event","debugHighlightRef","isFoundNodeEmptyParagraph","height","targetBlockElemHeight","top","targetBlockElemTop","anchorTop","width","anchorWidth","getBoundingClientRect","marginBottom","marginTop","lineTop","isBelow","window","scrollY","targetElemTranslate","targetElemTranslate2","left","style","transform","opacity"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,qCAAqC,QAAQ,uCAAsC;AAC5F,SAASC,6BAA6B,QAAQ,qCAAoC;AAClF,MAAMC,0BAA0B;AAChC,MAAMC,8BAA8B,CAAC;AACrC,MAAMC,QAAQ;AAEd,OAAO,SAASC,cACdC,KAAa,EACbC,cAA2B,EAC3BC,eAA4B,EAC5BC,mBAAuC,EACvCC,MAAc,EACdC,UAAuB,EACvBC,KAAgB,EAChBC,iBAAkD,EAClDC,4BAAqC,KAAK;IAE1C,MAAM,EAAEC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,YAAY,GAAGrB,0BAA0B,IAAI;QACrE,OAAO;YACLM,gBAAgBwB,KAAK,CAACR,SAAS,GAAGtB,0BAA0B,IAAI;QAClE;IACF;IAEA,IAAIE,OAAO;QACT,gDAAgD;QAChDH,8BAA8BY,mBAAmBL,iBAAiBG;IACpE;IAEA,IAAIF,uBAAuBA,wBAAwBD,iBAAiB;QAClEC,oBAAoBuB,KAAK,CAACE,OAAO,GAAG;QACpCzB,oBAAoBuB,KAAK,CAACC,SAAS,GAAG;QAEtC,kDAAkD;QAClDxB,oBAAoBuB,KAAK,CAACT,YAAY,GAAG;QACzCd,oBAAoBuB,KAAK,CAACR,SAAS,GAAG;IACtC,2CAA2C;IAC7C;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* From ChatGPT, only that verified it works for HR elements.
|
|
3
|
+
*
|
|
4
|
+
* HTML Elements can have CSS lineHeight applied to them, but it doesn't always affect the visual layout.
|
|
5
|
+
* This function checks if the line-height property has an effect on the element's layout.
|
|
6
|
+
* @param htmlElem
|
|
7
|
+
*/
|
|
8
|
+
export declare function doesLineHeightAffectElement(htmlElem: HTMLElement): boolean;
|
|
9
|
+
//# sourceMappingURL=doesLineHeightAffectElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doesLineHeightAffectElement.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,WAAW,WA2BhE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const replacedElements = [
|
|
2
|
+
'IMG',
|
|
3
|
+
'INPUT',
|
|
4
|
+
'TEXTAREA',
|
|
5
|
+
'SELECT',
|
|
6
|
+
'BUTTON',
|
|
7
|
+
'VIDEO',
|
|
8
|
+
'OBJECT',
|
|
9
|
+
'EMBED',
|
|
10
|
+
'IFRAME',
|
|
11
|
+
'HR'
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* From ChatGPT, only that verified it works for HR elements.
|
|
15
|
+
*
|
|
16
|
+
* HTML Elements can have CSS lineHeight applied to them, but it doesn't always affect the visual layout.
|
|
17
|
+
* This function checks if the line-height property has an effect on the element's layout.
|
|
18
|
+
* @param htmlElem
|
|
19
|
+
*/ export function doesLineHeightAffectElement(htmlElem) {
|
|
20
|
+
if (!htmlElem) return false;
|
|
21
|
+
// Check for replaced elements, elements that typically don't support line-height adjustments,
|
|
22
|
+
// and elements without visible content
|
|
23
|
+
if (replacedElements.includes(htmlElem.tagName) || htmlElem.offsetHeight === 0 || htmlElem.offsetWidth === 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// Check for specific CSS properties that negate line-height's visual effects
|
|
27
|
+
const style = window.getComputedStyle(htmlElem);
|
|
28
|
+
if (style.display === 'table-cell' || style.position === 'absolute' || style.visibility === 'hidden' || style.opacity === '0') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// This is a basic check, and there can be more complex scenarios where line-height doesn't have an effect.
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=doesLineHeightAffectElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.ts"],"sourcesContent":["const replacedElements = [\n 'IMG',\n 'INPUT',\n 'TEXTAREA',\n 'SELECT',\n 'BUTTON',\n 'VIDEO',\n 'OBJECT',\n 'EMBED',\n 'IFRAME',\n 'HR',\n]\n\n/**\n * From ChatGPT, only that verified it works for HR elements.\n *\n * HTML Elements can have CSS lineHeight applied to them, but it doesn't always affect the visual layout.\n * This function checks if the line-height property has an effect on the element's layout.\n * @param htmlElem\n */\nexport function doesLineHeightAffectElement(htmlElem: HTMLElement) {\n if (!htmlElem) return false\n\n // Check for replaced elements, elements that typically don't support line-height adjustments,\n // and elements without visible content\n\n if (\n replacedElements.includes(htmlElem.tagName) ||\n htmlElem.offsetHeight === 0 ||\n htmlElem.offsetWidth === 0\n ) {\n return false\n }\n\n // Check for specific CSS properties that negate line-height's visual effects\n const style = window.getComputedStyle(htmlElem)\n if (\n style.display === 'table-cell' ||\n style.position === 'absolute' ||\n style.visibility === 'hidden' ||\n style.opacity === '0'\n ) {\n return false\n }\n\n // This is a basic check, and there can be more complex scenarios where line-height doesn't have an effect.\n return true\n}\n"],"names":["replacedElements","doesLineHeightAffectElement","htmlElem","includes","tagName","offsetHeight","offsetWidth","style","window","getComputedStyle","display","position","visibility","opacity"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,mBAAmB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;CAMC,GACD,OAAO,SAASC,4BAA4BC,QAAqB;IAC/D,IAAI,CAACA,UAAU,OAAO;IAEtB,8FAA8F;IAC9F,uCAAuC;IAEvC,IACEF,iBAAiBG,QAAQ,CAACD,SAASE,OAAO,KAC1CF,SAASG,YAAY,KAAK,KAC1BH,SAASI,WAAW,KAAK,GACzB;QACA,OAAO;IACT;IAEA,6EAA6E;IAC7E,MAAMC,QAAQC,OAAOC,gBAAgB,CAACP;IACtC,IACEK,MAAMG,OAAO,KAAK,gBAClBH,MAAMI,QAAQ,KAAK,cACnBJ,MAAMK,UAAU,KAAK,YACrBL,MAAMM,OAAO,KAAK,KAClB;QACA,OAAO;IACT;IAEA,2GAA2G;IAC3G,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTopLevelNodeKeys.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getTopLevelNodeKeys.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAEnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.ts"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.ts"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\n\nimport { $getRoot } from 'lexical'\n\nexport function getTopLevelNodeKeys(editor: LexicalEditor): string[] {\n return editor.getEditorState().read(() => $getRoot().getChildrenKeys())\n}\n"],"names":["$getRoot","getTopLevelNodeKeys","editor","getEditorState","read","getChildrenKeys"],"rangeMappings":";;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAElC,OAAO,SAASC,oBAAoBC,MAAqB;IACvD,OAAOA,OAAOC,cAAc,GAAGC,IAAI,CAAC,IAAMJ,WAAWK,eAAe;AACtE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function setHandlePosition(targetElem: HTMLElement | null,
|
|
1
|
+
export declare function setHandlePosition(targetElem: HTMLElement | null, handleElem: HTMLElement, anchorElem: HTMLElement, leftOffset?: number): void;
|
|
2
2
|
//# sourceMappingURL=setHandlePosition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setHandlePosition.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/utils/setHandlePosition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setHandlePosition.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/handles/utils/setHandlePosition.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,WAAW,GAAG,IAAI,EAC9B,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,WAAW,EACvB,UAAU,GAAE,MAAU,QAkCvB"}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import { doesLineHeightAffectElement } from './doesLineHeightAffectElement.js';
|
|
2
|
+
export function setHandlePosition(targetElem, handleElem, anchorElem, leftOffset = 0) {
|
|
2
3
|
if (!targetElem) {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
handleElem.style.opacity = '0';
|
|
5
|
+
handleElem.style.transform = 'translate(-10000px, -10000px)';
|
|
5
6
|
return;
|
|
6
7
|
}
|
|
7
8
|
const targetRect = targetElem.getBoundingClientRect();
|
|
8
9
|
const targetStyle = window.getComputedStyle(targetElem);
|
|
9
|
-
const floatingElemRect =
|
|
10
|
+
const floatingElemRect = handleElem.getBoundingClientRect();
|
|
10
11
|
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
11
|
-
|
|
12
|
+
let top;
|
|
13
|
+
const shouldDisplayHandleInCenter = targetRect.height < 60;
|
|
14
|
+
if (!shouldDisplayHandleInCenter) {
|
|
15
|
+
// No need to let line height affect the re-positioning of the floating element if line height has no
|
|
16
|
+
// visual effect on the element. Otherwise, the floating element will be positioned incorrectly.
|
|
17
|
+
const actualLineHeight = doesLineHeightAffectElement(targetElem) ? parseInt(targetStyle.lineHeight, 10) : 0;
|
|
18
|
+
top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top;
|
|
19
|
+
} else {
|
|
20
|
+
top = targetRect.top - floatingElemRect.height / 2 - anchorElementRect.top + targetRect.height / 2;
|
|
21
|
+
}
|
|
12
22
|
const left = leftOffset;
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
handleElem.style.opacity = '1';
|
|
24
|
+
handleElem.style.transform = `translate(${left}px, ${top}px)`;
|
|
15
25
|
}
|
|
16
26
|
|
|
17
27
|
//# sourceMappingURL=setHandlePosition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/utils/setHandlePosition.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/handles/utils/setHandlePosition.ts"],"sourcesContent":["import { doesLineHeightAffectElement } from './doesLineHeightAffectElement.js'\n\nexport function setHandlePosition(\n targetElem: HTMLElement | null,\n handleElem: HTMLElement,\n anchorElem: HTMLElement,\n leftOffset: number = 0, // SPACE\n) {\n if (!targetElem) {\n handleElem.style.opacity = '0'\n handleElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const targetRect = targetElem.getBoundingClientRect()\n const targetStyle = window.getComputedStyle(targetElem)\n const floatingElemRect = handleElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n\n let top: number\n\n const shouldDisplayHandleInCenter = targetRect.height < 60\n\n if (!shouldDisplayHandleInCenter) {\n // No need to let line height affect the re-positioning of the floating element if line height has no\n // visual effect on the element. Otherwise, the floating element will be positioned incorrectly.\n const actualLineHeight = doesLineHeightAffectElement(targetElem)\n ? parseInt(targetStyle.lineHeight, 10)\n : 0\n\n top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top\n } else {\n top =\n targetRect.top - floatingElemRect.height / 2 - anchorElementRect.top + targetRect.height / 2\n }\n\n const left = leftOffset\n\n handleElem.style.opacity = '1'\n handleElem.style.transform = `translate(${left}px, ${top}px)`\n}\n"],"names":["doesLineHeightAffectElement","setHandlePosition","targetElem","handleElem","anchorElem","leftOffset","style","opacity","transform","targetRect","getBoundingClientRect","targetStyle","window","getComputedStyle","floatingElemRect","anchorElementRect","top","shouldDisplayHandleInCenter","height","actualLineHeight","parseInt","lineHeight","left"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,2BAA2B,QAAQ,mCAAkC;AAE9E,OAAO,SAASC,kBACdC,UAA8B,EAC9BC,UAAuB,EACvBC,UAAuB,EACvBC,aAAqB,CAAC;IAEtB,IAAI,CAACH,YAAY;QACfC,WAAWG,KAAK,CAACC,OAAO,GAAG;QAC3BJ,WAAWG,KAAK,CAACE,SAAS,GAAG;QAC7B;IACF;IAEA,MAAMC,aAAaP,WAAWQ,qBAAqB;IACnD,MAAMC,cAAcC,OAAOC,gBAAgB,CAACX;IAC5C,MAAMY,mBAAmBX,WAAWO,qBAAqB;IACzD,MAAMK,oBAAoBX,WAAWM,qBAAqB;IAE1D,IAAIM;IAEJ,MAAMC,8BAA8BR,WAAWS,MAAM,GAAG;IAExD,IAAI,CAACD,6BAA6B;QAChC,qGAAqG;QACrG,gGAAgG;QAChG,MAAME,mBAAmBnB,4BAA4BE,cACjDkB,SAAST,YAAYU,UAAU,EAAE,MACjC;QAEJL,MAAMP,WAAWO,GAAG,GAAG,AAACG,CAAAA,mBAAmBL,iBAAiBI,MAAM,AAAD,IAAK,IAAIH,kBAAkBC,GAAG;IACjG,OAAO;QACLA,MACEP,WAAWO,GAAG,GAAGF,iBAAiBI,MAAM,GAAG,IAAIH,kBAAkBC,GAAG,GAAGP,WAAWS,MAAM,GAAG;IAC/F;IAEA,MAAMI,OAAOjB;IAEbF,WAAWG,KAAK,CAACC,OAAO,GAAG;IAC3BJ,WAAWG,KAAK,CAACE,SAAS,GAAG,CAAC,UAAU,EAAEc,KAAK,IAAI,EAAEN,IAAI,GAAG,CAAC;AAC/D"}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
&__quote {
|
|
19
|
-
margin: 0;
|
|
20
|
-
margin-left: 20px;
|
|
21
|
-
margin-bottom: 10px;
|
|
19
|
+
margin: 0 0 10px 20px;
|
|
22
20
|
font-size: 15px;
|
|
23
21
|
color: rgb(101, 103, 107);
|
|
24
22
|
border-left-color: rgb(206, 208, 212);
|
|
@@ -115,9 +113,7 @@
|
|
|
115
113
|
padding: 8px 8px 8px 52px;
|
|
116
114
|
line-height: 1.53;
|
|
117
115
|
font-size: 13px;
|
|
118
|
-
margin: 0;
|
|
119
|
-
margin-top: 8px;
|
|
120
|
-
margin-bottom: 8px;
|
|
116
|
+
margin: 8px 0;
|
|
121
117
|
tab-size: 2;
|
|
122
118
|
/* white-space: pre; */
|
|
123
119
|
overflow-x: auto;
|
|
@@ -292,8 +288,7 @@
|
|
|
292
288
|
|
|
293
289
|
&__ol1 {
|
|
294
290
|
padding: 0;
|
|
295
|
-
|
|
296
|
-
list-style-position: inside;
|
|
291
|
+
list-style-position: outside;
|
|
297
292
|
margin: 0 0 1.5em;
|
|
298
293
|
}
|
|
299
294
|
|
|
@@ -301,38 +296,42 @@
|
|
|
301
296
|
padding: 0;
|
|
302
297
|
margin: 0;
|
|
303
298
|
list-style-type: upper-alpha;
|
|
304
|
-
list-style-position:
|
|
299
|
+
list-style-position: outside;
|
|
305
300
|
}
|
|
306
301
|
|
|
307
302
|
&__ol3 {
|
|
308
303
|
padding: 0;
|
|
309
304
|
margin: 0;
|
|
310
305
|
list-style-type: lower-alpha;
|
|
311
|
-
list-style-position:
|
|
306
|
+
list-style-position: outside;
|
|
312
307
|
}
|
|
313
308
|
|
|
314
309
|
&__ol4 {
|
|
315
310
|
padding: 0;
|
|
316
311
|
margin: 0;
|
|
317
312
|
list-style-type: upper-roman;
|
|
318
|
-
list-style-position:
|
|
313
|
+
list-style-position: outside;
|
|
319
314
|
}
|
|
320
315
|
|
|
321
316
|
&__ol5 {
|
|
322
317
|
padding: 0;
|
|
323
318
|
margin: 0;
|
|
324
319
|
list-style-type: lower-roman;
|
|
325
|
-
list-style-position:
|
|
320
|
+
list-style-position: outside;
|
|
326
321
|
}
|
|
327
322
|
|
|
328
323
|
&__ul {
|
|
329
324
|
padding: 0;
|
|
330
325
|
margin: 0 0 1.5em;
|
|
331
|
-
list-style-position:
|
|
326
|
+
list-style-position: outside;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
&__ul ul {
|
|
330
|
+
margin: 0;
|
|
332
331
|
}
|
|
333
332
|
|
|
334
333
|
&__listItem {
|
|
335
|
-
margin: 0
|
|
334
|
+
margin: 0 0 0.4em 16px;
|
|
336
335
|
}
|
|
337
336
|
|
|
338
337
|
&__listItemChecked,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEditable.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/ui/ContentEditable.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ContentEditable.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/ui/ContentEditable.tsx"],"names":[],"mappings":";AAGA,OAAO,wBAAwB,CAAA;AAE/B,wBAAgB,sBAAsB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAEzF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { ContentEditable } = lexicalContentEditableImport;
|
|
1
|
+
import { ContentEditable } from '@lexical/react/LexicalContentEditable.js';
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import './ContentEditable.scss';
|
|
5
4
|
export function LexicalContentEditable({ className }) {
|