@webiny/lexical-editor 0.0.0-unstable.06b2ede40f
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/LICENSE +21 -0
- package/README.md +17 -0
- package/commands/image.d.ts +6 -0
- package/commands/image.js +4 -0
- package/commands/image.js.map +1 -0
- package/commands/index.d.ts +5 -0
- package/commands/index.js +7 -0
- package/commands/index.js.map +1 -0
- package/commands/list.d.ts +7 -0
- package/commands/list.js +6 -0
- package/commands/list.js.map +1 -0
- package/commands/quote.d.ts +5 -0
- package/commands/quote.js +4 -0
- package/commands/quote.js.map +1 -0
- package/commands/toolbar.d.ts +1 -0
- package/commands/toolbar.js +4 -0
- package/commands/toolbar.js.map +1 -0
- package/commands/typography.d.ts +8 -0
- package/commands/typography.js +4 -0
- package/commands/typography.js.map +1 -0
- package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
- package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
- package/components/Editor/HeadingEditor.d.ts +7 -0
- package/components/Editor/HeadingEditor.js +22 -0
- package/components/Editor/HeadingEditor.js.map +1 -0
- package/components/Editor/ParagraphEditor.d.ts +7 -0
- package/components/Editor/ParagraphEditor.js +22 -0
- package/components/Editor/ParagraphEditor.js.map +1 -0
- package/components/Editor/RichTextEditor.d.ts +49 -0
- package/components/Editor/RichTextEditor.js +133 -0
- package/components/Editor/RichTextEditor.js.map +1 -0
- package/components/Editor/normalizeInputValue.d.ts +6 -0
- package/components/Editor/normalizeInputValue.js +16 -0
- package/components/Editor/normalizeInputValue.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +20 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
- package/components/LexicalEditorConfig/components/Node.js +30 -0
- package/components/LexicalEditorConfig/components/Node.js.map +1 -0
- package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
- package/components/LexicalEditorConfig/components/Plugin.js +30 -0
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +14 -0
- package/components/LexicalHtmlRenderer.js +55 -0
- package/components/LexicalHtmlRenderer.js.map +1 -0
- package/components/Toolbar/StaticToolbar.css +260 -0
- package/components/Toolbar/StaticToolbar.d.ts +5 -0
- package/components/Toolbar/StaticToolbar.js +22 -0
- package/components/Toolbar/StaticToolbar.js.map +1 -0
- package/components/Toolbar/Toolbar.css +643 -0
- package/components/Toolbar/Toolbar.d.ts +6 -0
- package/components/Toolbar/Toolbar.js +148 -0
- package/components/Toolbar/Toolbar.js.map +1 -0
- package/components/ToolbarActions/BoldAction.d.ts +2 -0
- package/components/ToolbarActions/BoldAction.js +25 -0
- package/components/ToolbarActions/BoldAction.js.map +1 -0
- package/components/ToolbarActions/BulletListAction.d.ts +2 -0
- package/components/ToolbarActions/BulletListAction.js +40 -0
- package/components/ToolbarActions/BulletListAction.js.map +1 -0
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
- package/components/ToolbarActions/CodeHighlightAction.js +25 -0
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
- package/components/ToolbarActions/FontColorAction.d.ts +29 -0
- package/components/ToolbarActions/FontColorAction.js +50 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.d.ts +14 -0
- package/components/ToolbarActions/FontSizeAction.js +91 -0
- package/components/ToolbarActions/FontSizeAction.js.map +1 -0
- package/components/ToolbarActions/ImageAction.d.ts +2 -0
- package/components/ToolbarActions/ImageAction.js +37 -0
- package/components/ToolbarActions/ImageAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.d.ts +2 -0
- package/components/ToolbarActions/ItalicAction.js +25 -0
- package/components/ToolbarActions/ItalicAction.js.map +1 -0
- package/components/ToolbarActions/LinkAction.d.ts +2 -0
- package/components/ToolbarActions/LinkAction.js +37 -0
- package/components/ToolbarActions/LinkAction.js.map +1 -0
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
- package/components/ToolbarActions/NumberedListAction.js +48 -0
- package/components/ToolbarActions/NumberedListAction.js.map +1 -0
- package/components/ToolbarActions/QuoteAction.d.ts +2 -0
- package/components/ToolbarActions/QuoteAction.js +33 -0
- package/components/ToolbarActions/QuoteAction.js.map +1 -0
- package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
- package/components/ToolbarActions/TextAlignmentAction.js +61 -0
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
- package/components/ToolbarActions/TypographyAction.d.ts +29 -0
- package/components/ToolbarActions/TypographyAction.js +108 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
- package/components/ToolbarActions/UnderlineAction.js +24 -0
- package/components/ToolbarActions/UnderlineAction.js.map +1 -0
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +4 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.d.ts +19 -0
- package/context/RichTextEditorContext.js +21 -0
- package/context/RichTextEditorContext.js.map +1 -0
- package/context/SharedHistoryContext.d.ts +10 -0
- package/context/SharedHistoryContext.js +19 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TextAlignmentActionContextProps.d.ts +9 -0
- package/context/TextAlignmentActionContextProps.js +4 -0
- package/context/TextAlignmentActionContextProps.js.map +1 -0
- package/context/TypographyActionContext.d.ts +8 -0
- package/context/TypographyActionContext.js +4 -0
- package/context/TypographyActionContext.js.map +1 -0
- package/hooks/index.d.ts +8 -0
- package/hooks/index.js +10 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useCurrentElement.d.ts +7 -0
- package/hooks/useCurrentElement.js +27 -0
- package/hooks/useCurrentElement.js.map +1 -0
- package/hooks/useCurrentSelection.d.ts +13 -0
- package/hooks/useCurrentSelection.js +57 -0
- package/hooks/useCurrentSelection.js.map +1 -0
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +11 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useIsMounted.d.ts +1 -0
- package/hooks/useIsMounted.js +12 -0
- package/hooks/useIsMounted.js.map +1 -0
- package/hooks/useList.d.ts +2 -0
- package/hooks/useList.js +50 -0
- package/hooks/useList.js.map +1 -0
- package/hooks/useQuote.d.ts +2 -0
- package/hooks/useQuote.js +17 -0
- package/hooks/useQuote.js.map +1 -0
- package/hooks/useRichTextEditor.d.ts +2 -0
- package/hooks/useRichTextEditor.js +11 -0
- package/hooks/useRichTextEditor.js.map +1 -0
- package/hooks/useTextAlignmentAction.d.ts +1 -0
- package/hooks/useTextAlignmentAction.js +11 -0
- package/hooks/useTextAlignmentAction.js.map +1 -0
- package/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +11 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/images/icons/LICENSE.md +5 -0
- package/images/icons/chat-square-quote.svg +1 -0
- package/images/icons/chevron-down.svg +1 -0
- package/images/icons/code.svg +1 -0
- package/images/icons/font-color.svg +1 -0
- package/images/icons/indent.svg +3 -0
- package/images/icons/insert-image.svg +4 -0
- package/images/icons/justify.svg +3 -0
- package/images/icons/link.svg +1 -0
- package/images/icons/list-ol.svg +1 -0
- package/images/icons/list-ul.svg +1 -0
- package/images/icons/outdent.svg +3 -0
- package/images/icons/pencil-fill.svg +1 -0
- package/images/icons/text-center.svg +1 -0
- package/images/icons/text-left.svg +1 -0
- package/images/icons/text-paragraph.svg +1 -0
- package/images/icons/text-right.svg +1 -0
- package/images/icons/type-bold.svg +1 -0
- package/images/icons/type-h1.svg +1 -0
- package/images/icons/type-h2.svg +1 -0
- package/images/icons/type-h3.svg +1 -0
- package/images/icons/type-h4.svg +1 -0
- package/images/icons/type-h5.svg +1 -0
- package/images/icons/type-h6.svg +1 -0
- package/images/icons/type-italic.svg +1 -0
- package/images/icons/type-strikethrough.svg +1 -0
- package/images/icons/type-underline.svg +1 -0
- package/images/icons/unlink_icon.svg +1 -0
- package/index.d.ts +37 -0
- package/index.js +50 -0
- package/index.js.map +1 -0
- package/package.json +40 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +20 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +14 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/index.js +3 -0
- package/plugins/CodeHighlightPlugin/index.js.map +1 -0
- 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 +176 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +14 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.js +3 -0
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +27 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
- package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
- package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
- package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +12 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js +151 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
- package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
- package/plugins/LinkPlugin/LinkPlugin.js +59 -0
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
- package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
- package/plugins/ListPLugin/ListPlugin.js +17 -0
- package/plugins/ListPLugin/ListPlugin.js.map +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
- package/plugins/StateHandlingPlugin.d.ts +8 -0
- package/plugins/StateHandlingPlugin.js +75 -0
- package/plugins/StateHandlingPlugin.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.d.ts +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/types.d.ts +12 -0
- package/types.js +9 -0
- package/types.js.map +1 -0
- package/ui/ContentEditable.css +22 -0
- package/ui/ContentEditable.d.ts +12 -0
- package/ui/ContentEditable.js +19 -0
- package/ui/ContentEditable.js.map +1 -0
- package/ui/Divider.d.ts +2 -0
- package/ui/Divider.js +8 -0
- package/ui/Divider.js.map +1 -0
- package/ui/DropDown.d.ts +25 -0
- package/ui/DropDown.js +182 -0
- package/ui/DropDown.js.map +1 -0
- package/ui/ImageResizer.d.ts +24 -0
- package/ui/ImageResizer.js +211 -0
- package/ui/ImageResizer.js.map +1 -0
- package/ui/Input.css +32 -0
- package/ui/LinkPreview.css +69 -0
- package/ui/LinkPreview.d.ts +12 -0
- package/ui/LinkPreview.js +97 -0
- package/ui/LinkPreview.js.map +1 -0
- package/ui/Placeholder.css +20 -0
- package/ui/Placeholder.d.ts +15 -0
- package/ui/Placeholder.js +24 -0
- package/ui/Placeholder.js.map +1 -0
- package/ui/TextInput.d.ts +18 -0
- package/ui/TextInput.js +34 -0
- package/ui/TextInput.js.map +1 -0
- package/ui/ToolbarActionDialog.d.ts +11 -0
- package/ui/ToolbarActionDialog.js +77 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/canUseDOM.d.ts +1 -0
- package/utils/canUseDOM.js +3 -0
- package/utils/canUseDOM.js.map +1 -0
- package/utils/files.d.ts +11 -0
- package/utils/files.js +21 -0
- package/utils/files.js.map +1 -0
- package/utils/getDOMRangeRect.d.ts +8 -0
- package/utils/getDOMRangeRect.js +23 -0
- package/utils/getDOMRangeRect.js.map +1 -0
- package/utils/getSelectedNode.d.ts +2 -0
- package/utils/getSelectedNode.js +25 -0
- package/utils/getSelectedNode.js.map +1 -0
- package/utils/getTransparentImage.d.ts +1 -0
- package/utils/getTransparentImage.js +5 -0
- package/utils/getTransparentImage.js.map +1 -0
- package/utils/insertImage.d.ts +2 -0
- package/utils/insertImage.js +16 -0
- package/utils/insertImage.js.map +1 -0
- package/utils/isAnchorLink.d.ts +1 -0
- package/utils/isAnchorLink.js +5 -0
- package/utils/isAnchorLink.js.map +1 -0
- package/utils/isChildOfFloatingToolbar.d.ts +1 -0
- package/utils/isChildOfFloatingToolbar.js +12 -0
- package/utils/isChildOfFloatingToolbar.js.map +1 -0
- package/utils/isHTMLElement.d.ts +8 -0
- package/utils/isHTMLElement.js +12 -0
- package/utils/isHTMLElement.js.map +1 -0
- package/utils/isValidJSON.d.ts +1 -0
- package/utils/isValidJSON.js +13 -0
- package/utils/isValidJSON.js.map +1 -0
- package/utils/isValidLexicalData.d.ts +4 -0
- package/utils/isValidLexicalData.js +24 -0
- package/utils/isValidLexicalData.js.map +1 -0
- package/utils/point.d.ts +21 -0
- package/utils/point.js +49 -0
- package/utils/point.js.map +1 -0
- package/utils/rect.d.ts +45 -0
- package/utils/rect.js +130 -0
- package/utils/rect.js.map +1 -0
- package/utils/sanitizeUrl.d.ts +1 -0
- package/utils/sanitizeUrl.js +25 -0
- package/utils/sanitizeUrl.js.map +1 -0
- package/utils/setFloatingElemPosition.d.ts +1 -0
- package/utils/setFloatingElemPosition.js +30 -0
- package/utils/setFloatingElemPosition.js.map +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
function MenuContainer({
|
|
3
|
+
children,
|
|
4
|
+
menuContainerRef,
|
|
5
|
+
onClose
|
|
6
|
+
}) {
|
|
7
|
+
const handleKeyDown = event => {
|
|
8
|
+
const key = event.key;
|
|
9
|
+
if (["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(key)) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
}
|
|
12
|
+
if (key === "Escape" || key === "Tab") {
|
|
13
|
+
onClose();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const handleContainerClick = e => {
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
};
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
style: {
|
|
21
|
+
position: "relative"
|
|
22
|
+
}
|
|
23
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
onClick: e => handleContainerClick(e),
|
|
25
|
+
style: {
|
|
26
|
+
position: "absolute",
|
|
27
|
+
top: -10,
|
|
28
|
+
left: 0,
|
|
29
|
+
width: 240,
|
|
30
|
+
backgroundColor: "#fff"
|
|
31
|
+
},
|
|
32
|
+
ref: menuContainerRef ?? null,
|
|
33
|
+
onKeyDown: handleKeyDown
|
|
34
|
+
}, children));
|
|
35
|
+
}
|
|
36
|
+
export const ToolbarActionDialog = ({
|
|
37
|
+
disabled,
|
|
38
|
+
buttonAriaLabel,
|
|
39
|
+
buttonClassName,
|
|
40
|
+
buttonIconClassName,
|
|
41
|
+
buttonLabel,
|
|
42
|
+
children
|
|
43
|
+
}) => {
|
|
44
|
+
const menuWindowRef = useRef(null);
|
|
45
|
+
const [showDropDown, setShowDropDown] = useState(false);
|
|
46
|
+
const handleClose = () => {
|
|
47
|
+
if (menuWindowRef && menuWindowRef.current) {
|
|
48
|
+
setShowDropDown(false);
|
|
49
|
+
menuWindowRef.current.focus();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
style: {
|
|
54
|
+
position: "relative"
|
|
55
|
+
}
|
|
56
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
57
|
+
style: {
|
|
58
|
+
position: "relative"
|
|
59
|
+
},
|
|
60
|
+
disabled: disabled,
|
|
61
|
+
"aria-label": buttonAriaLabel || buttonLabel,
|
|
62
|
+
className: buttonClassName,
|
|
63
|
+
onClick: () => {
|
|
64
|
+
setShowDropDown(!showDropDown);
|
|
65
|
+
}
|
|
66
|
+
}, buttonIconClassName && /*#__PURE__*/React.createElement("span", {
|
|
67
|
+
className: buttonIconClassName
|
|
68
|
+
}), buttonLabel && /*#__PURE__*/React.createElement("span", {
|
|
69
|
+
className: "text dropdown-button-text"
|
|
70
|
+
}, buttonLabel), /*#__PURE__*/React.createElement("i", {
|
|
71
|
+
className: "chevron-down"
|
|
72
|
+
})), showDropDown && /*#__PURE__*/React.createElement(MenuContainer, {
|
|
73
|
+
onClose: handleClose
|
|
74
|
+
}, children));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=ToolbarActionDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useRef","useState","MenuContainer","children","menuContainerRef","onClose","handleKeyDown","event","key","includes","preventDefault","handleContainerClick","e","createElement","style","position","onClick","top","left","width","backgroundColor","ref","onKeyDown","ToolbarActionDialog","disabled","buttonAriaLabel","buttonClassName","buttonIconClassName","buttonLabel","menuWindowRef","showDropDown","setShowDropDown","handleClose","current","focus","className"],"sources":["ToolbarActionDialog.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\n\nfunction MenuContainer({\n children,\n menuContainerRef,\n onClose\n}: {\n children: React.ReactNode | React.ReactNode[];\n menuContainerRef?: React.Ref<HTMLDivElement>;\n onClose: () => void;\n}) {\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const key = event.key;\n\n if ([\"Escape\", \"ArrowUp\", \"ArrowDown\", \"Tab\"].includes(key)) {\n event.preventDefault();\n }\n\n if (key === \"Escape\" || key === \"Tab\") {\n onClose();\n }\n };\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n e.preventDefault();\n };\n\n return (\n <div style={{ position: \"relative\" }}>\n <div\n onClick={e => handleContainerClick(e)}\n style={{\n position: \"absolute\",\n top: -10,\n left: 0,\n width: 240,\n backgroundColor: \"#fff\"\n }}\n ref={menuContainerRef ?? null}\n onKeyDown={handleKeyDown}\n >\n {children}\n </div>\n </div>\n );\n}\ninterface ToolbarActionDialogProps {\n disabled: boolean;\n buttonLabel?: string;\n buttonAriaLabel: string;\n buttonClassName: string;\n buttonIconClassName: string;\n children: React.ReactNode | React.ReactNode[];\n}\n\nexport const ToolbarActionDialog = ({\n disabled,\n buttonAriaLabel,\n buttonClassName,\n buttonIconClassName,\n buttonLabel,\n children\n}: ToolbarActionDialogProps): JSX.Element => {\n const menuWindowRef = useRef<HTMLDivElement>(null);\n const [showDropDown, setShowDropDown] = useState(false);\n\n const handleClose = () => {\n if (menuWindowRef && menuWindowRef.current) {\n setShowDropDown(false);\n menuWindowRef.current.focus();\n }\n };\n\n return (\n <div style={{ position: \"relative\" }}>\n <button\n style={{ position: \"relative\" }}\n disabled={disabled}\n aria-label={buttonAriaLabel || buttonLabel}\n className={buttonClassName}\n onClick={() => {\n setShowDropDown(!showDropDown);\n }}\n >\n {buttonIconClassName && <span className={buttonIconClassName} />}\n {buttonLabel && <span className=\"text dropdown-button-text\">{buttonLabel}</span>}\n <i className=\"chevron-down\" />\n </button>\n {showDropDown && <MenuContainer onClose={handleClose}>{children}</MenuContainer>}\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAE/C,SAASC,aAAaA,CAAC;EACnBC,QAAQ;EACRC,gBAAgB;EAChBC;AAKJ,CAAC,EAAE;EACC,MAAMC,aAAa,GAAIC,KAA0C,IAAK;IAClE,MAAMC,GAAG,GAAGD,KAAK,CAACC,GAAG;IAErB,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAACC,QAAQ,CAACD,GAAG,CAAC,EAAE;MACzDD,KAAK,CAACG,cAAc,CAAC,CAAC;IAC1B;IAEA,IAAIF,GAAG,KAAK,QAAQ,IAAIA,GAAG,KAAK,KAAK,EAAE;MACnCH,OAAO,CAAC,CAAC;IACb;EACJ,CAAC;EAED,MAAMM,oBAAoB,GAAIC,CAA+C,IAAK;IAC9EA,CAAC,CAACF,cAAc,CAAC,CAAC;EACtB,CAAC;EAED,oBACIX,KAAA,CAAAc,aAAA;IAAKC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAW;EAAE,gBACjChB,KAAA,CAAAc,aAAA;IACIG,OAAO,EAAEJ,CAAC,IAAID,oBAAoB,CAACC,CAAC,CAAE;IACtCE,KAAK,EAAE;MACHC,QAAQ,EAAE,UAAU;MACpBE,GAAG,EAAE,CAAC,EAAE;MACRC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAE,GAAG;MACVC,eAAe,EAAE;IACrB,CAAE;IACFC,GAAG,EAAEjB,gBAAgB,IAAI,IAAK;IAC9BkB,SAAS,EAAEhB;EAAc,GAExBH,QACA,CACJ,CAAC;AAEd;AAUA,OAAO,MAAMoB,mBAAmB,GAAGA,CAAC;EAChCC,QAAQ;EACRC,eAAe;EACfC,eAAe;EACfC,mBAAmB;EACnBC,WAAW;EACXzB;AACsB,CAAC,KAAkB;EACzC,MAAM0B,aAAa,GAAG7B,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAM,CAAC8B,YAAY,EAAEC,eAAe,CAAC,GAAG9B,QAAQ,CAAC,KAAK,CAAC;EAEvD,MAAM+B,WAAW,GAAGA,CAAA,KAAM;IACtB,IAAIH,aAAa,IAAIA,aAAa,CAACI,OAAO,EAAE;MACxCF,eAAe,CAAC,KAAK,CAAC;MACtBF,aAAa,CAACI,OAAO,CAACC,KAAK,CAAC,CAAC;IACjC;EACJ,CAAC;EAED,oBACInC,KAAA,CAAAc,aAAA;IAAKC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAW;EAAE,gBACjChB,KAAA,CAAAc,aAAA;IACIC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAW,CAAE;IAChCS,QAAQ,EAAEA,QAAS;IACnB,cAAYC,eAAe,IAAIG,WAAY;IAC3CO,SAAS,EAAET,eAAgB;IAC3BV,OAAO,EAAEA,CAAA,KAAM;MACXe,eAAe,CAAC,CAACD,YAAY,CAAC;IAClC;EAAE,GAEDH,mBAAmB,iBAAI5B,KAAA,CAAAc,aAAA;IAAMsB,SAAS,EAAER;EAAoB,CAAE,CAAC,EAC/DC,WAAW,iBAAI7B,KAAA,CAAAc,aAAA;IAAMsB,SAAS,EAAC;EAA2B,GAAEP,WAAkB,CAAC,eAChF7B,KAAA,CAAAc,aAAA;IAAGsB,SAAS,EAAC;EAAc,CAAE,CACzB,CAAC,EACRL,YAAY,iBAAI/B,KAAA,CAAAc,aAAA,CAACX,aAAa;IAACG,OAAO,EAAE2B;EAAY,GAAE7B,QAAwB,CAC9E,CAAC;AAEd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CAN_USE_DOM: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CAN_USE_DOM","window","document","createElement"],"sources":["canUseDOM.ts"],"sourcesContent":["export const CAN_USE_DOM: boolean =\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\" &&\n typeof window.document.createElement !== \"undefined\";\n"],"mappings":"AAAA,OAAO,MAAMA,WAAoB,GAC7B,OAAOC,MAAM,KAAK,WAAW,IAC7B,OAAOA,MAAM,CAACC,QAAQ,KAAK,WAAW,IACtC,OAAOD,MAAM,CAACC,QAAQ,CAACC,aAAa,KAAK,WAAW","ignoreList":[]}
|
package/utils/files.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ImagePayload } from "../commands";
|
|
2
|
+
export interface FileManagerFileItem {
|
|
3
|
+
id: string;
|
|
4
|
+
src: string;
|
|
5
|
+
meta?: Array<FileManagerFileItemMetaItem>;
|
|
6
|
+
}
|
|
7
|
+
export interface FileManagerFileItemMetaItem {
|
|
8
|
+
key: string;
|
|
9
|
+
value: any;
|
|
10
|
+
}
|
|
11
|
+
export declare const fileToImagePayload: (file: FileManagerFileItem) => ImagePayload | null;
|
package/utils/files.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const fileToImagePayload = file => {
|
|
2
|
+
const imagePayload = {};
|
|
3
|
+
imagePayload["id"] = file.id;
|
|
4
|
+
imagePayload["src"] = file.src;
|
|
5
|
+
imagePayload["showCaption"] = true;
|
|
6
|
+
imagePayload["captionsEnabled"] = true;
|
|
7
|
+
if (file?.meta) {
|
|
8
|
+
for (const metaValue of file.meta) {
|
|
9
|
+
if (metaValue.key === "name") {
|
|
10
|
+
imagePayload["altText"] = metaValue.value;
|
|
11
|
+
} else if (metaValue.key === "width") {
|
|
12
|
+
imagePayload["width"] = metaValue.value;
|
|
13
|
+
} else if (metaValue.key === "height") {
|
|
14
|
+
imagePayload["height"] = metaValue.value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return imagePayload;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fileToImagePayload","file","imagePayload","id","src","meta","metaValue","key","value"],"sources":["files.ts"],"sourcesContent":["import type { ImagePayload } from \"~/commands\";\n\nexport interface FileManagerFileItem {\n id: string;\n src: string;\n meta?: Array<FileManagerFileItemMetaItem>;\n}\n\nexport interface FileManagerFileItemMetaItem {\n key: string;\n value: any;\n}\n\nexport const fileToImagePayload = (file: FileManagerFileItem): ImagePayload | null => {\n const imagePayload = {} as ImagePayload;\n imagePayload[\"id\"] = file.id;\n imagePayload[\"src\"] = file.src;\n imagePayload[\"showCaption\"] = true;\n imagePayload[\"captionsEnabled\"] = true;\n\n if (file?.meta) {\n for (const metaValue of file.meta) {\n if (metaValue.key === \"name\") {\n imagePayload[\"altText\"] = metaValue.value;\n } else if (metaValue.key === \"width\") {\n imagePayload[\"width\"] = metaValue.value;\n } else if (metaValue.key === \"height\") {\n imagePayload[\"height\"] = metaValue.value;\n }\n }\n }\n\n return imagePayload;\n};\n"],"mappings":"AAaA,OAAO,MAAMA,kBAAkB,GAAIC,IAAyB,IAA0B;EAClF,MAAMC,YAAY,GAAG,CAAC,CAAiB;EACvCA,YAAY,CAAC,IAAI,CAAC,GAAGD,IAAI,CAACE,EAAE;EAC5BD,YAAY,CAAC,KAAK,CAAC,GAAGD,IAAI,CAACG,GAAG;EAC9BF,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI;EAClCA,YAAY,CAAC,iBAAiB,CAAC,GAAG,IAAI;EAEtC,IAAID,IAAI,EAAEI,IAAI,EAAE;IACZ,KAAK,MAAMC,SAAS,IAAIL,IAAI,CAACI,IAAI,EAAE;MAC/B,IAAIC,SAAS,CAACC,GAAG,KAAK,MAAM,EAAE;QAC1BL,YAAY,CAAC,SAAS,CAAC,GAAGI,SAAS,CAACE,KAAK;MAC7C,CAAC,MAAM,IAAIF,SAAS,CAACC,GAAG,KAAK,OAAO,EAAE;QAClCL,YAAY,CAAC,OAAO,CAAC,GAAGI,SAAS,CAACE,KAAK;MAC3C,CAAC,MAAM,IAAIF,SAAS,CAACC,GAAG,KAAK,QAAQ,EAAE;QACnCL,YAAY,CAAC,QAAQ,CAAC,GAAGI,SAAS,CAACE,KAAK;MAC5C;IACJ;EACJ;EAEA,OAAON,YAAY;AACvB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export declare function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export function getDOMRangeRect(nativeSelection, rootElement) {
|
|
9
|
+
const domRange = nativeSelection.getRangeAt(0);
|
|
10
|
+
let rect;
|
|
11
|
+
if (nativeSelection.anchorNode === rootElement) {
|
|
12
|
+
let inner = rootElement;
|
|
13
|
+
while (inner.firstElementChild != null) {
|
|
14
|
+
inner = inner.firstElementChild;
|
|
15
|
+
}
|
|
16
|
+
rect = inner.getBoundingClientRect();
|
|
17
|
+
} else {
|
|
18
|
+
rect = domRange.getBoundingClientRect();
|
|
19
|
+
}
|
|
20
|
+
return rect;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=getDOMRangeRect.js.map
|
|
@@ -0,0 +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":"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":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
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();
|
|
14
|
+
if (anchorNode === focusNode) {
|
|
15
|
+
return anchorNode;
|
|
16
|
+
}
|
|
17
|
+
const isBackward = selection.isBackward();
|
|
18
|
+
if (isBackward) {
|
|
19
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
20
|
+
} else {
|
|
21
|
+
return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=getSelectedNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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"],"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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTransparentImage: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $insertNodes, $isRootOrShadowRoot } from "lexical";
|
|
2
|
+
import { $wrapNodeInElement } from "@lexical/utils";
|
|
3
|
+
import { $createParagraphNode, $createImageNode } from "@webiny/lexical-nodes";
|
|
4
|
+
/*
|
|
5
|
+
* Insert image into editor.
|
|
6
|
+
*/
|
|
7
|
+
export const insertImage = payload => {
|
|
8
|
+
const imageNode = $createImageNode(payload);
|
|
9
|
+
$insertNodes([imageNode]);
|
|
10
|
+
if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {
|
|
11
|
+
$wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=insertImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 type { 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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isAnchorLink: (url: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isChildOfFloatingToolbar: (element: HTMLElement | null) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const isChildOfFloatingToolbar = element => {
|
|
2
|
+
const parent = element ? element.parentElement : null;
|
|
3
|
+
if (!parent) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (parent.classList.contains("floating-toolbar")) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return isChildOfFloatingToolbar(parent);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=isChildOfFloatingToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export declare function isHTMLElement(x: unknown): x is HTMLElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
export function isHTMLElement(x) {
|
|
9
|
+
return x instanceof HTMLElement;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=isHTMLElement.js.map
|
|
@@ -0,0 +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":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAACC,CAAU,EAAoB;EACxD,OAAOA,CAAC,YAAYC,WAAW;AACnC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isValidJSON: (value: string | undefined | null) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const isValidJSON = value => {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
const o = JSON.parse(value);
|
|
7
|
+
return !!o && typeof o === "object" && !Array.isArray(o);
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=isValidJSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SerializedEditorState } from "lexical";
|
|
2
|
+
import type { LexicalValue } from "../types";
|
|
3
|
+
export declare const parseLexicalState: (editorStateValue: LexicalValue | null) => false | SerializedEditorState;
|
|
4
|
+
export declare const isValidLexicalData: (editorStateValue: LexicalValue | null) => editorStateValue is string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const parseLexicalState = editorStateValue => {
|
|
2
|
+
if (!editorStateValue) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
const maybeValidState = JSON.parse(editorStateValue);
|
|
7
|
+
return maybeValidState["root"] ? maybeValidState : false;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const isValidLexicalData = editorStateValue => {
|
|
13
|
+
if (!editorStateValue) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const data = JSON.parse(editorStateValue);
|
|
18
|
+
return !!data["root"];
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=isValidLexicalData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseLexicalState","editorStateValue","maybeValidState","JSON","parse","isValidLexicalData","data"],"sources":["isValidLexicalData.ts"],"sourcesContent":["import type { SerializedEditorState } from \"lexical\";\nimport type { 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 = (\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"],"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,GAC3BJ,gBAAqC,IACF;EACnC,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.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export declare class Point {
|
|
9
|
+
private readonly _x;
|
|
10
|
+
private readonly _y;
|
|
11
|
+
constructor(x: number, y: number);
|
|
12
|
+
get x(): number;
|
|
13
|
+
get y(): number;
|
|
14
|
+
equals({ x, y }: Point): boolean;
|
|
15
|
+
calcDeltaXTo({ x }: Point): number;
|
|
16
|
+
calcDeltaYTo({ y }: Point): number;
|
|
17
|
+
calcHorizontalDistanceTo(point: Point): number;
|
|
18
|
+
calcVerticalDistance(point: Point): number;
|
|
19
|
+
calcDistanceTo(point: Point): number;
|
|
20
|
+
}
|
|
21
|
+
export declare function isPoint(x: unknown): x is Point;
|
package/utils/point.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
export class Point {
|
|
9
|
+
constructor(x, y) {
|
|
10
|
+
this._x = x;
|
|
11
|
+
this._y = y;
|
|
12
|
+
}
|
|
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) {
|
|
46
|
+
return x instanceof Point;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=point.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
package/utils/rect.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
import type { Point } from "./point";
|
|
9
|
+
type ContainsPointReturn = {
|
|
10
|
+
result: boolean;
|
|
11
|
+
reason: {
|
|
12
|
+
isOnTopSide: boolean;
|
|
13
|
+
isOnBottomSide: boolean;
|
|
14
|
+
isOnLeftSide: boolean;
|
|
15
|
+
isOnRightSide: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare class Rect {
|
|
19
|
+
private readonly _left;
|
|
20
|
+
private readonly _top;
|
|
21
|
+
private readonly _right;
|
|
22
|
+
private readonly _bottom;
|
|
23
|
+
constructor(left: number, top: number, right: number, bottom: number);
|
|
24
|
+
get top(): number;
|
|
25
|
+
get right(): number;
|
|
26
|
+
get bottom(): number;
|
|
27
|
+
get left(): number;
|
|
28
|
+
get width(): number;
|
|
29
|
+
get height(): number;
|
|
30
|
+
equals({ top, left, bottom, right }: Rect): boolean;
|
|
31
|
+
contains({ x, y }: Point): ContainsPointReturn;
|
|
32
|
+
contains({ top, left, bottom, right }: Rect): boolean;
|
|
33
|
+
intersectsWith(rect: Rect): boolean;
|
|
34
|
+
generateNewRect({ left, top, right, bottom }: {
|
|
35
|
+
left?: number | undefined;
|
|
36
|
+
top?: number | undefined;
|
|
37
|
+
right?: number | undefined;
|
|
38
|
+
bottom?: number | undefined;
|
|
39
|
+
}): Rect;
|
|
40
|
+
static fromLTRB(left: number, top: number, right: number, bottom: number): Rect;
|
|
41
|
+
static fromLWTH(left: number, width: number, top: number, height: number): Rect;
|
|
42
|
+
static fromPoints(startPoint: Point, endPoint: Point): Rect;
|
|
43
|
+
static fromDOM(dom: HTMLElement): Rect;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
package/utils/rect.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
import { isPoint } from "./point";
|
|
10
|
+
export class Rect {
|
|
11
|
+
constructor(left, top, right, bottom) {
|
|
12
|
+
const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top];
|
|
13
|
+
const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left];
|
|
14
|
+
this._top = physicTop;
|
|
15
|
+
this._right = physicRight;
|
|
16
|
+
this._left = physicLeft;
|
|
17
|
+
this._bottom = physicBottom;
|
|
18
|
+
}
|
|
19
|
+
get top() {
|
|
20
|
+
return this._top;
|
|
21
|
+
}
|
|
22
|
+
get right() {
|
|
23
|
+
return this._right;
|
|
24
|
+
}
|
|
25
|
+
get bottom() {
|
|
26
|
+
return this._bottom;
|
|
27
|
+
}
|
|
28
|
+
get left() {
|
|
29
|
+
return this._left;
|
|
30
|
+
}
|
|
31
|
+
get width() {
|
|
32
|
+
return Math.abs(this._left - this._right);
|
|
33
|
+
}
|
|
34
|
+
get height() {
|
|
35
|
+
return Math.abs(this._bottom - this._top);
|
|
36
|
+
}
|
|
37
|
+
equals({
|
|
38
|
+
top,
|
|
39
|
+
left,
|
|
40
|
+
bottom,
|
|
41
|
+
right
|
|
42
|
+
}) {
|
|
43
|
+
return top === this._top && bottom === this._bottom && left === this._left && right === this._right;
|
|
44
|
+
}
|
|
45
|
+
contains(target) {
|
|
46
|
+
if (isPoint(target)) {
|
|
47
|
+
const {
|
|
48
|
+
x,
|
|
49
|
+
y
|
|
50
|
+
} = target;
|
|
51
|
+
const isOnTopSide = y < this._top;
|
|
52
|
+
const isOnBottomSide = y > this._bottom;
|
|
53
|
+
const isOnLeftSide = x < this._left;
|
|
54
|
+
const isOnRightSide = x > this._right;
|
|
55
|
+
const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide;
|
|
56
|
+
return {
|
|
57
|
+
reason: {
|
|
58
|
+
isOnBottomSide,
|
|
59
|
+
isOnLeftSide,
|
|
60
|
+
isOnRightSide,
|
|
61
|
+
isOnTopSide
|
|
62
|
+
},
|
|
63
|
+
result
|
|
64
|
+
};
|
|
65
|
+
} else {
|
|
66
|
+
const {
|
|
67
|
+
top,
|
|
68
|
+
left,
|
|
69
|
+
bottom,
|
|
70
|
+
right
|
|
71
|
+
} = target;
|
|
72
|
+
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;
|
|
73
|
+
}
|
|
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
|
+
}
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=rect.js.map
|