@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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/getSelectedNode.js","sources":["../../src/utils/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 type { 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"],"names":["getSelectedNode","selection","anchor","focus","anchorNode","focusNode","isBackward","$isAtNodeEnd"],"mappings":";AAUO,SAASA,gBAAgBC,SAAyB;IACrD,MAAMC,SAASD,UAAU,MAAM;IAC/B,MAAME,QAAQF,UAAU,KAAK;IAC7B,MAAMG,aAAaH,UAAU,MAAM,CAAC,OAAO;IAC3C,MAAMI,YAAYJ,UAAU,KAAK,CAAC,OAAO;IACzC,IAAIG,eAAeC,WACf,OAAOD;IAEX,MAAME,aAAaL,UAAU,UAAU;IACvC,IAAIK,YACA,OAAOC,aAAaJ,SAASC,aAAaC;IAE1C,OAAOE,aAAaL,UAAUG,YAAYD;AAElD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
const getTransparentImage = ()=>"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
2
|
+
export { getTransparentImage };
|
|
4
3
|
|
|
5
4
|
//# sourceMappingURL=getTransparentImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/getTransparentImage.js","sources":["../../src/utils/getTransparentImage.ts"],"sourcesContent":["export const getTransparentImage = () => {\n return \"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\";\n};\n"],"names":["getTransparentImage"],"mappings":"AAAO,MAAMA,sBAAsB,IACxB"}
|
package/utils/insertImage.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { $insertNodes, $isRootOrShadowRoot } from "lexical";
|
|
2
2
|
import { $wrapNodeInElement } from "@lexical/utils";
|
|
3
|
-
import { $
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
$wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
12
|
-
}
|
|
13
|
-
return true;
|
|
3
|
+
import { $createImageNode, $createParagraphNode } from "@webiny/lexical-nodes";
|
|
4
|
+
const insertImage = (payload)=>{
|
|
5
|
+
const imageNode = $createImageNode(payload);
|
|
6
|
+
$insertNodes([
|
|
7
|
+
imageNode
|
|
8
|
+
]);
|
|
9
|
+
if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) $wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
10
|
+
return true;
|
|
14
11
|
};
|
|
12
|
+
export { insertImage };
|
|
15
13
|
|
|
16
14
|
//# sourceMappingURL=insertImage.js.map
|
package/utils/insertImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/insertImage.js","sources":["../../src/utils/insertImage.ts"],"sourcesContent":["import { $insertNodes, $isRootOrShadowRoot } from \"lexical\";\nimport { $wrapNodeInElement } from \"@lexical/utils\";\nimport { $createParagraphNode, $createImageNode } from \"@webiny/lexical-nodes\";\nimport type { InsertImagePayload } from \"~/plugins/ImagesPlugin/ImagesPlugin.js\";\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"],"names":["insertImage","payload","imageNode","$createImageNode","$insertNodes","$isRootOrShadowRoot","$wrapNodeInElement","$createParagraphNode"],"mappings":";;;AAQO,MAAMA,cAAc,CAACC;IACxB,MAAMC,YAAYC,iBAAiBF;IACnCG,aAAa;QAACF;KAAU;IACxB,IAAIG,oBAAoBH,UAAU,gBAAgB,KAC9CI,mBAAmBJ,WAAWK,sBAAsB,SAAS;IAEjE,OAAO;AACX"}
|
package/utils/isAnchorLink.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/isAnchorLink.js","sources":["../../src/utils/isAnchorLink.ts"],"sourcesContent":["export const isAnchorLink = (url: string) => {\n return url.startsWith(\"#\");\n};\n"],"names":["isAnchorLink","url"],"mappings":"AAAO,MAAMA,eAAe,CAACC,MAClBA,IAAI,UAAU,CAAC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
if (parent.classList.contains("floating-toolbar")) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
return isChildOfFloatingToolbar(parent);
|
|
1
|
+
const isChildOfFloatingToolbar = (element)=>{
|
|
2
|
+
const parent = element ? element.parentElement : null;
|
|
3
|
+
if (!parent) return false;
|
|
4
|
+
if (parent.classList.contains("floating-toolbar")) return true;
|
|
5
|
+
return isChildOfFloatingToolbar(parent);
|
|
10
6
|
};
|
|
7
|
+
export { isChildOfFloatingToolbar };
|
|
11
8
|
|
|
12
9
|
//# sourceMappingURL=isChildOfFloatingToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/isChildOfFloatingToolbar.js","sources":["../../src/utils/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"],"names":["isChildOfFloatingToolbar","element","parent"],"mappings":"AAAO,MAAMA,2BAA2B,CAACC;IACrC,MAAMC,SAASD,UAAUA,QAAQ,aAAa,GAAG;IAEjD,IAAI,CAACC,QACD,OAAO;IAGX,IAAIA,OAAO,SAAS,CAAC,QAAQ,CAAC,qBAC1B,OAAO;IAGX,OAAOF,yBAAyBE;AACpC"}
|
package/utils/isHTMLElement.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export function isHTMLElement(x) {
|
|
9
|
-
return x instanceof HTMLElement;
|
|
1
|
+
function isHTMLElement(x) {
|
|
2
|
+
return x instanceof HTMLElement;
|
|
10
3
|
}
|
|
4
|
+
export { isHTMLElement };
|
|
11
5
|
|
|
12
6
|
//# sourceMappingURL=isHTMLElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/isHTMLElement.js","sources":["../../src/utils/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"],"names":["isHTMLElement","x","HTMLElement"],"mappings":"AAOO,SAASA,cAAcC,CAAU;IACpC,OAAOA,aAAaC;AACxB"}
|
package/utils/isValidJSON.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
1
|
+
const isValidJSON = (value)=>{
|
|
2
|
+
if (!value) return false;
|
|
3
|
+
try {
|
|
4
|
+
const o = JSON.parse(value);
|
|
5
|
+
return !!o && "object" == typeof o && !Array.isArray(o);
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
11
9
|
};
|
|
10
|
+
export { isValidJSON };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=isValidJSON.js.map
|
package/utils/isValidJSON.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/isValidJSON.js","sources":["../../src/utils/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"],"names":["isValidJSON","value","o","JSON","Array"],"mappings":"AAAO,MAAMA,cAAc,CAACC;IACxB,IAAI,CAACA,OACD,OAAO;IAEX,IAAI;QACA,MAAMC,IAAIC,KAAK,KAAK,CAACF;QACrB,OAAO,CAAC,CAACC,KAAK,AAAa,YAAb,OAAOA,KAAkB,CAACE,MAAM,OAAO,CAACF;IAC1D,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
1
|
+
const parseLexicalState = (editorStateValue)=>{
|
|
2
|
+
if (!editorStateValue) return false;
|
|
3
|
+
try {
|
|
4
|
+
const maybeValidState = JSON.parse(editorStateValue);
|
|
5
|
+
return maybeValidState["root"] ? maybeValidState : false;
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
11
9
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
10
|
+
const isValidLexicalData = (editorStateValue)=>{
|
|
11
|
+
if (!editorStateValue) return false;
|
|
12
|
+
try {
|
|
13
|
+
const data = JSON.parse(editorStateValue);
|
|
14
|
+
return !!data["root"];
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
22
18
|
};
|
|
19
|
+
export { isValidLexicalData, parseLexicalState };
|
|
23
20
|
|
|
24
21
|
//# sourceMappingURL=isValidLexicalData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/isValidLexicalData.js","sources":["../../src/utils/isValidLexicalData.ts"],"sourcesContent":["import type { SerializedEditorState } from \"lexical\";\nimport type { LexicalValue } from \"~/types.js\";\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 = (\n editorStateValue: LexicalValue | null\n): 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"],"names":["parseLexicalState","editorStateValue","maybeValidState","JSON","isValidLexicalData","data"],"mappings":"AAGO,MAAMA,oBAAoB,CAC7BC;IAEA,IAAI,CAACA,kBACD,OAAO;IAEX,IAAI;QACA,MAAMC,kBAAkBC,KAAK,KAAK,CAACF;QACnC,OAAOC,eAAe,CAAC,OAAO,GAAGA,kBAAkB;IACvD,EAAE,OAAM;QACJ,OAAO;IACX;AACJ;AAEO,MAAME,qBAAqB,CAC9BH;IAEA,IAAI,CAACA,kBACD,OAAO;IAGX,IAAI;QACA,MAAMI,OAAOF,KAAK,KAAK,CAACF;QACxB,OAAO,CAAC,CAACI,IAAI,CAAC,OAAO;IACzB,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
|
package/utils/point.js
CHANGED
|
@@ -1,49 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
}
|
|
1
|
+
class Point {
|
|
2
|
+
constructor(x, y){
|
|
3
|
+
this._x = x;
|
|
4
|
+
this._y = y;
|
|
5
|
+
}
|
|
6
|
+
get x() {
|
|
7
|
+
return this._x;
|
|
8
|
+
}
|
|
9
|
+
get y() {
|
|
10
|
+
return this._y;
|
|
11
|
+
}
|
|
12
|
+
equals({ x, y }) {
|
|
13
|
+
return this.x === x && this.y === y;
|
|
14
|
+
}
|
|
15
|
+
calcDeltaXTo({ x }) {
|
|
16
|
+
return this.x - x;
|
|
17
|
+
}
|
|
18
|
+
calcDeltaYTo({ y }) {
|
|
19
|
+
return this.y - y;
|
|
20
|
+
}
|
|
21
|
+
calcHorizontalDistanceTo(point) {
|
|
22
|
+
return Math.abs(this.calcDeltaXTo(point));
|
|
23
|
+
}
|
|
24
|
+
calcVerticalDistance(point) {
|
|
25
|
+
return Math.abs(this.calcDeltaYTo(point));
|
|
26
|
+
}
|
|
27
|
+
calcDistanceTo(point) {
|
|
28
|
+
return Math.sqrt(Math.pow(this.calcDeltaXTo(point), 2) + Math.pow(this.calcDeltaYTo(point), 2));
|
|
29
|
+
}
|
|
44
30
|
}
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
function isPoint(x) {
|
|
32
|
+
return x instanceof Point;
|
|
47
33
|
}
|
|
34
|
+
export { Point, isPoint };
|
|
48
35
|
|
|
49
36
|
//# sourceMappingURL=point.js.map
|
package/utils/point.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/point.js","sources":["../../src/utils/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"],"names":["Point","x","y","point","Math","isPoint"],"mappings":"AAOO,MAAMA;IAIT,YAAYC,CAAS,EAAEC,CAAS,CAAE;QAC9B,IAAI,CAAC,EAAE,GAAGD;QACV,IAAI,CAAC,EAAE,GAAGC;IACd;IAEA,IAAI,IAAY;QACZ,OAAO,IAAI,CAAC,EAAE;IAClB;IAEA,IAAI,IAAY;QACZ,OAAO,IAAI,CAAC,EAAE;IAClB;IAEO,OAAO,EAAED,CAAC,EAAEC,CAAC,EAAS,EAAW;QACpC,OAAO,IAAI,CAAC,CAAC,KAAKD,KAAK,IAAI,CAAC,CAAC,KAAKC;IACtC;IAEO,aAAa,EAAED,CAAC,EAAS,EAAU;QACtC,OAAO,IAAI,CAAC,CAAC,GAAGA;IACpB;IAEO,aAAa,EAAEC,CAAC,EAAS,EAAU;QACtC,OAAO,IAAI,CAAC,CAAC,GAAGA;IACpB;IAEO,yBAAyBC,KAAY,EAAU;QAClD,OAAOC,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,CAACD;IACtC;IAEO,qBAAqBA,KAAY,EAAU;QAC9C,OAAOC,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,CAACD;IACtC;IAEO,eAAeA,KAAY,EAAU;QACxC,OAAOC,KAAK,IAAI,CACZA,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,CAACD,QAAQ,KAAKC,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,CAACD,QAAQ;IAEnF;AACJ;AAEO,SAASE,QAAQJ,CAAU;IAC9B,OAAOA,aAAaD;AACxB"}
|
package/utils/rect.js
CHANGED
|
@@ -1,130 +1,97 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
import { isPoint } from "./point.js";
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
2
|
+
class Rect {
|
|
3
|
+
constructor(left, top, right, bottom){
|
|
4
|
+
const [physicTop, physicBottom] = top <= bottom ? [
|
|
5
|
+
top,
|
|
6
|
+
bottom
|
|
7
|
+
] : [
|
|
8
|
+
bottom,
|
|
9
|
+
top
|
|
10
|
+
];
|
|
11
|
+
const [physicLeft, physicRight] = left <= right ? [
|
|
12
|
+
left,
|
|
13
|
+
right
|
|
14
|
+
] : [
|
|
15
|
+
right,
|
|
16
|
+
left
|
|
17
|
+
];
|
|
18
|
+
this._top = physicTop;
|
|
19
|
+
this._right = physicRight;
|
|
20
|
+
this._left = physicLeft;
|
|
21
|
+
this._bottom = physicBottom;
|
|
22
|
+
}
|
|
23
|
+
get top() {
|
|
24
|
+
return this._top;
|
|
25
|
+
}
|
|
26
|
+
get right() {
|
|
27
|
+
return this._right;
|
|
28
|
+
}
|
|
29
|
+
get bottom() {
|
|
30
|
+
return this._bottom;
|
|
31
|
+
}
|
|
32
|
+
get left() {
|
|
33
|
+
return this._left;
|
|
34
|
+
}
|
|
35
|
+
get width() {
|
|
36
|
+
return Math.abs(this._left - this._right);
|
|
37
|
+
}
|
|
38
|
+
get height() {
|
|
39
|
+
return Math.abs(this._bottom - this._top);
|
|
40
|
+
}
|
|
41
|
+
equals({ top, left, bottom, right }) {
|
|
42
|
+
return top === this._top && bottom === this._bottom && left === this._left && right === this._right;
|
|
43
|
+
}
|
|
44
|
+
contains(target) {
|
|
45
|
+
if (isPoint(target)) {
|
|
46
|
+
const { x, y } = target;
|
|
47
|
+
const isOnTopSide = y < this._top;
|
|
48
|
+
const isOnBottomSide = y > this._bottom;
|
|
49
|
+
const isOnLeftSide = x < this._left;
|
|
50
|
+
const isOnRightSide = x > this._right;
|
|
51
|
+
const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide;
|
|
52
|
+
return {
|
|
53
|
+
reason: {
|
|
54
|
+
isOnBottomSide,
|
|
55
|
+
isOnLeftSide,
|
|
56
|
+
isOnRightSide,
|
|
57
|
+
isOnTopSide
|
|
58
|
+
},
|
|
59
|
+
result
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
const { top, left, bottom, right } = target;
|
|
64
|
+
return top >= this._top && top <= this._bottom && bottom >= this._top && bottom <= this._bottom && left >= this._left && left <= this._right && right >= this._left && right <= this._right;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
intersectsWith(rect) {
|
|
68
|
+
const { left: x1, top: y1, width: w1, height: h1 } = rect;
|
|
69
|
+
const { left: x2, top: y2, width: w2, height: h2 } = this;
|
|
70
|
+
const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;
|
|
71
|
+
const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;
|
|
72
|
+
const minX = x1 <= x2 ? x1 : x2;
|
|
73
|
+
const minY = y1 <= y2 ? y1 : y2;
|
|
74
|
+
return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;
|
|
75
|
+
}
|
|
76
|
+
generateNewRect({ left = this.left, top = this.top, right = this.right, bottom = this.bottom }) {
|
|
77
|
+
return new Rect(left, top, right, bottom);
|
|
78
|
+
}
|
|
79
|
+
static fromLTRB(left, top, right, bottom) {
|
|
80
|
+
return new Rect(left, top, right, bottom);
|
|
81
|
+
}
|
|
82
|
+
static fromLWTH(left, width, top, height) {
|
|
83
|
+
return new Rect(left, top, left + width, top + height);
|
|
84
|
+
}
|
|
85
|
+
static fromPoints(startPoint, endPoint) {
|
|
86
|
+
const { y: top, x: left } = startPoint;
|
|
87
|
+
const { y: bottom, x: right } = endPoint;
|
|
88
|
+
return Rect.fromLTRB(left, top, right, bottom);
|
|
89
|
+
}
|
|
90
|
+
static fromDOM(dom) {
|
|
91
|
+
const { top, width, left, height } = dom.getBoundingClientRect();
|
|
92
|
+
return Rect.fromLWTH(left, width, top, height);
|
|
73
93
|
}
|
|
74
|
-
}
|
|
75
|
-
intersectsWith(rect) {
|
|
76
|
-
const {
|
|
77
|
-
left: x1,
|
|
78
|
-
top: y1,
|
|
79
|
-
width: w1,
|
|
80
|
-
height: h1
|
|
81
|
-
} = rect;
|
|
82
|
-
const {
|
|
83
|
-
left: x2,
|
|
84
|
-
top: y2,
|
|
85
|
-
width: w2,
|
|
86
|
-
height: h2
|
|
87
|
-
} = this;
|
|
88
|
-
const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;
|
|
89
|
-
const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;
|
|
90
|
-
const minX = x1 <= x2 ? x1 : x2;
|
|
91
|
-
const minY = y1 <= y2 ? y1 : y2;
|
|
92
|
-
return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;
|
|
93
|
-
}
|
|
94
|
-
generateNewRect({
|
|
95
|
-
left = this.left,
|
|
96
|
-
top = this.top,
|
|
97
|
-
right = this.right,
|
|
98
|
-
bottom = this.bottom
|
|
99
|
-
}) {
|
|
100
|
-
return new Rect(left, top, right, bottom);
|
|
101
|
-
}
|
|
102
|
-
static fromLTRB(left, top, right, bottom) {
|
|
103
|
-
return new Rect(left, top, right, bottom);
|
|
104
|
-
}
|
|
105
|
-
static fromLWTH(left, width, top, height) {
|
|
106
|
-
return new Rect(left, top, left + width, top + height);
|
|
107
|
-
}
|
|
108
|
-
static fromPoints(startPoint, endPoint) {
|
|
109
|
-
const {
|
|
110
|
-
y: top,
|
|
111
|
-
x: left
|
|
112
|
-
} = startPoint;
|
|
113
|
-
const {
|
|
114
|
-
y: bottom,
|
|
115
|
-
x: right
|
|
116
|
-
} = endPoint;
|
|
117
|
-
return Rect.fromLTRB(left, top, right, bottom);
|
|
118
|
-
}
|
|
119
|
-
static fromDOM(dom) {
|
|
120
|
-
const {
|
|
121
|
-
top,
|
|
122
|
-
width,
|
|
123
|
-
left,
|
|
124
|
-
height
|
|
125
|
-
} = dom.getBoundingClientRect();
|
|
126
|
-
return Rect.fromLWTH(left, width, top, height);
|
|
127
|
-
}
|
|
128
94
|
}
|
|
95
|
+
export { Rect };
|
|
129
96
|
|
|
130
97
|
//# sourceMappingURL=rect.js.map
|
package/utils/rect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/rect.js","sources":["../../src/utils/rect.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 type { Point } from \"./point.js\";\nimport { isPoint } from \"./point.js\";\n\ntype ContainsPointReturn = {\n result: boolean;\n reason: {\n isOnTopSide: boolean;\n isOnBottomSide: boolean;\n isOnLeftSide: boolean;\n isOnRightSide: boolean;\n };\n};\n\nexport class Rect {\n private readonly _left: number;\n private readonly _top: number;\n private readonly _right: number;\n private readonly _bottom: number;\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top];\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left];\n\n this._top = physicTop;\n this._right = physicRight;\n this._left = physicLeft;\n this._bottom = physicBottom;\n }\n\n get top(): number {\n return this._top;\n }\n\n get right(): number {\n return this._right;\n }\n\n get bottom(): number {\n return this._bottom;\n }\n\n get left(): number {\n return this._left;\n }\n\n get width(): number {\n return Math.abs(this._left - this._right);\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top);\n }\n\n public equals({ top, left, bottom, right }: Rect): boolean {\n return (\n top === this._top &&\n bottom === this._bottom &&\n left === this._left &&\n right === this._right\n );\n }\n\n public contains({ x, y }: Point): ContainsPointReturn;\n public contains({ top, left, bottom, right }: Rect): boolean;\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target;\n\n const isOnTopSide = y < this._top;\n const isOnBottomSide = y > this._bottom;\n const isOnLeftSide = x < this._left;\n const isOnRightSide = x > this._right;\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide;\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide\n },\n result\n };\n } else {\n const { top, left, bottom, right } = target;\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n );\n }\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { left: x1, top: y1, width: w1, height: h1 } = rect;\n const { left: x2, top: y2, width: w2, height: h2 } = this;\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;\n const minX = x1 <= x2 ? x1 : x2;\n const minY = y1 <= y2 ? y1 : y2;\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;\n }\n\n public generateNewRect({\n left = this.left,\n top = this.top,\n right = this.right,\n bottom = this.bottom\n }): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height);\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { y: top, x: left } = startPoint;\n const { y: bottom, x: right } = endPoint;\n return Rect.fromLTRB(left, top, right, bottom);\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { top, width, left, height } = dom.getBoundingClientRect();\n return Rect.fromLWTH(left, width, top, height);\n }\n}\n"],"names":["Rect","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","Math","target","isPoint","x","y","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","rect","x1","y1","w1","h1","x2","y2","w2","h2","maxX","maxY","minX","minY","width","height","startPoint","endPoint","dom"],"mappings":";AA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