@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,29 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
.code-block-floating-collapse-button {
|
|
4
|
+
all: unset;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
gap: base(0.5);
|
|
12
|
+
|
|
13
|
+
position: absolute;
|
|
14
|
+
left: 50%;
|
|
15
|
+
transform: translateX(-50%);
|
|
16
|
+
height: 24px;
|
|
17
|
+
bottom: -12px;
|
|
18
|
+
|
|
19
|
+
padding: base(0.2) base(0.4);
|
|
20
|
+
border-radius: $style-radius-s;
|
|
21
|
+
|
|
22
|
+
background: var(--theme-elevation-150);
|
|
23
|
+
color: var(--theme-elevation-600);
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
background: var(--theme-elevation-200);
|
|
27
|
+
color: var(--theme-elevation-800);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
.payload-richtext-code-block.collapsible--collapsed {
|
|
4
|
+
.rah-static {
|
|
5
|
+
height: unset !important;
|
|
6
|
+
max-height: 150px !important;
|
|
7
|
+
position: relative;
|
|
8
|
+
|
|
9
|
+
&::after {
|
|
10
|
+
content: '';
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
background: linear-gradient(
|
|
13
|
+
to bottom,
|
|
14
|
+
rgb(0 0 0 / 0%) 0%,
|
|
15
|
+
var(--theme-elevation-50) 90%,
|
|
16
|
+
var(--theme-elevation-50) 100%
|
|
17
|
+
);
|
|
18
|
+
position: absolute;
|
|
19
|
+
height: 100px;
|
|
20
|
+
top: 50px;
|
|
21
|
+
left: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
> div {
|
|
26
|
+
display: unset !important;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.payload-richtext-code-block {
|
|
32
|
+
&__pill {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
margin-right: base(0.4);
|
|
37
|
+
margin-left: base(0.4);
|
|
38
|
+
color: var(--theme-elevation-500);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.collapsible__header-wrap {
|
|
42
|
+
overflow: visible;
|
|
43
|
+
}
|
|
44
|
+
.collapsible__content {
|
|
45
|
+
padding: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.LexicalEditorTheme__block {
|
|
49
|
+
&__block-header {
|
|
50
|
+
overflow: visible;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.code-editor,
|
|
55
|
+
.monaco-editor,
|
|
56
|
+
.overflow-guard {
|
|
57
|
+
border-width: 0;
|
|
58
|
+
border-radius: 0 0 $style-radius-s $style-radius-s;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__actions {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: row;
|
|
64
|
+
gap: calc(var(--base) * 0.4);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.popup-button {
|
|
68
|
+
padding: 0 0 0 calc(var(--base) * 0.2);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.copy-to-clipboard,
|
|
72
|
+
.code-block-collapse-button,
|
|
73
|
+
.popup-button {
|
|
74
|
+
border-radius: $style-radius-s;
|
|
75
|
+
color: var(--theme-elevation-500);
|
|
76
|
+
min-width: 24px;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
color: var(--theme-elevation-800);
|
|
83
|
+
background-color: var(--theme-elevation-200);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&__language-selector {
|
|
88
|
+
pointer-events: all;
|
|
89
|
+
|
|
90
|
+
&-button {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: row;
|
|
93
|
+
width: max-content;
|
|
94
|
+
align-items: center;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/blocks/server/markdown/markdownTransformer.ts"],"sourcesContent":["import type { ElementNode, SerializedLexicalNode } from 'lexical'\nimport type { Block } from 'payload'\n\nimport { $parseSerializedNode } from 'lexical'\n\nimport type { NodeWithHooks } from '../../../typesServer.js'\n\nimport { getEnabledNodesFromServerNodes } from '../../../../lexical/nodes/index.js'\nimport {\n type MultilineElementTransformer,\n type TextMatchTransformer,\n type Transformer,\n} from '../../../../packages/@lexical/markdown/index.js'\nimport { extractPropsFromJSXPropsString } from '../../../../utilities/jsx/extractPropsFromJSXPropsString.js'\nimport { propsToJSXString } from '../../../../utilities/jsx/jsx.js'\nimport { getLexicalToMarkdown } from '../../client/markdown/getLexicalToMarkdown.js'\nimport { getMarkdownToLexical } from '../../client/markdown/getMarkdownToLexical.js'\nimport { $createServerBlockNode, $isServerBlockNode, ServerBlockNode } from '../nodes/BlocksNode.js'\nimport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n ServerInlineBlockNode,\n} from '../nodes/InlineBlocksNode.js'\nimport { linesFromStartToContentAndPropsString } from './linesFromMatchToContentAndPropsString.js'\n\nexport function createTagRegexes(tagName: string) {\n const escapedTagName = tagName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n // Regex components\n const openingTag = `<${escapedTagName}`\n const closingTag = `</${escapedTagName}`\n const optionalWhitespace = `\\\\s*`\n const mandatoryClosingBracket = `>`\n\n // Assembled regex patterns\n const startPattern = `${openingTag}(?=\\\\s|>|$)` // Only match the tag name\n const endPattern = `${closingTag}${optionalWhitespace}${mandatoryClosingBracket}`\n\n return {\n regExpEnd: new RegExp(endPattern, 'i'),\n regExpStart: new RegExp(startPattern, 'i'),\n }\n}\nexport const getBlockMarkdownTransformers = ({\n blocks,\n inlineBlocks,\n}: {\n blocks: Block[]\n inlineBlocks: Block[]\n}): ((props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n}) => MultilineElementTransformer | TextMatchTransformer)[] => {\n if (!blocks?.length && !inlineBlocks?.length) {\n return []\n }\n\n let transformers: ((props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer)[] = []\n\n if (blocks?.length) {\n for (const block of blocks) {\n const transformer = getMarkdownTransformerForBlock(block, false)\n\n if (transformer) {\n transformers = transformers.concat(transformer)\n }\n }\n }\n\n if (inlineBlocks?.length) {\n for (const block of inlineBlocks) {\n const transformer = getMarkdownTransformerForBlock(block, true)\n\n if (transformer) {\n transformers = transformers.concat(transformer)\n }\n }\n }\n\n return transformers\n}\n\nfunction getMarkdownTransformerForBlock(\n block: Block,\n isInlineBlock: boolean,\n): Array<\n (props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer\n> | null {\n if (!block.jsx) {\n return null\n }\n\n const regex = createTagRegexes(block.slug)\n const toReturn: Array<\n (props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer\n > = []\n\n if (isInlineBlock) {\n toReturn.push(({ allNodes, allTransformers }) => ({\n type: 'text-match',\n dependencies: [ServerInlineBlockNode],\n export: (node) => {\n if (!$isServerInlineBlockNode(node)) {\n return null\n }\n\n if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {\n return null\n }\n\n const nodeFields = node.getFields()\n const lexicalToMarkdown = getLexicalToMarkdown(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const exportResult = block.jsx!.export({\n fields: nodeFields,\n lexicalToMarkdown,\n })\n if (exportResult === false) {\n return null\n }\n if (typeof exportResult === 'string') {\n return exportResult\n }\n\n const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0\n const props = exportResult.props ?? {}\n\n if (exportResult?.children?.length) {\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}>${exportResult.children}</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}/>`\n },\n getEndIndex: (node, match) => {\n const { endlineLastCharIndex } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines: [node.getTextContent()],\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: 0,\n startMatch: match,\n trimChildren: false,\n })\n\n return endlineLastCharIndex\n },\n importRegExp: block.jsx?.customStartRegex ?? regex.regExpStart,\n regExp: /___ignoreignoreignore___/g,\n replace(node, match) {\n const { content, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines: [node.getTextContent()],\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: 0,\n startMatch: {\n ...match,\n index: 0,\n },\n trimChildren: false,\n })\n\n if (!block?.jsx?.import) {\n // No multiline transformer handled this line successfully\n return\n }\n\n const markdownToLexical = getMarkdownToLexical(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const blockFields = block.jsx.import({\n children: content,\n closeMatch: null,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: match,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return\n }\n\n const inlineBlockNode = $createServerInlineBlockNode({\n blockType: block.slug,\n ...(blockFields as any),\n })\n\n node.replace(inlineBlockNode)\n },\n }))\n\n return toReturn\n }\n\n toReturn.push(({ allNodes, allTransformers }) => ({\n dependencies: [ServerBlockNode],\n export: (node) => {\n if (!$isServerBlockNode(node)) {\n return null\n }\n\n if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {\n return null\n }\n\n const nodeFields = node.getFields()\n const lexicalToMarkdown = getLexicalToMarkdown(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const exportResult = block.jsx!.export({\n fields: nodeFields,\n lexicalToMarkdown,\n })\n if (exportResult === false) {\n return null\n }\n if (typeof exportResult === 'string') {\n return exportResult\n }\n\n const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0\n const props = exportResult.props ?? {}\n\n if (exportResult?.children?.length) {\n const children = exportResult.children\n let sanitizedChildren = ''\n\n // Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child\n if (children.includes('\\n')) {\n for (const child of children.split('\\n')) {\n let sanitizedChild = ''\n if (!block?.jsx?.doNotTrimChildren && child !== '') {\n sanitizedChild = ' '\n }\n sanitizedChild += child + '\\n'\n\n sanitizedChildren += sanitizedChild\n }\n } else {\n sanitizedChildren = (block?.jsx?.doNotTrimChildren ? '' : ' ') + children + '\\n'\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}>\\n${sanitizedChildren}</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}/>`\n },\n handleImportAfterStartMatch: block.jsx?.customEndRegex\n ? undefined\n : ({ lines, rootNode, startLineIndex, startMatch, transformer }) => {\n const regexpEndRegex: RegExp | undefined =\n typeof transformer.regExpEnd === 'object' && 'regExp' in transformer.regExpEnd\n ? transformer.regExpEnd.regExp\n : transformer.regExpEnd\n\n const isEndOptional =\n transformer.regExpEnd &&\n typeof transformer.regExpEnd === 'object' &&\n 'optional' in transformer.regExpEnd\n ? transformer.regExpEnd.optional\n : !transformer.regExpEnd\n\n const {\n afterEndLine,\n beforeStartLine,\n content: unsanitizedContent,\n endLineIndex,\n propsString,\n } = linesFromStartToContentAndPropsString({\n isEndOptional,\n lines,\n regexpEndRegex,\n startLineIndex,\n startMatch,\n trimChildren: false,\n })\n\n let content = ''\n\n if (block?.jsx?.doNotTrimChildren) {\n content = unsanitizedContent.endsWith('\\n')\n ? unsanitizedContent.slice(0, -1)\n : unsanitizedContent\n } else {\n // Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child\n if (unsanitizedContent.includes('\\n')) {\n const split = unsanitizedContent.split('\\n')\n let index = 0\n for (const child of split) {\n index++\n\n if (child.startsWith(' ')) {\n content += child.slice(2)\n } else {\n // If one child is misaligned, skip aligning completely, unless it's just empty\n if (child === '') {\n content += child\n } else {\n content = unsanitizedContent.endsWith('\\n')\n ? unsanitizedContent.slice(0, -1)\n : unsanitizedContent\n break\n }\n }\n\n content += index === split.length ? '' : '\\n'\n }\n } else {\n content =\n (!unsanitizedContent.startsWith(' ')\n ? unsanitizedContent\n : unsanitizedContent.slice(2)) + '\\n'\n }\n }\n\n if (!block?.jsx?.import) {\n // No multiline transformer handled this line successfully\n return [false, startLineIndex]\n }\n\n const markdownToLexical = getMarkdownToLexical(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const blockFields = block.jsx.import({\n children: content,\n closeMatch: null,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: startMatch,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return [false, startLineIndex]\n }\n\n const node = $createServerBlockNode({\n blockType: block.slug,\n ...blockFields,\n } as any)\n\n if (node) {\n // Now handle beforeStartLine and afterEndLine. If those are not empty, we need to add them as text nodes before and after the block node.\n // However, those themselves can contain other markdown matches, so we need to parse them as well.\n // Example where this is needed: \"Hello <InlineCode>inline code</InlineCode> test.\"\n let prevNodes: null | SerializedLexicalNode[] = null\n let nextNodes: null | SerializedLexicalNode[] = null\n // TODO: Might not need this prevNodes and nextNodes handling if inline nodes are handled by textmatch transformers\n\n if (beforeStartLine?.length) {\n prevNodes = markdownToLexical({ markdown: beforeStartLine })?.root?.children ?? []\n\n const firstPrevNode = prevNodes?.[0]\n if (firstPrevNode) {\n rootNode.append($parseSerializedNode(firstPrevNode))\n }\n }\n\n rootNode.append(node)\n\n if (afterEndLine?.length) {\n nextNodes = markdownToLexical({ markdown: afterEndLine })?.root?.children\n const lastChild = rootNode.getChildren()[rootNode.getChildren().length - 1]\n\n const children = ($parseSerializedNode(nextNodes[0]!) as ElementNode)?.getChildren()\n if (children?.length) {\n for (const child of children) {\n ;(lastChild as ElementNode).append(child)\n }\n }\n }\n }\n\n return [true, endLineIndex]\n },\n regExpEnd: block.jsx?.customEndRegex ?? regex.regExpEnd,\n regExpStart: block.jsx?.customStartRegex ?? regex.regExpStart,\n // This replace is ONLY run for ``` code blocks (so any blocks with custom start and end regexes). For others, we use the special JSX handling above:\n type: 'multiline-element',\n replace: (rootNode, children, openMatch, closeMatch, linesInBetween) => {\n if (block?.jsx?.import) {\n if (!linesInBetween) {\n // convert children to linesInBetween\n let line = ''\n if (children) {\n for (const child of children) {\n line += child.getTextContent()\n }\n }\n\n linesInBetween = [line]\n }\n\n let childrenString = ''\n if (block?.jsx?.doNotTrimChildren) {\n childrenString = linesInBetween.join('\\n')\n } else {\n childrenString = linesInBetween.join('\\n').trim()\n }\n\n const propsString = openMatch[1]?.trim()\n\n const markdownToLexical = getMarkdownToLexical(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const blockFields = block.jsx.import({\n children: childrenString,\n closeMatch: closeMatch as RegExpMatchArray,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: openMatch as RegExpMatchArray,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return false\n }\n\n const node = $createServerBlockNode({\n blockType: block.slug,\n ...blockFields,\n } as any)\n\n if (node) {\n rootNode.append(node)\n }\n\n return\n }\n return false // Run next transformer\n },\n }))\n\n return toReturn\n}\n"],"names":["$parseSerializedNode","getEnabledNodesFromServerNodes","extractPropsFromJSXPropsString","propsToJSXString","getLexicalToMarkdown","getMarkdownToLexical","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","linesFromStartToContentAndPropsString","createTagRegexes","tagName","escapedTagName","replace","openingTag","closingTag","optionalWhitespace","mandatoryClosingBracket","startPattern","endPattern","regExpEnd","RegExp","regExpStart","getBlockMarkdownTransformers","blocks","inlineBlocks","length","transformers","block","transformer","getMarkdownTransformerForBlock","concat","isInlineBlock","jsx","regex","slug","toReturn","push","allNodes","allTransformers","type","dependencies","export","node","getFields","blockType","toLowerCase","nodeFields","lexicalToMarkdown","nodes","exportResult","fields","hasProps","props","Object","keys","children","getEndIndex","match","endlineLastCharIndex","isEndOptional","lines","getTextContent","regexpEndRegex","startLineIndex","startMatch","trimChildren","importRegExp","customStartRegex","regExp","content","propsString","index","import","markdownToLexical","blockFields","closeMatch","htmlToLexical","openMatch","inlineBlockNode","sanitizedChildren","includes","child","split","sanitizedChild","doNotTrimChildren","handleImportAfterStartMatch","customEndRegex","undefined","rootNode","optional","afterEndLine","beforeStartLine","unsanitizedContent","endLineIndex","endsWith","slice","startsWith","prevNodes","nextNodes","markdown","root","firstPrevNode","append","lastChild","getChildren","linesInBetween","line","childrenString","join","trim"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ,UAAS;AAI9C,SAASC,8BAA8B,QAAQ,qCAAoC;AAMnF,SAASC,8BAA8B,QAAQ,8DAA6D;AAC5G,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,sBAAsB,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ,yBAAwB;AACpG,SACEC,4BAA4B,EAC5BC,wBAAwB,EACxBC,qBAAqB,QAChB,+BAA8B;AACrC,SAASC,qCAAqC,QAAQ,6CAA4C;AA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A,CAAC;oBACP;oBACA,IAAII,gBAAgB,OAAO;wBACzB,OAAO;oBACT;oBAEA,MAAMhC,OAAOxC,uBAAuB;wBAClC0C,WAAWjB,MAAMO,IAAI;wBACrB,GAAGwC,WAAW;oBAChB;oBAEA,IAAIhC,MAAM;wBACR8C,SAASc,MAAM,CAAC5D;oBAClB;oBAEA;gBACF;gBACA,OAAO;YACT;QACF,CAAA;IAFiB,uBAAuB;IAIxC,OAAOP;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/blocks/server/markdown/markdownTransformer.ts"],"sourcesContent":["import type { ElementNode, SerializedLexicalNode } from 'lexical'\nimport type { Block } from 'payload'\n\nimport { $parseSerializedNode } from 'lexical'\n\nimport type { NodeWithHooks } from '../../../typesServer.js'\n\nimport { getEnabledNodesFromServerNodes } from '../../../../lexical/nodes/index.js'\nimport {\n type MultilineElementTransformer,\n type TextMatchTransformer,\n type Transformer,\n} from '../../../../packages/@lexical/markdown/index.js'\nimport { extractPropsFromJSXPropsString } from '../../../../utilities/jsx/extractPropsFromJSXPropsString.js'\nimport { propsToJSXString } from '../../../../utilities/jsx/jsx.js'\nimport { getLexicalToMarkdown } from '../../client/markdown/getLexicalToMarkdown.js'\nimport { getMarkdownToLexical } from '../../client/markdown/getMarkdownToLexical.js'\nimport { $createServerBlockNode, $isServerBlockNode, ServerBlockNode } from '../nodes/BlocksNode.js'\nimport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n ServerInlineBlockNode,\n} from '../nodes/InlineBlocksNode.js'\nimport { linesFromStartToContentAndPropsString } from './linesFromMatchToContentAndPropsString.js'\n\nexport function createTagRegexes(tagName: string) {\n const escapedTagName = tagName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n // Regex components\n const openingTag = `<${escapedTagName}`\n const closingTag = `</${escapedTagName}`\n const optionalWhitespace = `\\\\s*`\n const mandatoryClosingBracket = `>`\n\n // Assembled regex patterns\n const startPattern = `${openingTag}(?=\\\\s|>|$)` // Only match the tag name\n const endPattern = `${closingTag}${optionalWhitespace}${mandatoryClosingBracket}`\n\n return {\n regExpEnd: new RegExp(endPattern, 'i'),\n regExpStart: new RegExp(startPattern, 'i'),\n }\n}\nexport const getBlockMarkdownTransformers = ({\n blocks,\n inlineBlocks,\n}: {\n blocks: Block[]\n inlineBlocks: Block[]\n}): ((props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n}) => MultilineElementTransformer | TextMatchTransformer)[] => {\n if (!blocks?.length && !inlineBlocks?.length) {\n return []\n }\n\n let transformers: ((props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer)[] = []\n\n if (blocks?.length) {\n for (const block of blocks) {\n const transformer = getMarkdownTransformerForBlock(block, false)\n\n if (transformer) {\n transformers = transformers.concat(transformer)\n }\n }\n }\n\n if (inlineBlocks?.length) {\n for (const block of inlineBlocks) {\n const transformer = getMarkdownTransformerForBlock(block, true)\n\n if (transformer) {\n transformers = transformers.concat(transformer)\n }\n }\n }\n\n return transformers\n}\n\nfunction getMarkdownTransformerForBlock(\n block: Block,\n isInlineBlock: boolean,\n): Array<\n (props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer\n> | null {\n if (!block.jsx) {\n return null\n }\n\n const regex = createTagRegexes(block.slug)\n const toReturn: Array<\n (props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer\n > = []\n\n if (isInlineBlock) {\n toReturn.push(({ allNodes, allTransformers }) => ({\n type: 'text-match',\n dependencies: [ServerInlineBlockNode],\n export: (node) => {\n if (!$isServerInlineBlockNode(node)) {\n return null\n }\n\n if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {\n return null\n }\n\n const nodeFields = node.getFields()\n const lexicalToMarkdown = getLexicalToMarkdown(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const exportResult = block.jsx!.export({\n fields: nodeFields,\n lexicalToMarkdown,\n })\n if (exportResult === false) {\n return null\n }\n if (typeof exportResult === 'string') {\n return exportResult\n }\n\n const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0\n const props = exportResult.props ?? {}\n\n if (exportResult?.children?.length) {\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}>${exportResult.children}</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}/>`\n },\n getEndIndex: (node, match) => {\n const { endlineLastCharIndex } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines: [node.getTextContent()],\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: 0,\n startMatch: match,\n trimChildren: false,\n })\n\n return endlineLastCharIndex\n },\n importRegExp: block.jsx?.customStartRegex ?? regex.regExpStart,\n regExp: /___ignoreignoreignore___/g,\n replace(node, match) {\n const { content, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines: [node.getTextContent()],\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: 0,\n startMatch: {\n ...match,\n index: 0,\n },\n trimChildren: false,\n })\n\n if (!block?.jsx?.import) {\n // No multiline transformer handled this line successfully\n return\n }\n\n const markdownToLexical = getMarkdownToLexical(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const blockFields = block.jsx.import({\n children: content,\n closeMatch: null,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: match,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return\n }\n\n const inlineBlockNode = $createServerInlineBlockNode({\n blockType: block.slug,\n ...(blockFields as any),\n })\n\n node.replace(inlineBlockNode)\n },\n }))\n\n return toReturn\n }\n\n toReturn.push(({ allNodes, allTransformers }) => ({\n dependencies: [ServerBlockNode],\n export: (node) => {\n if (!$isServerBlockNode(node)) {\n return null\n }\n\n if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {\n return null\n }\n\n const nodeFields = node.getFields()\n const lexicalToMarkdown = getLexicalToMarkdown(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const exportResult = block.jsx!.export({\n fields: nodeFields,\n lexicalToMarkdown,\n })\n if (exportResult === false) {\n return null\n }\n if (typeof exportResult === 'string') {\n return exportResult\n }\n\n const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0\n const props = exportResult.props ?? {}\n\n if (exportResult?.children?.length) {\n const children = exportResult.children\n let sanitizedChildren = ''\n\n // Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child\n if (children.includes('\\n')) {\n for (const child of children.split('\\n')) {\n let sanitizedChild = ''\n if (!block?.jsx?.doNotTrimChildren && child !== '') {\n sanitizedChild = ' '\n }\n sanitizedChild += child + '\\n'\n\n sanitizedChildren += sanitizedChild\n }\n } else {\n sanitizedChildren = (block?.jsx?.doNotTrimChildren ? '' : ' ') + children + '\\n'\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}>\\n${sanitizedChildren}</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}/>`\n },\n handleImportAfterStartMatch: block.jsx?.customEndRegex\n ? undefined\n : ({ lines, rootNode, startLineIndex, startMatch, transformer }) => {\n const regexpEndRegex: RegExp | undefined =\n typeof transformer.regExpEnd === 'object' && 'regExp' in transformer.regExpEnd\n ? transformer.regExpEnd.regExp\n : transformer.regExpEnd\n\n const isEndOptional =\n transformer.regExpEnd &&\n typeof transformer.regExpEnd === 'object' &&\n 'optional' in transformer.regExpEnd\n ? transformer.regExpEnd.optional\n : !transformer.regExpEnd\n\n const {\n afterEndLine,\n beforeStartLine,\n content: unsanitizedContent,\n endLineIndex,\n propsString,\n } = linesFromStartToContentAndPropsString({\n isEndOptional,\n lines,\n regexpEndRegex,\n startLineIndex,\n startMatch,\n trimChildren: false,\n })\n\n let content = ''\n\n if (block?.jsx?.doNotTrimChildren) {\n content = unsanitizedContent.endsWith('\\n')\n ? unsanitizedContent.slice(0, -1)\n : unsanitizedContent\n } else {\n // Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child\n if (unsanitizedContent.includes('\\n')) {\n const split = unsanitizedContent.split('\\n')\n let index = 0\n for (const child of split) {\n index++\n\n if (child.startsWith(' ')) {\n content += child.slice(2)\n } else {\n // If one child is misaligned, skip aligning completely, unless it's just empty\n if (child === '') {\n content += child\n } else {\n content = unsanitizedContent.endsWith('\\n')\n ? unsanitizedContent.slice(0, -1)\n : unsanitizedContent\n break\n }\n }\n\n content += index === split.length ? '' : '\\n'\n }\n } else {\n content =\n (!unsanitizedContent.startsWith(' ')\n ? unsanitizedContent\n : unsanitizedContent.slice(2)) + '\\n'\n }\n }\n\n if (!block?.jsx?.import) {\n // No multiline transformer handled this line successfully\n return [false, startLineIndex]\n }\n\n const markdownToLexical = getMarkdownToLexical(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const blockFields = block.jsx.import({\n children: content,\n closeMatch: null,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: startMatch,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return [false, startLineIndex]\n }\n\n const node = $createServerBlockNode({\n blockType: block.slug,\n ...blockFields,\n } as any)\n\n if (node) {\n // Now handle beforeStartLine and afterEndLine. If those are not empty, we need to add them as text nodes before and after the block node.\n // However, those themselves can contain other markdown matches, so we need to parse them as well.\n // Example where this is needed: \"Hello <InlineCode>inline code</InlineCode> test.\"\n let prevNodes: null | SerializedLexicalNode[] = null\n let nextNodes: null | SerializedLexicalNode[] = null\n // TODO: Might not need this prevNodes and nextNodes handling if inline nodes are handled by textmatch transformers\n\n if (beforeStartLine?.length) {\n prevNodes = markdownToLexical({ markdown: beforeStartLine })?.root?.children ?? []\n\n const firstPrevNode = prevNodes?.[0]\n if (firstPrevNode) {\n rootNode.append($parseSerializedNode(firstPrevNode))\n }\n }\n\n rootNode.append(node)\n\n if (afterEndLine?.length) {\n nextNodes = markdownToLexical({ markdown: afterEndLine })?.root?.children\n const lastChild = rootNode.getChildren()[rootNode.getChildren().length - 1]\n\n const children = ($parseSerializedNode(nextNodes[0]!) as ElementNode)?.getChildren()\n if (children?.length) {\n for (const child of children) {\n ;(lastChild as ElementNode).append(child)\n }\n }\n }\n }\n\n return [true, endLineIndex]\n },\n regExpEnd: block.jsx?.customEndRegex ?? regex.regExpEnd,\n regExpStart: block.jsx?.customStartRegex ?? regex.regExpStart,\n // This replace is ONLY run for ``` code blocks (so any blocks with custom start and end regexes). For others, we use the special JSX handling above:\n type: 'multiline-element',\n replace: (rootNode, children, openMatch, closeMatch, linesInBetween) => {\n if (block?.jsx?.import) {\n if (!linesInBetween) {\n // convert children to linesInBetween\n let line = ''\n if (children) {\n for (const child of children) {\n line += child.getTextContent()\n }\n }\n\n linesInBetween = [line]\n }\n\n let childrenString = ''\n if (block?.jsx?.doNotTrimChildren) {\n childrenString = linesInBetween.join('\\n')\n } else {\n childrenString = linesInBetween.join('\\n').trim()\n }\n\n const propsString = openMatch[1]?.trim()\n\n const markdownToLexical = getMarkdownToLexical(\n getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n allTransformers,\n )\n\n const blockFields = block.jsx.import({\n children: childrenString,\n closeMatch: closeMatch as RegExpMatchArray,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: openMatch as RegExpMatchArray,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return false\n }\n\n const node = $createServerBlockNode({\n blockType: block.slug,\n ...blockFields,\n } as any)\n\n if (node) {\n rootNode.append(node)\n }\n\n return\n }\n return false // Run next transformer\n },\n }))\n\n return toReturn\n}\n"],"names":["$parseSerializedNode","getEnabledNodesFromServerNodes","extractPropsFromJSXPropsString","propsToJSXString","getLexicalToMarkdown","getMarkdownToLexical","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","linesFromStartToContentAndPropsString","createTagRegexes","tagName","escapedTagName","replace","openingTag","closingTag","optionalWhitespace","mandatoryClosingBracket","startPattern","endPattern","regExpEnd","RegExp","regExpStart","getBlockMarkdownTransformers","blocks","inlineBlocks","length","transformers","block","transformer","getMarkdownTransformerForBlock","concat","isInlineBlock","jsx","regex","slug","toReturn","push","allNodes","allTransformers","type","dependencies","export","node","getFields","blockType","toLowerCase","nodeFields","lexicalToMarkdown","nodes","exportResult","fields","hasProps","props","Object","keys","children","getEndIndex","match","endlineLastCharIndex","isEndOptional","lines","getTextContent","regexpEndRegex","startLineIndex","startMatch","trimChildren","importRegExp","customStartRegex","regExp","content","propsString","index","import","markdownToLexical","blockFields","closeMatch","htmlToLexical","openMatch","inlineBlockNode","sanitizedChildren","includes","child","split","sanitizedChild","doNotTrimChildren","handleImportAfterStartMatch","customEndRegex","undefined","rootNode","optional","afterEndLine","beforeStartLine","unsanitizedContent","endLineIndex","endsWith","slice","startsWith","prevNodes","nextNodes","markdown","root","firstPrevNode","append","lastChild","getChildren","linesInBetween","line","childrenString","join","trim"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ,UAAS;AAI9C,SAASC,8BAA8B,QAAQ,qCAAoC;AAMnF,SAASC,8BAA8B,QAAQ,8DAA6D;AAC5G,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,sBAAsB,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ,yBAAwB;AACpG,SACEC,4BAA4B,EAC5BC,wBAAwB,EACxBC,qBAAqB,QAChB,+BAA8B;AACrC,SAASC,q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BAA+B;4BAC7BwE;wBACF,KACA,CAAC;oBACP;oBACA,IAAII,gBAAgB,OAAO;wBACzB,OAAO;oBACT;oBAEA,MAAMhC,OAAOxC,uBAAuB;wBAClC0C,WAAWjB,MAAMO,IAAI;wBACrB,GAAGwC,WAAW;oBAChB;oBAEA,IAAIhC,MAAM;wBACR8C,SAASc,MAAM,CAAC5D;oBAClB;oBAEA;gBACF;gBACA,OAAO;YACT;QACF,CAAA;IAFiB,uBAAuB;IAIxC,OAAOP;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { defaultJSXConverters } from '../converter/defaultConverters.js';
|
|
4
4
|
import { convertLexicalToJSX } from '../converter/index.js';
|
|
@@ -37,14 +37,18 @@ import { convertLexicalToJSX } from '../converter/index.js';
|
|
|
37
37
|
disableTextAlign
|
|
38
38
|
});
|
|
39
39
|
if (disableContainer) {
|
|
40
|
-
return /*#__PURE__*/
|
|
40
|
+
return /*#__PURE__*/ _jsxDEV(_Fragment, {
|
|
41
41
|
children: content
|
|
42
|
-
});
|
|
42
|
+
}, void 0, false);
|
|
43
43
|
}
|
|
44
|
-
return /*#__PURE__*/
|
|
44
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
45
45
|
className: className ?? 'payload-richtext',
|
|
46
46
|
children: content
|
|
47
|
-
}
|
|
47
|
+
}, void 0, false, {
|
|
48
|
+
fileName: "src/features/converters/lexicalToJSX/Component/index.tsx",
|
|
49
|
+
lineNumber: 88,
|
|
50
|
+
columnNumber: 10
|
|
51
|
+
}, this);
|
|
48
52
|
};
|
|
49
53
|
|
|
50
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\n\nimport React from 'react'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\nimport type { JSXConverters } from '../converter/types.js'\n\nimport { defaultJSXConverters } from '../converter/defaultConverters.js'\nimport { convertLexicalToJSX } from '../converter/index.js'\n\nexport type JSXConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string }>\n | SerializedInlineBlockNode<{ blockName?: null | string }>,\n> = (args: { defaultConverters: JSXConverters<DefaultNodeTypes> }) => JSXConverters<T>\n\ntype RichTextProps = {\n /**\n * Override class names for the container.\n */\n className?: string\n /**\n * Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.\n */\n converters?: JSXConverters | JSXConvertersFunction\n /**\n * Serialized editor state to render.\n */\n data: SerializedEditorState\n /**\n * If true, removes the container div wrapper.\n */\n disableContainer?: boolean\n /**\n * If true, disables indentation globally. If an array, disables for specific node `type` values.\n */\n disableIndent?: boolean | string[]\n /**\n * If true, disables text alignment globally. If an array, disables for specific node `type` values.\n */\n disableTextAlign?: boolean | string[]\n}\n\nexport const RichText: React.FC<RichTextProps> = ({\n className,\n converters,\n data: editorState,\n disableContainer,\n disableIndent,\n disableTextAlign,\n}) => {\n if (!editorState) {\n return null\n }\n\n let finalConverters: JSXConverters = {}\n if (converters) {\n if (typeof converters === 'function') {\n finalConverters = converters({ defaultConverters: defaultJSXConverters })\n } else {\n finalConverters = converters\n }\n } else {\n finalConverters = defaultJSXConverters\n }\n\n const content =\n editorState &&\n !Array.isArray(editorState) &&\n typeof editorState === 'object' &&\n 'root' in editorState &&\n convertLexicalToJSX({\n converters: finalConverters,\n data: editorState,\n disableIndent,\n disableTextAlign,\n })\n\n if (disableContainer) {\n return <>{content}</>\n }\n\n return <div className={className ?? 'payload-richtext'}>{content}</div>\n}\n"],"names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","finalConverters","defaultConverters","content","Array","isArray","div"],"mappings":";AAEA,OAAOA,WAAW,QAAO;AASzB,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,mBAAmB,QAAQ,wBAAuB;AAUzD;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAIH,OAAO,MAAMC,WAAoC,CAAC,EAChDC,SAAS,EACTC,UAAU,EACVC,MAAMC,WAAW,EACjBC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,EACjB;IACC,IAAI,CAACH,aAAa;QAChB,OAAO;IACT;IAEA,IAAII,kBAAiC,CAAC;IACtC,IAAIN,YAAY;QACd,IAAI,OAAOA,eAAe,YAAY;YACpCM,kBAAkBN,WAAW;gBAAEO,mBAAmBX;YAAqB;QACzE,OAAO;YACLU,kBAAkBN;QACpB;IACF,OAAO;QACLM,kBAAkBV;IACpB;IAEA,MAAMY,UACJN,eACA,CAACO,MAAMC,OAAO,CAACR,gBACf,OAAOA,gBAAgB,YACvB,UAAUA,eACVL,oBAAoB;QAClBG,YAAYM;QACZL,MAAMC;QACNE;QACAC;IACF;IAEF,IAAIF,kBAAkB;QACpB,qBAAO;sBAAGK;;IACZ;IAEA,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\n\nimport React from 'react'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\nimport type { JSXConverters } from '../converter/types.js'\n\nimport { defaultJSXConverters } from '../converter/defaultConverters.js'\nimport { convertLexicalToJSX } from '../converter/index.js'\n\nexport type JSXConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string }>\n | SerializedInlineBlockNode<{ blockName?: null | string }>,\n> = (args: { defaultConverters: JSXConverters<DefaultNodeTypes> }) => JSXConverters<T>\n\ntype RichTextProps = {\n /**\n * Override class names for the container.\n */\n className?: string\n /**\n * Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.\n */\n converters?: JSXConverters | JSXConvertersFunction\n /**\n * Serialized editor state to render.\n */\n data: SerializedEditorState\n /**\n * If true, removes the container div wrapper.\n */\n disableContainer?: boolean\n /**\n * If true, disables indentation globally. If an array, disables for specific node `type` values.\n */\n disableIndent?: boolean | string[]\n /**\n * If true, disables text alignment globally. If an array, disables for specific node `type` values.\n */\n disableTextAlign?: boolean | string[]\n}\n\nexport const RichText: React.FC<RichTextProps> = ({\n className,\n converters,\n data: editorState,\n disableContainer,\n disableIndent,\n disableTextAlign,\n}) => {\n if (!editorState) {\n return null\n }\n\n let finalConverters: JSXConverters = {}\n if (converters) {\n if (typeof converters === 'function') {\n finalConverters = converters({ defaultConverters: defaultJSXConverters })\n } else {\n finalConverters = converters\n }\n } else {\n finalConverters = defaultJSXConverters\n }\n\n const content =\n editorState &&\n !Array.isArray(editorState) &&\n typeof editorState === 'object' &&\n 'root' in editorState &&\n convertLexicalToJSX({\n converters: finalConverters,\n data: editorState,\n disableIndent,\n disableTextAlign,\n })\n\n if (disableContainer) {\n return <>{content}</>\n }\n\n return <div className={className ?? 'payload-richtext'}>{content}</div>\n}\n"],"names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","finalConverters","defaultConverters","content","Array","isArray","div"],"mappings":";AAEA,OAAOA,WAAW,QAAO;AASzB,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,mBAAmB,QAAQ,wBAAuB;AAUzD;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAIH,OAAO,MAAMC,WAAoC,CAAC,EAChDC,SAAS,EACTC,UAAU,EACVC,MAAMC,WAAW,EACjBC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,EACjB;IACC,IAAI,CAACH,aAAa;QAChB,OAAO;IACT;IAEA,IAAII,kBAAiC,CAAC;IACtC,IAAIN,YAAY;QACd,IAAI,OAAOA,eAAe,YAAY;YACpCM,kBAAkBN,WAAW;gBAAEO,mBAAmBX;YAAqB;QACzE,OAAO;YACLU,kBAAkBN;QACpB;IACF,OAAO;QACLM,kBAAkBV;IACpB;IAEA,MAAMY,UACJN,eACA,CAACO,MAAMC,OAAO,CAACR,gBACf,OAAOA,gBAAgB,YACvB,UAAUA,eACVL,oBAAoB;QAClBG,YAAYM;QACZL,MAAMC;QACNE;QACAC;IACF;IAEF,IAAIF,kBAAkB;QACpB,qBAAO;sBAAGK;;IACZ;IAEA,qBAAO,QAACG;QAAIZ,WAAWA,aAAa;kBAAqBS;;;;;;AAC3D,EAAC"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
export const BlockquoteJSXConverter = {
|
|
3
3
|
quote: ({ node, nodesToJSX })=>{
|
|
4
4
|
const children = nodesToJSX({
|
|
5
5
|
nodes: node.children
|
|
6
6
|
});
|
|
7
|
-
return /*#__PURE__*/
|
|
7
|
+
return /*#__PURE__*/ _jsxDEV("blockquote", {
|
|
8
8
|
children: children
|
|
9
|
-
}
|
|
9
|
+
}, void 0, false, {
|
|
10
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/blockquote.tsx",
|
|
11
|
+
lineNumber: 10,
|
|
12
|
+
columnNumber: 12
|
|
13
|
+
}, this);
|
|
10
14
|
}
|
|
11
15
|
};
|
|
12
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/blockquote.tsx"],"sourcesContent":["import type { SerializedQuoteNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const BlockquoteJSXConverter: JSXConverters<SerializedQuoteNode> = {\n quote: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n return <blockquote>{children}</blockquote>\n },\n}\n"],"names":["BlockquoteJSXConverter","quote","node","nodesToJSX","children","nodes","blockquote"],"mappings":";AAGA,OAAO,MAAMA,yBAA6D;IACxEC,OAAO,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;QAC1B,MAAMC,WAAWD,WAAW;YAC1BE,OAAOH,KAAKE,QAAQ;QACtB;QAEA,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/blockquote.tsx"],"sourcesContent":["import type { SerializedQuoteNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const BlockquoteJSXConverter: JSXConverters<SerializedQuoteNode> = {\n quote: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n return <blockquote>{children}</blockquote>\n },\n}\n"],"names":["BlockquoteJSXConverter","quote","node","nodesToJSX","children","nodes","blockquote"],"mappings":";AAGA,OAAO,MAAMA,yBAA6D;IACxEC,OAAO,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;QAC1B,MAAMC,WAAWD,WAAW;YAC1BE,OAAOH,KAAKE,QAAQ;QACtB;QAEA,qBAAO,QAACE;sBAAYF;;;;;;IACtB;AACF,EAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
export const HeadingJSXConverter = {
|
|
3
3
|
heading: ({ node, nodesToJSX })=>{
|
|
4
4
|
const children = nodesToJSX({
|
|
5
5
|
nodes: node.children
|
|
6
6
|
});
|
|
7
7
|
const NodeTag = node.tag;
|
|
8
|
-
return /*#__PURE__*/
|
|
8
|
+
return /*#__PURE__*/ _jsxDEV(NodeTag, {
|
|
9
9
|
children: children
|
|
10
|
-
}
|
|
10
|
+
}, void 0, false, {
|
|
11
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/heading.tsx",
|
|
12
|
+
lineNumber: 12,
|
|
13
|
+
columnNumber: 12
|
|
14
|
+
}, this);
|
|
11
15
|
}
|
|
12
16
|
};
|
|
13
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/heading.tsx"],"sourcesContent":["import type { SerializedHeadingNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const HeadingJSXConverter: JSXConverters<SerializedHeadingNode> = {\n heading: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const NodeTag = node.tag\n\n return <NodeTag>{children}</NodeTag>\n },\n}\n"],"names":["HeadingJSXConverter","heading","node","nodesToJSX","children","nodes","NodeTag","tag"],"mappings":";AAGA,OAAO,MAAMA,sBAA4D;IACvEC,SAAS,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;QAC5B,MAAMC,WAAWD,WAAW;YAC1BE,OAAOH,KAAKE,QAAQ;QACtB;QAEA,MAAME,UAAUJ,KAAKK,GAAG;QAExB,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/heading.tsx"],"sourcesContent":["import type { SerializedHeadingNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const HeadingJSXConverter: JSXConverters<SerializedHeadingNode> = {\n heading: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const NodeTag = node.tag\n\n return <NodeTag>{children}</NodeTag>\n },\n}\n"],"names":["HeadingJSXConverter","heading","node","nodesToJSX","children","nodes","NodeTag","tag"],"mappings":";AAGA,OAAO,MAAMA,sBAA4D;IACvEC,SAAS,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;QAC5B,MAAMC,WAAWD,WAAW;YAC1BE,OAAOH,KAAKE,QAAQ;QACtB;QAEA,MAAME,UAAUJ,KAAKK,GAAG;QAExB,qBAAO,QAACD;sBAASF;;;;;;IACnB;AACF,EAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
export const HorizontalRuleJSXConverter = {
|
|
3
|
-
horizontalrule: /*#__PURE__*/
|
|
3
|
+
horizontalrule: /*#__PURE__*/ _jsxDEV("hr", {}, void 0, false, {
|
|
4
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/horizontalRule.tsx",
|
|
5
|
+
lineNumber: 4,
|
|
6
|
+
columnNumber: 19
|
|
7
|
+
}, this)
|
|
4
8
|
};
|
|
5
9
|
|
|
6
10
|
//# sourceMappingURL=horizontalRule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/horizontalRule.tsx"],"sourcesContent":["import type { SerializedHorizontalRuleNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\nexport const HorizontalRuleJSXConverter: JSXConverters<SerializedHorizontalRuleNode> = {\n horizontalrule: <hr />,\n}\n"],"names":["HorizontalRuleJSXConverter","horizontalrule","hr"],"mappings":";AAEA,OAAO,MAAMA,6BAA0E;IACrFC,8BAAgB,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/horizontalRule.tsx"],"sourcesContent":["import type { SerializedHorizontalRuleNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\nexport const HorizontalRuleJSXConverter: JSXConverters<SerializedHorizontalRuleNode> = {\n horizontalrule: <hr />,\n}\n"],"names":["HorizontalRuleJSXConverter","horizontalrule","hr"],"mappings":";AAEA,OAAO,MAAMA,6BAA0E;IACrFC,8BAAgB,QAACC;;;;;AACnB,EAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
export const LinebreakJSXConverter = {
|
|
3
|
-
linebreak: /*#__PURE__*/
|
|
3
|
+
linebreak: /*#__PURE__*/ _jsxDEV("br", {}, void 0, false, {
|
|
4
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/linebreak.tsx",
|
|
5
|
+
lineNumber: 5,
|
|
6
|
+
columnNumber: 14
|
|
7
|
+
}, this)
|
|
4
8
|
};
|
|
5
9
|
|
|
6
10
|
//# sourceMappingURL=linebreak.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/linebreak.tsx"],"sourcesContent":["import type { SerializedLineBreakNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const LinebreakJSXConverter: JSXConverters<SerializedLineBreakNode> = {\n linebreak: <br />,\n}\n"],"names":["LinebreakJSXConverter","linebreak","br"],"mappings":";AAGA,OAAO,MAAMA,wBAAgE;IAC3EC,yBAAW,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/linebreak.tsx"],"sourcesContent":["import type { SerializedLineBreakNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const LinebreakJSXConverter: JSXConverters<SerializedLineBreakNode> = {\n linebreak: <br />,\n}\n"],"names":["LinebreakJSXConverter","linebreak","br"],"mappings":";AAGA,OAAO,MAAMA,wBAAgE;IAC3EC,yBAAW,QAACC;;;;;AACd,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
export const LinkJSXConverter = ({ internalDocToHref })=>({
|
|
3
3
|
autolink: ({ node, nodesToJSX })=>{
|
|
4
4
|
const children = nodesToJSX({
|
|
@@ -6,12 +6,16 @@ export const LinkJSXConverter = ({ internalDocToHref })=>({
|
|
|
6
6
|
});
|
|
7
7
|
const rel = node.fields.newTab ? 'noopener noreferrer' : undefined;
|
|
8
8
|
const target = node.fields.newTab ? '_blank' : undefined;
|
|
9
|
-
return /*#__PURE__*/
|
|
9
|
+
return /*#__PURE__*/ _jsxDEV("a", {
|
|
10
10
|
href: node.fields.url,
|
|
11
11
|
rel,
|
|
12
12
|
target,
|
|
13
13
|
children: children
|
|
14
|
-
}
|
|
14
|
+
}, void 0, false, {
|
|
15
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/link.tsx",
|
|
16
|
+
lineNumber: 16,
|
|
17
|
+
columnNumber: 7
|
|
18
|
+
}, this);
|
|
15
19
|
},
|
|
16
20
|
link: ({ node, nodesToJSX })=>{
|
|
17
21
|
const children = nodesToJSX({
|
|
@@ -31,12 +35,16 @@ export const LinkJSXConverter = ({ internalDocToHref })=>({
|
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
// fallback
|
|
34
|
-
return /*#__PURE__*/
|
|
38
|
+
return /*#__PURE__*/ _jsxDEV("a", {
|
|
35
39
|
href: href,
|
|
36
40
|
rel,
|
|
37
41
|
target,
|
|
38
42
|
children: children
|
|
39
|
-
}
|
|
43
|
+
}, void 0, false, {
|
|
44
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/link.tsx",
|
|
45
|
+
lineNumber: 42,
|
|
46
|
+
columnNumber: 7
|
|
47
|
+
}, this);
|
|
40
48
|
}
|
|
41
49
|
});
|
|
42
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/link.tsx"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const LinkJSXConverter: (args: {\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}) => JSXConverters<SerializedAutoLinkNode | SerializedLinkNode> = ({ internalDocToHref }) => ({\n autolink: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n return (\n <a href={node.fields.url} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n link: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = internalDocToHref({ linkNode: node })\n } else {\n console.error(\n 'Lexical => JSX converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return (\n <a href={href} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n})\n"],"names":["LinkJSXConverter","internalDocToHref","autolink","node","nodesToJSX","children","nodes","rel","fields","newTab","undefined","target","a","href","url","link","linkType","linkNode","console","error"],"mappings":";AAGA,OAAO,MAAMA,mBAEsD,CAAC,EAAEC,iBAAiB,EAAE,GAAM,CAAA;QAC7FC,UAAU,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;YAC7B,MAAMC,WAAWD,WAAW;gBAC1BE,OAAOH,KAAKE,QAAQ;YACtB;YAEA,MAAME,MAA0BJ,KAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC;YAC7E,MAAMC,SAA6BR,KAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC;YAEnE,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/link.tsx"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const LinkJSXConverter: (args: {\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}) => JSXConverters<SerializedAutoLinkNode | SerializedLinkNode> = ({ internalDocToHref }) => ({\n autolink: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n return (\n <a href={node.fields.url} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n link: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = internalDocToHref({ linkNode: node })\n } else {\n console.error(\n 'Lexical => JSX converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return (\n <a href={href} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n})\n"],"names":["LinkJSXConverter","internalDocToHref","autolink","node","nodesToJSX","children","nodes","rel","fields","newTab","undefined","target","a","href","url","link","linkType","linkNode","console","error"],"mappings":";AAGA,OAAO,MAAMA,mBAEsD,CAAC,EAAEC,iBAAiB,EAAE,GAAM,CAAA;QAC7FC,UAAU,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;YAC7B,MAAMC,WAAWD,WAAW;gBAC1BE,OAAOH,KAAKE,QAAQ;YACtB;YAEA,MAAME,MAA0BJ,KAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC;YAC7E,MAAMC,SAA6BR,KAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC;YAEnE,qBACE,QAACE;gBAAEC,MAAMV,KAAKK,MAAM,CAACM,GAAG;gBAAQP;gBAAKI;0BAClCN;;;;;;QAGP;QACAU,MAAM,CAAC,EAAEZ,IAAI,EAAEC,UAAU,EAAE;YACzB,MAAMC,WAAWD,WAAW;gBAC1BE,OAAOH,KAAKE,QAAQ;YACtB;YAEA,MAAME,MAA0BJ,KAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC;YAC7E,MAAMC,SAA6BR,KAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC;YAEnE,IAAIG,OAAeV,KAAKK,MAAM,CAACM,GAAG,IAAI;YACtC,IAAIX,KAAKK,MAAM,CAACQ,QAAQ,KAAK,YAAY;gBACvC,IAAIf,mBAAmB;oBACrBY,OAAOZ,kBAAkB;wBAAEgB,UAAUd;oBAAK;gBAC5C,OAAO;oBACLe,QAAQC,KAAK,CACX;oBAEFN,OAAO;gBACT;YACF;YAFe,WAAW;YAI1B,qBACE,QAACD;gBAAEC,MAAMA;gBAAYN;gBAAKI;0BACvBN;;;;;;QAGP;IACF,CAAA,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
export const ListJSXConverter = {
|
|
4
4
|
list: ({ node, nodesToJSX })=>{
|
|
@@ -6,10 +6,14 @@ export const ListJSXConverter = {
|
|
|
6
6
|
nodes: node.children
|
|
7
7
|
});
|
|
8
8
|
const NodeTag = node.tag;
|
|
9
|
-
return /*#__PURE__*/
|
|
9
|
+
return /*#__PURE__*/ _jsxDEV(NodeTag, {
|
|
10
10
|
className: `list-${node?.listType}`,
|
|
11
11
|
children: children
|
|
12
|
-
}
|
|
12
|
+
}, void 0, false, {
|
|
13
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/list.tsx",
|
|
14
|
+
lineNumber: 14,
|
|
15
|
+
columnNumber: 12
|
|
16
|
+
}, this);
|
|
13
17
|
},
|
|
14
18
|
listitem: ({ node, nodesToJSX, parent })=>{
|
|
15
19
|
const hasSubLists = node.children.some((child)=>child.type === 'list');
|
|
@@ -18,7 +22,7 @@ export const ListJSXConverter = {
|
|
|
18
22
|
});
|
|
19
23
|
if ('listType' in parent && parent?.listType === 'check') {
|
|
20
24
|
const uuid = uuidv4();
|
|
21
|
-
return /*#__PURE__*/
|
|
25
|
+
return /*#__PURE__*/ _jsxDEV("li", {
|
|
22
26
|
"aria-checked": node.checked ? 'true' : 'false',
|
|
23
27
|
className: `list-item-checkbox${node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked'}${hasSubLists ? ' nestedListItem' : ''}`,
|
|
24
28
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
@@ -28,31 +32,51 @@ export const ListJSXConverter = {
|
|
|
28
32
|
},
|
|
29
33
|
tabIndex: -1,
|
|
30
34
|
value: node?.value,
|
|
31
|
-
children: hasSubLists ? children : /*#__PURE__*/
|
|
35
|
+
children: hasSubLists ? children : /*#__PURE__*/ _jsxDEV(_Fragment, {
|
|
32
36
|
children: [
|
|
33
|
-
/*#__PURE__*/
|
|
37
|
+
/*#__PURE__*/ _jsxDEV("input", {
|
|
34
38
|
checked: node.checked,
|
|
35
39
|
id: uuid,
|
|
36
40
|
readOnly: true,
|
|
37
41
|
type: "checkbox"
|
|
38
|
-
}
|
|
39
|
-
|
|
42
|
+
}, void 0, false, {
|
|
43
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/list.tsx",
|
|
44
|
+
lineNumber: 40,
|
|
45
|
+
columnNumber: 15
|
|
46
|
+
}, this),
|
|
47
|
+
/*#__PURE__*/ _jsxDEV("label", {
|
|
40
48
|
htmlFor: uuid,
|
|
41
49
|
children: children
|
|
42
|
-
}
|
|
43
|
-
|
|
50
|
+
}, void 0, false, {
|
|
51
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/list.tsx",
|
|
52
|
+
lineNumber: 41,
|
|
53
|
+
columnNumber: 15
|
|
54
|
+
}, this),
|
|
55
|
+
/*#__PURE__*/ _jsxDEV("br", {}, void 0, false, {
|
|
56
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/list.tsx",
|
|
57
|
+
lineNumber: 42,
|
|
58
|
+
columnNumber: 15
|
|
59
|
+
}, this)
|
|
44
60
|
]
|
|
45
|
-
})
|
|
46
|
-
}
|
|
61
|
+
}, void 0, true)
|
|
62
|
+
}, void 0, false, {
|
|
63
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/list.tsx",
|
|
64
|
+
lineNumber: 27,
|
|
65
|
+
columnNumber: 9
|
|
66
|
+
}, this);
|
|
47
67
|
} else {
|
|
48
|
-
return /*#__PURE__*/
|
|
68
|
+
return /*#__PURE__*/ _jsxDEV("li", {
|
|
49
69
|
className: `${hasSubLists ? 'nestedListItem' : ''}`,
|
|
50
70
|
style: hasSubLists ? {
|
|
51
71
|
listStyleType: 'none'
|
|
52
72
|
} : undefined,
|
|
53
73
|
value: node?.value,
|
|
54
74
|
children: children
|
|
55
|
-
}
|
|
75
|
+
}, void 0, false, {
|
|
76
|
+
fileName: "src/features/converters/lexicalToJSX/converter/converters/list.tsx",
|
|
77
|
+
lineNumber: 49,
|
|
78
|
+
columnNumber: 9
|
|
79
|
+
}, this);
|
|
56
80
|
}
|
|
57
81
|
}
|
|
58
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/list.tsx"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport type { SerializedListItemNode, SerializedListNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const ListJSXConverter: JSXConverters<SerializedListItemNode | SerializedListNode> = {\n list: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const NodeTag = node.tag\n\n return <NodeTag className={`list-${node?.listType}`}>{children}</NodeTag>\n },\n listitem: ({ node, nodesToJSX, parent }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n const uuid = uuidv4()\n\n return (\n <li\n aria-checked={node.checked ? 'true' : 'false'}\n className={`list-item-checkbox${node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked'}${hasSubLists ? ' nestedListItem' : ''}`}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n role=\"checkbox\"\n style={{ listStyleType: 'none' }}\n tabIndex={-1}\n value={node?.value}\n >\n {hasSubLists ? (\n children\n ) : (\n <>\n <input checked={node.checked} id={uuid} readOnly={true} type=\"checkbox\" />\n <label htmlFor={uuid}>{children}</label>\n <br />\n </>\n )}\n </li>\n )\n } else {\n return (\n <li\n className={`${hasSubLists ? 'nestedListItem' : ''}`}\n style={hasSubLists ? { listStyleType: 'none' } : undefined}\n value={node?.value}\n >\n {children}\n </li>\n )\n }\n },\n}\n"],"names":["v4","uuidv4","ListJSXConverter","list","node","nodesToJSX","children","nodes","NodeTag","tag","className","listType","listitem","parent","hasSubLists","some","child","type","uuid","li","aria-checked","checked","role","style","listStyleType","tabIndex","value","input","id","readOnly","label","htmlFor","br","undefined"],"mappings":";AAAA,SAASA,MAAMC,MAAM,QAAQ,OAAM;AAKnC,OAAO,MAAMC,mBAA+E;IAC1FC,MAAM,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;QACzB,MAAMC,WAAWD,WAAW;YAC1BE,OAAOH,KAAKE,QAAQ;QACtB;QAEA,MAAME,UAAUJ,KAAKK,GAAG;QAExB,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/list.tsx"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport type { SerializedListItemNode, SerializedListNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const ListJSXConverter: JSXConverters<SerializedListItemNode | SerializedListNode> = {\n list: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const NodeTag = node.tag\n\n return <NodeTag className={`list-${node?.listType}`}>{children}</NodeTag>\n },\n listitem: ({ node, nodesToJSX, parent }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n const uuid = uuidv4()\n\n return (\n <li\n aria-checked={node.checked ? 'true' : 'false'}\n className={`list-item-checkbox${node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked'}${hasSubLists ? ' nestedListItem' : ''}`}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n role=\"checkbox\"\n style={{ listStyleType: 'none' }}\n tabIndex={-1}\n value={node?.value}\n >\n {hasSubLists ? (\n children\n ) : (\n <>\n <input checked={node.checked} id={uuid} readOnly={true} type=\"checkbox\" />\n <label htmlFor={uuid}>{children}</label>\n <br />\n </>\n )}\n </li>\n )\n } else {\n return (\n <li\n className={`${hasSubLists ? 'nestedListItem' : ''}`}\n style={hasSubLists ? { listStyleType: 'none' } : undefined}\n value={node?.value}\n >\n {children}\n </li>\n )\n }\n },\n}\n"],"names":["v4","uuidv4","ListJSXConverter","list","node","nodesToJSX","children","nodes","NodeTag","tag","className","listType","listitem","parent","hasSubLists","some","child","type","uuid","li","aria-checked","checked","role","style","listStyleType","tabIndex","value","input","id","readOnly","label","htmlFor","br","undefined"],"mappings":";AAAA,SAASA,MAAMC,MAAM,QAAQ,OAAM;AAKnC,OAAO,MAAMC,mBAA+E;IAC1FC,MAAM,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE;QACzB,MAAMC,WAAWD,WAAW;YAC1BE,OAAOH,KAAKE,QAAQ;QACtB;QAEA,MAAME,UAAUJ,KAAKK,GAAG;QAExB,qBAAO,QAACD;YAAQE,WAAW,CAAC,KAAK,EAAEN,MAAMO,UAAU;sBAAGL;;;;;;IACxD;IACAM,UAAU,CAAC,EAAER,IAAI,EAAEC,UAAU,EAAEQ,MAAM,EAAE;QACrC,MAAMC,cAAcV,KAAKE,QAAQ,CAACS,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,KAAK;QAEjE,MAAMX,WAAWD,WAAW;YAC1BE,OAAOH,KAA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