Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com

feat: add undo/redo to rich text editor

Add @milkdown/plugin-history to the Milkdown editor, enabling undo/redo
via Mod-z/Mod-Shift-z keyboard shortcuts. Also adds ↩/↪ toolbar buttons
visible only in rich mode.

+1108 -494
+1
milkdown-entry.js
··· 3 3 export { listener, listenerCtx } from '@milkdown/kit/plugin/listener'; 4 4 export { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip'; 5 5 export { callCommand } from '@milkdown/kit/utils'; 6 + export { history, undoCommand, redoCommand } from '@milkdown/plugin-history';
+1091 -494
static/vendor/milkdown.js
··· 11 11 for (var name in all2) 12 12 __defProp(target, name, { get: all2[name], enumerable: true }); 13 13 }; 14 - var __copyProps = (to, from, except, desc) => { 15 - if (from && typeof from === "object" || typeof from === "function") { 16 - for (let key3 of __getOwnPropNames(from)) 14 + var __copyProps = (to, from2, except, desc) => { 15 + if (from2 && typeof from2 === "object" || typeof from2 === "function") { 16 + for (let key3 of __getOwnPropNames(from2)) 17 17 if (!__hasOwnProp.call(to, key3) && key3 !== except) 18 - __defProp(to, key3, { get: () => from[key3], enumerable: !(desc = __getOwnPropDesc(from, key3)) || desc.enumerable }); 18 + __defProp(to, key3, { get: () => from2[key3], enumerable: !(desc = __getOwnPropDesc(from2, key3)) || desc.enumerable }); 19 19 } 20 20 return to; 21 21 }; ··· 272 272 var Container = class { 273 273 constructor() { 274 274 this.sliceMap = /* @__PURE__ */ new Map(); 275 - this.get = (slice) => { 276 - const context = typeof slice === "string" ? [...this.sliceMap.values()].find((x) => x.type.name === slice) : this.sliceMap.get(slice.id); 275 + this.get = (slice2) => { 276 + const context = typeof slice2 === "string" ? [...this.sliceMap.values()].find((x) => x.type.name === slice2) : this.sliceMap.get(slice2.id); 277 277 if (!context) { 278 - const name = typeof slice === "string" ? slice : slice.name; 278 + const name = typeof slice2 === "string" ? slice2 : slice2.name; 279 279 throw contextNotFound(name); 280 280 } 281 281 return context; 282 282 }; 283 - this.remove = (slice) => { 284 - const context = typeof slice === "string" ? [...this.sliceMap.values()].find((x) => x.type.name === slice) : this.sliceMap.get(slice.id); 283 + this.remove = (slice2) => { 284 + const context = typeof slice2 === "string" ? [...this.sliceMap.values()].find((x) => x.type.name === slice2) : this.sliceMap.get(slice2.id); 285 285 if (!context) return; 286 286 this.sliceMap.delete(context.type.id); 287 287 }; 288 - this.has = (slice) => { 289 - if (typeof slice === "string") 290 - return [...this.sliceMap.values()].some((x) => x.type.name === slice); 291 - return this.sliceMap.has(slice.id); 288 + this.has = (slice2) => { 289 + if (typeof slice2 === "string") 290 + return [...this.sliceMap.values()].some((x) => x.type.name === slice2); 291 + return this.sliceMap.has(slice2.id); 292 292 }; 293 293 } 294 294 }; ··· 371 371 this.read = () => { 372 372 return { 373 373 metadata: this.#meta, 374 - injectedSlices: [...this.#injectedSlices].map((slice) => ({ 375 - name: typeof slice === "string" ? slice : slice.name, 376 - value: this.#getSlice(slice) 374 + injectedSlices: [...this.#injectedSlices].map((slice2) => ({ 375 + name: typeof slice2 === "string" ? slice2 : slice2.name, 376 + value: this.#getSlice(slice2) 377 377 })), 378 - consumedSlices: [...this.#consumedSlices].map((slice) => ({ 379 - name: typeof slice === "string" ? slice : slice.name, 380 - value: this.#getSlice(slice) 378 + consumedSlices: [...this.#consumedSlices].map((slice2) => ({ 379 + name: typeof slice2 === "string" ? slice2 : slice2.name, 380 + value: this.#getSlice(slice2) 381 381 })), 382 382 recordedTimers: [...this.#recordedTimers].map( 383 383 ([timer, { duration }]) => ({ ··· 451 451 return this; 452 452 }; 453 453 this.inject = (sliceType, value) => { 454 - const slice = sliceType.create(this.#container.sliceMap); 455 - if (value != null) slice.set(value); 454 + const slice2 = sliceType.create(this.#container.sliceMap); 455 + if (value != null) slice2.set(value); 456 456 this.#inspector?.onInject(sliceType); 457 457 return this; 458 458 }; ··· 490 490 this.#inspector?.onWait(timer, promise); 491 491 return promise; 492 492 }; 493 - this.waitTimers = async (slice) => { 494 - await Promise.all(this.get(slice).map((x) => this.wait(x))); 493 + this.waitTimers = async (slice2) => { 494 + await Promise.all(this.get(slice2).map((x) => this.wait(x))); 495 495 }; 496 496 this.#container = container; 497 497 this.#clock = clock; ··· 676 676 // :: (union<Object, OrderedMap>) → OrderedMap 677 677 // Create a new map by prepending the keys in this map that don't 678 678 // appear in `map` before the keys in `map`. 679 - prepend: function(map4) { 680 - map4 = OrderedMap.from(map4); 681 - if (!map4.size) return this; 682 - return new OrderedMap(map4.content.concat(this.subtract(map4).content)); 679 + prepend: function(map5) { 680 + map5 = OrderedMap.from(map5); 681 + if (!map5.size) return this; 682 + return new OrderedMap(map5.content.concat(this.subtract(map5).content)); 683 683 }, 684 684 // :: (union<Object, OrderedMap>) → OrderedMap 685 685 // Create a new map by appending the keys in this map that don't 686 686 // appear in `map` after the keys in `map`. 687 - append: function(map4) { 688 - map4 = OrderedMap.from(map4); 689 - if (!map4.size) return this; 690 - return new OrderedMap(this.subtract(map4).content.concat(map4.content)); 687 + append: function(map5) { 688 + map5 = OrderedMap.from(map5); 689 + if (!map5.size) return this; 690 + return new OrderedMap(this.subtract(map5).content.concat(map5.content)); 691 691 }, 692 692 // :: (union<Object, OrderedMap>) → OrderedMap 693 693 // Create a map containing all the keys in this map that don't 694 694 // appear in `map`. 695 - subtract: function(map4) { 695 + subtract: function(map5) { 696 696 var result = this; 697 - map4 = OrderedMap.from(map4); 698 - for (var i = 0; i < map4.content.length; i += 2) 699 - result = result.remove(map4.content[i]); 697 + map5 = OrderedMap.from(map5); 698 + for (var i = 0; i < map5.content.length; i += 2) 699 + result = result.remove(map5.content[i]); 700 700 return result; 701 701 }, 702 702 // :: () → Object ··· 793 793 positions (relative to start of this fragment). Doesn't descend 794 794 into a node when the callback returns `false`. 795 795 */ 796 - nodesBetween(from, to, f, nodeStart = 0, parent) { 796 + nodesBetween(from2, to, f, nodeStart = 0, parent) { 797 797 for (let i = 0, pos = 0; pos < to; i++) { 798 798 let child = this.content[i], end = pos + child.nodeSize; 799 - if (end > from && f(child, nodeStart + pos, parent || null, i) !== false && child.content.size) { 799 + if (end > from2 && f(child, nodeStart + pos, parent || null, i) !== false && child.content.size) { 800 800 let start = pos + 1; 801 - child.nodesBetween(Math.max(0, from - start), Math.min(child.content.size, to - start), f, nodeStart + start); 801 + child.nodesBetween(Math.max(0, from2 - start), Math.min(child.content.size, to - start), f, nodeStart + start); 802 802 } 803 803 pos = end; 804 804 } ··· 815 815 Extract the text between `from` and `to`. See the same method on 816 816 [`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween). 817 817 */ 818 - textBetween(from, to, blockSeparator, leafText) { 818 + textBetween(from2, to, blockSeparator, leafText) { 819 819 let text4 = "", first = true; 820 - this.nodesBetween(from, to, (node2, pos) => { 821 - let nodeText = node2.isText ? node2.text.slice(Math.max(from, pos) - pos, to - pos) : !node2.isLeaf ? "" : leafText ? typeof leafText === "function" ? leafText(node2) : leafText : node2.type.spec.leafText ? node2.type.spec.leafText(node2) : ""; 820 + this.nodesBetween(from2, to, (node2, pos) => { 821 + let nodeText = node2.isText ? node2.text.slice(Math.max(from2, pos) - pos, to - pos) : !node2.isLeaf ? "" : leafText ? typeof leafText === "function" ? leafText(node2) : leafText : node2.type.spec.leafText ? node2.type.spec.leafText(node2) : ""; 822 822 if (node2.isBlock && (node2.isLeaf && nodeText || node2.isTextblock) && blockSeparator) { 823 823 if (first) 824 824 first = false; ··· 850 850 /** 851 851 Cut out the sub-fragment between the two given positions. 852 852 */ 853 - cut(from, to = this.size) { 854 - if (from == 0 && to == this.size) 853 + cut(from2, to = this.size) { 854 + if (from2 == 0 && to == this.size) 855 855 return this; 856 856 let result = [], size2 = 0; 857 - if (to > from) 857 + if (to > from2) 858 858 for (let i = 0, pos = 0; pos < to; i++) { 859 859 let child = this.content[i], end = pos + child.nodeSize; 860 - if (end > from) { 861 - if (pos < from || end > to) { 860 + if (end > from2) { 861 + if (pos < from2 || end > to) { 862 862 if (child.isText) 863 - child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos)); 863 + child = child.cut(Math.max(0, from2 - pos), Math.min(child.text.length, to - pos)); 864 864 else 865 - child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1)); 865 + child = child.cut(Math.max(0, from2 - pos - 1), Math.min(child.content.size, to - pos - 1)); 866 866 } 867 867 result.push(child); 868 868 size2 += child.nodeSize; ··· 874 874 /** 875 875 @internal 876 876 */ 877 - cutByIndex(from, to) { 878 - if (from == to) 877 + cutByIndex(from2, to) { 878 + if (from2 == to) 879 879 return _Fragment.empty; 880 - if (from == 0 && to == this.content.length) 880 + if (from2 == 0 && to == this.content.length) 881 881 return this; 882 - return new _Fragment(this.content.slice(from, to)); 882 + return new _Fragment(this.content.slice(from2, to)); 883 883 } 884 884 /** 885 885 Create a new fragment in which the node at the given index is ··· 1257 1257 /** 1258 1258 @internal 1259 1259 */ 1260 - removeBetween(from, to) { 1261 - return new _Slice(removeRange(this.content, from + this.openStart, to + this.openStart), this.openStart, this.openEnd); 1260 + removeBetween(from2, to) { 1261 + return new _Slice(removeRange(this.content, from2 + this.openStart, to + this.openStart), this.openStart, this.openEnd); 1262 1262 } 1263 1263 /** 1264 1264 Tests whether this slice is equal to another slice. ··· 1310 1310 } 1311 1311 }; 1312 1312 Slice2.empty = new Slice2(Fragment.empty, 0, 0); 1313 - function removeRange(content3, from, to) { 1314 - let { index: index2, offset: offset3 } = content3.findIndex(from), child = content3.maybeChild(index2); 1313 + function removeRange(content3, from2, to) { 1314 + let { index: index2, offset: offset3 } = content3.findIndex(from2), child = content3.maybeChild(index2); 1315 1315 let { index: indexTo, offset: offsetTo } = content3.findIndex(to); 1316 - if (offset3 == from || child.isText) { 1316 + if (offset3 == from2 || child.isText) { 1317 1317 if (offsetTo != to && !content3.child(indexTo).isText) 1318 1318 throw new RangeError("Removing non-flat range"); 1319 - return content3.cut(0, from).append(content3.cut(to)); 1319 + return content3.cut(0, from2).append(content3.cut(to)); 1320 1320 } 1321 1321 if (index2 != indexTo) 1322 1322 throw new RangeError("Removing non-flat range"); 1323 - return content3.replaceChild(index2, child.copy(removeRange(child.content, from - offset3 - 1, to - offset3 - 1))); 1323 + return content3.replaceChild(index2, child.copy(removeRange(child.content, from2 - offset3 - 1, to - offset3 - 1))); 1324 1324 } 1325 1325 function insertInto(content3, dist, insert, parent) { 1326 1326 let { index: index2, offset: offset3 } = content3.findIndex(dist), child = content3.maybeChild(index2); ··· 1332 1332 let inner = insertInto(child.content, dist - offset3 - 1, insert, child); 1333 1333 return inner && content3.replaceChild(index2, child.copy(inner)); 1334 1334 } 1335 - function replace($from, $to, slice) { 1336 - if (slice.openStart > $from.depth) 1335 + function replace($from, $to, slice2) { 1336 + if (slice2.openStart > $from.depth) 1337 1337 throw new ReplaceError("Inserted content deeper than insertion position"); 1338 - if ($from.depth - slice.openStart != $to.depth - slice.openEnd) 1338 + if ($from.depth - slice2.openStart != $to.depth - slice2.openEnd) 1339 1339 throw new ReplaceError("Inconsistent open depths"); 1340 - return replaceOuter($from, $to, slice, 0); 1340 + return replaceOuter($from, $to, slice2, 0); 1341 1341 } 1342 - function replaceOuter($from, $to, slice, depth) { 1342 + function replaceOuter($from, $to, slice2, depth) { 1343 1343 let index2 = $from.index(depth), node2 = $from.node(depth); 1344 - if (index2 == $to.index(depth) && depth < $from.depth - slice.openStart) { 1345 - let inner = replaceOuter($from, $to, slice, depth + 1); 1344 + if (index2 == $to.index(depth) && depth < $from.depth - slice2.openStart) { 1345 + let inner = replaceOuter($from, $to, slice2, depth + 1); 1346 1346 return node2.copy(node2.content.replaceChild(index2, inner)); 1347 - } else if (!slice.content.size) { 1347 + } else if (!slice2.content.size) { 1348 1348 return close(node2, replaceTwoWay($from, $to, depth)); 1349 - } else if (!slice.openStart && !slice.openEnd && $from.depth == depth && $to.depth == depth) { 1349 + } else if (!slice2.openStart && !slice2.openEnd && $from.depth == depth && $to.depth == depth) { 1350 1350 let parent = $from.parent, content3 = parent.content; 1351 - return close(parent, content3.cut(0, $from.parentOffset).append(slice.content).append(content3.cut($to.parentOffset))); 1351 + return close(parent, content3.cut(0, $from.parentOffset).append(slice2.content).append(content3.cut($to.parentOffset))); 1352 1352 } else { 1353 - let { start, end } = prepareSliceForReplace(slice, $from); 1353 + let { start, end } = prepareSliceForReplace(slice2, $from); 1354 1354 return close(node2, replaceThreeWay($from, start, end, $to, depth)); 1355 1355 } 1356 1356 } ··· 1419 1419 addRange($to, null, depth, content3); 1420 1420 return new Fragment(content3); 1421 1421 } 1422 - function prepareSliceForReplace(slice, $along) { 1423 - let extra = $along.depth - slice.openStart, parent = $along.node(extra); 1424 - let node2 = parent.copy(slice.content); 1422 + function prepareSliceForReplace(slice2, $along) { 1423 + let extra = $along.depth - slice2.openStart, parent = $along.node(extra); 1424 + let node2 = parent.copy(slice2.content); 1425 1425 for (let i = extra - 1; i >= 0; i--) 1426 1426 node2 = $along.node(i).copy(Fragment.from(node2)); 1427 1427 return { 1428 - start: node2.resolveNoCache(slice.openStart + extra), 1429 - end: node2.resolveNoCache(node2.content.size - slice.openEnd - extra) 1428 + start: node2.resolveNoCache(slice2.openStart + extra), 1429 + end: node2.resolveNoCache(node2.content.size - slice2.openEnd - extra) 1430 1430 }; 1431 1431 } 1432 1432 var ResolvedPos = class _ResolvedPos { ··· 1816 1816 recursed over. The last parameter can be used to specify a 1817 1817 starting position to count from. 1818 1818 */ 1819 - nodesBetween(from, to, f, startPos = 0) { 1820 - this.content.nodesBetween(from, to, f, startPos, this); 1819 + nodesBetween(from2, to, f, startPos = 0) { 1820 + this.content.nodesBetween(from2, to, f, startPos, this); 1821 1821 } 1822 1822 /** 1823 1823 Call the given callback for every descendant node. Doesn't ··· 1840 1840 inserted for every non-text leaf node encountered, otherwise 1841 1841 [`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec.leafText) will be used. 1842 1842 */ 1843 - textBetween(from, to, blockSeparator, leafText) { 1844 - return this.content.textBetween(from, to, blockSeparator, leafText); 1843 + textBetween(from2, to, blockSeparator, leafText) { 1844 + return this.content.textBetween(from2, to, blockSeparator, leafText); 1845 1845 } 1846 1846 /** 1847 1847 Returns this node's first child, or `null` if there are no ··· 1898 1898 given positions. If `to` is not given, it defaults to the end of 1899 1899 the node. 1900 1900 */ 1901 - cut(from, to = this.content.size) { 1902 - if (from == 0 && to == this.content.size) 1901 + cut(from2, to = this.content.size) { 1902 + if (from2 == 0 && to == this.content.size) 1903 1903 return this; 1904 - return this.copy(this.content.cut(from, to)); 1904 + return this.copy(this.content.cut(from2, to)); 1905 1905 } 1906 1906 /** 1907 1907 Cut out the part of the document between the given positions, and 1908 1908 return it as a `Slice` object. 1909 1909 */ 1910 - slice(from, to = this.content.size, includeParents = false) { 1911 - if (from == to) 1910 + slice(from2, to = this.content.size, includeParents = false) { 1911 + if (from2 == to) 1912 1912 return Slice2.empty; 1913 - let $from = this.resolve(from), $to = this.resolve(to); 1913 + let $from = this.resolve(from2), $to = this.resolve(to); 1914 1914 let depth = includeParents ? 0 : $from.sharedDepth(to); 1915 1915 let start = $from.start(depth), node2 = $from.node(depth); 1916 1916 let content3 = node2.content.cut($from.pos - start, $to.pos - start); ··· 1924 1924 into. If any of this is violated, an error of type 1925 1925 [`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown. 1926 1926 */ 1927 - replace(from, to, slice) { 1928 - return replace(this.resolve(from), this.resolve(to), slice); 1927 + replace(from2, to, slice2) { 1928 + return replace(this.resolve(from2), this.resolve(to), slice2); 1929 1929 } 1930 1930 /** 1931 1931 Find the node directly after the given position. ··· 1981 1981 Test whether a given mark or mark type occurs in this document 1982 1982 between the two given positions. 1983 1983 */ 1984 - rangeHasMark(from, to, type) { 1984 + rangeHasMark(from2, to, type) { 1985 1985 let found2 = false; 1986 - if (to > from) 1987 - this.nodesBetween(from, to, (node2) => { 1986 + if (to > from2) 1987 + this.nodesBetween(from2, to, (node2) => { 1988 1988 if (type.isInSet(node2.marks)) 1989 1989 found2 = true; 1990 1990 return !found2; ··· 2067 2067 can optionally pass `start` and `end` indices into the 2068 2068 replacement fragment. 2069 2069 */ 2070 - canReplace(from, to, replacement = Fragment.empty, start = 0, end = replacement.childCount) { 2071 - let one2 = this.contentMatchAt(from).matchFragment(replacement, start, end); 2070 + canReplace(from2, to, replacement = Fragment.empty, start = 0, end = replacement.childCount) { 2071 + let one2 = this.contentMatchAt(from2).matchFragment(replacement, start, end); 2072 2072 let two = one2 && one2.matchFragment(this.content, to); 2073 2073 if (!two || !two.validEnd) 2074 2074 return false; ··· 2081 2081 Test whether replacing the range `from` to `to` (by index) with 2082 2082 a node of the given type would leave the node's content valid. 2083 2083 */ 2084 - canReplaceWith(from, to, type, marks) { 2084 + canReplaceWith(from2, to, type, marks) { 2085 2085 if (marks && !this.type.allowsMarks(marks)) 2086 2086 return false; 2087 - let start = this.contentMatchAt(from).matchType(type); 2087 + let start = this.contentMatchAt(from2).matchType(type); 2088 2088 let end = start && start.matchFragment(this.content, to); 2089 2089 return end ? end.validEnd : false; 2090 2090 } ··· 2174 2174 get textContent() { 2175 2175 return this.text; 2176 2176 } 2177 - textBetween(from, to) { 2178 - return this.text.slice(from, to); 2177 + textBetween(from2, to) { 2178 + return this.text.slice(from2, to); 2179 2179 } 2180 2180 get nodeSize() { 2181 2181 return this.text.length; ··· 2188 2188 return this; 2189 2189 return new _TextNode(this.type, this.attrs, text4, this.marks); 2190 2190 } 2191 - cut(from = 0, to = this.text.length) { 2192 - if (from == 0 && to == this.text.length) 2191 + cut(from2 = 0, to = this.text.length) { 2192 + if (from2 == 0 && to == this.text.length) 2193 2193 return this; 2194 - return this.withText(this.text.slice(from, to)); 2194 + return this.withText(this.text.slice(from2, to)); 2195 2195 } 2196 2196 eq(other) { 2197 2197 return this.sameMarkup(other) && this.text == other.text; ··· 2491 2491 function node2() { 2492 2492 return nfa2.push([]) - 1; 2493 2493 } 2494 - function edge(from, to, term) { 2494 + function edge(from2, to, term) { 2495 2495 let edge2 = { term, to }; 2496 - nfa2[from].push(edge2); 2496 + nfa2[from2].push(edge2); 2497 2497 return edge2; 2498 2498 } 2499 2499 function connect(edges, to) { 2500 2500 edges.forEach((edge2) => edge2.to = to); 2501 2501 } 2502 - function compile(expr2, from) { 2502 + function compile(expr2, from2) { 2503 2503 if (expr2.type == "choice") { 2504 - return expr2.exprs.reduce((out, expr3) => out.concat(compile(expr3, from)), []); 2504 + return expr2.exprs.reduce((out, expr3) => out.concat(compile(expr3, from2)), []); 2505 2505 } else if (expr2.type == "seq") { 2506 2506 for (let i = 0; ; i++) { 2507 - let next = compile(expr2.exprs[i], from); 2507 + let next = compile(expr2.exprs[i], from2); 2508 2508 if (i == expr2.exprs.length - 1) 2509 2509 return next; 2510 - connect(next, from = node2()); 2510 + connect(next, from2 = node2()); 2511 2511 } 2512 2512 } else if (expr2.type == "star") { 2513 2513 let loop = node2(); 2514 - edge(from, loop); 2514 + edge(from2, loop); 2515 2515 connect(compile(expr2.expr, loop), loop); 2516 2516 return [edge(loop)]; 2517 2517 } else if (expr2.type == "plus") { 2518 2518 let loop = node2(); 2519 - connect(compile(expr2.expr, from), loop); 2519 + connect(compile(expr2.expr, from2), loop); 2520 2520 connect(compile(expr2.expr, loop), loop); 2521 2521 return [edge(loop)]; 2522 2522 } else if (expr2.type == "opt") { 2523 - return [edge(from)].concat(compile(expr2.expr, from)); 2523 + return [edge(from2)].concat(compile(expr2.expr, from2)); 2524 2524 } else if (expr2.type == "range") { 2525 - let cur = from; 2525 + let cur = from2; 2526 2526 for (let i = 0; i < expr2.min; i++) { 2527 2527 let next = node2(); 2528 2528 connect(compile(expr2.expr, cur), next); ··· 2540 2540 } 2541 2541 return [edge(cur)]; 2542 2542 } else if (expr2.type == "name") { 2543 - return [edge(from, void 0, expr2.value)]; 2543 + return [edge(from2, void 0, expr2.value)]; 2544 2544 } else { 2545 2545 throw new Error("Unknown expr type"); 2546 2546 } ··· 4083 4083 /** 4084 4084 Create a new mapping with the given position maps. 4085 4085 */ 4086 - constructor(maps, mirror, from = 0, to = maps ? maps.length : 0) { 4086 + constructor(maps, mirror, from2 = 0, to = maps ? maps.length : 0) { 4087 4087 this.mirror = mirror; 4088 - this.from = from; 4088 + this.from = from2; 4089 4089 this.to = to; 4090 4090 this._maps = maps || []; 4091 4091 this.ownData = !(maps || mirror); ··· 4099 4099 /** 4100 4100 Create a mapping that maps only through a part of this one. 4101 4101 */ 4102 - slice(from = 0, to = this.maps.length) { 4103 - return new _Mapping(this._maps, this.mirror, from, to); 4102 + slice(from2 = 0, to = this.maps.length) { 4103 + return new _Mapping(this._maps, this.mirror, from2, to); 4104 4104 } 4105 4105 /** 4106 4106 Add a step map to the end of this mapping. If `mirrors` is 4107 4107 given, it should be the index of the step map that is the mirror 4108 4108 image of this one. 4109 4109 */ 4110 - appendMap(map4, mirrors) { 4110 + appendMap(map5, mirrors) { 4111 4111 if (!this.ownData) { 4112 4112 this._maps = this._maps.slice(); 4113 4113 this.mirror = this.mirror && this.mirror.slice(); 4114 4114 this.ownData = true; 4115 4115 } 4116 - this.to = this._maps.push(map4); 4116 + this.to = this._maps.push(map5); 4117 4117 if (mirrors != null) 4118 4118 this.setMirror(this._maps.length - 1, mirrors); 4119 4119 } ··· 4187 4187 _map(pos, assoc, simple) { 4188 4188 let delInfo = 0; 4189 4189 for (let i = this.from; i < this.to; i++) { 4190 - let map4 = this._maps[i], result = map4.mapResult(pos, assoc); 4190 + let map5 = this._maps[i], result = map5.mapResult(pos, assoc); 4191 4191 if (result.recover != null) { 4192 4192 let corr = this.getMirror(i); 4193 4193 if (corr != null && corr > i && corr < this.to) { ··· 4271 4271 arguments. Create a successful result if it succeeds, and a 4272 4272 failed one if it throws a `ReplaceError`. 4273 4273 */ 4274 - static fromReplace(doc4, from, to, slice) { 4274 + static fromReplace(doc4, from2, to, slice2) { 4275 4275 try { 4276 - return _StepResult.ok(doc4.replace(from, to, slice)); 4276 + return _StepResult.ok(doc4.replace(from2, to, slice2)); 4277 4277 } catch (e) { 4278 4278 if (e instanceof ReplaceError) 4279 4279 return _StepResult.fail(e.message); ··· 4297 4297 /** 4298 4298 Create a mark step. 4299 4299 */ 4300 - constructor(from, to, mark) { 4300 + constructor(from2, to, mark) { 4301 4301 super(); 4302 - this.from = from; 4302 + this.from = from2; 4303 4303 this.to = to; 4304 4304 this.mark = mark; 4305 4305 } 4306 4306 apply(doc4) { 4307 4307 let oldSlice = doc4.slice(this.from, this.to), $from = doc4.resolve(this.from); 4308 4308 let parent = $from.node($from.sharedDepth(this.to)); 4309 - let slice = new Slice2(mapFragment(oldSlice.content, (node2, parent2) => { 4309 + let slice2 = new Slice2(mapFragment(oldSlice.content, (node2, parent2) => { 4310 4310 if (!node2.isAtom || !parent2.type.allowsMarkType(this.mark.type)) 4311 4311 return node2; 4312 4312 return node2.mark(this.mark.addToSet(node2.marks)); 4313 4313 }, parent), oldSlice.openStart, oldSlice.openEnd); 4314 - return StepResult.fromReplace(doc4, this.from, this.to, slice); 4314 + return StepResult.fromReplace(doc4, this.from, this.to, slice2); 4315 4315 } 4316 4316 invert() { 4317 4317 return new RemoveMarkStep(this.from, this.to, this.mark); 4318 4318 } 4319 4319 map(mapping) { 4320 - let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4321 - if (from.deleted && to.deleted || from.pos >= to.pos) 4320 + let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4321 + if (from2.deleted && to.deleted || from2.pos >= to.pos) 4322 4322 return null; 4323 - return new _AddMarkStep(from.pos, to.pos, this.mark); 4323 + return new _AddMarkStep(from2.pos, to.pos, this.mark); 4324 4324 } 4325 4325 merge(other) { 4326 4326 if (other instanceof _AddMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) ··· 4349 4349 /** 4350 4350 Create a mark-removing step. 4351 4351 */ 4352 - constructor(from, to, mark) { 4352 + constructor(from2, to, mark) { 4353 4353 super(); 4354 - this.from = from; 4354 + this.from = from2; 4355 4355 this.to = to; 4356 4356 this.mark = mark; 4357 4357 } 4358 4358 apply(doc4) { 4359 4359 let oldSlice = doc4.slice(this.from, this.to); 4360 - let slice = new Slice2(mapFragment(oldSlice.content, (node2) => { 4360 + let slice2 = new Slice2(mapFragment(oldSlice.content, (node2) => { 4361 4361 return node2.mark(this.mark.removeFromSet(node2.marks)); 4362 4362 }, doc4), oldSlice.openStart, oldSlice.openEnd); 4363 - return StepResult.fromReplace(doc4, this.from, this.to, slice); 4363 + return StepResult.fromReplace(doc4, this.from, this.to, slice2); 4364 4364 } 4365 4365 invert() { 4366 4366 return new AddMarkStep(this.from, this.to, this.mark); 4367 4367 } 4368 4368 map(mapping) { 4369 - let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4370 - if (from.deleted && to.deleted || from.pos >= to.pos) 4369 + let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4370 + if (from2.deleted && to.deleted || from2.pos >= to.pos) 4371 4371 return null; 4372 - return new _RemoveMarkStep(from.pos, to.pos, this.mark); 4372 + return new _RemoveMarkStep(from2.pos, to.pos, this.mark); 4373 4373 } 4374 4374 merge(other) { 4375 4375 if (other instanceof _RemoveMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) ··· 4489 4489 tokens (this is to guard against rebased replace steps 4490 4490 overwriting something they weren't supposed to). 4491 4491 */ 4492 - constructor(from, to, slice, structure = false) { 4492 + constructor(from2, to, slice2, structure = false) { 4493 4493 super(); 4494 - this.from = from; 4494 + this.from = from2; 4495 4495 this.to = to; 4496 - this.slice = slice; 4496 + this.slice = slice2; 4497 4497 this.structure = structure; 4498 4498 } 4499 4499 apply(doc4) { ··· 4508 4508 return new _ReplaceStep(this.from, this.from + this.slice.size, doc4.slice(this.from, this.to)); 4509 4509 } 4510 4510 map(mapping) { 4511 - let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4512 - if (from.deletedAcross && to.deletedAcross) 4511 + let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4512 + if (from2.deletedAcross && to.deletedAcross) 4513 4513 return null; 4514 - return new _ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure); 4514 + return new _ReplaceStep(from2.pos, Math.max(from2.pos, to.pos), this.slice, this.structure); 4515 4515 } 4516 4516 merge(other) { 4517 4517 if (!(other instanceof _ReplaceStep) || other.structure || this.structure) 4518 4518 return null; 4519 4519 if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) { 4520 - let slice = this.slice.size + other.slice.size == 0 ? Slice2.empty : new Slice2(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd); 4521 - return new _ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure); 4520 + let slice2 = this.slice.size + other.slice.size == 0 ? Slice2.empty : new Slice2(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd); 4521 + return new _ReplaceStep(this.from, this.to + (other.to - other.from), slice2, this.structure); 4522 4522 } else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) { 4523 - let slice = this.slice.size + other.slice.size == 0 ? Slice2.empty : new Slice2(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd); 4524 - return new _ReplaceStep(other.from, this.to, slice, this.structure); 4523 + let slice2 = this.slice.size + other.slice.size == 0 ? Slice2.empty : new Slice2(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd); 4524 + return new _ReplaceStep(other.from, this.to, slice2, this.structure); 4525 4525 } else { 4526 4526 return null; 4527 4527 } ··· 4551 4551 of the gap should be moved. `structure` has the same meaning as 4552 4552 it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class. 4553 4553 */ 4554 - constructor(from, to, gapFrom, gapTo, slice, insert, structure = false) { 4554 + constructor(from2, to, gapFrom, gapTo, slice2, insert, structure = false) { 4555 4555 super(); 4556 - this.from = from; 4556 + this.from = from2; 4557 4557 this.to = to; 4558 4558 this.gapFrom = gapFrom; 4559 4559 this.gapTo = gapTo; 4560 - this.slice = slice; 4560 + this.slice = slice2; 4561 4561 this.insert = insert; 4562 4562 this.structure = structure; 4563 4563 } ··· 4587 4587 return new _ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc4.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure); 4588 4588 } 4589 4589 map(mapping) { 4590 - let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4591 - let gapFrom = this.from == this.gapFrom ? from.pos : mapping.map(this.gapFrom, -1); 4590 + let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1); 4591 + let gapFrom = this.from == this.gapFrom ? from2.pos : mapping.map(this.gapFrom, -1); 4592 4592 let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1); 4593 - if (from.deletedAcross && to.deletedAcross || gapFrom < from.pos || gapTo > to.pos) 4593 + if (from2.deletedAcross && to.deletedAcross || gapFrom < from2.pos || gapTo > to.pos) 4594 4594 return null; 4595 - return new _ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure); 4595 + return new _ReplaceAroundStep(from2.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure); 4596 4596 } 4597 4597 toJSON() { 4598 4598 let json = { ··· 4619 4619 } 4620 4620 }; 4621 4621 Step.jsonID("replaceAround", ReplaceAroundStep); 4622 - function contentBetween(doc4, from, to) { 4623 - let $from = doc4.resolve(from), dist = to - from, depth = $from.depth; 4622 + function contentBetween(doc4, from2, to) { 4623 + let $from = doc4.resolve(from2), dist = to - from2, depth = $from.depth; 4624 4624 while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) { 4625 4625 depth--; 4626 4626 dist--; ··· 4636 4636 } 4637 4637 return false; 4638 4638 } 4639 - function addMark(tr, from, to, mark) { 4639 + function addMark(tr, from2, to, mark) { 4640 4640 let removed = [], added = []; 4641 4641 let removing, adding; 4642 - tr.doc.nodesBetween(from, to, (node2, pos, parent) => { 4642 + tr.doc.nodesBetween(from2, to, (node2, pos, parent) => { 4643 4643 if (!node2.isInline) 4644 4644 return; 4645 4645 let marks = node2.marks; 4646 4646 if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) { 4647 - let start = Math.max(pos, from), end = Math.min(pos + node2.nodeSize, to); 4647 + let start = Math.max(pos, from2), end = Math.min(pos + node2.nodeSize, to); 4648 4648 let newSet = mark.addToSet(marks); 4649 4649 for (let i = 0; i < marks.length; i++) { 4650 4650 if (!marks[i].isInSet(newSet)) { ··· 4663 4663 removed.forEach((s) => tr.step(s)); 4664 4664 added.forEach((s) => tr.step(s)); 4665 4665 } 4666 - function removeMark(tr, from, to, mark) { 4666 + function removeMark(tr, from2, to, mark) { 4667 4667 let matched = [], step = 0; 4668 - tr.doc.nodesBetween(from, to, (node2, pos) => { 4668 + tr.doc.nodesBetween(from2, to, (node2, pos) => { 4669 4669 if (!node2.isInline) 4670 4670 return; 4671 4671 step++; ··· 4695 4695 found2.to = end; 4696 4696 found2.step = step; 4697 4697 } else { 4698 - matched.push({ style, from: Math.max(pos, from), to: end, step }); 4698 + matched.push({ style, from: Math.max(pos, from2), to: end, step }); 4699 4699 } 4700 4700 } 4701 4701 } ··· 4716 4716 if (!parentType.allowsMarkType(child.marks[j].type)) 4717 4717 tr.step(new RemoveMarkStep(cur, end, child.marks[j])); 4718 4718 if (clearNewlines && child.isText && parentType.whitespace != "pre") { 4719 - let m, newline = /\r?\n|\r/g, slice; 4719 + let m, newline = /\r?\n|\r/g, slice2; 4720 4720 while (m = newline.exec(child.text)) { 4721 - if (!slice) 4722 - slice = new Slice2(Fragment.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0); 4723 - replSteps.push(new ReplaceStep(cur + m.index, cur + m.index + m[0].length, slice)); 4721 + if (!slice2) 4722 + slice2 = new Slice2(Fragment.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0); 4723 + replSteps.push(new ReplaceStep(cur + m.index, cur + m.index + m[0].length, slice2)); 4724 4724 } 4725 4725 } 4726 4726 } ··· 4822 4822 let start = range.start, end = range.end; 4823 4823 tr.step(new ReplaceAroundStep(start, end, start, end, new Slice2(content3, 0, 0), wrappers.length, true)); 4824 4824 } 4825 - function setBlockType(tr, from, to, type, attrs) { 4825 + function setBlockType(tr, from2, to, type, attrs) { 4826 4826 if (!type.isTextblock) 4827 4827 throw new RangeError("Type given to setBlockType should be a textblock"); 4828 4828 let mapFrom = tr.steps.length; 4829 - tr.doc.nodesBetween(from, to, (node2, pos) => { 4829 + tr.doc.nodesBetween(from2, to, (node2, pos) => { 4830 4830 let attrsHere = typeof attrs == "function" ? attrs(node2) : attrs; 4831 4831 if (node2.isTextblock && !node2.hasMarkup(type, attrsHere) && canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) { 4832 4832 let convertNewlines = null; ··· 4987 4987 } 4988 4988 return null; 4989 4989 } 4990 - function dropPoint(doc4, pos, slice) { 4990 + function dropPoint(doc4, pos, slice2) { 4991 4991 let $pos = doc4.resolve(pos); 4992 - if (!slice.content.size) 4992 + if (!slice2.content.size) 4993 4993 return pos; 4994 - let content3 = slice.content; 4995 - for (let i = 0; i < slice.openStart; i++) 4994 + let content3 = slice2.content; 4995 + for (let i = 0; i < slice2.openStart; i++) 4996 4996 content3 = content3.firstChild.content; 4997 - for (let pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) { 4997 + for (let pass = 1; pass <= (slice2.openStart == 0 && slice2.size ? 2 : 1); pass++) { 4998 4998 for (let d = $pos.depth; d >= 0; d--) { 4999 4999 let bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1; 5000 5000 let insertPos = $pos.index(d) + (bias > 0 ? 1 : 0); ··· 5011 5011 } 5012 5012 return null; 5013 5013 } 5014 - function replaceStep(doc4, from, to = from, slice = Slice2.empty) { 5015 - if (from == to && !slice.size) 5014 + function replaceStep(doc4, from2, to = from2, slice2 = Slice2.empty) { 5015 + if (from2 == to && !slice2.size) 5016 5016 return null; 5017 - let $from = doc4.resolve(from), $to = doc4.resolve(to); 5018 - if (fitsTrivially($from, $to, slice)) 5019 - return new ReplaceStep(from, to, slice); 5020 - return new Fitter($from, $to, slice).fit(); 5017 + let $from = doc4.resolve(from2), $to = doc4.resolve(to); 5018 + if (fitsTrivially($from, $to, slice2)) 5019 + return new ReplaceStep(from2, to, slice2); 5020 + return new Fitter($from, $to, slice2).fit(); 5021 5021 } 5022 - function fitsTrivially($from, $to, slice) { 5023 - return !slice.openStart && !slice.openEnd && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice.content); 5022 + function fitsTrivially($from, $to, slice2) { 5023 + return !slice2.openStart && !slice2.openEnd && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice2.content); 5024 5024 } 5025 5025 var Fitter = class { 5026 5026 constructor($from, $to, unplaced) { ··· 5060 5060 openStart--; 5061 5061 openEnd--; 5062 5062 } 5063 - let slice = new Slice2(content3, openStart, openEnd); 5063 + let slice2 = new Slice2(content3, openStart, openEnd); 5064 5064 if (moveInline > -1) 5065 - return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize); 5066 - if (slice.size || $from.pos != this.$to.pos) 5067 - return new ReplaceStep($from.pos, $to.pos, slice); 5065 + return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice2, placedSize); 5066 + if (slice2.size || $from.pos != this.$to.pos) 5067 + return new ReplaceStep($from.pos, $to.pos, slice2); 5068 5068 return null; 5069 5069 } 5070 5070 // Find a position on the start spine of `this.unplaced` that has ··· 5131 5131 if (wrap3) 5132 5132 for (let i = 0; i < wrap3.length; i++) 5133 5133 this.openFrontierNode(wrap3[i]); 5134 - let slice = this.unplaced, fragment = parent ? parent.content : slice.content; 5135 - let openStart = slice.openStart - sliceDepth; 5134 + let slice2 = this.unplaced, fragment = parent ? parent.content : slice2.content; 5135 + let openStart = slice2.openStart - sliceDepth; 5136 5136 let taken = 0, add = []; 5137 5137 let { match, type } = this.frontier[frontierDepth]; 5138 5138 if (inject) { ··· 5140 5140 add.push(inject.child(i)); 5141 5141 match = match.matchFragment(inject); 5142 5142 } 5143 - let openEndCount = fragment.size + sliceDepth - (slice.content.size - slice.openEnd); 5143 + let openEndCount = fragment.size + sliceDepth - (slice2.content.size - slice2.openEnd); 5144 5144 while (taken < fragment.childCount) { 5145 5145 let next = fragment.child(taken), matches2 = match.matchType(next.type); 5146 5146 if (!matches2) ··· 5163 5163 this.frontier.push({ type: node2.type, match: node2.contentMatchAt(node2.childCount) }); 5164 5164 cur = node2.content; 5165 5165 } 5166 - this.unplaced = !toEnd ? new Slice2(dropFromFragment(slice.content, sliceDepth, taken), slice.openStart, slice.openEnd) : sliceDepth == 0 ? Slice2.empty : new Slice2(dropFromFragment(slice.content, sliceDepth - 1, 1), sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1); 5166 + this.unplaced = !toEnd ? new Slice2(dropFromFragment(slice2.content, sliceDepth, taken), slice2.openStart, slice2.openEnd) : sliceDepth == 0 ? Slice2.empty : new Slice2(dropFromFragment(slice2.content, sliceDepth - 1, 1), sliceDepth - 1, openEndCount < 0 ? slice2.openEnd : sliceDepth - 1); 5167 5167 } 5168 5168 mustMoveInline() { 5169 5169 if (!this.$to.parent.isTextblock) ··· 5264 5264 function definesContent(type) { 5265 5265 return type.spec.defining || type.spec.definingForContent; 5266 5266 } 5267 - function replaceRange(tr, from, to, slice) { 5268 - if (!slice.size) 5269 - return tr.deleteRange(from, to); 5270 - let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to); 5271 - if (fitsTrivially($from, $to, slice)) 5272 - return tr.step(new ReplaceStep(from, to, slice)); 5267 + function replaceRange(tr, from2, to, slice2) { 5268 + if (!slice2.size) 5269 + return tr.deleteRange(from2, to); 5270 + let $from = tr.doc.resolve(from2), $to = tr.doc.resolve(to); 5271 + if (fitsTrivially($from, $to, slice2)) 5272 + return tr.step(new ReplaceStep(from2, to, slice2)); 5273 5273 let targetDepths = coveredDepths($from, $to); 5274 5274 if (targetDepths[targetDepths.length - 1] == 0) 5275 5275 targetDepths.pop(); ··· 5285 5285 targetDepths.splice(1, 0, -d); 5286 5286 } 5287 5287 let preferredTargetIndex = targetDepths.indexOf(preferredTarget); 5288 - let leftNodes = [], preferredDepth = slice.openStart; 5289 - for (let content3 = slice.content, i = 0; ; i++) { 5288 + let leftNodes = [], preferredDepth = slice2.openStart; 5289 + for (let content3 = slice2.content, i = 0; ; i++) { 5290 5290 let node2 = content3.firstChild; 5291 5291 leftNodes.push(node2); 5292 - if (i == slice.openStart) 5292 + if (i == slice2.openStart) 5293 5293 break; 5294 5294 content3 = node2.content; 5295 5295 } ··· 5300 5300 else if (def || !leftNode.type.isTextblock) 5301 5301 break; 5302 5302 } 5303 - for (let j = slice.openStart; j >= 0; j--) { 5304 - let openDepth = (j + preferredDepth + 1) % (slice.openStart + 1); 5303 + for (let j = slice2.openStart; j >= 0; j--) { 5304 + let openDepth = (j + preferredDepth + 1) % (slice2.openStart + 1); 5305 5305 let insert = leftNodes[openDepth]; 5306 5306 if (!insert) 5307 5307 continue; ··· 5313 5313 } 5314 5314 let parent = $from.node(targetDepth - 1), index2 = $from.index(targetDepth - 1); 5315 5315 if (parent.canReplaceWith(index2, index2, insert.type, insert.marks)) 5316 - return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice2(closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd)); 5316 + return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice2(closeFragment(slice2.content, 0, slice2.openStart, openDepth), openDepth, slice2.openEnd)); 5317 5317 } 5318 5318 } 5319 5319 let startSteps = tr.steps.length; 5320 5320 for (let i = targetDepths.length - 1; i >= 0; i--) { 5321 - tr.replace(from, to, slice); 5321 + tr.replace(from2, to, slice2); 5322 5322 if (tr.steps.length > startSteps) 5323 5323 break; 5324 5324 let depth = targetDepths[i]; 5325 5325 if (depth < 0) 5326 5326 continue; 5327 - from = $from.before(depth); 5327 + from2 = $from.before(depth); 5328 5328 to = $to.after(depth); 5329 5329 } 5330 5330 } ··· 5340 5340 } 5341 5341 return fragment; 5342 5342 } 5343 - function replaceRangeWith(tr, from, to, node2) { 5344 - if (!node2.isInline && from == to && tr.doc.resolve(from).parent.content.size) { 5345 - let point3 = insertPoint(tr.doc, from, node2.type); 5343 + function replaceRangeWith(tr, from2, to, node2) { 5344 + if (!node2.isInline && from2 == to && tr.doc.resolve(from2).parent.content.size) { 5345 + let point3 = insertPoint(tr.doc, from2, node2.type); 5346 5346 if (point3 != null) 5347 - from = to = point3; 5347 + from2 = to = point3; 5348 5348 } 5349 - tr.replaceRange(from, to, new Slice2(Fragment.from(node2), 0, 0)); 5349 + tr.replaceRange(from2, to, new Slice2(Fragment.from(node2), 0, 0)); 5350 5350 } 5351 - function deleteRange(tr, from, to) { 5352 - let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to); 5351 + function deleteRange(tr, from2, to) { 5352 + let $from = tr.doc.resolve(from2), $to = tr.doc.resolve(to); 5353 5353 let covered = coveredDepths($from, $to); 5354 5354 for (let i = 0; i < covered.length; i++) { 5355 5355 let depth = covered[i], last = i == covered.length - 1; ··· 5359 5359 return tr.delete($from.before(depth), $to.after(depth)); 5360 5360 } 5361 5361 for (let d = 1; d <= $from.depth && d <= $to.depth; d++) { 5362 - if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d && $from.start(d - 1) == $to.start(d - 1) && $from.node(d - 1).canReplace($from.index(d - 1), $to.index(d - 1))) 5362 + if (from2 - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d && $from.start(d - 1) == $to.start(d - 1) && $from.node(d - 1).canReplace($from.index(d - 1), $to.index(d - 1))) 5363 5363 return tr.delete($from.before(d), to); 5364 5364 } 5365 - tr.delete(from, to); 5365 + tr.delete(from2, to); 5366 5366 } 5367 5367 function coveredDepths($from, $to) { 5368 5368 let result = [], minDepth = Math.min($from.depth, $to.depth); ··· 5512 5512 that add/remove marks without replacing the underlying content. 5513 5513 */ 5514 5514 changedRange() { 5515 - let from = 1e9, to = -1e9; 5515 + let from2 = 1e9, to = -1e9; 5516 5516 for (let i = 0; i < this.mapping.maps.length; i++) { 5517 - let map4 = this.mapping.maps[i]; 5517 + let map5 = this.mapping.maps[i]; 5518 5518 if (i) { 5519 - from = map4.map(from, 1); 5520 - to = map4.map(to, -1); 5519 + from2 = map5.map(from2, 1); 5520 + to = map5.map(to, -1); 5521 5521 } 5522 - map4.forEach((_f, _t, fromB, toB) => { 5523 - from = Math.min(from, fromB); 5522 + map5.forEach((_f, _t, fromB, toB) => { 5523 + from2 = Math.min(from2, fromB); 5524 5524 to = Math.max(to, toB); 5525 5525 }); 5526 5526 } 5527 - return from == 1e9 ? null : { from, to }; 5527 + return from2 == 1e9 ? null : { from: from2, to }; 5528 5528 } 5529 5529 /** 5530 5530 @internal ··· 5539 5539 Replace the part of the document between `from` and `to` with the 5540 5540 given `slice`. 5541 5541 */ 5542 - replace(from, to = from, slice = Slice2.empty) { 5543 - let step = replaceStep(this.doc, from, to, slice); 5542 + replace(from2, to = from2, slice2 = Slice2.empty) { 5543 + let step = replaceStep(this.doc, from2, to, slice2); 5544 5544 if (step) 5545 5545 this.step(step); 5546 5546 return this; ··· 5549 5549 Replace the given range with the given content, which may be a 5550 5550 fragment, node, or array of nodes. 5551 5551 */ 5552 - replaceWith(from, to, content3) { 5553 - return this.replace(from, to, new Slice2(Fragment.from(content3), 0, 0)); 5552 + replaceWith(from2, to, content3) { 5553 + return this.replace(from2, to, new Slice2(Fragment.from(content3), 0, 0)); 5554 5554 } 5555 5555 /** 5556 5556 Delete the content between the given positions. 5557 5557 */ 5558 - delete(from, to) { 5559 - return this.replace(from, to, Slice2.empty); 5558 + delete(from2, to) { 5559 + return this.replace(from2, to, Slice2.empty); 5560 5560 } 5561 5561 /** 5562 5562 Insert the given content at the given position. ··· 5583 5583 range, and is useful in situations where you need more precise 5584 5584 control over what happens. 5585 5585 */ 5586 - replaceRange(from, to, slice) { 5587 - replaceRange(this, from, to, slice); 5586 + replaceRange(from2, to, slice2) { 5587 + replaceRange(this, from2, to, slice2); 5588 5588 return this; 5589 5589 } 5590 5590 /** ··· 5596 5596 completely covers a parent node, this method may completely replace 5597 5597 that parent node. 5598 5598 */ 5599 - replaceRangeWith(from, to, node2) { 5600 - replaceRangeWith(this, from, to, node2); 5599 + replaceRangeWith(from2, to, node2) { 5600 + replaceRangeWith(this, from2, to, node2); 5601 5601 return this; 5602 5602 } 5603 5603 /** 5604 5604 Delete the given range, expanding it to cover fully covered 5605 5605 parent nodes until a valid replace is found. 5606 5606 */ 5607 - deleteRange(from, to) { 5608 - deleteRange(this, from, to); 5607 + deleteRange(from2, to) { 5608 + deleteRange(this, from2, to); 5609 5609 return this; 5610 5610 } 5611 5611 /** ··· 5640 5640 Set the type of all textblocks (partly) between `from` and `to` to 5641 5641 the given node type with the given attributes. 5642 5642 */ 5643 - setBlockType(from, to = from, type, attrs = null) { 5644 - setBlockType(this, from, to, type, attrs); 5643 + setBlockType(from2, to = from2, type, attrs = null) { 5644 + setBlockType(this, from2, to, type, attrs); 5645 5645 return this; 5646 5646 } 5647 5647 /** ··· 5711 5711 /** 5712 5712 Add the given mark to the inline content between `from` and `to`. 5713 5713 */ 5714 - addMark(from, to, mark) { 5715 - addMark(this, from, to, mark); 5714 + addMark(from2, to, mark) { 5715 + addMark(this, from2, to, mark); 5716 5716 return this; 5717 5717 } 5718 5718 /** ··· 5721 5721 a mark type, remove all marks of that type. When it is null, 5722 5722 remove all marks of any type. 5723 5723 */ 5724 - removeMark(from, to, mark) { 5725 - removeMark(this, from, to, mark); 5724 + removeMark(from2, to, mark) { 5725 + removeMark(this, from2, to, mark); 5726 5726 return this; 5727 5727 } 5728 5728 /** ··· 5828 5828 let mapFrom = tr.steps.length, ranges = this.ranges; 5829 5829 for (let i = 0; i < ranges.length; i++) { 5830 5830 let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom); 5831 - let from = mapping.map($from.pos), to = mapping.map($to.pos); 5831 + let from2 = mapping.map($from.pos), to = mapping.map($to.pos); 5832 5832 if (i) { 5833 - tr.deleteRange(from, to); 5833 + tr.deleteRange(from2, to); 5834 5834 } else { 5835 - tr.replaceRangeWith(from, to, node2); 5835 + tr.replaceRangeWith(from2, to, node2); 5836 5836 selectionToInsertionEnd(tr, mapFrom, node2.isInline ? -1 : 1); 5837 5837 } 5838 5838 } ··· 6074 6074 /** 6075 6075 Create a node selection from non-resolved positions. 6076 6076 */ 6077 - static create(doc4, from) { 6078 - return new _NodeSelection(doc4.resolve(from)); 6077 + static create(doc4, from2) { 6078 + return new _NodeSelection(doc4.resolve(from2)); 6079 6079 } 6080 6080 /** 6081 6081 Determines whether the given node may be selected as a node ··· 6170 6170 let step = tr.steps[last]; 6171 6171 if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) 6172 6172 return; 6173 - let map4 = tr.mapping.maps[last], end; 6174 - map4.forEach((_from, _to, _newFrom, newTo) => { 6173 + let map5 = tr.mapping.maps[last], end; 6174 + map5.forEach((_from, _to, _newFrom, newTo) => { 6175 6175 if (end == null) 6176 6176 end = newTo; 6177 6177 }); ··· 6279 6279 /** 6280 6280 Replace the current selection with the given slice. 6281 6281 */ 6282 - replaceSelection(slice) { 6283 - this.selection.replace(this, slice); 6282 + replaceSelection(slice2) { 6283 + this.selection.replace(this, slice2); 6284 6284 return this; 6285 6285 } 6286 6286 /** ··· 6306 6306 Replace the given range, or the selection if no range is given, 6307 6307 with a text node containing the given string. 6308 6308 */ 6309 - insertText(text4, from, to) { 6309 + insertText(text4, from2, to) { 6310 6310 let schema3 = this.doc.type.schema; 6311 - if (from == null) { 6311 + if (from2 == null) { 6312 6312 if (!text4) 6313 6313 return this.deleteSelection(); 6314 6314 return this.replaceSelectionWith(schema3.text(text4), true); 6315 6315 } else { 6316 6316 if (to == null) 6317 - to = from; 6317 + to = from2; 6318 6318 if (!text4) 6319 - return this.deleteRange(from, to); 6319 + return this.deleteRange(from2, to); 6320 6320 let marks = this.storedMarks; 6321 6321 if (!marks) { 6322 - let $from = this.doc.resolve(from); 6323 - marks = to == from ? $from.marks() : $from.marksAcross(this.doc.resolve(to)); 6322 + let $from = this.doc.resolve(from2); 6323 + marks = to == from2 ? $from.marks() : $from.marksAcross(this.doc.resolve(to)); 6324 6324 } 6325 - this.replaceRangeWith(from, to, schema3.text(text4, marks)); 6326 - if (!this.selection.empty && this.selection.to == from + text4.length) 6325 + this.replaceRangeWith(from2, to, schema3.text(text4, marks)); 6326 + if (!this.selection.empty && this.selection.to == from2 + text4.length) 6327 6327 this.setSelection(Selection.near(this.selection.$to)); 6328 6328 return this; 6329 6329 } ··· 7068 7068 return function(state, dispatch) { 7069 7069 let applicable = false; 7070 7070 for (let i = 0; i < state.selection.ranges.length && !applicable; i++) { 7071 - let { $from: { pos: from }, $to: { pos: to } } = state.selection.ranges[i]; 7072 - state.doc.nodesBetween(from, to, (node2, pos) => { 7071 + let { $from: { pos: from2 }, $to: { pos: to } } = state.selection.ranges[i]; 7072 + state.doc.nodesBetween(from2, to, (node2, pos) => { 7073 7073 if (applicable) 7074 7074 return false; 7075 7075 if (!node2.isTextblock || node2.hasMarkup(nodeType, attrs)) ··· 7087 7087 if (dispatch) { 7088 7088 let tr = state.tr; 7089 7089 for (let i = 0; i < state.selection.ranges.length; i++) { 7090 - let { $from: { pos: from }, $to: { pos: to } } = state.selection.ranges[i]; 7091 - tr.setBlockType(from, to, nodeType, attrs); 7090 + let { $from: { pos: from2 }, $to: { pos: to } } = state.selection.ranges[i]; 7091 + tr.setBlockType(from2, to, nodeType, attrs); 7092 7092 } 7093 7093 dispatch(tr.scrollIntoView()); 7094 7094 } ··· 7162 7162 if (!add) { 7163 7163 tr.removeMark($from.pos, $to.pos, markType); 7164 7164 } else { 7165 - let from = $from.pos, to = $to.pos, start = $from.nodeAfter, end = $to.nodeBefore; 7165 + let from2 = $from.pos, to = $to.pos, start = $from.nodeAfter, end = $to.nodeBefore; 7166 7166 let spaceStart = dropSpace && start && start.isText ? /^\s*/.exec(start.text)[0].length : 0; 7167 7167 let spaceEnd = dropSpace && end && end.isText ? /\s*$/.exec(end.text)[0].length : 0; 7168 - if (from + spaceStart < to) { 7169 - from += spaceStart; 7168 + if (from2 + spaceStart < to) { 7169 + from2 += spaceStart; 7170 7170 to -= spaceEnd; 7171 7171 } 7172 - tr.addMark(from, to, markType.create(attrs)); 7172 + tr.addMark(from2, to, markType.create(attrs)); 7173 7173 } 7174 7174 } 7175 7175 dispatch(tr.scrollIntoView()); ··· 8759 8759 } 8760 8760 index2 = breaks.length; 8761 8761 while (index2--) { 8762 - const slice = childEvents.slice(breaks[index2], breaks[index2 + 1]); 8762 + const slice2 = childEvents.slice(breaks[index2], breaks[index2 + 1]); 8763 8763 const start2 = startPositions.pop(); 8764 - jumps.push([start2, start2 + slice.length - 1]); 8765 - events.splice(start2, 2, slice); 8764 + jumps.push([start2, start2 + slice2.length - 1]); 8765 + events.splice(start2, 2, slice2); 8766 8766 } 8767 8767 jumps.reverse(); 8768 8768 index2 = -1; ··· 10836 10836 }; 10837 10837 10838 10838 // node_modules/micromark/lib/create-tokenizer.js 10839 - function createTokenizer(parser2, initialize, from) { 10839 + function createTokenizer(parser2, initialize, from2) { 10840 10840 let point3 = { 10841 10841 _bufferIndex: -1, 10842 10842 _index: 0, 10843 - line: from && from.line || 1, 10844 - column: from && from.column || 1, 10845 - offset: from && from.offset || 0 10843 + line: from2 && from2.line || 1, 10844 + column: from2 && from2.column || 1, 10845 + offset: from2 && from2.offset || 0 10846 10846 }; 10847 10847 const columnStart = {}; 10848 10848 const resolveAllConstructs = []; ··· 10877 10877 resolveAllConstructs.push(initialize); 10878 10878 } 10879 10879 return context; 10880 - function write(slice) { 10881 - chunks = push(chunks, slice); 10880 + function write(slice2) { 10881 + chunks = push(chunks, slice2); 10882 10882 main(); 10883 10883 if (chunks[chunks.length - 1] !== null) { 10884 10884 return []; ··· 10997 10997 constructs2 10998 10998 ]) 10999 10999 ) : handleMapOfConstructs(constructs2); 11000 - function handleMapOfConstructs(map4) { 11000 + function handleMapOfConstructs(map5) { 11001 11001 return start; 11002 11002 function start(code2) { 11003 - const left = code2 !== null && map4[code2]; 11004 - const all2 = code2 !== null && map4.null; 11003 + const left = code2 !== null && map5[code2]; 11004 + const all2 = code2 !== null && map5.null; 11005 11005 const list4 = [ 11006 11006 // To do: add more extension tests. 11007 11007 /* c8 ignore next 2 */ ··· 11056 11056 } 11057 11057 } 11058 11058 } 11059 - function addResult(construct, from2) { 11059 + function addResult(construct, from3) { 11060 11060 if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { 11061 11061 resolveAllConstructs.push(construct); 11062 11062 } 11063 11063 if (construct.resolve) { 11064 - splice(context.events, from2, context.events.length - from2, construct.resolve(context.events.slice(from2), context)); 11064 + splice(context.events, from3, context.events.length - from3, construct.resolve(context.events.slice(from3), context)); 11065 11065 } 11066 11066 if (construct.resolveTo) { 11067 11067 context.events = construct.resolveTo(context.events, context); ··· 11178 11178 return parser2; 11179 11179 function create(initial) { 11180 11180 return creator; 11181 - function creator(from) { 11182 - return createTokenizer(parser2, initial, from); 11181 + function creator(from2) { 11182 + return createTokenizer(parser2, initial, from2); 11183 11183 } 11184 11184 } 11185 11185 } ··· 13069 13069 const exit2 = state.enter("listItem"); 13070 13070 const value = state.indentLines( 13071 13071 state.containerFlow(node2, tracker.current()), 13072 - map4 13072 + map5 13073 13073 ); 13074 13074 exit2(); 13075 13075 return value; 13076 - function map4(line, index2, blank) { 13076 + function map5(line, index2, blank) { 13077 13077 if (index2) { 13078 13078 return (blank ? "" : " ".repeat(size2)) + line; 13079 13079 } ··· 13505 13505 13506 13506 // node_modules/mdast-util-to-markdown/lib/util/indent-lines.js 13507 13507 var eol = /\r?\n|\r/g; 13508 - function indentLines(value, map4) { 13508 + function indentLines(value, map5) { 13509 13509 const result = []; 13510 13510 let start = 0; 13511 13511 let line = 0; ··· 13519 13519 one2(value.slice(start)); 13520 13520 return result.join(""); 13521 13521 function one2(value2) { 13522 - result.push(map4(value2, line, !value2)); 13522 + result.push(map5(value2, line, !value2)); 13523 13523 } 13524 13524 } 13525 13525 ··· 15917 15917 var android = /Android \d/.test(agent); 15918 15918 var webkit = !!doc2 && "webkitFontSmoothing" in doc2.documentElement.style; 15919 15919 var webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0; 15920 - function run(view, from, to, text4, rules, plugin) { 15920 + function run(view, from2, to, text4, rules, plugin) { 15921 15921 if (view.composing) return false; 15922 15922 const state = view.state; 15923 - const $from = state.doc.resolve(from); 15923 + const $from = state.doc.resolve(from2); 15924 15924 if ($from.parent.type.spec.code) return false; 15925 15925 const textBefore = $from.parent.textBetween( 15926 15926 Math.max(0, $from.parentOffset - 500), ··· 15931 15931 for (let _matcher of rules) { 15932 15932 const matcher = _matcher; 15933 15933 const match = matcher.match.exec(textBefore); 15934 - const tr = match && match[0] && matcher.handler(state, match, from - (match[0].length - text4.length), to); 15934 + const tr = match && match[0] && matcher.handler(state, match, from2 - (match[0].length - text4.length), to); 15935 15935 if (!tr) continue; 15936 15936 if (matcher.undoable !== false) 15937 - tr.setMeta(plugin, { transform: tr, from, to, text: text4 }); 15937 + tr.setMeta(plugin, { transform: tr, from: from2, to, text: text4 }); 15938 15938 view.dispatch(tr); 15939 15939 return true; 15940 15940 } ··· 15956 15956 } 15957 15957 }, 15958 15958 props: { 15959 - handleTextInput(view, from, to, text4) { 15960 - return run(view, from, to, text4, rules, plugin); 15959 + handleTextInput(view, from2, to, text4) { 15960 + return run(view, from2, to, text4, rules, plugin); 15961 15961 }, 15962 15962 handleDOMEvents: { 15963 15963 compositionend: (view) => { ··· 16037 16037 function minMax(value = 0, min2 = 0, max2 = 0) { 16038 16038 return Math.min(Math.max(value, min2), max2); 16039 16039 } 16040 - function posToDOMRect(view, from, to) { 16040 + function posToDOMRect(view, from2, to) { 16041 16041 const minPos = 0; 16042 16042 const maxPos = view.state.doc.content.size; 16043 - const resolvedFrom = minMax(from, minPos, maxPos); 16043 + const resolvedFrom = minMax(from2, minPos, maxPos); 16044 16044 const resolvedEnd = minMax(to, minPos, maxPos); 16045 16045 const start = view.coordsAtPos(resolvedFrom); 16046 16046 const end = view.coordsAtPos(resolvedEnd, -1); ··· 16090 16090 target: selection.node 16091 16091 }; 16092 16092 } 16093 - const { from, to } = selection; 16093 + const { from: from2, to } = selection; 16094 16094 let hasNode = false; 16095 16095 let pos = -1; 16096 16096 let target = null; 16097 - doc4.nodesBetween(from, to, (n, p) => { 16097 + doc4.nodesBetween(from2, to, (n, p) => { 16098 16098 if (target) return false; 16099 16099 if (n.type === node2) { 16100 16100 hasNode = true; ··· 16253 16253 result = "Shift-" + result; 16254 16254 return result; 16255 16255 } 16256 - function normalize2(map4) { 16256 + function normalize2(map5) { 16257 16257 let copy2 = /* @__PURE__ */ Object.create(null); 16258 - for (let prop in map4) 16259 - copy2[normalizeKeyName(prop)] = map4[prop]; 16258 + for (let prop in map5) 16259 + copy2[normalizeKeyName(prop)] = map5[prop]; 16260 16260 return copy2; 16261 16261 } 16262 16262 function modifiers(name, event, shift4 = true) { ··· 16274 16274 return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } }); 16275 16275 } 16276 16276 function keydownHandler(bindings) { 16277 - let map4 = normalize2(bindings); 16277 + let map5 = normalize2(bindings); 16278 16278 return function(view, event) { 16279 - let name = keyName(event), baseName, direct = map4[modifiers(name, event)]; 16279 + let name = keyName(event), baseName, direct = map5[modifiers(name, event)]; 16280 16280 if (direct && direct(view.state, view.dispatch, view)) 16281 16281 return true; 16282 16282 if (name.length == 1 && name != " ") { 16283 16283 if (event.shiftKey) { 16284 - let noShift = map4[modifiers(name, event, false)]; 16284 + let noShift = map5[modifiers(name, event, false)]; 16285 16285 if (noShift && noShift(view.state, view.dispatch, view)) 16286 16286 return true; 16287 16287 } 16288 16288 if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows 16289 16289 !(windows && event.ctrlKey && event.altKey) && (baseName = base[event.keyCode]) && baseName != name) { 16290 - let fromCode = map4[modifiers(baseName, event)]; 16290 + let fromCode = map5[modifiers(baseName, event)]; 16291 16291 if (fromCode && fromCode(view.state, view.dispatch, view)) 16292 16292 return true; 16293 16293 } ··· 16309 16309 return parent && parent.nodeType == 11 ? parent.host : parent; 16310 16310 }; 16311 16311 var reusedRange = null; 16312 - var textRange = function(node2, from, to) { 16312 + var textRange = function(node2, from2, to) { 16313 16313 let range = reusedRange || (reusedRange = document.createRange()); 16314 16314 range.setEnd(node2, to == null ? node2.nodeValue.length : to); 16315 - range.setStart(node2, from || 0); 16315 + range.setStart(node2, from2 || 0); 16316 16316 return range; 16317 16317 }; 16318 16318 var clearReusedRange = function() { ··· 16782 16782 } 16783 16783 return rect; 16784 16784 } else { 16785 - let from = offset3, to = offset3, takeSide = side < 0 ? 1 : -1; 16785 + let from2 = offset3, to = offset3, takeSide = side < 0 ? 1 : -1; 16786 16786 if (side < 0 && !offset3) { 16787 16787 to++; 16788 16788 takeSide = -1; 16789 16789 } else if (side >= 0 && offset3 == node2.nodeValue.length) { 16790 - from--; 16790 + from2--; 16791 16791 takeSide = 1; 16792 16792 } else if (side < 0) { 16793 - from--; 16793 + from2--; 16794 16794 } else { 16795 16795 to++; 16796 16796 } 16797 - return flattenV(singleRect(textRange(node2, from, to), takeSide), takeSide < 0); 16797 + return flattenV(singleRect(textRange(node2, from2, to), takeSide), takeSide < 0); 16798 16798 } 16799 16799 } 16800 16800 let $dom = view.state.doc.resolve(pos - (atom || 0)); ··· 17145 17145 } 17146 17146 // Used to find a DOM range in a single parent for a given changed 17147 17147 // range. 17148 - parseRange(from, to, base2 = 0) { 17148 + parseRange(from2, to, base2 = 0) { 17149 17149 if (this.children.length == 0) 17150 - return { node: this.contentDOM, from, to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length }; 17150 + return { node: this.contentDOM, from: from2, to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length }; 17151 17151 let fromOffset = -1, toOffset = -1; 17152 17152 for (let offset3 = base2, i = 0; ; i++) { 17153 17153 let child = this.children[i], end = offset3 + child.size; 17154 - if (fromOffset == -1 && from <= end) { 17154 + if (fromOffset == -1 && from2 <= end) { 17155 17155 let childBase = offset3 + child.border; 17156 - if (from >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM)) 17157 - return child.parseRange(from, to, childBase); 17158 - from = offset3; 17156 + if (from2 >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM)) 17157 + return child.parseRange(from2, to, childBase); 17158 + from2 = offset3; 17159 17159 for (let j = i; j > 0; j--) { 17160 17160 let prev = this.children[j - 1]; 17161 17161 if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) { 17162 17162 fromOffset = domIndex(prev.dom) + 1; 17163 17163 break; 17164 17164 } 17165 - from -= prev.size; 17165 + from2 -= prev.size; 17166 17166 } 17167 17167 if (fromOffset == -1) 17168 17168 fromOffset = 0; ··· 17183 17183 } 17184 17184 offset3 = end; 17185 17185 } 17186 - return { node: this.contentDOM, from, to, fromOffset, toOffset }; 17186 + return { node: this.contentDOM, from: from2, to, fromOffset, toOffset }; 17187 17187 } 17188 17188 emptyChildAt(side) { 17189 17189 if (this.border || !this.contentDOM || !this.children.length) ··· 17203 17203 // a selection starts in such a node and ends in another, in which 17204 17204 // case we just use whatever domFromPos produces as a best effort. 17205 17205 setSelection(anchor, head, view, force = false) { 17206 - let from = Math.min(anchor, head), to = Math.max(anchor, head); 17206 + let from2 = Math.min(anchor, head), to = Math.max(anchor, head); 17207 17207 for (let i = 0, offset3 = 0; i < this.children.length; i++) { 17208 17208 let child = this.children[i], end = offset3 + child.size; 17209 - if (from > offset3 && to < end) 17209 + if (from2 > offset3 && to < end) 17210 17210 return child.setSelection(anchor - offset3 - child.border, head - offset3 - child.border, view, force); 17211 17211 offset3 = end; 17212 17212 } ··· 17274 17274 } 17275 17275 // Remove a subtree of the element tree that has been touched 17276 17276 // by a DOM change, so that the next update will redraw it. 17277 - markDirty(from, to) { 17277 + markDirty(from2, to) { 17278 17278 for (let offset3 = 0, i = 0; i < this.children.length; i++) { 17279 17279 let child = this.children[i], end = offset3 + child.size; 17280 - if (offset3 == end ? from <= end && to >= offset3 : from < end && to > offset3) { 17280 + if (offset3 == end ? from2 <= end && to >= offset3 : from2 < end && to > offset3) { 17281 17281 let startInside = offset3 + child.border, endInside = end - child.border; 17282 - if (from >= startInside && to <= endInside) { 17283 - this.dirty = from == offset3 || to == end ? CONTENT_DIRTY : CHILD_DIRTY; 17284 - if (from == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM)) 17282 + if (from2 >= startInside && to <= endInside) { 17283 + this.dirty = from2 == offset3 || to == end ? CONTENT_DIRTY : CHILD_DIRTY; 17284 + if (from2 == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM)) 17285 17285 child.dirty = NODE_DIRTY; 17286 17286 else 17287 - child.markDirty(from - startInside, to - startInside); 17287 + child.markDirty(from2 - startInside, to - startInside); 17288 17288 return; 17289 17289 } else { 17290 17290 child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM && !child.children.length ? CONTENT_DIRTY : NODE_DIRTY; ··· 17408 17408 matchesMark(mark) { 17409 17409 return this.dirty != NODE_DIRTY && this.mark.eq(mark); 17410 17410 } 17411 - markDirty(from, to) { 17412 - super.markDirty(from, to); 17411 + markDirty(from2, to) { 17412 + super.markDirty(from2, to); 17413 17413 if (this.dirty != NOT_DIRTY) { 17414 17414 let parent = this.parent; 17415 17415 while (!parent.node) ··· 17419 17419 this.dirty = NOT_DIRTY; 17420 17420 } 17421 17421 } 17422 - slice(from, to, view) { 17422 + slice(from2, to, view) { 17423 17423 let copy2 = _MarkViewDesc.create(this.parent, this.mark, true, view); 17424 17424 let nodes = this.children, size2 = this.size; 17425 17425 if (to < size2) 17426 17426 nodes = replaceNodes(nodes, to, size2, view); 17427 - if (from > 0) 17428 - nodes = replaceNodes(nodes, 0, from, view); 17427 + if (from2 > 0) 17428 + nodes = replaceNodes(nodes, 0, from2, view); 17429 17429 for (let i = 0; i < nodes.length; i++) 17430 17430 nodes[i].parent = copy2; 17431 17431 copy2.children = nodes; ··· 17562 17562 } 17563 17563 } 17564 17564 localCompositionInfo(view, pos) { 17565 - let { from, to } = view.state.selection; 17566 - if (!(view.state.selection instanceof TextSelection) || from < pos || to > pos + this.node.content.size) 17565 + let { from: from2, to } = view.state.selection; 17566 + if (!(view.state.selection instanceof TextSelection) || from2 < pos || to > pos + this.node.content.size) 17567 17567 return null; 17568 17568 let textNode = view.input.compositionNode; 17569 17569 if (!textNode || !this.dom.contains(textNode.parentNode)) 17570 17570 return null; 17571 17571 if (this.node.inlineContent) { 17572 17572 let text4 = textNode.nodeValue; 17573 - let textPos = findTextInFragment(this.node.content, text4, from - pos, to - pos); 17573 + let textPos = findTextInFragment(this.node.content, text4, from2 - pos, to - pos); 17574 17574 return textPos < 0 ? null : { node: textNode, pos: textPos, text: text4 }; 17575 17575 } else { 17576 17576 return { node: textNode, pos: -1, text: "" }; ··· 17690 17690 ignoreMutation(mutation) { 17691 17691 return mutation.type != "characterData" && mutation.type != "selection"; 17692 17692 } 17693 - slice(from, to, view) { 17694 - let node2 = this.node.cut(from, to), dom = document.createTextNode(node2.text); 17693 + slice(from2, to, view) { 17694 + let node2 = this.node.cut(from2, to), dom = document.createTextNode(node2.text); 17695 17695 return new _TextViewDesc(this.parent, node2, this.outerDeco, this.innerDeco, dom, dom, view); 17696 17696 } 17697 - markDirty(from, to) { 17698 - super.markDirty(from, to); 17699 - if (this.dom != this.nodeDOM && (from == 0 || to == this.nodeDOM.nodeValue.length)) 17697 + markDirty(from2, to) { 17698 + super.markDirty(from2, to); 17699 + if (this.dom != this.nodeDOM && (from2 == 0 || to == this.nodeDOM.nodeValue.length)) 17700 17700 this.dirty = NODE_DIRTY; 17701 17701 } 17702 17702 get domAtom() { ··· 18223 18223 dom.style.cssText = oldCSS; 18224 18224 } 18225 18225 } 18226 - function findTextInFragment(frag, text4, from, to) { 18226 + function findTextInFragment(frag, text4, from2, to) { 18227 18227 for (let i = 0, pos = 0; i < frag.childCount && pos <= to; ) { 18228 18228 let child = frag.child(i++), childStart = pos; 18229 18229 pos += child.nodeSize; ··· 18237 18237 break; 18238 18238 str += next.text; 18239 18239 } 18240 - if (pos >= from) { 18240 + if (pos >= from2) { 18241 18241 if (pos >= to && str.slice(to - text4.length - childStart, to - childStart) == text4) 18242 18242 return to - text4.length; 18243 18243 let found2 = childStart < to ? str.lastIndexOf(text4, to - childStart - 1) : -1; 18244 - if (found2 >= 0 && found2 + text4.length + childStart >= from) 18244 + if (found2 >= 0 && found2 + text4.length + childStart >= from2) 18245 18245 return childStart + found2; 18246 - if (from == to && str.length >= to + text4.length - childStart && str.slice(to - childStart, to - childStart + text4.length) == text4) 18246 + if (from2 == to && str.length >= to + text4.length - childStart && str.slice(to - childStart, to - childStart + text4.length) == text4) 18247 18247 return to; 18248 18248 } 18249 18249 } 18250 18250 return -1; 18251 18251 } 18252 - function replaceNodes(nodes, from, to, view, replacement) { 18252 + function replaceNodes(nodes, from2, to, view, replacement) { 18253 18253 let result = []; 18254 18254 for (let i = 0, off = 0; i < nodes.length; i++) { 18255 18255 let child = nodes[i], start = off, end = off += child.size; 18256 - if (start >= to || end <= from) { 18256 + if (start >= to || end <= from2) { 18257 18257 result.push(child); 18258 18258 } else { 18259 - if (start < from) 18260 - result.push(child.slice(0, from - start, view)); 18259 + if (start < from2) 18260 + result.push(child.slice(0, from2 - start, view)); 18261 18261 if (replacement) { 18262 18262 result.push(replacement); 18263 18263 replacement = void 0; ··· 18782 18782 } 18783 18783 return false; 18784 18784 } 18785 - function serializeForClipboard(view, slice) { 18785 + function serializeForClipboard(view, slice2) { 18786 18786 view.someProp("transformCopied", (f) => { 18787 - slice = f(slice, view); 18787 + slice2 = f(slice2, view); 18788 18788 }); 18789 - let context = [], { content: content3, openStart, openEnd } = slice; 18789 + let context = [], { content: content3, openStart, openEnd } = slice2; 18790 18790 while (openStart > 1 && openEnd > 1 && content3.childCount == 1 && content3.firstChild.childCount == 1) { 18791 18791 openStart--; 18792 18792 openEnd--; ··· 18810 18810 } 18811 18811 if (firstChild && firstChild.nodeType == 1) 18812 18812 firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`); 18813 - let text4 = view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n"); 18814 - return { dom: wrap3, text: text4, slice }; 18813 + let text4 = view.someProp("clipboardTextSerializer", (f) => f(slice2, view)) || slice2.content.textBetween(0, slice2.content.size, "\n\n"); 18814 + return { dom: wrap3, text: text4, slice: slice2 }; 18815 18815 } 18816 18816 function parseFromClipboard(view, text4, html2, plainText, $context) { 18817 18817 let inCode = $context.parent.type.spec.code; 18818 - let dom, slice; 18818 + let dom, slice2; 18819 18819 if (!html2 && !text4) 18820 18820 return null; 18821 18821 let asText = !!text4 && (plainText || inCode || !html2); ··· 18824 18824 text4 = f(text4, inCode || plainText, view); 18825 18825 }); 18826 18826 if (inCode) { 18827 - slice = new Slice2(Fragment.from(view.state.schema.text(text4.replace(/\r\n?/g, "\n"))), 0, 0); 18827 + slice2 = new Slice2(Fragment.from(view.state.schema.text(text4.replace(/\r\n?/g, "\n"))), 0, 0); 18828 18828 view.someProp("transformPasted", (f) => { 18829 - slice = f(slice, view, true); 18829 + slice2 = f(slice2, view, true); 18830 18830 }); 18831 - return slice; 18831 + return slice2; 18832 18832 } 18833 18833 let parsed = view.someProp("clipboardTextParser", (f) => f(text4, $context, plainText, view)); 18834 18834 if (parsed) { 18835 - slice = parsed; 18835 + slice2 = parsed; 18836 18836 } else { 18837 18837 let marks = $context.marks(); 18838 18838 let { schema: schema3 } = view.state, serializer2 = DOMSerializer.fromSchema(schema3); ··· 18862 18862 break; 18863 18863 dom = child; 18864 18864 } 18865 - if (!slice) { 18865 + if (!slice2) { 18866 18866 let parser2 = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema); 18867 - slice = parser2.parseSlice(dom, { 18867 + slice2 = parser2.parseSlice(dom, { 18868 18868 preserveWhitespace: !!(asText || sliceData), 18869 18869 context: $context, 18870 18870 ruleFromNode(dom2) { ··· 18875 18875 }); 18876 18876 } 18877 18877 if (sliceData) { 18878 - slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[4]); 18878 + slice2 = addContext(closeSlice(slice2, +sliceData[1], +sliceData[2]), sliceData[4]); 18879 18879 } else { 18880 - slice = Slice2.maxOpen(normalizeSiblings(slice.content, $context), true); 18881 - if (slice.openStart || slice.openEnd) { 18880 + slice2 = Slice2.maxOpen(normalizeSiblings(slice2.content, $context), true); 18881 + if (slice2.openStart || slice2.openEnd) { 18882 18882 let openStart = 0, openEnd = 0; 18883 - for (let node2 = slice.content.firstChild; openStart < slice.openStart && !node2.type.spec.isolating; openStart++, node2 = node2.firstChild) { 18883 + for (let node2 = slice2.content.firstChild; openStart < slice2.openStart && !node2.type.spec.isolating; openStart++, node2 = node2.firstChild) { 18884 18884 } 18885 - for (let node2 = slice.content.lastChild; openEnd < slice.openEnd && !node2.type.spec.isolating; openEnd++, node2 = node2.lastChild) { 18885 + for (let node2 = slice2.content.lastChild; openEnd < slice2.openEnd && !node2.type.spec.isolating; openEnd++, node2 = node2.lastChild) { 18886 18886 } 18887 - slice = closeSlice(slice, openStart, openEnd); 18887 + slice2 = closeSlice(slice2, openStart, openEnd); 18888 18888 } 18889 18889 } 18890 18890 view.someProp("transformPasted", (f) => { 18891 - slice = f(slice, view, asText); 18891 + slice2 = f(slice2, view, asText); 18892 18892 }); 18893 - return slice; 18893 + return slice2; 18894 18894 } 18895 18895 var inlineParents = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i; 18896 18896 function normalizeSiblings(fragment, $context) { ··· 18922 18922 } 18923 18923 return fragment; 18924 18924 } 18925 - function withWrappers(node2, wrap3, from = 0) { 18926 - for (let i = wrap3.length - 1; i >= from; i--) 18925 + function withWrappers(node2, wrap3, from2 = 0) { 18926 + for (let i = wrap3.length - 1; i >= from2; i--) 18927 18927 node2 = wrap3[i].create(null, Fragment.from(node2)); 18928 18928 return node2; 18929 18929 } ··· 18944 18944 let fill = node2.contentMatchAt(node2.childCount).fillBefore(Fragment.empty, true); 18945 18945 return node2.copy(fragment.append(fill)); 18946 18946 } 18947 - function closeRange(fragment, side, from, to, depth, openEnd) { 18947 + function closeRange(fragment, side, from2, to, depth, openEnd) { 18948 18948 let node2 = side < 0 ? fragment.firstChild : fragment.lastChild, inner = node2.content; 18949 18949 if (fragment.childCount > 1) 18950 18950 openEnd = 0; 18951 18951 if (depth < to - 1) 18952 - inner = closeRange(inner, side, from, to, depth + 1, openEnd); 18953 - if (depth >= from) 18952 + inner = closeRange(inner, side, from2, to, depth + 1, openEnd); 18953 + if (depth >= from2) 18954 18954 inner = side < 0 ? node2.contentMatchAt(0).fillBefore(inner, openEnd <= depth).append(inner) : inner.append(node2.contentMatchAt(node2.childCount).fillBefore(Fragment.empty, true)); 18955 18955 return fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node2.copy(inner)); 18956 18956 } 18957 - function closeSlice(slice, openStart, openEnd) { 18958 - if (openStart < slice.openStart) 18959 - slice = new Slice2(closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd); 18960 - if (openEnd < slice.openEnd) 18961 - slice = new Slice2(closeRange(slice.content, 1, openEnd, slice.openEnd, 0, 0), slice.openStart, openEnd); 18962 - return slice; 18957 + function closeSlice(slice2, openStart, openEnd) { 18958 + if (openStart < slice2.openStart) 18959 + slice2 = new Slice2(closeRange(slice2.content, -1, openStart, slice2.openStart, 0, slice2.openEnd), openStart, slice2.openEnd); 18960 + if (openEnd < slice2.openEnd) 18961 + slice2 = new Slice2(closeRange(slice2.content, 1, openEnd, slice2.openEnd, 0, 0), slice2.openStart, openEnd); 18962 + return slice2; 18963 18963 } 18964 18964 var wrapMap = { 18965 18965 thead: ["table"], ··· 19007 19007 node2.parentNode.replaceChild(dom.ownerDocument.createTextNode(" "), node2); 19008 19008 } 19009 19009 } 19010 - function addContext(slice, context) { 19011 - if (!slice.size) 19012 - return slice; 19013 - let schema3 = slice.content.firstChild.type.schema, array; 19010 + function addContext(slice2, context) { 19011 + if (!slice2.size) 19012 + return slice2; 19013 + let schema3 = slice2.content.firstChild.type.schema, array; 19014 19014 try { 19015 19015 array = JSON.parse(context); 19016 19016 } catch (e) { 19017 - return slice; 19017 + return slice2; 19018 19018 } 19019 - let { content: content3, openStart, openEnd } = slice; 19019 + let { content: content3, openStart, openEnd } = slice2; 19020 19020 for (let i = array.length - 2; i >= 0; i -= 2) { 19021 19021 let type = schema3.nodes[array[i]]; 19022 19022 if (!type || type.hasRequiredAttrs()) ··· 19528 19528 if (sel.empty) 19529 19529 return; 19530 19530 let data = brokenClipboardAPI ? null : event.clipboardData; 19531 - let slice = sel.content(), { dom, text: text4 } = serializeForClipboard(view, slice); 19531 + let slice2 = sel.content(), { dom, text: text4 } = serializeForClipboard(view, slice2); 19532 19532 if (data) { 19533 19533 event.preventDefault(); 19534 19534 data.clearData(); ··· 19540 19540 if (cut) 19541 19541 view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut")); 19542 19542 }; 19543 - function sliceSingleNode(slice) { 19544 - return slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1 ? slice.content.firstChild : null; 19543 + function sliceSingleNode(slice2) { 19544 + return slice2.openStart == 0 && slice2.openEnd == 0 && slice2.content.childCount == 1 ? slice2.content.firstChild : null; 19545 19545 } 19546 19546 function capturePaste(view, event) { 19547 19547 if (!view.dom.parentNode) ··· 19564 19564 }, 50); 19565 19565 } 19566 19566 function doPaste(view, text4, html2, preferPlain, event) { 19567 - let slice = parseFromClipboard(view, text4, html2, preferPlain, view.state.selection.$from); 19568 - if (view.someProp("handlePaste", (f) => f(view, event, slice || Slice2.empty))) 19567 + let slice2 = parseFromClipboard(view, text4, html2, preferPlain, view.state.selection.$from); 19568 + if (view.someProp("handlePaste", (f) => f(view, event, slice2 || Slice2.empty))) 19569 19569 return true; 19570 - if (!slice) 19570 + if (!slice2) 19571 19571 return false; 19572 - let singleNode = sliceSingleNode(slice); 19573 - let tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, preferPlain) : view.state.tr.replaceSelection(slice); 19572 + let singleNode = sliceSingleNode(slice2); 19573 + let tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, preferPlain) : view.state.tr.replaceSelection(slice2); 19574 19574 view.dispatch(tr.scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste")); 19575 19575 return true; 19576 19576 } ··· 19593 19593 capturePaste(view, event); 19594 19594 }; 19595 19595 var Dragging = class { 19596 - constructor(slice, move, node2) { 19597 - this.slice = slice; 19596 + constructor(slice2, move, node2) { 19597 + this.slice = slice2; 19598 19598 this.move = move; 19599 19599 this.node = node2; 19600 19600 } ··· 19623 19623 node2 = NodeSelection.create(view.state.doc, desc.posBefore); 19624 19624 } 19625 19625 let draggedSlice = (node2 || view.state.selection).content(); 19626 - let { dom, text: text4, slice } = serializeForClipboard(view, draggedSlice); 19626 + let { dom, text: text4, slice: slice2 } = serializeForClipboard(view, draggedSlice); 19627 19627 if (!event.dataTransfer.files.length || !chrome || chrome_version2 > 120) 19628 19628 event.dataTransfer.clearData(); 19629 19629 event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML); 19630 19630 event.dataTransfer.effectAllowed = "copyMove"; 19631 19631 if (!brokenClipboardAPI) 19632 19632 event.dataTransfer.setData("text/plain", text4); 19633 - view.dragging = new Dragging(slice, dragMoves(view, event), node2); 19633 + view.dragging = new Dragging(slice2, dragMoves(view, event), node2); 19634 19634 }; 19635 19635 handlers.dragend = (view) => { 19636 19636 let dragging = view.dragging; ··· 19654 19654 if (!eventPos) 19655 19655 return; 19656 19656 let $mouse = view.state.doc.resolve(eventPos.pos); 19657 - let slice = dragging && dragging.slice; 19658 - if (slice) { 19657 + let slice2 = dragging && dragging.slice; 19658 + if (slice2) { 19659 19659 view.someProp("transformPasted", (f) => { 19660 - slice = f(slice, view, false); 19660 + slice2 = f(slice2, view, false); 19661 19661 }); 19662 19662 } else { 19663 - slice = parseFromClipboard(view, getText(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData("text/html"), false, $mouse); 19663 + slice2 = parseFromClipboard(view, getText(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData("text/html"), false, $mouse); 19664 19664 } 19665 19665 let move = !!(dragging && dragMoves(view, event)); 19666 - if (view.someProp("handleDrop", (f) => f(view, event, slice || Slice2.empty, move))) { 19666 + if (view.someProp("handleDrop", (f) => f(view, event, slice2 || Slice2.empty, move))) { 19667 19667 event.preventDefault(); 19668 19668 return; 19669 19669 } 19670 - if (!slice) 19670 + if (!slice2) 19671 19671 return; 19672 19672 event.preventDefault(); 19673 - let insertPos = slice ? dropPoint(view.state.doc, $mouse.pos, slice) : $mouse.pos; 19673 + let insertPos = slice2 ? dropPoint(view.state.doc, $mouse.pos, slice2) : $mouse.pos; 19674 19674 if (insertPos == null) 19675 19675 insertPos = $mouse.pos; 19676 19676 let tr = view.state.tr; ··· 19682 19682 tr.deleteSelection(); 19683 19683 } 19684 19684 let pos = tr.mapping.map(insertPos); 19685 - let isNode2 = slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1; 19685 + let isNode2 = slice2.openStart == 0 && slice2.openEnd == 0 && slice2.content.childCount == 1; 19686 19686 let beforeInsert = tr.doc; 19687 19687 if (isNode2) 19688 - tr.replaceRangeWith(pos, pos, slice.content.firstChild); 19688 + tr.replaceRangeWith(pos, pos, slice2.content.firstChild); 19689 19689 else 19690 - tr.replaceRange(pos, pos, slice); 19690 + tr.replaceRange(pos, pos, slice2); 19691 19691 if (tr.doc.eq(beforeInsert)) 19692 19692 return; 19693 19693 let $pos = tr.doc.resolve(pos); 19694 - if (isNode2 && NodeSelection.isSelectable(slice.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild)) { 19694 + if (isNode2 && NodeSelection.isSelectable(slice2.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice2.content.firstChild)) { 19695 19695 tr.setSelection(new NodeSelection($pos)); 19696 19696 } else { 19697 19697 let end = tr.mapping.map(insertPos); ··· 19783 19783 this.spec = spec || noSpec; 19784 19784 } 19785 19785 map(mapping, span, offset3, oldOffset) { 19786 - let from = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset3; 19786 + let from2 = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset3; 19787 19787 let to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset3; 19788 - return from >= to ? null : new Decoration(from, to, this); 19788 + return from2 >= to ? null : new Decoration(from2, to, this); 19789 19789 } 19790 19790 valid(_, span) { 19791 19791 return span.from < span.to; ··· 19805 19805 this.spec = spec || noSpec; 19806 19806 } 19807 19807 map(mapping, span, offset3, oldOffset) { 19808 - let from = mapping.mapResult(span.from + oldOffset, 1); 19809 - if (from.deleted) 19808 + let from2 = mapping.mapResult(span.from + oldOffset, 1); 19809 + if (from2.deleted) 19810 19810 return null; 19811 19811 let to = mapping.mapResult(span.to + oldOffset, -1); 19812 - if (to.deleted || to.pos <= from.pos) 19812 + if (to.deleted || to.pos <= from2.pos) 19813 19813 return null; 19814 - return new Decoration(from.pos - offset3, to.pos - offset3, this); 19814 + return new Decoration(from2.pos - offset3, to.pos - offset3, this); 19815 19815 } 19816 19816 valid(node2, span) { 19817 19817 let { index: index2, offset: offset3 } = node2.content.findIndex(span.from), child; ··· 19827 19827 /** 19828 19828 @internal 19829 19829 */ 19830 - constructor(from, to, type) { 19831 - this.from = from; 19830 + constructor(from2, to, type) { 19831 + this.from = from2; 19832 19832 this.to = to; 19833 19833 this.type = type; 19834 19834 } 19835 19835 /** 19836 19836 @internal 19837 19837 */ 19838 - copy(from, to) { 19839 - return new _Decoration(from, to, this.type); 19838 + copy(from2, to) { 19839 + return new _Decoration(from2, to, this.type); 19840 19840 } 19841 19841 /** 19842 19842 @internal ··· 19865 19865 Creates an inline decoration, which adds the given attributes to 19866 19866 each inline node between `from` and `to`. 19867 19867 */ 19868 - static inline(from, to, attrs, spec) { 19869 - return new _Decoration(from, to, new InlineType(attrs, spec)); 19868 + static inline(from2, to, attrs, spec) { 19869 + return new _Decoration(from2, to, new InlineType(attrs, spec)); 19870 19870 } 19871 19871 /** 19872 19872 Creates a node decoration. `from` and `to` should point precisely 19873 19873 before and after a node in the document. That node, and only that 19874 19874 node, will receive the given attributes. 19875 19875 */ 19876 - static node(from, to, attrs, spec) { 19877 - return new _Decoration(from, to, new NodeType2(attrs, spec)); 19876 + static node(from2, to, attrs, spec) { 19877 + return new _Decoration(from2, to, new NodeType2(attrs, spec)); 19878 19878 } 19879 19879 /** 19880 19880 The spec provided when creating this decoration. Can be useful ··· 20014 20014 let children = this.children, local = this.local; 20015 20015 for (let i = 0; i < children.length; i += 3) { 20016 20016 let found2; 20017 - let from = children[i] + offset3, to = children[i + 1] + offset3; 20017 + let from2 = children[i] + offset3, to = children[i + 1] + offset3; 20018 20018 for (let j = 0, span; j < decorations.length; j++) 20019 20019 if (span = decorations[j]) { 20020 - if (span.from > from && span.to < to) { 20020 + if (span.from > from2 && span.to < to) { 20021 20021 decorations[j] = null; 20022 20022 (found2 || (found2 = [])).push(span); 20023 20023 } ··· 20026 20026 continue; 20027 20027 if (children == this.children) 20028 20028 children = this.children.slice(); 20029 - let removed = children[i + 2].removeInner(found2, from + 1); 20029 + let removed = children[i + 2].removeInner(found2, from2 + 1); 20030 20030 if (removed != empty2) { 20031 20031 children[i + 2] = removed; 20032 20032 } else { ··· 20065 20065 for (let i = 0; i < this.local.length; i++) { 20066 20066 let dec = this.local[i]; 20067 20067 if (dec.from < end && dec.to > start && dec.type instanceof InlineType) { 20068 - let from = Math.max(start, dec.from) - start, to = Math.min(end, dec.to) - start; 20069 - if (from < to) 20070 - (local || (local = [])).push(dec.copy(from, to)); 20068 + let from2 = Math.max(start, dec.from) - start, to = Math.min(end, dec.to) - start; 20069 + if (from2 < to) 20070 + (local || (local = [])).push(dec.copy(from2, to)); 20071 20071 } 20072 20072 } 20073 20073 if (local) { ··· 20217 20217 children[i + 1] = -1; 20218 20218 continue; 20219 20219 } 20220 - let from = mapping.map(oldChildren[i] + oldOffset), fromLocal = from - offset3; 20220 + let from2 = mapping.map(oldChildren[i] + oldOffset), fromLocal = from2 - offset3; 20221 20221 if (fromLocal < 0 || fromLocal >= node2.content.size) { 20222 20222 mustRebuild = true; 20223 20223 continue; ··· 20226 20226 let { index: index2, offset: childOffset } = node2.content.findIndex(fromLocal); 20227 20227 let childNode = node2.maybeChild(index2); 20228 20228 if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) { 20229 - let mapped = children[i + 2].mapInner(mapping, childNode, from + 1, oldChildren[i] + oldOffset + 1, options); 20229 + let mapped = children[i + 2].mapInner(mapping, childNode, from2 + 1, oldChildren[i] + oldOffset + 1, options); 20230 20230 if (mapped != empty2) { 20231 20231 children[i] = fromLocal; 20232 20232 children[i + 1] = toLocal; ··· 20249 20249 i -= 3; 20250 20250 } 20251 20251 for (let i = 0, j = 0; i < built.children.length; i += 3) { 20252 - let from = built.children[i]; 20253 - while (j < children.length && children[j] < from) 20252 + let from2 = built.children[i]; 20253 + while (j < children.length && children[j] < from2) 20254 20254 j += 3; 20255 20255 children.splice(j, 0, built.children[i], built.children[i + 1], built.children[i + 2]); 20256 20256 } ··· 20527 20527 this.queue = []; 20528 20528 let sel = view.domSelectionRange(); 20529 20529 let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(view) && !this.ignoreSelectionChange(sel); 20530 - let from = -1, to = -1, typeOver = false, added = []; 20530 + let from2 = -1, to = -1, typeOver = false, added = []; 20531 20531 if (view.editable) { 20532 20532 for (let i = 0; i < mutations.length; i++) { 20533 20533 let result = this.registerMutation(mutations[i], added); 20534 20534 if (result) { 20535 - from = from < 0 ? result.from : Math.min(result.from, from); 20535 + from2 = from2 < 0 ? result.from : Math.min(result.from, from2); 20536 20536 to = to < 0 ? result.to : Math.max(result.to, to); 20537 20537 if (result.typeOver) 20538 20538 typeOver = true; ··· 20564 20564 } 20565 20565 } 20566 20566 let readSel = null; 20567 - if (from < 0 && newSel && view.input.lastFocus > Date.now() - 200 && Math.max(view.input.lastTouch, view.input.lastClick.time) < Date.now() - 300 && selectionCollapsed(sel) && (readSel = selectionFromDOM(view)) && readSel.eq(Selection.near(view.state.doc.resolve(0), 1))) { 20567 + if (from2 < 0 && newSel && view.input.lastFocus > Date.now() - 200 && Math.max(view.input.lastTouch, view.input.lastClick.time) < Date.now() - 300 && selectionCollapsed(sel) && (readSel = selectionFromDOM(view)) && readSel.eq(Selection.near(view.state.doc.resolve(0), 1))) { 20568 20568 view.input.lastFocus = 0; 20569 20569 selectionToDOM(view); 20570 20570 this.currentSelection.set(sel); 20571 20571 view.scrollToSelection(); 20572 - } else if (from > -1 || newSel) { 20573 - if (from > -1) { 20574 - view.docView.markDirty(from, to); 20572 + } else if (from2 > -1 || newSel) { 20573 + if (from2 > -1) { 20574 + view.docView.markDirty(from2, to); 20575 20575 checkCSS(view); 20576 20576 } 20577 20577 if (view.input.badSafariComposition) { 20578 20578 view.input.badSafariComposition = false; 20579 20579 fixUpBadSafariComposition(view, added); 20580 20580 } 20581 - this.handleDOMChange(from, to, typeOver, added); 20581 + this.handleDOMChange(from2, to, typeOver, added); 20582 20582 if (view.docView && view.docView.dirty) 20583 20583 view.updateState(view.state); 20584 20584 else if (!this.currentSelection.eq(sel)) ··· 20615 20615 } 20616 20616 } 20617 20617 let fromOffset = prev && prev.parentNode == mut.target ? domIndex(prev) + 1 : 0; 20618 - let from = desc.localPosFromDOM(mut.target, fromOffset, -1); 20618 + let from2 = desc.localPosFromDOM(mut.target, fromOffset, -1); 20619 20619 let toOffset = next && next.parentNode == mut.target ? domIndex(next) : mut.target.childNodes.length; 20620 20620 let to = desc.localPosFromDOM(mut.target, toOffset, 1); 20621 - return { from, to }; 20621 + return { from: from2, to }; 20622 20622 } else if (mut.type == "attributes") { 20623 20623 return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border }; 20624 20624 } else { ··· 20708 20708 } 20709 20709 } 20710 20710 function parseBetween(view, from_, to_) { 20711 - let { node: parent, fromOffset, toOffset, from, to } = view.docView.parseRange(from_, to_); 20711 + let { node: parent, fromOffset, toOffset, from: from2, to } = view.docView.parseRange(from_, to_); 20712 20712 let domSel = view.domSelectionRange(); 20713 20713 let find; 20714 20714 let anchor = domSel.anchorNode; ··· 20730 20730 } 20731 20731 let startDoc = view.state.doc; 20732 20732 let parser2 = view.someProp("domParser") || DOMParser.fromSchema(view.state.schema); 20733 - let $from = startDoc.resolve(from); 20733 + let $from = startDoc.resolve(from2); 20734 20734 let sel = null, doc4 = parser2.parse(parent, { 20735 20735 topNode: $from.parent, 20736 20736 topMatch: $from.parent.contentMatchAt($from.index()), ··· 20746 20746 let anchor2 = find[0].pos, head = find[1] && find[1].pos; 20747 20747 if (head == null) 20748 20748 head = anchor2; 20749 - sel = { anchor: anchor2 + from, head: head + from }; 20749 + sel = { anchor: anchor2 + from2, head: head + from2 }; 20750 20750 } 20751 - return { doc: doc4, sel, from, to }; 20751 + return { doc: doc4, sel, from: from2, to }; 20752 20752 } 20753 20753 function ruleFromNode(dom) { 20754 20754 let desc = dom.pmViewDesc; ··· 20768 20768 return null; 20769 20769 } 20770 20770 var isInline = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i; 20771 - function readDOMChange(view, from, to, typeOver, addedNodes) { 20771 + function readDOMChange(view, from2, to, typeOver, addedNodes) { 20772 20772 let compositionID = view.input.compositionPendingChanges || (view.composing ? view.input.compositionID : 0); 20773 20773 view.input.compositionPendingChanges = 0; 20774 - if (from < 0) { 20774 + if (from2 < 0) { 20775 20775 let origin = view.input.lastSelectionTime > Date.now() - 50 ? view.input.lastSelectionOrigin : null; 20776 20776 let newSel = selectionFromDOM(view, origin); 20777 20777 if (newSel && !view.state.selection.eq(newSel)) { ··· 20788 20788 } 20789 20789 return; 20790 20790 } 20791 - let $before = view.state.doc.resolve(from); 20791 + let $before = view.state.doc.resolve(from2); 20792 20792 let shared = $before.sharedDepth(to); 20793 - from = $before.before(shared + 1); 20793 + from2 = $before.before(shared + 1); 20794 20794 to = view.state.doc.resolve(to).after(shared + 1); 20795 20795 let sel = view.state.selection; 20796 - let parse2 = parseBetween(view, from, to); 20796 + let parse2 = parseBetween(view, from2, to); 20797 20797 let doc4 = view.state.doc, compare = doc4.slice(parse2.from, parse2.to); 20798 20798 let preferredPos, preferredSide; 20799 20799 if (view.input.lastKeyCode === 8 && Date.now() - 100 < view.input.lastKeyCodeTime) { ··· 21045 21045 updateCursorWrapper(this); 21046 21046 this.nodeViews = buildNodeViews(this); 21047 21047 this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this); 21048 - this.domObserver = new DOMObserver(this, (from, to, typeOver, added) => readDOMChange(this, from, to, typeOver, added)); 21048 + this.domObserver = new DOMObserver(this, (from2, to, typeOver, added) => readDOMChange(this, from2, to, typeOver, added)); 21049 21049 this.domObserver.start(); 21050 21050 initInput(this); 21051 21051 this.updatePluginViews(); ··· 21393 21393 different from the given input due to hooks like 21394 21394 [`transformCopied`](https://prosemirror.net/docs/ref/#view.EditorProps.transformCopied)). 21395 21395 */ 21396 - serializeForClipboard(slice) { 21397 - return serializeForClipboard(this, slice); 21396 + serializeForClipboard(slice2) { 21397 + return serializeForClipboard(this, slice2); 21398 21398 } 21399 21399 /** 21400 21400 Removes the editor from the DOM and destroys all [node ··· 21683 21683 if (this.#ctx == null) throw callCommandBeforeEditorView(); 21684 21684 const ctx = this.#ctx; 21685 21685 const commands22 = []; 21686 - const get = this.get.bind(this); 21686 + const get2 = this.get.bind(this); 21687 21687 const chains = { 21688 21688 run: () => { 21689 21689 const chained = chainCommands(...commands22); ··· 21696 21696 }, 21697 21697 pipe: pipe.bind(this) 21698 21698 }; 21699 - function pipe(slice, payload) { 21700 - const cmd = get(slice); 21699 + function pipe(slice2, payload) { 21700 + const cmd = get2(slice2); 21701 21701 commands22.push(cmd(payload)); 21702 21702 return chains; 21703 21703 } ··· 21711 21711 } 21712 21712 /// Register a command into the manager. 21713 21713 create(meta, value) { 21714 - const slice = meta.create(this.#container.sliceMap); 21715 - slice.set(value); 21716 - return slice; 21714 + const slice2 = meta.create(this.#container.sliceMap); 21715 + slice2.set(value); 21716 + return slice2; 21717 21717 } 21718 - get(slice) { 21719 - return this.#container.get(slice).get(); 21718 + get(slice2) { 21719 + return this.#container.get(slice2).get(); 21720 21720 } 21721 - remove(slice) { 21722 - return this.#container.remove(slice); 21721 + remove(slice2) { 21722 + return this.#container.remove(slice2); 21723 21723 } 21724 - call(slice, payload) { 21724 + call(slice2, payload) { 21725 21725 if (this.#ctx == null) throw callCommandBeforeEditorView(); 21726 - const cmd = this.get(slice); 21726 + const cmd = this.get(slice2); 21727 21727 const command = cmd(payload); 21728 21728 const view = this.#ctx.get(editorViewCtx); 21729 21729 return command(view.state, view.dispatch, view); ··· 22056 22056 state, 22057 22057 nodeViews, 22058 22058 markViews, 22059 - transformPasted: (slice, view2, isPlainText) => { 22059 + transformPasted: (slice2, view2, isPlainText) => { 22060 22060 ctx.get(pasteRulesCtx).sort((a, b) => (b.priority ?? 50) - (a.priority ?? 50)).map((rule) => rule.run).forEach((runner) => { 22061 - slice = runner(slice, view2, isPlainText); 22061 + slice2 = runner(slice2, view2, isPlainText); 22062 22062 }); 22063 - return slice; 22063 + return slice2; 22064 22064 }, 22065 22065 ...options 22066 22066 }); ··· 22396 22396 return plugin; 22397 22397 } 22398 22398 function $ctx(value, name) { 22399 - const slice = createSlice(value, name); 22399 + const slice2 = createSlice(value, name); 22400 22400 const plugin = (ctx) => { 22401 - ctx.inject(slice); 22401 + ctx.inject(slice2); 22402 22402 return () => { 22403 22403 return () => { 22404 - ctx.remove(slice); 22404 + ctx.remove(slice2); 22405 22405 }; 22406 22406 }; 22407 22407 }; 22408 - plugin.key = slice; 22408 + plugin.key = slice2; 22409 22409 return plugin; 22410 22410 } 22411 22411 function $nodeSchema(id, schema3) { ··· 22503 22503 result.options = options; 22504 22504 return result; 22505 22505 } 22506 - function callCommand(slice, payload) { 22506 + function callCommand(slice2, payload) { 22507 22507 return (ctx) => { 22508 - return ctx.get(commandsCtx).call(slice, payload); 22508 + return ctx.get(commandsCtx).call(slice2, payload); 22509 22509 }; 22510 22510 } 22511 22511 ··· 22616 22616 if (dispatch) { 22617 22617 let nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type; 22618 22618 let inner = Fragment.from(nestedBefore ? itemType.create() : null); 22619 - let slice = new Slice2(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0); 22619 + let slice2 = new Slice2(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0); 22620 22620 let before = range.start, after = range.end; 22621 - dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView()); 22621 + dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView()); 22622 22622 } 22623 22623 return true; 22624 22624 }; ··· 22918 22918 (ctx) => () => (state, dispatch) => { 22919 22919 const { selection, tr } = state; 22920 22920 if (selection.empty) return false; 22921 - const { from, to } = selection; 22922 - const has = state.doc.rangeHasMark(from, to, inlineCodeSchema.type(ctx)); 22921 + const { from: from2, to } = selection; 22922 + const has = state.doc.rangeHasMark(from2, to, inlineCodeSchema.type(ctx)); 22923 22923 if (has) { 22924 - dispatch?.(tr.removeMark(from, to, inlineCodeSchema.type(ctx))); 22924 + dispatch?.(tr.removeMark(from2, to, inlineCodeSchema.type(ctx))); 22925 22925 return true; 22926 22926 } 22927 22927 const restMarksName = Object.keys(state.schema.marks).filter( 22928 22928 (x) => x !== inlineCodeSchema.type.name 22929 22929 ); 22930 22930 restMarksName.map((name) => state.schema.marks[name]).forEach((t) => { 22931 - tr.removeMark(from, to, t); 22931 + tr.removeMark(from2, to, t); 22932 22932 }); 22933 - dispatch?.(tr.addMark(from, to, inlineCodeSchema.type(ctx).create())); 22933 + dispatch?.(tr.addMark(from2, to, inlineCodeSchema.type(ctx).create())); 22934 22934 return true; 22935 22935 } 22936 22936 ); ··· 23024 23024 let node2; 23025 23025 let pos = -1; 23026 23026 const { selection } = state; 23027 - const { from, to } = selection; 23028 - state.doc.nodesBetween(from, from === to ? to + 1 : to, (n, p) => { 23027 + const { from: from2, to } = selection; 23028 + state.doc.nodesBetween(from2, from2 === to ? to + 1 : to, (n, p) => { 23029 23029 if (linkSchema.type(ctx).isInSet(n.marks)) { 23030 23030 node2 = n; 23031 23031 pos = p; ··· 23837 23837 if (!dispatch) return true; 23838 23838 const paragraph2 = paragraphSchema.node.type(ctx).create(); 23839 23839 const { tr, selection } = state; 23840 - const { from } = selection; 23840 + const { from: from2 } = selection; 23841 23841 const node2 = hrSchema.type(ctx).create(); 23842 23842 if (!node2) return true; 23843 - const _tr = tr.replaceSelectionWith(node2).insert(from, paragraph2); 23844 - const sel = Selection.findFrom(_tr.doc.resolve(from), 1, true); 23843 + const _tr = tr.replaceSelectionWith(node2).insert(from2, paragraph2); 23844 + const sel = Selection.findFrom(_tr.doc.resolve(from2), 1, true); 23845 23845 if (!sel) return true; 23846 23846 dispatch(_tr.setSelection(sel).scrollIntoView()); 23847 23847 return true; ··· 24354 24354 () => () => (state, dispatch) => { 24355 24355 let tr = state.tr; 24356 24356 const { $from, $to } = tr.selection; 24357 - const { pos: from } = $from; 24357 + const { pos: from2 } = $from; 24358 24358 const { pos: right } = $to; 24359 - const left = from - $from.node().content.size; 24359 + const left = from2 - $from.node().content.size; 24360 24360 if (left < 0) return false; 24361 24361 tr = tr.deleteRange(left, right); 24362 24362 dispatch?.(tr); ··· 24369 24369 const { nodeType, attrs = null } = payload ?? {}; 24370 24370 if (!nodeType) return false; 24371 24371 const tr = state.tr; 24372 - const { from, to } = tr.selection; 24372 + const { from: from2, to } = tr.selection; 24373 24373 try { 24374 - tr.setBlockType(from, to, nodeType, attrs); 24374 + tr.setBlockType(from2, to, nodeType, attrs); 24375 24375 } catch { 24376 24376 return false; 24377 24377 } ··· 24648 24648 requestAnimationFrame(() => { 24649 24649 const active = inlineNodesCursorPlugin2.getState(view.state); 24650 24650 if (active) { 24651 - const from = view.state.selection.from; 24651 + const from2 = view.state.selection.from; 24652 24652 e.preventDefault(); 24653 - view.dispatch(view.state.tr.insertText(e.data || "", from)); 24653 + view.dispatch(view.state.tr.insertText(e.data || "", from2)); 24654 24654 } 24655 24655 }); 24656 24656 return true; ··· 24665 24665 beforeinput: (view, e) => { 24666 24666 const active = inlineNodesCursorPlugin2.getState(view.state); 24667 24667 if (active && e instanceof InputEvent && e.data && !lock) { 24668 - const from = view.state.selection.from; 24668 + const from2 = view.state.selection.from; 24669 24669 e.preventDefault(); 24670 - view.dispatch(view.state.tr.insertText(e.data || "", from)); 24670 + view.dispatch(view.state.tr.insertText(e.data || "", from2)); 24671 24671 return true; 24672 24672 } 24673 24673 return false; ··· 24711 24711 const isInsertHr = tr.getMeta("hardbreak"); 24712 24712 if (isInsertHr) { 24713 24713 if (!(step instanceof ReplaceStep)) return; 24714 - const { from } = step; 24714 + const { from: from2 } = step; 24715 24715 return newState.tr.setNodeMarkup( 24716 - from, 24716 + from2, 24717 24717 hardbreakSchema.type(ctx), 24718 24718 void 0, 24719 24719 [] ··· 24722 24722 const isAddMarkStep = step instanceof AddMarkStep; 24723 24723 if (isAddMarkStep) { 24724 24724 let _tr = newState.tr; 24725 - const { from, to } = step; 24726 - newState.doc.nodesBetween(from, to, (node2, pos) => { 24725 + const { from: from2, to } = step; 24726 + newState.doc.nodesBetween(from2, to, (node2, pos) => { 24727 24727 if (node2.type === hardbreakSchema.type(ctx)) 24728 24728 _tr = _tr.setNodeMarkup( 24729 24729 pos, ··· 24758 24758 const isInsertHr = tr.getMeta("hardbreak"); 24759 24759 const [step] = tr.steps; 24760 24760 if (isInsertHr && step) { 24761 - const { from } = step; 24762 - const $from = state.doc.resolve(from); 24761 + const { from: from2 } = step; 24762 + const $from = state.doc.resolve(from2); 24763 24763 let curDepth = $from.depth; 24764 24764 let canApply = true; 24765 24765 while (curDepth > 0) { ··· 26673 26673 const { state, composing } = view; 26674 26674 const { selection, doc: doc4 } = state; 26675 26675 const { ranges } = selection; 26676 - const from = Math.min(...ranges.map((range) => range.$from.pos)); 26676 + const from2 = Math.min(...ranges.map((range) => range.$from.pos)); 26677 26677 const to = Math.max(...ranges.map((range) => range.$to.pos)); 26678 26678 const isSame = prevState && prevState.doc.eq(doc4) && prevState.selection.eq(selection); 26679 26679 if (!this.#initialized) { ··· 26689 26689 return; 26690 26690 } 26691 26691 const virtualEl = { 26692 - getBoundingClientRect: () => posToDOMRect(view, from, to), 26692 + getBoundingClientRect: () => posToDOMRect(view, from2, to), 26693 26693 contextElement: view.dom 26694 26694 }; 26695 26695 if (this.#shouldAutoUpdate(view)) { ··· 26769 26769 /// @internal 26770 26770 #_shouldShow(view) { 26771 26771 const { doc: doc4, selection } = view.state; 26772 - const { empty: empty3, from, to } = selection; 26773 - const isEmptyTextBlock = !doc4.textBetween(from, to).length && view.state.selection instanceof TextSelection; 26772 + const { empty: empty3, from: from2, to } = selection; 26773 + const isEmptyTextBlock = !doc4.textBetween(from2, to).length && view.state.selection instanceof TextSelection; 26774 26774 const isTooltipChildren = this.element.contains(document.activeElement); 26775 26775 const notHasFocus = !view.hasFocus() && !isTooltipChildren; 26776 26776 const isReadonly = !view.editable; ··· 26803 26803 }; 26804 26804 return result; 26805 26805 } 26806 + 26807 + // node_modules/rope-sequence/dist/index.js 26808 + var GOOD_LEAF_SIZE = 200; 26809 + var RopeSequence = function RopeSequence2() { 26810 + }; 26811 + RopeSequence.prototype.append = function append(other) { 26812 + if (!other.length) { 26813 + return this; 26814 + } 26815 + other = RopeSequence.from(other); 26816 + return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other); 26817 + }; 26818 + RopeSequence.prototype.prepend = function prepend(other) { 26819 + if (!other.length) { 26820 + return this; 26821 + } 26822 + return RopeSequence.from(other).append(this); 26823 + }; 26824 + RopeSequence.prototype.appendInner = function appendInner(other) { 26825 + return new Append(this, other); 26826 + }; 26827 + RopeSequence.prototype.slice = function slice(from2, to) { 26828 + if (from2 === void 0) from2 = 0; 26829 + if (to === void 0) to = this.length; 26830 + if (from2 >= to) { 26831 + return RopeSequence.empty; 26832 + } 26833 + return this.sliceInner(Math.max(0, from2), Math.min(this.length, to)); 26834 + }; 26835 + RopeSequence.prototype.get = function get(i) { 26836 + if (i < 0 || i >= this.length) { 26837 + return void 0; 26838 + } 26839 + return this.getInner(i); 26840 + }; 26841 + RopeSequence.prototype.forEach = function forEach(f, from2, to) { 26842 + if (from2 === void 0) from2 = 0; 26843 + if (to === void 0) to = this.length; 26844 + if (from2 <= to) { 26845 + this.forEachInner(f, from2, to, 0); 26846 + } else { 26847 + this.forEachInvertedInner(f, from2, to, 0); 26848 + } 26849 + }; 26850 + RopeSequence.prototype.map = function map4(f, from2, to) { 26851 + if (from2 === void 0) from2 = 0; 26852 + if (to === void 0) to = this.length; 26853 + var result = []; 26854 + this.forEach(function(elt, i) { 26855 + return result.push(f(elt, i)); 26856 + }, from2, to); 26857 + return result; 26858 + }; 26859 + RopeSequence.from = function from(values) { 26860 + if (values instanceof RopeSequence) { 26861 + return values; 26862 + } 26863 + return values && values.length ? new Leaf(values) : RopeSequence.empty; 26864 + }; 26865 + var Leaf = /* @__PURE__ */ (function(RopeSequence3) { 26866 + function Leaf2(values) { 26867 + RopeSequence3.call(this); 26868 + this.values = values; 26869 + } 26870 + if (RopeSequence3) Leaf2.__proto__ = RopeSequence3; 26871 + Leaf2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype); 26872 + Leaf2.prototype.constructor = Leaf2; 26873 + var prototypeAccessors = { length: { configurable: true }, depth: { configurable: true } }; 26874 + Leaf2.prototype.flatten = function flatten() { 26875 + return this.values; 26876 + }; 26877 + Leaf2.prototype.sliceInner = function sliceInner(from2, to) { 26878 + if (from2 == 0 && to == this.length) { 26879 + return this; 26880 + } 26881 + return new Leaf2(this.values.slice(from2, to)); 26882 + }; 26883 + Leaf2.prototype.getInner = function getInner(i) { 26884 + return this.values[i]; 26885 + }; 26886 + Leaf2.prototype.forEachInner = function forEachInner(f, from2, to, start) { 26887 + for (var i = from2; i < to; i++) { 26888 + if (f(this.values[i], start + i) === false) { 26889 + return false; 26890 + } 26891 + } 26892 + }; 26893 + Leaf2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) { 26894 + for (var i = from2 - 1; i >= to; i--) { 26895 + if (f(this.values[i], start + i) === false) { 26896 + return false; 26897 + } 26898 + } 26899 + }; 26900 + Leaf2.prototype.leafAppend = function leafAppend(other) { 26901 + if (this.length + other.length <= GOOD_LEAF_SIZE) { 26902 + return new Leaf2(this.values.concat(other.flatten())); 26903 + } 26904 + }; 26905 + Leaf2.prototype.leafPrepend = function leafPrepend(other) { 26906 + if (this.length + other.length <= GOOD_LEAF_SIZE) { 26907 + return new Leaf2(other.flatten().concat(this.values)); 26908 + } 26909 + }; 26910 + prototypeAccessors.length.get = function() { 26911 + return this.values.length; 26912 + }; 26913 + prototypeAccessors.depth.get = function() { 26914 + return 0; 26915 + }; 26916 + Object.defineProperties(Leaf2.prototype, prototypeAccessors); 26917 + return Leaf2; 26918 + })(RopeSequence); 26919 + RopeSequence.empty = new Leaf([]); 26920 + var Append = /* @__PURE__ */ (function(RopeSequence3) { 26921 + function Append2(left, right) { 26922 + RopeSequence3.call(this); 26923 + this.left = left; 26924 + this.right = right; 26925 + this.length = left.length + right.length; 26926 + this.depth = Math.max(left.depth, right.depth) + 1; 26927 + } 26928 + if (RopeSequence3) Append2.__proto__ = RopeSequence3; 26929 + Append2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype); 26930 + Append2.prototype.constructor = Append2; 26931 + Append2.prototype.flatten = function flatten() { 26932 + return this.left.flatten().concat(this.right.flatten()); 26933 + }; 26934 + Append2.prototype.getInner = function getInner(i) { 26935 + return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length); 26936 + }; 26937 + Append2.prototype.forEachInner = function forEachInner(f, from2, to, start) { 26938 + var leftLen = this.left.length; 26939 + if (from2 < leftLen && this.left.forEachInner(f, from2, Math.min(to, leftLen), start) === false) { 26940 + return false; 26941 + } 26942 + if (to > leftLen && this.right.forEachInner(f, Math.max(from2 - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) { 26943 + return false; 26944 + } 26945 + }; 26946 + Append2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) { 26947 + var leftLen = this.left.length; 26948 + if (from2 > leftLen && this.right.forEachInvertedInner(f, from2 - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) { 26949 + return false; 26950 + } 26951 + if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from2, leftLen), to, start) === false) { 26952 + return false; 26953 + } 26954 + }; 26955 + Append2.prototype.sliceInner = function sliceInner(from2, to) { 26956 + if (from2 == 0 && to == this.length) { 26957 + return this; 26958 + } 26959 + var leftLen = this.left.length; 26960 + if (to <= leftLen) { 26961 + return this.left.slice(from2, to); 26962 + } 26963 + if (from2 >= leftLen) { 26964 + return this.right.slice(from2 - leftLen, to - leftLen); 26965 + } 26966 + return this.left.slice(from2, leftLen).append(this.right.slice(0, to - leftLen)); 26967 + }; 26968 + Append2.prototype.leafAppend = function leafAppend(other) { 26969 + var inner = this.right.leafAppend(other); 26970 + if (inner) { 26971 + return new Append2(this.left, inner); 26972 + } 26973 + }; 26974 + Append2.prototype.leafPrepend = function leafPrepend(other) { 26975 + var inner = this.left.leafPrepend(other); 26976 + if (inner) { 26977 + return new Append2(inner, this.right); 26978 + } 26979 + }; 26980 + Append2.prototype.appendInner = function appendInner2(other) { 26981 + if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) { 26982 + return new Append2(this.left, new Append2(this.right, other)); 26983 + } 26984 + return new Append2(this, other); 26985 + }; 26986 + return Append2; 26987 + })(RopeSequence); 26988 + var dist_default2 = RopeSequence; 26989 + 26990 + // node_modules/prosemirror-history/dist/index.js 26991 + var max_empty_items = 500; 26992 + var Branch = class _Branch { 26993 + constructor(items, eventCount) { 26994 + this.items = items; 26995 + this.eventCount = eventCount; 26996 + } 26997 + // Pop the latest event off the branch's history and apply it 26998 + // to a document transform. 26999 + popEvent(state, preserveItems) { 27000 + if (this.eventCount == 0) 27001 + return null; 27002 + let end = this.items.length; 27003 + for (; ; end--) { 27004 + let next = this.items.get(end - 1); 27005 + if (next.selection) { 27006 + --end; 27007 + break; 27008 + } 27009 + } 27010 + let remap, mapFrom; 27011 + if (preserveItems) { 27012 + remap = this.remapping(end, this.items.length); 27013 + mapFrom = remap.maps.length; 27014 + } 27015 + let transform = state.tr; 27016 + let selection, remaining; 27017 + let addAfter = [], addBefore = []; 27018 + this.items.forEach((item, i) => { 27019 + if (!item.step) { 27020 + if (!remap) { 27021 + remap = this.remapping(end, i + 1); 27022 + mapFrom = remap.maps.length; 27023 + } 27024 + mapFrom--; 27025 + addBefore.push(item); 27026 + return; 27027 + } 27028 + if (remap) { 27029 + addBefore.push(new Item(item.map)); 27030 + let step = item.step.map(remap.slice(mapFrom)), map5; 27031 + if (step && transform.maybeStep(step).doc) { 27032 + map5 = transform.mapping.maps[transform.mapping.maps.length - 1]; 27033 + addAfter.push(new Item(map5, void 0, void 0, addAfter.length + addBefore.length)); 27034 + } 27035 + mapFrom--; 27036 + if (map5) 27037 + remap.appendMap(map5, mapFrom); 27038 + } else { 27039 + transform.maybeStep(item.step); 27040 + } 27041 + if (item.selection) { 27042 + selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection; 27043 + remaining = new _Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1); 27044 + return false; 27045 + } 27046 + }, this.items.length, 0); 27047 + return { remaining, transform, selection }; 27048 + } 27049 + // Create a new branch with the given transform added. 27050 + addTransform(transform, selection, histOptions, preserveItems) { 27051 + let newItems = [], eventCount = this.eventCount; 27052 + let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null; 27053 + for (let i = 0; i < transform.steps.length; i++) { 27054 + let step = transform.steps[i].invert(transform.docs[i]); 27055 + let item = new Item(transform.mapping.maps[i], step, selection), merged; 27056 + if (merged = lastItem && lastItem.merge(item)) { 27057 + item = merged; 27058 + if (i) 27059 + newItems.pop(); 27060 + else 27061 + oldItems = oldItems.slice(0, oldItems.length - 1); 27062 + } 27063 + newItems.push(item); 27064 + if (selection) { 27065 + eventCount++; 27066 + selection = void 0; 27067 + } 27068 + if (!preserveItems) 27069 + lastItem = item; 27070 + } 27071 + let overflow = eventCount - histOptions.depth; 27072 + if (overflow > DEPTH_OVERFLOW) { 27073 + oldItems = cutOffEvents(oldItems, overflow); 27074 + eventCount -= overflow; 27075 + } 27076 + return new _Branch(oldItems.append(newItems), eventCount); 27077 + } 27078 + remapping(from2, to) { 27079 + let maps = new Mapping(); 27080 + this.items.forEach((item, i) => { 27081 + let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from2 ? maps.maps.length - item.mirrorOffset : void 0; 27082 + maps.appendMap(item.map, mirrorPos); 27083 + }, from2, to); 27084 + return maps; 27085 + } 27086 + addMaps(array) { 27087 + if (this.eventCount == 0) 27088 + return this; 27089 + return new _Branch(this.items.append(array.map((map5) => new Item(map5))), this.eventCount); 27090 + } 27091 + // When the collab module receives remote changes, the history has 27092 + // to know about those, so that it can adjust the steps that were 27093 + // rebased on top of the remote changes, and include the position 27094 + // maps for the remote changes in its array of items. 27095 + rebased(rebasedTransform, rebasedCount) { 27096 + if (!this.eventCount) 27097 + return this; 27098 + let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount); 27099 + let mapping = rebasedTransform.mapping; 27100 + let newUntil = rebasedTransform.steps.length; 27101 + let eventCount = this.eventCount; 27102 + this.items.forEach((item) => { 27103 + if (item.selection) 27104 + eventCount--; 27105 + }, start); 27106 + let iRebased = rebasedCount; 27107 + this.items.forEach((item) => { 27108 + let pos = mapping.getMirror(--iRebased); 27109 + if (pos == null) 27110 + return; 27111 + newUntil = Math.min(newUntil, pos); 27112 + let map5 = mapping.maps[pos]; 27113 + if (item.step) { 27114 + let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]); 27115 + let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos)); 27116 + if (selection) 27117 + eventCount++; 27118 + rebasedItems.push(new Item(map5, step, selection)); 27119 + } else { 27120 + rebasedItems.push(new Item(map5)); 27121 + } 27122 + }, start); 27123 + let newMaps = []; 27124 + for (let i = rebasedCount; i < newUntil; i++) 27125 + newMaps.push(new Item(mapping.maps[i])); 27126 + let items = this.items.slice(0, start).append(newMaps).append(rebasedItems); 27127 + let branch = new _Branch(items, eventCount); 27128 + if (branch.emptyItemCount() > max_empty_items) 27129 + branch = branch.compress(this.items.length - rebasedItems.length); 27130 + return branch; 27131 + } 27132 + emptyItemCount() { 27133 + let count = 0; 27134 + this.items.forEach((item) => { 27135 + if (!item.step) 27136 + count++; 27137 + }); 27138 + return count; 27139 + } 27140 + // Compressing a branch means rewriting it to push the air (map-only 27141 + // items) out. During collaboration, these naturally accumulate 27142 + // because each remote change adds one. The `upto` argument is used 27143 + // to ensure that only the items below a given level are compressed, 27144 + // because `rebased` relies on a clean, untouched set of items in 27145 + // order to associate old items with rebased steps. 27146 + compress(upto = this.items.length) { 27147 + let remap = this.remapping(0, upto), mapFrom = remap.maps.length; 27148 + let items = [], events = 0; 27149 + this.items.forEach((item, i) => { 27150 + if (i >= upto) { 27151 + items.push(item); 27152 + if (item.selection) 27153 + events++; 27154 + } else if (item.step) { 27155 + let step = item.step.map(remap.slice(mapFrom)), map5 = step && step.getMap(); 27156 + mapFrom--; 27157 + if (map5) 27158 + remap.appendMap(map5, mapFrom); 27159 + if (step) { 27160 + let selection = item.selection && item.selection.map(remap.slice(mapFrom)); 27161 + if (selection) 27162 + events++; 27163 + let newItem = new Item(map5.invert(), step, selection), merged, last = items.length - 1; 27164 + if (merged = items.length && items[last].merge(newItem)) 27165 + items[last] = merged; 27166 + else 27167 + items.push(newItem); 27168 + } 27169 + } else if (item.map) { 27170 + mapFrom--; 27171 + } 27172 + }, this.items.length, 0); 27173 + return new _Branch(dist_default2.from(items.reverse()), events); 27174 + } 27175 + }; 27176 + Branch.empty = new Branch(dist_default2.empty, 0); 27177 + function cutOffEvents(items, n) { 27178 + let cutPoint; 27179 + items.forEach((item, i) => { 27180 + if (item.selection && n-- == 0) { 27181 + cutPoint = i; 27182 + return false; 27183 + } 27184 + }); 27185 + return items.slice(cutPoint); 27186 + } 27187 + var Item = class _Item { 27188 + constructor(map5, step, selection, mirrorOffset) { 27189 + this.map = map5; 27190 + this.step = step; 27191 + this.selection = selection; 27192 + this.mirrorOffset = mirrorOffset; 27193 + } 27194 + merge(other) { 27195 + if (this.step && other.step && !other.selection) { 27196 + let step = other.step.merge(this.step); 27197 + if (step) 27198 + return new _Item(step.getMap().invert(), step, this.selection); 27199 + } 27200 + } 27201 + }; 27202 + var HistoryState = class { 27203 + constructor(done, undone, prevRanges, prevTime, prevComposition) { 27204 + this.done = done; 27205 + this.undone = undone; 27206 + this.prevRanges = prevRanges; 27207 + this.prevTime = prevTime; 27208 + this.prevComposition = prevComposition; 27209 + } 27210 + }; 27211 + var DEPTH_OVERFLOW = 20; 27212 + function applyTransaction(history3, state, tr, options) { 27213 + let historyTr = tr.getMeta(historyKey), rebased; 27214 + if (historyTr) 27215 + return historyTr.historyState; 27216 + if (tr.getMeta(closeHistoryKey)) 27217 + history3 = new HistoryState(history3.done, history3.undone, null, 0, -1); 27218 + let appended = tr.getMeta("appendedTransaction"); 27219 + if (tr.steps.length == 0) { 27220 + return history3; 27221 + } else if (appended && appended.getMeta(historyKey)) { 27222 + if (appended.getMeta(historyKey).redo) 27223 + return new HistoryState(history3.done.addTransform(tr, void 0, options, mustPreserveItems(state)), history3.undone, rangesFor(tr.mapping.maps), history3.prevTime, history3.prevComposition); 27224 + else 27225 + return new HistoryState(history3.done, history3.undone.addTransform(tr, void 0, options, mustPreserveItems(state)), null, history3.prevTime, history3.prevComposition); 27226 + } else if (tr.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) { 27227 + let composition = tr.getMeta("composition"); 27228 + let newGroup = history3.prevTime == 0 || !appended && history3.prevComposition != composition && (history3.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history3.prevRanges)); 27229 + let prevRanges = appended ? mapRanges(history3.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps); 27230 + return new HistoryState(history3.done.addTransform(tr, newGroup ? state.selection.getBookmark() : void 0, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time, composition == null ? history3.prevComposition : composition); 27231 + } else if (rebased = tr.getMeta("rebased")) { 27232 + return new HistoryState(history3.done.rebased(tr, rebased), history3.undone.rebased(tr, rebased), mapRanges(history3.prevRanges, tr.mapping), history3.prevTime, history3.prevComposition); 27233 + } else { 27234 + return new HistoryState(history3.done.addMaps(tr.mapping.maps), history3.undone.addMaps(tr.mapping.maps), mapRanges(history3.prevRanges, tr.mapping), history3.prevTime, history3.prevComposition); 27235 + } 27236 + } 27237 + function isAdjacentTo(transform, prevRanges) { 27238 + if (!prevRanges) 27239 + return false; 27240 + if (!transform.docChanged) 27241 + return true; 27242 + let adjacent = false; 27243 + transform.mapping.maps[0].forEach((start, end) => { 27244 + for (let i = 0; i < prevRanges.length; i += 2) 27245 + if (start <= prevRanges[i + 1] && end >= prevRanges[i]) 27246 + adjacent = true; 27247 + }); 27248 + return adjacent; 27249 + } 27250 + function rangesFor(maps) { 27251 + let result = []; 27252 + for (let i = maps.length - 1; i >= 0 && result.length == 0; i--) 27253 + maps[i].forEach((_from, _to, from2, to) => result.push(from2, to)); 27254 + return result; 27255 + } 27256 + function mapRanges(ranges, mapping) { 27257 + if (!ranges) 27258 + return null; 27259 + let result = []; 27260 + for (let i = 0; i < ranges.length; i += 2) { 27261 + let from2 = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1); 27262 + if (from2 <= to) 27263 + result.push(from2, to); 27264 + } 27265 + return result; 27266 + } 27267 + function histTransaction(history3, state, redo2) { 27268 + let preserveItems = mustPreserveItems(state); 27269 + let histOptions = historyKey.get(state).spec.config; 27270 + let pop = (redo2 ? history3.undone : history3.done).popEvent(state, preserveItems); 27271 + if (!pop) 27272 + return null; 27273 + let selection = pop.selection.resolve(pop.transform.doc); 27274 + let added = (redo2 ? history3.done : history3.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems); 27275 + let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1); 27276 + return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist }); 27277 + } 27278 + var cachedPreserveItems = false; 27279 + var cachedPreserveItemsPlugins = null; 27280 + function mustPreserveItems(state) { 27281 + let plugins2 = state.plugins; 27282 + if (cachedPreserveItemsPlugins != plugins2) { 27283 + cachedPreserveItems = false; 27284 + cachedPreserveItemsPlugins = plugins2; 27285 + for (let i = 0; i < plugins2.length; i++) 27286 + if (plugins2[i].spec.historyPreserveItems) { 27287 + cachedPreserveItems = true; 27288 + break; 27289 + } 27290 + } 27291 + return cachedPreserveItems; 27292 + } 27293 + var historyKey = new PluginKey("history"); 27294 + var closeHistoryKey = new PluginKey("closeHistory"); 27295 + function history(config2 = {}) { 27296 + config2 = { 27297 + depth: config2.depth || 100, 27298 + newGroupDelay: config2.newGroupDelay || 500 27299 + }; 27300 + return new Plugin({ 27301 + key: historyKey, 27302 + state: { 27303 + init() { 27304 + return new HistoryState(Branch.empty, Branch.empty, null, 0, -1); 27305 + }, 27306 + apply(tr, hist, state) { 27307 + return applyTransaction(hist, state, tr, config2); 27308 + } 27309 + }, 27310 + config: config2, 27311 + props: { 27312 + handleDOMEvents: { 27313 + beforeinput(view, e) { 27314 + let inputType = e.inputType; 27315 + let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null; 27316 + if (!command || !view.editable) 27317 + return false; 27318 + e.preventDefault(); 27319 + return command(view.state, view.dispatch); 27320 + } 27321 + } 27322 + } 27323 + }); 27324 + } 27325 + function buildCommand(redo2, scroll) { 27326 + return (state, dispatch) => { 27327 + let hist = historyKey.getState(state); 27328 + if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0) 27329 + return false; 27330 + if (dispatch) { 27331 + let tr = histTransaction(hist, state, redo2); 27332 + if (tr) 27333 + dispatch(scroll ? tr.scrollIntoView() : tr); 27334 + } 27335 + return true; 27336 + }; 27337 + } 27338 + var undo = buildCommand(false, true); 27339 + var redo = buildCommand(true, true); 27340 + var undoNoScroll = buildCommand(false, false); 27341 + var redoNoScroll = buildCommand(true, false); 27342 + 27343 + // node_modules/@milkdown/plugin-history/lib/index.js 27344 + function withMeta3(plugin, meta) { 27345 + Object.assign(plugin, { 27346 + meta: { 27347 + package: "@milkdown/plugin-history", 27348 + ...meta 27349 + } 27350 + }); 27351 + return plugin; 27352 + } 27353 + var undoCommand = $command("Undo", () => () => undo); 27354 + withMeta3(undoCommand, { 27355 + displayName: "Command<undo>" 27356 + }); 27357 + var redoCommand = $command("Redo", () => () => redo); 27358 + withMeta3(redoCommand, { 27359 + displayName: "Command<redo>" 27360 + }); 27361 + var historyProviderConfig = $ctx({}, "historyProviderConfig"); 27362 + withMeta3(historyProviderConfig, { 27363 + displayName: "Ctx<historyProviderConfig>" 27364 + }); 27365 + var historyProviderPlugin = $prose( 27366 + (ctx) => history(ctx.get(historyProviderConfig.key)) 27367 + ); 27368 + withMeta3(historyProviderPlugin, { 27369 + displayName: "Ctx<historyProviderPlugin>" 27370 + }); 27371 + var historyKeymap = $useKeymap("historyKeymap", { 27372 + Undo: { 27373 + shortcuts: "Mod-z", 27374 + command: (ctx) => { 27375 + const commands3 = ctx.get(commandsCtx); 27376 + return () => commands3.call(undoCommand.key); 27377 + } 27378 + }, 27379 + Redo: { 27380 + shortcuts: ["Mod-y", "Shift-Mod-z"], 27381 + command: (ctx) => { 27382 + const commands3 = ctx.get(commandsCtx); 27383 + return () => commands3.call(redoCommand.key); 27384 + } 27385 + } 27386 + }); 27387 + withMeta3(historyKeymap.ctx, { 27388 + displayName: "KeymapCtx<history>" 27389 + }); 27390 + withMeta3(historyKeymap.shortcuts, { 27391 + displayName: "Keymap<history>" 27392 + }); 27393 + var history2 = [ 27394 + historyProviderConfig, 27395 + historyProviderPlugin, 27396 + historyKeymap, 27397 + undoCommand, 27398 + redoCommand 27399 + ].flat(); 26806 27400 export { 26807 27401 Editor, 26808 27402 TooltipProvider, ··· 26810 27404 commonmark, 26811 27405 defaultValueCtx, 26812 27406 editorViewCtx, 27407 + history2 as history, 26813 27408 listener, 26814 27409 listenerCtx, 27410 + redoCommand, 26815 27411 rootCtx, 26816 27412 serializerCtx, 26817 27413 toggleEmphasisCommand, 26818 27414 toggleStrongCommand, 26819 27415 tooltipFactory, 26820 27416 turnIntoTextCommand, 27417 + undoCommand, 26821 27418 wrapInBlockquoteCommand, 26822 27419 wrapInBulletListCommand, 26823 27420 wrapInHeadingCommand
+16
templates/document_edit.html
··· 16 16 <div class="toolbar-actions"> 17 17 <button class="btn btn-sm btn-outline source-only active" id="btn-preview" onclick="togglePreview()">Preview</button> 18 18 <button class="btn btn-sm btn-outline source-only" id="btn-wrap" onclick="toggleWrap()">Wrap</button> 19 + <button class="btn btn-sm btn-outline rich-only" id="btn-undo" onclick="richUndo()" title="Undo (⌘Z)">↩</button> 20 + <button class="btn btn-sm btn-outline rich-only" id="btn-redo" onclick="richRedo()" title="Redo (⌘⇧Z)">↪</button> 19 21 <button class="btn btn-sm btn-outline" id="btn-source" onclick="toggleSourceMode()">Source</button> 20 22 <span id="save-status"></span> 21 23 <button class="btn btn-sm" id="btn-save" onclick="saveDocument()">Save</button> ··· 55 57 Editor, rootCtx, defaultValueCtx, editorViewCtx, serializerCtx, 56 58 commonmark, 57 59 listener, listenerCtx, 60 + history, undoCommand, redoCommand, callCommand, 58 61 } from '/static/vendor/milkdown.js'; 59 62 60 63 const textarea = document.getElementById('editor-textarea'); ··· 185 188 ctx.set(defaultValueCtx, initialMarkdown); 186 189 }) 187 190 .use(commonmark) 191 + .use(history) 188 192 .use(listener) 189 193 .config((ctx) => { 190 194 ctx.get(listenerCtx).markdownUpdated((_ctx, markdown, prevMarkdown) => { ··· 198 202 return milkdownEditor; 199 203 } 200 204 205 + // ── Undo / Redo ─────────────────────────────────────────────────────────── 206 + 207 + window.richUndo = function() { 208 + if (milkdownEditor) milkdownEditor.action(callCommand(undoCommand.key)); 209 + }; 210 + window.richRedo = function() { 211 + if (milkdownEditor) milkdownEditor.action(callCommand(redoCommand.key)); 212 + }; 213 + 201 214 // ── Mode switching ──────────────────────────────────────────────────────── 202 215 203 216 function applyMode(mode, animate) { 204 217 const richEl = document.getElementById('editor-rich'); 205 218 const sourceEl = document.getElementById('editor-source'); 206 219 const sourceOnlyBtns = document.querySelectorAll('.source-only'); 220 + const richOnlyBtns = document.querySelectorAll('.rich-only'); 207 221 const sourceBtn = document.getElementById('btn-source'); 208 222 209 223 if (mode === 'source') { 210 224 richEl.style.display = 'none'; 211 225 sourceEl.style.display = ''; 212 226 sourceOnlyBtns.forEach(b => b.style.display = ''); 227 + richOnlyBtns.forEach(b => b.style.display = 'none'); 213 228 sourceBtn.classList.add('active'); 214 229 } else { 215 230 richEl.style.display = ''; 216 231 sourceEl.style.display = 'none'; 217 232 sourceOnlyBtns.forEach(b => b.style.display = 'none'); 233 + richOnlyBtns.forEach(b => b.style.display = ''); 218 234 sourceBtn.classList.remove('active'); 219 235 } 220 236 }