slate-vue3 0.9.3 → 0.10.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/core.js +1 -1
- package/dist/{create-editor-Dbw6QgKv.js → create-editor-Dd3Wr7C9.js} +16 -22
- package/dist/dom.js +54 -39
- package/dist/{hotkeys-D3-bttRz.js → hotkeys-BOpYjXBU.js} +43 -41
- package/dist/hyperscript.js +1 -1
- package/dist/index.js +3 -3
- package/dist/slate/interfaces/editor.d.ts +3 -0
- package/dist/slate/utils/weak-maps.d.ts +0 -1
- package/dist/slate-dom/chunking/children-helper.d.ts +1 -1
- package/dist/slate-dom/chunking/reconcile-children.d.ts +1 -1
- package/dist/slate-dom/index.d.ts +1 -1
- package/dist/slate-dom/utils/weak-maps.d.ts +6 -0
- package/dist/slate-vue/components/children.d.ts +2 -2
- package/dist/slate-vue/hooks/use-render.d.ts +7 -2
- package/dist/slate-vue/utils/constants.d.ts +2 -1
- package/dist/{use-focused-C1iTOdlV.js → use-focused-P2l4TlLn.js} +144 -123
- package/dist/yjs.js +2 -2
- package/package.json +7 -7
- package/dist/slate-vue/hooks/use-decorate.d.ts +0 -5
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-Dd3Wr7C9.js";
|
|
2
2
|
import { E as E2, a as a10, I as I2, 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 "./index-Bj4hXlPm.js";
|
|
3
3
|
import { L as L2, S as S3 } from "./location-Ca0TF-GI.js";
|
|
4
4
|
export {
|
|
@@ -40,13 +40,6 @@ const RangeRef = {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
const DIRTY_PATHS = /* @__PURE__ */ new WeakMap();
|
|
44
|
-
const DIRTY_PATH_KEYS = /* @__PURE__ */ new WeakMap();
|
|
45
|
-
const FLUSHING = /* @__PURE__ */ new WeakMap();
|
|
46
|
-
const NORMALIZING = /* @__PURE__ */ new WeakMap();
|
|
47
|
-
const PATH_REFS = /* @__PURE__ */ new WeakMap();
|
|
48
|
-
const POINT_REFS = /* @__PURE__ */ new WeakMap();
|
|
49
|
-
const RANGE_REFS = /* @__PURE__ */ new WeakMap();
|
|
50
43
|
const matchPath = (editor, path2) => {
|
|
51
44
|
const [node2] = Editor.node(editor, path2);
|
|
52
45
|
return (n) => n === node2;
|
|
@@ -299,6 +292,12 @@ const endsWithOddNumberOfRIs = (str) => {
|
|
|
299
292
|
return numRIs % 2 === 1;
|
|
300
293
|
}
|
|
301
294
|
};
|
|
295
|
+
const DIRTY_PATHS = /* @__PURE__ */ new WeakMap();
|
|
296
|
+
const DIRTY_PATH_KEYS = /* @__PURE__ */ new WeakMap();
|
|
297
|
+
const NORMALIZING = /* @__PURE__ */ new WeakMap();
|
|
298
|
+
const PATH_REFS = /* @__PURE__ */ new WeakMap();
|
|
299
|
+
const POINT_REFS = /* @__PURE__ */ new WeakMap();
|
|
300
|
+
const RANGE_REFS = /* @__PURE__ */ new WeakMap();
|
|
302
301
|
const BATCHING_DIRTY_PATHS = /* @__PURE__ */ new WeakMap();
|
|
303
302
|
const isBatchingDirtyPaths = (editor) => {
|
|
304
303
|
return BATCHING_DIRTY_PATHS.get(editor) || false;
|
|
@@ -366,14 +365,11 @@ const apply = (editor, op) => {
|
|
|
366
365
|
if (op.type === "set_selection") {
|
|
367
366
|
editor.marks = null;
|
|
368
367
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
editor.operations = [];
|
|
375
|
-
});
|
|
376
|
-
}
|
|
368
|
+
editor.onImmediateChange({ operation: op });
|
|
369
|
+
Promise.resolve().then(() => {
|
|
370
|
+
editor.onChange({ operation: op });
|
|
371
|
+
editor.operations = [];
|
|
372
|
+
});
|
|
377
373
|
};
|
|
378
374
|
const getDirtyPaths = (editor, op) => {
|
|
379
375
|
switch (op.type) {
|
|
@@ -587,9 +583,7 @@ const addMark = (editor, key, value) => {
|
|
|
587
583
|
[key]: value
|
|
588
584
|
};
|
|
589
585
|
editor.marks = marks2;
|
|
590
|
-
|
|
591
|
-
editor.onChange();
|
|
592
|
-
}
|
|
586
|
+
editor.onChange();
|
|
593
587
|
}
|
|
594
588
|
}
|
|
595
589
|
};
|
|
@@ -1288,7 +1282,7 @@ const removeMark = (editor, key) => {
|
|
|
1288
1282
|
if (!Text.isText(node2)) {
|
|
1289
1283
|
return false;
|
|
1290
1284
|
}
|
|
1291
|
-
const [parentNode
|
|
1285
|
+
const [parentNode] = Editor.parent(editor, path2);
|
|
1292
1286
|
return !editor.isVoid(parentNode) || editor.markableVoid(parentNode);
|
|
1293
1287
|
};
|
|
1294
1288
|
const expandedSelection = Range.isExpanded(selection);
|
|
@@ -1310,9 +1304,7 @@ const removeMark = (editor, key) => {
|
|
|
1310
1304
|
const marks2 = { ...Editor.marks(editor) || {} };
|
|
1311
1305
|
delete marks2[key];
|
|
1312
1306
|
editor.marks = marks2;
|
|
1313
|
-
|
|
1314
|
-
editor.onChange();
|
|
1315
|
-
}
|
|
1307
|
+
editor.onChange();
|
|
1316
1308
|
}
|
|
1317
1309
|
}
|
|
1318
1310
|
};
|
|
@@ -2481,6 +2473,8 @@ const createEditor = () => {
|
|
|
2481
2473
|
markableVoid: () => false,
|
|
2482
2474
|
onChange: () => {
|
|
2483
2475
|
},
|
|
2476
|
+
onImmediateChange: () => {
|
|
2477
|
+
},
|
|
2484
2478
|
// Core
|
|
2485
2479
|
apply: (...args) => apply(editor, ...args),
|
|
2486
2480
|
// Editor
|
package/dist/dom.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
-
import { C,
|
|
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, f as EDITOR_TO_ON_IMMEDIATE_CHANGE } from "./hotkeys-BOpYjXBU.js";
|
|
2
|
+
import { C, P, Q, R, H, K, I, y, S, z, A, T, B, U, G, F, J, O, L, V, W, X, Y, h, j, k, l, m, o, p, q, r, s, t, u, v, w, x, n, M } from "./hotkeys-BOpYjXBU.js";
|
|
3
3
|
import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./index-Bj4hXlPm.js";
|
|
4
4
|
import "vue";
|
|
5
5
|
const doRectsIntersect = (rect, compareRect) => {
|
|
@@ -47,7 +47,14 @@ const findCurrentLineRange = (editor, parentRange) => {
|
|
|
47
47
|
};
|
|
48
48
|
const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
49
49
|
const e = editor;
|
|
50
|
-
const {
|
|
50
|
+
const {
|
|
51
|
+
apply,
|
|
52
|
+
onChange,
|
|
53
|
+
onImmediateChange,
|
|
54
|
+
deleteBackward,
|
|
55
|
+
addMark,
|
|
56
|
+
removeMark
|
|
57
|
+
} = e;
|
|
51
58
|
EDITOR_TO_KEY_TO_ELEMENT.set(e, /* @__PURE__ */ new WeakMap());
|
|
52
59
|
e.addMark = (key, value) => {
|
|
53
60
|
EDITOR_TO_USER_MARKS.delete(e);
|
|
@@ -245,6 +252,13 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
|
|
|
245
252
|
}
|
|
246
253
|
onChange(options);
|
|
247
254
|
};
|
|
255
|
+
e.onImmediateChange = (options) => {
|
|
256
|
+
const onContextImmediateChange = EDITOR_TO_ON_IMMEDIATE_CHANGE.get(e);
|
|
257
|
+
if (onContextImmediateChange) {
|
|
258
|
+
onContextImmediateChange(options);
|
|
259
|
+
}
|
|
260
|
+
onImmediateChange(options);
|
|
261
|
+
};
|
|
248
262
|
return e;
|
|
249
263
|
};
|
|
250
264
|
const getMatches = (e, path) => {
|
|
@@ -340,53 +354,54 @@ const splitDecorationsByChild = (editor, node, decorations) => {
|
|
|
340
354
|
export {
|
|
341
355
|
C as CAN_USE_DOM,
|
|
342
356
|
DOMEditor,
|
|
343
|
-
|
|
357
|
+
P as EDITOR_TO_ELEMENT,
|
|
344
358
|
EDITOR_TO_KEY_TO_ELEMENT,
|
|
345
359
|
EDITOR_TO_ON_CHANGE,
|
|
360
|
+
EDITOR_TO_ON_IMMEDIATE_CHANGE,
|
|
346
361
|
EDITOR_TO_USER_MARKS,
|
|
347
362
|
EDITOR_TO_USER_SELECTION,
|
|
348
|
-
|
|
349
|
-
|
|
363
|
+
Q as EDITOR_TO_WINDOW,
|
|
364
|
+
R as ELEMENT_TO_NODE,
|
|
350
365
|
H as HAS_BEFORE_INPUT_SUPPORT,
|
|
351
|
-
|
|
366
|
+
K as Hotkeys,
|
|
352
367
|
I as IS_ANDROID,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
+
y as IS_CHROME,
|
|
369
|
+
S as IS_COMPOSING,
|
|
370
|
+
z as IS_FIREFOX,
|
|
371
|
+
A as IS_FIREFOX_LEGACY,
|
|
372
|
+
T as IS_FOCUSED,
|
|
373
|
+
B as IS_IOS,
|
|
374
|
+
U as IS_READ_ONLY,
|
|
375
|
+
G as IS_UC_MOBILE,
|
|
376
|
+
F as IS_WEBKIT,
|
|
377
|
+
J as IS_WECHATBROWSER,
|
|
378
|
+
O as KEY_TO_CHUNK_TREE,
|
|
379
|
+
L as Key,
|
|
380
|
+
V as MARK_PLACEHOLDER_SYMBOL,
|
|
381
|
+
W as NODE_TO_ELEMENT,
|
|
382
|
+
X as NODE_TO_INDEX,
|
|
368
383
|
NODE_TO_KEY,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
384
|
+
Y as NODE_TO_PARENT,
|
|
385
|
+
h as applyStringDiff,
|
|
386
|
+
j as closestShadowAware,
|
|
387
|
+
k as containsShadowAware,
|
|
388
|
+
l as getActiveElement,
|
|
374
389
|
getChunkTreeForNode,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
390
|
+
m as getDefaultView,
|
|
391
|
+
o as getSelection,
|
|
392
|
+
p as hasShadowRoot,
|
|
393
|
+
q as isAfter,
|
|
394
|
+
r as isBefore,
|
|
395
|
+
s as isDOMElement,
|
|
396
|
+
t as isDOMNode,
|
|
397
|
+
u as isDOMSelection,
|
|
383
398
|
isElementDecorationsEqual,
|
|
384
|
-
|
|
399
|
+
v as isPlainTextOnlyPaste,
|
|
385
400
|
isTextDecorationsEqual,
|
|
386
|
-
|
|
387
|
-
|
|
401
|
+
w as isTrackedMutation,
|
|
402
|
+
x as normalizeDOMPoint,
|
|
388
403
|
n as normalizeStringDiff,
|
|
389
|
-
|
|
404
|
+
M as reconcileChildren,
|
|
390
405
|
splitDecorationsByChild,
|
|
391
406
|
withDOM
|
|
392
407
|
};
|
|
@@ -248,6 +248,7 @@ const IS_FOCUSED = /* @__PURE__ */ new WeakMap();
|
|
|
248
248
|
const IS_COMPOSING = /* @__PURE__ */ new WeakMap();
|
|
249
249
|
const EDITOR_TO_USER_SELECTION = /* @__PURE__ */ new WeakMap();
|
|
250
250
|
const EDITOR_TO_ON_CHANGE = /* @__PURE__ */ new WeakMap();
|
|
251
|
+
const EDITOR_TO_ON_IMMEDIATE_CHANGE = /* @__PURE__ */ new WeakMap();
|
|
251
252
|
const EDITOR_TO_USER_MARKS = /* @__PURE__ */ new WeakMap();
|
|
252
253
|
const MARK_PLACEHOLDER_SYMBOL = Symbol(
|
|
253
254
|
"mark-placeholder"
|
|
@@ -1202,10 +1203,10 @@ class ChildrenHelper {
|
|
|
1202
1203
|
* The index of the next node to be read in the children array
|
|
1203
1204
|
*/
|
|
1204
1205
|
pointerIndex;
|
|
1205
|
-
constructor(editor) {
|
|
1206
|
+
constructor(editor, children) {
|
|
1206
1207
|
this.editor = editor;
|
|
1207
|
-
this.children =
|
|
1208
|
-
this.cachedKeys = new Array(
|
|
1208
|
+
this.children = children;
|
|
1209
|
+
this.cachedKeys = new Array(children.length);
|
|
1209
1210
|
this.pointerIndex = 0;
|
|
1210
1211
|
}
|
|
1211
1212
|
/**
|
|
@@ -1285,7 +1286,7 @@ class ChildrenHelper {
|
|
|
1285
1286
|
return key;
|
|
1286
1287
|
}
|
|
1287
1288
|
}
|
|
1288
|
-
const reconcileChildren = (editor, {
|
|
1289
|
+
const reconcileChildren = (editor, children, {
|
|
1289
1290
|
chunkTree,
|
|
1290
1291
|
chunkSize,
|
|
1291
1292
|
onInsert,
|
|
@@ -1294,7 +1295,7 @@ const reconcileChildren = (editor, {
|
|
|
1294
1295
|
debug
|
|
1295
1296
|
}) => {
|
|
1296
1297
|
const chunkTreeHelper = new ChunkTreeHelper(chunkTree, { chunkSize, debug });
|
|
1297
|
-
const childrenHelper = new ChildrenHelper(editor);
|
|
1298
|
+
const childrenHelper = new ChildrenHelper(editor, children);
|
|
1298
1299
|
let treeLeaf;
|
|
1299
1300
|
while (treeLeaf = chunkTreeHelper.readLeaf()) {
|
|
1300
1301
|
const lookAhead = childrenHelper.lookAhead(treeLeaf.node, treeLeaf.key);
|
|
@@ -1664,54 +1665,55 @@ const Hotkeys = {
|
|
|
1664
1665
|
isUndo: create("undo")
|
|
1665
1666
|
};
|
|
1666
1667
|
export {
|
|
1667
|
-
|
|
1668
|
-
|
|
1668
|
+
IS_FIREFOX_LEGACY as A,
|
|
1669
|
+
IS_IOS as B,
|
|
1669
1670
|
CAN_USE_DOM as C,
|
|
1670
1671
|
DOMEditor as D,
|
|
1671
1672
|
EDITOR_TO_KEY_TO_ELEMENT as E,
|
|
1672
|
-
|
|
1673
|
-
|
|
1673
|
+
IS_WEBKIT as F,
|
|
1674
|
+
IS_UC_MOBILE as G,
|
|
1674
1675
|
HAS_BEFORE_INPUT_SUPPORT as H,
|
|
1675
1676
|
IS_ANDROID as I,
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1677
|
+
IS_WECHATBROWSER as J,
|
|
1678
|
+
Hotkeys as K,
|
|
1679
|
+
Key as L,
|
|
1680
|
+
reconcileChildren as M,
|
|
1680
1681
|
NODE_TO_KEY as N,
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1682
|
+
KEY_TO_CHUNK_TREE as O,
|
|
1683
|
+
EDITOR_TO_ELEMENT as P,
|
|
1684
|
+
EDITOR_TO_WINDOW as Q,
|
|
1685
|
+
ELEMENT_TO_NODE as R,
|
|
1686
|
+
IS_COMPOSING as S,
|
|
1687
|
+
IS_FOCUSED as T,
|
|
1688
|
+
IS_READ_ONLY as U,
|
|
1689
|
+
MARK_PLACEHOLDER_SYMBOL as V,
|
|
1690
|
+
NODE_TO_ELEMENT as W,
|
|
1691
|
+
NODE_TO_INDEX as X,
|
|
1692
|
+
NODE_TO_PARENT as Y,
|
|
1691
1693
|
EDITOR_TO_USER_MARKS as a,
|
|
1692
1694
|
EDITOR_TO_USER_SELECTION as b,
|
|
1693
1695
|
getPlainText as c,
|
|
1694
1696
|
getSlateFragmentAttribute as d,
|
|
1695
1697
|
EDITOR_TO_ON_CHANGE as e,
|
|
1696
|
-
|
|
1698
|
+
EDITOR_TO_ON_IMMEDIATE_CHANGE as f,
|
|
1697
1699
|
getChunkTreeForNode as g,
|
|
1698
|
-
|
|
1700
|
+
applyStringDiff as h,
|
|
1699
1701
|
isDOMText as i,
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1702
|
+
closestShadowAware as j,
|
|
1703
|
+
containsShadowAware as k,
|
|
1704
|
+
getActiveElement as l,
|
|
1705
|
+
getDefaultView as m,
|
|
1704
1706
|
normalizeStringDiff as n,
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1707
|
+
getSelection as o,
|
|
1708
|
+
hasShadowRoot as p,
|
|
1709
|
+
isAfter as q,
|
|
1710
|
+
isBefore as r,
|
|
1711
|
+
isDOMElement as s,
|
|
1712
|
+
isDOMNode as t,
|
|
1713
|
+
isDOMSelection as u,
|
|
1714
|
+
isPlainTextOnlyPaste as v,
|
|
1715
|
+
isTrackedMutation as w,
|
|
1716
|
+
normalizeDOMPoint as x,
|
|
1717
|
+
IS_CHROME as y,
|
|
1718
|
+
IS_FIREFOX as z
|
|
1717
1719
|
};
|
package/dist/hyperscript.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { R as Range, N as Node, T as Text, a as Element, d as isObject } from "./index-Bj4hXlPm.js";
|
|
2
|
-
import { c as createEditor$1 } from "./create-editor-
|
|
2
|
+
import { c as createEditor$1 } from "./create-editor-Dd3Wr7C9.js";
|
|
3
3
|
import "vue";
|
|
4
4
|
import { t as toRawWeakMap } from "./index-Ban80MbP.js";
|
|
5
5
|
const ANCHOR = new toRawWeakMap();
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as SLATE_USE_ELEMENT, u as useEditor, a as SLATE_USE_SELECTION } from "./use-focused-
|
|
2
|
-
import { e, h, D, c, f, g, d, E, b, i, j, k } from "./use-focused-
|
|
1
|
+
import { S as SLATE_USE_ELEMENT, u as useEditor, a as SLATE_USE_SELECTION } from "./use-focused-P2l4TlLn.js";
|
|
2
|
+
import { e, h, D, c, f, g, d, E, b, i, j, k } from "./use-focused-P2l4TlLn.js";
|
|
3
3
|
import { E as Editor, R as Range } from "./index-Bj4hXlPm.js";
|
|
4
4
|
import { inject, computed } from "vue";
|
|
5
|
-
import { D as DOMEditor } from "./hotkeys-
|
|
5
|
+
import { D as DOMEditor } from "./hotkeys-BOpYjXBU.js";
|
|
6
6
|
import { t } from "./index-Ban80MbP.js";
|
|
7
7
|
const useElement = () => {
|
|
8
8
|
const element = inject(SLATE_USE_ELEMENT);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Editor, Path, PathRef, PointRef, RangeRef } from '..';
|
|
2
2
|
export declare const DIRTY_PATHS: WeakMap<Editor, Path[]>;
|
|
3
3
|
export declare const DIRTY_PATH_KEYS: WeakMap<Editor, Set<string>>;
|
|
4
|
-
export declare const FLUSHING: WeakMap<Editor, boolean>;
|
|
5
4
|
export declare const NORMALIZING: WeakMap<Editor, boolean>;
|
|
6
5
|
export declare const PATH_REFS: WeakMap<Editor, Set<PathRef>>;
|
|
7
6
|
export declare const POINT_REFS: WeakMap<Editor, Set<PointRef>>;
|
|
@@ -19,7 +19,7 @@ export declare class ChildrenHelper {
|
|
|
19
19
|
* The index of the next node to be read in the children array
|
|
20
20
|
*/
|
|
21
21
|
pointerIndex: number;
|
|
22
|
-
constructor(editor: DOMEditor);
|
|
22
|
+
constructor(editor: DOMEditor, children: Descendant[]);
|
|
23
23
|
/**
|
|
24
24
|
* Read a given number of nodes, advancing the pointer by that amount
|
|
25
25
|
*/
|
|
@@ -14,4 +14,4 @@ export interface ReconcileOptions extends ChunkTreeHelperOptions {
|
|
|
14
14
|
* Update the chunk tree to match the children array, inserting, removing and
|
|
15
15
|
* updating differing nodes
|
|
16
16
|
*/
|
|
17
|
-
export declare const reconcileChildren: (editor: DOMEditor, { chunkTree, chunkSize, onInsert, onUpdate, onIndexChange, debug, }: ReconcileOptions) => void;
|
|
17
|
+
export declare const reconcileChildren: (editor: DOMEditor, children: Descendant[], { chunkTree, chunkSize, onInsert, onUpdate, onIndexChange, debug, }: ReconcileOptions) => void;
|
|
@@ -8,4 +8,4 @@ export { Hotkeys } from './utils/hotkeys';
|
|
|
8
8
|
export { Key } from './utils/key';
|
|
9
9
|
export { isElementDecorationsEqual, isTextDecorationsEqual, splitDecorationsByChild, } from './utils/range-list';
|
|
10
10
|
export { getChunkTreeForNode, reconcileChildren, KEY_TO_CHUNK_TREE, type ChunkAncestor, type ChunkTree, type ChunkLeaf, type ChunkNode, type ChunkDescendant, type Chunk, type ReconcileOptions, } from './chunking';
|
|
11
|
-
export { EDITOR_TO_ELEMENT, EDITOR_TO_KEY_TO_ELEMENT, EDITOR_TO_ON_CHANGE, EDITOR_TO_USER_MARKS, EDITOR_TO_USER_SELECTION, EDITOR_TO_WINDOW, ELEMENT_TO_NODE, IS_COMPOSING, IS_FOCUSED, IS_READ_ONLY, MARK_PLACEHOLDER_SYMBOL, NODE_TO_ELEMENT, NODE_TO_INDEX, NODE_TO_KEY, NODE_TO_PARENT, } from './utils/weak-maps';
|
|
11
|
+
export { EDITOR_TO_ELEMENT, EDITOR_TO_KEY_TO_ELEMENT, EDITOR_TO_ON_CHANGE, EDITOR_TO_ON_IMMEDIATE_CHANGE, EDITOR_TO_USER_MARKS, EDITOR_TO_USER_SELECTION, EDITOR_TO_WINDOW, ELEMENT_TO_NODE, IS_COMPOSING, IS_FOCUSED, IS_READ_ONLY, MARK_PLACEHOLDER_SYMBOL, NODE_TO_ELEMENT, NODE_TO_INDEX, NODE_TO_KEY, NODE_TO_PARENT, } from './utils/weak-maps';
|
|
@@ -33,5 +33,11 @@ export declare const EDITOR_TO_USER_SELECTION: WeakMap<Editor, RangeRef | null>;
|
|
|
33
33
|
export declare const EDITOR_TO_ON_CHANGE: WeakMap<import('../../slate/index.ts').BaseEditor, (options?: {
|
|
34
34
|
operation?: Operation;
|
|
35
35
|
}) => void>;
|
|
36
|
+
/**
|
|
37
|
+
* Weak map for trigger chunk tree reconciliation on immediate changes.
|
|
38
|
+
*/
|
|
39
|
+
export declare const EDITOR_TO_ON_IMMEDIATE_CHANGE: WeakMap<import('../../slate/index.ts').BaseEditor, (options?: {
|
|
40
|
+
operation?: Operation;
|
|
41
|
+
}) => void>;
|
|
36
42
|
export declare const EDITOR_TO_USER_MARKS: WeakMap<Editor, Partial<Text> | null>;
|
|
37
43
|
export declare const MARK_PLACEHOLDER_SYMBOL: string;
|
|
@@ -5,8 +5,8 @@ import { VNode } from 'vue';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const ChildrenComp: import('vue').DefineComponent<{
|
|
7
7
|
element: Ancestor;
|
|
8
|
-
}, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
8
|
+
}, (() => import('vue').VNodeChild[]) | (() => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
9
9
|
[key: string]: any;
|
|
10
|
-
}>
|
|
10
|
+
}>), {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
11
11
|
element: Ancestor;
|
|
12
12
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { ComputedRef, Ref, VNode } from 'vue';
|
|
2
2
|
import { RenderElementProps, RenderPlaceholderProps, RenderLeafProps, RenderTextProps, RenderChunkProps } from '../utils/interface';
|
|
3
|
-
import { BasePoint } from '../../slate/index.ts';
|
|
3
|
+
import { BasePoint, DecoratedRange, NodeEntry } from '../../slate/index.ts';
|
|
4
4
|
import { ChunkTree } from '../../slate-dom/index.ts';
|
|
5
5
|
export declare const useRenderElement: () => (props: RenderElementProps) => VNode;
|
|
6
6
|
export declare const useRenderLeaf: () => (props: RenderLeafProps) => VNode;
|
|
7
7
|
export declare const useRenderPlaceholder: () => (props: RenderPlaceholderProps) => VNode;
|
|
8
8
|
export declare const useRenderText: () => (props: RenderTextProps) => VNode;
|
|
9
9
|
export declare const useRenderChunk: () => (props: RenderChunkProps) => VNode;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current `decorate` prop of the editable.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useDecorate: () => ((entry: NodeEntry) => DecoratedRange[]);
|
|
10
14
|
export declare const useChunkRoot: () => ChunkTree;
|
|
11
|
-
export declare const
|
|
15
|
+
export declare const useEditorVersion: () => Ref<number, number>;
|
|
16
|
+
export declare const useEditorNodeVersion: () => Ref<number, number>;
|
|
12
17
|
export declare const useMarkPlaceholder: () => ComputedRef<{
|
|
13
18
|
anchor: BasePoint;
|
|
14
19
|
focus: BasePoint;
|
|
@@ -11,7 +11,8 @@ export declare const SLATE_INNER_RENDER_TEXT: unique symbol;
|
|
|
11
11
|
export declare const SLATE_INNER_RENDER_CHUNK: unique symbol;
|
|
12
12
|
export declare const SLATE_INNER_STATIC_CHUNK_ROOT: unique symbol;
|
|
13
13
|
export declare const SLATE_INNER_RENDER_DECORATE: unique symbol;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const SLATE_INNER_EDITOR_VERSION: unique symbol;
|
|
15
|
+
export declare const SLATE_INNER_EDITOR_NODE_VERSION: unique symbol;
|
|
15
16
|
export declare const SLATE_INNER_MARK_PLACEHOLDER: unique symbol;
|
|
16
17
|
export declare const SLATE_INNER_PLACEHOLDER: unique symbol;
|
|
17
18
|
export declare const SLATE_INNER_PLACEHOLDER_SHOW: unique symbol;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { h, defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject,
|
|
1
|
+
import { h, defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject, renderList, watch, onUpdated, useAttrs, reactive, toRaw } from "vue";
|
|
2
2
|
import { R as Range, N as Node, S as Scrubber, T as Text, P as Path, E as Editor, a as Element, c as Transforms } from "./index-Bj4hXlPm.js";
|
|
3
|
-
import { I as IS_ANDROID,
|
|
3
|
+
import { I as IS_ANDROID, t as isDOMNode, D as DOMEditor, V as MARK_PLACEHOLDER_SYMBOL, e as EDITOR_TO_ON_CHANGE, f as EDITOR_TO_ON_IMMEDIATE_CHANGE, z as IS_FIREFOX, F as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, R as ELEMENT_TO_NODE, W as NODE_TO_ELEMENT, X as NODE_TO_INDEX, Y as NODE_TO_PARENT, g as getChunkTreeForNode, M as reconcileChildren, h as applyStringDiff, u as isDOMSelection, n as normalizeStringDiff, U as IS_READ_ONLY, m as getDefaultView, Q as EDITOR_TO_WINDOW, P as EDITOR_TO_ELEMENT, o as getSelection, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, k as containsShadowAware, l as getActiveElement, T as IS_FOCUSED, v as isPlainTextOnlyPaste, S as IS_COMPOSING, K as Hotkeys, y as IS_CHROME, A as IS_FIREFOX_LEGACY, B as IS_IOS, J as IS_WECHATBROWSER, G as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, s as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-BOpYjXBU.js";
|
|
4
4
|
const SLATE_USE_EDITOR = Symbol("SLATE_USE_EDITOR");
|
|
5
5
|
const SLATE_USE_ELEMENT = Symbol("SLATE_USE_ELEMENT");
|
|
6
6
|
const SLATE_USE_FOCUSED = Symbol("SLATE_USE_FOCUSED");
|
|
@@ -20,8 +20,9 @@ const SLATE_INNER_STATIC_CHUNK_ROOT = Symbol(
|
|
|
20
20
|
const SLATE_INNER_RENDER_DECORATE = Symbol(
|
|
21
21
|
"SLATE_INNER_RENDER_DECORATE"
|
|
22
22
|
);
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const SLATE_INNER_EDITOR_VERSION = Symbol("SLATE_INNER_EDITOR_VERSION");
|
|
24
|
+
const SLATE_INNER_EDITOR_NODE_VERSION = Symbol(
|
|
25
|
+
"SLATE_INNER_EDITOR_NODE_VERSION"
|
|
25
26
|
);
|
|
26
27
|
const SLATE_INNER_MARK_PLACEHOLDER = Symbol(
|
|
27
28
|
"SLATE_INNER_MARK_PLACEHOLDER"
|
|
@@ -255,8 +256,10 @@ const Slate = defineComponent({
|
|
|
255
256
|
provide(SLATE_USE_READ_ONLY, ref(false));
|
|
256
257
|
provide(SLATE_USE_SELECTION, selection);
|
|
257
258
|
const focusCb = () => isFocus.value = DOMEditor.isFocused(editor);
|
|
258
|
-
const
|
|
259
|
-
|
|
259
|
+
const editorVersion = ref(0);
|
|
260
|
+
const editorNodeVersion = ref(0);
|
|
261
|
+
provide(SLATE_INNER_EDITOR_VERSION, editorVersion);
|
|
262
|
+
provide(SLATE_INNER_EDITOR_NODE_VERSION, editorNodeVersion);
|
|
260
263
|
const markPlaceholder = computed(() => {
|
|
261
264
|
if (editor.selection && Range.isCollapsed(editor.selection) && editor.marks) {
|
|
262
265
|
const anchor = editor.selection.anchor;
|
|
@@ -283,7 +286,7 @@ const Slate = defineComponent({
|
|
|
283
286
|
document.addEventListener("focusout", focusCb);
|
|
284
287
|
EDITOR_TO_ON_CHANGE.set(editor, (options) => {
|
|
285
288
|
emit("change", options);
|
|
286
|
-
|
|
289
|
+
editorVersion.value++;
|
|
287
290
|
switch (options?.operation?.type) {
|
|
288
291
|
case "set_selection":
|
|
289
292
|
emit("selectionchange", options);
|
|
@@ -292,6 +295,16 @@ const Slate = defineComponent({
|
|
|
292
295
|
emit("valuechange", options);
|
|
293
296
|
}
|
|
294
297
|
});
|
|
298
|
+
EDITOR_TO_ON_IMMEDIATE_CHANGE.set(
|
|
299
|
+
editor,
|
|
300
|
+
(options) => {
|
|
301
|
+
const type = options?.operation?.type;
|
|
302
|
+
if (!type || ["set_selection", "insert_text", "remove_text"].includes(type)) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
editorNodeVersion.value++;
|
|
306
|
+
}
|
|
307
|
+
);
|
|
295
308
|
});
|
|
296
309
|
onUnmounted(() => {
|
|
297
310
|
document.removeEventListener("focusin", focusCb);
|
|
@@ -309,59 +322,6 @@ function direction(value) {
|
|
|
309
322
|
const source = String(value || "");
|
|
310
323
|
return rtl.test(source) ? "rtl" : ltr.test(source) ? "ltr" : "neutral";
|
|
311
324
|
}
|
|
312
|
-
const useDecorate = () => {
|
|
313
|
-
const decorate = inject(
|
|
314
|
-
SLATE_INNER_RENDER_DECORATE
|
|
315
|
-
);
|
|
316
|
-
if (decorate === void 0) {
|
|
317
|
-
throw new Error(
|
|
318
|
-
`The \`useDecorate\` hook must be used inside the <Slate> component's context.`
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
return decorate;
|
|
322
|
-
};
|
|
323
|
-
const useEditor = () => {
|
|
324
|
-
const editor = inject(SLATE_USE_EDITOR);
|
|
325
|
-
if (editor === void 0) {
|
|
326
|
-
throw new Error(
|
|
327
|
-
`The \`useEditor\` hook must be used inside the <Slate> component's context.`
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
return editor;
|
|
331
|
-
};
|
|
332
|
-
const StringComp = defineComponent({
|
|
333
|
-
name: "slate-string",
|
|
334
|
-
props: ["leaf", "text", "element", "isLast"],
|
|
335
|
-
setup(props) {
|
|
336
|
-
const { leaf, text, element, isLast } = props;
|
|
337
|
-
const editor = useEditor();
|
|
338
|
-
const getTextContent = computed(() => {
|
|
339
|
-
const text2 = leaf.text;
|
|
340
|
-
return (text2 ?? "") + (isLast && text2.at(-1) === "\n" ? "\n" : "");
|
|
341
|
-
});
|
|
342
|
-
const isLineBreak = computed(() => {
|
|
343
|
-
const pathParent = Path.parent(DOMEditor.findPath(editor, text));
|
|
344
|
-
return leaf.text === "" && element.children.at(-1) === text && !editor.isInline(element) && Editor.string(editor, pathParent) === "";
|
|
345
|
-
});
|
|
346
|
-
const zeroStringAttrs = computed(() => {
|
|
347
|
-
const length = Node.string(element).length || 0;
|
|
348
|
-
const isMarkPlaceholder = Boolean(leaf[MARK_PLACEHOLDER_SYMBOL]) || false;
|
|
349
|
-
const isVoidParent = editor.isVoid(element);
|
|
350
|
-
if (isVoidParent || isLineBreak.value || leaf.text === "") {
|
|
351
|
-
return {
|
|
352
|
-
"data-slate-zero-width": isLineBreak.value ? "n" : "z",
|
|
353
|
-
"data-slate-length": length,
|
|
354
|
-
"data-slate-mark-placeholder": isMarkPlaceholder ? true : void 0
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
return null;
|
|
358
|
-
});
|
|
359
|
-
return () => zeroStringAttrs.value ? h("span", zeroStringAttrs.value, [
|
|
360
|
-
!IS_ANDROID || !isLineBreak.value ? "\uFEFF" : null,
|
|
361
|
-
!IS_FIREFOX && isLineBreak.value ? h("br") : null
|
|
362
|
-
]) : h("span", { "data-slate-string": true }, getTextContent.value);
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
325
|
const useRenderElement = () => {
|
|
366
326
|
const ELEMENT_RENDER = inject(
|
|
367
327
|
SLATE_INNER_RENDER_ELEMENT
|
|
@@ -417,6 +377,17 @@ const useRenderChunk = () => {
|
|
|
417
377
|
}
|
|
418
378
|
return CHUNK_RENDER;
|
|
419
379
|
};
|
|
380
|
+
const useDecorate = () => {
|
|
381
|
+
const decorate = inject(
|
|
382
|
+
SLATE_INNER_RENDER_DECORATE
|
|
383
|
+
);
|
|
384
|
+
if (decorate === void 0) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
`The \`useDecorate\` hook must be used inside the <Slate> component's context.`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
return decorate;
|
|
390
|
+
};
|
|
420
391
|
const useChunkRoot = () => {
|
|
421
392
|
const CHUNK_STATIC_ROOT = inject(SLATE_INNER_STATIC_CHUNK_ROOT);
|
|
422
393
|
if (CHUNK_STATIC_ROOT === void 0) {
|
|
@@ -426,17 +397,25 @@ const useChunkRoot = () => {
|
|
|
426
397
|
}
|
|
427
398
|
return CHUNK_STATIC_ROOT;
|
|
428
399
|
};
|
|
429
|
-
const
|
|
430
|
-
const
|
|
431
|
-
|
|
400
|
+
const useEditorVersion = () => {
|
|
401
|
+
const EDITOR_VERSION = inject(SLATE_INNER_EDITOR_VERSION);
|
|
402
|
+
if (EDITOR_VERSION === void 0) {
|
|
403
|
+
throw new Error(
|
|
404
|
+
`The \`useEditorVersion\` hook must be used inside the <Slate> component's context.`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
return EDITOR_VERSION;
|
|
408
|
+
};
|
|
409
|
+
const useEditorNodeVersion = () => {
|
|
410
|
+
const EDITOR_NODE_VERSION = inject(
|
|
411
|
+
SLATE_INNER_EDITOR_NODE_VERSION
|
|
432
412
|
);
|
|
433
|
-
if (
|
|
413
|
+
if (EDITOR_NODE_VERSION === void 0) {
|
|
434
414
|
throw new Error(
|
|
435
|
-
`The \`
|
|
415
|
+
`The \`useEditorNodeVersion\` hook must be used inside the <Slate> component's context.`
|
|
436
416
|
);
|
|
437
417
|
}
|
|
438
|
-
|
|
439
|
-
return CHANGE_EFFECT_INJECT;
|
|
418
|
+
return EDITOR_NODE_VERSION;
|
|
440
419
|
};
|
|
441
420
|
const useMarkPlaceholder = () => {
|
|
442
421
|
const MARK_PLACEHOLDER_INJECT = inject(SLATE_INNER_MARK_PLACEHOLDER);
|
|
@@ -480,6 +459,48 @@ const usePlaceholderResize = () => {
|
|
|
480
459
|
}
|
|
481
460
|
return PLACEHOLDER_RESIZE_INJECT;
|
|
482
461
|
};
|
|
462
|
+
const useEditor = () => {
|
|
463
|
+
const editor = inject(SLATE_USE_EDITOR);
|
|
464
|
+
if (editor === void 0) {
|
|
465
|
+
throw new Error(
|
|
466
|
+
`The \`useEditor\` hook must be used inside the <Slate> component's context.`
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
return editor;
|
|
470
|
+
};
|
|
471
|
+
const StringComp = defineComponent({
|
|
472
|
+
name: "slate-string",
|
|
473
|
+
props: ["leaf", "text", "element", "isLast"],
|
|
474
|
+
setup(props) {
|
|
475
|
+
const { leaf, text, element, isLast } = props;
|
|
476
|
+
const editor = useEditor();
|
|
477
|
+
const getTextContent = computed(() => {
|
|
478
|
+
const text2 = leaf.text;
|
|
479
|
+
return (text2 ?? "") + (isLast && text2.at(-1) === "\n" ? "\n" : "");
|
|
480
|
+
});
|
|
481
|
+
const isLineBreak = computed(() => {
|
|
482
|
+
const pathParent = Path.parent(DOMEditor.findPath(editor, text));
|
|
483
|
+
return leaf.text === "" && element.children.at(-1) === text && !editor.isInline(element) && Editor.string(editor, pathParent) === "";
|
|
484
|
+
});
|
|
485
|
+
const zeroStringAttrs = computed(() => {
|
|
486
|
+
const length = Node.string(element).length || 0;
|
|
487
|
+
const isMarkPlaceholder = Boolean(leaf[MARK_PLACEHOLDER_SYMBOL]) || false;
|
|
488
|
+
const isVoidParent = editor.isVoid(element);
|
|
489
|
+
if (isVoidParent || isLineBreak.value || leaf.text === "") {
|
|
490
|
+
return {
|
|
491
|
+
"data-slate-zero-width": isLineBreak.value ? "n" : "z",
|
|
492
|
+
"data-slate-length": length,
|
|
493
|
+
"data-slate-mark-placeholder": isMarkPlaceholder ? true : void 0
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return null;
|
|
497
|
+
});
|
|
498
|
+
return () => zeroStringAttrs.value ? h("span", zeroStringAttrs.value, [
|
|
499
|
+
!IS_ANDROID || !isLineBreak.value ? "\uFEFF" : null,
|
|
500
|
+
!IS_FIREFOX && isLineBreak.value ? h("br") : null
|
|
501
|
+
]) : h("span", { "data-slate-string": true }, getTextContent.value);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
483
504
|
const style = {
|
|
484
505
|
position: "absolute",
|
|
485
506
|
top: 0,
|
|
@@ -747,56 +768,52 @@ const ChildrenComp = defineComponent({
|
|
|
747
768
|
setup(props) {
|
|
748
769
|
const editor = useEditor();
|
|
749
770
|
const element = props.element;
|
|
750
|
-
const isBlock =
|
|
751
|
-
|
|
752
|
-
)
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
onInsert: (n2, i) => {
|
|
765
|
-
NODE_TO_INDEX.set(n2, i);
|
|
766
|
-
NODE_TO_PARENT.set(n2, element);
|
|
767
|
-
},
|
|
768
|
-
onUpdate: (n2, i) => {
|
|
769
|
-
NODE_TO_INDEX.set(n2, i);
|
|
770
|
-
NODE_TO_PARENT.set(n2, element);
|
|
771
|
-
},
|
|
772
|
-
onIndexChange: (n2, i) => {
|
|
773
|
-
NODE_TO_INDEX.set(n2, i);
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
return cacheTree;
|
|
777
|
-
});
|
|
778
|
-
provide(SLATE_INNER_STATIC_CHUNK_ROOT, cacheTree);
|
|
779
|
-
return () => {
|
|
780
|
-
if (chunkSize.value === null || isBlock.value) {
|
|
781
|
-
return renderList(element.children, (n2, i) => {
|
|
782
|
-
NODE_TO_INDEX.set(n2, i);
|
|
783
|
-
NODE_TO_PARENT.set(n2, element);
|
|
784
|
-
const key = DOMEditor.findKey(editor, n2);
|
|
785
|
-
return Text.isText(n2) ? h(TextComp, {
|
|
786
|
-
text: n2,
|
|
787
|
-
element,
|
|
788
|
-
key: key.id
|
|
789
|
-
}) : h(ElementComp, {
|
|
790
|
-
element: n2,
|
|
791
|
-
key: key.id
|
|
792
|
-
});
|
|
771
|
+
const isBlock = !Editor.isEditor(element) && Element.isElement(element) && !editor.isInline(element);
|
|
772
|
+
const chunkSize = Editor.hasInlines(editor, element) ? null : editor.getChunkSize(element);
|
|
773
|
+
if (isBlock || chunkSize === null) {
|
|
774
|
+
return () => renderList(element.children, (n2, i) => {
|
|
775
|
+
NODE_TO_INDEX.set(n2, i);
|
|
776
|
+
NODE_TO_PARENT.set(n2, element);
|
|
777
|
+
const key = DOMEditor.findKey(editor, n2);
|
|
778
|
+
return Text.isText(n2) ? h(TextComp, {
|
|
779
|
+
text: n2,
|
|
780
|
+
element,
|
|
781
|
+
key: key.id
|
|
782
|
+
}) : h(ElementComp, {
|
|
783
|
+
element: n2,
|
|
784
|
+
key: key.id
|
|
793
785
|
});
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
const cacheTree = getChunkTreeForNode(editor, props.element);
|
|
789
|
+
const editorNodeVersion = useEditorNodeVersion();
|
|
790
|
+
watch(
|
|
791
|
+
editorNodeVersion,
|
|
792
|
+
() => {
|
|
793
|
+
reconcileChildren(editor, element.children, {
|
|
794
|
+
chunkTree: cacheTree,
|
|
795
|
+
chunkSize,
|
|
796
|
+
onInsert: (n2, i) => {
|
|
797
|
+
NODE_TO_INDEX.set(n2, i);
|
|
798
|
+
NODE_TO_PARENT.set(n2, element);
|
|
799
|
+
},
|
|
800
|
+
onUpdate: (n2, i) => {
|
|
801
|
+
NODE_TO_INDEX.set(n2, i);
|
|
802
|
+
NODE_TO_PARENT.set(n2, element);
|
|
803
|
+
},
|
|
804
|
+
onIndexChange: (n2, i) => {
|
|
805
|
+
NODE_TO_INDEX.set(n2, i);
|
|
806
|
+
}
|
|
797
807
|
});
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
immediate: true
|
|
798
811
|
}
|
|
799
|
-
|
|
812
|
+
);
|
|
813
|
+
provide(SLATE_INNER_STATIC_CHUNK_ROOT, cacheTree);
|
|
814
|
+
return () => h(ChunkComp, {
|
|
815
|
+
ancestor: cacheTree
|
|
816
|
+
});
|
|
800
817
|
}
|
|
801
818
|
});
|
|
802
819
|
const useComposing = () => {
|
|
@@ -1293,16 +1310,20 @@ const Editable = defineComponent({
|
|
|
1293
1310
|
}
|
|
1294
1311
|
return newDomRange;
|
|
1295
1312
|
};
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1313
|
+
const editorVersion = useEditorVersion();
|
|
1314
|
+
watch(
|
|
1315
|
+
() => editorVersion.value,
|
|
1316
|
+
() => {
|
|
1317
|
+
const root = DOMEditor.findDocumentOrShadowRoot(editor);
|
|
1318
|
+
const domSelection = getSelection(root);
|
|
1319
|
+
if (!domSelection || !DOMEditor.isFocused(editor)) {
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
if (domSelection.rangeCount <= 1) {
|
|
1323
|
+
setDomSelection();
|
|
1324
|
+
}
|
|
1304
1325
|
}
|
|
1305
|
-
|
|
1326
|
+
);
|
|
1306
1327
|
const stoppedDragging = () => state.isDraggingInternally = false;
|
|
1307
1328
|
onMounted(() => {
|
|
1308
1329
|
const window2 = DOMEditor.getWindow(editor);
|
package/dist/yjs.js
CHANGED
|
@@ -2,8 +2,8 @@ import { d as isObject, T as Text, N as Node, P as Path, E as Editor, c as Trans
|
|
|
2
2
|
import { ref, onMounted, onUnmounted, watch, onUpdated, computed } from "vue";
|
|
3
3
|
import { XmlText, YTextEvent, createRelativePositionFromTypeIndex, createAbsolutePositionFromRelativePosition, createRelativePositionFromJSON, decodeRelativePosition, encodeRelativePosition, UndoManager, compareRelativePositions } from "yjs";
|
|
4
4
|
import { L as Location } from "./location-Ca0TF-GI.js";
|
|
5
|
-
import { u as useEditor, j as useFocused } from "./use-focused-
|
|
6
|
-
import { D as DOMEditor } from "./hotkeys-
|
|
5
|
+
import { u as useEditor, j as useFocused } from "./use-focused-P2l4TlLn.js";
|
|
6
|
+
import { D as DOMEditor } from "./hotkeys-BOpYjXBU.js";
|
|
7
7
|
function deepEquals(node, another) {
|
|
8
8
|
for (const key in node) {
|
|
9
9
|
const a = node[key];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slate-vue3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"@actions/core": "^1.11.1",
|
|
80
80
|
"@eslint/js": "^9.39.1",
|
|
81
81
|
"@faker-js/faker": "^10.1.0",
|
|
82
|
-
"@liveblocks/client": "^3.10.
|
|
83
|
-
"@liveblocks/yjs": "^3.10.
|
|
82
|
+
"@liveblocks/client": "^3.10.1",
|
|
83
|
+
"@liveblocks/yjs": "^3.10.1",
|
|
84
84
|
"@playwright/test": "^1.56.1",
|
|
85
85
|
"@testing-library/vue": "^8.1.0",
|
|
86
86
|
"@types/is-hotkey": "^0.1.10",
|
|
87
87
|
"@types/is-url": "^1.2.32",
|
|
88
88
|
"@types/lodash-es": "^4.17.12",
|
|
89
|
-
"@types/node": "^24.10.
|
|
89
|
+
"@types/node": "^24.10.1",
|
|
90
90
|
"@types/prismjs": "^1.26.5",
|
|
91
91
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
92
92
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
@@ -98,20 +98,20 @@
|
|
|
98
98
|
"image-extensions": "^1.1.0",
|
|
99
99
|
"is-url": "^1.2.4",
|
|
100
100
|
"jiti": "^2.6.1",
|
|
101
|
-
"jsdom": "^27.
|
|
101
|
+
"jsdom": "^27.2.0",
|
|
102
102
|
"lint-staged": "^16.2.6",
|
|
103
103
|
"prismjs": "^1.30.0",
|
|
104
104
|
"remark-gfm": "^4.0.1",
|
|
105
105
|
"remark-parse": "^11.0.0",
|
|
106
106
|
"remark-slate-transformer": "^0.9.0",
|
|
107
107
|
"typescript": "~5.9.3",
|
|
108
|
-
"typescript-eslint": "^8.46.
|
|
108
|
+
"typescript-eslint": "^8.46.4",
|
|
109
109
|
"unified": "^11.0.5",
|
|
110
110
|
"vite": "^7.2.2",
|
|
111
111
|
"vite-plugin-babel": "^1.3.2",
|
|
112
112
|
"vite-plugin-dts": "^4.5.4",
|
|
113
113
|
"vite-plugin-eslint": "^1.8.1",
|
|
114
|
-
"vitest": "^4.0.
|
|
114
|
+
"vitest": "^4.0.9",
|
|
115
115
|
"vue-router": "^4.6.3",
|
|
116
116
|
"yjs": "^13.6.27"
|
|
117
117
|
},
|