@payloadcms/richtext-lexical 3.68.0-internal-debug.185cc5f → 3.68.0-internal-debug.dafc24d
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/rscEntry.js +13 -5
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +29 -9
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -3
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +123 -43
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.scss +188 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +7 -3
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +117 -37
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.scss +90 -0
- package/dist/features/blocks/client/getBlockImageComponent.js +7 -3
- package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +7 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +7 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +87 -27
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +7 -3
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +12 -4
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.scss +6 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +18 -6
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.scss +29 -0
- package/dist/features/blocks/premade/CodeBlock/Component/index.scss +97 -0
- package/dist/features/converters/lexicalToJSX/Component/index.js +9 -5
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +7 -3
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +7 -3
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +6 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +6 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js +13 -5
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js +38 -14
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +18 -6
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js +31 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js +43 -15
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +31 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +8 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +13 -5
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/style.scss +12 -0
- package/dist/features/debug/testRecorder/client/plugin/index.js +61 -21
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.scss +53 -0
- package/dist/features/debug/treeView/client/plugin/index.js +7 -3
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.scss +80 -0
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +224 -72
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.scss +87 -0
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +31 -11
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.scss +11 -0
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +21 -9
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +25 -9
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.scss +233 -0
- package/dist/features/horizontalRule/client/plugin/index.scss +23 -0
- package/dist/features/indent/client/IndentPlugin.js +6 -2
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/link/client/plugins/clickableLink/index.js +6 -2
- package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +76 -24
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +7 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.scss +92 -0
- package/dist/features/lists/checklist/client/plugin/index.js +6 -2
- package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
- package/dist/features/lists/plugin/index.js +6 -2
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +13 -5
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +7 -3
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.scss +16 -0
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +13 -5
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +7 -3
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.scss +16 -0
- package/dist/features/relationship/client/components/RelationshipComponent.js +55 -19
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/components/index.scss +95 -0
- package/dist/features/relationship/client/drawer/index.js +18 -6
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +7 -3
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +7 -3
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/textState/feature.client.js +18 -6
- package/dist/features/textState/feature.client.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +71 -23
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.scss +113 -0
- package/dist/features/toolbars/inline/client/Toolbar/index.js +71 -23
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.scss +58 -0
- package/dist/features/toolbars/shared/ToolbarButton/index.js +7 -3
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.scss +46 -0
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +60 -20
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +36 -12
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.scss +129 -0
- package/dist/features/upload/client/component/index.js +91 -31
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/index.scss +191 -0
- package/dist/features/upload/client/component/pending/index.js +13 -5
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js +18 -6
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +12 -4
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +7 -3
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +36 -12
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.scss +47 -0
- package/dist/field/Diff/converters/relationship/index.js +36 -12
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.scss +73 -0
- package/dist/field/Diff/converters/unknown/index.js +30 -10
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.scss +40 -0
- package/dist/field/Diff/converters/upload/index.js +59 -19
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.scss +115 -0
- package/dist/field/Diff/index.js +7 -3
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Diff/index.scss +102 -0
- package/dist/field/Field.js +79 -27
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RenderLexical/index.js +36 -12
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/index.js +19 -7
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.scss +41 -0
- package/dist/field/rscEntry.js +7 -3
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/lexical/EditorPlugin.js +13 -5
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +162 -50
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalEditor.scss +54 -0
- package/dist/lexical/LexicalProvider.js +49 -17
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +7 -3
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.scss +13 -0
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +19 -7
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.scss +54 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +7 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +48 -16
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.scss +68 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +19 -7
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +35 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +31 -11
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.scss +80 -0
- package/dist/lexical/theme/EditorTheme.scss +357 -0
- package/dist/lexical/ui/ContentEditable.js +13 -5
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.scss +105 -0
- package/dist/lexical/ui/icons/AI/index.js +37 -13
- package/dist/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/lexical/ui/icons/Add/index.js +19 -7
- package/dist/lexical/ui/icons/Add/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignCenter/index.js +25 -9
- package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignJustify/index.js +25 -9
- package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignLeft/index.js +25 -9
- package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignRight/index.js +25 -9
- package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/lexical/ui/icons/Block/index.js +25 -9
- package/dist/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/lexical/ui/icons/Blockquote/index.js +13 -5
- package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/lexical/ui/icons/Bold/index.js +13 -5
- package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/lexical/ui/icons/Checklist/index.js +19 -7
- package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/lexical/ui/icons/Code/index.js +19 -7
- package/dist/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +13 -5
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.js +13 -5
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
- package/dist/lexical/ui/icons/H1/index.js +13 -5
- package/dist/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/lexical/ui/icons/H2/index.js +13 -5
- package/dist/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/lexical/ui/icons/H3/index.js +13 -5
- package/dist/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/lexical/ui/icons/H4/index.js +13 -5
- package/dist/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/lexical/ui/icons/H5/index.js +13 -5
- package/dist/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/lexical/ui/icons/H6/index.js +13 -5
- package/dist/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/lexical/ui/icons/HorizontalRule/index.js +13 -5
- package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentDecrease/index.js +31 -11
- package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentIncrease/index.js +31 -11
- package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/InlineBlocks/index.js +13 -5
- package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
- package/dist/lexical/ui/icons/Italic/index.js +13 -5
- package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/lexical/ui/icons/Link/index.js +13 -5
- package/dist/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/lexical/ui/icons/Meatballs/index.js +25 -9
- package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
- package/dist/lexical/ui/icons/OrderedList/index.js +37 -13
- package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Relationship/index.js +37 -13
- package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/lexical/ui/icons/Strikethrough/index.js +19 -7
- package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/lexical/ui/icons/Subscript/index.js +13 -5
- package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Superscript/index.js +13 -5
- package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Table/index.js +13 -5
- package/dist/lexical/ui/icons/Table/index.js.map +1 -1
- package/dist/lexical/ui/icons/Text/index.js +13 -5
- package/dist/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/lexical/ui/icons/TextState/index.js +7 -3
- package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
- package/dist/lexical/ui/icons/Underline/index.js +19 -7
- package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/lexical/ui/icons/UnorderedList/index.js +43 -15
- package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Upload/index.js +25 -9
- package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +19 -7
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +19 -7
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +7 -3
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +7 -3
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/package.json +9 -8
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { ShimmerEffect } from '@payloadcms/ui';
|
|
4
4
|
import '../index.scss';
|
|
5
5
|
export const PendingUploadComponent = ()=>{
|
|
6
|
-
return /*#__PURE__*/
|
|
6
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
7
7
|
className: 'lexical-upload',
|
|
8
|
-
children: /*#__PURE__*/
|
|
8
|
+
children: /*#__PURE__*/ _jsxDEV(ShimmerEffect, {
|
|
9
9
|
height: '95px',
|
|
10
10
|
width: '203px'
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}, void 0, false, {
|
|
12
|
+
fileName: "src/features/upload/client/component/pending/index.tsx",
|
|
13
|
+
lineNumber: 10,
|
|
14
|
+
columnNumber: 7
|
|
15
|
+
}, this)
|
|
16
|
+
}, void 0, false, {
|
|
17
|
+
fileName: "src/features/upload/client/component/pending/index.tsx",
|
|
18
|
+
lineNumber: 9,
|
|
19
|
+
columnNumber: 5
|
|
20
|
+
}, this);
|
|
13
21
|
};
|
|
14
22
|
|
|
15
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/upload/client/component/pending/index.tsx"],"sourcesContent":["'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\n\nimport '../index.scss'\n\nexport const PendingUploadComponent = (): React.ReactNode => {\n return (\n <div className={'lexical-upload'}>\n <ShimmerEffect height={'95px'} width={'203px'} />\n </div>\n )\n}\n"],"names":["ShimmerEffect","PendingUploadComponent","div","className","height","width"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,iBAAgB;AAE9C,OAAO,gBAAe;AAEtB,OAAO,MAAMC,yBAAyB;IACpC,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/upload/client/component/pending/index.tsx"],"sourcesContent":["'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\n\nimport '../index.scss'\n\nexport const PendingUploadComponent = (): React.ReactNode => {\n return (\n <div className={'lexical-upload'}>\n <ShimmerEffect height={'95px'} width={'203px'} />\n </div>\n )\n}\n"],"names":["ShimmerEffect","PendingUploadComponent","div","className","height","width"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,iBAAgB;AAE9C,OAAO,gBAAe;AAEtB,OAAO,MAAMC,yBAAyB;IACpC,qBACE,QAACC;QAAIC,WAAW;kBACd,cAAA,QAACH;YAAcI,QAAQ;YAAQC,OAAO;;;;;;;;;;;AAG5C,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
4
|
import { toast } from '@payloadcms/ui';
|
|
5
5
|
import { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
@@ -62,9 +62,13 @@ const UploadDrawerComponent = ({ enabledCollectionSlugs })=>{
|
|
|
62
62
|
closeListDrawer,
|
|
63
63
|
replaceNodeKey
|
|
64
64
|
]);
|
|
65
|
-
return /*#__PURE__*/
|
|
65
|
+
return /*#__PURE__*/ _jsxDEV(ListDrawer, {
|
|
66
66
|
onSelect: onSelect
|
|
67
|
-
}
|
|
67
|
+
}, void 0, false, {
|
|
68
|
+
fileName: "src/features/upload/client/drawer/index.tsx",
|
|
69
|
+
lineNumber: 94,
|
|
70
|
+
columnNumber: 10
|
|
71
|
+
}, this);
|
|
68
72
|
};
|
|
69
73
|
const UploadDrawerComponentFallback = ()=>{
|
|
70
74
|
const [editor] = useLexicalComposerContext();
|
|
@@ -80,11 +84,19 @@ const UploadDrawerComponentFallback = ()=>{
|
|
|
80
84
|
};
|
|
81
85
|
export const UploadDrawer = ({ enabledCollectionSlugs })=>{
|
|
82
86
|
if (!enabledCollectionSlugs?.length) {
|
|
83
|
-
return /*#__PURE__*/
|
|
87
|
+
return /*#__PURE__*/ _jsxDEV(UploadDrawerComponentFallback, {}, void 0, false, {
|
|
88
|
+
fileName: "src/features/upload/client/drawer/index.tsx",
|
|
89
|
+
lineNumber: 118,
|
|
90
|
+
columnNumber: 12
|
|
91
|
+
}, this);
|
|
84
92
|
}
|
|
85
|
-
return /*#__PURE__*/
|
|
93
|
+
return /*#__PURE__*/ _jsxDEV(UploadDrawerComponent, {
|
|
86
94
|
enabledCollectionSlugs: enabledCollectionSlugs
|
|
87
|
-
}
|
|
95
|
+
}, void 0, false, {
|
|
96
|
+
fileName: "src/features/upload/client/drawer/index.tsx",
|
|
97
|
+
lineNumber: 121,
|
|
98
|
+
columnNumber: 10
|
|
99
|
+
}, this);
|
|
88
100
|
};
|
|
89
101
|
|
|
90
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/upload/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { ListDrawerProps } from '@payloadcms/ui'\nimport type { LexicalEditor } from 'lexical'\nimport type { UploadCollectionSlug } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { toast } from '@payloadcms/ui'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useLexicalListDrawer } from '../../../../utilities/fieldsDrawer/useLexicalListDrawer.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 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 // @ts-expect-error - TODO: fix this\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 // @ts-expect-error - TODO: fix this\n fields: null,\n relationTo,\n value,\n },\n }),\n )\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: UploadCollectionSlug[]\n}\n\nconst UploadDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const { closeListDrawer, ListDrawer, openListDrawer } = useLexicalListDrawer({\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 openListDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openListDrawer])\n\n const onSelect = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n closeListDrawer()\n insertUpload({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: doc.id,\n })\n },\n [editor, closeListDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nconst UploadDrawerComponentFallback: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_UPLOAD_WITH_DRAWER_COMMAND,\n () => {\n toast.error('No upload collections enabled')\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n\nexport const UploadDrawer = ({ enabledCollectionSlugs }: Props): React.ReactNode => {\n if (!enabledCollectionSlugs?.length) {\n return <UploadDrawerComponentFallback />\n }\n\n return <UploadDrawerComponent enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","toast","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createUploadNode","INSERT_UPLOAD_COMMAND","INSERT_UPLOAD_WITH_DRAWER_COMMAND","insertUpload","editor","relationTo","replaceNodeKey","value","dispatchCommand","fields","update","node","replace","data","UploadDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","closeListDrawer","ListDrawer","openListDrawer","collectionSlugs","uploads","registerCommand","payload","nodeKey","onSelect","collectionSlug","doc","id","UploadDrawerComponentFallback","error","UploadDrawer","length"],"mappings":"AAAA;;AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,KAAK,QAAQ,iBAAgB;AACtC,SAASC,aAAa,EAAEC,uBAAuB,QAAQ,UAAS;AAChE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,oBAAoB,QAAQ,6DAA4D;AACjG,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,iCAAiC,QAAQ,gBAAe;AAEjE,MAAMC,eAAe,CAAC,EACpBC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,KAAK,EAMN;IACC,IAAI,CAACD,gBAAgB;QACnBF,OAAOI,eAAe,CAACP,uBAAuB;YAC5C,oCAAoC;YACpCQ,QAAQ;YACRJ;YACAE;QACF;IACF,OAAO;QACLH,OAAOM,MAAM,CAAC;YACZ,MAAMC,OAAOlB,cAAca;YAC3B,IAAIK,MAAM;gBACRA,KAAKC,OAAO,CACVZ,kBAAkB;oBAChBa,MAAM;wBACJ,oCAAoC;wBACpCJ,QAAQ;wBACRJ;wBACAE;oBACF;gBACF;YAEJ;QACF;IACF;AACF;AAMA,MAAMO,wBAAyC,CAAC,EAAEC,sBAAsB,EAAE;IACxE,MAAM,CAACX,OAAO,GAAGb;IAEjB,MAAM,CAACe,gBAAgBU,kBAAkB,GAAGlB,SAAwB;IAEpE,MAAM,EAAEmB,eAAe,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGpB,qBAAqB;QAC3EqB,iBAAiBL;QACjBM,SAAS;IACX;IAEAxB,UAAU;QACR,OAAOO,OAAOkB,eAAe,CAG3BpB,mCACA,CAACqB;YACCP,kBAAkBO,SAASX,UAAUW,SAASX,QAAQY,UAAU;YAChEL;YACA,OAAO;QACT,GACAzB;IAEJ,GAAG;QAACU;QAAQe;KAAe;IAE3B,MAAMM,WAAW7B,YACf,CAAC,EAAE8B,cAAc,EAAEC,GAAG,EAAE;QACtBV;QACAd,aAAa;YACXC;YACAC,YAAYqB;YACZpB;YACAC,OAAOoB,IAAIC,EAAE;QACf;IACF,GACA;QAACxB;QAAQa;QAAiBX;KAAe;IAG3C,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/upload/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { ListDrawerProps } from '@payloadcms/ui'\nimport type { LexicalEditor } from 'lexical'\nimport type { UploadCollectionSlug } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { toast } from '@payloadcms/ui'\nimport { $getNodeByKey, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useLexicalListDrawer } from '../../../../utilities/fieldsDrawer/useLexicalListDrawer.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 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 // @ts-expect-error - TODO: fix this\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 // @ts-expect-error - TODO: fix this\n fields: null,\n relationTo,\n value,\n },\n }),\n )\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: UploadCollectionSlug[]\n}\n\nconst UploadDrawerComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const [editor] = useLexicalComposerContext()\n\n const [replaceNodeKey, setReplaceNodeKey] = useState<null | string>(null)\n\n const { closeListDrawer, ListDrawer, openListDrawer } = useLexicalListDrawer({\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 openListDrawer()\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor, openListDrawer])\n\n const onSelect = useCallback<NonNullable<ListDrawerProps['onSelect']>>(\n ({ collectionSlug, doc }) => {\n closeListDrawer()\n insertUpload({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: doc.id,\n })\n },\n [editor, closeListDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nconst UploadDrawerComponentFallback: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_UPLOAD_WITH_DRAWER_COMMAND,\n () => {\n toast.error('No upload collections enabled')\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n\nexport const UploadDrawer = ({ enabledCollectionSlugs }: Props): React.ReactNode => {\n if (!enabledCollectionSlugs?.length) {\n return <UploadDrawerComponentFallback />\n }\n\n return <UploadDrawerComponent enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","toast","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createUploadNode","INSERT_UPLOAD_COMMAND","INSERT_UPLOAD_WITH_DRAWER_COMMAND","insertUpload","editor","relationTo","replaceNodeKey","value","dispatchCommand","fields","update","node","replace","data","UploadDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","closeListDrawer","ListDrawer","openListDrawer","collectionSlugs","uploads","registerCommand","payload","nodeKey","onSelect","collectionSlug","doc","id","UploadDrawerComponentFallback","error","UploadDrawer","length"],"mappings":"AAAA;;AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,KAAK,QAAQ,iBAAgB;AACtC,SAASC,aAAa,EAAEC,uBAAuB,QAAQ,UAAS;AAChE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,oBAAoB,QAAQ,6DAA4D;AACjG,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,iCAAiC,QAAQ,gBAAe;AAEjE,MAAMC,eAAe,CAAC,EACpBC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,KAAK,EAMN;IACC,IAAI,CAACD,gBAAgB;QACnBF,OAAOI,eAAe,CAACP,uBAAuB;YAC5C,oCAAoC;YACpCQ,QAAQ;YACRJ;YACAE;QACF;IACF,OAAO;QACLH,OAAOM,MAAM,CAAC;YACZ,MAAMC,OAAOlB,cAAca;YAC3B,IAAIK,MAAM;gBACRA,KAAKC,OAAO,CACVZ,kBAAkB;oBAChBa,MAAM;wBACJ,oCAAoC;wBACpCJ,QAAQ;wBACRJ;wBACAE;oBACF;gBACF;YAEJ;QACF;IACF;AACF;AAMA,MAAMO,wBAAyC,CAAC,EAAEC,sBAAsB,EAAE;IACxE,MAAM,CAACX,OAAO,GAAGb;IAEjB,MAAM,CAACe,gBAAgBU,kBAAkB,GAAGlB,SAAwB;IAEpE,MAAM,EAAEmB,eAAe,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGpB,qBAAqB;QAC3EqB,iBAAiBL;QACjBM,SAAS;IACX;IAEAxB,UAAU;QACR,OAAOO,OAAOkB,eAAe,CAG3BpB,mCACA,CAACqB;YACCP,kBAAkBO,SAASX,UAAUW,SAASX,QAAQY,UAAU;YAChEL;YACA,OAAO;QACT,GACAzB;IAEJ,GAAG;QAACU;QAAQe;KAAe;IAE3B,MAAMM,WAAW7B,YACf,CAAC,EAAE8B,cAAc,EAAEC,GAAG,EAAE;QACtBV;QACAd,aAAa;YACXC;YACAC,YAAYqB;YACZpB;YACAC,OAAOoB,IAAIC,EAAE;QACf;IACF,GACA;QAACxB;QAAQa;QAAiBX;KAAe;IAG3C,qBAAO,QAACY;QAAWO,UAAUA;;;;;;AAC/B;AAEA,MAAMI,gCAA0C;IAC9C,MAAM,CAACzB,OAAO,GAAGb;IAEjBM,UAAU;QACR,OAAOO,OAAOkB,eAAe,CAG3BpB,mCACA;YACEV,MAAMsC,KAAK,CAAC;YACZ,OAAO;QACT,GACApC;IAEJ,GAAG;QAACU;KAAO;IAEX,OAAO;AACT;AAEA,OAAO,MAAM2B,eAAe,CAAC,EAAEhB,sBAAsB,EAAS;IAC5D,IAAI,CAACA,wBAAwBiB,QAAQ;QACnC,qBAAO,QAACH;;;;;IACV;IAEA,qBAAO,QAACf;QAAsBC,wBAAwBA;;;;;;AACxD,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import ObjectID from 'bson-objectid';
|
|
4
4
|
import { $applyNodeReplacement } from 'lexical';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -47,14 +47,22 @@ export class UploadNode extends UploadServerNode {
|
|
|
47
47
|
}
|
|
48
48
|
decorate(editor, config) {
|
|
49
49
|
if (this.__data.pending) {
|
|
50
|
-
return /*#__PURE__*/
|
|
50
|
+
return /*#__PURE__*/ _jsxDEV(PendingUploadComponent, {}, void 0, false, {
|
|
51
|
+
fileName: "src/features/upload/client/nodes/UploadNode.tsx",
|
|
52
|
+
lineNumber: 66,
|
|
53
|
+
columnNumber: 14
|
|
54
|
+
}, this);
|
|
51
55
|
}
|
|
52
|
-
return /*#__PURE__*/
|
|
56
|
+
return /*#__PURE__*/ _jsxDEV(RawUploadComponent, {
|
|
53
57
|
className: config?.theme?.upload ?? 'LexicalEditorTheme__upload',
|
|
54
58
|
data: this.__data,
|
|
55
59
|
format: this.__format,
|
|
56
60
|
nodeKey: this.getKey()
|
|
57
|
-
}
|
|
61
|
+
}, void 0, false, {
|
|
62
|
+
fileName: "src/features/upload/client/nodes/UploadNode.tsx",
|
|
63
|
+
lineNumber: 69,
|
|
64
|
+
columnNumber: 7
|
|
65
|
+
}, this);
|
|
58
66
|
}
|
|
59
67
|
exportJSON() {
|
|
60
68
|
return super.exportJSON();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/upload/client/nodes/UploadNode.tsx"],"sourcesContent":["'use client'\nimport type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type {\n Internal_UploadData,\n SerializedUploadNode,\n UploadData,\n} from '../../server/nodes/UploadNode.js'\n\nimport { $convertUploadElement } from '../../server/nodes/conversions.js'\nimport { UploadServerNode } from '../../server/nodes/UploadNode.js'\nimport { PendingUploadComponent } from '../component/pending/index.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport class UploadNode extends UploadServerNode {\n static override clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadNode),\n priority: 0,\n }),\n }\n }\n\n static override 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 if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\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 override decorate(editor?: LexicalEditor, config?: EditorConfig): JSX.Element {\n if ((this.__data as Internal_UploadData).pending) {\n return <PendingUploadComponent />\n }\n return (\n <RawUploadComponent\n className={config?.theme?.upload ?? 'LexicalEditorTheme__upload'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedUploadNode {\n return super.exportJSON()\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],"names":["ObjectID","$applyNodeReplacement","React","$convertUploadElement","UploadServerNode","PendingUploadComponent","RawUploadComponent","lazy","then","module","default","UploadComponent","UploadNode","clone","node","getType","importDOM","img","conversion","domNode","$createUploadNode","priority","importJSON","serializedNode","version","value","id","toHexString","importedData","fields","pending","relationTo","data","setFormat","format","decorate","editor","config","__data","className","theme","upload","__format","nodeKey","getKey","exportJSON","$isUploadNode"],"mappings":"AAAA;;AAIA,OAAOA,cAAc,gBAAe;AACpC,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,YAAYC,WAAW,QAAO;AAQ9B,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,sBAAsB,QAAQ,gCAA+B;AAEtE,MAAMC,mCAAqBJ,MAAMK,IAAI,CAAC,IACpC,MAAM,CAAC,mCAAmCC,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,eAAe;QAAC,CAAA;AAGhG,OAAO,MAAMC,mBAAmBR;IAC9B,OAAgBS,MAAMC,IAAsB,EAAoB;QAC9D,OAAO,KAAK,CAACD,MAAMC;IACrB;IAEA,OAAgBC,UAAkB;QAChC,OAAO,KAAK,CAACA;IACf;IAEA,OAAgBC,YAAgD;QAC9D,OAAO;YACLC,KAAK,CAACH,OAAU,CAAA;oBACdI,YAAY,CAACC,UAAYhB,sBAAsBgB,SAASC;oBACxDC,UAAU;gBACZ,CAAA;QACF;IACF;IAEA,OAAgBC,WAAWC,cAAoC,EAAc;QAC3E,IAAIA,eAAeC,OAAO,KAAK,KAAMD,gBAAgBE,OAAqCC,IAAI;YAC5FH,eAAeE,KAAK,GAAG,AAACF,eAAeE,KAAK,CAA+BC,EAAE;QAC/E;QACA,IAAIH,eAAeC,OAAO,KAAK,KAAK,CAACD,gBAAgBG,IAAI;YACvDH,eAAeG,EAAE,GAAG,IAAI1B,SAASU,OAAO,GAAGiB,WAAW;YACtDJ,eAAeC,OAAO,GAAG;QAC3B;QAEA,MAAMI,eAAoC;YACxCF,IAAIH,eAAeG,EAAE;YACrBG,QAAQN,eAAeM,MAAM;YAC7BC,SAAS,AAACP,eAAuCO,OAAO;YACxDC,YAAYR,eAAeQ,UAAU;YACrCN,OAAOF,eAAeE,KAAK;QAC7B;QAEA,MAAMX,OAAOM,kBAAkB;YAAEY,MAAMJ;QAAa;QACpDd,KAAKmB,SAAS,CAACV,eAAeW,MAAM;QAEpC,OAAOpB;IACT;IAESqB,SAASC,MAAsB,EAAEC,MAAqB,EAAe;QAC5E,IAAI,AAAC,IAAI,CAACC,MAAM,CAAyBR,OAAO,EAAE;YAChD,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/upload/client/nodes/UploadNode.tsx"],"sourcesContent":["'use client'\nimport type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type {\n Internal_UploadData,\n SerializedUploadNode,\n UploadData,\n} from '../../server/nodes/UploadNode.js'\n\nimport { $convertUploadElement } from '../../server/nodes/conversions.js'\nimport { UploadServerNode } from '../../server/nodes/UploadNode.js'\nimport { PendingUploadComponent } from '../component/pending/index.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport class UploadNode extends UploadServerNode {\n static override clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadNode),\n priority: 0,\n }),\n }\n }\n\n static override 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 if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\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 override decorate(editor?: LexicalEditor, config?: EditorConfig): JSX.Element {\n if ((this.__data as Internal_UploadData).pending) {\n return <PendingUploadComponent />\n }\n return (\n <RawUploadComponent\n className={config?.theme?.upload ?? 'LexicalEditorTheme__upload'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedUploadNode {\n return super.exportJSON()\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],"names":["ObjectID","$applyNodeReplacement","React","$convertUploadElement","UploadServerNode","PendingUploadComponent","RawUploadComponent","lazy","then","module","default","UploadComponent","UploadNode","clone","node","getType","importDOM","img","conversion","domNode","$createUploadNode","priority","importJSON","serializedNode","version","value","id","toHexString","importedData","fields","pending","relationTo","data","setFormat","format","decorate","editor","config","__data","className","theme","upload","__format","nodeKey","getKey","exportJSON","$isUploadNode"],"mappings":"AAAA;;AAIA,OAAOA,cAAc,gBAAe;AACpC,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,YAAYC,WAAW,QAAO;AAQ9B,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,sBAAsB,QAAQ,gCAA+B;AAEtE,MAAMC,mCAAqBJ,MAAMK,IAAI,CAAC,IACpC,MAAM,CAAC,mCAAmCC,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,eAAe;QAAC,CAAA;AAGh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,CAACA;IACf;AACF;AAEA,OAAO,SAASzB,kBAAkB,EAChCY,IAAI,EAGL;IACC,IAAI,CAACA,MAAMN,IAAI;QACbM,KAAKN,EAAE,GAAG,IAAI1B,SAASU,OAAO,GAAGiB,WAAW;IAC9C;IAEA,OAAO1B,sBAAsB,IAAIW,WAAW;QAAEoB,MAAMA;IAAmB;AACzE;AAEA,OAAO,SAASc,cAAchC,IAAoC;IAChE,OAAOA,gBAAgBF;AACzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
4
|
import { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils';
|
|
5
5
|
import { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui';
|
|
@@ -308,9 +308,13 @@ export const INSERT_UPLOAD_COMMAND = createCommand('INSERT_UPLOAD_COMMAND');
|
|
|
308
308
|
}, [
|
|
309
309
|
editor
|
|
310
310
|
]);
|
|
311
|
-
return /*#__PURE__*/
|
|
311
|
+
return /*#__PURE__*/ _jsxDEV(UploadDrawer, {
|
|
312
312
|
enabledCollectionSlugs: enabledCollectionSlugs
|
|
313
|
-
}
|
|
313
|
+
}, void 0, false, {
|
|
314
|
+
fileName: "src/features/upload/client/plugin/index.tsx",
|
|
315
|
+
lineNumber: 401,
|
|
316
|
+
columnNumber: 10
|
|
317
|
+
}, this);
|
|
314
318
|
};
|
|
315
319
|
|
|
316
320
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui'\nimport ObjectID from 'bson-objectid'\nimport {\n $createRangeSelection,\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DROP_COMMAND,\n getDOMSelectionFromTarget,\n isHTMLElement,\n PASTE_COMMAND,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { Internal_UploadData, UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { useEnabledRelationships } from '../../../relationship/client/utils/useEnabledRelationships.js'\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\ndeclare global {\n interface DragEvent {\n rangeOffset?: number\n rangeParent?: Node\n }\n}\n\nfunction canDropImage(event: DragEvent): boolean {\n const target = event.target\n return !!(\n isHTMLElement(target) &&\n !target.closest('code, span.editor-image') &&\n isHTMLElement(target.parentElement) &&\n target.parentElement.closest('div.ContentEditable__root')\n )\n}\n\nfunction getDragSelection(event: DragEvent): null | Range | undefined {\n // Source: https://github.com/AlessioGr/lexical/blob/main/packages/lexical-playground/src/plugins/ImagesPlugin/index.tsx\n let range\n const domSelection = getDOMSelectionFromTarget(event.target)\n if (document.caretRangeFromPoint) {\n range = document.caretRangeFromPoint(event.clientX, event.clientY)\n } else if (event.rangeParent && domSelection !== null) {\n domSelection.collapse(event.rangeParent, event.rangeOffset || 0)\n range = domSelection.getRangeAt(0)\n } else {\n throw Error(`Cannot get the selection when dragging`)\n }\n\n return range\n}\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\ntype FileToUpload = {\n alt?: string\n file: File\n /**\n * Bulk Upload Form ID that should be created, which can then be matched\n * against the node formID if the upload is successful\n */\n formID: string\n}\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n uploads: true,\n })\n\n const {\n drawerSlug: bulkUploadDrawerSlug,\n setCollectionSlug,\n setInitialForms,\n setOnCancel,\n setOnSuccess,\n setSelectableCollections,\n } = useBulkUpload()\n\n const { isModalOpen, openModal } = useModal()\n\n const openBulkUpload = useEffectEvent(({ files }: { files: FileToUpload[] }) => {\n if (files?.length === 0) {\n return\n }\n\n setInitialForms((initialForms) => [\n ...(initialForms ?? []),\n ...files.map((file) => ({\n file: file.file,\n formID: file.formID,\n })),\n ])\n\n if (!isModalOpen(bulkUploadDrawerSlug)) {\n if (!enabledCollectionSlugs.length || !enabledCollectionSlugs[0]) {\n return\n }\n\n setCollectionSlug(enabledCollectionSlugs[0])\n setSelectableCollections(enabledCollectionSlugs)\n\n setOnCancel(() => {\n // Remove all the pending upload nodes that were added but not uploaded\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n\n if ($isUploadNode(node)) {\n const nodeData = node.getData()\n if ((nodeData as Internal_UploadData)?.pending) {\n node.remove()\n }\n }\n }\n })\n })\n\n setOnSuccess((newDocs) => {\n const newDocsMap = new Map(newDocs.map((doc) => [doc.formID, doc]))\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n if ($isUploadNode(node)) {\n const nodeData: Internal_UploadData = node.getData()\n\n if (nodeData?.pending) {\n const newDoc = newDocsMap.get(nodeData.pending?.formID)\n if (newDoc) {\n node.replace(\n $createUploadNode({\n data: {\n id: new ObjectID.default().toHexString(),\n fields: {},\n relationTo: newDoc.collectionSlug,\n value: newDoc.doc.id,\n } as UploadData,\n }),\n )\n }\n }\n }\n }\n })\n })\n\n openModal(bulkUploadDrawerSlug)\n }\n })\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n /**\n * Handle auto-uploading files if you copy & paste an image dom element from the clipboard\n */\n editor.registerNodeTransform(UploadNode, (node) => {\n const nodeData: Internal_UploadData = node.getData()\n if (!nodeData?.pending) {\n return\n }\n\n async function upload() {\n let transformedImage: FileToUpload | null = null\n\n const src = nodeData?.pending?.src\n const formID = nodeData?.pending?.formID as string\n\n if (src?.startsWith('data:')) {\n // It's a base64-encoded image\n const mimeMatch = src.match(/data:(image\\/[a-zA-Z]+);base64,/)\n const mimeType = mimeMatch ? mimeMatch[1] : 'image/png' // Default to PNG if MIME type not found\n const base64Data = src.replace(/^data:image\\/[a-zA-Z]+;base64,/, '')\n const byteCharacters = atob(base64Data)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const file = new File([byteArray], 'pasted-image.' + mimeType?.split('/', 2)[1], {\n type: mimeType,\n })\n transformedImage = { alt: undefined, file, formID }\n } else if (src?.startsWith('http') || src?.startsWith('https')) {\n // It's an image URL\n const res = await fetch(src)\n const blob = await res.blob()\n const inferredFileName =\n src.split('/').pop() || 'pasted-image' + blob.type.split('/', 2)[1]\n const file = new File([blob], inferredFileName, {\n type: blob.type,\n })\n\n transformedImage = { alt: undefined, file, formID }\n }\n\n if (!transformedImage) {\n return\n }\n\n openBulkUpload({ files: [transformedImage] })\n }\n void upload()\n }),\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n // Pending UploadNodes are automatically created when importDOM is called. However, if you paste a file from your computer\n // directly, importDOM won't be called, as it's not a HTML dom element. So we need to handle that case here.\n\n if (!(event instanceof ClipboardEvent)) {\n return false\n }\n const clipboardData = event.clipboardData\n\n if (!clipboardData?.types?.length || clipboardData?.types?.includes('text/html')) {\n // HTML is handled through importDOM => registerNodeTransform for pending UploadNode\n return false\n }\n\n const files: FileToUpload[] = []\n if (clipboardData?.files?.length) {\n Array.from(clipboardData.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Insert a pending UploadNode for each image\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n for (const file of files) {\n const pendingUploadNode = $createUploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Handle drag & drop of files from the desktop into the editor\n editor.registerCommand(\n DROP_COMMAND,\n (event) => {\n if (!(event instanceof DragEvent)) {\n return false\n }\n\n const dt = event.dataTransfer\n\n if (!dt?.types?.length) {\n return false\n }\n\n const files: FileToUpload[] = []\n if (dt?.files?.length) {\n Array.from(dt.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Prevent the default browser drop handling, which would open the file in the browser\n event.preventDefault()\n event.stopPropagation()\n\n // Insert a PendingUploadNode for each image\n editor.update(() => {\n if (canDropImage(event)) {\n const range = getDragSelection(event)\n const selection = $createRangeSelection()\n if (range !== null && range !== undefined) {\n selection.applyDOMRange(range)\n }\n $setSelection(selection)\n\n for (const file of files) {\n const pendingUploadNode = $createUploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","$dfsIterator","$insertNodeToNearestRoot","mergeRegister","useBulkUpload","useEffectEvent","useModal","ObjectID","$createRangeSelection","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","createCommand","DROP_COMMAND","getDOMSelectionFromTarget","isHTMLElement","PASTE_COMMAND","React","useEffect","useEnabledRelationships","UploadDrawer","$createUploadNode","$isUploadNode","UploadNode","canDropImage","event","target","closest","parentElement","getDragSelection","range","domSelection","document","caretRangeFromPoint","clientX","clientY","rangeParent","collapse","rangeOffset","getRangeAt","Error","INSERT_UPLOAD_COMMAND","UploadPlugin","clientProps","editor","enabledCollectionSlugs","collectionSlugsBlacklist","disabledCollections","collectionSlugsWhitelist","enabledCollections","uploads","drawerSlug","bulkUploadDrawerSlug","setCollectionSlug","setInitialForms","setOnCancel","setOnSuccess","setSelectableCollections","isModalOpen","openModal","openBulkUpload","files","length","initialForms","map","file","formID","update","dfsNode","node","nodeData","getData","pending","remove","newDocs","newDocsMap","Map","doc","newDoc","get","replace","data","id","default","toHexString","fields","relationTo","collectionSlug","value","hasNodes","registerNodeTransform","upload","transformedImage","src","startsWith","mimeMatch","match","mimeType","base64Data","byteCharacters","atob","byteNumbers","Array","i","charCodeAt","byteArray","Uint8Array","File","split","type","alt","undefined","res","fetch","blob","inferredFileName","pop","registerCommand","payload","selection","uploadNode","focus","focusNode","getNode","__first","ClipboardEvent","clipboardData","types","includes","from","forEach","push","pendingUploadNode","URL","createObjectURL","DragEvent","dt","dataTransfer","preventDefault","stopPropagation","applyDOMRange"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,YAAY,EAAEC,wBAAwB,EAAEC,aAAa,QAAQ,iBAAgB;AACtF,SAASC,aAAa,EAAEC,cAAc,EAAEC,QAAQ,QAAQ,iBAAgB;AACxE,OAAOC,cAAc,gBAAe;AACpC,SACEC,qBAAqB,EACrBC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,EACbC,uBAAuB,EACvBC,oBAAoB,EACpBC,aAAa,EACbC,YAA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BAEA,6GAA6G;gBAC7Gb,eAAe;oBAAEC;gBAAM;gBAEvB,OAAO;YACT;YAEA,OAAO;QACT,GACAlD;IAGN,GAAG;QAACiC;KAAO;IAEX,qBAAO,KAACxB;QAAayB,wBAAwBA;;AAC/C,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $dfsIterator, $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useBulkUpload, useEffectEvent, useModal } from '@payloadcms/ui'\nimport ObjectID from 'bson-objectid'\nimport {\n $createRangeSelection,\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DROP_COMMAND,\n getDOMSelectionFromTarget,\n isHTMLElement,\n PASTE_COMMAND,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { Internal_UploadData, UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { useEnabledRelationships } from '../../../relationship/client/utils/useEnabledRelationships.js'\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, $isUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\ndeclare global {\n interface DragEvent {\n rangeOffset?: number\n rangeParent?: Node\n }\n}\n\nfunction canDropImage(event: DragEvent): boolean {\n const target = event.target\n return !!(\n isHTMLElement(target) &&\n !target.closest('code, span.editor-image') &&\n isHTMLElement(target.parentElement) &&\n target.parentElement.closest('div.ContentEditable__root')\n )\n}\n\nfunction getDragSelection(event: DragEvent): null | Range | undefined {\n // Source: https://github.com/AlessioGr/lexical/blob/main/packages/lexical-playground/src/plugins/ImagesPlugin/index.tsx\n let range\n const domSelection = getDOMSelectionFromTarget(event.target)\n if (document.caretRangeFromPoint) {\n range = document.caretRangeFromPoint(event.clientX, event.clientY)\n } else if (event.rangeParent && domSelection !== null) {\n domSelection.collapse(event.rangeParent, event.rangeOffset || 0)\n range = domSelection.getRangeAt(0)\n } else {\n throw Error(`Cannot get the selection when dragging`)\n }\n\n return range\n}\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\ntype FileToUpload = {\n alt?: string\n file: File\n /**\n * Bulk Upload Form ID that should be created, which can then be matched\n * against the node formID if the upload is successful\n */\n formID: string\n}\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n uploads: true,\n })\n\n const {\n drawerSlug: bulkUploadDrawerSlug,\n setCollectionSlug,\n setInitialForms,\n setOnCancel,\n setOnSuccess,\n setSelectableCollections,\n } = useBulkUpload()\n\n const { isModalOpen, openModal } = useModal()\n\n const openBulkUpload = useEffectEvent(({ files }: { files: FileToUpload[] }) => {\n if (files?.length === 0) {\n return\n }\n\n setInitialForms((initialForms) => [\n ...(initialForms ?? []),\n ...files.map((file) => ({\n file: file.file,\n formID: file.formID,\n })),\n ])\n\n if (!isModalOpen(bulkUploadDrawerSlug)) {\n if (!enabledCollectionSlugs.length || !enabledCollectionSlugs[0]) {\n return\n }\n\n setCollectionSlug(enabledCollectionSlugs[0])\n setSelectableCollections(enabledCollectionSlugs)\n\n setOnCancel(() => {\n // Remove all the pending upload nodes that were added but not uploaded\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n\n if ($isUploadNode(node)) {\n const nodeData = node.getData()\n if ((nodeData as Internal_UploadData)?.pending) {\n node.remove()\n }\n }\n }\n })\n })\n\n setOnSuccess((newDocs) => {\n const newDocsMap = new Map(newDocs.map((doc) => [doc.formID, doc]))\n editor.update(() => {\n for (const dfsNode of $dfsIterator()) {\n const node = dfsNode.node\n if ($isUploadNode(node)) {\n const nodeData: Internal_UploadData = node.getData()\n\n if (nodeData?.pending) {\n const newDoc = newDocsMap.get(nodeData.pending?.formID)\n if (newDoc) {\n node.replace(\n $createUploadNode({\n data: {\n id: new ObjectID.default().toHexString(),\n fields: {},\n relationTo: newDoc.collectionSlug,\n value: newDoc.doc.id,\n } as UploadData,\n }),\n )\n }\n }\n }\n }\n })\n })\n\n openModal(bulkUploadDrawerSlug)\n }\n })\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n /**\n * Handle auto-uploading files if you copy & paste an image dom element from the clipboard\n */\n editor.registerNodeTransform(UploadNode, (node) => {\n const nodeData: Internal_UploadData = node.getData()\n if (!nodeData?.pending) {\n return\n }\n\n async function upload() {\n let transformedImage: FileToUpload | null = null\n\n const src = nodeData?.pending?.src\n const formID = nodeData?.pending?.formID as string\n\n if (src?.startsWith('data:')) {\n // It's a base64-encoded image\n const mimeMatch = src.match(/data:(image\\/[a-zA-Z]+);base64,/)\n const mimeType = mimeMatch ? mimeMatch[1] : 'image/png' // Default to PNG if MIME type not found\n const base64Data = src.replace(/^data:image\\/[a-zA-Z]+;base64,/, '')\n const byteCharacters = atob(base64Data)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const file = new File([byteArray], 'pasted-image.' + mimeType?.split('/', 2)[1], {\n type: mimeType,\n })\n transformedImage = { alt: undefined, file, formID }\n } else if (src?.startsWith('http') || src?.startsWith('https')) {\n // It's an image URL\n const res = await fetch(src)\n const blob = await res.blob()\n const inferredFileName =\n src.split('/').pop() || 'pasted-image' + blob.type.split('/', 2)[1]\n const file = new File([blob], inferredFileName, {\n type: blob.type,\n })\n\n transformedImage = { alt: undefined, file, formID }\n }\n\n if (!transformedImage) {\n return\n }\n\n openBulkUpload({ files: [transformedImage] })\n }\n void upload()\n }),\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n // Pending UploadNodes are automatically created when importDOM is called. However, if you paste a file from your computer\n // directly, importDOM won't be called, as it's not a HTML dom element. So we need to handle that case here.\n\n if (!(event instanceof ClipboardEvent)) {\n return false\n }\n const clipboardData = event.clipboardData\n\n if (!clipboardData?.types?.length || clipboardData?.types?.includes('text/html')) {\n // HTML is handled through importDOM => registerNodeTransform for pending UploadNode\n return false\n }\n\n const files: FileToUpload[] = []\n if (clipboardData?.files?.length) {\n Array.from(clipboardData.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Insert a pending UploadNode for each image\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n for (const file of files) {\n const pendingUploadNode = $createUploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Handle drag & drop of files from the desktop into the editor\n editor.registerCommand(\n DROP_COMMAND,\n (event) => {\n if (!(event instanceof DragEvent)) {\n return false\n }\n\n const dt = event.dataTransfer\n\n if (!dt?.types?.length) {\n return false\n }\n\n const files: FileToUpload[] = []\n if (dt?.files?.length) {\n Array.from(dt.files).forEach((file) => {\n files.push({\n alt: '',\n file,\n formID: new ObjectID.default().toHexString(),\n })\n })\n }\n\n if (files.length) {\n // Prevent the default browser drop handling, which would open the file in the browser\n event.preventDefault()\n event.stopPropagation()\n\n // Insert a PendingUploadNode for each image\n editor.update(() => {\n if (canDropImage(event)) {\n const range = getDragSelection(event)\n const selection = $createRangeSelection()\n if (range !== null && range !== undefined) {\n selection.applyDOMRange(range)\n }\n $setSelection(selection)\n\n for (const file of files) {\n const pendingUploadNode = $createUploadNode({\n data: {\n pending: {\n formID: file.formID,\n src: URL.createObjectURL(file.file),\n },\n } as Internal_UploadData,\n })\n // we need to get the focus node before inserting the upload node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(pendingUploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n }\n })\n\n // Open the bulk drawer - the node transform will not open it for us, as it does not handle blob/file uploads\n openBulkUpload({ files })\n\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","$dfsIterator","$insertNodeToNearestRoot","mergeRegister","useBulkUpload","useEffectEvent","useModal","ObjectID","$createRangeSelection","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","createCommand","DROP_COMMAND","getDOMSelectionFromTarget","isHTMLElement","PASTE_COMMAND","React","useEffect","useEnabledRelationships","UploadDrawer","$createUploadNode","$isUploadNode","UploadNode","canDropImage","event","target","closest","parentElement","getDragSelection","range","domSelection","document","caretRangeFromPoint","clientX","clientY","rangeParent","collapse","rangeOffset","getRangeAt","Error","INSERT_UPLOAD_COMMAND","UploadPlugin","clientProps","editor","enabledCollectionSlugs","collectionSlugsBlacklist","disabledCollections","collectionSlugsWhitelist","enabledCollections","uploads","drawerSlug","bulkUploadDrawerSlug","setCollectionSlug","setInitialForms","setOnCancel","setOnSuccess","setSelectableCollections","isModalOpen","openModal","openBulkUpload","files","length","initialForms","map","file","formID","update","dfsNode","node","nodeData","getData","pending","remove","newDocs","newDocsMap","Map","doc","newDoc","get","replace","data","id","default","toHexString","fields","relationTo","collectionSlug","value","hasNodes","registerNodeTransform","upload","transformedImage","src","startsWith","mimeMatch","match","mimeType","base64Data","byteCharacters","atob","byteNumbers","Array","i","charCodeAt","byteArray","Uint8Array","File","split","type","alt","undefined","res","fetch","blob","inferredFileName","pop","registerCommand","payload","selection","uploadNode","focus","focusNode","getNode","__first","ClipboardEvent","clipboardData","types","includes","from","forEach","push","pendingUploadNode","URL","createObjectURL","DragEvent","dt","dataTransfer","preventDefault","stopPropag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T,SAAS;wCACPN,QAAQD,KAAKC,MAAM;wCACnB2B,KAAKwC,IAAIC,eAAe,CAACrE,KAAKA,IAAI;oCACpC;gCACF;4BACF;4BACA,wHAAwH;4BACxH,MAAM,EAAEwD,KAAK,EAAE,GAAGF;4BAClB,MAAMG,YAAYD,MAAME,OAAO;4BAC/B,8HAA8H;4BAC9H7H,yBAAyBsI;4BAEzB,6CAA6C;4BAC7C,IAAI7H,iBAAiBmH,cAAc,CAACA,UAAUE,OAAO,EAAE;gCACrDF,UAAUjD,MAAM;4BAClB;wBACF;oBACF;gBACF;gBAEA,6GAA6G;gBAC7Gb,eAAe;oBAAEC;gBAAM;gBAEvB,OAAO;YACT;YAEA,OAAO;QACT,GACAlD;IAGN,GAAG;QAACiC;KAAO;IAEX,qBAAO,QAACxB;QAAayB,wBAAwBA;;;;;;AAC/C,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { CheckIcon } from '@payloadcms/ui/rsc';
|
|
3
3
|
import './index.scss';
|
|
4
4
|
export const ListItemDiffHTMLConverterAsync = {
|
|
@@ -9,7 +9,7 @@ export const ListItemDiffHTMLConverterAsync = {
|
|
|
9
9
|
})).join('');
|
|
10
10
|
if ('listType' in parent && parent?.listType === 'check') {
|
|
11
11
|
const ReactDOMServer = (await import('react-dom/server')).default;
|
|
12
|
-
const JSX = /*#__PURE__*/
|
|
12
|
+
const JSX = /*#__PURE__*/ _jsxDEV("li", {
|
|
13
13
|
"aria-checked": node.checked ? true : false,
|
|
14
14
|
className: `checkboxItem ${node.checked ? 'checkboxItem--checked' : 'checkboxItem--unchecked'}${hasSubLists ? ' checkboxItem--nested' : ''}`,
|
|
15
15
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
@@ -17,27 +17,51 @@ export const ListItemDiffHTMLConverterAsync = {
|
|
|
17
17
|
tabIndex: -1,
|
|
18
18
|
value: node.value,
|
|
19
19
|
children: hasSubLists ? // When sublists exist, just render them safely as HTML
|
|
20
|
-
/*#__PURE__*/
|
|
20
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
21
21
|
dangerouslySetInnerHTML: {
|
|
22
22
|
__html: children
|
|
23
23
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
24
|
+
}, void 0, false, {
|
|
25
|
+
fileName: "src/field/Diff/converters/listitem/index.tsx",
|
|
26
|
+
lineNumber: 34,
|
|
27
|
+
columnNumber: 13
|
|
28
|
+
}, this) : // Otherwise, show our custom styled checkbox
|
|
29
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
26
30
|
className: "checkboxItem__wrapper",
|
|
27
31
|
children: [
|
|
28
|
-
/*#__PURE__*/
|
|
32
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
29
33
|
className: "checkboxItem__icon",
|
|
30
34
|
"data-checked": node.checked,
|
|
31
35
|
"data-enable-match": "true",
|
|
32
|
-
children: node.checked && /*#__PURE__*/
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
children: node.checked && /*#__PURE__*/ _jsxDEV(CheckIcon, {}, void 0, false, {
|
|
37
|
+
fileName: "src/field/Diff/converters/listitem/index.tsx",
|
|
38
|
+
lineNumber: 43,
|
|
39
|
+
columnNumber: 34
|
|
40
|
+
}, this)
|
|
41
|
+
}, void 0, false, {
|
|
42
|
+
fileName: "src/field/Diff/converters/listitem/index.tsx",
|
|
43
|
+
lineNumber: 38,
|
|
44
|
+
columnNumber: 15
|
|
45
|
+
}, this),
|
|
46
|
+
/*#__PURE__*/ _jsxDEV("span", {
|
|
35
47
|
className: "checkboxItem__label",
|
|
36
48
|
children: children
|
|
37
|
-
}
|
|
49
|
+
}, void 0, false, {
|
|
50
|
+
fileName: "src/field/Diff/converters/listitem/index.tsx",
|
|
51
|
+
lineNumber: 45,
|
|
52
|
+
columnNumber: 15
|
|
53
|
+
}, this)
|
|
38
54
|
]
|
|
39
|
-
}
|
|
40
|
-
|
|
55
|
+
}, void 0, true, {
|
|
56
|
+
fileName: "src/field/Diff/converters/listitem/index.tsx",
|
|
57
|
+
lineNumber: 37,
|
|
58
|
+
columnNumber: 13
|
|
59
|
+
}, this)
|
|
60
|
+
}, void 0, false, {
|
|
61
|
+
fileName: "src/field/Diff/converters/listitem/index.tsx",
|
|
62
|
+
lineNumber: 22,
|
|
63
|
+
columnNumber: 9
|
|
64
|
+
}, this);
|
|
41
65
|
const html = ReactDOMServer.renderToStaticMarkup(JSX);
|
|
42
66
|
// Add style="list-style-type: none;${providedCSSString}" to html
|
|
43
67
|
const styleIndex = html.indexOf('class="list-item-checkbox');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/Diff/converters/listitem/index.tsx"],"sourcesContent":["import { CheckIcon } from '@payloadcms/ui/rsc'\n\nimport type { HTMLConvertersAsync } from '../../../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedListItemNode } from '../../../../nodeTypes.js'\n\nimport './index.scss'\n\nexport const ListItemDiffHTMLConverterAsync: HTMLConvertersAsync<SerializedListItemNode> = {\n listitem: async ({ node, nodesToHTML, parent, providedCSSString }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n if ('listType' in parent && parent?.listType === 'check') {\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const JSX = (\n <li\n aria-checked={node.checked ? true : false}\n className={`checkboxItem ${node.checked ? 'checkboxItem--checked' : 'checkboxItem--unchecked'}${\n hasSubLists ? ' checkboxItem--nested' : ''\n }`}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n role=\"checkbox\"\n tabIndex={-1}\n value={node.value}\n >\n {hasSubLists ? (\n // When sublists exist, just render them safely as HTML\n <div dangerouslySetInnerHTML={{ __html: children }} />\n ) : (\n // Otherwise, show our custom styled checkbox\n <div className=\"checkboxItem__wrapper\">\n <div\n className=\"checkboxItem__icon\"\n data-checked={node.checked}\n data-enable-match=\"true\"\n >\n {node.checked && <CheckIcon />}\n </div>\n <span className=\"checkboxItem__label\">{children}</span>\n </div>\n )}\n </li>\n )\n\n const html = ReactDOMServer.renderToStaticMarkup(JSX)\n\n // Add style=\"list-style-type: none;${providedCSSString}\" to html\n const styleIndex = html.indexOf('class=\"list-item-checkbox')\n const classIndex = html.indexOf('class=\"list-item-checkbox', styleIndex)\n const classEndIndex = html.indexOf('\"', classIndex + 6)\n const className = html.substring(classIndex, classEndIndex)\n const classNameWithStyle = `${className} style=\"list-style-type: none;${providedCSSString}\"`\n const htmlWithStyle = html.replace(className, classNameWithStyle)\n\n return htmlWithStyle\n } else {\n return `<li\n class=\"${hasSubLists ? 'nestedListItem' : ''}\"\n style=\"${hasSubLists ? `list-style-type: none;${providedCSSString}` : providedCSSString}\"\n value=\"${node.value}\"\n data-enable-match=\"true\"\n >${children}</li>`\n }\n },\n}\n"],"names":["CheckIcon","ListItemDiffHTMLConverterAsync","listitem","node","nodesToHTML","parent","providedCSSString","hasSubLists","children","some","child","type","nodes","join","listType","ReactDOMServer","default","JSX","li","aria-checked","checked","className","role","tabIndex","value","div","dangerouslySetInnerHTML","__html","data-checked","data-enable-match","span","html","renderToStaticMarkup","styleIndex","indexOf","classIndex","classEndIndex","substring","classNameWithStyle","htmlWithStyle","replace"],"mappings":";AAAA,SAASA,SAAS,QAAQ,qBAAoB;AAK9C,OAAO,eAAc;AAErB,OAAO,MAAMC,iCAA8E;IACzFC,UAAU,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAEC,MAAM,EAAEC,iBAAiB,EAAE;QAC/D,MAAMC,cAAcJ,KAAKK,QAAQ,CAACC,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,KAAK;QAEjE,MAAMH,WAAW,AACf,CAAA,MAAMJ,YAAY;YAChBQ,OAAOT,KAAKK,QAAQ;QACtB,EAAC,EACDK,IAAI,CAAC;QAEP,IAAI,cAAcR,UAAUA,QAAQS,aAAa,SAAS;YACxD,MAAMC,iBAAiB,AAAC,CAAA,MAAM,MAAM,CAAC,mBAAkB,EAAGC,OAAO;YAEjE,MAAMC,oBACJ,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/Diff/converters/listitem/index.tsx"],"sourcesContent":["import { CheckIcon } from '@payloadcms/ui/rsc'\n\nimport type { HTMLConvertersAsync } from '../../../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedListItemNode } from '../../../../nodeTypes.js'\n\nimport './index.scss'\n\nexport const ListItemDiffHTMLConverterAsync: HTMLConvertersAsync<SerializedListItemNode> = {\n listitem: async ({ node, nodesToHTML, parent, providedCSSString }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n if ('listType' in parent && parent?.listType === 'check') {\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const JSX = (\n <li\n aria-checked={node.checked ? true : false}\n className={`checkboxItem ${node.checked ? 'checkboxItem--checked' : 'checkboxItem--unchecked'}${\n hasSubLists ? ' checkboxItem--nested' : ''\n }`}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n role=\"checkbox\"\n tabIndex={-1}\n value={node.value}\n >\n {hasSubLists ? (\n // When sublists exist, just render them safely as HTML\n <div dangerouslySetInnerHTML={{ __html: children }} />\n ) : (\n // Otherwise, show our custom styled checkbox\n <div className=\"checkboxItem__wrapper\">\n <div\n className=\"checkboxItem__icon\"\n data-checked={node.checked}\n data-enable-match=\"true\"\n >\n {node.checked && <CheckIcon />}\n </div>\n <span className=\"checkboxItem__label\">{children}</span>\n </div>\n )}\n </li>\n )\n\n const html = ReactDOMServer.renderToStaticMarkup(JSX)\n\n // Add style=\"list-style-type: none;${providedCSSString}\" to html\n const styleIndex = html.indexOf('class=\"list-item-checkbox')\n const classIndex = html.indexOf('class=\"list-item-checkbox', styleIndex)\n const classEndIndex = html.indexOf('\"', classIndex + 6)\n const className = html.substring(classIndex, classEndIndex)\n const classNameWithStyle = `${className} style=\"list-style-type: none;${providedCSSString}\"`\n const htmlWithStyle = html.replace(className, classNameWithStyle)\n\n return htmlWithStyle\n } else {\n return `<li\n class=\"${hasSubLists ? 'nestedListItem' : ''}\"\n style=\"${hasSubLists ? `list-style-type: none;${providedCSSString}` : providedCSSString}\"\n value=\"${node.value}\"\n data-enable-match=\"true\"\n >${children}</li>`\n }\n },\n}\n"],"names":["CheckIcon","ListItemDiffHTMLConverterAsync","listitem","node","nodesToHTML","parent","providedCSSString","hasSubLists","children","some","child","type","nodes","join","listType","ReactDOMServer","default","JSX","li","aria-checked","checked","className","role","tabIndex","value","div","dangerouslySetInnerHTML","__html","data-checked","data-enable-match","span","html","renderToStaticMarkup","styleIndex","indexOf","classIndex","classEndIndex","substring","classNameWithStyle","htmlWithStyle","replace"],"mappings":";AAAA,SAASA,SAAS,QAAQ,qBAAoB;AAK9C,OAAO,eAAc;AAErB,OAAO,MAAMC,iCAA8E;IACzFC,UAAU,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAEC,MAAM,EAAEC,iBAAiB,EAAE;QAC/D,MAAMC,cAAcJ,KAAKK,QAAQ,CAACC,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,KAAK;QAEjE,MAAMH,WAAW,AACf,CAAA,MAAMJ,YAAY;YAChBQ,OAAOT,KAAKK,QAAQ;QACtB,EAAC,EACDK,IAAI,CAAC;QAEP,IAAI,cAAcR,UAAUA,QAAQS,aAAa,SAAS;YACxD,MAAMC,iBAAiB,AAAC,CAAA,MAAM,MAAM,CAAC,mBAAkB,EAAGC,OAAO;YAEjE,MAAMC,oBACJ,QAACC;gBACCC,gBAAchB,KAAKiB,OAAO,GAAG,OAAO;gBACpCC,WAAW,CAAC,aAAa,EAAElB,KAAKiB,OAAO,GAAG,0BAA0B,4BAClEb,cAAc,0BAA0B,IACxC;gBACF,kFAAkF;gBAClFe,MAAK;gBACLC,UAAU,CAAC;gBACXC,OAAOrB,KAAKqB,KAAK;0BAEhBjB,cACC,uDAAuD;8BACvD,QAACkB;oBAAIC,yBAAyB;wBAAEC,QAAQnB;oBAAS;;;;;2BAEjD,6CAA6C;8BAC7C,QAACiB;oBAAIJ,WAAU;;sCACb,QAACI;4BACCJ,WAAU;4BACVO,gBAAczB,KAAKiB,OAAO;4BAC1BS,qBAAkB;sCAEjB1B,KAAKiB,OAAO,kBAAI,QAACpB;;;;;;;;;;sCAEpB,QAAC8B;4BAAKT,WAAU;sCAAuBb;;;;;;;;;;;;;;;;;YAM/C,MAAMuB,OAAOhB,eAAeiB,oBAAoB,CAACf;YAEjD,iEAAiE;YACjE,MAAMgB,aAAaF,KAAKG,OAAO,CAAC;YAChC,MAAMC,aAAaJ,KAAKG,OAAO,CAAC,6BAA6BD;YAC7D,MAAMG,gBAAgBL,KAAKG,OAAO,CAAC,KAAKC,aAAa;YACrD,MAAMd,YAAYU,KAAKM,SAAS,CAACF,YAAYC;YAC7C,MAAME,qBAAqB,GAAGjB,UAAU,8BAA8B,EAAEf,kBAAkB,CAAC,CAAC;YAC5F,MAAMiC,gBAAgBR,KAAKS,OAAO,CAACnB,WAAWiB;YAE9C,OAAOC;QACT,OAAO;YACL,OAAO,CAAC;iBACG,EAAEhC,cAAc,mBAAmB,GAAG;iBACtC,EAAEA,cAAc,CAAC,sBAAsB,EAAED,mBAAmB,GAAGA,kBAAkB;iBACjF,EAAEH,KAAKqB,KAAK,CAAC;;SAErB,EAAEhB,SAAS,KAAK,CAAC;QACtB;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.lexical-diff {
|
|
5
|
+
ul.list-check {
|
|
6
|
+
padding-left: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.checkboxItem {
|
|
10
|
+
list-style-type: none;
|
|
11
|
+
|
|
12
|
+
&__wrapper {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&__icon {
|
|
18
|
+
width: 16px;
|
|
19
|
+
height: 16px;
|
|
20
|
+
margin-right: 8px; // Spacing before label text
|
|
21
|
+
border: 1px solid var(--theme-text);
|
|
22
|
+
border-radius: 3px;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
// Because the checkbox is non-interactive:
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
|
|
29
|
+
.icon--check {
|
|
30
|
+
height: 11px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&[data-match-type='create'] {
|
|
34
|
+
border-color: var(--diff-create-pill-color);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&[data-match-type='delete'] {
|
|
38
|
+
border-color: var(--diff-delete-pill-color);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--nested {
|
|
43
|
+
margin-left: 1.5rem;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { getTranslation } from '@payloadcms/translations';
|
|
3
3
|
import './index.scss';
|
|
4
4
|
import { formatAdminURL } from 'payload/shared';
|
|
@@ -22,24 +22,28 @@ export const RelationshipDiffHTMLConverterAsync = ({ i18n, req })=>{
|
|
|
22
22
|
}
|
|
23
23
|
const relatedCollection = req.payload.collections[node.relationTo]?.config;
|
|
24
24
|
const ReactDOMServer = (await import('react-dom/server')).default;
|
|
25
|
-
const JSX = /*#__PURE__*/
|
|
25
|
+
const JSX = /*#__PURE__*/ _jsxDEV("div", {
|
|
26
26
|
className: `${baseClass}${providedCSSString}`,
|
|
27
27
|
"data-enable-match": "true",
|
|
28
28
|
"data-id": id,
|
|
29
29
|
"data-slug": node.relationTo,
|
|
30
|
-
children: /*#__PURE__*/
|
|
30
|
+
children: /*#__PURE__*/ _jsxDEV("div", {
|
|
31
31
|
className: `${baseClass}__card`,
|
|
32
32
|
children: [
|
|
33
|
-
/*#__PURE__*/
|
|
33
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
34
34
|
className: `${baseClass}__collectionLabel`,
|
|
35
35
|
children: i18n.t('fields:labelRelationship', {
|
|
36
36
|
label: relatedCollection?.labels?.singular ? getTranslation(relatedCollection?.labels?.singular, i18n) : relatedCollection?.slug
|
|
37
37
|
})
|
|
38
|
-
}
|
|
39
|
-
|
|
38
|
+
}, void 0, false, {
|
|
39
|
+
fileName: "src/field/Diff/converters/relationship/index.tsx",
|
|
40
|
+
lineNumber: 49,
|
|
41
|
+
columnNumber: 13
|
|
42
|
+
}, this),
|
|
43
|
+
data && relatedCollection?.admin?.useAsTitle && data[relatedCollection.admin.useAsTitle] ? /*#__PURE__*/ _jsxDEV("strong", {
|
|
40
44
|
className: `${baseClass}__title`,
|
|
41
45
|
"data-enable-match": "false",
|
|
42
|
-
children: /*#__PURE__*/
|
|
46
|
+
children: /*#__PURE__*/ _jsxDEV("a", {
|
|
43
47
|
className: `${baseClass}__link`,
|
|
44
48
|
"data-enable-match": "false",
|
|
45
49
|
href: formatAdminURL({
|
|
@@ -50,13 +54,33 @@ export const RelationshipDiffHTMLConverterAsync = ({ i18n, req })=>{
|
|
|
50
54
|
rel: "noopener noreferrer",
|
|
51
55
|
target: "_blank",
|
|
52
56
|
children: data[relatedCollection.admin.useAsTitle]
|
|
53
|
-
}
|
|
54
|
-
|
|
57
|
+
}, void 0, false, {
|
|
58
|
+
fileName: "src/field/Diff/converters/relationship/index.tsx",
|
|
59
|
+
lineNumber: 60,
|
|
60
|
+
columnNumber: 17
|
|
61
|
+
}, this)
|
|
62
|
+
}, void 0, false, {
|
|
63
|
+
fileName: "src/field/Diff/converters/relationship/index.tsx",
|
|
64
|
+
lineNumber: 59,
|
|
65
|
+
columnNumber: 15
|
|
66
|
+
}, this) : /*#__PURE__*/ _jsxDEV("strong", {
|
|
55
67
|
children: id
|
|
56
|
-
}
|
|
68
|
+
}, void 0, false, {
|
|
69
|
+
fileName: "src/field/Diff/converters/relationship/index.tsx",
|
|
70
|
+
lineNumber: 75,
|
|
71
|
+
columnNumber: 15
|
|
72
|
+
}, this)
|
|
57
73
|
]
|
|
58
|
-
}
|
|
59
|
-
|
|
74
|
+
}, void 0, true, {
|
|
75
|
+
fileName: "src/field/Diff/converters/relationship/index.tsx",
|
|
76
|
+
lineNumber: 48,
|
|
77
|
+
columnNumber: 11
|
|
78
|
+
}, this)
|
|
79
|
+
}, void 0, false, {
|
|
80
|
+
fileName: "src/field/Diff/converters/relationship/index.tsx",
|
|
81
|
+
lineNumber: 42,
|
|
82
|
+
columnNumber: 9
|
|
83
|
+
}, this);
|
|
60
84
|
// Render to HTML
|
|
61
85
|
const html = ReactDOMServer.renderToStaticMarkup(JSX);
|
|
62
86
|
return html;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/Diff/converters/relationship/index.tsx"],"sourcesContent":["import type { FileData, PayloadRequest, TypeWithID } from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\n\nimport './index.scss'\n\nimport { formatAdminURL } from 'payload/shared'\n\nimport type { HTMLConvertersAsync } from '../../../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedRelationshipNode } from '../../../../nodeTypes.js'\n\nconst baseClass = 'lexical-relationship-diff'\n\nexport const RelationshipDiffHTMLConverterAsync: (args: {\n i18n: I18nClient\n req: PayloadRequest\n}) => HTMLConvertersAsync<SerializedRelationshipNode> = ({ i18n, req }) => {\n return {\n relationship: async ({ node, populate, providedCSSString }) => {\n let data: (Record<string, any> & TypeWithID) | undefined = undefined\n\n const id = typeof node.value === 'object' ? node.value.id : node.value\n\n // If there's no valid upload data, populate return an empty string\n if (typeof node.value !== 'object') {\n if (!populate) {\n return ''\n }\n data = await populate<FileData & TypeWithID>({\n id,\n collectionSlug: node.relationTo,\n })\n } else {\n data = node.value as unknown as FileData & TypeWithID\n }\n\n const relatedCollection = req.payload.collections[node.relationTo]?.config\n\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const JSX = (\n <div\n className={`${baseClass}${providedCSSString}`}\n data-enable-match=\"true\"\n data-id={id}\n data-slug={node.relationTo}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__collectionLabel`}>\n {i18n.t('fields:labelRelationship', {\n label: relatedCollection?.labels?.singular\n ? getTranslation(relatedCollection?.labels?.singular, i18n)\n : relatedCollection?.slug,\n })}\n </div>\n {data &&\n relatedCollection?.admin?.useAsTitle &&\n data[relatedCollection.admin.useAsTitle] ? (\n <strong className={`${baseClass}__title`} data-enable-match=\"false\">\n <a\n className={`${baseClass}__link`}\n data-enable-match=\"false\"\n href={formatAdminURL({\n adminRoute: req.payload.config.routes.admin,\n path: `/collections/${relatedCollection?.slug}/${data.id}`,\n serverURL: req.payload.config.serverURL,\n })}\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {data[relatedCollection.admin.useAsTitle]}\n </a>\n </strong>\n ) : (\n <strong>{id as string}</strong>\n )}\n </div>\n </div>\n )\n\n // Render to HTML\n const html = ReactDOMServer.renderToStaticMarkup(JSX)\n\n return html\n },\n }\n}\n"],"names":["getTranslation","formatAdminURL","baseClass","RelationshipDiffHTMLConverterAsync","i18n","req","relationship","node","populate","providedCSSString","data","undefined","id","value","collectionSlug","relationTo","relatedCollection","payload","collections","config","ReactDOMServer","default","JSX","div","className","data-enable-match","data-id","data-slug","t","label","labels","singular","slug","admin","useAsTitle","strong","a","href","adminRoute","routes","path","serverURL","rel","target","html","renderToStaticMarkup"],"mappings":";AAEA,SAASA,cAAc,QAAyB,2BAA0B;AAE1E,OAAO,eAAc;AAErB,SAASC,cAAc,QAAQ,iBAAgB;AAK/C,MAAMC,YAAY;AAElB,OAAO,MAAMC,qCAG2C,CAAC,EAAEC,IAAI,EAAEC,GAAG,EAAE;IACpE,OAAO;QACLC,cAAc,OAAO,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,iBAAiB,EAAE;YACxD,IAAIC,OAAuDC;YAE3D,MAAMC,KAAK,OAAOL,KAAKM,KAAK,KAAK,WAAWN,KAAKM,KAAK,CAACD,EAAE,GAAGL,KAAKM,KAAK;YAEtE,mEAAmE;YACnE,IAAI,OAAON,KAAKM,KAAK,KAAK,UAAU;gBAClC,IAAI,CAACL,UAAU;oBACb,OAAO;gBACT;gBACAE,OAAO,MAAMF,SAAgC;oBAC3CI;oBACAE,gBAAgBP,KAAKQ,UAAU;gBACjC;YACF,OAAO;gBACLL,OAAOH,KAAKM,KAAK;YACnB;YAEA,MAAMG,oBAAoBX,IAAIY,OAAO,CAACC,WAAW,CAACX,KAAKQ,UAAU,CAAC,EAAEI;YAEpE,MAAMC,iBAAiB,AAAC,CAAA,MAAM,MAAM,CAAC,mBAAkB,EAAGC,OAAO;YAEjE,MAAMC,oBACJ,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/Diff/converters/relationship/index.tsx"],"sourcesContent":["import type { FileData, PayloadRequest, TypeWithID } from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\n\nimport './index.scss'\n\nimport { formatAdminURL } from 'payload/shared'\n\nimport type { HTMLConvertersAsync } from '../../../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedRelationshipNode } from '../../../../nodeTypes.js'\n\nconst baseClass = 'lexical-relationship-diff'\n\nexport const RelationshipDiffHTMLConverterAsync: (args: {\n i18n: I18nClient\n req: PayloadRequest\n}) => HTMLConvertersAsync<SerializedRelationshipNode> = ({ i18n, req }) => {\n return {\n relationship: async ({ node, populate, providedCSSString }) => {\n let data: (Record<string, any> & TypeWithID) | undefined = undefined\n\n const id = typeof node.value === 'object' ? node.value.id : node.value\n\n // If there's no valid upload data, populate return an empty string\n if (typeof node.value !== 'object') {\n if (!populate) {\n return ''\n }\n data = await populate<FileData & TypeWithID>({\n id,\n collectionSlug: node.relationTo,\n })\n } else {\n data = node.value as unknown as FileData & TypeWithID\n }\n\n const relatedCollection = req.payload.collections[node.relationTo]?.config\n\n const ReactDOMServer = (await import('react-dom/server')).default\n\n const JSX = (\n <div\n className={`${baseClass}${providedCSSString}`}\n data-enable-match=\"true\"\n data-id={id}\n data-slug={node.relationTo}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__collectionLabel`}>\n {i18n.t('fields:labelRelationship', {\n label: relatedCollection?.labels?.singular\n ? getTranslation(relatedCollection?.labels?.singular, i18n)\n : relatedCollection?.slug,\n })}\n </div>\n {data &&\n relatedCollection?.admin?.useAsTitle &&\n data[relatedCollection.admin.useAsTitle] ? (\n <strong className={`${baseClass}__title`} data-enable-match=\"false\">\n <a\n className={`${baseClass}__link`}\n data-enable-match=\"false\"\n href={formatAdminURL({\n adminRoute: req.payload.config.routes.admin,\n path: `/collections/${relatedCollection?.slug}/${data.id}`,\n serverURL: req.payload.config.serverURL,\n })}\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {data[relatedCollection.admin.useAsTitle]}\n </a>\n </strong>\n ) : (\n <strong>{id as string}</strong>\n )}\n </div>\n </div>\n )\n\n // Render to HTML\n const html = ReactDOMServer.renderToStaticMarkup(JSX)\n\n return html\n },\n }\n}\n"],"names":["getTranslation","formatAdminURL","baseClass","RelationshipDiffHTMLConverterAsync","i18n","req","relationship","node","populate","providedCSSString","data","undefined","id","value","collectionSlug","relationTo","relatedCollection","payload","collections","config","ReactDOMServer","default","JSX","div","className","data-enable-match","data-id","data-slug","t","label","labels","singular","slug","admin","useAsTitle","strong","a","href","adminRoute","routes","path","serverURL","rel","target","html","renderToStaticMarkup"],"mappings":";AAEA,SAASA,cAAc,QAAyB,2BAA0B;AAE1E,OAAO,eAAc;AAErB,SAASC,cAAc,QAAQ,iBAAgB;AAK/C,MAAMC,YAAY;AAElB,OAAO,MAAMC,qCAG2C,CAAC,EAA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