@webiny/lexical-editor 5.44.1-beta.0 → 5.45.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -12
- package/commands/image.d.ts +2 -2
- package/commands/image.js +2 -8
- package/commands/image.js.map +1 -1
- package/commands/index.d.ts +5 -4
- package/commands/index.js +5 -49
- package/commands/index.js.map +1 -1
- package/commands/list.d.ts +1 -1
- package/commands/list.js +4 -10
- package/commands/list.js.map +1 -1
- package/commands/quote.d.ts +1 -1
- package/commands/quote.js +2 -8
- package/commands/quote.js.map +1 -1
- package/commands/toolbar.js +2 -8
- package/commands/toolbar.js.map +1 -1
- package/commands/typography.d.ts +8 -0
- package/commands/typography.js +4 -0
- package/commands/typography.js.map +1 -0
- package/components/Editor/EnsureHeadingTagPlugin.js +10 -16
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
- package/components/Editor/RichTextEditor.d.ts +12 -8
- package/components/Editor/RichTextEditor.js +89 -102
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.d.ts +1 -1
- package/components/Editor/normalizeInputValue.js +2 -8
- package/components/Editor/normalizeInputValue.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +14 -16
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +21 -69
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.d.ts +1 -1
- package/components/LexicalEditorConfig/components/Node.js +17 -26
- package/components/LexicalEditorConfig/components/Node.js.map +1 -1
- package/components/LexicalEditorConfig/components/Plugin.js +17 -26
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
- package/components/LexicalHtmlRenderer.d.ts +4 -7
- package/components/LexicalHtmlRenderer.js +35 -53
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.css +416 -0
- package/components/Toolbar/StaticToolbar.d.ts +3 -1
- package/components/Toolbar/StaticToolbar.js +19 -23
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +16 -21
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +25 -31
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js +16 -21
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +32 -42
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.js +19 -34
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js +16 -21
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js +19 -24
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +25 -36
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +20 -25
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js +36 -45
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +57 -79
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js +16 -21
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +2 -9
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.d.ts +6 -7
- package/context/RichTextEditorContext.js +28 -26
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.d.ts +2 -2
- package/context/SharedHistoryContext.js +12 -20
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.d.ts +1 -1
- package/context/TextAlignmentActionContextProps.js +2 -9
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.d.ts +3 -2
- package/context/TypographyActionContext.js +2 -9
- package/context/TypographyActionContext.js.map +1 -1
- package/exports/admin/lexical.d.ts +15 -0
- package/exports/admin/lexical.js +23 -0
- package/exports/admin/lexical.js.map +1 -0
- package/hooks/index.d.ts +7 -8
- package/hooks/index.js +7 -93
- package/hooks/index.js.map +1 -1
- package/hooks/useCurrentElement.d.ts +3 -3
- package/hooks/useCurrentElement.js +11 -18
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.d.ts +2 -1
- package/hooks/useCurrentSelection.js +27 -40
- package/hooks/useCurrentSelection.js.map +1 -1
- package/hooks/useFontColorPicker.d.ts +1 -1
- package/hooks/useFontColorPicker.js +5 -11
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useIsMounted.js +6 -14
- package/hooks/useIsMounted.js.map +1 -1
- package/hooks/useRichTextEditor.d.ts +1 -1
- package/hooks/useRichTextEditor.js +5 -11
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.d.ts +1 -1
- package/hooks/useTextAlignmentAction.js +5 -11
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.d.ts +1 -1
- package/hooks/useTypographyAction.js +5 -11
- package/hooks/useTypographyAction.js.map +1 -1
- package/index.d.ts +33 -38
- package/index.js +44 -322
- package/index.js.map +1 -1
- package/package.json +18 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
- package/plugins/CodeHighlightPlugin/index.js +1 -16
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +10 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +28 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +61 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -136
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -16
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +7 -180
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +3 -9
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/types.d.ts +10 -0
- package/plugins/FloatingLinkEditorPlugin/types.js +3 -0
- package/plugins/FloatingLinkEditorPlugin/types.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +8 -2
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +120 -88
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js +19 -22
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.d.ts +2 -2
- package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToSelection.d.ts +2 -2
- package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +1 -2
- package/plugins/ImagesPlugin/ImagesPlugin.js +58 -60
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +29 -37
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +52 -15
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +19 -16
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
- package/plugins/StateHandlingPlugin.d.ts +1 -1
- package/plugins/StateHandlingPlugin.js +32 -39
- package/plugins/StateHandlingPlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +17 -21
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/types.d.ts +4 -4
- package/types.js +6 -38
- package/types.js.map +1 -1
- package/ui/ContentEditable.d.ts +0 -1
- package/ui/ContentEditable.js +7 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.d.ts +0 -1
- package/ui/Divider.js +3 -10
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.d.ts +1 -1
- package/ui/DropDown.js +64 -90
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.d.ts +0 -1
- package/ui/ImageResizer.js +78 -83
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.d.ts +0 -1
- package/ui/LinkPreview.js +22 -29
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.d.ts +1 -1
- package/ui/Placeholder.js +10 -16
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.d.ts +0 -1
- package/ui/TextInput.js +11 -18
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.js +30 -42
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.js +1 -7
- package/utils/canUseDOM.js.map +1 -1
- package/utils/files.d.ts +6 -6
- package/utils/files.js +5 -32
- package/utils/files.js.map +1 -1
- package/utils/getDOMRangeRect.js +4 -10
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.d.ts +1 -1
- package/utils/getSelectedNode.js +9 -16
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.js +1 -7
- package/utils/getTransparentImage.js.map +1 -1
- package/utils/insertImage.d.ts +1 -1
- package/utils/insertImage.js +8 -14
- package/utils/insertImage.js.map +1 -1
- package/utils/isAnchorLink.js +1 -7
- package/utils/isAnchorLink.js.map +1 -1
- package/utils/isChildOfFloatingToolbar.js +3 -12
- package/utils/isChildOfFloatingToolbar.js.map +1 -1
- package/utils/isHTMLElement.js +1 -7
- package/utils/isHTMLElement.js.map +1 -1
- package/utils/isValidJSON.js +3 -9
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.d.ts +3 -3
- package/utils/isValidLexicalData.js +6 -12
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +35 -60
- package/utils/point.js.map +1 -1
- package/utils/rect.d.ts +1 -1
- package/utils/rect.js +115 -149
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +6 -13
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.d.ts +1 -1
- package/utils/setFloatingElemPosition.js +24 -30
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/components/Editor/HeadingEditor.d.ts +0 -7
- package/components/Editor/HeadingEditor.js +0 -30
- package/components/Editor/HeadingEditor.js.map +0 -1
- package/components/Editor/ParagraphEditor.d.ts +0 -7
- package/components/Editor/ParagraphEditor.js +0 -29
- package/components/Editor/ParagraphEditor.js.map +0 -1
- package/components/Toolbar/Toolbar.css +0 -643
- package/components/Toolbar/Toolbar.d.ts +0 -11
- package/components/Toolbar/Toolbar.js +0 -165
- package/components/Toolbar/Toolbar.js.map +0 -1
- package/components/ToolbarActions/FontSizeAction.d.ts +0 -14
- package/components/ToolbarActions/FontSizeAction.js +0 -109
- package/components/ToolbarActions/FontSizeAction.js.map +0 -1
- package/hooks/useList.d.ts +0 -2
- package/hooks/useList.js +0 -54
- package/hooks/useList.js.map +0 -1
- package/hooks/useQuote.d.ts +0 -2
- package/hooks/useQuote.js +0 -22
- package/hooks/useQuote.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +0 -9
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +0 -118
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +0 -9
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +0 -44
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +0 -1
- package/utils/generateInitialLexicalValue.d.ts +0 -4
- package/utils/generateInitialLexicalValue.js +0 -33
- package/utils/generateInitialLexicalValue.js.map +0 -1
package/ui/Placeholder.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.Placeholder = Placeholder;
|
|
9
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
-
require("./Placeholder.css");
|
|
11
|
-
var React = _interopRequireWildcard(require("react"));
|
|
12
1
|
/**
|
|
13
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
3
|
*
|
|
@@ -17,12 +6,17 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
17
6
|
*
|
|
18
7
|
*/
|
|
19
8
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
import "./Placeholder.css";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
export function Placeholder({
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
styles
|
|
15
|
+
}) {
|
|
24
16
|
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
-
style:
|
|
17
|
+
style: {
|
|
18
|
+
...styles
|
|
19
|
+
},
|
|
26
20
|
className: className || "Placeholder__root"
|
|
27
21
|
}, children);
|
|
28
22
|
}
|
package/ui/Placeholder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","Placeholder","children","className","styles","createElement","style"],"sources":["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}): JSX.Element {\n return (\n <div style={{ ...styles }} className={className || \"Placeholder__root\"}>\n {children}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,SAASC,WAAWA,CAAC;EACxBC,QAAQ;EACRC,SAAS;EACTC;AAKJ,CAAC,EAAe;EACZ,oBACIJ,KAAA,CAAAK,aAAA;IAAKC,KAAK,EAAE;MAAE,GAAGF;IAAO,CAAE;IAACD,SAAS,EAAEA,SAAS,IAAI;EAAoB,GAClED,QACA,CAAC;AAEd","ignoreList":[]}
|
package/ui/TextInput.d.ts
CHANGED
package/ui/TextInput.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = TextInput;
|
|
8
|
-
require("./Input.css");
|
|
9
|
-
var React = _interopRequireWildcard(require("react"));
|
|
10
1
|
/**
|
|
11
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
3
|
*
|
|
@@ -15,13 +6,15 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
15
6
|
*
|
|
16
7
|
*/
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
import "./Input.css";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
export default function TextInput({
|
|
12
|
+
label,
|
|
13
|
+
value,
|
|
14
|
+
onChange,
|
|
15
|
+
placeholder = "",
|
|
16
|
+
"data-test-id": dataTestId
|
|
17
|
+
}) {
|
|
25
18
|
return /*#__PURE__*/React.createElement("div", {
|
|
26
19
|
className: "Input__wrapper"
|
|
27
20
|
}, /*#__PURE__*/React.createElement("label", {
|
|
@@ -31,8 +24,8 @@ function TextInput(_ref) {
|
|
|
31
24
|
className: "Input__input",
|
|
32
25
|
placeholder: placeholder,
|
|
33
26
|
value: value,
|
|
34
|
-
onChange:
|
|
35
|
-
|
|
27
|
+
onChange: e => {
|
|
28
|
+
onChange(e.target.value);
|
|
36
29
|
},
|
|
37
30
|
"data-test-id": dataTestId
|
|
38
31
|
}));
|
package/ui/TextInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","TextInput","label","value","onChange","placeholder","dataTestId","createElement","className","type","e","target"],"sources":["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): 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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAU9B,eAAe,SAASC,SAASA,CAAC;EAC9BC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,WAAW,GAAG,EAAE;EAChB,cAAc,EAAEC;AACb,CAAC,EAAe;EACnB,oBACIN,KAAA,CAAAO,aAAA;IAAKC,SAAS,EAAC;EAAgB,gBAC3BR,KAAA,CAAAO,aAAA;IAAOC,SAAS,EAAC;EAAc,GAAEN,KAAa,CAAC,eAC/CF,KAAA,CAAAO,aAAA;IACIE,IAAI,EAAC,MAAM;IACXD,SAAS,EAAC,cAAc;IACxBH,WAAW,EAAEA,WAAY;IACzBF,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEM,CAAC,IAAI;MACXN,QAAQ,CAACM,CAAC,CAACC,MAAM,CAACR,KAAK,CAAC;IAC5B,CAAE;IACF,gBAAcG;EAAW,CAC5B,CACA,CAAC;AAEd","ignoreList":[]}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
function MenuContainer(_ref) {
|
|
12
|
-
var children = _ref.children,
|
|
13
|
-
menuContainerRef = _ref.menuContainerRef,
|
|
14
|
-
onClose = _ref.onClose;
|
|
15
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
16
|
-
var key = event.key;
|
|
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;
|
|
17
9
|
if (["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(key)) {
|
|
18
10
|
event.preventDefault();
|
|
19
11
|
}
|
|
@@ -21,17 +13,15 @@ function MenuContainer(_ref) {
|
|
|
21
13
|
onClose();
|
|
22
14
|
}
|
|
23
15
|
};
|
|
24
|
-
|
|
16
|
+
const handleContainerClick = e => {
|
|
25
17
|
e.preventDefault();
|
|
26
18
|
};
|
|
27
|
-
return /*#__PURE__*/
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
20
|
style: {
|
|
29
21
|
position: "relative"
|
|
30
22
|
}
|
|
31
|
-
}, /*#__PURE__*/
|
|
32
|
-
onClick:
|
|
33
|
-
return handleContainerClick(e);
|
|
34
|
-
},
|
|
23
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
onClick: e => handleContainerClick(e),
|
|
35
25
|
style: {
|
|
36
26
|
position: "absolute",
|
|
37
27
|
top: -10,
|
|
@@ -43,45 +33,43 @@ function MenuContainer(_ref) {
|
|
|
43
33
|
onKeyDown: handleKeyDown
|
|
44
34
|
}, children));
|
|
45
35
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
setShowDropDown = _useState2[1];
|
|
58
|
-
var handleClose = function handleClose() {
|
|
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 = () => {
|
|
59
47
|
if (menuWindowRef && menuWindowRef.current) {
|
|
60
48
|
setShowDropDown(false);
|
|
61
49
|
menuWindowRef.current.focus();
|
|
62
50
|
}
|
|
63
51
|
};
|
|
64
|
-
return /*#__PURE__*/
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
65
53
|
style: {
|
|
66
54
|
position: "relative"
|
|
67
55
|
}
|
|
68
|
-
}, /*#__PURE__*/
|
|
56
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
69
57
|
style: {
|
|
70
58
|
position: "relative"
|
|
71
59
|
},
|
|
72
60
|
disabled: disabled,
|
|
73
61
|
"aria-label": buttonAriaLabel || buttonLabel,
|
|
74
62
|
className: buttonClassName,
|
|
75
|
-
onClick:
|
|
63
|
+
onClick: () => {
|
|
76
64
|
setShowDropDown(!showDropDown);
|
|
77
65
|
}
|
|
78
|
-
}, buttonIconClassName && /*#__PURE__*/
|
|
66
|
+
}, buttonIconClassName && /*#__PURE__*/React.createElement("span", {
|
|
79
67
|
className: buttonIconClassName
|
|
80
|
-
}), buttonLabel && /*#__PURE__*/
|
|
68
|
+
}), buttonLabel && /*#__PURE__*/React.createElement("span", {
|
|
81
69
|
className: "text dropdown-button-text"
|
|
82
|
-
}, buttonLabel), /*#__PURE__*/
|
|
70
|
+
}, buttonLabel), /*#__PURE__*/React.createElement("i", {
|
|
83
71
|
className: "chevron-down"
|
|
84
|
-
})), showDropDown && /*#__PURE__*/
|
|
72
|
+
})), showDropDown && /*#__PURE__*/React.createElement(MenuContainer, {
|
|
85
73
|
onClose: handleClose
|
|
86
74
|
}, children));
|
|
87
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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":[]}
|
package/utils/canUseDOM.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CAN_USE_DOM = void 0;
|
|
7
|
-
var CAN_USE_DOM = exports.CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
1
|
+
export const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
8
2
|
|
|
9
3
|
//# sourceMappingURL=canUseDOM.js.map
|
package/utils/canUseDOM.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CAN_USE_DOM","
|
|
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
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ImagePayload } from "../commands";
|
|
1
|
+
import type { ImagePayload } from "../commands/index.js";
|
|
2
2
|
export interface FileManagerFileItem {
|
|
3
3
|
id: string;
|
|
4
4
|
src: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
size: number;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
10
|
}
|
|
11
11
|
export declare const fileToImagePayload: (file: FileManagerFileItem) => ImagePayload | null;
|
package/utils/files.js
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.fileToImagePayload = void 0;
|
|
8
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
9
|
-
var fileToImagePayload = exports.fileToImagePayload = function fileToImagePayload(file) {
|
|
10
|
-
var imagePayload = {};
|
|
1
|
+
export const fileToImagePayload = file => {
|
|
2
|
+
const imagePayload = {};
|
|
11
3
|
imagePayload["id"] = file.id;
|
|
12
4
|
imagePayload["src"] = file.src;
|
|
13
|
-
imagePayload["
|
|
14
|
-
imagePayload["
|
|
15
|
-
|
|
16
|
-
var _iterator = (0, _createForOfIteratorHelper2.default)(file.meta),
|
|
17
|
-
_step;
|
|
18
|
-
try {
|
|
19
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
20
|
-
var metaValue = _step.value;
|
|
21
|
-
if (metaValue.key === "name") {
|
|
22
|
-
imagePayload["altText"] = metaValue.value;
|
|
23
|
-
} else if (metaValue.key === "width") {
|
|
24
|
-
imagePayload["width"] = metaValue.value;
|
|
25
|
-
} else if (metaValue.key === "height") {
|
|
26
|
-
imagePayload["height"] = metaValue.value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
} catch (err) {
|
|
30
|
-
_iterator.e(err);
|
|
31
|
-
} finally {
|
|
32
|
-
_iterator.f();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
5
|
+
imagePayload["altText"] = file.name;
|
|
6
|
+
imagePayload["width"] = file.width;
|
|
7
|
+
imagePayload["height"] = file.height;
|
|
35
8
|
return imagePayload;
|
|
36
9
|
};
|
|
37
10
|
|
package/utils/files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fileToImagePayload","
|
|
1
|
+
{"version":3,"names":["fileToImagePayload","file","imagePayload","id","src","name","width","height"],"sources":["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"],"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,SAAS,CAAC,GAAGD,IAAI,CAACI,IAAI;EACnCH,YAAY,CAAC,OAAO,CAAC,GAAGD,IAAI,CAACK,KAAK;EAClCJ,YAAY,CAAC,QAAQ,CAAC,GAAGD,IAAI,CAACM,MAAM;EAEpC,OAAOL,YAAY;AACvB,CAAC","ignoreList":[]}
|
package/utils/getDOMRangeRect.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDOMRangeRect = getDOMRangeRect;
|
|
7
1
|
/**
|
|
8
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
3
|
*
|
|
@@ -11,11 +5,11 @@ exports.getDOMRangeRect = getDOMRangeRect;
|
|
|
11
5
|
* LICENSE file in the root directory of this source tree.
|
|
12
6
|
*
|
|
13
7
|
*/
|
|
14
|
-
function getDOMRangeRect(nativeSelection, rootElement) {
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export function getDOMRangeRect(nativeSelection, rootElement) {
|
|
9
|
+
const domRange = nativeSelection.getRangeAt(0);
|
|
10
|
+
let rect;
|
|
17
11
|
if (nativeSelection.anchorNode === rootElement) {
|
|
18
|
-
|
|
12
|
+
let inner = rootElement;
|
|
19
13
|
while (inner.firstElementChild != null) {
|
|
20
14
|
inner = inner.firstElementChild;
|
|
21
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","getRangeAt","rect","anchorNode","inner","firstElementChild","getBoundingClientRect"],"sources":["getDOMRangeRect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {\n const domRange = nativeSelection.getRangeAt(0);\n\n let rect;\n\n if (nativeSelection.anchorNode === rootElement) {\n let inner = rootElement;\n while (inner.firstElementChild != null) {\n inner = inner.firstElementChild as HTMLElement;\n }\n rect = inner.getBoundingClientRect();\n } else {\n rect = domRange.getBoundingClientRect();\n }\n\n return rect;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","getRangeAt","rect","anchorNode","inner","firstElementChild","getBoundingClientRect"],"sources":["getDOMRangeRect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {\n const domRange = nativeSelection.getRangeAt(0);\n\n let rect;\n\n if (nativeSelection.anchorNode === rootElement) {\n let inner = rootElement;\n while (inner.firstElementChild != null) {\n inner = inner.firstElementChild as HTMLElement;\n }\n rect = inner.getBoundingClientRect();\n } else {\n rect = domRange.getBoundingClientRect();\n }\n\n return rect;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAACC,eAA0B,EAAEC,WAAwB,EAAW;EAC3F,MAAMC,QAAQ,GAAGF,eAAe,CAACG,UAAU,CAAC,CAAC,CAAC;EAE9C,IAAIC,IAAI;EAER,IAAIJ,eAAe,CAACK,UAAU,KAAKJ,WAAW,EAAE;IAC5C,IAAIK,KAAK,GAAGL,WAAW;IACvB,OAAOK,KAAK,CAACC,iBAAiB,IAAI,IAAI,EAAE;MACpCD,KAAK,GAAGA,KAAK,CAACC,iBAAgC;IAClD;IACAH,IAAI,GAAGE,KAAK,CAACE,qBAAqB,CAAC,CAAC;EACxC,CAAC,MAAM;IACHJ,IAAI,GAAGF,QAAQ,CAACM,qBAAqB,CAAC,CAAC;EAC3C;EAEA,OAAOJ,IAAI;AACf","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ElementNode, RangeSelection, TextNode } from "lexical";
|
|
1
|
+
import type { ElementNode, RangeSelection, TextNode } from "lexical";
|
|
2
2
|
export declare function getSelectedNode(selection: RangeSelection): TextNode | ElementNode;
|
package/utils/getSelectedNode.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSelectedNode = getSelectedNode;
|
|
7
|
-
var _selection = require("@lexical/selection");
|
|
8
1
|
/**
|
|
9
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
3
|
*
|
|
@@ -12,20 +5,20 @@ var _selection = require("@lexical/selection");
|
|
|
12
5
|
* LICENSE file in the root directory of this source tree.
|
|
13
6
|
*
|
|
14
7
|
*/
|
|
15
|
-
|
|
16
|
-
function getSelectedNode(selection) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
import { $isAtNodeEnd } from "@lexical/selection";
|
|
9
|
+
export function getSelectedNode(selection) {
|
|
10
|
+
const anchor = selection.anchor;
|
|
11
|
+
const focus = selection.focus;
|
|
12
|
+
const anchorNode = selection.anchor.getNode();
|
|
13
|
+
const focusNode = selection.focus.getNode();
|
|
21
14
|
if (anchorNode === focusNode) {
|
|
22
15
|
return anchorNode;
|
|
23
16
|
}
|
|
24
|
-
|
|
17
|
+
const isBackward = selection.isBackward();
|
|
25
18
|
if (isBackward) {
|
|
26
|
-
return
|
|
19
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
27
20
|
} else {
|
|
28
|
-
return
|
|
21
|
+
return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["$isAtNodeEnd","getSelectedNode","selection","anchor","focus","anchorNode","getNode","focusNode","isBackward"],"sources":["getSelectedNode.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { $isAtNodeEnd } from \"@lexical/selection\";\nimport 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":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTransparentImage = void 0;
|
|
7
|
-
var getTransparentImage = exports.getTransparentImage = function getTransparentImage() {
|
|
1
|
+
export const getTransparentImage = () => {
|
|
8
2
|
return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
9
3
|
};
|
|
10
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getTransparentImage"
|
|
1
|
+
{"version":3,"names":["getTransparentImage"],"sources":["getTransparentImage.ts"],"sourcesContent":["export const getTransparentImage = () => {\n return \"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\";\n};\n"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO,gFAAgF;AAC3F,CAAC","ignoreList":[]}
|
package/utils/insertImage.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { InsertImagePayload } from "../plugins/ImagesPlugin/ImagesPlugin";
|
|
1
|
+
import type { InsertImagePayload } from "../plugins/ImagesPlugin/ImagesPlugin.js";
|
|
2
2
|
export declare const insertImage: (payload: InsertImagePayload) => boolean;
|
package/utils/insertImage.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.insertImage = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var _utils = require("@lexical/utils");
|
|
9
|
-
var _lexicalNodes = require("@webiny/lexical-nodes");
|
|
1
|
+
import { $insertNodes, $isRootOrShadowRoot } from "lexical";
|
|
2
|
+
import { $wrapNodeInElement } from "@lexical/utils";
|
|
3
|
+
import { $createParagraphNode, $createImageNode } from "@webiny/lexical-nodes";
|
|
10
4
|
/*
|
|
11
5
|
* Insert image into editor.
|
|
12
6
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
7
|
+
export const insertImage = payload => {
|
|
8
|
+
const imageNode = $createImageNode(payload);
|
|
9
|
+
$insertNodes([imageNode]);
|
|
10
|
+
if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {
|
|
11
|
+
$wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
18
12
|
}
|
|
19
13
|
return true;
|
|
20
14
|
};
|
package/utils/insertImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["$insertNodes","$isRootOrShadowRoot","$wrapNodeInElement","$createParagraphNode","$createImageNode","insertImage","payload","imageNode","getParentOrThrow","selectEnd"],"sources":["insertImage.ts"],"sourcesContent":["import { $insertNodes, $isRootOrShadowRoot } from \"lexical\";\nimport { $wrapNodeInElement } from \"@lexical/utils\";\nimport { $createParagraphNode, $createImageNode } from \"@webiny/lexical-nodes\";\nimport type { InsertImagePayload } from \"~/plugins/ImagesPlugin/ImagesPlugin.js\";\n\n/*\n * Insert image into editor.\n */\nexport const insertImage = (payload: InsertImagePayload): boolean => {\n const imageNode = $createImageNode(payload);\n $insertNodes([imageNode]);\n if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {\n $wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();\n }\n return true;\n};\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mBAAmB,QAAQ,SAAS;AAC3D,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,uBAAuB;AAG9E;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,OAA2B,IAAc;EACjE,MAAMC,SAAS,GAAGH,gBAAgB,CAACE,OAAO,CAAC;EAC3CN,YAAY,CAAC,CAACO,SAAS,CAAC,CAAC;EACzB,IAAIN,mBAAmB,CAACM,SAAS,CAACC,gBAAgB,CAAC,CAAC,CAAC,EAAE;IACnDN,kBAAkB,CAACK,SAAS,EAAEJ,oBAAoB,CAAC,CAACM,SAAS,CAAC,CAAC;EACnE;EACA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
package/utils/isAnchorLink.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isAnchorLink = void 0;
|
|
7
|
-
var isAnchorLink = exports.isAnchorLink = function isAnchorLink(url) {
|
|
1
|
+
export const isAnchorLink = url => {
|
|
8
2
|
return url.startsWith("#");
|
|
9
3
|
};
|
|
10
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isAnchorLink","
|
|
1
|
+
{"version":3,"names":["isAnchorLink","url","startsWith"],"sources":["isAnchorLink.ts"],"sourcesContent":["export const isAnchorLink = (url: string) => {\n return url.startsWith(\"#\");\n};\n"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAIC,GAAW,IAAK;EACzC,OAAOA,GAAG,CAACC,UAAU,CAAC,GAAG,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isChildOfFloatingToolbar = void 0;
|
|
7
|
-
var _isChildOfFloatingToolbar = exports.isChildOfFloatingToolbar = function isChildOfFloatingToolbar(element) {
|
|
8
|
-
if (!element && document["floatingToolbar"]) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
var parent = element ? element.parentElement : null;
|
|
1
|
+
export const isChildOfFloatingToolbar = element => {
|
|
2
|
+
const parent = element ? element.parentElement : null;
|
|
12
3
|
if (!parent) {
|
|
13
4
|
return false;
|
|
14
5
|
}
|
|
15
6
|
if (parent.classList.contains("floating-toolbar")) {
|
|
16
7
|
return true;
|
|
17
8
|
}
|
|
18
|
-
return
|
|
9
|
+
return isChildOfFloatingToolbar(parent);
|
|
19
10
|
};
|
|
20
11
|
|
|
21
12
|
//# sourceMappingURL=isChildOfFloatingToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isChildOfFloatingToolbar","
|
|
1
|
+
{"version":3,"names":["isChildOfFloatingToolbar","element","parent","parentElement","classList","contains"],"sources":["isChildOfFloatingToolbar.ts"],"sourcesContent":["export const isChildOfFloatingToolbar = (element: HTMLElement | null): boolean => {\n const parent = element ? element.parentElement : null;\n\n if (!parent) {\n return false;\n }\n\n if (parent.classList.contains(\"floating-toolbar\")) {\n return true;\n }\n\n return isChildOfFloatingToolbar(parent);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,GAAIC,OAA2B,IAAc;EAC9E,MAAMC,MAAM,GAAGD,OAAO,GAAGA,OAAO,CAACE,aAAa,GAAG,IAAI;EAErD,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,KAAK;EAChB;EAEA,IAAIA,MAAM,CAACE,SAAS,CAACC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;IAC/C,OAAO,IAAI;EACf;EAEA,OAAOL,wBAAwB,CAACE,MAAM,CAAC;AAC3C,CAAC","ignoreList":[]}
|
package/utils/isHTMLElement.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isHTMLElement = isHTMLElement;
|
|
7
1
|
/**
|
|
8
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
3
|
*
|
|
@@ -11,7 +5,7 @@ exports.isHTMLElement = isHTMLElement;
|
|
|
11
5
|
* LICENSE file in the root directory of this source tree.
|
|
12
6
|
*
|
|
13
7
|
*/
|
|
14
|
-
function isHTMLElement(x) {
|
|
8
|
+
export function isHTMLElement(x) {
|
|
15
9
|
return x instanceof HTMLElement;
|
|
16
10
|
}
|
|
17
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isHTMLElement","x","HTMLElement"],"sources":["isHTMLElement.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function isHTMLElement(x: unknown): x is HTMLElement {\n return x instanceof HTMLElement;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["isHTMLElement","x","HTMLElement"],"sources":["isHTMLElement.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function isHTMLElement(x: unknown): x is HTMLElement {\n return x instanceof HTMLElement;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAACC,CAAU,EAAoB;EACxD,OAAOA,CAAC,YAAYC,WAAW;AACnC","ignoreList":[]}
|