slate-vue3 0.6.0 → 0.7.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/dist/{batch-dirty-paths-DGoKWQz8.js → batch-dirty-paths-DTifjYae.js} +22 -23
- package/dist/core.js +3 -3
- package/dist/{create-editor-FUfSF1v5.js → create-editor-B9auxB5v.js} +3 -3
- package/dist/dom.js +147 -85
- package/dist/history.js +1 -1
- package/dist/{hotkeys-DdYAaAmE.js → hotkeys-C37qxxQK.js} +633 -36
- package/dist/hyperscript.js +2 -2
- package/dist/index.js +31 -13
- package/dist/{location-H02Ot2Mm.js → location-V9fJlEiJ.js} +1 -1
- package/dist/slate-dom/chunking/children-helper.d.ts +60 -0
- package/dist/slate-dom/chunking/chunk-tree-helper.d.ts +159 -0
- package/dist/slate-dom/chunking/get-chunk-tree-for-node.d.ts +16 -0
- package/dist/slate-dom/chunking/index.d.ts +2 -0
- package/dist/slate-dom/chunking/reconcile-children.d.ts +19 -0
- package/dist/slate-dom/chunking/types.d.ts +43 -0
- package/dist/slate-dom/index.d.ts +3 -1
- package/dist/slate-dom/plugin/dom-editor.d.ts +2 -1
- package/dist/slate-dom/utils/range-list.d.ts +12 -3
- package/dist/slate-vue/components/children.d.ts +6 -2
- package/dist/slate-vue/components/chunk.d.ts +8 -0
- package/dist/slate-vue/components/slate.d.ts +4 -1
- package/dist/slate-vue/components/utils.d.ts +2 -1
- package/dist/slate-vue/hooks/use-element.d.ts +7 -0
- package/dist/slate-vue/hooks/use-render.d.ts +2 -1
- package/dist/slate-vue/index.d.ts +2 -1
- package/dist/slate-vue/utils/constants.d.ts +2 -1
- package/dist/slate-vue/utils/interface.d.ts +11 -0
- package/dist/{use-focused-C00bi8rh.js → use-focused-Dy6j9QOF.js} +126 -39
- package/dist/yjs.js +4 -4
- package/package.json +1 -1
|
@@ -676,16 +676,15 @@ const Range = {
|
|
|
676
676
|
return start;
|
|
677
677
|
},
|
|
678
678
|
transform(range, op, options = {}) {
|
|
679
|
-
|
|
680
|
-
if (r === null) {
|
|
679
|
+
if (range === null) {
|
|
681
680
|
return null;
|
|
682
681
|
}
|
|
683
682
|
const { affinity = "inward" } = options;
|
|
684
683
|
let affinityAnchor;
|
|
685
684
|
let affinityFocus;
|
|
686
685
|
if (affinity === "inward") {
|
|
687
|
-
const isCollapsed = Range.isCollapsed(
|
|
688
|
-
if (Range.isForward(
|
|
686
|
+
const isCollapsed = Range.isCollapsed(range);
|
|
687
|
+
if (Range.isForward(range)) {
|
|
689
688
|
affinityAnchor = "forward";
|
|
690
689
|
affinityFocus = isCollapsed ? affinityAnchor : "backward";
|
|
691
690
|
} else {
|
|
@@ -693,7 +692,7 @@ const Range = {
|
|
|
693
692
|
affinityFocus = isCollapsed ? affinityAnchor : "forward";
|
|
694
693
|
}
|
|
695
694
|
} else if (affinity === "outward") {
|
|
696
|
-
if (Range.isForward(
|
|
695
|
+
if (Range.isForward(range)) {
|
|
697
696
|
affinityAnchor = "backward";
|
|
698
697
|
affinityFocus = "forward";
|
|
699
698
|
} else {
|
|
@@ -704,14 +703,12 @@ const Range = {
|
|
|
704
703
|
affinityAnchor = affinity;
|
|
705
704
|
affinityFocus = affinity;
|
|
706
705
|
}
|
|
707
|
-
const anchor = Point.transform(
|
|
708
|
-
const focus = Point.transform(
|
|
706
|
+
const anchor = Point.transform(range.anchor, op, { affinity: affinityAnchor });
|
|
707
|
+
const focus = Point.transform(range.focus, op, { affinity: affinityFocus });
|
|
709
708
|
if (!anchor || !focus) {
|
|
710
709
|
return null;
|
|
711
710
|
}
|
|
712
|
-
|
|
713
|
-
r.focus = focus;
|
|
714
|
-
return r;
|
|
711
|
+
return { anchor, focus };
|
|
715
712
|
}
|
|
716
713
|
};
|
|
717
714
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
@@ -2020,34 +2017,34 @@ const Point = {
|
|
|
2020
2017
|
return isObject$1(value) && typeof value.offset === "number" && Path.isPath(value.path);
|
|
2021
2018
|
},
|
|
2022
2019
|
transform(point, op, options = {}) {
|
|
2023
|
-
|
|
2024
|
-
if (p === null) {
|
|
2020
|
+
if (point === null) {
|
|
2025
2021
|
return null;
|
|
2026
2022
|
}
|
|
2027
2023
|
const { affinity = "forward" } = options;
|
|
2028
|
-
|
|
2024
|
+
let offset = point.offset;
|
|
2025
|
+
let path = cloneDeep(point.path);
|
|
2029
2026
|
switch (op.type) {
|
|
2030
2027
|
case "insert_node":
|
|
2031
2028
|
case "move_node": {
|
|
2032
|
-
|
|
2029
|
+
path = Path.transform(path, op, options);
|
|
2033
2030
|
break;
|
|
2034
2031
|
}
|
|
2035
2032
|
case "insert_text": {
|
|
2036
2033
|
if (Path.equals(op.path, path) && (op.offset < offset || op.offset === offset && affinity === "forward")) {
|
|
2037
|
-
|
|
2034
|
+
offset += op.text.length;
|
|
2038
2035
|
}
|
|
2039
2036
|
break;
|
|
2040
2037
|
}
|
|
2041
2038
|
case "merge_node": {
|
|
2042
2039
|
if (Path.equals(op.path, path)) {
|
|
2043
|
-
|
|
2040
|
+
offset += op.position;
|
|
2044
2041
|
}
|
|
2045
|
-
|
|
2042
|
+
path = Path.transform(path, op, options);
|
|
2046
2043
|
break;
|
|
2047
2044
|
}
|
|
2048
2045
|
case "remove_text": {
|
|
2049
2046
|
if (Path.equals(op.path, path) && op.offset <= offset) {
|
|
2050
|
-
|
|
2047
|
+
offset -= Math.min(offset - op.offset, op.text.length);
|
|
2051
2048
|
}
|
|
2052
2049
|
break;
|
|
2053
2050
|
}
|
|
@@ -2055,7 +2052,7 @@ const Point = {
|
|
|
2055
2052
|
if (Path.equals(op.path, path) || Path.isAncestor(op.path, path)) {
|
|
2056
2053
|
return null;
|
|
2057
2054
|
}
|
|
2058
|
-
|
|
2055
|
+
path = Path.transform(path, op, options);
|
|
2059
2056
|
break;
|
|
2060
2057
|
}
|
|
2061
2058
|
case "split_node": {
|
|
@@ -2063,19 +2060,21 @@ const Point = {
|
|
|
2063
2060
|
if (op.position === offset && affinity == null) {
|
|
2064
2061
|
return null;
|
|
2065
2062
|
} else if (op.position < offset || op.position === offset && affinity === "forward") {
|
|
2066
|
-
|
|
2067
|
-
|
|
2063
|
+
offset -= op.position;
|
|
2064
|
+
path = Path.transform(path, op, {
|
|
2068
2065
|
...options,
|
|
2069
2066
|
affinity: "forward"
|
|
2070
2067
|
});
|
|
2071
2068
|
}
|
|
2072
2069
|
} else {
|
|
2073
|
-
|
|
2070
|
+
path = Path.transform(path, op, options);
|
|
2074
2071
|
}
|
|
2075
2072
|
break;
|
|
2076
2073
|
}
|
|
2074
|
+
default:
|
|
2075
|
+
return point;
|
|
2077
2076
|
}
|
|
2078
|
-
return
|
|
2077
|
+
return { path, offset };
|
|
2079
2078
|
}
|
|
2080
2079
|
};
|
|
2081
2080
|
let _scrubber = void 0;
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a6, a7, a8, d, e, f, a, h, aj, c, i, j, k, ap, ak, l, m, o, p, q, g, b, r, t, u, v, w, x, aq, y, a9, z, A, B, C, D, E, F, G, H, I, J, aa, K, ab, al, ac, L, M, N, O, n, P, S, Q, R, V, T, U, W, X, _, Y, Z, $, ad, am, ae, a0, an, ao, a5, s, af, a1, a2, a3, ag, ah, a4, ai } from "./create-editor-
|
|
2
|
-
import { E as E2, a as a10, N as N2, O as O2, P as P2, b as b2, R as R2, S as S2, T as T2, c as c2, i as i2, d as d2 } from "./batch-dirty-paths-
|
|
3
|
-
import { L as L2, S as S3 } from "./location-
|
|
1
|
+
import { a6, a7, a8, d, e, f, a, h, aj, c, i, j, k, ap, ak, l, m, o, p, q, g, b, r, t, u, v, w, x, aq, y, a9, z, A, B, C, D, E, F, G, H, I, J, aa, K, ab, al, ac, L, M, N, O, n, P, S, Q, R, V, T, U, W, X, _, Y, Z, $, ad, am, ae, a0, an, ao, a5, s, af, a1, a2, a3, ag, ah, a4, ai } from "./create-editor-B9auxB5v.js";
|
|
2
|
+
import { E as E2, a as a10, N as N2, O as O2, P as P2, b as b2, R as R2, S as S2, T as T2, c as c2, i as i2, d as d2 } from "./batch-dirty-paths-DTifjYae.js";
|
|
3
|
+
import { L as L2, S as S3 } from "./location-V9fJlEiJ.js";
|
|
4
4
|
export {
|
|
5
5
|
E2 as Editor,
|
|
6
6
|
a10 as Element,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as Path, b as Point, R as Range, E as Editor, D as DIRTY_PATHS, e as DIRTY_PATH_KEYS, f as isBatchingDirtyPaths, c as Transforms, F as FLUSHING, T as Text, N as Node, a as Element, g as NORMALIZING, h as PATH_REFS, j as POINT_REFS, k as RANGE_REFS, l as cloneDeep, m as getDefaultInsertLocation, S as Scrubber, n as batchDirtyPaths } from "./batch-dirty-paths-
|
|
1
|
+
import { P as Path, b as Point, R as Range, E as Editor, D as DIRTY_PATHS, e as DIRTY_PATH_KEYS, f as isBatchingDirtyPaths, c as Transforms, F as FLUSHING, T as Text, N as Node, a as Element, g as NORMALIZING, h as PATH_REFS, j as POINT_REFS, k as RANGE_REFS, l as cloneDeep, m as getDefaultInsertLocation, S as Scrubber, n as batchDirtyPaths } from "./batch-dirty-paths-DTifjYae.js";
|
|
2
2
|
import { reactive } from "vue";
|
|
3
|
-
import { S as Span } from "./location-
|
|
3
|
+
import { S as Span } from "./location-V9fJlEiJ.js";
|
|
4
4
|
const PathRef = {
|
|
5
5
|
transform(ref, op) {
|
|
6
6
|
const { current, affinity } = ref;
|
|
@@ -1461,7 +1461,7 @@ const deleteText = (editor, options = {}) => {
|
|
|
1461
1461
|
voids
|
|
1462
1462
|
});
|
|
1463
1463
|
}
|
|
1464
|
-
if (isCollapsed && reverse && unit === "character" && removedText.length > 1 && removedText.match(/[\u0E00-\u0E7F]+/)) {
|
|
1464
|
+
if (isCollapsed && reverse && unit === "character" && removedText.length > 1 && removedText.match(/[\u0980-\u09FF\u0E00-\u0E7F]+/)) {
|
|
1465
1465
|
Transforms.insertText(
|
|
1466
1466
|
editor,
|
|
1467
1467
|
removedText.slice(0, removedText.length - distance)
|
package/dist/dom.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DOMEditor, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText,
|
|
2
|
-
import { C,
|
|
3
|
-
import { E as Editor, R as Range, a as Element, c as Transforms,
|
|
1
|
+
import { D as DOMEditor, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, g as getChunkTreeForNode, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, c as getPlainText, d as getSlateFragmentAttribute, e as EDITOR_TO_ON_CHANGE } from "./hotkeys-C37qxxQK.js";
|
|
2
|
+
import { C, J, L, M, H, F, I, v, O, w, x, P, y, Q, A, z, B, G, K, R, S, T, U, f, h, j, k, l, m, o, p, q, r, s, t, u, n } from "./hotkeys-C37qxxQK.js";
|
|
3
|
+
import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./batch-dirty-paths-DTifjYae.js";
|
|
4
4
|
import "vue";
|
|
5
5
|
const doRectsIntersect = (rect, compareRect) => {
|
|
6
6
|
const middle = (compareRect.top + compareRect.bottom) / 2;
|
|
@@ -46,42 +46,52 @@ const findCurrentLineRange = (editor, parentRange) => {
|
|
|
46
46
|
return Editor.range(editor, positions[left], parentRangeBoundary);
|
|
47
47
|
};
|
|
48
48
|
const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
49
|
-
const
|
|
50
|
-
const { apply, onChange, deleteBackward, addMark, removeMark } =
|
|
51
|
-
EDITOR_TO_KEY_TO_ELEMENT.set(
|
|
52
|
-
|
|
53
|
-
EDITOR_TO_USER_MARKS.delete(
|
|
49
|
+
const e = editor;
|
|
50
|
+
const { apply, onChange, deleteBackward, addMark, removeMark } = e;
|
|
51
|
+
EDITOR_TO_KEY_TO_ELEMENT.set(e, /* @__PURE__ */ new WeakMap());
|
|
52
|
+
e.addMark = (key, value) => {
|
|
53
|
+
EDITOR_TO_USER_MARKS.delete(e);
|
|
54
54
|
addMark(key, value);
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
EDITOR_TO_USER_MARKS.delete(
|
|
56
|
+
e.removeMark = (key) => {
|
|
57
|
+
EDITOR_TO_USER_MARKS.delete(e);
|
|
58
58
|
removeMark(key);
|
|
59
59
|
};
|
|
60
|
-
|
|
60
|
+
e.deleteBackward = (unit) => {
|
|
61
61
|
if (unit !== "line") {
|
|
62
62
|
return deleteBackward(unit);
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
65
|
-
const parentBlockEntry = Editor.above(
|
|
66
|
-
match: (n2) => Element.isElement(n2) && Editor.isBlock(
|
|
67
|
-
at:
|
|
64
|
+
if (e.selection && Range.isCollapsed(e.selection)) {
|
|
65
|
+
const parentBlockEntry = Editor.above(e, {
|
|
66
|
+
match: (n2) => Element.isElement(n2) && Editor.isBlock(e, n2),
|
|
67
|
+
at: e.selection
|
|
68
68
|
});
|
|
69
69
|
if (parentBlockEntry) {
|
|
70
70
|
const [, parentBlockPath] = parentBlockEntry;
|
|
71
71
|
const parentElementRange = Editor.range(
|
|
72
|
-
|
|
72
|
+
e,
|
|
73
73
|
parentBlockPath,
|
|
74
|
-
|
|
74
|
+
e.selection.anchor
|
|
75
75
|
);
|
|
76
|
-
const currentLineRange = findCurrentLineRange(
|
|
76
|
+
const currentLineRange = findCurrentLineRange(e, parentElementRange);
|
|
77
77
|
if (!Range.isCollapsed(currentLineRange)) {
|
|
78
|
-
Transforms.delete(
|
|
78
|
+
Transforms.delete(e, { at: currentLineRange });
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
e.apply = (op) => {
|
|
84
84
|
var _a;
|
|
85
|
+
if (op.type === "move_node") {
|
|
86
|
+
const parent = Node.parent(e, op.path);
|
|
87
|
+
const chunking = !!e.getChunkSize(parent);
|
|
88
|
+
if (chunking) {
|
|
89
|
+
const node = Node.get(e, op.path);
|
|
90
|
+
const chunkTree = getChunkTreeForNode(e, parent);
|
|
91
|
+
const key = DOMEditor.findKey(e, node);
|
|
92
|
+
chunkTree.movedNodeKeys.add(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
85
95
|
const matches = [];
|
|
86
96
|
const pathRefMatches = [];
|
|
87
97
|
switch (op.type) {
|
|
@@ -89,22 +99,22 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
|
89
99
|
case "remove_text":
|
|
90
100
|
case "set_node":
|
|
91
101
|
case "split_node": {
|
|
92
|
-
matches.push(...getMatches(
|
|
102
|
+
matches.push(...getMatches(e, op.path));
|
|
93
103
|
break;
|
|
94
104
|
}
|
|
95
105
|
case "set_selection": {
|
|
96
|
-
(_a = EDITOR_TO_USER_SELECTION.get(
|
|
97
|
-
EDITOR_TO_USER_SELECTION.delete(
|
|
106
|
+
(_a = EDITOR_TO_USER_SELECTION.get(e)) == null ? void 0 : _a.unref();
|
|
107
|
+
EDITOR_TO_USER_SELECTION.delete(e);
|
|
98
108
|
break;
|
|
99
109
|
}
|
|
100
110
|
case "insert_node":
|
|
101
111
|
case "remove_node": {
|
|
102
|
-
matches.push(...getMatches(
|
|
112
|
+
matches.push(...getMatches(e, Path.parent(op.path)));
|
|
103
113
|
break;
|
|
104
114
|
}
|
|
105
115
|
case "merge_node": {
|
|
106
116
|
const prevPath = Path.previous(op.path);
|
|
107
|
-
matches.push(...getMatches(
|
|
117
|
+
matches.push(...getMatches(e, prevPath));
|
|
108
118
|
break;
|
|
109
119
|
}
|
|
110
120
|
case "move_node": {
|
|
@@ -112,47 +122,47 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
|
112
122
|
Path.parent(op.path),
|
|
113
123
|
Path.parent(op.newPath)
|
|
114
124
|
);
|
|
115
|
-
matches.push(...getMatches(
|
|
125
|
+
matches.push(...getMatches(e, commonPath));
|
|
116
126
|
let changedPath;
|
|
117
127
|
if (Path.isBefore(op.path, op.newPath)) {
|
|
118
|
-
matches.push(...getMatches(
|
|
128
|
+
matches.push(...getMatches(e, Path.parent(op.path)));
|
|
119
129
|
changedPath = op.newPath;
|
|
120
130
|
} else {
|
|
121
|
-
matches.push(...getMatches(
|
|
131
|
+
matches.push(...getMatches(e, Path.parent(op.newPath)));
|
|
122
132
|
changedPath = op.path;
|
|
123
133
|
}
|
|
124
134
|
const changedNode = Node.get(editor, Path.parent(changedPath));
|
|
125
|
-
const changedNodeKey = DOMEditor.findKey(
|
|
126
|
-
const changedPathRef = Editor.pathRef(
|
|
135
|
+
const changedNodeKey = DOMEditor.findKey(e, changedNode);
|
|
136
|
+
const changedPathRef = Editor.pathRef(e, Path.parent(changedPath));
|
|
127
137
|
pathRefMatches.push([changedPathRef, changedNodeKey]);
|
|
128
138
|
break;
|
|
129
139
|
}
|
|
130
140
|
}
|
|
131
141
|
apply(op);
|
|
132
142
|
for (const [path, key] of matches) {
|
|
133
|
-
const [node] = Editor.node(
|
|
143
|
+
const [node] = Editor.node(e, path);
|
|
134
144
|
NODE_TO_KEY.set(node, key);
|
|
135
145
|
}
|
|
136
146
|
for (const [pathRef, key] of pathRefMatches) {
|
|
137
147
|
if (pathRef.current) {
|
|
138
|
-
const [node] = Editor.node(
|
|
148
|
+
const [node] = Editor.node(e, pathRef.current);
|
|
139
149
|
NODE_TO_KEY.set(node, key);
|
|
140
150
|
}
|
|
141
151
|
pathRef.unref();
|
|
142
152
|
}
|
|
143
153
|
};
|
|
144
|
-
|
|
145
|
-
const { selection } =
|
|
154
|
+
e.setFragmentData = (data) => {
|
|
155
|
+
const { selection } = e;
|
|
146
156
|
if (!selection) {
|
|
147
157
|
return;
|
|
148
158
|
}
|
|
149
159
|
const [start, end] = Range.edges(selection);
|
|
150
|
-
const startVoid = Editor.void(
|
|
151
|
-
const endVoid = Editor.void(
|
|
160
|
+
const startVoid = Editor.void(e, { at: start.path });
|
|
161
|
+
const endVoid = Editor.void(e, { at: end.path });
|
|
152
162
|
if (Range.isCollapsed(selection) && !startVoid) {
|
|
153
163
|
return;
|
|
154
164
|
}
|
|
155
|
-
const domRange = DOMEditor.toDOMRange(
|
|
165
|
+
const domRange = DOMEditor.toDOMRange(e, selection);
|
|
156
166
|
let contents = domRange.cloneContents();
|
|
157
167
|
let attach = contents.childNodes[0];
|
|
158
168
|
contents.childNodes.forEach((node) => {
|
|
@@ -163,7 +173,7 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
|
163
173
|
if (endVoid) {
|
|
164
174
|
const [voidNode] = endVoid;
|
|
165
175
|
const r2 = domRange.cloneRange();
|
|
166
|
-
const domNode = DOMEditor.toDOMNode(
|
|
176
|
+
const domNode = DOMEditor.toDOMNode(e, voidNode);
|
|
167
177
|
r2.setEndAfter(domNode);
|
|
168
178
|
contents = r2.cloneContents();
|
|
169
179
|
}
|
|
@@ -183,7 +193,7 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
|
183
193
|
contents.appendChild(span);
|
|
184
194
|
attach = span;
|
|
185
195
|
}
|
|
186
|
-
const fragment =
|
|
196
|
+
const fragment = e.getFragment();
|
|
187
197
|
const string = JSON.stringify(fragment);
|
|
188
198
|
const encoded = window.btoa(encodeURIComponent(string));
|
|
189
199
|
attach.setAttribute("data-slate-fragment", encoded);
|
|
@@ -197,50 +207,51 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
|
197
207
|
contents.ownerDocument.body.removeChild(div);
|
|
198
208
|
return data;
|
|
199
209
|
};
|
|
200
|
-
|
|
201
|
-
if (!
|
|
202
|
-
|
|
210
|
+
e.insertData = (data) => {
|
|
211
|
+
if (!e.insertFragmentData(data)) {
|
|
212
|
+
e.insertTextData(data);
|
|
203
213
|
}
|
|
204
214
|
};
|
|
205
|
-
|
|
215
|
+
e.insertFragmentData = (data) => {
|
|
206
216
|
const fragment = data.getData(`application/${clipboardFormatKey}`) || getSlateFragmentAttribute(data);
|
|
207
217
|
if (fragment) {
|
|
208
218
|
const decoded = decodeURIComponent(window.atob(fragment));
|
|
209
219
|
const parsed = JSON.parse(decoded);
|
|
210
|
-
|
|
220
|
+
e.insertFragment(parsed);
|
|
211
221
|
return true;
|
|
212
222
|
}
|
|
213
223
|
return false;
|
|
214
224
|
};
|
|
215
|
-
|
|
225
|
+
e.insertTextData = (data) => {
|
|
216
226
|
const text = data.getData("text/plain");
|
|
217
227
|
if (text) {
|
|
218
228
|
const lines = text.split(/\r\n|\r|\n/);
|
|
219
229
|
let split = false;
|
|
220
230
|
for (const line of lines) {
|
|
221
231
|
if (split) {
|
|
222
|
-
Transforms.splitNodes(
|
|
232
|
+
Transforms.splitNodes(e, { always: true });
|
|
223
233
|
}
|
|
224
|
-
|
|
234
|
+
e.insertText(line);
|
|
225
235
|
split = true;
|
|
226
236
|
}
|
|
227
237
|
return true;
|
|
228
238
|
}
|
|
229
239
|
return false;
|
|
230
240
|
};
|
|
231
|
-
|
|
232
|
-
|
|
241
|
+
e.getChunkSize = () => null;
|
|
242
|
+
e.onChange = (options) => {
|
|
243
|
+
const onContextChange = EDITOR_TO_ON_CHANGE.get(e);
|
|
233
244
|
if (onContextChange) {
|
|
234
245
|
onContextChange(options);
|
|
235
246
|
}
|
|
236
247
|
onChange(options);
|
|
237
248
|
};
|
|
238
|
-
return
|
|
249
|
+
return e;
|
|
239
250
|
};
|
|
240
|
-
const getMatches = (
|
|
251
|
+
const getMatches = (e, path) => {
|
|
241
252
|
const matches = [];
|
|
242
|
-
for (const [n2, p2] of Editor.levels(
|
|
243
|
-
const key = DOMEditor.findKey(
|
|
253
|
+
for (const [n2, p2] of Editor.levels(e, { at: path })) {
|
|
254
|
+
const key = DOMEditor.findKey(e, n2);
|
|
244
255
|
matches.push([p2, key]);
|
|
245
256
|
}
|
|
246
257
|
return matches;
|
|
@@ -257,7 +268,10 @@ const isDecorationFlagsEqual = (range, other) => {
|
|
|
257
268
|
);
|
|
258
269
|
};
|
|
259
270
|
const isElementDecorationsEqual = (list, another) => {
|
|
260
|
-
if (list
|
|
271
|
+
if (list === another) {
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
if (!list || !another) {
|
|
261
275
|
return false;
|
|
262
276
|
}
|
|
263
277
|
for (let i = 0; i < list.length; i++) {
|
|
@@ -270,6 +284,12 @@ const isElementDecorationsEqual = (list, another) => {
|
|
|
270
284
|
return true;
|
|
271
285
|
};
|
|
272
286
|
const isTextDecorationsEqual = (list, another) => {
|
|
287
|
+
if (list === another) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
if (!list || !another) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
273
293
|
if (list.length !== another.length) {
|
|
274
294
|
return false;
|
|
275
295
|
}
|
|
@@ -282,50 +302,92 @@ const isTextDecorationsEqual = (list, another) => {
|
|
|
282
302
|
}
|
|
283
303
|
return true;
|
|
284
304
|
};
|
|
305
|
+
const splitDecorationsByChild = (editor, node, decorations) => {
|
|
306
|
+
const decorationsByChild = Array.from(
|
|
307
|
+
node.children,
|
|
308
|
+
() => []
|
|
309
|
+
);
|
|
310
|
+
if (decorations.length === 0) {
|
|
311
|
+
return decorationsByChild;
|
|
312
|
+
}
|
|
313
|
+
const path = DOMEditor.findPath(editor, node);
|
|
314
|
+
const level = path.length;
|
|
315
|
+
const ancestorRange = Editor.range(editor, path);
|
|
316
|
+
const cachedChildRanges = new Array(node.children.length);
|
|
317
|
+
const getChildRange = (index) => {
|
|
318
|
+
const cachedRange = cachedChildRanges[index];
|
|
319
|
+
if (cachedRange) return cachedRange;
|
|
320
|
+
const childRange = Editor.range(editor, [...path, index]);
|
|
321
|
+
cachedChildRanges[index] = childRange;
|
|
322
|
+
return childRange;
|
|
323
|
+
};
|
|
324
|
+
for (const decoration of decorations) {
|
|
325
|
+
const decorationRange = Range.intersection(ancestorRange, decoration);
|
|
326
|
+
if (!decorationRange) continue;
|
|
327
|
+
const [startPoint, endPoint] = Range.edges(decorationRange);
|
|
328
|
+
const startIndex = startPoint.path[level];
|
|
329
|
+
const endIndex = endPoint.path[level];
|
|
330
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
331
|
+
const ds = decorationsByChild[i];
|
|
332
|
+
if (!ds) continue;
|
|
333
|
+
const childRange = getChildRange(i);
|
|
334
|
+
const childDecorationRange = Range.intersection(childRange, decoration);
|
|
335
|
+
if (!childDecorationRange) continue;
|
|
336
|
+
ds.push({
|
|
337
|
+
...decoration,
|
|
338
|
+
...childDecorationRange
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return decorationsByChild;
|
|
343
|
+
};
|
|
285
344
|
export {
|
|
286
345
|
C as CAN_USE_DOM,
|
|
287
346
|
DOMEditor,
|
|
288
|
-
|
|
347
|
+
J as EDITOR_TO_ELEMENT,
|
|
289
348
|
EDITOR_TO_KEY_TO_ELEMENT,
|
|
290
349
|
EDITOR_TO_ON_CHANGE,
|
|
291
350
|
EDITOR_TO_USER_MARKS,
|
|
292
351
|
EDITOR_TO_USER_SELECTION,
|
|
293
|
-
|
|
294
|
-
|
|
352
|
+
L as EDITOR_TO_WINDOW,
|
|
353
|
+
M as ELEMENT_TO_NODE,
|
|
295
354
|
H as HAS_BEFORE_INPUT_SUPPORT,
|
|
296
|
-
|
|
355
|
+
F as Hotkeys,
|
|
297
356
|
I as IS_ANDROID,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
357
|
+
v as IS_CHROME,
|
|
358
|
+
O as IS_COMPOSING,
|
|
359
|
+
w as IS_FIREFOX,
|
|
360
|
+
x as IS_FIREFOX_LEGACY,
|
|
361
|
+
P as IS_FOCUSED,
|
|
362
|
+
y as IS_IOS,
|
|
363
|
+
Q as IS_READ_ONLY,
|
|
364
|
+
A as IS_UC_MOBILE,
|
|
365
|
+
z as IS_WEBKIT,
|
|
366
|
+
B as IS_WECHATBROWSER,
|
|
367
|
+
G as KEY_TO_CHUNK_TREE,
|
|
308
368
|
K as Key,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
369
|
+
R as MARK_PLACEHOLDER_SYMBOL,
|
|
370
|
+
S as NODE_TO_ELEMENT,
|
|
371
|
+
T as NODE_TO_INDEX,
|
|
312
372
|
NODE_TO_KEY,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
j as
|
|
318
|
-
k as
|
|
319
|
-
l as
|
|
320
|
-
m as
|
|
321
|
-
o as
|
|
322
|
-
p as
|
|
323
|
-
q as
|
|
373
|
+
U as NODE_TO_PARENT,
|
|
374
|
+
f as applyStringDiff,
|
|
375
|
+
h as getActiveElement,
|
|
376
|
+
getChunkTreeForNode,
|
|
377
|
+
j as getDefaultView,
|
|
378
|
+
k as getSelection,
|
|
379
|
+
l as hasShadowRoot,
|
|
380
|
+
m as isAfter,
|
|
381
|
+
o as isBefore,
|
|
382
|
+
p as isDOMElement,
|
|
383
|
+
q as isDOMNode,
|
|
384
|
+
r as isDOMSelection,
|
|
324
385
|
isElementDecorationsEqual,
|
|
325
|
-
|
|
386
|
+
s as isPlainTextOnlyPaste,
|
|
326
387
|
isTextDecorationsEqual,
|
|
327
|
-
|
|
328
|
-
|
|
388
|
+
t as isTrackedMutation,
|
|
389
|
+
u as normalizeDOMPoint,
|
|
329
390
|
n as normalizeStringDiff,
|
|
391
|
+
splitDecorationsByChild,
|
|
330
392
|
withDOM
|
|
331
393
|
};
|
package/dist/history.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as isObject, O as Operation, t as toRawWeakMap, E as Editor, c as Transforms, P as Path } from "./batch-dirty-paths-
|
|
1
|
+
import { d as isObject, O as Operation, t as toRawWeakMap, E as Editor, c as Transforms, P as Path } from "./batch-dirty-paths-DTifjYae.js";
|
|
2
2
|
import "vue";
|
|
3
3
|
const History = {
|
|
4
4
|
/**
|