@webiny/lexical-editor 6.3.0 → 6.4.0-beta.1
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/commands/image.js +2 -1
- package/commands/image.js.map +1 -1
- package/commands/index.js +0 -2
- package/commands/list.js +4 -3
- package/commands/list.js.map +1 -1
- package/commands/quote.js +2 -1
- package/commands/quote.js.map +1 -1
- package/commands/toolbar.js +2 -1
- package/commands/toolbar.js.map +1 -1
- package/commands/typography.js +2 -1
- package/commands/typography.js.map +1 -1
- package/components/Editor/EnsureHeadingTagPlugin.js +8 -15
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
- package/components/Editor/RichTextEditor.js +82 -121
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.js +11 -13
- package/components/Editor/normalizeInputValue.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -15
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.js +21 -26
- package/components/LexicalEditorConfig/components/Node.js.map +1 -1
- package/components/LexicalEditorConfig/components/Plugin.js +21 -26
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +21 -26
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
- package/components/LexicalHtmlRenderer.js +35 -40
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.js +11 -16
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +16 -19
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +24 -32
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js +16 -19
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +32 -38
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.js +28 -30
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js +16 -19
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js +25 -30
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +28 -37
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +22 -27
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js +38 -50
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +69 -99
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js +16 -19
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +3 -2
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.js +26 -29
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.js +11 -15
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.js +3 -2
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.js +3 -2
- package/context/TypographyActionContext.js.map +1 -1
- package/exports/admin/lexical.js +2 -20
- package/hooks/index.js +0 -2
- package/hooks/useCurrentElement.js +18 -21
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.js +39 -48
- package/hooks/useCurrentSelection.js.map +1 -1
- package/hooks/useFontColorPicker.js +5 -6
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useIsMounted.js +7 -8
- package/hooks/useIsMounted.js.map +1 -1
- package/hooks/useRichTextEditor.js +5 -6
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.js +5 -6
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.js +5 -6
- package/hooks/useTypographyAction.js.map +1 -1
- package/images/icons/chat-square-quote.js +19 -0
- package/images/icons/chat-square-quote.js.map +1 -0
- package/images/icons/chevron-down.js +18 -0
- package/images/icons/chevron-down.js.map +1 -0
- package/images/icons/code.js +17 -0
- package/images/icons/code.js.map +1 -0
- package/images/icons/font-color.js +17 -0
- package/images/icons/font-color.js.map +1 -0
- package/images/icons/indent.js +18 -0
- package/images/icons/indent.js.map +1 -0
- package/images/icons/insert-image.js +20 -0
- package/images/icons/insert-image.js.map +1 -0
- package/images/icons/justify.js +19 -0
- package/images/icons/justify.js.map +1 -0
- package/images/icons/link.js +19 -0
- package/images/icons/link.js.map +1 -0
- package/images/icons/list-ol.js +20 -0
- package/images/icons/list-ol.js.map +1 -0
- package/images/icons/list-ul.js +18 -0
- package/images/icons/list-ul.js.map +1 -0
- package/images/icons/outdent.js +18 -0
- package/images/icons/outdent.js.map +1 -0
- package/images/icons/pencil-fill.js +17 -0
- package/images/icons/pencil-fill.js.map +1 -0
- package/images/icons/text-center.js +18 -0
- package/images/icons/text-center.js.map +1 -0
- package/images/icons/text-left.js +18 -0
- package/images/icons/text-left.js.map +1 -0
- package/images/icons/text-paragraph.js +18 -0
- package/images/icons/text-paragraph.js.map +1 -0
- package/images/icons/text-right.js +18 -0
- package/images/icons/text-right.js.map +1 -0
- package/images/icons/type-bold.js +17 -0
- package/images/icons/type-bold.js.map +1 -0
- package/images/icons/type-h1.js +17 -0
- package/images/icons/type-h1.js.map +1 -0
- package/images/icons/type-h2.js +17 -0
- package/images/icons/type-h2.js.map +1 -0
- package/images/icons/type-h3.js +17 -0
- package/images/icons/type-h3.js.map +1 -0
- package/images/icons/type-h4.js +17 -0
- package/images/icons/type-h4.js.map +1 -0
- package/images/icons/type-h5.js +17 -0
- package/images/icons/type-h5.js.map +1 -0
- package/images/icons/type-h6.js +17 -0
- package/images/icons/type-h6.js.map +1 -0
- package/images/icons/type-italic.js +17 -0
- package/images/icons/type-italic.js.map +1 -0
- package/images/icons/type-strikethrough.js +17 -0
- package/images/icons/type-strikethrough.js.map +1 -0
- package/images/icons/type-underline.js +17 -0
- package/images/icons/type-underline.js.map +1 -0
- package/images/icons/unlink_icon.js +27 -0
- package/images/icons/unlink_icon.js.map +1 -0
- package/index.js +5 -18
- package/package.json +7 -7
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +11 -14
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +7 -8
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.js +0 -2
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +16 -24
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +37 -51
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +6 -5
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +0 -2
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +6 -9
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/types.js +0 -3
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +101 -108
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js +14 -19
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.js +5 -4
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToSelection.js +42 -60
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.js +79 -121
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +46 -52
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +44 -52
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -19
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
- package/plugins/StateHandlingPlugin.js +55 -64
- package/plugins/StateHandlingPlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +13 -20
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/static/svg/chat-square-quote.123cfa24.svg +1 -0
- package/static/svg/chevron-down.d9636921.svg +1 -0
- package/static/svg/code.912b1f4d.svg +1 -0
- package/static/svg/font-color.4f0c0de5.svg +1 -0
- package/static/svg/indent.4d78e483.svg +3 -0
- package/static/svg/insert-image.354465f1.svg +4 -0
- package/static/svg/justify.dab42aec.svg +3 -0
- package/static/svg/link.b774de25.svg +1 -0
- package/static/svg/list-ol.d64946f3.svg +1 -0
- package/static/svg/list-ul.1d54da3f.svg +1 -0
- package/static/svg/outdent.5c13ff16.svg +3 -0
- package/static/svg/pencil-fill.94cb216b.svg +1 -0
- package/static/svg/text-center.a411e780.svg +1 -0
- package/static/svg/text-left.54f41f4e.svg +1 -0
- package/static/svg/text-paragraph.61674422.svg +1 -0
- package/static/svg/text-right.9288b7a2.svg +1 -0
- package/static/svg/type-bold.7e3e270b.svg +1 -0
- package/static/svg/type-h1.f292ffe1.svg +1 -0
- package/static/svg/type-h2.a9d1aa48.svg +1 -0
- package/static/svg/type-h3.4a29ff88.svg +1 -0
- package/static/svg/type-h4.7f48750c.svg +1 -0
- package/static/svg/type-h5.14b4ac56.svg +1 -0
- package/static/svg/type-h6.4e9dfe2d.svg +1 -0
- package/static/svg/type-italic.d8e45748.svg +1 -0
- package/static/svg/type-strikethrough.2694a816.svg +1 -0
- package/static/svg/type-underline.104a0ed5.svg +1 -0
- package/static/svg/unlink_icon.074ceed3.svg +1 -0
- package/types.js +0 -8
- package/ui/ContentEditable.js +6 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.js +6 -5
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.js +146 -176
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.js +173 -204
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.js +61 -84
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.js +9 -20
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.js +17 -30
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.js +64 -73
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.js +2 -1
- package/utils/canUseDOM.js.map +1 -1
- package/utils/files.js +9 -8
- package/utils/files.js.map +1 -1
- package/utils/getDOMRangeRect.js +10 -20
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.js +9 -20
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.js +2 -3
- package/utils/getTransparentImage.js.map +1 -1
- package/utils/insertImage.js +9 -11
- package/utils/insertImage.js.map +1 -1
- package/utils/isAnchorLink.js +2 -3
- package/utils/isAnchorLink.js.map +1 -1
- package/utils/isChildOfFloatingToolbar.js +6 -9
- package/utils/isChildOfFloatingToolbar.js.map +1 -1
- package/utils/isHTMLElement.js +3 -9
- package/utils/isHTMLElement.js.map +1 -1
- package/utils/isValidJSON.js +9 -10
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.js +17 -20
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +32 -45
- package/utils/point.js.map +1 -1
- package/utils/rect.js +92 -125
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +8 -21
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.js +23 -27
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/commands/index.js.map +0 -1
- package/exports/admin/lexical.js.map +0 -1
- package/hooks/index.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/CodeHighlightPlugin/index.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/index.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/types.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { Property } from "@webiny/react-properties";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
value: name
|
|
23
|
-
}), element ? /*#__PURE__*/React.createElement(Property, {
|
|
24
|
-
id: `plugin:${name}:element`,
|
|
25
|
-
name: "element",
|
|
26
|
-
value: element
|
|
27
|
-
}) : null);
|
|
3
|
+
const Plugin = ({ name, element, after, before, remove = false })=>{
|
|
4
|
+
const placeBefore = void 0 !== before ? `plugin:${before}` : void 0;
|
|
5
|
+
const placeAfter = void 0 !== after ? `plugin:${after}` : void 0;
|
|
6
|
+
return /*#__PURE__*/ react.createElement(Property, {
|
|
7
|
+
id: `plugins:${name}`,
|
|
8
|
+
name: "plugins",
|
|
9
|
+
array: true,
|
|
10
|
+
before: placeBefore,
|
|
11
|
+
after: placeAfter,
|
|
12
|
+
remove: remove
|
|
13
|
+
}, /*#__PURE__*/ react.createElement(Property, {
|
|
14
|
+
id: `plugin:${name}:name`,
|
|
15
|
+
name: "name",
|
|
16
|
+
value: name
|
|
17
|
+
}), element ? /*#__PURE__*/ react.createElement(Property, {
|
|
18
|
+
id: `plugin:${name}:element`,
|
|
19
|
+
name: "element",
|
|
20
|
+
value: element
|
|
21
|
+
}) : null);
|
|
28
22
|
};
|
|
23
|
+
export { Plugin };
|
|
29
24
|
|
|
30
25
|
//# sourceMappingURL=Plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/LexicalEditorConfig/components/Plugin.js","sources":["../../../../src/components/LexicalEditorConfig/components/Plugin.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\n\nexport interface PluginConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface PluginProps {\n name: string;\n element?: React.ReactElement<unknown>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Plugin = ({\n name,\n element,\n after = undefined,\n before = undefined,\n remove = false\n}: PluginProps) => {\n const placeBefore = before !== undefined ? `plugin:${before}` : undefined;\n const placeAfter = after !== undefined ? `plugin:${after}` : undefined;\n\n return (\n <Property\n id={`plugins:${name}`}\n name={\"plugins\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`plugin:${name}:name`} name={\"name\"} value={name} />\n {element ? (\n <Property id={`plugin:${name}:element`} name={\"element\"} value={element} />\n ) : null}\n </Property>\n );\n};\n"],"names":["Plugin","name","element","after","before","remove","placeBefore","undefined","placeAfter","Property"],"mappings":";;AAgBO,MAAMA,SAAS,CAAC,EACnBC,IAAI,EACJC,OAAO,EACPC,KAAiB,EACjBC,MAAkB,EAClBC,SAAS,KAAK,EACJ;IACV,MAAMC,cAAcF,AAAWG,WAAXH,SAAuB,CAAC,OAAO,EAAEA,QAAQ,GAAGG;IAChE,MAAMC,aAAaL,AAAUI,WAAVJ,QAAsB,CAAC,OAAO,EAAEA,OAAO,GAAGI;IAE7D,OAAO,WAAP,GACI,oBAACE,UAAQA;QACL,IAAI,CAAC,QAAQ,EAAER,MAAM;QACrB,MAAM;QACN,OAAO;QACP,QAAQK;QACR,OAAOE;QACP,QAAQH;qBAER,oBAACI,UAAQA;QAAC,IAAI,CAAC,OAAO,EAAER,KAAK,KAAK,CAAC;QAAE,MAAM;QAAQ,OAAOA;QACzDC,UAAU,WAAVA,GACG,oBAACO,UAAQA;QAAC,IAAI,CAAC,OAAO,EAAER,KAAK,QAAQ,CAAC;QAAE,MAAM;QAAW,OAAOC;SAChE;AAGhB"}
|
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { Property } from "@webiny/react-properties";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
value: name
|
|
23
|
-
}), element ? /*#__PURE__*/React.createElement(Property, {
|
|
24
|
-
id: `element:${name}:element`,
|
|
25
|
-
name: "element",
|
|
26
|
-
value: element
|
|
27
|
-
}) : null);
|
|
3
|
+
const ToolbarElement = ({ name, element, after, before, remove = false })=>{
|
|
4
|
+
const placeBefore = void 0 !== before ? `element:${before}` : void 0;
|
|
5
|
+
const placeAfter = void 0 !== after ? `element:${after}` : void 0;
|
|
6
|
+
return /*#__PURE__*/ react.createElement(Property, {
|
|
7
|
+
id: `element:${name}`,
|
|
8
|
+
name: "toolbarElements",
|
|
9
|
+
array: true,
|
|
10
|
+
before: placeBefore,
|
|
11
|
+
after: placeAfter,
|
|
12
|
+
remove: remove
|
|
13
|
+
}, /*#__PURE__*/ react.createElement(Property, {
|
|
14
|
+
id: `element:${name}:name`,
|
|
15
|
+
name: "name",
|
|
16
|
+
value: name
|
|
17
|
+
}), element ? /*#__PURE__*/ react.createElement(Property, {
|
|
18
|
+
id: `element:${name}:element`,
|
|
19
|
+
name: "element",
|
|
20
|
+
value: element
|
|
21
|
+
}) : null);
|
|
28
22
|
};
|
|
23
|
+
export { ToolbarElement };
|
|
29
24
|
|
|
30
25
|
//# sourceMappingURL=ToolbarElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/LexicalEditorConfig/components/ToolbarElement.js","sources":["../../../../src/components/LexicalEditorConfig/components/ToolbarElement.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\n\nexport interface ToolbarElementConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface ToolbarElementProps {\n name: string;\n element?: React.ReactElement<unknown>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const ToolbarElement = ({\n name,\n element,\n after = undefined,\n before = undefined,\n remove = false\n}: ToolbarElementProps) => {\n const placeBefore = before !== undefined ? `element:${before}` : undefined;\n const placeAfter = after !== undefined ? `element:${after}` : undefined;\n\n return (\n <Property\n id={`element:${name}`}\n name={\"toolbarElements\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`element:${name}:name`} name={\"name\"} value={name} />\n {element ? (\n <Property id={`element:${name}:element`} name={\"element\"} value={element} />\n ) : null}\n </Property>\n );\n};\n"],"names":["ToolbarElement","name","element","after","before","remove","placeBefore","undefined","placeAfter","Property"],"mappings":";;AAgBO,MAAMA,iBAAiB,CAAC,EAC3BC,IAAI,EACJC,OAAO,EACPC,KAAiB,EACjBC,MAAkB,EAClBC,SAAS,KAAK,EACI;IAClB,MAAMC,cAAcF,AAAWG,WAAXH,SAAuB,CAAC,QAAQ,EAAEA,QAAQ,GAAGG;IACjE,MAAMC,aAAaL,AAAUI,WAAVJ,QAAsB,CAAC,QAAQ,EAAEA,OAAO,GAAGI;IAE9D,OAAO,WAAP,GACI,oBAACE,UAAQA;QACL,IAAI,CAAC,QAAQ,EAAER,MAAM;QACrB,MAAM;QACN,OAAO;QACP,QAAQK;QACR,OAAOE;QACP,QAAQH;qBAER,oBAACI,UAAQA;QAAC,IAAI,CAAC,QAAQ,EAAER,KAAK,KAAK,CAAC;QAAE,MAAM;QAAQ,OAAOA;QAC1DC,UAAU,WAAVA,GACG,oBAACO,UAAQA;QAAC,IAAI,CAAC,QAAQ,EAAER,KAAK,QAAQ,CAAC;QAAE,MAAM;QAAW,OAAOC;SACjE;AAGhB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { useRef } from "react";
|
|
2
2
|
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
3
3
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
4
4
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
@@ -6,45 +6,40 @@ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary.js";
|
|
|
6
6
|
import { allNodes } from "@webiny/lexical-nodes";
|
|
7
7
|
import { RichTextEditorProvider } from "../context/RichTextEditorContext.js";
|
|
8
8
|
import { StateHandlingPlugin } from "../plugins/StateHandlingPlugin.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, /*#__PURE__*/React.createElement(ContentEditable, null)),
|
|
43
|
-
ErrorBoundary: LexicalErrorBoundary,
|
|
44
|
-
placeholder: null
|
|
45
|
-
}), /*#__PURE__*/React.createElement(StateHandlingPlugin, {
|
|
46
|
-
value: value
|
|
47
|
-
})));
|
|
9
|
+
const LexicalHtmlRenderer = ({ nodes, value, ...props })=>{
|
|
10
|
+
const theme = props.theme;
|
|
11
|
+
const editorTheme = useRef(theme);
|
|
12
|
+
const initialConfig = {
|
|
13
|
+
editorState: null,
|
|
14
|
+
namespace: "webiny",
|
|
15
|
+
onError: ()=>{},
|
|
16
|
+
editable: false,
|
|
17
|
+
nodes: [
|
|
18
|
+
...allNodes,
|
|
19
|
+
...nodes || []
|
|
20
|
+
],
|
|
21
|
+
theme: {
|
|
22
|
+
...editorTheme.current.tokens,
|
|
23
|
+
$colors: editorTheme.current.colors,
|
|
24
|
+
$typography: editorTheme.current.typography,
|
|
25
|
+
$cacheKey: JSON.stringify(editorTheme.current)
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/ react.createElement(LexicalComposer, {
|
|
29
|
+
initialConfig: initialConfig,
|
|
30
|
+
key: initialConfig.nodes.length
|
|
31
|
+
}, /*#__PURE__*/ react.createElement(RichTextEditorProvider, {
|
|
32
|
+
theme: theme
|
|
33
|
+
}, /*#__PURE__*/ react.createElement(RichTextPlugin, {
|
|
34
|
+
contentEditable: /*#__PURE__*/ react.createElement("div", {
|
|
35
|
+
className: "editor"
|
|
36
|
+
}, /*#__PURE__*/ react.createElement(ContentEditable, null)),
|
|
37
|
+
ErrorBoundary: LexicalErrorBoundary,
|
|
38
|
+
placeholder: null
|
|
39
|
+
}), /*#__PURE__*/ react.createElement(StateHandlingPlugin, {
|
|
40
|
+
value: value
|
|
41
|
+
})));
|
|
48
42
|
};
|
|
43
|
+
export { LexicalHtmlRenderer };
|
|
49
44
|
|
|
50
45
|
//# sourceMappingURL=LexicalHtmlRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/LexicalHtmlRenderer.js","sources":["../../src/components/LexicalHtmlRenderer.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary.js\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport type { LexicalValue } from \"~/types.js\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n theme: EditorTheme;\n}\n\nexport const LexicalHtmlRenderer = ({ nodes, value, ...props }: LexicalHtmlRendererProps) => {\n const theme: EditorTheme = props.theme;\n const editorTheme = useRef(theme);\n\n const initialConfig = {\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n editable: false,\n nodes: [...allNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider theme={theme}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <StateHandlingPlugin value={value} />\n </RichTextEditorProvider>\n </LexicalComposer>\n );\n};\n"],"names":["LexicalHtmlRenderer","nodes","value","props","theme","editorTheme","useRef","initialConfig","allNodes","JSON","LexicalComposer","RichTextEditorProvider","RichTextPlugin","ContentEditable","LexicalErrorBoundary","StateHandlingPlugin"],"mappings":";;;;;;;;AAkBO,MAAMA,sBAAsB,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGC,OAAiC;IACpF,MAAMC,QAAqBD,MAAM,KAAK;IACtC,MAAME,cAAcC,OAAOF;IAE3B,MAAMG,gBAAgB;QAClB,aAAa;QACb,WAAW;QACX,SAAS,KAGT;QACA,UAAU;QACV,OAAO;eAAIC;eAAcP,SAAS,EAAE;SAAE;QACtC,OAAO;YACH,GAAGI,YAAY,OAAO,CAAC,MAAM;YAG7B,SAASA,YAAY,OAAO,CAAC,MAAM;YACnC,aAAaA,YAAY,OAAO,CAAC,UAAU;YAC3C,WAAWI,KAAK,SAAS,CAACJ,YAAY,OAAO;QACjD;IACJ;IAEA,OAAO,WAAP,GACI,oBAACK,iBAAeA;QAAC,eAAeH;QAAe,KAAKA,cAAc,KAAK,CAAC,MAAM;qBAC1E,oBAACI,wBAAsBA;QAAC,OAAOP;qBAC3B,oBAACQ,gBAAcA;QACX,+BACI,oBAAC;YAAI,WAAU;yBACX,oBAACC,iBAAeA;QAGxB,eAAeC;QACf,aAAa;sBAEjB,oBAACC,qBAAmBA;QAAC,OAAOb;;AAI5C"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { Fragment } from "react";
|
|
2
2
|
import "./StaticToolbar.css";
|
|
3
3
|
import { useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig.js";
|
|
4
4
|
import { useRichTextEditor } from "../../hooks/index.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
-
className: className ?? "static-toolbar",
|
|
16
|
-
"data-role": "toolbar"
|
|
17
|
-
}, editor.isEditable() && /*#__PURE__*/React.createElement(React.Fragment, null, toolbarElements.map(action => /*#__PURE__*/React.createElement(Fragment, {
|
|
18
|
-
key: action.name
|
|
19
|
-
}, action.element))));
|
|
5
|
+
const StaticToolbar = ({ className })=>{
|
|
6
|
+
const { toolbarElements } = useLexicalEditorConfig();
|
|
7
|
+
const { editor } = useRichTextEditor();
|
|
8
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
9
|
+
className: className ?? "static-toolbar",
|
|
10
|
+
"data-role": "toolbar"
|
|
11
|
+
}, editor.isEditable() && /*#__PURE__*/ react.createElement(react.Fragment, null, toolbarElements.map((action)=>/*#__PURE__*/ react.createElement(Fragment, {
|
|
12
|
+
key: action.name
|
|
13
|
+
}, action.element))));
|
|
20
14
|
};
|
|
15
|
+
export { StaticToolbar };
|
|
21
16
|
|
|
22
17
|
//# sourceMappingURL=StaticToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/Toolbar/StaticToolbar.js","sources":["../../../src/components/Toolbar/StaticToolbar.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport \"./StaticToolbar.css\";\nimport { useLexicalEditorConfig } from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const StaticToolbar = ({ className }: { className?: string }) => {\n const { toolbarElements } = useLexicalEditorConfig();\n const { editor } = useRichTextEditor();\n\n return (\n <div className={className ?? \"static-toolbar\"} data-role={\"toolbar\"}>\n {editor.isEditable() && (\n <>\n {toolbarElements.map(action => (\n <Fragment key={action.name}>{action.element}</Fragment>\n ))}\n </>\n )}\n </div>\n );\n};\n"],"names":["StaticToolbar","className","toolbarElements","useLexicalEditorConfig","editor","useRichTextEditor","action","Fragment"],"mappings":";;;;AAKO,MAAMA,gBAAgB,CAAC,EAAEC,SAAS,EAA0B;IAC/D,MAAM,EAAEC,eAAe,EAAE,GAAGC;IAC5B,MAAM,EAAEC,MAAM,EAAE,GAAGC;IAEnB,OAAO,WAAP,GACI,oBAAC;QAAI,WAAWJ,aAAa;QAAkB,aAAW;OACrDG,OAAO,UAAU,MAAM,WAAN,GACd,0CACKF,gBAAgB,GAAG,CAACI,CAAAA,SAAAA,WAAAA,GACjB,oBAACC,UAAQA;YAAC,KAAKD,OAAO,IAAI;WAAGA,OAAO,OAAO;AAMnE"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { FORMAT_TEXT_COMMAND } from "lexical";
|
|
3
3
|
import { useCurrentSelection } from "../../hooks/useCurrentSelection.js";
|
|
4
4
|
import { useRichTextEditor } from "../../hooks/index.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"aria-label": "Format text as bold"
|
|
20
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
21
|
-
className: "format bold"
|
|
22
|
-
}));
|
|
5
|
+
const BoldAction = ()=>{
|
|
6
|
+
const { editor } = useRichTextEditor();
|
|
7
|
+
const { rangeSelection } = useCurrentSelection();
|
|
8
|
+
const isBoldSelected = rangeSelection ? rangeSelection.hasFormat("bold") : false;
|
|
9
|
+
const handleClick = ()=>{
|
|
10
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
|
|
11
|
+
};
|
|
12
|
+
return /*#__PURE__*/ react.createElement("button", {
|
|
13
|
+
onClick: handleClick,
|
|
14
|
+
className: "popup-item spaced " + (isBoldSelected ? "active" : ""),
|
|
15
|
+
"aria-label": "Format text as bold"
|
|
16
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
17
|
+
className: "format bold"
|
|
18
|
+
}));
|
|
23
19
|
};
|
|
20
|
+
export { BoldAction };
|
|
24
21
|
|
|
25
22
|
//# sourceMappingURL=BoldAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/ToolbarActions/BoldAction.js","sources":["../../../src/components/ToolbarActions/BoldAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { FORMAT_TEXT_COMMAND } from \"lexical\";\nimport { useCurrentSelection } from \"~/hooks/useCurrentSelection.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const BoldAction = () => {\n const { editor } = useRichTextEditor();\n const { rangeSelection } = useCurrentSelection();\n const isBoldSelected = rangeSelection ? rangeSelection.hasFormat(\"bold\") : false;\n\n const handleClick = () => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, \"bold\");\n };\n\n return (\n <button\n onClick={handleClick}\n className={\"popup-item spaced \" + (isBoldSelected ? \"active\" : \"\")}\n aria-label=\"Format text as bold\"\n >\n <i className=\"format bold\" />\n </button>\n );\n};\n"],"names":["BoldAction","editor","useRichTextEditor","rangeSelection","useCurrentSelection","isBoldSelected","handleClick","FORMAT_TEXT_COMMAND"],"mappings":";;;;AAKO,MAAMA,aAAa;IACtB,MAAM,EAAEC,MAAM,EAAE,GAAGC;IACnB,MAAM,EAAEC,cAAc,EAAE,GAAGC;IAC3B,MAAMC,iBAAiBF,iBAAiBA,eAAe,SAAS,CAAC,UAAU;IAE3E,MAAMG,cAAc;QAChBL,OAAO,eAAe,CAACM,qBAAqB;IAChD;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,SAASD;QACT,WAAW,uBAAwBD,CAAAA,iBAAiB,WAAW,EAAC;QAChE,cAAW;qBAEX,oBAAC;QAAE,WAAU;;AAGzB"}
|
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from "../../commands/index.js";
|
|
3
3
|
import { useRichTextEditor } from "../../hooks/useRichTextEditor.js";
|
|
4
4
|
import { $isListNode } from "@webiny/lexical-nodes";
|
|
5
5
|
import { useCurrentElement } from "../../hooks/useCurrentElement.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
element
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
31
|
-
onClick: () => formatBulletList(),
|
|
32
|
-
className: "popup-item spaced " + (isBullet ? "active" : ""),
|
|
33
|
-
"aria-label": "Format text as bullet list"
|
|
34
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
35
|
-
className: "icon bullet-list"
|
|
36
|
-
}));
|
|
6
|
+
const BulletListAction = ()=>{
|
|
7
|
+
const { editor } = useRichTextEditor();
|
|
8
|
+
const { element } = useCurrentElement();
|
|
9
|
+
const { theme } = useRichTextEditor();
|
|
10
|
+
const isList = $isListNode(element);
|
|
11
|
+
const isBullet = isList && "bullet" === element.getListType();
|
|
12
|
+
const formatBulletList = ()=>{
|
|
13
|
+
if (isBullet) editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
|
|
14
|
+
else {
|
|
15
|
+
const styleId = theme.getTypographyByTag("ul")?.id;
|
|
16
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, {
|
|
17
|
+
themeStyleId: styleId
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/ react.createElement("button", {
|
|
22
|
+
onClick: ()=>formatBulletList(),
|
|
23
|
+
className: "popup-item spaced " + (isBullet ? "active" : ""),
|
|
24
|
+
"aria-label": "Format text as bullet list"
|
|
25
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
26
|
+
className: "icon bullet-list"
|
|
27
|
+
}));
|
|
37
28
|
};
|
|
29
|
+
export { BulletListAction };
|
|
38
30
|
|
|
39
31
|
//# sourceMappingURL=BulletListAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/ToolbarActions/BulletListAction.js","sources":["../../../src/components/ToolbarActions/BulletListAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from \"~/commands/index.js\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor.js\";\nimport type { ListNode } from \"@webiny/lexical-nodes\";\nimport { $isListNode } from \"@webiny/lexical-nodes\";\nimport { useCurrentElement } from \"~/hooks/useCurrentElement.js\";\n\nexport const BulletListAction = () => {\n const { editor } = useRichTextEditor();\n const { element } = useCurrentElement();\n const { theme } = useRichTextEditor();\n const isList = $isListNode(element);\n\n const isBullet = isList && (element as ListNode).getListType() === \"bullet\";\n\n const formatBulletList = () => {\n if (!isBullet) {\n const styleId = theme.getTypographyByTag(\"ul\")?.id;\n\n // will update the active state in the useEffect\n editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, { themeStyleId: styleId });\n } else {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);\n }\n };\n\n return (\n <button\n onClick={() => formatBulletList()}\n className={\"popup-item spaced \" + (isBullet ? \"active\" : \"\")}\n aria-label=\"Format text as bullet list\"\n >\n <i className=\"icon bullet-list\" />\n </button>\n );\n};\n"],"names":["BulletListAction","editor","useRichTextEditor","element","useCurrentElement","theme","isList","$isListNode","isBullet","formatBulletList","REMOVE_LIST_COMMAND","undefined","styleId","INSERT_UNORDERED_LIST_COMMAND"],"mappings":";;;;;AAOO,MAAMA,mBAAmB;IAC5B,MAAM,EAAEC,MAAM,EAAE,GAAGC;IACnB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IACpB,MAAM,EAAEC,KAAK,EAAE,GAAGH;IAClB,MAAMI,SAASC,YAAYJ;IAE3B,MAAMK,WAAWF,UAAWH,AAAuC,aAAvCA,QAAqB,WAAW;IAE5D,MAAMM,mBAAmB;QACrB,IAAKD,UAMDP,OAAO,eAAe,CAACS,qBAAqBC;aANjC;YACX,MAAMC,UAAUP,MAAM,kBAAkB,CAAC,OAAO;YAGhDJ,OAAO,eAAe,CAACY,+BAA+B;gBAAE,cAAcD;YAAQ;QAClF;IAGJ;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,SAAS,IAAMH;QACf,WAAW,uBAAwBD,CAAAA,WAAW,WAAW,EAAC;QAC1D,cAAW;qBAEX,oBAAC;QAAE,WAAU;;AAGzB"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { FORMAT_TEXT_COMMAND } from "lexical";
|
|
3
3
|
import { useCurrentSelection } from "../../hooks/useCurrentSelection.js";
|
|
4
4
|
import { useRichTextEditor } from "../../hooks/index.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"aria-label": "Text code highlight"
|
|
20
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
21
|
-
className: "format code"
|
|
22
|
-
}));
|
|
5
|
+
const CodeHighlightAction = ()=>{
|
|
6
|
+
const { editor } = useRichTextEditor();
|
|
7
|
+
const { rangeSelection } = useCurrentSelection();
|
|
8
|
+
const isCodeSelected = rangeSelection ? rangeSelection.hasFormat("code") : false;
|
|
9
|
+
const handleClick = ()=>{
|
|
10
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "code");
|
|
11
|
+
};
|
|
12
|
+
return /*#__PURE__*/ react.createElement("button", {
|
|
13
|
+
onClick: handleClick,
|
|
14
|
+
className: "popup-item spaced " + (isCodeSelected ? "active" : ""),
|
|
15
|
+
"aria-label": "Text code highlight"
|
|
16
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
17
|
+
className: "format code"
|
|
18
|
+
}));
|
|
23
19
|
};
|
|
20
|
+
export { CodeHighlightAction };
|
|
24
21
|
|
|
25
22
|
//# sourceMappingURL=CodeHighlightAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/ToolbarActions/CodeHighlightAction.js","sources":["../../../src/components/ToolbarActions/CodeHighlightAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { FORMAT_TEXT_COMMAND } from \"lexical\";\nimport { useCurrentSelection } from \"~/hooks/useCurrentSelection.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const CodeHighlightAction = () => {\n const { editor } = useRichTextEditor();\n const { rangeSelection } = useCurrentSelection();\n const isCodeSelected = rangeSelection ? rangeSelection.hasFormat(\"code\") : false;\n\n const handleClick = () => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, \"code\");\n };\n\n return (\n <button\n onClick={handleClick}\n className={\"popup-item spaced \" + (isCodeSelected ? \"active\" : \"\")}\n aria-label=\"Text code highlight\"\n >\n <i className=\"format code\" />\n </button>\n );\n};\n"],"names":["CodeHighlightAction","editor","useRichTextEditor","rangeSelection","useCurrentSelection","isCodeSelected","handleClick","FORMAT_TEXT_COMMAND"],"mappings":";;;;AAKO,MAAMA,sBAAsB;IAC/B,MAAM,EAAEC,MAAM,EAAE,GAAGC;IACnB,MAAM,EAAEC,cAAc,EAAE,GAAGC;IAC3B,MAAMC,iBAAiBF,iBAAiBA,eAAe,SAAS,CAAC,UAAU;IAE3E,MAAMG,cAAc;QAChBL,OAAO,eAAe,CAACM,qBAAqB;IAChD;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,SAASD;QACT,WAAW,uBAAwBD,CAAAA,iBAAiB,WAAW,EAAC;QAChE,cAAW;qBAEX,oBAAC;QAAE,WAAU;;AAGzB"}
|
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { useCallback, useEffect, useMemo } from "react";
|
|
2
2
|
import { Compose, makeDecoratable } from "@webiny/react-composition";
|
|
3
3
|
import { FontColorActionContext } from "../../context/FontColorActionContext.js";
|
|
4
4
|
import { $isFontColorNode, ADD_FONT_COLOR_COMMAND, ThemeColorValue } from "@webiny/lexical-nodes";
|
|
5
5
|
import { getSelectedNode } from "../../utils/getSelectedNode.js";
|
|
6
6
|
import { useDeriveValueFromSelection } from "../../hooks/useCurrentSelection.js";
|
|
7
7
|
import { useRichTextEditor } from "../../hooks/index.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const FontColorPicker = makeDecoratable("FontColorPicker", ()=>{
|
|
9
|
+
useEffect(()=>{
|
|
10
|
+
console.log("Default FontColorPicker, please add your own component");
|
|
11
|
+
}, []);
|
|
12
|
+
return null;
|
|
13
13
|
});
|
|
14
|
-
const FontActionColorPicker = ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
editor
|
|
25
|
-
} = useRichTextEditor();
|
|
26
|
-
const fontColor = useDeriveValueFromSelection(({
|
|
27
|
-
rangeSelection
|
|
28
|
-
}) => {
|
|
29
|
-
if (!rangeSelection) {
|
|
30
|
-
return "#000";
|
|
31
|
-
}
|
|
32
|
-
const node = getSelectedNode(rangeSelection);
|
|
33
|
-
return $isFontColorNode(node) ? node.getColorStyle().color : "#000";
|
|
34
|
-
});
|
|
35
|
-
const onFontColorSelect = useCallback((colorValue, themeColorName) => {
|
|
36
|
-
editor.dispatchCommand(ADD_FONT_COLOR_COMMAND, {
|
|
37
|
-
color: new ThemeColorValue(colorValue, themeColorName)
|
|
14
|
+
const FontActionColorPicker = ({ element })=>/*#__PURE__*/ react.createElement(Compose, {
|
|
15
|
+
component: FontColorPicker,
|
|
16
|
+
with: ()=>()=>element
|
|
17
|
+
});
|
|
18
|
+
const FontColorAction = ()=>{
|
|
19
|
+
const { editor } = useRichTextEditor();
|
|
20
|
+
const fontColor = useDeriveValueFromSelection(({ rangeSelection })=>{
|
|
21
|
+
if (!rangeSelection) return "#000";
|
|
22
|
+
const node = getSelectedNode(rangeSelection);
|
|
23
|
+
return $isFontColorNode(node) ? node.getColorStyle().color : "#000";
|
|
38
24
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
const onFontColorSelect = useCallback((colorValue, themeColorName)=>{
|
|
26
|
+
editor.dispatchCommand(ADD_FONT_COLOR_COMMAND, {
|
|
27
|
+
color: new ThemeColorValue(colorValue, themeColorName)
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
const context = useMemo(()=>({
|
|
31
|
+
value: fontColor,
|
|
32
|
+
applyColor: onFontColorSelect
|
|
33
|
+
}), [
|
|
34
|
+
onFontColorSelect,
|
|
35
|
+
fontColor
|
|
36
|
+
]);
|
|
37
|
+
return /*#__PURE__*/ react.createElement(FontColorActionContext.Provider, {
|
|
38
|
+
value: context
|
|
39
|
+
}, /*#__PURE__*/ react.createElement(FontColorPicker, null));
|
|
47
40
|
};
|
|
48
41
|
FontColorAction.ColorPicker = FontActionColorPicker;
|
|
42
|
+
export { FontColorAction, FontColorPicker };
|
|
49
43
|
|
|
50
44
|
//# sourceMappingURL=FontColorAction.js.map
|