@payloadcms/richtext-lexical 3.68.0-internal-debug.185cc5f → 3.68.0-internal-debug.dafc24d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/rscEntry.js +13 -5
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +29 -9
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -3
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +123 -43
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.scss +188 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +7 -3
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +117 -37
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.scss +90 -0
- package/dist/features/blocks/client/getBlockImageComponent.js +7 -3
- package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +7 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +7 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +87 -27
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +7 -3
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +12 -4
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.scss +6 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +18 -6
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.scss +29 -0
- package/dist/features/blocks/premade/CodeBlock/Component/index.scss +97 -0
- package/dist/features/converters/lexicalToJSX/Component/index.js +9 -5
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +7 -3
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +7 -3
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +6 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +6 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js +13 -5
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js +38 -14
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +18 -6
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js +31 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js +43 -15
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +31 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +8 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +13 -5
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/style.scss +12 -0
- package/dist/features/debug/testRecorder/client/plugin/index.js +61 -21
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.scss +53 -0
- package/dist/features/debug/treeView/client/plugin/index.js +7 -3
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.scss +80 -0
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +224 -72
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.scss +87 -0
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +31 -11
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.scss +11 -0
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +21 -9
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +25 -9
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.scss +233 -0
- package/dist/features/horizontalRule/client/plugin/index.scss +23 -0
- package/dist/features/indent/client/IndentPlugin.js +6 -2
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/link/client/plugins/clickableLink/index.js +6 -2
- package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +76 -24
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +7 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.scss +92 -0
- package/dist/features/lists/checklist/client/plugin/index.js +6 -2
- package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
- package/dist/features/lists/plugin/index.js +6 -2
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +13 -5
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +7 -3
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.scss +16 -0
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +13 -5
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +7 -3
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.scss +16 -0
- package/dist/features/relationship/client/components/RelationshipComponent.js +55 -19
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/components/index.scss +95 -0
- package/dist/features/relationship/client/drawer/index.js +18 -6
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +7 -3
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +7 -3
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/textState/feature.client.js +18 -6
- package/dist/features/textState/feature.client.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +71 -23
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.scss +113 -0
- package/dist/features/toolbars/inline/client/Toolbar/index.js +71 -23
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.scss +58 -0
- package/dist/features/toolbars/shared/ToolbarButton/index.js +7 -3
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.scss +46 -0
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +60 -20
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +36 -12
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.scss +129 -0
- package/dist/features/upload/client/component/index.js +91 -31
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/index.scss +191 -0
- package/dist/features/upload/client/component/pending/index.js +13 -5
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js +18 -6
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +12 -4
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +7 -3
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +36 -12
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.scss +47 -0
- package/dist/field/Diff/converters/relationship/index.js +36 -12
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.scss +73 -0
- package/dist/field/Diff/converters/unknown/index.js +30 -10
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.scss +40 -0
- package/dist/field/Diff/converters/upload/index.js +59 -19
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.scss +115 -0
- package/dist/field/Diff/index.js +7 -3
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Diff/index.scss +102 -0
- package/dist/field/Field.js +79 -27
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RenderLexical/index.js +36 -12
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/index.js +19 -7
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.scss +41 -0
- package/dist/field/rscEntry.js +7 -3
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/lexical/EditorPlugin.js +13 -5
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +162 -50
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalEditor.scss +54 -0
- package/dist/lexical/LexicalProvider.js +49 -17
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +7 -3
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.scss +13 -0
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +19 -7
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.scss +54 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +7 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +48 -16
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.scss +68 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +19 -7
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +35 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +31 -11
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.scss +80 -0
- package/dist/lexical/theme/EditorTheme.scss +357 -0
- package/dist/lexical/ui/ContentEditable.js +13 -5
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.scss +105 -0
- package/dist/lexical/ui/icons/AI/index.js +37 -13
- package/dist/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/lexical/ui/icons/Add/index.js +19 -7
- package/dist/lexical/ui/icons/Add/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignCenter/index.js +25 -9
- package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignJustify/index.js +25 -9
- package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignLeft/index.js +25 -9
- package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignRight/index.js +25 -9
- package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/lexical/ui/icons/Block/index.js +25 -9
- package/dist/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/lexical/ui/icons/Blockquote/index.js +13 -5
- package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/lexical/ui/icons/Bold/index.js +13 -5
- package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/lexical/ui/icons/Checklist/index.js +19 -7
- package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/lexical/ui/icons/Code/index.js +19 -7
- package/dist/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +13 -5
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.js +13 -5
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
- package/dist/lexical/ui/icons/H1/index.js +13 -5
- package/dist/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/lexical/ui/icons/H2/index.js +13 -5
- package/dist/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/lexical/ui/icons/H3/index.js +13 -5
- package/dist/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/lexical/ui/icons/H4/index.js +13 -5
- package/dist/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/lexical/ui/icons/H5/index.js +13 -5
- package/dist/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/lexical/ui/icons/H6/index.js +13 -5
- package/dist/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/lexical/ui/icons/HorizontalRule/index.js +13 -5
- package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentDecrease/index.js +31 -11
- package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentIncrease/index.js +31 -11
- package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/InlineBlocks/index.js +13 -5
- package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
- package/dist/lexical/ui/icons/Italic/index.js +13 -5
- package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/lexical/ui/icons/Link/index.js +13 -5
- package/dist/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/lexical/ui/icons/Meatballs/index.js +25 -9
- package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
- package/dist/lexical/ui/icons/OrderedList/index.js +37 -13
- package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Relationship/index.js +37 -13
- package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/lexical/ui/icons/Strikethrough/index.js +19 -7
- package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/lexical/ui/icons/Subscript/index.js +13 -5
- package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Superscript/index.js +13 -5
- package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Table/index.js +13 -5
- package/dist/lexical/ui/icons/Table/index.js.map +1 -1
- package/dist/lexical/ui/icons/Text/index.js +13 -5
- package/dist/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/lexical/ui/icons/TextState/index.js +7 -3
- package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
- package/dist/lexical/ui/icons/Underline/index.js +19 -7
- package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/lexical/ui/icons/UnorderedList/index.js +43 -15
- package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Upload/index.js +25 -9
- package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +19 -7
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +19 -7
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +7 -3
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +7 -3
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\nexport type ConvertLexicalToJSXArgs = {\n converters: JSXConverters\n data: SerializedEditorState\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n}\n\nexport function convertLexicalToJSX({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n}: ConvertLexicalToJSXArgs): React.ReactNode {\n if (hasText(data)) {\n return convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes: data?.root?.children,\n parent: data?.root,\n })\n }\n return <></>\n}\n\nexport function convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes,\n parent,\n}: {\n converters: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent: SerializedLexicalNodeWithParent\n}): React.ReactNode[] {\n const unknownConverter: JSXConverter<any> = converters.unknown as JSXConverter<any>\n\n const jsxArray: React.ReactNode[] = nodes.map((node, i) => {\n let converterForNode: JSXConverter<any> | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[(node as SerializedBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Blocks converter: found ${(node as SerializedBlockNode)?.fields?.blockType} block, but no converter is provided`,\n )\n }\n } else if (node.type === 'inlineBlock') {\n converterForNode =\n converters?.inlineBlocks?.[(node as SerializedInlineBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Inline Blocks converter: found ${(node as SerializedInlineBlockNode)?.fields?.blockType} inline block, but no converter is provided`,\n )\n }\n } else {\n converterForNode = converters[node.type] as JSXConverter<any>\n }\n\n try {\n if (!converterForNode && unknownConverter) {\n converterForNode = unknownConverter\n }\n\n let reactNode: React.ReactNode\n if (converterForNode) {\n const converted =\n typeof converterForNode === 'function'\n ? converterForNode({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n : converterForNode\n reactNode = converted\n } else {\n reactNode = <span key={i}>unknown node</span>\n }\n\n const style: React.CSSProperties = {}\n\n // Check if disableTextAlign is not true and does not include node type\n if (\n !disableTextAlign &&\n (!Array.isArray(disableTextAlign) || !disableTextAlign?.includes(node.type))\n ) {\n if ('format' in node && node.format) {\n switch (node.format) {\n case 'center':\n style.textAlign = 'center'\n break\n case 'end':\n style.textAlign = 'right'\n break\n case 'justify':\n style.textAlign = 'justify'\n break\n case 'left':\n //style.textAlign = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style.textAlign = 'right'\n break\n case 'start':\n style.textAlign = 'left'\n break\n }\n }\n }\n\n if (\n !disableIndent &&\n (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))\n ) {\n if ('indent' in node && node.indent && node.type !== 'listitem') {\n // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n style.paddingInlineStart = `${Number(node.indent) * 40}px`\n }\n }\n\n if (React.isValidElement(reactNode)) {\n // Inject style into reactNode\n if (style.textAlign || style.paddingInlineStart) {\n const newStyle = {\n ...style,\n // @ts-expect-error type better later\n ...(reactNode?.props?.style ?? {}),\n // reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here\n }\n\n return React.cloneElement(reactNode, {\n key: i,\n // @ts-expect-error type better later\n style: newStyle,\n })\n }\n return React.cloneElement(reactNode, {\n key: i,\n })\n }\n\n return reactNode\n } catch (error) {\n console.error('Error converting lexical node to JSX:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean)\n}\n"],"names":["React","hasText","convertLexicalToJSX","converters","data","disableIndent","disableTextAlign","convertLexicalNodesToJSX","nodes","root","children","parent","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","reactNode","converted","childIndex","nodesToJSX","args","span","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean"],"mappings":";AAAA,6BAA6B,GAG7B,OAAOA,WAAW,QAAO;AAKzB,SAASC,OAAO,QAAQ,kCAAiC;AASzD,OAAO,SAASC,oBAAoB,EAClCC,UAAU,EACVC,IAAI,EACJC,aAAa,EACbC,gBAAgB,EACQ;IACxB,IAAIL,QAAQG,OAAO;QACjB,OAAOG,yBAAyB;YAC9BJ;YACAE;YACAC;YACAE,OAAOJ,MAAMK,MAAMC;YACnBC,QAAQP,MAAMK;QAChB;IACF;IACA,qBAAO;AACT;AAEA,OAAO,SAASF,yBAAyB,EACvCJ,UAAU,EACVE,aAAa,EACbC,gBAAgB,EAChBE,KAAK,EACLG,MAAM,EAOP;IACC,MAAMC,mBAAsCT,WAAWU,OAAO;IAE9D,MAAMC,WAA8BN,MAAMO,GAAG,CAAC,CAACC,MAAMC;QACnD,IAAIC;QACJ,IAAIF,KAAKG,IAAI,KAAK,SAAS;YACzBD,mBAAmBf,YAAYiB,QAAQ,CAAEJ,MAA8BK,QAAQC,UAAU;YACzF,IAAI,CAACJ,oBAAoB,CAACN,kBAAkB;gBAC1CW,QAAQC,KAAK,CACX,CAAC,kDAAkD,EAAGR,MAA8BK,QAAQC,UAAU,oCAAoC,CAAC;YAE/I;QACF,OAAO,IAAIN,KAAKG,IAAI,KAAK,eAAe;YACtCD,mBACEf,YAAYsB,cAAc,CAAET,MAAoCK,QAAQC,UAAU;YACpF,IAAI,CAACJ,oBAAoB,CAACN,kBAAkB;gBAC1CW,QAAQC,KAAK,CACX,CAAC,yDAAyD,EAAGR,MAAoCK,QAAQC,UAAU,2CAA2C,CAAC;YAEnK;QACF,OAAO;YACLJ,mBAAmBf,UAAU,CAACa,KAAKG,IAAI,CAAC;QAC1C;QAEA,IAAI;YACF,IAAI,CAACD,oBAAoBN,kBAAkB;gBACzCM,mBAAmBN;YACrB;YAEA,IAAIc;YACJ,IAAIR,kBAAkB;gBACpB,MAAMS,YACJ,OAAOT,qBAAqB,aACxBA,iBAAiB;oBACfU,YAAYX;oBACZd;oBACAa;oBACAa,YAAY,CAACC;wBACX,OAAOvB,yBAAyB;4BAC9BJ,YAAY2B,KAAK3B,UAAU,IAAIA;4BAC/BE,eAAeyB,KAAKzB,aAAa,IAAIA;4BACrCC,kBAAkBwB,KAAKxB,gBAAgB,IAAIA;4BAC3CE,OAAOsB,KAAKtB,KAAK;4BACjBG,QAAQmB,KAAKnB,MAAM,IAAI;gCACrB,GAAGK,IAAI;gCACPL;4BACF;wBACF;oBACF;oBACAA;gBACF,KACAO;gBACNQ,YAAYC;YACd,OAAO;gBACLD,0BAAY,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\nexport type ConvertLexicalToJSXArgs = {\n converters: JSXConverters\n data: SerializedEditorState\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n}\n\nexport function convertLexicalToJSX({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n}: ConvertLexicalToJSXArgs): React.ReactNode {\n if (hasText(data)) {\n return convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes: data?.root?.children,\n parent: data?.root,\n })\n }\n return <></>\n}\n\nexport function convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes,\n parent,\n}: {\n converters: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent: SerializedLexicalNodeWithParent\n}): React.ReactNode[] {\n const unknownConverter: JSXConverter<any> = converters.unknown as JSXConverter<any>\n\n const jsxArray: React.ReactNode[] = nodes.map((node, i) => {\n let converterForNode: JSXConverter<any> | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[(node as SerializedBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Blocks converter: found ${(node as SerializedBlockNode)?.fields?.blockType} block, but no converter is provided`,\n )\n }\n } else if (node.type === 'inlineBlock') {\n converterForNode =\n converters?.inlineBlocks?.[(node as SerializedInlineBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Inline Blocks converter: found ${(node as SerializedInlineBlockNode)?.fields?.blockType} inline block, but no converter is provided`,\n )\n }\n } else {\n converterForNode = converters[node.type] as JSXConverter<any>\n }\n\n try {\n if (!converterForNode && unknownConverter) {\n converterForNode = unknownConverter\n }\n\n let reactNode: React.ReactNode\n if (converterForNode) {\n const converted =\n typeof converterForNode === 'function'\n ? converterForNode({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n : converterForNode\n reactNode = converted\n } else {\n reactNode = <span key={i}>unknown node</span>\n }\n\n const style: React.CSSProperties = {}\n\n // Check if disableTextAlign is not true and does not include node type\n if (\n !disableTextAlign &&\n (!Array.isArray(disableTextAlign) || !disableTextAlign?.includes(node.type))\n ) {\n if ('format' in node && node.format) {\n switch (node.format) {\n case 'center':\n style.textAlign = 'center'\n break\n case 'end':\n style.textAlign = 'right'\n break\n case 'justify':\n style.textAlign = 'justify'\n break\n case 'left':\n //style.textAlign = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style.textAlign = 'right'\n break\n case 'start':\n style.textAlign = 'left'\n break\n }\n }\n }\n\n if (\n !disableIndent &&\n (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))\n ) {\n if ('indent' in node && node.indent && node.type !== 'listitem') {\n // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n style.paddingInlineStart = `${Number(node.indent) * 40}px`\n }\n }\n\n if (React.isValidElement(reactNode)) {\n // Inject style into reactNode\n if (style.textAlign || style.paddingInlineStart) {\n const newStyle = {\n ...style,\n // @ts-expect-error type better later\n ...(reactNode?.props?.style ?? {}),\n // reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here\n }\n\n return React.cloneElement(reactNode, {\n key: i,\n // @ts-expect-error type better later\n style: newStyle,\n })\n }\n return React.cloneElement(reactNode, {\n key: i,\n })\n }\n\n return reactNode\n } catch (error) {\n console.error('Error converting lexical node to JSX:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean)\n}\n"],"names":["React","hasText","convertLexicalToJSX","converters","data","disableIndent","disableTextAlign","convertLexicalNodesToJSX","nodes","root","children","parent","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","reactNode","converted","childIndex","nodesToJSX","args","span","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean"],"mappings":";AAAA,6BAA6B,GAG7B,OAAOA,WAAW,QAAO;AAKzB,SAASC,OAAO,QAAQ,kCAAiC;AASzD,OAAO,SAASC,oBAAoB,EAClCC,UAAU,EACVC,IAAI,EACJC,aAAa,EACbC,gBAAgB,EACQ;IACxB,IAAIL,QAAQG,OAAO;QACjB,OAAOG,yBAAyB;YAC9BJ;YACAE;YACAC;YACAE,OAAOJ,MAAMK,MAAMC;YACnBC,QAAQP,MAAMK;QAChB;IACF;IACA,qBAAO;AACT;AAEA,OAAO,SAASF,yBAAyB,EACvCJ,UAAU,EACVE,aAAa,EACbC,gBAAgB,EAChBE,KAAK,EACLG,MAAM,EAOP;IACC,MAAMC,mBAAsCT,WAAWU,OAAO;IAE9D,MAAMC,WAA8BN,MAAMO,GAAG,CAAC,CAACC,MAAMC;QACnD,IAAIC;QACJ,IAAIF,KAAKG,IAAI,KAAK,SAAS;YACzBD,mBAAmBf,YAAYiB,QAAQ,CAAEJ,MAA8BK,QAAQC,UAAU;YACzF,IAAI,CAACJ,oBAAoB,CAACN,kBAAkB;gBAC1CW,QAAQC,KAAK,CACX,CAAC,kDAAkD,EAAGR,MAA8BK,QAAQC,UAAU,oCAAoC,CAAC;YAE/I;QACF,OAAO,IAAIN,KAAKG,IAAI,KAAK,eAAe;YACtCD,mBACEf,YAAYsB,cAAc,CAAET,MAAoCK,QAAQC,UAAU;YACpF,IAAI,CAACJ,oBAAoB,CAACN,kBAAkB;gBAC1CW,QAAQC,KAAK,CACX,CAAC,yDAAyD,EAAGR,MAAoCK,QAAQC,UAAU,2CAA2C,CAAC;YAEnK;QACF,OAAO;YACLJ,mBAAmBf,UAAU,CAACa,KAAKG,IAAI,CAAC;QAC1C;QAEA,IAAI;YACF,IAAI,CAACD,oBAAoBN,kBAA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BACzE,wDAAwD;oBACxD,mBAAmB;oBACnB,6EAA6E;oBAC7Ea,MAAMO,kBAAkB,GAAG,GAAGC,OAAOxB,KAAKsB,MAAM,IAAI,GAAG,EAAE,CAAC;gBAC5D;YACF;YAEA,kBAAItC,MAAMyC,cAAc,CAACf,YAAY;gBACnC,8BAA8B;gBAC9B,IAAIM,MAAMK,SAAS,IAAIL,MAAMO,kBAAkB,EAAE;oBAC/C,MAAMG,WAAW;wBACf,GAAGV,KAAK;wBACR,qCAAqC;wBACrC,GAAIN,WAAWiB,OAAOX,SAAS,CAAC,CAAC;oBAEnC;oBADE,oHAAoH;oBAGtH,qBAAOhC,MAAM4C,YAAY,CAAClB,WAAW;wBACnCmB,KAAK5B;wBACL,qCAAqC;wBACrCe,OAAOU;oBACT;gBACF;gBACA,qBAAO1C,MAAM4C,YAAY,CAAClB,WAAW;oBACnCmB,KAAK5B;gBACP;YACF;YAEA,OAAOS;QACT,EAAE,OAAOF,OAAO;YACdD,QAAQC,KAAK,CAAC,yCAAyCA,OAAO,SAASR;YACvE,OAAO;QACT;IACF;IAEA,OAAOF,SAASgC,MAAM,CAACC;AACzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
// eslint-disable-next-line payload/no-imports-from-exports-dir
|
|
@@ -15,13 +15,21 @@ export function RichTextPlugin() {
|
|
|
15
15
|
}, [
|
|
16
16
|
editor
|
|
17
17
|
]);
|
|
18
|
-
return /*#__PURE__*/
|
|
18
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
19
19
|
className: "debug-jsx-converter",
|
|
20
|
-
children: /*#__PURE__*/
|
|
20
|
+
children: /*#__PURE__*/ _jsxDEV(RichText, {
|
|
21
21
|
converters: defaultJSXConverters,
|
|
22
22
|
data: editorState
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
}, void 0, false, {
|
|
24
|
+
fileName: "src/features/debug/jsxConverter/client/plugin/index.tsx",
|
|
25
|
+
lineNumber: 22,
|
|
26
|
+
columnNumber: 7
|
|
27
|
+
}, this)
|
|
28
|
+
}, void 0, false, {
|
|
29
|
+
fileName: "src/features/debug/jsxConverter/client/plugin/index.tsx",
|
|
30
|
+
lineNumber: 21,
|
|
31
|
+
columnNumber: 5
|
|
32
|
+
}, this);
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useEffect, useState } from 'react'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { defaultJSXConverters, RichText } from '../../../../../exports/react/index.js'\nimport './style.scss'\n\nexport function RichTextPlugin() {\n const [editor] = useLexicalComposerContext()\n const [editorState, setEditorState] = useState(editor.getEditorState().toJSON())\n\n useEffect(() => {\n return editor.registerUpdateListener(({ editorState }) => {\n setEditorState(editorState.toJSON())\n })\n }, [editor])\n\n return (\n <div className=\"debug-jsx-converter\">\n <RichText converters={defaultJSXConverters} data={editorState} />\n </div>\n )\n}\n"],"names":["useLexicalComposerContext","useEffect","useState","defaultJSXConverters","RichText","RichTextPlugin","editor","editorState","setEditorState","getEditorState","toJSON","registerUpdateListener","div","className","converters","data"],"mappings":"AAAA;;AAEA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE3C,+DAA+D;AAC/D,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ,wCAAuC;AACtF,OAAO,eAAc;AAErB,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGN;IACjB,MAAM,CAACO,aAAaC,eAAe,GAAGN,SAASI,OAAOG,cAAc,GAAGC,MAAM;IAE7ET,UAAU;QACR,OAAOK,OAAOK,sBAAsB,CAAC,CAAC,EAAEJ,WAAW,EAAE;YACnDC,eAAeD,YAAYG,MAAM;QACnC;IACF,GAAG;QAACJ;KAAO;IAEX,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useEffect, useState } from 'react'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { defaultJSXConverters, RichText } from '../../../../../exports/react/index.js'\nimport './style.scss'\n\nexport function RichTextPlugin() {\n const [editor] = useLexicalComposerContext()\n const [editorState, setEditorState] = useState(editor.getEditorState().toJSON())\n\n useEffect(() => {\n return editor.registerUpdateListener(({ editorState }) => {\n setEditorState(editorState.toJSON())\n })\n }, [editor])\n\n return (\n <div className=\"debug-jsx-converter\">\n <RichText converters={defaultJSXConverters} data={editorState} />\n </div>\n )\n}\n"],"names":["useLexicalComposerContext","useEffect","useState","defaultJSXConverters","RichText","RichTextPlugin","editor","editorState","setEditorState","getEditorState","toJSON","registerUpdateListener","div","className","converters","data"],"mappings":"AAAA;;AAEA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE3C,+DAA+D;AAC/D,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ,wCAAuC;AACtF,OAAO,eAAc;AAErB,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGN;IACjB,MAAM,CAACO,aAAaC,eAAe,GAAGN,SAASI,OAAOG,cAAc,GAAGC,MAAM;IAE7ET,UAAU;QACR,OAAOK,OAAOK,sBAAsB,CAAC,CAAC,EAAEJ,WAAW,EAAE;YACnDC,eAAeD,YAAYG,MAAM;QACnC;IACF,GAAG;QAACJ;KAAO;IAEX,qBACE,QAACM;QAAIC,WAAU;kBACb,cAAA,QAACT;YAASU,YAAYX;YAAsBY,MAAMR;;;;;;;;;;;AAGxD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.debug-jsx-converter {
|
|
2
|
+
// this is to match the editor component, and be able to compare aligned styles
|
|
3
|
+
padding-left: 36px;
|
|
4
|
+
|
|
5
|
+
// We revert to the browser defaults (user-agent), because we want to see
|
|
6
|
+
// the indentations look good without the need for CSS.
|
|
7
|
+
ul,
|
|
8
|
+
ol {
|
|
9
|
+
padding-left: revert;
|
|
10
|
+
margin: revert;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
4
|
import { $createParagraphNode, $createTextNode, $getRoot, getDOMSelection } from 'lexical';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -389,7 +389,7 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
389
389
|
}, [
|
|
390
390
|
generateTestContent
|
|
391
391
|
]);
|
|
392
|
-
const button = /*#__PURE__*/
|
|
392
|
+
const button = /*#__PURE__*/ _jsxDEV("button", {
|
|
393
393
|
className: `editor-dev-button ${isRecording ? 'active' : ''}`,
|
|
394
394
|
id: "test-recorder-button",
|
|
395
395
|
onClick: (e)=>{
|
|
@@ -399,14 +399,18 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
399
399
|
title: isRecording ? 'Disable test recorder' : 'Enable test recorder',
|
|
400
400
|
type: "button",
|
|
401
401
|
children: isRecording ? 'Disable test recorder' : 'Enable test recorder'
|
|
402
|
-
}
|
|
403
|
-
|
|
402
|
+
}, void 0, false, {
|
|
403
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
404
|
+
lineNumber: 386,
|
|
405
|
+
columnNumber: 5
|
|
406
|
+
}, this);
|
|
407
|
+
const output = isRecording ? /*#__PURE__*/ _jsxDEV("div", {
|
|
404
408
|
className: "test-recorder-output",
|
|
405
409
|
children: [
|
|
406
|
-
/*#__PURE__*/
|
|
410
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
407
411
|
className: "test-recorder-toolbar",
|
|
408
412
|
children: [
|
|
409
|
-
/*#__PURE__*/
|
|
413
|
+
/*#__PURE__*/ _jsxDEV("button", {
|
|
410
414
|
className: "test-recorder-button",
|
|
411
415
|
id: "test-recorder-button-snapshot",
|
|
412
416
|
onClick: (e)=>{
|
|
@@ -416,8 +420,12 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
416
420
|
title: "Insert snapshot",
|
|
417
421
|
type: "button",
|
|
418
422
|
children: "Insert Snapshot"
|
|
419
|
-
}
|
|
420
|
-
|
|
423
|
+
}, void 0, false, {
|
|
424
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
425
|
+
lineNumber: 402,
|
|
426
|
+
columnNumber: 9
|
|
427
|
+
}, this),
|
|
428
|
+
/*#__PURE__*/ _jsxDEV("button", {
|
|
421
429
|
className: "test-recorder-button",
|
|
422
430
|
id: "test-recorder-button-copy",
|
|
423
431
|
onClick: (e)=>{
|
|
@@ -427,8 +435,12 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
427
435
|
title: "Copy to clipboard",
|
|
428
436
|
type: "button",
|
|
429
437
|
children: "Copy"
|
|
430
|
-
}
|
|
431
|
-
|
|
438
|
+
}, void 0, false, {
|
|
439
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
440
|
+
lineNumber: 414,
|
|
441
|
+
columnNumber: 9
|
|
442
|
+
}, this),
|
|
443
|
+
/*#__PURE__*/ _jsxDEV("button", {
|
|
432
444
|
className: "test-recorder-button",
|
|
433
445
|
id: "test-recorder-button-download",
|
|
434
446
|
onClick: (e)=>{
|
|
@@ -438,16 +450,32 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
438
450
|
title: "Download as a file",
|
|
439
451
|
type: "button",
|
|
440
452
|
children: "Download"
|
|
441
|
-
}
|
|
453
|
+
}, void 0, false, {
|
|
454
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
455
|
+
lineNumber: 426,
|
|
456
|
+
columnNumber: 9
|
|
457
|
+
}, this)
|
|
442
458
|
]
|
|
443
|
-
}
|
|
444
|
-
|
|
459
|
+
}, void 0, true, {
|
|
460
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
461
|
+
lineNumber: 401,
|
|
462
|
+
columnNumber: 7
|
|
463
|
+
}, this),
|
|
464
|
+
/*#__PURE__*/ _jsxDEV("pre", {
|
|
445
465
|
id: "test-recorder",
|
|
446
466
|
ref: preRef,
|
|
447
467
|
children: templatedTest
|
|
448
|
-
}
|
|
468
|
+
}, void 0, false, {
|
|
469
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
470
|
+
lineNumber: 439,
|
|
471
|
+
columnNumber: 7
|
|
472
|
+
}, this)
|
|
449
473
|
]
|
|
450
|
-
}
|
|
474
|
+
}, void 0, true, {
|
|
475
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
476
|
+
lineNumber: 400,
|
|
477
|
+
columnNumber: 5
|
|
478
|
+
}, this) : null;
|
|
451
479
|
return [
|
|
452
480
|
button,
|
|
453
481
|
output
|
|
@@ -456,18 +484,30 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
456
484
|
export const TestRecorderPlugin = ()=>{
|
|
457
485
|
const [editor] = useLexicalComposerContext();
|
|
458
486
|
const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor);
|
|
459
|
-
return /*#__PURE__*/
|
|
487
|
+
return /*#__PURE__*/ _jsxDEV(React.Fragment, {
|
|
460
488
|
children: [
|
|
461
|
-
/*#__PURE__*/
|
|
489
|
+
/*#__PURE__*/ _jsxDEV("p", {
|
|
462
490
|
children: "HI"
|
|
463
|
-
}
|
|
491
|
+
}, void 0, false, {
|
|
492
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
493
|
+
lineNumber: 453,
|
|
494
|
+
columnNumber: 7
|
|
495
|
+
}, this),
|
|
464
496
|
testRecorderButton,
|
|
465
497
|
testRecorderOutput,
|
|
466
|
-
/*#__PURE__*/
|
|
498
|
+
/*#__PURE__*/ _jsxDEV("p", {
|
|
467
499
|
children: "DONE"
|
|
468
|
-
}
|
|
500
|
+
}, void 0, false, {
|
|
501
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
502
|
+
lineNumber: 456,
|
|
503
|
+
columnNumber: 7
|
|
504
|
+
}, this)
|
|
469
505
|
]
|
|
470
|
-
}
|
|
506
|
+
}, void 0, true, {
|
|
507
|
+
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
508
|
+
lineNumber: 452,
|
|
509
|
+
columnNumber: 5
|
|
510
|
+
}, this);
|
|
471
511
|
};
|
|
472
512
|
|
|
473
513
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/debug/testRecorder/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, $createTextNode, $getRoot, getDOMSelection } from 'lexical'\nimport * as React from 'react'\nimport { type JSX, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { IS_APPLE } from '../../../../../lexical/utils/environment.js'\nimport './index.scss'\n\nconst copy = (text: null | string) => {\n const textArea = document.createElement('textarea')\n textArea.value = text || ''\n textArea.style.position = 'absolute'\n textArea.style.opacity = '0'\n document.body?.appendChild(textArea)\n textArea.focus()\n textArea.select()\n try {\n const result = document.execCommand('copy')\n // eslint-disable-next-line no-console\n console.log(result)\n } catch (error) {\n console.error(error)\n }\n document.body?.removeChild(textArea)\n}\n\nconst download = (filename: string, text: null | string) => {\n const a = document.createElement('a')\n a.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text || ''))\n a.setAttribute('download', filename)\n a.style.display = 'none'\n document.body?.appendChild(a)\n a.click()\n document.body?.removeChild(a)\n}\n\nconst formatStep = (step: Step) => {\n const formatOneStep = (name: string, value: Step['value']) => {\n switch (name) {\n case 'click': {\n return ` await page.mouse.click(${value.x}, ${value.y});`\n }\n case 'keydown': {\n return ` await page.keyboard.keydown('${value}');`\n }\n case 'keyup': {\n return ` await page.keyboard.keyup('${value}');`\n }\n case 'press': {\n return ` await page.keyboard.press('${value}');`\n }\n case 'selectAll': {\n return ` await selectAll(page);`\n }\n case 'snapshot': {\n return ` await assertHTMLSnapshot(page);\n await assertSelection(page, {\n anchorPath: [${value.anchorPath.toString()}],\n anchorOffset: ${value.anchorOffset},\n focusPath: [${value.focusPath.toString()}],\n focusOffset: ${value.focusOffset},\n });\n`\n }\n case 'type': {\n return ` await page.keyboard.type('${value}');`\n }\n default:\n return ``\n }\n }\n const formattedStep = formatOneStep(step.name, step.value)\n switch (step.count) {\n case 1:\n return formattedStep\n case 2:\n return [formattedStep, formattedStep].join(`\\n`)\n default:\n return ` await repeat(${step.count}, async () => {\n ${formattedStep}\n );`\n }\n}\n\nexport function isSelectAll(event: KeyboardEvent): boolean {\n return event.key.toLowerCase() === 'a' && (IS_APPLE ? event.metaKey : event.ctrlKey)\n}\n\n// stolen from LexicalSelection-test\nfunction sanitizeSelection(selection: Selection) {\n const { anchorNode, focusNode } = selection\n let { anchorOffset, focusOffset } = selection\n if (anchorOffset !== 0) {\n anchorOffset--\n }\n if (focusOffset !== 0) {\n focusOffset--\n }\n return { anchorNode, anchorOffset, focusNode, focusOffset }\n}\n\nfunction getPathFromNodeToEditor(node: Node, rootElement: HTMLElement | null) {\n let currentNode: Node | null | undefined = node\n const path: number[] = []\n while (currentNode !== rootElement) {\n if (currentNode !== null && currentNode !== undefined) {\n path.unshift(\n Array.from(currentNode?.parentNode?.childNodes ?? []).indexOf(currentNode as ChildNode),\n )\n }\n currentNode = currentNode?.parentNode\n }\n return path\n}\n\nconst keyPresses = new Set([\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'Backspace',\n 'Delete',\n 'Enter',\n 'Escape',\n])\n\ntype Step = {\n count: number\n name: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any\n}\n\ntype Steps = Step[]\n\nfunction useTestRecorder(editor: LexicalEditor): [JSX.Element, JSX.Element | null] {\n const [steps, setSteps] = useState<Steps>([])\n const [isRecording, setIsRecording] = useState(false)\n const [, setCurrentInnerHTML] = useState('')\n const [templatedTest, setTemplatedTest] = useState('')\n const previousSelectionRef = useRef<BaseSelection | null>(null)\n const skipNextSelectionChangeRef = useRef(false)\n const preRef = useRef<HTMLPreElement>(null)\n\n const getCurrentEditor = useCallback(() => {\n return editor\n }, [editor])\n\n const generateTestContent = useCallback(() => {\n const rootElement = editor.getRootElement()\n const browserSelection = getDOMSelection(editor._window)\n\n if (\n rootElement == null ||\n browserSelection == null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null ||\n !rootElement.contains(browserSelection.anchorNode) ||\n !rootElement.contains(browserSelection.focusNode)\n ) {\n return null\n }\n\n return `\nimport {\n initializeE2E,\n assertHTMLSnapshot,\n assertSelection,\n repeat,\n} from '../utils';\nimport {selectAll} from '../keyboardShortcuts';\nimport { RangeSelection } from 'lexical';\nimport { NodeSelection } from 'lexical';\n\ndescribe('Test case', () => {\n initializeE2E((e2e) => {\n it('Should pass this test', async () => {\n const {page} = e2e;\n\n await page.focus('div[contenteditable=\"true\"]');\n${steps.map(formatStep).join(`\\n`)}\n });\n});\n `\n }, [editor, steps])\n\n // just a wrapper around inserting new actions so that we can\n // coalesce some actions like insertText/moveNativeSelection\n const pushStep = useCallback(\n (name: string, value: Step['value']) => {\n setSteps((currentSteps) => {\n // trying to group steps\n const currentIndex = steps.length - 1\n const lastStep = steps[currentIndex]\n if (lastStep) {\n if (lastStep.name === name) {\n if (name === 'type') {\n // for typing events we just append the text\n return [\n ...steps.slice(0, currentIndex),\n { ...lastStep, value: lastStep.value + value },\n ]\n } else {\n // for other events we bump the counter if their values are the same\n if (lastStep.value === value) {\n return [...steps.slice(0, currentIndex), { ...lastStep, count: lastStep.count + 1 }]\n }\n }\n }\n }\n // could not group, just append a new one\n return [...currentSteps, { name, count: 1, value }]\n })\n },\n [steps, setSteps],\n )\n\n useLayoutEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (isSelectAll(event)) {\n pushStep('selectAll', '')\n } else if (keyPresses.has(key)) {\n pushStep('press', event.key)\n } else if ([...key].length > 1) {\n pushStep('keydown', event.key)\n } else {\n pushStep('type', event.key)\n }\n }\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (!keyPresses.has(key) && [...key].length > 1) {\n pushStep('keyup', event.key)\n }\n }\n\n return editor.registerRootListener(\n (rootElement: HTMLElement | null, prevRootElement: HTMLElement | null) => {\n if (prevRootElement !== null) {\n prevRootElement.removeEventListener('keydown', onKeyDown)\n prevRootElement.removeEventListener('keyup', onKeyUp)\n }\n if (rootElement !== null) {\n rootElement.addEventListener('keydown', onKeyDown)\n rootElement.addEventListener('keyup', onKeyUp)\n }\n },\n )\n }, [editor, isRecording, pushStep])\n\n useLayoutEffect(() => {\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }, [generateTestContent])\n\n useEffect(() => {\n if (steps) {\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }\n }, [generateTestContent, steps])\n\n useEffect(() => {\n const removeUpdateListener = editor.registerUpdateListener(\n ({ dirtyElements, dirtyLeaves, editorState }) => {\n if (!isRecording) {\n return\n }\n const currentSelection = editorState._selection\n const previousSelection = previousSelectionRef.current\n const skipNextSelectionChange = skipNextSelectionChangeRef.current\n if (previousSelection !== currentSelection) {\n if (dirtyLeaves.size === 0 && dirtyElements.size === 0 && !skipNextSelectionChange) {\n const browserSelection = getDOMSelection(editor._window)\n if (\n browserSelection &&\n (browserSelection.anchorNode == null || browserSelection.focusNode == null)\n ) {\n return\n }\n }\n previousSelectionRef.current = currentSelection\n }\n skipNextSelectionChangeRef.current = false\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n },\n )\n return removeUpdateListener\n }, [editor, generateTestContent, isRecording, pushStep])\n\n // save innerHTML\n useEffect(() => {\n if (!isRecording) {\n return\n }\n const removeUpdateListener = editor.registerUpdateListener(() => {\n const rootElement = editor.getRootElement()\n if (rootElement !== null) {\n setCurrentInnerHTML(rootElement?.innerHTML)\n }\n })\n return removeUpdateListener\n }, [editor, isRecording])\n\n // clear editor and start recording\n const toggleEditorSelection = useCallback(\n (currentEditor: LexicalEditor) => {\n if (!isRecording) {\n currentEditor.update(() => {\n const root = $getRoot()\n root.clear()\n const text = $createTextNode()\n root.append($createParagraphNode().append(text))\n text.select()\n })\n setSteps([])\n }\n setIsRecording((currentIsRecording) => !currentIsRecording)\n },\n [isRecording],\n )\n\n const onSnapshotClick = useCallback(() => {\n if (!isRecording) {\n return\n }\n const browserSelection = getDOMSelection(editor._window)\n if (\n browserSelection === null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null\n ) {\n return\n }\n const { anchorNode, anchorOffset, focusNode, focusOffset } = sanitizeSelection(browserSelection)\n const rootElement = getCurrentEditor().getRootElement()\n let anchorPath\n if (anchorNode !== null) {\n anchorPath = getPathFromNodeToEditor(anchorNode, rootElement)\n }\n let focusPath\n if (focusNode !== null) {\n focusPath = getPathFromNodeToEditor(focusNode, rootElement)\n }\n pushStep('snapshot', {\n anchorNode,\n anchorOffset,\n anchorPath,\n focusNode,\n focusOffset,\n focusPath,\n })\n }, [pushStep, isRecording, getCurrentEditor])\n\n const onCopyClick = useCallback(() => {\n copy(generateTestContent())\n }, [generateTestContent])\n\n const onDownloadClick = useCallback(() => {\n download('test.js', generateTestContent())\n }, [generateTestContent])\n\n const button = (\n <button\n className={`editor-dev-button ${isRecording ? 'active' : ''}`}\n id=\"test-recorder-button\"\n onClick={(e) => {\n toggleEditorSelection(getCurrentEditor())\n e.preventDefault()\n }}\n title={isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n type=\"button\"\n >\n {isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n </button>\n )\n const output = isRecording ? (\n <div className=\"test-recorder-output\">\n <div className=\"test-recorder-toolbar\">\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-snapshot\"\n onClick={(e) => {\n onSnapshotClick()\n e.preventDefault()\n }}\n title=\"Insert snapshot\"\n type=\"button\"\n >\n Insert Snapshot\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-copy\"\n onClick={(e) => {\n onCopyClick()\n e.preventDefault()\n }}\n title=\"Copy to clipboard\"\n type=\"button\"\n >\n Copy\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-download\"\n onClick={(e) => {\n onDownloadClick()\n e.preventDefault()\n }}\n title=\"Download as a file\"\n type=\"button\"\n >\n Download\n </button>\n </div>\n <pre id=\"test-recorder\" ref={preRef}>\n {templatedTest}\n </pre>\n </div>\n ) : null\n\n return [button, output]\n}\nexport const TestRecorderPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor)\n\n return (\n <React.Fragment>\n <p>HI</p>\n {testRecorderButton}\n {testRecorderOutput}\n <p>DONE</p>\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","$createParagraphNode","$createTextNode","$getRoot","getDOMSelection","React","useCallback","useEffect","useLayoutEffect","useRef","useState","IS_APPLE","copy","text","textArea","document","createElement","value","style","position","opacity","body","appendChild","focus","select","result","execCommand","console","log","error","removeChild","download","filename","a","setAttribute","encodeURIComponent","display","click","formatStep","step","formatOneStep","name","x","y","anchorPath","toString","anchorOffset","focusPath","focusOffset","formattedStep","count","join","isSelectAll","event","key","toLowerCase","metaKey","ctrlKey","sanitizeSelection","selection","anchorNode","focusNode","getPathFromNodeToEditor","node","rootElement","currentNode","path","undefined","unshift","Array","from","parentNode","childNodes","indexOf","keyPresses","Set","useTestRecorder","editor","steps","setSteps","isRecording","setIsRecording","setCurrentInnerHTML","templatedTest","setTemplatedTest","previousSelectionRef","skipNextSelectionChangeRef","preRef","getCurrentEditor","generateTestContent","getRootElement","browserSelection","_window","contains","map","pushStep","currentSteps","currentIndex","length","lastStep","slice","onKeyDown","has","onKeyUp","registerRootListener","prevRootElement","removeEventListener","addEventListener","current","scrollTo","scrollHeight","testContent","removeUpdateListener","registerUpdateListener","dirtyElements","dirtyLeaves","editorState","currentSelection","_selection","previousSelection","skipNextSelectionChange","size","innerHTML","toggleEditorSelection","currentEditor","update","root","clear","append","currentIsRecording","onSnapshotClick","onCopyClick","onDownloadClick","button","className","id","onClick","e","preventDefault","title","type","output","div","pre","ref","TestRecorderPlugin","testRecorderButton","testRecorderOutput","Fragment","p"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,UAAS;AAC1F,YAAYC,WAAW,QAAO;AAC9B,SAAmBC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAI3F,SAASC,QAAQ,QAAQ,8CAA6C;AACtE,OAAO,eAAc;AAErB,MAAMC,OAAO,CAACC;IACZ,MAAMC,WAAWC,SAASC,aAAa,CAAC;IACxCF,SAASG,KAAK,GAAGJ,QAAQ;IACzBC,SAASI,KAAK,CAACC,QAAQ,GAAG;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oBC,mBAAmB,GAAGvE,gBAAgBC;IAEjE,qBACE,MAACxE,MAAM+I,QAAQ;;0BACb,KAACC;0BAAE;;YACFH;YACAC;0BACD,KAACE;0BAAE;;;;AAGT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/debug/testRecorder/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, $createTextNode, $getRoot, getDOMSelection } from 'lexical'\nimport * as React from 'react'\nimport { type JSX, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { IS_APPLE } from '../../../../../lexical/utils/environment.js'\nimport './index.scss'\n\nconst copy = (text: null | string) => {\n const textArea = document.createElement('textarea')\n textArea.value = text || ''\n textArea.style.position = 'absolute'\n textArea.style.opacity = '0'\n document.body?.appendChild(textArea)\n textArea.focus()\n textArea.select()\n try {\n const result = document.execCommand('copy')\n // eslint-disable-next-line no-console\n console.log(result)\n } catch (error) {\n console.error(error)\n }\n document.body?.removeChild(textArea)\n}\n\nconst download = (filename: string, text: null | string) => {\n const a = document.createElement('a')\n a.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text || ''))\n a.setAttribute('download', filename)\n a.style.display = 'none'\n document.body?.appendChild(a)\n a.click()\n document.body?.removeChild(a)\n}\n\nconst formatStep = (step: Step) => {\n const formatOneStep = (name: string, value: Step['value']) => {\n switch (name) {\n case 'click': {\n return ` await page.mouse.click(${value.x}, ${value.y});`\n }\n case 'keydown': {\n return ` await page.keyboard.keydown('${value}');`\n }\n case 'keyup': {\n return ` await page.keyboard.keyup('${value}');`\n }\n case 'press': {\n return ` await page.keyboard.press('${value}');`\n }\n case 'selectAll': {\n return ` await selectAll(page);`\n }\n case 'snapshot': {\n return ` await assertHTMLSnapshot(page);\n await assertSelection(page, {\n anchorPath: [${value.anchorPath.toString()}],\n anchorOffset: ${value.anchorOffset},\n focusPath: [${value.focusPath.toString()}],\n focusOffset: ${value.focusOffset},\n });\n`\n }\n case 'type': {\n return ` await page.keyboard.type('${value}');`\n }\n default:\n return ``\n }\n }\n const formattedStep = formatOneStep(step.name, step.value)\n switch (step.count) {\n case 1:\n return formattedStep\n case 2:\n return [formattedStep, formattedStep].join(`\\n`)\n default:\n return ` await repeat(${step.count}, async () => {\n ${formattedStep}\n );`\n }\n}\n\nexport function isSelectAll(event: KeyboardEvent): boolean {\n return event.key.toLowerCase() === 'a' && (IS_APPLE ? event.metaKey : event.ctrlKey)\n}\n\n// stolen from LexicalSelection-test\nfunction sanitizeSelection(selection: Selection) {\n const { anchorNode, focusNode } = selection\n let { anchorOffset, focusOffset } = selection\n if (anchorOffset !== 0) {\n anchorOffset--\n }\n if (focusOffset !== 0) {\n focusOffset--\n }\n return { anchorNode, anchorOffset, focusNode, focusOffset }\n}\n\nfunction getPathFromNodeToEditor(node: Node, rootElement: HTMLElement | null) {\n let currentNode: Node | null | undefined = node\n const path: number[] = []\n while (currentNode !== rootElement) {\n if (currentNode !== null && currentNode !== undefined) {\n path.unshift(\n Array.from(currentNode?.parentNode?.childNodes ?? []).indexOf(currentNode as ChildNode),\n )\n }\n currentNode = currentNode?.parentNode\n }\n return path\n}\n\nconst keyPresses = new Set([\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'Backspace',\n 'Delete',\n 'Enter',\n 'Escape',\n])\n\ntype Step = {\n count: number\n name: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any\n}\n\ntype Steps = Step[]\n\nfunction useTestRecorder(editor: LexicalEditor): [JSX.Element, JSX.Element | null] {\n const [steps, setSteps] = useState<Steps>([])\n const [isRecording, setIsRecording] = useState(false)\n const [, setCurrentInnerHTML] = useState('')\n const [templatedTest, setTemplatedTest] = useState('')\n const previousSelectionRef = useRef<BaseSelection | null>(null)\n const skipNextSelectionChangeRef = useRef(false)\n const preRef = useRef<HTMLPreElement>(null)\n\n const getCurrentEditor = useCallback(() => {\n return editor\n }, [editor])\n\n const generateTestContent = useCallback(() => {\n const rootElement = editor.getRootElement()\n const browserSelection = getDOMSelection(editor._window)\n\n if (\n rootElement == null ||\n browserSelection == null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null ||\n !rootElement.contains(browserSelection.anchorNode) ||\n !rootElement.contains(browserSelection.focusNode)\n ) {\n return null\n }\n\n return `\nimport {\n initializeE2E,\n assertHTMLSnapshot,\n assertSelection,\n repeat,\n} from '../utils';\nimport {selectAll} from '../keyboardShortcuts';\nimport { RangeSelection } from 'lexical';\nimport { NodeSelection } from 'lexical';\n\ndescribe('Test case', () => {\n initializeE2E((e2e) => {\n it('Should pass this test', async () => {\n const {page} = e2e;\n\n await page.focus('div[contenteditable=\"true\"]');\n${steps.map(formatStep).join(`\\n`)}\n });\n});\n `\n }, [editor, steps])\n\n // just a wrapper around inserting new actions so that we can\n // coalesce some actions like insertText/moveNativeSelection\n const pushStep = useCallback(\n (name: string, value: Step['value']) => {\n setSteps((currentSteps) => {\n // trying to group steps\n const currentIndex = steps.length - 1\n const lastStep = steps[currentIndex]\n if (lastStep) {\n if (lastStep.name === name) {\n if (name === 'type') {\n // for typing events we just append the text\n return [\n ...steps.slice(0, currentIndex),\n { ...lastStep, value: lastStep.value + value },\n ]\n } else {\n // for other events we bump the counter if their values are the same\n if (lastStep.value === value) {\n return [...steps.slice(0, currentIndex), { ...lastStep, count: lastStep.count + 1 }]\n }\n }\n }\n }\n // could not group, just append a new one\n return [...currentSteps, { name, count: 1, value }]\n })\n },\n [steps, setSteps],\n )\n\n useLayoutEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (isSelectAll(event)) {\n pushStep('selectAll', '')\n } else if (keyPresses.has(key)) {\n pushStep('press', event.key)\n } else if ([...key].length > 1) {\n pushStep('keydown', event.key)\n } else {\n pushStep('type', event.key)\n }\n }\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (!keyPresses.has(key) && [...key].length > 1) {\n pushStep('keyup', event.key)\n }\n }\n\n return editor.registerRootListener(\n (rootElement: HTMLElement | null, prevRootElement: HTMLElement | null) => {\n if (prevRootElement !== null) {\n prevRootElement.removeEventListener('keydown', onKeyDown)\n prevRootElement.removeEventListener('keyup', onKeyUp)\n }\n if (rootElement !== null) {\n rootElement.addEventListener('keydown', onKeyDown)\n rootElement.addEventListener('keyup', onKeyUp)\n }\n },\n )\n }, [editor, isRecording, pushStep])\n\n useLayoutEffect(() => {\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }, [generateTestContent])\n\n useEffect(() => {\n if (steps) {\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }\n }, [generateTestContent, steps])\n\n useEffect(() => {\n const removeUpdateListener = editor.registerUpdateListener(\n ({ dirtyElements, dirtyLeaves, editorState }) => {\n if (!isRecording) {\n return\n }\n const currentSelection = editorState._selection\n const previousSelection = previousSelectionRef.current\n const skipNextSelectionChange = skipNextSelectionChangeRef.current\n if (previousSelection !== currentSelection) {\n if (dirtyLeaves.size === 0 && dirtyElements.size === 0 && !skipNextSelectionChange) {\n const browserSelection = getDOMSelection(editor._window)\n if (\n browserSelection &&\n (browserSelection.anchorNode == null || browserSelection.focusNode == null)\n ) {\n return\n }\n }\n previousSelectionRef.current = currentSelection\n }\n skipNextSelectionChangeRef.current = false\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n },\n )\n return removeUpdateListener\n }, [editor, generateTestContent, isRecording, pushStep])\n\n // save innerHTML\n useEffect(() => {\n if (!isRecording) {\n return\n }\n const removeUpdateListener = editor.registerUpdateListener(() => {\n const rootElement = editor.getRootElement()\n if (rootElement !== null) {\n setCurrentInnerHTML(rootElement?.innerHTML)\n }\n })\n return removeUpdateListener\n }, [editor, isRecording])\n\n // clear editor and start recording\n const toggleEditorSelection = useCallback(\n (currentEditor: LexicalEditor) => {\n if (!isRecording) {\n currentEditor.update(() => {\n const root = $getRoot()\n root.clear()\n const text = $createTextNode()\n root.append($createParagraphNode().append(text))\n text.select()\n })\n setSteps([])\n }\n setIsRecording((currentIsRecording) => !currentIsRecording)\n },\n [isRecording],\n )\n\n const onSnapshotClick = useCallback(() => {\n if (!isRecording) {\n return\n }\n const browserSelection = getDOMSelection(editor._window)\n if (\n browserSelection === null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null\n ) {\n return\n }\n const { anchorNode, anchorOffset, focusNode, focusOffset } = sanitizeSelection(browserSelection)\n const rootElement = getCurrentEditor().getRootElement()\n let anchorPath\n if (anchorNode !== null) {\n anchorPath = getPathFromNodeToEditor(anchorNode, rootElement)\n }\n let focusPath\n if (focusNode !== null) {\n focusPath = getPathFromNodeToEditor(focusNode, rootElement)\n }\n pushStep('snapshot', {\n anchorNode,\n anchorOffset,\n anchorPath,\n focusNode,\n focusOffset,\n focusPath,\n })\n }, [pushStep, isRecording, getCurrentEditor])\n\n const onCopyClick = useCallback(() => {\n copy(generateTestContent())\n }, [generateTestContent])\n\n const onDownloadClick = useCallback(() => {\n download('test.js', generateTestContent())\n }, [generateTestContent])\n\n const button = (\n <button\n className={`editor-dev-button ${isRecording ? 'active' : ''}`}\n id=\"test-recorder-button\"\n onClick={(e) => {\n toggleEditorSelection(getCurrentEditor())\n e.preventDefault()\n }}\n title={isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n type=\"button\"\n >\n {isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n </button>\n )\n const output = isRecording ? (\n <div className=\"test-recorder-output\">\n <div className=\"test-recorder-toolbar\">\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-snapshot\"\n onClick={(e) => {\n onSnapshotClick()\n e.preventDefault()\n }}\n title=\"Insert snapshot\"\n type=\"button\"\n >\n Insert Snapshot\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-copy\"\n onClick={(e) => {\n onCopyClick()\n e.preventDefault()\n }}\n title=\"Copy to clipboard\"\n type=\"button\"\n >\n Copy\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-download\"\n onClick={(e) => {\n onDownloadClick()\n e.preventDefault()\n }}\n title=\"Download as a file\"\n type=\"button\"\n >\n Download\n </button>\n </div>\n <pre id=\"test-recorder\" ref={preRef}>\n {templatedTest}\n </pre>\n </div>\n ) : null\n\n return [button, output]\n}\nexport const TestRecorderPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor)\n\n return (\n <React.Fragment>\n <p>HI</p>\n {testRecorderButton}\n {testRecorderOutput}\n <p>DONE</p>\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","$createParagraphNode","$createTextNode","$getRoot","getDOMSelection","React","useCallback","useEffect","useLayoutEffect","useRef","useState","IS_APPLE","copy","text","textArea","document","createElement","value","style","position","opacity","body","appendChild","focus","select","result","execCommand","console","log","error","removeChild","download","filename","a","setAttribute","encodeURIComponent","display","click","formatStep","step","formatOneStep","name","x","y","anchorPath","toString","anchorOffset","focusPath","focusOffset","formattedStep","count","join","isSelectAll","event","key","toLowerCase","metaKey","ctrlKey","sanitizeSelection","selection","anchorNode","focusNode","getPathFromNodeToEditor","node","rootElement","currentNode","path","undefined","unshift","Array","from","parentNode","childNodes","indexOf","keyPresses","Set","useTestRecorder","editor","steps","setSteps","isRecording","setIsRecording","setCurrentInnerHTML","templatedTest","setTemplatedTest","previousSelectionRef","skipNextSelectionChangeRef","preRef","getCurrentEditor","generateTestContent","getRootElement","browserSelection","_window","contains","map","pushStep","currentSteps","currentIndex","length","lastStep","slice","onKeyDown","has","onKeyUp","registerRootListener","prevRootElement","removeEventListener","addEventListener","current","scrollTo","scrollHeight","testContent","removeUpdateListener","registerUpdateListener","dirtyElements","dirtyLeaves","editorState","currentSelection","_selection","previousSelection","skipNextSelectionChange","size","innerHTML","toggleEditorSelection","currentEditor","update","root","clear","append","currentIsRecording","onSnapshotClick","onCopyClick","onDownloadClick","button","className","id","onClick","e","preventDefault","title","type","output","div","pre","ref","TestRecorderPlugin","testRecorderButton","testRecorderOutput","Fragment","p"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,UAAS;AAC1F,YAAYC,WAAW,QAAO;AAC9B,SAAmBC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAI3F,SAASC,QAAQ,QAAQ,8CAA6C;AACtE,OAAO,eAAc;AAErB,MAAMC,OAAO,CAACC;IACZ,MAAMC,WAAWC,SAASC,aAAa,CAAC;IACxCF,SAASG,KAAK,GAAGJ,QAAQ;IACzBC,SAASI,KAAK,CAACC,QAAQ,GAAG;IAC1BL,SAASI,KAAK,CAACE,OAAO,GAAG;IACzBL,SAASM,IAAI,EAAEC,YAAYR;IAC3BA,SAASS,KAAK;IACdT,SAASU,MAAM;IACf,IAAI;QACF,MAAMC,SAASV,SAASW,WAAW,CAAC;QACpC,sCAAsC;QACtCC,QAAQC,GAAG,CAACH;IACd,EAAE,OAAOI,OAAO;QACdF,QAAQE,KAAK,CAACA;IAChB;IACAd,SAASM,IAAI,EAAES,YAAYhB;AAC7B;AAEA,MAAMiB,WAAW,CAACC,UAAkBnB;IAClC,MAAMoB,IAAIlB,SAASC,aAAa,CAAC;IACjCiB,EAAEC,YAAY,CAAC,QAAQ,mCAAmCC,mBAAmBtB,QAAQ;IACrFoB,EAAEC,YAAY,CAAC,YAAYF;IAC3BC,EAAEf,KAAK,CAACkB,OAAO,GAAG;IAClBrB,SAASM,IAAI,EAAEC,YAAYW;IAC3B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AEJ5D,cAAc,0BAA0B;;;;;;IAG7C,MAAM6D,SAAS7D,4BACb,QAAC8D;QAAIR,WAAU;;0BACb,QAACQ;gBAAIR,WAAU;;kCACb,QAACD;wBACCC,WAAU;wBACVC,IAAG;wBACHC,SAAS,CAACC;4BACRP;4BACAO,EAAEC,cAAc;wBAClB;wBACAC,OAAM;wBACNC,MAAK;kCACN;;;;;;kCAGD,QAACP;wBACCC,WAAU;wBACVC,IAAG;wBACHC,SAAS,CAACC;4BACRN;4BACAM,EAAEC,cAAc;wBAClB;wBACAC,OAAM;wBACNC,MAAK;kCACN;;;;;;kCAGD,QAACP;wBACCC,WAAU;wBACVC,IAAG;wBACHC,SAAS,CAACC;4BACRL;4BACAK,EAAEC,cAAc;wBAClB;wBACAC,OAAM;wBACNC,MAAK;kCACN;;;;;;;;;;;;0BAIH,QAACG;gBAAIR,IAAG;gBAAgBS,KAAKzD;0BAC1BJ;;;;;;;;;;;eAGH;IAEJ,OAAO;QAACkD;QAAQQ;KAAO;AACzB;AACA,OAAO,MAAMI,qBAAiD;IAC5D,MAAM,CAACpE,OAAO,GAAG7E;IACjB,MAAM,CAACkJ,oBAAoBC,mBAAmB,GAAGvE,gBAAgBC;IAEjE,qBACE,QAACxE,MAAM+I,QAAQ;;0BACb,QAACC;0BAAE;;;;;;YACFH;YACAC;0BACD,QAACE;0BAAE;;;;;;;;;;;;AAGT,EAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.test-recorder-output {
|
|
5
|
+
margin: 20px auto 20px auto;
|
|
6
|
+
width: 100%;
|
|
7
|
+
}
|
|
8
|
+
.test-recorder-toolbar {
|
|
9
|
+
display: flex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.test-recorder-button {
|
|
13
|
+
position: relative;
|
|
14
|
+
display: block;
|
|
15
|
+
font-size: 10px;
|
|
16
|
+
padding: 6px 6px;
|
|
17
|
+
border-radius: $style-radius-m;
|
|
18
|
+
border: none;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
outline: none;
|
|
21
|
+
box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.4);
|
|
22
|
+
background-color: #222;
|
|
23
|
+
color: white;
|
|
24
|
+
transition: box-shadow 50ms ease-out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.test-recorder-button:active {
|
|
28
|
+
box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.4);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.test-recorder-button + .test-recorder-button {
|
|
32
|
+
margin-left: 4px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.test-recorder-button::after {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 8px;
|
|
39
|
+
right: 8px;
|
|
40
|
+
bottom: 8px;
|
|
41
|
+
left: 8px;
|
|
42
|
+
display: block;
|
|
43
|
+
background-size: contain;
|
|
44
|
+
filter: invert(1);
|
|
45
|
+
}
|
|
46
|
+
#test-recorder-button {
|
|
47
|
+
position: relative;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#test-recorder-button-snapshot {
|
|
51
|
+
margin-right: auto;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
4
|
import { TreeView } from '@lexical/react/LexicalTreeView.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import './index.scss';
|
|
7
7
|
export const TreeViewPlugin = ()=>{
|
|
8
8
|
const [editor] = useLexicalComposerContext();
|
|
9
|
-
return /*#__PURE__*/
|
|
9
|
+
return /*#__PURE__*/ _jsxDEV(TreeView, {
|
|
10
10
|
editor: editor,
|
|
11
11
|
timeTravelButtonClassName: "debug-timetravel-button",
|
|
12
12
|
timeTravelPanelButtonClassName: "debug-timetravel-panel-button",
|
|
@@ -14,7 +14,11 @@ export const TreeViewPlugin = ()=>{
|
|
|
14
14
|
timeTravelPanelSliderClassName: "debug-timetravel-panel-slider",
|
|
15
15
|
treeTypeButtonClassName: "debug-treetype-button",
|
|
16
16
|
viewClassName: "tree-view-output"
|
|
17
|
-
}
|
|
17
|
+
}, void 0, false, {
|
|
18
|
+
fileName: "src/features/debug/treeView/client/plugin/index.tsx",
|
|
19
|
+
lineNumber: 13,
|
|
20
|
+
columnNumber: 5
|
|
21
|
+
}, this);
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/debug/treeView/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { TreeView } from '@lexical/react/LexicalTreeView.js'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\n\nexport const TreeViewPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n return (\n <TreeView\n editor={editor}\n timeTravelButtonClassName=\"debug-timetravel-button\"\n timeTravelPanelButtonClassName=\"debug-timetravel-panel-button\"\n timeTravelPanelClassName=\"debug-timetravel-panel\"\n timeTravelPanelSliderClassName=\"debug-timetravel-panel-slider\"\n treeTypeButtonClassName=\"debug-treetype-button\"\n viewClassName=\"tree-view-output\"\n />\n )\n}\n"],"names":["useLexicalComposerContext","TreeView","React","TreeViewPlugin","editor","timeTravelButtonClassName","timeTravelPanelButtonClassName","timeTravelPanelClassName","timeTravelPanelSliderClassName","treeTypeButtonClassName","viewClassName"],"mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,YAAYC,WAAW,QAAO;AAI9B,OAAO,eAAc;AAErB,OAAO,MAAMC,iBAA6C;IACxD,MAAM,CAACC,OAAO,GAAGJ;IACjB,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/debug/treeView/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { TreeView } from '@lexical/react/LexicalTreeView.js'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\n\nexport const TreeViewPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n return (\n <TreeView\n editor={editor}\n timeTravelButtonClassName=\"debug-timetravel-button\"\n timeTravelPanelButtonClassName=\"debug-timetravel-panel-button\"\n timeTravelPanelClassName=\"debug-timetravel-panel\"\n timeTravelPanelSliderClassName=\"debug-timetravel-panel-slider\"\n treeTypeButtonClassName=\"debug-treetype-button\"\n viewClassName=\"tree-view-output\"\n />\n )\n}\n"],"names":["useLexicalComposerContext","TreeView","React","TreeViewPlugin","editor","timeTravelButtonClassName","timeTravelPanelButtonClassName","timeTravelPanelClassName","timeTravelPanelSliderClassName","treeTypeButtonClassName","viewClassName"],"mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,YAAYC,WAAW,QAAO;AAI9B,OAAO,eAAc;AAErB,OAAO,MAAMC,iBAA6C;IACxD,MAAM,CAACC,OAAO,GAAGJ;IACjB,qBACE,QAACC;QACCG,QAAQA;QACRC,2BAA0B;QAC1BC,gCAA+B;QAC/BC,0BAAyB;QACzBC,gCAA+B;QAC/BC,yBAAwB;QACxBC,eAAc;;;;;;AAGpB,EAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.tree-view-output {
|
|
3
|
+
display: block;
|
|
4
|
+
background: #222;
|
|
5
|
+
color: #fff;
|
|
6
|
+
padding: 0;
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
margin: 1px auto 10px auto;
|
|
9
|
+
position: relative;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
border-bottom-left-radius: 10px;
|
|
12
|
+
border-bottom-right-radius: 10px;
|
|
13
|
+
|
|
14
|
+
pre {
|
|
15
|
+
line-height: 1.1;
|
|
16
|
+
background: #222;
|
|
17
|
+
color: #fff;
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 10px;
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
max-height: 400px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.debug-treetype-button {
|
|
26
|
+
border: 0;
|
|
27
|
+
padding: 0;
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
top: 10px;
|
|
30
|
+
right: 85px;
|
|
31
|
+
position: absolute;
|
|
32
|
+
background: none;
|
|
33
|
+
color: #fff;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
text-decoration: underline;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.debug-timetravel-button {
|
|
41
|
+
border: 0;
|
|
42
|
+
padding: 0;
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
top: 10px;
|
|
45
|
+
right: 15px;
|
|
46
|
+
position: absolute;
|
|
47
|
+
background: none;
|
|
48
|
+
color: #fff;
|
|
49
|
+
|
|
50
|
+
&:hover {
|
|
51
|
+
text-decoration: underline;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.debug-timetravel-panel {
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
padding: 0 0 10px;
|
|
58
|
+
margin: auto;
|
|
59
|
+
display: flex;
|
|
60
|
+
|
|
61
|
+
&-button {
|
|
62
|
+
padding: 0;
|
|
63
|
+
border: 0;
|
|
64
|
+
background: none;
|
|
65
|
+
flex: 1;
|
|
66
|
+
color: #fff;
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
text-decoration: underline;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&-slider {
|
|
75
|
+
padding: 0;
|
|
76
|
+
flex: 8;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|