@webiny/lexical-editor 5.43.2 → 6.0.0-alpha.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/commands/image.js +2 -8
- package/commands/image.js.map +1 -1
- package/commands/index.js +4 -49
- package/commands/index.js.map +1 -1
- package/commands/list.js +4 -10
- package/commands/list.js.map +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/components/Editor/EnsureHeadingTagPlugin.js +10 -16
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
- package/components/Editor/HeadingEditor.js +13 -21
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/ParagraphEditor.js +12 -19
- package/components/Editor/ParagraphEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.js +92 -105
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.js +2 -8
- package/components/Editor/normalizeInputValue.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +39 -49
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +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.js +37 -46
- package/components/LexicalHtmlRenderer.js.map +1 -1
- 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/Toolbar/Toolbar.js +66 -75
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +16 -21
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +26 -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/FontSizeAction.js +53 -71
- package/components/ToolbarActions/FontSizeAction.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 +26 -33
- 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 +43 -55
- 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.js +15 -26
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.js +12 -20
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.js +2 -9
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.js +2 -9
- package/context/TypographyActionContext.js.map +1 -1
- package/hooks/index.js +8 -93
- package/hooks/index.js.map +1 -1
- package/hooks/useCurrentElement.d.ts +2 -2
- package/hooks/useCurrentElement.js +12 -18
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.js +27 -40
- package/hooks/useCurrentSelection.js.map +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/useList.js +31 -35
- package/hooks/useList.js.map +1 -1
- package/hooks/useQuote.js +12 -17
- package/hooks/useQuote.js.map +1 -1
- package/hooks/useRichTextEditor.js +5 -11
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.js +5 -11
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.js +5 -11
- package/hooks/useTypographyAction.js.map +1 -1
- package/index.js +49 -322
- package/index.js.map +1 -1
- package/package.json +8 -7
- 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.js +1 -16
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +5 -16
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -180
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +2 -3
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +54 -68
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +16 -26
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +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/FontColorPlugin/FontColorPlugin.js +19 -22
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.js +59 -58
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js +23 -23
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/index.js +1 -16
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +30 -37
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +10 -15
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +11 -16
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +16 -21
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +6 -38
- package/types.js.map +1 -1
- package/ui/ContentEditable.js +7 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.js +3 -10
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.js +61 -88
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.js +78 -83
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.js +22 -29
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.js +10 -16
- package/ui/Placeholder.js.map +1 -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.js +9 -26
- package/utils/files.js.map +1 -1
- package/utils/generateInitialLexicalValue.js +2 -8
- package/utils/generateInitialLexicalValue.js.map +1 -1
- package/utils/getDOMRangeRect.js +4 -10
- package/utils/getDOMRangeRect.js.map +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.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 -9
- 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 +1 -1
- 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.js +114 -149
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +6 -13
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.js +11 -19
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +0 -2
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +0 -96
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +0 -1
package/utils/getDOMRangeRect.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDOMRangeRect = getDOMRangeRect;
|
|
7
1
|
/**
|
|
8
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
3
|
*
|
|
@@ -11,11 +5,11 @@ exports.getDOMRangeRect = getDOMRangeRect;
|
|
|
11
5
|
* LICENSE file in the root directory of this source tree.
|
|
12
6
|
*
|
|
13
7
|
*/
|
|
14
|
-
function getDOMRangeRect(nativeSelection, rootElement) {
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export function getDOMRangeRect(nativeSelection, rootElement) {
|
|
9
|
+
const domRange = nativeSelection.getRangeAt(0);
|
|
10
|
+
let rect;
|
|
17
11
|
if (nativeSelection.anchorNode === rootElement) {
|
|
18
|
-
|
|
12
|
+
let inner = rootElement;
|
|
19
13
|
while (inner.firstElementChild != null) {
|
|
20
14
|
inner = inner.firstElementChild;
|
|
21
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","getRangeAt","rect","anchorNode","inner","firstElementChild","getBoundingClientRect"],"sources":["getDOMRangeRect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {\n const domRange = nativeSelection.getRangeAt(0);\n\n let rect;\n\n if (nativeSelection.anchorNode === rootElement) {\n let inner = rootElement;\n while (inner.firstElementChild != null) {\n inner = inner.firstElementChild as HTMLElement;\n }\n rect = inner.getBoundingClientRect();\n } else {\n rect = domRange.getBoundingClientRect();\n }\n\n return rect;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","getRangeAt","rect","anchorNode","inner","firstElementChild","getBoundingClientRect"],"sources":["getDOMRangeRect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {\n const domRange = nativeSelection.getRangeAt(0);\n\n let rect;\n\n if (nativeSelection.anchorNode === rootElement) {\n let inner = rootElement;\n while (inner.firstElementChild != null) {\n inner = inner.firstElementChild as HTMLElement;\n }\n rect = inner.getBoundingClientRect();\n } else {\n rect = domRange.getBoundingClientRect();\n }\n\n return rect;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAACC,eAA0B,EAAEC,WAAwB,EAAW;EAC3F,MAAMC,QAAQ,GAAGF,eAAe,CAACG,UAAU,CAAC,CAAC,CAAC;EAE9C,IAAIC,IAAI;EAER,IAAIJ,eAAe,CAACK,UAAU,KAAKJ,WAAW,EAAE;IAC5C,IAAIK,KAAK,GAAGL,WAAW;IACvB,OAAOK,KAAK,CAACC,iBAAiB,IAAI,IAAI,EAAE;MACpCD,KAAK,GAAGA,KAAK,CAACC,iBAAgC;IAClD;IACAH,IAAI,GAAGE,KAAK,CAACE,qBAAqB,CAAC,CAAC;EACxC,CAAC,MAAM;IACHJ,IAAI,GAAGF,QAAQ,CAACM,qBAAqB,CAAC,CAAC;EAC3C;EAEA,OAAOJ,IAAI;AACf","ignoreList":[]}
|
package/utils/getSelectedNode.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSelectedNode = getSelectedNode;
|
|
7
|
-
var _selection = require("@lexical/selection");
|
|
8
1
|
/**
|
|
9
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
3
|
*
|
|
@@ -12,20 +5,20 @@ var _selection = require("@lexical/selection");
|
|
|
12
5
|
* LICENSE file in the root directory of this source tree.
|
|
13
6
|
*
|
|
14
7
|
*/
|
|
15
|
-
|
|
16
|
-
function getSelectedNode(selection) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
import { $isAtNodeEnd } from "@lexical/selection";
|
|
9
|
+
export function getSelectedNode(selection) {
|
|
10
|
+
const anchor = selection.anchor;
|
|
11
|
+
const focus = selection.focus;
|
|
12
|
+
const anchorNode = selection.anchor.getNode();
|
|
13
|
+
const focusNode = selection.focus.getNode();
|
|
21
14
|
if (anchorNode === focusNode) {
|
|
22
15
|
return anchorNode;
|
|
23
16
|
}
|
|
24
|
-
|
|
17
|
+
const isBackward = selection.isBackward();
|
|
25
18
|
if (isBackward) {
|
|
26
|
-
return
|
|
19
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
27
20
|
} else {
|
|
28
|
-
return
|
|
21
|
+
return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["$isAtNodeEnd","getSelectedNode","selection","anchor","focus","anchorNode","getNode","focusNode","isBackward"],"sources":["getSelectedNode.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { $isAtNodeEnd } from \"@lexical/selection\";\nimport { ElementNode, RangeSelection, TextNode } from \"lexical\";\n\nexport function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = selection.anchor.getNode();\n const focusNode = selection.focus.getNode();\n if (anchorNode === focusNode) {\n return anchorNode;\n }\n const isBackward = selection.isBackward();\n if (isBackward) {\n return $isAtNodeEnd(focus) ? anchorNode : focusNode;\n } else {\n return $isAtNodeEnd(anchor) ? focusNode : anchorNode;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AAGjD,OAAO,SAASC,eAAeA,CAACC,SAAyB,EAA0B;EAC/E,MAAMC,MAAM,GAAGD,SAAS,CAACC,MAAM;EAC/B,MAAMC,KAAK,GAAGF,SAAS,CAACE,KAAK;EAC7B,MAAMC,UAAU,GAAGH,SAAS,CAACC,MAAM,CAACG,OAAO,CAAC,CAAC;EAC7C,MAAMC,SAAS,GAAGL,SAAS,CAACE,KAAK,CAACE,OAAO,CAAC,CAAC;EAC3C,IAAID,UAAU,KAAKE,SAAS,EAAE;IAC1B,OAAOF,UAAU;EACrB;EACA,MAAMG,UAAU,GAAGN,SAAS,CAACM,UAAU,CAAC,CAAC;EACzC,IAAIA,UAAU,EAAE;IACZ,OAAOR,YAAY,CAACI,KAAK,CAAC,GAAGC,UAAU,GAAGE,SAAS;EACvD,CAAC,MAAM;IACH,OAAOP,YAAY,CAACG,MAAM,CAAC,GAAGI,SAAS,GAAGF,UAAU;EACxD;AACJ","ignoreList":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTransparentImage = void 0;
|
|
7
|
-
var getTransparentImage = exports.getTransparentImage = function getTransparentImage() {
|
|
1
|
+
export const getTransparentImage = () => {
|
|
8
2
|
return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
9
3
|
};
|
|
10
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getTransparentImage"
|
|
1
|
+
{"version":3,"names":["getTransparentImage"],"sources":["getTransparentImage.ts"],"sourcesContent":["export const getTransparentImage = () => {\n return \"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\";\n};\n"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO,gFAAgF;AAC3F,CAAC","ignoreList":[]}
|
package/utils/insertImage.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.insertImage = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var _utils = require("@lexical/utils");
|
|
9
|
-
var _lexicalNodes = require("@webiny/lexical-nodes");
|
|
1
|
+
import { $insertNodes, $isRootOrShadowRoot } from "lexical";
|
|
2
|
+
import { $wrapNodeInElement } from "@lexical/utils";
|
|
3
|
+
import { $createParagraphNode, $createImageNode } from "@webiny/lexical-nodes";
|
|
10
4
|
/*
|
|
11
5
|
* Insert image into editor.
|
|
12
6
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
7
|
+
export const insertImage = payload => {
|
|
8
|
+
const imageNode = $createImageNode(payload);
|
|
9
|
+
$insertNodes([imageNode]);
|
|
10
|
+
if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {
|
|
11
|
+
$wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
18
12
|
}
|
|
19
13
|
return true;
|
|
20
14
|
};
|
package/utils/insertImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["$insertNodes","$isRootOrShadowRoot","$wrapNodeInElement","$createParagraphNode","$createImageNode","insertImage","payload","imageNode","getParentOrThrow","selectEnd"],"sources":["insertImage.ts"],"sourcesContent":["import { $insertNodes, $isRootOrShadowRoot } from \"lexical\";\nimport { $wrapNodeInElement } from \"@lexical/utils\";\nimport { $createParagraphNode, $createImageNode } from \"@webiny/lexical-nodes\";\nimport { InsertImagePayload } from \"~/plugins/ImagesPlugin/ImagesPlugin\";\n\n/*\n * Insert image into editor.\n */\nexport const insertImage = (payload: InsertImagePayload): boolean => {\n const imageNode = $createImageNode(payload);\n $insertNodes([imageNode]);\n if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {\n $wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();\n }\n return true;\n};\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mBAAmB,QAAQ,SAAS;AAC3D,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,uBAAuB;AAG9E;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,OAA2B,IAAc;EACjE,MAAMC,SAAS,GAAGH,gBAAgB,CAACE,OAAO,CAAC;EAC3CN,YAAY,CAAC,CAACO,SAAS,CAAC,CAAC;EACzB,IAAIN,mBAAmB,CAACM,SAAS,CAACC,gBAAgB,CAAC,CAAC,CAAC,EAAE;IACnDN,kBAAkB,CAACK,SAAS,EAAEJ,oBAAoB,CAAC,CAACM,SAAS,CAAC,CAAC;EACnE;EACA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
package/utils/isAnchorLink.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isAnchorLink = void 0;
|
|
7
|
-
var isAnchorLink = exports.isAnchorLink = function isAnchorLink(url) {
|
|
1
|
+
export const isAnchorLink = url => {
|
|
8
2
|
return url.startsWith("#");
|
|
9
3
|
};
|
|
10
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isAnchorLink","
|
|
1
|
+
{"version":3,"names":["isAnchorLink","url","startsWith"],"sources":["isAnchorLink.ts"],"sourcesContent":["export const isAnchorLink = (url: string) => {\n return url.startsWith(\"#\");\n};\n"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAIC,GAAW,IAAK;EACzC,OAAOA,GAAG,CAACC,UAAU,CAAC,GAAG,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isChildOfFloatingToolbar = void 0;
|
|
7
|
-
var _isChildOfFloatingToolbar = exports.isChildOfFloatingToolbar = function isChildOfFloatingToolbar(element) {
|
|
8
|
-
var parent = element ? element.parentElement : null;
|
|
1
|
+
export const isChildOfFloatingToolbar = element => {
|
|
2
|
+
const parent = element ? element.parentElement : null;
|
|
9
3
|
if (!parent) {
|
|
10
4
|
return false;
|
|
11
5
|
}
|
|
12
6
|
if (parent.classList.contains("floating-toolbar")) {
|
|
13
7
|
return true;
|
|
14
8
|
}
|
|
15
|
-
return
|
|
9
|
+
return isChildOfFloatingToolbar(parent);
|
|
16
10
|
};
|
|
17
11
|
|
|
18
12
|
//# sourceMappingURL=isChildOfFloatingToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isChildOfFloatingToolbar","
|
|
1
|
+
{"version":3,"names":["isChildOfFloatingToolbar","element","parent","parentElement","classList","contains"],"sources":["isChildOfFloatingToolbar.ts"],"sourcesContent":["export const isChildOfFloatingToolbar = (element: HTMLElement | null): boolean => {\n const parent = element ? element.parentElement : null;\n\n if (!parent) {\n return false;\n }\n\n if (parent.classList.contains(\"floating-toolbar\")) {\n return true;\n }\n\n return isChildOfFloatingToolbar(parent);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,GAAIC,OAA2B,IAAc;EAC9E,MAAMC,MAAM,GAAGD,OAAO,GAAGA,OAAO,CAACE,aAAa,GAAG,IAAI;EAErD,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,KAAK;EAChB;EAEA,IAAIA,MAAM,CAACE,SAAS,CAACC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;IAC/C,OAAO,IAAI;EACf;EAEA,OAAOL,wBAAwB,CAACE,MAAM,CAAC;AAC3C,CAAC","ignoreList":[]}
|
package/utils/isHTMLElement.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isHTMLElement = isHTMLElement;
|
|
7
1
|
/**
|
|
8
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
3
|
*
|
|
@@ -11,7 +5,7 @@ exports.isHTMLElement = isHTMLElement;
|
|
|
11
5
|
* LICENSE file in the root directory of this source tree.
|
|
12
6
|
*
|
|
13
7
|
*/
|
|
14
|
-
function isHTMLElement(x) {
|
|
8
|
+
export function isHTMLElement(x) {
|
|
15
9
|
return x instanceof HTMLElement;
|
|
16
10
|
}
|
|
17
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isHTMLElement","x","HTMLElement"],"sources":["isHTMLElement.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function isHTMLElement(x: unknown): x is HTMLElement {\n return x instanceof HTMLElement;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["isHTMLElement","x","HTMLElement"],"sources":["isHTMLElement.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function isHTMLElement(x: unknown): x is HTMLElement {\n return x instanceof HTMLElement;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAACC,CAAU,EAAoB;EACxD,OAAOA,CAAC,YAAYC,WAAW;AACnC","ignoreList":[]}
|
package/utils/isValidJSON.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isValidJSON = void 0;
|
|
7
|
-
var isValidJSON = exports.isValidJSON = function isValidJSON(value) {
|
|
1
|
+
export const isValidJSON = value => {
|
|
8
2
|
if (!value) {
|
|
9
3
|
return false;
|
|
10
4
|
}
|
|
11
5
|
try {
|
|
12
|
-
|
|
6
|
+
const o = JSON.parse(value);
|
|
13
7
|
return !!o && typeof o === "object" && !Array.isArray(o);
|
|
14
|
-
} catch
|
|
8
|
+
} catch {
|
|
15
9
|
return false;
|
|
16
10
|
}
|
|
17
11
|
};
|
package/utils/isValidJSON.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isValidJSON","
|
|
1
|
+
{"version":3,"names":["isValidJSON","value","o","JSON","parse","Array","isArray"],"sources":["isValidJSON.ts"],"sourcesContent":["export const isValidJSON = (value: string | undefined | null): boolean => {\n if (!value) {\n return false;\n }\n try {\n const o = JSON.parse(value);\n return !!o && typeof o === \"object\" && !Array.isArray(o);\n } catch {\n return false;\n }\n};\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAIC,KAAgC,IAAc;EACtE,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,KAAK;EAChB;EACA,IAAI;IACA,MAAMC,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC;IAC3B,OAAO,CAAC,CAACC,CAAC,IAAI,OAAOA,CAAC,KAAK,QAAQ,IAAI,CAACG,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC;EAC5D,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SerializedEditorState } from "lexical";
|
|
2
2
|
import { LexicalValue } from "../types";
|
|
3
3
|
export declare const parseLexicalState: (editorStateValue: LexicalValue | null) => false | SerializedEditorState;
|
|
4
|
-
export declare const isValidLexicalData: (editorStateValue: LexicalValue | null) =>
|
|
4
|
+
export declare const isValidLexicalData: (editorStateValue: LexicalValue | null) => editorStateValue is string;
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parseLexicalState = exports.isValidLexicalData = void 0;
|
|
7
|
-
var parseLexicalState = exports.parseLexicalState = function parseLexicalState(editorStateValue) {
|
|
1
|
+
export const parseLexicalState = editorStateValue => {
|
|
8
2
|
if (!editorStateValue) {
|
|
9
3
|
return false;
|
|
10
4
|
}
|
|
11
5
|
try {
|
|
12
|
-
|
|
6
|
+
const maybeValidState = JSON.parse(editorStateValue);
|
|
13
7
|
return maybeValidState["root"] ? maybeValidState : false;
|
|
14
|
-
} catch
|
|
8
|
+
} catch {
|
|
15
9
|
return false;
|
|
16
10
|
}
|
|
17
11
|
};
|
|
18
|
-
|
|
12
|
+
export const isValidLexicalData = editorStateValue => {
|
|
19
13
|
if (!editorStateValue) {
|
|
20
14
|
return false;
|
|
21
15
|
}
|
|
22
16
|
try {
|
|
23
|
-
|
|
17
|
+
const data = JSON.parse(editorStateValue);
|
|
24
18
|
return !!data["root"];
|
|
25
|
-
} catch
|
|
19
|
+
} catch {
|
|
26
20
|
return false;
|
|
27
21
|
}
|
|
28
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["parseLexicalState","
|
|
1
|
+
{"version":3,"names":["parseLexicalState","editorStateValue","maybeValidState","JSON","parse","isValidLexicalData","data"],"sources":["isValidLexicalData.ts"],"sourcesContent":["import { SerializedEditorState } from \"lexical\";\nimport { LexicalValue } from \"~/types\";\n\nexport const parseLexicalState = (\n editorStateValue: LexicalValue | null\n): false | SerializedEditorState => {\n if (!editorStateValue) {\n return false;\n }\n try {\n const maybeValidState = JSON.parse(editorStateValue);\n return maybeValidState[\"root\"] ? maybeValidState : false;\n } catch {\n return false;\n }\n};\n\nexport const isValidLexicalData = (editorStateValue: LexicalValue | null): editorStateValue is LexicalValue => {\n if (!editorStateValue) {\n return false;\n }\n\n try {\n const data = JSON.parse(editorStateValue);\n return !!data[\"root\"];\n } catch {\n return false;\n }\n};\n"],"mappings":"AAGA,OAAO,MAAMA,iBAAiB,GAC1BC,gBAAqC,IACL;EAChC,IAAI,CAACA,gBAAgB,EAAE;IACnB,OAAO,KAAK;EAChB;EACA,IAAI;IACA,MAAMC,eAAe,GAAGC,IAAI,CAACC,KAAK,CAACH,gBAAgB,CAAC;IACpD,OAAOC,eAAe,CAAC,MAAM,CAAC,GAAGA,eAAe,GAAG,KAAK;EAC5D,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC;AAED,OAAO,MAAMG,kBAAkB,GAAIJ,gBAAqC,IAAuC;EAC3G,IAAI,CAACA,gBAAgB,EAAE;IACnB,OAAO,KAAK;EAChB;EAEA,IAAI;IACA,MAAMK,IAAI,GAAGH,IAAI,CAACC,KAAK,CAACH,gBAAgB,CAAC;IACzC,OAAO,CAAC,CAACK,IAAI,CAAC,MAAM,CAAC;EACzB,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC","ignoreList":[]}
|
package/utils/point.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Point = void 0;
|
|
8
|
-
exports.isPoint = isPoint;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
1
|
/**
|
|
12
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
3
|
*
|
|
@@ -15,59 +5,44 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
15
5
|
* LICENSE file in the root directory of this source tree.
|
|
16
6
|
*
|
|
17
7
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(0, _classCallCheck2.default)(this, Point);
|
|
8
|
+
export class Point {
|
|
9
|
+
constructor(x, y) {
|
|
21
10
|
this._x = x;
|
|
22
11
|
this._y = y;
|
|
23
12
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "calcVerticalDistance",
|
|
60
|
-
value: function calcVerticalDistance(point) {
|
|
61
|
-
return Math.abs(this.calcDeltaYTo(point));
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "calcDistanceTo",
|
|
65
|
-
value: function calcDistanceTo(point) {
|
|
66
|
-
return Math.sqrt(Math.pow(this.calcDeltaXTo(point), 2) + Math.pow(this.calcDeltaYTo(point), 2));
|
|
67
|
-
}
|
|
68
|
-
}]);
|
|
69
|
-
}();
|
|
70
|
-
function isPoint(x) {
|
|
13
|
+
get x() {
|
|
14
|
+
return this._x;
|
|
15
|
+
}
|
|
16
|
+
get y() {
|
|
17
|
+
return this._y;
|
|
18
|
+
}
|
|
19
|
+
equals({
|
|
20
|
+
x,
|
|
21
|
+
y
|
|
22
|
+
}) {
|
|
23
|
+
return this.x === x && this.y === y;
|
|
24
|
+
}
|
|
25
|
+
calcDeltaXTo({
|
|
26
|
+
x
|
|
27
|
+
}) {
|
|
28
|
+
return this.x - x;
|
|
29
|
+
}
|
|
30
|
+
calcDeltaYTo({
|
|
31
|
+
y
|
|
32
|
+
}) {
|
|
33
|
+
return this.y - y;
|
|
34
|
+
}
|
|
35
|
+
calcHorizontalDistanceTo(point) {
|
|
36
|
+
return Math.abs(this.calcDeltaXTo(point));
|
|
37
|
+
}
|
|
38
|
+
calcVerticalDistance(point) {
|
|
39
|
+
return Math.abs(this.calcDeltaYTo(point));
|
|
40
|
+
}
|
|
41
|
+
calcDistanceTo(point) {
|
|
42
|
+
return Math.sqrt(Math.pow(this.calcDeltaXTo(point), 2) + Math.pow(this.calcDeltaYTo(point), 2));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function isPoint(x) {
|
|
71
46
|
return x instanceof Point;
|
|
72
47
|
}
|
|
73
48
|
|
package/utils/point.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Point","
|
|
1
|
+
{"version":3,"names":["Point","constructor","x","y","_x","_y","equals","calcDeltaXTo","calcDeltaYTo","calcHorizontalDistanceTo","point","Math","abs","calcVerticalDistance","calcDistanceTo","sqrt","pow","isPoint"],"sources":["point.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport class Point {\n private readonly _x: number;\n private readonly _y: number;\n\n constructor(x: number, y: number) {\n this._x = x;\n this._y = y;\n }\n\n get x(): number {\n return this._x;\n }\n\n get y(): number {\n return this._y;\n }\n\n public equals({ x, y }: Point): boolean {\n return this.x === x && this.y === y;\n }\n\n public calcDeltaXTo({ x }: Point): number {\n return this.x - x;\n }\n\n public calcDeltaYTo({ y }: Point): number {\n return this.y - y;\n }\n\n public calcHorizontalDistanceTo(point: Point): number {\n return Math.abs(this.calcDeltaXTo(point));\n }\n\n public calcVerticalDistance(point: Point): number {\n return Math.abs(this.calcDeltaYTo(point));\n }\n\n public calcDistanceTo(point: Point): number {\n return Math.sqrt(\n Math.pow(this.calcDeltaXTo(point), 2) + Math.pow(this.calcDeltaYTo(point), 2)\n );\n }\n}\n\nexport function isPoint(x: unknown): x is Point {\n return x instanceof Point;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,KAAK,CAAC;EAIfC,WAAWA,CAACC,CAAS,EAAEC,CAAS,EAAE;IAC9B,IAAI,CAACC,EAAE,GAAGF,CAAC;IACX,IAAI,CAACG,EAAE,GAAGF,CAAC;EACf;EAEA,IAAID,CAACA,CAAA,EAAW;IACZ,OAAO,IAAI,CAACE,EAAE;EAClB;EAEA,IAAID,CAACA,CAAA,EAAW;IACZ,OAAO,IAAI,CAACE,EAAE;EAClB;EAEOC,MAAMA,CAAC;IAAEJ,CAAC;IAAEC;EAAS,CAAC,EAAW;IACpC,OAAO,IAAI,CAACD,CAAC,KAAKA,CAAC,IAAI,IAAI,CAACC,CAAC,KAAKA,CAAC;EACvC;EAEOI,YAAYA,CAAC;IAAEL;EAAS,CAAC,EAAU;IACtC,OAAO,IAAI,CAACA,CAAC,GAAGA,CAAC;EACrB;EAEOM,YAAYA,CAAC;IAAEL;EAAS,CAAC,EAAU;IACtC,OAAO,IAAI,CAACA,CAAC,GAAGA,CAAC;EACrB;EAEOM,wBAAwBA,CAACC,KAAY,EAAU;IAClD,OAAOC,IAAI,CAACC,GAAG,CAAC,IAAI,CAACL,YAAY,CAACG,KAAK,CAAC,CAAC;EAC7C;EAEOG,oBAAoBA,CAACH,KAAY,EAAU;IAC9C,OAAOC,IAAI,CAACC,GAAG,CAAC,IAAI,CAACJ,YAAY,CAACE,KAAK,CAAC,CAAC;EAC7C;EAEOI,cAAcA,CAACJ,KAAY,EAAU;IACxC,OAAOC,IAAI,CAACI,IAAI,CACZJ,IAAI,CAACK,GAAG,CAAC,IAAI,CAACT,YAAY,CAACG,KAAK,CAAC,EAAE,CAAC,CAAC,GAAGC,IAAI,CAACK,GAAG,CAAC,IAAI,CAACR,YAAY,CAACE,KAAK,CAAC,EAAE,CAAC,CAChF,CAAC;EACL;AACJ;AAEA,OAAO,SAASO,OAAOA,CAACf,CAAU,EAAc;EAC5C,OAAOA,CAAC,YAAYF,KAAK;AAC7B","ignoreList":[]}
|