@webiny/lexical-editor 6.3.0-beta.4 → 6.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
package/ui/LinkPreview.js
CHANGED
|
@@ -1,97 +1,74 @@
|
|
|
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 "./LinkPreview.css";
|
|
10
|
-
import * as
|
|
11
|
-
import { Suspense } from "react";
|
|
12
|
-
// Cached responses or running request promises
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
13
3
|
const PREVIEW_CACHE = {};
|
|
14
4
|
const URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
15
5
|
function useSuspenseRequest(url) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
preview: null
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if (!cached) {
|
|
23
|
-
cached = PREVIEW_CACHE[url] = fetch(`/api/link-preview?url=${encodeURI(url)}`).then(response => response.json()).then(preview => {
|
|
24
|
-
PREVIEW_CACHE[url] = preview;
|
|
25
|
-
return preview;
|
|
26
|
-
}).catch(() => {
|
|
27
|
-
PREVIEW_CACHE[url] = {
|
|
6
|
+
let cached = PREVIEW_CACHE[url];
|
|
7
|
+
if (!url.match(URL_MATCHER)) return {
|
|
28
8
|
preview: null
|
|
29
|
-
|
|
9
|
+
};
|
|
10
|
+
if (!cached) cached = PREVIEW_CACHE[url] = fetch(`/api/link-preview?url=${encodeURI(url)}`).then((response)=>response.json()).then((preview)=>{
|
|
11
|
+
PREVIEW_CACHE[url] = preview;
|
|
12
|
+
return preview;
|
|
13
|
+
}).catch(()=>{
|
|
14
|
+
PREVIEW_CACHE[url] = {
|
|
15
|
+
preview: null
|
|
16
|
+
};
|
|
30
17
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
throw cached;
|
|
34
|
-
}
|
|
35
|
-
return cached;
|
|
18
|
+
if (cached instanceof Promise) throw cached;
|
|
19
|
+
return cached;
|
|
36
20
|
}
|
|
37
|
-
function LinkPreviewContent({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
className: "CustomLinkPreview__domain"
|
|
56
|
-
}, preview.domain), preview.title && /*#__PURE__*/React.createElement("div", {
|
|
57
|
-
className: "CustomLinkPreview__title"
|
|
58
|
-
}, preview.title), preview.description && /*#__PURE__*/React.createElement("div", {
|
|
59
|
-
className: "CustomLinkPreview__description"
|
|
60
|
-
}, preview.description));
|
|
21
|
+
function LinkPreviewContent({ url }) {
|
|
22
|
+
const { preview } = useSuspenseRequest(url);
|
|
23
|
+
if (null === preview) return null;
|
|
24
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
25
|
+
className: "CustomLinkPreview__container"
|
|
26
|
+
}, preview.img && /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
27
|
+
className: "CustomLinkPreview__imageWrapper"
|
|
28
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("img", {
|
|
29
|
+
src: preview.img,
|
|
30
|
+
alt: preview.title,
|
|
31
|
+
className: "CustomLinkPreview__image"
|
|
32
|
+
})), preview.domain && /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
33
|
+
className: "CustomLinkPreview__domain"
|
|
34
|
+
}, preview.domain), preview.title && /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
35
|
+
className: "CustomLinkPreview__title"
|
|
36
|
+
}, preview.title), preview.description && /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
37
|
+
className: "CustomLinkPreview__description"
|
|
38
|
+
}, preview.description));
|
|
61
39
|
}
|
|
62
40
|
function Glimmer(props) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
41
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
42
|
+
className: "CustomLinkPreview__glimmer",
|
|
43
|
+
...props,
|
|
44
|
+
style: {
|
|
45
|
+
animationDelay: String(300 * (props.index || 0)),
|
|
46
|
+
...props.style || {}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
71
49
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
url: url
|
|
94
|
-
}));
|
|
50
|
+
function LinkPreview({ url }) {
|
|
51
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external_react.Suspense, {
|
|
52
|
+
fallback: /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external_react.Fragment, null, /*#__PURE__*/ __rspack_external_react.createElement(Glimmer, {
|
|
53
|
+
style: {
|
|
54
|
+
height: "80px"
|
|
55
|
+
},
|
|
56
|
+
index: 0
|
|
57
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement(Glimmer, {
|
|
58
|
+
style: {
|
|
59
|
+
width: "60%"
|
|
60
|
+
},
|
|
61
|
+
index: 1
|
|
62
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement(Glimmer, {
|
|
63
|
+
style: {
|
|
64
|
+
width: "80%"
|
|
65
|
+
},
|
|
66
|
+
index: 2
|
|
67
|
+
}))
|
|
68
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(LinkPreviewContent, {
|
|
69
|
+
url: url
|
|
70
|
+
}));
|
|
95
71
|
}
|
|
72
|
+
export { LinkPreview };
|
|
96
73
|
|
|
97
74
|
//# sourceMappingURL=LinkPreview.js.map
|
package/ui/LinkPreview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ui/LinkPreview.js","sources":["../../src/ui/LinkPreview.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 */\n\nimport \"./LinkPreview.css\";\n\nimport * as React from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { Suspense } from \"react\";\n\ntype Preview = {\n title: string;\n description: string;\n img: string;\n domain: string;\n} | null;\n\n// Cached responses or running request promises\nconst PREVIEW_CACHE: Record<string, Promise<Preview> | { preview: Preview }> = {};\n\nconst URL_MATCHER =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;\n\nfunction useSuspenseRequest(url: string) {\n let cached = PREVIEW_CACHE[url];\n\n if (!url.match(URL_MATCHER)) {\n return { preview: null };\n }\n\n if (!cached) {\n cached = PREVIEW_CACHE[url] = fetch(`/api/link-preview?url=${encodeURI(url)}`)\n .then(response => response.json())\n .then(preview => {\n PREVIEW_CACHE[url] = preview;\n return preview;\n })\n .catch(() => {\n PREVIEW_CACHE[url] = { preview: null };\n });\n }\n\n if (cached instanceof Promise) {\n throw cached;\n }\n\n return cached;\n}\n\nfunction LinkPreviewContent({\n url\n}: Readonly<{\n url: string;\n}>): React.JSX.Element | null {\n const { preview } = useSuspenseRequest(url);\n if (preview === null) {\n return null;\n }\n return (\n <div className=\"CustomLinkPreview__container\">\n {preview.img && (\n <div className=\"CustomLinkPreview__imageWrapper\">\n <img\n src={preview.img}\n alt={preview.title}\n className=\"CustomLinkPreview__image\"\n />\n </div>\n )}\n {preview.domain && <div className=\"CustomLinkPreview__domain\">{preview.domain}</div>}\n {preview.title && <div className=\"CustomLinkPreview__title\">{preview.title}</div>}\n {preview.description && (\n <div className=\"CustomLinkPreview__description\">{preview.description}</div>\n )}\n </div>\n );\n}\n\nfunction Glimmer(props: { style: CSSProperties; index: number }): React.JSX.Element {\n return (\n <div\n className=\"CustomLinkPreview__glimmer\"\n {...props}\n style={{\n animationDelay: String((props.index || 0) * 300),\n ...(props.style || {})\n }}\n />\n );\n}\n\nexport function LinkPreview({\n url\n}: Readonly<{\n url: string;\n}>): React.JSX.Element {\n return (\n <Suspense\n fallback={\n <>\n <Glimmer style={{ height: \"80px\" }} index={0} />\n <Glimmer style={{ width: \"60%\" }} index={1} />\n <Glimmer style={{ width: \"80%\" }} index={2} />\n </>\n }\n >\n <LinkPreviewContent url={url} />\n </Suspense>\n );\n}\n"],"names":["PREVIEW_CACHE","URL_MATCHER","useSuspenseRequest","url","cached","fetch","encodeURI","response","preview","Promise","LinkPreviewContent","Glimmer","props","String","LinkPreview","Suspense"],"mappings":";;AAsBA,MAAMA,gBAAyE,CAAC;AAEhF,MAAMC,cACF;AAEJ,SAASC,mBAAmBC,GAAW;IACnC,IAAIC,SAASJ,aAAa,CAACG,IAAI;IAE/B,IAAI,CAACA,IAAI,KAAK,CAACF,cACX,OAAO;QAAE,SAAS;IAAK;IAG3B,IAAI,CAACG,QACDA,SAASJ,aAAa,CAACG,IAAI,GAAGE,MAAM,CAAC,sBAAsB,EAAEC,UAAUH,MAAM,EACxE,IAAI,CAACI,CAAAA,WAAYA,SAAS,IAAI,IAC9B,IAAI,CAACC,CAAAA;QACFR,aAAa,CAACG,IAAI,GAAGK;QACrB,OAAOA;IACX,GACC,KAAK,CAAC;QACHR,aAAa,CAACG,IAAI,GAAG;YAAE,SAAS;QAAK;IACzC;IAGR,IAAIC,kBAAkBK,SAClB,MAAML;IAGV,OAAOA;AACX;AAEA,SAASM,mBAAmB,EACxBP,GAAG,EAGL;IACE,MAAM,EAAEK,OAAO,EAAE,GAAGN,mBAAmBC;IACvC,IAAIK,AAAY,SAAZA,SACA,OAAO;IAEX,OAAO,WAAP,GACI,sCAAC;QAAI,WAAU;OACVA,QAAQ,GAAG,IAAI,WAAJ,GACR,sCAAC;QAAI,WAAU;qBACX,sCAAC;QACG,KAAKA,QAAQ,GAAG;QAChB,KAAKA,QAAQ,KAAK;QAClB,WAAU;SAIrBA,QAAQ,MAAM,IAAI,WAAJ,GAAI,sCAAC;QAAI,WAAU;OAA6BA,QAAQ,MAAM,GAC5EA,QAAQ,KAAK,IAAI,WAAJ,GAAI,sCAAC;QAAI,WAAU;OAA4BA,QAAQ,KAAK,GACzEA,QAAQ,WAAW,IAAI,WAAJ,GAChB,sCAAC;QAAI,WAAU;OAAkCA,QAAQ,WAAW;AAIpF;AAEA,SAASG,QAAQC,KAA8C;IAC3D,OAAO,WAAP,GACI,sCAAC;QACG,WAAU;QACT,GAAGA,KAAK;QACT,OAAO;YACH,gBAAgBC,OAAQD,AAAoB,MAApBA,CAAAA,MAAM,KAAK,IAAI;YACvC,GAAIA,MAAM,KAAK,IAAI,CAAC,CAAC;QACzB;;AAGZ;AAEO,SAASE,YAAY,EACxBX,GAAG,EAGL;IACE,OAAO,WAAP,GACI,sCAACY,wBAAAA,QAAQA,EAAAA;QACL,wBACI,4FACI,sCAACJ,SAAOA;YAAC,OAAO;gBAAE,QAAQ;YAAO;YAAG,OAAO;0BAC3C,sCAACA,SAAOA;YAAC,OAAO;gBAAE,OAAO;YAAM;YAAG,OAAO;0BACzC,sCAACA,SAAOA;YAAC,OAAO;gBAAE,OAAO;YAAM;YAAG,OAAO;;qBAIjD,sCAACD,oBAAkBA;QAAC,KAAKP;;AAGrC"}
|
package/ui/Placeholder.js
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
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 "./Placeholder.css";
|
|
10
|
-
import * as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...styles
|
|
19
|
-
},
|
|
20
|
-
className: className || "Placeholder__root"
|
|
21
|
-
}, children);
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
function Placeholder({ children, className, styles }) {
|
|
4
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
5
|
+
style: {
|
|
6
|
+
...styles
|
|
7
|
+
},
|
|
8
|
+
className: className || "Placeholder__root"
|
|
9
|
+
}, children);
|
|
22
10
|
}
|
|
11
|
+
export { Placeholder };
|
|
23
12
|
|
|
24
13
|
//# sourceMappingURL=Placeholder.js.map
|
package/ui/Placeholder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ui/Placeholder.js","sources":["../../src/ui/Placeholder.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 */\n\nimport \"./Placeholder.css\";\n\nimport * as React from \"react\";\nimport type { ReactNode } from \"react\";\n\nexport function Placeholder({\n children,\n className,\n styles\n}: {\n children: ReactNode;\n className?: string;\n styles?: React.CSSProperties;\n}): React.JSX.Element {\n return (\n <div style={{ ...styles }} className={className || \"Placeholder__root\"}>\n {children}\n </div>\n );\n}\n"],"names":["Placeholder","children","className","styles"],"mappings":";;AAaO,SAASA,YAAY,EACxBC,QAAQ,EACRC,SAAS,EACTC,MAAM,EAKT;IACG,OAAO,WAAP,GACI,sCAAC;QAAI,OAAO;YAAE,GAAGA,MAAM;QAAC;QAAG,WAAWD,aAAa;OAC9CD;AAGb"}
|
package/ui/TextInput.js
CHANGED
|
@@ -1,34 +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
|
-
|
|
9
1
|
import "./Input.css";
|
|
10
|
-
import * as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
value: value,
|
|
27
|
-
onChange: e => {
|
|
28
|
-
onChange(e.target.value);
|
|
29
|
-
},
|
|
30
|
-
"data-test-id": dataTestId
|
|
31
|
-
}));
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
function TextInput({ label, value, onChange, placeholder = "", "data-test-id": dataTestId }) {
|
|
4
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
5
|
+
className: "Input__wrapper"
|
|
6
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("label", {
|
|
7
|
+
className: "Input__label"
|
|
8
|
+
}, label), /*#__PURE__*/ __rspack_external_react.createElement("input", {
|
|
9
|
+
type: "text",
|
|
10
|
+
className: "Input__input",
|
|
11
|
+
placeholder: placeholder,
|
|
12
|
+
value: value,
|
|
13
|
+
onChange: (e)=>{
|
|
14
|
+
onChange(e.target.value);
|
|
15
|
+
},
|
|
16
|
+
"data-test-id": dataTestId
|
|
17
|
+
}));
|
|
32
18
|
}
|
|
19
|
+
export default TextInput;
|
|
33
20
|
|
|
34
21
|
//# sourceMappingURL=TextInput.js.map
|
package/ui/TextInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ui/TextInput.js","sources":["../../src/ui/TextInput.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 */\n\nimport \"./Input.css\";\n\nimport * as React from \"react\";\n\ntype Props = Readonly<{\n \"data-test-id\"?: string;\n label: string;\n onChange: (val: string) => void;\n placeholder?: string;\n value: string;\n}>;\n\nexport default function TextInput({\n label,\n value,\n onChange,\n placeholder = \"\",\n \"data-test-id\": dataTestId\n}: Props): React.JSX.Element {\n return (\n <div className=\"Input__wrapper\">\n <label className=\"Input__label\">{label}</label>\n <input\n type=\"text\"\n className=\"Input__input\"\n placeholder={placeholder}\n value={value}\n onChange={e => {\n onChange(e.target.value);\n }}\n data-test-id={dataTestId}\n />\n </div>\n );\n}\n"],"names":["TextInput","label","value","onChange","placeholder","dataTestId","e"],"mappings":";;AAoBe,SAASA,UAAU,EAC9BC,KAAK,EACLC,KAAK,EACLC,QAAQ,EACRC,cAAc,EAAE,EAChB,gBAAgBC,UAAU,EACtB;IACJ,OAAO,WAAP,GACI,sCAAC;QAAI,WAAU;qBACX,sCAAC;QAAM,WAAU;OAAgBJ,QAAAA,WAAAA,GACjC,sCAAC;QACG,MAAK;QACL,WAAU;QACV,aAAaG;QACb,OAAOF;QACP,UAAUI,CAAAA;YACNH,SAASG,EAAE,MAAM,CAAC,KAAK;QAC3B;QACA,gBAAcD;;AAI9B"}
|
|
@@ -1,77 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
function MenuContainer({
|
|
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
|
-
|
|
31
|
-
},
|
|
32
|
-
ref: menuContainerRef ?? null,
|
|
33
|
-
onKeyDown: handleKeyDown
|
|
34
|
-
}, children));
|
|
1
|
+
import react, { useRef, useState } from "react";
|
|
2
|
+
function MenuContainer({ children, menuContainerRef, onClose }) {
|
|
3
|
+
const handleKeyDown = (event)=>{
|
|
4
|
+
const key = event.key;
|
|
5
|
+
if ([
|
|
6
|
+
"Escape",
|
|
7
|
+
"ArrowUp",
|
|
8
|
+
"ArrowDown",
|
|
9
|
+
"Tab"
|
|
10
|
+
].includes(key)) event.preventDefault();
|
|
11
|
+
if ("Escape" === key || "Tab" === key) onClose();
|
|
12
|
+
};
|
|
13
|
+
const handleContainerClick = (e)=>{
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
};
|
|
16
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
17
|
+
style: {
|
|
18
|
+
position: "relative"
|
|
19
|
+
}
|
|
20
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
21
|
+
onClick: (e)=>handleContainerClick(e),
|
|
22
|
+
style: {
|
|
23
|
+
position: "absolute",
|
|
24
|
+
top: -10,
|
|
25
|
+
left: 0,
|
|
26
|
+
width: 240,
|
|
27
|
+
backgroundColor: "#fff"
|
|
28
|
+
},
|
|
29
|
+
ref: menuContainerRef ?? null,
|
|
30
|
+
onKeyDown: handleKeyDown
|
|
31
|
+
}, children));
|
|
35
32
|
}
|
|
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
|
-
}), 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));
|
|
33
|
+
const ToolbarActionDialog = ({ disabled, buttonAriaLabel, buttonClassName, buttonIconClassName, buttonLabel, children })=>{
|
|
34
|
+
const menuWindowRef = useRef(null);
|
|
35
|
+
const [showDropDown, setShowDropDown] = useState(false);
|
|
36
|
+
const handleClose = ()=>{
|
|
37
|
+
if (menuWindowRef && menuWindowRef.current) {
|
|
38
|
+
setShowDropDown(false);
|
|
39
|
+
menuWindowRef.current.focus();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
43
|
+
style: {
|
|
44
|
+
position: "relative"
|
|
45
|
+
}
|
|
46
|
+
}, /*#__PURE__*/ react.createElement("button", {
|
|
47
|
+
style: {
|
|
48
|
+
position: "relative"
|
|
49
|
+
},
|
|
50
|
+
disabled: disabled,
|
|
51
|
+
"aria-label": buttonAriaLabel || buttonLabel,
|
|
52
|
+
className: buttonClassName,
|
|
53
|
+
onClick: ()=>{
|
|
54
|
+
setShowDropDown(!showDropDown);
|
|
55
|
+
}
|
|
56
|
+
}, buttonIconClassName && /*#__PURE__*/ react.createElement("span", {
|
|
57
|
+
className: buttonIconClassName
|
|
58
|
+
}), buttonLabel && /*#__PURE__*/ react.createElement("span", {
|
|
59
|
+
className: "text dropdown-button-text"
|
|
60
|
+
}, buttonLabel), /*#__PURE__*/ react.createElement("i", {
|
|
61
|
+
className: "chevron-down"
|
|
62
|
+
})), showDropDown && /*#__PURE__*/ react.createElement(MenuContainer, {
|
|
63
|
+
onClose: handleClose
|
|
64
|
+
}, children));
|
|
75
65
|
};
|
|
66
|
+
export { ToolbarActionDialog };
|
|
76
67
|
|
|
77
68
|
//# sourceMappingURL=ToolbarActionDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ui/ToolbarActionDialog.js","sources":["../../src/ui/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): React.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"],"names":["MenuContainer","children","menuContainerRef","onClose","handleKeyDown","event","key","handleContainerClick","e","ToolbarActionDialog","disabled","buttonAriaLabel","buttonClassName","buttonIconClassName","buttonLabel","menuWindowRef","useRef","showDropDown","setShowDropDown","useState","handleClose"],"mappings":";AAEA,SAASA,cAAc,EACnBC,QAAQ,EACRC,gBAAgB,EAChBC,OAAO,EAKV;IACG,MAAMC,gBAAgB,CAACC;QACnB,MAAMC,MAAMD,MAAM,GAAG;QAErB,IAAI;YAAC;YAAU;YAAW;YAAa;SAAM,CAAC,QAAQ,CAACC,MACnDD,MAAM,cAAc;QAGxB,IAAIC,AAAQ,aAARA,OAAoBA,AAAQ,UAARA,KACpBH;IAER;IAEA,MAAMI,uBAAuB,CAACC;QAC1BA,EAAE,cAAc;IACpB;IAEA,OAAO,WAAP,GACI,oBAAC;QAAI,OAAO;YAAE,UAAU;QAAW;qBAC/B,oBAAC;QACG,SAASA,CAAAA,IAAKD,qBAAqBC;QACnC,OAAO;YACH,UAAU;YACV,KAAK;YACL,MAAM;YACN,OAAO;YACP,iBAAiB;QACrB;QACA,KAAKN,oBAAoB;QACzB,WAAWE;OAEVH;AAIjB;AAUO,MAAMQ,sBAAsB,CAAC,EAChCC,QAAQ,EACRC,eAAe,EACfC,eAAe,EACfC,mBAAmB,EACnBC,WAAW,EACXb,QAAQ,EACe;IACvB,MAAMc,gBAAgBC,OAAuB;IAC7C,MAAM,CAACC,cAAcC,gBAAgB,GAAGC,SAAS;IAEjD,MAAMC,cAAc;QAChB,IAAIL,iBAAiBA,cAAc,OAAO,EAAE;YACxCG,gBAAgB;YAChBH,cAAc,OAAO,CAAC,KAAK;QAC/B;IACJ;IAEA,OAAO,WAAP,GACI,oBAAC;QAAI,OAAO;YAAE,UAAU;QAAW;qBAC/B,oBAAC;QACG,OAAO;YAAE,UAAU;QAAW;QAC9B,UAAUL;QACV,cAAYC,mBAAmBG;QAC/B,WAAWF;QACX,SAAS;YACLM,gBAAgB,CAACD;QACrB;OAECJ,uBAAuB,WAAvBA,GAAuB,oBAAC;QAAK,WAAWA;QACxCC,eAAe,WAAfA,GAAe,oBAAC;QAAK,WAAU;OAA6BA,cAAAA,WAAAA,GAC7D,oBAAC;QAAE,WAAU;SAEhBG,gBAAgB,WAAhBA,GAAgB,oBAACjB,eAAaA;QAAC,SAASoB;OAAcnB;AAGnE"}
|
package/utils/canUseDOM.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const CAN_USE_DOM = "u" > typeof window && void 0 !== window.document && void 0 !== window.document.createElement;
|
|
2
|
+
export { CAN_USE_DOM };
|
|
2
3
|
|
|
3
4
|
//# sourceMappingURL=canUseDOM.js.map
|
package/utils/canUseDOM.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/canUseDOM.js","sources":["../../src/utils/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"],"names":["CAN_USE_DOM","window"],"mappings":"AAAO,MAAMA,cACT,AAAkB,MAAlB,OAAOC,UACP,AAA2B,WAApBA,OAAO,QAAQ,IACtB,AAAyC,WAAlCA,OAAO,QAAQ,CAAC,aAAa"}
|
package/utils/files.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const fileToImagePayload = (file)=>{
|
|
2
|
+
const imagePayload = {};
|
|
3
|
+
imagePayload["id"] = file.id;
|
|
4
|
+
imagePayload["src"] = file.src;
|
|
5
|
+
imagePayload["altText"] = file.name;
|
|
6
|
+
imagePayload["width"] = file.width;
|
|
7
|
+
imagePayload["height"] = file.height;
|
|
8
|
+
return imagePayload;
|
|
9
9
|
};
|
|
10
|
+
export { fileToImagePayload };
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=files.js.map
|
package/utils/files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/files.js","sources":["../../src/utils/files.ts"],"sourcesContent":["import type { ImagePayload } from \"~/commands/index.js\";\n\nexport interface FileManagerFileItem {\n id: string;\n src: string;\n name: string;\n type: string; // MIME type\n size: number; // bytes\n // Required for images (apps depend on these for Next.js Image, etc.)\n width?: number;\n height?: number;\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[\"altText\"] = file.name;\n imagePayload[\"width\"] = file.width;\n imagePayload[\"height\"] = file.height;\n\n return imagePayload;\n};\n"],"names":["fileToImagePayload","file","imagePayload"],"mappings":"AAaO,MAAMA,qBAAqB,CAACC;IAC/B,MAAMC,eAAe,CAAC;IACtBA,YAAY,CAAC,KAAK,GAAGD,KAAK,EAAE;IAC5BC,YAAY,CAAC,MAAM,GAAGD,KAAK,GAAG;IAC9BC,YAAY,CAAC,UAAU,GAAGD,KAAK,IAAI;IACnCC,YAAY,CAAC,QAAQ,GAAGD,KAAK,KAAK;IAClCC,YAAY,CAAC,SAAS,GAAGD,KAAK,MAAM;IAEpC,OAAOC;AACX"}
|
package/utils/getDOMRangeRect.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
1
|
+
function getDOMRangeRect(nativeSelection, rootElement) {
|
|
2
|
+
const domRange = nativeSelection.getRangeAt(0);
|
|
3
|
+
let rect;
|
|
4
|
+
if (nativeSelection.anchorNode === rootElement) {
|
|
5
|
+
let inner = rootElement;
|
|
6
|
+
while(null != inner.firstElementChild)inner = inner.firstElementChild;
|
|
7
|
+
rect = inner.getBoundingClientRect();
|
|
8
|
+
} else rect = domRange.getBoundingClientRect();
|
|
9
|
+
return rect;
|
|
21
10
|
}
|
|
11
|
+
export { getDOMRangeRect };
|
|
22
12
|
|
|
23
13
|
//# sourceMappingURL=getDOMRangeRect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/getDOMRangeRect.js","sources":["../../src/utils/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"],"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","rect","inner"],"mappings":"AAOO,SAASA,gBAAgBC,eAA0B,EAAEC,WAAwB;IAChF,MAAMC,WAAWF,gBAAgB,UAAU,CAAC;IAE5C,IAAIG;IAEJ,IAAIH,gBAAgB,UAAU,KAAKC,aAAa;QAC5C,IAAIG,QAAQH;QACZ,MAAOG,AAA2B,QAA3BA,MAAM,iBAAiB,CAC1BA,QAAQA,MAAM,iBAAiB;QAEnCD,OAAOC,MAAM,qBAAqB;IACtC,OACID,OAAOD,SAAS,qBAAqB;IAGzC,OAAOC;AACX"}
|
package/utils/getSelectedNode.js
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
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
1
|
import { $isAtNodeEnd } from "@lexical/selection";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const isBackward = selection.isBackward();
|
|
18
|
-
if (isBackward) {
|
|
19
|
-
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
20
|
-
} else {
|
|
2
|
+
function getSelectedNode(selection) {
|
|
3
|
+
const anchor = selection.anchor;
|
|
4
|
+
const focus = selection.focus;
|
|
5
|
+
const anchorNode = selection.anchor.getNode();
|
|
6
|
+
const focusNode = selection.focus.getNode();
|
|
7
|
+
if (anchorNode === focusNode) return anchorNode;
|
|
8
|
+
const isBackward = selection.isBackward();
|
|
9
|
+
if (isBackward) return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
21
10
|
return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
|
|
22
|
-
}
|
|
23
11
|
}
|
|
12
|
+
export { getSelectedNode };
|
|
24
13
|
|
|
25
14
|
//# sourceMappingURL=getSelectedNode.js.map
|