@lexical/utils 0.44.1-nightly.20260519.0 → 0.45.1-dev.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/{LexicalUtils.dev.js → dist/LexicalUtils.dev.js} +19 -64
- package/{LexicalUtils.dev.mjs → dist/LexicalUtils.dev.mjs} +11 -56
- package/{LexicalUtils.js.flow → dist/LexicalUtils.js.flow} +4 -4
- package/dist/LexicalUtils.prod.js +9 -0
- package/dist/LexicalUtils.prod.mjs +9 -0
- package/{index.d.ts → dist/index.d.ts} +2 -10
- package/package.json +31 -16
- package/src/index.ts +1004 -0
- package/src/markSelection.ts +183 -0
- package/src/positionNodeOnRange.ts +157 -0
- package/src/px.ts +11 -0
- package/src/selectionAlwaysOnDisplay.ts +54 -0
- package/LexicalUtils.prod.js +0 -9
- package/LexicalUtils.prod.mjs +0 -9
- /package/{LexicalUtils.js → dist/LexicalUtils.js} +0 -0
- /package/{LexicalUtils.mjs → dist/LexicalUtils.mjs} +0 -0
- /package/{LexicalUtils.node.mjs → dist/LexicalUtils.node.mjs} +0 -0
- /package/{markSelection.d.ts → dist/markSelection.d.ts} +0 -0
- /package/{positionNodeOnRange.d.ts → dist/positionNodeOnRange.d.ts} +0 -0
- /package/{px.d.ts → dist/px.d.ts} +0 -0
- /package/{selectionAlwaysOnDisplay.d.ts → dist/selectionAlwaysOnDisplay.d.ts} +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
$getDOMSlot,
|
|
11
|
+
$getDOMTextNode,
|
|
12
|
+
$getSelection,
|
|
13
|
+
$isElementNode,
|
|
14
|
+
$isRangeSelection,
|
|
15
|
+
$isTextNode,
|
|
16
|
+
type EditorState,
|
|
17
|
+
ElementNode,
|
|
18
|
+
getDOMTextNode,
|
|
19
|
+
type LexicalEditor,
|
|
20
|
+
mergeRegister,
|
|
21
|
+
Point,
|
|
22
|
+
type RangeSelection,
|
|
23
|
+
TextNode,
|
|
24
|
+
} from 'lexical';
|
|
25
|
+
|
|
26
|
+
import positionNodeOnRange from './positionNodeOnRange';
|
|
27
|
+
import px from './px';
|
|
28
|
+
|
|
29
|
+
function $getOrderedSelectionPoints(selection: RangeSelection): [Point, Point] {
|
|
30
|
+
const points = selection.getStartEndPoints();
|
|
31
|
+
return selection.isBackward() ? [points[1], points[0]] : points;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function $rangeTargetFromPoint(
|
|
35
|
+
editor: LexicalEditor,
|
|
36
|
+
point: Point,
|
|
37
|
+
node: ElementNode | TextNode,
|
|
38
|
+
dom: HTMLElement,
|
|
39
|
+
): [HTMLElement | Text, number] {
|
|
40
|
+
if (point.type === 'text' || !$isElementNode(node)) {
|
|
41
|
+
const textDOM =
|
|
42
|
+
($isTextNode(node)
|
|
43
|
+
? $getDOMTextNode(node, dom, editor)
|
|
44
|
+
: getDOMTextNode(dom)) || dom;
|
|
45
|
+
return [textDOM, point.offset];
|
|
46
|
+
} else {
|
|
47
|
+
const slot = $getDOMSlot(node, dom, editor);
|
|
48
|
+
return [slot.element, slot.getFirstChildOffset() + point.offset];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function $rangeFromPoints(
|
|
53
|
+
editor: LexicalEditor,
|
|
54
|
+
start: Point,
|
|
55
|
+
startNode: ElementNode | TextNode,
|
|
56
|
+
startDOM: HTMLElement,
|
|
57
|
+
end: Point,
|
|
58
|
+
endNode: ElementNode | TextNode,
|
|
59
|
+
endDOM: HTMLElement,
|
|
60
|
+
): Range {
|
|
61
|
+
const editorDocument = editor._window ? editor._window.document : document;
|
|
62
|
+
const range = editorDocument.createRange();
|
|
63
|
+
range.setStart(...$rangeTargetFromPoint(editor, start, startNode, startDOM));
|
|
64
|
+
range.setEnd(...$rangeTargetFromPoint(editor, end, endNode, endDOM));
|
|
65
|
+
return range;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function defaultOnReposition(domNodes: readonly HTMLElement[]): void {
|
|
69
|
+
for (const domNode of domNodes) {
|
|
70
|
+
const domNodeStyle = domNode.style;
|
|
71
|
+
|
|
72
|
+
if (domNodeStyle.background !== 'Highlight') {
|
|
73
|
+
domNodeStyle.background = 'Highlight';
|
|
74
|
+
}
|
|
75
|
+
if (domNodeStyle.color !== 'HighlightText') {
|
|
76
|
+
domNodeStyle.color = 'HighlightText';
|
|
77
|
+
}
|
|
78
|
+
if (domNodeStyle.marginTop !== px(-1.5)) {
|
|
79
|
+
domNodeStyle.marginTop = px(-1.5);
|
|
80
|
+
}
|
|
81
|
+
if (domNodeStyle.paddingTop !== px(4)) {
|
|
82
|
+
domNodeStyle.paddingTop = px(4);
|
|
83
|
+
}
|
|
84
|
+
if (domNodeStyle.paddingBottom !== px(0)) {
|
|
85
|
+
domNodeStyle.paddingBottom = px(0);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Place one or multiple newly created Nodes at the current selection. Multiple
|
|
92
|
+
* nodes will only be created when the selection spans multiple lines (aka
|
|
93
|
+
* client rects).
|
|
94
|
+
*
|
|
95
|
+
* This function can come useful when you want to show the selection but the
|
|
96
|
+
* editor has been focused away.
|
|
97
|
+
*/
|
|
98
|
+
export default function markSelection(
|
|
99
|
+
editor: LexicalEditor,
|
|
100
|
+
onReposition: (node: readonly HTMLElement[]) => void = defaultOnReposition,
|
|
101
|
+
): () => void {
|
|
102
|
+
let previousAnchorNode: null | TextNode | ElementNode = null;
|
|
103
|
+
let previousAnchorNodeDOM: null | HTMLElement = null;
|
|
104
|
+
let previousAnchorOffset: null | number = null;
|
|
105
|
+
let previousFocusNode: null | TextNode | ElementNode = null;
|
|
106
|
+
let previousFocusNodeDOM: null | HTMLElement = null;
|
|
107
|
+
let previousFocusOffset: null | number = null;
|
|
108
|
+
let removeRangeListener: () => void = () => {};
|
|
109
|
+
function compute(editorState: EditorState) {
|
|
110
|
+
editorState.read(
|
|
111
|
+
() => {
|
|
112
|
+
const selection = $getSelection();
|
|
113
|
+
if (!$isRangeSelection(selection)) {
|
|
114
|
+
// TODO
|
|
115
|
+
previousAnchorNode = null;
|
|
116
|
+
previousAnchorOffset = null;
|
|
117
|
+
previousFocusNode = null;
|
|
118
|
+
previousFocusOffset = null;
|
|
119
|
+
removeRangeListener();
|
|
120
|
+
removeRangeListener = () => {};
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const [start, end] = $getOrderedSelectionPoints(selection);
|
|
124
|
+
const currentStartNode = start.getNode() as TextNode | ElementNode;
|
|
125
|
+
const currentStartNodeKey = currentStartNode.getKey();
|
|
126
|
+
const currentStartOffset = start.offset;
|
|
127
|
+
const currentEndNode = end.getNode() as TextNode | ElementNode;
|
|
128
|
+
const currentEndNodeKey = currentEndNode.getKey();
|
|
129
|
+
const currentEndOffset = end.offset;
|
|
130
|
+
const currentStartNodeDOM = editor.getElementByKey(currentStartNodeKey);
|
|
131
|
+
const currentEndNodeDOM = editor.getElementByKey(currentEndNodeKey);
|
|
132
|
+
const differentStartDOM =
|
|
133
|
+
previousAnchorNode === null ||
|
|
134
|
+
currentStartNodeDOM !== previousAnchorNodeDOM ||
|
|
135
|
+
currentStartOffset !== previousAnchorOffset ||
|
|
136
|
+
currentStartNodeKey !== previousAnchorNode.getKey();
|
|
137
|
+
const differentEndDOM =
|
|
138
|
+
previousFocusNode === null ||
|
|
139
|
+
currentEndNodeDOM !== previousFocusNodeDOM ||
|
|
140
|
+
currentEndOffset !== previousFocusOffset ||
|
|
141
|
+
currentEndNodeKey !== previousFocusNode.getKey();
|
|
142
|
+
if (
|
|
143
|
+
(differentStartDOM || differentEndDOM) &&
|
|
144
|
+
currentStartNodeDOM !== null &&
|
|
145
|
+
currentEndNodeDOM !== null
|
|
146
|
+
) {
|
|
147
|
+
const range = $rangeFromPoints(
|
|
148
|
+
editor,
|
|
149
|
+
start,
|
|
150
|
+
currentStartNode,
|
|
151
|
+
currentStartNodeDOM,
|
|
152
|
+
end,
|
|
153
|
+
currentEndNode,
|
|
154
|
+
currentEndNodeDOM,
|
|
155
|
+
);
|
|
156
|
+
removeRangeListener();
|
|
157
|
+
removeRangeListener = positionNodeOnRange(
|
|
158
|
+
editor,
|
|
159
|
+
range,
|
|
160
|
+
onReposition,
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
previousAnchorNode = currentStartNode;
|
|
164
|
+
previousAnchorNodeDOM = currentStartNodeDOM;
|
|
165
|
+
previousAnchorOffset = currentStartOffset;
|
|
166
|
+
previousFocusNode = currentEndNode;
|
|
167
|
+
previousFocusNodeDOM = currentEndNodeDOM;
|
|
168
|
+
previousFocusOffset = currentEndOffset;
|
|
169
|
+
// Pass {editor} so the active editor is set: $rangeTargetFromPoint reads
|
|
170
|
+
// the slot (getFirstChildOffset), which consults the active editor to
|
|
171
|
+
// skip the block cursor.
|
|
172
|
+
},
|
|
173
|
+
{editor},
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
compute(editor.getEditorState());
|
|
177
|
+
return mergeRegister(
|
|
178
|
+
editor.registerUpdateListener(({editorState}) => compute(editorState)),
|
|
179
|
+
() => {
|
|
180
|
+
removeRangeListener();
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import invariant from '@lexical/internal/invariant';
|
|
10
|
+
import {createRectsFromDOMRange} from '@lexical/selection';
|
|
11
|
+
import {isHTMLElement, type LexicalEditor} from 'lexical';
|
|
12
|
+
|
|
13
|
+
import px from './px';
|
|
14
|
+
|
|
15
|
+
const mutationObserverConfig = {
|
|
16
|
+
attributes: true,
|
|
17
|
+
characterData: true,
|
|
18
|
+
childList: true,
|
|
19
|
+
subtree: true,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function prependDOMNode(parent: HTMLElement, node: HTMLElement) {
|
|
23
|
+
parent.insertBefore(node, parent.firstChild);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Place one or multiple newly created Nodes at the passed Range's position.
|
|
28
|
+
* Multiple nodes will only be created when the Range spans multiple lines (aka
|
|
29
|
+
* client rects).
|
|
30
|
+
*
|
|
31
|
+
* This function can come particularly useful to highlight particular parts of
|
|
32
|
+
* the text without interfering with the EditorState, that will often replicate
|
|
33
|
+
* the state across collab and clipboard.
|
|
34
|
+
*
|
|
35
|
+
* This function accounts for DOM updates which can modify the passed Range.
|
|
36
|
+
* Hence, the function return to remove the listener.
|
|
37
|
+
*/
|
|
38
|
+
export default function mlcPositionNodeOnRange(
|
|
39
|
+
editor: LexicalEditor,
|
|
40
|
+
range: Range,
|
|
41
|
+
onReposition: (node: Array<HTMLElement>) => void,
|
|
42
|
+
): () => void {
|
|
43
|
+
let rootDOMNode: null | HTMLElement = null;
|
|
44
|
+
let parentDOMNode: null | HTMLElement = null;
|
|
45
|
+
let observer: null | MutationObserver = null;
|
|
46
|
+
let lastNodes: Array<HTMLElement> = [];
|
|
47
|
+
const wrapperNode = document.createElement('div');
|
|
48
|
+
wrapperNode.style.position = 'relative';
|
|
49
|
+
|
|
50
|
+
function position(): void {
|
|
51
|
+
invariant(rootDOMNode !== null, 'Unexpected null rootDOMNode');
|
|
52
|
+
invariant(parentDOMNode !== null, 'Unexpected null parentDOMNode');
|
|
53
|
+
const {left: parentLeft, top: parentTop} =
|
|
54
|
+
parentDOMNode.getBoundingClientRect();
|
|
55
|
+
const rects = createRectsFromDOMRange(editor, range);
|
|
56
|
+
if (!wrapperNode.isConnected) {
|
|
57
|
+
prependDOMNode(parentDOMNode, wrapperNode);
|
|
58
|
+
}
|
|
59
|
+
let hasRepositioned = false;
|
|
60
|
+
for (let i = 0; i < rects.length; i++) {
|
|
61
|
+
const rect = rects[i];
|
|
62
|
+
// Try to reuse the previously created Node when possible, no need to
|
|
63
|
+
// remove/create on the most common case reposition case
|
|
64
|
+
const rectNode = lastNodes[i] || document.createElement('div');
|
|
65
|
+
const rectNodeStyle = rectNode.style;
|
|
66
|
+
if (rectNodeStyle.position !== 'absolute') {
|
|
67
|
+
rectNodeStyle.position = 'absolute';
|
|
68
|
+
hasRepositioned = true;
|
|
69
|
+
}
|
|
70
|
+
const left = px(rect.left - parentLeft);
|
|
71
|
+
if (rectNodeStyle.left !== left) {
|
|
72
|
+
rectNodeStyle.left = left;
|
|
73
|
+
hasRepositioned = true;
|
|
74
|
+
}
|
|
75
|
+
const top = px(rect.top - parentTop);
|
|
76
|
+
if (rectNodeStyle.top !== top) {
|
|
77
|
+
rectNode.style.top = top;
|
|
78
|
+
hasRepositioned = true;
|
|
79
|
+
}
|
|
80
|
+
const width = px(rect.width);
|
|
81
|
+
if (rectNodeStyle.width !== width) {
|
|
82
|
+
rectNode.style.width = width;
|
|
83
|
+
hasRepositioned = true;
|
|
84
|
+
}
|
|
85
|
+
const height = px(rect.height);
|
|
86
|
+
if (rectNodeStyle.height !== height) {
|
|
87
|
+
rectNode.style.height = height;
|
|
88
|
+
hasRepositioned = true;
|
|
89
|
+
}
|
|
90
|
+
if (rectNode.parentNode !== wrapperNode) {
|
|
91
|
+
wrapperNode.append(rectNode);
|
|
92
|
+
hasRepositioned = true;
|
|
93
|
+
}
|
|
94
|
+
lastNodes[i] = rectNode;
|
|
95
|
+
}
|
|
96
|
+
while (lastNodes.length > rects.length) {
|
|
97
|
+
lastNodes.pop();
|
|
98
|
+
}
|
|
99
|
+
if (hasRepositioned) {
|
|
100
|
+
onReposition(lastNodes);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function stop(): void {
|
|
105
|
+
parentDOMNode = null;
|
|
106
|
+
rootDOMNode = null;
|
|
107
|
+
if (observer !== null) {
|
|
108
|
+
observer.disconnect();
|
|
109
|
+
}
|
|
110
|
+
observer = null;
|
|
111
|
+
wrapperNode.remove();
|
|
112
|
+
for (const node of lastNodes) {
|
|
113
|
+
node.remove();
|
|
114
|
+
}
|
|
115
|
+
lastNodes = [];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function restart(): void {
|
|
119
|
+
const currentRootDOMNode = editor.getRootElement();
|
|
120
|
+
if (currentRootDOMNode === null) {
|
|
121
|
+
return stop();
|
|
122
|
+
}
|
|
123
|
+
const currentParentDOMNode = currentRootDOMNode.parentElement;
|
|
124
|
+
if (!isHTMLElement(currentParentDOMNode)) {
|
|
125
|
+
return stop();
|
|
126
|
+
}
|
|
127
|
+
stop();
|
|
128
|
+
rootDOMNode = currentRootDOMNode;
|
|
129
|
+
parentDOMNode = currentParentDOMNode;
|
|
130
|
+
observer = new MutationObserver(mutations => {
|
|
131
|
+
const nextRootDOMNode = editor.getRootElement();
|
|
132
|
+
const nextParentDOMNode =
|
|
133
|
+
nextRootDOMNode && nextRootDOMNode.parentElement;
|
|
134
|
+
if (
|
|
135
|
+
nextRootDOMNode !== rootDOMNode ||
|
|
136
|
+
nextParentDOMNode !== parentDOMNode
|
|
137
|
+
) {
|
|
138
|
+
return restart();
|
|
139
|
+
}
|
|
140
|
+
for (const mutation of mutations) {
|
|
141
|
+
if (!wrapperNode.contains(mutation.target)) {
|
|
142
|
+
// TODO throttle
|
|
143
|
+
return position();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
observer.observe(currentParentDOMNode, mutationObserverConfig);
|
|
148
|
+
position();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const removeRootListener = editor.registerRootListener(restart);
|
|
152
|
+
|
|
153
|
+
return () => {
|
|
154
|
+
removeRootListener();
|
|
155
|
+
stop();
|
|
156
|
+
};
|
|
157
|
+
}
|
package/src/px.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default function px(value: number) {
|
|
10
|
+
return `${value}px`;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {LexicalEditor} from 'lexical';
|
|
10
|
+
|
|
11
|
+
import markSelection from './markSelection';
|
|
12
|
+
|
|
13
|
+
export default function selectionAlwaysOnDisplay(
|
|
14
|
+
editor: LexicalEditor,
|
|
15
|
+
onReposition?: (node: readonly HTMLElement[]) => void,
|
|
16
|
+
): () => void {
|
|
17
|
+
let removeSelectionMark: (() => void) | null = null;
|
|
18
|
+
|
|
19
|
+
const onSelectionChange = () => {
|
|
20
|
+
const domSelection = getSelection();
|
|
21
|
+
const domAnchorNode = domSelection && domSelection.anchorNode;
|
|
22
|
+
const editorRootElement = editor.getRootElement();
|
|
23
|
+
|
|
24
|
+
const isSelectionInsideEditor =
|
|
25
|
+
domAnchorNode !== null &&
|
|
26
|
+
editorRootElement !== null &&
|
|
27
|
+
editorRootElement.contains(domAnchorNode);
|
|
28
|
+
|
|
29
|
+
if (isSelectionInsideEditor) {
|
|
30
|
+
if (removeSelectionMark !== null) {
|
|
31
|
+
removeSelectionMark();
|
|
32
|
+
removeSelectionMark = null;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
if (removeSelectionMark === null) {
|
|
36
|
+
removeSelectionMark = markSelection(editor, onReposition);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return editor.registerRootListener(rootElement => {
|
|
42
|
+
if (rootElement) {
|
|
43
|
+
const document = rootElement.ownerDocument;
|
|
44
|
+
document.addEventListener('selectionchange', onSelectionChange);
|
|
45
|
+
onSelectionChange();
|
|
46
|
+
return () => {
|
|
47
|
+
if (removeSelectionMark !== null) {
|
|
48
|
+
removeSelectionMark();
|
|
49
|
+
}
|
|
50
|
+
document.removeEventListener('selectionchange', onSelectionChange);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
package/LexicalUtils.prod.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=r&&"documentMode"in document?document.documentMode:null,i=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=!(!r||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),a=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=r&&/Android/.test(navigator.userAgent),u=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,g=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),d=r&&c&&g,f=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!g;function p(e){return`${e}px`}const m={attributes:!0,characterData:!0,childList:!0,subtree:!0};function $(r,o,i){let s=null,l=null,a=null,c=[];const u=document.createElement("div");function g(){null===s&&n(182),null===l&&n(183);const{left:e,top:a}=l.getBoundingClientRect(),g=t.createRectsFromDOMRange(r,o);var d,f;u.isConnected||(f=u,(d=l).insertBefore(f,d.firstChild));let m=!1;for(let t=0;t<g.length;t++){const n=g[t],r=c[t]||document.createElement("div"),o=r.style;"absolute"!==o.position&&(o.position="absolute",m=!0);const i=p(n.left-e);o.left!==i&&(o.left=i,m=!0);const s=p(n.top-a);o.top!==s&&(r.style.top=s,m=!0);const l=p(n.width);o.width!==l&&(r.style.width=l,m=!0);const d=p(n.height);o.height!==d&&(r.style.height=d,m=!0),r.parentNode!==u&&(u.append(r),m=!0),c[t]=r}for(;c.length>g.length;)c.pop();m&&i(c)}function d(){l=null,s=null,null!==a&&a.disconnect(),a=null,u.remove();for(const e of c)e.remove();c=[]}u.style.position="relative";const f=r.registerRootListener(function t(){const n=r.getRootElement();if(null===n)return d();const o=n.parentElement;if(!e.isHTMLElement(o))return d();d(),s=n,l=o,a=new MutationObserver(e=>{const n=r.getRootElement(),o=n&&n.parentElement;if(n!==s||o!==l)return t();for(const t of e)if(!u.contains(t.target))return g()}),a.observe(o,m),g()});return()=>{f(),d()}}function h(t,n,r,o){if("text"!==n.type&&e.$isElementNode(r)){const i=e.$getEditorDOMRenderConfig(t).$getDOMSlot(r,o,t);return[i.element,i.getFirstChildOffset()+n.offset]}return[e.getDOMTextNode(o)||o,n.offset]}function C(e){for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==p(-1.5)&&(e.marginTop=p(-1.5)),e.paddingTop!==p(4)&&(e.paddingTop=p(4)),e.paddingBottom!==p(0)&&(e.paddingBottom=p(0))}}function x(t,n=C){let r=null,o=null,i=null,s=null,l=null,a=null,c=()=>{};function u(u){u.read(()=>{const u=e.$getSelection();if(!e.$isRangeSelection(u))return r=null,i=null,s=null,a=null,c(),void(c=()=>{});const[g,d]=function(e){const t=e.getStartEndPoints();return e.isBackward()?[t[1],t[0]]:t}(u),f=g.getNode(),p=f.getKey(),m=g.offset,C=d.getNode(),x=C.getKey(),S=d.offset,E=t.getElementByKey(p),N=t.getElementByKey(x),v=null===r||E!==o||m!==i||p!==r.getKey(),y=null===s||N!==l||S!==a||x!==s.getKey();if((v||y)&&null!==E&&null!==N){const e=function(e,t,n,r,o,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...h(e,t,n,r)),l.setEnd(...h(e,o,i,s)),l}(t,g,f,E,d,C,N);c(),c=$(t,e,n)}r=f,o=E,i=m,s=C,l=N,a=S})}return u(t.getEditorState()),e.mergeRegister(t.registerUpdateListener(({editorState:e})=>u(e)),()=>{c()})}const S=l,E=r,N=c,v=d,y=i,A=f,R=g,b=s,w=a,P=u;function I(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function T(e,t){return M("next",e,t)}function O(t,n){const r=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return r&&r[0]}function M(t,n,r){const o=e.$getRoot(),i=n||o,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=L(i),a=r?e.$getAdjacentChildCaret(e.$getChildCaretOrSelf(e.$getSiblingCaret(r,t)))||O(r,t):O(i,t);let c=l;return e.makeStepwiseIterator({hasNext:e=>null!==e,initial:s,map:e=>({depth:c,node:e.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;e.$isChildCaret(t)&&c++;const n=e.$getAdjacentSiblingOrParentSiblingCaret(t);return!n||n[0].isSameNodeCaret(a)?null:(c+=n[1],n[0])}})}function L(e){let t=-1;for(let n=e;null!==n;n=n.getParent())t++;return t}function _(e,t){return M("previous",e,t)}function D(t,r,o){let i=e.$getCaretInDirection(r,"next");e.$isTextPointCaret(i)&&(0===i.offset?i=e.$getSiblingCaret(i.origin,"previous").getFlipped():i.offset===i.origin.getTextContentSize()&&(i=e.$getSiblingCaret(i.origin,"next"))),i.origin.is(t)&&(e.$isSiblingCaret(i)||n(342,t.getKey(),t.getType()),i=e.$rewindSiblingCaret(i)),(t.is(i.getNodeAtCaret())||t.is(i.getFlipped().getNodeAtCaret()))&&t.remove(!0);for(let t=i;t;t=e.$splitAtPointCaretNext(t,o))i=t;return e.$isTextPointCaret(i)&&n(283),i.insert(t.isInline()?e.$createParagraphNode().append(t):t),e.$getCaretInDirection(e.$getSiblingCaret(t.getLatest(),"next"),r.direction)}let F=!(b||!E)&&void 0;function B(t,n,r){let o=!1;for(const i of j(t))n(i)?null!==r&&r(i):(o=!0,e.$isElementNode(i)&&B(i,n,r||(e=>i.insertAfter(e))),i.remove());return o}function j(t){return k(e.$getChildCaret(t,"previous"))}function k(t){return e.makeStepwiseIterator({hasNext:e.$isSiblingCaret,initial:t.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}exports.$findMatchingParent=e.$findMatchingParent,exports.$getAdjacentSiblingOrParentSiblingCaret=e.$getAdjacentSiblingOrParentSiblingCaret,exports.$splitNode=e.$splitNode,exports.addClassNamesToElement=e.addClassNamesToElement,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.mergeRegister=e.mergeRegister,exports.removeClassNamesFromElement=e.removeClassNamesFromElement,exports.$descendantsMatching=function(t,n){const r=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(n(t))r.push(t);else if(e.$isElementNode(t))for(const e of j(t))o.push(e);return r},exports.$dfs=function(e,t){return Array.from(T(e,t))},exports.$dfsIterator=T,exports.$filter=function(e,t){const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);null!==o&&n.push(o)}return n},exports.$firstToLastIterator=function(t){return k(e.$getChildCaret(t,"next"))},exports.$getAdjacentCaret=function(e){return e?e.getAdjacentCaret():null},exports.$getDepth=L,exports.$getNearestBlockElementAncestorOrThrow=function(t){const r=e.$findMatchingParent(t,t=>e.$isElementNode(t)&&!t.isInline());return e.$isElementNode(r)||n(4,t.__key),r},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){const n=e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),r=e.$getAdjacentSiblingOrParentSiblingCaret(n,"root");return r&&r[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,"next"));return n&&[n[0].origin,n[1]]},exports.$handleIndentAndOutdent=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const r=new Set,o=n.getNodes();for(let n=0;n<o.length;n++){const i=o[n],s=i.getKey();if(r.has(s))continue;const l=e.$findMatchingParent(i,t=>e.$isElementNode(t)&&!t.isInline());if(null===l)continue;const a=l.getKey();l.canIndent()&&!r.has(a)&&(r.add(a),t(l))}return r.size>0},exports.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},exports.$insertNodeIntoLeaf=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n))return void(n&&n.insertNodes([t]));const r=e.$caretRangeFromSelection(n);let o=e.$getCaretRangeInDirection(e.$removeTextFromCaretRange(r),"next").anchor;if(e.$isTextPointCaret(o)){const t=e.$splitAtPointCaretNext(o);if(!t)return;o=t}const i=o.getFlipped();i.insert(t),e.$setSelectionFromCaretRange(e.$getCaretRange(i,i))},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();let r;if(e.$isRangeSelection(n))r=e.$caretFromPoint(n.focus,"next");else{if(null!=n){const t=n.getNodes(),o=t[t.length-1];o&&(r=e.$getSiblingCaret(o,"next"))}r=r||e.$getChildCaret(e.$getRoot(),"previous").getFlipped().insert(e.$createParagraphNode())}const o=D(t,r),i=e.$getAdjacentChildCaret(o),s=e.$isChildCaret(i)?e.$normalizeCaret(i):o;return e.$setSelectionFromCaretRange(e.$getCollapsedCaretRange(s)),t.getLatest()},exports.$insertNodeToNearestRootAtCaret=D,exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=j,exports.$restoreEditorState=function(t,n){const r=new Map,o=t._pendingEditorState;for(const[t,o]of n._nodeMap)r.set(t,e.$cloneWithProperties(o));o&&(o._nodeMap=r),t._dirtyType=2;const i=n._selection;e.$setSelection(null===i?null:i.clone())},exports.$reverseDfs=function(e,t){return Array.from(_(e,t))},exports.$reverseDfsIterator=_,exports.$unwrapAndFilterDescendants=function(e,t){return B(e,t,null)},exports.$unwrapNode=function(t){e.$rewindSiblingCaret(e.$getSiblingCaret(t,"next")).splice(1,t.getChildren())},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=S,exports.CAN_USE_DOM=E,exports.IS_ANDROID=N,exports.IS_ANDROID_CHROME=v,exports.IS_APPLE=y,exports.IS_APPLE_WEBKIT=A,exports.IS_CHROME=R,exports.IS_FIREFOX=b,exports.IS_IOS=w,exports.IS_SAFARI=P,exports.calculateZoomLevel=function(e,t=!1){let n=1;if(function(){if(void 0===F){const e=document.createElement("div");e.style.position="absolute",e.style.opacity="0",e.style.width="100px",e.style.left="-1000px",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),F=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return F}()||t)for(;e;)n*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return n},exports.isMimeType=I,exports.makeStateWrapper=function(t){const n=n=>e.$getState(n,t),r=(n,r)=>e.$setState(n,t,r);return{$get:n,$set:r,accessors:[n,r],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return r(this,e)},stateConfig:t}},exports.markSelection=x,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise((e,r)=>{const o=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(o);const a=new FileReader;a.addEventListener("error",r),a.addEventListener("load",()=>{const e=a.result;"string"==typeof e&&o.push({file:l,result:e}),i()}),I(l,t)?a.readAsDataURL(l):i()};i()})},exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=$,exports.registerNestedElementResolver=function(e,t,n,r){const o=e=>e instanceof t;return e.registerNodeTransform(t,e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e<t.length;e++){const n=t[e];if(o(n))return null}let n=e,r=e;for(;null!==n;)if(r=n,n=n.getParent(),o(n))return{child:r,parent:n};return null})(e);if(null!==t){const{child:o,parent:i}=t;if(o.is(e)){r(i,e);const t=o.getNextSiblings(),s=t.length;if(i.insertAfter(o),0!==s){const e=n(i);o.insertAfter(e);for(let n=0;n<s;n++)e.append(t[n])}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove()}}})},exports.selectionAlwaysOnDisplay=function(e,t){let n=null;const r=()=>{const r=getSelection(),o=r&&r.anchorNode,i=e.getRootElement();null!==o&&null!==i&&i.contains(o)?null!==n&&(n(),n=null):null===n&&(n=x(e,t))};return e.registerRootListener(e=>{if(e){const t=e.ownerDocument;return t.addEventListener("selectionchange",r),r(),()=>{null!==n&&n(),t.removeEventListener("selectionchange",r)}}})};
|
package/LexicalUtils.prod.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import{isHTMLElement as t,mergeRegister as e,$getSelection as n,$isRangeSelection as o,$isElementNode as r,getDOMTextNode as i,$getEditorDOMRenderConfig as l,$getChildCaret as s,$findMatchingParent as u,$getChildCaretOrSelf as c,$getSiblingCaret as a,$getAdjacentSiblingOrParentSiblingCaret as f,$caretRangeFromSelection as d,$getCaretRangeInDirection as g,$removeTextFromCaretRange as p,$isTextPointCaret as m,$splitAtPointCaretNext as h,$setSelectionFromCaretRange as v,$getCaretRange as y,$getPreviousSelection as w,$caretFromPoint as x,$getRoot as E,$createParagraphNode as C,$getAdjacentChildCaret as S,$isChildCaret as A,$normalizeCaret as N,$getCollapsedCaretRange as b,$getCaretInDirection as L,$isSiblingCaret as P,$rewindSiblingCaret as R,$cloneWithProperties as M,$setSelection as T,makeStepwiseIterator as B,$getState as K,$setState as _}from"lexical";export{$findMatchingParent,$getAdjacentSiblingOrParentSiblingCaret,$splitNode,addClassNamesToElement,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode,mergeRegister,removeClassNamesFromElement}from"lexical";import{createRectsFromDOMRange as $}from"@lexical/selection";function k(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const F="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,I=F&&"documentMode"in document?document.documentMode:null,O=F&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),D=F&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),H=!(!F||!("InputEvent"in window)||I)&&"getTargetRanges"in new window.InputEvent("input"),j=F&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,z=F&&/Android/.test(navigator.userAgent),U=F&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!z,V=F&&/^(?=.*Chrome).*/i.test(navigator.userAgent),W=F&&z&&V,G=F&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&O&&!V;function q(t){return`${t}px`}const J={attributes:!0,characterData:!0,childList:!0,subtree:!0};function Q(e,n,o){let r=null,i=null,l=null,s=[];const u=document.createElement("div");function c(){null===r&&k(182),null===i&&k(183);const{left:t,top:l}=i.getBoundingClientRect(),c=$(e,n);var a,f;u.isConnected||(f=u,(a=i).insertBefore(f,a.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=s[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=q(n.left-t);r.left!==i&&(r.left=i,d=!0);const a=q(n.top-l);r.top!==a&&(o.style.top=a,d=!0);const f=q(n.width);r.width!==f&&(o.style.width=f,d=!0);const g=q(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==u&&(u.append(o),d=!0),s[e]=o}for(;s.length>c.length;)s.pop();d&&o(s)}function a(){i=null,r=null,null!==l&&l.disconnect(),l=null,u.remove();for(const t of s)t.remove();s=[]}u.style.position="relative";const f=e.registerRootListener(function n(){const o=e.getRootElement();if(null===o)return a();const s=o.parentElement;if(!t(s))return a();a(),r=o,i=s,l=new MutationObserver(t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!u.contains(e.target))return c()}),l.observe(s,J),c()});return()=>{f(),a()}}function X(t,e,n,o){if("text"!==e.type&&r(n)){const r=l(t).$getDOMSlot(n,o,t);return[r.element,r.getFirstChildOffset()+e.offset]}return[i(o)||o,e.offset]}function Y(t){for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==q(-1.5)&&(t.marginTop=q(-1.5)),t.paddingTop!==q(4)&&(t.paddingTop=q(4)),t.paddingBottom!==q(0)&&(t.paddingBottom=q(0))}}function Z(t,r=Y){let i=null,l=null,s=null,u=null,c=null,a=null,f=()=>{};function d(e){e.read(()=>{const e=n();if(!o(e))return i=null,s=null,u=null,a=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(e),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),C=null===i||x!==l||h!==s||m!==i.getKey(),S=null===u||E!==c||w!==a||y!==u.getKey();if((C||S)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return s.setStart(...X(t,e,n,o)),s.setEnd(...X(t,r,i,l)),s}(t,d,p,x,g,v,E);f(),f=Q(t,e,r)}i=p,l=x,s=h,u=v,c=E,a=w})}return d(t.getEditorState()),e(t.registerUpdateListener(({editorState:t})=>d(t)),()=>{f()})}function tt(t,e){let n=null;const o=()=>{const o=getSelection(),r=o&&o.anchorNode,i=t.getRootElement();null!==r&&null!==i&&i.contains(r)?null!==n&&(n(),n=null):null===n&&(n=Z(t,e))};return t.registerRootListener(t=>{if(t){const e=t.ownerDocument;return e.addEventListener("selectionchange",o),o(),()=>{null!==n&&n(),e.removeEventListener("selectionchange",o)}}})}const et=H,nt=F,ot=z,rt=W,it=O,lt=G,st=V,ut=D,ct=j,at=U;function ft(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function dt(t,e){const n=t[Symbol.iterator]();return new Promise((t,o)=>{const r=[],i=()=>{const{done:l,value:s}=n.next();if(l)return t(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",()=>{const t=u.result;"string"==typeof t&&r.push({file:s,result:t}),i()}),ft(s,e)?u.readAsDataURL(s):i()};i()})}function gt(t,e){return Array.from(ht(t,e))}function pt(t){return t?t.getAdjacentCaret():null}function mt(t,e){return Array.from(Ct(t,e))}function ht(t,e){return yt("next",t,e)}function vt(t,e){const n=f(a(t,e));return n&&n[0]}function yt(t,e,n){const o=E(),i=e||o,l=r(i)?s(i,t):a(i,t),u=xt(i),d=n?S(c(a(n,t)))||vt(n,t):vt(i,t);let g=u;return B({hasNext:t=>null!==t,initial:l,map:t=>({depth:g,node:t.origin}),step:t=>{if(t.isSameNodeCaret(d))return null;A(t)&&g++;const e=f(t);return!e||e[0].isSameNodeCaret(d)?null:(g+=e[1],e[0])}})}function wt(t){const e=f(a(t,"next"));return e&&[e[0].origin,e[1]]}function xt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function Et(t){const e=c(a(t,"previous")),n=f(e,"root");return n&&n[0].origin}function Ct(t,e){return yt("previous",t,e)}function St(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function At(t){const e=u(t,t=>r(t)&&!t.isInline());return r(e)||k(4,t.__key),e}function Nt(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,t=>{const e=(t=>{const e=t.getChildren();for(let t=0;t<e.length;t++){const n=e[t];if(r(n))return null}let n=t,o=t;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return{child:o,parent:n};return null})(t);if(null!==e){const{child:r,parent:i}=e;if(r.is(t)){o(i,t);const e=r.getNextSiblings(),l=e.length;if(i.insertAfter(r),0!==l){const t=n(i);r.insertAfter(t);for(let n=0;n<l;n++)t.append(e[n])}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove()}}})}function bt(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,M(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;T(null===r?null:r.clone())}function Lt(t){const e=n()||w();let r;if(o(e))r=x(e.focus,"next");else{if(null!=e){const t=e.getNodes(),n=t[t.length-1];n&&(r=a(n,"next"))}r=r||s(E(),"previous").getFlipped().insert(C())}const i=Pt(t,r),l=S(i),u=A(l)?N(l):i;return v(b(u)),t.getLatest()}function Pt(t,e,n){let o=L(e,"next");m(o)&&(0===o.offset?o=a(o.origin,"previous").getFlipped():o.offset===o.origin.getTextContentSize()&&(o=a(o.origin,"next"))),o.origin.is(t)&&(P(o)||k(342,t.getKey(),t.getType()),o=R(o)),(t.is(o.getNodeAtCaret())||t.is(o.getFlipped().getNodeAtCaret()))&&t.remove(!0);for(let t=o;t;t=h(t,n))o=t;return m(o)&&k(283),o.insert(t.isInline()?C().append(t):t),L(a(t.getLatest(),"next"),e.direction)}function Rt(t){const e=n();if(!o(e))return void(e&&e.insertNodes([t]));const r=d(e);let i=g(p(r),"next").anchor;if(m(i)){const t=h(i);if(!t)return;i=t}const l=i.getFlipped();l.insert(t),v(y(l,l))}function Mt(t,e){const n=e();return t.replace(n),n.append(t),n}function Tt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Bt(t,e){const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);null!==r&&n.push(r)}return n}function Kt(t){const e=n();if(!o(e))return!1;const i=new Set,l=e.getNodes();for(let e=0;e<l.length;e++){const n=l[e],o=n.getKey();if(i.has(o))continue;const s=u(n,t=>r(t)&&!t.isInline());if(null===s)continue;const c=s.getKey();s.canIndent()&&!i.has(c)&&(i.add(c),t(s))}return i.size>0}function _t(t,e){s(t,"next").insert(e)}let $t=!(ut||!nt)&&void 0;function kt(t,e=!1){let n=1;if(function(){if(void 0===$t){const t=document.createElement("div");t.style.position="absolute",t.style.opacity="0",t.style.width="100px",t.style.left="-1000px",document.body.appendChild(t);const e=t.getBoundingClientRect();t.style.setProperty("zoom","2"),$t=t.getBoundingClientRect().width===e.width,document.body.removeChild(t)}return $t}()||e)for(;t;)n*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return n}function Ft(t){return null!==t._parentEditor}function It(t,e){return Ot(t,e,null)}function Ot(t,e,n){let o=!1;for(const i of jt(t))e(i)?null!==n&&n(i):(o=!0,r(i)&&Ot(i,e,n||(t=>i.insertAfter(t))),i.remove());return o}function Dt(t,e){const n=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(e(t))n.push(t);else if(r(t))for(const e of jt(t))o.push(e);return n}function Ht(t){return zt(s(t,"next"))}function jt(t){return zt(s(t,"previous"))}function zt(t){return B({hasNext:P,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ut(t){R(a(t,"next")).splice(1,t.getChildren())}function Vt(t){const e=e=>K(e,t),n=(e,n)=>_(e,t,n);return{$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}export{Dt as $descendantsMatching,gt as $dfs,ht as $dfsIterator,Bt as $filter,Ht as $firstToLastIterator,pt as $getAdjacentCaret,xt as $getDepth,At as $getNearestBlockElementAncestorOrThrow,St as $getNearestNodeOfType,Et as $getNextRightPreorderNode,wt as $getNextSiblingOrParentSibling,Kt as $handleIndentAndOutdent,_t as $insertFirst,Rt as $insertNodeIntoLeaf,Lt as $insertNodeToNearestRoot,Pt as $insertNodeToNearestRootAtCaret,Ft as $isEditorIsNestedEditor,jt as $lastToFirstIterator,bt as $restoreEditorState,mt as $reverseDfs,Ct as $reverseDfsIterator,It as $unwrapAndFilterDescendants,Ut as $unwrapNode,Mt as $wrapNodeInElement,et as CAN_USE_BEFORE_INPUT,nt as CAN_USE_DOM,ot as IS_ANDROID,rt as IS_ANDROID_CHROME,it as IS_APPLE,lt as IS_APPLE_WEBKIT,st as IS_CHROME,ut as IS_FIREFOX,ct as IS_IOS,at as IS_SAFARI,kt as calculateZoomLevel,ft as isMimeType,Vt as makeStateWrapper,Z as markSelection,dt as mediaFileReader,Tt as objectKlassEquals,Q as positionNodeOnRange,Nt as registerNestedElementResolver,tt as selectionAlwaysOnDisplay};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|