@payloadcms/richtext-lexical 3.0.0-beta.2 → 3.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/index.d.ts +1 -1
- package/dist/cell/index.d.ts.map +1 -1
- package/dist/cell/index.js +2 -4
- package/dist/cell/index.js.map +1 -1
- package/dist/field/features/align/feature.client.d.ts.map +1 -1
- package/dist/field/features/align/feature.client.js +1 -2
- package/dist/field/features/align/feature.client.js.map +1 -1
- package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
- package/dist/field/features/blockquote/feature.client.js +3 -6
- package/dist/field/features/blockquote/feature.client.js.map +1 -1
- package/dist/field/features/blockquote/feature.server.d.ts.map +1 -1
- package/dist/field/features/blockquote/feature.server.js +4 -4
- package/dist/field/features/blockquote/feature.server.js.map +1 -1
- package/dist/field/features/blockquote/markdownTransformer.d.ts.map +1 -1
- package/dist/field/features/blockquote/markdownTransformer.js +2 -4
- package/dist/field/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.js +3 -5
- package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
- package/dist/field/features/blocks/component/index.d.ts.map +1 -1
- package/dist/field/features/blocks/component/index.js +36 -3
- package/dist/field/features/blocks/component/index.js.map +1 -1
- package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
- package/dist/field/features/blocks/drawer/index.js +2 -4
- package/dist/field/features/blocks/drawer/index.js.map +1 -1
- package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.server.js +109 -77
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -3
- package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.js +1 -2
- package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
- package/dist/field/features/blocks/plugin/commands.d.ts.map +1 -1
- package/dist/field/features/blocks/plugin/commands.js +1 -2
- package/dist/field/features/blocks/plugin/commands.js.map +1 -1
- package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
- package/dist/field/features/blocks/plugin/index.js +3 -6
- package/dist/field/features/blocks/plugin/index.js.map +1 -1
- package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
- package/dist/field/features/blocks/populationPromise.js +3 -18
- package/dist/field/features/blocks/populationPromise.js.map +1 -1
- package/dist/field/features/blocks/validate.d.ts.map +1 -1
- package/dist/field/features/blocks/validate.js +22 -36
- package/dist/field/features/blocks/validate.js.map +1 -1
- package/dist/field/features/converters/html/field/index.d.ts +8 -2
- package/dist/field/features/converters/html/field/index.d.ts.map +1 -1
- package/dist/field/features/converters/html/field/index.js +6 -3
- package/dist/field/features/converters/html/field/index.js.map +1 -1
- package/dist/field/features/debug/testrecorder/plugin/index.d.ts.map +1 -1
- package/dist/field/features/debug/testrecorder/plugin/index.js +2 -4
- package/dist/field/features/debug/testrecorder/plugin/index.js.map +1 -1
- package/dist/field/features/debug/treeview/plugin/index.d.ts.map +1 -1
- package/dist/field/features/debug/treeview/plugin/index.js +2 -4
- package/dist/field/features/debug/treeview/plugin/index.js.map +1 -1
- package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/bold/feature.client.js +1 -2
- package/dist/field/features/format/bold/feature.client.js.map +1 -1
- package/dist/field/features/format/inlinecode/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/inlinecode/feature.client.js +1 -2
- package/dist/field/features/format/inlinecode/feature.client.js.map +1 -1
- package/dist/field/features/format/italic/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/italic/feature.client.js +1 -2
- package/dist/field/features/format/italic/feature.client.js.map +1 -1
- package/dist/field/features/format/strikethrough/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/strikethrough/feature.client.js +1 -2
- package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
- package/dist/field/features/format/subscript/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/subscript/feature.client.js +1 -2
- package/dist/field/features/format/subscript/feature.client.js.map +1 -1
- package/dist/field/features/format/superscript/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/superscript/feature.client.js +1 -2
- package/dist/field/features/format/superscript/feature.client.js.map +1 -1
- package/dist/field/features/format/underline/feature.client.d.ts.map +1 -1
- package/dist/field/features/format/underline/feature.client.js +1 -2
- package/dist/field/features/format/underline/feature.client.js.map +1 -1
- package/dist/field/features/heading/feature.client.d.ts.map +1 -1
- package/dist/field/features/heading/feature.client.js +3 -6
- package/dist/field/features/heading/feature.client.js.map +1 -1
- package/dist/field/features/heading/feature.server.d.ts.map +1 -1
- package/dist/field/features/heading/feature.server.js +5 -5
- package/dist/field/features/heading/feature.server.js.map +1 -1
- package/dist/field/features/heading/markdownTransformer.d.ts.map +1 -1
- package/dist/field/features/heading/markdownTransformer.js +1 -2
- package/dist/field/features/heading/markdownTransformer.js.map +1 -1
- package/dist/field/features/horizontalrule/component/index.d.ts +10 -0
- package/dist/field/features/horizontalrule/component/index.d.ts.map +1 -0
- package/dist/field/features/horizontalrule/component/index.js +62 -0
- package/dist/field/features/horizontalrule/component/index.js.map +1 -0
- package/dist/field/features/horizontalrule/feature.client.d.ts +3 -0
- package/dist/field/features/horizontalrule/feature.client.d.ts.map +1 -0
- package/dist/field/features/horizontalrule/feature.client.js +53 -0
- package/dist/field/features/horizontalrule/feature.client.js.map +1 -0
- package/dist/field/features/horizontalrule/feature.server.d.ts +3 -0
- package/dist/field/features/horizontalrule/feature.server.d.ts.map +1 -0
- package/dist/field/features/horizontalrule/feature.server.js +37 -0
- package/dist/field/features/horizontalrule/feature.server.js.map +1 -0
- package/dist/field/features/horizontalrule/markdownTransformer.d.ts +3 -0
- package/dist/field/features/horizontalrule/markdownTransformer.d.ts.map +1 -0
- package/dist/field/features/horizontalrule/markdownTransformer.js +23 -0
- package/dist/field/features/horizontalrule/markdownTransformer.js.map +1 -0
- package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts +53 -0
- package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts.map +1 -0
- package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js +88 -0
- package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js.map +1 -0
- package/dist/field/features/horizontalrule/plugin/index.d.ts +6 -0
- package/dist/field/features/horizontalrule/plugin/index.d.ts.map +1 -0
- package/dist/field/features/horizontalrule/plugin/index.js +31 -0
- package/dist/field/features/horizontalrule/plugin/index.js.map +1 -0
- package/dist/field/features/horizontalrule/plugin/index.scss +20 -0
- package/dist/field/features/indent/feature.client.d.ts.map +1 -1
- package/dist/field/features/indent/feature.client.js +1 -2
- package/dist/field/features/indent/feature.client.js.map +1 -1
- package/dist/field/features/link/drawer/baseFields.d.ts +3 -3
- package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
- package/dist/field/features/link/drawer/baseFields.js +28 -42
- package/dist/field/features/link/drawer/baseFields.js.map +1 -1
- package/dist/field/features/link/drawer/index.js +3 -2
- package/dist/field/features/link/drawer/index.js.map +1 -1
- package/dist/field/features/link/drawer/types.d.ts +4 -2
- package/dist/field/features/link/drawer/types.d.ts.map +1 -1
- package/dist/field/features/link/drawer/types.js.map +1 -1
- package/dist/field/features/link/feature.client.d.ts.map +1 -1
- package/dist/field/features/link/feature.client.js +2 -4
- package/dist/field/features/link/feature.client.js.map +1 -1
- package/dist/field/features/link/feature.server.d.ts +0 -2
- package/dist/field/features/link/feature.server.d.ts.map +1 -1
- package/dist/field/features/link/feature.server.js +48 -9
- package/dist/field/features/link/feature.server.js.map +1 -1
- package/dist/field/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
- package/dist/field/features/link/nodes/AutoLinkNode.js +1 -2
- package/dist/field/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/field/features/link/nodes/LinkNode.d.ts +1 -3
- package/dist/field/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/field/features/link/nodes/LinkNode.js +2 -4
- package/dist/field/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/autoLink/index.js +3 -6
- package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js +1 -2
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +56 -39
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +9 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -5
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +11 -29
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
- package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/link/index.js +3 -12
- package/dist/field/features/link/plugins/link/index.js.map +1 -1
- package/dist/field/features/link/populationPromise.d.ts.map +1 -1
- package/dist/field/features/link/populationPromise.js +9 -25
- package/dist/field/features/link/populationPromise.js.map +1 -1
- package/dist/field/features/link/validate.d.ts +5 -0
- package/dist/field/features/link/validate.d.ts.map +1 -0
- package/dist/field/features/link/validate.js +32 -0
- package/dist/field/features/link/validate.js.map +1 -0
- package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/feature.client.js +1 -2
- package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.js +6 -6
- package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
- package/dist/field/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/markdownTransformers.js +1 -2
- package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
- package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
- package/dist/field/features/lists/checklist/plugin/index.js +1 -2
- package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
- package/dist/field/features/lists/common/markdown.d.ts.map +1 -1
- package/dist/field/features/lists/common/markdown.js +1 -2
- package/dist/field/features/lists/common/markdown.js.map +1 -1
- package/dist/field/features/lists/htmlConverter.d.ts.map +1 -1
- package/dist/field/features/lists/htmlConverter.js +13 -6
- package/dist/field/features/lists/htmlConverter.js.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.client.d.ts.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.client.js +1 -2
- package/dist/field/features/lists/orderedlist/feature.client.js.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.server.js +6 -6
- package/dist/field/features/lists/orderedlist/feature.server.js.map +1 -1
- package/dist/field/features/lists/orderedlist/markdownTransformer.d.ts.map +1 -1
- package/dist/field/features/lists/orderedlist/markdownTransformer.js +1 -2
- package/dist/field/features/lists/orderedlist/markdownTransformer.js.map +1 -1
- package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
- package/dist/field/features/lists/plugin/index.js +1 -2
- package/dist/field/features/lists/plugin/index.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.client.js +1 -2
- package/dist/field/features/lists/unorderedlist/feature.client.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.server.d.ts.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.server.js +6 -6
- package/dist/field/features/lists/unorderedlist/feature.server.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/markdownTransformer.d.ts.map +1 -1
- package/dist/field/features/lists/unorderedlist/markdownTransformer.js +1 -2
- package/dist/field/features/lists/unorderedlist/markdownTransformer.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js +2 -4
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -4
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js +2 -4
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js +2 -4
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.js +2 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -4
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
- package/dist/field/features/paragraph/feature.client.js +2 -4
- package/dist/field/features/paragraph/feature.client.js.map +1 -1
- package/dist/field/features/relationship/drawer/commands.d.ts.map +1 -1
- package/dist/field/features/relationship/drawer/commands.js +1 -2
- package/dist/field/features/relationship/drawer/commands.js.map +1 -1
- package/dist/field/features/relationship/drawer/index.d.ts.map +1 -1
- package/dist/field/features/relationship/drawer/index.js +7 -13
- package/dist/field/features/relationship/drawer/index.js.map +1 -1
- package/dist/field/features/relationship/feature.server.d.ts.map +1 -1
- package/dist/field/features/relationship/feature.server.js +3 -2
- package/dist/field/features/relationship/feature.server.js.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +3 -8
- package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.js +8 -8
- package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +54 -7
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
- package/dist/field/features/relationship/plugins/index.js +3 -6
- package/dist/field/features/relationship/plugins/index.js.map +1 -1
- package/dist/field/features/relationship/populationPromise.js +7 -6
- package/dist/field/features/relationship/populationPromise.js.map +1 -1
- package/dist/field/features/typeUtilities.d.ts +8 -0
- package/dist/field/features/typeUtilities.d.ts.map +1 -0
- package/dist/field/features/typeUtilities.js +8 -0
- package/dist/field/features/typeUtilities.js.map +1 -0
- package/dist/field/features/types.d.ts +57 -33
- package/dist/field/features/types.d.ts.map +1 -1
- package/dist/field/features/types.js.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +5 -6
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
- package/dist/field/features/upload/component/index.d.ts.map +1 -1
- package/dist/field/features/upload/component/index.js +55 -9
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/drawer/commands.d.ts.map +1 -1
- package/dist/field/features/upload/drawer/commands.js +1 -2
- package/dist/field/features/upload/drawer/commands.js.map +1 -1
- package/dist/field/features/upload/drawer/index.d.ts.map +1 -1
- package/dist/field/features/upload/drawer/index.js +8 -12
- package/dist/field/features/upload/drawer/index.js.map +1 -1
- package/dist/field/features/upload/feature.server.d.ts.map +1 -1
- package/dist/field/features/upload/feature.server.js +39 -11
- package/dist/field/features/upload/feature.server.js.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.d.ts +2 -14
- package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.js +6 -9
- package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
- package/dist/field/features/upload/plugin/index.d.ts +2 -2
- package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
- package/dist/field/features/upload/plugin/index.js +4 -9
- package/dist/field/features/upload/plugin/index.js.map +1 -1
- package/dist/field/features/upload/populationPromise.js +11 -8
- package/dist/field/features/upload/populationPromise.js.map +1 -1
- package/dist/field/features/upload/validate.d.ts +2 -1
- package/dist/field/features/upload/validate.d.ts.map +1 -1
- package/dist/field/features/upload/validate.js +34 -12
- package/dist/field/features/upload/validate.js.map +1 -1
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/field/lexical/LexicalEditor.js +6 -11
- package/dist/field/lexical/LexicalEditor.js.map +1 -1
- package/dist/field/lexical/LexicalProvider.d.ts +1 -1
- package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/field/lexical/LexicalProvider.js +1 -2
- package/dist/field/lexical/LexicalProvider.js.map +1 -1
- package/dist/field/lexical/config/client/default.d.ts +1 -1
- package/dist/field/lexical/config/client/default.d.ts.map +1 -1
- package/dist/field/lexical/config/client/default.js.map +1 -1
- package/dist/field/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/client/sanitize.js.map +1 -1
- package/dist/field/lexical/config/server/default.d.ts +2 -3
- package/dist/field/lexical/config/server/default.d.ts.map +1 -1
- package/dist/field/lexical/config/server/default.js +3 -3
- package/dist/field/lexical/config/server/default.js.map +1 -1
- package/dist/field/lexical/config/server/loader.d.ts +4 -2
- package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
- package/dist/field/lexical/config/server/loader.js +3 -2
- package/dist/field/lexical/config/server/loader.js.map +1 -1
- package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
- package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/server/sanitize.js +23 -8
- package/dist/field/lexical/config/server/sanitize.js.map +1 -1
- package/dist/field/lexical/config/types.d.ts +1 -1
- package/dist/field/lexical/config/types.d.ts.map +1 -1
- package/dist/field/lexical/config/types.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js +3 -6
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js +3 -6
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +27 -29
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
- package/dist/field/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js +1 -2
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +3 -6
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -6
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.js +1 -2
- package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +13 -10
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +1 -2
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +10 -7
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts +9 -0
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -0
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +35 -0
- package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -0
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js +1 -2
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js +17 -7
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/field/lexical/theme/EditorTheme.scss +11 -8
- package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/field/lexical/ui/ContentEditable.js +1 -2
- package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/field/lexical/ui/icons/HorizontalRule/index.d.ts +3 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.d.ts.map +1 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.js +19 -0
- package/dist/field/lexical/ui/icons/HorizontalRule/index.js.map +1 -0
- package/dist/field/lexical/utils/getSelectedNode.d.ts.map +1 -1
- package/dist/field/lexical/utils/getSelectedNode.js +1 -2
- package/dist/field/lexical/utils/getSelectedNode.js.map +1 -1
- package/dist/field/lexical/utils/nodeFormat.d.ts +2 -1
- package/dist/field/lexical/utils/nodeFormat.d.ts.map +1 -1
- package/dist/field/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.js +15 -13
- package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/field/lexical/utils/url.d.ts.map +1 -1
- package/dist/field/lexical/utils/url.js +3 -0
- package/dist/field/lexical/utils/url.js.map +1 -1
- package/dist/forEachNodeRecursively.d.ts +10 -0
- package/dist/forEachNodeRecursively.d.ts.map +1 -0
- package/dist/forEachNodeRecursively.js +24 -0
- package/dist/forEachNodeRecursively.js.map +1 -0
- package/dist/generateComponentMap.d.ts.map +1 -1
- package/dist/generateComponentMap.js +16 -22
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +4 -12
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +260 -173
- package/dist/index.js.map +1 -1
- package/dist/populate/defaultValue.d.ts.map +1 -1
- package/dist/populate/defaultValue.js +1 -0
- package/dist/populate/defaultValue.js.map +1 -1
- package/dist/populate/populate.d.ts +3 -3
- package/dist/populate/populate.d.ts.map +1 -1
- package/dist/populate/populate.js.map +1 -1
- package/dist/populate/populateLexicalPopulationPromises.d.ts +12 -0
- package/dist/populate/populateLexicalPopulationPromises.d.ts.map +1 -0
- package/dist/populate/populateLexicalPopulationPromises.js +35 -0
- package/dist/populate/populateLexicalPopulationPromises.js.map +1 -0
- package/dist/populate/recurseNestedFields.d.ts +7 -4
- package/dist/populate/recurseNestedFields.d.ts.map +1 -1
- package/dist/populate/recurseNestedFields.js +3 -5
- package/dist/populate/recurseNestedFields.js.map +1 -1
- package/dist/scss/app.scss +2 -3
- package/dist/scss/vars.scss +0 -7
- package/dist/types.d.ts +11 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/package.json +47 -46
- package/components.d.ts +0 -6
- package/components.js +0 -7
- package/dist/populate/richTextRelationshipPromise.d.ts +0 -23
- package/dist/populate/richTextRelationshipPromise.d.ts.map +0 -1
- package/dist/populate/richTextRelationshipPromise.js +0 -68
- package/dist/populate/richTextRelationshipPromise.js.map +0 -1
- package/dist/scss/fonts.scss +0 -75
- package/src/index.ts +0 -423
package/dist/cell/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditorConfig as LexicalEditorConfig } from 'lexical
|
|
1
|
+
import type { EditorConfig as LexicalEditorConfig } from 'lexical';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare const RichTextCell: React.FC<{
|
|
4
4
|
lexicalEditorConfig: LexicalEditorConfig;
|
package/dist/cell/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAOlE,OAAO,KAA8B,MAAM,OAAO,CAAA;AAWlD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,mBAAmB,EAAE,mBAAmB,CAAA;CACzC,CA0JA,CAAA"}
|
package/dist/cell/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
const { createHeadlessEditor } = lexicalHeadlessImport;
|
|
4
|
-
import lexicalImport from 'lexical';
|
|
5
|
-
const { $getRoot } = lexicalImport;
|
|
2
|
+
import { createHeadlessEditor } from '@lexical/headless';
|
|
6
3
|
import { useTableCell } from '@payloadcms/ui/elements/Table';
|
|
7
4
|
import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
|
|
8
5
|
import { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction';
|
|
6
|
+
import { $getRoot } from 'lexical';
|
|
9
7
|
import React, { useEffect, useState } from 'react';
|
|
10
8
|
import { defaultEditorLexicalConfig } from '../field/lexical/config/client/default.js';
|
|
11
9
|
import { loadClientFeatures } from '../field/lexical/config/client/loader.js';
|
package/dist/cell/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cell/index.tsx"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport lexicalHeadlessImport from '@lexical/headless'\nconst { createHeadlessEditor } = lexicalHeadlessImport\nimport lexicalImport from 'lexical'\nconst { $getRoot } = lexicalImport\nimport { useTableCell } from '@payloadcms/ui/elements/Table'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction'\nimport React, { useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../field/features/types.js'\nimport type { SanitizedClientEditorConfig } from '../field/lexical/config/types.js'\nimport type { GeneratedFeatureProviderComponent } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../field/lexical/config/client/default.js'\nimport { loadClientFeatures } from '../field/lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../field/lexical/config/client/sanitize.js'\nimport { getEnabledNodes } from '../field/lexical/nodes/index.js'\n\nexport const RichTextCell: React.FC<{\n lexicalEditorConfig: LexicalEditorConfig\n}> = (props) => {\n const { lexicalEditorConfig } = props\n\n const [preview, setPreview] = React.useState('Loading...')\n const { schemaPath } = useFieldProps()\n\n const { cellData, richTextComponentMap } = useTableCell()\n\n const clientFunctions = useClientFunctions()\n const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false)\n\n const [featureProviders, setFeatureProviders] = useState<FeatureProviderClient<unknown>[]>([])\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n let featureProviderComponents: GeneratedFeatureProviderComponent[] = richTextComponentMap.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[] // TODO: Type better\n // order by order\n featureProviderComponents = featureProviderComponents.sort((a, b) => a.order - b.order)\n\n const featureComponentsWithFeaturesLength =\n Array.from(richTextComponentMap.keys()).filter(\n (key) => key.startsWith(`feature.`) && !key.includes('.fields.'),\n ).length + featureProviderComponents.length\n\n useEffect(() => {\n if (!hasLoadedFeatures) {\n const featureProvidersLocal: FeatureProviderClient<unknown>[] = []\n let featureProvidersAndComponentsLoaded = 0\n\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (key.startsWith(`lexicalFeature.${schemaPath}.`)) {\n if (!key.includes('.components.')) {\n featureProvidersLocal.push(plugin)\n }\n featureProvidersAndComponentsLoaded++\n }\n })\n\n if (featureProvidersAndComponentsLoaded === featureComponentsWithFeaturesLength) {\n setFeatureProviders(featureProvidersLocal)\n setHasLoadedFeatures(true)\n\n /**\n * Loaded feature provided => create the final sanitized editor config\n */\n\n const resolvedClientFeatures = loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig,\n resolvedClientFeatures,\n ),\n )\n }\n }\n }, [\n hasLoadedFeatures,\n clientFunctions,\n schemaPath,\n featureProviderComponents.length,\n featureProviders,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n featureComponentsWithFeaturesLength,\n ])\n\n useEffect(() => {\n let dataToUse = cellData\n if (dataToUse == null || !hasLoadedFeatures || !finalSanitizedEditorConfig) {\n setPreview('')\n return\n }\n\n // Transform data through load hooks\n if (finalSanitizedEditorConfig?.features?.hooks?.load?.length) {\n finalSanitizedEditorConfig.features.hooks.load.forEach((hook) => {\n dataToUse = hook({ incomingEditorState: dataToUse })\n })\n }\n\n if (!dataToUse || typeof dataToUse !== 'object') {\n setPreview('')\n return\n }\n\n // If data is from Slate and not Lexical\n if (Array.isArray(dataToUse) && !('root' in dataToUse)) {\n setPreview('')\n return\n }\n\n // If data is from payload-plugin-lexical\n if ('jsonContent' in dataToUse) {\n setPreview('')\n return\n }\n\n // initialize headless editor\n const headlessEditor = createHeadlessEditor({\n namespace: finalSanitizedEditorConfig.lexical.namespace,\n nodes: getEnabledNodes({ editorConfig: finalSanitizedEditorConfig }),\n theme: finalSanitizedEditorConfig.lexical.theme,\n })\n headlessEditor.setEditorState(headlessEditor.parseEditorState(dataToUse))\n\n const textContent =\n headlessEditor.getEditorState().read(() => {\n return $getRoot().getTextContent()\n }) || ''\n\n // Limiting the number of characters shown is done in a CSS rule\n setPreview(textContent)\n }, [cellData, lexicalEditorConfig, hasLoadedFeatures, finalSanitizedEditorConfig])\n\n if (!hasLoadedFeatures) {\n return (\n <React.Fragment>\n {Array.isArray(featureProviderComponents) &&\n featureProviderComponents.map((featureProvider) => {\n // get all components starting with key feature.${FeatureProvider.key}.components.{featureComponentKey}\n const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key) =>\n key.startsWith(`feature.${featureProvider.key}.components.`),\n )\n const featureComponents: React.ReactNode[] = featureComponentKeys.map((key) => {\n return richTextComponentMap.get(key)\n })\n\n return (\n <React.Fragment key={featureProvider.key}>\n {featureComponents?.length\n ? featureComponents.map((FeatureComponent) => {\n return FeatureComponent\n })\n : null}\n {featureProvider.ClientComponent}\n </React.Fragment>\n )\n })}\n </React.Fragment>\n )\n }\n\n return <span>{preview}</span>\n}\n"],"names":["lexicalHeadlessImport","createHeadlessEditor","lexicalImport","$getRoot","useTableCell","useFieldProps","useClientFunctions","React","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","getEnabledNodes","RichTextCell","props","lexicalEditorConfig","preview","setPreview","schemaPath","cellData","richTextComponentMap","clientFunctions","hasLoadedFeatures","setHasLoadedFeatures","featureProviders","setFeatureProviders","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProviderComponents","get","sort","a","b","order","featureComponentsWithFeaturesLength","Array","from","keys","filter","key","startsWith","includes","length","featureProvidersLocal","featureProvidersAndComponentsLoaded","Object","entries","forEach","plugin","push","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","dataToUse","hooks","load","hook","incomingEditorState","isArray","headlessEditor","namespace","nodes","editorConfig","theme","setEditorState","parseEditorState","textContent","getEditorState","read","getTextContent","Fragment","map","featureProvider","featureComponentKeys","featureComponents","FeatureComponent","ClientComponent","span"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,OAAOA,2BAA2B,oBAAmB;AACrD,MAAM,EAAEC,oBAAoB,EAAE,GAAGD;AACjC,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AACrB,SAASE,YAAY,QAAQ,gCAA+B;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlD,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,0BAA0B,QAAQ,6CAA4C;AACvF,SAASC,eAAe,QAAQ,kCAAiC;AAEjE,OAAO,MAAMC,eAER,CAACC;IACJ,MAAM,EAAEC,mBAAmB,EAAE,GAAGD;IAEhC,MAAM,CAACE,SAASC,WAAW,GAAGX,MAAME,QAAQ,CAAC;IAC7C,MAAM,EAAEU,UAAU,EAAE,GAAGd;IAEvB,MAAM,EAAEe,QAAQ,EAAEC,oBAAoB,EAAE,GAAGjB;IAE3C,MAAMkB,kBAAkBhB;IACxB,MAAM,CAACiB,mBAAmBC,qBAAqB,GAAGf,SAAS;IAE3D,MAAM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AAY,CAAC;YAE7D,MAAMoC,oBAAuCD,qBAAqBF,GAAG,CAAC,CAACjC;gBACrE,OAAOnB,qBAAqBS,GAAG,CAACU;YAClC;YAEA,qBACE,oBAACjC,MAAMiE,QAAQ;gBAAChC,KAAKkC,gBAAgBlC,GAAG;eACrCoC,mBAAmBjC,SAChBiC,kBAAkBH,GAAG,CAAC,CAACI;gBACrB,OAAOA;YACT,KACA,MACHH,gBAAgBI,eAAe;QAGtC;IAGR;IAEA,qBAAO,oBAACC,cAAM9D;AAChB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/cell/index.tsx"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { useTableCell } from '@payloadcms/ui/elements/Table'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction'\nimport { $getRoot } from 'lexical'\nimport React, { useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../field/features/types.js'\nimport type { SanitizedClientEditorConfig } from '../field/lexical/config/types.js'\nimport type { GeneratedFeatureProviderComponent } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../field/lexical/config/client/default.js'\nimport { loadClientFeatures } from '../field/lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../field/lexical/config/client/sanitize.js'\nimport { getEnabledNodes } from '../field/lexical/nodes/index.js'\n\nexport const RichTextCell: React.FC<{\n lexicalEditorConfig: LexicalEditorConfig\n}> = (props) => {\n const { lexicalEditorConfig } = props\n\n const [preview, setPreview] = React.useState('Loading...')\n const { schemaPath } = useFieldProps()\n\n const { cellData, richTextComponentMap } = useTableCell()\n\n const clientFunctions = useClientFunctions()\n const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false)\n\n const [featureProviders, setFeatureProviders] = useState<FeatureProviderClient<unknown>[]>([])\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n let featureProviderComponents: GeneratedFeatureProviderComponent[] = richTextComponentMap.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[] // TODO: Type better\n // order by order\n featureProviderComponents = featureProviderComponents.sort((a, b) => a.order - b.order)\n\n const featureComponentsWithFeaturesLength =\n Array.from(richTextComponentMap.keys()).filter(\n (key) => key.startsWith(`feature.`) && !key.includes('.fields.'),\n ).length + featureProviderComponents.length\n\n useEffect(() => {\n if (!hasLoadedFeatures) {\n const featureProvidersLocal: FeatureProviderClient<unknown>[] = []\n let featureProvidersAndComponentsLoaded = 0\n\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (key.startsWith(`lexicalFeature.${schemaPath}.`)) {\n if (!key.includes('.components.')) {\n featureProvidersLocal.push(plugin)\n }\n featureProvidersAndComponentsLoaded++\n }\n })\n\n if (featureProvidersAndComponentsLoaded === featureComponentsWithFeaturesLength) {\n setFeatureProviders(featureProvidersLocal)\n setHasLoadedFeatures(true)\n\n /**\n * Loaded feature provided => create the final sanitized editor config\n */\n\n const resolvedClientFeatures = loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig,\n resolvedClientFeatures,\n ),\n )\n }\n }\n }, [\n hasLoadedFeatures,\n clientFunctions,\n schemaPath,\n featureProviderComponents.length,\n featureProviders,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n featureComponentsWithFeaturesLength,\n ])\n\n useEffect(() => {\n let dataToUse = cellData\n if (dataToUse == null || !hasLoadedFeatures || !finalSanitizedEditorConfig) {\n setPreview('')\n return\n }\n\n // Transform data through load hooks\n if (finalSanitizedEditorConfig?.features?.hooks?.load?.length) {\n finalSanitizedEditorConfig.features.hooks.load.forEach((hook) => {\n dataToUse = hook({ incomingEditorState: dataToUse })\n })\n }\n\n if (!dataToUse || typeof dataToUse !== 'object') {\n setPreview('')\n return\n }\n\n // If data is from Slate and not Lexical\n if (Array.isArray(dataToUse) && !('root' in dataToUse)) {\n setPreview('')\n return\n }\n\n // If data is from payload-plugin-lexical\n if ('jsonContent' in dataToUse) {\n setPreview('')\n return\n }\n\n // initialize headless editor\n const headlessEditor = createHeadlessEditor({\n namespace: finalSanitizedEditorConfig.lexical.namespace,\n nodes: getEnabledNodes({ editorConfig: finalSanitizedEditorConfig }),\n theme: finalSanitizedEditorConfig.lexical.theme,\n })\n headlessEditor.setEditorState(headlessEditor.parseEditorState(dataToUse))\n\n const textContent =\n headlessEditor.getEditorState().read(() => {\n return $getRoot().getTextContent()\n }) || ''\n\n // Limiting the number of characters shown is done in a CSS rule\n setPreview(textContent)\n }, [cellData, lexicalEditorConfig, hasLoadedFeatures, finalSanitizedEditorConfig])\n\n if (!hasLoadedFeatures) {\n return (\n <React.Fragment>\n {Array.isArray(featureProviderComponents) &&\n featureProviderComponents.map((featureProvider) => {\n // get all components starting with key feature.${FeatureProvider.key}.components.{featureComponentKey}\n const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key) =>\n key.startsWith(`feature.${featureProvider.key}.components.`),\n )\n const featureComponents: React.ReactNode[] = featureComponentKeys.map((key) => {\n return richTextComponentMap.get(key)\n })\n\n return (\n <React.Fragment key={featureProvider.key}>\n {featureComponents?.length\n ? featureComponents.map((FeatureComponent) => {\n return FeatureComponent\n })\n : null}\n {featureProvider.ClientComponent}\n </React.Fragment>\n )\n })}\n </React.Fragment>\n )\n }\n\n return <span>{preview}</span>\n}\n"],"names":["createHeadlessEditor","useTableCell","useFieldProps","useClientFunctions","$getRoot","React","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","getEnabledNodes","RichTextCell","props","lexicalEditorConfig","preview","setPreview","schemaPath","cellData","richTextComponentMap","clientFunctions","hasLoadedFeatures","setHasLoadedFeatures","featureProviders","setFeatureProviders","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProviderComponents","get","sort","a","b","order","featureComponentsWithFeaturesLength","Array","from","keys","filter","key","startsWith","includes","length","featureProvidersLocal","featureProvidersAndComponentsLoaded","Object","entries","forEach","plugin","push","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","dataToUse","hooks","load","hook","incomingEditorState","isArray","headlessEditor","namespace","nodes","editorConfig","theme","setEditorState","parseEditorState","textContent","getEditorState","read","getTextContent","Fragment","map","featureProvider","featureComponentKeys","featureComponents","FeatureComponent","ClientComponent","span"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,oBAAoB,QAAQ,oBAAmB;AACxD,SAASC,YAAY,QAAQ,gCAA+B;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,SAASC,QAAQ,QAAQ,UAAS;AAClC,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlD,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,0BAA0B,QAAQ,6CAA4C;AACvF,SAASC,eAAe,QAAQ,kCAAiC;AAEjE,OAAO,MAAMC,eAER,CAACC;IACJ,MAAM,EAAEC,mBAAmB,EAAE,GAAGD;IAEhC,MAAM,CAACE,SAASC,WAAW,GAAGX,MAAME,QAAQ,CAAC;IAC7C,MAAM,EAAEU,UAAU,EAAE,GAAGf;IAEvB,MAAM,EAAEgB,QAAQ,EAAEC,oBAAoB,EAAE,GAAGlB;IAE3C,MAAMmB,kBAAkBjB;IACxB,MAAM,CAACkB,mBAAmBC,qBAAqB,GAAGf,SAAS;IAE3D,M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C,YAAY,CAAC;YAE7D,MAAMoC,oBAAuCD,qBAAqBF,GAAG,CAAC,CAACjC;gBACrE,OAAOnB,qBAAqBS,GAAG,CAACU;YAClC;YAEA,qBACE,oBAACjC,MAAMiE,QAAQ;gBAAChC,KAAKkC,gBAAgBlC,GAAG;eACrCoC,mBAAmBjC,SAChBiC,kBAAkBH,GAAG,CAAC,CAACI;gBACrB,OAAOA;YACT,KACA,MACHH,gBAAgBI,eAAe;QAGtC;IAGR;IAEA,qBAAO,oBAACC,cAAM9D;AAChB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../../src/field/features/align/feature.client.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../../src/field/features/align/feature.client.tsx"],"names":[],"mappings":";AA0EA,eAAO,MAAM,2BAA2B,+BAA4C,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
const { FORMAT_ELEMENT_COMMAND } = lexicalImport;
|
|
2
|
+
import { FORMAT_ELEMENT_COMMAND } from 'lexical';
|
|
4
3
|
import { AlignCenterIcon } from '../../lexical/ui/icons/AlignCenter/index.js';
|
|
5
4
|
import { AlignJustifyIcon } from '../../lexical/ui/icons/AlignJustify/index.js';
|
|
6
5
|
import { AlignLeftIcon } from '../../lexical/ui/icons/AlignLeft/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/align/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/align/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { FORMAT_ELEMENT_COMMAND } from 'lexical'\n\nimport type { FeatureProviderProviderClient } from '../types.js'\n\nimport { AlignCenterIcon } from '../../lexical/ui/icons/AlignCenter/index.js'\nimport { AlignJustifyIcon } from '../../lexical/ui/icons/AlignJustify/index.js'\nimport { AlignLeftIcon } from '../../lexical/ui/icons/AlignLeft/index.js'\nimport { AlignRightIcon } from '../../lexical/ui/icons/AlignRight/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { AlignDropdownSectionWithEntries } from './floatingSelectToolbarAlignDropdownSection.js'\n\nconst AlignFeatureClient: FeatureProviderProviderClient<undefined> = (props) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n floatingSelectToolbar: {\n sections: [\n AlignDropdownSectionWithEntries([\n {\n ChildComponent: AlignLeftIcon,\n isActive: () => false,\n key: 'align-left',\n label: `Align Left`,\n onClick: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left')\n },\n order: 1,\n },\n ]),\n AlignDropdownSectionWithEntries([\n {\n ChildComponent: AlignCenterIcon,\n isActive: () => false,\n key: 'align-center',\n label: `Align Center`,\n onClick: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center')\n },\n order: 2,\n },\n ]),\n AlignDropdownSectionWithEntries([\n {\n ChildComponent: AlignRightIcon,\n isActive: () => false,\n key: 'align-right',\n label: `Align Right`,\n onClick: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right')\n },\n order: 3,\n },\n ]),\n AlignDropdownSectionWithEntries([\n {\n ChildComponent: AlignJustifyIcon,\n isActive: () => false,\n key: 'align-justify',\n label: `Align Justify`,\n onClick: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify')\n },\n order: 4,\n },\n ]),\n ],\n },\n }),\n }\n}\n\nexport const AlignFeatureClientComponent = createClientComponent(AlignFeatureClient)\n"],"names":["FORMAT_ELEMENT_COMMAND","AlignCenterIcon","AlignJustifyIcon","AlignLeftIcon","AlignRightIcon","createClientComponent","AlignDropdownSectionWithEntries","AlignFeatureClient","props","clientFeatureProps","feature","floatingSelectToolbar","sections","ChildComponent","isActive","key","label","onClick","editor","dispatchCommand","order","AlignFeatureClientComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,sBAAsB,QAAQ,UAAS;AAIhD,SAASC,eAAe,QAAQ,8CAA6C;AAC7E,SAASC,gBAAgB,QAAQ,+CAA8C;AAC/E,SAASC,aAAa,QAAQ,4CAA2C;AACzE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,+BAA+B,QAAQ,iDAAgD;AAEhG,MAAMC,qBAA+D,CAACC;IACpE,OAAO;QACLC,oBAAoBD;QACpBE,SAAS,IAAO,CAAA;gBACdD,oBAAoBD;gBACpBG,uBAAuB;oBACrBC,UAAU;wBACRN,gCAAgC;4BAC9B;gCACEO,gBAAgBV;gCAChBW,UAAU,IAAM;gCAChBC,KAAK;gCACLC,OAAO,CAAC,UAAU,CAAC;gCACnBC,SAAS,CAAC,EAAEC,MAAM,EAAE;oCAClBA,OAAOC,eAAe,CAACnB,wBAAwB;gCACjD;gCACAoB,OAAO;4BACT;yBACD;wBACDd,gCAAgC;4BAC9B;gCACEO,gBAAgBZ;gCAChBa,UAAU,IAAM;gCAChBC,KAAK;gCACLC,OAAO,CAAC,YAAY,CAAC;gCACrBC,SAAS,CAAC,EAAEC,MAAM,EAAE;oCAClBA,OAAOC,eAAe,CAACnB,wBAAwB;gCACjD;gCACAoB,OAAO;4BACT;yBACD;wBACDd,gCAAgC;4BAC9B;gCACEO,gBAAgBT;gCAChBU,UAAU,IAAM;gCAChBC,KAAK;gCACLC,OAAO,CAAC,WAAW,CAAC;gCACpBC,SAAS,CAAC,EAAEC,MAAM,EAAE;oCAClBA,OAAOC,eAAe,CAACnB,wBAAwB;gCACjD;gCACAoB,OAAO;4BACT;yBACD;wBACDd,gCAAgC;4BAC9B;gCACEO,gBAAgBX;gCAChBY,UAAU,IAAM;gCAChBC,KAAK;gCACLC,OAAO,CAAC,aAAa,CAAC;gCACtBC,SAAS,CAAC,EAAEC,MAAM,EAAE;oCAClBA,OAAOC,eAAe,CAACnB,wBAAwB;gCACjD;gCACAoB,OAAO;4BACT;yBACD;qBACF;gBACH;YACF,CAAA;IACF;AACF;AAEA,OAAO,MAAMC,8BAA8BhB,sBAAsBE,oBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blockquote/feature.client.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blockquote/feature.client.tsx"],"names":[],"mappings":";AAgEA,eAAO,MAAM,gCAAgC,+BAAiD,CAAA"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
const { $setBlocksType } = lexicalSelectionImport;
|
|
6
|
-
import lexicalImport from 'lexical';
|
|
7
|
-
const { $getSelection } = lexicalImport;
|
|
2
|
+
import { $createQuoteNode, QuoteNode } from '@lexical/rich-text';
|
|
3
|
+
import { $setBlocksType } from '@lexical/selection';
|
|
4
|
+
import { $getSelection } from 'lexical';
|
|
8
5
|
import { SlashMenuOption } from '../../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js';
|
|
9
6
|
import { BlockquoteIcon } from '../../lexical/ui/icons/Blockquote/index.js';
|
|
10
7
|
import { TextDropdownSectionWithEntries } from '../common/floatingSelectToolbarTextDropdownSection/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/blockquote/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/blockquote/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { $createQuoteNode, QuoteNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getSelection } from 'lexical'\n\nimport type { FeatureProviderProviderClient } from '../types.js'\n\nimport { SlashMenuOption } from '../../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport { BlockquoteIcon } from '../../lexical/ui/icons/Blockquote/index.js'\nimport { TextDropdownSectionWithEntries } from '../common/floatingSelectToolbarTextDropdownSection/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { MarkdownTransformer } from './markdownTransformer.js'\n\nconst BlockQuoteFeatureClient: FeatureProviderProviderClient<undefined> = (props) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n floatingSelectToolbar: {\n sections: [\n TextDropdownSectionWithEntries([\n {\n ChildComponent: BlockquoteIcon,\n isActive: () => false,\n key: 'blockquote',\n label: `Blockquote`,\n onClick: ({ editor }) => {\n editor.update(() => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createQuoteNode())\n })\n },\n order: 20,\n },\n ]),\n ],\n },\n markdownTransformers: [MarkdownTransformer],\n\n nodes: [QuoteNode],\n slashMenu: {\n options: [\n {\n displayName: 'Basic',\n key: 'basic',\n options: [\n new SlashMenuOption(`blockquote`, {\n Icon: BlockquoteIcon,\n displayName: `Blockquote`,\n keywords: ['quote', 'blockquote'],\n onSelect: () => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createQuoteNode())\n },\n }),\n ],\n },\n ],\n },\n }),\n }\n}\n\nexport const BlockQuoteFeatureClientComponent = createClientComponent(BlockQuoteFeatureClient)\n"],"names":["$createQuoteNode","QuoteNode","$setBlocksType","$getSelection","SlashMenuOption","BlockquoteIcon","TextDropdownSectionWithEntries","createClientComponent","MarkdownTransformer","BlockQuoteFeatureClient","props","clientFeatureProps","feature","floatingSelectToolbar","sections","ChildComponent","isActive","key","label","onClick","editor","update","selection","order","markdownTransformers","nodes","slashMenu","options","displayName","Icon","keywords","onSelect","BlockQuoteFeatureClientComponent"],"rangeMappings":";;;;;;;;;;;;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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blockquote/feature.server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blockquote/feature.server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAOhE,eAAO,MAAM,iBAAiB,EAAE,6BAA6B,CAAC,SAAS,EAAE,SAAS,CAoCjF,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { QuoteNode } = lexicalRichTextImport;
|
|
1
|
+
import { QuoteNode } from '@lexical/rich-text';
|
|
3
2
|
import { convertLexicalNodesToHTML } from '../converters/html/converter/index.js';
|
|
3
|
+
import { createNode } from '../typeUtilities.js';
|
|
4
4
|
import { BlockQuoteFeatureClientComponent } from './feature.client.js';
|
|
5
5
|
import { MarkdownTransformer } from './markdownTransformer.js';
|
|
6
6
|
export const BlockQuoteFeature = (props)=>{
|
|
@@ -13,7 +13,7 @@ export const BlockQuoteFeature = (props)=>{
|
|
|
13
13
|
MarkdownTransformer
|
|
14
14
|
],
|
|
15
15
|
nodes: [
|
|
16
|
-
{
|
|
16
|
+
createNode({
|
|
17
17
|
converters: {
|
|
18
18
|
html: {
|
|
19
19
|
converter: async ({ converters, node, parent, payload })=>{
|
|
@@ -34,7 +34,7 @@ export const BlockQuoteFeature = (props)=>{
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
node: QuoteNode
|
|
37
|
-
}
|
|
37
|
+
})
|
|
38
38
|
],
|
|
39
39
|
serverFeatureProps: props
|
|
40
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/blockquote/feature.server.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/blockquote/feature.server.ts"],"sourcesContent":["import { QuoteNode } from '@lexical/rich-text'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { BlockQuoteFeatureClientComponent } from './feature.client.js'\nimport { MarkdownTransformer } from './markdownTransformer.js'\n\nexport const BlockQuoteFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => {\n return {\n feature: () => {\n return {\n ClientComponent: BlockQuoteFeatureClientComponent,\n clientFeatureProps: null,\n markdownTransformers: [MarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n return `<blockquote>${childrenText}</blockquote>`\n },\n nodeTypes: [QuoteNode.getType()],\n },\n },\n node: QuoteNode,\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blockquote',\n serverFeatureProps: props,\n }\n}\n"],"names":["QuoteNode","convertLexicalNodesToHTML","createNode","BlockQuoteFeatureClientComponent","MarkdownTransformer","BlockQuoteFeature","props","feature","ClientComponent","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","node","parent","payload","childrenText","lexicalNodes","children","nodeTypes","getType","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAoB;AAI9C,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,gCAAgC,QAAQ,sBAAqB;AACtE,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,OAAO,MAAMC,oBAAyE,CAACC;IACrF,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBL;gBACjBM,oBAAoB;gBACpBC,sBAAsB;oBAACN;iBAAoB;gBAC3CO,OAAO;oBACLT,WAAW;wBACTU,YAAY;4BACVC,MAAM;gCACJC,WAAW,OAAO,EAAEF,UAAU,EAAEG,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;oCACrD,MAAMC,eAAe,MAAMjB,0BAA0B;wCACnDW;wCACAO,cAAcJ,KAAKK,QAAQ;wCAC3BJ,QAAQ;4CACN,GAAGD,IAAI;4CACPC;wCACF;wCACAC;oCACF;oCAEA,OAAO,CAAC,YAAY,EAAEC,aAAa,aAAa,CAAC;gCACnD;gCACAG,WAAW;oCAACrB,UAAUsB,OAAO;iCAAG;4BAClC;wBACF;wBACAP,MAAMf;oBACR;iBACD;gBACDuB,oBAAoBjB;YACtB;QACF;QACAkB,KAAK;QACLD,oBAAoBjB;IACtB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blockquote/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blockquote/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAK3D,eAAO,MAAM,mBAAmB,EAAE,kBAmCjC,CAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import lexicalImport from 'lexical';
|
|
4
|
-
const { $createLineBreakNode } = lexicalImport;
|
|
1
|
+
import { $createQuoteNode, $isQuoteNode, QuoteNode } from '@lexical/rich-text';
|
|
2
|
+
import { $createLineBreakNode } from 'lexical';
|
|
5
3
|
export const MarkdownTransformer = {
|
|
6
4
|
type: 'element',
|
|
7
5
|
dependencies: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/blockquote/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/blockquote/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport { $createQuoteNode, $isQuoteNode, QuoteNode } from '@lexical/rich-text'\nimport { $createLineBreakNode } from 'lexical'\n\nexport const MarkdownTransformer: ElementTransformer = {\n type: 'element',\n dependencies: [QuoteNode],\n export: (node, exportChildren) => {\n if (!$isQuoteNode(node)) {\n return null\n }\n\n const lines = exportChildren(node).split('\\n')\n const output = []\n for (const line of lines) {\n output.push('> ' + line)\n }\n return output.join('\\n')\n },\n regExp: /^>\\s/,\n replace: (parentNode, children, _match, isImport) => {\n if (isImport) {\n const previousNode = parentNode.getPreviousSibling()\n if ($isQuoteNode(previousNode)) {\n previousNode.splice(previousNode.getChildrenSize(), 0, [\n $createLineBreakNode(),\n ...children,\n ])\n previousNode.select(0, 0)\n parentNode.remove()\n return\n }\n }\n\n const node = $createQuoteNode()\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n },\n}\n"],"names":["$createQuoteNode","$isQuoteNode","QuoteNode","$createLineBreakNode","MarkdownTransformer","type","dependencies","export","node","exportChildren","lines","split","output","line","push","join","regExp","replace","parentNode","children","_match","isImport","previousNode","getPreviousSibling","splice","getChildrenSize","select","remove","append"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,gBAAgB,EAAEC,YAAY,EAAEC,SAAS,QAAQ,qBAAoB;AAC9E,SAASC,oBAAoB,QAAQ,UAAS;AAE9C,OAAO,MAAMC,sBAA0C;IACrDC,MAAM;IACNC,cAAc;QAACJ;KAAU;IACzBK,QAAQ,CAACC,MAAMC;QACb,IAAI,CAACR,aAAaO,OAAO;YACvB,OAAO;QACT;QAEA,MAAME,QAAQD,eAAeD,MAAMG,KAAK,CAAC;QACzC,MAAMC,SAAS,EAAE;QACjB,KAAK,MAAMC,QAAQH,MAAO;YACxBE,OAAOE,IAAI,CAAC,OAAOD;QACrB;QACA,OAAOD,OAAOG,IAAI,CAAC;IACrB;IACAC,QAAQ;IACRC,SAAS,CAACC,YAAYC,UAAUC,QAAQC;QACtC,IAAIA,UAAU;YACZ,MAAMC,eAAeJ,WAAWK,kBAAkB;YAClD,IAAItB,aAAaqB,eAAe;gBAC9BA,aAAaE,MAAM,CAACF,aAAaG,eAAe,IAAI,GAAG;oBACrDtB;uBACGgB;iBACJ;gBACDG,aAAaI,MAAM,CAAC,GAAG;gBACvBR,WAAWS,MAAM;gBACjB;YACF;QACF;QAEA,MAAMnB,OAAOR;QACbQ,KAAKoB,MAAM,IAAIT;QACfD,WAAWD,OAAO,CAACT;QACnBA,KAAKkB,MAAM,CAAC,GAAG;IACjB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockContent.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/component/BlockContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BlockContent.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/component/BlockContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAkBxF,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AACnF,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,wBAAwB,CAAA;AAIpE,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,aAAa,GAAG;QACrB,YAAY,EAAE,2BAA2B,CAAA;QACzC,IAAI,EAAE,MAAM,CAAA;QACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;KACnD,CAAA;IACD,QAAQ,EAAE,WAAW,CAAA;IACrB,UAAU,EAAE,QAAQ,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAyMxC,CAAA"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { useLexicalComposerContext } = lexicalComposerContextImport;
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
3
2
|
import { getTranslation } from '@payloadcms/translations';
|
|
4
|
-
import isDeepEqual from 'deep-equal';
|
|
5
|
-
import lexicalImport from 'lexical';
|
|
6
|
-
const { $getNodeByKey } = lexicalImport;
|
|
7
3
|
import { Button } from '@payloadcms/ui/elements/Button';
|
|
8
4
|
import { Collapsible } from '@payloadcms/ui/elements/Collapsible';
|
|
9
5
|
import { ErrorPill } from '@payloadcms/ui/elements/ErrorPill';
|
|
@@ -13,6 +9,8 @@ import { useFormSubmitted } from '@payloadcms/ui/forms/Form';
|
|
|
13
9
|
import { RenderFields } from '@payloadcms/ui/forms/RenderFields';
|
|
14
10
|
import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
|
|
15
11
|
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
12
|
+
import isDeepEqual from 'deep-equal';
|
|
13
|
+
import { $getNodeByKey } from 'lexical';
|
|
16
14
|
import React, { useCallback } from 'react';
|
|
17
15
|
import { FormSavePlugin } from './FormSavePlugin.js';
|
|
18
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/blocks/component/BlockContent.tsx"],"sourcesContent":["import type { FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { getTranslation } from '@payloadcms/translations'\nimport isDeepEqual from 'deep-equal'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { FieldMap, ReducedBlock } from '@payloadcms/ui/utilities/buildComponentMap'\nimport type { CollapsedPreferences } from 'payload/types'\n\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { Collapsible } from '@payloadcms/ui/elements/Collapsible'\nimport { ErrorPill } from '@payloadcms/ui/elements/ErrorPill'\nimport { Pill } from '@payloadcms/ui/elements/Pill'\nimport { SectionTitle } from '@payloadcms/ui/fields/Blocks/SectionTitle'\nimport { useFormSubmitted } from '@payloadcms/ui/forms/Form'\nimport { RenderFields } from '@payloadcms/ui/forms/RenderFields'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../../../lexical/config/types.js'\nimport type { BlockFields, BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n formData: BlockFields\n formSchema: FieldMap\n nodeKey: string\n path: string\n reducedBlock: ReducedBlock\n schemaPath: string\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const {\n baseClass,\n field,\n formData,\n formSchema,\n nodeKey,\n path,\n reducedBlock: { labels },\n schemaPath,\n } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => {\n newFormData = {\n ...newFormData,\n id: formData.id,\n blockType: formData.blockType,\n }\n\n // Recursively remove all undefined values from even being present in formData, as they will\n // cause isDeepEqual to return false if, for example, formData has a key that fields.data\n // does not have, even if it's undefined.\n // Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n // Inside of fields.data however, that sub-blocks blockName property does not exist at all.\n function removeUndefinedAndNullRecursively(obj: object) {\n Object.keys(obj).forEach((key) => {\n if (obj[key] && typeof obj[key] === 'object') {\n removeUndefinedAndNullRecursively(obj[key])\n } else if (obj[key] === undefined || obj[key] === null) {\n delete obj[key]\n }\n })\n }\n removeUndefinedAndNullRecursively(newFormData)\n removeUndefinedAndNullRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!isDeepEqual(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n node.setFields(newFormData as BlockFields)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof labels.singular === 'string'\n ? getTranslation(labels.singular, i18n)\n : '[Singular Label]'}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fieldMap={Array.isArray(formSchema) ? formSchema : []}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","getTranslation","isDeepEqual","lexicalImport","$getNodeByKey","Button","Collapsible","ErrorPill","Pill","SectionTitle","useFormSubmitted","RenderFields","useDocumentInfo","useTranslation","React","useCallback","FormSavePlugin","BlockContent","props","baseClass","field","formData","formSchema","nodeKey","path","reducedBlock","labels","schemaPath","i18n","editor","getDocPreferences","setDocFieldPreferences","isCollapsed","setIsCollapsed","useState","initialState","then","currentDocPreferences","currentFieldPreferences","fields","name","collapsedArray","collapsed","includes","id","hasSubmitted","errorCount","setErrorCount","fieldHasErrors","classNames","filter","Boolean","join","onFormChange","fullFieldsWithValues","newFormData","blockType","removeUndefinedAndNullRecursively","obj","Object","keys","forEach","key","undefined","setTimeout","update","node","setFields","rowErrorCount","formField","values","valid","onCollapsedChange","changedCollapsed","newCollapsed","length","push","splice","indexOf","hello","removeBlock","remove","Fragment","className","collapsibleStyle","header","div","pillStyle","singular","readOnly","count","withMessage","isEditable","buttonStyle","disabled","icon","onClick","e","preventDefault","round","tooltip","onToggle","incomingCollapsedState","fieldMap","Array","isArray","forceRender","margins","onChange"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,iBAAiB,aAAY;AACpC,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAK1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,IAAI,QAAQ,+BAA8B;AACnD,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,cAAc,QAAQ,sBAAqB;AAiBpD;;;;CAIC,GACD,OAAO,MAAMC,eAAgC,CAACC;IAC5C,MAAM,EACJC,SAAS,EACTC,KAAK,EACLC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,cAAc,EAAEC,MAAM,EAAE,EACxBC,UAAU,EACX,GAAGT;IAEJ,MAAM,EAAEU,IAAI,EAAE,GAAGf;IACjB,MAAM,CAACgB,OAAO,GAAG7B;IACjB,6EAA6E;IAC7E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ACV9D,YAAYA;uBAIhB,oBAACX;QAAe4F,UAAUvD;;AAGhC,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/blocks/component/BlockContent.tsx"],"sourcesContent":["import type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { FieldMap, ReducedBlock } from '@payloadcms/ui/utilities/buildComponentMap'\nimport type { FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\nimport type { CollapsedPreferences } from 'payload/types'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { Collapsible } from '@payloadcms/ui/elements/Collapsible'\nimport { ErrorPill } from '@payloadcms/ui/elements/ErrorPill'\nimport { Pill } from '@payloadcms/ui/elements/Pill'\nimport { SectionTitle } from '@payloadcms/ui/fields/Blocks/SectionTitle'\nimport { useFormSubmitted } from '@payloadcms/ui/forms/Form'\nimport { RenderFields } from '@payloadcms/ui/forms/RenderFields'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport isDeepEqual from 'deep-equal'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../../../lexical/config/types.js'\nimport type { BlockFields, BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n formData: BlockFields\n formSchema: FieldMap\n nodeKey: string\n path: string\n reducedBlock: ReducedBlock\n schemaPath: string\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const {\n baseClass,\n field,\n formData,\n formSchema,\n nodeKey,\n path,\n reducedBlock: { labels },\n schemaPath,\n } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => {\n newFormData = {\n ...newFormData,\n id: formData.id,\n blockType: formData.blockType,\n }\n\n // Recursively remove all undefined values from even being present in formData, as they will\n // cause isDeepEqual to return false if, for example, formData has a key that fields.data\n // does not have, even if it's undefined.\n // Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n // Inside of fields.data however, that sub-blocks blockName property does not exist at all.\n function removeUndefinedAndNullRecursively(obj: object) {\n Object.keys(obj).forEach((key) => {\n if (obj[key] && typeof obj[key] === 'object') {\n removeUndefinedAndNullRecursively(obj[key])\n } else if (obj[key] === undefined || obj[key] === null) {\n delete obj[key]\n }\n })\n }\n removeUndefinedAndNullRecursively(newFormData)\n removeUndefinedAndNullRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!isDeepEqual(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n node.setFields(newFormData as BlockFields)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof labels.singular === 'string'\n ? getTranslation(labels.singular, i18n)\n : '[Singular Label]'}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fieldMap={Array.isArray(formSchema) ? formSchema : []}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","getTranslation","Button","Collapsible","ErrorPill","Pill","SectionTitle","useFormSubmitted","RenderFields","useDocumentInfo","useTranslation","isDeepEqual","$getNodeByKey","React","useCallback","FormSavePlugin","BlockContent","props","baseClass","field","formData","formSchema","nodeKey","path","reducedBlock","labels","schemaPath","i18n","editor","getDocPreferences","setDocFieldPreferences","isCollapsed","setIsCollapsed","useState","initialState","then","currentDocPreferences","currentFieldPreferences","fields","name","collapsedArray","collapsed","includes","id","hasSubmitted","errorCount","setErrorCount","fieldHasErrors","classNames","filter","Boolean","join","onFormChange","fullFieldsWithValues","newFormData","blockType","removeUndefinedAndNullRecursively","obj","Object","keys","forEach","key","undefined","setTimeout","update","node","setFields","rowErrorCount","formField","values","valid","onCollapsedChange","changedCollapsed","newCollapsed","length","push","splice","indexOf","hello","removeBlock","remove","Fragment","className","collapsibleStyle","header","div","pillStyle","singular","readOnly","count","withMessage","isEditable","buttonStyle","disabled","icon","onClick","e","preventDefault","round","tooltip","onToggle","incomingCollapsedState","fieldMap","Array","isArray","forceRender","margins","onChange"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,IAAI,QAAQ,+BAA8B;AACnD,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,iBAAiB,aAAY;AACpC,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,cAAc,QAAQ,sBAAqB;AAiBpD;;;;CAIC,GACD,OAAO,MAAMC,eAAgC,CAACC;IAC5C,MAAM,EACJC,SAAS,EACTC,KAAK,EACLC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,cAAc,EAAEC,MAAM,EAAE,EACxBC,UAAU,EACX,GAAGT;IAEJ,MAAM,EAAEU,IAAI,EAAE,GAAGjB;IACj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QACRnF,MAAK,GAAG,wQAAwQ;;QAChRiE,UAAU;QACV9D,YAAYA;uBAIhB,oBAACX;QAAe4F,UAAUvD;;AAGhC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/component/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/component/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAuBzD,OAAO,cAAc,CAAA;AAGrB,KAAK,KAAK,GAAG;IACX,qBAAqB,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAE1B,QAAQ,EAAE,WAAW,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,mBAAmB,EAAE,WAAW,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAkJ1C,CAAA"}
|
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
import { Form } from '@payloadcms/ui/forms/Form';
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
const baseClass = 'lexical-block';
|
|
5
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
6
|
+
import { Collapsible } from '@payloadcms/ui/elements/Collapsible';
|
|
7
|
+
import { Pill } from '@payloadcms/ui/elements/Pill';
|
|
8
|
+
import { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect';
|
|
9
|
+
import { SectionTitle } from '@payloadcms/ui/fields/Blocks/SectionTitle';
|
|
5
10
|
import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
|
|
6
11
|
import { useFormSubmitted } from '@payloadcms/ui/forms/Form';
|
|
7
12
|
import { useConfig } from '@payloadcms/ui/providers/Config';
|
|
8
13
|
import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
|
|
14
|
+
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
9
15
|
import { getFormState } from '@payloadcms/ui/utilities/getFormState';
|
|
10
16
|
import { v4 as uuid } from 'uuid';
|
|
11
17
|
import { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js';
|
|
@@ -89,9 +95,17 @@ export const BlockComponent = (props)=>{
|
|
|
89
95
|
id,
|
|
90
96
|
formData.blockName
|
|
91
97
|
]);
|
|
98
|
+
const { i18n } = useTranslation();
|
|
99
|
+
const classNames = [
|
|
100
|
+
`${baseClass}__row`,
|
|
101
|
+
`${baseClass}__row--no-errors`
|
|
102
|
+
].filter(Boolean).join(' ');
|
|
92
103
|
// Memoized Form JSX
|
|
93
104
|
const formContent = useMemo(()=>{
|
|
94
|
-
return reducedBlock && initialState !== false
|
|
105
|
+
return reducedBlock && initialState !== false ? /*#__PURE__*/ React.createElement(Form, {
|
|
106
|
+
beforeSubmit: [
|
|
107
|
+
onChange
|
|
108
|
+
],
|
|
95
109
|
// @ts-expect-error TODO: Fix this
|
|
96
110
|
fields: fieldMap,
|
|
97
111
|
initialState: initialState,
|
|
@@ -109,17 +123,36 @@ export const BlockComponent = (props)=>{
|
|
|
109
123
|
path: `${path}.feature.blocks.${formData.blockType}`,
|
|
110
124
|
reducedBlock: reducedBlock,
|
|
111
125
|
schemaPath: schemaFieldsPath
|
|
126
|
+
})) : /*#__PURE__*/ React.createElement(Collapsible, {
|
|
127
|
+
className: classNames,
|
|
128
|
+
collapsibleStyle: "default",
|
|
129
|
+
header: /*#__PURE__*/ React.createElement("div", {
|
|
130
|
+
className: `${baseClass}__block-header`
|
|
131
|
+
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(Pill, {
|
|
132
|
+
className: `${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`,
|
|
133
|
+
pillStyle: "white"
|
|
134
|
+
}, typeof reducedBlock.labels.singular === 'string' ? getTranslation(reducedBlock.labels.singular, i18n) : '[Singular Label]'), /*#__PURE__*/ React.createElement(SectionTitle, {
|
|
135
|
+
path: "blockName",
|
|
136
|
+
readOnly: parentLexicalRichTextField?.readOnly
|
|
137
|
+
}))),
|
|
138
|
+
key: 0
|
|
139
|
+
}, /*#__PURE__*/ React.createElement(ShimmerEffect, {
|
|
140
|
+
height: "35vh"
|
|
112
141
|
}));
|
|
113
142
|
}, [
|
|
114
143
|
fieldMap,
|
|
115
144
|
parentLexicalRichTextField,
|
|
116
145
|
nodeKey,
|
|
146
|
+
i18n,
|
|
117
147
|
submitted,
|
|
118
148
|
initialState,
|
|
119
149
|
reducedBlock,
|
|
120
150
|
blockFieldWrapperName,
|
|
121
|
-
onChange
|
|
122
|
-
|
|
151
|
+
onChange,
|
|
152
|
+
schemaFieldsPath,
|
|
153
|
+
path
|
|
154
|
+
]) // Adding formData to the dependencies here might break it
|
|
155
|
+
;
|
|
123
156
|
return /*#__PURE__*/ React.createElement("div", {
|
|
124
157
|
className: baseClass
|
|
125
158
|
}, formContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/blocks/component/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui/forms/Form'\n\nimport { Form } from '@payloadcms/ui/forms/Form'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { type BlockFields } from '../nodes/BlocksNode.js'\nconst baseClass = 'lexical-block'\n\nimport type { ReducedBlock } from '@payloadcms/ui/utilities/buildComponentMap'\nimport type { FormState } from 'payload/types'\n\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useFormSubmitted } from '@payloadcms/ui/forms/Form'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { getFormState } from '@payloadcms/ui/utilities/getFormState'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { BlocksFeatureClientProps } from '../feature.client.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n blockFieldWrapperName: string\n children?: React.ReactNode\n\n formData: BlockFields\n nodeKey?: string\n /**\n * This transformedFormData already comes wrapped in blockFieldWrapperName\n */\n transformedFormData: BlockFields\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { blockFieldWrapperName, formData, nodeKey } = props\n const config = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { editorConfig, field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `feature.blocks.fields.${formData?.blockType}`\n const schemaFieldsPath = `${schemaPath}.feature.blocks.${formData?.blockType}`\n\n const reducedBlock: ReducedBlock = (\n editorConfig?.resolvedFeatureMap?.get('blocks')\n ?.clientFeatureProps as ClientComponentProps<BlocksFeatureClientProps>\n )?.reducedBlocks?.find((block) => block.slug === formData?.blockType)\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath)\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: JSON.parse(JSON.stringify(formData)),\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n if (state) {\n setInitialState({\n ...removeEmptyArrayValues({ fields: state }),\n blockName: {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n })\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n const formState = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n return {\n ...formState,\n blockName: {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id, formData.blockName],\n )\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return (\n reducedBlock &&\n initialState !== false && (\n <Form\n // @ts-expect-error TODO: Fix this\n fields={fieldMap}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={Array.isArray(fieldMap) ? fieldMap : []}\n nodeKey={nodeKey}\n path={`${path}.feature.blocks.${formData.blockType}`}\n reducedBlock={reducedBlock}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n )\n )\n }, [\n fieldMap,\n parentLexicalRichTextField,\n nodeKey,\n submitted,\n initialState,\n reducedBlock,\n blockFieldWrapperName,\n onChange,\n ])\n\n return <div className={baseClass}>{formContent}</div>\n}\n"],"names":["Form","React","useCallback","useEffect","useMemo","useState","baseClass","useFieldProps","useFormSubmitted","useConfig","useDocumentInfo","getFormState","v4","uuid","useEditorConfigContext","BlockContent","removeEmptyArrayValues","BlockComponent","props","blockFieldWrapperName","formData","nodeKey","config","submitted","id","path","schemaPath","editorConfig","field","parentLexicalRichTextField","initialState","setInitialState","richTextComponentMap","componentMapRenderedFieldsPath","blockType","schemaFieldsPath","reducedBlock","resolvedFeatureMap","get","clientFeatureProps","reducedBlocks","find","block","slug","fieldMap","awaitInitialState","state","apiRoute","routes","api","body","data","JSON","parse","stringify","operation","serverURL","fields","blockName","initialValue","passesCondition","valid","value","onChange","formState","prevFormState","formContent","formSchema","Array","isArray","div","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,IAAI,QAAQ,4BAA2B;AAChD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAGxE,MAAMC,YAAY;AAKlB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,YAAY,QAAQ,wCAAuC;AACpE,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAKjC,SAASC,sBAAsB,QAAQ,yDAAwD;AAC/F,SAASC,YAAY,QAAQ,oBAAmB;AAChD,OAAO,eAAc;AACrB,SAASC,sBAAsB,QAAQ,8BAA6B;AAcpE,OAAO,MAAMC,iBAAkC,CAACC;IAC9C,MAAM,EAAEC,qBAAqB,EAAEC,QAAQ,EAAEC,OAAO,EAAE,GAAGH;IACrD,MAAMI,SAASb;IACf,MAAMc,YAAYf;IAClB,MAAM,EAAEgB,EAAE,EAAE,GAAGd;IACf,MAAM,EAAEe,IAAI,EAAEC,UAAU,EAAE,GAAGnB;IAC7B,MAAM,EAAEoB,YAAY,EAAEC,OAAOC,0BAA0B,EAAE,GAAGf;IAE5D,MAAM,CAACgB,cAAcC,gBAAgB,GAAG1B,SAA4B;IACpE,MAAM,EACJuB,OAAO,EAAEI,oBAAoB,EAAE,EAChC,GAAGlB;IAEJ,MAAMmB,iCAAiC,CAAC,sBAAsB,EAAEb,UAAUc,UAAU,CAAC;IACr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;IACF,GAEA;QAACpC,OAAO0B,MAAM,CAACC,GAAG;QAAE3B,OAAOkC,SAAS;QAAErB;QAAkBX;QAAIJ,SAASsC,SAAS;KAAC;IAGjF,oBAAoB;IACpB,MAAMQ,cAAc9D,QAAQ;QAC1B,OACEgC,gBACAN,iBAAiB,uBACf,oBAAC9B;YACC,kCAAkC;YAClCyD,QAAQb;YACRd,cAAcA;YACdiC,UAAU;gBAACA;aAAS;YACpBxC,WAAWA;YACXV,MAAMA;yBAEN,oBAACE;YACCT,WAAWA;YACXsB,OAAOC;YACPT,UAAUA;YACV+C,YAAYC,MAAMC,OAAO,CAACzB,YAAYA,WAAW,EAAE;YACnDvB,SAASA;YACTI,MAAM,CAAC,EAAEA,KAAK,gBAAgB,EAAEL,SAASc,SAAS,CAAC,CAAC;YACpDE,cAAcA;YACdV,YAAYS;;IAKtB,GAAG;QACDS;QACAf;QACAR;QACAE;QACAO;QACAM;QACAjB;QACA4C;KACD;IAED,qBAAO,oBAACO;QAAIC,WAAWjE;OAAY4D;AACrC,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/blocks/component/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui/forms/Form'\n\nimport { Form } from '@payloadcms/ui/forms/Form'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { type BlockFields } from '../nodes/BlocksNode.js'\nconst baseClass = 'lexical-block'\nimport type { ReducedBlock } from '@payloadcms/ui/utilities/buildComponentMap'\nimport type { FormState } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Collapsible } from '@payloadcms/ui/elements/Collapsible'\nimport { Pill } from '@payloadcms/ui/elements/Pill'\nimport { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect'\nimport { SectionTitle } from '@payloadcms/ui/fields/Blocks/SectionTitle'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useFormSubmitted } from '@payloadcms/ui/forms/Form'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { getFormState } from '@payloadcms/ui/utilities/getFormState'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { BlocksFeatureClientProps } from '../feature.client.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n blockFieldWrapperName: string\n children?: React.ReactNode\n\n formData: BlockFields\n nodeKey?: string\n /**\n * This transformedFormData already comes wrapped in blockFieldWrapperName\n */\n transformedFormData: BlockFields\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { blockFieldWrapperName, formData, nodeKey } = props\n const config = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { editorConfig, field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `feature.blocks.fields.${formData?.blockType}`\n const schemaFieldsPath = `${schemaPath}.feature.blocks.${formData?.blockType}`\n\n const reducedBlock: ReducedBlock = (\n editorConfig?.resolvedFeatureMap?.get('blocks')\n ?.clientFeatureProps as ClientComponentProps<BlocksFeatureClientProps>\n )?.reducedBlocks?.find((block) => block.slug === formData?.blockType)\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath)\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: JSON.parse(JSON.stringify(formData)),\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n if (state) {\n setInitialState({\n ...removeEmptyArrayValues({ fields: state }),\n blockName: {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n })\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n const formState = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n return {\n ...formState,\n blockName: {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return reducedBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n // @ts-expect-error TODO: Fix this\n fields={fieldMap}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={Array.isArray(fieldMap) ? fieldMap : []}\n nodeKey={nodeKey}\n path={`${path}.feature.blocks.${formData.blockType}`}\n reducedBlock={reducedBlock}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof reducedBlock.labels.singular === 'string'\n ? getTranslation(reducedBlock.labels.singular, i18n)\n : '[Singular Label]'}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={parentLexicalRichTextField?.readOnly} />\n </div>\n </div>\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n fieldMap,\n parentLexicalRichTextField,\n nodeKey,\n i18n,\n submitted,\n initialState,\n reducedBlock,\n blockFieldWrapperName,\n onChange,\n schemaFieldsPath,\n path,\n ]) // Adding formData to the dependencies here might break it\n\n return <div className={baseClass}>{formContent}</div>\n}\n"],"names":["Form","React","useCallback","useEffect","useMemo","useState","baseClass","getTranslation","Collapsible","Pill","ShimmerEffect","SectionTitle","useFieldProps","useFormSubmitted","useConfig","useDocumentInfo","useTranslation","getFormState","v4","uuid","useEditorConfigContext","BlockContent","removeEmptyArrayValues","BlockComponent","props","blockFieldWrapperName","formData","nodeKey","config","submitted","id","path","schemaPath","editorConfig","field","parentLexicalRichTextField","initialState","setInitialState","richTextComponentMap","componentMapRenderedFieldsPath","blockType","schemaFieldsPath","reducedBlock","resolvedFeatureMap","get","clientFeatureProps","reducedBlocks","find","block","slug","fieldMap","awaitInitialState","state","apiRoute","routes","api","body","data","JSON","parse","stringify","operation","serverURL","fields","blockName","initialValue","passesCondition","valid","value","onChange","formState","prevFormState","i18n","classNames","filter","Boolean","join","formContent","beforeSubmit","formSchema","Array","isArray","className","collapsibleStyle","header","div","pillStyle","labels","singular","readOnly","key","height"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,IAAI,QAAQ,4BAA2B;AAChD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAGxE,MAAMC,YAAY;AAIlB,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,IAAI,QAAQ,+BAA8B;AACnD,SAASC,aAAa,QAAQ,wCAAuC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AC1B,OAAOsC,gBAAgBN,iBAAiB,sBACtC,oBAACpC;YACC8E,cAAc;gBAACT;aAAS;YACxB,kCAAkC;YAClCN,QAAQb;YACRd,cAAcA;YACdiC,UAAU;gBAACA;aAAS;YACpBxC,WAAWA;YACXV,MAAMA;yBAEN,oBAACE;YACCf,WAAWA;YACX4B,OAAOC;YACPT,UAAUA;YACVqD,YAAYC,MAAMC,OAAO,CAAC/B,YAAYA,WAAW,EAAE;YACnDvB,SAASA;YACTI,MAAM,CAAC,EAAEA,KAAK,gBAAgB,EAAEL,SAASc,SAAS,CAAC,CAAC;YACpDE,cAAcA;YACdV,YAAYS;4BAIhB,oBAACjC;YACC0E,WAAWT;YACXU,kBAAiB;YACjBC,sBACE,oBAACC;gBAAIH,WAAW,CAAC,EAAE5E,UAAU,cAAc,CAAC;6BAC1C,oBAAC+E,2BACC,oBAAC5E;gBACCyE,WAAW,CAAC,EAAE5E,UAAU,aAAa,EAAEA,UAAU,aAAa,EAAEoB,UAAUc,UAAU,CAAC;gBACrF8C,WAAU;eAET,OAAO5C,aAAa6C,MAAM,CAACC,QAAQ,KAAK,WACrCjF,eAAemC,aAAa6C,MAAM,CAACC,QAAQ,EAAEhB,QAC7C,mCAEN,oBAAC7D;gBAAaoB,MAAK;gBAAY0D,UAAUtD,4BAA4BsD;;YAI3EC,KAAK;yBAEL,oBAAChF;YAAciF,QAAO;;IAG5B,GAAG;QACDzC;QACAf;QACAR;QACA6C;QACA3C;QACAO;QACAM;QACAjB;QACA4C;QACA5B;QACAV;KACD,EAAE,0DAA0D;;IAE7D,qBAAO,oBAACsD;QAAIH,WAAW5E;OAAYuE;AACrC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/drawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/drawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAA;AAS5D,OAAO,KAA2C,MAAM,OAAO,CAAA;AAU/D,eAAO,MAAM,gCAAgC,EAAE,cAAc,CAAC;IAC5D,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAA;CACrC,CAAqD,CAAA;AAiCtD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EA4DzC,CAAA"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as facelessUIImport from '@faceless-ui/modal';
|
|
3
|
-
import
|
|
4
|
-
const { useLexicalComposerContext } = lexicalComposerContextImport;
|
|
5
|
-
import lexicalImport from 'lexical';
|
|
6
|
-
const { $getNodeByKey, COMMAND_PRIORITY_EDITOR, createCommand } = lexicalImport;
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
7
4
|
import { formatDrawerSlug } from '@payloadcms/ui/elements/Drawer';
|
|
8
5
|
import { BlocksDrawer } from '@payloadcms/ui/fields/Blocks/BlocksDrawer';
|
|
9
6
|
import { useEditDepth } from '@payloadcms/ui/providers/EditDepth';
|
|
10
7
|
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
8
|
+
import { $getNodeByKey, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
11
9
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
12
10
|
import { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js';
|
|
13
11
|
import { $createBlockNode } from '../nodes/BlocksNode.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/blocks/drawer/index.tsx"],"sourcesContent":["'use client'\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/blocks/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand, LexicalEditor } from 'lexical'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { formatDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { BlocksDrawer } from '@payloadcms/ui/fields/Blocks/BlocksDrawer'\nimport { useEditDepth } from '@payloadcms/ui/providers/EditDepth'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { BlocksFeatureClientProps } from '../feature.client.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { $createBlockNode } from '../nodes/BlocksNode.js'\nimport { INSERT_BLOCK_COMMAND } from '../plugin/commands.js'\nconst baseClass = 'lexical-blocks-drawer'\n\nexport const INSERT_BLOCK_WITH_DRAWER_COMMAND: LexicalCommand<{\n replace: { nodeKey: string } | false\n}> = createCommand('INSERT_BLOCK_WITH_DRAWER_COMMAND')\n\nconst insertBlock = ({\n blockType,\n editor,\n replaceNodeKey,\n}: {\n blockType: string\n editor: LexicalEditor\n replaceNodeKey: null | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_BLOCK_COMMAND, {\n id: null,\n blockName: '',\n blockType,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace(\n $createBlockNode({\n id: null,\n blockName: '',\n blockType,\n }),\n )\n }\n })\n }\n}\n\nexport const BlocksDrawerComponent: React.FC = () => {\n const { useModal } = facelessUIImport\n\n const [editor] = useLexicalComposerContext()\n const { editorConfig, uuid } = useEditorConfigContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n const editDepth = useEditDepth()\n const { t } = useTranslation()\n const { openModal } = useModal()\n\n const labels = {\n plural: t('fields:blocks') || 'Blocks',\n singular: t('fields:block') || 'Block',\n }\n\n const addRow = useCallback(\n (rowIndex: number, blockType: string) => {\n insertBlock({\n blockType,\n editor,\n replaceNodeKey,\n })\n },\n [editor, replaceNodeKey],\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-rich-text-blocks-` + uuid,\n depth: editDepth,\n })\n\n const reducedBlocks = (\n editorConfig?.resolvedFeatureMap?.get('blocks')\n ?.clientFeatureProps as ClientComponentProps<BlocksFeatureClientProps>\n )?.reducedBlocks\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_BLOCK_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openModal(drawerSlug)\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, drawerSlug, openModal])\n\n return (\n <BlocksDrawer\n addRow={addRow}\n addRowIndex={0}\n blocks={reducedBlocks}\n drawerSlug={drawerSlug}\n labels={labels}\n />\n )\n}\n"],"names":["facelessUIImport","useLexicalComposerContext","formatDrawerSlug","BlocksDrawer","useEditDepth","useTranslation","$getNodeByKey","COMMAND_PRIORITY_EDITOR","createCommand","React","useCallback","useEffect","useState","useEditorConfigContext","$createBlockNode","INSERT_BLOCK_COMMAND","baseClass","INSERT_BLOCK_WITH_DRAWER_COMMAND","insertBlock","blockType","editor","replaceNodeKey","dispatchCommand","id","blockName","update","node","replace","BlocksDrawerComponent","useModal","editorConfig","uuid","setReplaceNodeKey","editDepth","t","openModal","labels","plural","singular","addRow","rowIndex","drawerSlug","slug","depth","reducedBlocks","resolvedFeatureMap","get","clientFeatureProps","registerCommand","payload","nodeKey","addRowIndex","blocks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,YAAYA,sBAAsB,qBAAoB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,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AAY;YACVC;YACAC;YACAC;QACF;IACF,GACA;QAACD;QAAQC;KAAe;IAG1B,MAAMoB,aAAavC,iBAAiB;QAClCwC,MAAM,CAAC,yBAAyB,CAAC,GAAGX;QACpCY,OAAOV;IACT;IAEA,MAAMW,gBACJd,cAAce,oBAAoBC,IAAI,WAClCC,oBACHH;IAEHjC,UAAU;QACR,OAAOS,OAAO4B,eAAe,CAG3B/B,kCACA,CAACgC;YACCjB,kBAAkBiB,SAAStB,UAAUsB,SAAStB,QAAQuB,UAAU;YAChEf,UAAUM;YACV,OAAO;QACT,GACAlC;IAEJ,GAAG;QAACa;QAAQqB;QAAYN;KAAU;IAElC,qBACE,oBAAChC;QACCoC,QAAQA;QACRY,aAAa;QACbC,QAAQR;QACRH,YAAYA;QACZL,QAAQA;;AAGd,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/feature.server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/feature.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAqB,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAM9F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG;IACjD,MAAM,EAAE,+BAA+B,EAAE,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,YAAY,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAsKzB,CAAA"}
|