@payloadcms/richtext-lexical 3.68.0-internal-debug.2eb12b9 → 3.68.0-internal-debug.dafc24d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/rscEntry.js +13 -5
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +29 -9
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -3
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +124 -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 +118 -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/markdown/markdownTransformer.js +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.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 +88 -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 +13 -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 +19 -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/blocks/server/markdown/markdownTransformer.js +1 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
- 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 +14 -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 +62 -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 +8 -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 +225 -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 +32 -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 +26 -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.js +1 -0
- package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
- 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/autoLink/index.js +3 -0
- package/dist/features/link/client/plugins/autoLink/index.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 +8 -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/link/server/baseFields.js +1 -0
- package/dist/features/link/server/baseFields.js.map +1 -1
- 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 +14 -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 +14 -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 +56 -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 +72 -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 +72 -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 +8 -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 +37 -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 +92 -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 +14 -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 +37 -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 +37 -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 +31 -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 +60 -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 +8 -3
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Diff/index.scss +102 -0
- package/dist/field/Field.js +81 -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/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/EditorPlugin.js +13 -5
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +163 -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.js +1 -0
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.scss +13 -0
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +20 -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/LexicalMenu.js +2 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- 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 +50 -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 +20 -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 +32 -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 +14 -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/packages/@lexical/markdown/MarkdownShortcuts.js +2 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +2 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +2 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.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/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +2 -0
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +2 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/package.json +8 -7
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.lexical-diff {
|
|
5
|
+
.lexical-upload-diff {
|
|
6
|
+
@extend %body;
|
|
7
|
+
@include shadow-sm;
|
|
8
|
+
min-width: calc(var(--base) * 10);
|
|
9
|
+
max-width: fit-content;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
background-color: var(--theme-input-bg);
|
|
13
|
+
border-radius: $style-radius-s;
|
|
14
|
+
border: 1px solid var(--theme-elevation-100);
|
|
15
|
+
position: relative;
|
|
16
|
+
font-family: var(--font-body);
|
|
17
|
+
margin-block: base(0.5);
|
|
18
|
+
max-height: calc(var(--base) * 3);
|
|
19
|
+
padding: base(0.6);
|
|
20
|
+
|
|
21
|
+
&[data-match-type='create'] {
|
|
22
|
+
border-color: var(--diff-create-pill-border);
|
|
23
|
+
color: var(--diff-create-parent-color);
|
|
24
|
+
|
|
25
|
+
* {
|
|
26
|
+
color: var(--diff-create-parent-color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.lexical-upload-diff__meta {
|
|
30
|
+
color: var(--diff-create-link-color);
|
|
31
|
+
* {
|
|
32
|
+
color: var(--diff-create-link-color);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.lexical-upload-diff__thumbnail {
|
|
37
|
+
border-radius: 0px;
|
|
38
|
+
border-color: var(--diff-create-pill-border);
|
|
39
|
+
background-color: none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&[data-match-type='delete'] {
|
|
44
|
+
border-color: var(--diff-delete-pill-border);
|
|
45
|
+
text-decoration-line: none;
|
|
46
|
+
color: var(--diff-delete-parent-color);
|
|
47
|
+
background-color: var(--diff-delete-pill-bg);
|
|
48
|
+
|
|
49
|
+
.lexical-upload-diff__meta {
|
|
50
|
+
color: var(--diff-delete-link-color);
|
|
51
|
+
* {
|
|
52
|
+
color: var(--diff-delete-link-color);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
* {
|
|
57
|
+
text-decoration-line: none;
|
|
58
|
+
color: var(--diff-delete-parent-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.lexical-upload-diff__thumbnail {
|
|
62
|
+
border-radius: 0px;
|
|
63
|
+
border-color: var(--diff-delete-pill-border);
|
|
64
|
+
background-color: none;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&__card {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: row;
|
|
71
|
+
align-items: center;
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&__thumbnail {
|
|
76
|
+
width: calc(var(--base) * 3 - base(0.6) * 2);
|
|
77
|
+
height: calc(var(--base) * 3 - base(0.6) * 2);
|
|
78
|
+
position: relative;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
flex-shrink: 0;
|
|
81
|
+
border-radius: 0px;
|
|
82
|
+
border: 1px solid var(--theme-elevation-100);
|
|
83
|
+
|
|
84
|
+
img,
|
|
85
|
+
svg {
|
|
86
|
+
position: absolute;
|
|
87
|
+
object-fit: cover;
|
|
88
|
+
width: 100%;
|
|
89
|
+
height: 100%;
|
|
90
|
+
border-radius: 0px;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&__info {
|
|
95
|
+
flex-grow: 1;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: flex-start;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
padding: calc(var(--base) * 0.25) calc(var(--base) * 0.75);
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
font-weight: 400;
|
|
102
|
+
|
|
103
|
+
strong {
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&__meta {
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
text-overflow: ellipsis;
|
|
111
|
+
white-space: nowrap;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
package/dist/field/Diff/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc';
|
|
3
|
+
import './index.scss';
|
|
3
4
|
import '../bundled.css';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js';
|
|
@@ -51,7 +52,7 @@ export const LexicalDiffComponent = async (args)=>{
|
|
|
51
52
|
fromHTML: fromHTML?.length ? fromHTML : '<p></p>',
|
|
52
53
|
toHTML: toHTML?.length ? toHTML : '<p></p>'
|
|
53
54
|
});
|
|
54
|
-
return /*#__PURE__*/
|
|
55
|
+
return /*#__PURE__*/ _jsxDEV(FieldDiffContainer, {
|
|
55
56
|
className: baseClass,
|
|
56
57
|
From: From,
|
|
57
58
|
i18n: i18n,
|
|
@@ -61,7 +62,11 @@ export const LexicalDiffComponent = async (args)=>{
|
|
|
61
62
|
},
|
|
62
63
|
nestingLevel: nestingLevel,
|
|
63
64
|
To: To
|
|
64
|
-
}
|
|
65
|
+
}, void 0, false, {
|
|
66
|
+
fileName: "src/field/Diff/index.tsx",
|
|
67
|
+
lineNumber: 69,
|
|
68
|
+
columnNumber: 5
|
|
69
|
+
}, this);
|
|
65
70
|
};
|
|
66
71
|
|
|
67
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\nimport '../bundled.css'\n\nimport React from 'react'\n\nimport type { HTMLConvertersFunctionAsync } from '../../features/converters/lexicalToHtml/async/types.js'\n\nimport { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js'\nimport { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js'\nimport { LinkDiffHTMLConverterAsync } from './converters/link.js'\nimport { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js'\nimport { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js'\nimport { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js'\nimport { UploadDiffHTMLConverterAsync } from './converters/upload/index.js'\n\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const {\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n req,\n versionValue: valueTo,\n } = args\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({}),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n, req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n, req }),\n ...UnknownDiffHTMLConverterAsync({ i18n, req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req,\n })\n const fromHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueFrom as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const toHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueTo as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const { From, To } = getHTMLDiffComponents({\n // Ensure empty paragraph is displayed for empty rich text fields - otherwise, toHTML may be displayed in the wrong column\n fromHTML: fromHTML?.length ? fromHTML : '<p></p>',\n toHTML: toHTML?.length ? toHTML : '<p></p>',\n })\n\n return (\n <FieldDiffContainer\n className={baseClass}\n From={From}\n i18n={i18n}\n label={{\n label: field.label,\n locale,\n }}\n nestingLevel={nestingLevel}\n To={To}\n />\n )\n}\n"],"names":["FieldDiffContainer","getHTMLDiffComponents","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","baseClass","LexicalDiffComponent","args","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","req","versionValue","valueTo","converters","defaultConverters","payloadPopulateFn","currentDepth","depth","fromHTML","data","disableContainer","populate","toHTML","From","To","length","className","label"],"mappings":";AAGA,SAASA,kBAAkB,EAAEC,qBAAqB,QAAQ,qBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\nimport '../bundled.css'\n\nimport React from 'react'\n\nimport type { HTMLConvertersFunctionAsync } from '../../features/converters/lexicalToHtml/async/types.js'\n\nimport { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js'\nimport { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js'\nimport { LinkDiffHTMLConverterAsync } from './converters/link.js'\nimport { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js'\nimport { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js'\nimport { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js'\nimport { UploadDiffHTMLConverterAsync } from './converters/upload/index.js'\n\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const {\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n req,\n versionValue: valueTo,\n } = args\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({}),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n, req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n, req }),\n ...UnknownDiffHTMLConverterAsync({ i18n, req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req,\n })\n const fromHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueFrom as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const toHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueTo as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const { From, To } = getHTMLDiffComponents({\n // Ensure empty paragraph is displayed for empty rich text fields - otherwise, toHTML may be displayed in the wrong column\n fromHTML: fromHTML?.length ? fromHTML : '<p></p>',\n toHTML: toHTML?.length ? toHTML : '<p></p>',\n })\n\n return (\n <FieldDiffContainer\n className={baseClass}\n From={From}\n i18n={i18n}\n label={{\n label: field.label,\n locale,\n }}\n nestingLevel={nestingLevel}\n To={To}\n />\n )\n}\n"],"names":["FieldDiffContainer","getHTMLDiffComponents","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","baseClass","LexicalDiffComponent","args","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","req","versionValue","valueTo","converters","defaultConverters","payloadPopulateFn","currentDepth","depth","fromHTML","data","disableContainer","populate","toHTML","From","To","length","className","label"],"mappings":";AAGA,SAASA,kBAAkB,EAAEC,qBAAqB,QAAQ,qBAAoB;AAE9E,OAAO,eAAc;AACrB,OAAO,iBAAgB;AAEvB,OAAOC,WAAW,QAAO;AAIzB,SAASC,yBAAyB,QAAQ,yDAAwD;AAClG,SAASC,oBA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F;QACAC,cAAcA;QACde,IAAIA;;;;;;AAGV,EAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.lexical-diff .field-diff-content {
|
|
5
|
+
.html-diff {
|
|
6
|
+
font-family: var(--font-serif);
|
|
7
|
+
font-size: base(0.8);
|
|
8
|
+
letter-spacing: 0.02em;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
blockquote {
|
|
12
|
+
font-size: base(0.8);
|
|
13
|
+
margin-block: base(0.8);
|
|
14
|
+
margin-inline: 0;
|
|
15
|
+
padding-inline-start: base(0.6);
|
|
16
|
+
padding-block: base(0.2);
|
|
17
|
+
position: relative; // Required for absolute positioning of ::after
|
|
18
|
+
|
|
19
|
+
&::after {
|
|
20
|
+
content: '';
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 0;
|
|
23
|
+
bottom: 0;
|
|
24
|
+
inset-inline-start: 0;
|
|
25
|
+
width: base(0.2);
|
|
26
|
+
background-color: var(--theme-elevation-150);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:has([data-match-type='create'])::after {
|
|
30
|
+
background-color: var(--theme-success-150);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:has([data-match-type='delete'])::after {
|
|
34
|
+
background-color: var(--theme-error-150);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
border-bottom: 1px dotted;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
h1 {
|
|
44
|
+
padding: base(0.7) 0px base(0.55);
|
|
45
|
+
line-height: base(1.5);
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
font-size: base(1.4);
|
|
48
|
+
font-family: var(--font-body);
|
|
49
|
+
}
|
|
50
|
+
h2 {
|
|
51
|
+
padding: base(0.7) 0px base(0.5);
|
|
52
|
+
line-height: base(1.4);
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
font-size: base(1.25);
|
|
55
|
+
font-family: var(--font-body);
|
|
56
|
+
}
|
|
57
|
+
h3 {
|
|
58
|
+
padding: base(0.6) 0px base(0.45);
|
|
59
|
+
line-height: base(1.4);
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
font-size: base(1.1);
|
|
62
|
+
font-family: var(--font-body);
|
|
63
|
+
}
|
|
64
|
+
h4 {
|
|
65
|
+
padding: base(0.4) 0px base(0.35);
|
|
66
|
+
line-height: base(1.5);
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
font-size: base(1.05);
|
|
69
|
+
font-family: var(--font-body);
|
|
70
|
+
}
|
|
71
|
+
h5 {
|
|
72
|
+
padding: base(0.3) 0px base(0.3);
|
|
73
|
+
line-height: base(1.4);
|
|
74
|
+
font-weight: 600;
|
|
75
|
+
font-size: base(0.9);
|
|
76
|
+
font-family: var(--font-body);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
h6 {
|
|
80
|
+
padding: base(0.55) 0px base(0.25);
|
|
81
|
+
line-height: base(0.5);
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
font-size: base(0.75);
|
|
84
|
+
font-family: var(--font-body);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
p {
|
|
88
|
+
padding: base(0.4) 0 base(0.4);
|
|
89
|
+
|
|
90
|
+
// First paraagraph has no top padding
|
|
91
|
+
&:first-child {
|
|
92
|
+
padding: 0 0 base(0.4);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ul,
|
|
97
|
+
ol {
|
|
98
|
+
padding-top: base(0.4);
|
|
99
|
+
padding-bottom: base(0.4);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
package/dist/field/Field.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { BulkUploadProvider, FieldDescription, FieldError, FieldLabel, RenderCustomComponent, useEditDepth, useEffectEvent, useField } from '@payloadcms/ui';
|
|
4
4
|
import { mergeFieldStyles } from '@payloadcms/ui/shared';
|
|
5
5
|
import { dequal } from 'dequal/lite';
|
|
6
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
|
+
import '../lexical/theme/EditorTheme.scss';
|
|
8
9
|
import './bundled.css';
|
|
10
|
+
import './index.scss';
|
|
9
11
|
import { LexicalProvider } from '../lexical/LexicalProvider.js';
|
|
10
12
|
import { useRunDeprioritized } from '../utilities/useRunDeprioritized.js';
|
|
11
13
|
const baseClass = 'rich-text-lexical';
|
|
@@ -107,35 +109,47 @@ const RichTextComponent = // With rendered features n stuff
|
|
|
107
109
|
}, [
|
|
108
110
|
initialValue
|
|
109
111
|
]);
|
|
110
|
-
return /*#__PURE__*/
|
|
112
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
111
113
|
className: classes,
|
|
112
114
|
style: styles,
|
|
113
115
|
children: [
|
|
114
|
-
/*#__PURE__*/
|
|
116
|
+
/*#__PURE__*/ _jsxDEV(RenderCustomComponent, {
|
|
115
117
|
CustomComponent: Error,
|
|
116
|
-
Fallback: /*#__PURE__*/
|
|
118
|
+
Fallback: /*#__PURE__*/ _jsxDEV(FieldError, {
|
|
117
119
|
path: path,
|
|
118
120
|
showError: showError
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
}, void 0, false, {
|
|
122
|
+
fileName: "src/field/Field.tsx",
|
|
123
|
+
lineNumber: 179,
|
|
124
|
+
columnNumber: 19
|
|
125
|
+
}, void 0)
|
|
126
|
+
}, void 0, false, {
|
|
127
|
+
fileName: "src/field/Field.tsx",
|
|
128
|
+
lineNumber: 177,
|
|
129
|
+
columnNumber: 7
|
|
130
|
+
}, this),
|
|
131
|
+
Label || /*#__PURE__*/ _jsxDEV(FieldLabel, {
|
|
122
132
|
label: label,
|
|
123
133
|
localized: localized,
|
|
124
134
|
path: path,
|
|
125
135
|
required: required
|
|
126
|
-
}
|
|
127
|
-
|
|
136
|
+
}, void 0, false, {
|
|
137
|
+
fileName: "src/field/Field.tsx",
|
|
138
|
+
lineNumber: 181,
|
|
139
|
+
columnNumber: 17
|
|
140
|
+
}, this),
|
|
141
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
128
142
|
className: `${baseClass}__wrap`,
|
|
129
143
|
children: [
|
|
130
|
-
/*#__PURE__*/
|
|
144
|
+
/*#__PURE__*/ _jsxDEV(ErrorBoundary, {
|
|
131
145
|
fallbackRender: fallbackRender,
|
|
132
146
|
onReset: ()=>{},
|
|
133
147
|
children: [
|
|
134
148
|
BeforeInput,
|
|
135
149
|
/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer
|
|
136
|
-
is rendered in the correct depth (not displayed *behind* the current drawer)*/ /*#__PURE__*/
|
|
150
|
+
is rendered in the correct depth (not displayed *behind* the current drawer)*/ /*#__PURE__*/ _jsxDEV(BulkUploadProvider, {
|
|
137
151
|
drawerSlugPrefix: path,
|
|
138
|
-
children: /*#__PURE__*/
|
|
152
|
+
children: /*#__PURE__*/ _jsxDEV(LexicalProvider, {
|
|
139
153
|
composerKey: pathWithEditDepth,
|
|
140
154
|
editorConfig: editorConfig,
|
|
141
155
|
fieldProps: props,
|
|
@@ -147,40 +161,80 @@ const RichTextComponent = // With rendered features n stuff
|
|
|
147
161
|
}, JSON.stringify({
|
|
148
162
|
path,
|
|
149
163
|
rerenderProviderKey
|
|
150
|
-
})
|
|
151
|
-
|
|
164
|
+
}), false, {
|
|
165
|
+
fileName: "src/field/Field.tsx",
|
|
166
|
+
lineNumber: 188,
|
|
167
|
+
columnNumber: 13
|
|
168
|
+
}, this)
|
|
169
|
+
}, void 0, false, {
|
|
170
|
+
fileName: "src/field/Field.tsx",
|
|
171
|
+
lineNumber: 187,
|
|
172
|
+
columnNumber: 11
|
|
173
|
+
}, this),
|
|
152
174
|
AfterInput
|
|
153
175
|
]
|
|
154
|
-
}
|
|
155
|
-
|
|
176
|
+
}, void 0, true, {
|
|
177
|
+
fileName: "src/field/Field.tsx",
|
|
178
|
+
lineNumber: 183,
|
|
179
|
+
columnNumber: 9
|
|
180
|
+
}, this),
|
|
181
|
+
/*#__PURE__*/ _jsxDEV(RenderCustomComponent, {
|
|
156
182
|
CustomComponent: Description,
|
|
157
|
-
Fallback: /*#__PURE__*/
|
|
183
|
+
Fallback: /*#__PURE__*/ _jsxDEV(FieldDescription, {
|
|
158
184
|
description: description,
|
|
159
185
|
path: path
|
|
160
|
-
}
|
|
161
|
-
|
|
186
|
+
}, void 0, false, {
|
|
187
|
+
fileName: "src/field/Field.tsx",
|
|
188
|
+
lineNumber: 203,
|
|
189
|
+
columnNumber: 21
|
|
190
|
+
}, void 0)
|
|
191
|
+
}, void 0, false, {
|
|
192
|
+
fileName: "src/field/Field.tsx",
|
|
193
|
+
lineNumber: 201,
|
|
194
|
+
columnNumber: 9
|
|
195
|
+
}, this)
|
|
162
196
|
]
|
|
163
|
-
}
|
|
197
|
+
}, void 0, true, {
|
|
198
|
+
fileName: "src/field/Field.tsx",
|
|
199
|
+
lineNumber: 182,
|
|
200
|
+
columnNumber: 7
|
|
201
|
+
}, this)
|
|
164
202
|
]
|
|
165
|
-
}, pathWithEditDepth
|
|
203
|
+
}, pathWithEditDepth, true, {
|
|
204
|
+
fileName: "src/field/Field.tsx",
|
|
205
|
+
lineNumber: 176,
|
|
206
|
+
columnNumber: 5
|
|
207
|
+
}, this);
|
|
166
208
|
};
|
|
167
209
|
function fallbackRender({ error }) {
|
|
168
210
|
// Call resetErrorBoundary() to reset the error boundary and retry the render.
|
|
169
|
-
return /*#__PURE__*/
|
|
211
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
170
212
|
className: "errorBoundary",
|
|
171
213
|
role: "alert",
|
|
172
214
|
children: [
|
|
173
|
-
/*#__PURE__*/
|
|
215
|
+
/*#__PURE__*/ _jsxDEV("p", {
|
|
174
216
|
children: "Something went wrong:"
|
|
175
|
-
}
|
|
176
|
-
|
|
217
|
+
}, void 0, false, {
|
|
218
|
+
fileName: "src/field/Field.tsx",
|
|
219
|
+
lineNumber: 215,
|
|
220
|
+
columnNumber: 7
|
|
221
|
+
}, this),
|
|
222
|
+
/*#__PURE__*/ _jsxDEV("pre", {
|
|
177
223
|
style: {
|
|
178
224
|
color: 'red'
|
|
179
225
|
},
|
|
180
226
|
children: error.message
|
|
181
|
-
}
|
|
227
|
+
}, void 0, false, {
|
|
228
|
+
fileName: "src/field/Field.tsx",
|
|
229
|
+
lineNumber: 216,
|
|
230
|
+
columnNumber: 7
|
|
231
|
+
}, this)
|
|
182
232
|
]
|
|
183
|
-
}
|
|
233
|
+
}, void 0, true, {
|
|
234
|
+
fileName: "src/field/Field.tsx",
|
|
235
|
+
lineNumber: 214,
|
|
236
|
+
columnNumber: 5
|
|
237
|
+
}, this);
|
|
184
238
|
}
|
|
185
239
|
export const RichText = RichTextComponent;
|
|
186
240
|
|
package/dist/field/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n BulkUploadProvider,\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(\n prevValueRef.current != null\n ? JSON.parse(JSON.stringify(prevValueRef.current))\n : prevValueRef.current,\n value,\n )\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n {/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer\n is rendered in the correct depth (not displayed *behind* the current drawer)*/}\n <BulkUploadProvider drawerSlugPrefix={path}>\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n </BulkUploadProvider>\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"names":["BulkUploadProvider","FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","div","style","CustomComponent","Fallback","fallbackRender","onReset","drawerSlugPrefix","composerKey","fieldProps","onChange","error","role","p","pre","color","message","RichText"],"mappings":"AAAA;;AAGA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH,iBAAgB;AACvB,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,MAAM,QAAQ,cAAa;AAEpC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,SAASC,aAAa,QAAQ,uBAAsB;AAKpD,OAAO,gBAAe;AAKtB,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,mBAAmB,QAAQ,sCAAqC;AAEzE,MAAMC,YAAY;AAElB,MAAMC,oBAEiD,iCAAiC;AAEpF,CAACC;IACH,MAAM,EACJC,YAAY,EACZC,KAAK,EACLA,OAAO,EACLC,OAAO,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAUC,iBAAiB,EAAE,GAAG,CAAC,CAAC,EACnEC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACT,EACDC,MAAMC,aAAa,EACnBN,UAAUO,yBAAyB,EACnCC,QAAQ,EACT,GADW,0FAA0F;IAClGd;IAEJ,MAAMe,oBAAoBF,6BAA6BN;IAEvD,MAAMS,YAAY/B;IAElB,MAAMgC,mBAAmB1B,YACvB,CAAC2B,OAAOC;QACN,IAAI,OAAOL,aAAa,YAAY;YAClC,oFAAoF;YACpF,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AAgBA;wBAAgBC,SAAS,KAAO;;4BAC5DlD;4BACA;sFAC2E,iBAC5E,KAAC1C;gCAAmB6F,kBAAkB9D;0CACpC,cAAA,KAACf;oCACC8E,aAAavB;oCACblD,cAAcA;oCACd0E,YAAY3E;oCACZgC,sBAAsBA;oCAC8B,0QAA0Q;oCAC9T4C,UAAUvB;oCACV/C,UAAUoB;oCACVR,OAAOA;mCAHF2C,KAAKE,SAAS,CAAC;oCAAEpD;oCAAMuB;gCAAoB;;4BAMnDb;;;kCAEH,KAACrC;wBACCqF,iBAAiB9C;wBACjB+C,wBAAU,KAACzF;4BAAiBwB,aAAaA;4BAAaM,MAAMA;;;;;;OA3BpCwC;AAgClC;AAEA,SAASoB,eAAe,EAAEM,KAAK,EAAoB;IACjD,8EAA8E;IAE9E,qBACE,MAACV;QAAI/D,WAAU;QAAgB0E,MAAK;;0BAClC,KAACC;0BAAE;;0BACH,KAACC;gBAAIZ,OAAO;oBAAEa,OAAO;gBAAM;0BAAIJ,MAAMK,OAAO;;;;AAGlD;AAEA,OAAO,MAAMC,WAAqCpF,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n BulkUploadProvider,\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(\n prevValueRef.current != null\n ? JSON.parse(JSON.stringify(prevValueRef.current))\n : prevValueRef.current,\n value,\n )\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n {/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer\n is rendered in the correct depth (not displayed *behind* the current drawer)*/}\n <BulkUploadProvider drawerSlugPrefix={path}>\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n </BulkUploadProvider>\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"names":["BulkUploadProvider","FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","div","style","CustomComponent","Fallback","fallbackRender","onReset","drawerSlugPrefix","composerKey","fieldProps","onChange","error","role","p","pre","color","message","RichText"],"mappings":"AAAA;;AAGA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH,iBAAgB;AACvB,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,MAAM,QAAQ,cAAa;AAEpC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,SAASC,aAAa,QAAQ,uBAAsB;AAIpD,OAAO,oCAAmC;AAC1C,OAAO,gBAAe;AACtB,OAAO,eAAc;AAIrB,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,mBAAmB,QAAQ,sCAAqC;AAEzE,MAAMC,YAAY;AAElB,MAAMC,oBAEiD,iCAAiC;AAEpF,CAACC;IACH,MAAM,EACJC,YAAY,EACZC,KAAK,EACLA,OAAO,EACLC,OAAO,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAUC,iBAAiB,EAAE,GAAG,CAAC,CAAC,EACnEC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACT,EACDC,MAAMC,aAAa,EACnBN,UAAUO,yBAAyB,EACnCC,QAAQ,EACT,GADW,0FAA0F;IAClGd;IAEJ,MAAMe,oBAAoBF,6BAA6BN;IAEvD,MAAMS,YAAY/B;IAElB,MAAMgC,mBAAmB1B,YACvB,CAAC2B,OAAOC;QACN,IAAI,OAAOL,aAAa,YAAY;YAClC,oFAAoF;YACpF,OAAOA,SAASI,O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AAgBA;wBAAgBC,SAAS,KAAO;;4BAC5DlD;4BACA;sFAC2E,iBAC5E,QAAC1C;gCAAmB6F,kBAAkB9D;0CACpC,cAAA,QAACf;oCACC8E,aAAavB;oCACblD,cAAcA;oCACd0E,YAAY3E;oCACZgC,sBAAsBA;oCAC8B,0QAA0Q;oCAC9T4C,UAAUvB;oCACV/C,UAAUoB;oCACVR,OAAOA;mCAHF2C,KAAKE,SAAS,CAAC;oCAAEpD;oCAAMuB;gCAAoB;;;;;;;;;;4BAMnDb;;;;;;;kCAEH,QAACrC;wBACCqF,iBAAiB9C;wBACjB+C,wBAAU,QAACzF;4BAAiBwB,aAAaA;4BAAaM,MAAMA;;;;;;;;;;;;;;;;;;OA3BpCwC;;;;;AAgClC;AAEA,SAASoB,eAAe,EAAEM,KAAK,EAAoB;IACjD,8EAA8E;IAE9E,qBACE,QAACV;QAAI/D,WAAU;QAAgB0E,MAAK;;0BAClC,QAACC;0BAAE;;;;;;0BACH,QAACC;gBAAIZ,OAAO;oBAAEa,OAAO;gBAAM;0BAAIJ,MAAMK,OAAO;;;;;;;;;;;;AAGlD;AAEA,OAAO,MAAMC,WAAqCpF,kBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { FieldContext, FieldPathContext, ServerFunctionsContext, ShimmerEffect, useServerFunctions } from '@payloadcms/ui';
|
|
4
4
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
5
5
|
/**
|
|
@@ -56,7 +56,11 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
56
56
|
renderLexical
|
|
57
57
|
]);
|
|
58
58
|
if (!Component) {
|
|
59
|
-
return typeof Loading !== 'undefined' ? Loading : /*#__PURE__*/
|
|
59
|
+
return typeof Loading !== 'undefined' ? Loading : /*#__PURE__*/ _jsxDEV(ShimmerEffect, {}, void 0, false, {
|
|
60
|
+
fileName: "src/field/RenderLexical/index.tsx",
|
|
61
|
+
lineNumber: 82,
|
|
62
|
+
columnNumber: 55
|
|
63
|
+
}, this);
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
62
66
|
* By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments
|
|
@@ -73,15 +77,23 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
79
|
if (typeof value === 'undefined' && !setValue) {
|
|
76
|
-
return /*#__PURE__*/
|
|
80
|
+
return /*#__PURE__*/ _jsxDEV(ServerFunctionsContext, {
|
|
77
81
|
value: {
|
|
78
82
|
...adjustedServerFunctionContext
|
|
79
83
|
},
|
|
80
|
-
children: /*#__PURE__*/
|
|
84
|
+
children: /*#__PURE__*/ _jsxDEV(FieldPathContext, {
|
|
81
85
|
value: fieldPath,
|
|
82
86
|
children: Component
|
|
83
|
-
}, fieldPath
|
|
84
|
-
|
|
87
|
+
}, fieldPath, false, {
|
|
88
|
+
fileName: "src/field/RenderLexical/index.tsx",
|
|
89
|
+
lineNumber: 104,
|
|
90
|
+
columnNumber: 9
|
|
91
|
+
}, this)
|
|
92
|
+
}, void 0, false, {
|
|
93
|
+
fileName: "src/field/RenderLexical/index.tsx",
|
|
94
|
+
lineNumber: 103,
|
|
95
|
+
columnNumber: 7
|
|
96
|
+
}, this);
|
|
85
97
|
}
|
|
86
98
|
const fieldValue = {
|
|
87
99
|
disabled: false,
|
|
@@ -94,18 +106,30 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
94
106
|
showError: false,
|
|
95
107
|
value
|
|
96
108
|
};
|
|
97
|
-
return /*#__PURE__*/
|
|
109
|
+
return /*#__PURE__*/ _jsxDEV(ServerFunctionsContext, {
|
|
98
110
|
value: {
|
|
99
111
|
...adjustedServerFunctionContext
|
|
100
112
|
},
|
|
101
|
-
children: /*#__PURE__*/
|
|
113
|
+
children: /*#__PURE__*/ _jsxDEV(FieldPathContext, {
|
|
102
114
|
value: fieldPath,
|
|
103
|
-
children: /*#__PURE__*/
|
|
115
|
+
children: /*#__PURE__*/ _jsxDEV(FieldContext, {
|
|
104
116
|
value: fieldValue,
|
|
105
117
|
children: Component
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
}, void 0, false, {
|
|
119
|
+
fileName: "src/field/RenderLexical/index.tsx",
|
|
120
|
+
lineNumber: 126,
|
|
121
|
+
columnNumber: 9
|
|
122
|
+
}, this)
|
|
123
|
+
}, fieldPath, false, {
|
|
124
|
+
fileName: "src/field/RenderLexical/index.tsx",
|
|
125
|
+
lineNumber: 125,
|
|
126
|
+
columnNumber: 7
|
|
127
|
+
}, this)
|
|
128
|
+
}, void 0, false, {
|
|
129
|
+
fileName: "src/field/RenderLexical/index.tsx",
|
|
130
|
+
lineNumber: 124,
|
|
131
|
+
columnNumber: 5
|
|
132
|
+
}, this);
|
|
109
133
|
};
|
|
110
134
|
|
|
111
135
|
//# sourceMappingURL=index.js.map
|
|
@@ -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","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,
|
|
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,YA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