@payloadcms/richtext-lexical 3.68.0-internal-debug.185cc5f → 3.68.0-internal-debug.591ab42
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static override clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new this({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'unknownConverted'\n }\n\n static override importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n override decorate(): JSX.Element {\n return <Component data={this.__data} />\n }\n\n override exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n override isInline(): boolean {\n return true\n }\n\n override updateDOM(prevNode: this, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return $applyNodeReplacement(\n new UnknownConvertedNode({\n data,\n }),\n )\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"names":["addClassNamesToElement","$applyNodeReplacement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"mappings":";AAGA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,SAASC,qBAAqB,EAAEC,aAAa,QAAQ,UAAS;AAC9D,YAAYC,WAAW,QAAO;AAc9B,MAAMC,0BAAYD,MAAME,IAAI,CAAC,IAC3B,MAAM,CAAC,kBAAkBC,IAAI,CAAC,CAACC,SAAY,CAAA;YACzCC,SAASD,OAAOE,6BAA6B;QAC/C,CAAA;AAGF,kBAAkB,GAClB,OAAO,MAAMC,6BAA6BR;IACxCS,OAAgC;IAEhCC,YAAY,EAAEC,IAAI,EAAEC,GAAG,EAAqD,CAAE;QAC5E,KAAK,CAACA;QACN,IAAI,CAACH,MAAM,GAAGE;IAChB;IAEA,OAAgBE,MAAMC,IAA0B,EAAwB;QACtE,OAAO,IAAI,IAAI,CAAC;YACdH,MAAMG,KAAKL,MAAM;YACjBG,KAAKE,KAAKC,KAAK;QACjB;IACF;IAEA,OAAgBC,UAAkB;QAChC,OAAO;IACT;IAEA,OAAgBC,WAAWC,cAA8C,EAAwB;QAC/F,MAAMJ,OAAOK,4BAA4B;YAAER,MAAMO,eAAeP,IAAI;QAAC;QACrE,OAAOG;IACT;IAEAM,qBAA2B;QACzB,OAAO;IACT;IAEAC,sBAA4B;QAC1B,OAAO;IACT;IAESC,UAAUC,MAAoB,EAAe;QACpD,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvC5B,uBAAuB0B,SAAS;QAChC,OAAOA;IACT;IAESG,WAAwB;QAC/B,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static override clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new this({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'unknownConverted'\n }\n\n static override importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n override decorate(): JSX.Element {\n return <Component data={this.__data} />\n }\n\n override exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n override isInline(): boolean {\n return true\n }\n\n override updateDOM(prevNode: this, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return $applyNodeReplacement(\n new UnknownConvertedNode({\n data,\n }),\n )\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"names":["addClassNamesToElement","$applyNodeReplacement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"mappings":";AAGA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,SAASC,qBAAqB,EAAEC,aAAa,QAAQ,UAAS;AAC9D,YAAYC,WAAW,QAAO;AAc9B,MAAMC,0BAAYD,MAAME,IAAI,CAAC,IAC3B,MAAM,CAAC,kBAAkBC,IAAI,CAAC,CAACC,SAAY,CAAA;YACzCC,SAASD,OAAOE,6BAA6B;QAC/C,CAAA;AAGF,kBAAkB,GAClB,OAAO,MAAMC,6BAA6BR;IACxCS,OAAgC;IAEhCC,YAAY,EAAEC,IAAI,EAAEC,GAAG,EAAqD,CAAE;QAC5E,KAAK,CAACA;QACN,IAAI,CAACH,MAAM,GAAGE;IAChB;IAEA,OAAgBE,MAAMC,IAA0B,EAAwB;QACtE,OAAO,IAAI,IAAI,CAAC;YACdH,MAAMG,KAAKL,MAAM;YACjBG,KAAKE,KAAKC,KAAK;QACjB;IACF;IAEA,OAAgBC,UAAkB;QAChC,OAAO;IACT;IAEA,OAAgBC,WAAWC,cAA8C,EAAwB;QAC/F,MAAMJ,OAAOK,4BAA4B;YAAER,MAAMO,eAAeP,IAAI;QAAC;QACrE,OAAOG;IACT;IAEAM,qBAA2B;QACzB,OAAO;IACT;IAEAC,sBAA4B;QAC1B,OAAO;IACT;IAESC,UAAUC,MAAoB,EAAe;QACpD,MAAMC,UAAUC,SAASC,aAAa,CAAC;QACvC5B,uBAAuB0B,SAAS;QAChC,OAAOA;IACT;IAESG,WAAwB;QAC/B,qBAAO,QAACzB;YAAUS,MAAM,IAAI,CAACF,MAAM;;;;;;IACrC;IAESmB,aAA6C;QACpD,OAAO;YACLC,MAAM,IAAI,CAACb,OAAO;YAClBL,MAAM,IAAI,CAACF,MAAM;YACjBqB,SAAS;QACX;IACF;IAEA,WAAW;IAEFC,WAAoB;QAC3B,OAAO;IACT;IAESC,UAAUC,QAAc,EAAEC,GAAgB,EAAW;QAC5D,OAAO;IACT;AACF;AAEA,OAAO,SAASf,4BAA4B,EAC1CR,IAAI,EAGL;IACC,OAAOZ,sBACL,IAAIS,qBAAqB;QACvBG;IACF;AAEJ;AAEA,OAAO,SAASwB,wBACdrB,IAAoC;IAEpC,OAAOA,gBAAgBN;AACzB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
span.unknownConverted {
|
|
3
|
+
text-transform: uppercase;
|
|
4
|
+
font-family: 'Roboto Mono', monospace;
|
|
5
|
+
letter-spacing: 2px;
|
|
6
|
+
font-size: calc(var(--base) * 0.5);
|
|
7
|
+
margin: 0 0 var(--base);
|
|
8
|
+
background: red;
|
|
9
|
+
color: white;
|
|
10
|
+
display: inline-block;
|
|
11
|
+
|
|
12
|
+
div {
|
|
13
|
+
background: red;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -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 { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
5
|
import { getTranslation } from '@payloadcms/translations';
|
|
@@ -54,33 +54,49 @@ export const RelationshipComponent = (props)=>{
|
|
|
54
54
|
setParams,
|
|
55
55
|
closeDocumentDrawer
|
|
56
56
|
]);
|
|
57
|
-
return /*#__PURE__*/
|
|
57
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
58
58
|
className: `${baseClass}__contents`,
|
|
59
59
|
contentEditable: false,
|
|
60
60
|
ref: relationshipElemRef,
|
|
61
61
|
children: [
|
|
62
|
-
/*#__PURE__*/
|
|
62
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
63
63
|
className: `${baseClass}__wrap`,
|
|
64
64
|
children: [
|
|
65
|
-
/*#__PURE__*/
|
|
65
|
+
/*#__PURE__*/ _jsxDEV("p", {
|
|
66
66
|
className: `${baseClass}__label`,
|
|
67
67
|
children: t('fields:labelRelationship', {
|
|
68
68
|
label: relatedCollection.labels?.singular ? getTranslation(relatedCollection.labels?.singular, i18n) : relatedCollection.slug
|
|
69
69
|
})
|
|
70
|
-
}
|
|
71
|
-
|
|
70
|
+
}, void 0, false, {
|
|
71
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
72
|
+
lineNumber: 86,
|
|
73
|
+
columnNumber: 9
|
|
74
|
+
}, this),
|
|
75
|
+
/*#__PURE__*/ _jsxDEV(DocumentDrawerToggler, {
|
|
72
76
|
className: `${baseClass}__doc-drawer-toggler`,
|
|
73
|
-
children: /*#__PURE__*/
|
|
77
|
+
children: /*#__PURE__*/ _jsxDEV("p", {
|
|
74
78
|
className: `${baseClass}__title`,
|
|
75
79
|
children: data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value
|
|
76
|
-
}
|
|
77
|
-
|
|
80
|
+
}, void 0, false, {
|
|
81
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
82
|
+
lineNumber: 94,
|
|
83
|
+
columnNumber: 11
|
|
84
|
+
}, this)
|
|
85
|
+
}, void 0, false, {
|
|
86
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
87
|
+
lineNumber: 93,
|
|
88
|
+
columnNumber: 9
|
|
89
|
+
}, this)
|
|
78
90
|
]
|
|
79
|
-
}
|
|
80
|
-
|
|
91
|
+
}, void 0, true, {
|
|
92
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
93
|
+
lineNumber: 85,
|
|
94
|
+
columnNumber: 7
|
|
95
|
+
}, this),
|
|
96
|
+
isEditable && /*#__PURE__*/ _jsxDEV("div", {
|
|
81
97
|
className: `${baseClass}__actions`,
|
|
82
98
|
children: [
|
|
83
|
-
/*#__PURE__*/
|
|
99
|
+
/*#__PURE__*/ _jsxDEV(Button, {
|
|
84
100
|
buttonStyle: "icon-label",
|
|
85
101
|
className: `${baseClass}__swapButton`,
|
|
86
102
|
disabled: !isEditable,
|
|
@@ -97,8 +113,12 @@ export const RelationshipComponent = (props)=>{
|
|
|
97
113
|
},
|
|
98
114
|
round: true,
|
|
99
115
|
tooltip: t('fields:swapRelationship')
|
|
100
|
-
}
|
|
101
|
-
|
|
116
|
+
}, void 0, false, {
|
|
117
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
118
|
+
lineNumber: 101,
|
|
119
|
+
columnNumber: 11
|
|
120
|
+
}, this),
|
|
121
|
+
/*#__PURE__*/ _jsxDEV(Button, {
|
|
102
122
|
buttonStyle: "icon-label",
|
|
103
123
|
className: `${baseClass}__removeButton`,
|
|
104
124
|
disabled: !isEditable,
|
|
@@ -109,14 +129,30 @@ export const RelationshipComponent = (props)=>{
|
|
|
109
129
|
},
|
|
110
130
|
round: true,
|
|
111
131
|
tooltip: t('fields:removeRelationship')
|
|
112
|
-
}
|
|
132
|
+
}, void 0, false, {
|
|
133
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
134
|
+
lineNumber: 117,
|
|
135
|
+
columnNumber: 11
|
|
136
|
+
}, this)
|
|
113
137
|
]
|
|
114
|
-
}
|
|
115
|
-
|
|
138
|
+
}, void 0, true, {
|
|
139
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
140
|
+
lineNumber: 100,
|
|
141
|
+
columnNumber: 9
|
|
142
|
+
}, this),
|
|
143
|
+
!!value && /*#__PURE__*/ _jsxDEV(DocumentDrawer, {
|
|
116
144
|
onSave: updateRelationship
|
|
117
|
-
}
|
|
145
|
+
}, void 0, false, {
|
|
146
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
147
|
+
lineNumber: 132,
|
|
148
|
+
columnNumber: 19
|
|
149
|
+
}, this)
|
|
118
150
|
]
|
|
119
|
-
}
|
|
151
|
+
}, void 0, true, {
|
|
152
|
+
fileName: "src/features/relationship/client/components/RelationshipComponent.tsx",
|
|
153
|
+
lineNumber: 84,
|
|
154
|
+
columnNumber: 5
|
|
155
|
+
}, this);
|
|
120
156
|
};
|
|
121
157
|
|
|
122
158
|
//# sourceMappingURL=RelationshipComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n className: baseClass,\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={`${baseClass}__contents`} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","initialParams","depth","RelationshipComponent","props","className","baseClass","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isEditable","config","routes","api","serverURL","getEntityConfig","relatedCollection","collectionSlug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","slug","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","removeRelationship","update","remove","updateRelationship","div","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","buttonStyle","disabled","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AACjF,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAIxE,SAASC,wBAAwB,QAAQ,iEAAgE;AACzG,OAAO,eAAc;AACrB,SAASC,uCAAuC,QAAQ,wBAAuB;AAE/E,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AASA,OAAO,MAAMC,wBAAyC,CAACC;IACrD,MAAM,EACJC,WAAWC,SAAS,EACpBC,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC3BC,OAAO,EACR,GAAGN;IAEJ,IAAI,OAAOK,UAAU,UAAU;QAC7B,MAAM,IAAIE,MACR;IAEJ;IAEA,MAAMC,sBAAsBf,OAA8B;IAE1D,MAAM,CAACgB,OAAO,GAAG3B;IACjB,MAAM4B,aAAa3B;IACnB,MAAM,EACJ4B,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACDC,eAAe,EAChB,GAAG7B;IAEJ,MAAM,CAAC8B,kBAAkB,GAAGtB,SAAS,IAAMqB,gBAAgB;YAAEE,gBAAgBb;QAAW;IAExF,MAAM,EAAEc,IAAI,EAAEC,CAAC,EAAE,GAAG/B;IACpB,MAAM,CAACgC,WAAWC,kBAAkB,GAAG7B,WAAW,CAAC8B,QAAUA,QAAQ,GAAG;IACxE,MAAM,CAAC,EAAEnB,IAAI,EAAE,EAAE,EAAEoB,SAAS,EAAE,CAAC,GAAGpC,cAChC,GAAG2B,YAAYD,IAAI,CAAC,EAAEG,kBAAkBQ,IAAI,CAAC,CAAC,EAAEnB,OAAO,EACvD;QAAER;IAAc;IAGlB,MAAM,EAAE4B,mBAAmB,EAAEC,cAAc,EAAEC,qBAAqB,EAAE,GAAGhC,yBAAyB;QAC9FiC,IAAIvB;QACJY,gBAAgBD,kBAAkBQ,IAAI;IACxC;IAEA,MAAMK,qBAAqBtC,YAAY;QACrCkB,OAAOqB,MAAM,CAAC;YACZzC,cAAciB,UAAWyB;QAC3B;IACF,GAAG;QAACtB;QAAQH;KAAQ;IAEpB,MAAM0B,qBAAqB1C,MAAMC,WAAW,CAAC;QAC3CgC,UAAU;YACR,GAAG1B,aAAa;YAChBuB;QACF;QADa,kGAAkG;QAG/GK;QACAJ;IACF,GAAG;QAACD;QAAWG;QAAWE;KAAoB;IAE9C,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n className: baseClass,\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={`${baseClass}__contents`} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","initialParams","depth","RelationshipComponent","props","className","baseClass","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isEditable","config","routes","api","serverURL","getEntityConfig","relatedCollection","collectionSlug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","slug","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","removeRelationship","update","remove","updateRelationship","div","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","buttonStyle","disabled","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AACjF,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAIxE,SAASC,wBAAwB,QAAQ,iEAAgE;AACzG,OAAO,eAAc;AACrB,SAASC,uCAAuC,QAAQ,wBAAuB;AAE/E,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AASA,OAAO,MAAMC,wBAAyC,CAACC;IACrD,MAAM,EACJC,WAAWC,SAAS,EACpBC,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC3BC,OAAO,EACR,GAAGN;IAEJ,IAAI,OAAOK,UAAU,UAAU;QAC7B,MAAM,IAAIE,MACR;IAEJ;IAEA,MAAMC,sBAAsBf,OAA8B;IAE1D,MAAM,CAACgB,OAAO,GAAG3B;IACjB,MAAM4B,aAAa3B;IACnB,MAAM,EACJ4B,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACDC,eAAe,EAChB,GAAG7B;IAEJ,MAAM,CAAC8B,kBAAkB,GAAGtB,SAAS,IAAMqB,gBAAgB;YAAEE,gBAAgBb;QAAW;IAExF,MAAM,EAAEc,IAAI,EAAEC,CAAC,EAAE,GAAG/B;IACpB,MAAM,CAACgC,WAAWC,kBAAkB,GAAG7B,WAAW,CAAC8B,QAAUA,QAAQ,GAAG;IACxE,MAAM,CAAC,EAAEnB,IAAI,EAAE,EAAE,EAAEoB,SAAS,EAAE,CAAC,GAAGpC,cAChC,GAAG2B,YAAYD,IAAI,CAAC,EAAEG,kBAAkBQ,IAAI,CAAC,CAAC,EAAEnB,OAAO,EACvD;QAAER;IAAc;IAGlB,MAAM,EAAE4B,mBAAmB,EAAEC,cAAc,EAAEC,qBAAqB,EAAE,GAAGhC,yBAAyB;QAC9FiC,IAAIvB;QACJY,gBAAgBD,kBAAkBQ,IAAI;IACxC;IAEA,MAAMK,qBAAqBtC,YAAY;QACrCkB,OAAOqB,MAAM,CAAC;YACZzC,cAAciB,UAAWyB;QAC3B;IACF,GAAG;QAACtB;QAAQH;KAAQ;IAEpB,MAAM0B,qBAAqB1C,MAAMC,WAAW,CAAC;QAC3CgC,UAAU;YACR,GAAG1B,aAAa;YAChBuB;QACF;QADa,kGAAkG;QAG/GK;QACAJ;IACF,GAAG;QAACD;QAAWG;QAAWE;KAAoB;IAE9C,qBACE,QAACQ;QAAIhC,WAAW,GAAGC,UAAU,UAAU,CAAC;QAAEgC,iBAAiB;QAAOC,KAAK3B;;0BACrE,QAACyB;gBAAIhC,WAAW,GAAGC,UAAU,MAAM,CAAC;;kCAClC,QAACkC;wBAAEnC,WAAW,GAAGC,UAAU,OAAO,CAAC;kCAChCiB,EAAE,4BAA4B;4BAC7BkB,OAAOrB,kBAAkBsB,MAAM,EAAEC,WAC7BvD,eAAegC,kBAAkBsB,MAAM,EAAEC,UAAUrB,QACnDF,kBAAkBQ,IAAI;wBAC5B;;;;;;kCAEF,QAACG;wBAAsB1B,WAAW,GAAGC,UAAU,oBAAoB,CAAC;kCAClE,cAAA,QAACkC;4BAAEnC,WAAW,GAAGC,UAAU,OAAO,CAAC;sCAChCC,OAAOA,IAAI,CAACa,mBAAmBwB,OAAOC,cAAc,KAAK,GAAGpC;;;;;;;;;;;;;;;;;YAIlEK,4BACC,QAACuB;gBAAIhC,WAAW,GAAGC,UAAU,SAAS,CAAC;;kCACrC,QAACjB;wBACCyD,aAAY;wBACZzC,WAAW,GAAGC,UAAU,YAAY,CAAC;wBACrCyC,UAAU,CAACjC;wBACXkC,IAAG;wBACHC,MAAK;wBACLC,SAAS;4BACP,IAAIxC,SAAS;gCACXG,OAAOsC,eAAe,CAACnD,yCAAyC;oCAC9DoD,SAAS;wCAAE1C;oCAAQ;gCACrB;4BACF;wBACF;wBACA2C,KAAK;wBACLC,SAAS/B,EAAE;;;;;;kCAEb,QAAClC;wBACCyD,aAAY;wBACZzC,WAAW,GAAGC,UAAU,cAAc,CAAC;wBACvCyC,UAAU,CAACjC;wBACXmC,MAAK;wBACLC,SAAS,CAACK;4BACRA,EAAEC,cAAc;4BAChBvB;wBACF;wBACAoB,KAAK;wBACLC,SAAS/B,EAAE;;;;;;;;;;;;YAKhB,CAAC,CAACd,uBAAS,QAACqB;gBAAe2B,QAAQrB;;;;;;;;;;;;AAG1C,EAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.LexicalEditorTheme__relationship {
|
|
5
|
+
@extend %body;
|
|
6
|
+
@include shadow-sm;
|
|
7
|
+
padding: calc(var(--base) * 0.75);
|
|
8
|
+
background: var(--theme-input-bg);
|
|
9
|
+
border: 1px solid var(--theme-elevation-100);
|
|
10
|
+
border-radius: $style-radius-m;
|
|
11
|
+
max-width: calc(var(--base) * 15);
|
|
12
|
+
font-family: var(--font-body);
|
|
13
|
+
margin-block: base(0.5);
|
|
14
|
+
color: var(--theme-text);
|
|
15
|
+
|
|
16
|
+
&__contents {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
border: 1px solid var(--theme-elevation-150);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__label {
|
|
26
|
+
margin-bottom: calc(var(--base) * 0.25);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__title {
|
|
30
|
+
margin: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__label,
|
|
34
|
+
&__title {
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
line-height: 1 !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__title {
|
|
42
|
+
font-weight: bold;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&__wrap {
|
|
46
|
+
flex-grow: 1;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&__doc-drawer-toggler {
|
|
51
|
+
text-decoration: underline;
|
|
52
|
+
pointer-events: all;
|
|
53
|
+
line-height: inherit;
|
|
54
|
+
& > * {
|
|
55
|
+
margin: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&__swapButton.btn {
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&__doc-drawer-toggler,
|
|
64
|
+
&__swapButton {
|
|
65
|
+
&:disabled {
|
|
66
|
+
color: var(--theme-elevation-300);
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&__actions {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
flex-shrink: 0;
|
|
75
|
+
margin-left: calc(var(--base) * 0.5);
|
|
76
|
+
|
|
77
|
+
& > *:not(:last-child) {
|
|
78
|
+
margin-right: calc(var(--base) * 0.25);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&__removeButton.btn {
|
|
83
|
+
margin: 0;
|
|
84
|
+
|
|
85
|
+
line {
|
|
86
|
+
stroke-width: $style-stroke-width-m;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:disabled {
|
|
90
|
+
color: var(--theme-elevation-300);
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -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';
|
|
@@ -56,9 +56,13 @@ const RelationshipDrawerComponent = ({ enabledCollectionSlugs })=>{
|
|
|
56
56
|
closeListDrawer,
|
|
57
57
|
replaceNodeKey
|
|
58
58
|
]);
|
|
59
|
-
return /*#__PURE__*/
|
|
59
|
+
return /*#__PURE__*/ _jsxDEV(ListDrawer, {
|
|
60
60
|
onSelect: onSelect
|
|
61
|
-
}
|
|
61
|
+
}, void 0, false, {
|
|
62
|
+
fileName: "src/features/relationship/client/drawer/index.tsx",
|
|
63
|
+
lineNumber: 82,
|
|
64
|
+
columnNumber: 10
|
|
65
|
+
}, this);
|
|
62
66
|
};
|
|
63
67
|
const RelationshipDrawerComponentFallback = ()=>{
|
|
64
68
|
const [editor] = useLexicalComposerContext();
|
|
@@ -74,11 +78,19 @@ const RelationshipDrawerComponentFallback = ()=>{
|
|
|
74
78
|
};
|
|
75
79
|
export const RelationshipDrawer = ({ enabledCollectionSlugs })=>{
|
|
76
80
|
if (!enabledCollectionSlugs?.length) {
|
|
77
|
-
return /*#__PURE__*/
|
|
81
|
+
return /*#__PURE__*/ _jsxDEV(RelationshipDrawerComponentFallback, {}, void 0, false, {
|
|
82
|
+
fileName: "src/features/relationship/client/drawer/index.tsx",
|
|
83
|
+
lineNumber: 106,
|
|
84
|
+
columnNumber: 12
|
|
85
|
+
}, this);
|
|
78
86
|
}
|
|
79
|
-
return /*#__PURE__*/
|
|
87
|
+
return /*#__PURE__*/ _jsxDEV(RelationshipDrawerComponent, {
|
|
80
88
|
enabledCollectionSlugs: enabledCollectionSlugs
|
|
81
|
-
}
|
|
89
|
+
}, void 0, false, {
|
|
90
|
+
fileName: "src/features/relationship/client/drawer/index.tsx",
|
|
91
|
+
lineNumber: 109,
|
|
92
|
+
columnNumber: 10
|
|
93
|
+
}, this);
|
|
82
94
|
};
|
|
83
95
|
|
|
84
96
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { CollectionSlug } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { type ListDrawerProps, 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 { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\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_RELATIONSHIP_COMMAND, {\n relationTo,\n value,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: CollectionSlug[]\n}\n\nconst RelationshipDrawerComponent: 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 selectedCollection: enabledCollectionSlugs?.[0],\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_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 insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: doc.id,\n })\n closeListDrawer()\n },\n [editor, closeListDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nconst RelationshipDrawerComponentFallback: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n () => {\n toast.error('No relationship collections enabled')\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n\nexport const RelationshipDrawer = ({ enabledCollectionSlugs }: Props): React.ReactNode => {\n if (!enabledCollectionSlugs?.length) {\n return <RelationshipDrawerComponentFallback />\n }\n\n return <RelationshipDrawerComponent enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","toast","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","closeListDrawer","ListDrawer","openListDrawer","collectionSlugs","selectedCollection","registerCommand","payload","nodeKey","onSelect","collectionSlug","doc","id","RelationshipDrawerComponentFallback","error","RelationshipDrawer","length"],"mappings":"AAAA;;AAIA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAA+BC,KAAK,QAAQ,iBAAgB;AAC5D,SAASC,aAAa,EAAEC,uBAAuB,QAAQ,UAAS;AAChE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,oBAAoB,QAAQ,6DAA4D;AACjG,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,2BAA2B,QAAQ,sBAAqB;AACjE,SAASC,uCAAuC,QAAQ,gBAAe;AAEvE,MAAMC,qBAAqB,CAAC,EAC1BC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,KAAK,EAMN;IACC,IAAI,CAACD,gBAAgB;QACnBF,OAAOI,eAAe,CAACP,6BAA6B;YAClDI;YACAE;QACF;IACF,OAAO;QACLH,OAAOK,MAAM,CAAC;YACZ,MAAMC,OAAOjB,cAAca;YAC3B,IAAII,MAAM;gBACRA,KAAKC,OAAO,CAACX,wBAAwB;oBAAEK;oBAAYE;gBAAM;YAC3D;QACF;IACF;AACF;AAMA,MAAMK,8BAA+C,CAAC,EAAEC,sBAAsB,EAAE;IAC9E,MAAM,CAACT,OAAO,GAAGb;IAEjB,MAAM,CAACe,gBAAgBQ,kBAAkB,GAAGhB,SAAwB;IAEpE,MAAM,EAAEiB,eAAe,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGlB,qBAAqB;QAC3EmB,iBAAiBL;QACjBM,oBAAoBN,wBAAwB,CAAC,EAAE;IACjD;IAEAhB,UAAU;QACR,OAAOO,OAAOgB,eAAe,CAG3BlB,yCACA,CAACmB;YACCP,kBAAkBO,SAASV,UAAUU,SAASV,QAAQW,UAAU;YAChEL;YACA,OAAO;QACT,GACAvB;IAEJ,GAAG;QAACU;QAAQa;KAAe;IAE3B,MAAMM,WAAW3B,YACf,CAAC,EAAE4B,cAAc,EAAEC,GAAG,EAAE;QACtBtB,mBAAmB;YACjBC;YACAC,YAAYmB;YACZlB;YACAC,OAAOkB,IAAIC,EAAE;QACf;QACAX;IACF,GACA;QAACX;QAAQW;QAAiBT;KAAe;IAG3C,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/relationship/client/drawer/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { CollectionSlug } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { type ListDrawerProps, 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 { $createRelationshipNode } from '../nodes/RelationshipNode.js'\nimport { INSERT_RELATIONSHIP_COMMAND } from '../plugins/index.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './commands.js'\n\nconst insertRelationship = ({\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_RELATIONSHIP_COMMAND, {\n relationTo,\n value,\n })\n } else {\n editor.update(() => {\n const node = $getNodeByKey(replaceNodeKey)\n if (node) {\n node.replace($createRelationshipNode({ relationTo, value }))\n }\n })\n }\n}\n\ntype Props = {\n enabledCollectionSlugs: CollectionSlug[]\n}\n\nconst RelationshipDrawerComponent: 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 selectedCollection: enabledCollectionSlugs?.[0],\n })\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_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 insertRelationship({\n editor,\n relationTo: collectionSlug,\n replaceNodeKey,\n value: doc.id,\n })\n closeListDrawer()\n },\n [editor, closeListDrawer, replaceNodeKey],\n )\n\n return <ListDrawer onSelect={onSelect} />\n}\n\nconst RelationshipDrawerComponentFallback: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand<{\n replace: { nodeKey: string } | false\n }>(\n INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND,\n () => {\n toast.error('No relationship collections enabled')\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n\nexport const RelationshipDrawer = ({ enabledCollectionSlugs }: Props): React.ReactNode => {\n if (!enabledCollectionSlugs?.length) {\n return <RelationshipDrawerComponentFallback />\n }\n\n return <RelationshipDrawerComponent enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","toast","$getNodeByKey","COMMAND_PRIORITY_EDITOR","React","useCallback","useEffect","useState","useLexicalListDrawer","$createRelationshipNode","INSERT_RELATIONSHIP_COMMAND","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","insertRelationship","editor","relationTo","replaceNodeKey","value","dispatchCommand","update","node","replace","RelationshipDrawerComponent","enabledCollectionSlugs","setReplaceNodeKey","closeListDrawer","ListDrawer","openListDrawer","collectionSlugs","selectedCollection","registerCommand","payload","nodeKey","onSelect","collectionSlug","doc","id","RelationshipDrawerComponentFallback","error","RelationshipDrawer","length"],"mappings":"AAAA;;AAIA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAA+BC,KAAK,QAAQ,iBAAgB;AAC5D,SAASC,aAAa,EAAEC,uBAAuB,QAAQ,UAAS;AAChE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,oBAAoB,QAAQ,6DAA4D;AACjG,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,2BAA2B,QAAQ,sBAAqB;AACjE,SAASC,uCAAuC,QAAQ,gBAAe;AAEvE,MAAMC,qBAAqB,CAAC,EAC1BC,MAAM,EACNC,UAAU,EACVC,cAAc,EACdC,KAAK,EAMN;IACC,IAAI,CAACD,gBAAgB;QACnBF,OAAOI,eAAe,CAACP,6BAA6B;YAClDI;YACAE;QACF;IACF,OAAO;QACLH,OAAOK,MAAM,CAAC;YACZ,MAAMC,OAAOjB,cAAca;YAC3B,IAAII,MAAM;gBACRA,KAAKC,OAAO,CAACX,wBAAwB;oBAAEK;oBAAYE;gBAAM;YAC3D;QACF;IACF;AACF;AAMA,MAAMK,8BAA+C,CAAC,EAAEC,sBAAsB,EAAE;IAC9E,MAAM,CAACT,OAAO,GAAGb;IAEjB,MAAM,CAACe,gBAAgBQ,kBAAkB,GAAGhB,SAAwB;IAEpE,MAAM,EAAEiB,eAAe,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGlB,qBAAqB;QAC3EmB,iBAAiBL;QACjBM,oBAAoBN,wBAAwB,CAAC,EAAE;IACjD;IAEAhB,UAAU;QACR,OAAOO,OAAOgB,eAAe,CAG3BlB,yCACA,CAACmB;YACCP,kBAAkBO,SAASV,UAAUU,SAASV,QAAQW,UAAU;YAChEL;YACA,OAAO;QACT,GACAvB;IAEJ,GAAG;QAACU;QAAQa;KAAe;IAE3B,MAAMM,WAAW3B,YACf,CAAC,EAAE4B,cAAc,EAAEC,GAAG,EAAE;QACtBtB,mBAAmB;YACjBC;YACAC,YAAYmB;YACZlB;YACAC,OAAOkB,IAAIC,EAAE;QACf;QACAX;IACF,GACA;QAACX;QAAQW;QAAiBT;KAAe;IAG3C,qBAAO,QAACU;QAAWO,UAAUA;;;;;;AAC/B;AAEA,MAAMI,sCAAgD;IACpD,MAAM,CAACvB,OAAO,GAAGb;IAEjBM,UAAU;QACR,OAAOO,OAAOgB,eAAe,CAG3BlB,yCACA;YACEV,MAAMoC,KAAK,CAAC;YACZ,OAAO;QACT,GACAlC;IAEJ,GAAG;QAACU;KAAO;IAEX,OAAO;AACT;AAEA,OAAO,MAAMyB,qBAAqB,CAAC,EAAEhB,sBAAsB,EAAS;IAClE,IAAI,CAACA,wBAAwBiB,QAAQ;QACnC,qBAAO,QAACH;;;;;IACV;IAEA,qBAAO,QAACf;QAA4BC,wBAAwBA;;;;;;AAC9D,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { $applyNodeReplacement } from 'lexical';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js';
|
|
@@ -53,12 +53,16 @@ export class RelationshipNode extends RelationshipServerNode {
|
|
|
53
53
|
return node;
|
|
54
54
|
}
|
|
55
55
|
decorate(editor, config) {
|
|
56
|
-
return /*#__PURE__*/
|
|
56
|
+
return /*#__PURE__*/ _jsxDEV(RelationshipComponent, {
|
|
57
57
|
className: config.theme.relationship ?? 'LexicalEditorTheme__relationship',
|
|
58
58
|
data: this.__data,
|
|
59
59
|
format: this.__format,
|
|
60
60
|
nodeKey: this.getKey()
|
|
61
|
-
}
|
|
61
|
+
}, void 0, false, {
|
|
62
|
+
fileName: "src/features/relationship/client/nodes/RelationshipNode.tsx",
|
|
63
|
+
lineNumber: 83,
|
|
64
|
+
columnNumber: 7
|
|
65
|
+
}, this);
|
|
62
66
|
}
|
|
63
67
|
exportJSON() {
|
|
64
68
|
return super.exportJSON();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport {\n $applyNodeReplacement,\n type DOMConversionMap,\n type DOMConversionOutput,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport * as React from 'react'\n\nimport type {\n RelationshipData,\n SerializedRelationshipNode,\n} from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js'\n\nconst RelationshipComponent = React.lazy(() =>\n import('../components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends RelationshipServerNode {\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return super.exportJSON()\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return $applyNodeReplacement(\n new RelationshipNode({\n data,\n }),\n )\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | null | RelationshipNode | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"names":["$applyNodeReplacement","React","RelationshipServerNode","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","clone","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","format","decorate","editor","config","className","theme","relationship","data","__data","__format","nodeKey","getKey","exportJSON","$isRelationshipNode"],"mappings":"AAAA;;AAGA,SACEA,qBAAqB,QAMhB,UAAS;AAChB,YAAYC,WAAW,QAAO;AAO9B,SAASC,sBAAsB,QAAQ,yCAAwC;AAE/E,MAAMC,sCAAwBF,MAAMG,IAAI,CAAC,IACvC,MAAM,CAAC,0CAA0CC,IAAI,CAAC,CAACC,SAAY,CAAA;YACjEC,SAASD,OAAOH,qBAAqB;QACvC,CAAA;AAGF,SAASK,2BAA2BC,OAAuB;IACzD,MAAMC,KAAKD,QAAQE,YAAY,CAAC;IAChC,MAAMC,aAAaH,QAAQE,YAAY,CAAC;IAExC,IAAID,MAAM,QAAQE,cAAc,MAAM;QACpC,MAAMC,OAAOC,wBAAwB;YACnCF;YACAG,OAAOL;QACT;QACA,OAAO;YAAEG;QAAK;IAChB;IACA,OAAO;AACT;AAEA,OAAO,MAAMG,yBAAyBd;IACpC,OAAgBe,MAAMJ,IAA4B,EAA0B;QAC1E,OAAO,KAAK,CAACI,MAAMJ;IACrB;IAEA,OAAgBK,UAAkB;QAChC,OAAO,KAAK,CAACA;IACf;IAEA,OAAgBC,YAAqD;QACnE,OAAO;YACLC,KAAK,CAACX;gBACJ,IACE,CAACA,QAAQY,YAAY,CAAC,2CACtB,CAACZ,QAAQY,YAAY,CAAC,iCACtB;oBACA,OAAO;gBACT;gBACA,OAAO;oBACLC,YAAYd;oBACZe,UAAU;gBACZ;YACF;QACF;IACF;IAEA,OAAgBC,WAAWC,cAA0C,EAAoB;QACvF,IAAIA,eAAeC,OAAO,KAAK,KAAMD,gBAAgBV,OAAqCL,IAAI;YAC5Fe,eAAeV,KAAK,GAAG,AAACU,eAAeV,KAAK,CAA+BL,EAAE;QAC/E;QAEA,MAAMiB,eAAiC;YACrCf,YAAYa,eAAeb,UAAU;YACrCG,OAAOU,eAAeV,KAAK;QAC7B;QACA,MAAMF,OAAOC,wBAAwBa;QACrCd,KAAKe,SAAS,CAACH,eAAeI,MAAM;QACpC,OAAOhB;IACT;IAESiB,SAASC,MAAqB,EAAEC,MAAoB,EAAe;QAC1E,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport {\n $applyNodeReplacement,\n type DOMConversionMap,\n type DOMConversionOutput,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport * as React from 'react'\n\nimport type {\n RelationshipData,\n SerializedRelationshipNode,\n} from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js'\n\nconst RelationshipComponent = React.lazy(() =>\n import('../components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends RelationshipServerNode {\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return super.exportJSON()\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return $applyNodeReplacement(\n new RelationshipNode({\n data,\n }),\n )\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | null | RelationshipNode | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"names":["$applyNodeReplacement","React","RelationshipServerNode","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","clone","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","format","decorate","editor","config","className","theme","relationship","data","__data","__format","nodeKey","getKey","exportJSON","$isRelationshipNode"],"mappings":"AAAA;;AAGA,SACEA,qBAAqB,QAMhB,UAAS;AAChB,YAAYC,WAAW,QAAO;AAO9B,SAASC,sBAAsB,QAAQ,yCAAwC;AAE/E,MAAMC,sCAAwBF,MAAMG,IAAI,CAAC,IACvC,MAAM,CAAC,0CAA0CC,IAAI,CAAC,CAACC,SAAY,CAAA;YACjEC,SAASD,OAAOH,qBAAqB;QACvC,CAAA;AAGF,SAASK,2BAA2BC,OAAuB;IACzD,MAAMC,KAAKD,QAAQE,YAAY,CAAC;IAChC,MAAMC,aAAaH,QAAQE,YAAY,CAAC;IAExC,IAAID,MAAM,QAAQE,cAAc,MAAM;QACpC,MAAMC,OAAOC,wBAAwB;YACnCF;YACAG,OAAOL;QACT;QACA,OAAO;YAAEG;QAAK;IAChB;IACA,OAAO;AACT;AAEA,OAAO,MAAMG,yBAAyBd;IACpC,OAAgBe,MAAMJ,IAA4B,EAA0B;QAC1E,OAAO,KAAK,CAACI,MAAMJ;IACrB;IAEA,OAAgBK,UAAkB;QAChC,OAAO,KAAK,CAACA;IACf;IAEA,OAAgBC,YAAqD;QACnE,OAAO;YACLC,KAAK,CAACX;gBACJ,IACE,CAACA,QAAQY,YAAY,CAAC,2CACtB,CAACZ,QAAQY,YAAY,CAAC,iCACtB;oBACA,OAAO;gBACT;gBACA,OAAO;oBACLC,YAAYd;oBACZe,UAAU;gBACZ;YACF;QACF;IACF;IAEA,OAAgBC,WAAWC,cAA0C,EAAoB;QACvF,IAAIA,eAAeC,OAAO,KAAK,KAAMD,gBAAgBV,OAAqCL,IAAI;YAC5Fe,eAAeV,KAAK,GAAG,AAACU,eAAeV,KAAK,CAA+BL,EAAE;QAC/E;QAEA,MAAMiB,eAAiC;YACrCf,YAAYa,eAAeb,UAAU;YACrCG,OAAOU,eAAeV,KAAK;QAC7B;QACA,MAAMF,OAAOC,wBAAwBa;QACrCd,KAAKe,SAAS,CAACH,eAAeI,MAAM;QACpC,OAAOhB;IACT;IAESiB,SAASC,MAAqB,EAAEC,MAAoB,EAAe;QAC1E,qBACE,QAAC7B;YACC8B,WAAWD,OAAOE,KAAK,CAACC,YAAY,IAAI;YACxCC,MAAM,IAAI,CAACC,MAAM;YACjBR,QAAQ,IAAI,CAACS,QAAQ;YACrBC,SAAS,IAAI,CAACC,MAAM;;;;;;IAG1B;IAESC,aAAyC;QAChD,OAAO,KAAK,CAACA;IACf;AACF;AAEA,OAAO,SAAS3B,wBAAwBsB,IAAsB;IAC5D,OAAOpC,sBACL,IAAIgB,iBAAiB;QACnBoB;IACF;AAEJ;AAEA,OAAO,SAASM,oBACd7B,IAAuD;IAEvD,OAAOA,gBAAgBG;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 { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
5
5
|
import { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
@@ -39,9 +39,13 @@ export const RelationshipPlugin = ({ clientProps })=>{
|
|
|
39
39
|
}, [
|
|
40
40
|
editor
|
|
41
41
|
]);
|
|
42
|
-
return /*#__PURE__*/
|
|
42
|
+
return /*#__PURE__*/ _jsxDEV(RelationshipDrawer, {
|
|
43
43
|
enabledCollectionSlugs: enabledCollectionSlugs
|
|
44
|
-
}
|
|
44
|
+
}, void 0, false, {
|
|
45
|
+
fileName: "src/features/relationship/client/plugins/index.tsx",
|
|
46
|
+
lineNumber: 66,
|
|
47
|
+
columnNumber: 10
|
|
48
|
+
}, this);
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { RelationshipFeatureProps } from '../../server/index.js'\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\nimport { useEnabledRelationships } from '../utils/useEnabledRelationships.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n })\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\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 relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","useEnabledRelationships","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","clientProps","editor","enabledCollectionSlugs","collectionSlugsBlacklist","disabledCollections","collectionSlugsWhitelist","enabledCollections","hasNodes","Error","registerCommand","payload","selection","relationshipNode","focus","focusNode","getNode","__first","remove"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AAMjC,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AACxF,SAASC,uBAAuB,QAAQ,sCAAqC;AAE7E,OAAO,MAAMC,8BAAgEN,cAC3E,+BACD;AAED,OAAO,MAAMO,qBAAgE,CAAC,EAAEC,WAAW,EAAE;IAC3F,MAAM,CAACC,OAAO,GAAGhB;IAEjB,MAAM,EAAEiB,sBAAsB,EAAE,GAAGL,wBAAwB;QACzDM,0BAA0BH,aAAaI;QACvCC,0BAA0BL,aAAaM;IACzC;IAEAb,UAAU;QACR,IAAI,CAACQ,OAAOM,QAAQ,CAAC;YAACX;SAAiB,GAAG;YACxC,MAAM,IAAIY,MAAM;QAClB;QAEA,OAAOP,OAAOQ,eAAe,CAC3BX,6BACA,CAACY;YACC,MAAMC,YAAYvB,mBAAmBD;YAErC,IAAIG,kBAAkBqB,YAAY;gBAChC,MAAMC,mBAAmBjB,wBAAwBe;gBACjD,uHAAuH;gBACvH,MAAM,EAAEG,KAAK,EAAE,GAAGF;gBAClB,MAAMG,YAAYD,MAAME,OAAO;gBAC/B,oIAAoI;gBACpI7B,yBAAyB0B;gBAEzB,6CAA6C;gBAC7C,IAAIvB,iBAAiByB,cAAc,CAACA,UAAUE,OAAO,EAAE;oBACrDF,UAAUG,MAAM;gBAClB;YACF;YAEA,OAAO;QACT,GACA1B;IAEJ,GAAG;QAACU;KAAO;IAEX,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { RelationshipFeatureProps } from '../../server/index.js'\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\nimport { useEnabledRelationships } from '../utils/useEnabledRelationships.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n\n const { enabledCollectionSlugs } = useEnabledRelationships({\n collectionSlugsBlacklist: clientProps?.disabledCollections,\n collectionSlugsWhitelist: clientProps?.enabledCollections,\n })\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\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 relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledCollectionSlugs} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","useEnabledRelationships","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","clientProps","editor","enabledCollectionSlugs","collectionSlugsBlacklist","disabledCollections","collectionSlugsWhitelist","enabledCollections","hasNodes","Error","registerCommand","payload","selection","relationshipNode","focus","focusNode","getNode","__first","remove"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AAMjC,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AACxF,SAASC,uBAAuB,QAAQ,sCAAqC;AAE7E,OAAO,MAAMC,8BAAgEN,cAC3E,+BACD;AAED,OAAO,MAAMO,qBAAgE,CAAC,EAAEC,WAAW,EAAE;IAC3F,MAAM,CAACC,OAAO,GAAGhB;IAEjB,MAAM,EAAEiB,sBAAsB,EAAE,GAAGL,wBAAwB;QACzDM,0BAA0BH,aAAaI;QACvCC,0BAA0BL,aAAaM;IACzC;IAEAb,UAAU;QACR,IAAI,CAACQ,OAAOM,QAAQ,CAAC;YAACX;SAAiB,GAAG;YACxC,MAAM,IAAIY,MAAM;QAClB;QAEA,OAAOP,OAAOQ,eAAe,CAC3BX,6BACA,CAACY;YACC,MAAMC,YAAYvB,mBAAmBD;YAErC,IAAIG,kBAAkBqB,YAAY;gBAChC,MAAMC,mBAAmBjB,wBAAwBe;gBACjD,uHAAuH;gBACvH,MAAM,EAAEG,KAAK,EAAE,GAAGF;gBAClB,MAAMG,YAAYD,MAAME,OAAO;gBAC/B,oIAAoI;gBACpI7B,yBAAyB0B;gBAEzB,6CAA6C;gBAC7C,IAAIvB,iBAAiByB,cAAc,CAACA,UAAUE,OAAO,EAAE;oBACrDF,UAAUG,MAAM;gBAClB;YACF;YAEA,OAAO;QACT,GACA1B;IAEJ,GAAG;QAACU;KAAO;IAEX,qBAAO,QAACP;QAAmBQ,wBAAwBA;;;;;;AACrD,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js';
|
|
4
4
|
import { createClientFeature } from '../../utilities/createClientFeature.js';
|
|
5
5
|
import { registerTextStates, setTextState, StatePlugin } from './textState.js';
|
|
@@ -10,9 +10,13 @@ const toolbarGroups = (props, stateMap)=>{
|
|
|
10
10
|
for(const stateValue in key){
|
|
11
11
|
const meta = key[stateValue];
|
|
12
12
|
items.push({
|
|
13
|
-
ChildComponent: ()=>/*#__PURE__*/
|
|
13
|
+
ChildComponent: ()=>/*#__PURE__*/ _jsxDEV(TextStateIcon, {
|
|
14
14
|
css: meta.css
|
|
15
|
-
}
|
|
15
|
+
}, void 0, false, {
|
|
16
|
+
fileName: "src/features/textState/feature.client.tsx",
|
|
17
|
+
lineNumber: 18,
|
|
18
|
+
columnNumber: 31
|
|
19
|
+
}, this),
|
|
16
20
|
key: stateValue,
|
|
17
21
|
label: meta.label,
|
|
18
22
|
onSelect: ({ editor })=>{
|
|
@@ -23,7 +27,11 @@ const toolbarGroups = (props, stateMap)=>{
|
|
|
23
27
|
}
|
|
24
28
|
const clearStyle = [
|
|
25
29
|
{
|
|
26
|
-
ChildComponent: ()=>/*#__PURE__*/
|
|
30
|
+
ChildComponent: ()=>/*#__PURE__*/ _jsxDEV(TextStateIcon, {}, void 0, false, {
|
|
31
|
+
fileName: "src/features/textState/feature.client.tsx",
|
|
32
|
+
lineNumber: 30,
|
|
33
|
+
columnNumber: 29
|
|
34
|
+
}, this),
|
|
27
35
|
key: `clear-style`,
|
|
28
36
|
label: ({ i18n })=>i18n.t('lexical:textState:defaultStyle'),
|
|
29
37
|
onSelect: ({ editor })=>{
|
|
@@ -37,11 +45,15 @@ const toolbarGroups = (props, stateMap)=>{
|
|
|
37
45
|
return [
|
|
38
46
|
{
|
|
39
47
|
type: 'dropdown',
|
|
40
|
-
ChildComponent: ()=>/*#__PURE__*/
|
|
48
|
+
ChildComponent: ()=>/*#__PURE__*/ _jsxDEV(TextStateIcon, {
|
|
41
49
|
css: {
|
|
42
50
|
color: 'var(--theme-elevation-600)'
|
|
43
51
|
}
|
|
44
|
-
}
|
|
52
|
+
}, void 0, false, {
|
|
53
|
+
fileName: "src/features/textState/feature.client.tsx",
|
|
54
|
+
lineNumber: 45,
|
|
55
|
+
columnNumber: 29
|
|
56
|
+
}, this),
|
|
45
57
|
items: [
|
|
46
58
|
...clearStyle,
|
|
47
59
|
...items
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/textState/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport type { ToolbarDropdownGroup, ToolbarGroup } from '../toolbars/types.js'\nimport type { TextStateFeatureProps } from './feature.server.js'\n\nimport { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js'\nimport { createClientFeature } from '../../utilities/createClientFeature.js'\nimport { registerTextStates, setTextState, type StateMap, StatePlugin } from './textState.js'\n\nconst toolbarGroups = (props: TextStateFeatureProps, stateMap: StateMap): ToolbarGroup[] => {\n const items: ToolbarDropdownGroup['items'] = []\n\n for (const stateKey in props.state) {\n const key = props.state[stateKey]!\n for (const stateValue in key) {\n const meta = key[stateValue]!\n items.push({\n ChildComponent: () => <TextStateIcon css={meta.css} />,\n key: stateValue,\n label: meta.label,\n onSelect: ({ editor }) => {\n setTextState(editor, stateMap, stateKey, stateValue)\n },\n })\n }\n }\n\n const clearStyle: ToolbarDropdownGroup['items'] = [\n {\n ChildComponent: () => <TextStateIcon />,\n key: `clear-style`,\n label: ({ i18n }) => i18n.t('lexical:textState:defaultStyle'),\n onSelect: ({ editor }) => {\n for (const stateKey in props.state) {\n setTextState(editor, stateMap, stateKey, undefined)\n }\n },\n order: 1,\n },\n ]\n\n return [\n {\n type: 'dropdown',\n ChildComponent: () => <TextStateIcon css={{ color: 'var(--theme-elevation-600)' }} />,\n items: [...clearStyle, ...items],\n key: 'textState',\n order: 30,\n },\n ]\n}\n\nexport const TextStateFeatureClient = createClientFeature<TextStateFeatureProps>(({ props }) => {\n const stateMap = registerTextStates(props.state)\n return {\n plugins: [\n {\n Component: () => StatePlugin({ stateMap }),\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups(props, stateMap),\n },\n toolbarInline: {\n groups: toolbarGroups(props, stateMap),\n },\n }\n})\n"],"names":["TextStateIcon","createClientFeature","registerTextStates","setTextState","StatePlugin","toolbarGroups","props","stateMap","items","stateKey","state","key","stateValue","meta","push","ChildComponent","css","label","onSelect","editor","clearStyle","i18n","t","undefined","order","type","color","TextStateFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline"],"mappings":"AAAA;;AAKA,SAASA,aAAa,QAAQ,4CAA2C;AACzE,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,kBAAkB,EAAEC,YAAY,EAAiBC,WAAW,QAAQ,iBAAgB;AAE7F,MAAMC,gBAAgB,CAACC,OAA8BC;IACnD,MAAMC,QAAuC,EAAE;IAE/C,IAAK,MAAMC,YAAYH,MAAMI,KAAK,CAAE;QAClC,MAAMC,MAAML,MAAMI,KAAK,CAACD,SAAS;QACjC,IAAK,MAAMG,cAAcD,IAAK;YAC5B,MAAME,OAAOF,GAAG,CAACC,WAAW;YAC5BJ,MAAMM,IAAI,CAAC;gBACTC,gBAAgB,kBAAM,
|
|
1
|
+
{"version":3,"sources":["../../../src/features/textState/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport type { ToolbarDropdownGroup, ToolbarGroup } from '../toolbars/types.js'\nimport type { TextStateFeatureProps } from './feature.server.js'\n\nimport { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js'\nimport { createClientFeature } from '../../utilities/createClientFeature.js'\nimport { registerTextStates, setTextState, type StateMap, StatePlugin } from './textState.js'\n\nconst toolbarGroups = (props: TextStateFeatureProps, stateMap: StateMap): ToolbarGroup[] => {\n const items: ToolbarDropdownGroup['items'] = []\n\n for (const stateKey in props.state) {\n const key = props.state[stateKey]!\n for (const stateValue in key) {\n const meta = key[stateValue]!\n items.push({\n ChildComponent: () => <TextStateIcon css={meta.css} />,\n key: stateValue,\n label: meta.label,\n onSelect: ({ editor }) => {\n setTextState(editor, stateMap, stateKey, stateValue)\n },\n })\n }\n }\n\n const clearStyle: ToolbarDropdownGroup['items'] = [\n {\n ChildComponent: () => <TextStateIcon />,\n key: `clear-style`,\n label: ({ i18n }) => i18n.t('lexical:textState:defaultStyle'),\n onSelect: ({ editor }) => {\n for (const stateKey in props.state) {\n setTextState(editor, stateMap, stateKey, undefined)\n }\n },\n order: 1,\n },\n ]\n\n return [\n {\n type: 'dropdown',\n ChildComponent: () => <TextStateIcon css={{ color: 'var(--theme-elevation-600)' }} />,\n items: [...clearStyle, ...items],\n key: 'textState',\n order: 30,\n },\n ]\n}\n\nexport const TextStateFeatureClient = createClientFeature<TextStateFeatureProps>(({ props }) => {\n const stateMap = registerTextStates(props.state)\n return {\n plugins: [\n {\n Component: () => StatePlugin({ stateMap }),\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups(props, stateMap),\n },\n toolbarInline: {\n groups: toolbarGroups(props, stateMap),\n },\n }\n})\n"],"names":["TextStateIcon","createClientFeature","registerTextStates","setTextState","StatePlugin","toolbarGroups","props","stateMap","items","stateKey","state","key","stateValue","meta","push","ChildComponent","css","label","onSelect","editor","clearStyle","i18n","t","undefined","order","type","color","TextStateFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline"],"mappings":"AAAA;;AAKA,SAASA,aAAa,QAAQ,4CAA2C;AACzE,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,kBAAkB,EAAEC,YAAY,EAAiBC,WAAW,QAAQ,iBAAgB;AAE7F,MAAMC,gBAAgB,CAACC,OAA8BC;IACnD,MAAMC,QAAuC,EAAE;IAE/C,IAAK,MAAMC,YAAYH,MAAMI,KAAK,CAAE;QAClC,MAAMC,MAAML,MAAMI,KAAK,CAACD,SAAS;QACjC,IAAK,MAAMG,cAAcD,IAAK;YAC5B,MAAME,OAAOF,GAAG,CAACC,WAAW;YAC5BJ,MAAMM,IAAI,CAAC;gBACTC,gBAAgB,kBAAM,QAACf;wBAAcgB,KAAKH,KAAKG,GAAG;;;;;;gBAClDL,KAAKC;gBACLK,OAAOJ,KAAKI,KAAK;gBACjBC,UAAU,CAAC,EAAEC,MAAM,EAAE;oBACnBhB,aAAagB,QAAQZ,UAAUE,UAAUG;gBAC3C;YACF;QACF;IACF;IAEA,MAAMQ,aAA4C;QAChD;YACEL,gBAAgB,kBAAM,QAACf;;;;;YACvBW,KAAK,CAAC,WAAW,CAAC;YAClBM,OAAO,CAAC,EAAEI,IAAI,EAAE,GAAKA,KAAKC,CAAC,CAAC;YAC5BJ,UAAU,CAAC,EAAEC,MAAM,EAAE;gBACnB,IAAK,MAAMV,YAAYH,MAAMI,KAAK,CAAE;oBAClCP,aAAagB,QAAQZ,UAAUE,UAAUc;gBAC3C;YACF;YACAC,OAAO;QACT;KACD;IAED,OAAO;QACL;YACEC,MAAM;YACNV,gBAAgB,kBAAM,QAACf;oBAAcgB,KAAK;wBAAEU,OAAO;oBAA6B;;;;;;YAChFlB,OAAO;mBAAIY;mBAAeZ;aAAM;YAChCG,KAAK;YACLa,OAAO;QACT;KACD;AACH;AAEA,OAAO,MAAMG,yBAAyB1B,oBAA2C,CAAC,EAAEK,KAAK,EAAE;IACzF,MAAMC,WAAWL,mBAAmBI,MAAMI,KAAK;IAC/C,OAAO;QACLkB,SAAS;YACP;gBACEC,WAAW,IAAMzB,YAAY;wBAAEG;oBAAS;gBACxCuB,UAAU;YACZ;SACD;QACDC,cAAc;YACZC,QAAQ3B,cAAcC,OAAOC;QAC/B;QACA0B,eAAe;YACbD,QAAQ3B,cAAcC,OAAOC;QAC/B;IACF;AACF,GAAE"}
|