slate-vue3 0.7.5 → 0.7.7
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-BGS8X5pd.js → batch-dirty-paths-9ixbU5Xv.js} +180 -199
- package/dist/core.js +3 -3
- package/dist/{create-editor-ZZEkf55h.js → create-editor-CDo9JOV_.js} +4 -4
- package/dist/dom.js +106 -85
- package/dist/history.js +1 -1
- package/dist/{hotkeys-Czzs_Ye-.js → hotkeys-WTh2lFjJ.js} +118 -151
- package/dist/hyperscript.js +6 -9
- package/dist/index.js +6 -6
- package/dist/{location-D4Ys3xEt.js → location-Df07ugyf.js} +1 -1
- package/dist/slate-dom/chunking/index.d.ts +1 -0
- package/dist/slate-dom/index.d.ts +1 -2
- package/dist/slate-vue/components/children.d.ts +1 -1
- package/dist/slate-vue/components/editable.d.ts +6 -347
- package/dist/slate-vue/hooks/use-render.d.ts +1 -1
- package/dist/slate-vue/utils/constants.d.ts +1 -1
- package/dist/{use-focused-ZIuAbLWv.js → use-focused-CVsb6MZ7.js} +89 -93
- package/dist/yjs.js +16 -20
- package/package.json +9 -9
|
@@ -303,246 +303,227 @@ const Path = {
|
|
|
303
303
|
return p;
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (selection) {
|
|
319
|
-
for (const [point, key] of Range.points(selection)) {
|
|
320
|
-
selection[key] = Point.transform(point, op);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
case "insert_text": {
|
|
326
|
-
const { path, offset, text } = op;
|
|
327
|
-
if (text.length === 0) break;
|
|
328
|
-
const node = Node.leaf(editor, path);
|
|
329
|
-
const before = node.text.slice(0, offset);
|
|
330
|
-
const after = node.text.slice(offset);
|
|
331
|
-
node.text = before + text + after;
|
|
332
|
-
if (selection) {
|
|
333
|
-
for (const [point, key] of Range.points(selection)) {
|
|
334
|
-
selection[key] = Point.transform(point, op);
|
|
306
|
+
const GeneralTransforms = {
|
|
307
|
+
transform(editor, op) {
|
|
308
|
+
let transformSelection = false;
|
|
309
|
+
switch (op.type) {
|
|
310
|
+
case "insert_node": {
|
|
311
|
+
const { path, node } = op;
|
|
312
|
+
const parent = Node.parent(editor, path);
|
|
313
|
+
const index = path[path.length - 1];
|
|
314
|
+
if (index > parent.children.length) {
|
|
315
|
+
throw new Error(
|
|
316
|
+
`Cannot apply an 'insert_node' operation at path [${path}] because the destination is past the end of the node.`
|
|
317
|
+
);
|
|
335
318
|
}
|
|
319
|
+
parent.children.splice(index, 0, node);
|
|
320
|
+
transformSelection = true;
|
|
321
|
+
break;
|
|
336
322
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (Text.isText(node) && Text.isText(prev)) {
|
|
347
|
-
prev.text += node.text;
|
|
348
|
-
} else if (!Text.isText(node) && !Text.isText(prev)) {
|
|
349
|
-
prev.children.push(...node.children);
|
|
350
|
-
} else {
|
|
351
|
-
throw new Error(
|
|
352
|
-
`Cannot apply a "merge_node" operation at path [${path}] to nodes of different interfaces: ${Scrubber.stringify(
|
|
353
|
-
node
|
|
354
|
-
)} ${Scrubber.stringify(prev)}`
|
|
355
|
-
);
|
|
323
|
+
case "insert_text": {
|
|
324
|
+
const { path, offset, text } = op;
|
|
325
|
+
if (text.length === 0) break;
|
|
326
|
+
const node = Node.leaf(editor, path);
|
|
327
|
+
const before = node.text.slice(0, offset);
|
|
328
|
+
const after = node.text.slice(offset);
|
|
329
|
+
node.text = before + text + after;
|
|
330
|
+
transformSelection = true;
|
|
331
|
+
break;
|
|
356
332
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
333
|
+
case "merge_node": {
|
|
334
|
+
const { path } = op;
|
|
335
|
+
const node = Node.get(editor, path);
|
|
336
|
+
const prevPath = Path.previous(path);
|
|
337
|
+
const prev = Node.get(editor, prevPath);
|
|
338
|
+
const parent = Node.parent(editor, path);
|
|
339
|
+
const index = path[path.length - 1];
|
|
340
|
+
if (Text.isText(node) && Text.isText(prev)) {
|
|
341
|
+
prev.text += node.text;
|
|
342
|
+
} else if (!Text.isText(node) && !Text.isText(prev)) {
|
|
343
|
+
prev.children.push(...node.children);
|
|
344
|
+
} else {
|
|
345
|
+
throw new Error(
|
|
346
|
+
`Cannot apply a 'merge_node' operation at path [${path}] to nodes of different interfaces: ${Scrubber.stringify(
|
|
347
|
+
node
|
|
348
|
+
)} ${Scrubber.stringify(prev)}`
|
|
349
|
+
);
|
|
361
350
|
}
|
|
351
|
+
parent.children.splice(index, 1);
|
|
352
|
+
transformSelection = true;
|
|
353
|
+
break;
|
|
362
354
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
`Cannot move a path [${path}] to new path [${newPath}] because the destination is inside itself.`
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
const node = Node.get(editor, path);
|
|
373
|
-
const parent = Node.parent(editor, path);
|
|
374
|
-
const index = path[path.length - 1];
|
|
375
|
-
parent.children.splice(index, 1);
|
|
376
|
-
const truePath = Path.transform(path, op);
|
|
377
|
-
const newParent = Node.get(editor, Path.parent(truePath));
|
|
378
|
-
const newIndex = truePath[truePath.length - 1];
|
|
379
|
-
newParent.children.splice(newIndex, 0, node);
|
|
380
|
-
if (selection) {
|
|
381
|
-
for (const [point, key] of Range.points(selection)) {
|
|
382
|
-
selection[key] = Point.transform(point, op);
|
|
355
|
+
case "move_node": {
|
|
356
|
+
const { path, newPath } = op;
|
|
357
|
+
if (Path.isAncestor(path, newPath)) {
|
|
358
|
+
throw new Error(
|
|
359
|
+
`Cannot move a path [${path}] to new path [${newPath}] because the destination is inside itself.`
|
|
360
|
+
);
|
|
383
361
|
}
|
|
362
|
+
const node = Node.get(editor, path);
|
|
363
|
+
const parent = Node.parent(editor, path);
|
|
364
|
+
const index = path[path.length - 1];
|
|
365
|
+
parent.children.splice(index, 1);
|
|
366
|
+
const truePath = Path.transform(path, op);
|
|
367
|
+
const newParent = Node.get(editor, Path.parent(truePath));
|
|
368
|
+
const newIndex = truePath[truePath.length - 1];
|
|
369
|
+
newParent.children.splice(newIndex, 0, node);
|
|
370
|
+
transformSelection = true;
|
|
371
|
+
break;
|
|
384
372
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
373
|
+
case "remove_node": {
|
|
374
|
+
const { path } = op;
|
|
375
|
+
const index = path[path.length - 1];
|
|
376
|
+
const parent = Node.parent(editor, path);
|
|
377
|
+
parent.children.splice(index, 1);
|
|
378
|
+
if (editor.selection) {
|
|
379
|
+
let selection = { ...editor.selection };
|
|
380
|
+
for (const [point, key] of Range.points(selection)) {
|
|
381
|
+
const result = Point.transform(point, op);
|
|
382
|
+
if (selection != null && result != null) {
|
|
383
|
+
selection[key] = result;
|
|
384
|
+
} else {
|
|
385
|
+
let prev;
|
|
386
|
+
let next;
|
|
387
|
+
for (const [n, p] of Node.texts(editor)) {
|
|
388
|
+
if (Path.compare(p, path) === -1) {
|
|
389
|
+
prev = [n, p];
|
|
390
|
+
} else {
|
|
391
|
+
next = [n, p];
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
406
394
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
395
|
+
let preferNext = false;
|
|
396
|
+
if (prev && next) {
|
|
397
|
+
if (Path.equals(next[1], path)) {
|
|
398
|
+
preferNext = !Path.hasPrevious(next[1]);
|
|
399
|
+
} else {
|
|
400
|
+
preferNext = Path.common(prev[1], path).length < Path.common(next[1], path).length;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (prev && !preferNext) {
|
|
404
|
+
selection[key] = {
|
|
405
|
+
path: prev[1],
|
|
406
|
+
offset: prev[0].text.length
|
|
407
|
+
};
|
|
408
|
+
} else if (next) {
|
|
409
|
+
selection[key] = { path: next[1], offset: 0 };
|
|
412
410
|
} else {
|
|
413
|
-
|
|
411
|
+
selection = null;
|
|
414
412
|
}
|
|
415
413
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
} else if (next) {
|
|
420
|
-
point.path = next[1];
|
|
421
|
-
point.offset = 0;
|
|
422
|
-
} else {
|
|
423
|
-
selection = null;
|
|
424
|
-
}
|
|
414
|
+
}
|
|
415
|
+
if (!selection || !Range.equals(selection, editor.selection)) {
|
|
416
|
+
editor.selection = selection;
|
|
425
417
|
}
|
|
426
418
|
}
|
|
419
|
+
break;
|
|
427
420
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (selection) {
|
|
438
|
-
for (const [point, key] of Range.points(selection)) {
|
|
439
|
-
selection[key] = Point.transform(point, op);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
case "set_node": {
|
|
445
|
-
const { path, properties, newProperties } = op;
|
|
446
|
-
if (path.length === 0) {
|
|
447
|
-
throw new Error(`Cannot set properties on the root node!`);
|
|
421
|
+
case "remove_text": {
|
|
422
|
+
const { path, offset, text } = op;
|
|
423
|
+
if (text.length === 0) break;
|
|
424
|
+
const node = Node.leaf(editor, path);
|
|
425
|
+
const before = node.text.slice(0, offset);
|
|
426
|
+
const after = node.text.slice(offset + text.length);
|
|
427
|
+
node.text = before + after;
|
|
428
|
+
transformSelection = true;
|
|
429
|
+
break;
|
|
448
430
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if (
|
|
452
|
-
throw new Error(`Cannot set
|
|
431
|
+
case "set_node": {
|
|
432
|
+
const { path, properties, newProperties } = op;
|
|
433
|
+
if (path.length === 0) {
|
|
434
|
+
throw new Error(`Cannot set properties on the root node!`);
|
|
453
435
|
}
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
436
|
+
const node = Node.get(editor, path);
|
|
437
|
+
for (const key in newProperties) {
|
|
438
|
+
if (key === "children" || key === "text") {
|
|
439
|
+
throw new Error(`Cannot set the '${key}' property of nodes!`);
|
|
440
|
+
}
|
|
441
|
+
const value = newProperties[key];
|
|
442
|
+
if (value == null) {
|
|
443
|
+
delete node[key];
|
|
444
|
+
} else {
|
|
445
|
+
node[key] = value;
|
|
446
|
+
}
|
|
459
447
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
448
|
+
for (const key in properties) {
|
|
449
|
+
if (!newProperties.hasOwnProperty(key)) {
|
|
450
|
+
delete node[key];
|
|
451
|
+
}
|
|
464
452
|
}
|
|
453
|
+
break;
|
|
465
454
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
if (selection == null) {
|
|
455
|
+
case "set_selection": {
|
|
456
|
+
const { newProperties } = op;
|
|
457
|
+
if (newProperties == null) {
|
|
458
|
+
editor.selection = null;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
if (editor.selection == null) {
|
|
474
462
|
if (!Range.isRange(newProperties)) {
|
|
475
463
|
throw new Error(
|
|
476
|
-
`Cannot apply an incomplete
|
|
464
|
+
`Cannot apply an incomplete 'set_selection' operation properties ${Scrubber.stringify(
|
|
477
465
|
newProperties
|
|
478
466
|
)} when there is no current selection.`
|
|
479
467
|
);
|
|
480
468
|
}
|
|
481
|
-
selection = { ...newProperties };
|
|
469
|
+
editor.selection = { ...newProperties };
|
|
470
|
+
break;
|
|
482
471
|
}
|
|
472
|
+
const selection = { ...editor.selection };
|
|
483
473
|
for (const key in newProperties) {
|
|
484
474
|
const value = newProperties[key];
|
|
485
475
|
if (value == null) {
|
|
486
476
|
if (key === "anchor" || key === "focus") {
|
|
487
|
-
throw new Error(`Cannot remove the
|
|
477
|
+
throw new Error(`Cannot remove the '${key}' selection property`);
|
|
488
478
|
}
|
|
489
479
|
delete selection[key];
|
|
490
480
|
} else {
|
|
491
481
|
selection[key] = value;
|
|
492
482
|
}
|
|
493
483
|
}
|
|
484
|
+
editor.selection = selection;
|
|
485
|
+
break;
|
|
494
486
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
children: after
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
parent.children.splice(index + 1, 0, newNode);
|
|
526
|
-
if (selection) {
|
|
527
|
-
for (const [point, key] of Range.points(selection)) {
|
|
528
|
-
selection[key] = Point.transform(point, op);
|
|
487
|
+
case "split_node": {
|
|
488
|
+
const { path, position, properties } = op;
|
|
489
|
+
if (path.length === 0) {
|
|
490
|
+
throw new Error(
|
|
491
|
+
`Cannot apply a 'split_node' operation at path [${path}] because the root node cannot be split.`
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
const node = Node.get(editor, path);
|
|
495
|
+
const parent = Node.parent(editor, path);
|
|
496
|
+
const index = path[path.length - 1];
|
|
497
|
+
let newNode;
|
|
498
|
+
if (Text.isText(node)) {
|
|
499
|
+
const before = node.text.slice(0, position);
|
|
500
|
+
const after = node.text.slice(position);
|
|
501
|
+
node.text = before;
|
|
502
|
+
newNode = {
|
|
503
|
+
...properties,
|
|
504
|
+
text: after
|
|
505
|
+
};
|
|
506
|
+
} else {
|
|
507
|
+
const before = node.children.slice(0, position);
|
|
508
|
+
const after = node.children.slice(position);
|
|
509
|
+
node.children = before;
|
|
510
|
+
newNode = {
|
|
511
|
+
...properties,
|
|
512
|
+
children: after
|
|
513
|
+
};
|
|
529
514
|
}
|
|
515
|
+
parent.children.splice(index + 1, 0, newNode);
|
|
516
|
+
transformSelection = true;
|
|
517
|
+
break;
|
|
530
518
|
}
|
|
531
|
-
break;
|
|
532
519
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
try {
|
|
540
|
-
selection = applyToDraft(editor, selection, op);
|
|
541
|
-
} finally {
|
|
542
|
-
if (selection) {
|
|
520
|
+
if (transformSelection && editor.selection) {
|
|
521
|
+
const selection = { ...editor.selection };
|
|
522
|
+
for (const [point, key] of Range.points(selection)) {
|
|
523
|
+
selection[key] = Point.transform(point, op);
|
|
524
|
+
}
|
|
525
|
+
if (!Range.equals(selection, editor.selection)) {
|
|
543
526
|
editor.selection = selection;
|
|
544
|
-
} else {
|
|
545
|
-
editor.selection = null;
|
|
546
527
|
}
|
|
547
528
|
}
|
|
548
529
|
}
|
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, 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 "./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-CDo9JOV_.js";
|
|
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 "./batch-dirty-paths-9ixbU5Xv.js";
|
|
3
|
+
import { L as L2, S as S3 } from "./location-Df07ugyf.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, I as IS_EDITOR_SET } 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, I as IS_EDITOR_SET } from "./batch-dirty-paths-9ixbU5Xv.js";
|
|
2
2
|
import { reactive } from "vue";
|
|
3
|
-
import { S as Span } from "./location-
|
|
3
|
+
import { S as Span } from "./location-Df07ugyf.js";
|
|
4
4
|
const PathRef = {
|
|
5
5
|
transform(ref, op) {
|
|
6
6
|
const { current, affinity } = ref;
|
|
@@ -439,7 +439,7 @@ const normalizeNode = (editor, entry, options) => {
|
|
|
439
439
|
const isInlineOrText = Text.isText(child) || Element.isElement(child) && editor.isInline(child);
|
|
440
440
|
if (isInlineOrText !== shouldHaveInlines) {
|
|
441
441
|
if (isInlineOrText) {
|
|
442
|
-
if (options
|
|
442
|
+
if (options?.fallbackElement) {
|
|
443
443
|
Transforms.wrapNodes(editor, options.fallbackElement(), {
|
|
444
444
|
at: path2.concat(n),
|
|
445
445
|
voids: true
|
|
@@ -2276,7 +2276,7 @@ const splitNodes = (editor, options = {}) => {
|
|
|
2276
2276
|
}
|
|
2277
2277
|
} finally {
|
|
2278
2278
|
beforeRef.unref();
|
|
2279
|
-
afterRef
|
|
2279
|
+
afterRef?.unref();
|
|
2280
2280
|
}
|
|
2281
2281
|
});
|
|
2282
2282
|
};
|