@payloadcms/richtext-lexical 3.0.0-beta.2 → 3.0.0-beta.20
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 +105 -33
- 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 -5
- 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 +21 -23
- 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.js +1 -1
- 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/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.map +1 -1
- package/dist/field/features/link/feature.server.js +30 -7
- 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 +20 -17
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/link/index.js +3 -6
- 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 +28 -26
- package/dist/field/features/link/populationPromise.js.map +1 -1
- 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 +3 -5
- 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 +52 -32
- 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 +25 -9
- 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.d.ts.map +1 -1
- package/dist/field/features/upload/populationPromise.js +22 -9
- package/dist/field/features/upload/populationPromise.js.map +1 -1
- package/dist/field/features/upload/validate.d.ts.map +1 -1
- package/dist/field/features/upload/validate.js +7 -7
- 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 +5 -10
- 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 +1 -1
- package/dist/field/lexical/config/server/default.d.ts.map +1 -1
- package/dist/field/lexical/config/server/default.js +3 -1
- package/dist/field/lexical/config/server/default.js.map +1 -1
- package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/server/sanitize.js +20 -6
- 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 +3 -6
- 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/url.d.ts.map +1 -1
- package/dist/field/lexical/utils/url.js +1 -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 +22 -19
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.js +10 -9
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -23
- 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 +3 -4
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/component/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler } from '@payloadcms/ui/elements/Drawer'\nimport { useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n //uploadProps: UploadFeatureProps\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (json) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.clientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n {hasExtraFields ? (\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","lexicalImport","$getNodeByKey","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","File","usePayloadAPI","useConfig","useTranslation","React","useCallback","useReducer","useState","useEditorConfigContext","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","ExtraFieldsUploadDrawer","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","collections","routes","api","serverURL","editor","isSelected","setSelected","clearSelection","editorConfig","field","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","id","collectionSlug","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","update","remove","updateUpload","json","hasExtraFields","resolvedFeatureMap","get","clientFeatureProps","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","isEditable","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","dispatchCommand","replace","strong","onSave","UploadComponent","uploads"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,aAAa,QAAQ,iCAAgC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AQ,EAAExC,QAEpDN,OAAO+C,UAAU,oBAChB,oBAACZ;QAAIC,WAAW,CAAC,EAAElD,UAAU,SAAS,CAAC;OACpC6C,+BACC,oBAAC3D;QACCgE,WAAW,CAAC,EAAElD,UAAU,uBAAuB,CAAC;QAChD8D,UAAU3C,OAAO4C;QACjBlC,MAAMC;qBAEN,oBAAC9C;QACCgF,aAAY;QACZC,IAAG;QACHC,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;QAClB;QACAC,OAAAA;QACAC,SAASlD,EAAE;UAGb,oBAEJ,oBAACrC;QACCgF,aAAY;QACZF,UAAU3C,OAAO4C;QACjBE,IAAG;QACHC,MAAK;QACLC,SAAS;YACPrD,OAAO0D,eAAe,CAAC1E,mCAAmC;gBACxD2E,SAAS;oBAAEhE;gBAAQ;YACrB;QACF;QACA6D,OAAAA;QACAC,SAASlD,EAAE;sBAEb,oBAACrC;QACCgF,aAAY;QACZd,WAAW,CAAC,EAAElD,UAAU,cAAc,CAAC;QACvC8D,UAAU3C,OAAO4C;QACjBG,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA8B,OAAAA;QACAC,SAASlD,EAAE;yBAMrB,oBAAC4B;QAAIC,WAAW,CAAC,EAAElD,UAAU,WAAW,CAAC;qBACvC,oBAACgC;QAAsBkB,WAAW,CAAC,EAAElD,UAAU,oBAAoB,CAAC;qBAClE,oBAAC0E,gBAAQrE,MAAMoD,cAIpBjD,OAAO0B,oBAAM,oBAACH;QAAe4C,QAAQhC;QACrCE,+BACC,oBAAC9C;QACC+B,YAAYA;QACZL,mBAAmBA;QAClB,GAAGrB,KAAK;SAET;AAGV;AAEA,OAAO,MAAMwE,kBAAkB,CAACxE;IAC9B,qBACE,oBAACP;QAA+B,GAAGO,KAAK;QAAEyE,SAAAA;qBACxC,oBAAC1E,WAAcC;AAGrB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/upload/component/index.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection } from 'lexical'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler } from '@payloadcms/ui/elements/Drawer'\nimport { useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isUploadNode } from '../nodes/UploadNode.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (json) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const onDelete = useCallback(\n (payload: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isUploadNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if uploadRef.target or anything WITHIN uploadRef.target was clicked\n if (event.target === uploadRef.current || uploadRef.current?.contains(event.target as Node)) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n clearSelection()\n setSelected(true)\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected, onClick])\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.clientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value && <DocumentDrawer onSave={updateUpload} />}\n {hasExtraFields ? (\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","File","usePayloadAPI","useConfig","useTranslation","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","$isUploadNode","ExtraFieldsUploadDrawer","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","collections","routes","api","serverURL","uploadRef","editor","isSelected","setSelected","clearSelection","editorConfig","field","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","id","collectionSlug","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","update","remove","updateUpload","json","onDelete","payload","event","preventDefault","node","onClick","target","current","contains","shiftKey","registerCommand","hasExtraFields","resolvedFeatureMap","get","clientFeatureProps","div","className","filter","Boolean","join","contentEditable","ref","img","alt","filename","src","labels","singular","isEditable","disabled","readOnly","buttonStyle","el","icon","e","round","tooltip","dispatchCommand","replace","strong","onSave","UploadComponent","uploads"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,IAAI,QAAQ,+BAA8B;AACnD,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SACEC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb,UAAS;AAChB,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAMnF,SAASC,sBAAsB,QAAQ,yDAAwD;AAC/F,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,iCAAiC,QAAQ,wBAAuB;AACzE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAOA,MAAMC,YAAoC,CAACC;IACzC,MAAM,EACJC,MAAM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W,CAAC,EAAE9D,UAAU,oBAAoB,CAAC;qBAClE,oBAACqF,gBAAQhF,MAAMiE,cAIpB9D,uBAAS,oBAACwB;QAAesD,QAAQ1C;QACjCa,+BACC,oBAAC1D;QACCgC,YAAYA;QACZL,mBAAmBA;QAClB,GAAGtB,KAAK;SAET;AAGV;AAEA,OAAO,MAAMmF,kBAAkB,CAACnF;IAC9B,qBACE,oBAACR;QAA+B,GAAGQ,KAAK;QAAEoF,SAAAA;qBACxC,oBAACrF,WAAcC;AAGrB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/drawer/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/drawer/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,eAAO,MAAM,iCAAiC,EAAE,cAAc,CAAC;IAC7D,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAA;CACrC,CAAsD,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
const { createCommand } = lexicalImport;
|
|
2
|
+
import { createCommand } from 'lexical';
|
|
4
3
|
export const INSERT_UPLOAD_WITH_DRAWER_COMMAND = createCommand('INSERT_UPLOAD_WITH_DRAWER_COMMAND');
|
|
5
4
|
|
|
6
5
|
//# sourceMappingURL=commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/drawer/commands.ts"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/upload/drawer/commands.ts"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nexport const INSERT_UPLOAD_WITH_DRAWER_COMMAND: LexicalCommand<{\n replace: { nodeKey: string } | false\n}> = createCommand('INSERT_UPLOAD_WITH_DRAWER_COMMAND')\n"],"names":["createCommand","INSERT_UPLOAD_WITH_DRAWER_COMMAND"],"rangeMappings":";;","mappings":"AAAA;AAGA,SAASA,aAAa,QAAQ,UAAS;AAEvC,OAAO,MAAMC,oCAERD,cAAc,qCAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA2C,MAAM,OAAO,CAAA;AA4C/D,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,MAAM,EAAE,CAAA;CACjC,CAAA;AA0CD,eAAO,MAAM,YAAY,UAAW,KAAK,KAAG,MAAM,SAMjD,CAAA"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
const { useLexicalComposerContext } = lexicalComposerContextImport;
|
|
4
|
-
import lexicalImport from 'lexical';
|
|
5
|
-
const { $getNodeByKey, COMMAND_PRIORITY_EDITOR } = lexicalImport;
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
3
|
import { useListDrawer } from '@payloadcms/ui/elements/ListDrawer';
|
|
4
|
+
import { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
7
5
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
8
6
|
import { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js';
|
|
9
7
|
import { $createUploadNode } from '../nodes/UploadNode.js';
|
|
10
8
|
import { INSERT_UPLOAD_COMMAND } from '../plugin/index.js';
|
|
11
9
|
import { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from './commands.js';
|
|
12
10
|
const baseClass = 'lexical-upload-drawer';
|
|
13
|
-
const insertUpload = ({
|
|
11
|
+
const insertUpload = ({ editor, relationTo, replaceNodeKey, value })=>{
|
|
14
12
|
if (!replaceNodeKey) {
|
|
15
13
|
editor.dispatchCommand(INSERT_UPLOAD_COMMAND, {
|
|
16
|
-
id,
|
|
17
14
|
fields: null,
|
|
18
|
-
relationTo
|
|
15
|
+
relationTo,
|
|
16
|
+
value
|
|
19
17
|
});
|
|
20
18
|
} else {
|
|
21
19
|
editor.update(()=>{
|
|
@@ -25,9 +23,7 @@ const insertUpload = ({ id, editor, relationTo, replaceNodeKey })=>{
|
|
|
25
23
|
data: {
|
|
26
24
|
fields: null,
|
|
27
25
|
relationTo,
|
|
28
|
-
value
|
|
29
|
-
id
|
|
30
|
-
}
|
|
26
|
+
value
|
|
31
27
|
}
|
|
32
28
|
}));
|
|
33
29
|
}
|
|
@@ -53,10 +49,10 @@ const UploadDrawerComponent = ({ enabledCollectionSlugs })=>{
|
|
|
53
49
|
]);
|
|
54
50
|
const onSelect = useCallback(({ collectionSlug, docID })=>{
|
|
55
51
|
insertUpload({
|
|
56
|
-
id: docID,
|
|
57
52
|
editor,
|
|
58
53
|
relationTo: collectionSlug,
|
|
59
|
-
replaceNodeKey
|
|
54
|
+
replaceNodeKey,
|
|
55
|
+
value: docID
|
|
60
56
|
});
|
|
61
57
|
closeDrawer();
|
|
62
58
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/upload/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useListDrawer } from '@payloadcms/ui/elements/ListDrawer'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { $createUploadNode } from '../nodes/UploadNode.js'\nimport { INSERT_UPLOAD_COMMAND } from '../plugin/index.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst baseClass = 'lexical-upload-drawer'\n\nconst insertUpload = ({\n editor,\n relationTo,\n replaceNodeKey,\n value,\n}: {\n editor: LexicalEditor\n relationTo: string\n replaceNodeKey: null | string\n value: number | string\n}) => {\n if (!replaceNodeKey) {\n editor.dispatchCommand(INSERT_UPLOAD_COMMAND, {\n fields: null,\n relationTo,\n value,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace(\n $createUploadNode({\n data: {\n fields: null,\n relationTo,\n value,\n },\n }),\n )\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n}\n\nconst UploadDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer, openDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n uploads: true,\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_UPLOAD_WITH_DRAWER_COMMAND,\n (payload) => {\n setReplaceNodeKey(payload?.replace ? payload?.replace.nodeKey : null)\n openDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openDrawer])\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertUpload({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: docID,\n })\n closeDrawer()\n },\n [editor, closeDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nexport const UploadDrawer = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <UploadDrawerComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useLexicalComposerContext","useListDrawer","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","EnabledRelationshipsCondition","$createUploadNode","INSERT_UPLOAD_COMMAND","INSERT_UPLOAD_WITH_DRAWER_COMMAND","baseClass","insertUpload","editor","relationTo","replaceNodeKey","value","dispatchCommand","fields","update","node","replace","data","UploadDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","ListDrawer","ListDrawerToggler","closeDrawer","openDrawer","collectionSlugs","uploads","registerCommand","payload","nodeKey","onSelect","collectionSlug","docID","UploadDrawer","props"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,aAAa,EAAEC,uBAAuB,QAAQ,UAAS;AAChE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,iCAAiC,QAAQ,gBAAe;AAEjE,MAAMC,YAAY;AAElB,MAAMC,eAAe,CAAC,EACpBC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,KAAK,EAMN;IACC,IAAI,CAACD,gBAAgB;QACnBF,OAAOI,eAAe,CAACR,uBAAuB;YAC5CS,QAAQ;YACRJ;YACAE;QACF;IACF,OAAO;QACLH,OAAOM,MAAM,CAAC;YACZ,MAAMC,OAAOnB,cAAcc;YAC3B,IAAIK,MAAM;gBACRA,KAAKC,OAAO,CACVb,kBAAkB;oBAChBc,MAAM;wBACJJ,QAAQ;wBACRJ;wBACAE;oBACF;gBACF;YAEJ;QACF;IACF;AACF;AAMA,MAAMO,wBAAyC,CAAC,EAAEC,sBAAsB,EAAE;IACxE,MAAM,CAACX,OAAO,GAAGd;IAEjB,MAAM,CAACgB,gBAAgBU,kBAAkB,GAAGnB,SAAwB;IAEpE,MAAM,CAACoB,YAAYC,mBAAmB,EAAEC,WAAW,EAAEC,UAAU,EAAE,CAAC,GAAG7B,cAAc;QACjF8B,iBAAiBN;QACjBO,SAAS;IACX;IAEA1B,UAAU;QACR,OAAOQ,OAAOmB,eAAe,CAG3BtB,mCACA,CAACuB;YACCR,kBAAkBQ,SAASZ,UAAUY,SAASZ,QAAQa,UAAU;YAChEL;YACA,OAAO;QACT,GACA3B;IAEJ,GAAG;QAACW;QAAQgB;KAAW;IAEvB,MAAMM,WAAW/B,YACf,CAAC,EAAEgC,cAAc,EAAEC,KAAK,EAAE;QACxBzB,aAAa;YACXC;YACAC,YAAYsB;YACZrB;YACAC,OAAOqB;QACT;QACAT;IACF,GACA;QAACf;QAAQe;QAAab;KAAe;IAGvC,qBAAO,oBAACW;QAAWS,UAAUA;;AAC/B;AAEA,OAAO,MAAMG,eAAe,CAACC;IAC3B,qBACE,oBAAChC;QAA+B,GAAGgC,KAAK;QAAER,SAAAA;qBACxC,oBAACR,uBAA0BgB;AAGjC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,+BAA+B,EAKhC,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE;QACX,CAAC,UAAU,EAAE,MAAM,GAAG;YACpB,MAAM,EAAE,+BAA+B,EAAE,CAAA;SAC1C,CAAA;KACF,CAAA;CACF,CAAA;AASD,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAsIzB,CAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { traverseFields } from '@payloadcms/next/utilities';
|
|
2
|
+
import { createNode } from '../typeUtilities.js';
|
|
1
3
|
import { UploadFeatureClientComponent } from './feature.client.js';
|
|
2
4
|
import { UploadNode } from './nodes/UploadNode.js';
|
|
3
5
|
import { uploadPopulationPromiseHOC } from './populationPromise.js';
|
|
@@ -28,24 +30,38 @@ export const UploadFeature = (props)=>{
|
|
|
28
30
|
return {
|
|
29
31
|
ClientComponent: UploadFeatureClientComponent,
|
|
30
32
|
clientFeatureProps: clientProps,
|
|
31
|
-
generateSchemaMap: ({ props })=>{
|
|
32
|
-
if (!props?.collections) return
|
|
33
|
-
const
|
|
33
|
+
generateSchemaMap: ({ config, i18n, props })=>{
|
|
34
|
+
if (!props?.collections) return null;
|
|
35
|
+
const schemaMap = new Map();
|
|
36
|
+
const validRelationships = config.collections.map((c)=>c.slug) || [];
|
|
34
37
|
for(const collection in props.collections){
|
|
35
|
-
|
|
38
|
+
if (props.collections[collection].fields?.length) {
|
|
39
|
+
schemaMap.set(collection, props.collections[collection].fields);
|
|
40
|
+
traverseFields({
|
|
41
|
+
config,
|
|
42
|
+
fields: props.collections[collection].fields,
|
|
43
|
+
i18n,
|
|
44
|
+
schemaMap,
|
|
45
|
+
schemaPath: collection,
|
|
46
|
+
validRelationships
|
|
47
|
+
});
|
|
48
|
+
}
|
|
36
49
|
}
|
|
37
|
-
return
|
|
50
|
+
return schemaMap;
|
|
38
51
|
},
|
|
39
52
|
nodes: [
|
|
40
|
-
{
|
|
53
|
+
createNode({
|
|
41
54
|
converters: {
|
|
42
55
|
html: {
|
|
43
56
|
converter: async ({ node, payload })=>{
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
const id = node?.value?.id || node?.value // for backwards-compatibility
|
|
59
|
+
;
|
|
44
60
|
if (payload) {
|
|
45
61
|
let uploadDocument;
|
|
46
62
|
try {
|
|
47
63
|
uploadDocument = await payload.findByID({
|
|
48
|
-
id
|
|
64
|
+
id,
|
|
49
65
|
collection: node.relationTo
|
|
50
66
|
});
|
|
51
67
|
} catch (ignored) {
|
|
@@ -82,7 +98,7 @@ export const UploadFeature = (props)=>{
|
|
|
82
98
|
pictureHTML += '</picture>';
|
|
83
99
|
return pictureHTML;
|
|
84
100
|
} else {
|
|
85
|
-
return `<img src="${
|
|
101
|
+
return `<img src="${id}" />`;
|
|
86
102
|
}
|
|
87
103
|
},
|
|
88
104
|
nodeTypes: [
|
|
@@ -97,7 +113,7 @@ export const UploadFeature = (props)=>{
|
|
|
97
113
|
validations: [
|
|
98
114
|
uploadValidation()
|
|
99
115
|
]
|
|
100
|
-
}
|
|
116
|
+
})
|
|
101
117
|
],
|
|
102
118
|
serverFeatureProps: props
|
|
103
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type { Field, FieldWithRichTextRequiredEditor, Payload } from 'payload/types'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { type SerializedUploadNode, UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\n}\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection].fields.length >= 1,\n }\n }\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ props }) => {\n if (!props?.collections) return {}\n\n const map: {\n [key: string]: Field[]\n } = {}\n\n for (const collection in props.collections) {\n map[collection] = props.collections[collection].fields\n }\n\n return map\n },\n nodes: [\n {\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n if (payload) {\n let uploadDocument: any\n try {\n uploadDocument = await payload.findByID({\n id: node.value.id,\n collection: node.relationTo,\n })\n } catch (ignored) {\n // eslint-disable-next-line no-console\n console.error(\n 'Lexical upload node HTML converter: error fetching upload file',\n ignored,\n 'Node:',\n node,\n )\n return `<img />`\n }\n\n const url: string = getAbsoluteURL(uploadDocument?.url as string, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!(uploadDocument?.mimeType as string)?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.sizes) {\n const imageSize = uploadDocument.sizes[size]\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL: string = getAbsoluteURL(imageSize?.url as string, payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${node.value.id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n } as HTMLConverter<SerializedUploadNode>,\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation()],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","ClientComponent","clientFeatureProps","generateSchemaMap","map","nodes","converters","html","converter","node","uploadDocument","findByID","id","value","relationTo","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,4BAA4B,QAAQ,sBAAqB;AAClE,SAAoCC,UAAU,QAAQ,wBAAuB;AAC7E,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,gBAAgB,QAAQ,gBAAe;AAUhD;;CAEC,GAC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;gCACAkB,WAAW;oCAAC/C,WAAWgD,OAAO;iCAAG;4BACnC;wBACF;wBACAtB,MAAM1B;wBACNiD,oBAAoB;4BAAChD,2BAA2BS;yBAAO;wBACvDwC,aAAa;4BAAChD;yBAAmB;oBACnC;iBACD;gBACDiD,oBAAoBzC;YACtB;QACF;QACA0C,KAAK;QACLD,oBAAoBzC;IACtB;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type {\n Field,\n FieldWithRichTextRequiredEditor,\n FileData,\n FileSize,\n Payload,\n TypeWithID,\n} from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\n}\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection].fields.length >= 1,\n }\n }\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n if (!props?.collections) return null\n\n const schemaMap = new Map<string, Field[]>()\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const collection in props.collections) {\n if (props.collections[collection].fields?.length) {\n schemaMap.set(collection, props.collections[collection].fields)\n traverseFields({\n config,\n fields: props.collections[collection].fields,\n i18n,\n schemaMap,\n schemaPath: collection,\n validRelationships,\n })\n }\n }\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n if (payload) {\n let uploadDocument: TypeWithID & FileData\n\n try {\n uploadDocument = (await payload.findByID({\n id,\n collection: node.relationTo,\n })) as TypeWithID & FileData\n } catch (ignored) {\n // eslint-disable-next-line no-console\n console.error(\n 'Lexical upload node HTML converter: error fetching upload file',\n ignored,\n 'Node:',\n node,\n )\n return `<img />`\n }\n\n const url = getAbsoluteURL(uploadDocument?.url, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.mimeType?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.sizes) {\n const imageSize: FileSize & {\n url?: string\n } = uploadDocument.sizes[size]\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = getAbsoluteURL(imageSize?.url, payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n },\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation()],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","createNode","UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","validRelationships","map","c","slug","set","schemaPath","nodes","converters","html","converter","node","id","value","uploadDocument","findByID","relationTo","ignored","console","error","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,cAAc,QAAQ,6BAA4B;AAK3D,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,UAAU,QAAQ,wBAAuB;AAClD,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,gBAAgB,QAAQ,gBAAe;AAUhD;;CAEC,GACD,SAASC,eAAeC,GAAW,EAAEC,OAAgB;IACnD,OAAOD,KAAKE,WAAW,UAAUF,MAAM,AAACC,CAAAA,SAASE,QAAQC,aAAa,EAAC,IAAKJ;AAC9E;AAEA,OAAO,MAAMK,gBAGT,CAACC;IACH,IAAI,CAACA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C,eAAeW,KAAK,CAAC,UAAU,EAAEX,eAAeY,MAAM,CAAC,EAAE,CAAC;wCACjHC,eAAe;wCACf,OAAOA;oCACT,OAAO;wCACL,OAAO,CAAC,UAAU,EAAEf,GAAG,IAAI,CAAC;oCAC9B;gCACF;gCACAoB,WAAW;oCAACvD,WAAWwD,OAAO;iCAAG;4BACnC;wBACF;wBACAtB,MAAMlC;wBACNyD,oBAAoB;4BAACxD,2BAA2BS;yBAAO;wBACvDgD,aAAa;4BAACxD;yBAAmB;oBACnC;iBACD;gBACDyD,oBAAoBjD;YACtB;QACF;QACAkD,KAAK;QACLD,oBAAoBjD;IACtB;AACF,EAAC"}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
3
3
|
import type { ElementFormatType, NodeKey } from 'lexical';
|
|
4
|
-
import lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
5
|
-
declare const DecoratorBlockNode: typeof lexicalDecoratorBlockNodeImport.DecoratorBlockNode;
|
|
6
4
|
import type { DOMConversionMap, DOMExportOutput, LexicalNode, Spread } from 'lexical';
|
|
7
|
-
|
|
8
|
-
fields: {
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
id: string;
|
|
12
|
-
relationTo: string;
|
|
13
|
-
};
|
|
5
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
14
6
|
export type UploadData = {
|
|
15
7
|
fields: {
|
|
16
8
|
[key: string]: unknown;
|
|
17
9
|
};
|
|
18
10
|
relationTo: string;
|
|
19
|
-
value:
|
|
20
|
-
[key: string]: unknown;
|
|
21
|
-
id: string;
|
|
22
|
-
};
|
|
11
|
+
value: number | string;
|
|
23
12
|
};
|
|
24
13
|
export type SerializedUploadNode = Spread<UploadData, SerializedDecoratorBlockNode>;
|
|
25
14
|
export declare class UploadNode extends DecoratorBlockNode {
|
|
@@ -45,5 +34,4 @@ export declare function $createUploadNode({ data }: {
|
|
|
45
34
|
data: UploadData;
|
|
46
35
|
}): UploadNode;
|
|
47
36
|
export declare function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode;
|
|
48
|
-
export {};
|
|
49
37
|
//# sourceMappingURL=UploadNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,WAAW,EACX,MAAM,EACP,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAQhF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE;QAEN,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB,CAAA;AAQD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,UAAU,EAAE,4BAA4B,CAAC,CAAA;AAEnF,qBAAa,UAAW,SAAQ,kBAAkB;IAChD,MAAM,EAAE,UAAU,CAAA;gBAEN,EACV,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;QACD,IAAI,EAAE,UAAU,CAAA;QAChB,MAAM,CAAC,EAAE,iBAAiB,CAAA;QAC1B,GAAG,CAAC,EAAE,OAAO,CAAA;KACd;IAKD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;IAQ1C,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAS3C,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,oBAAoB,GAAG,UAAU;IAiBnE,MAAM,CAAC,QAAQ,IAAI,KAAK;IAIxB,QAAQ,IAAI,GAAG,CAAC,OAAO;IAKvB,SAAS,IAAI,eAAe;IAO5B,UAAU,IAAI,oBAAoB;IASlC,OAAO,IAAI,UAAU;IAIrB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAM/B,SAAS,IAAI,KAAK;CAGnB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAE5E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,UAAU,CAEtF"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import lexicalImport from 'lexical';
|
|
4
|
-
const { $applyNodeReplacement } = lexicalImport;
|
|
1
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
|
+
import { $applyNodeReplacement } from 'lexical';
|
|
5
3
|
import * as React from 'react';
|
|
6
4
|
const RawUploadComponent = /*#__PURE__*/ React.lazy(()=>import('../component/index.js').then((module)=>({
|
|
7
5
|
default: module.UploadComponent
|
|
8
6
|
})));
|
|
9
7
|
function convertUploadElement(domNode) {
|
|
10
|
-
//if (domNode instanceof HTMLImageElement) {
|
|
11
|
-
// const { alt: altText, src } = domNode;
|
|
12
|
-
// const node = $createImageNode({ altText, src });
|
|
13
|
-
// return { node };
|
|
14
8
|
// TODO: Auto-upload functionality here!
|
|
15
9
|
//}
|
|
16
10
|
return null;
|
|
@@ -40,6 +34,9 @@ export class UploadNode extends DecoratorBlockNode {
|
|
|
40
34
|
};
|
|
41
35
|
}
|
|
42
36
|
static importJSON(serializedNode) {
|
|
37
|
+
if (serializedNode.version === 1 && serializedNode?.value?.id) {
|
|
38
|
+
serializedNode.value = serializedNode.value.id;
|
|
39
|
+
}
|
|
43
40
|
const importedData = {
|
|
44
41
|
fields: serializedNode.fields,
|
|
45
42
|
relationTo: serializedNode.relationTo,
|
|
@@ -75,7 +72,7 @@ export class UploadNode extends DecoratorBlockNode {
|
|
|
75
72
|
...super.exportJSON(),
|
|
76
73
|
...this.getData(),
|
|
77
74
|
type: this.getType(),
|
|
78
|
-
version:
|
|
75
|
+
version: 2
|
|
79
76
|
};
|
|
80
77
|
}
|
|
81
78
|
getData() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { ElementFormatType, NodeKey } from 'lexical'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/upload/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { ElementFormatType, NodeKey } from 'lexical'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n Spread,\n} from 'lexical'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type UploadData = {\n fields: {\n // unknown, custom fields:\n [key: string]: unknown\n }\n relationTo: string\n value: number | string\n}\n\nfunction convertUploadElement(domNode: Node): DOMConversionOutput | null {\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static clone(node: UploadNode): UploadNode {\n return new UploadNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'upload'\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n img: (node: Node) => ({\n conversion: convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static importJSON(serializedNode: SerializedUploadNode): UploadNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: UploadData = {\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n // element.setAttribute('src', this.__src);\n // element.setAttribute('alt', this.__altText); //TODO\n return { element }\n }\n\n exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: this.getType(),\n version: 2,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n // eslint-disable-next-line class-methods-use-this\n updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadNode({ data }: { data: UploadData }): UploadNode {\n return $applyNodeReplacement(new UploadNode({ data }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],"names":["DecoratorBlockNode","$applyNodeReplacement","React","RawUploadComponent","lazy","then","module","default","UploadComponent","convertUploadElement","domNode","UploadNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","priority","importJSON","serializedNode","version","value","id","importedData","fields","relationTo","$createUploadNode","setFormat","isInline","decorate","nodeKey","getKey","exportDOM","element","document","createElement","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAUA,SAASA,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,YAAYC,WAAW,QAAO;AAE9B,MAAMC,mCAAqBD,MAAME,IAAI,CAAC,IACpC,MAAM,CAAC,yBAAyBC,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,eAAe;QAAC,CAAA;AAYtF,SAASC,qBAAqBC,OAAa;IACzC,wCAAwC;IACxC,GAAG;IACH,OAAO;AACT;AAIA,OAAO,MAAMC,mBAAmBX;IAC9BY,OAAkB;IAElBC,YAAY,EACVC,IAAI,EACJC,MAAM,EACNC,GAAG,EAKJ,CAAE;QACD,KAAK,CAACD,QAAQC;QACd,IAAI,CAACJ,MAAM,GAAGE;IAChB;IAEA,OAAOG,MAAMC,IAAgB,EAAc;QACzC,OAAO,IAAIP,WAAW;YACpBG,MAAMI,KAAKN,MAAM;YACjBG,QAAQG,KAAKC,QAAQ;YACrBH,KAAKE,KAAKE,KAAK;QACjB;IACF;IAEA,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,YAAqC;QAC1C,OAAO;YACLC,KAAK,CAACL,OAAgB,CAA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ACrD;AAEA,OAAO,SAASsC,cAAclC,IAAoC;IAChE,OAAOA,gBAAgBP;AACzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import type { LexicalCommand } from 'lexical';
|
|
3
|
-
import type {
|
|
4
|
-
export type InsertUploadPayload = Readonly<
|
|
3
|
+
import type { UploadData } from '../nodes/UploadNode.js';
|
|
4
|
+
export type InsertUploadPayload = Readonly<UploadData>;
|
|
5
5
|
export declare const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload>;
|
|
6
6
|
export declare function UploadPlugin(): JSX.Element | null;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKxD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;AAEtD,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,wBAAgB,YAAY,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAqDjD"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import lexicalUtilsImport from '@lexical/utils';
|
|
5
|
-
const { $insertNodeToNearestRoot, mergeRegister } = lexicalUtilsImport;
|
|
6
|
-
import lexicalImport from 'lexical';
|
|
7
|
-
const { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } = lexicalImport;
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
3
|
+
import { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils';
|
|
8
4
|
import { useConfig } from '@payloadcms/ui/providers/Config';
|
|
5
|
+
import { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
9
6
|
import React, { useEffect } from 'react';
|
|
10
7
|
import { UploadDrawer } from '../drawer/index.js';
|
|
11
8
|
import { $createUploadNode, UploadNode } from '../nodes/UploadNode.js';
|
|
@@ -25,9 +22,7 @@ export function UploadPlugin() {
|
|
|
25
22
|
data: {
|
|
26
23
|
fields: payload.fields,
|
|
27
24
|
relationTo: payload.relationTo,
|
|
28
|
-
value:
|
|
29
|
-
id: payload.id
|
|
30
|
-
}
|
|
25
|
+
value: payload.value
|
|
31
26
|
}
|
|
32
27
|
});
|
|
33
28
|
const selection = $getSelection() || $getPreviousSelection();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/features/upload/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<UploadData>\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\nexport function UploadPlugin(): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const uploadNode = $createUploadNode({\n data: {\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(uploadNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={collections.map(({ slug }) => slug)} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","mergeRegister","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","React","useEffect","UploadDrawer","$createUploadNode","UploadNode","INSERT_UPLOAD_COMMAND","UploadPlugin","editor","collections","hasNodes","Error","registerCommand","payload","update","uploadNode","data","fields","relationTo","value","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove","enabledCollectionSlugs","map","slug"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,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L;QAAa4B,wBAAwBtB,YAAYuB,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;;AAC7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/populationPromise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/populationPromise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAKjE,eAAO,MAAM,0BAA0B,WAC7B,kBAAkB,KACzB,kBAAkB,oBAAoB,CAyExC,CAAA"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { sanitizeFields } from 'payload/config';
|
|
1
2
|
import { populate } from '../../../populate/populate.js';
|
|
2
3
|
import { recurseNestedFields } from '../../../populate/recurseNestedFields.js';
|
|
3
4
|
export const uploadPopulationPromiseHOC = (props)=>{
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
if (node?.value
|
|
5
|
+
return ({ context, currentDepth, depth, editorPopulationPromises, field, fieldPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields })=>{
|
|
6
|
+
const payloadConfig = req.payload.config;
|
|
7
|
+
if (node?.value) {
|
|
7
8
|
const collection = req.payload.collections[node?.relationTo];
|
|
8
9
|
if (collection) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
const id = node?.value?.id || node?.value // for backwards-compatibility
|
|
12
|
+
;
|
|
13
|
+
populationPromises.push(populate({
|
|
14
|
+
id,
|
|
11
15
|
collection,
|
|
12
16
|
currentDepth,
|
|
13
17
|
data: node,
|
|
@@ -20,27 +24,36 @@ export const uploadPopulationPromiseHOC = (props)=>{
|
|
|
20
24
|
}));
|
|
21
25
|
}
|
|
22
26
|
if (Array.isArray(props?.collections?.[node?.relationTo]?.fields)) {
|
|
27
|
+
const validRelationships = payloadConfig.collections.map((c)=>c.slug) || [];
|
|
28
|
+
// TODO: Sanitize & transform ahead of time! On startup!
|
|
29
|
+
const sanitizedFields = sanitizeFields({
|
|
30
|
+
config: payloadConfig,
|
|
31
|
+
fields: props?.collections?.[node?.relationTo]?.fields,
|
|
32
|
+
requireFieldLevelRichTextEditor: true,
|
|
33
|
+
validRelationships
|
|
34
|
+
});
|
|
35
|
+
if (!sanitizedFields?.length) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
23
38
|
recurseNestedFields({
|
|
24
39
|
context,
|
|
25
40
|
currentDepth,
|
|
26
41
|
data: node.fields || {},
|
|
27
42
|
depth,
|
|
28
43
|
editorPopulationPromises,
|
|
29
|
-
|
|
44
|
+
fieldPromises,
|
|
45
|
+
fields: sanitizedFields,
|
|
30
46
|
findMany,
|
|
31
47
|
flattenLocales,
|
|
32
48
|
overrideAccess,
|
|
33
49
|
populationPromises,
|
|
34
|
-
promises,
|
|
35
50
|
req,
|
|
36
51
|
showHiddenFields,
|
|
37
52
|
siblingDoc: node.fields || {}
|
|
38
53
|
});
|
|
39
54
|
}
|
|
40
55
|
}
|
|
41
|
-
return promises;
|
|
42
56
|
};
|
|
43
|
-
return uploadPopulationPromise;
|
|
44
57
|
};
|
|
45
58
|
|
|
46
59
|
//# sourceMappingURL=populationPromise.js.map
|