@webiny/lexical-editor 5.44.1-beta.1 → 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 +2 -3
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +21 -32
- 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/utils/rect.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Rect = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _point = require("./point");
|
|
12
1
|
/**
|
|
13
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
3
|
*
|
|
@@ -16,149 +5,126 @@ var _point = require("./point");
|
|
|
16
5
|
* LICENSE file in the root directory of this source tree.
|
|
17
6
|
*
|
|
18
7
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
physicBottom = _ref2[1];
|
|
26
|
-
var _ref3 = left <= right ? [left, right] : [right, left],
|
|
27
|
-
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
28
|
-
physicLeft = _ref4[0],
|
|
29
|
-
physicRight = _ref4[1];
|
|
8
|
+
|
|
9
|
+
import { isPoint } from "./point.js";
|
|
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];
|
|
30
14
|
this._top = physicTop;
|
|
31
15
|
this._right = physicRight;
|
|
32
16
|
this._left = physicLeft;
|
|
33
17
|
this._bottom = physicBottom;
|
|
34
18
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
isOnRightSide: isOnRightSide,
|
|
90
|
-
isOnTopSide: isOnTopSide
|
|
91
|
-
},
|
|
92
|
-
result: result
|
|
93
|
-
};
|
|
94
|
-
} else {
|
|
95
|
-
var top = target.top,
|
|
96
|
-
left = target.left,
|
|
97
|
-
bottom = target.bottom,
|
|
98
|
-
right = target.right;
|
|
99
|
-
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;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "intersectsWith",
|
|
104
|
-
value: function intersectsWith(rect) {
|
|
105
|
-
var x1 = rect.left,
|
|
106
|
-
y1 = rect.top,
|
|
107
|
-
w1 = rect.width,
|
|
108
|
-
h1 = rect.height;
|
|
109
|
-
var x2 = this.left,
|
|
110
|
-
y2 = this.top,
|
|
111
|
-
w2 = this.width,
|
|
112
|
-
h2 = this.height;
|
|
113
|
-
var maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;
|
|
114
|
-
var maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;
|
|
115
|
-
var minX = x1 <= x2 ? x1 : x2;
|
|
116
|
-
var minY = y1 <= y2 ? y1 : y2;
|
|
117
|
-
return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "generateNewRect",
|
|
121
|
-
value: function generateNewRect(_ref6) {
|
|
122
|
-
var _ref6$left = _ref6.left,
|
|
123
|
-
left = _ref6$left === void 0 ? this.left : _ref6$left,
|
|
124
|
-
_ref6$top = _ref6.top,
|
|
125
|
-
top = _ref6$top === void 0 ? this.top : _ref6$top,
|
|
126
|
-
_ref6$right = _ref6.right,
|
|
127
|
-
right = _ref6$right === void 0 ? this.right : _ref6$right,
|
|
128
|
-
_ref6$bottom = _ref6.bottom,
|
|
129
|
-
bottom = _ref6$bottom === void 0 ? this.bottom : _ref6$bottom;
|
|
130
|
-
return new Rect(left, top, right, bottom);
|
|
131
|
-
}
|
|
132
|
-
}], [{
|
|
133
|
-
key: "fromLTRB",
|
|
134
|
-
value: function fromLTRB(left, top, right, bottom) {
|
|
135
|
-
return new Rect(left, top, right, bottom);
|
|
136
|
-
}
|
|
137
|
-
}, {
|
|
138
|
-
key: "fromLWTH",
|
|
139
|
-
value: function fromLWTH(left, width, top, height) {
|
|
140
|
-
return new Rect(left, top, left + width, top + height);
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
key: "fromPoints",
|
|
144
|
-
value: function fromPoints(startPoint, endPoint) {
|
|
145
|
-
var top = startPoint.y,
|
|
146
|
-
left = startPoint.x;
|
|
147
|
-
var bottom = endPoint.y,
|
|
148
|
-
right = endPoint.x;
|
|
149
|
-
return Rect.fromLTRB(left, top, right, bottom);
|
|
150
|
-
}
|
|
151
|
-
}, {
|
|
152
|
-
key: "fromDOM",
|
|
153
|
-
value: function fromDOM(dom) {
|
|
154
|
-
var _dom$getBoundingClien = dom.getBoundingClientRect(),
|
|
155
|
-
top = _dom$getBoundingClien.top,
|
|
156
|
-
width = _dom$getBoundingClien.width,
|
|
157
|
-
left = _dom$getBoundingClien.left,
|
|
158
|
-
height = _dom$getBoundingClien.height;
|
|
159
|
-
return Rect.fromLWTH(left, width, top, height);
|
|
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;
|
|
160
73
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
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
|
+
}
|
|
163
129
|
|
|
164
130
|
//# sourceMappingURL=rect.js.map
|
package/utils/rect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_point","require","Rect","exports","left","top","right","bottom","_classCallCheck2","default","_ref","_ref2","_slicedToArray2","physicTop","physicBottom","_ref3","_ref4","physicLeft","physicRight","_top","_right","_left","_bottom","_createClass2","key","get","Math","abs","value","equals","_ref5","contains","target","isPoint","x","y","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","intersectsWith","rect","x1","y1","w1","width","h1","height","x2","y2","w2","h2","maxX","maxY","minX","minY","generateNewRect","_ref6","_ref6$left","_ref6$top","_ref6$right","_ref6$bottom","fromLTRB","fromLWTH","fromPoints","startPoint","endPoint","fromDOM","dom","_dom$getBoundingClien","getBoundingClientRect"],"sources":["rect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { isPoint, Point } from \"./point\";\n\ntype ContainsPointReturn = {\n result: boolean;\n reason: {\n isOnTopSide: boolean;\n isOnBottomSide: boolean;\n isOnLeftSide: boolean;\n isOnRightSide: boolean;\n };\n};\n\nexport class Rect {\n private readonly _left: number;\n private readonly _top: number;\n private readonly _right: number;\n private readonly _bottom: number;\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top];\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left];\n\n this._top = physicTop;\n this._right = physicRight;\n this._left = physicLeft;\n this._bottom = physicBottom;\n }\n\n get top(): number {\n return this._top;\n }\n\n get right(): number {\n return this._right;\n }\n\n get bottom(): number {\n return this._bottom;\n }\n\n get left(): number {\n return this._left;\n }\n\n get width(): number {\n return Math.abs(this._left - this._right);\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top);\n }\n\n public equals({ top, left, bottom, right }: Rect): boolean {\n return (\n top === this._top &&\n bottom === this._bottom &&\n left === this._left &&\n right === this._right\n );\n }\n\n public contains({ x, y }: Point): ContainsPointReturn;\n public contains({ top, left, bottom, right }: Rect): boolean;\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target;\n\n const isOnTopSide = y < this._top;\n const isOnBottomSide = y > this._bottom;\n const isOnLeftSide = x < this._left;\n const isOnRightSide = x > this._right;\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide;\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide\n },\n result\n };\n } else {\n const { top, left, bottom, right } = target;\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n );\n }\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { left: x1, top: y1, width: w1, height: h1 } = rect;\n const { left: x2, top: y2, width: w2, height: h2 } = this;\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;\n const minX = x1 <= x2 ? x1 : x2;\n const minY = y1 <= y2 ? y1 : y2;\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;\n }\n\n public generateNewRect({\n left = this.left,\n top = this.top,\n right = this.right,\n bottom = this.bottom\n }): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height);\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { y: top, x: left } = startPoint;\n const { y: bottom, x: right } = endPoint;\n return Rect.fromLTRB(left, top, right, bottom);\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { top, width, left, height } = dom.getBoundingClientRect();\n return Rect.fromLWTH(left, width, top, height);\n }\n}\n"],"mappings":";;;;;;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAmBaC,IAAI,GAAAC,OAAA,CAAAD,IAAA;EAMb,SAAAA,KAAYE,IAAY,EAAEC,GAAW,EAAEC,KAAa,EAAEC,MAAc,EAAE;IAAA,IAAAC,g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,IAAI,GAAG2C,KAAK,EAAE1C,GAAG,GAAG4C,MAAM,CAAC;IAC1D;EAAC;IAAAzB,GAAA;IAAAI,KAAA,EAED,SAAOsC,UAAUA,CAACC,UAAiB,EAAEC,QAAe,EAAQ;MACxD,IAAW/D,GAAG,GAAc8D,UAAU,CAA9BhC,CAAC;QAAU/B,IAAI,GAAK+D,UAAU,CAAtBjC,CAAC;MACjB,IAAW3B,MAAM,GAAe6D,QAAQ,CAAhCjC,CAAC;QAAa7B,KAAK,GAAK8D,QAAQ,CAArBlC,CAAC;MACpB,OAAOhC,IAAI,CAAC8D,QAAQ,CAAC5D,IAAI,EAAEC,GAAG,EAAEC,KAAK,EAAEC,MAAM,CAAC;IAClD;EAAC;IAAAiB,GAAA;IAAAI,KAAA,EAED,SAAOyC,OAAOA,CAACC,GAAgB,EAAQ;MACnC,IAAAC,qBAAA,GAAqCD,GAAG,CAACE,qBAAqB,CAAC,CAAC;QAAxDnE,GAAG,GAAAkE,qBAAA,CAAHlE,GAAG;QAAE0C,KAAK,GAAAwB,qBAAA,CAALxB,KAAK;QAAE3C,IAAI,GAAAmE,qBAAA,CAAJnE,IAAI;QAAE6C,MAAM,GAAAsB,qBAAA,CAANtB,MAAM;MAChC,OAAO/C,IAAI,CAAC+D,QAAQ,CAAC7D,IAAI,EAAE2C,KAAK,EAAE1C,GAAG,EAAE4C,MAAM,CAAC;IAClD;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["isPoint","Rect","constructor","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","_top","_right","_left","_bottom","width","Math","abs","height","equals","contains","target","x","y","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","intersectsWith","rect","x1","y1","w1","h1","x2","y2","w2","h2","maxX","maxY","minX","minY","generateNewRect","fromLTRB","fromLWTH","fromPoints","startPoint","endPoint","fromDOM","dom","getBoundingClientRect"],"sources":["rect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type { Point } from \"./point.js\";\nimport { isPoint } from \"./point.js\";\n\ntype ContainsPointReturn = {\n result: boolean;\n reason: {\n isOnTopSide: boolean;\n isOnBottomSide: boolean;\n isOnLeftSide: boolean;\n isOnRightSide: boolean;\n };\n};\n\nexport class Rect {\n private readonly _left: number;\n private readonly _top: number;\n private readonly _right: number;\n private readonly _bottom: number;\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top];\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left];\n\n this._top = physicTop;\n this._right = physicRight;\n this._left = physicLeft;\n this._bottom = physicBottom;\n }\n\n get top(): number {\n return this._top;\n }\n\n get right(): number {\n return this._right;\n }\n\n get bottom(): number {\n return this._bottom;\n }\n\n get left(): number {\n return this._left;\n }\n\n get width(): number {\n return Math.abs(this._left - this._right);\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top);\n }\n\n public equals({ top, left, bottom, right }: Rect): boolean {\n return (\n top === this._top &&\n bottom === this._bottom &&\n left === this._left &&\n right === this._right\n );\n }\n\n public contains({ x, y }: Point): ContainsPointReturn;\n public contains({ top, left, bottom, right }: Rect): boolean;\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target;\n\n const isOnTopSide = y < this._top;\n const isOnBottomSide = y > this._bottom;\n const isOnLeftSide = x < this._left;\n const isOnRightSide = x > this._right;\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide;\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide\n },\n result\n };\n } else {\n const { top, left, bottom, right } = target;\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n );\n }\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { left: x1, top: y1, width: w1, height: h1 } = rect;\n const { left: x2, top: y2, width: w2, height: h2 } = this;\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;\n const minX = x1 <= x2 ? x1 : x2;\n const minY = y1 <= y2 ? y1 : y2;\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;\n }\n\n public generateNewRect({\n left = this.left,\n top = this.top,\n right = this.right,\n bottom = this.bottom\n }): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height);\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { y: top, x: left } = startPoint;\n const { y: bottom, x: right } = endPoint;\n return Rect.fromLTRB(left, top, right, bottom);\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { top, width, left, height } = dom.getBoundingClientRect();\n return Rect.fromLWTH(left, width, top, height);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO;AAYhB,OAAO,MAAMC,IAAI,CAAC;EAMdC,WAAWA,CAACC,IAAY,EAAEC,GAAW,EAAEC,KAAa,EAAEC,MAAc,EAAE;IAClE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGJ,GAAG,IAAIE,MAAM,GAAG,CAACF,GAAG,EAAEE,MAAM,CAAC,GAAG,CAACA,MAAM,EAAEF,GAAG,CAAC;IAE/E,MAAM,CAACK,UAAU,EAAEC,WAAW,CAAC,GAAGP,IAAI,IAAIE,KAAK,GAAG,CAACF,IAAI,EAAEE,KAAK,CAAC,GAAG,CAACA,KAAK,EAAEF,IAAI,CAAC;IAE/E,IAAI,CAACQ,IAAI,GAAGJ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C,MAAM,CAAC;EAClD;EAEA,OAAO4C,OAAOA,CAACC,GAAgB,EAAQ;IACnC,MAAM;MAAE/C,GAAG;MAAEW,KAAK;MAAEZ,IAAI;MAAEe;IAAO,CAAC,GAAGiC,GAAG,CAACC,qBAAqB,CAAC,CAAC;IAChE,OAAOnD,IAAI,CAAC6C,QAAQ,CAAC3C,IAAI,EAAEY,KAAK,EAAEX,GAAG,EAAEc,MAAM,CAAC;EAClD;AACJ","ignoreList":[]}
|
package/utils/sanitizeUrl.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sanitizeUrl = void 0;
|
|
7
|
-
var _isAnchorLink = require("./isAnchorLink");
|
|
8
1
|
/**
|
|
9
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
3
|
*
|
|
@@ -12,21 +5,21 @@ var _isAnchorLink = require("./isAnchorLink");
|
|
|
12
5
|
* LICENSE file in the root directory of this source tree.
|
|
13
6
|
*
|
|
14
7
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import { isAnchorLink } from "./isAnchorLink.js";
|
|
9
|
+
export const sanitizeUrl = url => {
|
|
17
10
|
/** A pattern that matches safe URLs. */
|
|
18
|
-
|
|
11
|
+
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi;
|
|
19
12
|
|
|
20
13
|
/** A pattern that matches safe data URLs. */
|
|
21
|
-
|
|
14
|
+
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
|
|
22
15
|
url = String(url).trim();
|
|
23
|
-
if (
|
|
16
|
+
if (isAnchorLink(url)) {
|
|
24
17
|
return url;
|
|
25
18
|
}
|
|
26
19
|
if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN)) {
|
|
27
20
|
return url;
|
|
28
21
|
}
|
|
29
|
-
return
|
|
22
|
+
return `https://`;
|
|
30
23
|
};
|
|
31
24
|
|
|
32
25
|
//# sourceMappingURL=sanitizeUrl.js.map
|
package/utils/sanitizeUrl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isAnchorLink","sanitizeUrl","url","SAFE_URL_PATTERN","DATA_URL_PATTERN","String","trim","match"],"sources":["sanitizeUrl.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 { isAnchorLink } from \"~/utils/isAnchorLink.js\";\n\nexport const sanitizeUrl = (url: string): string => {\n /** A pattern that matches safe URLs. */\n const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi;\n\n /** A pattern that matches safe data URLs. */\n const DATA_URL_PATTERN =\n /^data:(?:image\\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\\/(?:mpeg|mp4|ogg|webm)|audio\\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;\n\n url = String(url).trim();\n\n if (isAnchorLink(url)) {\n return url;\n }\n\n if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN)) {\n return url;\n }\n\n return `https://`;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY;AAErB,OAAO,MAAMC,WAAW,GAAIC,GAAW,IAAa;EAChD;EACA,MAAMC,gBAAgB,GAAG,iEAAiE;;EAE1F;EACA,MAAMC,gBAAgB,GAClB,qIAAqI;EAEzIF,GAAG,GAAGG,MAAM,CAACH,GAAG,CAAC,CAACI,IAAI,CAAC,CAAC;EAExB,IAAIN,YAAY,CAACE,GAAG,CAAC,EAAE;IACnB,OAAOA,GAAG;EACd;EAEA,IAAIA,GAAG,CAACK,KAAK,CAACJ,gBAAgB,CAAC,IAAID,GAAG,CAACK,KAAK,CAACH,gBAAgB,CAAC,EAAE;IAC5D,OAAOF,GAAG;EACd;EAEA,OAAO,UAAU;AACrB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function setFloatingElemPosition(basePosition:
|
|
1
|
+
export declare function setFloatingElemPosition(basePosition: Range | null, elementToPosition: HTMLElement): void;
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setFloatingElemPosition = setFloatingElemPosition;
|
|
7
|
-
var VERTICAL_GAP = 10;
|
|
8
|
-
var HORIZONTAL_OFFSET = 5;
|
|
9
|
-
function setFloatingElemPosition(basePosition, elementToPosition, anchorElem) {
|
|
10
|
-
var verticalGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : VERTICAL_GAP;
|
|
11
|
-
var horizontalOffset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : HORIZONTAL_OFFSET;
|
|
1
|
+
import { computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
2
|
+
const GAP = 10;
|
|
3
|
+
export function setFloatingElemPosition(basePosition, elementToPosition) {
|
|
12
4
|
// A small timeout gives enough time for DOM to update and provides us with correct bounding rect values.
|
|
13
|
-
setTimeout(
|
|
14
|
-
|
|
15
|
-
if (basePosition === null || !scrollerElem) {
|
|
16
|
-
elementToPosition.style.opacity = "0";
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
if (basePosition === null) {
|
|
17
7
|
elementToPosition.style.transform = "translate(-10000px, -10000px)";
|
|
18
8
|
return;
|
|
19
9
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
const virtualElement = {
|
|
11
|
+
getBoundingClientRect: () => basePosition.getBoundingClientRect()
|
|
12
|
+
};
|
|
13
|
+
computePosition(virtualElement, elementToPosition, {
|
|
14
|
+
placement: "bottom",
|
|
15
|
+
middleware: [offset(GAP),
|
|
16
|
+
// adds gap between anchor and popup
|
|
17
|
+
flip(),
|
|
18
|
+
// switches to the opposite side if no room (bottom → top)
|
|
19
|
+
shift({
|
|
20
|
+
padding: GAP
|
|
21
|
+
}) // slides along the axis to stay within viewport
|
|
22
|
+
]
|
|
23
|
+
}).then(({
|
|
24
|
+
x,
|
|
25
|
+
y
|
|
26
|
+
}) => {
|
|
27
|
+
elementToPosition.style.transform = `translate(${x}px, ${y}px)`;
|
|
28
|
+
});
|
|
35
29
|
}, 10);
|
|
36
30
|
}
|
|
37
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["computePosition","flip","offset","shift","GAP","setFloatingElemPosition","basePosition","elementToPosition","setTimeout","style","transform","virtualElement","getBoundingClientRect","placement","middleware","padding","then","x","y"],"sources":["setFloatingElemPosition.ts"],"sourcesContent":["import { computePosition, flip, offset, shift } from \"@floating-ui/dom\";\n\nconst GAP = 10;\n\nexport function setFloatingElemPosition(\n basePosition: Range | null,\n elementToPosition: HTMLElement\n): void {\n // A small timeout gives enough time for DOM to update and provides us with correct bounding rect values.\n setTimeout(() => {\n if (basePosition === null) {\n elementToPosition.style.transform = \"translate(-10000px, -10000px)\";\n return;\n }\n\n const virtualElement = {\n getBoundingClientRect: () => basePosition.getBoundingClientRect()\n };\n\n computePosition(virtualElement, elementToPosition, {\n placement: \"bottom\",\n middleware: [\n offset(GAP), // adds gap between anchor and popup\n flip(), // switches to the opposite side if no room (bottom → top)\n shift({ padding: GAP }) // slides along the axis to stay within viewport\n ]\n }).then(({ x, y }) => {\n elementToPosition.style.transform = `translate(${x}px, ${y}px)`;\n });\n }, 10);\n}\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,IAAI,EAAEC,MAAM,EAAEC,KAAK,QAAQ,kBAAkB;AAEvE,MAAMC,GAAG,GAAG,EAAE;AAEd,OAAO,SAASC,uBAAuBA,CACnCC,YAA0B,EAC1BC,iBAA8B,EAC1B;EACJ;EACAC,UAAU,CAAC,MAAM;IACb,IAAIF,YAAY,KAAK,IAAI,EAAE;MACvBC,iBAAiB,CAACE,KAAK,CAACC,SAAS,GAAG,+BAA+B;MACnE;IACJ;IAEA,MAAMC,cAAc,GAAG;MACnBC,qBAAqB,EAAEA,CAAA,KAAMN,YAAY,CAACM,qBAAqB,CAAC;IACpE,CAAC;IAEDZ,eAAe,CAACW,cAAc,EAAEJ,iBAAiB,EAAE;MAC/CM,SAAS,EAAE,QAAQ;MACnBC,UAAU,EAAE,CACRZ,MAAM,CAACE,GAAG,CAAC;MAAE;MACbH,IAAI,CAAC,CAAC;MAAE;MACRE,KAAK,CAAC;QAAEY,OAAO,EAAEX;MAAI,CAAC,CAAC,CAAC;MAAA;IAEhC,CAAC,CAAC,CAACY,IAAI,CAAC,CAAC;MAAEC,CAAC;MAAEC;IAAE,CAAC,KAAK;MAClBX,iBAAiB,CAACE,KAAK,CAACC,SAAS,GAAG,aAAaO,CAAC,OAAOC,CAAC,KAAK;IACnE,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;AACV","ignoreList":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { RichTextEditorProps } from "./RichTextEditor";
|
|
3
|
-
interface HeadingEditorProps extends RichTextEditorProps {
|
|
4
|
-
tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
5
|
-
}
|
|
6
|
-
export declare const HeadingEditor: ({ tag, placeholder, ...rest }: HeadingEditorProps) => React.JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.HeadingEditor = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _RichTextEditor = require("./RichTextEditor");
|
|
11
|
-
var _Toolbar = require("../Toolbar/Toolbar");
|
|
12
|
-
var _EnsureHeadingTagPlugin = require("./EnsureHeadingTagPlugin");
|
|
13
|
-
var _excluded = ["tag", "placeholder"];
|
|
14
|
-
var styles = {
|
|
15
|
-
padding: 5
|
|
16
|
-
};
|
|
17
|
-
var HeadingEditor = exports.HeadingEditor = function HeadingEditor(_ref) {
|
|
18
|
-
var tag = _ref.tag,
|
|
19
|
-
placeholder = _ref.placeholder,
|
|
20
|
-
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
21
|
-
return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
|
|
22
|
-
toolbar: /*#__PURE__*/_react.default.createElement(_Toolbar.Toolbar, null),
|
|
23
|
-
tag: tag ?? "h1",
|
|
24
|
-
placeholder: placeholder ?? "Enter your heading text here..."
|
|
25
|
-
}, rest, {
|
|
26
|
-
styles: styles
|
|
27
|
-
}), /*#__PURE__*/_react.default.createElement(_EnsureHeadingTagPlugin.EnsureHeadingTagPlugin, null), rest?.children);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=HeadingEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_RichTextEditor","_Toolbar","_EnsureHeadingTagPlugin","_excluded","styles","padding","HeadingEditor","exports","_ref","tag","placeholder","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","Toolbar","EnsureHeadingTagPlugin","children"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\nimport { EnsureHeadingTagPlugin } from \"~/components/Editor/EnsureHeadingTagPlugin\";\n\ninterface HeadingEditorProps extends RichTextEditorProps {\n tag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\nconst styles = { padding: 5 };\n\nexport const HeadingEditor = ({ tag, placeholder, ...rest }: HeadingEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n styles={styles}\n >\n <EnsureHeadingTagPlugin />\n {rest?.children}\n </RichTextEditor>\n );\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAAoF,IAAAI,SAAA;AAMpF,IAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAEtB,IAAMC,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAAE,IAAA,EAA0D;EAAA,IAApDC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAL,SAAA;EACrD,oBACIN,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACd,eAAA,CAAAe,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAErB,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACb,QAAA,CAAAkB,OAAO,MAAE,CAAE;IACrBV,GAAG,EAAEA,GAAG,IAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,IAAI;EAAkC,GAC1DC,IAAI;IACRP,MAAM,EAAEA;EAAO,iBAEfP,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACZ,uBAAA,CAAAkB,sBAAsB,MAAE,CAAC,EACzBT,IAAI,EAAEU,QACK,CAAC;AAEzB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { RichTextEditorProps } from "./RichTextEditor";
|
|
3
|
-
interface ParagraphLexicalEditorProps extends RichTextEditorProps {
|
|
4
|
-
tag?: "p";
|
|
5
|
-
}
|
|
6
|
-
declare const ParagraphEditor: ({ placeholder, tag, ...rest }: ParagraphLexicalEditorProps) => React.JSX.Element;
|
|
7
|
-
export { ParagraphEditor };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.ParagraphEditor = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _RichTextEditor = require("./RichTextEditor");
|
|
11
|
-
var _Toolbar = require("../Toolbar/Toolbar");
|
|
12
|
-
var _excluded = ["placeholder", "tag"];
|
|
13
|
-
var styles = {
|
|
14
|
-
padding: 5
|
|
15
|
-
};
|
|
16
|
-
var ParagraphEditor = exports.ParagraphEditor = function ParagraphEditor(_ref) {
|
|
17
|
-
var placeholder = _ref.placeholder,
|
|
18
|
-
tag = _ref.tag,
|
|
19
|
-
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
20
|
-
return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
|
|
21
|
-
toolbar: /*#__PURE__*/_react.default.createElement(_Toolbar.Toolbar, null),
|
|
22
|
-
tag: tag ?? "p",
|
|
23
|
-
placeholder: placeholder ?? "Enter your text here..."
|
|
24
|
-
}, rest, {
|
|
25
|
-
styles: styles
|
|
26
|
-
}), rest?.children);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=ParagraphEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_RichTextEditor","_Toolbar","_excluded","styles","padding","ParagraphEditor","exports","_ref","placeholder","tag","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","Toolbar","children"],"sources":["ParagraphEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface ParagraphLexicalEditorProps extends RichTextEditorProps {\n tag?: \"p\";\n}\n\nconst styles = { padding: 5 };\n\nconst ParagraphEditor = ({ placeholder, tag, ...rest }: ParagraphLexicalEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"p\"}\n placeholder={placeholder ?? \"Enter your text here...\"}\n {...rest}\n styles={styles}\n >\n {rest?.children}\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAAuD,IAAAG,SAAA;AAMvD,IAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAE7B,IAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,SAAlBA,eAAeA,CAAAE,IAAA,EAAmE;EAAA,IAA7DC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAL,SAAA;EAChD,oBACIL,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACb,eAAA,CAAAc,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEpB,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACZ,QAAA,CAAAiB,OAAO,MAAE,CAAE;IACrBT,GAAG,EAAEA,GAAG,IAAI,GAAI;IAChBD,WAAW,EAAEA,WAAW,IAAI;EAA0B,GAClDE,IAAI;IACRP,MAAM,EAAEA;EAAO,IAEdO,IAAI,EAAES,QACK,CAAC;AAEzB,CAAC","ignoreList":[]}
|