@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,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 { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
5
|
import { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui';
|
|
@@ -11,20 +11,32 @@ import './index.scss';
|
|
|
11
11
|
import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
|
|
12
12
|
function ButtonGroupItem({ anchorElem, editor, item }) {
|
|
13
13
|
if (item.Component) {
|
|
14
|
-
return item?.Component && /*#__PURE__*/
|
|
14
|
+
return item?.Component && /*#__PURE__*/ _jsxDEV(item.Component, {
|
|
15
15
|
anchorElem: anchorElem,
|
|
16
16
|
editor: editor,
|
|
17
17
|
item: item
|
|
18
|
-
}, item.key
|
|
18
|
+
}, item.key, false, {
|
|
19
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
20
|
+
lineNumber: 33,
|
|
21
|
+
columnNumber: 9
|
|
22
|
+
}, this);
|
|
19
23
|
}
|
|
20
24
|
if (!item.ChildComponent) {
|
|
21
25
|
return null;
|
|
22
26
|
}
|
|
23
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/ _jsxDEV(ToolbarButton, {
|
|
24
28
|
editor: editor,
|
|
25
29
|
item: item,
|
|
26
|
-
children: /*#__PURE__*/
|
|
27
|
-
|
|
30
|
+
children: /*#__PURE__*/ _jsxDEV(item.ChildComponent, {}, void 0, false, {
|
|
31
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
32
|
+
lineNumber: 44,
|
|
33
|
+
columnNumber: 7
|
|
34
|
+
}, this)
|
|
35
|
+
}, item.key, false, {
|
|
36
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
37
|
+
lineNumber: 43,
|
|
38
|
+
columnNumber: 5
|
|
39
|
+
}, this);
|
|
28
40
|
}
|
|
29
41
|
function ToolbarGroupComponent({ anchorElem, editor, editorConfig, group, index }) {
|
|
30
42
|
const { i18n } = useTranslation();
|
|
@@ -83,11 +95,11 @@ function ToolbarGroupComponent({ anchorElem, editor, editorConfig, group, index
|
|
|
83
95
|
featureClientSchemaMap,
|
|
84
96
|
schemaPath
|
|
85
97
|
]);
|
|
86
|
-
return /*#__PURE__*/
|
|
98
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
87
99
|
className: `fixed-toolbar__group fixed-toolbar__group-${group.key}`,
|
|
88
100
|
"data-toolbar-group-key": group.key,
|
|
89
101
|
children: [
|
|
90
|
-
group.type === 'dropdown' && group.items.length ? DropdownIcon ? /*#__PURE__*/
|
|
102
|
+
group.type === 'dropdown' && group.items.length ? DropdownIcon ? /*#__PURE__*/ _jsxDEV(ToolbarDropdown, {
|
|
91
103
|
anchorElem: anchorElem,
|
|
92
104
|
editor: editor,
|
|
93
105
|
group: group,
|
|
@@ -98,7 +110,11 @@ function ToolbarGroupComponent({ anchorElem, editor, editorConfig, group, index
|
|
|
98
110
|
label: dropdownLabel,
|
|
99
111
|
maxActiveItems: group.maxActiveItems ?? 1,
|
|
100
112
|
onActiveChange: onActiveChange
|
|
101
|
-
}
|
|
113
|
+
}, void 0, false, {
|
|
114
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
115
|
+
lineNumber: 128,
|
|
116
|
+
columnNumber: 11
|
|
117
|
+
}, this) : /*#__PURE__*/ _jsxDEV(ToolbarDropdown, {
|
|
102
118
|
anchorElem: anchorElem,
|
|
103
119
|
editor: editor,
|
|
104
120
|
group: group,
|
|
@@ -108,19 +124,35 @@ function ToolbarGroupComponent({ anchorElem, editor, editorConfig, group, index
|
|
|
108
124
|
label: dropdownLabel,
|
|
109
125
|
maxActiveItems: group.maxActiveItems ?? 1,
|
|
110
126
|
onActiveChange: onActiveChange
|
|
111
|
-
}
|
|
127
|
+
}, void 0, false, {
|
|
128
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
129
|
+
lineNumber: 139,
|
|
130
|
+
columnNumber: 11
|
|
131
|
+
}, this) : null,
|
|
112
132
|
group.type === 'buttons' && group.items.length ? group.items.map((item)=>{
|
|
113
|
-
return /*#__PURE__*/
|
|
133
|
+
return /*#__PURE__*/ _jsxDEV(ButtonGroupItem, {
|
|
114
134
|
anchorElem: anchorElem,
|
|
115
135
|
editor: editor,
|
|
116
136
|
item: item
|
|
117
|
-
}, item.key
|
|
137
|
+
}, item.key, false, {
|
|
138
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
139
|
+
lineNumber: 153,
|
|
140
|
+
columnNumber: 15
|
|
141
|
+
}, this);
|
|
118
142
|
}) : null,
|
|
119
|
-
index < editorConfig.features.toolbarFixed?.groups.length - 1 && /*#__PURE__*/
|
|
143
|
+
index < editorConfig.features.toolbarFixed?.groups.length - 1 && /*#__PURE__*/ _jsxDEV("div", {
|
|
120
144
|
className: "divider"
|
|
121
|
-
}
|
|
145
|
+
}, void 0, false, {
|
|
146
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
147
|
+
lineNumber: 157,
|
|
148
|
+
columnNumber: 73
|
|
149
|
+
}, this)
|
|
122
150
|
]
|
|
123
|
-
}, group.key
|
|
151
|
+
}, group.key, true, {
|
|
152
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
153
|
+
lineNumber: 121,
|
|
154
|
+
columnNumber: 5
|
|
155
|
+
}, this);
|
|
124
156
|
}
|
|
125
157
|
function FixedToolbar({ anchorElem, clientProps, editor, editorConfig, parentWithFixedToolbar }) {
|
|
126
158
|
const currentToolbarRef = React.useRef(null);
|
|
@@ -176,7 +208,7 @@ function FixedToolbar({ anchorElem, clientProps, editor, editorConfig, parentWit
|
|
|
176
208
|
parentToolbarElem,
|
|
177
209
|
y
|
|
178
210
|
]);
|
|
179
|
-
return /*#__PURE__*/
|
|
211
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
180
212
|
className: "fixed-toolbar",
|
|
181
213
|
onFocus: (event)=>{
|
|
182
214
|
// Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,
|
|
@@ -184,18 +216,30 @@ function FixedToolbar({ anchorElem, clientProps, editor, editorConfig, parentWit
|
|
|
184
216
|
event.stopPropagation();
|
|
185
217
|
},
|
|
186
218
|
ref: currentToolbarRef,
|
|
187
|
-
children: isEditable && /*#__PURE__*/
|
|
219
|
+
children: isEditable && /*#__PURE__*/ _jsxDEV(React.Fragment, {
|
|
188
220
|
children: editorConfig?.features && editorConfig.features?.toolbarFixed?.groups.map((group, i)=>{
|
|
189
|
-
return /*#__PURE__*/
|
|
221
|
+
return /*#__PURE__*/ _jsxDEV(ToolbarGroupComponent, {
|
|
190
222
|
anchorElem: anchorElem,
|
|
191
223
|
editor: editor,
|
|
192
224
|
editorConfig: editorConfig,
|
|
193
225
|
group: group,
|
|
194
226
|
index: i
|
|
195
|
-
}, group.key
|
|
227
|
+
}, group.key, false, {
|
|
228
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
229
|
+
lineNumber: 250,
|
|
230
|
+
columnNumber: 17
|
|
231
|
+
}, this);
|
|
196
232
|
})
|
|
197
|
-
}
|
|
198
|
-
|
|
233
|
+
}, void 0, false, {
|
|
234
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
235
|
+
lineNumber: 246,
|
|
236
|
+
columnNumber: 9
|
|
237
|
+
}, this)
|
|
238
|
+
}, void 0, false, {
|
|
239
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
240
|
+
lineNumber: 236,
|
|
241
|
+
columnNumber: 5
|
|
242
|
+
}, this);
|
|
199
243
|
}
|
|
200
244
|
const getParentEditorWithFixedToolbar = (editorConfigContext)=>{
|
|
201
245
|
if (editorConfigContext.parentEditor?.editorConfig) {
|
|
@@ -228,12 +272,16 @@ export const FixedToolbarPlugin = ({ clientProps })=>{
|
|
|
228
272
|
if (!editorConfig?.features?.toolbarFixed?.groups?.length) {
|
|
229
273
|
return null;
|
|
230
274
|
}
|
|
231
|
-
return /*#__PURE__*/
|
|
275
|
+
return /*#__PURE__*/ _jsxDEV(FixedToolbar, {
|
|
232
276
|
anchorElem: document.body,
|
|
233
277
|
editor: editor,
|
|
234
278
|
editorConfig: editorConfig,
|
|
235
279
|
parentWithFixedToolbar: parentWithFixedToolbar
|
|
236
|
-
}
|
|
280
|
+
}, void 0, false, {
|
|
281
|
+
fileName: "src/features/toolbars/fixed/client/Toolbar/index.tsx",
|
|
282
|
+
lineNumber: 312,
|
|
283
|
+
columnNumber: 5
|
|
284
|
+
}, this);
|
|
237
285
|
};
|
|
238
286
|
|
|
239
287
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport './index.scss'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const [dropdownLabel, setDropdownLabel] = React.useState<string | undefined>(undefined)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | undefined>(undefined)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }, [group])\n\n const onActiveChange = React.useCallback(\n ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n setDropdownLabel(undefined)\n } else {\n setDropdownIcon(undefined)\n setDropdownLabel(undefined)\n }\n return\n }\n const item = activeItems[0]!\n\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n if (activeItems.length === 1) {\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n } else {\n setDropdownLabel(\n i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length }),\n )\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }\n },\n [group, i18n, featureClientSchemaMap, schemaPath],\n )\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length ? (\n DropdownIcon ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={group.maxActiveItems ?? 1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={group.maxActiveItems ?? 1}\n onActiveChange={onActiveChange}\n />\n )\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {isEditable && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","i18n","fieldProps","featureClientSchemaMap","schemaPath","dropdownLabel","setDropdownLabel","useState","undefined","DropdownIcon","setDropdownIcon","useEffect","type","items","length","onActiveChange","useCallback","activeItems","label","substring","t","count","div","className","data-toolbar-group-key","Icon","itemsContainerClassNames","maxActiveItems","map","features","toolbarFixed","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","onFocus","event","stopPropagation","ref","Fragment","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","document","body"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ,iBAAgB;AAClF,YAAYC,WAAW,QAAO;AAC9B,SAASC,OAAO,QAAQ,QAAO;AAQ/B,SAASC,sBAAsB,QAAQ,+DAA8D;AACrG,SAASC,aAAa,QAAQ,yCAAwC;AACtE,OAAO,eAAc;AACrB,SAASC,eAAe,QAAQ,2CAA0C;AAE1E,SAASC,gBAAgB,EACvBC,UAAU,EACVC,MAAM,EACNC,IAAI,EAKL;IACC,IAAIA,KAAKC,SAAS,EAAE;QAClB,OACED,MAAMC,2BACJ,KAACD,KAAKC,SAAS;YAACH,YAAYA;YAAYC,QAAQA;YAAQC,MAAMA;WAAWA,KAAKE,GAAG;IAGvF;IAEA,IAAI,CAACF,KAAKG,cAAc,EAAE;QACxB,OAAO;IACT;IAEA,qBACE,KAACR;QAAcI,QAAQA;QAAQC,MAAMA;kBACnC,cAAA,KAACA,KAAKG,cAAc;OAD0BH,KAAKE,GAAG;AAI5D;AAEA,SAASE,sBAAsB,EAC7BN,UAAU,EACVC,MAAM,EACNM,YAAY,EACZC,KAAK,EACLC,KAAK,EAON;IAC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AAgCC;IAE/D,IAAI/B,aAAaO,gCAAgC;QAC/C,IAAIN,wBAAwB;YAC1B,OAAO;QACT;IACF;IAEA,IAAI,CAACpC,cAAc+B,UAAUC,cAAcC,QAAQjB,QAAQ;QACzD,OAAO;IACT;IAEA,qBACE,KAACkB;QACCzC,YAAYkF,SAASC,IAAI;QACzBlF,QAAQA;QACRM,cAAcA;QACdoC,wBAAwBA;;AAG9B,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport './index.scss'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const [dropdownLabel, setDropdownLabel] = React.useState<string | undefined>(undefined)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | undefined>(undefined)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }, [group])\n\n const onActiveChange = React.useCallback(\n ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n setDropdownLabel(undefined)\n } else {\n setDropdownIcon(undefined)\n setDropdownLabel(undefined)\n }\n return\n }\n const item = activeItems[0]!\n\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n if (activeItems.length === 1) {\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n } else {\n setDropdownLabel(\n i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length }),\n )\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }\n },\n [group, i18n, featureClientSchemaMap, schemaPath],\n )\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length ? (\n DropdownIcon ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={group.maxActiveItems ?? 1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={group.maxActiveItems ?? 1}\n onActiveChange={onActiveChange}\n />\n )\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {isEditable && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","i18n","fieldProps","featureClientSchemaMap","schemaPath","dropdownLabel","setDropdownLabel","useState","undefined","DropdownIcon","setDropdownIcon","useEffect","type","items","length","onActiveChange","useCallback","activeItems","label","substring","t","count","div","className","data-toolbar-group-key","Icon","itemsContainerClassNames","maxActiveItems","map","features","toolbarFixed","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","onFocus","event","stopPropagation","ref","Fragment","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","document","body"],"mappings":"AAAA;;AAGA,SA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.fixed-toolbar {
|
|
6
|
+
&__dropdown-items {
|
|
7
|
+
background: var(--theme-elevation-0);
|
|
8
|
+
transition: background 0.2s cubic-bezier(0, 0.2, 0.2, 1);
|
|
9
|
+
|
|
10
|
+
.toolbar-popup__dropdown-item {
|
|
11
|
+
color: var(--theme-elevation-900);
|
|
12
|
+
|
|
13
|
+
&:hover:not([disabled]),
|
|
14
|
+
&.active {
|
|
15
|
+
background: var(--theme-elevation-100);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon {
|
|
19
|
+
color: var(--theme-elevation-600);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.toolbar-popup {
|
|
25
|
+
&__dropdown {
|
|
26
|
+
transition: background-color 0.15s cubic-bezier(0, 0.2, 0.2, 1);
|
|
27
|
+
|
|
28
|
+
&:hover:not([disabled]) {
|
|
29
|
+
background: var(--theme-elevation-100);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&-caret:after {
|
|
33
|
+
filter: invert(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&-label {
|
|
37
|
+
color: var(--theme-elevation-750);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.fixed-toolbar.fixed-toolbar--hide {
|
|
45
|
+
visibility: hidden; // Still needs to take up space so content does not jump, thus we cannot use display: none
|
|
46
|
+
// make sure you cant interact with it
|
|
47
|
+
pointer-events: none;
|
|
48
|
+
user-select: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.fixed-toolbar {
|
|
52
|
+
@include blur-bg(var(--theme-elevation-0));
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-wrap: wrap;
|
|
55
|
+
align-items: center;
|
|
56
|
+
padding: calc(var(--base) / 4);
|
|
57
|
+
vertical-align: middle;
|
|
58
|
+
position: sticky;
|
|
59
|
+
z-index: 2;
|
|
60
|
+
top: var(--doc-controls-height);
|
|
61
|
+
border: $style-stroke-width-s solid var(--theme-elevation-150);
|
|
62
|
+
// Make it so border itself is round too and not cut off at the corners
|
|
63
|
+
border-collapse: unset;
|
|
64
|
+
transform: translateY(1px); // aligns with top bar pixel line when stuck
|
|
65
|
+
min-height: 40px; // Reduces shift when saving document if toolbar items did not load yet
|
|
66
|
+
|
|
67
|
+
&__group {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-wrap: wrap;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 2px;
|
|
72
|
+
z-index: 1;
|
|
73
|
+
|
|
74
|
+
.icon {
|
|
75
|
+
min-width: 20px;
|
|
76
|
+
height: 20px;
|
|
77
|
+
color: var(--theme-elevation-600);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.divider {
|
|
81
|
+
width: 1px;
|
|
82
|
+
height: 15px;
|
|
83
|
+
background-color: var(--theme-elevation-100);
|
|
84
|
+
margin: 0 6.25px 0 4.25px; // substract 2px from the gap
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
+ .editor-container {
|
|
89
|
+
> .editor-scroller > .editor {
|
|
90
|
+
> .ContentEditable__root {
|
|
91
|
+
padding-top: calc(var(--base) * 1.25);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
> .editor-scroller > .editor > div > .LexicalEditorTheme__placeholder {
|
|
96
|
+
top: calc(var(--base) * 1.25);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rich-text-lexical--show-gutter {
|
|
102
|
+
.fixed-toolbar {
|
|
103
|
+
+ .editor-container {
|
|
104
|
+
> .editor-scroller > .editor {
|
|
105
|
+
> .ContentEditable__root::before {
|
|
106
|
+
top: calc(var(--base) * 1.25) !important;
|
|
107
|
+
height: calc(100% - calc(var(--base) * 1.25) - 8px) !important;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -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 { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
5
|
import { mergeRegister } from '@lexical/utils';
|
|
@@ -15,20 +15,32 @@ import './index.scss';
|
|
|
15
15
|
import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
|
|
16
16
|
function ButtonGroupItem({ anchorElem, editor, item }) {
|
|
17
17
|
if (item.Component) {
|
|
18
|
-
return item?.Component && /*#__PURE__*/
|
|
18
|
+
return item?.Component && /*#__PURE__*/ _jsxDEV(item.Component, {
|
|
19
19
|
anchorElem: anchorElem,
|
|
20
20
|
editor: editor,
|
|
21
21
|
item: item
|
|
22
|
-
}, item.key
|
|
22
|
+
}, item.key, false, {
|
|
23
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
24
|
+
lineNumber: 41,
|
|
25
|
+
columnNumber: 9
|
|
26
|
+
}, this);
|
|
23
27
|
}
|
|
24
28
|
if (!item.ChildComponent) {
|
|
25
29
|
return null;
|
|
26
30
|
}
|
|
27
|
-
return /*#__PURE__*/
|
|
31
|
+
return /*#__PURE__*/ _jsxDEV(ToolbarButton, {
|
|
28
32
|
editor: editor,
|
|
29
33
|
item: item,
|
|
30
|
-
children: /*#__PURE__*/
|
|
31
|
-
|
|
34
|
+
children: /*#__PURE__*/ _jsxDEV(item.ChildComponent, {}, void 0, false, {
|
|
35
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
36
|
+
lineNumber: 51,
|
|
37
|
+
columnNumber: 7
|
|
38
|
+
}, this)
|
|
39
|
+
}, item.key, false, {
|
|
40
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
41
|
+
lineNumber: 50,
|
|
42
|
+
columnNumber: 5
|
|
43
|
+
}, this);
|
|
32
44
|
}
|
|
33
45
|
function ToolbarGroupComponent({ anchorElem, editor, group, index }) {
|
|
34
46
|
const { editorConfig } = useEditorConfigContext();
|
|
@@ -56,36 +68,56 @@ function ToolbarGroupComponent({ anchorElem, editor, group, index }) {
|
|
|
56
68
|
}, [
|
|
57
69
|
group
|
|
58
70
|
]);
|
|
59
|
-
return /*#__PURE__*/
|
|
71
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
60
72
|
className: `inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`,
|
|
61
73
|
"data-toolbar-group-key": group.key,
|
|
62
74
|
children: [
|
|
63
|
-
group.type === 'dropdown' && group.items.length ? DropdownIcon ? /*#__PURE__*/
|
|
75
|
+
group.type === 'dropdown' && group.items.length ? DropdownIcon ? /*#__PURE__*/ _jsxDEV(ToolbarDropdown, {
|
|
64
76
|
anchorElem: anchorElem,
|
|
65
77
|
editor: editor,
|
|
66
78
|
group: group,
|
|
67
79
|
Icon: DropdownIcon,
|
|
68
80
|
maxActiveItems: group.maxActiveItems ?? 1,
|
|
69
81
|
onActiveChange: onActiveChange
|
|
70
|
-
}
|
|
82
|
+
}, void 0, false, {
|
|
83
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
84
|
+
lineNumber: 103,
|
|
85
|
+
columnNumber: 11
|
|
86
|
+
}, this) : /*#__PURE__*/ _jsxDEV(ToolbarDropdown, {
|
|
71
87
|
anchorElem: anchorElem,
|
|
72
88
|
editor: editor,
|
|
73
89
|
group: group,
|
|
74
90
|
maxActiveItems: group.maxActiveItems ?? 1,
|
|
75
91
|
onActiveChange: onActiveChange
|
|
76
|
-
}
|
|
92
|
+
}, void 0, false, {
|
|
93
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
94
|
+
lineNumber: 112,
|
|
95
|
+
columnNumber: 11
|
|
96
|
+
}, this) : null,
|
|
77
97
|
group.type === 'buttons' && group.items.length ? group.items.map((item)=>{
|
|
78
|
-
return /*#__PURE__*/
|
|
98
|
+
return /*#__PURE__*/ _jsxDEV(ButtonGroupItem, {
|
|
79
99
|
anchorElem: anchorElem,
|
|
80
100
|
editor: editor,
|
|
81
101
|
item: item
|
|
82
|
-
}, item.key
|
|
102
|
+
}, item.key, false, {
|
|
103
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
104
|
+
lineNumber: 124,
|
|
105
|
+
columnNumber: 15
|
|
106
|
+
}, this);
|
|
83
107
|
}) : null,
|
|
84
|
-
index < editorConfig.features.toolbarInline?.groups.length - 1 && /*#__PURE__*/
|
|
108
|
+
index < editorConfig.features.toolbarInline?.groups.length - 1 && /*#__PURE__*/ _jsxDEV("div", {
|
|
85
109
|
className: "divider"
|
|
86
|
-
}
|
|
110
|
+
}, void 0, false, {
|
|
111
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
112
|
+
lineNumber: 129,
|
|
113
|
+
columnNumber: 9
|
|
114
|
+
}, this)
|
|
87
115
|
]
|
|
88
|
-
}, group.key
|
|
116
|
+
}, group.key, true, {
|
|
117
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
118
|
+
lineNumber: 96,
|
|
119
|
+
columnNumber: 5
|
|
120
|
+
}, this);
|
|
89
121
|
}
|
|
90
122
|
function InlineToolbar({ anchorElem, editor }) {
|
|
91
123
|
const floatingToolbarRef = useRef(null);
|
|
@@ -223,24 +255,36 @@ function InlineToolbar({ anchorElem, editor }) {
|
|
|
223
255
|
editor,
|
|
224
256
|
$updateTextFormatFloatingToolbar
|
|
225
257
|
]);
|
|
226
|
-
return /*#__PURE__*/
|
|
258
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
227
259
|
className: "inline-toolbar-popup",
|
|
228
260
|
ref: floatingToolbarRef,
|
|
229
261
|
children: [
|
|
230
|
-
/*#__PURE__*/
|
|
262
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
231
263
|
className: "caret",
|
|
232
264
|
ref: caretRef
|
|
233
|
-
}
|
|
265
|
+
}, void 0, false, {
|
|
266
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
267
|
+
lineNumber: 300,
|
|
268
|
+
columnNumber: 7
|
|
269
|
+
}, this),
|
|
234
270
|
editorConfig?.features && editorConfig.features?.toolbarInline?.groups.map((group, i)=>{
|
|
235
|
-
return /*#__PURE__*/
|
|
271
|
+
return /*#__PURE__*/ _jsxDEV(ToolbarGroupComponent, {
|
|
236
272
|
anchorElem: anchorElem,
|
|
237
273
|
editor: editor,
|
|
238
274
|
group: group,
|
|
239
275
|
index: i
|
|
240
|
-
}, group.key
|
|
276
|
+
}, group.key, false, {
|
|
277
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
278
|
+
lineNumber: 304,
|
|
279
|
+
columnNumber: 13
|
|
280
|
+
}, this);
|
|
241
281
|
})
|
|
242
282
|
]
|
|
243
|
-
}
|
|
283
|
+
}, void 0, true, {
|
|
284
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
285
|
+
lineNumber: 299,
|
|
286
|
+
columnNumber: 5
|
|
287
|
+
}, this);
|
|
244
288
|
}
|
|
245
289
|
function useInlineToolbar(editor, anchorElem) {
|
|
246
290
|
const [isText, setIsText] = useState(false);
|
|
@@ -311,10 +355,14 @@ function useInlineToolbar(editor, anchorElem) {
|
|
|
311
355
|
if (!isText || !isEditable) {
|
|
312
356
|
return null;
|
|
313
357
|
}
|
|
314
|
-
return /*#__PURE__*/ createPortal(/*#__PURE__*/
|
|
358
|
+
return /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsxDEV(InlineToolbar, {
|
|
315
359
|
anchorElem: anchorElem,
|
|
316
360
|
editor: editor
|
|
317
|
-
}
|
|
361
|
+
}, void 0, false, {
|
|
362
|
+
fileName: "src/features/toolbars/inline/client/Toolbar/index.tsx",
|
|
363
|
+
lineNumber: 399,
|
|
364
|
+
columnNumber: 23
|
|
365
|
+
}, this), anchorElem);
|
|
318
366
|
}
|
|
319
367
|
export const InlineToolbarPlugin = ({ anchorElem })=>{
|
|
320
368
|
const [editor] = useLexicalComposerContext();
|