plitejs 54.0.0-beta.3 → 54.0.0-beta.4
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/annotations/index.d.ts +1 -1
- package/dist/annotations/index.js +1 -1
- package/dist/authored/index.d.ts +2 -2
- package/dist/authored/index.js +168 -46
- package/dist/{authored-veto-DSnQcHGR.js → authored-veto-D_9wCJcK.js} +1 -1
- package/dist/{comparison-plan-CEQL0ooW.js → comparison-plan-DY_vuGPq.js} +1 -1
- package/dist/{comparison-types-Dt-unJZY.d.ts → comparison-types-DdwE6mYq.d.ts} +1 -1
- package/dist/{create-editor-CkHtPWXV.js → create-editor-CLQEkEZ1.js} +2 -1
- package/dist/diff/index.d.ts +2 -2
- package/dist/diff/index.js +2 -2
- package/dist/dom/index.d.ts +1 -1
- package/dist/dom/index.js +1 -1
- package/dist/{dom-Cgfscvnm.js → dom-CH2BXXj6.js} +2 -2
- package/dist/{editor-owner-IUmkTeXz.js → editor-owner-C9rVbMTs.js} +1 -1
- package/dist/history/index.d.ts +1 -1
- package/dist/history/index.js +2 -2
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/hyperscript/index.js +1 -1
- package/dist/{hyperscript-FPuoArEi.js → hyperscript-CeT83ZLB.js} +2 -2
- package/dist/{index-DPWyk3lG.d.ts → index-BWPcE4ac.d.ts} +7 -1
- package/dist/{index-DpltOCot.d.ts → index-BXjLmx1n.d.ts} +101 -27
- package/dist/{index-K0Za9YXc.d.ts → index-DVMNewDn.d.ts} +10 -13
- package/dist/{index-BpQx2UG4.d.ts → index-Db-ktCTE.d.ts} +5 -6
- package/dist/{index-HPYawTae.d.ts → index-Dq3Jlj8O.d.ts} +1 -1
- package/dist/{index-Cw-oC2ps.d.ts → index-UrB4jAwl.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +4 -4
- package/dist/{mapped-view-store-ld-6uxEU.js → mapped-view-store-CbWqba_1.js} +1 -1
- package/dist/{native-grouping-input-DMNcsIaW.js → native-grouping-input-DXNhlPHd.js} +1 -1
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/pagination/react.d.ts +2 -2
- package/dist/pagination/react.js +5 -5
- package/dist/{pagination-D_A8iPJP.js → pagination-CBdYiOuR.js} +1 -1
- package/dist/{plugin-DWzkJbnJ.js → plugin-SR3HTH0j.js} +1458 -952
- package/dist/{range-geometry-BjeLHOnl.js → range-geometry-CdltxcH6.js} +2 -2
- package/dist/{range-geometry-BLAHRE11.d.ts → range-geometry-Dwp2oyCc.d.ts} +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +6 -6
- package/dist/react/virtualized.d.ts +2 -2
- package/dist/react/virtualized.js +1 -1
- package/dist/{react-DZ15gmz2.js → react-CN-iBh1z.js} +8 -8
- package/dist/{retraction-BMem8Rfk.js → retraction-BmPJB9cE.js} +1 -1
- package/dist/{src-cT1OTKP_.js → src-B-zm0kz4.js} +128 -3
- package/dist/{store-Cz2mXyDe.js → store-51r4zpCR.js} +24 -11
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +3 -3
- package/dist/{use-editor-dom-scope-BbMDSCpW.js → use-editor-dom-scope-uDJQ692F.js} +184 -168
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/index.js +1 -1
- package/dist/yjs/react/index.d.ts +3 -3
- package/dist/yjs/react/index.js +3 -3
- package/dist/{yjs-DOK-m7kl.js → yjs-IGE0Al3n.js} +5 -2
- package/package.json +1 -1
|
@@ -81,6 +81,8 @@ const coreWork = {
|
|
|
81
81
|
collapsedBoundaryVisits: 0,
|
|
82
82
|
composedProjectionSections: 0,
|
|
83
83
|
contentRootOwnerScans: 0,
|
|
84
|
+
contentSpanNodes: 0,
|
|
85
|
+
tokenRangeVisits: 0,
|
|
84
86
|
coverageCandidateChecks: 0,
|
|
85
87
|
coverageQueries: 0,
|
|
86
88
|
coverageRootKeyBuilds: 0,
|
|
@@ -408,6 +410,337 @@ const persistentMapChanges = (before, after, same = Object.is) => {
|
|
|
408
410
|
return changed;
|
|
409
411
|
};
|
|
410
412
|
//#endregion
|
|
413
|
+
//#region src/utils/is-object.ts
|
|
414
|
+
const isObject = (value) => typeof value === "object" && value !== null;
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/interfaces/path.ts
|
|
417
|
+
const PathApi = Object.freeze({
|
|
418
|
+
ancestors(path, options = {}) {
|
|
419
|
+
const { reverse = false } = options;
|
|
420
|
+
let paths = PathApi.levels(path, options);
|
|
421
|
+
if (reverse) paths = paths.slice(1);
|
|
422
|
+
else paths = paths.slice(0, -1);
|
|
423
|
+
return paths;
|
|
424
|
+
},
|
|
425
|
+
common(path, another) {
|
|
426
|
+
const common = [];
|
|
427
|
+
for (let i = 0; i < path.length && i < another.length; i++) {
|
|
428
|
+
const av = path[i];
|
|
429
|
+
const bv = another[i];
|
|
430
|
+
if (typeof av !== "number" || typeof bv !== "number") throw new Error("Got non-numeric path index");
|
|
431
|
+
if (av !== bv) break;
|
|
432
|
+
common.push(av);
|
|
433
|
+
}
|
|
434
|
+
return common;
|
|
435
|
+
},
|
|
436
|
+
compare(path, another) {
|
|
437
|
+
const min = Math.min(path.length, another.length);
|
|
438
|
+
for (let i = 0; i < min; i++) {
|
|
439
|
+
if (path[i] < another[i]) return -1;
|
|
440
|
+
if (path[i] > another[i]) return 1;
|
|
441
|
+
}
|
|
442
|
+
return 0;
|
|
443
|
+
},
|
|
444
|
+
endsAfter(path, another) {
|
|
445
|
+
const i = path.length - 1;
|
|
446
|
+
const as = path.slice(0, i);
|
|
447
|
+
const bs = another.slice(0, i);
|
|
448
|
+
const av = path[i];
|
|
449
|
+
const bv = another[i];
|
|
450
|
+
return PathApi.equals(as, bs) && av > bv;
|
|
451
|
+
},
|
|
452
|
+
endsAt(path, another) {
|
|
453
|
+
const i = path.length;
|
|
454
|
+
const as = path.slice(0, i);
|
|
455
|
+
const bs = another.slice(0, i);
|
|
456
|
+
return PathApi.equals(as, bs);
|
|
457
|
+
},
|
|
458
|
+
endsBefore(path, another) {
|
|
459
|
+
const i = path.length - 1;
|
|
460
|
+
const as = path.slice(0, i);
|
|
461
|
+
const bs = another.slice(0, i);
|
|
462
|
+
const av = path[i];
|
|
463
|
+
const bv = another[i];
|
|
464
|
+
return PathApi.equals(as, bs) && av < bv;
|
|
465
|
+
},
|
|
466
|
+
equals(path, another) {
|
|
467
|
+
return path.length === another.length && path.every((n, i) => n === another[i]);
|
|
468
|
+
},
|
|
469
|
+
hasPrevious(path) {
|
|
470
|
+
return getDefined(path.at(-1)) > 0;
|
|
471
|
+
},
|
|
472
|
+
isAfter(path, another) {
|
|
473
|
+
return PathApi.compare(path, another) === 1;
|
|
474
|
+
},
|
|
475
|
+
isAncestor(path, another) {
|
|
476
|
+
return path.length < another.length && PathApi.compare(path, another) === 0;
|
|
477
|
+
},
|
|
478
|
+
isBefore(path, another) {
|
|
479
|
+
return PathApi.compare(path, another) === -1;
|
|
480
|
+
},
|
|
481
|
+
isChild(path, another) {
|
|
482
|
+
return path.length === another.length + 1 && PathApi.compare(path, another) === 0;
|
|
483
|
+
},
|
|
484
|
+
isCommon(path, another) {
|
|
485
|
+
return path.length <= another.length && PathApi.compare(path, another) === 0;
|
|
486
|
+
},
|
|
487
|
+
isDescendant(path, another) {
|
|
488
|
+
return path.length > another.length && PathApi.compare(path, another) === 0;
|
|
489
|
+
},
|
|
490
|
+
isParent(path, another) {
|
|
491
|
+
return path.length + 1 === another.length && PathApi.compare(path, another) === 0;
|
|
492
|
+
},
|
|
493
|
+
isPath(value) {
|
|
494
|
+
return Array.isArray(value) && value.every((n) => typeof n === "number");
|
|
495
|
+
},
|
|
496
|
+
isSibling(path, another) {
|
|
497
|
+
if (path.length !== another.length) return false;
|
|
498
|
+
const as = path.slice(0, -1);
|
|
499
|
+
const bs = another.slice(0, -1);
|
|
500
|
+
return getDefined(path.at(-1)) !== getDefined(another.at(-1)) && PathApi.equals(as, bs);
|
|
501
|
+
},
|
|
502
|
+
levels(path, options = {}) {
|
|
503
|
+
const { reverse = false } = options;
|
|
504
|
+
const list = [];
|
|
505
|
+
for (let i = 0; i <= path.length; i++) list.push(path.slice(0, i));
|
|
506
|
+
if (reverse) list.reverse();
|
|
507
|
+
return list;
|
|
508
|
+
},
|
|
509
|
+
next(path) {
|
|
510
|
+
if (path.length === 0) throw new Error(`Cannot get the next path of a root path [${path}], because it has no next index.`);
|
|
511
|
+
const last = getDefined(path.at(-1));
|
|
512
|
+
return path.slice(0, -1).concat(last + 1);
|
|
513
|
+
},
|
|
514
|
+
parent(path) {
|
|
515
|
+
if (path.length === 0) throw new Error(`Cannot get the parent path of the root path [${path}].`);
|
|
516
|
+
return path.slice(0, -1);
|
|
517
|
+
},
|
|
518
|
+
previous(path) {
|
|
519
|
+
if (path.length === 0) throw new Error(`Cannot get the previous path of a root path [${path}], because it has no previous index.`);
|
|
520
|
+
const last = getDefined(path.at(-1));
|
|
521
|
+
if (last <= 0) throw new Error(`Cannot get the previous path of a first child path [${path}] because it would result in a negative index.`);
|
|
522
|
+
return path.slice(0, -1).concat(last - 1);
|
|
523
|
+
},
|
|
524
|
+
relative(path, ancestor) {
|
|
525
|
+
if (!PathApi.isAncestor(ancestor, path) && !PathApi.equals(path, ancestor)) throw new Error(`Cannot get the relative path of [${path}] inside ancestor [${ancestor}], because it is not above or equal to the path.`);
|
|
526
|
+
return path.slice(ancestor.length);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/internal/root-location.ts
|
|
531
|
+
/** @internal */
|
|
532
|
+
const MAIN_ROOT_KEY = "main";
|
|
533
|
+
const getPointRoot = (point, fallback = MAIN_ROOT_KEY) => ({
|
|
534
|
+
root: point.root ?? fallback,
|
|
535
|
+
visibility: point.root === void 0 ? "implicit" : "explicit"
|
|
536
|
+
});
|
|
537
|
+
const getRangeRoot = (range, fallback = MAIN_ROOT_KEY) => {
|
|
538
|
+
const anchor = getPointRoot(range.anchor, fallback);
|
|
539
|
+
const focus = getPointRoot(range.focus, fallback);
|
|
540
|
+
return {
|
|
541
|
+
anchor,
|
|
542
|
+
focus,
|
|
543
|
+
root: anchor.root === focus.root ? anchor.root : null
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
const getLocationRoot = (location) => {
|
|
547
|
+
if (!location || Array.isArray(location)) return;
|
|
548
|
+
if ("path" in location && "offset" in location) return location.root;
|
|
549
|
+
if ("anchor" in location && "focus" in location) return getExplicitRangeLocationRoot(location) ?? void 0;
|
|
550
|
+
};
|
|
551
|
+
const getExplicitRangeLocationRoot = (range) => {
|
|
552
|
+
const anchorRoot = range.anchor.root;
|
|
553
|
+
const focusRoot = range.focus.root;
|
|
554
|
+
if (anchorRoot && focusRoot && anchorRoot !== focusRoot) return null;
|
|
555
|
+
return anchorRoot ?? focusRoot;
|
|
556
|
+
};
|
|
557
|
+
const getCommonLocationRoot = (...locations) => {
|
|
558
|
+
let root;
|
|
559
|
+
for (const location of locations) {
|
|
560
|
+
const nextRoot = location && !Array.isArray(location) && "anchor" in location && "focus" in location ? getExplicitRangeLocationRoot(location) : getLocationRoot(location);
|
|
561
|
+
if (nextRoot === null) return null;
|
|
562
|
+
if (!nextRoot) continue;
|
|
563
|
+
if (root && root !== nextRoot) return null;
|
|
564
|
+
root = nextRoot;
|
|
565
|
+
}
|
|
566
|
+
return root;
|
|
567
|
+
};
|
|
568
|
+
const withImplicitPointRoot = (point, root) => point.root === void 0 ? {
|
|
569
|
+
...point,
|
|
570
|
+
root
|
|
571
|
+
} : point;
|
|
572
|
+
const withImplicitRangeRoot = (range, root) => ({
|
|
573
|
+
anchor: withImplicitPointRoot(range.anchor, root),
|
|
574
|
+
focus: withImplicitPointRoot(range.focus, root)
|
|
575
|
+
});
|
|
576
|
+
const stripImplicitPointRoot = (point, meta) => {
|
|
577
|
+
if (meta.visibility === "explicit" || point.root === void 0) return point;
|
|
578
|
+
const { root: _root, ...pointWithoutRoot } = point;
|
|
579
|
+
return pointWithoutRoot;
|
|
580
|
+
};
|
|
581
|
+
const stripImplicitRangeRoots = (range, meta) => ({
|
|
582
|
+
anchor: stripImplicitPointRoot(range.anchor, meta.anchor),
|
|
583
|
+
focus: stripImplicitPointRoot(range.focus, meta.focus)
|
|
584
|
+
});
|
|
585
|
+
/**
|
|
586
|
+
* Relate a range produced by a reader of `root`, such as decoration output, to
|
|
587
|
+
* that root. Endpoints without a root belong to the reader. Returns the range
|
|
588
|
+
* without roots, or `null` when an endpoint names another root.
|
|
589
|
+
*/
|
|
590
|
+
const getReaderRange = (range, root) => {
|
|
591
|
+
const { anchor, focus } = range;
|
|
592
|
+
if (anchor.root === void 0 && focus.root === void 0) return range;
|
|
593
|
+
if ((anchor.root ?? root) !== root || (focus.root ?? root) !== root) return null;
|
|
594
|
+
return {
|
|
595
|
+
...range,
|
|
596
|
+
...stripLocationRoots({
|
|
597
|
+
anchor,
|
|
598
|
+
focus
|
|
599
|
+
})
|
|
600
|
+
};
|
|
601
|
+
};
|
|
602
|
+
const stripLocationRoots = (location) => {
|
|
603
|
+
if (PathApi.isPath(location)) return location;
|
|
604
|
+
if ("path" in location && "offset" in location) {
|
|
605
|
+
const { root: _root, ...point } = location;
|
|
606
|
+
return point;
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
anchor: stripLocationRoots(location.anchor),
|
|
610
|
+
focus: stripLocationRoots(location.focus)
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/interfaces/point.ts
|
|
615
|
+
const PointApi = Object.freeze({
|
|
616
|
+
compare(point, another) {
|
|
617
|
+
const pointRoot = getPointRoot(point).root;
|
|
618
|
+
const anotherRoot = getPointRoot(another).root;
|
|
619
|
+
if (pointRoot !== anotherRoot) return pointRoot < anotherRoot ? -1 : 1;
|
|
620
|
+
const result = PathApi.compare(point.path, another.path);
|
|
621
|
+
if (result === 0) {
|
|
622
|
+
if (point.offset < another.offset) return -1;
|
|
623
|
+
if (point.offset > another.offset) return 1;
|
|
624
|
+
return 0;
|
|
625
|
+
}
|
|
626
|
+
return result;
|
|
627
|
+
},
|
|
628
|
+
isAfter(point, another) {
|
|
629
|
+
return PointApi.compare(point, another) === 1;
|
|
630
|
+
},
|
|
631
|
+
isBefore(point, another) {
|
|
632
|
+
return PointApi.compare(point, another) === -1;
|
|
633
|
+
},
|
|
634
|
+
equals(point, another) {
|
|
635
|
+
return point.offset === another.offset && getPointRoot(point).root === getPointRoot(another).root && PathApi.equals(point.path, another.path);
|
|
636
|
+
},
|
|
637
|
+
isPoint(value) {
|
|
638
|
+
return isObject(value) && typeof value.offset === "number" && (value.root === void 0 || typeof value.root === "string") && PathApi.isPath(value.path);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region src/interfaces/location.ts
|
|
643
|
+
const LocationApi = Object.freeze({
|
|
644
|
+
isLocation(value) {
|
|
645
|
+
return PathApi.isPath(value) || PointApi.isPoint(value) || RangeApi.isRange(value);
|
|
646
|
+
},
|
|
647
|
+
isPath(at) {
|
|
648
|
+
return Array.isArray(at);
|
|
649
|
+
},
|
|
650
|
+
isPoint(at) {
|
|
651
|
+
return "offset" in at;
|
|
652
|
+
},
|
|
653
|
+
isRange(at) {
|
|
654
|
+
return "anchor" in at;
|
|
655
|
+
},
|
|
656
|
+
isSpan(at) {
|
|
657
|
+
return Array.isArray(at) && Array.isArray(at[0]);
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
const SpanApi = Object.freeze({ isSpan(value) {
|
|
661
|
+
return Array.isArray(value) && value.length === 2 && value.every(PathApi.isPath);
|
|
662
|
+
} });
|
|
663
|
+
//#endregion
|
|
664
|
+
//#region src/interfaces/range.ts
|
|
665
|
+
const RangeApi = Object.freeze({
|
|
666
|
+
edges(range, options = {}) {
|
|
667
|
+
const { reverse = false } = options;
|
|
668
|
+
const { anchor, focus } = range;
|
|
669
|
+
return RangeApi.isBackward(range) === reverse ? [anchor, focus] : [focus, anchor];
|
|
670
|
+
},
|
|
671
|
+
end(range) {
|
|
672
|
+
const [, end] = RangeApi.edges(range);
|
|
673
|
+
return end;
|
|
674
|
+
},
|
|
675
|
+
equals(range, another) {
|
|
676
|
+
if (range === another) return true;
|
|
677
|
+
if (!range || !another) return false;
|
|
678
|
+
return PointApi.equals(range.anchor, another.anchor) && PointApi.equals(range.focus, another.focus);
|
|
679
|
+
},
|
|
680
|
+
surrounds(range, target) {
|
|
681
|
+
const intersectionRange = RangeApi.intersection(range, target);
|
|
682
|
+
if (!intersectionRange) return false;
|
|
683
|
+
return RangeApi.equals(intersectionRange, target);
|
|
684
|
+
},
|
|
685
|
+
includes(range, target) {
|
|
686
|
+
if (LocationApi.isRange(target)) {
|
|
687
|
+
if (RangeApi.includes(range, target.anchor) || RangeApi.includes(range, target.focus)) return true;
|
|
688
|
+
const [rs, re] = RangeApi.edges(range);
|
|
689
|
+
const [ts, te] = RangeApi.edges(target);
|
|
690
|
+
return PointApi.isBefore(rs, ts) && PointApi.isAfter(re, te);
|
|
691
|
+
}
|
|
692
|
+
const [start, end] = RangeApi.edges(range);
|
|
693
|
+
let isAfterStart = false;
|
|
694
|
+
let isBeforeEnd = false;
|
|
695
|
+
if (LocationApi.isPoint(target)) {
|
|
696
|
+
isAfterStart = PointApi.compare(target, start) >= 0;
|
|
697
|
+
isBeforeEnd = PointApi.compare(target, end) <= 0;
|
|
698
|
+
} else {
|
|
699
|
+
isAfterStart = PathApi.compare(target, start.path) >= 0;
|
|
700
|
+
isBeforeEnd = PathApi.compare(target, end.path) <= 0;
|
|
701
|
+
}
|
|
702
|
+
return isAfterStart && isBeforeEnd;
|
|
703
|
+
},
|
|
704
|
+
intersection(range, another) {
|
|
705
|
+
const { anchor, focus, ...rest } = range;
|
|
706
|
+
const [s1, e1] = RangeApi.edges(range);
|
|
707
|
+
const [s2, e2] = RangeApi.edges(another);
|
|
708
|
+
const start = PointApi.isBefore(s1, s2) ? s2 : s1;
|
|
709
|
+
const end = PointApi.isBefore(e1, e2) ? e1 : e2;
|
|
710
|
+
if (PointApi.isBefore(end, start)) return null;
|
|
711
|
+
return {
|
|
712
|
+
anchor: start,
|
|
713
|
+
focus: end,
|
|
714
|
+
...rest
|
|
715
|
+
};
|
|
716
|
+
},
|
|
717
|
+
isBackward(range) {
|
|
718
|
+
const { anchor, focus } = range;
|
|
719
|
+
return PointApi.isAfter(anchor, focus);
|
|
720
|
+
},
|
|
721
|
+
isCollapsed(range) {
|
|
722
|
+
const { anchor, focus } = range;
|
|
723
|
+
return PointApi.equals(anchor, focus);
|
|
724
|
+
},
|
|
725
|
+
isExpanded(range) {
|
|
726
|
+
return !RangeApi.isCollapsed(range);
|
|
727
|
+
},
|
|
728
|
+
isForward(range) {
|
|
729
|
+
return !RangeApi.isBackward(range);
|
|
730
|
+
},
|
|
731
|
+
isRange(value) {
|
|
732
|
+
return isObject(value) && PointApi.isPoint(value.anchor) && PointApi.isPoint(value.focus);
|
|
733
|
+
},
|
|
734
|
+
*points(range) {
|
|
735
|
+
yield [range.anchor, "anchor"];
|
|
736
|
+
yield [range.focus, "focus"];
|
|
737
|
+
},
|
|
738
|
+
start(range) {
|
|
739
|
+
const [start] = RangeApi.edges(range);
|
|
740
|
+
return start;
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
//#endregion
|
|
411
744
|
//#region src/core/transaction-values.ts
|
|
412
745
|
const defineEffect = (options) => {
|
|
413
746
|
const { key } = options;
|
|
@@ -463,6 +796,11 @@ const mapEffect = (effect, changes) => {
|
|
|
463
796
|
return value === void 0 ? void 0 : createEditorEffect(effect.type, value);
|
|
464
797
|
};
|
|
465
798
|
const invertEffect = (effect) => createEditorEffect(effect.type, effect.type.invert(effect.value));
|
|
799
|
+
const readLastCommitAnnotation = (state, annotation, selection) => {
|
|
800
|
+
const commit = state.lastCommit();
|
|
801
|
+
const value = commit?.annotations[annotation.key];
|
|
802
|
+
return value !== void 0 && RangeApi.isRange(commit?.selectionAfter) && RangeApi.equals(commit.selectionAfter, selection) ? value : null;
|
|
803
|
+
};
|
|
466
804
|
const defineUpdateAnnotation = (options) => {
|
|
467
805
|
if (!options.key) throw new Error("Editor annotation key cannot be empty.");
|
|
468
806
|
return Object.freeze({
|
|
@@ -1850,6 +2188,7 @@ var ResolvedTokenCursor = class {
|
|
|
1850
2188
|
}
|
|
1851
2189
|
children.forEach(first, (child, index, start) => {
|
|
1852
2190
|
const childFrom = contentFrom + start;
|
|
2191
|
+
countCoreWork("tokenRangeVisits");
|
|
1853
2192
|
if (childFrom > to) return false;
|
|
1854
2193
|
if (childFrom + child.length < from) return true;
|
|
1855
2194
|
path.push(index);
|
|
@@ -11734,337 +12073,6 @@ const refusedIn = (editor, reason) => getEditorCommandDocument(editor)?.refuse?.
|
|
|
11734
12073
|
/** @internal */
|
|
11735
12074
|
const unplacedIn = (editor, what) => getEditorCommandDocument(editor)?.unplaced?.() ?? /* @__PURE__ */ new Error(`The command frame has no place for ${what}.`);
|
|
11736
12075
|
//#endregion
|
|
11737
|
-
//#region src/interfaces/path.ts
|
|
11738
|
-
const PathApi = Object.freeze({
|
|
11739
|
-
ancestors(path, options = {}) {
|
|
11740
|
-
const { reverse = false } = options;
|
|
11741
|
-
let paths = PathApi.levels(path, options);
|
|
11742
|
-
if (reverse) paths = paths.slice(1);
|
|
11743
|
-
else paths = paths.slice(0, -1);
|
|
11744
|
-
return paths;
|
|
11745
|
-
},
|
|
11746
|
-
common(path, another) {
|
|
11747
|
-
const common = [];
|
|
11748
|
-
for (let i = 0; i < path.length && i < another.length; i++) {
|
|
11749
|
-
const av = path[i];
|
|
11750
|
-
const bv = another[i];
|
|
11751
|
-
if (typeof av !== "number" || typeof bv !== "number") throw new Error("Got non-numeric path index");
|
|
11752
|
-
if (av !== bv) break;
|
|
11753
|
-
common.push(av);
|
|
11754
|
-
}
|
|
11755
|
-
return common;
|
|
11756
|
-
},
|
|
11757
|
-
compare(path, another) {
|
|
11758
|
-
const min = Math.min(path.length, another.length);
|
|
11759
|
-
for (let i = 0; i < min; i++) {
|
|
11760
|
-
if (path[i] < another[i]) return -1;
|
|
11761
|
-
if (path[i] > another[i]) return 1;
|
|
11762
|
-
}
|
|
11763
|
-
return 0;
|
|
11764
|
-
},
|
|
11765
|
-
endsAfter(path, another) {
|
|
11766
|
-
const i = path.length - 1;
|
|
11767
|
-
const as = path.slice(0, i);
|
|
11768
|
-
const bs = another.slice(0, i);
|
|
11769
|
-
const av = path[i];
|
|
11770
|
-
const bv = another[i];
|
|
11771
|
-
return PathApi.equals(as, bs) && av > bv;
|
|
11772
|
-
},
|
|
11773
|
-
endsAt(path, another) {
|
|
11774
|
-
const i = path.length;
|
|
11775
|
-
const as = path.slice(0, i);
|
|
11776
|
-
const bs = another.slice(0, i);
|
|
11777
|
-
return PathApi.equals(as, bs);
|
|
11778
|
-
},
|
|
11779
|
-
endsBefore(path, another) {
|
|
11780
|
-
const i = path.length - 1;
|
|
11781
|
-
const as = path.slice(0, i);
|
|
11782
|
-
const bs = another.slice(0, i);
|
|
11783
|
-
const av = path[i];
|
|
11784
|
-
const bv = another[i];
|
|
11785
|
-
return PathApi.equals(as, bs) && av < bv;
|
|
11786
|
-
},
|
|
11787
|
-
equals(path, another) {
|
|
11788
|
-
return path.length === another.length && path.every((n, i) => n === another[i]);
|
|
11789
|
-
},
|
|
11790
|
-
hasPrevious(path) {
|
|
11791
|
-
return getDefined(path.at(-1)) > 0;
|
|
11792
|
-
},
|
|
11793
|
-
isAfter(path, another) {
|
|
11794
|
-
return PathApi.compare(path, another) === 1;
|
|
11795
|
-
},
|
|
11796
|
-
isAncestor(path, another) {
|
|
11797
|
-
return path.length < another.length && PathApi.compare(path, another) === 0;
|
|
11798
|
-
},
|
|
11799
|
-
isBefore(path, another) {
|
|
11800
|
-
return PathApi.compare(path, another) === -1;
|
|
11801
|
-
},
|
|
11802
|
-
isChild(path, another) {
|
|
11803
|
-
return path.length === another.length + 1 && PathApi.compare(path, another) === 0;
|
|
11804
|
-
},
|
|
11805
|
-
isCommon(path, another) {
|
|
11806
|
-
return path.length <= another.length && PathApi.compare(path, another) === 0;
|
|
11807
|
-
},
|
|
11808
|
-
isDescendant(path, another) {
|
|
11809
|
-
return path.length > another.length && PathApi.compare(path, another) === 0;
|
|
11810
|
-
},
|
|
11811
|
-
isParent(path, another) {
|
|
11812
|
-
return path.length + 1 === another.length && PathApi.compare(path, another) === 0;
|
|
11813
|
-
},
|
|
11814
|
-
isPath(value) {
|
|
11815
|
-
return Array.isArray(value) && value.every((n) => typeof n === "number");
|
|
11816
|
-
},
|
|
11817
|
-
isSibling(path, another) {
|
|
11818
|
-
if (path.length !== another.length) return false;
|
|
11819
|
-
const as = path.slice(0, -1);
|
|
11820
|
-
const bs = another.slice(0, -1);
|
|
11821
|
-
return getDefined(path.at(-1)) !== getDefined(another.at(-1)) && PathApi.equals(as, bs);
|
|
11822
|
-
},
|
|
11823
|
-
levels(path, options = {}) {
|
|
11824
|
-
const { reverse = false } = options;
|
|
11825
|
-
const list = [];
|
|
11826
|
-
for (let i = 0; i <= path.length; i++) list.push(path.slice(0, i));
|
|
11827
|
-
if (reverse) list.reverse();
|
|
11828
|
-
return list;
|
|
11829
|
-
},
|
|
11830
|
-
next(path) {
|
|
11831
|
-
if (path.length === 0) throw new Error(`Cannot get the next path of a root path [${path}], because it has no next index.`);
|
|
11832
|
-
const last = getDefined(path.at(-1));
|
|
11833
|
-
return path.slice(0, -1).concat(last + 1);
|
|
11834
|
-
},
|
|
11835
|
-
parent(path) {
|
|
11836
|
-
if (path.length === 0) throw new Error(`Cannot get the parent path of the root path [${path}].`);
|
|
11837
|
-
return path.slice(0, -1);
|
|
11838
|
-
},
|
|
11839
|
-
previous(path) {
|
|
11840
|
-
if (path.length === 0) throw new Error(`Cannot get the previous path of a root path [${path}], because it has no previous index.`);
|
|
11841
|
-
const last = getDefined(path.at(-1));
|
|
11842
|
-
if (last <= 0) throw new Error(`Cannot get the previous path of a first child path [${path}] because it would result in a negative index.`);
|
|
11843
|
-
return path.slice(0, -1).concat(last - 1);
|
|
11844
|
-
},
|
|
11845
|
-
relative(path, ancestor) {
|
|
11846
|
-
if (!PathApi.isAncestor(ancestor, path) && !PathApi.equals(path, ancestor)) throw new Error(`Cannot get the relative path of [${path}] inside ancestor [${ancestor}], because it is not above or equal to the path.`);
|
|
11847
|
-
return path.slice(ancestor.length);
|
|
11848
|
-
}
|
|
11849
|
-
});
|
|
11850
|
-
//#endregion
|
|
11851
|
-
//#region src/internal/root-location.ts
|
|
11852
|
-
/** @internal */
|
|
11853
|
-
const MAIN_ROOT_KEY = "main";
|
|
11854
|
-
const getPointRoot = (point, fallback = MAIN_ROOT_KEY) => ({
|
|
11855
|
-
root: point.root ?? fallback,
|
|
11856
|
-
visibility: point.root === void 0 ? "implicit" : "explicit"
|
|
11857
|
-
});
|
|
11858
|
-
const getRangeRoot = (range, fallback = MAIN_ROOT_KEY) => {
|
|
11859
|
-
const anchor = getPointRoot(range.anchor, fallback);
|
|
11860
|
-
const focus = getPointRoot(range.focus, fallback);
|
|
11861
|
-
return {
|
|
11862
|
-
anchor,
|
|
11863
|
-
focus,
|
|
11864
|
-
root: anchor.root === focus.root ? anchor.root : null
|
|
11865
|
-
};
|
|
11866
|
-
};
|
|
11867
|
-
const getLocationRoot = (location) => {
|
|
11868
|
-
if (!location || Array.isArray(location)) return;
|
|
11869
|
-
if ("path" in location && "offset" in location) return location.root;
|
|
11870
|
-
if ("anchor" in location && "focus" in location) return getExplicitRangeLocationRoot(location) ?? void 0;
|
|
11871
|
-
};
|
|
11872
|
-
const getExplicitRangeLocationRoot = (range) => {
|
|
11873
|
-
const anchorRoot = range.anchor.root;
|
|
11874
|
-
const focusRoot = range.focus.root;
|
|
11875
|
-
if (anchorRoot && focusRoot && anchorRoot !== focusRoot) return null;
|
|
11876
|
-
return anchorRoot ?? focusRoot;
|
|
11877
|
-
};
|
|
11878
|
-
const getCommonLocationRoot = (...locations) => {
|
|
11879
|
-
let root;
|
|
11880
|
-
for (const location of locations) {
|
|
11881
|
-
const nextRoot = location && !Array.isArray(location) && "anchor" in location && "focus" in location ? getExplicitRangeLocationRoot(location) : getLocationRoot(location);
|
|
11882
|
-
if (nextRoot === null) return null;
|
|
11883
|
-
if (!nextRoot) continue;
|
|
11884
|
-
if (root && root !== nextRoot) return null;
|
|
11885
|
-
root = nextRoot;
|
|
11886
|
-
}
|
|
11887
|
-
return root;
|
|
11888
|
-
};
|
|
11889
|
-
const withImplicitPointRoot = (point, root) => point.root === void 0 ? {
|
|
11890
|
-
...point,
|
|
11891
|
-
root
|
|
11892
|
-
} : point;
|
|
11893
|
-
const withImplicitRangeRoot = (range, root) => ({
|
|
11894
|
-
anchor: withImplicitPointRoot(range.anchor, root),
|
|
11895
|
-
focus: withImplicitPointRoot(range.focus, root)
|
|
11896
|
-
});
|
|
11897
|
-
const stripImplicitPointRoot = (point, meta) => {
|
|
11898
|
-
if (meta.visibility === "explicit" || point.root === void 0) return point;
|
|
11899
|
-
const { root: _root, ...pointWithoutRoot } = point;
|
|
11900
|
-
return pointWithoutRoot;
|
|
11901
|
-
};
|
|
11902
|
-
const stripImplicitRangeRoots = (range, meta) => ({
|
|
11903
|
-
anchor: stripImplicitPointRoot(range.anchor, meta.anchor),
|
|
11904
|
-
focus: stripImplicitPointRoot(range.focus, meta.focus)
|
|
11905
|
-
});
|
|
11906
|
-
/**
|
|
11907
|
-
* Relate a range produced by a reader of `root`, such as decoration output, to
|
|
11908
|
-
* that root. Endpoints without a root belong to the reader. Returns the range
|
|
11909
|
-
* without roots, or `null` when an endpoint names another root.
|
|
11910
|
-
*/
|
|
11911
|
-
const getReaderRange = (range, root) => {
|
|
11912
|
-
const { anchor, focus } = range;
|
|
11913
|
-
if (anchor.root === void 0 && focus.root === void 0) return range;
|
|
11914
|
-
if ((anchor.root ?? root) !== root || (focus.root ?? root) !== root) return null;
|
|
11915
|
-
return {
|
|
11916
|
-
...range,
|
|
11917
|
-
...stripLocationRoots({
|
|
11918
|
-
anchor,
|
|
11919
|
-
focus
|
|
11920
|
-
})
|
|
11921
|
-
};
|
|
11922
|
-
};
|
|
11923
|
-
const stripLocationRoots = (location) => {
|
|
11924
|
-
if (PathApi.isPath(location)) return location;
|
|
11925
|
-
if ("path" in location && "offset" in location) {
|
|
11926
|
-
const { root: _root, ...point } = location;
|
|
11927
|
-
return point;
|
|
11928
|
-
}
|
|
11929
|
-
return {
|
|
11930
|
-
anchor: stripLocationRoots(location.anchor),
|
|
11931
|
-
focus: stripLocationRoots(location.focus)
|
|
11932
|
-
};
|
|
11933
|
-
};
|
|
11934
|
-
//#endregion
|
|
11935
|
-
//#region src/utils/is-object.ts
|
|
11936
|
-
const isObject = (value) => typeof value === "object" && value !== null;
|
|
11937
|
-
//#endregion
|
|
11938
|
-
//#region src/interfaces/point.ts
|
|
11939
|
-
const PointApi = Object.freeze({
|
|
11940
|
-
compare(point, another) {
|
|
11941
|
-
const pointRoot = getPointRoot(point).root;
|
|
11942
|
-
const anotherRoot = getPointRoot(another).root;
|
|
11943
|
-
if (pointRoot !== anotherRoot) return pointRoot < anotherRoot ? -1 : 1;
|
|
11944
|
-
const result = PathApi.compare(point.path, another.path);
|
|
11945
|
-
if (result === 0) {
|
|
11946
|
-
if (point.offset < another.offset) return -1;
|
|
11947
|
-
if (point.offset > another.offset) return 1;
|
|
11948
|
-
return 0;
|
|
11949
|
-
}
|
|
11950
|
-
return result;
|
|
11951
|
-
},
|
|
11952
|
-
isAfter(point, another) {
|
|
11953
|
-
return PointApi.compare(point, another) === 1;
|
|
11954
|
-
},
|
|
11955
|
-
isBefore(point, another) {
|
|
11956
|
-
return PointApi.compare(point, another) === -1;
|
|
11957
|
-
},
|
|
11958
|
-
equals(point, another) {
|
|
11959
|
-
return point.offset === another.offset && getPointRoot(point).root === getPointRoot(another).root && PathApi.equals(point.path, another.path);
|
|
11960
|
-
},
|
|
11961
|
-
isPoint(value) {
|
|
11962
|
-
return isObject(value) && typeof value.offset === "number" && (value.root === void 0 || typeof value.root === "string") && PathApi.isPath(value.path);
|
|
11963
|
-
}
|
|
11964
|
-
});
|
|
11965
|
-
//#endregion
|
|
11966
|
-
//#region src/interfaces/range.ts
|
|
11967
|
-
const RangeApi = Object.freeze({
|
|
11968
|
-
edges(range, options = {}) {
|
|
11969
|
-
const { reverse = false } = options;
|
|
11970
|
-
const { anchor, focus } = range;
|
|
11971
|
-
return RangeApi.isBackward(range) === reverse ? [anchor, focus] : [focus, anchor];
|
|
11972
|
-
},
|
|
11973
|
-
end(range) {
|
|
11974
|
-
const [, end] = RangeApi.edges(range);
|
|
11975
|
-
return end;
|
|
11976
|
-
},
|
|
11977
|
-
equals(range, another) {
|
|
11978
|
-
if (range === another) return true;
|
|
11979
|
-
if (!range || !another) return false;
|
|
11980
|
-
return PointApi.equals(range.anchor, another.anchor) && PointApi.equals(range.focus, another.focus);
|
|
11981
|
-
},
|
|
11982
|
-
surrounds(range, target) {
|
|
11983
|
-
const intersectionRange = RangeApi.intersection(range, target);
|
|
11984
|
-
if (!intersectionRange) return false;
|
|
11985
|
-
return RangeApi.equals(intersectionRange, target);
|
|
11986
|
-
},
|
|
11987
|
-
includes(range, target) {
|
|
11988
|
-
if (LocationApi.isRange(target)) {
|
|
11989
|
-
if (RangeApi.includes(range, target.anchor) || RangeApi.includes(range, target.focus)) return true;
|
|
11990
|
-
const [rs, re] = RangeApi.edges(range);
|
|
11991
|
-
const [ts, te] = RangeApi.edges(target);
|
|
11992
|
-
return PointApi.isBefore(rs, ts) && PointApi.isAfter(re, te);
|
|
11993
|
-
}
|
|
11994
|
-
const [start, end] = RangeApi.edges(range);
|
|
11995
|
-
let isAfterStart = false;
|
|
11996
|
-
let isBeforeEnd = false;
|
|
11997
|
-
if (LocationApi.isPoint(target)) {
|
|
11998
|
-
isAfterStart = PointApi.compare(target, start) >= 0;
|
|
11999
|
-
isBeforeEnd = PointApi.compare(target, end) <= 0;
|
|
12000
|
-
} else {
|
|
12001
|
-
isAfterStart = PathApi.compare(target, start.path) >= 0;
|
|
12002
|
-
isBeforeEnd = PathApi.compare(target, end.path) <= 0;
|
|
12003
|
-
}
|
|
12004
|
-
return isAfterStart && isBeforeEnd;
|
|
12005
|
-
},
|
|
12006
|
-
intersection(range, another) {
|
|
12007
|
-
const { anchor, focus, ...rest } = range;
|
|
12008
|
-
const [s1, e1] = RangeApi.edges(range);
|
|
12009
|
-
const [s2, e2] = RangeApi.edges(another);
|
|
12010
|
-
const start = PointApi.isBefore(s1, s2) ? s2 : s1;
|
|
12011
|
-
const end = PointApi.isBefore(e1, e2) ? e1 : e2;
|
|
12012
|
-
if (PointApi.isBefore(end, start)) return null;
|
|
12013
|
-
return {
|
|
12014
|
-
anchor: start,
|
|
12015
|
-
focus: end,
|
|
12016
|
-
...rest
|
|
12017
|
-
};
|
|
12018
|
-
},
|
|
12019
|
-
isBackward(range) {
|
|
12020
|
-
const { anchor, focus } = range;
|
|
12021
|
-
return PointApi.isAfter(anchor, focus);
|
|
12022
|
-
},
|
|
12023
|
-
isCollapsed(range) {
|
|
12024
|
-
const { anchor, focus } = range;
|
|
12025
|
-
return PointApi.equals(anchor, focus);
|
|
12026
|
-
},
|
|
12027
|
-
isExpanded(range) {
|
|
12028
|
-
return !RangeApi.isCollapsed(range);
|
|
12029
|
-
},
|
|
12030
|
-
isForward(range) {
|
|
12031
|
-
return !RangeApi.isBackward(range);
|
|
12032
|
-
},
|
|
12033
|
-
isRange(value) {
|
|
12034
|
-
return isObject(value) && PointApi.isPoint(value.anchor) && PointApi.isPoint(value.focus);
|
|
12035
|
-
},
|
|
12036
|
-
*points(range) {
|
|
12037
|
-
yield [range.anchor, "anchor"];
|
|
12038
|
-
yield [range.focus, "focus"];
|
|
12039
|
-
},
|
|
12040
|
-
start(range) {
|
|
12041
|
-
const [start] = RangeApi.edges(range);
|
|
12042
|
-
return start;
|
|
12043
|
-
}
|
|
12044
|
-
});
|
|
12045
|
-
//#endregion
|
|
12046
|
-
//#region src/interfaces/location.ts
|
|
12047
|
-
const LocationApi = Object.freeze({
|
|
12048
|
-
isLocation(value) {
|
|
12049
|
-
return PathApi.isPath(value) || PointApi.isPoint(value) || RangeApi.isRange(value);
|
|
12050
|
-
},
|
|
12051
|
-
isPath(at) {
|
|
12052
|
-
return Array.isArray(at);
|
|
12053
|
-
},
|
|
12054
|
-
isPoint(at) {
|
|
12055
|
-
return "offset" in at;
|
|
12056
|
-
},
|
|
12057
|
-
isRange(at) {
|
|
12058
|
-
return "anchor" in at;
|
|
12059
|
-
},
|
|
12060
|
-
isSpan(at) {
|
|
12061
|
-
return Array.isArray(at) && Array.isArray(at[0]);
|
|
12062
|
-
}
|
|
12063
|
-
});
|
|
12064
|
-
const SpanApi = Object.freeze({ isSpan(value) {
|
|
12065
|
-
return Array.isArray(value) && value.length === 2 && value.every(PathApi.isPath);
|
|
12066
|
-
} });
|
|
12067
|
-
//#endregion
|
|
12068
12076
|
//#region src/core/content.ts
|
|
12069
12077
|
const CONTENT = /* @__PURE__ */ new WeakMap();
|
|
12070
12078
|
/** @internal */
|
|
@@ -16600,6 +16608,7 @@ const toInternalRoot = (root) => {
|
|
|
16600
16608
|
};
|
|
16601
16609
|
const RECOVERY_AFTER_A_FORWARD = 1024;
|
|
16602
16610
|
const RECOVERY_AFTER_B_FORWARD = 2048;
|
|
16611
|
+
const RECOVERY_AT_ONCE = 4096;
|
|
16603
16612
|
const ACTIVE_ANCHORS = /* @__PURE__ */ new WeakMap();
|
|
16604
16613
|
const ANCHOR_SCOPES = /* @__PURE__ */ new WeakMap();
|
|
16605
16614
|
const BOUND_ANCHORS = /* @__PURE__ */ new WeakMap();
|
|
@@ -16619,6 +16628,7 @@ const COHERENT_ANCHOR_WORK = /* @__PURE__ */ new WeakMap();
|
|
|
16619
16628
|
const ANCHOR_RUNTIME_ID = /* @__PURE__ */ new WeakMap();
|
|
16620
16629
|
const ANCHOR_TRANSACTION_CEILING = /* @__PURE__ */ new WeakMap();
|
|
16621
16630
|
const COMMIT_ANCHOR_HISTORY = /* @__PURE__ */ new WeakMap();
|
|
16631
|
+
const STAGED_ANCHOR_PLACEMENTS = /* @__PURE__ */ new WeakMap();
|
|
16622
16632
|
const STAGED_ANCHOR_HISTORY = /* @__PURE__ */ new WeakMap();
|
|
16623
16633
|
const observeAnchorStateWork = (editor, observer) => {
|
|
16624
16634
|
ANCHOR_STATE_WORK_OBSERVERS.set(editor, observer);
|
|
@@ -17026,9 +17036,9 @@ const mergeAnchorHistoryRecovery = (previous, current, anchorCeiling) => {
|
|
|
17026
17036
|
const beforeRoot = beforePacket.roots[beforePacket.data[beforeOffset + 1]];
|
|
17027
17037
|
const afterRoot = afterPacket.roots[afterPacket.data[afterOffset + 1]];
|
|
17028
17038
|
if (!beforeRoot || beforeRoot !== afterRoot) throw new Error("Cannot merge incompatible anchor recovery roots.");
|
|
17029
|
-
const staticMask = -
|
|
17039
|
+
const staticMask = -7937;
|
|
17030
17040
|
if ((beforeFlags & staticMask) !== (afterFlags & staticMask)) throw new Error("Cannot merge incompatible anchor recovery records.");
|
|
17031
|
-
data.push(id, appendRoot(beforeRoot), beforeFlags & -3073 | afterFlags &
|
|
17041
|
+
data.push(id, appendRoot(beforeRoot), beforeFlags & -3073 | afterFlags & 7168, beforePacket.data[beforeOffset + 3], beforePacket.data[beforeOffset + 4], afterPacket.data[afterOffset + 5], afterPacket.data[afterOffset + 6]);
|
|
17032
17042
|
}
|
|
17033
17043
|
return createAnchorHistoryRecovery(roots, data, (previous?.restoresOnCommit ?? false) || (current?.restoresOnCommit ?? false));
|
|
17034
17044
|
};
|
|
@@ -17155,11 +17165,27 @@ const notifyAnchorChanges = (editor, change, indexedAfter, options = {}) => {
|
|
|
17155
17165
|
listener.change(context);
|
|
17156
17166
|
indexAnchorListener(state, listener);
|
|
17157
17167
|
}
|
|
17168
|
+
const placement = options.commit && STAGED_ANCHOR_PLACEMENTS.get(editor);
|
|
17169
|
+
if (!placement) return;
|
|
17170
|
+
STAGED_ANCHOR_PLACEMENTS.delete(editor);
|
|
17171
|
+
placement(context, (listener, ...ends) => {
|
|
17172
|
+
if (!state.listeners.has(listener)) return;
|
|
17173
|
+
if (state.activeTransaction && !state.activeTransaction.has(listener)) {
|
|
17174
|
+
PREPARING_ANCHOR_STATES.get(state)?.pending.add(listener);
|
|
17175
|
+
listener.begin();
|
|
17176
|
+
state.activeTransaction.add(listener);
|
|
17177
|
+
}
|
|
17178
|
+
if (listener.move?.place(context.afterRoot(listener.root), after, ...ends)) indexAnchorListener(state, listener);
|
|
17179
|
+
});
|
|
17180
|
+
};
|
|
17181
|
+
const placeAnchorsOnCommit = (editor, placement) => {
|
|
17182
|
+
STAGED_ANCHOR_PLACEMENTS.set(editor, placement);
|
|
17158
17183
|
};
|
|
17184
|
+
const getMovableAnchors = (editor, nodeKeys) => new Set(nodeKeys.flatMap((nodeKey) => [...ACTIVE_ANCHORS.get(editor)?.listenersByNodeKey.get(nodeKey) ?? []].filter((listener) => listener.move)));
|
|
17159
17185
|
const commitAnchorTransaction = (editor, value, commit) => {
|
|
17160
17186
|
const state = getActiveAnchorState(editor);
|
|
17161
17187
|
const staged = STAGED_ANCHOR_HISTORY.get(editor);
|
|
17162
|
-
|
|
17188
|
+
clearStagedAnchorHistory(editor);
|
|
17163
17189
|
if (value && state && value !== state.value) {
|
|
17164
17190
|
state.value = value;
|
|
17165
17191
|
state.indexes = /* @__PURE__ */ new Map();
|
|
@@ -17175,7 +17201,7 @@ const commitAnchorTransaction = (editor, value, commit) => {
|
|
|
17175
17201
|
for (let offset = 0; offset < data.length; offset += 7) {
|
|
17176
17202
|
const listener = state.listenersByRuntimeId.get(data[offset + 0]);
|
|
17177
17203
|
if (!listener?.history) continue;
|
|
17178
|
-
if (deferRecovery) {
|
|
17204
|
+
if (deferRecovery && (data[offset + 2] & 4096) === 0) {
|
|
17179
17205
|
const preparing = PREPARING_ANCHOR_STATES.get(state);
|
|
17180
17206
|
if (preparing && !preparing.pending.has(listener)) {
|
|
17181
17207
|
preparing.pending.add(listener);
|
|
@@ -17270,7 +17296,7 @@ const discardAnchorTransaction = (editor, value) => {
|
|
|
17270
17296
|
state.transactionBeforeValue = null;
|
|
17271
17297
|
}
|
|
17272
17298
|
ANCHOR_TRANSACTION_CEILING.delete(editor);
|
|
17273
|
-
|
|
17299
|
+
clearStagedAnchorHistory(editor);
|
|
17274
17300
|
const listeners = state?.activeTransaction ?? state?.listeners;
|
|
17275
17301
|
recordAnchorStateWork(editor, "discard", listeners?.size ?? 0);
|
|
17276
17302
|
for (const listener of listeners ?? []) listener.discard(value);
|
|
@@ -17290,6 +17316,7 @@ const commitPreparedAnchorListener = (state, listener, value, commit) => {
|
|
|
17290
17316
|
};
|
|
17291
17317
|
const clearStagedAnchorHistory = (editor) => {
|
|
17292
17318
|
STAGED_ANCHOR_HISTORY.delete(editor);
|
|
17319
|
+
STAGED_ANCHOR_PLACEMENTS.delete(editor);
|
|
17293
17320
|
};
|
|
17294
17321
|
const prepareAnchorPublication = (editor, commit, prepare) => {
|
|
17295
17322
|
const resumeScopes = suspendAnchorScopes(editor);
|
|
@@ -17396,6 +17423,42 @@ const prepareAnchorPublication = (editor, commit, prepare) => {
|
|
|
17396
17423
|
}
|
|
17397
17424
|
};
|
|
17398
17425
|
//#endregion
|
|
17426
|
+
//#region src/core/document-view-read.ts
|
|
17427
|
+
const DOCUMENT_VIEWS = /* @__PURE__ */ new WeakSet();
|
|
17428
|
+
const DOCUMENT_VIEW_READS = /* @__PURE__ */ new WeakMap();
|
|
17429
|
+
/** Whether a view renders its own document. @internal */
|
|
17430
|
+
const isDocumentView = (view) => DOCUMENT_VIEWS.has(view);
|
|
17431
|
+
/** Mark a view bound to its own document. @internal */
|
|
17432
|
+
const registerDocumentView = (view) => {
|
|
17433
|
+
DOCUMENT_VIEWS.add(view);
|
|
17434
|
+
};
|
|
17435
|
+
/**
|
|
17436
|
+
* Run code on behalf of a document view. While it runs, reading the source
|
|
17437
|
+
* editor through its own API throws: plugin code must read the view's
|
|
17438
|
+
* document through the editor or state passed to it. Other editors run `fn`
|
|
17439
|
+
* unchanged.
|
|
17440
|
+
*
|
|
17441
|
+
* @internal
|
|
17442
|
+
*/
|
|
17443
|
+
const withDocumentViewRead = (editor, fn) => {
|
|
17444
|
+
if (!DOCUMENT_VIEWS.has(editor)) return fn();
|
|
17445
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
17446
|
+
const depth = DOCUMENT_VIEW_READS.get(owner) ?? 0;
|
|
17447
|
+
DOCUMENT_VIEW_READS.set(owner, depth + 1);
|
|
17448
|
+
try {
|
|
17449
|
+
return fn();
|
|
17450
|
+
} finally {
|
|
17451
|
+
if (depth === 0) DOCUMENT_VIEW_READS.delete(owner);
|
|
17452
|
+
else DOCUMENT_VIEW_READS.set(owner, depth);
|
|
17453
|
+
}
|
|
17454
|
+
};
|
|
17455
|
+
/** @internal */
|
|
17456
|
+
const isDocumentViewReading = (editor) => DOCUMENT_VIEW_READS.has(getEditorRuntimeOwner(editor));
|
|
17457
|
+
/** Refuse a source-editor read made while a document view is reading. @internal */
|
|
17458
|
+
const assertNoDocumentViewRead = (editor) => {
|
|
17459
|
+
if (isDocumentViewReading(editor)) throw new Error("Editor read its own document while a document view was reading. Read through the editor or state passed to this call: an editor captured when a plugin was created is the source editor.");
|
|
17460
|
+
};
|
|
17461
|
+
//#endregion
|
|
17399
17462
|
//#region src/core/authored-runtime.ts
|
|
17400
17463
|
const AUTHORED_RUNTIMES = /* @__PURE__ */ new WeakMap();
|
|
17401
17464
|
const UPDATE_VIEWS = /* @__PURE__ */ new WeakMap();
|
|
@@ -17420,6 +17483,10 @@ const isAuthoredPreview = (view) => {
|
|
|
17420
17483
|
const authored = readAuthoredView(view);
|
|
17421
17484
|
return authored !== void 0 && "preview" in authored;
|
|
17422
17485
|
};
|
|
17486
|
+
const readShownPreview = (view) => {
|
|
17487
|
+
const authored = isDocumentView(view) ? void 0 : readAuthoredView(view);
|
|
17488
|
+
return authored && "preview" in authored ? authored.preview : void 0;
|
|
17489
|
+
};
|
|
17423
17490
|
const withAuthoredViewRead = (source, view, read) => {
|
|
17424
17491
|
const installed = AUTHORED_RUNTIMES.get(getEditorRuntimeOwner(source));
|
|
17425
17492
|
return installed ? installed.readView(view, read) : read();
|
|
@@ -17460,40 +17527,6 @@ const registerAuthoredRuntime = (editor, runtime) => {
|
|
|
17460
17527
|
};
|
|
17461
17528
|
};
|
|
17462
17529
|
//#endregion
|
|
17463
|
-
//#region src/core/document-view-read.ts
|
|
17464
|
-
const DOCUMENT_VIEWS = /* @__PURE__ */ new WeakSet();
|
|
17465
|
-
const DOCUMENT_VIEW_READS = /* @__PURE__ */ new WeakMap();
|
|
17466
|
-
/** Whether a view renders its own document. @internal */
|
|
17467
|
-
const isDocumentView = (view) => DOCUMENT_VIEWS.has(view);
|
|
17468
|
-
/** Mark a view bound to its own document. @internal */
|
|
17469
|
-
const registerDocumentView = (view) => {
|
|
17470
|
-
DOCUMENT_VIEWS.add(view);
|
|
17471
|
-
};
|
|
17472
|
-
/**
|
|
17473
|
-
* Run code on behalf of a document view. While it runs, reading the source
|
|
17474
|
-
* editor through its own API throws: plugin code must read the view's
|
|
17475
|
-
* document through the editor or state passed to it. Other editors run `fn`
|
|
17476
|
-
* unchanged.
|
|
17477
|
-
*
|
|
17478
|
-
* @internal
|
|
17479
|
-
*/
|
|
17480
|
-
const withDocumentViewRead = (editor, fn) => {
|
|
17481
|
-
if (!DOCUMENT_VIEWS.has(editor)) return fn();
|
|
17482
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
17483
|
-
const depth = DOCUMENT_VIEW_READS.get(owner) ?? 0;
|
|
17484
|
-
DOCUMENT_VIEW_READS.set(owner, depth + 1);
|
|
17485
|
-
try {
|
|
17486
|
-
return fn();
|
|
17487
|
-
} finally {
|
|
17488
|
-
if (depth === 0) DOCUMENT_VIEW_READS.delete(owner);
|
|
17489
|
-
else DOCUMENT_VIEW_READS.set(owner, depth);
|
|
17490
|
-
}
|
|
17491
|
-
};
|
|
17492
|
-
/** Refuse a source-editor read made while a document view is reading. @internal */
|
|
17493
|
-
const assertNoDocumentViewRead = (editor) => {
|
|
17494
|
-
if (DOCUMENT_VIEW_READS.has(getEditorRuntimeOwner(editor))) throw new Error("Editor read its own document while a document view was reading. Read through the editor or state passed to this call: an editor captured when a plugin was created is the source editor.");
|
|
17495
|
-
};
|
|
17496
|
-
//#endregion
|
|
17497
17530
|
//#region src/core/anchor.ts
|
|
17498
17531
|
const SAVED_RANGES = /* @__PURE__ */ new WeakMap();
|
|
17499
17532
|
const RELEASED_RANGES = /* @__PURE__ */ new WeakSet();
|
|
@@ -17845,6 +17878,8 @@ function createAnchor(editor, value, options) {
|
|
|
17845
17878
|
if (side === 1) flags |= RECOVERY_AFTER_B_FORWARD;
|
|
17846
17879
|
}
|
|
17847
17880
|
}
|
|
17881
|
+
if (placed || kind !== "path" && checkpoint.current && pointStates.some((state, index) => state.nodeKey !== checkpoint.pointStates[index]?.nodeKey)) flags |= RECOVERY_AT_ONCE;
|
|
17882
|
+
placed = false;
|
|
17848
17883
|
data[offset + 0] = id;
|
|
17849
17884
|
data[offset + 1] = rootIndex;
|
|
17850
17885
|
data[offset + 2] = flags;
|
|
@@ -17854,6 +17889,7 @@ function createAnchor(editor, value, options) {
|
|
|
17854
17889
|
data[offset + 6] = afterB;
|
|
17855
17890
|
return true;
|
|
17856
17891
|
};
|
|
17892
|
+
let placed = false;
|
|
17857
17893
|
let pendingRecoveryActive = false;
|
|
17858
17894
|
let pendingRecoveryBefore = false;
|
|
17859
17895
|
let pendingRecoveryFirst = -1;
|
|
@@ -17925,6 +17961,7 @@ function createAnchor(editor, value, options) {
|
|
|
17925
17961
|
sourceValue = documentValue;
|
|
17926
17962
|
return false;
|
|
17927
17963
|
}
|
|
17964
|
+
pendingRecoveryActive = false;
|
|
17928
17965
|
return applyHistoryRecovery(flags, first, second, documentValue, memoize, target === "before");
|
|
17929
17966
|
};
|
|
17930
17967
|
const mapPendingHistoryRecovery = (nextValue, context) => {
|
|
@@ -18128,7 +18165,6 @@ function createAnchor(editor, value, options) {
|
|
|
18128
18165
|
const targetWasExpanded = kind === "range" && !PointApi.equals(pointStates[0].point, getDefined(pointStates[1]).point);
|
|
18129
18166
|
const sourceFrom = beforeDocument.positionAt(pointStates[0].point);
|
|
18130
18167
|
const sourceTo = kind === "range" ? beforeDocument.positionAt(getDefined(pointStates[1]).point) : sourceFrom;
|
|
18131
|
-
const sourceRangeWasReplaced = targetWasExpanded && options.deletion === "drop" && changeCoversSourceRange(change, root, Math.min(sourceFrom, sourceTo), Math.max(sourceFrom, sourceTo));
|
|
18132
18168
|
const sourceNodesKeepIdentity = pointStates.every((state) => {
|
|
18133
18169
|
const runtimePath = runtimePathOf(state.nodeKey, context);
|
|
18134
18170
|
if (!runtimePath) return false;
|
|
@@ -18138,6 +18174,7 @@ function createAnchor(editor, value, options) {
|
|
|
18138
18174
|
return false;
|
|
18139
18175
|
}
|
|
18140
18176
|
});
|
|
18177
|
+
const sourceRangeWasDeleted = targetWasExpanded && !sourceNodesKeepIdentity && changeCoversSourceRange(change, root, Math.min(sourceFrom, sourceTo), Math.max(sourceFrom, sourceTo));
|
|
18141
18178
|
const associations = kind === "point" ? [association === "backward" ? -1 : 1] : getRangeEndpointAssociations(PointApi.equals(current.anchor, current.focus) ? "collapsed" : PointApi.isBefore(current.anchor, current.focus) ? "forward" : "backward", association);
|
|
18142
18179
|
const replacement = kind === "range" && options.deletion === "nearest" && !PointApi.equals(pointStates[0].point, getDefined(pointStates[1]).point) ? mapDocumentRangeReplacement(change, root, getSourceDocument().positionAt(pointStates[0].point), getSourceDocument().positionAt(getDefined(pointStates[1]).point), associations) : null;
|
|
18143
18180
|
const mappedPoints = pointStates.map((state, index) => {
|
|
@@ -18167,10 +18204,13 @@ function createAnchor(editor, value, options) {
|
|
|
18167
18204
|
point: withPublicPointRoot(mapped.point, root, state.includeRoot)
|
|
18168
18205
|
} : null;
|
|
18169
18206
|
});
|
|
18170
|
-
const
|
|
18171
|
-
const
|
|
18207
|
+
const start = sourceFrom <= sourceTo ? 0 : 1;
|
|
18208
|
+
const sources = options.deletion === "nearest" && sourceRangeWasDeleted && !replacement ? [start, start] : mappedPoints.map((_, index) => index);
|
|
18209
|
+
const points = sources.map((index) => mappedPoints[index]?.point ?? null);
|
|
18210
|
+
const nextPointStates = sources.map((source) => {
|
|
18211
|
+
const mapped = mappedPoints[source];
|
|
18172
18212
|
if (!mapped) return null;
|
|
18173
|
-
const previous = pointStates[
|
|
18213
|
+
const previous = pointStates[source];
|
|
18174
18214
|
if (mapped.runtimeStable) return {
|
|
18175
18215
|
...previous,
|
|
18176
18216
|
point: {
|
|
@@ -18180,7 +18220,7 @@ function createAnchor(editor, value, options) {
|
|
|
18180
18220
|
};
|
|
18181
18221
|
return createPointState(runtimeEditor, nextValue, mapped.point, root, nextDocument());
|
|
18182
18222
|
});
|
|
18183
|
-
current =
|
|
18223
|
+
current = options.deletion === "drop" && sourceRangeWasDeleted ? null : kind === "point" ? points[0] : points[0] && points[1] ? {
|
|
18184
18224
|
anchor: points[0],
|
|
18185
18225
|
focus: points[1]
|
|
18186
18226
|
} : null;
|
|
@@ -18188,11 +18228,25 @@ function createAnchor(editor, value, options) {
|
|
|
18188
18228
|
}
|
|
18189
18229
|
sourceValue = nextValue;
|
|
18190
18230
|
};
|
|
18231
|
+
const readMappedTo = (target, read) => {
|
|
18232
|
+
const saved = {
|
|
18233
|
+
current: cloneAnchorValue(current),
|
|
18234
|
+
pointStates: clonePointStates(),
|
|
18235
|
+
sourceValue
|
|
18236
|
+
};
|
|
18237
|
+
try {
|
|
18238
|
+
mapTo(target);
|
|
18239
|
+
return read();
|
|
18240
|
+
} finally {
|
|
18241
|
+
({current, pointStates, sourceValue} = saved);
|
|
18242
|
+
}
|
|
18243
|
+
};
|
|
18191
18244
|
const subscription = subscribeAnchorState(runtimeEditor, {
|
|
18192
18245
|
begin() {
|
|
18246
|
+
placed = false;
|
|
18193
18247
|
checkpoints.push({
|
|
18194
|
-
current:
|
|
18195
|
-
pointStates:
|
|
18248
|
+
current: cloneAnchorValue(current),
|
|
18249
|
+
pointStates: clonePointStates(),
|
|
18196
18250
|
recoveryActive: pendingRecoveryActive,
|
|
18197
18251
|
recoveryBefore: pendingRecoveryBefore,
|
|
18198
18252
|
recoveryFirst: pendingRecoveryFirst,
|
|
@@ -18237,10 +18291,7 @@ function createAnchor(editor, value, options) {
|
|
|
18237
18291
|
pendingRecoveryFirst = checkpoint.recoveryFirst;
|
|
18238
18292
|
pendingRecoveryFlags = checkpoint.recoveryFlags;
|
|
18239
18293
|
pendingRecoverySecond = checkpoint.recoverySecond;
|
|
18240
|
-
|
|
18241
|
-
return;
|
|
18242
|
-
}
|
|
18243
|
-
pendingRecoveryActive = false;
|
|
18294
|
+
} else pendingRecoveryActive = false;
|
|
18244
18295
|
({current, pointStates} = checkpoint);
|
|
18245
18296
|
sourceValue = innerValue2;
|
|
18246
18297
|
return;
|
|
@@ -18258,6 +18309,29 @@ function createAnchor(editor, value, options) {
|
|
|
18258
18309
|
capture: appendHistoryRecovery,
|
|
18259
18310
|
restore: restoreHistoryRecovery
|
|
18260
18311
|
} } : {},
|
|
18312
|
+
...options.deletion === "nearest" && kind === "range" ? { move: {
|
|
18313
|
+
span(document, documentValue) {
|
|
18314
|
+
materializeHistoryRecovery();
|
|
18315
|
+
return readMappedTo(documentValue, () => current && pointStates.map((state) => document.positionAt(state.point)));
|
|
18316
|
+
},
|
|
18317
|
+
place(document, documentValue, first, second) {
|
|
18318
|
+
const sides = getRangeEndpointAssociations(first.forward[0] <= second.forward[0] ? "forward" : "backward", association);
|
|
18319
|
+
const [anchor, focus] = [first, second].map((place, index) => {
|
|
18320
|
+
const point = document.pointAt(...sides[index] === 1 ? place.forward : place.backward);
|
|
18321
|
+
const includeRoot = pointStates[index]?.includeRoot ?? false;
|
|
18322
|
+
return point && withPublicPointRoot(point, root, includeRoot);
|
|
18323
|
+
});
|
|
18324
|
+
if (!anchor || !focus) return false;
|
|
18325
|
+
placed = true;
|
|
18326
|
+
sourceValue = documentValue;
|
|
18327
|
+
pointStates = [anchor, focus].map((point) => createPointState(runtimeEditor, sourceValue, point, root, document));
|
|
18328
|
+
current = {
|
|
18329
|
+
anchor,
|
|
18330
|
+
focus
|
|
18331
|
+
};
|
|
18332
|
+
return true;
|
|
18333
|
+
}
|
|
18334
|
+
} } : {},
|
|
18261
18335
|
nodeKeys: () => {
|
|
18262
18336
|
if (current === null) return [];
|
|
18263
18337
|
if (kind === "path") {
|
|
@@ -18291,17 +18365,7 @@ function createAnchor(editor, value, options) {
|
|
|
18291
18365
|
materializeHistoryRecovery();
|
|
18292
18366
|
const innerValue3 = getAnchorStateValue(runtimeEditor) ?? readValue(runtimeEditor);
|
|
18293
18367
|
if (innerValue3 !== sourceValue) if (!subscription.isShadowed()) mapTo(innerValue3);
|
|
18294
|
-
else
|
|
18295
|
-
const checkpoint = {
|
|
18296
|
-
current: cloneAnchorValue(current),
|
|
18297
|
-
pointStates: clonePointStates(),
|
|
18298
|
-
sourceValue
|
|
18299
|
-
};
|
|
18300
|
-
mapTo(innerValue3);
|
|
18301
|
-
const resolved = cloneAnchorValue(current);
|
|
18302
|
-
({current, pointStates, sourceValue} = checkpoint);
|
|
18303
|
-
return toViewValue(runtimeEditor, root, view, resolved);
|
|
18304
|
-
}
|
|
18368
|
+
else return toViewValue(runtimeEditor, root, view, readMappedTo(innerValue3, () => cloneAnchorValue(current)));
|
|
18305
18369
|
return toViewValue(runtimeEditor, root, view, current);
|
|
18306
18370
|
},
|
|
18307
18371
|
root: toPublicRoot(root)
|
|
@@ -23798,6 +23862,7 @@ const replaceCanonicalChildWindow = (draft, editor, schema, root, rootContent, p
|
|
|
23798
23862
|
root
|
|
23799
23863
|
});
|
|
23800
23864
|
const baselineAt = (from) => beforeDocument ? {
|
|
23865
|
+
afterLength: source.length,
|
|
23801
23866
|
document: beforeDocument,
|
|
23802
23867
|
from,
|
|
23803
23868
|
path
|
|
@@ -25074,6 +25139,26 @@ var FitOriginLog = class {
|
|
|
25074
25139
|
}))) });
|
|
25075
25140
|
}
|
|
25076
25141
|
};
|
|
25142
|
+
const markFit = (origins, offsets, insert) => {
|
|
25143
|
+
const log = new FitOriginLog();
|
|
25144
|
+
const sorted = [...offsets].sort((left, right) => left - right);
|
|
25145
|
+
let runAt = 0;
|
|
25146
|
+
for (const { length, source } of origins.runs) {
|
|
25147
|
+
const runEnd = runAt + length;
|
|
25148
|
+
let kept = runAt;
|
|
25149
|
+
if (source.kind === "document") {
|
|
25150
|
+
for (const offset of sorted) {
|
|
25151
|
+
if (offset < runAt || offset >= runEnd) continue;
|
|
25152
|
+
log.add(offset - kept, "document", source.at + kept - runAt);
|
|
25153
|
+
log.add(1, "fit");
|
|
25154
|
+
kept = offset + 1;
|
|
25155
|
+
}
|
|
25156
|
+
log.add(runEnd - kept, "document", source.at + kept - runAt);
|
|
25157
|
+
} else log.add(length, source.kind);
|
|
25158
|
+
runAt = runEnd;
|
|
25159
|
+
}
|
|
25160
|
+
return log.seal(insert);
|
|
25161
|
+
};
|
|
25077
25162
|
const sliceOrigins = (insert) => {
|
|
25078
25163
|
const log = new FitOriginLog();
|
|
25079
25164
|
log.add(insert.length, "slice");
|
|
@@ -26151,6 +26236,18 @@ const compileSliceFitter = (input) => {
|
|
|
26151
26236
|
}
|
|
26152
26237
|
return false;
|
|
26153
26238
|
};
|
|
26239
|
+
const opensIntoInline = (slice) => {
|
|
26240
|
+
const edgeOpensIntoInline = (edge, depth, side) => {
|
|
26241
|
+
let node = edge;
|
|
26242
|
+
for (let level = 0; level < depth; level++) {
|
|
26243
|
+
if (!node || !ElementApi.isElement(node)) return false;
|
|
26244
|
+
if (getElementBehavior(node).inline) return true;
|
|
26245
|
+
node = node.children.at(side);
|
|
26246
|
+
}
|
|
26247
|
+
return false;
|
|
26248
|
+
};
|
|
26249
|
+
return edgeOpensIntoInline(slice.content[0], slice.openStart, 0) || edgeOpensIntoInline(slice.content.at(-1), slice.openEnd, -1);
|
|
26250
|
+
};
|
|
26154
26251
|
const restorePartiallyDeletedContext = (document, rootChildren, start, end, boundary, exactFrom, exactTo, insert) => {
|
|
26155
26252
|
const tokens = [];
|
|
26156
26253
|
if (boundary.from < exactFrom && boundary.to === exactTo) for (let depth = 1; depth <= end.path.length; depth++) {
|
|
@@ -26461,11 +26558,8 @@ const compileSliceFitter = (input) => {
|
|
|
26461
26558
|
let variantFamilies;
|
|
26462
26559
|
const getTargetVariantFamilies = () => variantFamilies ??= options.target.kind === "root" ? [] : profileCoreDuration("slice-fit-variants", () => getSliceVariantFamilies(inputSlice, at, root, rootChildren, targetRootProgram));
|
|
26463
26560
|
const tokenLength = (token) => token.kind === "text" ? token.text.length : 1;
|
|
26464
|
-
const splitTailNodes = /* @__PURE__ */ new WeakMap();
|
|
26465
26561
|
const openTokenNode = (token) => {
|
|
26466
26562
|
if (token.sourceNode) return token.sourceNode;
|
|
26467
|
-
const splitFrom = splitTailNodes.get(token);
|
|
26468
|
-
if (splitFrom) return splitFrom;
|
|
26469
26563
|
return token.nodeKind === "text" ? {
|
|
26470
26564
|
...token.props,
|
|
26471
26565
|
text: ""
|
|
@@ -26486,12 +26580,10 @@ const compileSliceFitter = (input) => {
|
|
|
26486
26580
|
return allowed;
|
|
26487
26581
|
};
|
|
26488
26582
|
const openTokenAt = /* @__PURE__ */ new WeakMap();
|
|
26489
|
-
const openTokenPath = /* @__PURE__ */ new WeakMap();
|
|
26490
26583
|
const getOpenContext = (position) => profileCoreDuration("slice-fit-open-context", () => document.openContextAt(position).filter(({ from, to }) => from < position && position < to).map(({ from, path }) => {
|
|
26491
26584
|
const token = encodeNodes([document.node(path)]).slice.tokens[0];
|
|
26492
26585
|
if (token?.kind !== "open") throw new Error(`Missing open token at document path [${path}].`);
|
|
26493
26586
|
openTokenAt.set(token, from);
|
|
26494
|
-
openTokenPath.set(token, path);
|
|
26495
26587
|
return token;
|
|
26496
26588
|
}));
|
|
26497
26589
|
const openContextsMatch = (left, right) => {
|
|
@@ -26524,6 +26616,16 @@ const compileSliceFitter = (input) => {
|
|
|
26524
26616
|
return sync;
|
|
26525
26617
|
};
|
|
26526
26618
|
const targetHasInlineAncestor = start.path.slice(0, -1).map((_part, index) => getDescendant(rootChildren, start.path.slice(0, index + 1))).some((node) => ElementApi.isElement(node) && getElementBehavior(node).inline);
|
|
26619
|
+
const getTailSplitProperties = (node, path) => {
|
|
26620
|
+
if (isFittingMove() || getElementBehavior(node).inline) return null;
|
|
26621
|
+
const ancestors = getElementAncestors(rootChildren, path);
|
|
26622
|
+
const declared = getDeclarativeSchema();
|
|
26623
|
+
const content = ancestors[0] ? getCompiledElement(ancestors[0])?.content : targetRootProgram;
|
|
26624
|
+
return !declared || !content || contentAllowsAt(declared, content, node, getDefined(path.at(-1)) + 1, {
|
|
26625
|
+
ancestors,
|
|
26626
|
+
root
|
|
26627
|
+
}) ? api.elementPropertiesForSplitUnder(node, ancestors, root) : null;
|
|
26628
|
+
};
|
|
26527
26629
|
const createLocalTextCandidate = (variant, cost, allowAsymmetric = false) => {
|
|
26528
26630
|
if (exactBounds || !targetText || !NodeApi.isText(targetText)) return null;
|
|
26529
26631
|
if (!allowAsymmetric && inputSlice.openStart === inputSlice.openEnd && variant.openStart !== variant.openEnd) return null;
|
|
@@ -26543,6 +26645,8 @@ const compileSliceFitter = (input) => {
|
|
|
26543
26645
|
const text = ElementApi.isElement(block) ? block.children[0] : void 0;
|
|
26544
26646
|
return !NodeApi.isText(text) || getElementType(block) !== targetType || block.children.length !== 1 || !nodePropertiesEqual(block, targetBlock, "children", targetElementKeys) || !nodePropertiesEqual(text, targetText, "text", targetTextKeys);
|
|
26545
26647
|
})) return null;
|
|
26648
|
+
const tailProperties = getTailSplitProperties(targetBlock, targetPath);
|
|
26649
|
+
if (tailProperties && !nodePropertiesEqual(targetBlock, tailProperties, "children", Object.keys(tailProperties))) return null;
|
|
26546
26650
|
const prefix = targetText.text.slice(0, start.offset);
|
|
26547
26651
|
const suffix = targetText.text.slice(end.offset);
|
|
26548
26652
|
if (!isDetachedContentSlice(variant)) return null;
|
|
@@ -26719,41 +26823,9 @@ const compileSliceFitter = (input) => {
|
|
|
26719
26823
|
const syncPosition = getLocalSyncPosition();
|
|
26720
26824
|
const tail = document.tokens.slice(exactTo, syncPosition).tokens;
|
|
26721
26825
|
const tailContentAt = tail.findIndex((token) => token.kind !== "close");
|
|
26722
|
-
const
|
|
26723
|
-
const opened = [];
|
|
26724
|
-
for (const [tokenAt, token] of encoded.tokens.entries()) if (token.kind === "open") opened.push(tokenAt);
|
|
26725
|
-
else if (token.kind === "close") opened.pop();
|
|
26726
|
-
const openAtEnd = new Set(opened);
|
|
26727
|
-
const parentAdmitsCopyAfter = (token) => {
|
|
26728
|
-
const path = openTokenPath.get(token);
|
|
26729
|
-
const innerSchema = getDeclarativeSchema();
|
|
26730
|
-
if (!path || !innerSchema) return true;
|
|
26731
|
-
const ancestors = getElementAncestors(rootChildren, path.slice(0, -1), { includeTarget: true });
|
|
26732
|
-
const content = ancestors[0] ? getCompiledElement(ancestors[0])?.content : targetRootProgram;
|
|
26733
|
-
return !content || contentAllowsAt(innerSchema, content, openTokenNode(token), (path.at(-1) ?? 0) + 1, {
|
|
26734
|
-
ancestors,
|
|
26735
|
-
root
|
|
26736
|
-
});
|
|
26737
|
-
};
|
|
26738
|
-
const splitTailOf = (target, node) => {
|
|
26739
|
-
const props = api.elementPropertiesForSplitUnder(node, getElementAncestors(rootChildren, getDefined(openTokenPath.get(target))), root);
|
|
26740
|
-
const tailToken = openToken("element", props);
|
|
26741
|
-
splitTailNodes.set(tailToken, {
|
|
26742
|
-
...props,
|
|
26743
|
-
children: node.children
|
|
26744
|
-
});
|
|
26745
|
-
return tailToken;
|
|
26746
|
-
};
|
|
26747
|
-
const getTargetSplitTail = (tokenAt, token) => {
|
|
26748
|
-
const depth = stack.length;
|
|
26749
|
-
const target = localEndContext[depth];
|
|
26750
|
-
const node = target && openTokenNode(target);
|
|
26751
|
-
return !isFittingMove() && token.kind === "open" && openAtEnd.has(tokenAt) && depth < receiving && ElementApi.isElement(node) && !getElementBehavior(node).inline && openContextsMatch(target, token) && stack.every((open, index) => openContextsMatch(open, localEndContext[index])) && parentAdmitsCopyAfter(target) ? splitTailOf(target, node) : null;
|
|
26752
|
-
};
|
|
26753
|
-
for (const [tokenAt, token] of encoded.tokens.entries()) {
|
|
26826
|
+
for (const token of encoded.tokens) {
|
|
26754
26827
|
const appended = output.length;
|
|
26755
|
-
|
|
26756
|
-
if (splitTail ? !openFitted(splitTail) : !process(token, "slice")) return null;
|
|
26828
|
+
if (!process(token, "slice")) return null;
|
|
26757
26829
|
if (output.length > appended) contentStart ??= outputPosition - tokenLength(token);
|
|
26758
26830
|
insertedPosition += tokenLength(token);
|
|
26759
26831
|
if (selectionPosition === null && insertedPosition >= contentEnd) selectionPosition = outputPosition - (insertedPosition - contentEnd);
|
|
@@ -26812,7 +26884,7 @@ const compileSliceFitter = (input) => {
|
|
|
26812
26884
|
const hasContextualStructuralVariant = () => getTargetVariantFamilies().some((family) => family.priority < 0);
|
|
26813
26885
|
const preserveClosedInlineBoundary = inputSlice.openStart === 0 && inputSlice.openEnd === 0 && targetHasInlineAncestor;
|
|
26814
26886
|
const preserveClosedStructuralBoundary = sourceSlice.openStart === 0 && sourceSlice.openEnd === 0 && inputSlice.content.every(rootCanContain) && !sourceSharesTargetContent;
|
|
26815
|
-
const shouldGenerateLocalCandidate = () => prefixInsertionBoundary === null && !exactBounds && inputSlice.content.length > 0 && (!sameTextPath && NodeApi.isText(targetText) && NodeApi.isText(endText) && (start.offset > 0 || end.offset < endText.text.length) || hasContextualStructuralVariant() && start.path.length > 2 && Boolean(targetText && NodeApi.isText(targetText) && targetText.text) || inputSlice.openStart !== inputSlice.openEnd && start.path.length > 2 || inputSlice.openStart === 1 && inputSlice.openEnd === 1 && start.path.length === 2 || inputSlice.content.length > 1 && start.path.length > 2 || inputSlice.openStart > 0 && targetHasInlineAncestor || !collapsed && targetHasInlineAncestor || inputSlice.openStart === 0 && inputSlice.openEnd === 0 && caretSplitsBlockContent || inputSlice.openStart === 0 && inputSlice.openEnd === 0 && Boolean(targetText && NodeApi.isText(targetText) && (targetText.text ? sourceSharesTargetContent ? start.offset > 0 || end.offset < targetText.text.length : start.offset > 0 && end.offset < targetText.text.length : sourceSharesTargetContent && start.path.length > 2)));
|
|
26887
|
+
const shouldGenerateLocalCandidate = () => prefixInsertionBoundary === null && !exactBounds && inputSlice.content.length > 0 && (!sameTextPath && NodeApi.isText(targetText) && NodeApi.isText(endText) && (start.offset > 0 || end.offset < endText.text.length) || hasContextualStructuralVariant() && start.path.length > 2 && Boolean(targetText && NodeApi.isText(targetText) && targetText.text) || inputSlice.openStart !== inputSlice.openEnd && start.path.length > 2 || inputSlice.openStart === 1 && inputSlice.openEnd === 1 && start.path.length === 2 || inputSlice.openStart > 0 && inputSlice.openEnd > 0 && !opensIntoInline(inputSlice) && sameTextPath && NodeApi.isText(targetText) && start.offset > 0 && end.offset < targetText.text.length || inputSlice.content.length > 1 && start.path.length > 2 || inputSlice.openStart > 0 && targetHasInlineAncestor || !collapsed && targetHasInlineAncestor || inputSlice.openStart === 0 && inputSlice.openEnd === 0 && caretSplitsBlockContent || inputSlice.openStart === 0 && inputSlice.openEnd === 0 && Boolean(targetText && NodeApi.isText(targetText) && (targetText.text ? sourceSharesTargetContent ? start.offset > 0 || end.offset < targetText.text.length : start.offset > 0 && end.offset < targetText.text.length : sourceSharesTargetContent && start.path.length > 2)));
|
|
26816
26888
|
const preferOpenVariants = !preserveClosedInlineBoundary && !preserveClosedStructuralBoundary && (!collapsed || start.offset > 0 && targetText && NodeApi.isText(targetText) && start.offset < targetText.text.length || caretSplitsBlockContent || sourceSharesTargetContent);
|
|
26817
26889
|
const getInsertionContent = (variant) => {
|
|
26818
26890
|
if (variant.openStart !== variant.openEnd) return null;
|
|
@@ -26872,21 +26944,31 @@ const compileSliceFitter = (input) => {
|
|
|
26872
26944
|
to: document.nodeRange(endBlockPath).to
|
|
26873
26945
|
}, [targetBlock, ...sourceBlocks.slice(1)]);
|
|
26874
26946
|
};
|
|
26875
|
-
const
|
|
26876
|
-
if (variant.openStart !== 1 || variant.openEnd !== 1
|
|
26947
|
+
const fitOpenBlocksToLandingIndexes = (variant) => {
|
|
26948
|
+
if (variant.openStart !== 1 || variant.openEnd !== 1) return null;
|
|
26877
26949
|
const targetSchema = getDeclarativeSchema();
|
|
26878
|
-
const
|
|
26879
|
-
|
|
26950
|
+
const blockPathOf = (path) => {
|
|
26951
|
+
let blockPath = path.slice(0, -1);
|
|
26952
|
+
while (blockPath.length > 1) {
|
|
26953
|
+
const node = getDescendant(rootChildren, blockPath);
|
|
26954
|
+
if (!ElementApi.isElement(node) || !getElementBehavior(node).inline) break;
|
|
26955
|
+
blockPath = blockPath.slice(0, -1);
|
|
26956
|
+
}
|
|
26957
|
+
return blockPath;
|
|
26958
|
+
};
|
|
26959
|
+
const startBlockPath = blockPathOf(start.path);
|
|
26960
|
+
const endBlockPath = blockPathOf(end.path);
|
|
26880
26961
|
const parentPath = startBlockPath.slice(0, -1);
|
|
26881
26962
|
const endParentPath = endBlockPath.slice(0, -1);
|
|
26882
26963
|
const startIndex = startBlockPath.at(-1);
|
|
26883
26964
|
const parent = parentPath.length ? getDescendant(rootChildren, parentPath) : null;
|
|
26884
26965
|
const content = targetSchema && parent && ElementApi.isElement(parent) ? targetSchema.elements.byType.get(getElementType(parent) ?? "")?.content : targetSchema ? targetRootProgram : null;
|
|
26885
|
-
if (!targetSchema || !content
|
|
26966
|
+
if (!targetSchema || !content || startIndex === void 0 || parentPath.length !== endParentPath.length || parentPath.some((part, index) => part !== endParentPath[index]) || variant.content.some((child) => !ElementApi.isElement(child))) return null;
|
|
26886
26967
|
const targetOptions = {
|
|
26887
26968
|
ancestors: parent && ElementApi.isElement(parent) ? [parent, ...getElementAncestors(rootChildren, parentPath)] : [],
|
|
26888
26969
|
root
|
|
26889
26970
|
};
|
|
26971
|
+
const slotPastPrefix = (content.prefix && content.remainder || content).defaultPlan;
|
|
26890
26972
|
const fitted = [];
|
|
26891
26973
|
let changed = false;
|
|
26892
26974
|
for (const [offset, descendant] of variant.content.entries()) {
|
|
@@ -26896,7 +26978,7 @@ const compileSliceFitter = (input) => {
|
|
|
26896
26978
|
fitted.push(sourceBlock);
|
|
26897
26979
|
continue;
|
|
26898
26980
|
}
|
|
26899
|
-
const slot = content.prefix[index];
|
|
26981
|
+
const slot = content.prefix?.[index] ?? (slotPastPrefix?.kind === "element" ? slotPastPrefix : null);
|
|
26900
26982
|
if (!slot) return null;
|
|
26901
26983
|
const shell = createDeclarativeAndFill(targetSchema, slot.type, slot.properties, /* @__PURE__ */ new Set(), targetOptions);
|
|
26902
26984
|
if (!contextsShareContent(shell, sourceBlock)) return null;
|
|
@@ -26979,6 +27061,60 @@ const compileSliceFitter = (input) => {
|
|
|
26979
27061
|
});
|
|
26980
27062
|
};
|
|
26981
27063
|
const getStructuralContext = (position) => document.openContextAt(position).filter((entry) => entry.from < position && position < entry.to);
|
|
27064
|
+
const withTailSplit = (candidate) => {
|
|
27065
|
+
if (!("insert" in candidate) || options.target.kind === "root") return candidate;
|
|
27066
|
+
const { from, insert, origins, to } = candidate;
|
|
27067
|
+
const destination = getStructuralContext(exactTo);
|
|
27068
|
+
const closedFirst = document.tokens.slice(exactTo, Math.min(document.length, exactTo + destination.length + 1)).tokens.findIndex((token) => token.kind !== "close");
|
|
27069
|
+
const receiving = closedFirst === -1 ? 0 : destination.length - closedFirst;
|
|
27070
|
+
if (receiving === 0) return candidate;
|
|
27071
|
+
let tailAt = to === exactTo ? insert.length : null;
|
|
27072
|
+
let runAt = 0;
|
|
27073
|
+
for (const { length, source } of origins.runs) {
|
|
27074
|
+
if (tailAt !== null) break;
|
|
27075
|
+
if (source.kind === "document" && source.at <= exactTo && exactTo < source.at + length) tailAt = runAt + exactTo - source.at;
|
|
27076
|
+
runAt += length;
|
|
27077
|
+
}
|
|
27078
|
+
if (tailAt === null) return candidate;
|
|
27079
|
+
const stack = getStructuralContext(from).map(() => null);
|
|
27080
|
+
let position = 0;
|
|
27081
|
+
for (const [index, token] of insert.tokens.entries()) {
|
|
27082
|
+
if (position >= tailAt) break;
|
|
27083
|
+
if (token.kind === "open") stack.push({
|
|
27084
|
+
at: position,
|
|
27085
|
+
index
|
|
27086
|
+
});
|
|
27087
|
+
else if (token.kind === "close") stack.pop();
|
|
27088
|
+
position += tokenLength(token);
|
|
27089
|
+
}
|
|
27090
|
+
if (stack.length !== destination.length) return candidate;
|
|
27091
|
+
const replaced = /* @__PURE__ */ new Map();
|
|
27092
|
+
const replacedAt = [];
|
|
27093
|
+
for (let depth = stack.length - 1; depth >= 0; depth--) {
|
|
27094
|
+
const written = stack[depth];
|
|
27095
|
+
if (!written) break;
|
|
27096
|
+
if (depth >= receiving) continue;
|
|
27097
|
+
const token = insert.tokens[written.index];
|
|
27098
|
+
const { path } = destination[depth];
|
|
27099
|
+
const node = document.node(path);
|
|
27100
|
+
if (NodeApi.isText(node)) {
|
|
27101
|
+
if (token.kind !== "open" || token.nodeKind !== "text") break;
|
|
27102
|
+
continue;
|
|
27103
|
+
}
|
|
27104
|
+
if (token.kind !== "open" || token.nodeKind !== "element" || getElementType(token.props) !== getElementType(node)) break;
|
|
27105
|
+
const props = getTailSplitProperties(node, path);
|
|
27106
|
+
if (!props || jsonEqual$1(props, token.props)) continue;
|
|
27107
|
+
replaced.set(written.index, openToken("element", props));
|
|
27108
|
+
replacedAt.push(written.at);
|
|
27109
|
+
}
|
|
27110
|
+
if (replaced.size === 0) return candidate;
|
|
27111
|
+
const rewritten = PreparedTokenSlice.fromTokens(insert.tokens.map((token, index) => replaced.get(index) ?? token));
|
|
27112
|
+
return Object.freeze({
|
|
27113
|
+
...candidate,
|
|
27114
|
+
insert: rewritten,
|
|
27115
|
+
origins: markFit(origins, replacedAt, rewritten)
|
|
27116
|
+
});
|
|
27117
|
+
};
|
|
26982
27118
|
const textCell = (() => {
|
|
26983
27119
|
const context = getStructuralContext(exactFrom);
|
|
26984
27120
|
for (let level = context.length - 1; level >= 0; level -= 1) {
|
|
@@ -27154,8 +27290,8 @@ const compileSliceFitter = (input) => {
|
|
|
27154
27290
|
}));
|
|
27155
27291
|
};
|
|
27156
27292
|
const directLocalCandidate = prefixInsertionBoundary === null && inputSlice.openStart === 1 && inputSlice.openEnd === 1 ? createLocalTextCandidate(inputSlice, 0) : null;
|
|
27157
|
-
const
|
|
27158
|
-
const
|
|
27293
|
+
const landingTypedSlice = fitOpenBlocksToLandingIndexes(inputSlice);
|
|
27294
|
+
const landingTypedCandidate = landingTypedSlice ? createLocalTextCandidate(landingTypedSlice, -1) : null;
|
|
27159
27295
|
const selectedPrefixCandidate = (() => {
|
|
27160
27296
|
if (options.target.kind !== "range" || textCell || exactBounds || !sameTextPath || collapsed || !targetText || !NodeApi.isText(targetText)) return null;
|
|
27161
27297
|
const boundary = getPrefixInsertionBoundary(at, rootChildren, document, inputSlice, targetRootProgram, true);
|
|
@@ -27223,7 +27359,7 @@ const compileSliceFitter = (input) => {
|
|
|
27223
27359
|
selectionOffset: getContentEndOffset(insert),
|
|
27224
27360
|
to: document.length
|
|
27225
27361
|
});
|
|
27226
|
-
})() : closedBoundaryCandidate ?? selectedPrefixCandidate ?? (
|
|
27362
|
+
})() : closedBoundaryCandidate ?? selectedPrefixCandidate ?? (landingTypedCandidate && isStructurallyApplicable(landingTypedCandidate) ? landingTypedCandidate : null) ?? (directLocalCandidate && "preparedOpenBlock" in directLocalCandidate && isStructurallyApplicable(directLocalCandidate) ? {
|
|
27227
27363
|
...directLocalCandidate,
|
|
27228
27364
|
...preparedInput ? { preparation: preparedInput.preparation } : {}
|
|
27229
27365
|
} : selectSliceFitCandidate({
|
|
@@ -27248,7 +27384,7 @@ const compileSliceFitter = (input) => {
|
|
|
27248
27384
|
seeds: createSeeds()
|
|
27249
27385
|
}));
|
|
27250
27386
|
if (!selectedCandidate) return false;
|
|
27251
|
-
const fittedCandidate = profileCoreDuration("slice-fit-candidate-materialize", () => materializeCandidate(selectedCandidate));
|
|
27387
|
+
const fittedCandidate = profileCoreDuration("slice-fit-candidate-materialize", () => materializeCandidate(withTailSplit(selectedCandidate)));
|
|
27252
27388
|
const sections = options.target.kind === "range" && !exactBounds && options.target.byLook !== "commit" ? fitSections(fittedCandidate) : null;
|
|
27253
27389
|
const materializedCandidate = options.target.kind === "range" && !exactBounds && !sections ? withoutUnchangedTail(document, fittedCandidate) : fittedCandidate;
|
|
27254
27390
|
const candidate = materializedCandidate.preparation ? Object.freeze({
|
|
@@ -27789,7 +27925,7 @@ const acceptsPropertyValue = (descriptor, value) => {
|
|
|
27789
27925
|
}
|
|
27790
27926
|
};
|
|
27791
27927
|
const getDocumentRoot = (value, root) => root === "main" ? value.children : value.roots?.[root] ?? [];
|
|
27792
|
-
const getDocumentRootNodes = (value, root) => valueRootNodes(value, root);
|
|
27928
|
+
const getDocumentRootNodes$1 = (value, root) => valueRootNodes(value, root);
|
|
27793
27929
|
const editorRootLabel = (root) => root === "main" ? "primary root" : `root "${root}"`;
|
|
27794
27930
|
const getDescendant = (children, path) => {
|
|
27795
27931
|
let descendants = children;
|
|
@@ -28324,7 +28460,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28324
28460
|
if (index === void 0 || !ancestors) return false;
|
|
28325
28461
|
const [parent] = ancestors;
|
|
28326
28462
|
if (parent && !getCompiledElement(parent)?.content) return true;
|
|
28327
|
-
return canPlaceIn(ancestors, parent?.children ?? getDocumentRootNodes(getDocument(), root), fit, index, {
|
|
28463
|
+
return canPlaceIn(ancestors, parent?.children ?? getDocumentRootNodes$1(getDocument(), root), fit, index, {
|
|
28328
28464
|
removing,
|
|
28329
28465
|
root
|
|
28330
28466
|
});
|
|
@@ -28430,7 +28566,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28430
28566
|
};
|
|
28431
28567
|
};
|
|
28432
28568
|
const getSlotAncestors = (at, root) => {
|
|
28433
|
-
const ancestors = at.length > 1 ? getElementAncestors(getDocumentRootNodes(getDocument(), root), at) : [];
|
|
28569
|
+
const ancestors = at.length > 1 ? getElementAncestors(getDocumentRootNodes$1(getDocument(), root), at) : [];
|
|
28434
28570
|
return ancestors.length === at.length - 1 ? ancestors : null;
|
|
28435
28571
|
};
|
|
28436
28572
|
const resolveDefaultSlot = (at, root) => {
|
|
@@ -28698,10 +28834,11 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28698
28834
|
const outputKeys = Object.keys(canonicalOutput);
|
|
28699
28835
|
return sourceKeys.length === outputKeys.length && sourceKeys.every((key) => Object.hasOwn(canonicalOutput, key) && structurallyEqual(source[key], canonicalOutput[key])) ? source : canonicalOutput;
|
|
28700
28836
|
};
|
|
28701
|
-
const canonicalizeDeclarativeChildren = (children, schema, root, ancestors, dropMisplaced, baseline,
|
|
28837
|
+
const canonicalizeDeclarativeChildren = (children, schema, root, ancestors, dropMisplaced, baseline, carried, prefix = []) => {
|
|
28702
28838
|
const canonical = children.map((node, index) => {
|
|
28703
|
-
const
|
|
28704
|
-
|
|
28839
|
+
const at = index + (baseline?.from ?? 0);
|
|
28840
|
+
const previous = baseline?.children.at(at);
|
|
28841
|
+
if (node === previous || baseline !== void 0 && baseline.shift !== 0 && node === baseline.children.at(at + baseline.shift)) return node;
|
|
28705
28842
|
countCoreWork("canonicalNodes");
|
|
28706
28843
|
const path = carried ? [...prefix, index] : prefix;
|
|
28707
28844
|
const carriedKey = carried && ((key) => carried(path, node, key));
|
|
@@ -28710,7 +28847,11 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28710
28847
|
const previousChildren = previous && !NodeApi.isText(previous) && getElementType(previous) === type ? previous.children : void 0;
|
|
28711
28848
|
if (!type || !schema.elements.byType.has(type)) {
|
|
28712
28849
|
if (schema.unknown === "reject") throw new EditorSchemaValidationError(`Unknown editor element type "${type ?? "missing"}".`);
|
|
28713
|
-
const nested = canonicalizeDeclarativeChildren(node.children, schema, root, [node, ...ancestors], dropMisplaced, previousChildren
|
|
28850
|
+
const nested = canonicalizeDeclarativeChildren(node.children, schema, root, [node, ...ancestors], dropMisplaced, previousChildren && {
|
|
28851
|
+
children: previousChildren,
|
|
28852
|
+
from: 0,
|
|
28853
|
+
shift: 0
|
|
28854
|
+
}, carried, path);
|
|
28714
28855
|
return nested === node.children ? node : {
|
|
28715
28856
|
...node,
|
|
28716
28857
|
children: nested
|
|
@@ -28721,7 +28862,11 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28721
28862
|
"type",
|
|
28722
28863
|
...(schema.elements.byType.get(type)?.contentRoots.size ?? 0) > 0 ? ["childRoots"] : []
|
|
28723
28864
|
]), dropMisplaced, false, void 0, carriedKey);
|
|
28724
|
-
const nested = canonicalizeDeclarativeChildren(node.children, schema, root, [candidate, ...ancestors], dropMisplaced, previousChildren
|
|
28865
|
+
const nested = canonicalizeDeclarativeChildren(node.children, schema, root, [candidate, ...ancestors], dropMisplaced, previousChildren && {
|
|
28866
|
+
children: previousChildren,
|
|
28867
|
+
from: 0,
|
|
28868
|
+
shift: 0
|
|
28869
|
+
}, carried, path);
|
|
28725
28870
|
if (candidate === node && nested === node.children) return node;
|
|
28726
28871
|
return {
|
|
28727
28872
|
...candidate,
|
|
@@ -28742,7 +28887,11 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28742
28887
|
}
|
|
28743
28888
|
previous = parent.children;
|
|
28744
28889
|
}
|
|
28745
|
-
const canonical = schema ? canonicalizeDeclarativeChildren(children, schema, root, ancestors, dropMisplaced, previous
|
|
28890
|
+
const canonical = schema ? canonicalizeDeclarativeChildren(children, schema, root, ancestors, dropMisplaced, previous && baseline ? {
|
|
28891
|
+
children: previous,
|
|
28892
|
+
from: baseline.from,
|
|
28893
|
+
shift: previous.length - baseline.afterLength
|
|
28894
|
+
} : void 0, carried) : children;
|
|
28746
28895
|
if (canonicalizationObserver?.root === root && ancestors.length === 0 && baseline === void 0) canonicalizationObserver.passes.push(Object.freeze({
|
|
28747
28896
|
input: children,
|
|
28748
28897
|
output: canonical
|
|
@@ -28798,7 +28947,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28798
28947
|
return schema && referencedKeysOf(schema).size > 0 ? copyChildren(children, root, ancestors) : children;
|
|
28799
28948
|
};
|
|
28800
28949
|
const copyNodeAtWith = (copy) => (node, path, root = "main") => {
|
|
28801
|
-
const children = getDocumentRootNodes(getDocument(), root);
|
|
28950
|
+
const children = getDocumentRootNodes$1(getDocument(), root);
|
|
28802
28951
|
return copy(node ? [node] : [], root, getElementAncestors(children, path))[0];
|
|
28803
28952
|
};
|
|
28804
28953
|
const copyNodeAt = copyNodeAtWith(copyChildren);
|
|
@@ -28808,7 +28957,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28808
28957
|
return getTextPropertyInParent(schema, key, parentType ? toCompiledTargetContext(parentType, options) : null);
|
|
28809
28958
|
};
|
|
28810
28959
|
const getTextTargetOptions = (value, path, root = "main") => {
|
|
28811
|
-
const children = getDocumentRootNodes(value, root);
|
|
28960
|
+
const children = getDocumentRootNodes$1(value, root);
|
|
28812
28961
|
const ancestors = getElementAncestors(children, path);
|
|
28813
28962
|
return {
|
|
28814
28963
|
ancestors: ancestors.slice(1),
|
|
@@ -28817,7 +28966,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
28817
28966
|
};
|
|
28818
28967
|
};
|
|
28819
28968
|
const getTextTargetOptionsAt = (path, root = "main") => getTextTargetOptions(getDocument(), path, root);
|
|
28820
|
-
const getElementTargetOptionsAt = (path, root = "main", children = getDocumentRootNodes(getDocument(), root)) => ({
|
|
28969
|
+
const getElementTargetOptionsAt = (path, root = "main", children = getDocumentRootNodes$1(getDocument(), root)) => ({
|
|
28821
28970
|
ancestors: getElementAncestors(children, path),
|
|
28822
28971
|
root
|
|
28823
28972
|
});
|
|
@@ -29027,7 +29176,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
29027
29176
|
const landTextPropertiesAt = (properties, at) => {
|
|
29028
29177
|
const schema = getDeclarativeSchema();
|
|
29029
29178
|
if (!schema) return properties;
|
|
29030
|
-
const children = getDocumentRootNodes(at.value, at.root);
|
|
29179
|
+
const children = getDocumentRootNodes$1(at.value, at.root);
|
|
29031
29180
|
const ancestors = getElementAncestors(children, at.path);
|
|
29032
29181
|
const context = toCompiledNodeContext({ text: "" }, ancestors, at.root);
|
|
29033
29182
|
const stored = getDescendant(children, at.path);
|
|
@@ -29061,7 +29210,7 @@ const createEditorSchema = (getEditor, getRegistry = () => getPluginRegistry$1(g
|
|
|
29061
29210
|
...properties,
|
|
29062
29211
|
...retype
|
|
29063
29212
|
};
|
|
29064
|
-
const children = getDocumentRootNodes(getDocument(), root);
|
|
29213
|
+
const children = getDocumentRootNodes$1(getDocument(), root);
|
|
29065
29214
|
const node = getDescendant(children, path);
|
|
29066
29215
|
if (!node) return {};
|
|
29067
29216
|
const ancestors = getElementAncestors(children, path);
|
|
@@ -30106,9 +30255,9 @@ const TX_LOCATES = getRuntimeRegistry("tx-locates", () => /* @__PURE__ */ new We
|
|
|
30106
30255
|
* registered, `locate` also maps them into the document editing commands
|
|
30107
30256
|
* decide on, or returns null when they have no place there, so the method
|
|
30108
30257
|
* does nothing. `false` says the arguments hold no location. A call that
|
|
30109
|
-
* passes a function runs in the caller's root, and `locate`
|
|
30110
|
-
*
|
|
30111
|
-
* that has no declaration throws.
|
|
30258
|
+
* passes a function runs in the caller's root, and `locate` only places its
|
|
30259
|
+
* arguments, so an id that names no element still does nothing. A method
|
|
30260
|
+
* called with arguments that has no declaration throws.
|
|
30112
30261
|
*/
|
|
30113
30262
|
const txLocate = (locate, method) => {
|
|
30114
30263
|
TX_LOCATES.set(method, locate);
|
|
@@ -30187,6 +30336,13 @@ const callMember = (tx, group, path, args) => {
|
|
|
30187
30336
|
const authored = Reflect.get(member, PLUGIN_UPDATE_METHOD);
|
|
30188
30337
|
return Reflect.apply(typeof authored === "function" ? authored : member, owner, args);
|
|
30189
30338
|
};
|
|
30339
|
+
/** @internal */
|
|
30340
|
+
const dispatchOneShot = (caller, transaction, group, key, args) => callAtElementIds(caller, args, (placed, framed) => {
|
|
30341
|
+
const owner = getEditorRuntimeOwner(caller);
|
|
30342
|
+
const target = framed ? caller === owner ? getUpdateView(owner) : getRootTransaction(owner, transaction.view.root() ?? "main") : transaction;
|
|
30343
|
+
const methods = Reflect.get(target, group);
|
|
30344
|
+
return Reflect.apply(getDefined(methods[key]), methods, placed);
|
|
30345
|
+
});
|
|
30190
30346
|
const dispatchPluginUpdate = (caller, transaction, group, path, method, thisArg, args, transactionOnly = false) => {
|
|
30191
30347
|
countCoreWork("pluginDispatches");
|
|
30192
30348
|
const editor = getEditorRuntimeOwner(caller);
|
|
@@ -30207,16 +30363,20 @@ const dispatchPluginUpdate = (caller, transaction, group, path, method, thisArg,
|
|
|
30207
30363
|
const locateCall = (framePlace) => {
|
|
30208
30364
|
const calledInFrame = !framePlace && COMMAND_FRAMES.has(editor);
|
|
30209
30365
|
let targetRoot;
|
|
30210
|
-
if (typeof locate === "function"
|
|
30211
|
-
const
|
|
30366
|
+
if (typeof locate === "function") located = locate(args, { location: ((at) => {
|
|
30367
|
+
const id = elementIdOf(at);
|
|
30368
|
+
const holder = id === void 0 ? void 0 : framePlace ? placeElementIdIn(framePlace, id) : lookupElementId(editor, id);
|
|
30369
|
+
if (holder === null) return null;
|
|
30370
|
+
const keyRoot = holder ? holder.root : getNodeTargetRoot(editor, at);
|
|
30212
30371
|
if (calledInFrame && keyRoot === void 0 && (typeof at === "string" || NodeApi.isDescendant(at))) return null;
|
|
30213
30372
|
const root = keyRoot ?? (SelectionApi.isNode(at) || RangeApi.isRange(at) ? SelectionApi.root(at) : PointApi.isPoint(at) ? at.root : void 0) ?? ownRoot;
|
|
30214
30373
|
if (!callback) {
|
|
30215
30374
|
if (targetRoot !== void 0 && targetRoot !== root) throw new Error(`Plugin method "${name}" targets two roots.`);
|
|
30216
30375
|
targetRoot = root;
|
|
30217
30376
|
}
|
|
30377
|
+
if (holder) return holder.key;
|
|
30218
30378
|
return framePlace ? withEditorUpdateRootScope(editor, root, () => framePlace.location(at)) : at;
|
|
30219
|
-
} });
|
|
30379
|
+
}) });
|
|
30220
30380
|
decidedRoot = callback ? ownRoot : targetRoot ?? inheritedRoot ?? (isView ? ownRoot : getBaseCallRoot(editor));
|
|
30221
30381
|
};
|
|
30222
30382
|
const invoke = (framed) => {
|
|
@@ -30226,7 +30386,7 @@ const dispatchPluginUpdate = (caller, transaction, group, path, method, thisArg,
|
|
|
30226
30386
|
const previous = active.pluginRoot;
|
|
30227
30387
|
active.pluginRoot = callback ? inheritedRoot : decidedRoot;
|
|
30228
30388
|
try {
|
|
30229
|
-
if (callback) return framed ? callMember(getUpdateView(editor), group, path, [...located]) :
|
|
30389
|
+
if (callback) return framed ? callMember(getUpdateView(editor), group, path, [...located]) : Reflect.apply(method, thisArg, located);
|
|
30230
30390
|
const base = !isView && decidedRoot === "main" && (!getCurrentSelection(editor) || getCurrentSelectionRoot(editor) === "main");
|
|
30231
30391
|
if (!framed && (isView ? decidedRoot === ownRoot : base)) return Reflect.apply(method, thisArg, located);
|
|
30232
30392
|
return callMember(getRootTransaction(editor, decidedRoot), group, path, [...located]);
|
|
@@ -30238,15 +30398,23 @@ const dispatchPluginUpdate = (caller, transaction, group, path, method, thisArg,
|
|
|
30238
30398
|
active.pluginRoot = previous;
|
|
30239
30399
|
}
|
|
30240
30400
|
};
|
|
30241
|
-
|
|
30401
|
+
const locatesElementId = () => {
|
|
30402
|
+
let named = false;
|
|
30403
|
+
if (typeof locate === "function") locate(args, { location: ((at) => {
|
|
30404
|
+
named ||= elementIdOf(at) !== void 0;
|
|
30405
|
+
return at;
|
|
30406
|
+
}) });
|
|
30407
|
+
return named;
|
|
30408
|
+
};
|
|
30409
|
+
if (!COMMAND_FRAMES.has(editor) && (!isView || locatesElementId())) {
|
|
30242
30410
|
let result;
|
|
30243
|
-
if (withEditorUpdateRootScope(editor, ownRoot, () => runInEditorCommandFrame(editor, (place) => {
|
|
30411
|
+
if (withViewPlacement(caller, () => withEditorUpdateRootScope(editor, ownRoot, () => runInEditorCommandFrame(editor, (place) => {
|
|
30244
30412
|
locateCall(place);
|
|
30245
30413
|
return () => {
|
|
30246
30414
|
result = invoke(true);
|
|
30247
30415
|
return located !== null;
|
|
30248
30416
|
};
|
|
30249
|
-
}, { targetRoot: () => decidedRoot })) !== null) return result;
|
|
30417
|
+
}, { targetRoot: () => decidedRoot }))) !== null) return result;
|
|
30250
30418
|
}
|
|
30251
30419
|
locateCall();
|
|
30252
30420
|
return invoke(false);
|
|
@@ -30390,6 +30558,7 @@ const createEditorReadApi = (runRead) => {
|
|
|
30390
30558
|
const pluginPathCache = /* @__PURE__ */ new Map();
|
|
30391
30559
|
const read = ((fn) => runRead(fn));
|
|
30392
30560
|
const createGroup = (groupName) => new Proxy({}, { get(target, key, receiver) {
|
|
30561
|
+
if (key === ELEMENT_FINDER) return (id) => read((state) => readElementById(state[groupName], id));
|
|
30393
30562
|
if (typeof key !== "string") return void 0;
|
|
30394
30563
|
if (key === "toJSON") return void 0;
|
|
30395
30564
|
if (key in target) return Reflect.get(target, key, receiver);
|
|
@@ -30493,7 +30662,7 @@ const createEditorUpdateApi = (runUpdate, apiOptions) => {
|
|
|
30493
30662
|
const method = (...args) => invoke((tx) => {
|
|
30494
30663
|
const transactionMethod = tx[groupName][key];
|
|
30495
30664
|
const lower = getSemanticUpdateLowering(transactionMethod);
|
|
30496
|
-
return lower ? lower(tx.command, args, transactionMethod) :
|
|
30665
|
+
return lower ? lower(tx.command, args, transactionMethod) : dispatchOneShot(apiOptions.caller(), tx, groupName, key, [...args]);
|
|
30497
30666
|
});
|
|
30498
30667
|
methodCache.set(key, method);
|
|
30499
30668
|
return method;
|
|
@@ -30737,7 +30906,11 @@ const rejectRootSnapshot = (issue) => {
|
|
|
30737
30906
|
const shownOnlyReadOnly = ({ readOnly, writable }) => readOnly > 0 && writable === 0;
|
|
30738
30907
|
const isShown$1 = ({ surfaces }) => surfaces.readOnly > 0 || surfaces.writable > 0;
|
|
30739
30908
|
const ownsFocus = (state) => "focused" in state;
|
|
30740
|
-
const
|
|
30909
|
+
const isLinkLocked = ({ lockScope }) => {
|
|
30910
|
+
for (let scope = lockScope?.link; scope; scope = scope.link) if (scope.locked) return true;
|
|
30911
|
+
return false;
|
|
30912
|
+
};
|
|
30913
|
+
const isOwnLock = (state) => state.readOnly || shownOnlyReadOnly(state.surfaces) || isLinkLocked(state);
|
|
30741
30914
|
const mountingState = (state) => state.mountedIn && VIEW_STATES.get(state.mountedIn);
|
|
30742
30915
|
const isLocked = (state) => {
|
|
30743
30916
|
const mounting = mountingState(state);
|
|
@@ -30794,18 +30967,20 @@ const withRootRead = (editor, viewState, fn) => {
|
|
|
30794
30967
|
selection: () => null
|
|
30795
30968
|
}) : withAuthoredViewRead(editor, viewState.editor ?? editor, read);
|
|
30796
30969
|
};
|
|
30797
|
-
const withRootGenerator = (editor, viewState, create) =>
|
|
30970
|
+
const withRootGenerator = (editor, viewState, create) => {
|
|
30798
30971
|
const iterator = withRootRead(editor, viewState, () => create()[Symbol.iterator]());
|
|
30799
|
-
|
|
30800
|
-
|
|
30801
|
-
|
|
30802
|
-
|
|
30803
|
-
|
|
30972
|
+
return (function* iterateViewRoot() {
|
|
30973
|
+
try {
|
|
30974
|
+
while (true) {
|
|
30975
|
+
const result = withRootRead(editor, viewState, () => iterator.next());
|
|
30976
|
+
if (result.done) return;
|
|
30977
|
+
yield result.value;
|
|
30978
|
+
}
|
|
30979
|
+
} finally {
|
|
30980
|
+
withRootRead(editor, viewState, () => iterator.return?.());
|
|
30804
30981
|
}
|
|
30805
|
-
}
|
|
30806
|
-
|
|
30807
|
-
}
|
|
30808
|
-
})();
|
|
30982
|
+
})();
|
|
30983
|
+
};
|
|
30809
30984
|
const VIEW_PAGE = Symbol("view page");
|
|
30810
30985
|
const readViewPage = (state) => state[VIEW_PAGE]?.();
|
|
30811
30986
|
const rootMethod = (editor, viewState, method) => ((...args) => withRootRead(editor, viewState, () => method(...args)));
|
|
@@ -30833,28 +31008,32 @@ const withViewSnapshot = (snapshot, viewState, selectionRoot) => {
|
|
|
30833
31008
|
if (selection === snapshot.selection) return snapshot;
|
|
30834
31009
|
return Object.freeze(Object.assign(copyFields({}, snapshot, ["selection"]), { selection }));
|
|
30835
31010
|
};
|
|
30836
|
-
const withRootChildren = (editor, state, viewState) =>
|
|
30837
|
-
|
|
30838
|
-
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
|
|
30842
|
-
|
|
30843
|
-
|
|
30844
|
-
|
|
30845
|
-
|
|
30846
|
-
|
|
30847
|
-
|
|
30848
|
-
|
|
30849
|
-
|
|
30850
|
-
|
|
30851
|
-
|
|
30852
|
-
|
|
30853
|
-
|
|
30854
|
-
|
|
30855
|
-
|
|
30856
|
-
|
|
30857
|
-
|
|
31011
|
+
const withRootChildren = (editor, state, viewState) => {
|
|
31012
|
+
const namesItsRoot = (entry) => viewState.root === "main" || entry?.root !== void 0 ? entry : null;
|
|
31013
|
+
return withElementFinder({
|
|
31014
|
+
...state.nodes,
|
|
31015
|
+
above: rootMethod(editor, viewState, state.nodes.above),
|
|
31016
|
+
block: rootMethod(editor, viewState, state.nodes.block),
|
|
31017
|
+
blocks: rootMethod(editor, viewState, state.nodes.blocks),
|
|
31018
|
+
byId: rootMethod(editor, viewState, (id) => namesItsRoot(state.nodes.byId(id))),
|
|
31019
|
+
children: rootMethod(editor, viewState, state.nodes.children),
|
|
31020
|
+
elementReadOnly: rootMethod(editor, viewState, state.nodes.elementReadOnly),
|
|
31021
|
+
entries: rootGeneratorMethod(editor, viewState, state.nodes.entries),
|
|
31022
|
+
find: rootMethod(editor, viewState, state.nodes.find),
|
|
31023
|
+
first: rootMethod(editor, viewState, state.nodes.first),
|
|
31024
|
+
get: rootMethod(editor, viewState, state.nodes.get),
|
|
31025
|
+
last: rootMethod(editor, viewState, state.nodes.last),
|
|
31026
|
+
leaf: rootMethod(editor, viewState, state.nodes.leaf),
|
|
31027
|
+
levels: rootGeneratorMethod(editor, viewState, state.nodes.levels),
|
|
31028
|
+
next: rootMethod(editor, viewState, state.nodes.next),
|
|
31029
|
+
parent: rootMethod(editor, viewState, state.nodes.parent),
|
|
31030
|
+
path: rootMethod(editor, viewState, state.nodes.path),
|
|
31031
|
+
previous: rootMethod(editor, viewState, state.nodes.previous),
|
|
31032
|
+
some: rootMethod(editor, viewState, state.nodes.some),
|
|
31033
|
+
toArray: rootMethod(editor, viewState, state.nodes.toArray),
|
|
31034
|
+
void: rootMethod(editor, viewState, state.nodes.void)
|
|
31035
|
+
}, rootMethod(editor, viewState, (id) => readElementById(state.nodes, id)));
|
|
31036
|
+
};
|
|
30858
31037
|
const withRootPoints = (editor, state, viewState) => Object.freeze({
|
|
30859
31038
|
...state.points,
|
|
30860
31039
|
after: rootMethod(editor, viewState, state.points.after),
|
|
@@ -30873,6 +31052,7 @@ const withRootRanges = (editor, state, viewState) => Object.freeze({
|
|
|
30873
31052
|
edges: rootMethod(editor, viewState, state.ranges.edges),
|
|
30874
31053
|
fromEntries: rootMethod(editor, viewState, state.ranges.fromEntries),
|
|
30875
31054
|
get: rootMethod(editor, viewState, state.ranges.get),
|
|
31055
|
+
isEmpty: rootMethod(editor, viewState, state.ranges.isEmpty),
|
|
30876
31056
|
project: rootMethod(editor, viewState, state.ranges.project),
|
|
30877
31057
|
unhang: rootMethod(editor, viewState, state.ranges.unhang)
|
|
30878
31058
|
});
|
|
@@ -31074,7 +31254,7 @@ const withViewTransaction = (editor, transaction, viewState, getViewEditor) => {
|
|
|
31074
31254
|
transaction.marks.toggle(key, value);
|
|
31075
31255
|
})
|
|
31076
31256
|
})),
|
|
31077
|
-
nodes:
|
|
31257
|
+
nodes: withElementFinder({
|
|
31078
31258
|
...state.nodes,
|
|
31079
31259
|
insert: (nodes, options) => runImplicitSelectionMutation(options, () => {
|
|
31080
31260
|
transaction.nodes.insert(nodes, options);
|
|
@@ -31106,7 +31286,7 @@ const withViewTransaction = (editor, transaction, viewState, getViewEditor) => {
|
|
|
31106
31286
|
})),
|
|
31107
31287
|
unwrap: (options) => runImplicitSelectionMutation(options, () => transaction.nodes.unwrap(options)) ?? false,
|
|
31108
31288
|
wrap: (element, options) => runImplicitSelectionMutation(options, () => transaction.nodes.wrap(element, options)) ?? false
|
|
31109
|
-
}),
|
|
31289
|
+
}, (id) => readElementById(state.nodes, id)),
|
|
31110
31290
|
selection: Object.freeze(Object.assign(() => state.selection(), {
|
|
31111
31291
|
contains: (target) => state.selection.contains(target),
|
|
31112
31292
|
intersects: (target) => state.selection.intersects(target),
|
|
@@ -31318,6 +31498,7 @@ const createEditorViewRuntime = (sourceEditor, options = {}, presentation, polic
|
|
|
31318
31498
|
authorId: options.authorId ?? sourceView?.authorId,
|
|
31319
31499
|
editor: null,
|
|
31320
31500
|
document,
|
|
31501
|
+
lockScope: void 0,
|
|
31321
31502
|
mountedIn: mountedIn && getEditorRuntime(mountedIn),
|
|
31322
31503
|
...policyTarget && !document ? { policySource: followOf(policyTarget, root) } : {
|
|
31323
31504
|
composing: seedsFocus && sourceEditor.read.view.isComposing(),
|
|
@@ -31348,6 +31529,7 @@ const createEditorViewRuntime = (sourceEditor, options = {}, presentation, polic
|
|
|
31348
31529
|
assertViewWritable(viewState);
|
|
31349
31530
|
return viewRuntime.update(fn, { tags: policy.tags });
|
|
31350
31531
|
}, {
|
|
31532
|
+
caller: () => getDefined(viewEditor),
|
|
31351
31533
|
hasTxGroup: (groupName) => getPluginRegistry$1(sourceEditor).txGroups.has(groupName),
|
|
31352
31534
|
repairValue: () => {
|
|
31353
31535
|
assertViewWritable(viewState);
|
|
@@ -31476,6 +31658,54 @@ const withMountedPresentation = (editor, view, nested = false) => {
|
|
|
31476
31658
|
return mounted;
|
|
31477
31659
|
};
|
|
31478
31660
|
const getCarriedMount = (editor) => MOUNTED_PRESENTATIONS.get(editor);
|
|
31661
|
+
const createViewLockScope = (locked) => ({
|
|
31662
|
+
children: /* @__PURE__ */ new Set(),
|
|
31663
|
+
link: void 0,
|
|
31664
|
+
locked,
|
|
31665
|
+
view: void 0
|
|
31666
|
+
});
|
|
31667
|
+
const linkedViews = (scope, views = []) => {
|
|
31668
|
+
for (const child of scope.children) {
|
|
31669
|
+
if (child.view) views.push(child.view);
|
|
31670
|
+
linkedViews(child, views);
|
|
31671
|
+
}
|
|
31672
|
+
return views;
|
|
31673
|
+
};
|
|
31674
|
+
const reportLockChange = (views, change) => {
|
|
31675
|
+
const was = views.map((view) => view.read.view.isReadOnly());
|
|
31676
|
+
change();
|
|
31677
|
+
views.forEach((view, index) => {
|
|
31678
|
+
if (view.read.view.isReadOnly() !== was[index]) notifyEditorViewState(view, "readOnly");
|
|
31679
|
+
});
|
|
31680
|
+
};
|
|
31681
|
+
const setViewLockScopeLocked = (scope, locked) => {
|
|
31682
|
+
if (scope.locked === locked) return;
|
|
31683
|
+
reportLockChange(linkedViews(scope), () => {
|
|
31684
|
+
scope.locked = locked;
|
|
31685
|
+
});
|
|
31686
|
+
};
|
|
31687
|
+
const linkViewLockScope = (scope, link) => {
|
|
31688
|
+
if (scope.link === link) return;
|
|
31689
|
+
reportLockChange(linkedViews(scope, scope.view ? [scope.view] : []), () => {
|
|
31690
|
+
scope.link?.children.delete(scope);
|
|
31691
|
+
scope.link = link;
|
|
31692
|
+
link?.children.add(scope);
|
|
31693
|
+
});
|
|
31694
|
+
};
|
|
31695
|
+
const joinViewLockScope = (scope, view) => {
|
|
31696
|
+
const state = getDefined(VIEW_STATES.get(getEditorRuntime(view)));
|
|
31697
|
+
reportLockChange([view], () => {
|
|
31698
|
+
state.lockScope = scope;
|
|
31699
|
+
scope.view = view;
|
|
31700
|
+
});
|
|
31701
|
+
return () => {
|
|
31702
|
+
state.lockScope = void 0;
|
|
31703
|
+
if (scope.view === view) scope.view = void 0;
|
|
31704
|
+
};
|
|
31705
|
+
};
|
|
31706
|
+
const flushViewLockScope = (scope) => {
|
|
31707
|
+
for (const view of linkedViews(scope)) flushEditorViewState(view);
|
|
31708
|
+
};
|
|
31479
31709
|
const ROOT_EDITORS = /* @__PURE__ */ new WeakMap();
|
|
31480
31710
|
const carryRootEditors = (view, rootEditor) => {
|
|
31481
31711
|
ROOT_EDITORS.set(view, rootEditor);
|
|
@@ -35410,17 +35640,19 @@ const removeDeleteContents = (editor, plan) => {
|
|
|
35410
35640
|
association: "forward",
|
|
35411
35641
|
deletion: "drop"
|
|
35412
35642
|
}) : null;
|
|
35413
|
-
let
|
|
35643
|
+
let removedContent = false;
|
|
35414
35644
|
if (!plan.isSingleText && !plan.startNonEditable && !skipStartText) {
|
|
35415
35645
|
const point = getDefined(startAnchor.resolve());
|
|
35416
35646
|
const [node] = leaf(editor, point);
|
|
35417
35647
|
const text = node.text.slice(plan.start.offset);
|
|
35418
35648
|
if (text.length > 0) {
|
|
35419
35649
|
applyBuiltDocumentChange(editor, (builder, root) => builder.removeText(root, point.path, plan.start.offset, text));
|
|
35420
|
-
|
|
35650
|
+
removedContent = true;
|
|
35421
35651
|
}
|
|
35422
35652
|
}
|
|
35423
35653
|
pathAnchors.slice().reverse().map((anchor) => anchor.release()).filter((path) => path !== null).forEach((path) => {
|
|
35654
|
+
const node = getCurrentNode$1(editor, path);
|
|
35655
|
+
if (!NodeApi.isText(node) || node.text.length > 0) removedContent = true;
|
|
35424
35656
|
applyBuiltDocumentChange(editor, (builder, root) => builder.removeNode(root, path));
|
|
35425
35657
|
});
|
|
35426
35658
|
if (!plan.endNonEditable && !plan.preserveEndBlock && !skipEndText) {
|
|
@@ -35431,7 +35663,7 @@ const removeDeleteContents = (editor, plan) => {
|
|
|
35431
35663
|
const text = node.text.slice(offset, plan.end.offset);
|
|
35432
35664
|
if (text.length > 0) {
|
|
35433
35665
|
applyBuiltDocumentChange(editor, (builder, root) => builder.removeText(root, point.path, offset, text));
|
|
35434
|
-
|
|
35666
|
+
removedContent = true;
|
|
35435
35667
|
}
|
|
35436
35668
|
}
|
|
35437
35669
|
return {
|
|
@@ -35439,7 +35671,7 @@ const removeDeleteContents = (editor, plan) => {
|
|
|
35439
35671
|
endAnchor,
|
|
35440
35672
|
startBlockAnchor,
|
|
35441
35673
|
endChain,
|
|
35442
|
-
|
|
35674
|
+
removedContent
|
|
35443
35675
|
};
|
|
35444
35676
|
};
|
|
35445
35677
|
//#endregion
|
|
@@ -35839,11 +36071,13 @@ const releaseCollapsePoint = (editor, plan, removal, keptIncompatibleBlockBounda
|
|
|
35839
36071
|
offset: plan.start.offset
|
|
35840
36072
|
} : reverseMergePoint;
|
|
35841
36073
|
};
|
|
35842
|
-
const
|
|
35843
|
-
|
|
35844
|
-
|
|
35845
|
-
|
|
35846
|
-
|
|
36074
|
+
const readFinalPointOptions = (plan, removedContent) => ({
|
|
36075
|
+
reverse: plan.reverse,
|
|
36076
|
+
allowForwardBoundaryJump: plan.initialAt != null && LocationApi.isPoint(plan.initialAt) || plan.initialAt != null && LocationApi.isRange(plan.initialAt) && RangeApi.isCollapsed(plan.initialAt),
|
|
36077
|
+
removedContent
|
|
36078
|
+
});
|
|
36079
|
+
const resolveDeletePoint = (editor, plan, collapseTarget, removedContent) => {
|
|
36080
|
+
let point$4 = normalizeFinalDeletePoint(editor, collapseTarget, readFinalPointOptions(plan, removedContent));
|
|
35847
36081
|
if (!plan.reverse && !plan.isCollapsed) point$4 = moveLeadingSpacerPointIntoFollowingInline(editor, point$4);
|
|
35848
36082
|
if (!plan.reverse && plan.isCollapsed) point$4 = moveTrailingTextPointIntoFollowingInline(editor, point$4);
|
|
35849
36083
|
if (!plan.reverse && !plan.isCollapsed && plan.isAcrossBlocks) point$4 = movePointToFollowingInline(editor, point$4);
|
|
@@ -35879,18 +36113,15 @@ const resolveDeletePoint = (editor, plan, collapseTarget) => {
|
|
|
35879
36113
|
}
|
|
35880
36114
|
return point$4;
|
|
35881
36115
|
};
|
|
35882
|
-
const resolveDeleteSelection = (editor, plan, collapseTarget, tx) => {
|
|
35883
|
-
const point = resolveDeletePoint(editor, plan, collapseTarget);
|
|
36116
|
+
const resolveDeleteSelection = (editor, plan, collapseTarget, tx, removedContent) => {
|
|
36117
|
+
const point = resolveDeletePoint(editor, plan, collapseTarget, removedContent);
|
|
35884
36118
|
if ((!plan.initialAt || !LocationApi.isPath(plan.initialAt)) && point) tx.setSelection(SelectionApi.text({
|
|
35885
36119
|
anchor: point,
|
|
35886
36120
|
focus: point
|
|
35887
36121
|
}));
|
|
35888
36122
|
const finalSelection = getCurrentSelection(editor);
|
|
35889
36123
|
if (finalSelection && RangeApi.isRange(finalSelection) && RangeApi.isCollapsed(finalSelection)) {
|
|
35890
|
-
let normalizedSelectionPoint = normalizeFinalDeletePoint(editor, finalSelection.anchor,
|
|
35891
|
-
reverse: plan.reverse,
|
|
35892
|
-
allowForwardBoundaryJump: plan.initialAt != null && LocationApi.isPoint(plan.initialAt) || plan.initialAt != null && LocationApi.isRange(plan.initialAt) && RangeApi.isCollapsed(plan.initialAt)
|
|
35893
|
-
});
|
|
36124
|
+
let normalizedSelectionPoint = normalizeFinalDeletePoint(editor, finalSelection.anchor, readFinalPointOptions(plan, removedContent));
|
|
35894
36125
|
if (!plan.reverse && !plan.isCollapsed) normalizedSelectionPoint = moveLeadingSpacerPointIntoFollowingInline(editor, normalizedSelectionPoint);
|
|
35895
36126
|
if (!plan.reverse && plan.isCollapsed) normalizedSelectionPoint = moveTrailingTextPointIntoFollowingInline(editor, normalizedSelectionPoint);
|
|
35896
36127
|
if (!plan.reverse && !plan.isCollapsed && plan.isAcrossBlocks) normalizedSelectionPoint = movePointToFollowingInline(editor, normalizedSelectionPoint);
|
|
@@ -35953,14 +36184,14 @@ const normalizeFinalDeletePoint = (editor, point$5, options) => {
|
|
|
35953
36184
|
const nextSiblingPath = point$5.path.at(-1) == null ? null : PathApi.next(point$5.path);
|
|
35954
36185
|
if (isTextNode$1(currentNode) && point$5.offset === currentNode.text.length && nextSiblingPath && hasPath(editor, nextSiblingPath)) {
|
|
35955
36186
|
const nextSibling = getCurrentNode$1(editor, nextSiblingPath);
|
|
35956
|
-
if (NodeApi.isElement(nextSibling) && (
|
|
36187
|
+
if (NodeApi.isElement(nextSibling) && (getEditorSchema(editor).isInline(nextSibling) ? getEditorSchema(editor).isVoid(nextSibling) : !options.removedContent)) return point(editor, nextSiblingPath, { edge: "start" });
|
|
35957
36188
|
}
|
|
35958
36189
|
if (point$5.path.length >= 2) {
|
|
35959
36190
|
const parentPath = point$5.path.slice(0, -1);
|
|
35960
36191
|
if (hasPath(editor, parentPath)) {
|
|
35961
36192
|
const parent = getCurrentNode$1(editor, parentPath);
|
|
35962
36193
|
if (NodeApi.isElement(parent) && parentPath.length > 1 && PointApi.equals(point$5, point(editor, parentPath, { edge: "end" }))) {
|
|
35963
|
-
if (!getEditorSchema(editor).isVoid(parent) && NodeApi.string(parent) === "") return point$5;
|
|
36194
|
+
if (options.removedContent && !getEditorSchema(editor).isInline(parent) || !getEditorSchema(editor).isVoid(parent) && NodeApi.string(parent) === "") return point$5;
|
|
35964
36195
|
const afterParentPath = parentPath.at(-1) == null ? null : PathApi.next(parentPath);
|
|
35965
36196
|
if (afterParentPath && hasPath(editor, afterParentPath)) return point(editor, afterParentPath, { edge: "start" });
|
|
35966
36197
|
}
|
|
@@ -36212,7 +36443,7 @@ const removePlainRange = (editor, range, voids) => {
|
|
|
36212
36443
|
if (target?.kind !== "range") return null;
|
|
36213
36444
|
const removal = removeDeleteContents(editor, target);
|
|
36214
36445
|
const keptIncompatibleBlockBoundary = reconcileDeleteStructure(editor, target, removal);
|
|
36215
|
-
return resolveDeletePoint(editor, target, releaseCollapsePoint(editor, target, removal, keptIncompatibleBlockBoundary)) ?? null;
|
|
36446
|
+
return resolveDeletePoint(editor, target, releaseCollapsePoint(editor, target, removal, keptIncompatibleBlockBoundary), removal.removedContent) ?? null;
|
|
36216
36447
|
};
|
|
36217
36448
|
const inRoot = (editor, root, run) => root ? withEditorUpdateRoot(editor, root, () => withEditorUpdateRootChildren(editor, root, run)) : run();
|
|
36218
36449
|
const inRemovalRoot = (editor, at, run) => inRoot(editor, getTransactionRoot(editor, at), () => runEditorTransaction(editor, (tx) => {
|
|
@@ -36332,7 +36563,7 @@ const applyAt = (editor, tx, site, prepared) => {
|
|
|
36332
36563
|
const removal = removeDeleteContents(editor, target);
|
|
36333
36564
|
const keptIncompatibleBlockBoundary = reconcileDeleteStructure(editor, target, removal);
|
|
36334
36565
|
const landing = releaseCollapsePoint(editor, target, removal, keptIncompatibleBlockBoundary);
|
|
36335
|
-
if (writesSelection) resolveDeleteSelection(editor, target, landing, tx);
|
|
36566
|
+
if (writesSelection) resolveDeleteSelection(editor, target, landing, tx, removal.removedContent);
|
|
36336
36567
|
setDeletedMarks();
|
|
36337
36568
|
return {
|
|
36338
36569
|
kind: "ordinary",
|
|
@@ -37867,6 +38098,48 @@ const notifyEditorChangeListeners = (editor, commit, beforeValue, afterValue) =>
|
|
|
37867
38098
|
});
|
|
37868
38099
|
};
|
|
37869
38100
|
//#endregion
|
|
38101
|
+
//#region src/core/change/range-content.ts
|
|
38102
|
+
const insideVoid = (voids, position) => {
|
|
38103
|
+
let low = 0;
|
|
38104
|
+
let high = voids.length - 1;
|
|
38105
|
+
while (low <= high) {
|
|
38106
|
+
const middle = low + high >> 1;
|
|
38107
|
+
const [voidFrom, voidTo] = voids[middle];
|
|
38108
|
+
if (position < voidFrom) high = middle - 1;
|
|
38109
|
+
else if (position >= voidTo) low = middle + 1;
|
|
38110
|
+
else return true;
|
|
38111
|
+
}
|
|
38112
|
+
return false;
|
|
38113
|
+
};
|
|
38114
|
+
const FIRST_WINDOW = 64;
|
|
38115
|
+
/** @internal */
|
|
38116
|
+
const coversContent = (index, from, to, schema) => {
|
|
38117
|
+
if (from >= to) return false;
|
|
38118
|
+
for (let width = FIRST_WINDOW;; width *= 2) {
|
|
38119
|
+
const end = Math.min(to, from + width);
|
|
38120
|
+
if (coversContentUpTo(index, from, end, to, schema)) return true;
|
|
38121
|
+
if (end === to) return false;
|
|
38122
|
+
}
|
|
38123
|
+
};
|
|
38124
|
+
const coversContentUpTo = (index, from, end, to, schema) => {
|
|
38125
|
+
const entries = index.nodeRangesTouching(from, end);
|
|
38126
|
+
const voids = [];
|
|
38127
|
+
countCoreWork("contentSpanNodes", entries.length);
|
|
38128
|
+
for (const entry of entries) {
|
|
38129
|
+
if (entry.kind === "text" || !schema.isVoid(index.node(entry.path))) continue;
|
|
38130
|
+
if (from <= entry.from && entry.to <= to) return true;
|
|
38131
|
+
voids.push([entry.from, entry.to]);
|
|
38132
|
+
}
|
|
38133
|
+
voids.sort(([a], [b]) => a - b);
|
|
38134
|
+
const outerVoids = [];
|
|
38135
|
+
for (const range of voids) if (range[0] >= (outerVoids.at(-1)?.[1] ?? -1)) outerVoids.push(range);
|
|
38136
|
+
return entries.some((entry) => {
|
|
38137
|
+
if (entry.kind !== "text") return false;
|
|
38138
|
+
const start = Math.max(from, entry.contentFrom);
|
|
38139
|
+
return start < Math.min(end, entry.contentTo) && !insideVoid(outerVoids, start);
|
|
38140
|
+
});
|
|
38141
|
+
};
|
|
38142
|
+
//#endregion
|
|
37870
38143
|
//#region src/core/content-slice-roots.ts
|
|
37871
38144
|
const namesContentRoot = (editor, children) => {
|
|
37872
38145
|
const schema = getEditorSchema(editor);
|
|
@@ -38831,21 +39104,13 @@ const subscribeRootTarget = (owner, presentation, root, listener) => {
|
|
|
38831
39104
|
dropUnusedEntry(key, entry);
|
|
38832
39105
|
};
|
|
38833
39106
|
};
|
|
38834
|
-
const showsRootView = (owner, presentation) => {
|
|
38835
|
-
for (const entry of ENTRIES.get(owner)?.get(presentation)?.values() ?? []) for (const view of entry.views) if (isShown(view)) return true;
|
|
38836
|
-
return false;
|
|
38837
|
-
};
|
|
38838
39107
|
const readRootViewPresentationRevision = (presentation) => NOTICES.get(presentation)?.revision ?? 0;
|
|
38839
|
-
/**
|
|
38840
|
-
* Hear, once per microtask, that a view of the presentation mounted,
|
|
38841
|
-
* unmounted, gained or lost its surface, changed its read-only state, or that
|
|
38842
|
-
* the user used another of its views.
|
|
38843
|
-
*/
|
|
38844
39108
|
const subscribeRootViewPresentation = (presentation, listener) => {
|
|
38845
39109
|
const { listeners } = noticeOf(presentation);
|
|
38846
|
-
|
|
39110
|
+
const entry = () => listener();
|
|
39111
|
+
listeners.add(entry);
|
|
38847
39112
|
return () => {
|
|
38848
|
-
listeners.delete(
|
|
39113
|
+
listeners.delete(entry);
|
|
38849
39114
|
};
|
|
38850
39115
|
};
|
|
38851
39116
|
const readViewState = (view) => {
|
|
@@ -39851,11 +40116,11 @@ const runEditorDocumentRecorder = (editor) => {
|
|
|
39851
40116
|
typed: getTypedMarks(editor)
|
|
39852
40117
|
});
|
|
39853
40118
|
};
|
|
39854
|
-
const rootsThatCanMoveHolders = (change, replace, after,
|
|
40119
|
+
const rootsThatCanMoveHolders = (change, replace, after, beforeRoots) => {
|
|
39855
40120
|
if (replace) return /* @__PURE__ */ new Set([
|
|
39856
40121
|
MAIN_ROOT_KEY,
|
|
39857
40122
|
...visitRootNames(after.roots),
|
|
39858
|
-
...visitRootNames(
|
|
40123
|
+
...visitRootNames(beforeRoots)
|
|
39859
40124
|
]);
|
|
39860
40125
|
return /* @__PURE__ */ new Set([
|
|
39861
40126
|
...change.createRoots,
|
|
@@ -39866,6 +40131,7 @@ const rootsThatCanMoveHolders = (change, replace, after, before) => {
|
|
|
39866
40131
|
})
|
|
39867
40132
|
]);
|
|
39868
40133
|
};
|
|
40134
|
+
const onlyRemovesHolders = (change, root) => !change.createRoots.has(root) && !change.deleteRoots.has(root) && getInternalDocumentRootChange(change, root)?.sections.every((inserted, index) => index % 2 === 0 || inserted === -1 || inserted === 0) === true;
|
|
39869
40135
|
const ROOT_DIRECTORIES = /* @__PURE__ */ new WeakMap();
|
|
39870
40136
|
const advanceStoredRootDirectory = (owner, changed, drafted) => {
|
|
39871
40137
|
const roots = getEditorDocumentRoots(owner);
|
|
@@ -39923,10 +40189,33 @@ const transactionRootDirectory = (owner, snapshot) => {
|
|
|
39923
40189
|
return directory;
|
|
39924
40190
|
};
|
|
39925
40191
|
const readUniqueHolder = (editor, property, value) => {
|
|
39926
|
-
|
|
40192
|
+
const schema = getCompiledEditorSchema(editor);
|
|
40193
|
+
if (!uniquePropertiesOf(schema).has(property)) throw new Error(`Property "${property}" is not unique in this editor's schema.`);
|
|
40194
|
+
if (property === "id" && schema.everyElementHasId) throw new Error("This editor stores element ids: find an element by its id with nodes.byId(id).");
|
|
39927
40195
|
countCoreWork("uniqueHolderQueries");
|
|
39928
40196
|
return stateUniqueHolder(getEditorRuntimeOwner(editor), property, value);
|
|
39929
40197
|
};
|
|
40198
|
+
const holderOfElementId = (editor, id) => {
|
|
40199
|
+
countCoreWork("uniqueHolderQueries");
|
|
40200
|
+
return stateUniqueHolder(getEditorRuntimeOwner(editor), "id", id);
|
|
40201
|
+
};
|
|
40202
|
+
/** @internal */
|
|
40203
|
+
const lookupElementId = (editor, id) => {
|
|
40204
|
+
if (!getCompiledEditorSchema(editor).everyElementHasId) throw new Error("This editor's elements store no ids: its schema must declare id as a generated, unique string property on every element type, and no content may admit undeclared element types.");
|
|
40205
|
+
return holderOfElementId(editor, id);
|
|
40206
|
+
};
|
|
40207
|
+
/** @internal */
|
|
40208
|
+
const ELEMENT_FINDER = Symbol("element finder");
|
|
40209
|
+
/** @internal */
|
|
40210
|
+
const withElementFinder = (nodes, find) => Object.freeze(Object.defineProperty(nodes, ELEMENT_FINDER, { value: find }));
|
|
40211
|
+
/**
|
|
40212
|
+
* Finds the element that holds an id, as `nodes.byId` does, also in a schema
|
|
40213
|
+
* that gives only some elements an id, where `nodes.byId` throws. Plate's id
|
|
40214
|
+
* plugin lets a schema give ids to blocks alone.
|
|
40215
|
+
*
|
|
40216
|
+
* @internal
|
|
40217
|
+
*/
|
|
40218
|
+
const readElementById = (nodes, id) => (nodes[ELEMENT_FINDER] ?? nodes.byId)(id);
|
|
39930
40219
|
const stateUniqueHolder = (owner, property, value) => {
|
|
39931
40220
|
if (!(getReadProjection(owner) ? void 0 : TRANSACTION_SPEC_CONTEXTS.get(owner)?.[0])) return stateUniqueHolders(owner, property, value)[0] ?? null;
|
|
39932
40221
|
const holder = draftUniqueHolder(owner, property, value);
|
|
@@ -39966,8 +40255,8 @@ const draftUniqueHolder = (owner, property, value) => {
|
|
|
39966
40255
|
};
|
|
39967
40256
|
const updateIncumbent = (owner, property, value) => {
|
|
39968
40257
|
const update = TRANSACTION_SPEC_CONTEXTS.get(owner)?.[0];
|
|
39969
|
-
if (!update || getActiveEditorUpdateTags(owner).includes("collaboration") || update.snapshot.annotations.get(documentReplacement.key)?.value === true) return null;
|
|
39970
|
-
const stored = withContextsBelow(owner, update, () => withEditorDocumentProjection(owner,
|
|
40258
|
+
if (!update || (update.kind === "update" ? getActiveEditorUpdateTags(owner).includes("collaboration") : update.snapshot.tags.has("collaboration")) || update.snapshot.annotations.get(documentReplacement.key)?.value === true) return null;
|
|
40259
|
+
const stored = withContextsBelow(owner, update, () => withEditorDocumentProjection(owner, update.baseViewDocument, () => stateUniqueHolders(owner, property, value)[0]));
|
|
39971
40260
|
return stored ? {
|
|
39972
40261
|
key: stored.key,
|
|
39973
40262
|
left: () => getEditorRuntimeRootKeys(owner).every((root) => !runtimeRootIndex(owner, root).pathOf(stored.key)),
|
|
@@ -40006,6 +40295,14 @@ const admitTransactionDraft = (editor) => {
|
|
|
40006
40295
|
const schema = getCompiledEditorSchema(editor);
|
|
40007
40296
|
const unique = uniquePropertiesOf(schema).size > 0;
|
|
40008
40297
|
if (!admission && !unique) return;
|
|
40298
|
+
const replace = snapshot.reason === "replace";
|
|
40299
|
+
const rootsThatCanRepeat = () => {
|
|
40300
|
+
const { change } = snapshot.builder;
|
|
40301
|
+
const roots = rootsThatCanMoveHolders(change, replace, snapshot.builder.value, snapshot.roots);
|
|
40302
|
+
return replace ? roots : new Set([...roots].filter((root) => !onlyRemovesHolders(change, root)));
|
|
40303
|
+
};
|
|
40304
|
+
const unadmittedRoots = admission ? null : rootsThatCanRepeat();
|
|
40305
|
+
if (unadmittedRoots?.size === 0) return;
|
|
40009
40306
|
const stored = getChangeValue(snapshot.roots, snapshot.records);
|
|
40010
40307
|
const collaboration = getActiveEditorUpdateTags(editor).includes("collaboration");
|
|
40011
40308
|
const loads = snapshot.annotations.get(documentReplacement.key)?.value === true && !collaboration;
|
|
@@ -40034,7 +40331,7 @@ const admitTransactionDraft = (editor) => {
|
|
|
40034
40331
|
snapshot.admissionRepair = snapshot.admissionRepair?.compose(change) ?? change;
|
|
40035
40332
|
if (!options.renames) {
|
|
40036
40333
|
rootsToCheck ??= /* @__PURE__ */ new Set();
|
|
40037
|
-
for (const root of rootsThatCanMoveHolders(change, false, after,
|
|
40334
|
+
for (const root of rootsThatCanMoveHolders(change, false, after, void 0)) rootsToCheck.add(root);
|
|
40038
40335
|
}
|
|
40039
40336
|
if (takeBack) takeBack.change = takeBack.change?.compose(change) ?? change;
|
|
40040
40337
|
return change;
|
|
@@ -40084,7 +40381,7 @@ const admitTransactionDraft = (editor) => {
|
|
|
40084
40381
|
});
|
|
40085
40382
|
};
|
|
40086
40383
|
admit(stored, snapshot.activeChange.change);
|
|
40087
|
-
rootsToCheck =
|
|
40384
|
+
rootsToCheck = unadmittedRoots ?? rootsThatCanRepeat();
|
|
40088
40385
|
let settledAt = null;
|
|
40089
40386
|
for (;;) {
|
|
40090
40387
|
const after = snapshot.builder.value;
|
|
@@ -40404,8 +40701,9 @@ const readNodePath = (editor, at, options = {}) => {
|
|
|
40404
40701
|
};
|
|
40405
40702
|
const resolveNodeTargetLocation = (editor, target) => {
|
|
40406
40703
|
if (typeof target === "string") return getPathByNodeKey$1(editor, target) ?? void 0;
|
|
40407
|
-
if (typeof target === "object" && target !== null && !Array.isArray(target) && "path" in target && !("offset" in target) && Array.isArray(target.path)) return target.path;
|
|
40408
40704
|
if (!NodeApi.isDescendant(target)) {
|
|
40705
|
+
const { path } = target;
|
|
40706
|
+
if (!Array.isArray(target) && !("offset" in target) && Array.isArray(path)) return path;
|
|
40409
40707
|
const location = target;
|
|
40410
40708
|
assertLocationPathShape(location);
|
|
40411
40709
|
return location;
|
|
@@ -40420,7 +40718,6 @@ const resolveNodeTargetLocation = (editor, target) => {
|
|
|
40420
40718
|
getCurrentRuntimeIndex(owner).entries();
|
|
40421
40719
|
return readPath();
|
|
40422
40720
|
};
|
|
40423
|
-
const resolveReadableNodeTarget = (editor, target) => resolveNodeTargetLocation(editor, target);
|
|
40424
40721
|
const getOptionsNodeTarget = (options) => options && "at" in options ? options.at : void 0;
|
|
40425
40722
|
const LAST_TARGET_ROOTS = /* @__PURE__ */ new WeakMap();
|
|
40426
40723
|
const getLookupIndex = (owner, transactionSnapshot, root) => {
|
|
@@ -40442,6 +40739,29 @@ const getRuntimeTargetRoot = (editor, nodeKey) => {
|
|
|
40442
40739
|
if (root !== void 0) LAST_TARGET_ROOTS.set(owner, root);
|
|
40443
40740
|
return root;
|
|
40444
40741
|
};
|
|
40742
|
+
/** @internal */
|
|
40743
|
+
const UNPLACED_TARGET = Object.freeze({ id: "" });
|
|
40744
|
+
const elementIdOf = (target) => {
|
|
40745
|
+
if (typeof target !== "object" || target === null || Array.isArray(target)) return;
|
|
40746
|
+
const keys = Reflect.ownKeys(target);
|
|
40747
|
+
if (keys.length !== 1 || keys[0] !== "id") return void 0;
|
|
40748
|
+
const { id } = target;
|
|
40749
|
+
return typeof id === "string" ? id : void 0;
|
|
40750
|
+
};
|
|
40751
|
+
const routeNodeTarget = (editor, target) => {
|
|
40752
|
+
if (target === UNPLACED_TARGET) return null;
|
|
40753
|
+
const id = elementIdOf(target);
|
|
40754
|
+
if (id === void 0) return {
|
|
40755
|
+
root: getNodeTargetRoot(editor, target),
|
|
40756
|
+
target
|
|
40757
|
+
};
|
|
40758
|
+
const holder = lookupElementId(editor, id);
|
|
40759
|
+
return holder && {
|
|
40760
|
+
path: holder.path,
|
|
40761
|
+
root: holder.root,
|
|
40762
|
+
target: holder.key
|
|
40763
|
+
};
|
|
40764
|
+
};
|
|
40445
40765
|
const getNodeTargetRoot = (editor, target) => {
|
|
40446
40766
|
if (typeof target === "string") return getRuntimeTargetRoot(editor, target);
|
|
40447
40767
|
if (NodeApi.isDescendant(target)) {
|
|
@@ -40457,16 +40777,41 @@ const getSelectionNodeTargetRoot = (editor, target) => {
|
|
|
40457
40777
|
const nodeKey = getNodeKeyForNode(target, getEditorRuntimeOwner(editor));
|
|
40458
40778
|
return nodeKey ? getRuntimeTargetRoot(editor, nodeKey) : void 0;
|
|
40459
40779
|
};
|
|
40460
|
-
const
|
|
40461
|
-
|
|
40462
|
-
|
|
40780
|
+
const inTargetRoot = (editor, root, fn) => root ? withRoutedCallerScope(editor, () => withEditorRootChildren(editor, root, fn)) : fn();
|
|
40781
|
+
const readAtNodeTarget = (editor, target, miss, read) => {
|
|
40782
|
+
const route = routeNodeTarget(editor, target);
|
|
40783
|
+
if (!route) return miss;
|
|
40784
|
+
return inTargetRoot(editor, route.root, () => {
|
|
40785
|
+
const at = route.path ?? resolveNodeTargetLocation(editor, route.target);
|
|
40786
|
+
return at ? read(at, route.root) : miss;
|
|
40787
|
+
});
|
|
40788
|
+
};
|
|
40789
|
+
const assertInTargetRoot = (root, location) => {
|
|
40790
|
+
const other = location && getLocationRoot(location);
|
|
40791
|
+
if (root !== void 0 && other !== void 0 && other !== root) throw new Error("Cannot read an editor location across multiple roots.");
|
|
40463
40792
|
};
|
|
40464
|
-
const
|
|
40465
|
-
|
|
40466
|
-
|
|
40467
|
-
|
|
40793
|
+
const routeOptions = (options, { target }) => getOptionsNodeTarget(options) === target ? options : {
|
|
40794
|
+
...options,
|
|
40795
|
+
at: target
|
|
40796
|
+
};
|
|
40797
|
+
const readAtOptionsTarget = (editor, options, miss, read) => {
|
|
40798
|
+
const route = routeNodeTarget(editor, getOptionsNodeTarget(options));
|
|
40799
|
+
return route ? inTargetRoot(editor, route.root, () => read(routeOptions(options, route))) : miss;
|
|
40800
|
+
};
|
|
40801
|
+
const readAtOptionsTargetGenerator = (editor, options, create) => {
|
|
40802
|
+
const route = routeNodeTarget(editor, getOptionsNodeTarget(options));
|
|
40803
|
+
if (!route) return (function* missedNodeTarget() {})();
|
|
40804
|
+
const routed = routeOptions(options, route);
|
|
40805
|
+
return route.root ? withRoutedCallerScopeGenerator(editor, withEditorRootChildrenGenerator(editor, route.root, () => create(routed))) : (function* unscopedNodeTargetGenerator() {
|
|
40806
|
+
yield* create(routed);
|
|
40468
40807
|
})();
|
|
40469
40808
|
};
|
|
40809
|
+
const readElementEntry = (editor, { key, path, root }) => Object.freeze({
|
|
40810
|
+
key,
|
|
40811
|
+
node: withEditorRootChildren(editor, root, () => node(editor, path)[0]),
|
|
40812
|
+
path,
|
|
40813
|
+
...root !== "main" && { root }
|
|
40814
|
+
});
|
|
40470
40815
|
const localizeLocation = (location) => LocationApi.isPath(location) ? location : stripLocationRoots(location);
|
|
40471
40816
|
const normalizeNodeMatchOption = (editor, options) => {
|
|
40472
40817
|
const callerOptions = keepCallbacksInCallerScope(editor, options);
|
|
@@ -40736,6 +41081,39 @@ const getMutationRoot = (editor, options) => {
|
|
|
40736
41081
|
};
|
|
40737
41082
|
const getLocationMutationRoot = (editor, location) => getPublicExplicitLocationRoot(location) ?? getActiveMutationRoot(editor) ?? "main";
|
|
40738
41083
|
const runWithMutationRoot = (editor, root, fn) => profileCoreDuration("mutation-root", () => root ? withRoutedCallerScope(editor, () => withEditorUpdateRoot(editor, root, () => withEditorUpdateRootChildren(editor, root, fn))) : fn());
|
|
41084
|
+
const runInTargetRoot = (editor, at, selectionRoot, fn, miss) => {
|
|
41085
|
+
if (SelectionApi.isNode(at)) {
|
|
41086
|
+
const root = selectionRoot(at);
|
|
41087
|
+
return runWithMutationRoot(editor, root, () => fn(at, root));
|
|
41088
|
+
}
|
|
41089
|
+
const route = routeNodeTarget(editor, at);
|
|
41090
|
+
if (!route) return miss;
|
|
41091
|
+
const { root } = route;
|
|
41092
|
+
if (root) return runWithMutationRoot(editor, root, () => {
|
|
41093
|
+
const location = route.path ?? resolveNodeTargetLocation(editor, route.target);
|
|
41094
|
+
return location ? fn(location, root) : miss;
|
|
41095
|
+
});
|
|
41096
|
+
const location = resolveNodeTargetLocation(editor, route.target);
|
|
41097
|
+
const locationRoot = location && getLocationMutationRoot(editor, location);
|
|
41098
|
+
return location ? runWithMutationRoot(editor, locationRoot, () => fn(location, locationRoot)) : miss;
|
|
41099
|
+
};
|
|
41100
|
+
const runAtOptionsTarget = (editor, options, childrenRoot, run, miss) => {
|
|
41101
|
+
const route = routeNodeTarget(editor, options?.at);
|
|
41102
|
+
if (!route) return miss;
|
|
41103
|
+
const routed = options && routeOptions(options, route);
|
|
41104
|
+
const runtimeRoot = childrenRoot ?? route.root;
|
|
41105
|
+
const preResolvedOptions = runtimeRoot ? void 0 : resolveNodeTargetOptions(editor, routed);
|
|
41106
|
+
if (preResolvedOptions === null) return miss;
|
|
41107
|
+
const root = runtimeRoot ?? getMutationRoot(editor, preResolvedOptions);
|
|
41108
|
+
return runWithMutationRoot(editor, root, () => {
|
|
41109
|
+
const resolvedOptions = runtimeRoot ? resolveNodeTargetOptions(editor, routed) : preResolvedOptions;
|
|
41110
|
+
if (resolvedOptions === null) return miss;
|
|
41111
|
+
return run(resolvedOptions?.at === void 0 ? resolvedOptions : {
|
|
41112
|
+
...resolvedOptions,
|
|
41113
|
+
at: localizeLocation(resolvedOptions.at)
|
|
41114
|
+
}, root);
|
|
41115
|
+
});
|
|
41116
|
+
};
|
|
40739
41117
|
const ROUTED_CALLER_SCOPE = /* @__PURE__ */ new WeakMap();
|
|
40740
41118
|
const readRootScope = (context) => ({
|
|
40741
41119
|
activeChildrenRoot: context.activeChildrenRoot,
|
|
@@ -40960,7 +41338,7 @@ const nodeAtPath = (children, path) => {
|
|
|
40960
41338
|
let node;
|
|
40961
41339
|
let nodes = children;
|
|
40962
41340
|
for (const index of path) {
|
|
40963
|
-
node = nodes
|
|
41341
|
+
node = nodes && childAtPathIndex(nodes, index);
|
|
40964
41342
|
nodes = node && ElementApi.isElement(node) ? node.children : void 0;
|
|
40965
41343
|
}
|
|
40966
41344
|
return node;
|
|
@@ -41100,15 +41478,10 @@ const getSelectionMarks = (editor) => {
|
|
|
41100
41478
|
});
|
|
41101
41479
|
};
|
|
41102
41480
|
const createNodesToArray = (editor) => {
|
|
41103
|
-
const toArray = (options = {}) =>
|
|
41104
|
-
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor,
|
|
41481
|
+
const toArray = (options = {}) => readAtOptionsTarget(editor, options, [], (routedOptions) => {
|
|
41482
|
+
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor, routedOptions);
|
|
41105
41483
|
if (resolvedOptions === null) return [];
|
|
41106
|
-
return (
|
|
41107
|
-
if (!hasReadableNodeCollection(editor, innerOptions)) return [];
|
|
41108
|
-
const entries = [];
|
|
41109
|
-
for (const entry of nodes(editor, innerOptions)) entries.push(entry);
|
|
41110
|
-
return entries;
|
|
41111
|
-
}, { selectionFallback: usesImplicitSelectionLocation(innerOptions) }))({ options: resolvedOptions });
|
|
41484
|
+
return withOptionsRootRead(editor, resolvedOptions, () => hasReadableNodeCollection(editor, resolvedOptions) ? Array.from(nodes(editor, resolvedOptions)) : [], { selectionFallback: usesImplicitSelectionLocation(resolvedOptions) });
|
|
41112
41485
|
});
|
|
41113
41486
|
return toArray;
|
|
41114
41487
|
};
|
|
@@ -41271,18 +41644,7 @@ var SliceFitSite = class {
|
|
|
41271
41644
|
const withSliceFitTarget = (editor, options, childrenAt, run) => {
|
|
41272
41645
|
const childrenRoot = childrenAt === void 0 ? void 0 : typeof childrenAt === "string" ? getRuntimeTargetRoot(editor, childrenAt) : getCurrentChildrenRoot(editor);
|
|
41273
41646
|
if (childrenAt !== void 0 && !childrenRoot) return false;
|
|
41274
|
-
|
|
41275
|
-
const preResolvedOptions = runtimeRoot ? void 0 : resolveNodeTargetOptions(editor, options);
|
|
41276
|
-
if (preResolvedOptions === null) return false;
|
|
41277
|
-
const root = runtimeRoot ?? getMutationRoot(editor, preResolvedOptions);
|
|
41278
|
-
return runWithMutationRoot(editor, root, () => {
|
|
41279
|
-
const resolvedOptions = runtimeRoot ? resolveNodeTargetOptions(editor, options) : preResolvedOptions;
|
|
41280
|
-
if (resolvedOptions === null) return false;
|
|
41281
|
-
return run(resolvedOptions?.at === void 0 ? resolvedOptions : {
|
|
41282
|
-
...resolvedOptions,
|
|
41283
|
-
at: localizeLocation(resolvedOptions.at)
|
|
41284
|
-
}, root);
|
|
41285
|
-
});
|
|
41647
|
+
return runAtOptionsTarget(editor, options, childrenRoot, run, false);
|
|
41286
41648
|
};
|
|
41287
41649
|
const placeSliceFitRange = (editor, state, at, root, options) => {
|
|
41288
41650
|
const childrenAt = options?.childrenAt;
|
|
@@ -42124,8 +42486,17 @@ const getStateView = (editor) => {
|
|
|
42124
42486
|
nodes: selectionNodes,
|
|
42125
42487
|
ranges: () => getSelectionRanges(editor, getCurrentSelection(editor), getEditorDocumentValue(editor))
|
|
42126
42488
|
}));
|
|
42127
|
-
const
|
|
42128
|
-
const resolvedOptions =
|
|
42489
|
+
const findNode = (options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42490
|
+
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor, routedOptions);
|
|
42491
|
+
if (resolvedOptions === null) return void 0;
|
|
42492
|
+
return withOptionsRootRead(editor, resolvedOptions, () => {
|
|
42493
|
+
if (!hasReadableNodeCollection(editor, resolvedOptions)) return;
|
|
42494
|
+
const [entry] = nodes(editor, resolvedOptions);
|
|
42495
|
+
return entry;
|
|
42496
|
+
}, { selectionFallback: usesImplicitSelectionLocation(resolvedOptions) });
|
|
42497
|
+
});
|
|
42498
|
+
const readBlock = ((options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42499
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42129
42500
|
if (resolvedOptions === null) return void 0;
|
|
42130
42501
|
const nextOptions = resolvedOptions ?? {};
|
|
42131
42502
|
const { at, match } = nextOptions;
|
|
@@ -42138,7 +42509,7 @@ const getStateView = (editor) => {
|
|
|
42138
42509
|
});
|
|
42139
42510
|
return entry && NodeApi.isElement(entry[0]) ? entry : void 0;
|
|
42140
42511
|
}));
|
|
42141
|
-
const readBlocks = ((inputOptions = {}) =>
|
|
42512
|
+
const readBlocks = ((inputOptions = {}) => {
|
|
42142
42513
|
const target = inputOptions.at ?? getCurrentSelection(editor) ?? void 0;
|
|
42143
42514
|
if (!target) return [];
|
|
42144
42515
|
const match = normalizeCallerMatch(editor, inputOptions.type, inputOptions.match);
|
|
@@ -42173,33 +42544,35 @@ const getStateView = (editor) => {
|
|
|
42173
42544
|
return Object.freeze(inputOptions.reverse ? read.toReversed() : read);
|
|
42174
42545
|
});
|
|
42175
42546
|
const { coverage, ...targetOptions } = inputOptions;
|
|
42176
|
-
|
|
42547
|
+
return readAtOptionsTarget(editor, {
|
|
42177
42548
|
...targetOptions,
|
|
42178
42549
|
at: target
|
|
42550
|
+
}, Object.freeze([]), (routedOptions) => {
|
|
42551
|
+
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor, routedOptions);
|
|
42552
|
+
if (resolvedOptions === null) return [];
|
|
42553
|
+
const queryOptions = resolvedOptions ?? {};
|
|
42554
|
+
const full = coverage === "full";
|
|
42555
|
+
const { at } = queryOptions;
|
|
42556
|
+
const coveredPath = full && PathApi.isPath(at) ? at : null;
|
|
42557
|
+
const coveredRange = !full || !at || coveredPath || SelectionApi.isNode(at) ? null : LocationApi.isSpan(at) ? range$1(editor, at[0], at[1]) : range$1(editor, at);
|
|
42558
|
+
if (coveredRange && RangeApi.isCollapsed(coveredRange)) return [];
|
|
42559
|
+
return withOptionsRootRead(editor, queryOptions, () => {
|
|
42560
|
+
if (!hasReadableNodeCollection(editor, queryOptions)) return [];
|
|
42561
|
+
const entries = Array.from(nodes(editor, {
|
|
42562
|
+
...queryOptions,
|
|
42563
|
+
match: matchesBlock,
|
|
42564
|
+
mode: full ? "all" : queryOptions.mode ?? "lowest",
|
|
42565
|
+
reverse: !full && queryOptions.reverse
|
|
42566
|
+
}));
|
|
42567
|
+
if (!full) return Object.freeze(entries);
|
|
42568
|
+
const schema = getEditorSchema(editor);
|
|
42569
|
+
const [rangeStart, rangeEnd] = coveredRange ? RangeApi.edges(coveredRange) : [];
|
|
42570
|
+
const covered = entries.filter(([block, path]) => coveredPath ? PathApi.equals(coveredPath, path) || PathApi.isAncestor(coveredPath, path) : !rangeStart || !rangeEnd || rangeCoversBlock(schema, block, path, rangeStart, rangeEnd));
|
|
42571
|
+
const read = narrowCoveredBlocks(covered, queryOptions.mode);
|
|
42572
|
+
return Object.freeze(queryOptions.reverse ? read.toReversed() : read);
|
|
42573
|
+
});
|
|
42179
42574
|
});
|
|
42180
|
-
|
|
42181
|
-
const queryOptions = resolvedOptions ?? {};
|
|
42182
|
-
const full = coverage === "full";
|
|
42183
|
-
const { at } = queryOptions;
|
|
42184
|
-
const coveredPath = full && PathApi.isPath(at) ? at : null;
|
|
42185
|
-
const coveredRange = !full || !at || coveredPath || SelectionApi.isNode(at) ? null : LocationApi.isSpan(at) ? range$1(editor, at[0], at[1]) : range$1(editor, at);
|
|
42186
|
-
if (coveredRange && RangeApi.isCollapsed(coveredRange)) return [];
|
|
42187
|
-
return withOptionsRootRead(editor, queryOptions, () => {
|
|
42188
|
-
if (!hasReadableNodeCollection(editor, queryOptions)) return [];
|
|
42189
|
-
const entries = Array.from(nodes(editor, {
|
|
42190
|
-
...queryOptions,
|
|
42191
|
-
match: matchesBlock,
|
|
42192
|
-
mode: full ? "all" : queryOptions.mode ?? "lowest",
|
|
42193
|
-
reverse: !full && queryOptions.reverse
|
|
42194
|
-
}));
|
|
42195
|
-
if (!full) return Object.freeze(entries);
|
|
42196
|
-
const schema = getEditorSchema(editor);
|
|
42197
|
-
const [rangeStart, rangeEnd] = coveredRange ? RangeApi.edges(coveredRange) : [];
|
|
42198
|
-
const covered = entries.filter(([block, path]) => coveredPath ? PathApi.equals(coveredPath, path) || PathApi.isAncestor(coveredPath, path) : !rangeStart || !rangeEnd || rangeCoversBlock(schema, block, path, rangeStart, rangeEnd));
|
|
42199
|
-
const read = narrowCoveredBlocks(covered, queryOptions.mode);
|
|
42200
|
-
return Object.freeze(queryOptions.reverse ? read.toReversed() : read);
|
|
42201
|
-
});
|
|
42202
|
-
}));
|
|
42575
|
+
});
|
|
42203
42576
|
function getStateNodeKey(target) {
|
|
42204
42577
|
const key = NodeApi.isDescendant(target) ? getEditorNodeKeyForNode(editor, target) : withLocationRootRead(editor, target, () => {
|
|
42205
42578
|
const path = readNodePath(editor, target);
|
|
@@ -42216,159 +42589,99 @@ const getStateView = (editor) => {
|
|
|
42216
42589
|
lastCommit: () => getLastCommit$1(editor),
|
|
42217
42590
|
marks: marksApi,
|
|
42218
42591
|
meta: () => getEditorDocumentValue(editor).meta,
|
|
42219
|
-
nodes:
|
|
42220
|
-
above: ((options = {}) =>
|
|
42221
|
-
const resolvedOptions = resolveNodeTargetOptions(editor,
|
|
42592
|
+
nodes: withElementFinder({
|
|
42593
|
+
above: ((options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42594
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42222
42595
|
if (resolvedOptions === null) return void 0;
|
|
42223
|
-
return
|
|
42596
|
+
return getEditorRuntime(editor).above(resolvedOptions);
|
|
42224
42597
|
})),
|
|
42225
42598
|
block: readBlock,
|
|
42226
42599
|
blocks: readBlocks,
|
|
42600
|
+
byId: ((id) => {
|
|
42601
|
+
const holder = lookupElementId(editor, id);
|
|
42602
|
+
return holder && readElementEntry(editor, holder);
|
|
42603
|
+
}),
|
|
42227
42604
|
children(target = []) {
|
|
42228
|
-
return
|
|
42229
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42230
|
-
if (!at) return [];
|
|
42231
|
-
return (({ at: innerAt = [] }) => withLocationRootRead(editor, innerAt, () => readNodeChildren(editor, innerAt)))({ at });
|
|
42232
|
-
});
|
|
42605
|
+
return readAtNodeTarget(editor, target, [], (at) => withLocationRootRead(editor, at, () => readNodeChildren(editor, at)));
|
|
42233
42606
|
},
|
|
42234
|
-
elementReadOnly: (options = {}) =>
|
|
42235
|
-
const resolvedOptions = resolveNodeTargetOptions(editor,
|
|
42607
|
+
elementReadOnly: (options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42608
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42236
42609
|
if (resolvedOptions === null) return void 0;
|
|
42237
|
-
return
|
|
42610
|
+
return getEditorRuntime(editor).elementReadOnly(resolvedOptions);
|
|
42238
42611
|
}),
|
|
42239
|
-
first: (target) =>
|
|
42240
|
-
|
|
42241
|
-
|
|
42242
|
-
|
|
42243
|
-
|
|
42244
|
-
|
|
42245
|
-
|
|
42246
|
-
if (!at) return void 0;
|
|
42247
|
-
return (({ at: innerAt3, options: innerOptions5 }) => withLocationRootRead(editor, innerAt3, () => {
|
|
42248
|
-
const entry = readNodeEntry(editor, innerAt3);
|
|
42249
|
-
const match = normalizeCallerMatch(editor, innerOptions5.type, innerOptions5.match);
|
|
42250
|
-
if (!entry) return void 0;
|
|
42251
|
-
return !match || match(entry[0], entry[1]) ? entry : void 0;
|
|
42252
|
-
}))({
|
|
42253
|
-
at,
|
|
42254
|
-
options
|
|
42255
|
-
});
|
|
42256
|
-
})),
|
|
42612
|
+
first: (target) => readAtNodeTarget(editor, target, void 0, (at) => withLocationRootRead(editor, at, () => readNodeFirst(editor, at))),
|
|
42613
|
+
get: ((target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => withLocationRootRead(editor, at, () => {
|
|
42614
|
+
const entry = readNodeEntry(editor, at);
|
|
42615
|
+
const match = normalizeCallerMatch(editor, options.type, options.match);
|
|
42616
|
+
if (!entry) return void 0;
|
|
42617
|
+
return !match || match(entry[0], entry[1]) ? entry : void 0;
|
|
42618
|
+
}))),
|
|
42257
42619
|
isContent: (node) => isEditorContent(editor, node),
|
|
42258
42620
|
isSelectable: (element) => isEditorNodeSelectable(editor, element),
|
|
42259
42621
|
isEmpty: (element) => (({ element: innerElement5 }) => getEditorRuntime(editor).isEmpty(innerElement5))({ element }),
|
|
42260
|
-
last: (target, options = {}) =>
|
|
42261
|
-
|
|
42262
|
-
|
|
42263
|
-
|
|
42264
|
-
at,
|
|
42265
|
-
options
|
|
42266
|
-
});
|
|
42267
|
-
}),
|
|
42268
|
-
leaf: (target, options = {}) => withNodeTargetRootRead(editor, target, () => {
|
|
42269
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42270
|
-
if (!at) return void 0;
|
|
42271
|
-
return (({ at: innerAt5, options: innerOptions7 }) => withLocationRootRead(editor, innerAt5, () => readNodeLeaf(editor, innerAt5, innerOptions7)))({
|
|
42272
|
-
at,
|
|
42273
|
-
options
|
|
42274
|
-
});
|
|
42275
|
-
}),
|
|
42276
|
-
levels: (options = {}) => withNodeTargetRootGenerator(editor, getOptionsNodeTarget(options), () => {
|
|
42277
|
-
const resolvedOptions = resolveNodeTargetOptions(editor, options);
|
|
42622
|
+
last: (target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => getEditorRuntime(editor).last(at, options)),
|
|
42623
|
+
leaf: (target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => withLocationRootRead(editor, at, () => readNodeLeaf(editor, at, options))),
|
|
42624
|
+
levels: (options = {}) => readAtOptionsTargetGenerator(editor, options, (routedOptions) => {
|
|
42625
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42278
42626
|
if (resolvedOptions === null) return [];
|
|
42279
42627
|
return hasReadableNodeCollection(editor, resolvedOptions) ? getEditorRuntime(editor).levels(resolvedOptions) : [];
|
|
42280
42628
|
}),
|
|
42281
42629
|
path: (target, options = {}) => {
|
|
42282
|
-
const
|
|
42630
|
+
const id = elementIdOf(target);
|
|
42631
|
+
const holder = id === void 0 ? null : lookupElementId(editor, id);
|
|
42632
|
+
const at = id === void 0 ? resolveNodeTargetLocation(editor, target) : holder?.root === getCurrentChildrenRoot(editor) ? holder.path : void 0;
|
|
42283
42633
|
if (!at) return void 0;
|
|
42284
|
-
return
|
|
42285
|
-
at,
|
|
42286
|
-
options
|
|
42287
|
-
});
|
|
42634
|
+
return withLocationRootRead(editor, at, () => readNodePath(editor, at, options));
|
|
42288
42635
|
},
|
|
42289
|
-
entries: (options = {}) =>
|
|
42290
|
-
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor,
|
|
42636
|
+
entries: (options = {}) => readAtOptionsTargetGenerator(editor, options, (routedOptions) => {
|
|
42637
|
+
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor, routedOptions);
|
|
42291
42638
|
if (resolvedOptions === null) return [];
|
|
42292
42639
|
return withOptionsRootGenerator(editor, resolvedOptions, () => hasReadableNodeCollection(editor, resolvedOptions) ? nodes(editor, resolvedOptions) : [], { selectionFallback: usesImplicitSelectionLocation(resolvedOptions) });
|
|
42293
42640
|
}),
|
|
42294
|
-
find:
|
|
42295
|
-
|
|
42296
|
-
if (resolvedOptions === null) return;
|
|
42297
|
-
return withOptionsRootRead(editor, resolvedOptions, () => {
|
|
42298
|
-
if (!hasReadableNodeCollection(editor, resolvedOptions)) return;
|
|
42299
|
-
const [entry] = nodes(editor, resolvedOptions);
|
|
42300
|
-
return entry;
|
|
42301
|
-
}, { selectionFallback: usesImplicitSelectionLocation(resolvedOptions) });
|
|
42302
|
-
})),
|
|
42303
|
-
some: (options = {}) => withNodeTargetRootRead(editor, getOptionsNodeTarget(options), () => {
|
|
42304
|
-
const resolvedOptions = resolveNodeTargetOrSpanOptions(editor, options);
|
|
42305
|
-
if (resolvedOptions === null) return false;
|
|
42306
|
-
return withOptionsRootRead(editor, resolvedOptions, () => {
|
|
42307
|
-
if (!hasReadableNodeCollection(editor, resolvedOptions)) return false;
|
|
42308
|
-
const [entry] = nodes(editor, resolvedOptions);
|
|
42309
|
-
return entry !== void 0;
|
|
42310
|
-
}, { selectionFallback: usesImplicitSelectionLocation(resolvedOptions) });
|
|
42311
|
-
}),
|
|
42641
|
+
find: findNode,
|
|
42642
|
+
some: (options = {}) => findNode(options) !== void 0,
|
|
42312
42643
|
toArray: createNodesToArray(editor),
|
|
42313
|
-
next: ((options = {}) =>
|
|
42314
|
-
const resolvedOptions = resolveNodeTargetOptions(editor,
|
|
42644
|
+
next: ((options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42645
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42315
42646
|
if (resolvedOptions === null) return void 0;
|
|
42316
42647
|
return hasReadableNodeCollection(editor, resolvedOptions) ? getEditorRuntime(editor).next(resolvedOptions) : void 0;
|
|
42317
42648
|
})),
|
|
42318
|
-
previous: ((options = {}) =>
|
|
42319
|
-
const resolvedOptions = resolveNodeTargetOptions(editor,
|
|
42649
|
+
previous: ((options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42650
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42320
42651
|
if (resolvedOptions === null) return void 0;
|
|
42321
42652
|
return hasReadableNodeCollection(editor, resolvedOptions) ? getEditorRuntime(editor).previous(resolvedOptions) : void 0;
|
|
42322
42653
|
})),
|
|
42323
|
-
parent: ((target, options = {}) =>
|
|
42324
|
-
const
|
|
42325
|
-
|
|
42326
|
-
|
|
42327
|
-
|
|
42328
|
-
|
|
42329
|
-
|
|
42330
|
-
|
|
42331
|
-
}))({
|
|
42332
|
-
at,
|
|
42333
|
-
options
|
|
42334
|
-
});
|
|
42335
|
-
})),
|
|
42336
|
-
void: (options = {}) => withNodeTargetRootRead(editor, options.at, () => {
|
|
42337
|
-
const resolvedOptions = resolveNodeTargetOptions(editor, options);
|
|
42654
|
+
parent: ((target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => withLocationRootRead(editor, at, () => {
|
|
42655
|
+
const entry = readNodeParent(editor, at, options);
|
|
42656
|
+
const match = normalizeCallerMatch(editor, options.type, options.match);
|
|
42657
|
+
if (!entry) return void 0;
|
|
42658
|
+
return !match || match(entry[0], entry[1]) ? entry : void 0;
|
|
42659
|
+
}))),
|
|
42660
|
+
void: (options = {}) => readAtOptionsTarget(editor, options, void 0, (routedOptions) => {
|
|
42661
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42338
42662
|
if (resolvedOptions === null) return void 0;
|
|
42339
42663
|
return getEditorRuntime(editor).void(resolvedOptions);
|
|
42340
42664
|
})
|
|
42665
|
+
}, (id) => {
|
|
42666
|
+
const holder = holderOfElementId(editor, id);
|
|
42667
|
+
return holder && readElementEntry(editor, holder);
|
|
42341
42668
|
}),
|
|
42342
42669
|
points: Object.freeze({
|
|
42343
|
-
after: (target, options = {}) =>
|
|
42344
|
-
|
|
42345
|
-
|
|
42346
|
-
|
|
42670
|
+
after: (target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => readAdjacentPoint(editor, at, "after", options)),
|
|
42671
|
+
before: (target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => readAdjacentPoint(editor, at, "before", options)),
|
|
42672
|
+
end: (target) => readAtNodeTarget(editor, target, void 0, (at) => readPointEdge(editor, at, "end")),
|
|
42673
|
+
get: (target, options = {}) => readAtNodeTarget(editor, target, void 0, (at) => readPoint(editor, at, options)),
|
|
42674
|
+
isEdge: (point, target) => readAtNodeTarget(editor, target, false, (at, root) => {
|
|
42675
|
+
assertInTargetRoot(root, point);
|
|
42676
|
+
return hasLocationPath(editor, at) && getEditorRuntime(editor).isEdge(point, at);
|
|
42347
42677
|
}),
|
|
42348
|
-
|
|
42349
|
-
|
|
42350
|
-
|
|
42351
|
-
return readAdjacentPoint(editor, at, "before", options);
|
|
42678
|
+
isEnd: (point, target) => readAtNodeTarget(editor, target, false, (at, root) => {
|
|
42679
|
+
assertInTargetRoot(root, point);
|
|
42680
|
+
return hasLocationPath(editor, at) && getEditorRuntime(editor).isEnd(point, at);
|
|
42352
42681
|
}),
|
|
42353
|
-
|
|
42354
|
-
|
|
42355
|
-
return at
|
|
42356
|
-
}),
|
|
42357
|
-
get: (target, options = {}) => withNodeTargetRootRead(editor, target, () => {
|
|
42358
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42359
|
-
return at ? readPoint(editor, at, options) : void 0;
|
|
42360
|
-
}),
|
|
42361
|
-
isEdge: (point, target) => withNodeTargetRootRead(editor, target, () => {
|
|
42362
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42363
|
-
return !!at && hasLocationPath(editor, at) && getEditorRuntime(editor).isEdge(point, at);
|
|
42364
|
-
}),
|
|
42365
|
-
isEnd: (point, target) => withNodeTargetRootRead(editor, target, () => {
|
|
42366
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42367
|
-
return !!at && hasLocationPath(editor, at) && getEditorRuntime(editor).isEnd(point, at);
|
|
42368
|
-
}),
|
|
42369
|
-
isStart: (point, target) => withNodeTargetRootRead(editor, target, () => {
|
|
42370
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42371
|
-
return !!at && hasLocationPath(editor, at) && getEditorRuntime(editor).isStart(point, at);
|
|
42682
|
+
isStart: (point, target) => readAtNodeTarget(editor, target, false, (at, root) => {
|
|
42683
|
+
assertInTargetRoot(root, point);
|
|
42684
|
+
return hasLocationPath(editor, at) && getEditorRuntime(editor).isStart(point, at);
|
|
42372
42685
|
}),
|
|
42373
42686
|
isWordEnd: (point) => {
|
|
42374
42687
|
const after = state.points.after(point);
|
|
@@ -42376,24 +42689,25 @@ const getStateView = (editor) => {
|
|
|
42376
42689
|
const range = state.ranges.get(point, after);
|
|
42377
42690
|
return !!range && WHITESPACE_OR_END_REGEX.test(state.text.string(range));
|
|
42378
42691
|
},
|
|
42379
|
-
positions: (options = {}) =>
|
|
42380
|
-
const resolvedOptions = resolveNodeTargetOptions(editor,
|
|
42692
|
+
positions: (options = {}) => readAtOptionsTargetGenerator(editor, options, (routedOptions) => {
|
|
42693
|
+
const resolvedOptions = resolveNodeTargetOptions(editor, routedOptions);
|
|
42381
42694
|
return resolvedOptions !== null && hasReadableNodeCollection(editor, resolvedOptions) ? getEditorRuntime(editor).positions(resolvedOptions) : [];
|
|
42382
42695
|
}),
|
|
42383
|
-
start: (target) =>
|
|
42384
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42385
|
-
return at ? readPointEdge(editor, at, "start") : void 0;
|
|
42386
|
-
})
|
|
42696
|
+
start: (target) => readAtNodeTarget(editor, target, void 0, (at) => readPointEdge(editor, at, "start"))
|
|
42387
42697
|
}),
|
|
42388
42698
|
ranges: Object.freeze({
|
|
42389
|
-
edges: (target) =>
|
|
42390
|
-
const at = resolveReadableNodeTarget(editor, target);
|
|
42391
|
-
return at ? readRangeEdges(editor, at) : void 0;
|
|
42392
|
-
}),
|
|
42699
|
+
edges: (target) => readAtNodeTarget(editor, target, void 0, (at) => readRangeEdges(editor, at)),
|
|
42393
42700
|
fromEntries: (entries) => (({ entries: innerEntries }) => readRangeFromEntries(editor, innerEntries))({ entries }),
|
|
42394
|
-
get: (target, to) =>
|
|
42395
|
-
|
|
42396
|
-
return
|
|
42701
|
+
get: (target, to) => readAtNodeTarget(editor, target, void 0, (at, root) => {
|
|
42702
|
+
assertInTargetRoot(root, to);
|
|
42703
|
+
return readRange(editor, at, to);
|
|
42704
|
+
}),
|
|
42705
|
+
isEmpty: (range) => withLocationRootRead(editor, range, () => {
|
|
42706
|
+
const source = getChildrenSource(editor);
|
|
42707
|
+
const index = source instanceof DocumentIndex ? source : DocumentIndex.fromValue(source);
|
|
42708
|
+
const from = index.positionAt(range.anchor);
|
|
42709
|
+
const to = index.positionAt(range.focus);
|
|
42710
|
+
return !coversContent(index, Math.min(from, to), Math.max(from, to), getEditorSchema(editor));
|
|
42397
42711
|
}),
|
|
42398
42712
|
project: (range) => (({ range: innerRange }) => getEditorRuntime(editor).projectRange(innerRange))({ range }),
|
|
42399
42713
|
unhang: (range, options = {}) => (({ options: innerOptions10, range: innerRange2 }) => getEditorRuntime(editor).unhangRange(innerRange2, innerOptions10))({
|
|
@@ -42415,11 +42729,7 @@ const getStateView = (editor) => {
|
|
|
42415
42729
|
const resolvedTarget = target ?? getCurrentSelection(editor);
|
|
42416
42730
|
if (!resolvedTarget) return "";
|
|
42417
42731
|
if (SelectionApi.isNode(resolvedTarget)) return withEditorRootChildren(editor, getNodeSelectionRoot(editor, resolvedTarget, target === void 0 ? "stored" : "target"), () => resolvedTarget.paths.filter((path) => NodeApi.has(editor, path)).map((path) => getEditorRuntime(editor).string(path, options)).join(""));
|
|
42418
|
-
return
|
|
42419
|
-
const at = resolveReadableNodeTarget(editor, resolvedTarget);
|
|
42420
|
-
if (!at) return "";
|
|
42421
|
-
return withLocationRootRead(editor, at, () => hasLocationPath(editor, at) ? getEditorRuntime(editor).string(at, options) : "");
|
|
42422
|
-
});
|
|
42732
|
+
return readAtNodeTarget(editor, resolvedTarget, "", (at) => withLocationRootRead(editor, at, () => hasLocationPath(editor, at) ? getEditorRuntime(editor).string(at, options) : ""));
|
|
42423
42733
|
} }),
|
|
42424
42734
|
unique: Object.freeze({ holder: (property, value) => readUniqueHolder(editor, property, value) }),
|
|
42425
42735
|
value: () => withEditorDocumentProjection(editor, void 0, () => getEditorDocumentValue(editor)),
|
|
@@ -42664,18 +42974,7 @@ const getUpdateView = (editor) => {
|
|
|
42664
42974
|
};
|
|
42665
42975
|
const runTargetMutation = (options, fn) => {
|
|
42666
42976
|
assertActive();
|
|
42667
|
-
|
|
42668
|
-
const preResolvedOptions = runtimeRoot ? void 0 : resolveNodeTargetOptions(editor, options);
|
|
42669
|
-
if (preResolvedOptions === null) return void 0;
|
|
42670
|
-
const root = runtimeRoot ?? getMutationRoot(editor, preResolvedOptions);
|
|
42671
|
-
return runWithMutationRoot(editor, root, () => {
|
|
42672
|
-
const resolvedOptions = runtimeRoot ? resolveNodeTargetOptions(editor, options) : preResolvedOptions;
|
|
42673
|
-
if (resolvedOptions === null) return void 0;
|
|
42674
|
-
return fn(resolvedOptions?.at === void 0 ? resolvedOptions : {
|
|
42675
|
-
...resolvedOptions,
|
|
42676
|
-
at: localizeLocation(resolvedOptions.at)
|
|
42677
|
-
});
|
|
42678
|
-
});
|
|
42977
|
+
return runAtOptionsTarget(editor, options, void 0, fn, void 0);
|
|
42679
42978
|
};
|
|
42680
42979
|
const runNodeTargetMutation = (options, fn) => {
|
|
42681
42980
|
const currentSelection = options?.at === void 0 ? getCurrentSelection(editor) : null;
|
|
@@ -42755,50 +43054,44 @@ const getUpdateView = (editor) => {
|
|
|
42755
43054
|
return !!patches && applyBlockPatches(patches, root);
|
|
42756
43055
|
}) ?? false;
|
|
42757
43056
|
const toggleBlock = defineSemanticUpdateMethod((props, { at: explicitAt, voids, wrap } = {}) => {
|
|
43057
|
+
assertActive();
|
|
42758
43058
|
const at = explicitAt ?? getCurrentSelection(editor) ?? void 0;
|
|
42759
43059
|
if (!at) return false;
|
|
42760
|
-
return
|
|
42761
|
-
const
|
|
42762
|
-
const
|
|
42763
|
-
|
|
42764
|
-
const root = nodeSelection ? getNodeSelectionRoot(editor, nodeSelection, explicitAt === void 0 ? "stored" : "target") : targetAt ? getLocationMutationRoot(editor, targetAt) ?? "main" : MAIN_ROOT_KEY;
|
|
42765
|
-
const selectedBlockPaths = runWithMutationRoot(editor, root, () => state.nodes.blocks({
|
|
42766
|
-
at: nodeSelection ?? targetAt ?? void 0,
|
|
43060
|
+
return runInTargetRoot(editor, at, (selection) => getNodeSelectionRoot(editor, selection, explicitAt === void 0 ? "stored" : "target"), (routedTarget, targetRoot) => {
|
|
43061
|
+
const root = targetRoot ?? "main";
|
|
43062
|
+
const selectedBlockPaths = state.nodes.blocks({
|
|
43063
|
+
at: routedTarget,
|
|
42767
43064
|
voids
|
|
42768
|
-
}).map(([, path]) => path)
|
|
43065
|
+
}).map(([, path]) => path);
|
|
42769
43066
|
if (selectedBlockPaths.length === 0) return false;
|
|
42770
43067
|
const propsMatch = (node) => NodeApi.isElement(node) && ElementApi.matches(node, props);
|
|
42771
|
-
const isActive =
|
|
43068
|
+
const isActive = wrap ? selectedBlockPaths.some((path) => state.nodes.some({
|
|
42772
43069
|
at: path,
|
|
42773
43070
|
match: propsMatch,
|
|
42774
43071
|
voids
|
|
42775
43072
|
})) : selectedBlockPaths.some((path) => {
|
|
42776
43073
|
const entry = state.nodes.get(path);
|
|
42777
43074
|
return !!entry && propsMatch(entry[0]);
|
|
42778
|
-
})
|
|
43075
|
+
});
|
|
42779
43076
|
if (!wrap) {
|
|
42780
43077
|
const before = getActiveDocumentChangeBuilder(editor).change;
|
|
42781
|
-
|
|
42782
|
-
|
|
42783
|
-
|
|
42784
|
-
|
|
42785
|
-
|
|
42786
|
-
|
|
42787
|
-
return !!patches && applyBlockPatches(patches, root, voids);
|
|
42788
|
-
}) && getActiveDocumentChangeBuilder(editor).change !== before;
|
|
43078
|
+
const patches = isActive ? prepareBlockResets(selectedBlockPaths, root, Object.keys(props)) : selectedBlockPaths.map((path) => ({
|
|
43079
|
+
path,
|
|
43080
|
+
props,
|
|
43081
|
+
unset: []
|
|
43082
|
+
}));
|
|
43083
|
+
return !!patches && applyBlockPatches(patches, root, voids) && getActiveDocumentChangeBuilder(editor).change !== before;
|
|
42789
43084
|
}
|
|
42790
43085
|
const before = getActiveDocumentChangeBuilder(editor).change;
|
|
42791
43086
|
if (isActive) {
|
|
42792
|
-
for (const path of selectedBlockPaths.toReversed())
|
|
42793
|
-
|
|
42794
|
-
|
|
42795
|
-
|
|
42796
|
-
|
|
42797
|
-
|
|
42798
|
-
|
|
42799
|
-
|
|
42800
|
-
voids
|
|
42801
|
-
});
|
|
43087
|
+
for (const path of selectedBlockPaths.toReversed()) if (state.nodes.some({
|
|
43088
|
+
at: path,
|
|
43089
|
+
match: propsMatch,
|
|
43090
|
+
voids
|
|
43091
|
+
})) unwrapNodes$1(editor, {
|
|
43092
|
+
at: path,
|
|
43093
|
+
match: propsMatch,
|
|
43094
|
+
voids
|
|
42802
43095
|
});
|
|
42803
43096
|
return getActiveDocumentChangeBuilder(editor).change !== before;
|
|
42804
43097
|
}
|
|
@@ -42810,7 +43103,7 @@ const getUpdateView = (editor) => {
|
|
|
42810
43103
|
else runs.push([path]);
|
|
42811
43104
|
}
|
|
42812
43105
|
const schema = getEditorSchema(editor);
|
|
42813
|
-
if (!
|
|
43106
|
+
if (!runs.every((run) => {
|
|
42814
43107
|
const children = run.map((path) => state.nodes.get(path)?.[0]);
|
|
42815
43108
|
if (!children.every((node) => ElementApi.isElement(node))) return false;
|
|
42816
43109
|
const [first] = run;
|
|
@@ -42819,19 +43112,17 @@ const getUpdateView = (editor) => {
|
|
|
42819
43112
|
...props,
|
|
42820
43113
|
children
|
|
42821
43114
|
}, first.at(-1) ?? 0, root);
|
|
42822
|
-
}))
|
|
42823
|
-
for (const run of runs.toReversed())
|
|
42824
|
-
|
|
42825
|
-
|
|
42826
|
-
|
|
42827
|
-
|
|
42828
|
-
|
|
42829
|
-
|
|
42830
|
-
voids
|
|
42831
|
-
});
|
|
43115
|
+
})) return false;
|
|
43116
|
+
for (const run of runs.toReversed()) wrapNodes$1(editor, {
|
|
43117
|
+
...props,
|
|
43118
|
+
children: []
|
|
43119
|
+
}, {
|
|
43120
|
+
at: PathApi.parent(run[0]),
|
|
43121
|
+
match: (_node, path) => run.some((member) => PathApi.equals(member, path)),
|
|
43122
|
+
voids
|
|
42832
43123
|
});
|
|
42833
43124
|
return getActiveDocumentChangeBuilder(editor).change !== before;
|
|
42834
|
-
});
|
|
43125
|
+
}, false);
|
|
42835
43126
|
}, (command, [props, options]) => command(editorCommands.toggleBlock, {
|
|
42836
43127
|
options,
|
|
42837
43128
|
props
|
|
@@ -42916,20 +43207,20 @@ const getUpdateView = (editor) => {
|
|
|
42916
43207
|
};
|
|
42917
43208
|
const duplicateBlocks = ((inputOptions = {}) => {
|
|
42918
43209
|
const { at: explicitAt, hanging, match, mode, select: innerSelect, type, voids } = inputOptions;
|
|
43210
|
+
assertActive();
|
|
42919
43211
|
const at = explicitAt ?? getCurrentSelection(editor) ?? void 0;
|
|
42920
43212
|
if (!at) return;
|
|
42921
|
-
|
|
42922
|
-
const nodeSelection = SelectionApi.isNode(
|
|
42923
|
-
const targetAt = nodeSelection ? null :
|
|
42924
|
-
if (!nodeSelection && !targetAt) return;
|
|
43213
|
+
runInTargetRoot(editor, at, (selection) => getNodeSelectionRoot(editor, selection, explicitAt === void 0 ? "stored" : "target"), (routedTarget) => {
|
|
43214
|
+
const nodeSelection = SelectionApi.isNode(routedTarget) ? routedTarget : null;
|
|
43215
|
+
const targetAt = nodeSelection ? null : routedTarget;
|
|
42925
43216
|
const blockMatch = normalizeCallerMatch(editor, type, match);
|
|
42926
43217
|
const matchesBlock = (node, path) => NodeApi.isElement(node) && state.schema.isBlock(node) && (!blockMatch || blockMatch(node, path));
|
|
42927
|
-
const entries = nodeSelection ?
|
|
43218
|
+
const entries = nodeSelection ? nodeSelection.paths.reduce((all, path) => {
|
|
42928
43219
|
const exact = state.nodes.get(path);
|
|
42929
43220
|
const block = exact && NodeApi.isElement(exact[0]) && state.schema.isBlock(exact[0]) ? exact : state.nodes.block({ at: path });
|
|
42930
43221
|
if (block && matchesBlock(block[0], block[1]) && !all.some(([, candidate]) => PathApi.equals(candidate, block[1]))) all.push(block);
|
|
42931
43222
|
return all;
|
|
42932
|
-
}, [])
|
|
43223
|
+
}, []) : targetAt ? LocationApi.isRange(targetAt) ? state.nodes.blocks({
|
|
42933
43224
|
at: targetAt,
|
|
42934
43225
|
match,
|
|
42935
43226
|
mode,
|
|
@@ -42944,7 +43235,7 @@ const getUpdateView = (editor) => {
|
|
|
42944
43235
|
select: innerSelect,
|
|
42945
43236
|
voids
|
|
42946
43237
|
});
|
|
42947
|
-
});
|
|
43238
|
+
}, void 0);
|
|
42948
43239
|
});
|
|
42949
43240
|
const insertBlocks = (nodes, { after, at, before, replaceEmpty, ...options } = {}) => {
|
|
42950
43241
|
if ([
|
|
@@ -43201,8 +43492,9 @@ const getUpdateView = (editor) => {
|
|
|
43201
43492
|
});
|
|
43202
43493
|
})
|
|
43203
43494
|
})),
|
|
43204
|
-
nodes:
|
|
43495
|
+
nodes: withElementFinder({
|
|
43205
43496
|
...state.nodes,
|
|
43497
|
+
byId: (id) => runActive(() => state.nodes.byId(id)),
|
|
43206
43498
|
insert: defineSemanticUpdateMethod((nodes, options) => runTargetMutation(options, (resolvedOptions) => {
|
|
43207
43499
|
const runtimeOptions = resolvedOptions;
|
|
43208
43500
|
const limited = limitNodeInsert(getStateView(editor), nodes, runtimeOptions);
|
|
@@ -43256,7 +43548,7 @@ const getUpdateView = (editor) => {
|
|
|
43256
43548
|
wrapNodes$1(editor, element, resolvedOptions);
|
|
43257
43549
|
return getActiveDocumentChangeBuilder(editor).change !== before;
|
|
43258
43550
|
}) ?? false
|
|
43259
|
-
}),
|
|
43551
|
+
}, (id) => runActive(() => readElementById(state.nodes, id))),
|
|
43260
43552
|
records: Object.freeze({
|
|
43261
43553
|
drop: (set, id) => {
|
|
43262
43554
|
runActive(() => {
|
|
@@ -43453,6 +43745,7 @@ const getUpdateView = (editor) => {
|
|
|
43453
43745
|
});
|
|
43454
43746
|
})
|
|
43455
43747
|
}),
|
|
43748
|
+
unique: Object.freeze({ holder: (property, value) => runActive(() => state.unique.holder(property, value)) }),
|
|
43456
43749
|
value: Object.freeze(Object.assign(() => state.value(), { replace: (input) => {
|
|
43457
43750
|
runActive(() => replaceSnapshot(editor, input));
|
|
43458
43751
|
} }))
|
|
@@ -43512,6 +43805,7 @@ const createTransactionSpecContext = (editor, options = {}) => {
|
|
|
43512
43805
|
const activeChildrenRoot = getEditorChildrenRoot(editor);
|
|
43513
43806
|
const activeUpdateRoot = getActiveUpdateRoot(editor);
|
|
43514
43807
|
const anchorValue = getEditorDocumentValue(editor);
|
|
43808
|
+
const baseViewDocument = parent ? void 0 : getReadProjection(editor);
|
|
43515
43809
|
const roots = getEditorDocumentRoots(editor);
|
|
43516
43810
|
const selection = getCurrentSelection(editor);
|
|
43517
43811
|
const caret = {
|
|
@@ -43555,7 +43849,7 @@ const createTransactionSpecContext = (editor, options = {}) => {
|
|
|
43555
43849
|
reservedRoots: parentSnapshot?.reservedRoots ?? NO_RESERVED_ROOTS,
|
|
43556
43850
|
selectionInDroppedRoot: parentSnapshot?.selectionInDroppedRoot ?? false,
|
|
43557
43851
|
records,
|
|
43558
|
-
rootDirectory: { initial: parentSnapshot ? () => transactionRootDirectory(getEditorRuntimeOwner(editor), parentSnapshot) : () => ROOT_DIRECTORIES.get(getEditorRuntimeOwner(editor)) },
|
|
43852
|
+
rootDirectory: { initial: parentSnapshot ? () => transactionRootDirectory(getEditorRuntimeOwner(editor), parentSnapshot) : baseViewDocument ? () => projectedRootDirectory(getEditorRuntimeOwner(editor), baseViewDocument) : () => ROOT_DIRECTORIES.get(getEditorRuntimeOwner(editor)) },
|
|
43559
43853
|
rootIndexes: /* @__PURE__ */ new Map(),
|
|
43560
43854
|
roots,
|
|
43561
43855
|
runtimeIndexRollbacks: /* @__PURE__ */ new Map(),
|
|
@@ -43569,6 +43863,7 @@ const createTransactionSpecContext = (editor, options = {}) => {
|
|
|
43569
43863
|
const context = {
|
|
43570
43864
|
...activeChildrenRoot ? { activeChildrenRoot } : {},
|
|
43571
43865
|
...activeUpdateRoot ? { activeUpdateRoot } : {},
|
|
43866
|
+
...baseViewDocument ? { baseViewDocument } : {},
|
|
43572
43867
|
baseDraftEpoch: parent?.draftEpoch ?? 0,
|
|
43573
43868
|
baseRevision: getMutationVersion(editor),
|
|
43574
43869
|
changed: false,
|
|
@@ -43646,7 +43941,7 @@ const assertTransactionSpecBase = (editor, spec) => {
|
|
|
43646
43941
|
if (!base) throw new Error("Transaction spec is missing its opaque base.");
|
|
43647
43942
|
if (base.editor !== editor) throw new Error("Cannot apply a transaction spec to a different editor.");
|
|
43648
43943
|
const context = getTransactionSpecContext(editor);
|
|
43649
|
-
if (!(base.context === context?.id || context?.kind === "update" && base.context === void 0) && (base.context !== void 0 || context !== void 0)) throw new Error("Cannot apply a transaction spec outside its base state.");
|
|
43944
|
+
if (!(base.context === context?.id || context?.kind === "update" && base.context === void 0) && (base.context !== void 0 || context !== void 0) || base.viewDocument && base.viewDocument !== TRANSACTION_SPEC_CONTEXTS.get(editor)?.[0]?.baseViewDocument) throw new Error("Cannot apply a transaction spec outside its base state.");
|
|
43650
43945
|
if (base.revision !== getMutationVersion(editor)) throw new Error("Cannot apply a stale transaction spec.");
|
|
43651
43946
|
};
|
|
43652
43947
|
/**
|
|
@@ -43718,7 +44013,8 @@ const finalizeTransactionSpecContext = (editor, context) => {
|
|
|
43718
44013
|
...context.parentId ? { context: context.parentId } : {},
|
|
43719
44014
|
draftEpoch: context.baseDraftEpoch,
|
|
43720
44015
|
editor,
|
|
43721
|
-
revision: context.baseRevision
|
|
44016
|
+
revision: context.baseRevision,
|
|
44017
|
+
...context.baseViewDocument ? { viewDocument: context.baseViewDocument } : {}
|
|
43722
44018
|
});
|
|
43723
44019
|
if (snapshot.reason === "replace") TRANSACTION_SPEC_DOCUMENT_STATES.set(spec, copyDocumentState(getDocumentState(editor)));
|
|
43724
44020
|
if (snapshot.contentSliceRoots.size > 0) TRANSACTION_SPEC_CONTENT_SLICE_ROOTS.set(spec, Object.freeze([...snapshot.contentSliceRoots]));
|
|
@@ -44626,6 +44922,12 @@ const transformImplicitTarget = (editor, change, before, after, root, options =
|
|
|
44626
44922
|
if (!snapshot?.implicitTargetResolved || !snapshot.implicitTarget) return;
|
|
44627
44923
|
snapshot.implicitTarget = mapSelectionThroughChange(editor, snapshot.implicitTarget, change, before, after, root, options).selection;
|
|
44628
44924
|
};
|
|
44925
|
+
const peekImplicitTarget = (editor) => {
|
|
44926
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
44927
|
+
const snapshot = getTransactionSnapshot(owner);
|
|
44928
|
+
if (snapshot?.implicitTargetResolved) return cloneValue(snapshot.implicitTarget);
|
|
44929
|
+
return moveImplicitTarget(owner)?.target ?? getCurrentSelection(owner);
|
|
44930
|
+
};
|
|
44629
44931
|
const moveImplicitTarget = (editor) => {
|
|
44630
44932
|
const frame = getTransactionSnapshot(editor)?.implicitTargetFrame;
|
|
44631
44933
|
if (!frame) return resolveTargetRuntimeImplicitTarget(editor, getCurrentSelection(editor));
|
|
@@ -45066,6 +45368,7 @@ const withTransactionDocumentChangeObserver = (editor, listener, fn) => {
|
|
|
45066
45368
|
}
|
|
45067
45369
|
};
|
|
45068
45370
|
const getDocumentRootChildren = (value, root) => root === "main" ? value.children : value.roots?.[root] ?? [];
|
|
45371
|
+
const getDocumentRootNodes = (value, root) => root === "main" ? rootNodesOf(value, "children") : rootNodesOf(value.roots ?? {}, root);
|
|
45069
45372
|
const inheritDocumentChangeStepNodeKeys = (editor, snapshot, step, options = {}) => {
|
|
45070
45373
|
const owner = getEditorRuntimeOwner(editor);
|
|
45071
45374
|
const publishNodeKeys = getTransactionSpecContext(editor)?.kind !== "spec";
|
|
@@ -45222,19 +45525,40 @@ const committedSettlementSplit = (editor, snapshot, after) => {
|
|
|
45222
45525
|
* caret on a neighbor and the element is remembered; the step that gives the
|
|
45223
45526
|
* element a text again puts the caret at that text's start.
|
|
45224
45527
|
*/
|
|
45225
|
-
const keepStrandedCaret = (editor, specContext, caretBefore, mapped,
|
|
45528
|
+
const keepStrandedCaret = (editor, specContext, caretBefore, mapped, step, root, indexes) => {
|
|
45529
|
+
const after = step.after;
|
|
45226
45530
|
const pending = specContext.strandedCaret?.root === root && specContext.strandedCaret.selection === caretBefore.selection ? specContext.strandedCaret : void 0;
|
|
45227
45531
|
specContext.strandedCaret = void 0;
|
|
45228
45532
|
const { selection } = mapped;
|
|
45229
45533
|
if (!indexes || !selection || SelectionApi.isNode(selection)) return mapped;
|
|
45230
45534
|
const schema = getEditorSchema(editor);
|
|
45535
|
+
const firstText = (node) => {
|
|
45536
|
+
const [text] = NodeApi.texts(node, { pass: ([child]) => NodeApi.isElement(child) && schema.isVoid(child) });
|
|
45537
|
+
return text;
|
|
45538
|
+
};
|
|
45231
45539
|
const textIn = (key) => {
|
|
45232
45540
|
const path = indexes.after.pathOf(key);
|
|
45233
|
-
const node = path ? nodeAtPath(
|
|
45541
|
+
const node = path ? nodeAtPath(getDocumentRootNodes(after, root), path) : void 0;
|
|
45234
45542
|
if (!path || !node) return void 0;
|
|
45235
|
-
const
|
|
45543
|
+
const text = firstText(node);
|
|
45236
45544
|
return text ? [...path, ...text[1]] : null;
|
|
45237
45545
|
};
|
|
45546
|
+
const removesTextAndLeavesTextless = (textPath) => {
|
|
45547
|
+
const rootChange = getInternalDocumentRootChange(step.change, root);
|
|
45548
|
+
if (!rootChange) return false;
|
|
45549
|
+
const { from } = (step.indexedBefore.get(root) ?? valueRootIndex(step.before, root)).nodeRange(textPath);
|
|
45550
|
+
if (rootChange.mapPos(from, 1, "after") !== null) return false;
|
|
45551
|
+
const afterIndex = step.indexedAfter.get(root) ?? valueRootIndex(step.after, root);
|
|
45552
|
+
let leavesTextless = false;
|
|
45553
|
+
rootChange.iterChangedRanges((_fromBefore, _toBefore, fromAfter, toAfter) => {
|
|
45554
|
+
leavesTextless ||= afterIndex.nodeRangesTouching(fromAfter, toAfter).some(({ kind, path }) => {
|
|
45555
|
+
if (kind !== "element") return false;
|
|
45556
|
+
const node = afterIndex.node(path);
|
|
45557
|
+
return !schema.isVoid(node) && !firstText(node);
|
|
45558
|
+
});
|
|
45559
|
+
});
|
|
45560
|
+
return leavesTextless;
|
|
45561
|
+
};
|
|
45238
45562
|
if (pending) {
|
|
45239
45563
|
const path = textIn(pending.key);
|
|
45240
45564
|
if (path === null) specContext.strandedCaret = {
|
|
@@ -45258,6 +45582,7 @@ const keepStrandedCaret = (editor, specContext, caretBefore, mapped, after, root
|
|
|
45258
45582
|
}
|
|
45259
45583
|
const held = caretBefore.selection;
|
|
45260
45584
|
if (!held || SelectionApi.isNode(held) || !RangeApi.isCollapsed(held)) return mapped;
|
|
45585
|
+
if (!removesTextAndLeavesTextless(held.anchor.path)) return mapped;
|
|
45261
45586
|
const heldText = indexes.before.keyAt(held.anchor.path);
|
|
45262
45587
|
if (!heldText || indexes.after.pathOf(heldText)) return mapped;
|
|
45263
45588
|
for (let depth = held.anchor.path.length - 1; depth > 0; depth--) {
|
|
@@ -45313,7 +45638,7 @@ const applyTransactionSpecDocumentChangeStep = (editor, step, options = {}) => {
|
|
|
45313
45638
|
session: specContext.caret.session,
|
|
45314
45639
|
inSetRoot: specContext.caret.inSetRoot
|
|
45315
45640
|
}, selectionRoot) : null;
|
|
45316
|
-
const caret = mappedCaret && hasRoot(mappedCaret.root) ? keepStrandedCaret(editor, specContext, carets, mappedCaret,
|
|
45641
|
+
const caret = mappedCaret && hasRoot(mappedCaret.root) ? keepStrandedCaret(editor, specContext, carets, mappedCaret, step, selectionRoot, selectionRuntimeIndexes) : null;
|
|
45317
45642
|
specContext.caret = {
|
|
45318
45643
|
...carets,
|
|
45319
45644
|
book: mapBookThroughStep(carets.book, {
|
|
@@ -45861,7 +46186,7 @@ const runEditorTransaction = (editor, fn, options = {}) => {
|
|
|
45861
46186
|
});
|
|
45862
46187
|
committed = change;
|
|
45863
46188
|
const owner = getEditorRuntimeOwner(editor);
|
|
45864
|
-
advanceStoredRootDirectory(owner, () => rootsThatCanMoveHolders(canonicalChanges, snapshot.reason === "replace", afterValue, beforeValue), {
|
|
46189
|
+
advanceStoredRootDirectory(owner, () => rootsThatCanMoveHolders(canonicalChanges, snapshot.reason === "replace", afterValue, beforeValue.roots), {
|
|
45865
46190
|
change: snapshot.builder.change,
|
|
45866
46191
|
directory: snapshot.rootDirectory
|
|
45867
46192
|
});
|
|
@@ -46721,6 +47046,8 @@ const resolveCommandRange = (state, at) => {
|
|
|
46721
47046
|
if (at === void 0) return state.selection() ?? void 0;
|
|
46722
47047
|
return RangeApi.isRange(at) ? at : state.ranges.get(at);
|
|
46723
47048
|
};
|
|
47049
|
+
const readCommandTarget = (state, at) => at ?? (state.selection() === null ? null : peekImplicitTarget(getActiveCommandEditor()));
|
|
47050
|
+
const readLandingRange = (state, target) => !target || SelectionApi.isNode(target) ? null : resolveCommandRange(state, target) ?? null;
|
|
46724
47051
|
const equalsInRoot = (point, target) => {
|
|
46725
47052
|
if (!point) return false;
|
|
46726
47053
|
return PointApi.equals(point.root === void 0 && target.root !== void 0 ? {
|
|
@@ -46728,6 +47055,10 @@ const equalsInRoot = (point, target) => {
|
|
|
46728
47055
|
root: target.root
|
|
46729
47056
|
} : point, target);
|
|
46730
47057
|
};
|
|
47058
|
+
const selectMovedTarget = (tx, state, at, target) => {
|
|
47059
|
+
const stored = state.selection();
|
|
47060
|
+
if (at === void 0 && RangeApi.isRange(target) && !(stored && equalsInRoot(stored.anchor, target.anchor) && equalsInRoot(stored.focus, target.focus))) tx.selection.set(target);
|
|
47061
|
+
};
|
|
46731
47062
|
const withPointRoot = (point, root) => point && root !== void 0 ? {
|
|
46732
47063
|
...point,
|
|
46733
47064
|
root
|
|
@@ -46815,33 +47146,140 @@ const getFullySelectedSiblingBlocks = (state, range) => {
|
|
|
46815
47146
|
if (!endsAtBlockStart && !endsAtBlockEnd || !PathApi.isSibling(startPath, endPath) || !PathApi.isBefore(startPath, endPath)) return null;
|
|
46816
47147
|
return endsAtBlockEnd ? blocks : blocks.slice(0, -1);
|
|
46817
47148
|
};
|
|
46818
|
-
const
|
|
46819
|
-
|
|
46820
|
-
|
|
46821
|
-
|
|
46822
|
-
|
|
46823
|
-
const
|
|
46824
|
-
|
|
46825
|
-
|
|
46826
|
-
const
|
|
46827
|
-
|
|
47149
|
+
const isGrid = (state, node) => getCompiledEditorSchemaFromApi(state.schema)?.elements.byType.get(node.type)?.structure?.kind === "grid";
|
|
47150
|
+
const takesText = (state, node) => NodeApi.isElement(node) && !isGrid(state, node) && holdsWritableText(getInternalEditorSchemaFromApi(state.schema), node);
|
|
47151
|
+
const tripleClickedBlock = defineUpdateAnnotation({ key: "selection.triple-clicked-block" });
|
|
47152
|
+
const readWholeBlockLanding = (state, at, { root, tripleClicked }) => {
|
|
47153
|
+
const range = resolveCommandRange(state, at);
|
|
47154
|
+
const blocks = range && getFullySelectedSiblingBlocks(state, range);
|
|
47155
|
+
if (!range || !blocks) return null;
|
|
47156
|
+
const publicRoot = toPublicRoot(root);
|
|
47157
|
+
const inRoot = publicRoot ? { root: publicRoot } : {};
|
|
47158
|
+
const keyAt = (path) => getDefined(state.key({
|
|
47159
|
+
offset: 0,
|
|
47160
|
+
path,
|
|
47161
|
+
...inRoot
|
|
47162
|
+
}));
|
|
47163
|
+
const [first, firstPath] = getDefined(blocks[0]);
|
|
47164
|
+
const next = state.nodes.get({
|
|
47165
|
+
offset: 0,
|
|
47166
|
+
path: PathApi.next(getDefined(blocks.at(-1))[1]),
|
|
47167
|
+
...inRoot
|
|
47168
|
+
})?.[0];
|
|
47169
|
+
const clicked = tripleClicked && state.nodes.get(tripleClicked)?.[1];
|
|
47170
|
+
const landing = {
|
|
46828
47171
|
blocks,
|
|
46829
|
-
|
|
46830
|
-
|
|
46831
|
-
|
|
47172
|
+
root: publicRoot
|
|
47173
|
+
};
|
|
47174
|
+
if (clicked && blocks.length === 1 && PathApi.isCommon(firstPath, clicked) && takesText(state, first) && takesText(state, next) && getInternalEditorSchemaFromApi(state.schema).canPlaceAtPath(firstPath, [], {
|
|
47175
|
+
removing: [getDefined(firstPath.at(-1))],
|
|
47176
|
+
root
|
|
47177
|
+
})) return {
|
|
47178
|
+
...landing,
|
|
47179
|
+
keeps: "next"
|
|
47180
|
+
};
|
|
47181
|
+
const keepsFirst = PathApi.hasPrevious(firstPath) || next !== void 0;
|
|
47182
|
+
if (RangeApi.isRange(at)) {
|
|
47183
|
+
const endsInFirst = PathApi.isAncestor(firstPath, RangeApi.end(range).path);
|
|
47184
|
+
if (keepsFirst && (endsInFirst || takesText(state, first))) {
|
|
47185
|
+
const text = endsInFirst ? range : {
|
|
47186
|
+
anchor: RangeApi.start(range),
|
|
47187
|
+
focus: getDefined(withPointRoot(state.points.end(keyAt(firstPath)), publicRoot))
|
|
47188
|
+
};
|
|
47189
|
+
const [startLine, endLine] = RangeApi.edges(text).map((point) => state.nodes.block({
|
|
47190
|
+
at: point,
|
|
47191
|
+
mode: "lowest"
|
|
47192
|
+
}));
|
|
47193
|
+
return {
|
|
47194
|
+
...landing,
|
|
47195
|
+
keeps: "first",
|
|
47196
|
+
spansLines: !!startLine && !!endLine && !PathApi.equals(startLine[1], endLine[1]),
|
|
47197
|
+
text
|
|
47198
|
+
};
|
|
47199
|
+
}
|
|
47200
|
+
} else if (PathApi.hasPrevious(firstPath)) return {
|
|
47201
|
+
...landing,
|
|
47202
|
+
keeps: "previous"
|
|
47203
|
+
};
|
|
47204
|
+
else if (next) return {
|
|
47205
|
+
...landing,
|
|
47206
|
+
keeps: "next"
|
|
47207
|
+
};
|
|
47208
|
+
const block = blockReplacing(state, firstPath, root, "", state.marks() ?? getConsistentBlockTextMarks(state, blocks.map(([, path]) => keyAt(path))));
|
|
47209
|
+
if (!block) return null;
|
|
47210
|
+
return {
|
|
47211
|
+
...landing,
|
|
47212
|
+
block,
|
|
47213
|
+
keeps: "default",
|
|
47214
|
+
reusesFirst: !keepsFirst && NodeApi.isElement(block) && block.children.every(NodeApi.isText) && takesText(state, first),
|
|
47215
|
+
whole: !keepsFirst
|
|
46832
47216
|
};
|
|
46833
47217
|
};
|
|
46834
|
-
const
|
|
46835
|
-
const
|
|
46836
|
-
const
|
|
46837
|
-
const
|
|
46838
|
-
const
|
|
46839
|
-
|
|
46840
|
-
const
|
|
46841
|
-
|
|
46842
|
-
|
|
46843
|
-
|
|
46844
|
-
|
|
47218
|
+
const writeWholeBlockLanding = (tx, landing, { at, direction, selectsText = false }) => {
|
|
47219
|
+
const { blocks, root } = landing;
|
|
47220
|
+
const [, firstPath] = getDefined(blocks[0]);
|
|
47221
|
+
const [, lastPath] = getDefined(blocks.at(-1));
|
|
47222
|
+
const parentPath = PathApi.parent(firstPath);
|
|
47223
|
+
const index = getDefined(firstPath.at(-1));
|
|
47224
|
+
const inRoot = root ? { root } : {};
|
|
47225
|
+
const keyAt = (path) => getDefined(tx.key({
|
|
47226
|
+
offset: 0,
|
|
47227
|
+
path,
|
|
47228
|
+
...inRoot
|
|
47229
|
+
}));
|
|
47230
|
+
const replace = (path, from, count, children = []) => {
|
|
47231
|
+
if (count > 0 || children.length > 0) tx.nodes.replaceChildren(children, {
|
|
47232
|
+
at: path,
|
|
47233
|
+
count,
|
|
47234
|
+
index: from,
|
|
47235
|
+
...inRoot
|
|
47236
|
+
});
|
|
47237
|
+
};
|
|
47238
|
+
const collapse = (point) => {
|
|
47239
|
+
const caret = withPointRoot(point, root);
|
|
47240
|
+
if (caret) tx.selection.set({
|
|
47241
|
+
anchor: caret,
|
|
47242
|
+
focus: caret
|
|
47243
|
+
});
|
|
47244
|
+
};
|
|
47245
|
+
if (landing.keeps === "next" || landing.keeps === "previous") {
|
|
47246
|
+
const kept = keyAt(landing.keeps === "next" ? PathApi.next(lastPath) : PathApi.previous(firstPath));
|
|
47247
|
+
replace(parentPath, index, blocks.length);
|
|
47248
|
+
collapse(landing.keeps === "next" ? tx.points.start(kept) : tx.points.end(kept));
|
|
47249
|
+
return;
|
|
47250
|
+
}
|
|
47251
|
+
if (landing.keeps === "first") {
|
|
47252
|
+
replace(parentPath, index + 1, blocks.length - 1);
|
|
47253
|
+
if (RangeApi.isCollapsed(landing.text)) collapse(landing.text.anchor);
|
|
47254
|
+
else if (selectsText) tx.selection.set(landing.text);
|
|
47255
|
+
else tx.fragment.delete({
|
|
47256
|
+
at: landing.text,
|
|
47257
|
+
direction
|
|
47258
|
+
});
|
|
47259
|
+
return;
|
|
47260
|
+
}
|
|
47261
|
+
if (!landing.reusesFirst) {
|
|
47262
|
+
replace(parentPath, index, blocks.length, [landing.block]);
|
|
47263
|
+
collapse(tx.points.start(keyAt(firstPath)));
|
|
47264
|
+
const blockText = NodeApi.texts(landing.block).next().value;
|
|
47265
|
+
const marks = blockText ? NodeApi.extractProps(blockText[0]) : {};
|
|
47266
|
+
if (Object.keys(marks).length > 0) tx.marks.set(marks);
|
|
47267
|
+
return;
|
|
47268
|
+
}
|
|
47269
|
+
tx.fragment.delete({
|
|
47270
|
+
at,
|
|
47271
|
+
direction
|
|
47272
|
+
});
|
|
47273
|
+
let kept = tx.nodes.get(keyAt(firstPath))?.[0];
|
|
47274
|
+
while (NodeApi.isElement(kept) && kept.children.length === 1 && NodeApi.isElement(kept.children[0])) {
|
|
47275
|
+
tx.nodes.unwrap({ at: keyAt(firstPath) });
|
|
47276
|
+
kept = tx.nodes.get(keyAt(firstPath))?.[0];
|
|
47277
|
+
}
|
|
47278
|
+
if (!NodeApi.isElement(kept) || !NodeApi.isElement(landing.block)) return;
|
|
47279
|
+
const { children: _children, ...props } = landing.block;
|
|
47280
|
+
const stale = Object.keys(kept).filter((key) => key !== "children" && !(key in props));
|
|
47281
|
+
tx.nodes.set(props, { at: keyAt(firstPath) });
|
|
47282
|
+
if (stale.length > 0) tx.nodes.unset(stale, { at: keyAt(firstPath) });
|
|
46845
47283
|
};
|
|
46846
47284
|
const getTextMarks = (node) => {
|
|
46847
47285
|
const { text: _text, ...marks } = node;
|
|
@@ -46864,9 +47302,9 @@ const getConsistentBlockTextMarks = (state, targets) => {
|
|
|
46864
47302
|
}
|
|
46865
47303
|
return expected ?? null;
|
|
46866
47304
|
};
|
|
46867
|
-
const blockReplacing = (state,
|
|
47305
|
+
const blockReplacing = (state, at, root, text, marks) => {
|
|
46868
47306
|
const publicRoot = toPublicRoot(root);
|
|
46869
|
-
const defaultChild =
|
|
47307
|
+
const defaultChild = state.schema.createDefaultChild({
|
|
46870
47308
|
at,
|
|
46871
47309
|
root: publicRoot
|
|
46872
47310
|
});
|
|
@@ -46878,7 +47316,11 @@ const blockReplacing = (state, [block, at], root, text, marks, shell) => {
|
|
|
46878
47316
|
root: publicRoot
|
|
46879
47317
|
}) : { text };
|
|
46880
47318
|
const landed = (parents) => withoutUnheldDefaults(getCompiledEditorSchemaFromApi(state.schema), copied, () => toCompiledNodeContext(copied, [...parents, ...Array.from(state.nodes.levels({
|
|
46881
|
-
at: state.key(
|
|
47319
|
+
at: getDefined(state.key({
|
|
47320
|
+
offset: 0,
|
|
47321
|
+
path: at,
|
|
47322
|
+
...publicRoot ? { root: publicRoot } : {}
|
|
47323
|
+
})),
|
|
46882
47324
|
reverse: true,
|
|
46883
47325
|
voids: true
|
|
46884
47326
|
}), ([node]) => node).filter(NodeApi.isElement).slice(1)], root));
|
|
@@ -46896,24 +47338,53 @@ const blockReplacing = (state, [block, at], root, text, marks, shell) => {
|
|
|
46896
47338
|
};
|
|
46897
47339
|
};
|
|
46898
47340
|
const LINE_BREAK_PATTERN = /\r|\n/;
|
|
47341
|
+
const typesInPlace = (state, blocks, text) => blocks.length === 1 && getInternalEditorSchemaFromApi(state.schema).canContain(getDefined(blocks[0])[0], { text });
|
|
47342
|
+
const readRangeLanding = (state, range) => {
|
|
47343
|
+
if (RangeApi.isCollapsed(range)) return null;
|
|
47344
|
+
const root = rootOrUpdateRoot(range.anchor.root ?? range.focus.root);
|
|
47345
|
+
const landing = readWholeBlockLanding(state, range, {
|
|
47346
|
+
root,
|
|
47347
|
+
tripleClicked: null
|
|
47348
|
+
});
|
|
47349
|
+
const lands = landing?.keeps === "first" ? !landing.spansLines : landing?.keeps === "default" && !landing.whole;
|
|
47350
|
+
return landing && lands ? {
|
|
47351
|
+
landing,
|
|
47352
|
+
root
|
|
47353
|
+
} : null;
|
|
47354
|
+
};
|
|
47355
|
+
const breakAfterLanding = (state, write) => {
|
|
47356
|
+
const target = readCommandTarget(state, void 0);
|
|
47357
|
+
const range = readLandingRange(state, target);
|
|
47358
|
+
const over = range && readRangeLanding(state, range);
|
|
47359
|
+
if (range && over) refuseCrossing(getSetSite(getActiveCommandEditor()), range, over.root);
|
|
47360
|
+
return state.transaction((tx) => {
|
|
47361
|
+
selectMovedTarget(tx, state, void 0, target);
|
|
47362
|
+
if (range && over) writeWholeBlockLanding(tx, over.landing, {
|
|
47363
|
+
at: range,
|
|
47364
|
+
direction: "backward"
|
|
47365
|
+
});
|
|
47366
|
+
write(tx);
|
|
47367
|
+
});
|
|
47368
|
+
};
|
|
46899
47369
|
const getFullBlockTextReplacement = (state, range, text, typing, force = false) => {
|
|
46900
47370
|
if (LINE_BREAK_PATTERN.test(text)) return null;
|
|
46901
47371
|
const blocks = getFullySelectedSiblingBlocks(state, range);
|
|
46902
47372
|
if (!blocks) return null;
|
|
46903
|
-
const [
|
|
46904
|
-
if (!force &&
|
|
47373
|
+
const [, firstPath] = getDefined(blocks[0]);
|
|
47374
|
+
if (!force && typesInPlace(state, blocks, text)) return null;
|
|
46905
47375
|
const root = rootOrUpdateRoot(range.anchor.root ?? range.focus.root);
|
|
46906
|
-
const
|
|
46907
|
-
const
|
|
46908
|
-
|
|
46909
|
-
|
|
46910
|
-
|
|
47376
|
+
const publicRoot = toPublicRoot(root);
|
|
47377
|
+
const inRoot = publicRoot ? { root: publicRoot } : {};
|
|
47378
|
+
const replacement = blockReplacing(state, firstPath, root, text, (typing ? state.marks() : null) ?? getConsistentBlockTextMarks(state, blocks.map(([, path]) => getDefined(state.key({
|
|
47379
|
+
offset: 0,
|
|
47380
|
+
path,
|
|
47381
|
+
...inRoot
|
|
47382
|
+
})))));
|
|
46911
47383
|
if (!replacement) return null;
|
|
46912
47384
|
const firstText = NodeApi.texts(replacement).next().value;
|
|
46913
47385
|
if (!firstText) return null;
|
|
46914
47386
|
const parentPath = PathApi.parent(firstPath);
|
|
46915
47387
|
const index = getDefined(firstPath.at(-1));
|
|
46916
|
-
const publicRoot = toPublicRoot(root);
|
|
46917
47388
|
const point = {
|
|
46918
47389
|
offset: text.length,
|
|
46919
47390
|
path: [
|
|
@@ -46921,7 +47392,7 @@ const getFullBlockTextReplacement = (state, range, text, typing, force = false)
|
|
|
46921
47392
|
index,
|
|
46922
47393
|
...firstText[1]
|
|
46923
47394
|
],
|
|
46924
|
-
...
|
|
47395
|
+
...inRoot
|
|
46925
47396
|
};
|
|
46926
47397
|
return {
|
|
46927
47398
|
count: blocks.length,
|
|
@@ -46987,102 +47458,31 @@ const editorCommands = Object.freeze({
|
|
|
46987
47458
|
};
|
|
46988
47459
|
},
|
|
46989
47460
|
build: ({ input, state }) => {
|
|
46990
|
-
const
|
|
47461
|
+
const target = readCommandTarget(state, input.at) ?? void 0;
|
|
47462
|
+
const at = SelectionApi.isNode(target) ? void 0 : target;
|
|
47463
|
+
const range = readLandingRange(state, target);
|
|
46991
47464
|
const root = rootOrUpdateRoot(range?.anchor.root ?? range?.focus.root);
|
|
46992
47465
|
if (range) refuseCrossing(getSetSite(getActiveCommandEditor()), range, root);
|
|
46993
|
-
const
|
|
46994
|
-
|
|
46995
|
-
|
|
46996
|
-
|
|
46997
|
-
|
|
46998
|
-
|
|
46999
|
-
|
|
47000
|
-
|
|
47001
|
-
if (textRange && (endsInFirst || wholeBlocks.takesCaret)) {
|
|
47002
|
-
const at = endsInFirst ? textRange : {
|
|
47003
|
-
anchor: RangeApi.start(textRange),
|
|
47004
|
-
focus: {
|
|
47005
|
-
...getDefined(state.points.end(state.key(firstBlock))),
|
|
47006
|
-
...publicRoot ? { root: publicRoot } : {}
|
|
47007
|
-
}
|
|
47008
|
-
};
|
|
47009
|
-
return state.transaction((tx) => {
|
|
47010
|
-
if (selectedBlocks.length > 1) tx.nodes.replaceChildren([], {
|
|
47011
|
-
at: PathApi.parent(firstPath),
|
|
47012
|
-
count: selectedBlocks.length - 1,
|
|
47013
|
-
index: getDefined(firstPath.at(-1)) + 1,
|
|
47014
|
-
...publicRoot ? { root: publicRoot } : {}
|
|
47015
|
-
});
|
|
47016
|
-
if (!RangeApi.isCollapsed(at)) tx.fragment.delete({
|
|
47017
|
-
at,
|
|
47018
|
-
direction: input.direction
|
|
47019
|
-
});
|
|
47020
|
-
else if (selectedBlocks.length > 1) tx.selection.set({
|
|
47021
|
-
anchor: at.anchor,
|
|
47022
|
-
focus: at.anchor
|
|
47023
|
-
});
|
|
47024
|
-
});
|
|
47025
|
-
}
|
|
47026
|
-
const parentPath = PathApi.parent(firstPath);
|
|
47027
|
-
const index = getDefined(firstPath.at(-1));
|
|
47028
|
-
const previous = textRange ? void 0 : state.nodes.previous({
|
|
47029
|
-
at: state.key(firstBlock),
|
|
47030
|
-
sibling: true
|
|
47031
|
-
})?.[0];
|
|
47032
|
-
const previousPoint = previous && NodeApi.isElement(previous) ? state.points.end(state.key(previous)) : void 0;
|
|
47033
|
-
const next = textRange || previousPoint ? void 0 : state.nodes.next({ at: state.key(lastBlock) });
|
|
47034
|
-
const nextPoint = next ? state.points.start(state.key(next[0])) : void 0;
|
|
47035
|
-
const mappedNextPoint = nextPoint ? {
|
|
47036
|
-
...nextPoint,
|
|
47037
|
-
path: [
|
|
47038
|
-
...parentPath,
|
|
47039
|
-
index,
|
|
47040
|
-
...nextPoint.path.slice(parentPath.length + 1)
|
|
47041
|
-
]
|
|
47042
|
-
} : void 0;
|
|
47043
|
-
const survivingPoint = previousPoint ?? mappedNextPoint;
|
|
47044
|
-
const defaultChild = survivingPoint ? null : blockReplacing(state, getDefined(selectedBlocks[0]), root, "", state.marks() ?? getConsistentBlockTextMarks(state, selectedBlocks.map(([block]) => state.key(block))));
|
|
47045
|
-
if (!survivingPoint && !defaultChild) return state.transaction((tx) => {
|
|
47046
|
-
tx.fragment.delete({
|
|
47047
|
-
direction: input.direction,
|
|
47048
|
-
...input.at === void 0 ? {} : { at: range ?? input.at }
|
|
47049
|
-
});
|
|
47050
|
-
});
|
|
47051
|
-
return state.transaction((tx) => {
|
|
47052
|
-
const defaultText = defaultChild ? NodeApi.texts(defaultChild).next().value : void 0;
|
|
47053
|
-
const point = survivingPoint ?? (defaultText ? {
|
|
47054
|
-
offset: 0,
|
|
47055
|
-
path: [
|
|
47056
|
-
...parentPath,
|
|
47057
|
-
index,
|
|
47058
|
-
...defaultText[1]
|
|
47059
|
-
],
|
|
47060
|
-
...publicRoot ? { root: publicRoot } : {}
|
|
47061
|
-
} : void 0);
|
|
47062
|
-
tx.nodes.replaceChildren(defaultChild ? [defaultChild] : [], {
|
|
47063
|
-
at: parentPath,
|
|
47064
|
-
count: selectedBlocks.length,
|
|
47065
|
-
index,
|
|
47066
|
-
...publicRoot ? { root: publicRoot } : {},
|
|
47067
|
-
...point ? { newSelection: {
|
|
47068
|
-
anchor: point,
|
|
47069
|
-
focus: point,
|
|
47070
|
-
kind: "text"
|
|
47071
|
-
} } : {}
|
|
47072
|
-
});
|
|
47073
|
-
const deletedTextMarks = !survivingPoint && defaultText ? NodeApi.extractProps(defaultText[0]) : {};
|
|
47074
|
-
if (Object.keys(deletedTextMarks).length > 0) tx.marks.set(deletedTextMarks);
|
|
47466
|
+
const landing = at !== void 0 && range ? readWholeBlockLanding(state, at, {
|
|
47467
|
+
root,
|
|
47468
|
+
tripleClicked: RangeApi.isRange(at) ? readLastCommitAnnotation(state, tripleClickedBlock, range) : null
|
|
47469
|
+
}) : null;
|
|
47470
|
+
if (range && landing && (input.at !== void 0 || landing.keeps !== "default" || !landing.whole)) return state.transaction((tx) => {
|
|
47471
|
+
writeWholeBlockLanding(tx, landing, {
|
|
47472
|
+
at: range,
|
|
47473
|
+
direction: input.direction
|
|
47075
47474
|
});
|
|
47076
|
-
}
|
|
47475
|
+
});
|
|
47077
47476
|
return state.transaction((tx) => {
|
|
47477
|
+
if (SelectionApi.isNode(target)) tx.selection.set(target);
|
|
47078
47478
|
tx.fragment.delete({
|
|
47079
47479
|
direction: input.direction,
|
|
47080
|
-
...
|
|
47480
|
+
...at === void 0 ? {} : { at }
|
|
47081
47481
|
});
|
|
47082
47482
|
});
|
|
47083
47483
|
}
|
|
47084
47484
|
}),
|
|
47085
|
-
insertBreak: defineCommand$1("break.insert", { build: ({ state }) => state
|
|
47485
|
+
insertBreak: defineCommand$1("break.insert", { build: ({ state }) => breakAfterLanding(state, (tx) => {
|
|
47086
47486
|
tx.break.insert();
|
|
47087
47487
|
}) }),
|
|
47088
47488
|
insertNodes: defineCommand$1("node.insert", {
|
|
@@ -47091,7 +47491,7 @@ const editorCommands = Object.freeze({
|
|
|
47091
47491
|
tx.nodes.insert(input.nodes, input.options);
|
|
47092
47492
|
})
|
|
47093
47493
|
}),
|
|
47094
|
-
insertSoftBreak: defineCommand$1("break.insertSoft", { build: ({ state }) => state
|
|
47494
|
+
insertSoftBreak: defineCommand$1("break.insertSoft", { build: ({ state }) => breakAfterLanding(state, (tx) => {
|
|
47095
47495
|
tx.break.insertSoft();
|
|
47096
47496
|
}) }),
|
|
47097
47497
|
insertText: defineCommand$1("text.insert", {
|
|
@@ -47108,7 +47508,7 @@ const editorCommands = Object.freeze({
|
|
|
47108
47508
|
if (!nodeBlocks || LINE_BREAK_PATTERN.test(nodeReplacementText)) return false;
|
|
47109
47509
|
const root = rootOrUpdateRoot(SelectionApi.root(state.selection()));
|
|
47110
47510
|
const typing = typesAtSelection(getActiveCommandEditor(), { marks: input.options?.marks });
|
|
47111
|
-
const replacement = blockReplacing(state, getDefined(nodeBlocks[0]), root, nodeReplacementText, (typing ? state.marks() : null) ?? getConsistentBlockTextMarks(state, nodeBlocks.map(([block]) => state.key(block))));
|
|
47511
|
+
const replacement = blockReplacing(state, getDefined(nodeBlocks[0])[1], root, nodeReplacementText, (typing ? state.marks() : null) ?? getConsistentBlockTextMarks(state, nodeBlocks.map(([block]) => state.key(block))));
|
|
47112
47512
|
const nodeReplacement = replacement && getNodeSelectionReplacement(state, nodeBlocks, root, [replacement]);
|
|
47113
47513
|
if (!nodeReplacement) return false;
|
|
47114
47514
|
return state.transaction((tx) => {
|
|
@@ -47116,15 +47516,34 @@ const editorCommands = Object.freeze({
|
|
|
47116
47516
|
if (typing) setNextKeyMarks(getActiveCommandEditor());
|
|
47117
47517
|
});
|
|
47118
47518
|
}
|
|
47119
|
-
const
|
|
47519
|
+
const target = readCommandTarget(state, input.options?.at);
|
|
47520
|
+
const range = readLandingRange(state, target);
|
|
47120
47521
|
const typing = typesAtSelection(getActiveCommandEditor(), {
|
|
47121
47522
|
at: range ?? void 0,
|
|
47122
47523
|
marks: input.options?.marks
|
|
47123
47524
|
});
|
|
47124
47525
|
if (range) refuseCrossing(getSetSite(getActiveCommandEditor()), range, rootOrUpdateRoot(range.anchor.root ?? range.focus.root));
|
|
47125
47526
|
const replacementText = range ? limitTextInsert(state, input.text, { at: range }) : input.text;
|
|
47527
|
+
const over = range && !LINE_BREAK_PATTERN.test(replacementText) ? readRangeLanding(state, range) : null;
|
|
47528
|
+
if (range && over?.landing.keeps === "first" && !typesInPlace(state, over.landing.blocks, replacementText)) {
|
|
47529
|
+
const { landing } = over;
|
|
47530
|
+
return state.transaction((tx) => {
|
|
47531
|
+
selectMovedTarget(tx, state, input.options?.at, target);
|
|
47532
|
+
writeWholeBlockLanding(tx, landing, {
|
|
47533
|
+
at: range,
|
|
47534
|
+
direction: "backward",
|
|
47535
|
+
selectsText: true
|
|
47536
|
+
});
|
|
47537
|
+
tx.text.insert(replacementText, input.options?.at === void 0 ? input.options : {
|
|
47538
|
+
...input.options,
|
|
47539
|
+
at: landing.text
|
|
47540
|
+
});
|
|
47541
|
+
if (typing) setNextKeyMarks(getActiveCommandEditor());
|
|
47542
|
+
});
|
|
47543
|
+
}
|
|
47126
47544
|
const replacement = range ? getFullBlockTextReplacement(state, range, replacementText, typing, replacementText !== input.text) : null;
|
|
47127
47545
|
if (replacement) return state.transaction((tx) => {
|
|
47546
|
+
selectMovedTarget(tx, state, input.options?.at, target);
|
|
47128
47547
|
tx.nodes.replaceChildren([replacement.replacement], {
|
|
47129
47548
|
at: replacement.parentPath,
|
|
47130
47549
|
count: replacement.count,
|
|
@@ -47135,6 +47554,7 @@ const editorCommands = Object.freeze({
|
|
|
47135
47554
|
if (typing) setNextKeyMarks(getActiveCommandEditor());
|
|
47136
47555
|
});
|
|
47137
47556
|
return state.transaction((tx) => {
|
|
47557
|
+
selectMovedTarget(tx, state, input.options?.at, target);
|
|
47138
47558
|
writeComposedText(getActiveCommandEditor(), input.options?.at, input.text, () => tx.text.insert(input.text, input.options));
|
|
47139
47559
|
});
|
|
47140
47560
|
}
|
|
@@ -47262,19 +47682,6 @@ const editorCommands = Object.freeze({
|
|
|
47262
47682
|
}
|
|
47263
47683
|
})
|
|
47264
47684
|
});
|
|
47265
|
-
const deleteTripleClickedBlock = (tx, block, direction) => {
|
|
47266
|
-
const next = tx.nodes.next({ at: block })?.[0];
|
|
47267
|
-
tx.command(editorCommands.deleteFragment, {
|
|
47268
|
-
at: block,
|
|
47269
|
-
direction
|
|
47270
|
-
});
|
|
47271
|
-
if (!next || tx.nodes.get(block)) return;
|
|
47272
|
-
const start = tx.points.start(tx.key(next));
|
|
47273
|
-
if (start) tx.selection.set({
|
|
47274
|
-
anchor: start,
|
|
47275
|
-
focus: start
|
|
47276
|
-
});
|
|
47277
|
-
};
|
|
47278
47685
|
//#endregion
|
|
47279
47686
|
//#region src/editor/delete-forward.ts
|
|
47280
47687
|
const deleteForward$1 = (editor, unit) => {
|
|
@@ -47984,19 +48391,20 @@ const probeInEditorCommandFrame = (editor, body) => {
|
|
|
47984
48391
|
const index = valueRootIndex(stored, root);
|
|
47985
48392
|
const insideRemoved = (point) => projected.map.hides(root, index.positionAt(point));
|
|
47986
48393
|
let moved = storedSelection?.kind === "text" && (insideRemoved(storedSelection.anchor) || insideRemoved(storedSelection.focus));
|
|
47987
|
-
const
|
|
48394
|
+
const parent = getTransactionSnapshot(editor);
|
|
48395
|
+
const published = new Map(parent ? [] : projected.map.roots.map((rootName) => [rootName, withEditorUpdateRootScope(editor, rootName, () => getSnapshot$1(editor))]));
|
|
48396
|
+
const storedIndex = (rootName) => parent ? retainTransactionSnapshotIndex(editor, parent, rootName) : published.get(rootName)?.index ?? snapshotIndexOf(getEditorRuntimeOwner(editor), valueRootNodes(stored, rootName));
|
|
48397
|
+
const placed = createFramePlace(editor, projected, stored, storedIndex, selectionRoot, () => {
|
|
47988
48398
|
moved = true;
|
|
47989
48399
|
});
|
|
47990
48400
|
const selection = placed.selection(storedSelection);
|
|
47991
48401
|
const evaluate = body(placed.place);
|
|
47992
|
-
const parent = getTransactionSnapshot(editor);
|
|
47993
|
-
const published = new Map(parent ? [] : projected.map.roots.map((rootName) => [rootName, withEditorUpdateRootScope(editor, rootName, () => getSnapshot$1(editor))]));
|
|
47994
48402
|
const typed = getTypedMarks(editor);
|
|
47995
48403
|
const frame = createTransactionSpecContext(editor);
|
|
47996
48404
|
const { snapshot } = frame;
|
|
47997
48405
|
COMMAND_FRAMES.add(editor);
|
|
47998
48406
|
try {
|
|
47999
|
-
enterFrameDraft(editor, frame, stored, projected,
|
|
48407
|
+
enterFrameDraft(editor, frame, stored, projected, storedIndex, storedSelection, selectionRoot, selection, placed.bookCaret);
|
|
48000
48408
|
setTypedMarks(editor, typed);
|
|
48001
48409
|
snapshot.implicitTarget = null;
|
|
48002
48410
|
snapshot.implicitTargetResolved = false;
|
|
@@ -48033,6 +48441,42 @@ const runSelectionOnlyInEditorUpdate = (editor, declaration, run) => {
|
|
|
48033
48441
|
return applied;
|
|
48034
48442
|
};
|
|
48035
48443
|
const TEXT_STARTS = /* @__PURE__ */ new WeakMap();
|
|
48444
|
+
const ELEMENT_ID_PLACES = /* @__PURE__ */ new WeakMap();
|
|
48445
|
+
const OPTION_PLACES = /* @__PURE__ */ new WeakMap();
|
|
48446
|
+
/** @internal */
|
|
48447
|
+
const placeElementIdIn = (place, id) => getDefined(ELEMENT_ID_PLACES.get(place))(id);
|
|
48448
|
+
const TARGET_OPTIONS = [
|
|
48449
|
+
"at",
|
|
48450
|
+
"after",
|
|
48451
|
+
"before"
|
|
48452
|
+
];
|
|
48453
|
+
const isOptions = (arg) => typeof arg === "object" && arg !== null && !Array.isArray(arg) && !NodeApi.isDescendant(arg);
|
|
48454
|
+
const namesElementId = (args) => {
|
|
48455
|
+
const options = args.at(-1);
|
|
48456
|
+
return isOptions(options) && TARGET_OPTIONS.some((name) => elementIdOf(options[name]) !== void 0);
|
|
48457
|
+
};
|
|
48458
|
+
/** @internal */
|
|
48459
|
+
const callAtElementIds = (caller, args, call) => {
|
|
48460
|
+
if (!namesElementId(args)) return call(args, false);
|
|
48461
|
+
const owner = getEditorRuntimeOwner(caller);
|
|
48462
|
+
let result;
|
|
48463
|
+
return withViewPlacement(caller, () => runInEditorCommandFrame(owner, (place) => {
|
|
48464
|
+
const last = args.length - 1;
|
|
48465
|
+
const options = getDefined(OPTION_PLACES.get(place))(args[last]);
|
|
48466
|
+
const placed = args.with(last, options ?? missedOptions(args[last]));
|
|
48467
|
+
return () => {
|
|
48468
|
+
result = call(placed, true);
|
|
48469
|
+
return true;
|
|
48470
|
+
};
|
|
48471
|
+
})) === null ? call(args, false) : result;
|
|
48472
|
+
};
|
|
48473
|
+
const missedOptions = (options) => Object.fromEntries(Object.entries(options).map(([name, value]) => [name, TARGET_OPTIONS.includes(name) && value !== void 0 ? UNPLACED_TARGET : value]));
|
|
48474
|
+
/** @internal */
|
|
48475
|
+
const unframedPlace = (editor) => Object.freeze({ location: ((at) => {
|
|
48476
|
+
const id = elementIdOf(at);
|
|
48477
|
+
if (id !== void 0) return lookupElementId(editor, id)?.key ?? null;
|
|
48478
|
+
return COMMAND_FRAMES.has(getEditorRuntimeOwner(editor)) && (typeof at === "string" || NodeApi.isDescendant(at)) && getNodeTargetRoot(editor, at) === void 0 ? null : at;
|
|
48479
|
+
}) });
|
|
48036
48480
|
/** @internal */
|
|
48037
48481
|
const refusesTextStartInStruck = (place, at) => TEXT_STARTS.get(place)?.(at) ?? false;
|
|
48038
48482
|
const LAST_FRAME_INDEXES = /* @__PURE__ */ new WeakMap();
|
|
@@ -48131,7 +48575,7 @@ const keepWhereHeld = () => {};
|
|
|
48131
48575
|
* projection removes it. A location without a root addresses the update's
|
|
48132
48576
|
* root, and a selection without one its own root.
|
|
48133
48577
|
*/
|
|
48134
|
-
const createFramePlace = (editor, projected, stored, selectionRoot, refuse, stamp = null, refusesStruckTargets = true) => {
|
|
48578
|
+
const createFramePlace = (editor, projected, stored, storedIndex, selectionRoot, refuse, stamp = null, refusesStruckTargets = true) => {
|
|
48135
48579
|
let heldRefusal = null;
|
|
48136
48580
|
let located = false;
|
|
48137
48581
|
const compositionRoot = stamp && (stamp.place.root ?? selectionRoot);
|
|
@@ -48335,13 +48779,16 @@ const createFramePlace = (editor, projected, stored, selectionRoot, refuse, stam
|
|
|
48335
48779
|
};
|
|
48336
48780
|
function location(at) {
|
|
48337
48781
|
located = true;
|
|
48782
|
+
const id = elementIdOf(at);
|
|
48783
|
+
if (id !== void 0) return placeElementId(id)?.key ?? null;
|
|
48784
|
+
const isNode = NodeApi.isDescendant(at);
|
|
48338
48785
|
if (SelectionApi.isNode(at)) {
|
|
48339
48786
|
const root = SelectionApi.root(at) ?? getEditorUpdateRoot(editor);
|
|
48340
48787
|
if (refusesStruck(at.paths, root) || insideStruckText(at.paths, root)) return null;
|
|
48341
48788
|
const mapped = map(at, getEditorUpdateRoot(editor));
|
|
48342
48789
|
return mapped?.kind === "node" ? mapped : null;
|
|
48343
48790
|
}
|
|
48344
|
-
if (PointApi.isPoint(at)) return caret(at, getEditorUpdateRoot(editor), refuse);
|
|
48791
|
+
if (!isNode && PointApi.isPoint(at)) return caret(at, getEditorUpdateRoot(editor), refuse);
|
|
48345
48792
|
if (LocationApi.isSpan(at)) {
|
|
48346
48793
|
const root = getEditorUpdateRoot(editor);
|
|
48347
48794
|
if (refusesStruck(at, root) || insideStruckText(at, root)) return null;
|
|
@@ -48349,7 +48796,7 @@ const createFramePlace = (editor, projected, stored, selectionRoot, refuse, stam
|
|
|
48349
48796
|
const to = path(at[1]);
|
|
48350
48797
|
return from && to && [from, to];
|
|
48351
48798
|
}
|
|
48352
|
-
if (RangeApi.isRange(at)) {
|
|
48799
|
+
if (!isNode && RangeApi.isRange(at)) {
|
|
48353
48800
|
const placed = span(at, getEditorUpdateRoot(editor), refuse);
|
|
48354
48801
|
return placed && {
|
|
48355
48802
|
...at,
|
|
@@ -48361,7 +48808,7 @@ const createFramePlace = (editor, projected, stored, selectionRoot, refuse, stam
|
|
|
48361
48808
|
const root = getEditorUpdateRoot(editor);
|
|
48362
48809
|
if (target && (refusesStruck([target], root) || insideStruckText([target], root))) return null;
|
|
48363
48810
|
const placed = target ? path(target) : null;
|
|
48364
|
-
return placed && (typeof at === "string" ||
|
|
48811
|
+
return placed && (typeof at === "string" || isNode) ? at : placed;
|
|
48365
48812
|
}
|
|
48366
48813
|
const startsInStruckText = (at) => {
|
|
48367
48814
|
if (SelectionApi.isNode(at)) return false;
|
|
@@ -48371,8 +48818,64 @@ const createFramePlace = (editor, projected, stored, selectionRoot, refuse, stam
|
|
|
48371
48818
|
const node = nodeAt$1(valueRootNodes(stored, root), resolved);
|
|
48372
48819
|
return node !== void 0 && insideStruckText([[...resolved, ...NodeApi.first(node, [])[1]]], root);
|
|
48373
48820
|
};
|
|
48821
|
+
const storedHolders = /* @__PURE__ */ new Map();
|
|
48822
|
+
const storedHolder = (id) => {
|
|
48823
|
+
const known = storedHolders.get(id);
|
|
48824
|
+
if (known !== void 0) return known;
|
|
48825
|
+
const held = lookupElementId(editor, id);
|
|
48826
|
+
storedHolders.set(id, held);
|
|
48827
|
+
return held;
|
|
48828
|
+
};
|
|
48829
|
+
const placeElementId = (id) => {
|
|
48830
|
+
located = true;
|
|
48831
|
+
const held = storedHolder(id);
|
|
48832
|
+
const changed = projected.map.roots;
|
|
48833
|
+
if (held && !changed.includes(held.root)) return held;
|
|
48834
|
+
for (const root of changed.toSorted((a, b) => a === "main" ? -1 : b === "main" ? 1 : a < b ? -1 : 1)) {
|
|
48835
|
+
const topology = uniqueTopologyOf(getEditorRuntimeOwner(editor), frameIndexOf(editor, stored, projected, root, () => storedIndex(root)), valueRootNodes(projected.value, root));
|
|
48836
|
+
const [shown] = topology && topologyHolding(topology, "id", id)?.all() || [null];
|
|
48837
|
+
if (shown?.key) return {
|
|
48838
|
+
key: shown.key,
|
|
48839
|
+
path: shown.path,
|
|
48840
|
+
root
|
|
48841
|
+
};
|
|
48842
|
+
}
|
|
48843
|
+
if (held && !refusesStruck([held.path], held.root)) insideStruckText([held.path], held.root);
|
|
48844
|
+
return null;
|
|
48845
|
+
};
|
|
48846
|
+
const placeOptions = (options) => {
|
|
48847
|
+
const id = elementIdOf(options.at);
|
|
48848
|
+
const held = id === void 0 ? null : storedHolder(id);
|
|
48849
|
+
const inHolderRoot = (fn) => held ? withEditorUpdateRootScope(editor, held.root, fn) : fn();
|
|
48850
|
+
const placed = { ...options };
|
|
48851
|
+
for (const name of [
|
|
48852
|
+
"at",
|
|
48853
|
+
"after",
|
|
48854
|
+
"before",
|
|
48855
|
+
"to"
|
|
48856
|
+
]) {
|
|
48857
|
+
const target = options[name];
|
|
48858
|
+
if (target === void 0 || target === null) continue;
|
|
48859
|
+
const at = inHolderRoot(() => location(target));
|
|
48860
|
+
if (at === null) return null;
|
|
48861
|
+
placed[name] = at;
|
|
48862
|
+
}
|
|
48863
|
+
const childIndexInFrame = (position) => inHolderRoot(() => {
|
|
48864
|
+
const holder = resolveNodeTargetLocation(editor, placed.at);
|
|
48865
|
+
return (holder && PathApi.isPath(holder) ? path([...holder, position]) : null)?.at(-1) ?? null;
|
|
48866
|
+
});
|
|
48867
|
+
const { position } = options;
|
|
48868
|
+
if (held && typeof position === "number") {
|
|
48869
|
+
const index = childIndexInFrame(position);
|
|
48870
|
+
if (index === null) return null;
|
|
48871
|
+
placed.position = index;
|
|
48872
|
+
}
|
|
48873
|
+
return placed;
|
|
48874
|
+
};
|
|
48374
48875
|
const place = Object.freeze({ location });
|
|
48375
48876
|
TEXT_STARTS.set(place, startsInStruckText);
|
|
48877
|
+
ELEMENT_ID_PLACES.set(place, placeElementId);
|
|
48878
|
+
OPTION_PLACES.set(place, placeOptions);
|
|
48376
48879
|
const placeSelection = (selection, root, onRefuse) => {
|
|
48377
48880
|
if (selection?.kind !== "text") {
|
|
48378
48881
|
if (selection) refusesStruck(selection.paths, SelectionApi.root(selection) ?? root, onRefuse);
|
|
@@ -48453,7 +48956,8 @@ const runInEditorCommandFrame = (editor, body, { framedOn, ignoresSelection = fa
|
|
|
48453
48956
|
if (framedOn && (stored.children !== framedOn.children || outer.caret.generation !== framedOn.generation)) throw new Error("Cannot apply a stale framed spec.");
|
|
48454
48957
|
const projected = document.project(stored);
|
|
48455
48958
|
if (!projected) return null;
|
|
48456
|
-
const
|
|
48959
|
+
const storedIndex = (root) => retainTransactionSnapshotIndex(editor, outer.snapshot, root);
|
|
48960
|
+
const placed = createFramePlace(editor, projected, stored, storedIndex, outer.caret.root, (reason) => {
|
|
48457
48961
|
throw refusedIn(editor, reason);
|
|
48458
48962
|
}, stamp, refusesStruckTargets);
|
|
48459
48963
|
const stamped = stamp && stampFrame(stamp, placed.place);
|
|
@@ -48461,7 +48965,6 @@ const runInEditorCommandFrame = (editor, body, { framedOn, ignoresSelection = fa
|
|
|
48461
48965
|
const target = outer.snapshot.implicitTarget ? placed.held(outer.snapshot.implicitTarget) : null;
|
|
48462
48966
|
const run = body(placed.place);
|
|
48463
48967
|
if (!ignoresSelection) placed.refuseAtHeldSelection();
|
|
48464
|
-
const storedIndex = (root) => retainTransactionSnapshotIndex(editor, outer.snapshot, root);
|
|
48465
48968
|
const runFramed = () => {
|
|
48466
48969
|
const typed = getTypedMarks(editor);
|
|
48467
48970
|
const frame = createTransactionSpecContext(editor);
|
|
@@ -48786,7 +49289,10 @@ const applyCommandEvaluation = (editor, evaluation) => {
|
|
|
48786
49289
|
const runCommandChain = (editor, command, input) => withViewPlacement(editor, () => runPlacedCommandChain(editor, command, input));
|
|
48787
49290
|
const runPlacedCommandChain = (editor, command, input) => {
|
|
48788
49291
|
const owner = getEditorRuntimeOwner(editor);
|
|
48789
|
-
const run = () =>
|
|
49292
|
+
const run = () => {
|
|
49293
|
+
const located = locateCommandInput(command, input, unframedPlace(editor));
|
|
49294
|
+
return located !== null && applyCommandEvaluation(editor, evaluateCommandChain(editor, command, located));
|
|
49295
|
+
};
|
|
48790
49296
|
if (!getEditorCommandDocument(owner)) return run();
|
|
48791
49297
|
const { selection } = getCommandRuntime(command);
|
|
48792
49298
|
if (!selection) assertCommandLocated(command, input);
|
|
@@ -50996,4 +51502,4 @@ const extendEditor = (editor, input, options = {}) => {
|
|
|
50996
51502
|
};
|
|
50997
51503
|
};
|
|
50998
51504
|
//#endregion
|
|
50999
|
-
export { first as $, sameCarets as $a, vetoesWrite as $c, pathKey$2 as $d, cloneFrozen as $f, trackDraftSpans as $i, rejectEditorRecord as $l, getEditorReadDepth as $n, canonicalizeCompiledTextProperties as $o, setCurrentSelection as $r, ownedRootsOf as $s, setPoint as $t, createInternalRootChangeFromSections as $u, definePluginSlot as A, nodes as Aa, assertNoDocumentViewRead as Ac, propertyDeltaFromModifications as Ad, decodeVersionedValue as Af, planPaste as Ai, holdsUniqueKey as Al, documentReplacement as An, subscribeCommit as Ao, isInTransaction as Ar, constructCanonicalDocumentChange as As, last as At, UNSCOPED_ORIGINS as Au, NodeApi as B, getRangeBreakCount as Ba, withStoredAuthoredRead as Bc, rootNodesOf as Bd, defineEffect as Bf, readRootViewPresentationRevision as Bi, splitDroppedKeysOf as Bl, getChildList as Bn, txOnly as Bo, recordEditorHistoryReplayReceipt as Br, carriesDefault as Bs, point as Bt, historyFollowsAllFacts as Bu, setPluginPortalFactory as C, getWordSegments as Ca, getDocumentChangeRelocations as Cc, addSection as Cd, showValueRecords as Cf, withEditorRootChildrenGenerator as Ci, diffEditorSchemaContracts as Cl, applyTransactionSpecToDocument as Cn, withMountedPresentation as Co, initializeEditorSchemaDocument as Cr, mapSelectionWithContext as Cs, isElementReadOnly as Ct, getEditorRuntime as Cu, property as D, gridRolesOf as Da, authoredDocumentCapabilityPoint as Dc, getDocumentPropertyContext as Dd, assertEditorJsonValue as Df, setTargetRuntime as Di, handoverKeysOf as Dl, attachTransactionSpecAfterCommit as Dn, onPresentationRelease as Do, invalidateEditorTransactionSpecs as Dr, sealsText as Ds, isSelectable as Dt, hasEditorRuntime as Du, getSchemaElementSourceReference as E, gridPartsOf as Ea, hasIndexedPathAncestor as Ec, applyPropertyModificationsToSlice as Ed, areEditorJsonValuesEqual as Ef, withUpdateTagContext as Ei, getCompiledSchemaPropertyId as El, assertEditorExternalMutationAllowed as En, isViewPresentationRetained as Eo, initializePublicState as Er, withLandedMarks as Es, isInline as Et, getEditorSchema as Eu, getActiveCommandEditor as F, clearCaretUnlessHeldElsewhere as Fa, isAuthoredPreview as Fc, DocumentIndex as Fd, snapshotEditorJsonValue as Ff, readCaretViewIn as Fi, propertyTargetsReadParents as Fl, getActiveEditorTransaction as Fn, callPluginUpdateMethod as Fo, readEditor as Fr, EditorNoncanonicalChangeError as Fs, move as Ft, UNKNOWN_FACTS as Fu, collapse as G, mayClearCaret as Ga, observeAnchorStateWork as Gc, PreparedTokenSliceStructureError as Gd, copyRoot as Gf, subscribeRootTarget as Gi, EDITOR_DOCUMENT_FIELDS as Gl, getCurrentSelection as Gn, admitEditorDocument as Go, replaceSliceAtBlockBoundary as Gr, changedRootsOf as Gs, read as Gt, invertCarriedRun as Gu, addMark as H, holdsCaretAt as Ha, hasActiveAnchors as Hc, normalizeSetValues as Hd, invertEffect as Hf, readShownViewUse as Hi, toCompiledTargetContext as Hl, getCollabEffectTypes as Hn, txStored as Ho, registerEditorSurface as Hr, isLeftOutDefault as Hs, previous as Ht, carriedLetterPairs as Hu, hasCommandHandler as I, consumeCommitCarets as Ia, readAuthoredView as Ic, NO_NODES as Id, supportsEditorValuePersistenceVersion as If, readLatestShownWritableRootView as Ii, readEditorSchemaContract as Il, getActiveEditorUpdateId as In, getRootTransaction as Io, readEditorCommitHistoryEntry as Ir, EditorSchemaValidationError as Is, moveNodes as It, composeFacts as Iu, deleteForward as J, resolveBookmark as Ja, getPublicExplicitLocationRoot as Jc, getDocumentSliceNodeKeys as Jd, lazyRootOf as Jf, getFragment$1 as Ji, isEnvelopeInput as Jl, getEditorDocumentRecords as Jn, withoutRepairOrphans as Jo, saveEditorSchemaDocument as Jr, orphanedValueRoots as Js, replace as Jt, widenRun as Ju, deleteBackward as K, nextMintedGeneration as Ka, stageAnchorHistoryRecovery as Kc, closeToken as Kd, copyRoots as Kf, subscribeRootViewPresentation as Ki, assertEditorDocumentContainers as Kl, getCurrentSelectionRoot as Kn, documentAdmissionPoint as Ko, resolveEditorNodeKeyForNode as Kr, judgeProjectedRoots as Ks, removeMark as Kt, landCarriedRuns as Ku, probeCommandNativeEquivalent as L, getBookmark as La, registerAuthoredRuntime as Lc, childAtPathIndex as Ld, textPropertiesEqual as Lf, readLatestShownWritableView as Li, readEditorSchemaIdentity as Ll, getActiveEditorUpdateTags as Ln, resolvePluginMethod as Lo, readEditorHistoryHeadRoots as Lr, adoptVerdicts as Ls, next as Lt, factsFromJSON as Lu, dispatchCommand as M, node as Ma, withDocumentViewRead as Mc, markReadBack as Md, encodeVersionedValue as Mf, getSelectionStateCaret as Mi, isSupportedGeneratedElementProperty as Ml, fitSliceChildren as Mn, createEditorReadApi as Mo, isPresentationComposing as Mr, fitImportedBlock as Ms, levels as Mt, letterOriginsOfChange as Mu, evaluateCommand as N, capturePlacement as Na, configureAuthoredView as Nc, joinsOf as Nd, isEditorJsonValue as Nf, markRootViewUsed as Ni, matchesCompiledSchemaTarget as Nl, fitSlicePlacements as Nn, createEditorUpdateApi as No, loadOpenedRecords as Nr, joinedAway as Ns, liftNodes as Nt, NO_FACTS as Nu, schema as O, leftWithNoGridPart as Oa, isAuthorId as Oc, keptRunsOf as Od, cloneEditorJsonValue as Of, resolveStateFieldInitial as Oi, hasPlaceDependentElementProperty as Ol, continueTransactionSpecOrDiscardPrefix as On, retainPresentation as Oo, isBuildingTransactionSpec as Or, settleRange as Os, isStart as Ot, setEditorRuntime as Ou, evaluateCommandWithState as P, changedBookmarks as Pa, getAuthoredUpdateView as Pc, liftOf as Pd, normalizeEditorValuePersistence as Pf, mountRootView as Pi, preserveCompiledSchemaPropertyIdentity as Pl, flushEditorViewState as Pn, mapSemanticUpdateMethodArguments as Po, notifyPresentationViewState as Pr, isEmptyElement as Ps, mergeNodes as Pt, NO_ROOT_FACTS as Pu, elementReadOnly as Q, rootChildrenOf as Qa, nodeWriteVeto as Qc, openToken as Qd, readCoreWork as Qf, readDraftTrackAt as Qi, readStoredEditorDocument as Ql, getEditorProjectionSnapshotIndex as Qn, canPlaceBlocksAtPath as Qo, setCurrentMarks as Qr, ensureElementOwnedRootIndex as Qs, setNodes as Qt, createInternalDocumentChange as Qu, commandViewHides as R, getCaretOwner as Ra, requestAuthoredView as Rc, decodeNodes as Rd, valueCodecs as Rf, readNestedRootView as Ri, resolveCompiledSchemaProperty as Rl, getAppliedSpecLanding as Rn, locateAt as Ro, readEditorHistoryReplayReceipt as Rr, judgedBy as Rs, parent as Rt, factsToJSON as Ru, resolveInstalledPlugin as S, getWordDistances as Sa, snapshotIndexOf as Sc, RootChange as Sd, recordSetIds as Sf, withEditorRootChildren as Si, crossesUniqueTarget as Sl, applyTransactionSpec as Sn, retainViewPresentation as So, inheritEditorProjectionIndexes as Sr, mapSelectionThroughChange as Ss, isEditor as St, registerEditorCommandDocument as Su, withPluginPortalCandidates as T, gridHoldersOf as Ta, getExactDocumentChangeRelocations as Tc, applyPropertyModifications as Td, withoutValueRoots as Tf, withTransactionSpecDraftRead as Ti, getCompiledPropertyMergeStrategy as Tl, asSelectionMotion as Tn, getStateViewPresentation as To, initializeEditorSchemaSnapshot as Tr, settleSelectionMode as Ts, isEnd as Tt, getEditorRuntimeRoot as Tu, after as U, keepBookmark as Ua, mapAnchorHistoryRecovery as Uc, classifyRootChange as Ud, mapEffect as Uf, readShownWritableRootViews as Ui, tracksPlaces as Ul, getCollabEffects$1 as Un, DOCUMENT_SETTLED_TAG as Uo, registerEditorTransactionGuard as Ur, isSplitOutput as Us, projectRange as Ut, carriesRun as Uu, above as V, holdsCaret as Va, consumeAnchorHistoryCapture as Vc, canonicalJsonKey as Vd, defineUpdateAnnotation as Vf, readRootViewUse as Vi, toCompiledNodeContext as Vl, getChildren$1 as Vn, txSelection as Vo, registerEditorHistoryRuntime as Vr, elementSplitOutput as Vs, positions as Vt, recordedFacts as Vu, before as W, liftShownTarget as Wa, mergeAnchorHistoryRecovery as Wc, PreparedTokenSlice as Wd, copyFields as Wf, showsRootView as Wi, uniquePropertiesOf as Wl, getCurrentMarks as Wn, admitDocument as Wo, repairEditorValue as Wr, readsAt as Ws, range as Wt, exactRunOn as Wu, deselect as X, resolveParkedCaret as Xa, toPublicRoot as Xc, isTextNode$3 as Xd, visitRootNames as Xf, assertEditorNotDestroyed as Xi, readEditorDocument as Xl, getEditorMaxLength as Xn, ElementGenerationMaskedError as Xo, seedUniqueMaps as Xr, schemaHasContentRoots as Xs, reset as Xt, alignedDocumentChange as Xu, deleteFragment as Y, resolveLiveCaret as Ya, toInternalRoot as Yc, isElementNode as Yd, setLazyRoot as Yf, getContentSlice as Yi, readDocumentRecord as Yl, getEditorDocumentValue as Yn, documentRootsOf as Yo, scheduleAfterCommitNotification as Yr, rootsDeletedByName as Ys, replaceChildren as Yt, DocumentChange as Yu, edges as Z, restoreHistoryCarets as Za, getRangeEndpointAssociations as Zc, nodeProps as Zd, countCoreWork as Zf, readDraftTrack as Zi, readPersistedEnvelope as Zl, getEditorNodeKeyForNode as Zn, acceptsPropertyValue as Zo, setChildren as Zr, advanceElementOwnedRootIndex as Zs, select as Zt, collapseDocumentElementPropertyWrites as Zu, markEditorDormant as _, exportContentSlice as _a, getEditorCommitUnsettle as _c, valueRootIndex as _d, hasRecordWithPrefix as _f, trackEditorLetters as _i, markDefinedStateField as _l, withCompositionStamp as _n, mountViewPeer as _o, getStateFieldEffectTypes as _r, decodeEditorSelection as _s, insertSoftBreak as _t, MAIN_ROOT_KEY as _u, compilePluginInput as a, range$1 as aa, claimsHistoryReplay as ac, getInternalDocumentChangeEntries as ad, NO_RECORD_OPS as af, setEditorSnapshotInputTransform as ai, reportEditorLifecycleError as al, toggleBlock as an, carryRootEditors as ao, getLiveNode as ar, getRepresentationEditorFromApi as as, getNodeKey as at, ElementApi as au, queueAfterPluginAcquisition as b, editorReads as ba, keyMovedAt as bc, withInternalDocumentRootChange as bd, recordOpsFromJson as bf, withDraftMove as bi, areEditorSchemaIdentitiesEqual as bl, applyBuiltDocumentChange as bn, readShownRecords as bo, hasEditorProjectionSnapshotIndex as br, isObjectSelectionTarget as bs, isBlock as bt, getReaderRange as bu, defineEditorSchema as c, deleteText as ca, getEditorCommitAdmission as cc, getInternalDocumentChangeRootKeys as cd, deriveValue as cf, setEditorViewing as ci, assertPluginPublicationInactive as cl, unsetNodes as cn, createEditorViewRuntime as co, getMutationVersion as cr, landNodePropertiesAt as cs, getSelection as ct, getTextSearchScope as cu, extendEditor as d, removeNodes$1 as da, getEditorCommitFacts as dc, isDocumentRootKey as dd, getRecordIds as df, snapshotInitialDocumentState as di, getCompiledEditorSchema as dl, voidEditor as dn, getOwnViewPresentation as do, getPathByNodeKey$1 as dr, withoutGeneration as ds, hasInlines as dt, registerEditorContent as du, registerEditorDocumentRecorder as ea, rebaseElementOwnedRootIndex as ec, documentChangeBetween as ed, textToken as ef, setEditorComposing as ei, EditorRefusalError as el, setSelection as en, setSelectionAsView as eo, deepFreeze as ep, getEditorRuntimeElementEntries as er, createDetachedEditorSchema as es, fragment as et, failInvariant as eu, getCandidatePluginApi as f, elementReadOnly$1 as fa, getEditorCommitNode as fc, isInternalDocumentChangeNoop as fd, getRecordSetVersion as ff, subscribeCaretTarget as fi, getConfiguredPluginRegistry as fl, wrapNodes as fn, getOwnViewReadOnly as fo, getRestorableMarks as fr, withoutGenerationOf as fs, hasPath as ft, LocationApi as fu, isPlugin as g, after$1 as ga, getEditorCommitStartedAt as gc, valueRoot$1 as gd, hasRecord as gf, toEditorCoreStateView as gi, initializeBasePluginRegistry as gl, readWholeBlockDelete as gn, matchesPresentationOf as go, getSnapshotVersion as gr, assertSelectionSupported as gs, insertNodes as gt, isObject as gu, getInstalledPluginApi as h, before$1 as ha, getEditorCommitSnapshot as hc, transformInternalDocumentChange as hd, getValueRecords as hf, syncImplicitTargetToCurrentSelection as hi, inheritPluginRegistry as hl, getRemovableTripleClickedBlock as hn, getViewPresentation as ho, getSnapshot$1 as hr, assertDetachedSelectionSupported as hs, insertNode as ht, PointApi as hu, compilePlugin as i, rewriteContentRootReferences as ia, createDetachedContentSlice as ic, getInternalDocumentChangeClassificationEntries as id, getNodeKeyForNode as if, setEditorReadOnly as ii, notifyObservers as il, subscribeSource as in, withoutPlacement as io, getDefined as ip, getLastCommit$1 as ir, getInternalEditorSchemaFromApi as is, getLastCommit as it, SelectionApi as iu, createCommandDispatch as j, normalizeNodeMatch as ja, isDocumentView as jc, semanticPropertyModifications as jd, encodeEditorEffect as jf, writePaste as ji, isPlaceDependentElementProperty as jl, finalizeTransactionRepresentation as jn, subscribeSource$1 as jo, isNotifyingNestedCommit as jr, constructLoadedDocumentChange as js, leaf as jt, classifyDocumentChange as ju, target as k, survivalUnder as ka, createEditorAnchorApi as kc, mapRootChangePositionBackward as kd, decodeEditorEffect as kf, captureSliceLanding as ki, hashSchemaIdentityString as kl, createTransactionSpec as kn, subscribe as ko, isEditorPublishingCommit as kr, completeChildrenAt as ks, isVoid as kt, defineCommand$1 as ku, definePlugin as l, readRemovalLanding as la, getEditorCommitCarriedRuns as lc, getInternalDocumentRootChange as ld, getRecordCount as lf, setRootCopyScope as li, createPluginRegistry as ll, unwrapNodes as ln, getCarriedCaretEditor as lo, getNodeKey$1 as lr, placeElementAt as ls, getSnapshot as lt, TextApi as lu, getInstalledPlugin as m, readOnlyInlineAt as ma, getEditorCommitSchemas as mc, mapInternalDocumentChangePosition as md, getRecordsWithPrefix as mf, subscribePresentationComposition as mi, getPluginRegistry$1 as ml, editorCommands as mn, getViewFollowTarget as mo, getSetSite as mr, withFitLanding as ms, insertBreak as mt, RangeApi as mu, brandPluginDescriptor as n, registerEditorDraftView as na, lawCheckEnabled as nc, filterDocumentChangeRoots as nd, tokensEqual as nf, setEditorFocused as ni, subscribeEditorRefusals as nl, splitNodes as nn, subscribeCommittedPlacement as no, jsonEqual$1 as np, getEditorStateView as nr, generateElementPropertyValue as ns, getCollabEffects as nt, point$1 as nu, containsCompleteEditorSchema as o, withLandingBlock as oa, createEditorCommit as oc, getInternalDocumentChangeRanges as od, canonicalRecordJson as of, setEditorStateViewTransform as oi, runEditorObserver as ol, toggleMark as on, createAuthoredEditorView as oo, getLiveSelection as or, holdsImportedRoot as os, getPathByNodeKey as ot, formatDebugValue as ou, getCompiledEditorConfiguration as p, hasEdgeInReadOnlyInline as pa, getEditorCommitRest as pc, mapInternalDocumentChangePoint as pd, getRecordText as pf, subscribeEditorViewState as pi, getPluginContributions as pl, deleteTripleClickedBlock as pn, getViewAuthor as po, getSelectionRoot as pr, payloadKeyOf as ps, hasTexts as pt, SpanApi as pu, deleteEditor as q, placedSince as qa, assertPublicRootKey as qc, encodeNodes as qd, isFrozenWithRoots as qf, subscribeShownViewUse as qi, getEditorDocumentShapeIssueMessage as ql, getEditorChildrenRoot as qn, onlyDocumentAdmission as qo, runTrustedUpdate as qr, orphanedRoots as qs, removeNodes as qt, mapCarriedRunThrough as qu, carryPluginFactoryType as r, registerEditorFitsByLook as ra, ContentSlice as rc, getInternalDocumentChangeClassification as rd, getNodeKeyDOMValue as rf, setEditorMaxLength as ri, REMOTE_UPDATE as rl, string as rn, watchFirstPlacement as ro, cloneFrozen$1 as rp, getEditorUpdateRoot as rr, getCompiledEditorSchemaFromApi as rs, getFragment as rt, readTextEdge as ru, createEditorViewPluginApis as s, dividesTextCell as sa, getDocumentValueNode as sc, getInternalDocumentChangeRecords as sd, composeRecordOps as sf, setEditorTransactionViewTransform as si, setEditorLifecycleErrorSink as sl, unhangRange as sn, createEditorView as so, getLiveText as sr, holdsOneText as ss, getPluginRegistry as st, setDebugValueScrubber as su, PluginPublicationError as t, registerEditorDraftGuard as ta, rootsOwnedOnlyWithin as tc, documentChangeWritesOnlyElementProperties as td, tokenLength as tf, setEditorCompositionPending as ti, publishEditorRefusal as tl, shouldMergeNodesRemovePrevNode as tn, setShownSelectionAsView as to, isRecord$5 as tp, getEditorRuntimeRootKeys as tr, createEditorSchema as ts, getChildren as tt, definePluginPoint as tu, destroyEditor as u, resolveDeletedRange as ua, getEditorCommitCompletedTextDeletion as uc, hasInternalDocumentChangeRoot as ud, getRecordEntries as uf, setTypedMarks as ui, finalizePluginRegistry as ul, update as un, getCarriedMount as uo, getNodeTargetRoot as ur, readEmptyText as us, hasBlocks as ut, isEditorContent as uu, prepareInitialPluginPublication as v, resolveShouldMergeNodesRemovePrevNode as va, getEditorCommitValue as vc, valueRootNodes as vd, readRecord as vf, transformEditorSnapshotInput as vi, registerEffectTypeInRegistry as vl, afterActiveTransactionEnds as vn, projectEditorView as vo, getTransactionSnapshot as vr, encodeEditorSelection as vs, insertText as vt, getCommonLocationRoot as vu, startEditor as w, isTextCell as wa, getExactDocumentChangeRelocation as wc, ancestorType as wd, withValueRecords as wf, withEditorUpdateRootScope as wi, getCompiledPropertyCandidates as wl, applyUnnamedDocumentChange as wn, getBaseViewPresentation as wo, initializeEditorSchemaSelection as wr, rawNodeAt as ws, isEmpty as wt, getEditorRuntimeOwner as wu, releaseEditor as x, getCharacterDistance as xa, readRootEntries as xc, withoutRetainedRecordSets as xd, recordSetChanges as xf, withEditorDocumentProjection as xi, compileEditorSchemaContributions as xl, applyDocumentChange as xn, readViewPage as xo, hasEditorSurface as xr, mapDetachedSelectionThroughChange as xs, isEdge as xt, PathApi as xu, prepareScopedPluginPublication as y, executeEditorRead as ya, historyReplayClaim as yc, withDocumentChangeRecords as yd, recordOpsBetween as yf, updateEditor as yi, EditorSchemaCompileError as yl, afterOpenDrafts as yn, readShownDocument as yo, getUpdateView as yr, getSelectionDOMRange as ys, install as yt, getRangeRoot as yu, prepareCommandFrame as z, getPlacementGeneration as za, withAuthoredUpdateView as zc, rootIndexOf as zd, createEditorEffect as zf, readRootTarget as zi, restoreEditorSchemaContract as zl, getBaseCallRoot as zn, txLocate as zo, readElementPropertyWrites as zr, readingCovered as zs, path as zt, flipFacts as zu };
|
|
51505
|
+
export { first as $, restoreHistoryCarets as $a, mergeAnchorHistoryRecovery as $c, pathKey$2 as $d, PathApi as $f, trackDraftSpans as $i, tracksPlaces as $l, getEditorRuntimeElementEntries as $n, onlyDocumentAdmission as $o, setCurrentSelection as $r, orphanedRoots as $s, setPoint as $t, createInternalRootChangeFromSections as $u, definePluginSlot as A, leftWithNoGridPart as Aa, getExactDocumentChangeRelocation as Ac, propertyDeltaFromModifications as Ad, decodeVersionedValue as Af, planPaste as Ai, areEditorSchemaIdentitiesEqual as Al, finalizeTransactionRepresentation as An, withMountedPresentation as Ao, isNotifyingNestedCommit as Ar, rawNodeAt as As, last as At, UNSCOPED_ORIGINS as Au, NodeApi as B, getCaretOwner as Ba, readShownPreview as Bc, rootNodesOf as Bd, defineEffect as Bf, readRootViewPresentationRevision as Bi, holdsUniqueKey as Bl, getChildren$1 as Bn, mapSemanticUpdateMethodArguments as Bo, recordEditorHistoryReplayReceipt as Br, isEmptyElement as Bs, point as Bt, historyFollowsAllFacts as Bu, setPluginPortalFactory as C, getCharacterDistance as Ca, getEditorCommitUnsettle as Cc, addSection as Cd, showValueRecords as Cf, withEditorRootChildrenGenerator as Ci, getPluginContributions as Cl, applyUnnamedDocumentChange as Cn, mountViewPeer as Co, initializeEditorSchemaSelection as Cr, decodeEditorSelection as Cs, isElementReadOnly as Ct, getEditorRuntime as Cu, property as D, gridHoldersOf as Da, readRootEntries as Dc, getDocumentPropertyContext as Dd, assertEditorJsonValue as Df, setTargetRuntime as Di, markDefinedStateField as Dl, continueTransactionSpecOrDiscardPrefix as Dn, readViewPage as Do, isBuildingTransactionSpec as Dr, mapDetachedSelectionThroughChange as Ds, isSelectable as Dt, hasEditorRuntime as Du, getSchemaElementSourceReference as E, isTextCell as Ea, keyMovedAt as Ec, applyPropertyModificationsToSlice as Ed, areEditorJsonValuesEqual as Ef, withUpdateTagContext as Ei, initializeBasePluginRegistry as El, attachTransactionSpecAfterCommit as En, readShownRecords as Eo, invalidateEditorTransactionSpecs as Er, isObjectSelectionTarget as Es, isInline as Et, getEditorSchema as Eu, getActiveCommandEditor as F, capturePlacement as Fa, createEditorAnchorApi as Fc, DocumentIndex as Fd, snapshotEditorJsonValue as Ff, readCaretViewIn as Fi, getCompiledPropertyMergeStrategy as Fl, getActiveEditorUpdateId as Fn, subscribe as Fo, readEditorCommitHistoryEntry as Fr, completeChildrenAt as Fs, move as Ft, UNKNOWN_FACTS as Fu, collapse as G, keepBookmark as Ga, assertNoDocumentViewRead as Gc, PreparedTokenSliceStructureError as Gd, RangeApi as Gf, subscribeRootViewPresentation as Gi, propertyTargetsReadParents as Gl, getCurrentSelectionRoot as Gn, txLocate as Go, replaceSliceAtBlockBoundary as Gr, readingCovered as Gs, read as Gt, invertCarriedRun as Gu, addMark as H, getRangeBreakCount as Ha, requestAuthoredView as Hc, normalizeSetValues as Hd, invertEffect as Hf, readShownViewUse as Hi, isSupportedGeneratedElementProperty as Hl, getCollabEffects$1 as Hn, getRootTransaction as Ho, registerEditorSurface as Hr, EditorSchemaValidationError as Hs, previous as Ht, carriedLetterPairs as Hu, hasCommandHandler as I, changedBookmarks as Ia, configureAuthoredView as Ic, NO_NODES as Id, supportsEditorValuePersistenceVersion as If, readLatestShownWritableRootView as Ii, getCompiledSchemaPropertyId as Il, getActiveEditorUpdateTags as In, subscribeCommit as Io, readEditorHistoryHeadRoots as Ir, constructCanonicalDocumentChange as Is, moveNodes as It, composeFacts as Iu, deleteForward as J, nextMintedGeneration as Ja, withDocumentViewRead as Jc, getDocumentSliceNodeKeys as Jd, PointApi as Jf, getContentSlice as Ji, resolveCompiledSchemaProperty as Jl, getEditorDocumentValue as Jn, txStored as Jo, saveEditorSchemaDocument as Jr, isLeftOutDefault as Js, replace as Jt, widenRun as Ju, deleteBackward as K, liftShownTarget as Ka, isDocumentView as Kc, closeToken as Kd, LocationApi as Kf, subscribeShownViewUse as Ki, readEditorSchemaContract as Kl, getEditorChildrenRoot as Kn, txOnly as Ko, resolveEditorNodeKeyForNode as Kr, carriesDefault as Ks, removeMark as Kt, landCarriedRuns as Ku, probeCommandNativeEquivalent as L, clearCaretUnlessHeldElsewhere as La, getAuthoredUpdateView as Lc, childAtPathIndex as Ld, textPropertiesEqual as Lf, readLatestShownWritableView as Li, handoverKeysOf as Ll, getAppliedSpecLanding as Ln, subscribeSource$1 as Lo, readEditorHistoryReplayReceipt as Lr, constructLoadedDocumentChange as Ls, next as Lt, factsFromJSON as Lu, dispatchCommand as M, nodes as Ma, hasIndexedPathAncestor as Mc, markReadBack as Md, encodeVersionedValue as Mf, getSelectionStateCaret as Mi, crossesUniqueTarget as Ml, fitSlicePlacements as Mn, getStateViewPresentation as Mo, loadOpenedRecords as Mr, withLandedMarks as Ms, levels as Mt, letterOriginsOfChange as Mu, evaluateCommand as N, normalizeNodeMatch as Na, authoredDocumentCapabilityPoint as Nc, joinsOf as Nd, isEditorJsonValue as Nf, markRootViewUsed as Ni, diffEditorSchemaContracts as Nl, flushEditorViewState as Nn, onPresentationRelease as No, notifyPresentationViewState as Nr, sealsText as Ns, liftNodes as Nt, NO_FACTS as Nu, schema as O, gridPartsOf as Oa, snapshotIndexOf as Oc, keptRunsOf as Od, cloneEditorJsonValue as Of, resolveStateFieldInitial as Oi, registerEffectTypeInRegistry as Ol, createTransactionSpec as On, retainViewPresentation as Oo, isEditorPublishingCommit as Or, mapSelectionThroughChange as Os, isStart as Ot, setEditorRuntime as Ou, evaluateCommandWithState as P, node as Pa, isAuthorId as Pc, liftOf as Pd, normalizeEditorValuePersistence as Pf, mountRootView as Pi, getCompiledPropertyCandidates as Pl, getActiveEditorTransaction as Pn, retainPresentation as Po, readEditor as Pr, settleRange as Ps, mergeNodes as Pt, NO_ROOT_FACTS as Pu, elementReadOnly as Q, resolveParkedCaret as Qa, mapAnchorHistoryRecovery as Qc, openToken as Qd, getReaderRange as Qf, settleDraftTrack as Qi, toCompiledTargetContext as Ql, getEditorReadDepth as Qn, documentAdmissionPoint as Qo, setCurrentMarks as Qr, judgeProjectedRoots as Qs, setNodes as Qt, createInternalDocumentChange as Qu, commandViewHides as R, consumeCommitCarets as Ra, isAuthoredPreview as Rc, decodeNodes as Rd, valueCodecs as Rf, readNestedRootView as Ri, hasPlaceDependentElementProperty as Rl, getBaseCallRoot as Rn, createEditorReadApi as Ro, readElementById as Rr, fitImportedBlock as Rs, parent as Rt, factsToJSON as Ru, resolveInstalledPlugin as S, editorReads as Sa, getEditorCommitStartedAt as Sc, RootChange as Sd, recordSetIds as Sf, withEditorRootChildren as Si, getConfiguredPluginRegistry as Sl, applyTransactionSpecToDocument as Sn, matchesPresentationOf as So, initializeEditorSchemaDocument as Sr, assertSelectionSupported as Ss, isEditor as St, registerEditorCommandDocument as Su, withPluginPortalCandidates as T, getWordSegments as Ta, historyReplayClaim as Tc, applyPropertyModifications as Td, withoutValueRoots as Tf, withTransactionSpecDraftRead as Ti, inheritPluginRegistry as Tl, assertEditorExternalMutationAllowed as Tn, readShownDocument as To, initializePublicState as Tr, getSelectionDOMRange as Ts, isEnd as Tt, getEditorRuntimeRoot as Tu, after as U, holdsCaret as Ua, withAuthoredUpdateView as Uc, classifyRootChange as Ud, mapEffect as Uf, readShownWritableRootViews as Ui, matchesCompiledSchemaTarget as Ul, getCurrentMarks as Un, resolvePluginMethod as Uo, registerEditorTransactionGuard as Ur, adoptVerdicts as Us, projectRange as Ut, carriesRun as Uu, above as V, getPlacementGeneration as Va, registerAuthoredRuntime as Vc, canonicalJsonKey as Vd, defineUpdateAnnotation as Vf, readRootViewUse as Vi, isPlaceDependentElementProperty as Vl, getCollabEffectTypes as Vn, callPluginUpdateMethod as Vo, registerEditorHistoryRuntime as Vr, EditorNoncanonicalChangeError as Vs, positions as Vt, recordedFacts as Vu, before as W, holdsCaretAt as Wa, withStoredAuthoredRead as Wc, PreparedTokenSlice as Wd, readLastCommitAnnotation as Wf, subscribeRootTarget as Wi, preserveCompiledSchemaPropertyIdentity as Wl, getCurrentSelection as Wn, locateAt as Wo, repairEditorValue as Wr, judgedBy as Ws, range as Wt, exactRunOn as Wu, deselect as X, resolveBookmark as Xa, getMovableAnchors as Xc, isTextNode$3 as Xd, getCommonLocationRoot as Xf, readDraftTrack as Xi, splitDroppedKeysOf as Xl, getEditorNodeKeyForNode as Xn, admitDocument as Xo, seedUniqueMaps as Xr, readsAt as Xs, reset as Xt, alignedDocumentChange as Xu, deleteFragment as Y, placedSince as Ya, consumeAnchorHistoryCapture as Yc, isElementNode as Yd, MAIN_ROOT_KEY as Yf, assertEditorNotDestroyed as Yi, restoreEditorSchemaContract as Yl, getEditorMaxLength as Yn, DOCUMENT_SETTLED_TAG as Yo, scheduleAfterCommitNotification as Yr, isSplitOutput as Ys, replaceChildren as Yt, DocumentChange as Yu, edges as Z, resolveLiveCaret as Za, hasActiveAnchors as Zc, nodeProps as Zd, getRangeRoot as Zf, readDraftTrackAt as Zi, toCompiledNodeContext as Zl, getEditorProjectionSnapshotIndex as Zn, admitEditorDocument as Zo, setChildren as Zr, changedRootsOf as Zs, select as Zt, collapseDocumentElementPropertyWrites as Zu, markEditorDormant as _, before$1 as _a, getEditorCommitFacts as _c, valueRootIndex as _d, hasRecordWithPrefix as _f, trackEditorLetters as _i, setEditorLifecycleErrorSink as _l, afterActiveTransactionEnds as _n, getViewAuthor as _o, getTransactionSnapshot as _r, withoutGeneration as _s, insertSoftBreak as _t, setDebugValueScrubber as _u, compilePluginInput as a, rewriteContentRootReferences as aa, ownedRootsOf as ac, getInternalDocumentChangeEntries as ad, NO_RECORD_OPS as af, setEditorSnapshotInputTransform as ai, toInternalRoot as al, toggleBlock as an, watchFirstPlacement as ao, lazyRootOf as ap, getLiveSelection as ar, canonicalizeCompiledTextProperties as as, getNodeKey as at, readDocumentRecord as au, queueAfterPluginAcquisition as b, resolveShouldMergeNodesRemovePrevNode as ba, getEditorCommitSchemas as bc, withInternalDocumentRootChange as bd, recordOpsFromJson as bf, withDraftMove as bi, finalizePluginRegistry as bl, applyDocumentChange as bn, joinViewLockScope as bo, hasEditorSurface as br, withFitLanding as bs, isBlock as bt, isEditorContent as bu, defineEditorSchema as c, withLandingBlock as ca, lawCheckEnabled as cc, getInternalDocumentChangeRootKeys as cd, deriveValue as cf, setEditorViewing as ci, nodeWriteVeto as cl, unsetNodes as cn, createAuthoredEditorView as co, countCoreWork as cp, getNodeKey$1 as cr, generateElementPropertyValue as cs, getSelection as ct, readStoredEditorDocument as cu, extendEditor as d, readRemovalLanding as da, claimsHistoryReplay as dc, isDocumentRootKey as dd, getRecordIds as df, snapshotInitialDocumentState as di, publishEditorRefusal as dl, voidEditor as dn, createViewLockScope as do, deepFreeze as dp, getRestorableMarks as dr, getRepresentationEditorFromApi as ds, hasInlines as dt, definePluginPoint as du, isEditorDraftView as ea, orphanedValueRoots as ec, documentChangeBetween as ed, textToken as ef, setEditorComposing as ei, observeAnchorStateWork as el, setSelection as en, rootChildrenOf as eo, isObject as ep, getEditorRuntimeRootKeys as er, withoutRepairOrphans as es, fragment as et, uniquePropertiesOf as eu, getCandidatePluginApi as f, resolveDeletedRange as fa, createEditorCommit as fc, isInternalDocumentChangeNoop as fd, getRecordSetVersion as ff, subscribeCaretTarget as fi, subscribeEditorRefusals as fl, wrapNodes as fn, flushViewLockScope as fo, isRecord$5 as fp, getSelectionRoot as fr, holdsImportedRoot as fs, hasPath as ft, point$1 as fu, isPlugin as g, readOnlyInlineAt as ga, getEditorCommitCompletedTextDeletion as gc, valueRoot$1 as gd, hasRecord as gf, toEditorCoreStateView as gi, runEditorObserver as gl, withCompositionStamp as gn, getOwnViewReadOnly as go, getStateFieldEffectTypes as gr, readEmptyText as gs, insertNodes as gt, formatDebugValue as gu, getInstalledPluginApi as h, hasEdgeInReadOnlyInline as ha, getEditorCommitCarriedRuns as hc, transformInternalDocumentChange as hd, getValueRecords as hf, syncImplicitTargetToCurrentSelection as hi, reportEditorLifecycleError as hl, tripleClickedBlock as hn, getOwnViewPresentation as ho, getDefined as hp, getSnapshotVersion as hr, placeElementAt as hs, insertNode as ht, ElementApi as hu, compilePlugin as i, registerEditorFitsByLook as ia, ensureElementOwnedRootIndex as ic, getInternalDocumentChangeClassificationEntries as id, getNodeKeyForNode as if, setEditorReadOnly as ii, getPublicExplicitLocationRoot as il, subscribeSource as in, subscribeCommittedPlacement as io, isFrozenWithRoots as ip, getLiveNode as ir, canPlaceBlocksAtPath as is, getLastCommit as it, isEnvelopeInput as iu, createCommandDispatch as j, survivalUnder as ja, getExactDocumentChangeRelocations as jc, semanticPropertyModifications as jd, encodeEditorEffect as jf, writePaste as ji, compileEditorSchemaContributions as jl, fitSliceChildren as jn, getBaseViewPresentation as jo, isPresentationComposing as jr, settleSelectionMode as js, leaf as jt, classifyDocumentChange as ju, target as k, gridRolesOf as ka, getDocumentChangeRelocations as kc, mapRootChangePositionBackward as kd, decodeEditorEffect as kf, captureSliceLanding as ki, EditorSchemaCompileError as kl, documentReplacement as kn, setViewLockScopeLocked as ko, isInTransaction as kr, mapSelectionWithContext as ks, isVoid as kt, defineCommand$1 as ku, definePlugin as l, dividesTextCell as la, ContentSlice as lc, getInternalDocumentRootChange as ld, getRecordCount as lf, setRootCopyScope as li, vetoesWrite as ll, unwrapNodes as ln, createEditorView as lo, readCoreWork as lp, getNodeTargetRoot as lr, getCompiledEditorSchemaFromApi as ls, getSnapshot as lt, rejectEditorRecord as lu, getInstalledPlugin as m, elementReadOnly$1 as ma, getEditorCommitAdmission as mc, mapInternalDocumentChangePosition as md, getRecordsWithPrefix as mf, subscribePresentationComposition as mi, notifyObservers as ml, readWholeBlockLanding as mn, getCarriedMount as mo, cloneFrozen$1 as mp, getSnapshot$1 as mr, landNodePropertiesAt as ms, insertBreak as mt, SelectionApi as mu, brandPluginDescriptor as n, registerEditorDraftGuard as na, schemaHasContentRoots as nc, filterDocumentChangeRoots as nd, tokensEqual as nf, setEditorFocused as ni, stageAnchorHistoryRecovery as nl, splitNodes as nn, setSelectionAsView as no, copyRoot as np, getEditorUpdateRoot as nr, ElementGenerationMaskedError as ns, getCollabEffects as nt, assertEditorDocumentContainers as nu, containsCompleteEditorSchema as o, coversContent as oa, rebaseElementOwnedRootIndex as oc, getInternalDocumentChangeRanges as od, canonicalRecordJson as of, setEditorStateViewTransform as oi, toPublicRoot as ol, toggleMark as on, withoutPlacement as oo, setLazyRoot as op, getLiveText as or, createDetachedEditorSchema as os, getPathByNodeKey as ot, readEditorDocument as ou, getCompiledEditorConfiguration as p, removeNodes$1 as pa, getDocumentValueNode as pc, mapInternalDocumentChangePoint as pd, getRecordText as pf, subscribeEditorViewState as pi, REMOTE_UPDATE as pl, editorCommands as pn, getCarriedCaretEditor as po, jsonEqual$1 as pp, getSetSite as pr, holdsOneText as ps, hasTexts as pt, readTextEdge as pu, deleteEditor as q, mayClearCaret as qa, isDocumentViewReading as qc, encodeNodes as qd, SpanApi as qf, getFragment$1 as qi, readEditorSchemaIdentity as ql, getEditorDocumentRecords as qn, txSelection as qo, runTrustedUpdate as qr, elementSplitOutput as qs, removeNodes as qt, mapCarriedRunThrough as qu, carryPluginFactoryType as r, registerEditorDraftView as ra, advanceElementOwnedRootIndex as rc, getInternalDocumentChangeClassification as rd, getNodeKeyDOMValue as rf, setEditorMaxLength as ri, assertPublicRootKey as rl, string as rn, setShownSelectionAsView as ro, copyRoots as rp, getLastCommit$1 as rr, acceptsPropertyValue as rs, getFragment as rt, getEditorDocumentShapeIssueMessage as ru, createEditorViewPluginApis as s, range$1 as sa, rootsOwnedOnlyWithin as sc, getInternalDocumentChangeRecords as sd, composeRecordOps as sf, setEditorTransactionViewTransform as si, getRangeEndpointAssociations as sl, unhangRange as sn, carryRootEditors as so, visitRootNames as sp, getMutationVersion as sr, createEditorSchema as ss, getPluginRegistry as st, readPersistedEnvelope as su, PluginPublicationError as t, registerEditorDocumentRecorder as ta, rootsDeletedByName as tc, documentChangeWritesOnlyElementProperties as td, tokenLength as tf, setEditorCompositionPending as ti, placeAnchorsOnCommit as tl, shouldMergeNodesRemovePrevNode as tn, sameCarets as to, copyFields as tp, getEditorStateView as tr, documentRootsOf as ts, getChildren as tt, EDITOR_DOCUMENT_FIELDS as tu, destroyEditor as u, deleteText as ua, createDetachedContentSlice as uc, hasInternalDocumentChangeRoot as ud, getRecordEntries as uf, setTypedMarks as ui, EditorRefusalError as ul, update as un, createEditorViewRuntime as uo, cloneFrozen as up, getPathByNodeKey$1 as ur, getInternalEditorSchemaFromApi as us, hasBlocks as ut, failInvariant as uu, prepareInitialPluginPublication as v, after$1 as va, getEditorCommitNode as vc, valueRootNodes as vd, readRecord as vf, transformEditorSnapshotInput as vi, assertPluginPublicationInactive as vl, afterOpenDrafts as vn, getViewFollowTarget as vo, getUpdateView as vr, withoutGenerationOf as vs, insertText as vt, getTextSearchScope as vu, startEditor as w, getWordDistances as wa, getEditorCommitValue as wc, ancestorType as wd, withValueRecords as wf, withEditorUpdateRootScope as wi, getPluginRegistry$1 as wl, asSelectionMotion as wn, projectEditorView as wo, initializeEditorSchemaSnapshot as wr, encodeEditorSelection as ws, isEmpty as wt, getEditorRuntimeOwner as wu, releaseEditor as x, executeEditorRead as xa, getEditorCommitSnapshot as xc, withoutRetainedRecordSets as xd, recordSetChanges as xf, withEditorDocumentProjection as xi, getCompiledEditorSchema as xl, applyTransactionSpec as xn, linkViewLockScope as xo, inheritEditorProjectionIndexes as xr, assertDetachedSelectionSupported as xs, isEdge as xt, registerEditorContent as xu, prepareScopedPluginPublication as y, exportContentSlice as ya, getEditorCommitRest as yc, withDocumentChangeRecords as yd, recordOpsBetween as yf, updateEditor as yi, createPluginRegistry as yl, applyBuiltDocumentChange as yn, getViewPresentation as yo, hasEditorProjectionSnapshotIndex as yr, payloadKeyOf as ys, install as yt, TextApi as yu, prepareCommandFrame as z, getBookmark as za, readAuthoredView as zc, rootIndexOf as zd, createEditorEffect as zf, readRootTarget as zi, hashSchemaIdentityString as zl, getChildList as zn, createEditorUpdateApi as zo, readElementPropertyWrites as zr, joinedAway as zs, path as zt, flipFacts as zu };
|