@payloadcms/richtext-lexical 3.0.0-canary.ff8c8fd → 3.0.0
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/LICENSE.md +1 -1
- package/dist/cell/rscEntry.d.ts +12 -0
- package/dist/cell/rscEntry.d.ts.map +1 -0
- package/dist/cell/rscEntry.js +82 -0
- package/dist/cell/rscEntry.js.map +1 -0
- package/dist/exports/client/Field-KKSJXHR7.js +2 -0
- package/dist/exports/client/Field-KKSJXHR7.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-2RT3YXUT.js +2 -0
- package/dist/exports/client/RelationshipComponent-2RT3YXUT.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-2CYU43GM.js +2 -0
- package/dist/exports/client/chunk-2CYU43GM.js.map +7 -0
- package/dist/exports/client/chunk-5PBXL4HT.js +2 -0
- package/dist/exports/client/chunk-5PBXL4HT.js.map +7 -0
- package/dist/exports/client/chunk-C7S3V4EB.js +2 -0
- package/dist/exports/client/chunk-C7S3V4EB.js.map +7 -0
- package/dist/exports/client/chunk-CUIBIFW2.js +2 -0
- package/dist/exports/client/chunk-CUIBIFW2.js.map +7 -0
- package/dist/exports/client/{chunk-UJDWBQ2K.js → chunk-MI5HS4QX.js} +2 -2
- package/dist/exports/client/{chunk-UJDWBQ2K.js.map → chunk-MI5HS4QX.js.map} +2 -2
- package/dist/exports/client/chunk-QPPOQTHD.js +2 -0
- package/dist/exports/client/chunk-QPPOQTHD.js.map +7 -0
- package/dist/exports/client/chunk-U7O7EYCP.js +2 -0
- package/dist/exports/client/chunk-U7O7EYCP.js.map +7 -0
- package/dist/exports/client/{chunk-V2LKLT2F.js → chunk-XCEM47RI.js} +3 -3
- package/dist/exports/client/{chunk-V2LKLT2F.js.map → chunk-XCEM47RI.js.map} +3 -3
- package/dist/exports/client/component-ANB7VZLA.js +2 -0
- package/dist/exports/client/component-ANB7VZLA.js.map +7 -0
- package/dist/exports/client/component-H3EYQ5KG.js +2 -0
- package/dist/exports/client/component-H3EYQ5KG.js.map +7 -0
- package/dist/exports/client/componentInline-ZGO3K4TA.js +2 -0
- package/dist/exports/client/componentInline-ZGO3K4TA.js.map +7 -0
- package/dist/exports/client/index.d.ts +10 -4
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -8
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/ast/mdx.d.ts +7 -0
- package/dist/exports/server/ast/mdx.d.ts.map +1 -0
- package/dist/exports/server/ast/mdx.js +37 -0
- package/dist/exports/server/ast/mdx.js.map +1 -0
- package/dist/exports/server/rsc.d.ts +3 -0
- package/dist/exports/server/rsc.d.ts.map +1 -0
- package/dist/exports/server/rsc.js +3 -0
- package/dist/exports/server/rsc.js.map +1 -0
- package/dist/exports/shared.d.ts +4 -0
- package/dist/exports/shared.d.ts.map +1 -0
- package/dist/exports/shared.js +4 -0
- package/dist/exports/shared.js.map +1 -0
- package/dist/features/align/client/index.d.ts +1 -4
- package/dist/features/align/client/index.d.ts.map +1 -1
- package/dist/features/blockquote/client/index.d.ts +1 -4
- package/dist/features/blockquote/client/index.d.ts.map +1 -1
- package/dist/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/features/blockquote/server/index.d.ts +1 -1
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js +5 -1
- package/dist/features/blockquote/server/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.d.ts +34 -8
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +66 -170
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +11 -0
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -0
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +37 -0
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.d.ts +3 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.d.ts.map +1 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.js +22 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts +3 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts.map +1 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +22 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -0
- package/dist/features/blocks/client/component/index.d.ts +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +294 -93
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +5 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +28 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts +3 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +22 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts +3 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +22 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts +3 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +22 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -0
- package/dist/features/blocks/client/componentInline/index.d.ts +14 -2
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +237 -63
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts +1 -8
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +140 -147
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +16 -0
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdownTransformer.js +144 -0
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/plugin/commands.d.ts +0 -4
- package/dist/features/blocks/client/plugin/commands.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/commands.js +0 -1
- package/dist/features/blocks/client/plugin/commands.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts +3 -4
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +25 -129
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +1 -2
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +72 -35
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts +22 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js +136 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.js +400 -0
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +11 -5
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +3 -3
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js +8 -5
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.d.ts.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.js +4 -0
- package/dist/features/converters/html/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/html/converter/converters/text.d.ts.map +1 -1
- package/dist/features/converters/html/converter/converters/text.js +2 -1
- package/dist/features/converters/html/converter/converters/text.js.map +1 -1
- package/dist/features/converters/html/converter/index.d.ts +11 -7
- package/dist/features/converters/html/converter/index.d.ts.map +1 -1
- package/dist/features/converters/html/converter/index.js +17 -1
- package/dist/features/converters/html/converter/index.js.map +1 -1
- package/dist/features/converters/html/converter/types.d.ts +3 -1
- package/dist/features/converters/html/converter/types.d.ts.map +1 -1
- package/dist/features/converters/html/converter/types.js.map +1 -1
- package/dist/features/converters/html/field/index.d.ts.map +1 -1
- package/dist/features/converters/html/field/index.js +7 -1
- package/dist/features/converters/html/field/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/index.d.ts +1 -4
- package/dist/features/debug/testRecorder/client/index.d.ts.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +25 -14
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/index.d.ts +1 -4
- package/dist/features/debug/treeView/client/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/index.d.ts +1 -1
- package/dist/features/experimental_table/client/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/index.js +2 -0
- package/dist/features/experimental_table/client/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +49 -51
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +55 -42
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +58 -19
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +52 -50
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.js +4 -4
- package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
- package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts +5 -0
- package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -0
- package/dist/features/experimental_table/markdownTransformer.js +127 -0
- package/dist/features/experimental_table/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +22 -4
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/format/bold/feature.client.d.ts +1 -4
- package/dist/features/format/bold/feature.client.d.ts.map +1 -1
- package/dist/features/format/bold/feature.client.js +2 -1
- package/dist/features/format/bold/feature.client.js.map +1 -1
- package/dist/features/format/inlineCode/feature.client.d.ts +1 -4
- package/dist/features/format/inlineCode/feature.client.d.ts.map +1 -1
- package/dist/features/format/inlineCode/feature.client.js +2 -1
- package/dist/features/format/inlineCode/feature.client.js.map +1 -1
- package/dist/features/format/italic/feature.client.d.ts +1 -4
- package/dist/features/format/italic/feature.client.d.ts.map +1 -1
- package/dist/features/format/italic/feature.client.js +2 -1
- package/dist/features/format/italic/feature.client.js.map +1 -1
- package/dist/features/format/strikethrough/feature.client.d.ts +1 -4
- package/dist/features/format/strikethrough/feature.client.d.ts.map +1 -1
- package/dist/features/format/strikethrough/feature.client.js +2 -1
- package/dist/features/format/strikethrough/feature.client.js.map +1 -1
- package/dist/features/format/subscript/feature.client.d.ts +1 -4
- package/dist/features/format/subscript/feature.client.d.ts.map +1 -1
- package/dist/features/format/subscript/feature.client.js +2 -1
- package/dist/features/format/subscript/feature.client.js.map +1 -1
- package/dist/features/format/superscript/feature.client.d.ts +1 -4
- package/dist/features/format/superscript/feature.client.d.ts.map +1 -1
- package/dist/features/format/superscript/feature.client.js +2 -1
- package/dist/features/format/superscript/feature.client.js.map +1 -1
- package/dist/features/format/underline/feature.client.d.ts +1 -4
- package/dist/features/format/underline/feature.client.d.ts.map +1 -1
- package/dist/features/format/underline/feature.client.js +2 -1
- package/dist/features/format/underline/feature.client.js.map +1 -1
- package/dist/features/heading/client/index.d.ts +1 -4
- package/dist/features/heading/client/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +4 -0
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/horizontalRule/client/component/index.d.ts +1 -1
- package/dist/features/horizontalRule/client/component/index.d.ts.map +1 -1
- package/dist/features/horizontalRule/client/component/index.js +12 -9
- package/dist/features/horizontalRule/client/component/index.js.map +1 -1
- package/dist/features/horizontalRule/client/index.d.ts +1 -4
- package/dist/features/horizontalRule/client/index.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +2 -2
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/indent/client/index.d.ts +1 -4
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +2 -1
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/link/client/index.d.ts +1 -13
- package/dist/features/link/client/index.d.ts.map +1 -1
- package/dist/features/link/client/index.js +2 -2
- package/dist/features/link/client/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js +3 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +78 -40
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +2 -2
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +12 -7
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/nodes/types.d.ts +3 -3
- package/dist/features/link/nodes/types.d.ts.map +1 -1
- package/dist/features/link/nodes/types.js.map +1 -1
- package/dist/features/link/server/baseFields.d.ts +1 -1
- package/dist/features/link/server/baseFields.d.ts.map +1 -1
- package/dist/features/link/server/baseFields.js +15 -3
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/link/server/i18n.d.ts.map +1 -1
- package/dist/features/link/server/i18n.js +64 -32
- package/dist/features/link/server/i18n.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +17 -4
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/transformExtraFields.d.ts +1 -1
- package/dist/features/link/server/transformExtraFields.d.ts.map +1 -1
- package/dist/features/link/server/transformExtraFields.js.map +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js +8 -5
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/lists/checklist/client/index.d.ts +1 -4
- package/dist/features/lists/checklist/client/index.d.ts.map +1 -1
- package/dist/features/lists/htmlConverter.d.ts.map +1 -1
- package/dist/features/lists/htmlConverter.js +8 -0
- package/dist/features/lists/htmlConverter.js.map +1 -1
- package/dist/features/lists/orderedList/client/index.d.ts +1 -4
- package/dist/features/lists/orderedList/client/index.d.ts.map +1 -1
- package/dist/features/lists/shared/markdown.js.map +1 -1
- package/dist/features/lists/unorderedList/client/index.d.ts +1 -4
- package/dist/features/lists/unorderedList/client/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.js +1 -0
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/feature.client.d.ts +1 -4
- package/dist/features/migrations/lexicalPluginToLexical/feature.client.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/blockquote/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/listItem/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/orderedList/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/unknown/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/unorderedList/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.js +1 -0
- package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/feature.client.d.ts +1 -4
- package/dist/features/migrations/slateToLexical/feature.client.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/feature.client.js +1 -3
- package/dist/features/migrations/slateToLexical/feature.client.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/paragraph/client/index.d.ts +1 -4
- package/dist/features/paragraph/client/index.d.ts.map +1 -1
- package/dist/features/paragraph/server/index.d.ts +1 -1
- package/dist/features/paragraph/server/index.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +34 -24
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +27 -26
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/index.d.ts +2 -17
- package/dist/features/relationship/client/index.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/features/relationship/server/index.d.ts +1 -1
- package/dist/features/relationship/server/index.d.ts.map +1 -1
- package/dist/features/relationship/server/index.js +50 -40
- package/dist/features/relationship/server/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +2 -2
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +93 -66
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/fixed/client/index.d.ts +1 -4
- package/dist/features/toolbars/fixed/client/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +135 -97
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/index.d.ts +1 -4
- package/dist/features/toolbars/inline/client/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +5 -2
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +5 -4
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +24 -10
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +4 -5
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +127 -127
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/types.d.ts +23 -11
- package/dist/features/toolbars/types.d.ts.map +1 -1
- package/dist/features/toolbars/types.js.map +1 -1
- package/dist/features/typesClient.d.ts +22 -30
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts +23 -28
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +66 -58
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
- package/dist/features/upload/client/drawer/index.js +34 -32
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/feature.client.d.ts +1 -4
- package/dist/features/upload/client/feature.client.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/feature.server.d.ts.map +1 -1
- package/dist/features/upload/server/feature.server.js +17 -8
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js +7 -4
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +39 -65
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +74 -74
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +9 -0
- package/dist/field/rscEntry.d.ts.map +1 -0
- package/dist/field/rscEntry.js +56 -0
- package/dist/field/rscEntry.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -105
- package/dist/index.js.map +1 -1
- package/dist/lexical/EditorPlugin.d.ts.map +1 -1
- package/dist/lexical/EditorPlugin.js +2 -1
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +10 -10
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts +2 -2
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +18 -25
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +6 -5
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +14 -13
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts +5 -2
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +12 -18
- package/dist/lexical/config/client/loader.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +19 -18
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/loader.d.ts +2 -1
- package/dist/lexical/config/server/loader.d.ts.map +1 -1
- package/dist/lexical/config/server/loader.js +2 -0
- package/dist/lexical/config/server/loader.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +27 -13
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +2 -2
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +4 -0
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +8 -1
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +6 -6
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +19 -8
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +2 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +7 -7
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +3 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +24 -30
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +11 -9
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +15 -8
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +9 -7
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +3 -1
- package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js +3 -4
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +1 -2
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/lexical/utils/nodeFormat.d.ts +2 -2
- package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
- package/dist/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/lexical/utils/rect.d.ts +4 -4
- package/dist/lexical/utils/rect.d.ts.map +1 -1
- package/dist/lexical/utils/rect.js.map +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.d.ts +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/lexical/utils/url.d.ts +5 -0
- package/dist/lexical/utils/url.d.ts.map +1 -1
- package/dist/lexical/utils/url.js +25 -5
- package/dist/lexical/utils/url.js.map +1 -1
- package/dist/lexical-proxy/@lexical-headless.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-headless.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-headless.js +2 -0
- package/dist/lexical-proxy/@lexical-headless.js.map +1 -0
- package/dist/lexical-proxy/@lexical-link.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-link.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-link.js +2 -0
- package/dist/lexical-proxy/@lexical-link.js.map +1 -0
- package/dist/lexical-proxy/@lexical-list.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-list.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-list.js +2 -0
- package/dist/lexical-proxy/@lexical-list.js.map +1 -0
- package/dist/lexical-proxy/@lexical-mark.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-mark.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-mark.js +2 -0
- package/dist/lexical-proxy/@lexical-mark.js.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.js +2 -0
- package/dist/lexical-proxy/@lexical-markdown.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.js.map +1 -0
- package/dist/lexical-proxy/@lexical-rich-text.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-rich-text.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-rich-text.js +2 -0
- package/dist/lexical-proxy/@lexical-rich-text.js.map +1 -0
- package/dist/lexical-proxy/@lexical-selection.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-selection.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-selection.js +2 -0
- package/dist/lexical-proxy/@lexical-selection.js.map +1 -0
- package/dist/lexical-proxy/@lexical-utils.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-utils.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-utils.js +2 -0
- package/dist/lexical-proxy/@lexical-utils.js.map +1 -0
- package/dist/lexical-proxy/lexical.d.ts +2 -0
- package/dist/lexical-proxy/lexical.d.ts.map +1 -0
- package/dist/lexical-proxy/lexical.js +2 -0
- package/dist/lexical-proxy/lexical.js.map +1 -0
- package/dist/populateGraphQL/populate.d.ts +3 -2
- package/dist/populateGraphQL/populate.d.ts.map +1 -1
- package/dist/populateGraphQL/populate.js +3 -1
- package/dist/populateGraphQL/populate.js.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js +5 -4
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
- package/dist/types.d.ts +23 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +27 -0
- package/dist/utilities/buildInitialState.d.ts.map +1 -0
- package/dist/utilities/buildInitialState.js +53 -0
- package/dist/utilities/buildInitialState.js.map +1 -0
- package/dist/utilities/createClientFeature.d.ts +8 -5
- package/dist/utilities/createClientFeature.d.ts.map +1 -1
- package/dist/utilities/createClientFeature.js +7 -4
- package/dist/utilities/createClientFeature.js.map +1 -1
- package/dist/utilities/createServerFeature.d.ts +1 -0
- package/dist/utilities/createServerFeature.d.ts.map +1 -1
- package/dist/utilities/createServerFeature.js +2 -0
- package/dist/utilities/createServerFeature.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.d.ts +1 -0
- package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +68 -27
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +102 -138
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.d.ts +13 -0
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.d.ts.map +1 -0
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +129 -0
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -0
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts +10 -0
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -0
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +136 -0
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -0
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.d.ts +16 -0
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.d.ts.map +1 -0
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +144 -0
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -0
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +2 -3
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
- package/dist/utilities/generateSchemaMap.js +13 -10
- package/dist/utilities/generateSchemaMap.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts +18 -0
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -0
- package/dist/utilities/initLexicalFeatures.js +96 -0
- package/dist/utilities/initLexicalFeatures.js.map +1 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts +52 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts.map +1 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +79 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.d.ts +12 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.d.ts.map +1 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js +125 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js.map +1 -0
- package/dist/utilities/jsx/jsx.d.ts +26 -0
- package/dist/utilities/jsx/jsx.d.ts.map +1 -0
- package/dist/utilities/jsx/jsx.js +105 -0
- package/dist/utilities/jsx/jsx.js.map +1 -0
- package/dist/utilities/jsx/jsx.spec.d.ts +2 -0
- package/dist/utilities/jsx/jsx.spec.d.ts.map +1 -0
- package/dist/utilities/jsx/jsx.spec.js +142 -0
- package/dist/utilities/jsx/jsx.spec.js.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts +11 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.js +61 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +1 -0
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +5 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/useLexicalFeature.d.ts.map +1 -1
- package/dist/utilities/useLexicalFeature.js +12 -4
- package/dist/utilities/useLexicalFeature.js.map +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +2 -2
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/validateNodes.d.ts +2 -2
- package/dist/validate/validateNodes.d.ts.map +1 -1
- package/dist/validate/validateNodes.js +4 -4
- package/dist/validate/validateNodes.js.map +1 -1
- package/package.json +332 -46
- package/dist/cell/index.d.ts +0 -9
- package/dist/cell/index.d.ts.map +0 -1
- package/dist/cell/index.js +0 -135
- package/dist/cell/index.js.map +0 -1
- package/dist/exports/client/Field-SUWHJ4HF.js +0 -2
- package/dist/exports/client/Field-SUWHJ4HF.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js +0 -2
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js.map +0 -7
- package/dist/exports/client/chunk-OLSILJA6.js +0 -2
- package/dist/exports/client/chunk-OLSILJA6.js.map +0 -7
- package/dist/exports/client/chunk-TD7O23AB.js +0 -2
- package/dist/exports/client/chunk-TD7O23AB.js.map +0 -7
- package/dist/exports/client/chunk-YL453UOS.js +0 -2
- package/dist/exports/client/chunk-YL453UOS.js.map +0 -7
- package/dist/exports/client/chunk-YSI2QILQ.js +0 -2
- package/dist/exports/client/chunk-YSI2QILQ.js.map +0 -7
- package/dist/exports/client/component-2YLEVOFH.js +0 -2
- package/dist/exports/client/component-2YLEVOFH.js.map +0 -7
- package/dist/exports/client/component-7RAP75FW.js +0 -2
- package/dist/exports/client/component-7RAP75FW.js.map +0 -7
- package/dist/exports/client/component-LLWMZU6K.js +0 -2
- package/dist/exports/client/component-LLWMZU6K.js.map +0 -7
- package/dist/exports/client/componentInline-YSHGRL2J.js +0 -2
- package/dist/exports/client/componentInline-YSHGRL2J.js.map +0 -7
- package/dist/features/blocks/client/component/FormSavePlugin.d.ts +0 -11
- package/dist/features/blocks/client/component/FormSavePlugin.d.ts.map +0 -1
- package/dist/features/blocks/client/component/FormSavePlugin.js +0 -53
- package/dist/features/blocks/client/component/FormSavePlugin.js.map +0 -1
- package/dist/features/createClientComponent.d.ts +0 -7
- package/dist/features/createClientComponent.d.ts.map +0 -1
- package/dist/features/createClientComponent.js +0 -13
- package/dist/features/createClientComponent.js.map +0 -1
- package/dist/features/createFeaturePropComponent.d.ts +0 -6
- package/dist/features/createFeaturePropComponent.d.ts.map +0 -1
- package/dist/features/createFeaturePropComponent.js +0 -19
- package/dist/features/createFeaturePropComponent.js.map +0 -1
- package/dist/utilities/generateComponentMap.d.ts +0 -6
- package/dist/utilities/generateComponentMap.d.ts.map +0 -1
- package/dist/utilities/generateComponentMap.js +0 -99
- package/dist/utilities/generateComponentMap.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","createCommand","useCallback","useEffect","useState","React","LexicalMenu","useMenuAnchorRef","PUNCTUATION","getTextUpToAnchor","selection","anchor","type","anchorNode","getNode","isSimpleText","anchorOffset","offset","getTextContent","slice","tryToPositionRange","leadOffset","range","editorWindow","domSelection","getSelection","isCollapsed","startOffset","endOffset","setStart","setEnd","error","getQueryTextForSearch","editor","text","getEditorState","read","isSelectionOnEntityBoundary","prevSibling","getPreviousSibling","isTextEntity","startTransition","callback","useDynamicPositioning","ENABLE_SLASH_MENU_COMMAND","LexicalTypeaheadMenuPlugin","t0","$","anchorClassName","anchorElem","groups","menuRenderFn","onClose","onOpen","onQueryChange","onSelectItem","triggerFn","resolution","setResolution","anchorElementRef","t1","closeTypeahead","t2","res","openTypeahead","t3","t4","registerCommand","t5","node","match","matchingString","replaceableString","_window","window","document","createRange","isRangePositioned","getRect","getBoundingClientRect","updateListener","editorWindow_0","range_0","match_0","query","isRangePositioned_0","removeUpdateListener","registerUpdateListener","t6","t7","_jsx","close","shouldSplitNodeWithQuery"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type {\n LexicalCommand,\n LexicalEditor,\n ParagraphNode,\n RangeSelection,\n TextNode,\n} from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n createCommand,\n} from 'lexical'\nimport { type JSX, useCallback, useEffect, useState } from 'react'\nimport * as React from 'react'\n\nimport type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js'\nimport type { MenuRenderFn, MenuResolution } from './LexicalMenu.js'\nimport type { SlashMenuGroupInternal, SlashMenuItem } from './types.js'\n\nimport { LexicalMenu, useMenuAnchorRef } from './LexicalMenu.js'\n\nexport const PUNCTUATION = '\\\\.,\\\\+\\\\*\\\\?\\\\$\\\\@\\\\|#{}\\\\(\\\\)\\\\^\\\\-\\\\[\\\\]\\\\\\\\/!%\\'\"~=<>_:;'\n\nfunction getTextUpToAnchor(selection: RangeSelection): null | string {\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const anchorOffset = anchor.offset\n return anchorNode.getTextContent().slice(0, anchorOffset)\n}\n\nfunction tryToPositionRange(leadOffset: number, range: Range, editorWindow: Window): boolean {\n const domSelection = editorWindow.getSelection()\n if (domSelection === null || !domSelection.isCollapsed) {\n return false\n }\n const anchorNode = domSelection.anchorNode\n const startOffset = leadOffset\n const endOffset = domSelection.anchorOffset\n\n if (anchorNode == null || endOffset == null) {\n return false\n }\n\n try {\n range.setStart(anchorNode, startOffset)\n // if endOffset is 0, positioning the range for when you click the plus button to open the slash menu will fial\n range.setEnd(anchorNode, endOffset > 1 ? endOffset : 1)\n } catch (error) {\n return false\n }\n\n return true\n}\n\nfunction getQueryTextForSearch(editor: LexicalEditor): null | string {\n let text = null\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return\n }\n text = getTextUpToAnchor(selection)\n })\n return text\n}\n\nfunction isSelectionOnEntityBoundary(editor: LexicalEditor, offset: number): boolean {\n if (offset !== 0) {\n return false\n }\n return editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor\n const anchorNode = anchor.getNode()\n const prevSibling = anchorNode.getPreviousSibling()\n return $isTextNode(prevSibling) && prevSibling.isTextEntity()\n }\n return false\n })\n}\n\nfunction startTransition(callback: () => void) {\n if (React.startTransition) {\n React.startTransition(callback)\n } else {\n callback()\n }\n}\n\nexport { useDynamicPositioning } from './LexicalMenu.js'\n\nexport type TypeaheadMenuPluginProps = {\n anchorClassName?: string\n anchorElem: HTMLElement\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n onClose?: () => void\n onOpen?: (resolution: MenuResolution) => void\n onQueryChange: (matchingString: null | string) => void\n onSelectItem: (\n item: SlashMenuItem,\n textNodeContainingQuery: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => void\n triggerFn: TriggerFn\n}\n\nexport const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{\n node: ParagraphNode\n}> = createCommand('ENABLE_SLASH_MENU_COMMAND')\n\nexport function LexicalTypeaheadMenuPlugin({\n anchorClassName,\n anchorElem,\n groups,\n menuRenderFn,\n onClose,\n onOpen,\n onQueryChange,\n onSelectItem,\n triggerFn,\n}: TypeaheadMenuPluginProps): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const [resolution, setResolution] = useState<MenuResolution | null>(null)\n const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName)\n\n const closeTypeahead = useCallback(() => {\n setResolution(null)\n if (onClose != null && resolution !== null) {\n onClose()\n }\n }, [onClose, resolution])\n\n const openTypeahead = useCallback(\n (res: MenuResolution) => {\n setResolution(res)\n if (onOpen != null && resolution === null) {\n onOpen(res)\n }\n },\n [onOpen, resolution],\n )\n\n // This is mainly used for the AddBlockHandlePlugin, so that the slash menu can be opened from there\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n ENABLE_SLASH_MENU_COMMAND,\n ({ node }) => {\n editor.getEditorState().read(() => {\n const match: MenuTextMatch = {\n leadOffset: 0,\n matchingString: '',\n replaceableString: '',\n }\n if (!isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n if (node !== null) {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n }\n\n return\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, openTypeahead])\n\n useEffect(() => {\n const updateListener = () => {\n editor.getEditorState().read(() => {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n const selection = $getSelection()\n const text = getQueryTextForSearch(editor)\n\n if (\n !$isRangeSelection(selection) ||\n !selection.isCollapsed() ||\n text === null ||\n range === null\n ) {\n closeTypeahead()\n return\n }\n\n const match = triggerFn({ editor, query: text })\n onQueryChange(match ? match.matchingString : null)\n\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n return\n }\n }\n closeTypeahead()\n })\n }\n\n const removeUpdateListener = editor.registerUpdateListener(updateListener)\n\n return () => {\n removeUpdateListener()\n }\n }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead])\n\n return resolution === null || editor === null ? null : (\n <LexicalMenu\n anchorElementRef={anchorElementRef}\n close={closeTypeahead}\n editor={editor}\n groups={groups}\n menuRenderFn={menuRenderFn}\n onSelectItem={onSelectItem}\n resolution={resolution}\n shouldSplitNodeWithQuery\n />\n )\n}\n\nexport type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn }\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AASA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,QAAQ;AAC9B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,oBAAoB,EACpBC,aAAa,QACR;AACP,SAAmBC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAC3D,YAAYC,KAAA,MAAW;AAMvB,SAASC,WAAW,EAAEC,gBAAgB,QAAQ;AAE9C,OAAO,MAAMC,WAAA,GAAc;AAE3B,SAASC,kBAAkBC,SAAyB;EAClD,MAAMC,MAAA,GAASD,SAAA,CAAUC,MAAM;EAC/B,IAAIA,MAAA,CAAOC,IAAI,KAAK,QAAQ;IAC1B,OAAO;EACT;EACA,MAAMC,UAAA,GAAaF,MAAA,CAAOG,OAAO;EACjC,IAAI,CAACD,UAAA,CAAWE,YAAY,IAAI;IAC9B,OAAO;EACT;EACA,MAAMC,YAAA,GAAeL,MAAA,CAAOM,MAAM;EAClC,OAAOJ,UAAA,CAAWK,cAAc,GAAGC,KAAK,CAAC,GAAGH,YAAA;AAC9C;AAEA,SAASI,mBAAmBC,UAAkB,EAAEC,KAAY,EAAEC,YAAoB;EAChF,MAAMC,YAAA,GAAeD,YAAA,CAAaE,YAAY;EAC9C,IAAID,YAAA,KAA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ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","createCommand","useCallback","useEffect","useState","React","LexicalMenu","useMenuAnchorRef","PUNCTUATION","getTextUpToAnchor","selection","anchor","type","anchorNode","getNode","isSimpleText","anchorOffset","offset","getTextContent","slice","tryToPositionRange","leadOffset","range","editorWindow","domSelection","getSelection","isCollapsed","startOffset","endOffset","setStart","setEnd","error","getQueryTextForSearch","editor","text","getEditorState","read","isSelectionOnEntityBoundary","prevSibling","getPreviousSibling","isTextEntity","startTransition","callback","useDynamicPositioning","ENABLE_SLASH_MENU_COMMAND","LexicalTypeaheadMenuPlugin","t0","$","anchorClassName","anchorElem","groups","menuRenderFn","onClose","onOpen","onQueryChange","onSelectItem","triggerFn","resolution","setResolution","anchorElementRef","t1","closeTypeahead","t2","res","openTypeahead","t3","t4","registerCommand","t5","node","match","matchingString","replaceableString","_window","window","document","createRange","isRangePositioned","getRect","getBoundingClientRect","updateListener","editorWindow_0","range_0","undefined","match_0","query","isRangePositioned_0","removeUpdateListener","registerUpdateListener","t6","t7","current","_jsx","close","shouldSplitNodeWithQuery"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type {\n LexicalCommand,\n LexicalEditor,\n ParagraphNode,\n RangeSelection,\n TextNode,\n} from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n createCommand,\n} from 'lexical'\nimport { type JSX, useCallback, useEffect, useState } from 'react'\nimport * as React from 'react'\n\nimport type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js'\nimport type { MenuRenderFn, MenuResolution } from './LexicalMenu.js'\nimport type { SlashMenuGroupInternal, SlashMenuItem } from './types.js'\n\nimport { LexicalMenu, useMenuAnchorRef } from './LexicalMenu.js'\n\nexport const PUNCTUATION = '\\\\.,\\\\+\\\\*\\\\?\\\\$\\\\@\\\\|#{}\\\\(\\\\)\\\\^\\\\-\\\\[\\\\]\\\\\\\\/!%\\'\"~=<>_:;'\n\nfunction getTextUpToAnchor(selection: RangeSelection): null | string {\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const anchorOffset = anchor.offset\n return anchorNode.getTextContent().slice(0, anchorOffset)\n}\n\nfunction tryToPositionRange(leadOffset: number, range: Range, editorWindow: Window): boolean {\n const domSelection = editorWindow.getSelection()\n if (domSelection === null || !domSelection.isCollapsed) {\n return false\n }\n const anchorNode = domSelection.anchorNode\n const startOffset = leadOffset\n const endOffset = domSelection.anchorOffset\n\n if (anchorNode == null || endOffset == null) {\n return false\n }\n\n try {\n range.setStart(anchorNode, startOffset)\n // if endOffset is 0, positioning the range for when you click the plus button to open the slash menu will fial\n range.setEnd(anchorNode, endOffset > 1 ? endOffset : 1)\n } catch (error) {\n return false\n }\n\n return true\n}\n\nfunction getQueryTextForSearch(editor: LexicalEditor): string | undefined {\n let text\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return\n }\n text = getTextUpToAnchor(selection)\n })\n return text\n}\n\nfunction isSelectionOnEntityBoundary(editor: LexicalEditor, offset: number): boolean {\n if (offset !== 0) {\n return false\n }\n return editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor\n const anchorNode = anchor.getNode()\n const prevSibling = anchorNode.getPreviousSibling()\n return $isTextNode(prevSibling) && prevSibling.isTextEntity()\n }\n return false\n })\n}\n\nfunction startTransition(callback: () => void) {\n if (React.startTransition) {\n React.startTransition(callback)\n } else {\n callback()\n }\n}\n\nexport { useDynamicPositioning } from './LexicalMenu.js'\n\nexport type TypeaheadMenuPluginProps = {\n anchorClassName?: string\n anchorElem: HTMLElement\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n onClose?: () => void\n onOpen?: (resolution: MenuResolution) => void\n onQueryChange: (matchingString: null | string) => void\n onSelectItem: (item: SlashMenuItem, closeMenu: () => void, matchingString: string) => void\n triggerFn: TriggerFn\n}\n\nexport const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{\n node: ParagraphNode\n}> = createCommand('ENABLE_SLASH_MENU_COMMAND')\n\nexport function LexicalTypeaheadMenuPlugin({\n anchorClassName,\n anchorElem,\n groups,\n menuRenderFn,\n onClose,\n onOpen,\n onQueryChange,\n onSelectItem,\n triggerFn,\n}: TypeaheadMenuPluginProps): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const [resolution, setResolution] = useState<MenuResolution | null>(null)\n const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName)\n\n const closeTypeahead = useCallback(() => {\n setResolution(null)\n if (onClose != null && resolution !== null) {\n onClose()\n }\n }, [onClose, resolution])\n\n const openTypeahead = useCallback(\n (res: MenuResolution) => {\n setResolution(res)\n if (onOpen != null && resolution === null) {\n onOpen(res)\n }\n },\n [onOpen, resolution],\n )\n\n // This is mainly used for the AddBlockHandlePlugin, so that the slash menu can be opened from there\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n ENABLE_SLASH_MENU_COMMAND,\n ({ node }) => {\n editor.getEditorState().read(() => {\n const match: MenuTextMatch = {\n leadOffset: 0,\n matchingString: '',\n replaceableString: '',\n }\n if (!isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n if (node !== null) {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n }\n\n return\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, openTypeahead])\n\n useEffect(() => {\n const updateListener = () => {\n editor.getEditorState().read(() => {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n const selection = $getSelection()\n const text = getQueryTextForSearch(editor)\n\n if (\n !$isRangeSelection(selection) ||\n !selection.isCollapsed() ||\n text === undefined ||\n range === null\n ) {\n closeTypeahead()\n return\n }\n\n const match = triggerFn({ editor, query: text })\n onQueryChange(match ? match.matchingString : null)\n\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n return\n }\n }\n closeTypeahead()\n })\n }\n\n const removeUpdateListener = editor.registerUpdateListener(updateListener)\n\n return () => {\n removeUpdateListener()\n }\n }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead])\n\n return anchorElementRef.current === null || resolution === null || editor === null ? null : (\n <LexicalMenu\n anchorElementRef={anchorElementRef}\n close={closeTypeahead}\n editor={editor}\n groups={groups}\n menuRenderFn={menuRenderFn}\n onSelectItem={onSelectItem}\n resolution={resolution}\n shouldSplitNodeWithQuery\n />\n )\n}\n\nexport type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn }\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AASA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,QAAQ;AAC9B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,oBAAoB,EACpBC,aAAa,QACR;AACP,SAAmBC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAC3D,YAAYC,KAAA,MAAW;AAMvB,SAASC,WAAW,EAAEC,gBAAgB,QAAQ;AAE9C,OAAO,MAAMC,WAAA,GAAc;AAE3B,SAASC,kB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qB,EAA6E;EAAA,IAAAC,EAAA;EAAA,IAAA3C,CAAA,SAAAY,gBAAA,IAAAZ,CAAA,SAAAU,UAAA,IAAAV,CAAA,SAAAd,MAAA,IAAAc,CAAA,SAAAc,cAAA,IAAAd,CAAA,SAAAG,MAAA,IAAAH,CAAA,SAAAI,YAAA,IAAAJ,CAAA,SAAAQ,YAAA;IAEzEmC,EAAA,GAAA/B,gBAAA,CAAAgC,OAAA,SAA6B,IAAQlC,UAAA,SAAe,IAAQxB,MAAA,SAAW,UAC5E2D,IAAA,CAAAtF,WAAA;MAAAqD,gBAAA;MAAAkC,KAAA,EAEShC,cAAA;MAAA5B,MAAA;MAAAiB,MAAA;MAAAC,YAAA;MAAAI,YAAA;MAAAE,UAAA;MAAAqC,wBAAA;IAAA,C;;;;;;;;;;;;SAHJJ,E","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@ import type { I18nClient } from '@payloadcms/translations';
|
|
|
2
2
|
import type { LexicalEditor, Spread } from 'lexical';
|
|
3
3
|
import type React from 'react';
|
|
4
4
|
import type { RefObject } from 'react';
|
|
5
|
+
import type { FeatureClientSchemaMap } from '../../../../types.js';
|
|
5
6
|
export type SlashMenuItem = {
|
|
6
7
|
/** The icon which is rendered in your slash menu item. */
|
|
7
8
|
Icon: React.FC;
|
|
@@ -15,8 +16,8 @@ export type SlashMenuItem = {
|
|
|
15
16
|
keywords?: Array<string>;
|
|
16
17
|
/** The label will be displayed in your slash menu item. In order to make use of i18n, this can be a function. */
|
|
17
18
|
label?: ((args: {
|
|
19
|
+
featureClientSchemaMap: FeatureClientSchemaMap;
|
|
18
20
|
i18n: I18nClient<{}, string>;
|
|
19
|
-
richTextComponentMap: Map<string, React.ReactNode>;
|
|
20
21
|
schemaPath: string;
|
|
21
22
|
}) => string) | string;
|
|
22
23
|
/** A function which is called when the slash menu item is selected. */
|
|
@@ -36,8 +37,8 @@ export type SlashMenuGroup = {
|
|
|
36
37
|
key: string;
|
|
37
38
|
/** The label will be displayed before your Slash Menu group. In order to make use of i18n, this can be a function. */
|
|
38
39
|
label?: ((args: {
|
|
40
|
+
featureClientSchemaMap: FeatureClientSchemaMap;
|
|
39
41
|
i18n: I18nClient<{}, string>;
|
|
40
|
-
richTextComponentMap: Map<string, React.ReactNode>;
|
|
41
42
|
schemaPath: string;
|
|
42
43
|
}) => string) | string;
|
|
43
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,MAAM,aAAa,GAAG;IAC1B,0DAA0D;IAC1D,IAAI,EAAE,KAAK,CAAC,EAAE,CAAA;IACd,8JAA8J;IAC9J,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACxB,iHAAiH;IACjH,KAAK,CAAC,EACF,CAAC,CAAC,IAAI,EAAE;QACN,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,sBAAsB,EA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,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { LexicalEditor, Spread } from 'lexical'\nimport type React from 'react'\nimport type { RefObject } from 'react'\n\nexport type SlashMenuItem = {\n /** The icon which is rendered in your slash menu item. */\n Icon: React.FC\n /** Each slash menu item needs to have a unique key. The key will be matched when typing, displayed if no `label` property is set, and used for classNames. */\n key: string\n /**\n * Keywords are used to match the item for different texts typed after the '/'.\n * E.g. you might want to show a horizontal rule item if you type both /hr, /separator, /horizontal etc.\n * In addition to the keywords, the label and key will be used to find the right slash menu item.\n */\n keywords?: Array<string>\n /** The label will be displayed in your slash menu item. In order to make use of i18n, this can be a function. */\n label?:\n | ((args: {\n i18n: I18nClient<{}, string>\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { LexicalEditor, Spread } from 'lexical'\nimport type React from 'react'\nimport type { RefObject } from 'react'\n\nimport type { FeatureClientSchemaMap } from '../../../../types.js'\n\nexport type SlashMenuItem = {\n /** The icon which is rendered in your slash menu item. */\n Icon: React.FC\n /** Each slash menu item needs to have a unique key. The key will be matched when typing, displayed if no `label` property is set, and used for classNames. */\n key: string\n /**\n * Keywords are used to match the item for different texts typed after the '/'.\n * E.g. you might want to show a horizontal rule item if you type both /hr, /separator, /horizontal etc.\n * In addition to the keywords, the label and key will be used to find the right slash menu item.\n */\n keywords?: Array<string>\n /** The label will be displayed in your slash menu item. In order to make use of i18n, this can be a function. */\n label?:\n | ((args: {\n featureClientSchemaMap: FeatureClientSchemaMap\n i18n: I18nClient<{}, string>\n schemaPath: string\n }) => string)\n | string\n /** A function which is called when the slash menu item is selected. */\n onSelect: ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => void\n}\n\nexport type SlashMenuGroup = {\n /**\n * An array of `SlashMenuItem`'s which will be displayed in the slash menu.\n */\n items: Array<SlashMenuItem>\n /**\n * Used for class names and, if label is not provided, for display. Slash menus with the same key will have their items merged together.\n */\n key: string\n /** The label will be displayed before your Slash Menu group. In order to make use of i18n, this can be a function. */\n label?:\n | ((args: {\n featureClientSchemaMap: FeatureClientSchemaMap\n i18n: I18nClient<{}, string>\n schemaPath: string\n }) => string)\n | string\n}\n\nexport type SlashMenuItemInternal = {\n ref: RefObject<HTMLButtonElement | null>\n} & SlashMenuItem\n\nexport type SlashMenuGroupInternal = Spread<\n {\n items: Array<SlashMenuItemInternal>\n },\n SlashMenuGroup\n>\n"],"mappings":"AAqDA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/SlashMenu/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/SlashMenu/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,OAAO,cAAc,CAAA;AA+DrB,wBAAgB,eAAe,CAAC,EAC9B,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAoKrB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
5
|
-
import {
|
|
5
|
+
import { useTranslation } from '@payloadcms/ui';
|
|
6
6
|
import { useCallback, useMemo, useState } from 'react';
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import * as ReactDOM from 'react-dom';
|
|
@@ -17,13 +17,11 @@ function SlashMenuItem({
|
|
|
17
17
|
onMouseEnter
|
|
18
18
|
}) {
|
|
19
19
|
const {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
fieldProps: {
|
|
21
|
+
featureClientSchemaMap,
|
|
22
|
+
schemaPath
|
|
22
23
|
}
|
|
23
24
|
} = useEditorConfigContext();
|
|
24
|
-
const {
|
|
25
|
-
schemaPath
|
|
26
|
-
} = useFieldProps();
|
|
27
25
|
const {
|
|
28
26
|
i18n
|
|
29
27
|
} = useTranslation();
|
|
@@ -34,8 +32,8 @@ function SlashMenuItem({
|
|
|
34
32
|
let title = item.key;
|
|
35
33
|
if (item.label) {
|
|
36
34
|
title = typeof item.label === 'function' ? item.label({
|
|
35
|
+
featureClientSchemaMap,
|
|
37
36
|
i18n,
|
|
38
|
-
richTextComponentMap,
|
|
39
37
|
schemaPath
|
|
40
38
|
}) : item.label;
|
|
41
39
|
}
|
|
@@ -75,24 +73,24 @@ export function SlashMenuPlugin({
|
|
|
75
73
|
i18n
|
|
76
74
|
} = useTranslation();
|
|
77
75
|
const {
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
fieldProps: {
|
|
77
|
+
featureClientSchemaMap,
|
|
78
|
+
schemaPath
|
|
80
79
|
}
|
|
81
80
|
} = useEditorConfigContext();
|
|
82
|
-
const {
|
|
83
|
-
schemaPath
|
|
84
|
-
} = useFieldProps();
|
|
85
81
|
const checkForTriggerMatch = useMenuTriggerMatch('/', {
|
|
86
82
|
minLength: 0
|
|
87
83
|
});
|
|
88
84
|
const getDynamicItems = useCallback(() => {
|
|
89
85
|
let groupWithItems = [];
|
|
90
86
|
for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
if (queryString) {
|
|
88
|
+
const dynamicGroupWithItems = dynamicItem({
|
|
89
|
+
editor,
|
|
90
|
+
queryString
|
|
91
|
+
});
|
|
92
|
+
groupWithItems = groupWithItems.concat(dynamicGroupWithItems);
|
|
93
|
+
}
|
|
96
94
|
}
|
|
97
95
|
return groupWithItems;
|
|
98
96
|
}, [editor, queryString, editorConfig?.features]);
|
|
@@ -103,13 +101,14 @@ export function SlashMenuPlugin({
|
|
|
103
101
|
}
|
|
104
102
|
if (queryString) {
|
|
105
103
|
// Filter current groups first
|
|
104
|
+
// @ts-expect-error - TODO: fix this
|
|
106
105
|
groupsWithItems = groupsWithItems.map(group => {
|
|
107
106
|
const filteredItems = group.items.filter(item => {
|
|
108
107
|
let itemTitle = item.key;
|
|
109
108
|
if (item.label) {
|
|
110
109
|
itemTitle = typeof item.label === 'function' ? item.label({
|
|
110
|
+
featureClientSchemaMap,
|
|
111
111
|
i18n,
|
|
112
|
-
richTextComponentMap,
|
|
113
112
|
schemaPath
|
|
114
113
|
}) : item.label;
|
|
115
114
|
}
|
|
@@ -152,34 +151,29 @@ export function SlashMenuPlugin({
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
return groupsWithItems;
|
|
155
|
-
}, [
|
|
156
|
-
const onSelectItem = useCallback((selectedItem,
|
|
157
|
-
|
|
158
|
-
editor.update(() => {
|
|
159
|
-
nodeToRemove.remove();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
154
|
+
}, [queryString, editorConfig?.features.slashMenu.groups, getDynamicItems, featureClientSchemaMap, i18n, schemaPath]);
|
|
155
|
+
const onSelectItem = useCallback((selectedItem, closeMenu, matchingString) => {
|
|
156
|
+
closeMenu();
|
|
162
157
|
selectedItem.onSelect({
|
|
163
158
|
editor,
|
|
164
159
|
queryString: matchingString
|
|
165
160
|
});
|
|
166
|
-
closeMenu();
|
|
167
161
|
}, [editor]);
|
|
168
162
|
return /*#__PURE__*/_jsx(LexicalTypeaheadMenuPlugin, {
|
|
169
163
|
anchorElem: anchorElem,
|
|
170
164
|
groups: groups,
|
|
171
165
|
menuRenderFn: (anchorElementRef, {
|
|
172
|
-
selectItemAndCleanUp,
|
|
173
166
|
selectedItemKey,
|
|
167
|
+
selectItemAndCleanUp,
|
|
174
168
|
setSelectedItemKey
|
|
175
|
-
}) => anchorElementRef.current && groups.length ? /*#__PURE__*/ReactDOM.createPortal(
|
|
169
|
+
}) => anchorElementRef.current && groups.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/_jsx("div", {
|
|
176
170
|
className: baseClass,
|
|
177
171
|
children: groups.map(group_4 => {
|
|
178
172
|
let groupTitle = group_4.key;
|
|
179
|
-
if (group_4.label) {
|
|
173
|
+
if (group_4.label && featureClientSchemaMap) {
|
|
180
174
|
groupTitle = typeof group_4.label === 'function' ? group_4.label({
|
|
175
|
+
featureClientSchemaMap,
|
|
181
176
|
i18n,
|
|
182
|
-
richTextComponentMap,
|
|
183
177
|
schemaPath
|
|
184
178
|
}) : group_4.label;
|
|
185
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useFieldProps","useTranslation","useCallback","useMemo","useState","React","ReactDOM","useEditorConfigContext","LexicalTypeaheadMenuPlugin","useMenuTriggerMatch","baseClass","SlashMenuItem","isSelected","item","onClick","onMouseEnter","field","richTextComponentMap","schemaPath","i18n","className","key","title","label","length","substring","_jsxs","id","ref","element","current","role","tabIndex","type","Icon","_jsx","SlashMenuPlugin","anchorElem","document","body","editor","queryString","setQueryString","editorConfig","checkForTriggerMatch","minLength","getDynamicItems","groupWithItems","dynamicItem","features","slashMenu","dynamicGroups","dynamicGroupWithItems","concat","groups","groupsWithItems","groupWithItem","push","map","group","filteredItems","items","filter","itemTitle","RegExp","exec","keywords","some","keyword","dynamicItemGroups","dynamicGroup","find","onSelectItem","selectedItem","nodeToRemove","closeMenu","matchingString","update","remove","onSelect","menuRenderFn","anchorElementRef","selectItemAndCleanUp","selectedItemKey","setSelectedItemKey","createPortal","groupTitle","oi","index","onQueryChange","triggerFn"],"sources":["../../../../src/lexical/plugins/SlashMenu/index.tsx"],"sourcesContent":["'use client'\nimport type { TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useFieldProps, useTranslation } from '@payloadcms/ui'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type {\n SlashMenuGroup,\n SlashMenuGroupInternal,\n SlashMenuItemInternal,\n SlashMenuItem as SlashMenuItemType,\n} from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport './index.scss'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n item,\n onClick,\n onMouseEnter,\n}: {\n index: number\n isSelected: boolean\n item: SlashMenuItemInternal\n onClick: () => void\n onMouseEnter: () => void\n}) {\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n const { schemaPath } = useFieldProps()\n\n const { i18n } = useTranslation()\n\n let className = `${baseClass}__item ${baseClass}__item-${item.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = item.key\n if (item.label) {\n title =\n typeof item.label === 'function'\n ? item.label({ i18n, richTextComponentMap, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + item.key}\n key={item.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={(element) => {\n item.ref = { current: element }\n }}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {item?.Icon && <item.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation()\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n const { schemaPath } = useFieldProps()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicItems = useCallback(() => {\n let groupWithItems: Array<SlashMenuGroup> = []\n\n for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups) {\n const dynamicGroupWithItems = dynamicItem({\n editor,\n queryString,\n })\n groupWithItems = groupWithItems.concat(dynamicGroupWithItems)\n }\n\n return groupWithItems\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithItems: SlashMenuGroup[] = []\n for (const groupWithItem of editorConfig?.features.slashMenu.groups ?? []) {\n groupsWithItems.push(groupWithItem)\n }\n\n if (queryString) {\n // Filter current groups first\n groupsWithItems = groupsWithItems.map((group) => {\n const filteredItems = group.items.filter((item) => {\n let itemTitle = item.key\n if (item.label) {\n itemTitle =\n typeof item.label === 'function'\n ? item.label({ i18n, richTextComponentMap, schemaPath })\n : item.label\n }\n\n if (new RegExp(queryString, 'gi').exec(itemTitle)) {\n return true\n }\n if (item.keywords != null) {\n return item.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n }\n return false\n })\n if (filteredItems.length) {\n return {\n ...group,\n items: filteredItems,\n }\n }\n return null\n })\n\n groupsWithItems = groupsWithItems.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicItemGroups = getDynamicItems()\n\n // merge dynamic items into groups\n for (const dynamicGroup of dynamicItemGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithItems.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n items: [],\n }\n } else {\n groupsWithItems = groupsWithItems.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add items to group items array and add to sanitized.slashMenu.groupsWithItems\n if (group?.items?.length) {\n group.items = group.items.concat(group.items)\n }\n groupsWithItems.push(group)\n }\n }\n\n return groupsWithItems\n }, [getDynamicItems, queryString, editorConfig?.features, i18n])\n\n const onSelectItem = useCallback(\n (\n selectedItem: SlashMenuItemType,\n nodeToRemove: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => {\n if (nodeToRemove) {\n editor.update(() => {\n nodeToRemove.remove()\n })\n }\n selectedItem.onSelect({ editor, queryString: matchingString })\n\n closeMenu()\n },\n [editor],\n )\n\n return (\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groups={groups as SlashMenuGroupInternal[]}\n menuRenderFn={(\n anchorElementRef,\n { selectItemAndCleanUp, selectedItemKey, setSelectedItemKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.label) {\n groupTitle =\n typeof group.label === 'function'\n ? group.label({ i18n, richTextComponentMap, schemaPath })\n : group.label\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.items.map((item, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedItemKey === item.key}\n item={item as SlashMenuItemInternal}\n key={item.key}\n onClick={() => {\n setSelectedItemKey(item.key)\n selectItemAndCleanUp(item)\n }}\n onMouseEnter={() => {\n setSelectedItemKey(item.key)\n }}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n onSelectItem={onSelectItem}\n triggerFn={checkForTriggerMatch}\n />\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,cAAc,QAAQ;AAC9C,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAC/C,YAAYC,KAAA,MAAW;AACvB,YA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;YAAEJ,IAAA;YAAMF,oBAAA;YAAsBC;UAAW,KACrDyC,OAAA,CAAMpC,KAAK;QACnB;QAEA,oBACEG,KAAA,CAAC;UACCN,SAAA,EAAW,GAAGV,SAAA,WAAoBA,SAAA,WAAoBiD,OAAA,CAAMtC,GAAG,EAAE;kCAGjEc,IAAA,CAAC;YAAIf,SAAA,EAAW,GAAGV,SAAA,eAAwB;sBAAG4E;cAC7C3B,OAAA,CAAME,KAAK,CAACH,GAAG,CAAC,CAAC7C,MAAA,EAAM0E,EAAA,kBACtBpD,IAAA,CAACxB,aAAA;YACC6E,KAAA,EAAOD,EAAA;YACP3E,UAAA,EAAYuE,eAAA,KAAoBtE,MAAA,CAAKQ,GAAG;YACxCR,IAAA,EAAMA,MAAA;YAENC,OAAA,EAASA,CAAA;cACPsE,kBAAA,CAAmBvE,MAAA,CAAKQ,GAAG;cAC3B6D,oBAAA,CAAqBrE,MAAA;YACvB;YACAE,YAAA,EAAcA,CAAA;cACZqE,kBAAA,CAAmBvE,MAAA,CAAKQ,GAAG;YAC7B;aAPKR,MAAA,CAAKQ,GAAG;WARZsC,OAAA,CAAMtC,GAAG;MAoBpB;QAEF4D,gBAAA,CAAiBnD,OAAO,IAE1B;IAEN2D,aAAA,EAAe/C,cAAA;IACf8B,YAAA,EAAcA,YAAA;IACdkB,SAAA,EAAW9C;;AAGjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useTranslation","useCallback","useMemo","useState","React","ReactDOM","useEditorConfigContext","LexicalTypeaheadMenuPlugin","useMenuTriggerMatch","baseClass","SlashMenuItem","isSelected","item","onClick","onMouseEnter","fieldProps","featureClientSchemaMap","schemaPath","i18n","className","key","title","label","length","substring","_jsxs","id","ref","element","current","role","tabIndex","type","Icon","_jsx","SlashMenuPlugin","anchorElem","document","body","editor","queryString","setQueryString","editorConfig","checkForTriggerMatch","minLength","getDynamicItems","groupWithItems","dynamicItem","features","slashMenu","dynamicGroups","dynamicGroupWithItems","concat","groups","groupsWithItems","groupWithItem","push","map","group","filteredItems","items","filter","itemTitle","RegExp","exec","keywords","some","keyword","dynamicItemGroups","dynamicGroup","find","onSelectItem","selectedItem","closeMenu","matchingString","onSelect","menuRenderFn","anchorElementRef","selectedItemKey","selectItemAndCleanUp","setSelectedItemKey","createPortal","groupTitle","oi","index","onQueryChange","triggerFn"],"sources":["../../../../src/lexical/plugins/SlashMenu/index.tsx"],"sourcesContent":["'use client'\nimport type { TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type {\n SlashMenuGroup,\n SlashMenuGroupInternal,\n SlashMenuItemInternal,\n SlashMenuItem as SlashMenuItemType,\n} from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n item,\n onClick,\n onMouseEnter,\n}: {\n index: number\n isSelected: boolean\n item: SlashMenuItemInternal\n onClick: () => void\n onMouseEnter: () => void\n}) {\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const { i18n } = useTranslation()\n\n let className = `${baseClass}__item ${baseClass}__item-${item.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = item.key\n if (item.label) {\n title =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + item.key}\n key={item.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={(element) => {\n item.ref = { current: element }\n }}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {item?.Icon && <item.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicItems = useCallback(() => {\n let groupWithItems: Array<SlashMenuGroup> = []\n\n for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups) {\n if (queryString) {\n const dynamicGroupWithItems = dynamicItem({\n editor,\n queryString,\n })\n groupWithItems = groupWithItems.concat(dynamicGroupWithItems)\n }\n }\n\n return groupWithItems\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithItems: SlashMenuGroup[] = []\n for (const groupWithItem of editorConfig?.features.slashMenu.groups ?? []) {\n groupsWithItems.push(groupWithItem)\n }\n\n if (queryString) {\n // Filter current groups first\n // @ts-expect-error - TODO: fix this\n groupsWithItems = groupsWithItems.map((group) => {\n const filteredItems = group.items.filter((item) => {\n let itemTitle = item.key\n if (item.label) {\n itemTitle =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n\n if (new RegExp(queryString, 'gi').exec(itemTitle)) {\n return true\n }\n if (item.keywords != null) {\n return item.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n }\n return false\n })\n if (filteredItems.length) {\n return {\n ...group,\n items: filteredItems,\n }\n }\n return null\n })\n\n groupsWithItems = groupsWithItems.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicItemGroups = getDynamicItems()\n\n // merge dynamic items into groups\n for (const dynamicGroup of dynamicItemGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithItems.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n items: [],\n }\n } else {\n groupsWithItems = groupsWithItems.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add items to group items array and add to sanitized.slashMenu.groupsWithItems\n if (group?.items?.length) {\n group.items = group.items.concat(group.items)\n }\n groupsWithItems.push(group)\n }\n }\n\n return groupsWithItems\n }, [\n queryString,\n editorConfig?.features.slashMenu.groups,\n getDynamicItems,\n featureClientSchemaMap,\n i18n,\n schemaPath,\n ])\n\n const onSelectItem = useCallback(\n (selectedItem: SlashMenuItemType, closeMenu: () => void, matchingString: string) => {\n closeMenu()\n\n selectedItem.onSelect({ editor, queryString: matchingString })\n },\n [editor],\n )\n\n return (\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groups={groups as SlashMenuGroupInternal[]}\n menuRenderFn={(\n anchorElementRef,\n { selectedItemKey, selectItemAndCleanUp, setSelectedItemKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.label && featureClientSchemaMap) {\n groupTitle =\n typeof group.label === 'function'\n ? group.label({ featureClientSchemaMap, i18n, schemaPath })\n : group.label\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.items.map((item, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedItemKey === item.key}\n item={item as SlashMenuItemInternal}\n key={item.key}\n onClick={() => {\n setSelectedItemKey(item.key)\n selectItemAndCleanUp(item)\n }}\n onMouseEnter={() => {\n setSelectedItemKey(item.key)\n }}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementR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AA,GAAaxB,OAAA,CAAMtC,GAAG;QAC1B,IAAIsC,OAAA,CAAMpC,KAAK,IAAIN,sBAAA,EAAwB;UACzCkE,UAAA,GACE,OAAOxB,OAAA,CAAMpC,KAAK,KAAK,aACnBoC,OAAA,CAAMpC,KAAK,CAAC;YAAEN,sBAAA;YAAwBE,IAAA;YAAMD;UAAW,KACvDyC,OAAA,CAAMpC,KAAK;QACnB;QAEA,oBACEG,KAAA,CAAC;UACCN,SAAA,EAAW,GAAGV,SAAA,WAAoBA,SAAA,WAAoBiD,OAAA,CAAMtC,GAAG,EAAE;kCAGjEc,IAAA,CAAC;YAAIf,SAAA,EAAW,GAAGV,SAAA,eAAwB;sBAAGyE;cAC7CxB,OAAA,CAAME,KAAK,CAACH,GAAG,CAAC,CAAC7C,MAAA,EAAMuE,EAAA,kBACtBjD,IAAA,CAACxB,aAAA;YACC0E,KAAA,EAAOD,EAAA;YACPxE,UAAA,EAAYmE,eAAA,KAAoBlE,MAAA,CAAKQ,GAAG;YACxCR,IAAA,EAAMA,MAAA;YAENC,OAAA,EAASA,CAAA;cACPmE,kBAAA,CAAmBpE,MAAA,CAAKQ,GAAG;cAC3B2D,oBAAA,CAAqBnE,MAAA;YACvB;YACAE,YAAA,EAAcA,CAAA;cACZkE,kBAAA,CAAmBpE,MAAA,CAAKQ,GAAG;YAC7B;aAPKR,MAAA,CAAKQ,GAAG;WARZsC,OAAA,CAAMtC,GAAG;MAoBpB;QAEFyD,gBAAA,CAAiBhD,OAAO,IAE1B;IAENwD,aAAA,EAAe5C,cAAA;IACf8B,YAAA,EAAcA,YAAA;IACde,SAAA,EAAW3C;;AAGjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,OAAO,cAAc,CAAA;AA2LrB,wBAAgB,oBAAoB,CAAC,EACnC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAGrB"}
|
|
@@ -67,7 +67,7 @@ function useAddBlockHandle(editor, anchorElem, isEditable) {
|
|
|
67
67
|
if (!_emptyBlockElem) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
if (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem) {
|
|
70
|
+
if (blockNode && (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)) {
|
|
71
71
|
setHoveredElement({
|
|
72
72
|
elem: _emptyBlockElem,
|
|
73
73
|
node: blockNode
|
|
@@ -96,12 +96,12 @@ function useAddBlockHandle(editor, anchorElem, isEditable) {
|
|
|
96
96
|
editor.update(() => {
|
|
97
97
|
// Check if blockNode is an empty text node
|
|
98
98
|
let isEmptyParagraph = true;
|
|
99
|
-
if (hoveredElementToUse
|
|
99
|
+
if (hoveredElementToUse?.node.getType() !== 'paragraph' || hoveredElementToUse.node.getTextContent() !== '') {
|
|
100
100
|
isEmptyParagraph = false;
|
|
101
101
|
}
|
|
102
102
|
if (!isEmptyParagraph) {
|
|
103
103
|
const newParagraph = $createParagraphNode();
|
|
104
|
-
hoveredElementToUse
|
|
104
|
+
hoveredElementToUse?.node.insertAfter(newParagraph);
|
|
105
105
|
setTimeout(() => {
|
|
106
106
|
hoveredElementToUse = {
|
|
107
107
|
elem: editor.getElementByKey(newParagraph.getKey()),
|
|
@@ -115,7 +115,7 @@ function useAddBlockHandle(editor, anchorElem, isEditable) {
|
|
|
115
115
|
setTimeout(() => {
|
|
116
116
|
editor.update(() => {
|
|
117
117
|
editor.focus();
|
|
118
|
-
if (hoveredElementToUse
|
|
118
|
+
if (hoveredElementToUse?.node && 'select' in hoveredElementToUse.node && typeof hoveredElementToUse.node.select === 'function') {
|
|
119
119
|
hoveredElementToUse.node.select();
|
|
120
120
|
}
|
|
121
121
|
});
|
|
@@ -124,13 +124,13 @@ function useAddBlockHandle(editor, anchorElem, isEditable) {
|
|
|
124
124
|
// Otherwise, this won't work
|
|
125
125
|
setTimeout(() => {
|
|
126
126
|
editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {
|
|
127
|
-
node: hoveredElementToUse
|
|
127
|
+
node: hoveredElementToUse?.node
|
|
128
128
|
});
|
|
129
129
|
}, 2);
|
|
130
130
|
event_0.stopPropagation();
|
|
131
131
|
event_0.preventDefault();
|
|
132
132
|
}, [editor, hoveredElement]);
|
|
133
|
-
return /*#__PURE__*/createPortal(
|
|
133
|
+
return /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(React.Fragment, {
|
|
134
134
|
children: /*#__PURE__*/_jsx("button", {
|
|
135
135
|
className: "icon add-block-menu",
|
|
136
136
|
onClick: event_1 => {
|
|
@@ -144,9 +144,11 @@ function useAddBlockHandle(editor, anchorElem, isEditable) {
|
|
|
144
144
|
})
|
|
145
145
|
}), anchorElem);
|
|
146
146
|
}
|
|
147
|
-
export function AddBlockHandlePlugin({
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
export function AddBlockHandlePlugin(t0) {
|
|
148
|
+
const {
|
|
149
|
+
anchorElem: t1
|
|
150
|
+
} = t0;
|
|
151
|
+
const anchorElem = t1 === undefined ? document.body : t1;
|
|
150
152
|
const [editor] = useLexicalComposerContext();
|
|
151
153
|
return useAddBlockHandle(editor, anchorElem, editor._editable);
|
|
152
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","$createParagraphNode","React","useCallback","useEffect","useRef","useState","createPortal","useEditorConfigContext","isHTMLElement","Point","ENABLE_SLASH_MENU_COMMAND","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","ADD_BLOCK_MENU_CLASSNAME","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","useAddBlockHandle","editor","anchorElem","isEditable","scrollerElem","parentElement","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","menuRef","hoveredElement","setHoveredElement","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_emptyBlockElem","blockNode","foundAtIndex","cache_threshold","horizontalOffset","point","x","y","returnEmptyParagraphs","startIndex","length","useEdgeAsDefault","node","elem","document","addEventListener","removeEventListener","current","handleAddClick","hoveredElementToUse","update","isEmptyParagraph","getType","getTextContent","newParagraph","insertAfter","setTimeout","getElementByKey","getKey","focus","select","dispatchCommand","stopPropagation","preventDefault","_jsx","Fragment","className","onClick","ref","type","AddBlockHandlePlugin","body","_editable"],"sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode } from 'lexical'\nimport * as React from 'react'\nimport { type JSX, useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.scss'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\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 useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\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\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, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey()),\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,YAAYC,KAAA,MAAW;AACvB,SAAmBC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACnE,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAGlC,MAAMC,wBAAA,GAA2B;AAEjC,IAAIC,SAAA,GAAYC,QAAA;AAEhB,SAASC,gBAAgBC,UAAkB;EACzC,IAAIA,UAAA,KAAe,GAAG;IACpB,OAAOF,QAAA;EACT;EACA,IAAID,SAAA,IAAa,KAAKA,SAAA,GAAYG,UAAA,EAAY;IAC5C,OAAOH,SAAA;EACT;EAEA,OAAOI,IAAA,CAAKC,KAAK,CAACF,UAAA,GAAa;AACjC;AAEA,SAASG,kBACPC,MAAqB,EACrBC,UAAuB,EACvBC,UAAmB;EAEnB,MAAMC,YAAA,GAAeF,UAAA,CAAWG,aAAa;EAE7C,MAAM;IAAEC;EAAY,CAAE,GAAGtB,sBAAA;EACzB,MAAMuB,2BAAA,GAA8BD,YAAA,EAAcE,KAAA,EAAOC,UAAA,GAAa,CAAC,KAAK;EAE5E,MAAMC,OAAA,GAAU7B,MAAA,CAA0B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oBP,IAAI,CAACkB,MAAM,KAAK,YAC3C;UACAX,mBAAA,CAAoBP,IAAI,CAACkB,MAAM;QACjC;MACF;IACF,GAAG;IAEH;IACA;IACAJ,UAAA,CAAW;MACT9C,MAAA,CAAOmD,eAAe,CAACjE,yBAAA,EAA2B;QAChD8C,IAAA,EAAMO,mBAAA,CAAoBP;MAC5B;IACF,GAAG;IAEHnB,OAAA,CAAMuC,eAAe;IACrBvC,OAAA,CAAMwC,cAAc;EACtB,GACA,CAACrD,MAAA,EAAQU,cAAA,CAAe;EAG1B,oBAAO5B,YAAA,eACLwE,IAAA,CAAC7E,KAAA,CAAM8E,QAAQ;cACb,aAAAD,IAAA,CAAC;MACCE,SAAA,EAAU;MACVC,OAAA,EAAU5C,OAAA;QACRyB,cAAA,CAAezB,OAAA;MACjB;MACA6C,GAAA,EAAKjD,OAAA;MACLkD,IAAA,EAAK;gBAEL,aAAAL,IAAA,CAAC;QAAIE,SAAA,EAAWtD,UAAA,GAAa,SAAS;;;MAG1CD,UAAA;AAEJ;AAEA,OAAO,SAAS2D,qBAAqB;EACnC3D,UAAA,GAAaiC,QAAA,CAAS2B;AAAI,CAG3B;EACC,MAAM,CAAC7D,MAAA,CAAO,GAAGzB,yBAAA;EACjB,OAAOwB,iBAAA,CAAkBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAO8D,SAAS;AAC/D","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","$createParagraphNode","React","useCallback","useEffect","useRef","useState","createPortal","useEditorConfigContext","isHTMLElement","Point","ENABLE_SLASH_MENU_COMMAND","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","ADD_BLOCK_MENU_CLASSNAME","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","useAddBlockHandle","editor","anchorElem","isEditable","scrollerElem","parentElement","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","menuRef","hoveredElement","setHoveredElement","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_emptyBlockElem","blockNode","foundAtIndex","cache_threshold","horizontalOffset","point","x","y","returnEmptyParagraphs","startIndex","length","useEdgeAsDefault","node","elem","document","addEventListener","removeEventListener","current","handleAddClick","hoveredElementToUse","update","isEmptyParagraph","getType","getTextContent","newParagraph","insertAfter","setTimeout","getElementByKey","getKey","focus","select","dispatchCommand","stopPropagation","preventDefault","_jsx","Fragment","className","onClick","ref","type","AddBlockHandlePlugin","t0","t1","undefined","body","_editable"],"sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.scss'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\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 useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\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\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, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n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AC7B;IACF,GAAG;IAEHnB,OAAA,CAAMuC,eAAe;IACrBvC,OAAA,CAAMwC,cAAc;EACtB,GACA,CAACrD,MAAA,EAAQU,cAAA,CAAe;EAG1B,oBAAO5B,YAAA,cACLwE,IAAA,CAAC7E,KAAA,CAAM8E,QAAQ;cACb,aAAAD,IAAA,CAAC;MACCE,SAAA,EAAU;MACVC,OAAA,EAAU5C,OAAA;QACRyB,cAAA,CAAezB,OAAA;MACjB;MACA6C,GAAA,EAAKjD,OAAA;MACLkD,IAAA,EAAK;gBAEL,aAAAL,IAAA,CAAC;QAAIE,SAAA,EAAWtD,UAAA,GAAa,SAAS;;;MAG1CD,UAAA;AAEJ;AAEA,OAAO,SAAA2D,qBAAAC,EAAA;EAA8B;IAAA5D,UAAA,EAAA6D;EAAA,IAAAD,EAIpC;EAHC,MAAA5D,UAAA,GAAA6D,EAA0B,KAAAC,SAAA,GAAA7B,QAAA,CAAA8B,IAAA,GAA1BF,EAA0B;EAI1B,OAAA9D,MAAA,IAAiBzB,yBAAA;EAAA,OACVwB,iBAAA,CAAkBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAAiE,SAAgB;AAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function debounce(func:
|
|
1
|
+
export declare function debounce(func: (...args: any[]) => void, wait: number): (...args: any[]) => void;
|
|
2
2
|
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/debounce.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/debounce.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,MAAM,aAEzC,GAAG,EAAE,UAUhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","names":["debounce","func","wait","timeout","args","later","clearTimeout","window","setTimeout"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/debounce.ts"],"sourcesContent":["'use client'\nexport function debounce(func:
|
|
1
|
+
{"version":3,"file":"debounce.js","names":["debounce","func","wait","timeout","args","later","clearTimeout","window","setTimeout"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/debounce.ts"],"sourcesContent":["'use client'\nexport function debounce(func: (...args: any[]) => void, wait: number) {\n let timeout\n return function (...args: any[]) {\n const later = () => {\n clearTimeout(timeout)\n timeout = null\n func(...args)\n }\n\n clearTimeout(timeout)\n timeout = window.setTimeout(later, wait)\n }\n}\n"],"mappings":"AAAA;;AACA,OAAO,SAASA,SAASC,IAA8B,EAAEC,IAAY;EACnE,IAAIC,OAAA;EACJ,OAAO,UAAU,GAAGC,IAAW;IAC7B,MAAMC,KAAA,GAAQA,CAAA;MACZC,YAAA,CAAaH,OAAA;MACbA,OAAA,GAAU;MACVF,IAAA,IAAQG,IAAA;IACV;IAEAE,YAAA,CAAaH,OAAA;IACbA,OAAA,GAAUI,MAAA,CAAOC,UAAU,CAACH,KAAA,EAAOH,IAAA;EACrC;AACF","ignoreList":[]}
|
package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js
CHANGED
|
@@ -8,7 +8,7 @@ export function getBoundingClientRectWithoutTransform(elem) {
|
|
|
8
8
|
return rect;
|
|
9
9
|
}
|
|
10
10
|
const lastNumberOfTransformValue = transformValue.split(',').pop();
|
|
11
|
-
rect.y = rect.y - Number(lastNumberOfTransformValue
|
|
11
|
+
rect.y = rect.y - Number(lastNumberOfTransformValue?.replace(')', ''));
|
|
12
12
|
// Return the original bounding rect if no translation is applied
|
|
13
13
|
return rect;
|
|
14
14
|
}
|
package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBoundingRectWithoutTransform.js","names":["getBoundingClientRectWithoutTransform","elem","rect","getBoundingClientRect","transformValue","getComputedStyle","getPropertyValue","lastNumberOfTransformValue","split","pop","y","Number","replace"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.ts"],"sourcesContent":["'use client'\nexport function getBoundingClientRectWithoutTransform(elem: HTMLElement): DOMRect {\n const rect = elem.getBoundingClientRect()\n\n // Extract the translation value from the transform style\n const transformValue = getComputedStyle(elem).getPropertyValue('transform')\n if (!transformValue || transformValue === 'none') {\n return rect\n }\n\n const lastNumberOfTransformValue = transformValue.split(',').pop()\n rect.y = rect.y - Number(lastNumberOfTransformValue
|
|
1
|
+
{"version":3,"file":"getBoundingRectWithoutTransform.js","names":["getBoundingClientRectWithoutTransform","elem","rect","getBoundingClientRect","transformValue","getComputedStyle","getPropertyValue","lastNumberOfTransformValue","split","pop","y","Number","replace"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.ts"],"sourcesContent":["'use client'\nexport function getBoundingClientRectWithoutTransform(elem: HTMLElement): DOMRect {\n const rect = elem.getBoundingClientRect()\n\n // Extract the translation value from the transform style\n const transformValue = getComputedStyle(elem).getPropertyValue('transform')\n if (!transformValue || transformValue === 'none') {\n return rect\n }\n\n const lastNumberOfTransformValue = transformValue.split(',').pop()\n rect.y = rect.y - Number(lastNumberOfTransformValue?.replace(')', ''))\n\n // Return the original bounding rect if no translation is applied\n return rect\n}\n"],"mappings":"AAAA;;AACA,OAAO,SAASA,sCAAsCC,IAAiB;EACrE,MAAMC,IAAA,GAAOD,IAAA,CAAKE,qBAAqB;EAEvC;EACA,MAAMC,cAAA,GAAiBC,gBAAA,CAAiBJ,IAAA,EAAMK,gBAAgB,CAAC;EAC/D,IAAI,CAACF,cAAA,IAAkBA,cAAA,KAAmB,QAAQ;IAChD,OAAOF,IAAA;EACT;EAEA,MAAMK,0BAAA,GAA6BH,cAAA,CAAeI,KAAK,CAAC,KAAKC,GAAG;EAChEP,IAAA,CAAKQ,CAAC,GAAGR,IAAA,CAAKQ,CAAC,GAAGC,MAAA,CAAOJ,0BAAA,EAA4BK,OAAA,CAAQ,KAAK;EAElE;EACA,OAAOV,IAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,OAAO,cAAc,CAAA;AAqarB,wBAAgB,oBAAoB,CAAC,EACnC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAGrB"}
|
|
@@ -174,8 +174,8 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
174
174
|
isBelow
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
} else {
|
|
178
|
-
hideTargetLine(targetLineElem, lastTargetBlock
|
|
177
|
+
} else if (lastTargetBlock?.elem) {
|
|
178
|
+
hideTargetLine(targetLineElem, lastTargetBlock.elem);
|
|
179
179
|
setLastTargetBlock({
|
|
180
180
|
boundingBox: targetBlockElem.getBoundingClientRect(),
|
|
181
181
|
elem: targetBlockElem,
|
|
@@ -265,7 +265,10 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
265
265
|
setTimeout(() => {
|
|
266
266
|
// add new temp html element to newInsertedElem with the same height and width and the class block-selected
|
|
267
267
|
// to highlight the new inserted element
|
|
268
|
-
const newInsertedElemRect = newInsertedElem
|
|
268
|
+
const newInsertedElemRect = newInsertedElem?.getBoundingClientRect();
|
|
269
|
+
if (!newInsertedElemRect) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
269
272
|
const highlightElem = document.createElement('div');
|
|
270
273
|
highlightElem.className = 'lexical-block-highlighter';
|
|
271
274
|
highlightElem.style.backgroundColor = 'var(--theme-elevation-1000';
|
|
@@ -318,9 +321,11 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
318
321
|
}
|
|
319
322
|
function onDragEnd() {
|
|
320
323
|
isDraggingBlockRef.current = false;
|
|
321
|
-
|
|
324
|
+
if (lastTargetBlock?.elem) {
|
|
325
|
+
hideTargetLine(targetLineRef.current, lastTargetBlock?.elem);
|
|
326
|
+
}
|
|
322
327
|
}
|
|
323
|
-
return /*#__PURE__*/createPortal(
|
|
328
|
+
return /*#__PURE__*/createPortal(/*#__PURE__*/_jsxs(React.Fragment, {
|
|
324
329
|
children: [/*#__PURE__*/_jsx("div", {
|
|
325
330
|
className: "icon draggable-block-menu",
|
|
326
331
|
draggable: true,
|
|
@@ -339,9 +344,11 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
339
344
|
})]
|
|
340
345
|
}), anchorElem);
|
|
341
346
|
}
|
|
342
|
-
export function DraggableBlockPlugin({
|
|
343
|
-
|
|
344
|
-
|
|
347
|
+
export function DraggableBlockPlugin(t0) {
|
|
348
|
+
const {
|
|
349
|
+
anchorElem: t1
|
|
350
|
+
} = t0;
|
|
351
|
+
const anchorElem = t1 === undefined ? document.body : t1;
|
|
345
352
|
const [editor] = useLexicalComposerContext();
|
|
346
353
|
return useDraggableBlockMenu(editor, anchorElem, editor._editable);
|
|
347
354
|
}
|