@payloadcms/richtext-lexical 3.68.0-internal-debug.35482da → 3.68.0-internal-debug.e9b66ee
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 +2 -21
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +13 -48
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +1 -10
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js +1 -7
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +1 -7
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +81 -247
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +1 -9
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +1 -7
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +1 -7
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +1 -7
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +68 -217
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/getBlockImageComponent.js +4 -15
- package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +1 -12
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +2 -12
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +26 -127
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +49 -65
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +3 -16
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +4 -25
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +2 -13
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +1 -8
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +1 -8
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +1 -6
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +1 -6
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js +10 -19
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js +16 -63
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +4 -19
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js +12 -45
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js +11 -57
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +7 -46
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +5 -12
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +3 -16
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +38 -113
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.js +1 -15
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +79 -357
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +7 -41
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +9 -39
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +28 -59
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +0 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/indent/client/IndentPlugin.js +1 -6
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/link/client/plugins/clickableLink/index.js +1 -7
- package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +59 -151
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +1 -9
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/lists/checklist/client/plugin/index.js +1 -7
- package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
- package/dist/features/lists/plugin/index.js +1 -7
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +3 -18
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -9
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +3 -18
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -9
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +31 -100
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +4 -21
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +2 -12
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +1 -8
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/textState/feature.client.js +5 -22
- package/dist/features/textState/feature.client.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +27 -123
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +18 -111
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +4 -14
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +56 -135
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +16 -70
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/upload/client/component/index.js +43 -167
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/pending/index.js +3 -16
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js +4 -21
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +3 -17
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +2 -9
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +11 -54
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.js +18 -60
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.js +7 -42
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.js +21 -91
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/index.js +4 -17
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Field.js +25 -124
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RenderLexical/index.js +15 -47
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/index.js +5 -24
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.js +1 -9
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/lexical/EditorPlugin.js +2 -17
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +69 -232
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.js +13 -64
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +2 -11
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +5 -28
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +1 -14
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +31 -98
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +7 -27
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +7 -45
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +3 -18
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/ui/icons/AI/index.js +10 -58
- package/dist/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/lexical/ui/icons/Add/index.js +4 -31
- package/dist/lexical/ui/icons/Add/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignCenter/index.js +5 -45
- package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignJustify/index.js +5 -45
- package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignLeft/index.js +5 -45
- package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignRight/index.js +5 -45
- package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/lexical/ui/icons/Block/index.js +5 -54
- package/dist/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/lexical/ui/icons/Blockquote/index.js +3 -24
- package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/lexical/ui/icons/Bold/index.js +3 -24
- package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/lexical/ui/icons/Checklist/index.js +4 -39
- package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/lexical/ui/icons/Code/index.js +4 -34
- package/dist/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +3 -22
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.js +3 -23
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
- package/dist/lexical/ui/icons/H1/index.js +3 -24
- package/dist/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/lexical/ui/icons/H2/index.js +3 -24
- package/dist/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/lexical/ui/icons/H3/index.js +3 -24
- package/dist/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/lexical/ui/icons/H4/index.js +3 -24
- package/dist/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/lexical/ui/icons/H5/index.js +3 -24
- package/dist/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/lexical/ui/icons/H6/index.js +3 -24
- package/dist/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/lexical/ui/icons/HorizontalRule/index.js +3 -27
- package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentDecrease/index.js +6 -53
- package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentIncrease/index.js +6 -53
- package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/InlineBlocks/index.js +3 -26
- package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
- package/dist/lexical/ui/icons/Italic/index.js +3 -24
- package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/lexical/ui/icons/Link/index.js +3 -25
- package/dist/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/lexical/ui/icons/Meatballs/index.js +5 -39
- package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
- package/dist/lexical/ui/icons/OrderedList/index.js +7 -61
- package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Relationship/index.js +10 -58
- package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/lexical/ui/icons/Strikethrough/index.js +4 -34
- package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/lexical/ui/icons/Subscript/index.js +3 -24
- package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Superscript/index.js +3 -24
- package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Table/index.js +3 -24
- package/dist/lexical/ui/icons/Table/index.js.map +1 -1
- package/dist/lexical/ui/icons/Text/index.js +3 -24
- package/dist/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/lexical/ui/icons/TextState/index.js +12 -18
- package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
- package/dist/lexical/ui/icons/Underline/index.js +4 -34
- package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/lexical/ui/icons/UnorderedList/index.js +8 -81
- package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Upload/index.js +5 -48
- package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/lexical/utils/point.js.map +1 -1
- package/dist/lexical/utils/rect.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +16 -41
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +10 -42
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +1 -9
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +3 -11
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
1
|
export const UploadJSXConverter = {
|
|
3
2
|
upload: ({ node })=>{
|
|
4
3
|
// TO-DO (v4): SerializedUploadNode should use UploadData_P4
|
|
@@ -11,29 +10,14 @@ export const UploadJSXConverter = {
|
|
|
11
10
|
/**
|
|
12
11
|
* If the upload is not an image, return a link to the upload
|
|
13
12
|
*/ if (!uploadDoc.mimeType.startsWith('image')) {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
children: uploadDoc.filename
|
|
18
|
-
}, void 0, false, {
|
|
19
|
-
fileName: "src/features/converters/lexicalToJSX/converter/converters/upload.tsx",
|
|
20
|
-
lineNumber: 24,
|
|
21
|
-
columnNumber: 9
|
|
22
|
-
}, this);
|
|
13
|
+
return <a href={url} rel="noopener noreferrer">
|
|
14
|
+
{uploadDoc.filename}
|
|
15
|
+
</a>;
|
|
23
16
|
}
|
|
24
17
|
/**
|
|
25
18
|
* If the upload is a simple image with no different sizes, return a simple img tag
|
|
26
19
|
*/ if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {
|
|
27
|
-
return
|
|
28
|
-
alt: uploadDoc.filename,
|
|
29
|
-
height: uploadDoc.height,
|
|
30
|
-
src: url,
|
|
31
|
-
width: uploadDoc.width
|
|
32
|
-
}, void 0, false, {
|
|
33
|
-
fileName: "src/features/converters/lexicalToJSX/converter/converters/upload.tsx",
|
|
34
|
-
lineNumber: 35,
|
|
35
|
-
columnNumber: 9
|
|
36
|
-
}, this);
|
|
20
|
+
return <img alt={uploadDoc.filename} height={uploadDoc.height} src={url} width={uploadDoc.width}/>;
|
|
37
21
|
}
|
|
38
22
|
/**
|
|
39
23
|
* If the upload is an image with different sizes, return a picture element
|
|
@@ -46,34 +30,11 @@ export const UploadJSXConverter = {
|
|
|
46
30
|
continue;
|
|
47
31
|
}
|
|
48
32
|
const imageSizeURL = imageSize?.url;
|
|
49
|
-
pictureJSX.push(
|
|
50
|
-
media: `(max-width: ${imageSize.width}px)`,
|
|
51
|
-
srcSet: imageSizeURL,
|
|
52
|
-
type: imageSize.mimeType
|
|
53
|
-
}, size, false, {
|
|
54
|
-
fileName: "src/features/converters/lexicalToJSX/converter/converters/upload.tsx",
|
|
55
|
-
lineNumber: 63,
|
|
56
|
-
columnNumber: 9
|
|
57
|
-
}, this));
|
|
33
|
+
pictureJSX.push(<source key={size} media={`(max-width: ${imageSize.width}px)`} srcSet={imageSizeURL} type={imageSize.mimeType}/>);
|
|
58
34
|
}
|
|
59
35
|
// Add the default img tag
|
|
60
|
-
pictureJSX.push(
|
|
61
|
-
|
|
62
|
-
height: uploadDoc?.height,
|
|
63
|
-
src: url,
|
|
64
|
-
width: uploadDoc?.width
|
|
65
|
-
}, 'image', false, {
|
|
66
|
-
fileName: "src/features/converters/lexicalToJSX/converter/converters/upload.tsx",
|
|
67
|
-
lineNumber: 74,
|
|
68
|
-
columnNumber: 7
|
|
69
|
-
}, this));
|
|
70
|
-
return /*#__PURE__*/ _jsxDEV("picture", {
|
|
71
|
-
children: pictureJSX
|
|
72
|
-
}, void 0, false, {
|
|
73
|
-
fileName: "src/features/converters/lexicalToJSX/converter/converters/upload.tsx",
|
|
74
|
-
lineNumber: 82,
|
|
75
|
-
columnNumber: 12
|
|
76
|
-
}, this);
|
|
36
|
+
pictureJSX.push(<img alt={uploadDoc?.filename} height={uploadDoc?.height} key={'image'} src={url} width={uploadDoc?.width}/>);
|
|
37
|
+
return <picture>{pictureJSX}</picture>;
|
|
77
38
|
}
|
|
78
39
|
};
|
|
79
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/upload.tsx"],"sourcesContent":["import type { FileData, FileSizeImproved, TypeWithID } from 'payload'\n\nimport type { SerializedUploadNode } from '../../../../../nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/nodes/UploadNode.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n // TO-DO (v4): SerializedUploadNode should use UploadData_P4\n const uploadNode = node as UploadDataImproved\n if (typeof uploadNode.value !== 'object') {\n return null\n }\n\n const uploadDoc = uploadNode.value as FileData & TypeWithID\n\n const url = uploadDoc.url\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDoc.mimeType.startsWith('image')) {\n return (\n <a href={url} rel=\"noopener noreferrer\">\n {uploadDoc.filename}\n </a>\n )\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {\n return (\n <img alt={uploadDoc.filename} height={uploadDoc.height} src={url} width={uploadDoc.width} />\n )\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n const pictureJSX: React.ReactNode[] = []\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDoc.sizes) {\n const imageSize = uploadDoc.sizes[size] as FileSizeImproved\n\n // Skip if any property of the size object is null\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = imageSize?.url\n\n pictureJSX.push(\n <source\n key={size}\n media={`(max-width: ${imageSize.width}px)`}\n srcSet={imageSizeURL}\n type={imageSize.mimeType}\n />,\n )\n }\n\n // Add the default img tag\n pictureJSX.push(\n <img\n alt={uploadDoc?.filename}\n height={uploadDoc?.height}\n key={'image'}\n src={url}\n width={uploadDoc?.width}\n />,\n )\n return <picture>{pictureJSX}</picture>\n },\n}\n"],"names":["UploadJSXConverter","upload","node","uploadNode","value","uploadDoc","url","mimeType","startsWith","a","href","rel","filename","sizes","Object","keys","length","img","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","source","media","srcSet","type","picture"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/upload.tsx"],"sourcesContent":["import type { FileData, FileSizeImproved, TypeWithID } from 'payload'\n\nimport type { SerializedUploadNode } from '../../../../../nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/nodes/UploadNode.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n // TO-DO (v4): SerializedUploadNode should use UploadData_P4\n const uploadNode = node as UploadDataImproved\n if (typeof uploadNode.value !== 'object') {\n return null\n }\n\n const uploadDoc = uploadNode.value as FileData & TypeWithID\n\n const url = uploadDoc.url\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDoc.mimeType.startsWith('image')) {\n return (\n <a href={url} rel=\"noopener noreferrer\">\n {uploadDoc.filename}\n </a>\n )\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {\n return (\n <img alt={uploadDoc.filename} height={uploadDoc.height} src={url} width={uploadDoc.width} />\n )\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n const pictureJSX: React.ReactNode[] = []\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDoc.sizes) {\n const imageSize = uploadDoc.sizes[size] as FileSizeImproved\n\n // Skip if any property of the size object is null\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = imageSize?.url\n\n pictureJSX.push(\n <source\n key={size}\n media={`(max-width: ${imageSize.width}px)`}\n srcSet={imageSizeURL}\n type={imageSize.mimeType}\n />,\n )\n }\n\n // Add the default img tag\n pictureJSX.push(\n <img\n alt={uploadDoc?.filename}\n height={uploadDoc?.height}\n key={'image'}\n src={url}\n width={uploadDoc?.width}\n />,\n )\n return <picture>{pictureJSX}</picture>\n },\n}\n"],"names":["UploadJSXConverter","upload","node","uploadNode","value","uploadDoc","url","mimeType","startsWith","a","href","rel","filename","sizes","Object","keys","length","img","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","source","key","media","srcSet","type","picture"],"mappings":"AAMA,OAAO,MAAMA,qBAA0D;IACrEC,QAAQ,CAAC,EAAEC,IAAI,EAAE;QACf,4DAA4D;QAC5D,MAAMC,aAAaD;QACnB,IAAI,OAAOC,WAAWC,KAAK,KAAK,UAAU;YACxC,OAAO;QACT;QAEA,MAAMC,YAAYF,WAAWC,KAAK;QAElC,MAAME,MAAMD,UAAUC,GAAG;QAEzB;;KAEC,GACD,IAAI,CAACD,UAAUE,QAAQ,CAACC,UAAU,CAAC,UAAU;YAC3C,QACGC,EAAEC,MAAMJ,KAAKK,IAAI,sBAAsB;UACtC,CAACN,UAAUO,QAAQ,CAAC;QACtB,EAAEH;QAEN;QAEA;;KAEC,GACD,IAAI,CAACJ,UAAUQ,KAAK,IAAI,CAACC,OAAOC,IAAI,CAACV,UAAUQ,KAAK,EAAEG,MAAM,EAAE;YAC5D,QACGC,IAAIC,KAAKb,UAAUO,QAAQ,EAAEO,QAAQd,UAAUc,MAAM,EAAEC,KAAKd,KAAKe,OAAOhB,UAAUgB,KAAK;QAE5F;QAEA;;KAEC,GACD,MAAMC,aAAgC,EAAE;QAExC,qDAAqD;QACrD,IAAK,MAAMC,QAAQlB,UAAUQ,KAAK,CAAE;YAClC,MAAMW,YAAYnB,UAAUQ,KAAK,CAACU,KAAK;YAEvC,kDAAkD;YAClD,IACE,CAACC,aACD,CAACA,UAAUH,KAAK,IAChB,CAACG,UAAUL,MAAM,IACjB,CAACK,UAAUjB,QAAQ,IACnB,CAACiB,UAAUC,QAAQ,IACnB,CAACD,UAAUZ,QAAQ,IACnB,CAACY,UAAUlB,GAAG,EACd;gBACA;YACF;YACA,MAAMoB,eAAeF,WAAWlB;YAEhCgB,WAAWK,IAAI,EACZC,OACCC,KAAKN,MACLO,OAAO,CAAC,YAAY,EAAEN,UAAUH,KAAK,CAAC,GAAG,CAAC,EAC1CU,QAAQL,cACRM,MAAMR,UAAUjB,QAAQ;QAG9B;QAEA,0BAA0B;QAC1Be,WAAWK,IAAI,EACZV,IACCC,KAAKb,WAAWO,UAChBO,QAAQd,WAAWc,QACnBU,KAAK,SACLT,KAAKd,KACLe,OAAOhB,WAAWgB;QAGtB,QAAQY,SAASX,aAAaW;IAChC;AACF,EAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
|
|
2
1
|
/* eslint-disable no-console */ import React from 'react';
|
|
3
2
|
import { hasText } from '../../../../validate/hasText.js';
|
|
4
3
|
export function convertLexicalToJSX({ converters, data, disableIndent, disableTextAlign }) {
|
|
@@ -11,7 +10,7 @@ export function convertLexicalToJSX({ converters, data, disableIndent, disableTe
|
|
|
11
10
|
parent: data?.root
|
|
12
11
|
});
|
|
13
12
|
}
|
|
14
|
-
return
|
|
13
|
+
return <></>;
|
|
15
14
|
}
|
|
16
15
|
export function convertLexicalNodesToJSX({ converters, disableIndent, disableTextAlign, nodes, parent }) {
|
|
17
16
|
const unknownConverter = converters.unknown;
|
|
@@ -56,13 +55,7 @@ export function convertLexicalNodesToJSX({ converters, disableIndent, disableTex
|
|
|
56
55
|
}) : converterForNode;
|
|
57
56
|
reactNode = converted;
|
|
58
57
|
} else {
|
|
59
|
-
reactNode =
|
|
60
|
-
children: "unknown node"
|
|
61
|
-
}, i, false, {
|
|
62
|
-
fileName: "src/features/converters/lexicalToJSX/converter/index.tsx",
|
|
63
|
-
lineNumber: 102,
|
|
64
|
-
columnNumber: 21
|
|
65
|
-
}, this);
|
|
58
|
+
reactNode = <span key={i}>unknown node</span>;
|
|
66
59
|
}
|
|
67
60
|
const style = {};
|
|
68
61
|
// Check if disableTextAlign is not true and does not include node type
|
|
@@ -98,7 +91,7 @@ export function convertLexicalNodesToJSX({ converters, disableIndent, disableTex
|
|
|
98
91
|
style.paddingInlineStart = `${Number(node.indent) * 40}px`;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
|
-
if (
|
|
94
|
+
if (React.isValidElement(reactNode)) {
|
|
102
95
|
// Inject style into reactNode
|
|
103
96
|
if (style.textAlign || style.paddingInlineStart) {
|
|
104
97
|
const newStyle = {
|
|
@@ -107,13 +100,13 @@ export function convertLexicalNodesToJSX({ converters, disableIndent, disableTex
|
|
|
107
100
|
...reactNode?.props?.style ?? {}
|
|
108
101
|
};
|
|
109
102
|
// reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here
|
|
110
|
-
return
|
|
103
|
+
return React.cloneElement(reactNode, {
|
|
111
104
|
key: i,
|
|
112
105
|
// @ts-expect-error type better later
|
|
113
106
|
style: newStyle
|
|
114
107
|
});
|
|
115
108
|
}
|
|
116
|
-
return
|
|
109
|
+
return React.cloneElement(reactNode, {
|
|
117
110
|
key: i
|
|
118
111
|
});
|
|
119
112
|
}
|
|
@@ -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","
|
|
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","key","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","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;AACF;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,k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EV } from "react/jsx-dev-runtime";
|
|
3
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
3
|
import { useEffect, useState } from 'react';
|
|
5
4
|
// eslint-disable-next-line payload/no-imports-from-exports-dir
|
|
@@ -15,21 +14,9 @@ export function RichTextPlugin() {
|
|
|
15
14
|
}, [
|
|
16
15
|
editor
|
|
17
16
|
]);
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
converters: defaultJSXConverters,
|
|
22
|
-
data: editorState
|
|
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);
|
|
17
|
+
return <div className="debug-jsx-converter">
|
|
18
|
+
<RichText converters={defaultJSXConverters} data={editorState}/>
|
|
19
|
+
</div>;
|
|
33
20
|
}
|
|
34
21
|
|
|
35
22
|
//# 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
|
|
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,QACGM,IAAIC,UAAU,sBAAsB;MACnC,CAACT,SAASU,YAAYX,sBAAsBY,MAAMR,cAAe;IACnE,EAAEK;AAEN"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
3
|
import { $createParagraphNode, $createTextNode, $getRoot, getDOMSelection } from 'lexical';
|
|
5
4
|
import * as React from 'react';
|
|
@@ -389,125 +388,51 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
389
388
|
}, [
|
|
390
389
|
generateTestContent
|
|
391
390
|
]);
|
|
392
|
-
const button =
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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", {
|
|
429
|
-
className: "test-recorder-button",
|
|
430
|
-
id: "test-recorder-button-copy",
|
|
431
|
-
onClick: (e)=>{
|
|
432
|
-
onCopyClick();
|
|
433
|
-
e.preventDefault();
|
|
434
|
-
},
|
|
435
|
-
title: "Copy to clipboard",
|
|
436
|
-
type: "button",
|
|
437
|
-
children: "Copy"
|
|
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", {
|
|
444
|
-
className: "test-recorder-button",
|
|
445
|
-
id: "test-recorder-button-download",
|
|
446
|
-
onClick: (e)=>{
|
|
447
|
-
onDownloadClick();
|
|
448
|
-
e.preventDefault();
|
|
449
|
-
},
|
|
450
|
-
title: "Download as a file",
|
|
451
|
-
type: "button",
|
|
452
|
-
children: "Download"
|
|
453
|
-
}, void 0, false, {
|
|
454
|
-
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
455
|
-
lineNumber: 426,
|
|
456
|
-
columnNumber: 9
|
|
457
|
-
}, this)
|
|
458
|
-
]
|
|
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", {
|
|
465
|
-
id: "test-recorder",
|
|
466
|
-
ref: preRef,
|
|
467
|
-
children: templatedTest
|
|
468
|
-
}, void 0, false, {
|
|
469
|
-
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
470
|
-
lineNumber: 439,
|
|
471
|
-
columnNumber: 7
|
|
472
|
-
}, this)
|
|
473
|
-
]
|
|
474
|
-
}, void 0, true, {
|
|
475
|
-
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
476
|
-
lineNumber: 400,
|
|
477
|
-
columnNumber: 5
|
|
478
|
-
}, this) : null;
|
|
391
|
+
const button1 = <button className={`editor-dev-button ${isRecording ? 'active' : ''}`} id="test-recorder-button" onClick={(e)=>{
|
|
392
|
+
toggleEditorSelection(getCurrentEditor());
|
|
393
|
+
e.preventDefault();
|
|
394
|
+
}} title={isRecording ? 'Disable test recorder' : 'Enable test recorder'} type="button">
|
|
395
|
+
{isRecording ? 'Disable test recorder' : 'Enable test recorder'}
|
|
396
|
+
</button>;
|
|
397
|
+
const output = isRecording ? <div className="test-recorder-output">
|
|
398
|
+
<div className="test-recorder-toolbar">
|
|
399
|
+
<button className="test-recorder-button" id="test-recorder-button-snapshot" onClick={(e)=>{
|
|
400
|
+
onSnapshotClick();
|
|
401
|
+
e.preventDefault();
|
|
402
|
+
}} title="Insert snapshot" type="button">
|
|
403
|
+
Insert Snapshot
|
|
404
|
+
</button>
|
|
405
|
+
<button className="test-recorder-button" id="test-recorder-button-copy" onClick={(e)=>{
|
|
406
|
+
onCopyClick();
|
|
407
|
+
e.preventDefault();
|
|
408
|
+
}} title="Copy to clipboard" type="button">
|
|
409
|
+
Copy
|
|
410
|
+
</button>
|
|
411
|
+
<button className="test-recorder-button" id="test-recorder-button-download" onClick={(e)=>{
|
|
412
|
+
onDownloadClick();
|
|
413
|
+
e.preventDefault();
|
|
414
|
+
}} title="Download as a file" type="button">
|
|
415
|
+
Download
|
|
416
|
+
</button>
|
|
417
|
+
</div>
|
|
418
|
+
<pre id="test-recorder" ref={preRef}>
|
|
419
|
+
{templatedTest}
|
|
420
|
+
</pre>
|
|
421
|
+
</div> : null;
|
|
479
422
|
return [
|
|
480
|
-
|
|
423
|
+
button1,
|
|
481
424
|
output
|
|
482
425
|
];
|
|
483
426
|
}
|
|
484
427
|
export const TestRecorderPlugin = ()=>{
|
|
485
428
|
const [editor] = useLexicalComposerContext();
|
|
486
429
|
const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor);
|
|
487
|
-
return
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
lineNumber: 453,
|
|
494
|
-
columnNumber: 7
|
|
495
|
-
}, this),
|
|
496
|
-
testRecorderButton,
|
|
497
|
-
testRecorderOutput,
|
|
498
|
-
/*#__PURE__*/ _jsxDEV("p", {
|
|
499
|
-
children: "DONE"
|
|
500
|
-
}, void 0, false, {
|
|
501
|
-
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
502
|
-
lineNumber: 456,
|
|
503
|
-
columnNumber: 7
|
|
504
|
-
}, this)
|
|
505
|
-
]
|
|
506
|
-
}, void 0, true, {
|
|
507
|
-
fileName: "src/features/debug/testRecorder/client/plugin/index.tsx",
|
|
508
|
-
lineNumber: 452,
|
|
509
|
-
columnNumber: 5
|
|
510
|
-
}, this);
|
|
430
|
+
return <React.Fragment>
|
|
431
|
+
<p>HI</p>
|
|
432
|
+
{testRecorderButton}
|
|
433
|
+
{testRecorderOutput}
|
|
434
|
+
<p>DONE</p>
|
|
435
|
+
</React.Fragment>;
|
|
511
436
|
};
|
|
512
437
|
|
|
513
438
|
//# 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;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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AACA;KAAoB;IAExB,MAAM2C,kBAAkB9H,YAAY;QAClCyB,SAAS,WAAW0D;IACtB,GAAG;QAACA;KAAoB;IAExB,MAAM4C,uBACJ,QAACA;QACCC,WAAW,CAAC,kBAAkB,EAAEtD,cAAc,WAAW,IAAI;QAC7DuD,IAAG;QACHC,SAAS,CAACC;YACRd,sBAAsBnC;YACtBiD,EAAEC,cAAc;QAClB;QACAC,OAAO3D,cAAc,0BAA0B;QAC/C4D,MAAK;kBAEJ5D,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"}
|
|
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","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EAAEC,cAAc;IAClB,GACAC,MAAM,kBACNC,KAAK,SACN;;QAED,EAAEP,OAAO;QACT,CAACA,OACCC,UAAU,uBACVC,GAAG,4BACHC,SAAS,CAACC;QACRN;QACAM,EAAEC,cAAc;IAClB,GACAC,MAAM,oBACNC,KAAK,SACN;;QAED,EAAEP,OAAO;QACT,CAACA,OACCC,UAAU,uBACVC,GAAG,gCACHC,SAAS,CAACC;QACRL;QACAK,EAAEC,cAAc;IAClB,GACAC,MAAM,qBACNC,KAAK,SACN;;QAED,EAAEP,OAAO;MACX,EAAES,IAAI;MACN,CAACC,IAAIR,GAAG,gBAAgBS,KAAKzD,QAAQ;QACnC,CAACJ,cAAc;MACjB,EAAE4D,IAAI;IACR,EAAED,OACA;IAEJ,OAAO;QAACT;QAAQQ;KAAO;AACzB;AACA,OAAO,MAAMI,qBAAiD;IAC5D,MAAM,CAACpE,OAAO,GAAG7E;IACjB,MAAM,CAACkJ,oBAAoBC,mBAAmB,GAAGvE,gBAAgBC;IAEjE,QACGxE,MAAM+I,SAAS;MACd,CAACC,EAAE,EAAE,EAAEA,EAAE;MACT,CAACH,mBAAmB;MACpB,CAACC,mBAAmB;MACpB,CAACE,EAAE,IAAI,EAAEA,EAAE;IACb,EAAEhJ,MAAM+I;AAEZ,EAAC"}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
3
|
import { TreeView } from '@lexical/react/LexicalTreeView.js';
|
|
5
|
-
import * as React from 'react';
|
|
6
4
|
import './index.scss';
|
|
7
5
|
export const TreeViewPlugin = ()=>{
|
|
8
6
|
const [editor] = useLexicalComposerContext();
|
|
9
|
-
return
|
|
10
|
-
editor: editor,
|
|
11
|
-
timeTravelButtonClassName: "debug-timetravel-button",
|
|
12
|
-
timeTravelPanelButtonClassName: "debug-timetravel-panel-button",
|
|
13
|
-
timeTravelPanelClassName: "debug-timetravel-panel",
|
|
14
|
-
timeTravelPanelSliderClassName: "debug-timetravel-panel-slider",
|
|
15
|
-
treeTypeButtonClassName: "debug-treetype-button",
|
|
16
|
-
viewClassName: "tree-view-output"
|
|
17
|
-
}, void 0, false, {
|
|
18
|
-
fileName: "src/features/debug/treeView/client/plugin/index.tsx",
|
|
19
|
-
lineNumber: 13,
|
|
20
|
-
columnNumber: 5
|
|
21
|
-
}, this);
|
|
7
|
+
return <TreeView editor={editor} timeTravelButtonClassName="debug-timetravel-button" timeTravelPanelButtonClassName="debug-timetravel-panel-button" timeTravelPanelClassName="debug-timetravel-panel" timeTravelPanelSliderClassName="debug-timetravel-panel-slider" treeTypeButtonClassName="debug-treetype-button" viewClassName="tree-view-output"/>;
|
|
22
8
|
};
|
|
23
9
|
|
|
24
10
|
//# 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","
|
|
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","TreeViewPlugin","editor","timeTravelButtonClassName","timeTravelPanelButtonClassName","timeTravelPanelClassName","timeTravelPanelSliderClassName","treeTypeButtonClassName","viewClassName"],"mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,QAAQ,QAAQ,oCAAmC;AAK5D,OAAO,eAAc;AAErB,OAAO,MAAMC,iBAA6C;IACxD,MAAM,CAACC,OAAO,GAAGH;IACjB,QACGC,SACCE,QAAQA,QACRC,0BAA0B,0BAC1BC,+BAA+B,gCAC/BC,yBAAyB,yBACzBC,+BAA+B,gCAC/BC,wBAAwB,wBACxBC,cAAc;AAGpB,EAAC"}
|