@payloadcms/richtext-lexical 3.68.0-internal-debug.e9b66ee → 3.68.0-internal-debug.654e4ad
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 +21 -2
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -0
- package/dist/exports/client/index.js.map +1 -1
- package/dist/exports/client/internal-client.d.ts +3 -0
- package/dist/exports/client/internal-client.d.ts.map +1 -0
- package/dist/exports/client/internal-client.js +4 -0
- package/dist/exports/client/internal-client.js.map +1 -0
- package/dist/exports/react/index.d.ts +1 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +48 -13
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +10 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js +7 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +7 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +247 -81
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +9 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +7 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +7 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +7 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +217 -68
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/getBlockImageComponent.js +15 -4
- package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +12 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +12 -2
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +127 -26
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +65 -49
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +16 -3
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +25 -4
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +16 -10
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +8 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +8 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +6 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +6 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js +19 -10
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js +63 -16
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +19 -4
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js +45 -12
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js +57 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +46 -7
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +98 -9
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +17 -4
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +113 -38
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.js +15 -1
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +357 -79
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +41 -7
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +39 -9
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +59 -28
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +1 -0
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/indent/client/IndentPlugin.js +6 -1
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/link/client/plugins/clickableLink/index.js +7 -1
- package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +151 -59
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +9 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/lists/checklist/client/plugin/index.js +7 -1
- package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
- package/dist/features/lists/plugin/index.js +7 -1
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +18 -3
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +9 -2
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +18 -3
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +9 -2
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +100 -31
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +21 -4
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +12 -2
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +8 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/textState/feature.client.js +22 -5
- package/dist/features/textState/feature.client.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +123 -27
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +111 -18
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +14 -4
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +135 -56
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +70 -16
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/upload/client/component/index.js +167 -43
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/pending/index.js +16 -3
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js +21 -4
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +17 -3
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +9 -2
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +54 -11
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.js +60 -18
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.js +42 -7
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.js +91 -21
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/index.js +17 -4
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +141 -26
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RenderLexical/index.js +47 -15
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/RichTextViewProvider.d.ts +83 -0
- package/dist/field/RichTextViewProvider.d.ts.map +1 -0
- package/dist/field/RichTextViewProvider.js +102 -0
- package/dist/field/RichTextViewProvider.js.map +1 -0
- package/dist/field/ViewSelector.d.ts +4 -0
- package/dist/field/ViewSelector.d.ts.map +1 -0
- package/dist/field/ViewSelector.js +90 -0
- package/dist/field/ViewSelector.js.map +1 -0
- package/dist/field/ViewSelector.scss +34 -0
- package/dist/field/index.d.ts +1 -0
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +56 -12
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.scss +12 -0
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +21 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/EditorPlugin.js +17 -2
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +238 -69
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +74 -15
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +11 -2
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +3 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +4 -0
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js +3 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +12 -2
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +187 -2
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +28 -5
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +31 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +14 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +98 -31
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +27 -7
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +45 -7
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +18 -3
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/ui/icons/AI/index.js +58 -10
- package/dist/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/lexical/ui/icons/Add/index.js +31 -4
- package/dist/lexical/ui/icons/Add/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignCenter/index.js +45 -5
- package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignJustify/index.js +45 -5
- package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignLeft/index.js +45 -5
- package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignRight/index.js +45 -5
- package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/lexical/ui/icons/Block/index.js +54 -5
- package/dist/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/lexical/ui/icons/Blockquote/index.js +24 -3
- package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/lexical/ui/icons/Bold/index.js +24 -3
- package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/lexical/ui/icons/Checklist/index.js +39 -4
- package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/lexical/ui/icons/Code/index.js +34 -4
- package/dist/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +22 -3
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.js +23 -3
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
- package/dist/lexical/ui/icons/H1/index.js +24 -3
- package/dist/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/lexical/ui/icons/H2/index.js +24 -3
- package/dist/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/lexical/ui/icons/H3/index.js +24 -3
- package/dist/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/lexical/ui/icons/H4/index.js +24 -3
- package/dist/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/lexical/ui/icons/H5/index.js +24 -3
- package/dist/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/lexical/ui/icons/H6/index.js +24 -3
- package/dist/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/lexical/ui/icons/HorizontalRule/index.js +27 -3
- package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentDecrease/index.js +53 -6
- package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentIncrease/index.js +53 -6
- package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/InlineBlocks/index.js +26 -3
- package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
- package/dist/lexical/ui/icons/Italic/index.js +24 -3
- package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/lexical/ui/icons/Link/index.js +25 -3
- package/dist/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/lexical/ui/icons/Meatballs/index.js +39 -5
- package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
- package/dist/lexical/ui/icons/OrderedList/index.js +61 -7
- package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Relationship/index.js +58 -10
- package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/lexical/ui/icons/Strikethrough/index.js +34 -4
- package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/lexical/ui/icons/Subscript/index.js +24 -3
- package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Superscript/index.js +24 -3
- package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Table/index.js +24 -3
- package/dist/lexical/ui/icons/Table/index.js.map +1 -1
- package/dist/lexical/ui/icons/Text/index.js +24 -3
- package/dist/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/lexical/ui/icons/TextState/index.js +18 -12
- package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
- package/dist/lexical/ui/icons/Underline/index.js +34 -4
- package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/lexical/ui/icons/UnorderedList/index.js +81 -8
- package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Upload/index.js +48 -5
- package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/types.d.ts +152 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +55 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +41 -16
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +42 -10
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +9 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +11 -3
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -0
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +6 -1
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +10 -4
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +12 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport type { RichTextField } from 'payload'\n\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { DefaultTypedEditorState } from '../../nodeTypes.js'\nimport type { LexicalRichTextField } from '../../types.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & RenderFieldServerFnArgs<LexicalRichTextField>\n> = (args) => {\n const { field, initialValue, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.', 2)\n\n const fieldPath = path ?? (field && 'name' in field ? field?.name : '') ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n field: {\n ...((field as RichTextField) || {}),\n type: 'richText',\n admin: {\n ...((field as RichTextField)?.admin || {}),\n // When using \"fake\" anchor fields, hidden is often set to true. We need to override that here to ensure the field is rendered.\n hidden: false,\n },\n },\n initialValue: initialValue ?? undefined,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, field, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"names":["FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","field","initialValue","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldPath","name","renderLexical","render","Field","type","admin","hidden","undefined","mounted","current","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","
|
|
1
|
+
{"version":3,"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport type { RichTextField } from 'payload'\n\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { DefaultTypedEditorState } from '../../nodeTypes.js'\nimport type { LexicalRichTextField } from '../../types.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & RenderFieldServerFnArgs<LexicalRichTextField>\n> = (args) => {\n const { field, initialValue, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.', 2)\n\n const fieldPath = path ?? (field && 'name' in field ? field?.name : '') ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n field: {\n ...((field as RichTextField) || {}),\n type: 'richText',\n admin: {\n ...((field as RichTextField)?.admin || {}),\n // When using \"fake\" anchor fields, hidden is often set to true. We need to override that here to ensure the field is rendered.\n hidden: false,\n },\n },\n initialValue: initialValue ?? undefined,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, field, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"names":["FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","field","initialValue","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldPath","name","renderLexical","render","Field","type","admin","hidden","undefined","mounted","current","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","fieldValue","disabled","formInitializing","formProcessing","formSubmitted","showError"],"mappings":"AAAA;;AAGA,SACEA,YAAY,EACZC,gBAAgB,EAGhBC,sBAAsB,EAEtBC,aAAa,EACbC,kBAAkB,QACb,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,QAAO;AAK7D;;;;;CAKC,GACD,OAAO,MAAMC,gBACX;;;GAGC,GAEC;;KAEC,GAMD,CAACC;IACH,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,OAAO,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGP;IAC5E,MAAM,CAACQ,WAAWC,aAAa,GAAGd,MAAMe,QAAQ,CAAyB;IACzE,MAAMC,wBAAwBjB;IAC9B,MAAM,EAAEkB,qBAAqB,EAAE,GAAGD;IAElC,MAAM,CAACE,YAAYC,WAAW,GAAGT,WAAWU,KAAK,CAAC,KAAK;IAEvD,MAAMC,YAAYZ,QAASH,CAAAA,SAAS,UAAUA,QAAQA,OAAOgB,OAAO,EAAC,KAAM;IAE3E,MAAMC,gBAAgBtB,YAAY;QAChC,eAAeuB;YACb,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMR,sBAAsB;gBAC5CX,OAAO;oBACL,GAAI,AAACA,SAA2B,CAAC,CAAC;oBAClCoB,MAAM;oBACNC,OAAO;wBACL,GAAI,AAACrB,OAAyBqB,SAAS,CAAC,CAAC;wBACzC,+HAA+H;wBAC/HC,QAAQ;oBACV;gBACF;gBACArB,cAAcA,gBAAgBsB;gBAC9BpB;gBACAC;YACF;YAEAI,aAAaW;QACf;QACA,KAAKD;IACP,GAAG;QAACP;QAAuBP;QAAYD;QAAMH;QAAOC;KAAa;IAEjE,MAAMuB,UAAU3B,OAAO;IAEvBD,UAAU;QACR,IAAI4B,QAAQC,OAAO,EAAE;YACnB;QACF;QACAD,QAAQC,OAAO,GAAG;QAClB,KAAKR;IACP,GAAG;QAACA;KAAc;IAElB,IAAI,CAACV,WAAW;QACd,OAAO,OAAOL,YAAY,cAAcA,wBAAU,QAACV;;;;;IACrD;IAEA;;;;GAIC,GACD,MAAMkC,gCAA4D;QAChE,GAAGhB,qBAAqB;QACxBiB,cAAc,OAAOC;YACnB,OAAOlB,sBAAsBiB,YAAY,CAAC;gBACxC,GAAGC,gBAAgB;gBACnBC,gBAAgBjB,eAAe,eAAeC,aAAaU;gBAC3DO,YAAYlB,eAAe,WAAWC,aAAaU;YACrD;QACF;IACF;IAEA,IAAI,OAAOjB,UAAU,eAAe,CAACD,UAAU;QAC7C,qBACE,QAACd;YAAuBe,OAAO;gBAAE,GAAGoB,6BAA6B;YAAC;sBAChE,cAAA,QAACpC;gBAAiCgB,OAAOS;0BACtCR;eADoBQ;;;;;;;;;;IAK7B;IAEA,MAAMgB,aAA6D;QACjEC,UAAU;QACVC,kBAAkB;QAClBC,gBAAgB;QAChBC,eAAe;QACflC,cAAcK;QACdH,MAAMY;QACNV,UAAUA,YAAa,CAAA,IAAMkB,SAAQ;QACrCa,WAAW;QACX9B;IACF;IAEA,qBACE,QAACf;QAAuBe,OAAO;YAAE,GAAGoB,6BAA6B;QAAC;kBAChE,cAAA,QAACpC;YAAiCgB,OAAOS;sBACvC,cAAA,QAAC1B;gBAAaiB,OAAOyB;0BAAaxB;;;;;;WADbQ;;;;;;;;;;AAK7B,EAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Context type for rich text view management.
|
|
5
|
+
*/
|
|
6
|
+
type RichTextViewContextType = {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the currently active view (e.g., 'default', 'frontend', 'debug')
|
|
9
|
+
*/
|
|
10
|
+
currentView: string;
|
|
11
|
+
/**
|
|
12
|
+
* The node map for the currently active view, containing rendering overrides for each node type.
|
|
13
|
+
* This is the resolved view from the views map based on currentView.
|
|
14
|
+
*/
|
|
15
|
+
currentViewMap?: LexicalEditorNodeMap;
|
|
16
|
+
/**
|
|
17
|
+
* If true, the current view will be inherited by nested richtext editors.
|
|
18
|
+
*/
|
|
19
|
+
inheritable?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Function to change the current view.
|
|
22
|
+
*/
|
|
23
|
+
setCurrentView: (view: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* The complete map of all available views for this field.
|
|
26
|
+
*/
|
|
27
|
+
views?: LexicalEditorViewMap;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Provider component for rich text view context.
|
|
31
|
+
*
|
|
32
|
+
* This provider manages the current view state internally and makes it accessible to child components
|
|
33
|
+
* via the useRichTextView hook. It automatically resolves the current view's node map
|
|
34
|
+
* based on the active view name.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <RichTextViewProvider
|
|
39
|
+
* currentView="frontend"
|
|
40
|
+
* views={myViews}
|
|
41
|
+
* >
|
|
42
|
+
* <MyEditor />
|
|
43
|
+
* </RichTextViewProvider>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const RichTextViewProvider: React.FC<{
|
|
47
|
+
children: React.ReactNode;
|
|
48
|
+
currentView?: string;
|
|
49
|
+
inheritable?: boolean;
|
|
50
|
+
views?: LexicalEditorViewMap;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Hook to access the current rich text view context.
|
|
54
|
+
*
|
|
55
|
+
* Use this hook to access the currently active view and its node map,
|
|
56
|
+
* or to programmatically switch between views.
|
|
57
|
+
*
|
|
58
|
+
* @returns An object containing:
|
|
59
|
+
* - `currentView`: The name of the active view
|
|
60
|
+
* - `currentViewMap`: The node overrides for the current view
|
|
61
|
+
* - `setCurrentView`: Function to change views
|
|
62
|
+
* - `views`: All available views
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* function MyComponent() {
|
|
67
|
+
* const { currentView, currentViewMap, setCurrentView } = useRichTextView()
|
|
68
|
+
*
|
|
69
|
+
* return (
|
|
70
|
+
* <div>
|
|
71
|
+
* <p>Current view: {currentView}</p>
|
|
72
|
+
* {currentViewMap?.heading && <p>Heading overrides are active</p>}
|
|
73
|
+
* <button onClick={() => setCurrentView('frontend')}>
|
|
74
|
+
* Switch to frontend view
|
|
75
|
+
* </button>
|
|
76
|
+
* </div>
|
|
77
|
+
* )
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function useRichTextView(): RichTextViewContextType;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=RichTextViewProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextViewProvider.d.ts","sourceRoot":"","sources":["../../src/field/RichTextViewProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAE7E;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B,CAAA;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B,CA6BA,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,IAAI,uBAAuB,CAEzD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
|
+
import { useControllableState } from '@payloadcms/ui';
|
|
4
|
+
import React, { createContext, use, useMemo } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Context type for rich text view management.
|
|
7
|
+
*/ /**
|
|
8
|
+
* The name of the currently active view (e.g., 'default', 'frontend', 'debug')
|
|
9
|
+
*/ /**
|
|
10
|
+
* The node map for the currently active view, containing rendering overrides for each node type.
|
|
11
|
+
* This is the resolved view from the views map based on currentView.
|
|
12
|
+
*/ /**
|
|
13
|
+
* If true, the current view will be inherited by nested richtext editors.
|
|
14
|
+
*/ /**
|
|
15
|
+
* Function to change the current view.
|
|
16
|
+
*/ /**
|
|
17
|
+
* The complete map of all available views for this field.
|
|
18
|
+
*/ const RichTextViewContext = /*#__PURE__*/ createContext({
|
|
19
|
+
currentView: 'default',
|
|
20
|
+
inheritable: false,
|
|
21
|
+
setCurrentView: ()=>{}
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Provider component for rich text view context.
|
|
25
|
+
*
|
|
26
|
+
* This provider manages the current view state internally and makes it accessible to child components
|
|
27
|
+
* via the useRichTextView hook. It automatically resolves the current view's node map
|
|
28
|
+
* based on the active view name.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <RichTextViewProvider
|
|
33
|
+
* currentView="frontend"
|
|
34
|
+
* views={myViews}
|
|
35
|
+
* >
|
|
36
|
+
* <MyEditor />
|
|
37
|
+
* </RichTextViewProvider>
|
|
38
|
+
* ```
|
|
39
|
+
*/ export const RichTextViewProvider = (args)=>{
|
|
40
|
+
const parentContext = useRichTextView();
|
|
41
|
+
const { children, currentView: currentViewFromProps, inheritable, views } = parentContext.inheritable ? {
|
|
42
|
+
...parentContext,
|
|
43
|
+
...args
|
|
44
|
+
} : args;
|
|
45
|
+
const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default');
|
|
46
|
+
const value = useMemo(()=>{
|
|
47
|
+
const currentViewMap = views ? views[currentView] || views.default : undefined;
|
|
48
|
+
return {
|
|
49
|
+
currentView,
|
|
50
|
+
currentViewMap,
|
|
51
|
+
inheritable,
|
|
52
|
+
setCurrentView,
|
|
53
|
+
views
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
currentView,
|
|
57
|
+
inheritable,
|
|
58
|
+
setCurrentView,
|
|
59
|
+
views
|
|
60
|
+
]);
|
|
61
|
+
return /*#__PURE__*/ _jsxDEV(RichTextViewContext, {
|
|
62
|
+
value: value,
|
|
63
|
+
children: children
|
|
64
|
+
}, void 0, false, {
|
|
65
|
+
fileName: "src/field/RichTextViewProvider.tsx",
|
|
66
|
+
lineNumber: 90,
|
|
67
|
+
columnNumber: 10
|
|
68
|
+
}, this);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Hook to access the current rich text view context.
|
|
72
|
+
*
|
|
73
|
+
* Use this hook to access the currently active view and its node map,
|
|
74
|
+
* or to programmatically switch between views.
|
|
75
|
+
*
|
|
76
|
+
* @returns An object containing:
|
|
77
|
+
* - `currentView`: The name of the active view
|
|
78
|
+
* - `currentViewMap`: The node overrides for the current view
|
|
79
|
+
* - `setCurrentView`: Function to change views
|
|
80
|
+
* - `views`: All available views
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* function MyComponent() {
|
|
85
|
+
* const { currentView, currentViewMap, setCurrentView } = useRichTextView()
|
|
86
|
+
*
|
|
87
|
+
* return (
|
|
88
|
+
* <div>
|
|
89
|
+
* <p>Current view: {currentView}</p>
|
|
90
|
+
* {currentViewMap?.heading && <p>Heading overrides are active</p>}
|
|
91
|
+
* <button onClick={() => setCurrentView('frontend')}>
|
|
92
|
+
* Switch to frontend view
|
|
93
|
+
* </button>
|
|
94
|
+
* </div>
|
|
95
|
+
* )
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/ export function useRichTextView() {
|
|
99
|
+
return use(RichTextViewContext);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=RichTextViewProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/field/RichTextViewProvider.tsx"],"sourcesContent":["'use client'\nimport { useControllableState } from '@payloadcms/ui'\nimport React, { createContext, use, useMemo } from 'react'\n\nimport type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js'\n\n/**\n * Context type for rich text view management.\n */\ntype RichTextViewContextType = {\n /**\n * The name of the currently active view (e.g., 'default', 'frontend', 'debug')\n */\n currentView: string\n /**\n * The node map for the currently active view, containing rendering overrides for each node type.\n * This is the resolved view from the views map based on currentView.\n */\n currentViewMap?: LexicalEditorNodeMap\n /**\n * If true, the current view will be inherited by nested richtext editors.\n */\n inheritable?: boolean\n /**\n * Function to change the current view.\n */\n setCurrentView: (view: string) => void\n /**\n * The complete map of all available views for this field.\n */\n views?: LexicalEditorViewMap\n}\n\nconst RichTextViewContext = createContext<RichTextViewContextType>({\n currentView: 'default',\n inheritable: false,\n setCurrentView: () => {},\n})\n\n/**\n * Provider component for rich text view context.\n *\n * This provider manages the current view state internally and makes it accessible to child components\n * via the useRichTextView hook. It automatically resolves the current view's node map\n * based on the active view name.\n *\n * @example\n * ```tsx\n * <RichTextViewProvider\n * currentView=\"frontend\"\n * views={myViews}\n * >\n * <MyEditor />\n * </RichTextViewProvider>\n * ```\n */\nexport const RichTextViewProvider: React.FC<{\n children: React.ReactNode\n currentView?: string\n inheritable?: boolean\n views?: LexicalEditorViewMap\n}> = (args) => {\n const parentContext = useRichTextView()\n\n const {\n children,\n currentView: currentViewFromProps,\n inheritable,\n views,\n } = parentContext.inheritable\n ? {\n ...parentContext,\n ...args,\n }\n : args\n\n const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default')\n\n const value = useMemo(() => {\n const currentViewMap = views ? views[currentView] || views.default : undefined\n return {\n currentView,\n currentViewMap,\n inheritable,\n setCurrentView,\n views,\n }\n }, [currentView, inheritable, setCurrentView, views])\n\n return <RichTextViewContext value={value}>{children}</RichTextViewContext>\n}\n\n/**\n * Hook to access the current rich text view context.\n *\n * Use this hook to access the currently active view and its node map,\n * or to programmatically switch between views.\n *\n * @returns An object containing:\n * - `currentView`: The name of the active view\n * - `currentViewMap`: The node overrides for the current view\n * - `setCurrentView`: Function to change views\n * - `views`: All available views\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { currentView, currentViewMap, setCurrentView } = useRichTextView()\n *\n * return (\n * <div>\n * <p>Current view: {currentView}</p>\n * {currentViewMap?.heading && <p>Heading overrides are active</p>}\n * <button onClick={() => setCurrentView('frontend')}>\n * Switch to frontend view\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRichTextView(): RichTextViewContextType {\n return use(RichTextViewContext)\n}\n"],"names":["useControllableState","React","createContext","use","useMemo","RichTextViewContext","currentView","inheritable","setCurrentView","RichTextViewProvider","args","parentContext","useRichTextView","children","currentViewFromProps","views","value","currentViewMap","default","undefined"],"mappings":"AAAA;;AACA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,OAAO,QAAQ,QAAO;AAI1D;;CAEC,GAEC;;GAEC,GAED;;;GAGC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAIH,MAAMC,oCAAsBH,cAAuC;IACjEI,aAAa;IACbC,aAAa;IACbC,gBAAgB,KAAO;AACzB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAKR,CAACC;IACJ,MAAMC,gBAAgBC;IAEtB,MAAM,EACJC,QAAQ,EACRP,aAAaQ,oBAAoB,EACjCP,WAAW,EACXQ,KAAK,EACN,GAAGJ,cAAcJ,WAAW,GACzB;QACE,GAAGI,aAAa;QAChB,GAAGD,IAAI;IACT,IACAA;IAEJ,MAAM,CAACJ,aAAaE,eAAe,GAAGR,qBAAqBc,sBAAsB;IAEjF,MAAME,QAAQZ,QAAQ;QACpB,MAAMa,iBAAiBF,QAAQA,KAAK,CAACT,YAAY,IAAIS,MAAMG,OAAO,GAAGC;QACrE,OAAO;YACLb;YACAW;YACAV;YACAC;YACAO;QACF;IACF,GAAG;QAACT;QAAaC;QAAaC;QAAgBO;KAAM;IAEpD,qBAAO,QAACV;QAAoBW,OAAOA;kBAAQH;;;;;;AAC7C,EAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,SAASD;IACd,OAAOT,IAAIE;AACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewSelector.d.ts","sourceRoot":"","sources":["../../src/field/ViewSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,qBAAqB,CAAA;AAE5B,wBAAgB,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,YAAY,CAyDxD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
|
+
import { ChevronIcon, Popup, PopupList } from '@payloadcms/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useRichTextView } from './RichTextViewProvider.js';
|
|
6
|
+
import './ViewSelector.scss';
|
|
7
|
+
export function ViewSelector() {
|
|
8
|
+
const { currentView, setCurrentView, views } = useRichTextView();
|
|
9
|
+
// Don't show if no views or only default exists
|
|
10
|
+
if (!views || Object.keys(views).length === 0) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const viewKeys = Object.keys(views);
|
|
14
|
+
const hasNonDefaultViews = viewKeys.some((key)=>key !== 'default');
|
|
15
|
+
// If only 'default' exists, no need to show selector
|
|
16
|
+
if (!hasNonDefaultViews) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
// Build list of available views
|
|
20
|
+
const allViews = [
|
|
21
|
+
'default',
|
|
22
|
+
...viewKeys.filter((key)=>key !== 'default')
|
|
23
|
+
];
|
|
24
|
+
const currentViewLabel = currentView.charAt(0).toUpperCase() + currentView.slice(1);
|
|
25
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
26
|
+
className: "lexical-view-selector",
|
|
27
|
+
children: /*#__PURE__*/ _jsxDEV(Popup, {
|
|
28
|
+
button: /*#__PURE__*/ _jsxDEV("button", {
|
|
29
|
+
className: "lexical-view-selector__button",
|
|
30
|
+
type: "button",
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ _jsxDEV("span", {
|
|
33
|
+
className: "lexical-view-selector__label",
|
|
34
|
+
children: currentViewLabel
|
|
35
|
+
}, void 0, false, {
|
|
36
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
37
|
+
lineNumber: 34,
|
|
38
|
+
columnNumber: 13
|
|
39
|
+
}, void 0),
|
|
40
|
+
/*#__PURE__*/ _jsxDEV(ChevronIcon, {
|
|
41
|
+
className: "lexical-view-selector__icon"
|
|
42
|
+
}, void 0, false, {
|
|
43
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
44
|
+
lineNumber: 35,
|
|
45
|
+
columnNumber: 13
|
|
46
|
+
}, void 0)
|
|
47
|
+
]
|
|
48
|
+
}, void 0, true, {
|
|
49
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
50
|
+
lineNumber: 33,
|
|
51
|
+
columnNumber: 11
|
|
52
|
+
}, void 0),
|
|
53
|
+
buttonType: "custom",
|
|
54
|
+
horizontalAlign: "left",
|
|
55
|
+
render: ({ close })=>/*#__PURE__*/ _jsxDEV(PopupList.ButtonGroup, {
|
|
56
|
+
children: allViews.map((viewName)=>{
|
|
57
|
+
const viewLabel = viewName.charAt(0).toUpperCase() + viewName.slice(1);
|
|
58
|
+
return /*#__PURE__*/ _jsxDEV(PopupList.Button, {
|
|
59
|
+
active: viewName === currentView,
|
|
60
|
+
disabled: viewName === currentView,
|
|
61
|
+
onClick: ()=>{
|
|
62
|
+
setCurrentView?.(viewName);
|
|
63
|
+
close();
|
|
64
|
+
},
|
|
65
|
+
children: viewLabel
|
|
66
|
+
}, viewName, false, {
|
|
67
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
68
|
+
lineNumber: 46,
|
|
69
|
+
columnNumber: 17
|
|
70
|
+
}, void 0);
|
|
71
|
+
})
|
|
72
|
+
}, void 0, false, {
|
|
73
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
74
|
+
lineNumber: 41,
|
|
75
|
+
columnNumber: 11
|
|
76
|
+
}, void 0),
|
|
77
|
+
size: "large"
|
|
78
|
+
}, void 0, false, {
|
|
79
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
80
|
+
lineNumber: 31,
|
|
81
|
+
columnNumber: 7
|
|
82
|
+
}, this)
|
|
83
|
+
}, void 0, false, {
|
|
84
|
+
fileName: "src/field/ViewSelector.tsx",
|
|
85
|
+
lineNumber: 30,
|
|
86
|
+
columnNumber: 5
|
|
87
|
+
}, this);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=ViewSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/field/ViewSelector.tsx"],"sourcesContent":["'use client'\nimport { ChevronIcon, Popup, PopupList } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useRichTextView } from './RichTextViewProvider.js'\nimport './ViewSelector.scss'\n\nexport function ViewSelector(): null | React.ReactElement {\n const { currentView, setCurrentView, views } = useRichTextView()\n\n // Don't show if no views or only default exists\n if (!views || Object.keys(views).length === 0) {\n return null\n }\n\n const viewKeys = Object.keys(views)\n const hasNonDefaultViews = viewKeys.some((key) => key !== 'default')\n\n // If only 'default' exists, no need to show selector\n if (!hasNonDefaultViews) {\n return null\n }\n\n // Build list of available views\n const allViews = ['default', ...viewKeys.filter((key) => key !== 'default')]\n\n const currentViewLabel = currentView.charAt(0).toUpperCase() + currentView.slice(1)\n\n return (\n <div className=\"lexical-view-selector\">\n <Popup\n button={\n <button className=\"lexical-view-selector__button\" type=\"button\">\n <span className=\"lexical-view-selector__label\">{currentViewLabel}</span>\n <ChevronIcon className=\"lexical-view-selector__icon\" />\n </button>\n }\n buttonType=\"custom\"\n horizontalAlign=\"left\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {allViews.map((viewName) => {\n const viewLabel = viewName.charAt(0).toUpperCase() + viewName.slice(1)\n\n return (\n <PopupList.Button\n active={viewName === currentView}\n disabled={viewName === currentView}\n key={viewName}\n onClick={() => {\n setCurrentView?.(viewName)\n close()\n }}\n >\n {viewLabel}\n </PopupList.Button>\n )\n })}\n </PopupList.ButtonGroup>\n )}\n size=\"large\"\n />\n </div>\n )\n}\n"],"names":["ChevronIcon","Popup","PopupList","React","useRichTextView","ViewSelector","currentView","setCurrentView","views","Object","keys","length","viewKeys","hasNonDefaultViews","some","key","allViews","filter","currentViewLabel","charAt","toUpperCase","slice","div","className","button","type","span","buttonType","horizontalAlign","render","close","ButtonGroup","map","viewName","viewLabel","Button","active","disabled","onClick","size"],"mappings":"AAAA;;AACA,SAASA,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,iBAAgB;AAC9D,OAAOC,WAAW,QAAO;AAEzB,SAASC,eAAe,QAAQ,4BAA2B;AAC3D,OAAO,sBAAqB;AAE5B,OAAO,SAASC;IACd,MAAM,EAAEC,WAAW,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGJ;IAE/C,gDAAgD;IAChD,IAAI,CAACI,SAASC,OAAOC,IAAI,CAACF,OAAOG,MAAM,KAAK,GAAG;QAC7C,OAAO;IACT;IAEA,MAAMC,WAAWH,OAAOC,IAAI,CAACF;IAC7B,MAAMK,qBAAqBD,SAASE,IAAI,CAAC,CAACC,MAAQA,QAAQ;IAE1D,qDAAqD;IACrD,IAAI,CAACF,oBAAoB;QACvB,OAAO;IACT;IAEA,gCAAgC;IAChC,MAAMG,WAAW;QAAC;WAAcJ,SAASK,MAAM,CAAC,CAACF,MAAQA,QAAQ;KAAW;IAE5E,MAAMG,mBAAmBZ,YAAYa,MAAM,CAAC,GAAGC,WAAW,KAAKd,YAAYe,KAAK,CAAC;IAEjF,qBACE,QAACC;QAAIC,WAAU;kBACb,cAAA,QAACtB;YACCuB,sBACE,QAACA;gBAAOD,WAAU;gBAAgCE,MAAK;;kCACrD,QAACC;wBAAKH,WAAU;kCAAgCL;;;;;;kCAChD,QAAClB;wBAAYuB,WAAU;;;;;;;;;;;;YAG3BI,YAAW;YACXC,iBAAgB;YAChBC,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,QAAC5B,UAAU6B,WAAW;8BACnBf,SAASgB,GAAG,CAAC,CAACC;wBACb,MAAMC,YAAYD,SAASd,MAAM,CAAC,GAAGC,WAAW,KAAKa,SAASZ,KAAK,CAAC;wBAEpE,qBACE,QAACnB,UAAUiC,MAAM;4BACfC,QAAQH,aAAa3B;4BACrB+B,UAAUJ,aAAa3B;4BAEvBgC,SAAS;gCACP/B,iBAAiB0B;gCACjBH;4BACF;sCAECI;2BANID;;;;;oBASX;;;;;;YAGJM,MAAK;;;;;;;;;;;AAIb"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
.lexical-view-selector {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
margin-left: var(--spacing-xs);
|
|
6
|
+
vertical-align: middle;
|
|
7
|
+
|
|
8
|
+
&__button {
|
|
9
|
+
all: unset;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 4px;
|
|
13
|
+
padding: 2px 6px;
|
|
14
|
+
background: transparent;
|
|
15
|
+
border-radius: var(--border-radius-s);
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
color: var(--theme-elevation-600);
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
background: var(--theme-elevation-100);
|
|
22
|
+
color: var(--theme-elevation-800);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__label {
|
|
27
|
+
line-height: 1;
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&__icon {
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/field/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { LexicalRichTextFieldProps } from '../types.js';
|
|
3
3
|
export declare const RichTextField: React.FC<LexicalRichTextFieldProps>;
|
|
4
|
+
export declare const RichTextFieldImpl: React.FC<LexicalRichTextFieldProps>;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAIlE,OAAO,KAAK,EAAgC,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAW1F,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAM7D,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAgFjE,CAAA"}
|
package/dist/field/index.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
|
+
import { createElement as _createElement } from "react";
|
|
2
4
|
import { ShimmerEffect, useConfig } from '@payloadcms/ui';
|
|
3
|
-
import { lazy, Suspense, useEffect, useState } from 'react';
|
|
5
|
+
import React, { lazy, Suspense, useEffect, useState } from 'react';
|
|
4
6
|
import { defaultEditorLexicalConfig } from '../lexical/config/client/default.js';
|
|
5
7
|
import { loadClientFeatures } from '../lexical/config/client/loader.js';
|
|
6
8
|
import { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js';
|
|
7
|
-
|
|
9
|
+
import { RichTextViewProvider, useRichTextView } from './RichTextViewProvider.js';
|
|
10
|
+
const RichTextEditor = /*#__PURE__*/ lazy(()=>import('./Field.js').then((module)=>({
|
|
8
11
|
default: module.RichText
|
|
9
12
|
})));
|
|
10
13
|
export const RichTextField = (props)=>{
|
|
11
|
-
|
|
14
|
+
return /*#__PURE__*/ _jsxDEV(RichTextViewProvider, {
|
|
15
|
+
views: props.views,
|
|
16
|
+
children: /*#__PURE__*/ _jsxDEV(RichTextFieldImpl, {
|
|
17
|
+
...props
|
|
18
|
+
}, void 0, false, {
|
|
19
|
+
fileName: "src/field/index.tsx",
|
|
20
|
+
lineNumber: 25,
|
|
21
|
+
columnNumber: 7
|
|
22
|
+
}, this)
|
|
23
|
+
}, void 0, false, {
|
|
24
|
+
fileName: "src/field/index.tsx",
|
|
25
|
+
lineNumber: 24,
|
|
26
|
+
columnNumber: 5
|
|
27
|
+
}, this);
|
|
28
|
+
};
|
|
29
|
+
export const RichTextFieldImpl = (props)=>{
|
|
30
|
+
const { admin: _admin = {}, clientFeatures, featureClientImportMap = {}, featureClientSchemaMap, field, lexicalEditorConfig: _lexicalEditorConfig = defaultEditorLexicalConfig, schemaPath, views } = props;
|
|
31
|
+
const { currentView } = useRichTextView();
|
|
32
|
+
const currentViewAdminConfig = views?.[currentView]?.admin ?? _admin;
|
|
33
|
+
const currentViewLexicalEditorConfig = views?.[currentView]?.lexical ?? _lexicalEditorConfig;
|
|
12
34
|
const { config } = useConfig();
|
|
13
35
|
const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] = useState(null);
|
|
14
36
|
useEffect(()=>{
|
|
15
|
-
if (finalSanitizedEditorConfig) {
|
|
37
|
+
if (finalSanitizedEditorConfig && finalSanitizedEditorConfig.view === currentView) {
|
|
16
38
|
return;
|
|
17
39
|
}
|
|
18
40
|
const featureProvidersLocal = [];
|
|
@@ -31,25 +53,47 @@ export const RichTextField = (props)=>{
|
|
|
31
53
|
schemaPath: schemaPath ?? field.name,
|
|
32
54
|
unSanitizedEditorConfig: {
|
|
33
55
|
features: featureProvidersLocal,
|
|
34
|
-
lexical:
|
|
56
|
+
lexical: currentViewLexicalEditorConfig
|
|
35
57
|
}
|
|
36
58
|
});
|
|
37
|
-
setFinalSanitizedEditorConfig(sanitizeClientEditorConfig(resolvedClientFeatures,
|
|
59
|
+
setFinalSanitizedEditorConfig(sanitizeClientEditorConfig(resolvedClientFeatures, currentViewLexicalEditorConfig, currentViewAdminConfig, currentView));
|
|
38
60
|
}, [
|
|
39
|
-
|
|
61
|
+
currentViewAdminConfig,
|
|
40
62
|
clientFeatures,
|
|
41
63
|
config,
|
|
42
64
|
featureClientImportMap,
|
|
43
65
|
featureClientSchemaMap,
|
|
44
66
|
field,
|
|
45
67
|
finalSanitizedEditorConfig,
|
|
46
|
-
|
|
47
|
-
schemaPath
|
|
68
|
+
currentViewLexicalEditorConfig,
|
|
69
|
+
schemaPath,
|
|
70
|
+
currentView
|
|
48
71
|
]);
|
|
49
72
|
// TODO: Optimize this and use useMemo for this in the future. This might break sub-richtext-blocks from the blocks feature. Need to investigate
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
return /*#__PURE__*/ _jsxDEV(Suspense, {
|
|
74
|
+
fallback: /*#__PURE__*/ _jsxDEV(ShimmerEffect, {
|
|
75
|
+
height: "35vh"
|
|
76
|
+
}, void 0, false, {
|
|
77
|
+
fileName: "src/field/index.tsx",
|
|
78
|
+
lineNumber: 100,
|
|
79
|
+
columnNumber: 25
|
|
80
|
+
}, void 0),
|
|
81
|
+
children: finalSanitizedEditorConfig && /*#__PURE__*/ _createElement(RichTextEditor, {
|
|
82
|
+
...props,
|
|
83
|
+
editorConfig: finalSanitizedEditorConfig,
|
|
84
|
+
key: finalSanitizedEditorConfig.view,
|
|
85
|
+
__source: {
|
|
86
|
+
fileName: "src/field/index.tsx",
|
|
87
|
+
lineNumber: 102,
|
|
88
|
+
columnNumber: 9
|
|
89
|
+
},
|
|
90
|
+
__self: this
|
|
91
|
+
})
|
|
92
|
+
}, void 0, false, {
|
|
93
|
+
fileName: "src/field/index.tsx",
|
|
94
|
+
lineNumber: 100,
|
|
95
|
+
columnNumber: 5
|
|
96
|
+
}, this);
|
|
53
97
|
};
|
|
54
98
|
|
|
55
99
|
//# sourceMappingURL=index.js.map
|
package/dist/field/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RichTextFieldClient } from 'payload'\n\nimport { ShimmerEffect, useConfig } from '@payloadcms/ui'\nimport React, { lazy, Suspense, useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../lexical/config/client/default.js'\nimport { loadClientFeatures } from '../lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {\n const {\n admin = {},\n clientFeatures,\n featureClientImportMap = {},\n featureClientSchemaMap,\n field,\n lexicalEditorConfig = defaultEditorLexicalConfig,\n schemaPath,\n } = props\n\n const { config } = useConfig()\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<null | SanitizedClientEditorConfig>(null)\n\n useEffect(() => {\n if (finalSanitizedEditorConfig) {\n return\n }\n\n const featureProvidersLocal: FeatureProviderClient<any, any>[] = []\n for (const clientFeature of Object.values(clientFeatures)) {\n if (!clientFeature.clientFeatureProvider) {\n continue\n }\n featureProvidersLocal.push(\n clientFeature.clientFeatureProvider(clientFeature.clientFeatureProps),\n ) // Execute the clientFeatureProvider function here, as the server cannot execute functions imported from use client files\n }\n\n const resolvedClientFeatures = loadClientFeatures({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field: field as RichTextFieldClient,\n schemaPath: schemaPath ?? field.name,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical:
|
|
1
|
+
{"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\nimport type { RichTextFieldClient } from 'payload'\n\nimport { ShimmerEffect, useConfig } from '@payloadcms/ui'\nimport React, { lazy, Suspense, useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalFieldAdminClientProps, LexicalRichTextFieldProps } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../lexical/config/client/default.js'\nimport { loadClientFeatures } from '../lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js'\nimport { RichTextViewProvider, useRichTextView } from './RichTextViewProvider.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {\n return (\n <RichTextViewProvider views={props.views}>\n <RichTextFieldImpl {...props} />\n </RichTextViewProvider>\n )\n}\n\nexport const RichTextFieldImpl: React.FC<LexicalRichTextFieldProps> = (props) => {\n const {\n admin: _admin = {},\n clientFeatures,\n featureClientImportMap = {},\n featureClientSchemaMap,\n field,\n lexicalEditorConfig: _lexicalEditorConfig = defaultEditorLexicalConfig,\n schemaPath,\n views,\n } = props\n const { currentView } = useRichTextView()\n const currentViewAdminConfig: LexicalFieldAdminClientProps = views?.[currentView]?.admin ?? _admin\n const currentViewLexicalEditorConfig: LexicalEditorConfig =\n views?.[currentView]?.lexical ?? _lexicalEditorConfig\n\n const { config } = useConfig()\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<null | SanitizedClientEditorConfig>(null)\n\n useEffect(() => {\n if (finalSanitizedEditorConfig && finalSanitizedEditorConfig.view === currentView) {\n return\n }\n\n const featureProvidersLocal: FeatureProviderClient<any, any>[] = []\n for (const clientFeature of Object.values(clientFeatures)) {\n if (!clientFeature.clientFeatureProvider) {\n continue\n }\n featureProvidersLocal.push(\n clientFeature.clientFeatureProvider(clientFeature.clientFeatureProps),\n ) // Execute the clientFeatureProvider function here, as the server cannot execute functions imported from use client files\n }\n\n const resolvedClientFeatures = loadClientFeatures({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field: field as RichTextFieldClient,\n schemaPath: schemaPath ?? field.name,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: currentViewLexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n resolvedClientFeatures,\n currentViewLexicalEditorConfig,\n currentViewAdminConfig,\n currentView,\n ),\n )\n }, [\n currentViewAdminConfig,\n clientFeatures,\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n finalSanitizedEditorConfig,\n currentViewLexicalEditorConfig,\n schemaPath,\n currentView,\n ]) // TODO: Optimize this and use useMemo for this in the future. This might break sub-richtext-blocks from the blocks feature. Need to investigate\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor\n {...props}\n editorConfig={finalSanitizedEditorConfig}\n key={finalSanitizedEditorConfig.view}\n />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useConfig","React","lazy","Suspense","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextViewProvider","useRichTextView","RichTextEditor","then","module","default","RichText","RichTextField","props","views","RichTextFieldImpl","admin","_admin","clientFeatures","featureClientImportMap","featureClientSchemaMap","field","lexicalEditorConfig","_lexicalEditorConfig","schemaPath","currentView","currentViewAdminConfig","currentViewLexicalEditorConfig","lexical","config","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","view","featureProvidersLocal","clientFeature","Object","values","clientFeatureProvider","push","clientFeatureProps","resolvedClientFeatures","name","unSanitizedEditorConfig","features","fallback","height","editorConfig","key"],"mappings":"AAAA;;;AAKA,SAASA,aAAa,EAAEC,SAAS,QAAQ,iBAAgB;AACzD,OAAOC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlE,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,0BAA0B,QAAQ,uCAAsC;AACjF,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,4BAA2B;AAEjF,MAAMC,+BAAiBT,KAAK,IAC1B,MAAM,CAAC,cAAcU,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,QAAQ;QAAC,CAAA;AAGpE,OAAO,MAAMC,gBAAqD,CAACC;IACjE,qBACE,QAACR;QAAqBS,OAAOD,MAAMC,KAAK;kBACtC,cAAA,QAACC;YAAmB,GAAGF,KAAK;;;;;;;;;;;AAGlC,EAAC;AAED,OAAO,MAAME,oBAAyD,CAACF;IACrE,MAAM,EACJG,OAAOC,SAAS,CAAC,CAAC,EAClBC,cAAc,EACdC,yBAAyB,CAAC,CAAC,EAC3BC,sBAAsB,EACtBC,KAAK,EACLC,qBAAqBC,uBAAuBrB,0BAA0B,EACtEsB,UAAU,EACVV,KAAK,EACN,GAAGD;IACJ,MAAM,EAAEY,WAAW,EAAE,GAAGnB;IACxB,MAAMoB,yBAAuDZ,OAAO,CAACW,YAAY,EAAET,SAASC;IAC5F,MAAMU,iCACJb,OAAO,CAACW,YAAY,EAAEG,WAAWL;IAEnC,MAAM,EAAEM,MAAM,EAAE,GAAGjC;IAEnB,MAAM,CAACkC,4BAA4BC,8BAA8B,GAC/D9B,SAA6C;IAE/CD,UAAU;QACR,IAAI8B,8BAA8BA,2BAA2BE,IAAI,KAAKP,aAAa;YACjF;QACF;QAEA,MAAMQ,wBAA2D,EAAE;QACnE,KAAK,MAAMC,iBAAiBC,OAAOC,MAAM,CAAClB,gBAAiB;YACzD,IAAI,CAACgB,cAAcG,qBAAqB,EAAE;gBACxC;YACF;YACAJ,sBAAsBK,IAAI,CACxBJ,cAAcG,qBAAqB,CAACH,cAAcK,kBAAkB;QAExE;QADI,yHAAyH;QAG7H,MAAMC,yBAAyBrC,mBAAmB;YAChD0B;YACAV;YACAC;YACAC,OAAOA;YACPG,YAAYA,cAAcH,MAAMoB,IAAI;YACpCC,yBAAyB;gBACvBC,UAAUV;gBACVL,SAASD;YACX;QACF;QAEAI,8BACE3B,2BACEoC,wBACAb,gCACAD,wBACAD;IAGN,GAAG;QACDC;QACAR;QACAW;QACAV;QACAC;QACAC;QACAS;QACAH;QACAH;QACAC;KACD;IAAE,gJAAgJ;IAEnJ,qBACE,QAAC1B;QAAS6C,wBAAU,QAACjD;YAAckD,QAAO;;;;;;kBACvCf,4CACC,eAACvB;YACE,GAAGM,KAAK;YACTiC,cAAchB;YACdiB,KAAKjB,2BAA2BE,IAAI;;;;;;;;;;;;;AAK9C,EAAC"}
|
package/dist/field/index.scss
CHANGED
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
&__label-row {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
margin-bottom: calc(var(--base) / 4);
|
|
22
|
+
gap: calc(var(--base) / 3);
|
|
23
|
+
|
|
24
|
+
label.field-label:not(.unstyled) {
|
|
25
|
+
margin-right: unset;
|
|
26
|
+
padding-bottom: unset;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
&__wrap {
|
|
19
31
|
width: 100%;
|
|
20
32
|
position: relative;
|
package/dist/field/rscEntry.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ import type { SanitizedServerEditorConfig } from '../lexical/config/types.js';
|
|
|
4
4
|
import type { LexicalEditorProps } from '../types.js';
|
|
5
5
|
export declare const RscEntryLexicalField: React.FC<{
|
|
6
6
|
sanitizedEditorConfig: SanitizedServerEditorConfig;
|
|
7
|
-
} & ClientComponentProps & Pick<FieldPaths, 'path'> & Pick<LexicalEditorProps, 'admin'> & ServerComponentProps>;
|
|
7
|
+
} & ClientComponentProps & Pick<FieldPaths, 'path'> & Pick<LexicalEditorProps, 'admin' | 'views'> & ServerComponentProps>;
|
|
8
8
|
//# sourceMappingURL=rscEntry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/field/rscEntry.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/field/rscEntry.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,aAAa,CAAA;AAOpB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IACE,qBAAqB,EAAE,2BAA2B,CAAA;CACnD,GAAG,oBAAoB,GACtB,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GACxB,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAC,GAC3C,oBAAoB,CAyGvB,CAAA"}
|
package/dist/field/rscEntry.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
1
2
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
3
|
import { renderField } from '@payloadcms/ui/forms/renderField';
|
|
4
|
+
import { getFromImportMap } from 'payload/shared';
|
|
5
|
+
import React from 'react';
|
|
3
6
|
// eslint-disable-next-line payload/no-imports-from-exports-dir
|
|
4
7
|
import { RichTextField } from '../exports/client/index.js';
|
|
5
8
|
import { buildInitialState } from '../utilities/buildInitialState.js';
|
|
@@ -74,6 +77,17 @@ export const RscEntryLexicalField = async (args)=>{
|
|
|
74
77
|
renderedBlocks: args.renderedBlocks,
|
|
75
78
|
schemaPath
|
|
76
79
|
};
|
|
80
|
+
if (args?.views) {
|
|
81
|
+
const viewMap = getFromImportMap({
|
|
82
|
+
importMap: args.payload.importMap,
|
|
83
|
+
PayloadComponent: args.views,
|
|
84
|
+
schemaPath: 'lexical-viewMap',
|
|
85
|
+
silent: true
|
|
86
|
+
});
|
|
87
|
+
if (viewMap) {
|
|
88
|
+
props.views = viewMap;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
77
91
|
if (Object.keys(admin).length) {
|
|
78
92
|
props.admin = admin;
|
|
79
93
|
}
|
|
@@ -85,7 +99,13 @@ export const RscEntryLexicalField = async (args)=>{
|
|
|
85
99
|
delete props[key];
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
|
-
return
|
|
102
|
+
return /*#__PURE__*/ _jsxDEV(RichTextField, {
|
|
103
|
+
...props
|
|
104
|
+
}, void 0, false, {
|
|
105
|
+
fileName: "src/field/rscEntry.tsx",
|
|
106
|
+
lineNumber: 138,
|
|
107
|
+
columnNumber: 10
|
|
108
|
+
}, this);
|
|
89
109
|
};
|
|
90
110
|
|
|
91
111
|
//# sourceMappingURL=rscEntry.js.map
|