@webiny/lexical-editor 5.44.1-beta.0 → 5.45.0-beta.0
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/README.md +6 -12
- package/commands/image.d.ts +2 -2
- package/commands/image.js +2 -8
- package/commands/image.js.map +1 -1
- package/commands/index.d.ts +5 -4
- package/commands/index.js +5 -49
- package/commands/index.js.map +1 -1
- package/commands/list.d.ts +1 -1
- package/commands/list.js +4 -10
- package/commands/list.js.map +1 -1
- package/commands/quote.d.ts +1 -1
- package/commands/quote.js +2 -8
- package/commands/quote.js.map +1 -1
- package/commands/toolbar.js +2 -8
- package/commands/toolbar.js.map +1 -1
- package/commands/typography.d.ts +8 -0
- package/commands/typography.js +4 -0
- package/commands/typography.js.map +1 -0
- package/components/Editor/EnsureHeadingTagPlugin.js +10 -16
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
- package/components/Editor/RichTextEditor.d.ts +12 -8
- package/components/Editor/RichTextEditor.js +89 -102
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.d.ts +1 -1
- package/components/Editor/normalizeInputValue.js +2 -8
- package/components/Editor/normalizeInputValue.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +14 -16
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +21 -69
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.d.ts +1 -1
- package/components/LexicalEditorConfig/components/Node.js +17 -26
- package/components/LexicalEditorConfig/components/Node.js.map +1 -1
- package/components/LexicalEditorConfig/components/Plugin.js +17 -26
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
- package/components/LexicalHtmlRenderer.d.ts +4 -7
- package/components/LexicalHtmlRenderer.js +35 -53
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.css +416 -0
- package/components/Toolbar/StaticToolbar.d.ts +3 -1
- package/components/Toolbar/StaticToolbar.js +19 -23
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +16 -21
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +25 -31
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js +16 -21
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +32 -42
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.js +19 -34
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js +16 -21
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js +19 -24
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +25 -36
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +20 -25
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js +36 -45
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +57 -79
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js +16 -21
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +2 -9
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.d.ts +6 -7
- package/context/RichTextEditorContext.js +28 -26
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.d.ts +2 -2
- package/context/SharedHistoryContext.js +12 -20
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.d.ts +1 -1
- package/context/TextAlignmentActionContextProps.js +2 -9
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.d.ts +3 -2
- package/context/TypographyActionContext.js +2 -9
- package/context/TypographyActionContext.js.map +1 -1
- package/exports/admin/lexical.d.ts +15 -0
- package/exports/admin/lexical.js +23 -0
- package/exports/admin/lexical.js.map +1 -0
- package/hooks/index.d.ts +7 -8
- package/hooks/index.js +7 -93
- package/hooks/index.js.map +1 -1
- package/hooks/useCurrentElement.d.ts +3 -3
- package/hooks/useCurrentElement.js +11 -18
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.d.ts +2 -1
- package/hooks/useCurrentSelection.js +27 -40
- package/hooks/useCurrentSelection.js.map +1 -1
- package/hooks/useFontColorPicker.d.ts +1 -1
- package/hooks/useFontColorPicker.js +5 -11
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useIsMounted.js +6 -14
- package/hooks/useIsMounted.js.map +1 -1
- package/hooks/useRichTextEditor.d.ts +1 -1
- package/hooks/useRichTextEditor.js +5 -11
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.d.ts +1 -1
- package/hooks/useTextAlignmentAction.js +5 -11
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.d.ts +1 -1
- package/hooks/useTypographyAction.js +5 -11
- package/hooks/useTypographyAction.js.map +1 -1
- package/index.d.ts +33 -38
- package/index.js +44 -322
- package/index.js.map +1 -1
- package/package.json +18 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
- package/plugins/CodeHighlightPlugin/index.js +1 -16
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +10 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +28 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +61 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -136
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -16
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +7 -180
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +3 -9
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/types.d.ts +10 -0
- package/plugins/FloatingLinkEditorPlugin/types.js +3 -0
- package/plugins/FloatingLinkEditorPlugin/types.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +8 -2
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +120 -88
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js +19 -22
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.d.ts +2 -2
- package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToSelection.d.ts +2 -2
- package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +1 -2
- package/plugins/ImagesPlugin/ImagesPlugin.js +58 -60
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +29 -37
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +52 -15
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +19 -16
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
- package/plugins/StateHandlingPlugin.d.ts +1 -1
- package/plugins/StateHandlingPlugin.js +32 -39
- package/plugins/StateHandlingPlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +17 -21
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/types.d.ts +4 -4
- package/types.js +6 -38
- package/types.js.map +1 -1
- package/ui/ContentEditable.d.ts +0 -1
- package/ui/ContentEditable.js +7 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.d.ts +0 -1
- package/ui/Divider.js +3 -10
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.d.ts +1 -1
- package/ui/DropDown.js +64 -90
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.d.ts +0 -1
- package/ui/ImageResizer.js +78 -83
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.d.ts +0 -1
- package/ui/LinkPreview.js +22 -29
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.d.ts +1 -1
- package/ui/Placeholder.js +10 -16
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.d.ts +0 -1
- package/ui/TextInput.js +11 -18
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.js +30 -42
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.js +1 -7
- package/utils/canUseDOM.js.map +1 -1
- package/utils/files.d.ts +6 -6
- package/utils/files.js +5 -32
- package/utils/files.js.map +1 -1
- package/utils/getDOMRangeRect.js +4 -10
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.d.ts +1 -1
- package/utils/getSelectedNode.js +9 -16
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.js +1 -7
- package/utils/getTransparentImage.js.map +1 -1
- package/utils/insertImage.d.ts +1 -1
- package/utils/insertImage.js +8 -14
- package/utils/insertImage.js.map +1 -1
- package/utils/isAnchorLink.js +1 -7
- package/utils/isAnchorLink.js.map +1 -1
- package/utils/isChildOfFloatingToolbar.js +3 -12
- package/utils/isChildOfFloatingToolbar.js.map +1 -1
- package/utils/isHTMLElement.js +1 -7
- package/utils/isHTMLElement.js.map +1 -1
- package/utils/isValidJSON.js +3 -9
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.d.ts +3 -3
- package/utils/isValidLexicalData.js +6 -12
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +35 -60
- package/utils/point.js.map +1 -1
- package/utils/rect.d.ts +1 -1
- package/utils/rect.js +115 -149
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +6 -13
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.d.ts +1 -1
- package/utils/setFloatingElemPosition.js +24 -30
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/components/Editor/HeadingEditor.d.ts +0 -7
- package/components/Editor/HeadingEditor.js +0 -30
- package/components/Editor/HeadingEditor.js.map +0 -1
- package/components/Editor/ParagraphEditor.d.ts +0 -7
- package/components/Editor/ParagraphEditor.js +0 -29
- package/components/Editor/ParagraphEditor.js.map +0 -1
- package/components/Toolbar/Toolbar.css +0 -643
- package/components/Toolbar/Toolbar.d.ts +0 -11
- package/components/Toolbar/Toolbar.js +0 -165
- package/components/Toolbar/Toolbar.js.map +0 -1
- package/components/ToolbarActions/FontSizeAction.d.ts +0 -14
- package/components/ToolbarActions/FontSizeAction.js +0 -109
- package/components/ToolbarActions/FontSizeAction.js.map +0 -1
- package/hooks/useList.d.ts +0 -2
- package/hooks/useList.js +0 -54
- package/hooks/useList.js.map +0 -1
- package/hooks/useQuote.d.ts +0 -2
- package/hooks/useQuote.js +0 -22
- package/hooks/useQuote.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +0 -9
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +0 -118
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +0 -9
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +0 -44
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +0 -1
- package/utils/generateInitialLexicalValue.d.ts +0 -4
- package/utils/generateInitialLexicalValue.js +0 -33
- package/utils/generateInitialLexicalValue.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","FORMAT_TEXT_COMMAND","useCurrentSelection","useRichTextEditor","BoldAction","editor","rangeSelection","isBoldSelected","hasFormat","handleClick","dispatchCommand","createElement","onClick","className"],"sources":["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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,QAAQ,SAAS;AAC7C,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,UAAU,GAAGA,CAAA,KAAM;EAC5B,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACtC,MAAM;IAAEG;EAAe,CAAC,GAAGJ,mBAAmB,CAAC,CAAC;EAChD,MAAMK,cAAc,GAAGD,cAAc,GAAGA,cAAc,CAACE,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK;EAEhF,MAAMC,WAAW,GAAGA,CAAA,KAAM;IACtBJ,MAAM,CAACK,eAAe,CAACT,mBAAmB,EAAE,MAAM,CAAC;EACvD,CAAC;EAED,oBACID,KAAA,CAAAW,aAAA;IACIC,OAAO,EAAEH,WAAY;IACrBI,SAAS,EAAE,oBAAoB,IAAIN,cAAc,GAAG,QAAQ,GAAG,EAAE,CAAE;IACnE,cAAW;EAAqB,gBAEhCP,KAAA,CAAAW,aAAA;IAAGE,SAAS,EAAC;EAAa,CAAE,CACxB,CAAC;AAEjB,CAAC","ignoreList":[]}
|
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _useRichTextEditor2 = (0, _useRichTextEditor3.useRichTextEditor)(),
|
|
20
|
-
themeEmotionMap = _useRichTextEditor2.themeEmotionMap;
|
|
21
|
-
var isList = (0, _lexicalNodes.$isListNode)(element);
|
|
22
|
-
var isBullet = isList && element.getListType() === "bullet";
|
|
23
|
-
var formatBulletList = function formatBulletList() {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from "../../commands/index.js";
|
|
3
|
+
import { useRichTextEditor } from "../../hooks/useRichTextEditor.js";
|
|
4
|
+
import { $isListNode } from "@webiny/lexical-nodes";
|
|
5
|
+
import { useCurrentElement } from "../../hooks/useCurrentElement.js";
|
|
6
|
+
export const BulletListAction = () => {
|
|
7
|
+
const {
|
|
8
|
+
editor
|
|
9
|
+
} = useRichTextEditor();
|
|
10
|
+
const {
|
|
11
|
+
element
|
|
12
|
+
} = useCurrentElement();
|
|
13
|
+
const {
|
|
14
|
+
theme
|
|
15
|
+
} = useRichTextEditor();
|
|
16
|
+
const isList = $isListNode(element);
|
|
17
|
+
const isBullet = isList && element.getListType() === "bullet";
|
|
18
|
+
const formatBulletList = () => {
|
|
24
19
|
if (!isBullet) {
|
|
25
|
-
|
|
20
|
+
const styleId = theme.getTypographyByTag("ul")?.id;
|
|
21
|
+
|
|
26
22
|
// will update the active state in the useEffect
|
|
27
|
-
editor.dispatchCommand(
|
|
23
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, {
|
|
28
24
|
themeStyleId: styleId
|
|
29
25
|
});
|
|
30
26
|
} else {
|
|
31
|
-
editor.dispatchCommand(
|
|
27
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
32
28
|
}
|
|
33
29
|
};
|
|
34
|
-
return /*#__PURE__*/
|
|
35
|
-
onClick:
|
|
36
|
-
return formatBulletList();
|
|
37
|
-
},
|
|
30
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
31
|
+
onClick: () => formatBulletList(),
|
|
38
32
|
className: "popup-item spaced " + (isBullet ? "active" : ""),
|
|
39
33
|
"aria-label": "Format text as bullet list"
|
|
40
|
-
}, /*#__PURE__*/
|
|
34
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
41
35
|
className: "icon bullet-list"
|
|
42
36
|
}));
|
|
43
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","INSERT_UNORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND","useRichTextEditor","$isListNode","useCurrentElement","BulletListAction","editor","element","theme","isList","isBullet","getListType","formatBulletList","styleId","getTypographyByTag","id","dispatchCommand","themeStyleId","undefined","createElement","onClick","className"],"sources":["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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,6BAA6B,EAAEC,mBAAmB;AAC3D,SAASC,iBAAiB;AAE1B,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAM;IAAEC;EAAO,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EACtC,MAAM;IAAEK;EAAQ,CAAC,GAAGH,iBAAiB,CAAC,CAAC;EACvC,MAAM;IAAEI;EAAM,CAAC,GAAGN,iBAAiB,CAAC,CAAC;EACrC,MAAMO,MAAM,GAAGN,WAAW,CAACI,OAAO,CAAC;EAEnC,MAAMG,QAAQ,GAAGD,MAAM,IAAKF,OAAO,CAAcI,WAAW,CAAC,CAAC,KAAK,QAAQ;EAE3E,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;IAC3B,IAAI,CAACF,QAAQ,EAAE;MACX,MAAMG,OAAO,GAAGL,KAAK,CAACM,kBAAkB,CAAC,IAAI,CAAC,EAAEC,EAAE;;MAElD;MACAT,MAAM,CAACU,eAAe,CAAChB,6BAA6B,EAAE;QAAEiB,YAAY,EAAEJ;MAAQ,CAAC,CAAC;IACpF,CAAC,MAAM;MACHP,MAAM,CAACU,eAAe,CAACf,mBAAmB,EAAEiB,SAAS,CAAC;IAC1D;EACJ,CAAC;EAED,oBACInB,KAAA,CAAAoB,aAAA;IACIC,OAAO,EAAEA,CAAA,KAAMR,gBAAgB,CAAC,CAAE;IAClCS,SAAS,EAAE,oBAAoB,IAAIX,QAAQ,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC7D,cAAW;EAA4B,gBAEvCX,KAAA,CAAAoB,aAAA;IAAGE,SAAS,EAAC;EAAkB,CAAE,CAC7B,CAAC;AAEjB,CAAC","ignoreList":[]}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
editor
|
|
15
|
-
var _useCurrentSelection = (0, _useCurrentSelection2.useCurrentSelection)(),
|
|
16
|
-
rangeSelection = _useCurrentSelection.rangeSelection;
|
|
17
|
-
var isCodeSelected = rangeSelection ? rangeSelection.hasFormat("code") : false;
|
|
18
|
-
var handleClick = function handleClick() {
|
|
19
|
-
editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, "code");
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FORMAT_TEXT_COMMAND } from "lexical";
|
|
3
|
+
import { useCurrentSelection } from "../../hooks/useCurrentSelection.js";
|
|
4
|
+
import { useRichTextEditor } from "../../hooks/index.js";
|
|
5
|
+
export const CodeHighlightAction = () => {
|
|
6
|
+
const {
|
|
7
|
+
editor
|
|
8
|
+
} = useRichTextEditor();
|
|
9
|
+
const {
|
|
10
|
+
rangeSelection
|
|
11
|
+
} = useCurrentSelection();
|
|
12
|
+
const isCodeSelected = rangeSelection ? rangeSelection.hasFormat("code") : false;
|
|
13
|
+
const handleClick = () => {
|
|
14
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "code");
|
|
20
15
|
};
|
|
21
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
22
17
|
onClick: handleClick,
|
|
23
18
|
className: "popup-item spaced " + (isCodeSelected ? "active" : ""),
|
|
24
19
|
"aria-label": "Text code highlight"
|
|
25
|
-
}, /*#__PURE__*/
|
|
20
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
26
21
|
className: "format code"
|
|
27
22
|
}));
|
|
28
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","FORMAT_TEXT_COMMAND","useCurrentSelection","useRichTextEditor","CodeHighlightAction","editor","rangeSelection","isCodeSelected","hasFormat","handleClick","dispatchCommand","createElement","onClick","className"],"sources":["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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,QAAQ,SAAS;AAC7C,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACrC,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACtC,MAAM;IAAEG;EAAe,CAAC,GAAGJ,mBAAmB,CAAC,CAAC;EAChD,MAAMK,cAAc,GAAGD,cAAc,GAAGA,cAAc,CAACE,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK;EAEhF,MAAMC,WAAW,GAAGA,CAAA,KAAM;IACtBJ,MAAM,CAACK,eAAe,CAACT,mBAAmB,EAAE,MAAM,CAAC;EACvD,CAAC;EAED,oBACID,KAAA,CAAAW,aAAA;IACIC,OAAO,EAAEH,WAAY;IACrBI,SAAS,EAAE,oBAAoB,IAAIN,cAAc,GAAG,QAAQ,GAAG,EAAE,CAAE;IACnE,cAAW;EAAqB,gBAEhCP,KAAA,CAAAW,aAAA;IAAGE,SAAS,EAAC;EAAa,CAAE,CACxB,CAAC;AAEjB,CAAC","ignoreList":[]}
|
|
@@ -1,59 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _FontColorActionContext = require("../../context/FontColorActionContext");
|
|
11
|
-
var _lexicalNodes = require("@webiny/lexical-nodes");
|
|
12
|
-
var _getSelectedNode = require("../../utils/getSelectedNode");
|
|
13
|
-
var _useCurrentSelection = require("../../hooks/useCurrentSelection");
|
|
14
|
-
var _hooks = require("../../hooks");
|
|
15
|
-
var FontColorPicker = exports.FontColorPicker = (0, _reactComposition.makeDecoratable)("FontColorPicker", function () {
|
|
16
|
-
(0, _react.useEffect)(function () {
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from "react";
|
|
2
|
+
import { Compose, makeDecoratable } from "@webiny/react-composition";
|
|
3
|
+
import { FontColorActionContext } from "../../context/FontColorActionContext.js";
|
|
4
|
+
import { $isFontColorNode, ADD_FONT_COLOR_COMMAND, ThemeColorValue } from "@webiny/lexical-nodes";
|
|
5
|
+
import { getSelectedNode } from "../../utils/getSelectedNode.js";
|
|
6
|
+
import { useDeriveValueFromSelection } from "../../hooks/useCurrentSelection.js";
|
|
7
|
+
import { useRichTextEditor } from "../../hooks/index.js";
|
|
8
|
+
export const FontColorPicker = makeDecoratable("FontColorPicker", () => {
|
|
9
|
+
useEffect(() => {
|
|
17
10
|
console.log("Default FontColorPicker, please add your own component");
|
|
18
11
|
}, []);
|
|
19
12
|
return null;
|
|
20
13
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const FontActionColorPicker = ({
|
|
15
|
+
element
|
|
16
|
+
}) => {
|
|
17
|
+
return /*#__PURE__*/React.createElement(Compose, {
|
|
24
18
|
component: FontColorPicker,
|
|
25
|
-
with:
|
|
26
|
-
return function () {
|
|
27
|
-
return element;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
19
|
+
with: () => () => element
|
|
30
20
|
});
|
|
31
21
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
editor
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
export const FontColorAction = () => {
|
|
23
|
+
const {
|
|
24
|
+
editor
|
|
25
|
+
} = useRichTextEditor();
|
|
26
|
+
const fontColor = useDeriveValueFromSelection(({
|
|
27
|
+
rangeSelection
|
|
28
|
+
}) => {
|
|
37
29
|
if (!rangeSelection) {
|
|
38
30
|
return "#000";
|
|
39
31
|
}
|
|
40
|
-
|
|
41
|
-
return
|
|
32
|
+
const node = getSelectedNode(rangeSelection);
|
|
33
|
+
return $isFontColorNode(node) ? node.getColorStyle().color : "#000";
|
|
42
34
|
});
|
|
43
|
-
|
|
44
|
-
editor.dispatchCommand(
|
|
45
|
-
color: new
|
|
35
|
+
const onFontColorSelect = useCallback((colorValue, themeColorName) => {
|
|
36
|
+
editor.dispatchCommand(ADD_FONT_COLOR_COMMAND, {
|
|
37
|
+
color: new ThemeColorValue(colorValue, themeColorName)
|
|
46
38
|
});
|
|
47
39
|
}, []);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [onFontColorSelect, fontColor]);
|
|
54
|
-
return /*#__PURE__*/_react.default.createElement(_FontColorActionContext.FontColorActionContext.Provider, {
|
|
40
|
+
const context = useMemo(() => ({
|
|
41
|
+
value: fontColor,
|
|
42
|
+
applyColor: onFontColorSelect
|
|
43
|
+
}), [onFontColorSelect, fontColor]);
|
|
44
|
+
return /*#__PURE__*/React.createElement(FontColorActionContext.Provider, {
|
|
55
45
|
value: context
|
|
56
|
-
}, /*#__PURE__*/
|
|
46
|
+
}, /*#__PURE__*/React.createElement(FontColorPicker, null));
|
|
57
47
|
};
|
|
58
48
|
FontColorAction.ColorPicker = FontActionColorPicker;
|
|
59
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useMemo","Compose","makeDecoratable","FontColorActionContext","$isFontColorNode","ADD_FONT_COLOR_COMMAND","ThemeColorValue","getSelectedNode","useDeriveValueFromSelection","useRichTextEditor","FontColorPicker","console","log","FontActionColorPicker","element","createElement","component","with","FontColorAction","editor","fontColor","rangeSelection","node","getColorStyle","color","onFontColorSelect","colorValue","themeColorName","dispatchCommand","context","value","applyColor","Provider","ColorPicker"],"sources":["FontColorAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport type { LexicalCommand } from \"lexical\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport { FontColorActionContext } from \"~/context/FontColorActionContext.js\";\nimport type { FontColorPayload } from \"@webiny/lexical-nodes\";\nimport { $isFontColorNode, ADD_FONT_COLOR_COMMAND, ThemeColorValue } from \"@webiny/lexical-nodes\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode.js\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const FontColorPicker = makeDecoratable(\"FontColorPicker\", (): JSX.Element | null => {\n useEffect(() => {\n console.log(\"Default FontColorPicker, please add your own component\");\n }, []);\n return null;\n});\n\ninterface FontActionColorPicker {\n element: JSX.Element;\n}\n\nconst FontActionColorPicker = ({ element }: FontActionColorPicker): JSX.Element => {\n return <Compose component={FontColorPicker} with={() => () => element} />;\n};\n\nexport type FontColorAction = React.ComponentType<unknown> & {\n ColorPicker: typeof FontActionColorPicker;\n};\n\nexport const FontColorAction: FontColorAction = () => {\n const { editor } = useRichTextEditor();\n const fontColor = useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return \"#000\";\n }\n\n const node = getSelectedNode(rangeSelection);\n return $isFontColorNode(node) ? node.getColorStyle().color : \"#000\";\n });\n\n const onFontColorSelect = useCallback(\n (colorValue: string, themeColorName: string | undefined) => {\n editor.dispatchCommand<LexicalCommand<FontColorPayload>>(ADD_FONT_COLOR_COMMAND, {\n color: new ThemeColorValue(colorValue, themeColorName)\n });\n },\n []\n );\n\n const context = useMemo(\n () => ({\n value: fontColor,\n applyColor: onFontColorSelect\n }),\n [onFontColorSelect, fontColor]\n );\n\n return (\n <FontColorActionContext.Provider value={context}>\n <FontColorPicker />\n </FontColorActionContext.Provider>\n );\n};\n\nFontColorAction.ColorPicker = FontActionColorPicker;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE9D,SAASC,OAAO,EAAEC,eAAe,QAAQ,2BAA2B;AACpE,SAASC,sBAAsB;AAE/B,SAASC,gBAAgB,EAAEC,sBAAsB,EAAEC,eAAe,QAAQ,uBAAuB;AACjG,SAASC,eAAe;AACxB,SAASC,2BAA2B;AACpC,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,eAAe,GAAGR,eAAe,CAAC,iBAAiB,EAAE,MAA0B;EACxFH,SAAS,CAAC,MAAM;IACZY,OAAO,CAACC,GAAG,CAAC,wDAAwD,CAAC;EACzE,CAAC,EAAE,EAAE,CAAC;EACN,OAAO,IAAI;AACf,CAAC,CAAC;AAMF,MAAMC,qBAAqB,GAAGA,CAAC;EAAEC;AAA+B,CAAC,KAAkB;EAC/E,oBAAOjB,KAAA,CAAAkB,aAAA,CAACd,OAAO;IAACe,SAAS,EAAEN,eAAgB;IAACO,IAAI,EAAEA,CAAA,KAAM,MAAMH;EAAQ,CAAE,CAAC;AAC7E,CAAC;AAMD,OAAO,MAAMI,eAAgC,GAAGA,CAAA,KAAM;EAClD,MAAM;IAAEC;EAAO,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EACtC,MAAMW,SAAS,GAAGZ,2BAA2B,CAAC,CAAC;IAAEa;EAAe,CAAC,KAAK;IAClE,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO,MAAM;IACjB;IAEA,MAAMC,IAAI,GAAGf,eAAe,CAACc,cAAc,CAAC;IAC5C,OAAOjB,gBAAgB,CAACkB,IAAI,CAAC,GAAGA,IAAI,CAACC,aAAa,CAAC,CAAC,CAACC,KAAK,GAAG,MAAM;EACvE,CAAC,CAAC;EAEF,MAAMC,iBAAiB,GAAG3B,WAAW,CACjC,CAAC4B,UAAkB,EAAEC,cAAkC,KAAK;IACxDR,MAAM,CAACS,eAAe,CAAmCvB,sBAAsB,EAAE;MAC7EmB,KAAK,EAAE,IAAIlB,eAAe,CAACoB,UAAU,EAAEC,cAAc;IACzD,CAAC,CAAC;EACN,CAAC,EACD,EACJ,CAAC;EAED,MAAME,OAAO,GAAG7B,OAAO,CACnB,OAAO;IACH8B,KAAK,EAAEV,SAAS;IAChBW,UAAU,EAAEN;EAChB,CAAC,CAAC,EACF,CAACA,iBAAiB,EAAEL,SAAS,CACjC,CAAC;EAED,oBACIvB,KAAA,CAAAkB,aAAA,CAACZ,sBAAsB,CAAC6B,QAAQ;IAACF,KAAK,EAAED;EAAQ,gBAC5ChC,KAAA,CAAAkB,aAAA,CAACL,eAAe,MAAE,CACW,CAAC;AAE1C,CAAC;AAEDQ,eAAe,CAACe,WAAW,GAAGpB,qBAAqB","ignoreList":[]}
|
|
@@ -1,50 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _files = require("../../utils/files");
|
|
13
|
-
var _commands = require("../../commands");
|
|
14
|
-
var ImageAction = exports.ImageAction = function ImageAction() {
|
|
15
|
-
var _useRichTextEditor = (0, _useRichTextEditor2.useRichTextEditor)(),
|
|
16
|
-
editor = _useRichTextEditor.editor,
|
|
17
|
-
toolbarActionPlugins = _useRichTextEditor.toolbarActionPlugins;
|
|
18
|
-
var _useState = (0, _react.useState)(),
|
|
19
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
20
|
-
imageActionPlugin = _useState2[0],
|
|
21
|
-
setImageActionPlugin = _useState2[1];
|
|
22
|
-
(0, _react.useEffect)(function () {
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { useRichTextEditor } from "../../hooks/useRichTextEditor.js";
|
|
3
|
+
import { fileToImagePayload } from "../../utils/files.js";
|
|
4
|
+
import { INSERT_IMAGE_COMMAND } from "../../commands/index.js";
|
|
5
|
+
export const ImageAction = () => {
|
|
6
|
+
const {
|
|
7
|
+
editor,
|
|
8
|
+
toolbarActionPlugins
|
|
9
|
+
} = useRichTextEditor();
|
|
10
|
+
const [imageActionPlugin, setImageActionPlugin] = useState();
|
|
11
|
+
useEffect(() => {
|
|
23
12
|
if (!!toolbarActionPlugins?.length) {
|
|
24
|
-
|
|
25
|
-
return action.targetAction === "image-action";
|
|
26
|
-
});
|
|
13
|
+
const actionPlugin = toolbarActionPlugins.find(action => action.targetAction === "image-action");
|
|
27
14
|
setImageActionPlugin(actionPlugin);
|
|
28
15
|
}
|
|
29
16
|
}, [toolbarActionPlugins]);
|
|
30
|
-
|
|
17
|
+
const handleClick = () => {
|
|
31
18
|
if (typeof imageActionPlugin?.plugin === "function") {
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const cb = data => {
|
|
20
|
+
const imagePayload = fileToImagePayload(data);
|
|
34
21
|
if (imagePayload) {
|
|
35
|
-
editor.dispatchCommand(
|
|
22
|
+
editor.dispatchCommand(INSERT_IMAGE_COMMAND, imagePayload);
|
|
36
23
|
}
|
|
37
24
|
};
|
|
38
25
|
imageActionPlugin.plugin(cb);
|
|
39
26
|
}
|
|
40
27
|
};
|
|
41
|
-
return /*#__PURE__*/
|
|
42
|
-
onClick:
|
|
43
|
-
return handleClick();
|
|
44
|
-
},
|
|
28
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
29
|
+
onClick: () => handleClick(),
|
|
45
30
|
className: "popup-item",
|
|
46
31
|
"aria-label": "Insert image"
|
|
47
|
-
}, /*#__PURE__*/
|
|
32
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
48
33
|
className: "icon insert-image"
|
|
49
34
|
}));
|
|
50
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","useRichTextEditor","fileToImagePayload","INSERT_IMAGE_COMMAND","ImageAction","editor","toolbarActionPlugins","imageActionPlugin","setImageActionPlugin","length","actionPlugin","find","action","targetAction","handleClick","plugin","cb","data","imagePayload","dispatchCommand","createElement","onClick","className"],"sources":["ImageAction.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport type { LexicalCommand } from \"lexical\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor.js\";\nimport type { FileManagerFileItem } from \"~/utils/files.js\";\nimport { fileToImagePayload } from \"~/utils/files.js\";\nimport type { ImagePayload } from \"~/commands/index.js\";\nimport { INSERT_IMAGE_COMMAND } from \"~/commands/index.js\";\nimport type { ToolbarActionPlugin } from \"~/types.js\";\n\nexport const ImageAction = () => {\n const { editor, toolbarActionPlugins } = useRichTextEditor();\n const [imageActionPlugin, setImageActionPlugin] = useState<ToolbarActionPlugin | undefined>();\n\n useEffect(() => {\n if (!!toolbarActionPlugins?.length) {\n const actionPlugin = toolbarActionPlugins.find(\n action => action.targetAction === \"image-action\"\n );\n setImageActionPlugin(actionPlugin);\n }\n }, [toolbarActionPlugins]);\n\n const handleClick = () => {\n if (typeof imageActionPlugin?.plugin === \"function\") {\n const cb = (data: FileManagerFileItem) => {\n const imagePayload = fileToImagePayload(data);\n if (imagePayload) {\n editor.dispatchCommand<LexicalCommand<ImagePayload>>(\n INSERT_IMAGE_COMMAND,\n imagePayload\n );\n }\n };\n imageActionPlugin.plugin(cb);\n }\n };\n\n return (\n <button onClick={() => handleClick()} className={\"popup-item\"} aria-label=\"Insert image\">\n <i className=\"icon insert-image\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAElD,SAASC,iBAAiB;AAE1B,SAASC,kBAAkB;AAE3B,SAASC,oBAAoB;AAG7B,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,MAAM;IAAEC,MAAM;IAAEC;EAAqB,CAAC,GAAGL,iBAAiB,CAAC,CAAC;EAC5D,MAAM,CAACM,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGR,QAAQ,CAAkC,CAAC;EAE7FD,SAAS,CAAC,MAAM;IACZ,IAAI,CAAC,CAACO,oBAAoB,EAAEG,MAAM,EAAE;MAChC,MAAMC,YAAY,GAAGJ,oBAAoB,CAACK,IAAI,CAC1CC,MAAM,IAAIA,MAAM,CAACC,YAAY,KAAK,cACtC,CAAC;MACDL,oBAAoB,CAACE,YAAY,CAAC;IACtC;EACJ,CAAC,EAAE,CAACJ,oBAAoB,CAAC,CAAC;EAE1B,MAAMQ,WAAW,GAAGA,CAAA,KAAM;IACtB,IAAI,OAAOP,iBAAiB,EAAEQ,MAAM,KAAK,UAAU,EAAE;MACjD,MAAMC,EAAE,GAAIC,IAAyB,IAAK;QACtC,MAAMC,YAAY,GAAGhB,kBAAkB,CAACe,IAAI,CAAC;QAC7C,IAAIC,YAAY,EAAE;UACdb,MAAM,CAACc,eAAe,CAClBhB,oBAAoB,EACpBe,YACJ,CAAC;QACL;MACJ,CAAC;MACDX,iBAAiB,CAACQ,MAAM,CAACC,EAAE,CAAC;IAChC;EACJ,CAAC;EAED,oBACIlB,KAAA,CAAAsB,aAAA;IAAQC,OAAO,EAAEA,CAAA,KAAMP,WAAW,CAAC,CAAE;IAACQ,SAAS,EAAE,YAAa;IAAC,cAAW;EAAc,gBACpFxB,KAAA,CAAAsB,aAAA;IAAGE,SAAS,EAAC;EAAmB,CAAE,CAC9B,CAAC;AAEjB,CAAC","ignoreList":[]}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
editor
|
|
15
|
-
var _useCurrentSelection = (0, _useCurrentSelection2.useCurrentSelection)(),
|
|
16
|
-
rangeSelection = _useCurrentSelection.rangeSelection;
|
|
17
|
-
var isItalicSelected = rangeSelection ? rangeSelection.hasFormat("italic") : false;
|
|
18
|
-
var handleClick = function handleClick() {
|
|
19
|
-
editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, "italic");
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FORMAT_TEXT_COMMAND } from "lexical";
|
|
3
|
+
import { useCurrentSelection } from "../../hooks/useCurrentSelection.js";
|
|
4
|
+
import { useRichTextEditor } from "../../hooks/index.js";
|
|
5
|
+
export const ItalicAction = () => {
|
|
6
|
+
const {
|
|
7
|
+
editor
|
|
8
|
+
} = useRichTextEditor();
|
|
9
|
+
const {
|
|
10
|
+
rangeSelection
|
|
11
|
+
} = useCurrentSelection();
|
|
12
|
+
const isItalicSelected = rangeSelection ? rangeSelection.hasFormat("italic") : false;
|
|
13
|
+
const handleClick = () => {
|
|
14
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "italic");
|
|
20
15
|
};
|
|
21
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
22
17
|
onClick: handleClick,
|
|
23
18
|
className: "popup-item spaced " + (isItalicSelected ? "active" : ""),
|
|
24
19
|
"aria-label": "Format text as italic"
|
|
25
|
-
}, /*#__PURE__*/
|
|
20
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
26
21
|
className: "format italic"
|
|
27
22
|
}));
|
|
28
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","FORMAT_TEXT_COMMAND","useCurrentSelection","useRichTextEditor","ItalicAction","editor","rangeSelection","isItalicSelected","hasFormat","handleClick","dispatchCommand","createElement","onClick","className"],"sources":["ItalicAction.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 ItalicAction = () => {\n const { editor } = useRichTextEditor();\n const { rangeSelection } = useCurrentSelection();\n const isItalicSelected = rangeSelection ? rangeSelection.hasFormat(\"italic\") : false;\n\n const handleClick = () => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, \"italic\");\n };\n\n return (\n <button\n onClick={handleClick}\n className={\"popup-item spaced \" + (isItalicSelected ? \"active\" : \"\")}\n aria-label=\"Format text as italic\"\n >\n <i className=\"format italic\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,QAAQ,SAAS;AAC7C,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACtC,MAAM;IAAEG;EAAe,CAAC,GAAGJ,mBAAmB,CAAC,CAAC;EAChD,MAAMK,gBAAgB,GAAGD,cAAc,GAAGA,cAAc,CAACE,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK;EAEpF,MAAMC,WAAW,GAAGA,CAAA,KAAM;IACtBJ,MAAM,CAACK,eAAe,CAACT,mBAAmB,EAAE,QAAQ,CAAC;EACzD,CAAC;EAED,oBACID,KAAA,CAAAW,aAAA;IACIC,OAAO,EAAEH,WAAY;IACrBI,SAAS,EAAE,oBAAoB,IAAIN,gBAAgB,GAAG,QAAQ,GAAG,EAAE,CAAE;IACrE,cAAW;EAAuB,gBAElCP,KAAA,CAAAW,aAAA;IAAGE,SAAS,EAAC;EAAe,CAAE,CAC1B,CAAC;AAEjB,CAAC","ignoreList":[]}
|
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var LinkAction = exports.LinkAction = function LinkAction() {
|
|
14
|
-
var _useRichTextEditor = (0, _hooks.useRichTextEditor)(),
|
|
15
|
-
editor = _useRichTextEditor.editor;
|
|
16
|
-
var isLink = (0, _useCurrentSelection.useDeriveValueFromSelection)(function (_ref) {
|
|
17
|
-
var rangeSelection = _ref.rangeSelection;
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@webiny/lexical-nodes";
|
|
3
|
+
import { getNodeFromSelection } from "../../hooks/useCurrentElement.js";
|
|
4
|
+
import { useDeriveValueFromSelection } from "../../hooks/useCurrentSelection.js";
|
|
5
|
+
import { useRichTextEditor } from "../../hooks/index.js";
|
|
6
|
+
export const LinkAction = () => {
|
|
7
|
+
const {
|
|
8
|
+
editor
|
|
9
|
+
} = useRichTextEditor();
|
|
10
|
+
const isLink = useDeriveValueFromSelection(({
|
|
11
|
+
rangeSelection
|
|
12
|
+
}) => {
|
|
18
13
|
if (!rangeSelection) {
|
|
19
14
|
return false;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
return node ?
|
|
16
|
+
const node = getNodeFromSelection(rangeSelection);
|
|
17
|
+
return node ? $isLinkNode(node) || $isLinkNode(node.getParent()) : false;
|
|
23
18
|
});
|
|
24
|
-
|
|
19
|
+
const insertLink = useCallback(() => {
|
|
25
20
|
if (!isLink) {
|
|
26
|
-
editor.dispatchCommand(
|
|
21
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
|
|
27
22
|
url: "https://"
|
|
28
23
|
});
|
|
29
24
|
} else {
|
|
30
|
-
editor.dispatchCommand(
|
|
25
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
31
26
|
}
|
|
32
27
|
}, [editor, isLink]);
|
|
33
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
34
29
|
onClick: insertLink,
|
|
35
30
|
className: "popup-item spaced " + (isLink ? "active" : ""),
|
|
36
31
|
"aria-label": "Insert link"
|
|
37
|
-
}, /*#__PURE__*/
|
|
32
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
38
33
|
className: "format link"
|
|
39
34
|
}));
|
|
40
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","useCallback","$isLinkNode","TOGGLE_LINK_COMMAND","getNodeFromSelection","useDeriveValueFromSelection","useRichTextEditor","LinkAction","editor","isLink","rangeSelection","node","getParent","insertLink","dispatchCommand","url","createElement","onClick","className"],"sources":["LinkAction.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from \"@webiny/lexical-nodes\";\nimport { getNodeFromSelection } from \"~/hooks/useCurrentElement.js\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const LinkAction = () => {\n const { editor } = useRichTextEditor();\n const isLink = useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return false;\n }\n const node = getNodeFromSelection(rangeSelection);\n return node ? $isLinkNode(node) || $isLinkNode(node.getParent()) : false;\n });\n\n const insertLink = useCallback(() => {\n if (!isLink) {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, { url: \"https://\" });\n } else {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);\n }\n }, [editor, isLink]);\n\n return (\n <button\n onClick={insertLink}\n className={\"popup-item spaced \" + (isLink ? \"active\" : \"\")}\n aria-label=\"Insert link\"\n >\n <i className=\"format link\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB;AACxE,SAASC,oBAAoB;AAC7B,SAASC,2BAA2B;AACpC,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,UAAU,GAAGA,CAAA,KAAM;EAC5B,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACtC,MAAMG,MAAM,GAAGJ,2BAA2B,CAAC,CAAC;IAAEK;EAAe,CAAC,KAAK;IAC/D,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO,KAAK;IAChB;IACA,MAAMC,IAAI,GAAGP,oBAAoB,CAACM,cAAc,CAAC;IACjD,OAAOC,IAAI,GAAGT,WAAW,CAACS,IAAI,CAAC,IAAIT,WAAW,CAACS,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK;EAC5E,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAGZ,WAAW,CAAC,MAAM;IACjC,IAAI,CAACQ,MAAM,EAAE;MACTD,MAAM,CAACM,eAAe,CAACX,mBAAmB,EAAE;QAAEY,GAAG,EAAE;MAAW,CAAC,CAAC;IACpE,CAAC,MAAM;MACHP,MAAM,CAACM,eAAe,CAACX,mBAAmB,EAAE,IAAI,CAAC;IACrD;EACJ,CAAC,EAAE,CAACK,MAAM,EAAEC,MAAM,CAAC,CAAC;EAEpB,oBACIT,KAAA,CAAAgB,aAAA;IACIC,OAAO,EAAEJ,UAAW;IACpBK,SAAS,EAAE,oBAAoB,IAAIT,MAAM,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC3D,cAAW;EAAa,gBAExBT,KAAA,CAAAgB,aAAA;IAAGE,SAAS,EAAC;EAAa,CAAE,CACxB,CAAC;AAEjB,CAAC","ignoreList":[]}
|