vendor: 11,596 bytes, lines 1-287
1import { I as Te, o as Nn, s as it, p as Oo, q as Ql, u as No, r as Eo, t as Zl, h as Ot, v as ea, w as Do, c as jn, m as ta, i as ri, b as na, x as ra, f as ia, __tla as __tla_0 } from "./fullfat_bundler-CIyKZvs_.js"; 2import { o as Ft, E as sr, s as Nt, l as oa, b as sa, B as la, u as aa, a as ca } from "./runtime-UCdpVvNx.js"; 3let z, Fh, Tn, de, Lp, Dr, wn, ni, Yp, Xl, To, _p, qp, Up, Kp, Hp, X, se, Jp, ei, Fp; 4let __tla = Promise.all([ 5 (()=>{ 6 try { 7 return __tla_0; 8 } catch {} 9 })() 10]).then(async ()=>{ 11 const fa = [ 12 "This local copy is still open in another tab. Close that writer before recovering it.", 13 "The local copy changed. Review it again before recovery.", 14 "The recovery request is not saved on this device. Keep this page open and retry.", 15 "Recovery is kept in this browser but could not be saved on this device. Keep this page open.", 16 "This editing session is already open in another tab.", 17 "This report writer is already active in another tab.", 18 "The selected local copy is no longer available. Its saved content has not been changed." 19 ], ua = [ 20 "This editing operation is not available yet. Your existing text has been retained.", 21 "This content needs an editor capability that is not yet available. The original content has been retained." 22 ]; 23 function Ao(n, e, t) { 24 return n instanceof Error && e.includes(n.message) ? n.message : t; 25 } 26 Jp = function(n) { 27 return Ao(n, fa, "Recovery could not be completed. Your original copies are retained. Check your connection and report access, then retry."); 28 }; 29 function da(n) { 30 return Ao(n, ua, "This edit could not be added safely. Your existing text has been retained. Try pasting as plain text or use the reportâs editing controls."); 31 } 32 var ii = Object.defineProperty, ha = (n, e)=>{ 33 let t = {}; 34 for(var r in n)ii(t, r, { 35 get: n[r], 36 enumerable: !0 37 }); 38 return ii(t, Symbol.toStringTag, { 39 value: "Module" 40 }), t; 41 }; 42 function $(n) { 43 this.content = n; 44 } 45 $.prototype = { 46 constructor: $, 47 find: function(n) { 48 for(var e = 0; e < this.content.length; e += 2)if (this.content[e] === n) return e; 49 return -1; 50 }, 51 get: function(n) { 52 var e = this.find(n); 53 return e == -1 ? void 0 : this.content[e + 1]; 54 }, 55 update: function(n, e, t) { 56 var r = t && t != n ? this.remove(t) : this, i = r.find(n), o = r.content.slice(); 57 return i == -1 ? o.push(t || n, e) : (o[i + 1] = e, t && (o[i] = t)), new $(o); 58 }, 59 remove: function(n) { 60 var e = this.find(n); 61 if (e == -1) return this; 62 var t = this.content.slice(); 63 return t.splice(e, 2), new $(t); 64 }, 65 addToStart: function(n, e) { 66 return new $([ 67 n, 68 e 69 ].concat(this.remove(n).content)); 70 }, 71 addToEnd: function(n, e) { 72 var t = this.remove(n).content.slice(); 73 return t.push(n, e), new $(t); 74 }, 75 addBefore: function(n, e, t) { 76 var r = this.remove(e), i = r.content.slice(), o = r.find(n); 77 return i.splice(o == -1 ? i.length : o, 0, e, t), new $(i); 78 }, 79 forEach: function(n) { 80 for(var e = 0; e < this.content.length; e += 2)n(this.content[e], this.content[e + 1]); 81 }, 82 prepend: function(n) { 83 return n = $.from(n), n.size ? new $(n.content.concat(this.subtract(n).content)) : this; 84 }, 85 append: function(n) { 86 return n = $.from(n), n.size ? new $(this.subtract(n).content.concat(n.content)) : this; 87 }, 88 subtract: function(n) { 89 var e = this; 90 n = $.from(n); 91 for(var t = 0; t < n.content.length; t += 2)e = e.remove(n.content[t]); 92 return e; 93 }, 94 toObject: function() { 95 var n = {}; 96 return this.forEach(function(e, t) { 97 n[e] = t; 98 }), n; 99 }, 100 get size () { 101 return this.content.length >> 1; 102 } 103 }; 104 $.from = function(n) { 105 if (n instanceof $) return n; 106 var e = []; 107 if (n) for(var t in n)e.push(t, n[t]); 108 return new $(e); 109 }; 110 function Io(n, e, t) { 111 for(let r = 0;; r++){ 112 if (r == n.childCount || r == e.childCount) return n.childCount == e.childCount ? null : t; 113 let i = n.child(r), o = e.child(r); 114 if (i == o) { 115 t += i.nodeSize; 116 continue; 117 } 118 if (!i.sameMarkup(o)) return t; 119 if (i.isText && i.text != o.text) { 120 let s = i.text, l = o.text, a = 0; 121 for(; s[a] == l[a]; a++)t++; 122 return a && a < s.length && a < l.length && Po(s.charCodeAt(a - 1)) && Bo(s.charCodeAt(a)) && t--, t; 123 } 124 if (i.content.size || o.content.size) { 125 let s = Io(i.content, o.content, t + 1); 126 if (s != null) return s; 127 } 128 t += i.nodeSize; 129 } 130 } 131 function Ro(n, e, t, r) { 132 for(let i = n.childCount, o = e.childCount;;){ 133 if (i == 0 || o == 0) return i == o ? null : { 134 a: t, 135 b: r 136 }; 137 let s = n.child(--i), l = e.child(--o), a = s.nodeSize; 138 if (s == l) { 139 t -= a, r -= a; 140 continue; 141 } 142 if (!s.sameMarkup(l)) return { 143 a: t, 144 b: r 145 }; 146 if (s.isText && s.text != l.text) { 147 let c = s.text, f = l.text, u = c.length, d = f.length; 148 for(; u > 0 && d > 0 && c[u - 1] == f[d - 1];)u--, d--, t--, r--; 149 return u && d && u < c.length && Po(c.charCodeAt(u - 1)) && Bo(c.charCodeAt(u)) && (t++, r++), { 150 a: t, 151 b: r 152 }; 153 } 154 if (s.content.size || l.content.size) { 155 let c = Ro(s.content, l.content, t - 1, r - 1); 156 if (c) return c; 157 } 158 t -= a, r -= a; 159 } 160 } 161 function Bo(n) { 162 return n >= 56320 && n < 57344; 163 } 164 function Po(n) { 165 return n >= 55296 && n < 56320; 166 } 167 class k { 168 constructor(e, t){ 169 if (this.content = e, this.size = t || 0, t == null) for(let r = 0; r < e.length; r++)this.size += e[r].nodeSize; 170 } 171 nodesBetween(e, t, r, i = 0, o) { 172 for(let s = 0, l = 0; l < t; s++){ 173 let a = this.content[s], c = l + a.nodeSize; 174 if (c > e && r(a, i + l, o || null, s) !== !1 && a.content.size) { 175 let f = l + 1; 176 a.nodesBetween(Math.max(0, e - f), Math.min(a.content.size, t - f), r, i + f); 177 } 178 l = c; 179 } 180 } 181 descendants(e) { 182 this.nodesBetween(0, this.size, e); 183 } 184 textBetween(e, t, r, i) { 185 let o = "", s = !0; 186 return this.nodesBetween(e, t, (l, a)=>{ 187 let c = l.isText ? l.text.slice(Math.max(e, a) - a, t - a) : l.isLeaf ? i ? typeof i == "function" ? i(l) : i : l.type.spec.leafText ? l.type.spec.leafText(l) : "" : ""; 188 l.isBlock && (l.isLeaf && c || l.isTextblock) && r && (s ? s = !1 : o += r), o += c; 189 }, 0), o; 190 } 191 append(e) { 192 if (!e.size) return this; 193 if (!this.size) return e; 194 let t = this.lastChild, r = e.firstChild, i = this.content.slice(), o = 0; 195 for(t.isText && t.sameMarkup(r) && (i[i.length - 1] = t.withText(t.text + r.text), o = 1); o < e.content.length; o++)i.push(e.content[o]); 196 return new k(i, this.size + e.size); 197 } 198 cut(e, t = this.size) { 199 if (e == 0 && t == this.size) return this; 200 let r = [], i = 0; 201 if (t > e) for(let o = 0, s = 0; s < t; o++){ 202 let l = this.content[o], a = s + l.nodeSize; 203 a > e && ((s < e || a > t) && (l.isText ? l = l.cut(Math.max(0, e - s), Math.min(l.text.length, t - s)) : l = l.cut(Math.max(0, e - s - 1), Math.min(l.content.size, t - s - 1))), r.push(l), i += l.nodeSize), s = a; 204 } 205 return new k(r, i); 206 } 207 cutByIndex(e, t) { 208 return e == t ? k.empty : e == 0 && t == this.content.length ? this : new k(this.content.slice(e, t)); 209 } 210 replaceChild(e, t) { 211 let r = this.content[e]; 212 if (r == t) return this; 213 let i = this.content.slice(), o = this.size + t.nodeSize - r.nodeSize; 214 return i[e] = t, new k(i, o); 215 } 216 addToStart(e) { 217 return new k([ 218 e 219 ].concat(this.content), this.size + e.nodeSize); 220 } 221 addToEnd(e) { 222 return new k(this.content.concat(e), this.size + e.nodeSize); 223 } 224 eq(e) { 225 if (this.content.length != e.content.length) return !1; 226 for(let t = 0; t < this.content.length; t++)if (!this.content[t].eq(e.content[t])) return !1; 227 return !0; 228 } 229 get firstChild() { 230 return this.content.length ? this.content[0] : null; 231 } 232 get lastChild() { 233 return this.content.length ? this.content[this.content.length - 1] : null; 234 } 235 get childCount() { 236 return this.content.length; 237 } 238 child(e) { 239 let t = this.content[e]; 240 if (!t) throw new RangeError("Index " + e + " out of range for " + this); 241 return t; 242 } 243 maybeChild(e) { 244 return this.content[e] || null; 245 } 246 forEach(e) { 247 for(let t = 0, r = 0; t < this.content.length; t++){ 248 let i = this.content[t]; 249 e(i, r, t), r += i.nodeSize; 250 } 251 } 252 findDiffStart(e, t = 0) { 253 return Io(this, e, t); 254 } 255 findDiffEnd(e, t = this.size, r = e.size) { 256 return Ro(this, e, t, r); 257 } 258 findIndex(e) { 259 if (e == 0) return _t(0, e); 260 if (e == this.size) return _t(this.content.length, e); 261 if (e > this.size || e < 0) throw new RangeError(`Position ${e} outside of fragment (${this})`); 262 for(let t = 0, r = 0;; t++){ 263 let i = this.child(t), o = r + i.nodeSize; 264 if (o >= e) return o == e ? _t(t + 1, o) : _t(t, r); 265 r = o; 266 } 267 } 268 toString() { 269 return "<" + this.toStringInner() + ">"; 270 } 271 toStringInner() { 272 return this.content.join(", "); 273 } 274 toJSON() { 275 return this.content.length ? this.content.map((e)=>e.toJSON()) : null; 276 } 277 static fromJSON(e, t) { 278 if (!t) return k.empty; 279 if (!Array.isArray(t)) throw new RangeError("Invalid input for Fragment.fromJSON"); 280 return k.fromArray(t.map(e.nodeFromJSON)); 281 } 282 static fromArray(e) { 283 if (!e.length) return k.empty; 284 let t, r = 0; 285 for(let i = 0; i < e.length; i++){ 286 let o = e[i]; 287 r += o.nodeSize, i && o.isText && e[i - 1].sameMarkup(o) ? (t || (t = e.slice(0, i)
287), t[t.length - 1] = o.withText(t[t.length - 1].text + o.text)) : t && t.push(o); 288 } 289 return new k(t || e, r); 290 } 291 static from(e) { 292 if (!e) return k.empty; 293 if (e instanceof k) return e; 294 if (Array.isArray(e)) return this.fromArray(e); 295 if (e.attrs) return new k([ 296 e 297 ], e.nodeSize); 298 throw new RangeError("Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : "")); 299 } 300 } 301 k.empty = new k([], 0); 302 const Wn = { 303 index: 0, 304 offset: 0 305 }; 306 function _t(n, e) { 307 return Wn.index = n, Wn.offset = e, Wn; 308 } 309 function an(n, e) { 310 if (n === e) return !0; 311 if (!(n && typeof n == "object") || !(e && typeof e == "object")) return !1; 312 let t = Array.isArray(n); 313 if (Array.isArray(e) != t) return !1; 314 if (t) { 315 if (n.length != e.length) return !1; 316 for(let r = 0; r < n.length; r++)if (!an(n[r], e[r])) return !1; 317 } else { 318 for(let r in n)if (!(r in e) || !an(n[r], e[r])) return !1; 319 for(let r in e)if (!(r in n)) return !1; 320 } 321 return !0; 322 } 323 let I = class lr { 324 constructor(e, t){ 325 this.type = e, this.attrs = t; 326 } 327 addToSet(e) { 328 let t, r = !1; 329 for(let i = 0; i < e.length; i++){ 330 let o = e[i]; 331 if (this.eq(o)) return e; 332 if (this.type.excludes(o.type)) t || (t = e.slice(0, i)); 333 else { 334 if (o.type.excludes(this.type)) return e; 335 !r && o.type.rank > this.type.rank && (t || (t = e.slice(0, i)), t.push(this), r = !0), t && t.push(o); 336 } 337 } 338 return t || (t = e.slice()), r || t.push(this), t; 339 } 340 removeFromSet(e) { 341 for(let t = 0; t < e.length; t++)if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1)); 342 return e; 343 } 344 isInSet(e) { 345 for(let t = 0; t < e.length; t++)if (this.eq(e[t])) return !0; 346 return !1; 347 } 348 eq(e) { 349 return this == e || this.type == e.type && an(this.attrs, e.attrs); 350 } 351 toJSON() { 352 let e = { 353 type: this.type.name 354 }; 355 for(let t in this.attrs){ 356 e.attrs = this.attrs; 357 break; 358 } 359 return e; 360 } 361 static fromJSON(e, t) { 362 if (!t) throw new RangeError("Invalid input for Mark.fromJSON"); 363 let r = e.marks[t.type]; 364 if (!r) throw new RangeError(`There is no mark type ${t.type} in this schema`); 365 let i = r.create(t.attrs); 366 return r.checkAttrs(i.attrs), i; 367 } 368 static sameSet(e, t) { 369 if (e == t) return !0; 370 if (e.length != t.length) return !1; 371 for(let r = 0; r < e.length; r++)if (!e[r].eq(t[r])) return !1; 372 return !0; 373 } 374 static setFrom(e) { 375 if (!e || Array.isArray(e) && e.length == 0) return lr.none; 376 if (e instanceof lr) return [ 377 e 378 ]; 379 let t = e.slice(); 380 return t.sort((r, i)=>r.type.rank - i.type.rank), t; 381 } 382 }; 383 I.none = []; 384 class Et extends Error { 385 } 386 class b { 387 constructor(e, t, r){ 388 this.content = e, this.openStart = t, this.openEnd = r; 389 } 390 get size() { 391 return this.content.size - this.openStart - this.openEnd; 392 } 393 insertAt(e, t) { 394 let r = Fo(this.content, e + this.openStart, t, this.openStart + 1, this.openEnd + 1); 395 return r && new b(r, this.openStart, this.openEnd); 396 } 397 removeBetween(e, t) { 398 return new b(zo(this.content, e + this.openStart, t + this.openStart), this.openStart, this.openEnd); 399 } 400 eq(e) { 401 return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd; 402 } 403 toString() { 404 return this.content + "(" + this.openStart + "," + this.openEnd + ")"; 405 } 406 toJSON() { 407 if (!this.content.size) return null; 408 let e = { 409 content: this.content.toJSON() 410 }; 411 return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e; 412 } 413 static fromJSON(e, t) { 414 if (!t) return b.empty; 415 let r = t.openStart || 0, i = t.openEnd || 0; 416 if (typeof r != "number" || typeof i != "number") throw new RangeError("Invalid input for Slice.fromJSON"); 417 return new b(k.fromJSON(e, t.content), r, i); 418 } 419 static maxOpen(e, t = !0) { 420 let r = 0, i = 0; 421 for(let o = e.firstChild; o && !o.isLeaf && (t || !o.type.spec.isolating); o = o.firstChild)r++; 422 for(let o = e.lastChild; o && !o.isLeaf && (t || !o.type.spec.isolating); o = o.lastChild)i++; 423 return new b(e, r, i); 424 } 425 } 426 b.empty = new b(k.empty, 0, 0); 427 function zo(n, e, t) { 428 let { index: r, offset: i } = n.findIndex(e), o = n.maybeChild(r), { index: s, offset: l } = n.findIndex(t); 429 if (i == e || o.isText) { 430 if (l != t && !n.child(s).isText) throw new RangeError("Removing non-flat range"); 431 return n.cut(0, e).append(n.cut(t)); 432 } 433 if (r != s) throw new RangeError("Removing non-flat range"); 434 return n.replaceChild(r, o.copy(zo(o.content, e - i - 1, t - i - 1))); 435 } 436 function Fo(n, e, t, r, i, o) { 437 let { index: s, offset: l } = n.findIndex(e), a = n.maybeChild(s); 438 if (l == e || a.isText) return o && r <= 0 && i <= 0 && !o.canReplace(s, s, t) ? null : n.cut(0, e).append(t).append(n.cut(e)); 439 let c = Fo(a.content, e - l - 1, t, s == 0 ? r - 1 : 0, s == n.childCount - 1 ? i - 1 : 0, a); 440 return c && n.replaceChild(s, a.copy(c)); 441 } 442 function pa(n, e, t) { 443 if (t.openStart >
vendor: 7,243 bytes, lines 443-609
443 n.depth) throw new Et("Inserted content deeper than insertion position"); 444 if (n.depth - t.openStart != e.depth - t.openEnd) throw new Et("Inconsistent open depths"); 445 return Lo(n, e, t, 0); 446 } 447 function Lo(n, e, t, r) { 448 let i = n.index(r), o = n.node(r); 449 if (i == e.index(r) && r < n.depth - t.openStart) { 450 let s = Lo(n, e, t, r + 1); 451 return o.copy(o.content.replaceChild(i, s)); 452 } else if (t.content.size) if (!t.openStart && !t.openEnd && n.depth == r && e.depth == r) { 453 let s = n.parent, l = s.content; 454 return We(s, l.cut(0, n.parentOffset).append(t.content).append(l.cut(e.parentOffset))); 455 } else { 456 let { start: s, end: l } = ma(t, n); 457 return We(o, $o(n, s, l, e, r)); 458 } 459 else return We(o, cn(n, e, r)); 460 } 461 function Vo(n, e) { 462 if (!e.type.compatibleContent(n.type)) throw new Et("Cannot join " + e.type.name + " onto " + n.type.name); 463 } 464 function ar(n, e, t) { 465 let r = n.node(t); 466 return Vo(r, e.node(t)), r; 467 } 468 function je(n, e) { 469 let t = e.length - 1; 470 t >= 0 && n.isText && n.sameMarkup(e[t]) ? e[t] = n.withText(e[t].text + n.text) : e.push(n); 471 } 472 function St(n, e, t, r) { 473 let i = (e || n).node(t), o = 0, s = e ? e.index(t) : i.childCount; 474 n && (o = n.index(t), n.depth > t ? o++ : n.textOffset && (je(n.nodeAfter, r), o++)); 475 for(let l = o; l < s; l++)je(i.child(l), r); 476 e && e.depth == t && e.textOffset && je(e.nodeBefore, r); 477 } 478 function We(n, e) { 479 if (!n.type.validContent(e)) throw new Et("Invalid content for node " + n.type.name); 480 return n.copy(e); 481 } 482 function $o(n, e, t, r, i) { 483 let o = n.depth > i && ar(n, e, i + 1), s = r.depth > i && ar(t, r, i + 1), l = []; 484 return St(null, n, i, l), o && s && e.index(i) == t.index(i) ? (Vo(o, s), je(We(o, $o(n, e, t, r, i + 1)), l)) : (o && je(We(o, cn(n, e, i + 1)), l), St(e, t, i, l), s && je(We(s, cn(t, r, i + 1)), l)), St(r, null, i, l), new k(l); 485 } 486 function cn(n, e, t) { 487 let r = []; 488 if (St(null, n, t, r), n.depth > t) { 489 let i = ar(n, e, t + 1); 490 je(We(i, cn(n, e, t + 1)), r); 491 } 492 return St(e, null, t, r), new k(r); 493 } 494 function ma(n, e) { 495 let t = e.depth - n.openStart, i = e.node(t).copy(n.content); 496 for(let o = t - 1; o >= 0; o--)i = e.node(o).copy(k.from(i)); 497 return { 498 start: i.resolveNoCache(n.openStart + t), 499 end: i.resolveNoCache(i.content.size - n.openEnd - t) 500 }; 501 } 502 class Dt { 503 constructor(e, t, r){ 504 this.pos = e, this.path = t, this.parentOffset = r, this.depth = t.length / 3 - 1; 505 } 506 resolveDepth(e) { 507 return e == null ? this.depth : e < 0 ? this.depth + e : e; 508 } 509 get parent() { 510 return this.node(this.depth); 511 } 512 get doc() { 513 return this.node(0); 514 } 515 node(e) { 516 return this.path[this.resolveDepth(e) * 3]; 517 } 518 index(e) { 519 return this.path[this.resolveDepth(e) * 3 + 1]; 520 } 521 indexAfter(e) { 522 return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1); 523 } 524 start(e) { 525 return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1; 526 } 527 end(e) { 528 return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size; 529 } 530 before(e) { 531 if (e = this.resolveDepth(e), !e) throw new RangeError("There is no position before the top-level node"); 532 return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1]; 533 } 534 after(e) { 535 if (e = this.resolveDepth(e), !e) throw new RangeError("There is no position after the top-level node"); 536 return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize; 537 } 538 get textOffset() { 539 return this.pos - this.path[this.path.length - 1]; 540 } 541 get nodeAfter() { 542 let e = this.parent, t = this.index(this.depth); 543 if (t == e.childCount) return null; 544 let r = this.pos - this.path[this.path.length - 1], i = e.child(t); 545 return r ? e.child(t).cut(r) : i; 546 } 547 get nodeBefore() { 548 let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1]; 549 return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1); 550 } 551 posAtIndex(e, t) { 552 t = this.resolveDepth(t); 553 let r = this.path[t * 3], i = t == 0 ? 0 : this.path[t * 3 - 1] + 1; 554 for(let o = 0; o < e; o++)i += r.child(o).nodeSize; 555 return i; 556 } 557 marks() { 558 let e = this.parent, t = this.index(); 559 if (e.content.size == 0) return I.none; 560 if (this.textOffset) return e.child(t).marks; 561 let r = e.maybeChild(t - 1), i = e.maybeChild(t); 562 if (!r) { 563 let l = r; 564 r = i, i = l; 565 } 566 let o = r.marks; 567 for(var s = 0; s < o.length; s++)o[s].type.spec.inclusive === !1 && (!i || !o[s].isInSet(i.marks)) && (o = o[s--].removeFromSet(o)); 568 return o; 569 } 570 marksAcross(e) { 571 let t = this.parent.maybeChild(this.index()); 572 if (!t || !t.isInline) return null; 573 let r = t.marks, i = e.parent.maybeChild(e.index()); 574 for(var o = 0; o < r.length; o++)r[o].type.spec.inclusive === !1 && (!i || !r[o].isInSet(i.marks)) && (r = r[o--].removeFromSet(r)); 575 return r; 576 } 577 sharedDepth(e) { 578 for(let t = this.depth; t > 0; t--)if (this.start(t) <= e && this.end(t) >= e) return t; 579 return 0; 580 } 581 blockRange(e = this, t) { 582 if (e.pos < this.pos) return e.blockRange(this); 583 for(let r = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); r >= 0; r--)if (e.pos <= this.end(r) && (!t || t(this.node(r)))) return new fn(this, e, r); 584 return null; 585 } 586 sameParent(e) { 587 return this.pos - this.parentOffset == e.pos - e.parentOffset; 588 } 589 max(e) { 590 return e.pos > this.pos ? e : this; 591 } 592 min(e) { 593 return e.pos < this.pos ? e : this; 594 } 595 toString() { 596 let e = ""; 597 for(let t = 1; t <= this.depth; t++)e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1); 598 return e + ":" + this.parentOffset; 599 } 600 static resolve(e, t) { 601 if (!(t >= 0 && t <= e.content.size)) throw new RangeError("Position " + t + " out of range"); 602 let r = [], i = 0, o = t; 603 for(let s = e;;){ 604 let { index: l, offset: a } = s.content.findIndex(o), c = o - a; 605 if (r.push(s, l, i + a), !c || (s = s.child(l), s.isText)) break; 606 o = c - 1, i += a + 1; 607 } 608 return new Dt(t, r, o); 609 }
610 static resolveCached(e, t) { 611 let r = oi.get(e); 612 if (r) for(let o = 0; o < r.elts.length; o++){ 613 let s = r.elts[o]; 614 if (s.pos == t) return s; 615 } 616 else oi.set(e, r = new ga); 617 let i = r.elts[r.i] = Dt.resolve(e, t); 618 return r.i = (r.i + 1) % ya, i; 619 } 620 } 621 class ga { 622 constructor(){ 623 this.elts = [], this.i = 0; 624 } 625 } 626 const ya = 12, oi = new WeakMap; 627 class fn { 628 constructor(e, t, r){ 629 this.$from = e, this.$to = t, this.depth = r; 630 } 631 get start() { 632 return this.$from.before(this.depth + 1); 633 } 634 get end() { 635 return this.$to.after(this.depth + 1); 636 } 637 get parent() { 638 return this.$from.node(this.depth); 639 } 640 get startIndex() { 641 return this.$from.index(this.depth); 642 } 643 get endIndex() { 644 return this.$to.indexAfter(this.depth); 645 } 646 } 647 const ka = Object.create(null); 648 let Je = class cr { 649 constructor(e, t, r, i = I.none){ 650 this.type = e, this.attrs = t, this.marks = i, this.content = r || k.empty; 651 } 652 get children() { 653 return this.content.content; 654 } 655 get nodeSize() { 656 return this.isLeaf ? 1 : 2 + this.content.size; 657 } 658 get childCount() { 659 return this.content.childCount; 660 } 661 child(e) { 662 return this.content.child(e); 663 } 664 maybeChild(e) { 665 return this.content.maybeChild(e); 666 } 667 forEach(e) { 668 this.content.forEach(e); 669 } 670 nodesBetween(e, t, r, i = 0) { 671 this.content.nodesBetween(e, t, r, i, this); 672 } 673 descendants(e) { 674 this.nodesBetween(0, this.content.size, e); 675 } 676 get textContent() { 677 return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, ""); 678 } 679 textBetween(e, t, r, i) { 680 return this.content.textBetween(e, t, r, i); 681 } 682 get firstChild() { 683 return this.content.firstChild; 684 } 685 get lastChild() { 686 return this.content.lastChild; 687 } 688 eq(e) { 689 return this == e || this.sameMarkup(e) && this.content.eq(e.content); 690 } 691 sameMarkup(e) { 692 return this.hasMarkup(e.type, e.attrs, e.marks); 693 } 694 hasMarkup(e, t, r) { 695 return this.type == e && an(this.attrs, t || e.defaultAttrs || ka) && I.sameSet(this.marks, r || I.none); 696 } 697 copy(e = null) { 698 return e == this.content ? this : new cr(this.type, this.attrs, e, this.marks); 699 } 700 mark(e) { 701 return e == this.marks ? this : new cr(this.type, this.attrs, this.content, e); 702 } 703 cut(e, t = this.content.size) { 704 return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t)); 705 } 706 slice(e, t = this.content.size, r = !1) { 707 if (e == t) return b.empty; 708 let i = this.resolve(e), o = this.resolve(t), s = r ? 0 : i.sharedDepth(t), l = i.start(s), c = i.node(s).content.cut(i.pos - l, o.pos - l); 709 return new b(c, i.depth - s, o.depth - s); 710 } 711 replace(e, t, r) { 712 return pa(this.resolve(e), this.resolve(t), r); 713 } 714 nodeAt(e) { 715 for(let t = this;;){ 716 let { index: r, offset: i } = t.content.findIndex(e); 717 if (t = t.maybeChild(r), !t) return null; 718 if (i == e || t.isText) return t; 719 e -= i + 1; 720 } 721 } 722 childAfter(e) { 723 let { index: t, offset: r } = this.content.findIndex(e); 724 return { 725 node: this.content.maybeChild(t), 726 index: t, 727 offset: r 728 }; 729 } 730 childBefore(e) { 731 if (e == 0) return { 732 node: null, 733 index: 0, 734 offset: 0 735 }; 736 let { index: t, offset: r } = this.content.findIndex(e); 737 if (r < e) return { 738 node: this.content.child(t), 739 index: t, 740 offset: r 741 }; 742 let i = this.content.child(t - 1); 743 return { 744 node: i, 745 index: t - 1, 746 offset: r - i.nodeSize 747 }; 748 } 749 resolve(e) {
vendor: 26,938 bytes, lines 750-1457
750 return Dt.resolveCached(this, e); 751 } 752 resolveNoCache(e) { 753 return Dt.resolve(this, e); 754 } 755 rangeHasMark(e, t, r) { 756 let i = !1; 757 return t > e && this.nodesBetween(e, t, (o)=>(r.isInSet(o.marks) && (i = !0), !i)), i; 758 } 759 get isBlock() { 760 return this.type.isBlock; 761 } 762 get isTextblock() { 763 return this.type.isTextblock; 764 } 765 get inlineContent() { 766 return this.type.inlineContent; 767 } 768 get isInline() { 769 return this.type.isInline; 770 } 771 get isText() { 772 return this.type.isText; 773 } 774 get isLeaf() { 775 return this.type.isLeaf; 776 } 777 get isAtom() { 778 return this.type.isAtom; 779 } 780 toString() { 781 if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this); 782 let e = this.type.name; 783 return this.content.size && (e += "(" + this.content.toStringInner() + ")"), jo(this.marks, e); 784 } 785 contentMatchAt(e) { 786 let t = this.type.contentMatch.matchFragment(this.content, 0, e); 787 if (!t) throw new Error("Called contentMatchAt on a node with invalid content"); 788 return t; 789 } 790 canReplace(e, t, r = k.empty, i = 0, o = r.childCount) { 791 let s = this.contentMatchAt(e).matchFragment(r, i, o), l = s && s.matchFragment(this.content, t); 792 if (!l || !l.validEnd) return !1; 793 for(let a = i; a < o; a++)if (!this.type.allowsMarks(r.child(a).marks)) return !1; 794 return !0; 795 } 796 canReplaceWith(e, t, r, i) { 797 if (i && !this.type.allowsMarks(i)) return !1; 798 let o = this.contentMatchAt(e).matchType(r), s = o && o.matchFragment(this.content, t); 799 return s ? s.validEnd : !1; 800 } 801 canAppend(e) { 802 return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type); 803 } 804 check() { 805 this.type.checkContent(this.content), this.type.checkAttrs(this.attrs); 806 let e = I.none; 807 for(let t = 0; t < this.marks.length; t++){ 808 let r = this.marks[t]; 809 r.type.checkAttrs(r.attrs), e = r.addToSet(e); 810 } 811 if (!I.sameSet(e, this.marks)) throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t)=>t.type.name)}`); 812 this.content.forEach((t)=>t.check()); 813 } 814 toJSON() { 815 let e = { 816 type: this.type.name 817 }; 818 for(let t in this.attrs){ 819 e.attrs = this.attrs; 820 break; 821 } 822 return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((t)=>t.toJSON())), e; 823 } 824 static fromJSON(e, t) { 825 if (!t) throw new RangeError("Invalid input for Node.fromJSON"); 826 let r; 827 if (t.marks) { 828 if (!Array.isArray(t.marks)) throw new RangeError("Invalid mark data for Node.fromJSON"); 829 r = t.marks.map(e.markFromJSON); 830 } 831 if (t.type == "text") { 832 if (typeof t.text != "string") throw new RangeError("Invalid text node in JSON"); 833 return e.text(t.text, r); 834 } 835 let i = k.fromJSON(e, t.content), o = e.nodeType(t.type).create(t.attrs, i, r); 836 return o.type.checkAttrs(o.attrs), o; 837 } 838 }; 839 Je.prototype.text = void 0; 840 class un extends Je { 841 constructor(e, t, r, i){ 842 if (super(e, t, null, i), !r) throw new RangeError("Empty text nodes are not allowed"); 843 this.text = r; 844 } 845 toString() { 846 return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : jo(this.marks, JSON.stringify(this.text)); 847 } 848 get textContent() { 849 return this.text; 850 } 851 textBetween(e, t) { 852 return this.text.slice(e, t); 853 } 854 get nodeSize() { 855 return this.text.length; 856 } 857 mark(e) { 858 return e == this.marks ? this : new un(this.type, this.attrs, this.text, e); 859 } 860 withText(e) { 861 return e == this.text ? this : new un(this.type, this.attrs, e, this.marks); 862 } 863 cut(e = 0, t = this.text.length) { 864 return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t)); 865 } 866 eq(e) { 867 return this.sameMarkup(e) && this.text == e.text; 868 } 869 toJSON() { 870 let e = super.toJSON(); 871 return e.text = this.text, e; 872 } 873 } 874 function jo(n, e) { 875 for(let t = n.length - 1; t >= 0; t--)e = n[t].type.name + "(" + e + ")"; 876 return e; 877 } 878 class _e { 879 constructor(e){ 880 this.validEnd = e, this.next = [], this.wrapCache = []; 881 } 882 static parse(e, t) { 883 let r = new ba(e, t); 884 if (r.next == null) return _e.empty; 885 let i = Wo(r); 886 r.next && r.err("Unexpected trailing text"); 887 let o = va(Ta(i)); 888 return Oa(o, r), o; 889 } 890 matchType(e) { 891 for(let t = 0; t < this.next.length; t++)if (this.next[t].type == e) return this.next[t].next; 892 return null; 893 } 894 matchFragment(e, t = 0, r = e.childCount) { 895 let i = this; 896 for(let o = t; i && o < r; o++)i = i.matchType(e.child(o).type); 897 return i; 898 } 899 get inlineContent() { 900 return this.next.length != 0 && this.next[0].type.isInline; 901 } 902 get defaultType() { 903 for(let e = 0; e < this.next.length; e++){ 904 let { type: t } = this.next[e]; 905 if (!(t.isText || t.hasRequiredAttrs())) return t; 906 } 907 return null; 908 } 909 compatible(e) { 910 for(let t = 0; t < this.next.length; t++)for(let r = 0; r < e.next.length; r++)if (this.next[t].type == e.next[r].type) return !0; 911 return !1; 912 } 913 fillBefore(e, t = !1, r = 0) { 914 let i = [ 915 this 916 ]; 917 function o(s, l) { 918 let a = s.matchFragment(e, r); 919 if (a && (!t || a.validEnd)) return k.from(l.map((c)=>c.createAndFill())); 920 for(let c = 0; c < s.next.length; c++){ 921 let { type: f, next: u } = s.next[c]; 922 if (!(f.isText || f.hasRequiredAttrs()) && i.indexOf(u) == -1) { 923 i.push(u); 924 let d = o(u, l.concat(f)); 925 if (d) return d; 926 } 927 } 928 return null; 929 } 930 return o(this, []); 931 } 932 findWrapping(e) { 933 for(let r = 0; r < this.wrapCache.length; r += 2)if (this.wrapCache[r] == e) return this.wrapCache[r + 1]; 934 let t = this.computeWrapping(e); 935 return this.wrapCache.push(e, t), t; 936 } 937 computeWrapping(e) { 938 let t = Object.create(null), r = [ 939 { 940 match: this, 941 type: null, 942 via: null 943 } 944 ]; 945 for(; r.length;){ 946 let i = r.shift(), o = i.match; 947 if (o.matchType(e)) { 948 let s = []; 949 for(let l = i; l.type; l = l.via)s.push(l.type); 950 return s.reverse(); 951 } 952 for(let s = 0; s < o.next.length; s++){ 953 let { type: l, next: a } = o.next[s]; 954 !l.isLeaf && !l.hasRequiredAttrs() && !(l.name in t) && (!i.type || a.validEnd) && (r.push({ 955 match: l.contentMatch, 956 type: l, 957 via: i 958 }), t[l.name] = !0); 959 } 960 } 961 return null; 962 } 963 get edgeCount() { 964 return this.next.length; 965 } 966 edge(e) { 967 if (e >= this.next.length) throw new RangeError(`There's no ${e}th edge in this content match`); 968 return this.next[e]; 969 } 970 toString() { 971 let e = []; 972 function t(r) { 973 e.push(r); 974 for(let i = 0; i < r.next.length; i++)e.indexOf(r.next[i].next) == -1 && t(r.next[i].next); 975 } 976 return t(this), e.map((r, i)=>{ 977 let o = i + (r.validEnd ? "*" : " ") + " "; 978 for(let s = 0; s < r.next.length; s++)o += (s ? ", " : "") + r.next[s].type.name + "->" + e.indexOf(r.next[s].next); 979 return o; 980 }).join(` 981`); 982 } 983 } 984 _e.empty = new _e(!0); 985 class ba { 986 constructor(e, t){ 987 this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift(); 988 } 989 get next() { 990 return this.tokens[this.pos]; 991 } 992 eat(e) { 993 return this.next == e && (this.pos++ || !0); 994 } 995 err(e) { 996 throw new SyntaxError(e + " (in content expression '" + this.string + "')"); 997 } 998 } 999 function Wo(n) { 1000 let e = []; 1001 do e.push(xa(n)); 1002 while (n.eat("|")); 1003 return e.length == 1 ? e[0] : { 1004 type: "choice", 1005 exprs: e 1006 }; 1007 } 1008 function xa(n) { 1009 let e = []; 1010 do e.push(Sa(n)); 1011 while (n.next && n.next != ")" && n.next != "|"); 1012 return e.length == 1 ? e[0] : { 1013 type: "seq", 1014 exprs: e 1015 }; 1016 } 1017 function Sa(n) { 1018 let e = Ca(n); 1019 for(;;)if (n.eat("+")) e = { 1020 type: "plus", 1021 expr: e 1022 }; 1023 else if (n.eat("*")) e = { 1024 type: "star", 1025 expr: e 1026 }; 1027 else if (n.eat("?")) e = { 1028 type: "opt", 1029 expr: e 1030 }; 1031 else if (n.eat("{")) e = wa(n, e); 1032 else break; 1033 return e; 1034 } 1035 function si(n) { 1036 /\D/.test(n.next) && n.err("Expected number, got '" + n.next + "'"); 1037 let e = Number(n.next); 1038 return n.pos++, e; 1039 } 1040 function wa(n, e) { 1041 let t = si(n), r = t; 1042 return n.eat(",") && (n.next != "}" ? r = si(n) : r = -1), n.eat("}") || n.err("Unclosed braced range"), { 1043 type: "range", 1044 min: t, 1045 max: r, 1046 expr: e 1047 }; 1048 } 1049 function Ma(n, e) { 1050 let t = n.nodeTypes, r = t[e]; 1051 if (r) return [ 1052 r 1053 ]; 1054 let i = []; 1055 for(let o in t){ 1056 let s = t[o]; 1057 s.isInGroup(e) && i.push(s); 1058 } 1059 return i.length == 0 && n.err("No node type or group '" + e + "' found"), i; 1060 } 1061 function Ca(n) { 1062 if (n.eat("(")) { 1063 let e = Wo(n); 1064 return n.eat(")") || n.err("Missing closing paren"), e; 1065 } else if (/\W/.test(n.next)) n.err("Unexpected token '" + n.next + "'"); 1066 else { 1067 let e = Ma(n, n.next).map((t)=>(n.inline == null ? n.inline = t.isInline : n.inline != t.isInline && n.err("Mixing inline and block content"), { 1068 type: "name", 1069 value: t 1070 })); 1071 return n.pos++, e.length == 1 ? e[0] : { 1072 type: "choice", 1073 exprs: e 1074 }; 1075 } 1076 } 1077 function Ta(n) { 1078 let e = [ 1079 [] 1080 ]; 1081 return i(o(n, 0), t()), e; 1082 function t() { 1083 return e.push([]) - 1; 1084 } 1085 function r(s, l, a) { 1086 let c = { 1087 term: a, 1088 to: l 1089 }; 1090 return e[s].push(c), c; 1091 } 1092 function i(s, l) { 1093 s.forEach((a)=>a.to = l); 1094 } 1095 function o(s, l) { 1096 if (s.type == "choice") return s.exprs.reduce((a, c)=>a.concat(o(c, l)), []); 1097 if (s.type == "seq") for(let a = 0;; a++){ 1098 let c = o(s.exprs[a], l); 1099 if (a == s.exprs.length - 1) return c; 1100 i(c, l = t()); 1101 } 1102 else if (s.type == "star") { 1103 let a = t(); 1104 return r(l, a), i(o(s.expr, a), a), [ 1105 r(a) 1106 ]; 1107 } else if (s.type == "plus") { 1108 let a = t(); 1109 return i(o(s.expr, l), a), i(o(s.expr, a), a), [ 1110 r(a) 1111 ]; 1112 } else { 1113 if (s.type == "opt") return [ 1114 r(l) 1115 ].concat(o(s.expr, l)); 1116 if (s.type == "range") { 1117 let a = l; 1118 for(let c = 0; c < s.min; c++){ 1119 let f = t(); 1120 i(o(s.expr, a), f), a = f; 1121 } 1122 if (s.max == -1) i(o(s.expr, a), a); 1123 else for(let c = s.min; c < s.max; c++){ 1124 let f = t(); 1125 r(a, f), i(o(s.expr, a), f), a = f; 1126 } 1127 return [ 1128 r(a) 1129 ]; 1130 } else { 1131 if (s.type == "name") return [ 1132 r(l, void 0, s.value) 1133 ]; 1134 throw new Error("Unknown expr type"); 1135 } 1136 } 1137 } 1138 } 1139 function Jo(n, e) { 1140 return e - n; 1141 } 1142 function li(n, e) { 1143 let t = []; 1144 return r(e), t.sort(Jo); 1145 function r(i) { 1146 let o = n[i]; 1147 if (o.length == 1 && !o[0].term) return r(o[0].to); 1148 t.push(i); 1149 for(let s = 0; s < o.length; s++){ 1150 let { term: l, to: a } = o[s]; 1151 !l && t.indexOf(a) == -1 && r(a); 1152 } 1153 } 1154 } 1155 function va(n) { 1156 let e = Object.create(null); 1157 return t(li(n, 0)); 1158 function t(r) { 1159 let i = []; 1160 r.forEach((s)=>{ 1161 n[s].forEach(({ term: l, to: a })=>{ 1162 if (!l) return; 1163 let c; 1164 for(let f = 0; f < i.length; f++)i[f][0] == l && (c = i[f][1]); 1165 li(n, a).forEach((f)=>{ 1166 c || i.push([ 1167 l, 1168 c = [] 1169 ]), c.indexOf(f) == -1 && c.push(f); 1170 }); 1171 }); 1172 }); 1173 let o = e[r.join(",")] = new _e(r.indexOf(n.length - 1) > -1); 1174 for(let s = 0; s < i.length; s++){ 1175 let l = i[s][1].sort(Jo); 1176 o.next.push({ 1177 type: i[s][0], 1178 next: e[l.join(",")] || t(l) 1179 }); 1180 } 1181 return o; 1182 } 1183 } 1184 function Oa(n, e) { 1185 for(let t = 0, r = [ 1186 n 1187 ]; t < r.length; t++){ 1188 let i = r[t], o = !i.validEnd, s = []; 1189 for(let l = 0; l < i.next.length; l++){ 1190 let { type: a, next: c } = i.next[l]; 1191 s.push(a.name), o && !(a.isText || a.hasRequiredAttrs()) && (o = !1), r.indexOf(c) == -1 && r.push(c); 1192 } 1193 o && e.err("Only non-generatable nodes (" + s.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)"); 1194 } 1195 } 1196 function qo(n) { 1197 let e = Object.create(null); 1198 for(let t in n){ 1199 let r = n[t]; 1200 if (!r.hasDefault) return null; 1201 e[t] = r.default; 1202 } 1203 return e; 1204 } 1205 function Ko(n, e) { 1206 let t = Object.create(null); 1207 for(let r in n){ 1208 let i = e && e[r]; 1209 if (i === void 0) { 1210 let o = n[r]; 1211 if (o.hasDefault) i = o.default; 1212 else throw new RangeError("No value supplied for attribute " + r); 1213 } 1214 t[r] = i; 1215 } 1216 return t; 1217 } 1218 function Ho(n, e, t, r) { 1219 for(let i in e)if (!(i in n)) throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`); 1220 for(let i in n)n[i].validate && n[i].validate(e[i]); 1221 } 1222 function _o(n, e) { 1223 let t = Object.create(null); 1224 if (e) for(let r in e)t[r] = new Ea(n, r, e[r]); 1225 return t; 1226 } 1227 let ai = class Uo { 1228 constructor(e, t, r){ 1229 this.name = e, this.schema = t, this.spec = r, this.markSet = null, this.groups = r.group ? r.group.split(" ") : [], this.attrs = _o(e, r.attrs), this.defaultAttrs = qo(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(r.inline || e == "text"), this.isText = e == "text"; 1230 } 1231 get isInline() { 1232 return !this.isBlock; 1233 } 1234 get isTextblock() { 1235 return this.isBlock && this.inlineContent; 1236 } 1237 get isLeaf() { 1238 return this.contentMatch == _e.empty; 1239 } 1240 get isAtom() { 1241 return this.isLeaf || !!this.spec.atom; 1242 } 1243 isInGroup(e) { 1244 return this.groups.indexOf(e) > -1; 1245 } 1246 get whitespace() { 1247 return this.spec.whitespace || (this.spec.code ? "pre" : "normal"); 1248 } 1249 hasRequiredAttrs() { 1250 for(let e in this.attrs)if (this.attrs[e].isRequired) return !0; 1251 return !1; 1252 } 1253 compatibleContent(e) { 1254 return this == e || this.contentMatch.compatible(e.contentMatch); 1255 } 1256 computeAttrs(e) { 1257 return !e && this.defaultAttrs ? this.defaultAttrs : Ko(this.attrs, e); 1258 } 1259 create(e = null, t, r) { 1260 if (this.isText) throw new Error("NodeType.create can't construct text nodes"); 1261 return new Je(this, this.computeAttrs(e), k.from(t), I.setFrom(r)); 1262 } 1263 createChecked(e = null, t, r) { 1264 return t = k.from(t), this.checkContent(t), new Je(this, this.computeAttrs(e), t, I.setFrom(r)); 1265 } 1266 createAndFill(e = null, t, r) { 1267 if (e = this.computeAttrs(e), t = k.from(t), t.size) { 1268 let s = this.contentMatch.fillBefore(t); 1269 if (!s) return null; 1270 t = s.append(t); 1271 } 1272 let i = this.contentMatch.matchFragment(t), o = i && i.fillBefore(k.empty, !0); 1273 return o ? new Je(this, e, t.append(o), I.setFrom(r)) : null; 1274 } 1275 validContent(e) { 1276 let t = this.contentMatch.matchFragment(e); 1277 if (!t || !t.validEnd) return !1; 1278 for(let r = 0; r < e.childCount; r++)if (!this.allowsMarks(e.child(r).marks)) return !1; 1279 return !0; 1280 } 1281 checkContent(e) { 1282 if (!this.validContent(e)) throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`); 1283 } 1284 checkAttrs(e) { 1285 Ho(this.attrs, e, "node", this.name); 1286 } 1287 allowsMarkType(e) { 1288 return this.markSet == null || this.markSet.indexOf(e) > -1; 1289 } 1290 allowsMarks(e) { 1291 if (this.markSet == null) return !0; 1292 for(let t = 0; t < e.length; t++)if (!this.allowsMarkType(e[t].type)) return !1; 1293 return !0; 1294 } 1295 allowedMarks(e) { 1296 if (this.markSet == null) return e; 1297 let t; 1298 for(let r = 0; r < e.length; r++)this.allowsMarkType(e[r].type) ? t && t.push(e[r]) : t || (t = e.slice(0, r)); 1299 return t ? t.length ? t : I.none : e; 1300 } 1301 static compile(e, t) { 1302 let r = Object.create(null); 1303 e.forEach((o, s)=>r[o] = new Uo(o, t, s)); 1304 let i = t.spec.topNode || "doc"; 1305 if (!r[i]) throw new RangeError("Schema is missing its top node type ('" + i + "')"); 1306 if (!r.text) throw new RangeError("Every schema needs a 'text' type"); 1307 for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes"); 1308 return r; 1309 } 1310 }; 1311 function Na(n, e, t) { 1312 let r = t.split("|"); 1313 return (i)=>{ 1314 let o = i === null ? "null" : typeof i; 1315 if (r.indexOf(o) < 0) throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`); 1316 }; 1317 } 1318 class Ea { 1319 constructor(e, t, r){ 1320 this.hasDefault = Object.prototype.hasOwnProperty.call(r, "default"), this.default = r.default, this.validate = typeof r.validate == "string" ? Na(e, t, r.validate) : r.validate; 1321 } 1322 get isRequired() { 1323 return !this.hasDefault; 1324 } 1325 } 1326 class En { 1327 constructor(e, t, r, i){ 1328 this.name = e, this.rank = t, this.schema = r, this.spec = i, this.attrs = _o(e, i.attrs), this.excluded = null; 1329 let o = qo(this.attrs); 1330 this.instance = o ? new I(this, o) : null; 1331 } 1332 create(e = null) { 1333 return !e && this.instance ? this.instance : new I(this, Ko(this.attrs, e)); 1334 } 1335 static compile(e, t) { 1336 let r = Object.create(null), i = 0; 1337 return e.forEach((o, s)=>r[o] = new En(o, i++, t, s)), r; 1338 } 1339 removeFromSet(e) { 1340 for(var t = 0; t < e.length; t++)e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--); 1341 return e; 1342 } 1343 isInSet(e) { 1344 for(let t = 0; t < e.length; t++)if (e[t].type == this) return e[t]; 1345 } 1346 checkAttrs(e) { 1347 Ho(this.attrs, e, "mark", this.name); 1348 } 1349 excludes(e) { 1350 return this.excluded.indexOf(e) > -1; 1351 } 1352 } 1353 Dr = class { 1354 constructor(e){ 1355 this.linebreakReplacement = null, this.cached = Object.create(null); 1356 let t = this.spec = {}; 1357 for(let i in e)t[i] = e[i]; 1358 t.nodes = $.from(e.nodes), t.marks = $.from(e.marks || {}), this.nodes = ai.compile(this.spec.nodes, this), this.marks = En.compile(this.spec.marks, this); 1359 let r = Object.create(null); 1360 for(let i in this.nodes){ 1361 if (i in this.marks) throw new RangeError(i + " can not be both a node and a mark"); 1362 let o = this.nodes[i], s = o.spec.content || "", l = o.spec.marks; 1363 if (o.contentMatch = r[s] || (r[s] = _e.parse(s, this.nodes)), o.inlineContent = o.contentMatch.inlineContent, o.spec.linebreakReplacement) { 1364 if (this.linebreakReplacement) throw new RangeError("Multiple linebreak nodes defined"); 1365 if (!o.isInline || !o.isLeaf) throw new RangeError("Linebreak replacement nodes must be inline leaf nodes"); 1366 this.linebreakReplacement = o; 1367 } 1368 o.markSet = l == "_" ? null : l ? ci(this, l.split(" ")) : l == "" || !o.inlineContent ? [] : null; 1369 } 1370 for(let i in this.marks){ 1371 let o = this.marks[i], s = o.spec.excludes; 1372 o.excluded = s == null ? [ 1373 o 1374 ] : s == "" ? [] : ci(this, s.split(" ")); 1375 } 1376 this.nodeFromJSON = (i)=>Je.fromJSON(this, i), this.markFromJSON = (i)=>I.fromJSON(this, i), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = Object.create(null); 1377 } 1378 node(e, t = null, r, i) { 1379 if (typeof e == "string") e = this.nodeType(e); 1380 else if (e instanceof ai) { 1381 if (e.schema != this) throw new RangeError("Node type from different schema used (" + e.name + ")"); 1382 } else throw new RangeError("Invalid node type: " + e); 1383 return e.createChecked(t, r, i); 1384 } 1385 text(e, t) { 1386 let r = this.nodes.text; 1387 return new un(r, r.defaultAttrs, e, I.setFrom(t)); 1388 } 1389 mark(e, t) { 1390 return typeof e == "string" && (e = this.marks[e]), e.create(t); 1391 } 1392 nodeType(e) { 1393 let t = this.nodes[e]; 1394 if (!t) throw new RangeError("Unknown node type: " + e); 1395 return t; 1396 } 1397 }; 1398 function ci(n, e) { 1399 let t = []; 1400 for(let r = 0; r < e.length; r++){ 1401 let i = e[r], o = n.marks[i], s = o; 1402 if (o) t.push(o); 1403 else for(let l in n.marks){ 1404 let a = n.marks[l]; 1405 (i == "_" || a.spec.group && a.spec.group.split(" ").indexOf(i) > -1) && t.push(s = a); 1406 } 1407 if (!s) throw new SyntaxError("Unknown mark type: '" + e[r] + "'"); 1408 } 1409 return t; 1410 } 1411 function Da(n) { 1412 return n.tag != null; 1413 } 1414 function Aa(n) { 1415 return n.style != null; 1416 } 1417 let wt = class fr { 1418 constructor(e, t){ 1419 this.schema = e, this.rules = t, this.tags = [], this.styles = []; 1420 let r = this.matchedStyles = []; 1421 t.forEach((i)=>{ 1422 if (Da(i)) this.tags.push(i); 1423 else if (Aa(i)) { 1424 let o = /[^=]*/.exec(i.style)[0]; 1425 r.indexOf(o) < 0 && r.push(o), this.styles.push(i); 1426 } 1427 }), this.normalizeLists = !this.tags.some((i)=>{ 1428 if (!/^(ul|ol)\b/.test(i.tag) || !i.node) return !1; 1429 let o = e.nodes[i.node]; 1430 return o.contentMatch.matchType(o); 1431 }); 1432 } 1433 parse(e, t = {}) { 1434 let r = new ui(this, t, !1); 1435 return r.addAll(e, I.none, t.from, t.to), r.finish(); 1436 } 1437 parseSlice(e, t = {}) { 1438 let r = new ui(this, t, !0); 1439 return r.addAll(e, I.none, t.from, t.to), b.maxOpen(r.finish()); 1440 } 1441 matchTag(e, t, r) { 1442 for(let i = r ? this.tags.indexOf(r) + 1 : 0; i < this.tags.length; i++){ 1443 let o = this.tags[i]; 1444 if (Ba(e, o.tag) && (o.namespace === void 0 || e.namespaceURI == o.namespace) && (!o.context || t.matchesContext(o.context))) { 1445 if (o.getAttrs) { 1446 let s = o.getAttrs(e); 1447 if (s === !1) continue; 1448 o.attrs = s || void 0; 1449 } 1450 return o; 1451 } 1452 } 1453 } 1454 matchStyle(e, t, r, i) { 1455 for(let o = i ? this.styles.indexOf(i) + 1 : 0; o < this.styles.length; o++){ 1456 let s = this.styles[o], l = s.style; 1457 if (!(l.indexOf(e) != 0 || s.context && !r.matchesContext(s.context) || l.length > e.length && (l.charCodeAt(e.length) != 61 || l.slice(e.length + 1) != t))) {
1458 if (s.getAttrs) { 1459 let a = s.getAttrs(t); 1460 if (a === !1) continue; 1461 s.attrs = a || void 0; 1462 } 1463 return s; 1464 } 1465 } 1466 } 1467 static schemaRules(e) { 1468 let t = []; 1469 function r(i) { 1470 let o = i.priority == null ? 50 : i.priority, s = 0; 1471 for(; s < t.length; s++){ 1472 let l = t[s]; 1473 if ((l.priority == null ? 50 : l.priority) < o) break; 1474 } 1475 t.splice(s, 0, i); 1476 } 1477 for(let i in e.marks){ 1478 let o = e.marks[i].spec.parseDOM; 1479 o && o.forEach((s)=>{ 1480 r(s = di(s)), s.mark || s.ignore || s.clearMark || (s.mark = i); 1481 }); 1482 } 1483 for(let i in e.nodes){ 1484 let o = e.nodes[i].spec.parseDOM; 1485 o && o.forEach((s)=>{ 1486 r(s = di(s)), s.node || s.ignore || s.mark || (s.node = i); 1487 }); 1488 } 1489 return t; 1490 } 1491 static fromSchema(e) { 1492 return e.cached.domParser || (e.cached.domParser = new fr(e, fr.schemaRules(e))); 1493 } 1494 }; 1495 const Yo = { 1496 address: !0, 1497 article: !0, 1498 aside: !0, 1499 blockquote: !0, 1500 body: !0, 1501 canvas: !0, 1502 dd: !0, 1503 div: !0, 1504 dl: !0, 1505 fieldset: !0, 1506 figcaption: !0, 1507 figure: !0, 1508 footer: !0, 1509 form: !0, 1510 h1: !0, 1511 h2: !0, 1512 h3: !0, 1513 h4: !0, 1514 h5: !0, 1515 h6: !0, 1516 header: !0, 1517 hgroup: !0, 1518 hr: !0, 1519 li: !0, 1520 noscript: !0, 1521 ol: !0, 1522 output: !0, 1523 p: !0, 1524 pre: !0, 1525 section: !0, 1526 table: !0, 1527 tfoot: !0, 1528 ul: !0 1529 }, Ia = { 1530 head: !0, 1531 noscript: !0, 1532 object: !0, 1533 script: !0, 1534 style: !0, 1535 title: !0 1536 }, Go = { 1537 ol: !0, 1538 ul: !0 1539 }, At = 1, ur = 2, Mt = 4; 1540 function fi(n, e, t) { 1541 return e != null ? (e ? At : 0) | (e === "full" ? ur : 0) : n && n.whitespace == "pre" ? At | ur : t & ~Mt; 1542 } 1543 class Ut { 1544 constructor(e, t, r, i, o, s){ 1545 this.type = e, this.attrs = t, this.marks = r, this.solid = i, this.options = s, this.content = [], this.activeMarks = I.none, this.match = o || (s & Mt ? null : e.contentMatch); 1546 } 1547 findWrapping(e) { 1548 if (!this.match) { 1549 if (!this.type) return []; 1550 let t = this.type.contentMatch.fillBefore(k.from(e)); 1551 if (t) this.match = this.type.contentMatch.matchFragment(t); 1552 else { 1553 let r = this.type.contentMatch, i; 1554 return (i = r.findWrapping(e.type)) ? (this.match = r, i) : null; 1555 } 1556 } 1557 return this.match.findWrapping(e.type); 1558 } 1559 finish(e) { 1560 if (!(this.options & At)) { 1561 let r = this.content[this.content.length - 1], i; 1562 if (r && r.isText && (i = /[ \t\r\n\u000c]+$/.exec(r.text))) { 1563 let o = r; 1564 r.text.length == i[0].length ? this.content.pop() : this.content[this.content.length - 1] = o.withText(o.text.slice(0, o.text.length - i[0].length)); 1565 } 1566 } 1567 let t = k.from(this.content); 1568 return !e && this.match && (t = t.append(this.match.fillBefore(k.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t; 1569 } 1570 inlineContext(e) { 1571 return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !Yo.hasOwnProperty(e.parentNode.nodeName.toLowerCase()); 1572 } 1573 } 1574 class ui { 1575 constructor(e, t, r){ 1576 this.parser = e, this.options = t, this.isOpen = r, this.open = 0, this.localPreserveWS = !1; 1577 let i = t.topNode, o, s = fi(null, t.preserveWhitespace, 0) | (r ? Mt : 0); 1578 i ? o = new Ut(i.type, i.attrs, I.none, !0, t.topMatch || i.type.contentMatch, s) : r ? o = new Ut(null, null, I.none, !0, null, s) : o = new Ut(e.schema.topNodeType, null, I.none, !0, null, s), this.nodes = [ 1579 o 1580 ], this.find = t.findPositions, this.needsBlock = !1; 1581 } 1582 get top() { 1583 return this.nodes[this.open]; 1584 } 1585 addDOM(e, t) {
vendor: 14,108 bytes, lines 1586-1877
1586 e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t); 1587 } 1588 addTextNode(e, t) { 1589 let r = e.nodeValue, i = this.top, o = i.options & ur ? "full" : this.localPreserveWS || (i.options & At) > 0, { schema: s } = this.parser; 1590 if (o === "full" || i.inlineContext(e) || /[^ \t\r\n\u000c]/.test(r)) { 1591 if (o) if (o === "full") r = r.replace(/\r\n?/g, ` 1592`); 1593 else if (s.linebreakReplacement && /[\r\n]/.test(r) && this.top.findWrapping(s.linebreakReplacement.create())) { 1594 let l = r.split(/\r?\n|\r/); 1595 for(let a = 0; a < l.length; a++)a && this.insertNode(s.linebreakReplacement.create(), t, !0), l[a] && this.insertNode(s.text(l[a]), t, !/\S/.test(l[a])); 1596 r = ""; 1597 } else r = r.replace(/\r?\n|\r/g, " "); 1598 else if (r = r.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(r) && this.open == this.nodes.length - 1) { 1599 let l = i.content[i.content.length - 1], a = e.previousSibling; 1600 (!l || a && a.nodeName == "BR" || l.isText && /[ \t\r\n\u000c]$/.test(l.text)) && (r = r.slice(1)); 1601 } 1602 r && this.insertNode(s.text(r), t, !/\S/.test(r)), this.findInText(e); 1603 } else this.findInside(e); 1604 } 1605 addElement(e, t, r) { 1606 let i = this.localPreserveWS, o = this.top; 1607 (e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0); 1608 let s = e.nodeName.toLowerCase(), l; 1609 Go.hasOwnProperty(s) && this.parser.normalizeLists && Ra(e); 1610 let a = this.options.ruleFromNode && this.options.ruleFromNode(e) || (l = this.parser.matchTag(e, this, r)); 1611 e: if (a ? a.ignore : Ia.hasOwnProperty(s)) this.findInside(e), this.ignoreFallback(e, t); 1612 else if (!a || a.skip || a.closeParent) { 1613 a && a.closeParent ? this.open = Math.max(0, this.open - 1) : a && a.skip.nodeType && (e = a.skip); 1614 let c, f = this.needsBlock; 1615 if (Yo.hasOwnProperty(s)) o.content.length && o.content[0].isInline && this.open && (this.open--, o = this.top), c = !0, o.type || (this.needsBlock = !0); 1616 else if (!e.firstChild) { 1617 this.leafFallback(e, t); 1618 break e; 1619 } 1620 let u = a && a.skip ? t : this.readStyles(e, t); 1621 u && this.addAll(e, u), c && this.sync(o), this.needsBlock = f; 1622 } else { 1623 let c = this.readStyles(e, t); 1624 c && this.addElementByRule(e, a, c, a.consuming === !1 ? l : void 0); 1625 } 1626 this.localPreserveWS = i; 1627 } 1628 leafFallback(e, t) { 1629 e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode(` 1630`), t); 1631 } 1632 ignoreFallback(e, t) { 1633 e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, !0); 1634 } 1635 readStyles(e, t) { 1636 let r = e.style; 1637 if (r && r.length) for(let i = 0; i < this.parser.matchedStyles.length; i++){ 1638 let o = this.parser.matchedStyles[i], s = r.getPropertyValue(o); 1639 if (s) for(let l = void 0;;){ 1640 let a = this.parser.matchStyle(o, s, this, l); 1641 if (!a) break; 1642 if (a.ignore) return null; 1643 if (a.clearMark ? t = t.filter((c)=>!a.clearMark(c)) : t = t.concat(this.parser.schema.marks[a.mark].create(a.attrs)), a.consuming === !1) l = a; 1644 else break; 1645 } 1646 } 1647 return t; 1648 } 1649 addElementByRule(e, t, r, i) { 1650 let o, s; 1651 if (t.node) if (s = this.parser.schema.nodes[t.node], s.isLeaf) this.insertNode(s.create(t.attrs), r, e.nodeName == "BR") || this.leafFallback(e, r); 1652 else { 1653 let a = this.enter(s, t.attrs || null, r, t.preserveWhitespace); 1654 a && (o = !0, r = a); 1655 } 1656 else { 1657 let a = this.parser.schema.marks[t.mark]; 1658 r = r.concat(a.create(t.attrs)); 1659 } 1660 let l = this.top; 1661 if (s && s.isLeaf) this.findInside(e); 1662 else if (i) this.addElement(e, r, i); 1663 else if (t.getContent) this.findInside(e), t.getContent(e, this.parser.schema).forEach((a)=>this.insertNode(a, r, !1)); 1664 else { 1665 let a = e; 1666 typeof t.contentElement == "string" ? a = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? a = t.contentElement(e) : t.contentElement && (a = t.contentElement), this.findAround(e, a, !0), this.addAll(a, r), this.findAround(e, a, !1); 1667 } 1668 o && this.sync(l) && this.open--; 1669 } 1670 addAll(e, t, r, i) { 1671 let o = r || 0; 1672 for(let s = r ? e.childNodes[r] : e.firstChild, l = i == null ? null : e.childNodes[i]; s != l; s = s.nextSibling, ++o)this.findAtPoint(e, o), this.addDOM(s, t); 1673 this.findAtPoint(e, o); 1674 } 1675 findPlace(e, t, r) { 1676 let i, o; 1677 for(let s = this.open, l = 0; s >= 0; s--){ 1678 let a = this.nodes[s], c = a.findWrapping(e); 1679 if (c && (!i || i.length > c.length + l) && (i = c, o = a, !c.length)) break; 1680 if (a.solid) { 1681 if (r) break; 1682 l += 2; 1683 } 1684 } 1685 if (!i) return null; 1686 this.sync(o); 1687 for(let s = 0; s < i.length; s++)t = this.enterInner(i[s], null, t, !1); 1688 return t; 1689 } 1690 insertNode(e, t, r) { 1691 if (e.isInline && this.needsBlock && !this.top.type) { 1692 let o = this.textblockFromContext(); 1693 o && (t = this.enterInner(o, null, t)); 1694 } 1695 let i = this.findPlace(e, t, r); 1696 if (i) { 1697 this.closeExtra(); 1698 let o = this.top; 1699 o.match && (o.match = o.match.matchType(e.type)); 1700 let s = I.none; 1701 for (let l of i.concat(e.marks))(o.type ? o.type.allowsMarkType(l.type) : hi(l.type, e.type)) && (s = l.addToSet(s)); 1702 return o.content.push(e.mark(s)), !0; 1703 } 1704 return !1; 1705 } 1706 enter(e, t, r, i) { 1707 let o = this.findPlace(e.create(t), r, !1); 1708 return o && (o = this.enterInner(e, t, r, !0, i)), o; 1709 } 1710 enterInner(e, t, r, i = !1, o) { 1711 this.closeExtra(); 1712 let s = this.top; 1713 s.match = s.match && s.match.matchType(e); 1714 let l = fi(e, o, s.options); 1715 s.options & Mt && s.content.length == 0 && (l |= Mt); 1716 let a = I.none; 1717 return r = r.filter((c)=>(s.type ? s.type.allowsMarkType(c.type) : hi(c.type, e)) ? (a = c.addToSet(a), !1) : !0), this.nodes.push(new Ut(e, t, a, i, null, l)), this.open++, r; 1718 } 1719 closeExtra(e = !1) { 1720 let t = this.nodes.length - 1; 1721 if (t > this.open) { 1722 for(; t > this.open; t--)this.nodes[t - 1].content.push(this.nodes[t].finish(e)); 1723 this.nodes.length = this.open + 1; 1724 } 1725 } 1726 finish() { 1727 return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen)); 1728 } 1729 sync(e) { 1730 for(let t = this.open; t >= 0; t--){ 1731 if (this.nodes[t] == e) return this.open = t, !0; 1732 this.localPreserveWS && (this.nodes[t].options |= At); 1733 } 1734 return !1; 1735 } 1736 get currentPos() { 1737 this.closeExtra(); 1738 let e = 0; 1739 for(let t = this.open; t >= 0; t--){ 1740 let r = this.nodes[t].content; 1741 for(let i = r.length - 1; i >= 0; i--)e += r[i].nodeSize; 1742 t && e++; 1743 } 1744 return e; 1745 } 1746 findAtPoint(e, t) { 1747 if (this.find) for(let r = 0; r < this.find.length; r++)this.find[r].node == e && this.find[r].offset == t && (this.find[r].pos = this.currentPos); 1748 } 1749 findInside(e) { 1750 if (this.find) for(let t = 0; t < this.find.length; t++)this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos); 1751 } 1752 findAround(e, t, r) { 1753 if (e != t && this.find) for(let i = 0; i < this.find.length; i++)this.find[i].pos == null && e.nodeType == 1 && e.contains(this.find[i].node) && t.compareDocumentPosition(this.find[i].node) & (r ? 2 : 4) && (this.find[i].pos = this.currentPos); 1754 } 1755 findInText(e) { 1756 if (this.find) for(let t = 0; t < this.find.length; t++)this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset)); 1757 } 1758 matchesContext(e) { 1759 if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this); 1760 let t = e.split("/"), r = this.options.context, i = !this.isOpen && (!r || r.parent.type == this.nodes[0].type), o = -(r ? r.depth + 1 : 0) + (i ? 0 : 1), s = (l, a)=>{ 1761 for(; l >= 0; l--){ 1762 let c = t[l]; 1763 if (c == "") { 1764 if (l == t.length - 1 || l == 0) continue; 1765 for(; a >= o; a--)if (s(l - 1, a)) return !0; 1766 return !1; 1767 } else { 1768 let f = a > 0 || a == 0 && i ? this.nodes[a].type : r && a >= o ? r.node(a - o).type : null; 1769 if (!f || f.name != c && !f.isInGroup(c)) return !1; 1770 a--; 1771 } 1772 } 1773 return !0; 1774 }; 1775 return s(t.length - 1, this.open); 1776 } 1777 textblockFromContext() { 1778 let e = this.options.context; 1779 if (e) for(let t = e.depth; t >= 0; t--){ 1780 let r = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType; 1781 if (r && r.isTextblock && r.defaultAttrs) return r; 1782 } 1783 for(let t in this.parser.schema.nodes){ 1784 let r = this.parser.schema.nodes[t]; 1785 if (r.isTextblock && r.defaultAttrs) return r; 1786 } 1787 } 1788 } 1789 function Ra(n) { 1790 for(let e = n.firstChild, t = null; e; e = e.nextSibling){ 1791 let r = e.nodeType == 1 ? e.nodeName.toLowerCase() : null; 1792 r && Go.hasOwnProperty(r) && t ? (t.appendChild(e), e = t) : r == "li" ? t = e : r && (t = null); 1793 } 1794 } 1795 function Ba(n, e) { 1796 return (n.matches || n.msMatchesSelector || n.webkitMatchesSelector || n.mozMatchesSelector).call(n, e); 1797 } 1798 function di(n) { 1799 let e = {}; 1800 for(let t in n)e[t] = n[t]; 1801 return e; 1802 } 1803 function hi(n, e) { 1804 let t = e.schema.nodes; 1805 for(let r in t){ 1806 let i = t[r]; 1807 if (!i.allowsMarkType(n)) continue; 1808 let o = [], s = (l)=>{ 1809 o.push(l); 1810 for(let a = 0; a < l.edgeCount; a++){ 1811 let { type: c, next: f } = l.edge(a); 1812 if (c == e || o.indexOf(f) < 0 && s(f)) return !0; 1813 } 1814 }; 1815 if (s(i.contentMatch)) return !0; 1816 } 1817 } 1818 class Ge { 1819 constructor(e, t){ 1820 this.nodes = e, this.marks = t; 1821 } 1822 serializeFragment(e, t = {}, r) { 1823 r || (r = Yt(t).createDocumentFragment()); 1824 let i = r, o = []; 1825 return e.forEach((s)=>{ 1826 if (o.length || s.marks.length) { 1827 let l = 0, a = 0; 1828 for(; l < o.length && a < s.marks.length;){ 1829 let c = s.marks[a]; 1830 if (!this.marks[c.type.name]) { 1831 a++; 1832 continue; 1833 } 1834 if (!c.eq(o[l][0]) || c.type.spec.spanning === !1) break; 1835 l++, a++; 1836 } 1837 for(; l < o.length;)i = o.pop()[1]; 1838 for(; a < s.marks.length;){ 1839 let c = s.marks[a++], f = this.serializeMark(c, s.isInline, t); 1840 f && (o.push([ 1841 c, 1842 i 1843 ]), i.appendChild(f.dom), i = f.contentDOM || f.dom); 1844 } 1845 } 1846 i.appendChild(this.serializeNodeInner(s, t)); 1847 }), r; 1848 } 1849 serializeNodeInner(e, t) { 1850 if (e.isText) return Yt(t).createTextNode(e.text); 1851 let { dom: r, contentDOM: i } = nn(Yt(t), this.nodes[e.type.name](e), null, e.attrs); 1852 if (i) { 1853 if (e.isLeaf) throw new RangeError("Content hole not allowed in a leaf node spec"); 1854 this.serializeFragment(e.content, t, i); 1855 } 1856 return r; 1857 } 1858 serializeNode(e, t = {}) { 1859 let r = this.serializeNodeInner(e, t); 1860 for(let i = e.marks.length - 1; i >= 0; i--){ 1861 let o = this.serializeMark(e.marks[i], e.isInline, t); 1862 o && ((o.contentDOM || o.dom).appendChild(r), r = o.dom); 1863 } 1864 return r; 1865 } 1866 serializeMark(e, t, r = {}) { 1867 let i = this.marks[e.type.name]; 1868 return i && nn(Yt(r), i(e, t), null, e.attrs); 1869 } 1870 static renderSpec(e, t, r = null, i) { 1871 return typeof t == "string" ? { 1872 dom: e.createTextNode(t) 1873 } : nn(e, t, r, i); 1874 } 1875 static fromSchema(e) { 1876 return e.cached.domSerializer || (e.cached.domSerializer = new Ge(this.nodesFromSchema(e), this.marksFromSchema(e))); 1877 }
1878 static nodesFromSchema(e) { 1879 let t = pi(e.nodes); 1880 return t.text || (t.text = (r)=>r.text), t; 1881 } 1882 static marksFromSchema(e) { 1883 return pi(e.marks); 1884 } 1885 } 1886 function pi(n) { 1887 let e = {}; 1888 for(let t in n){ 1889 let r = n[t].spec.toDOM; 1890 r && (e[t] = r); 1891 } 1892 return e; 1893 } 1894 function Yt(n) { 1895 return n.document || window.document; 1896 } 1897 const mi = new WeakMap; 1898 function Pa(n) { 1899 let e = mi.get(n); 1900 return e === void 0 && mi.set(n, e = za(n)), e; 1901 } 1902 function za(n) { 1903 let e = null; 1904 function t(r) { 1905 if (r && typeof r == "object") if (Array.isArray(r)) if (typeof r[0] == "string") e || (e = []), e.push(r); 1906 else for(let i = 0; i < r.length; i++)t(r[i]); 1907 else for(let i in r)t(r[i]); 1908 } 1909 return t(n), e; 1910 } 1911 function nn(n, e, t, r) { 1912 if (e.nodeType == 1) return { 1913 dom: e 1914 }; 1915 if (e.dom && e.dom.nodeType == 1) return e; 1916 let i = e[0], o; 1917 if (typeof i != "string") throw new RangeError("Invalid array passed to renderSpec"); 1918 if (r && (o = Pa(r)) && o.indexOf(e) > -1) throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack."); 1919 let s = i.indexOf(" "); 1920 s > 0 && (t = i.slice(0, s), i = i.slice(s + 1)); 1921 let l, a = t ? n.createElementNS(t, i) : n.createElement(i), c = e[1], f = 1; 1922 if (c && typeof c == "object" && c.nodeType == null && !Array.isArray(c)) { 1923 f = 2; 1924 for(let u in c)if (c[u] != null) { 1925 let d = u.indexOf(" "); 1926 d > 0 ? a.setAttributeNS(u.slice(0, d), u.slice(d + 1), c[u]) : u == "style" && a.style ? a.style.cssText = c[u] : a.setAttribute(u, c[u]); 1927 } 1928 } 1929 for(let u = f; u < e.length; u++){ 1930 let d = e[u]; 1931 if (d === 0) { 1932 if (u < e.length - 1 || u > f) throw new RangeError("Content hole must be the only child of its parent node"); 1933 return { 1934 dom: a, 1935 contentDOM: a 1936 }; 1937 } else if (typeof d == "string") a.appendChild(n.createTextNode(d)); 1938 else { 1939 let { dom: h, contentDOM: p } = nn(n, d, t, r); 1940 if (a.appendChild(h), p) { 1941 if (l) throw new RangeError("Multiple content holes"); 1942 l = p; 1943 } 1944 } 1945 } 1946 return { 1947 dom: a, 1948 contentDOM: l 1949 }; 1950 } 1951 const Xo = 65535, Qo = Math.pow(2, 16); 1952 function Fa(n, e) { 1953 return n + e * Qo; 1954 } 1955 function gi(n) { 1956 return n & Xo; 1957 } 1958 function La(n) { 1959 return (n - (n & Xo)) / Qo; 1960 } 1961 const Zo = 1, es = 2, rn = 4, ts = 8; 1962 class dr { 1963 constructor(e, t, r){ 1964 this.pos = e, this.delInfo = t, this.recover = r; 1965 } 1966 get deleted() { 1967 return (this.delInfo & ts) > 0; 1968 } 1969 get deletedBefore() { 1970 return (this.delInfo & (Zo | rn)) > 0; 1971 } 1972 get deletedAfter() { 1973 return (this.delInfo & (es | rn)) > 0; 1974 } 1975 get deletedAcross() { 1976 return (this.delInfo & rn) > 0; 1977 } 1978 } 1979 class Z { 1980 constructor(e, t = !1){ 1981 if (this.ranges = e, this.inverted = t, !e.length && Z.empty) return Z.empty; 1982 } 1983 recover(e) { 1984 let t = 0, r = gi(e); 1985 if (!this.inverted) for(let i = 0; i < r; i++)t += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1]; 1986 return this.ranges[r * 3] + t + La(e); 1987 } 1988 mapResult(e, t = 1) { 1989 return this._map(e, t, !1); 1990 } 1991 map(e, t = 1) { 1992 return this._map(e, t, !0); 1993 } 1994 _map(e, t, r) { 1995 let i = 0, o = this.inverted ? 2 : 1, s = this.inverted ? 1 : 2; 1996 for(let l = 0; l < this.ranges.length; l += 3){ 1997 let a = this.ranges[l] - (this.inverted ? i : 0); 1998 if (a > e) break; 1999 let c = this.ranges[l + o], f = this.ranges[l + s], u = a + c; 2000 if (e <= u) { 2001 let d = c ? e == a ? -1 : e == u ? 1 : t : t, h = a + i + (d < 0 ? 0 : f); 2002 if (r) return h; 2003 let p = e == (t < 0 ? a : u) ? null : Fa(l / 3, e - a), m = e == a ? es : e == u ? Zo : rn; 2004 return (t < 0 ? e != a : e != u) && (m |= ts), new dr(h, m, p); 2005 } 2006 i += f - c; 2007 } 2008 return r ? e + i : new dr(e + i, 0, null); 2009 } 2010 touches(e, t) { 2011 let r = 0, i = gi(t), o = this.inverted ? 2 : 1, s = this.inverted ? 1 : 2; 2012 for(let l = 0; l < this.ranges.length; l += 3){ 2013 let a = this.ranges[l] - (this.inverted ? r : 0); 2014 if (a > e) break; 2015 let c = this.ranges[l + o], f = a + c; 2016 if (e <= f && l == i * 3) return !0; 2017 r += this.ranges[l + s] - c; 2018 } 2019 return !1; 2020 }
vendor: 50,397 bytes, lines 2021-3205
2021 forEach(e) { 2022 let t = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2; 2023 for(let i = 0, o = 0; i < this.ranges.length; i += 3){ 2024 let s = this.ranges[i], l = s - (this.inverted ? o : 0), a = s + (this.inverted ? 0 : o), c = this.ranges[i + t], f = this.ranges[i + r]; 2025 e(l, l + c, a, a + f), o += f - c; 2026 } 2027 } 2028 invert() { 2029 return new Z(this.ranges, !this.inverted); 2030 } 2031 toString() { 2032 return (this.inverted ? "-" : "") + JSON.stringify(this.ranges); 2033 } 2034 static offset(e) { 2035 return e == 0 ? Z.empty : new Z(e < 0 ? [ 2036 0, 2037 -e, 2038 0 2039 ] : [ 2040 0, 2041 0, 2042 e 2043 ]); 2044 } 2045 } 2046 Z.empty = new Z([]); 2047 class dn { 2048 constructor(e, t, r = 0, i = e ? e.length : 0){ 2049 this.mirror = t, this.from = r, this.to = i, this._maps = e || [], this.ownData = !(e || t); 2050 } 2051 get maps() { 2052 return this._maps; 2053 } 2054 slice(e = 0, t = this.maps.length) { 2055 return new dn(this._maps, this.mirror, e, t); 2056 } 2057 appendMap(e, t) { 2058 this.ownData || (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), this.ownData = !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t); 2059 } 2060 appendMapping(e) { 2061 for(let t = 0, r = this._maps.length; t < e._maps.length; t++){ 2062 let i = e.getMirror(t); 2063 this.appendMap(e._maps[t], i != null && i < t ? r + i : void 0); 2064 } 2065 } 2066 getMirror(e) { 2067 if (this.mirror) { 2068 for(let t = 0; t < this.mirror.length; t++)if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)]; 2069 } 2070 } 2071 setMirror(e, t) { 2072 this.mirror || (this.mirror = []), this.mirror.push(e, t); 2073 } 2074 appendMappingInverted(e) { 2075 for(let t = e.maps.length - 1, r = this._maps.length + e._maps.length; t >= 0; t--){ 2076 let i = e.getMirror(t); 2077 this.appendMap(e._maps[t].invert(), i != null && i > t ? r - i - 1 : void 0); 2078 } 2079 } 2080 invert() { 2081 let e = new dn; 2082 return e.appendMappingInverted(this), e; 2083 } 2084 map(e, t = 1) { 2085 if (this.mirror) return this._map(e, t, !0); 2086 for(let r = this.from; r < this.to; r++)e = this._maps[r].map(e, t); 2087 return e; 2088 } 2089 mapResult(e, t = 1) { 2090 return this._map(e, t, !1); 2091 } 2092 _map(e, t, r) { 2093 let i = 0; 2094 for(let o = this.from; o < this.to; o++){ 2095 let s = this._maps[o], l = s.mapResult(e, t); 2096 if (l.recover != null) { 2097 let a = this.getMirror(o); 2098 if (a != null && a > o && a < this.to) { 2099 o = a, e = this._maps[a].recover(l.recover); 2100 continue; 2101 } 2102 } 2103 i |= l.delInfo, e = l.pos; 2104 } 2105 return r ? e : new dr(e, i, null); 2106 } 2107 } 2108 const Jn = Object.create(null); 2109 class H { 2110 getMap() { 2111 return Z.empty; 2112 } 2113 merge(e) { 2114 return null; 2115 } 2116 static fromJSON(e, t) { 2117 if (!t || !t.stepType) throw new RangeError("Invalid input for Step.fromJSON"); 2118 let r = Jn[t.stepType]; 2119 if (!r) throw new RangeError(`No step type ${t.stepType} defined`); 2120 return r.fromJSON(e, t); 2121 } 2122 static jsonID(e, t) { 2123 if (e in Jn) throw new RangeError("Duplicate use of step JSON ID " + e); 2124 return Jn[e] = t, t.prototype.jsonID = e, t; 2125 } 2126 } 2127 class F { 2128 constructor(e, t){ 2129 this.doc = e, this.failed = t; 2130 } 2131 static ok(e) { 2132 return new F(e, null); 2133 } 2134 static fail(e) { 2135 return new F(null, e); 2136 } 2137 static fromReplace(e, t, r, i) { 2138 try { 2139 return F.ok(e.replace(t, r, i)); 2140 } catch (o) { 2141 if (o instanceof Et) return F.fail(o.message); 2142 throw o; 2143 } 2144 } 2145 } 2146 function Ar(n, e, t) { 2147 let r = []; 2148 for(let i = 0; i < n.childCount; i++){ 2149 let o = n.child(i); 2150 o.content.size && (o = o.copy(Ar(o.content, e, o))), o.isInline && (o = e(o, t, i)), r.push(o); 2151 } 2152 return k.fromArray(r); 2153 } 2154 class me extends H { 2155 constructor(e, t, r){ 2156 super(), this.from = e, this.to = t, this.mark = r; 2157 } 2158 apply(e) { 2159 let t = e.slice(this.from, this.to), r = e.resolve(this.from), i = r.node(r.sharedDepth(this.to)), o = new b(Ar(t.content, (s, l)=>!s.isAtom || !l.type.allowsMarkType(this.mark.type) ? s : s.mark(this.mark.addToSet(s.marks)), i), t.openStart, t.openEnd); 2160 return F.fromReplace(e, this.from, this.to, o); 2161 } 2162 invert() { 2163 return new re(this.from, this.to, this.mark); 2164 } 2165 map(e) { 2166 let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1); 2167 return t.deleted && r.deleted || t.pos >= r.pos ? null : new me(t.pos, r.pos, this.mark); 2168 } 2169 merge(e) { 2170 return e instanceof me && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new me(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null; 2171 } 2172 toJSON() { 2173 return { 2174 stepType: "addMark", 2175 mark: this.mark.toJSON(), 2176 from: this.from, 2177 to: this.to 2178 }; 2179 } 2180 static fromJSON(e, t) { 2181 if (typeof t.from != "number" || typeof t.to != "number") throw new RangeError("Invalid input for AddMarkStep.fromJSON"); 2182 return new me(t.from, t.to, e.markFromJSON(t.mark)); 2183 } 2184 } 2185 H.jsonID("addMark", me); 2186 class re extends H { 2187 constructor(e, t, r){ 2188 super(), this.from = e, this.to = t, this.mark = r; 2189 } 2190 apply(e) { 2191 let t = e.slice(this.from, this.to), r = new b(Ar(t.content, (i)=>i.mark(this.mark.removeFromSet(i.marks)), e), t.openStart, t.openEnd); 2192 return F.fromReplace(e, this.from, this.to, r); 2193 } 2194 invert() { 2195 return new me(this.from, this.to, this.mark); 2196 } 2197 map(e) { 2198 let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1); 2199 return t.deleted && r.deleted || t.pos >= r.pos ? null : new re(t.pos, r.pos, this.mark); 2200 } 2201 merge(e) { 2202 return e instanceof re && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new re(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null; 2203 } 2204 toJSON() { 2205 return { 2206 stepType: "removeMark", 2207 mark: this.mark.toJSON(), 2208 from: this.from, 2209 to: this.to 2210 }; 2211 } 2212 static fromJSON(e, t) { 2213 if (typeof t.from != "number" || typeof t.to != "number") throw new RangeError("Invalid input for RemoveMarkStep.fromJSON"); 2214 return new re(t.from, t.to, e.markFromJSON(t.mark)); 2215 } 2216 } 2217 H.jsonID("removeMark", re); 2218 class ve extends H { 2219 constructor(e, t){ 2220 super(), this.pos = e, this.mark = t; 2221 } 2222 apply(e) { 2223 let t = e.nodeAt(this.pos); 2224 if (!t) return F.fail("No node at mark step's position"); 2225 let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks)); 2226 return F.fromReplace(e, this.pos, this.pos + 1, new b(k.from(r), 0, t.isLeaf ? 0 : 1)); 2227 } 2228 invert(e) { 2229 let t = e.nodeAt(this.pos); 2230 if (t) { 2231 let r = this.mark.addToSet(t.marks); 2232 if (r.length == t.marks.length) { 2233 for(let i = 0; i < t.marks.length; i++)if (!t.marks[i].isInSet(r)) return new ve(this.pos, t.marks[i]); 2234 return new ve(this.pos, this.mark); 2235 } 2236 } 2237 return new Ue(this.pos, this.mark); 2238 } 2239 map(e) { 2240 let t = e.mapResult(this.pos, 1); 2241 return t.deletedAfter ? null : new ve(t.pos, this.mark); 2242 } 2243 toJSON() { 2244 return { 2245 stepType: "addNodeMark", 2246 pos: this.pos, 2247 mark: this.mark.toJSON() 2248 }; 2249 } 2250 static fromJSON(e, t) { 2251 if (typeof t.pos != "number") throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON"); 2252 return new ve(t.pos, e.markFromJSON(t.mark)); 2253 } 2254 } 2255 H.jsonID("addNodeMark", ve); 2256 class Ue extends H { 2257 constructor(e, t){ 2258 super(), this.pos = e, this.mark = t; 2259 } 2260 apply(e) { 2261 let t = e.nodeAt(this.pos); 2262 if (!t) return F.fail("No node at mark step's position"); 2263 let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks)); 2264 return F.fromReplace(e, this.pos, this.pos + 1, new b(k.from(r), 0, t.isLeaf ? 0 : 1)); 2265 } 2266 invert(e) { 2267 let t = e.nodeAt(this.pos); 2268 return !t || !this.mark.isInSet(t.marks) ? this : new ve(this.pos, this.mark); 2269 } 2270 map(e) { 2271 let t = e.mapResult(this.pos, 1); 2272 return t.deletedAfter ? null : new Ue(t.pos, this.mark); 2273 } 2274 toJSON() { 2275 return { 2276 stepType: "removeNodeMark", 2277 pos: this.pos, 2278 mark: this.mark.toJSON() 2279 }; 2280 } 2281 static fromJSON(e, t) { 2282 if (typeof t.pos != "number") throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON"); 2283 return new Ue(t.pos, e.markFromJSON(t.mark)); 2284 } 2285 } 2286 H.jsonID("removeNodeMark", Ue); 2287 class P extends H { 2288 constructor(e, t, r, i = !1){ 2289 super(), this.from = e, this.to = t, this.slice = r, this.structure = i; 2290 } 2291 apply(e) { 2292 return this.structure && hr(e, this.from, this.to) ? F.fail("Structure replace would overwrite content") : F.fromReplace(e, this.from, this.to, this.slice); 2293 } 2294 getMap() { 2295 return new Z([ 2296 this.from, 2297 this.to - this.from, 2298 this.slice.size 2299 ]); 2300 } 2301 invert(e) { 2302 return new P(this.from, this.from + this.slice.size, e.slice(this.from, this.to)); 2303 } 2304 map(e) { 2305 let t = e.mapResult(this.to, -1), r = this.from == this.to && P.MAP_BIAS < 0 ? t : e.mapResult(this.from, 1); 2306 return r.deletedAcross && t.deletedAcross ? null : new P(r.pos, Math.max(r.pos, t.pos), this.slice, this.structure); 2307 } 2308 merge(e) { 2309 if (!(e instanceof P) || e.structure || this.structure) return null; 2310 if (this.from + this.slice.size == e.from && !this.slice.openEnd && !e.slice.openStart) { 2311 let t = this.slice.size + e.slice.size == 0 ? b.empty : new b(this.slice.content.append(e.slice.content), this.slice.openStart, e.slice.openEnd); 2312 return new P(this.from, this.to + (e.to - e.from), t, this.structure); 2313 } else if (e.to == this.from && !this.slice.openStart && !e.slice.openEnd) { 2314 let t = this.slice.size + e.slice.size == 0 ? b.empty : new b(e.slice.content.append(this.slice.content), e.slice.openStart, this.slice.openEnd); 2315 return new P(e.from, this.to, t, this.structure); 2316 } else return null; 2317 } 2318 toJSON() { 2319 let e = { 2320 stepType: "replace", 2321 from: this.from, 2322 to: this.to 2323 }; 2324 return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e; 2325 } 2326 static fromJSON(e, t) { 2327 if (typeof t.from != "number" || typeof t.to != "number") throw new RangeError("Invalid input for ReplaceStep.fromJSON"); 2328 return new P(t.from, t.to, b.fromJSON(e, t.slice), !!t.structure); 2329 } 2330 } 2331 P.MAP_BIAS = 1; 2332 H.jsonID("replace", P); 2333 class L extends H { 2334 constructor(e, t, r, i, o, s, l = !1){ 2335 super(), this.from = e, this.to = t, this.gapFrom = r, this.gapTo = i, this.slice = o, this.insert = s, this.structure = l; 2336 } 2337 apply(e) { 2338 if (this.structure && (hr(e, this.from, this.gapFrom) || hr(e, this.gapTo, this.to))) return F.fail("Structure gap-replace would overwrite content"); 2339 let t = e.slice(this.gapFrom, this.gapTo); 2340 if (t.openStart || t.openEnd) return F.fail("Gap is not a flat range"); 2341 let r = this.slice.insertAt(this.insert, t.content); 2342 return r ? F.fromReplace(e, this.from, this.to, r) : F.fail("Content does not fit in gap"); 2343 } 2344 getMap() { 2345 return new Z([ 2346 this.from, 2347 this.gapFrom - this.from, 2348 this.insert, 2349 this.gapTo, 2350 this.to - this.gapTo, 2351 this.slice.size - this.insert 2352 ]); 2353 } 2354 invert(e) { 2355 let t = this.gapTo - this.gapFrom; 2356 return new L(this.from, this.from + this.slice.size + t, this.from + this.insert, this.from + this.insert + t, e.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure); 2357 } 2358 map(e) { 2359 let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1), i = this.from == this.gapFrom ? t.pos : e.map(this.gapFrom, -1), o = this.to == this.gapTo ? r.pos : e.map(this.gapTo, 1); 2360 return t.deletedAcross && r.deletedAcross || i < t.pos || o > r.pos ? null : new L(t.pos, r.pos, i, o, this.slice, this.insert, this.structure); 2361 } 2362 toJSON() { 2363 let e = { 2364 stepType: "replaceAround", 2365 from: this.from, 2366 to: this.to, 2367 gapFrom: this.gapFrom, 2368 gapTo: this.gapTo, 2369 insert: this.insert 2370 }; 2371 return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e; 2372 } 2373 static fromJSON(e, t) { 2374 if (typeof t.from != "number" || typeof t.to != "number" || typeof t.gapFrom != "number" || typeof t.gapTo != "number" || typeof t.insert != "number") throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON"); 2375 return new L(t.from, t.to, t.gapFrom, t.gapTo, b.fromJSON(e, t.slice), t.insert, !!t.structure); 2376 } 2377 } 2378 H.jsonID("replaceAround", L); 2379 function hr(n, e, t) { 2380 let r = n.resolve(e), i = t - e, o = r.depth; 2381 for(; i > 0 && o > 0 && r.indexAfter(o) == r.node(o).childCount;)o--, i--; 2382 if (i > 0) { 2383 let s = r.node(o).maybeChild(r.indexAfter(o)); 2384 for(; i > 0;){ 2385 if (!s || s.isLeaf) return !0; 2386 s = s.firstChild, i--; 2387 } 2388 } 2389 return !1; 2390 } 2391 function Va(n, e, t, r) { 2392 let i = [], o = [], s, l; 2393 n.doc.nodesBetween(e, t, (a, c, f)=>{ 2394 if (!a.isInline) return; 2395 let u = a.marks; 2396 if (!r.isInSet(u) && f.type.allowsMarkType(r.type)) { 2397 let d = Math.max(c, e), h = Math.min(c + a.nodeSize, t), p = r.addToSet(u); 2398 for(let m = 0; m < u.length; m++)u[m].isInSet(p) || (s && s.to == d && s.mark.eq(u[m]) ? s.to = h : i.push(s = new re(d, h, u[m]))); 2399 l && l.to == d ? l.to = h : o.push(l = new me(d, h, r)); 2400 } 2401 }), i.forEach((a)=>n.step(a)), o.forEach((a)=>n.step(a)); 2402 } 2403 function $a(n, e, t, r) { 2404 let i = [], o = 0; 2405 n.doc.nodesBetween(e, t, (s, l)=>{ 2406 if (!s.isInline) return; 2407 o++; 2408 let a = null; 2409 if (r instanceof En) { 2410 let c = s.marks, f; 2411 for(; f = r.isInSet(c);)(a || (a = [])).push(f), c = f.removeFromSet(c); 2412 } else r ? r.isInSet(s.marks) && (a = [ 2413 r 2414 ]) : a = s.marks; 2415 if (a && a.length) { 2416 let c = Math.min(l + s.nodeSize, t); 2417 for(let f = 0; f < a.length; f++){ 2418 let u = a[f], d; 2419 for(let h = 0; h < i.length; h++){ 2420 let p = i[h]; 2421 p.step == o - 1 && u.eq(i[h].style) && (d = p); 2422 } 2423 d ? (d.to = c, d.step = o) : i.push({ 2424 style: u, 2425 from: Math.max(l, e), 2426 to: c, 2427 step: o 2428 }); 2429 } 2430 } 2431 }), i.forEach((s)=>n.step(new re(s.from, s.to, s.style))); 2432 } 2433 function Ir(n, e, t, r = t.contentMatch, i = !0) { 2434 let o = n.doc.nodeAt(e), s = [], l = e + 1; 2435 for(let a = 0; a < o.childCount; a++){ 2436 let c = o.child(a), f = l + c.nodeSize, u = r.matchType(c.type); 2437 if (!u) s.push(new P(l, f, b.empty)); 2438 else { 2439 r = u; 2440 for(let d = 0; d < c.marks.length; d++)t.allowsMarkType(c.marks[d].type) || n.step(new re(l, f, c.marks[d])); 2441 if (i && c.isText && t.whitespace != "pre") { 2442 let d, h = /\r?\n|\r/g, p; 2443 for(; d = h.exec(c.text);)p || (p = new b(k.from(t.schema.text(" ", t.allowedMarks(c.marks))), 0, 0)), s.push(new P(l + d.index, l + d.index + d[0].length, p)); 2444 } 2445 } 2446 l = f; 2447 } 2448 if (!r.validEnd) { 2449 let a = r.fillBefore(k.empty, !0); 2450 n.replace(l, l, new b(a, 0, 0)); 2451 } 2452 for(let a = s.length - 1; a >= 0; a--)n.step(s[a]); 2453 } 2454 function ja(n, e, t) { 2455 return (e == 0 || n.canReplace(e, n.childCount)) && (t == n.childCount || n.canReplace(0, t)); 2456 } 2457 function ht(n) { 2458 let t = n.parent.content.cutByIndex(n.startIndex, n.endIndex); 2459 for(let r = n.depth, i = 0, o = 0;; --r){ 2460 let s = n.$from.node(r), l = n.$from.index(r) + i, a = n.$to.indexAfter(r) - o; 2461 if (r < n.depth && s.canReplace(l, a, t)) return r; 2462 if (r == 0 || s.type.spec.isolating || !ja(s, l, a)) break; 2463 l && (i = 1), a < s.childCount && (o = 1); 2464 } 2465 return null; 2466 } 2467 function Wa(n, e, t) { 2468 let { $from: r, $to: i, depth: o } = e, s = r.before(o + 1), l = i.after(o + 1), a = s, c = l, f = k.empty, u = 0; 2469 for(let p = o, m = !1; p > t; p--)m || r.index(p) > 0 ? (m = !0, f = k.from(r.node(p).copy(f)), u++) : a--; 2470 let d = k.empty, h = 0; 2471 for(let p = o, m = !1; p > t; p--)m || i.after(p + 1) < i.end(p) ? (m = !0, d = k.from(i.node(p).copy(d)), h++) : c++; 2472 n.step(new L(a, c, s, l, new b(f.append(d), u, h), f.size - u, !0)); 2473 } 2474 function ns(n, e, t = null, r = n) { 2475 let i = Ja(n, e), o = i && qa(r, e); 2476 return o ? i.map(yi).concat({ 2477 type: e, 2478 attrs: t 2479 }).concat(o.map(yi)) : null; 2480 } 2481 function yi(n) { 2482 return { 2483 type: n, 2484 attrs: null 2485 }; 2486 } 2487 function Ja(n, e) { 2488 let { parent: t, startIndex: r, endIndex: i } = n, o = t.contentMatchAt(r).findWrapping(e); 2489 if (!o) return null; 2490 let s = o.length ? o[0] : e; 2491 return t.canReplaceWith(r, i, s) ? o : null; 2492 } 2493 function qa(n, e) { 2494 let { parent: t, startIndex: r, endIndex: i } = n, o = t.child(r), s = e.contentMatch.findWrapping(o.type); 2495 if (!s) return null; 2496 let a = (s.length ? s[s.length - 1] : e).contentMatch; 2497 for(let c = r; a && c < i; c++)a = a.matchType(t.child(c).type); 2498 return !a || !a.validEnd ? null : s; 2499 } 2500 function Ka(n, e, t) { 2501 let r = k.empty; 2502 for(let s = t.length - 1; s >= 0; s--){ 2503 if (r.size) { 2504 let l = t[s].type.contentMatch.matchFragment(r); 2505 if (!l || !l.validEnd) throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper"); 2506 } 2507 r = k.from(t[s].type.create(t[s].attrs, r)); 2508 } 2509 let i = e.start, o = e.end; 2510 n.step(new L(i, o, i, o, new b(r, 0, 0), t.length, !0)); 2511 } 2512 function Ha(n, e, t, r, i) { 2513 if (!r.isTextblock) throw new RangeError("Type given to setBlockType should be a textblock"); 2514 let o = n.steps.length; 2515 n.doc.nodesBetween(e, t, (s, l)=>{ 2516 let a = typeof i == "function" ? i(s) : i; 2517 if (s.isTextblock && !s.hasMarkup(r, a) && _a(n.doc, n.mapping.slice(o).map(l), r)) { 2518 let c = null; 2519 if (r.schema.linebreakReplacement) { 2520 let h = r.whitespace == "pre", p = !!r.contentMatch.matchType(r.schema.linebreakReplacement); 2521 h && !p ? c = !1 : !h && p && (c = !0); 2522 } 2523 c === !1 && is(n, s, l, o), Ir(n, n.mapping.slice(o).map(l, 1), r, void 0, c === null); 2524 let f = n.mapping.slice(o), u = f.map(l, 1), d = f.map(l + s.nodeSize, 1); 2525 return n.step(new L(u, d, u + 1, d - 1, new b(k.from(r.create(a, null, s.marks)), 0, 0), 1, !0)), c === !0 && rs(n, s, l, o), !1; 2526 } 2527 }); 2528 } 2529 function rs(n, e, t, r) { 2530 e.forEach((i, o)=>{ 2531 if (i.isText) { 2532 let s, l = /\r?\n|\r/g; 2533 for(; s = l.exec(i.text);){ 2534 let a = n.mapping.slice(r).map(t + 1 + o + s.index); 2535 n.replaceWith(a, a + 1, e.type.schema.linebreakReplacement.create()); 2536 } 2537 } 2538 }); 2539 } 2540 function is(n, e, t, r) { 2541 e.forEach((i, o)=>{ 2542 if (i.type == i.type.schema.linebreakReplacement) { 2543 let s = n.mapping.slice(r).map(t + 1 + o); 2544 n.replaceWith(s, s + 1, e.type.schema.text(` 2545`)); 2546 } 2547 }); 2548 } 2549 function _a(n, e, t) { 2550 let r = n.resolve(e), i = r.index(); 2551 return r.parent.canReplaceWith(i, i + 1, t); 2552 } 2553 function Ua(n, e, t, r, i) { 2554 let o = n.doc.nodeAt(e); 2555 if (!o) throw new RangeError("No node at given position"); 2556 t || (t = o.type); 2557 let s = t.create(r, null, i || o.marks); 2558 if (o.isLeaf) return n.replaceWith(e, e + o.nodeSize, s); 2559 if (!t.validContent(o.content)) throw new RangeError("Invalid content for node type " + t.name); 2560 n.step(new L(e, e + o.nodeSize, e + 1, e + o.nodeSize - 1, new b(k.from(s), 0, 0), 1, !0)); 2561 } 2562 function be(n, e, t = 1, r) { 2563 let i = n.resolve(e), o = i.depth - t, s = r && r[r.length - 1] || i.parent; 2564 if (o < 0 || i.parent.type.spec.isolating || !i.parent.canReplace(i.index(), i.parent.childCount) || !s.type.validContent(i.parent.content.cutByIndex(i.index(), i.parent.childCount))) return !1; 2565 for(let c = i.depth - 1, f = t - 2; c > o; c--, f--){ 2566 let u = i.node(c), d = i.index(c); 2567 if (u.type.spec.isolating) return !1; 2568 let h = u.content.cutByIndex(d, u.childCount), p = r && r[f + 1]; 2569 p && (h = h.replaceChild(0, p.type.create(p.attrs))); 2570 let m = r && r[f] || u; 2571 if (!u.canReplace(d + 1, u.childCount) || !m.type.validContent(h)) return !1; 2572 } 2573 let l = i.indexAfter(o), a = r && r[0]; 2574 return i.node(o).canReplaceWith(l, l, a ? a.type : i.node(o + 1).type); 2575 } 2576 function Ya(n, e, t = 1, r) { 2577 let i = n.doc.resolve(e), o = k.empty, s = k.empty; 2578 for(let l = i.depth, a = i.depth - t, c = t - 1; l > a; l--, c--){ 2579 o = k.from(i.node(l).copy(o)); 2580 let f = r && r[c]; 2581 s = k.from(f ? f.type.create(f.attrs, s) : i.node(l).copy(s)); 2582 } 2583 n.step(new P(e, e, new b(o.append(s), t, t), !0)); 2584 } 2585 function Xe(n, e) { 2586 let t = n.resolve(e), r = t.index(); 2587 return ss(t.nodeBefore, t.nodeAfter) && t.parent.canReplace(r, r + 1); 2588 } 2589 function Ga(n, e) { 2590 e.content.size || n.type.compatibleContent(e.type); 2591 let t = n.contentMatchAt(n.childCount), { linebreakReplacement: r } = n.type.schema; 2592 for(let i = 0; i < e.childCount; i++){ 2593 let o = e.child(i), s = o.type == r ? n.type.schema.nodes.text : o.type; 2594 if (t = t.matchType(s), !t || !n.type.allowsMarks(o.marks)) return !1; 2595 } 2596 return t.validEnd; 2597 } 2598 function ss(n, e) { 2599 return !!(n && e && !n.isLeaf && Ga(n, e)); 2600 } 2601 function Dn(n, e, t = -1) { 2602 let r = n.resolve(e); 2603 for(let i = r.depth;; i--){ 2604 let o, s, l = r.index(i); 2605 if (i == r.depth ? (o = r.nodeBefore, s = r.nodeAfter) : t > 0 ? (o = r.node(i + 1), l++, s = r.node(i).maybeChild(l)) : (o = r.node(i).maybeChild(l - 1), s = r.node(i + 1)), o && !o.isTextblock && ss(o, s) && r.node(i).canReplace(l, l + 1)) return e; 2606 if (i == 0) break; 2607 e = t < 0 ? r.before(i) : r.after(i); 2608 } 2609 } 2610 function Xa(n, e, t) { 2611 let r = null, { linebreakReplacement: i } = n.doc.type.schema, o = n.doc.resolve(e - t), s = o.node().type; 2612 if (i && s.inlineContent) { 2613 let f = s.whitespace == "pre", u = !!s.contentMatch.matchType(i); 2614 f && !u ? r = !1 : !f && u && (r = !0); 2615 } 2616 let l = n.steps.length; 2617 if (r === !1) { 2618 let f = n.doc.resolve(e + t); 2619 is(n, f.node(), f.before(), l); 2620 } 2621 s.inlineContent && Ir(n, e + t - 1, s, o.node().contentMatchAt(o.index()), r == null); 2622 let a = n.mapping.slice(l), c = a.map(e - t); 2623 if (n.step(new P(c, a.map(e + t, -1), b.empty, !0)), r === !0) { 2624 let f = n.doc.resolve(c); 2625 rs(n, f.node(), f.before(), n.steps.length); 2626 } 2627 return n; 2628 } 2629 function Qa(n, e, t) { 2630 let r = n.resolve(e); 2631 if (r.parent.canReplaceWith(r.index(), r.index(), t)) return e; 2632 if (r.parentOffset == 0) for(let i = r.depth - 1; i >= 0; i--){ 2633 let o = r.index(i); 2634 if (r.node(i).canReplaceWith(o, o, t)) return r.before(i + 1); 2635 if (o > 0) return null; 2636 } 2637 if (r.parentOffset == r.parent.content.size) for(let i = r.depth - 1; i >= 0; i--){ 2638 let o = r.indexAfter(i); 2639 if (r.node(i).canReplaceWith(o, o, t)) return r.after(i + 1); 2640 if (o < r.node(i).childCount) return null; 2641 } 2642 return null; 2643 } 2644 function Za(n, e, t) { 2645 let r = n.resolve(e); 2646 if (!t.content.size) return e; 2647 let i = t.content; 2648 for(let o = 0; o < t.openStart; o++)i = i.firstChild.content; 2649 for(let o = 1; o <= (t.openStart == 0 && t.size ? 2 : 1); o++)for(let s = r.depth; s >= 0; s--){ 2650 let l = s == r.depth ? 0 : r.pos <= (r.start(s + 1) + r.end(s + 1)) / 2 ? -1 : 1, a = r.index(s) + (l > 0 ? 1 : 0), c = r.node(s), f = !1; 2651 if (o == 1) f = c.canReplace(a, a, i); 2652 else { 2653 let u = c.contentMatchAt(a).findWrapping(i.firstChild.type); 2654 f = u && c.canReplaceWith(a, a, u[0]); 2655 } 2656 if (f) return l == 0 ? r.pos : l < 0 ? r.before(s + 1) : r.after(s + 1); 2657 } 2658 return null; 2659 } 2660 function An(n, e, t = e, r = b.empty) { 2661 if (e == t && !r.size) return null; 2662 let i = n.resolve(e), o = n.resolve(t); 2663 return ls(i, o, r) ? new P(e, t, r) : new ec(i, o, r).fit(); 2664 } 2665 function ls(n, e, t) { 2666 return !t.openStart && !t.openEnd && n.start() == e.start() && n.parent.canReplace(n.index(), e.index(), t.content); 2667 } 2668 class ec { 2669 constructor(e, t, r){ 2670 this.$from = e, this.$to = t, this.unplaced = r, this.frontier = [], this.placed = k.empty; 2671 for(let i = 0; i <= e.depth; i++){ 2672 let o = e.node(i); 2673 this.frontier.push({ 2674 type: o.type, 2675 match: o.contentMatchAt(e.indexAfter(i)) 2676 }); 2677 } 2678 for(let i = e.depth; i > 0; i--)this.placed = k.from(e.node(i).copy(this.placed)); 2679 } 2680 get depth() { 2681 return this.frontier.length - 1; 2682 } 2683 fit() { 2684 for(; this.unplaced.size;){ 2685 let c = this.findFittable(); 2686 c ? this.placeNodes(c) : this.openMore() || this.dropNode(); 2687 } 2688 let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, r = this.$from, i = this.close(e < 0 ? this.$to : r.doc.resolve(e)); 2689 if (!i) return null; 2690 let o = this.placed, s = r.depth, l = i.depth; 2691 for(; s && l && o.childCount == 1;)o = o.firstChild.content, s--, l--; 2692 let a = new b(o, s, l); 2693 return e > -1 ? new L(r.pos, e, this.$to.pos, this.$to.end(), a, t) : a.size || r.pos != this.$to.pos ? new P(r.pos, i.pos, a) : null; 2694 } 2695 findFittable() { 2696 let e = this.unplaced.openStart; 2697 for(let t = this.unplaced.content, r = 0, i = this.unplaced.openEnd; r < e; r++){ 2698 let o = t.firstChild; 2699 if (t.childCount > 1 && (i = 0), o.type.spec.isolating && i <= r) { 2700 e = r; 2701 break; 2702 } 2703 t = o.content; 2704 } 2705 for(let t = 1; t <= 2; t++)for(let r = t == 1 ? e : this.unplaced.openStart; r >= 0; r--){ 2706 let i, o = null; 2707 r ? (o = ki(this.unplaced.content, r - 1).firstChild, i = o.content) : i = this.unplaced.content; 2708 let s = i.firstChild; 2709 for(let l = this.depth; l >= 0; l--){ 2710 let { type: a, match: c } = this.frontier[l], f, u = null; 2711 if (t == 1 && (s ? c.matchType(s.type) || (u = c.fillBefore(k.from(s), !1)) : o && a.compatibleContent(o.type))) return { 2712 sliceDepth: r, 2713 frontierDepth: l, 2714 parent: o, 2715 inject: u 2716 }; 2717 if (t == 2 && s && (f = c.findWrapping(s.type))) return { 2718 sliceDepth: r, 2719 frontierDepth: l, 2720 parent: o, 2721 wrap: f 2722 }; 2723 if (o && c.matchType(o.type)) break; 2724 } 2725 } 2726 } 2727 openMore() { 2728 let { content: e, openStart: t, openEnd: r } = this.unplaced; 2729 return bi(e, -1) <= t ? !1 : (this.unplaced.size > 1 && bi(e, 1) > r && r++, this.unplaced = new b(e, t + 1, r), !0); 2730 } 2731 dropNode() { 2732 let { content: e, openStart: t, openEnd: r } = this.unplaced, i = ki(e, t); 2733 if (i.childCount <= 1 && t > 0) { 2734 let o = e.size - t <= t + i.size; 2735 this.unplaced = new b(yt(e, t - 1, 1), t - 1, o ? t - 1 : r); 2736 } else this.unplaced = new b(yt(e, t, 1), t, r); 2737 } 2738 placeNodes({ sliceDepth: e, frontierDepth: t, parent: r, inject: i, wrap: o }) { 2739 for(; this.depth > t;)this.closeFrontierNode(); 2740 if (o) for(let m = 0; m < o.length; m++)this.openFrontierNode(o[m]); 2741 let s = this.unplaced, l = r ? r.content : s.content, a = s.openStart - e, c = 0, f = [], { match: u, type: d } = this.frontier[t]; 2742 if (i) { 2743 for(let m = 0; m < i.childCount; m++)f.push(i.child(m)); 2744 u = u.matchFragment(i); 2745 } 2746 let h = l.size + e - (s.content.size - s.openEnd); 2747 for(; c < l.childCount;){ 2748 let m = l.child(c), g = u.matchType(m.type); 2749 if (!g) break; 2750 c++, (c > 1 || a == 0 || m.content.size) && (u = g, f.push(as(m.mark(d.allowedMarks(m.marks)), c == 1 ? a : 0, c == l.childCount ? h : -1))); 2751 } 2752 let p = c == l.childCount; 2753 p || (h = -1), this.placed = kt(this.placed, t, k.from(f)), this.frontier[t].match = u, p && h < 0 && r && r.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode(); 2754 for(let m = 0, g = l; m < h; m++){ 2755 let y = g.lastChild; 2756 this.frontier.push({ 2757 type: y.type, 2758 match: y.contentMatchAt(y.childCount) 2759 }), g = y.content; 2760 } 2761 this.unplaced = p ? e == 0 ? b.empty : new b(yt(s.content, e - 1, 1), e - 1, h < 0 ? s.openEnd : e - 1) : new b(yt(s.content, e, c), s.openStart, s.openEnd); 2762 } 2763 mustMoveInline() { 2764 if (!this.$to.parent.isTextblock) return -1; 2765 let e = this.frontier[this.depth], t; 2766 if (!e.type.isTextblock || !qn(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) return -1; 2767 let { depth: r } = this.$to, i = this.$to.after(r); 2768 for(; r > 1 && i == this.$to.end(--r);)++i; 2769 return i; 2770 } 2771 findCloseLevel(e) { 2772 e: for(let t = Math.min(this.depth, e.depth); t >= 0; t--){ 2773 let { match: r, type: i } = this.frontier[t], o = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), s = qn(e, t, i, r, o); 2774 if (s) { 2775 for(let l = t - 1; l >= 0; l--){ 2776 let { match: a, type: c } = this.frontier[l], f = qn(e, l, c, a, !0); 2777 if (!f || f.childCount) continue e; 2778 } 2779 return { 2780 depth: t, 2781 fit: s, 2782 move: o ? e.doc.resolve(e.after(t + 1)) : e 2783 }; 2784 } 2785 } 2786 } 2787 close(e) { 2788 let t = this.findCloseLevel(e); 2789 if (!t) return null; 2790 for(; this.depth > t.depth;)this.closeFrontierNode(); 2791 t.fit.childCount && (this.placed = kt(this.placed, t.depth, t.fit)), e = t.move; 2792 for(let r = t.depth + 1; r <= e.depth; r++){ 2793 let i = e.node(r), o = i.type.contentMatch.fillBefore(i.content, !0, e.index(r)); 2794 this.openFrontierNode(i.type, i.attrs, o); 2795 } 2796 return e; 2797 } 2798 openFrontierNode(e, t = null, r) { 2799 let i = this.frontier[this.depth]; 2800 i.match = i.match.matchType(e), this.placed = kt(this.placed, this.depth, k.from(e.create(t, r))), this.frontier.push({ 2801 type: e, 2802 match: e.contentMatch 2803 }); 2804 } 2805 closeFrontierNode() { 2806 let t = this.frontier.pop().match.fillBefore(k.empty, !0); 2807 t.childCount && (this.placed = kt(this.placed, this.frontier.length, t)); 2808 } 2809 } 2810 function yt(n, e, t) { 2811 return e == 0 ? n.cutByIndex(t, n.childCount) : n.replaceChild(0, n.firstChild.copy(yt(n.firstChild.content, e - 1, t))); 2812 } 2813 function kt(n, e, t) { 2814 return e == 0 ? n.append(t) : n.replaceChild(n.childCount - 1, n.lastChild.copy(kt(n.lastChild.content, e - 1, t))); 2815 } 2816 function ki(n, e) { 2817 for(let t = 0; t < e; t++)n = n.firstChild.content; 2818 return n; 2819 } 2820 function as(n, e, t) { 2821 if (e <= 0) return n; 2822 let r = n.content; 2823 return e > 1 && (r = r.replaceChild(0, as(r.firstChild, e - 1, r.childCount == 1 ? t - 1 : 0))), e > 0 && (r = n.type.contentMatch.fillBefore(r).append(r), t <= 0 && (r = r.append(n.type.contentMatch.matchFragment(r).fillBefore(k.empty, !0)))), n.copy(r); 2824 } 2825 function qn(n, e, t, r, i) { 2826 let o = n.node(e), s = i ? n.indexAfter(e) : n.index(e); 2827 if (s == o.childCount && !t.compatibleContent(o.type)) return null; 2828 let l = r.fillBefore(o.content, !0, s); 2829 return l && !tc(t, o.content, s) ? l : null; 2830 } 2831 function tc(n, e, t) { 2832 for(let r = t; r < e.childCount; r++)if (!n.allowsMarks(e.child(r).marks)) return !0; 2833 return !1; 2834 } 2835 function nc(n) { 2836 return n.spec.defining || n.spec.definingForContent; 2837 } 2838 function bi(n, e) { 2839 for(let t = 0;; t++){ 2840 let r = e < 0 ? n.firstChild : n.lastChild; 2841 if (!r || r.isAtom) return t; 2842 n = r.content; 2843 } 2844 } 2845 function rc(n, e, t, r) { 2846 if (!r.size) return n.deleteRange(e, t); 2847 let i = n.doc.resolve(e), o = n.doc.resolve(t); 2848 if (ls(i, o, r)) return n.step(new P(e, t, r)); 2849 let s = fs(i, o); 2850 s[s.length - 1] == 0 && s.pop(); 2851 let l = -(i.depth + 1); 2852 s.unshift(l); 2853 for(let d = i.depth, h = i.pos - 1; d > 0; d--, h--){ 2854 let p = i.node(d).type.spec; 2855 if (p.defining || p.definingAsContext || p.isolating) break; 2856 s.indexOf(d) > -1 ? l = d : i.before(d) == h && s.splice(1, 0, -d); 2857 } 2858 let a = s.indexOf(l), c = [], f = r.openStart; 2859 for(let d = r.content, h = 0;; h++){ 2860 let p = d.firstChild; 2861 if (c.push(p), h == r.openStart) break; 2862 d = p.content; 2863 } 2864 for(let d = f - 1; d >= 0; d--){ 2865 let h = c[d], p = nc(h.type); 2866 if (p && !h.sameMarkup(i.node(Math.abs(l) - 1))) f = d; 2867 else if (p || !h.type.isTextblock) break; 2868 } 2869 for(let d = r.openStart; d >= 0; d--){ 2870 let h = (d + f + 1) % (r.openStart + 1), p = c[h]; 2871 if (p) for(let m = 0; m < s.length; m++){ 2872 let g = s[(m + a) % s.length], y = !0; 2873 g < 0 && (y = !1, g = -g); 2874 let x = i.node(g - 1), M = i.index(g - 1); 2875 if (x.canReplaceWith(M, M, p.type, p.marks)) return n.replace(i.before(g), y ? o.after(g) : t, new b(cs(r.content, 0, r.openStart, h), h, r.openEnd)); 2876 } 2877 } 2878 let u = n.steps.length; 2879 for(let d = s.length - 1; d >= 0 && (n.replace(e, t, r), !(n.steps.length > u)); d--){ 2880 let h = s[d]; 2881 h < 0 || (e = i.before(h), t = o.after(h)); 2882 } 2883 } 2884 function cs(n, e, t, r, i) { 2885 if (e < t) { 2886 let o = n.firstChild; 2887 n = n.replaceChild(0, o.copy(cs(o.content, e + 1, t, r, o))); 2888 } 2889 if (e > r) { 2890 let o = i.contentMatchAt(0), s = o.fillBefore(n).append(n); 2891 n = s.append(o.matchFragment(s).fillBefore(k.empty, !0)); 2892 } 2893 return n; 2894 } 2895 function ic(n, e, t, r) { 2896 if (!r.isInline && e == t && n.doc.resolve(e).parent.content.size) { 2897 let i = Qa(n.doc, e, r.type); 2898 i != null && (e = t = i); 2899 } 2900 n.replaceRange(e, t, new b(k.from(r), 0, 0)); 2901 } 2902 function oc(n, e, t) { 2903 let r = n.doc.resolve(e), i = n.doc.resolve(t); 2904 if (r.parent.isTextblock && i.parent.isTextblock && r.start() != i.start() && r.parentOffset == 0 && i.parentOffset == 0) { 2905 let s = r.sharedDepth(t), l = !1; 2906 for(let a = r.depth; a > s; a--)r.node(a).type.spec.isolating && (l = !0); 2907 for(let a = i.depth; a > s; a--)i.node(a).type.spec.isolating && (l = !0); 2908 if (!l) { 2909 for(let a = r.depth; a > 0 && e == r.start(a); a--)e = r.before(a); 2910 for(let a = i.depth; a > 0 && t == i.start(a); a--)t = i.before(a); 2911 r = n.doc.resolve(e), i = n.doc.resolve(t); 2912 } 2913 } 2914 let o = fs(r, i); 2915 for(let s = 0; s < o.length; s++){ 2916 let l = o[s], a = s == o.length - 1; 2917 if (a && l == 0 || r.node(l).type.contentMatch.validEnd) return n.delete(r.start(l), i.end(l)); 2918 if (l > 0 && (a || r.node(l - 1).canReplace(r.index(l - 1), i.indexAfter(l - 1)))) return n.delete(r.before(l), i.after(l)); 2919 } 2920 for(let s = 1; s <= r.depth && s <= i.depth; s++)if (e - r.start(s) == r.depth - s && t > r.end(s) && i.end(s) - t != i.depth - s && r.start(s - 1) == i.start(s - 1) && r.node(s - 1).canReplace(r.index(s - 1), i.index(s - 1))) return n.delete(r.before(s), t); 2921 n.delete(e, t); 2922 } 2923 function fs(n, e) { 2924 let t = [], r = Math.min(n.depth, e.depth); 2925 for(let i = r; i >= 0; i--){ 2926 let o = n.start(i); 2927 if (o < n.pos - (n.depth - i) || e.end(i) > e.pos + (e.depth - i) || n.node(i).type.spec.isolating || e.node(i).type.spec.isolating) break; 2928 (o == e.start(i) || i == n.depth && i == e.depth && n.parent.inlineContent && e.parent.inlineContent && i && e.start(i - 1) == o - 1) && t.push(i); 2929 } 2930 return t; 2931 } 2932 class ot extends H { 2933 constructor(e, t, r){ 2934 super(), this.pos = e, this.attr = t, this.value = r; 2935 } 2936 apply(e) { 2937 let t = e.nodeAt(this.pos); 2938 if (!t) return F.fail("No node at attribute step's position"); 2939 let r = Object.create(null); 2940 for(let o in t.attrs)r[o] = t.attrs[o]; 2941 r[this.attr] = this.value; 2942 let i = t.type.create(r, null, t.marks); 2943 return F.fromReplace(e, this.pos, this.pos + 1, new b(k.from(i), 0, t.isLeaf ? 0 : 1)); 2944 } 2945 getMap() { 2946 return Z.empty; 2947 } 2948 invert(e) { 2949 return new ot(this.pos, this.attr, e.nodeAt(this.pos).attrs[this.attr]); 2950 } 2951 map(e) { 2952 let t = e.mapResult(this.pos, 1); 2953 return t.deletedAfter ? null : new ot(t.pos, this.attr, this.value); 2954 } 2955 toJSON() { 2956 return { 2957 stepType: "attr", 2958 pos: this.pos, 2959 attr: this.attr, 2960 value: this.value 2961 }; 2962 } 2963 static fromJSON(e, t) { 2964 if (typeof t.pos != "number" || typeof t.attr != "string") throw new RangeError("Invalid input for AttrStep.fromJSON"); 2965 return new ot(t.pos, t.attr, t.value); 2966 } 2967 } 2968 H.jsonID("attr", ot); 2969 class It extends H { 2970 constructor(e, t){ 2971 super(), this.attr = e, this.value = t; 2972 } 2973 apply(e) { 2974 let t = Object.create(null); 2975 for(let i in e.attrs)t[i] = e.attrs[i]; 2976 t[this.attr] = this.value; 2977 let r = e.type.create(t, e.content, e.marks); 2978 return F.ok(r); 2979 } 2980 getMap() { 2981 return Z.empty; 2982 } 2983 invert(e) { 2984 return new It(this.attr, e.attrs[this.attr]); 2985 } 2986 map(e) { 2987 return this; 2988 } 2989 toJSON() { 2990 return { 2991 stepType: "docAttr", 2992 attr: this.attr, 2993 value: this.value 2994 }; 2995 } 2996 static fromJSON(e, t) { 2997 if (typeof t.attr != "string") throw new RangeError("Invalid input for DocAttrStep.fromJSON"); 2998 return new It(t.attr, t.value); 2999 } 3000 } 3001 H.jsonID("docAttr", It); 3002 let lt = class extends Error { 3003 }; 3004 lt = function n(e) { 3005 let t = Error.call(this, e); 3006 return t.__proto__ = n.prototype, t; 3007 }; 3008 lt.prototype = Object.create(Error.prototype); 3009 lt.prototype.constructor = lt; 3010 lt.prototype.name = "TransformError"; 3011 class us { 3012 constructor(e){ 3013 this.doc = e, this.steps = [], this.docs = [], this.mapping = new dn; 3014 } 3015 get before() { 3016 return this.docs.length ? this.docs[0] : this.doc; 3017 } 3018 step(e) { 3019 let t = this.maybeStep(e); 3020 if (t.failed) throw new lt(t.failed); 3021 return this; 3022 } 3023 maybeStep(e) { 3024 let t = e.apply(this.doc); 3025 return t.failed || this.addStep(e, t.doc), t; 3026 } 3027 get docChanged() { 3028 return this.steps.length > 0; 3029 } 3030 changedRange() { 3031 let e = 1e9, t = -1e9; 3032 for(let r = 0; r < this.mapping.maps.length; r++){ 3033 let i = this.mapping.maps[r]; 3034 r && (e = i.map(e, 1), t = i.map(t, -1)), i.forEach((o, s, l, a)=>{ 3035 e = Math.min(e, l), t = Math.max(t, a); 3036 }); 3037 } 3038 return e == 1e9 ? null : { 3039 from: e, 3040 to: t 3041 }; 3042 } 3043 addStep(e, t) { 3044 this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t; 3045 } 3046 replace(e, t = e, r = b.empty) { 3047 let i = An(this.doc, e, t, r); 3048 return i && this.step(i), this; 3049 } 3050 replaceWith(e, t, r) { 3051 return this.replace(e, t, new b(k.from(r), 0, 0)); 3052 } 3053 delete(e, t) { 3054 return this.replace(e, t, b.empty); 3055 } 3056 insert(e, t) { 3057 return this.replaceWith(e, e, t); 3058 } 3059 replaceRange(e, t, r) { 3060 return rc(this, e, t, r), this; 3061 } 3062 replaceRangeWith(e, t, r) { 3063 return ic(this, e, t, r), this; 3064 } 3065 deleteRange(e, t) { 3066 return oc(this, e, t), this; 3067 } 3068 lift(e, t) { 3069 return Wa(this, e, t), this; 3070 } 3071 join(e, t = 1) { 3072 return Xa(this, e, t), this; 3073 } 3074 wrap(e, t) { 3075 return Ka(this, e, t), this; 3076 } 3077 setBlockType(e, t = e, r, i = null) { 3078 return Ha(this, e, t, r, i), this; 3079 } 3080 setNodeMarkup(e, t, r = null, i) { 3081 return Ua(this, e, t, r, i), this; 3082 } 3083 setNodeAttribute(e, t, r) { 3084 return this.step(new ot(e, t, r)), this; 3085 } 3086 setDocAttribute(e, t) { 3087 return this.step(new It(e, t)), this; 3088 } 3089 addNodeMark(e, t) { 3090 return this.step(new ve(e, t)), this; 3091 } 3092 removeNodeMark(e, t) { 3093 let r = this.doc.nodeAt(e); 3094 if (!r) throw new RangeError("No node at position " + e); 3095 if (t instanceof I) t.isInSet(r.marks) && this.step(new Ue(e, t)); 3096 else { 3097 let i = r.marks, o, s = []; 3098 for(; o = t.isInSet(i);)s.push(new Ue(e, o)), i = o.removeFromSet(i); 3099 for(let l = s.length - 1; l >= 0; l--)this.step(s[l]); 3100 } 3101 return this; 3102 } 3103 split(e, t = 1, r) { 3104 return Ya(this, e, t, r), this; 3105 } 3106 addMark(e, t, r) { 3107 return Va(this, e, t, r), this; 3108 } 3109 removeMark(e, t, r) { 3110 return $a(this, e, t, r), this; 3111 } 3112 clearIncompatible(e, t, r) { 3113 return Ir(this, e, t, r), this; 3114 } 3115 } 3116 const Kn = Object.create(null); 3117 class D { 3118 constructor(e, t, r){ 3119 this.$anchor = e, this.$head = t, this.ranges = r || [ 3120 new sc(e.min(t), e.max(t)) 3121 ]; 3122 } 3123 get anchor() { 3124 return this.$anchor.pos; 3125 } 3126 get head() { 3127 return this.$head.pos; 3128 } 3129 get from() { 3130 return this.$from.pos; 3131 } 3132 get to() { 3133 return this.$to.pos; 3134 } 3135 get $from() { 3136 return this.ranges[0].$from; 3137 } 3138 get $to() { 3139 return this.ranges[0].$to; 3140 } 3141 get empty() { 3142 let e = this.ranges; 3143 for(let t = 0; t < e.length; t++)if (e[t].$from.pos != e[t].$to.pos) return !1; 3144 return !0; 3145 } 3146 content() { 3147 return this.$from.doc.slice(this.from, this.to, !0); 3148 } 3149 replace(e, t = b.empty) { 3150 let r = t.content.lastChild, i = null; 3151 for(let l = 0; l < t.openEnd; l++)i = r, r = r.lastChild; 3152 let o = e.steps.length, s = this.ranges; 3153 for(let l = 0; l < s.length; l++){ 3154 let { $from: a, $to: c } = s[l], f = e.mapping.slice(o); 3155 e.replaceRange(f.map(a.pos), f.map(c.pos), l ? b.empty : t), l == 0 && wi(e, o, (r ? r.isInline : i && i.isTextblock) ? -1 : 1); 3156 } 3157 } 3158 replaceWith(e, t) { 3159 let r = e.steps.length, i = this.ranges; 3160 for(let o = 0; o < i.length; o++){ 3161 let { $from: s, $to: l } = i[o], a = e.mapping.slice(r), c = a.map(s.pos), f = a.map(l.pos); 3162 o ? e.deleteRange(c, f) : (e.replaceRangeWith(c, f, t), wi(e, r, t.isInline ? -1 : 1)); 3163 } 3164 } 3165 static findFrom(e, t, r = !1) { 3166 let i = e.parent.inlineContent ? new v(e) : tt(e.node(0), e.parent, e.pos, e.index(), t, r); 3167 if (i) return i; 3168 for(let o = e.depth - 1; o >= 0; o--){ 3169 let s = t < 0 ? tt(e.node(0), e.node(o), e.before(o + 1), e.index(o), t, r) : tt(e.node(0), e.node(o), e.after(o + 1), e.index(o) + 1, t, r); 3170 if (s) return s; 3171 } 3172 return null; 3173 } 3174 static near(e, t = 1) { 3175 return this.findFrom(e, t) || this.findFrom(e, -t) || new ee(e.node(0)); 3176 } 3177 static atStart(e) { 3178 return tt(e, e, 0, 0, 1) || new ee(e); 3179 } 3180 static atEnd(e) { 3181 return tt(e, e, e.content.size, e.childCount, -1) || new ee(e); 3182 } 3183 static fromJSON(e, t) { 3184 if (!t || !t.type) throw new RangeError("Invalid input for Selection.fromJSON"); 3185 let r = Kn[t.type]; 3186 if (!r) throw new RangeError(`No selection type ${t.type} defined`); 3187 return r.fromJSON(e, t); 3188 } 3189 static jsonID(e, t) { 3190 if (e in Kn) throw new RangeError("Duplicate use of selection JSON ID " + e); 3191 return Kn[e] = t, t.prototype.jsonID = e, t; 3192 } 3193 getBookmark() { 3194 return v.between(this.$anchor, this.$head).getBookmark(); 3195 } 3196 } 3197 D.prototype.visible = !0; 3198 class sc { 3199 constructor(e, t){ 3200 this.$from = e, this.$to = t; 3201 } 3202 } 3203 let xi = !1; 3204 function Si(n) { 3205 !xi && !n.parent.inlineContent && (xi = !0, console.warn("TextSelection endpoint not pointing into a
3205node with inline content (" + n.parent.type.name + ")")); 3206 } 3207 class v extends D { 3208 constructor(e, t = e){ 3209 Si(e), Si(t), super(e, t); 3210 } 3211 get $cursor() { 3212 return this.$anchor.pos == this.$head.pos ? this.$head : null; 3213 } 3214 map(e, t) { 3215 let r = e.resolve(t.map(this.head)); 3216 if (!r.parent.inlineContent) return D.near(r); 3217 let i = e.resolve(t.map(this.anchor)); 3218 return new v(i.parent.inlineContent ? i : r, r); 3219 } 3220 replace(e, t = b.empty) { 3221 if (super.replace(e, t), t == b.empty) { 3222 let r = this.$from.marksAcross(this.$to); 3223 r && e.ensureMarks(r); 3224 } 3225 } 3226 eq(e) { 3227 return e instanceof v && e.anchor == this.anchor && e.head == this.head; 3228 } 3229 getBookmark() { 3230 return new In(this.anchor, this.head); 3231 } 3232 toJSON() { 3233 return { 3234 type: "text", 3235 anchor: this.anchor, 3236 head: this.head 3237 }; 3238 } 3239 static fromJSON(e, t) { 3240 if (typeof t.anchor != "number" || typeof t.head != "number") throw new RangeError("Invalid input for TextSelection.fromJSON"); 3241 return new v(e.resolve(t.anchor), e.resolve(t.head)); 3242 } 3243 static create(e, t, r = t) { 3244 let i = e.resolve(t); 3245 return new this(i, r == t ? i : e.resolve(r)); 3246 } 3247 static between(e, t, r) { 3248 let i = e.pos - t.pos; 3249 if ((!r || i) && (r = i >= 0 ? 1 : -1), !t.parent.inlineContent) { 3250 let o = D.findFrom(t, r, !0) || D.findFrom(t, -r, !0); 3251 if (o) t = o.$head; 3252 else return D.near(t, r); 3253 } 3254 return e.parent.inlineContent || (i == 0 ? e = t : (e = (D.findFrom(e, -r, !0) || D.findFrom(e, r, !0)).$anchor, e.pos < t.pos != i < 0 && (e = t))), new v(e, t); 3255 } 3256 } 3257 D.jsonID("text", v); 3258 class In { 3259 constructor(e, t){ 3260 this.anchor = e, this.head = t; 3261 } 3262 map(e) { 3263 return new In(e.map(this.anchor), e.map(this.head)); 3264 } 3265 resolve(e) { 3266 return v.between(e.resolve(this.anchor), e.resolve(this.head)); 3267 } 3268 } 3269 class T extends D { 3270 constructor(e){ 3271 let t = e.nodeAfter, r = e.node(0).resolve(e.pos + t.nodeSize); 3272 super(e, r), this.node = t; 3273 } 3274 map(e, t) { 3275 let { deleted: r, pos: i } = t.mapResult(this.anchor), o = e.resolve(i); 3276 return r ? D.near(o) : new T(o); 3277 } 3278 content() { 3279 return new b(k.from(this.node), 0, 0); 3280 } 3281 eq(e) { 3282 return e instanceof T && e.anchor == this.anchor; 3283 } 3284 toJSON() { 3285 return { 3286 type: "node", 3287 anchor: this.anchor 3288 }; 3289 } 3290 getBookmark() { 3291 return new Rr(this.anchor); 3292 } 3293 static fromJSON(e, t) { 3294 if (typeof t.anchor != "number") throw new RangeError("Invalid input for NodeSelection.fromJSON"); 3295 return new T(e.resolve(t.anchor)); 3296 } 3297 static create(e, t) { 3298 return new T(e.resolve(t)); 3299 } 3300 static isSelectable(e) { 3301 return !e.isText && e.type.spec.selectable !== !1; 3302 } 3303 } 3304 T.prototype.visible = !1; 3305 D.jsonID("node", T); 3306 class Rr { 3307 constructor(e){ 3308 this.anchor = e; 3309 } 3310 map(e) { 3311 let { deleted: t, pos: r } = e.mapResult(this.anchor); 3312 return t ? new In(r, r) : new Rr(r); 3313 } 3314 resolve(e) { 3315 let t = e.resolve(this.anchor), r = t.nodeAfter; 3316 return r && T.isSelectable(r) ? new T(t) : D.near(t); 3317 } 3318 } 3319 class ee extends D { 3320 constructor(e){ 3321 super(e.resolve(0), e.resolve(e.content.size)); 3322 } 3323 replace(e, t = b.empty) { 3324 if (t == b.empty) { 3325 e.delete(0, e.doc.content.size); 3326 let r = D.atStart(e.doc); 3327 r.eq(e.selection) || e.setSelection(r); 3328 } else super.replace(e, t); 3329 } 3330 toJSON() { 3331 return { 3332 type: "all" 3333 }; 3334 } 3335 static fromJSON(e) { 3336 return new ee(e); 3337 } 3338 map(e) { 3339 return new ee(e); 3340 } 3341 eq(e) { 3342 return e instanceof ee; 3343 } 3344 getBookmark() { 3345 return lc; 3346 } 3347 } 3348 D.jsonID("all", ee); 3349 const lc = { 3350 map () { 3351 return this; 3352 }, 3353 resolve (n) { 3354 return new ee(n); 3355 } 3356 }; 3357 function tt(n, e, t, r, i, o = !1) { 3358 if (e.inlineContent) return v.create(n, t); 3359 for(let s = r - (i > 0 ? 0 : 1); i > 0 ? s < e.childCount : s >= 0; s += i){ 3360 let l = e.child(s); 3361 if (l.isAtom) { 3362 if (!o && T.isSelectable(l)) return T.create(n, t - (i < 0 ? l.nodeSize : 0)); 3363 } else { 3364 let a = tt(n, l, t + i, i < 0 ? l.childCount : 0, i, o); 3365 if (a) return a; 3366 } 3367 t += l.nodeSize * i; 3368 } 3369 return null; 3370 } 3371 function wi(n, e, t) { 3372 let r = n.steps.length - 1; 3373 if (r < e) return; 3374 let i = n.steps[r]; 3375 if (!(i instanceof P || i instanceof L)) return; 3376 let o = n.mapping.maps[r], s; 3377 o.forEach((l, a, c, f)=>{ 3378 s == null && (s = f); 3379 }), n.setSelection(D.near(n.doc.resolve(s), t)); 3380 } 3381 const Mi = 1, Gt = 2, Ci = 4; 3382 class ac extends us { 3383 constructor(e){ 3384 super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks; 3385 } 3386 get selection() { 3387 return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection; 3388 } 3389 setSelection(e) { 3390 if (e.$from.doc != this.doc) throw new RangeError("Selection passed to setSelection must point at the current document"); 3391 return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | Mi) & ~Gt, this.storedMarks = null, this; 3392 } 3393 get selectionSet() { 3394 return (this.updated & Mi) > 0; 3395 } 3396 setStoredMarks(e) { 3397 return this.storedMarks = e, this.updated |= Gt, this; 3398 } 3399 ensureMarks(e) { 3400 return I.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this; 3401 } 3402 addStoredMark(e) { 3403 return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks())); 3404 } 3405 removeStoredMark(e) { 3406 return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks())); 3407 } 3408 get storedMarksSet() { 3409 return (this.updated & Gt) > 0; 3410 } 3411 addStep(e, t) { 3412 super.addStep(e, t), this.updated = this.updated & ~Gt, this.storedMarks = null; 3413 } 3414 setTime(e) { 3415 return this.time = e, this; 3416 } 3417 replaceSelection(e) { 3418 return this.selection.replace(this, e), this; 3419 } 3420 replaceSelectionWith(e, t = !0) { 3421 let r = this.selection; 3422 return t && (e = e.mark(this.storedMarks || (r.empty ? r.$from.marks() : r.$from.marksAcross(r.$to) || I.none))), r.replaceWith(this, e), this; 3423 } 3424 deleteSelection() { 3425 return this.selection.replace(this), this; 3426 } 3427 insertText(e, t, r) { 3428 let i = this.doc.type.schema; 3429 if (t == null) return e ? this.replaceSelectionWith(i.text(e), !0) : this.deleteSelection(); 3430 { 3431 if (r == null && (r = t), !e) return this.deleteRange(t, r); 3432 let o = this.storedMarks; 3433 if (!o) { 3434 let s = this.doc.resolve(t); 3435 o = r == t ? s.marks() : s.marksAcross(this.doc.resolve(r)); 3436 } 3437 return this.replaceRangeWith(t, r, i.text(e, o)), !this.selection.empty && this.selection.to == t + e.length && this.setSelection(D.near(this.selection.$to)), this; 3438 } 3439 } 3440 setMeta(e, t) { 3441 return this.meta[typeof e == "string" ? e : e.key] = t, this; 3442 } 3443 getMeta(e) { 3444 return this.meta[typeof e == "string" ? e : e.key]; 3445 } 3446 get isGeneric() { 3447 for(let e in this.meta)return !1; 3448 return !0; 3449 } 3450 scrollIntoView() { 3451 return this.updated |= Ci, this; 3452 } 3453 get scrolledIntoView() { 3454 return (this.updated & Ci) > 0; 3455 } 3456 } 3457 function Ti(n, e) { 3458 return !e || !n ? n : n.bind(e); 3459 } 3460 class bt { 3461 constructor(e, t, r){ 3462 this.name = e, this.init = Ti(t.init, r), this.apply = Ti(t.apply, r); 3463 } 3464 } 3465 const cc = [ 3466 new bt("doc", { 3467 init (n) { 3468 return n.doc || n.schema.topNodeType.createAndFill(); 3469 }, 3470 apply (n) { 3471 return n.doc; 3472 } 3473 }), 3474 new bt("selection", { 3475 init (n, e) { 3476 return n.selection || D.atStart(e.doc); 3477 }, 3478 apply (n) { 3479 return n.selection; 3480 } 3481 }), 3482 new bt("storedMarks", { 3483 init (n) { 3484 return n.storedMarks || null; 3485 }, 3486 apply (n, e, t, r) { 3487 return r.selection.$cursor ? n.storedMarks : null; 3488 } 3489 }), 3490 new bt("scrollToSelection", { 3491 init () { 3492 return 0; 3493 }, 3494 apply (n, e) { 3495 return n.scrolledIntoView ? e + 1 : e; 3496 } 3497 }) 3498 ]; 3499 class Hn { 3500 constructor(e, t){ 3501 this.schema = e, this.plugins = [], this.pluginsByKey = Object.create(null), this.fields = cc.slice(), t && t.forEach((r)=>{ 3502 if (this.pluginsByKey[r.key]) throw new RangeError("Adding different instances of a keyed plugin (" + r.key + ")"); 3503 this.plugins.push(r), this.pluginsByKey[r.key] = r, r.spec.state && this.fields.push(new bt(r.key, r.spec.state, r)); 3504 }); 3505 } 3506 } 3507 class ze { 3508 constructor(e){ 3509 this.config = e; 3510 } 3511 get schema() { 3512 return this.config.schema; 3513 } 3514 get plugins() { 3515 return this.config.plugins; 3516 } 3517 apply(e) { 3518 return this.applyTransaction(e).state; 3519 } 3520 filterTransaction(e, t = -1) { 3521 for(let r = 0; r < this.config.plugins.length; r++)if (r != t) { 3522 let i = this.config.plugins[r]; 3523 if (i.spec.filterTransaction && !i.spec.filterTransaction.call(i, e, this)) return !1; 3524 } 3525 return !0; 3526 } 3527 applyTransaction(e) { 3528 if (!this.filterTransaction(e)) return { 3529 state: this, 3530 transactions: [] 3531 }; 3532 let t = [ 3533 e 3534 ], r = this.applyInner(e), i = null; 3535 for(;;){ 3536 let o = !1; 3537 for(let s = 0; s < this.config.plugins.length; s++){ 3538 let l = this.config.plugins[s]; 3539 if (l.spec.appendTransaction) { 3540 let a = i ? i[s].n : 0, c = i ? i[s].state : this, f = a < t.length && l.spec.appendTransaction.call(l, a ? t.slice(a) : t, c, r); 3541 if (f && r.filterTransaction(f, s)) { 3542 if (f.setMeta("appendedTransaction", e), !i) { 3543 i = []; 3544 for(let u = 0; u < this.config.plugins.length; u++)i.push(u < s ? { 3545 state: r, 3546 n: t.length 3547 } : { 3548 state: this, 3549 n: 0 3550 }); 3551 } 3552 t.push(f), r = r.applyInner(f), o = !0; 3553 } 3554 i && (i[s] = { 3555 state: r, 3556 n: t.length 3557 }); 3558 } 3559 } 3560 if (!o) return { 3561 state: r, 3562 transactions: t 3563 }; 3564 } 3565 } 3566 applyInner(e) { 3567 if (!e.before.eq(this.doc)) throw new RangeError("Applying a mismatched transaction"); 3568 let t = new ze(this.config), r = this.config.fields; 3569 for(let i = 0; i < r.length; i++){ 3570 let o = r[i]; 3571 t[o.name] = o.apply(e, this[o.name], this, t); 3572 } 3573 return t; 3574 } 3575 get tr() { 3576 return new ac(this); 3577 } 3578 static create(e) { 3579 let t = new Hn(e.doc ? e.doc.type.schema : e.schema, e.plugins), r = new ze(t); 3580 for(let i = 0; i < t.fields.length; i++)r[t.fields[i].name] = t.fields[i].init(e, r); 3581 return r; 3582 } 3583 reconfigure(e) { 3584 let t = new Hn(this.schema, e.plugins), r = t.fields, i = new ze(t); 3585 for(let o = 0; o < r.length; o++){ 3586 let s = r[o].name; 3587 i[s] = this.hasOwnProperty(s) ? this[s] : r[o].init(e, i); 3588 } 3589 return i; 3590 } 3591 toJSON(e) { 3592 let t = { 3593 doc: this.doc.toJSON(), 3594 selection: this.selection.toJSON() 3595 }; 3596 if (this.storedMarks && (t.storedMarks = this.storedMarks.map((r)=>r.toJSON())), e && typeof e == "object") for(let r in e){ 3597 if (r == "doc" || r == "selection") throw new RangeError("The JSON fields `doc` and `selection` are reserved"); 3598 let i = e[r], o = i.spec.state; 3599 o && o.toJSON && (t[r] = o.toJSON.call(i, this[i.key])); 3600 } 3601 return t; 3602 } 3603 static fromJSON(e, t, r) { 3604 if (!t) throw new RangeError("Invalid input for EditorState.fromJSON"); 3605 if (!e.schema) throw new RangeError("Required config field 'schema' missing");
3606 let i = new Hn(e.schema, e.plugins), o = new ze(i); 3607 return i.fields.forEach((s)=>{ 3608 if (s.name == "doc") o.doc = Je.fromJSON(e.schema, t.doc); 3609 else if (s.name == "selection") o.selection = D.fromJSON(o.doc, t.selection); 3610 else if (s.name == "storedMarks") t.storedMarks && (o.storedMarks = t.storedMarks.map(e.schema.markFromJSON)); 3611 else { 3612 if (r) for(let l in r){ 3613 let a = r[l], c = a.spec.state; 3614 if (a.key == s.name && c && c.fromJSON && Object.prototype.hasOwnProperty.call(t, l)) { 3615 o[s.name] = c.fromJSON.call(a, e, t[l], o); 3616 return; 3617 } 3618 } 3619 o[s.name] = s.init(e, o); 3620 } 3621 }), o; 3622 } 3623 } 3624 function ds(n, e, t) { 3625 for(let r in n){ 3626 let i = n[r]; 3627 i instanceof Function ? i = i.bind(e) : r == "handleDOMEvents" && (i = ds(i, e, {})), t[r] = i; 3628 } 3629 return t; 3630 } 3631 X = class { 3632 constructor(e){ 3633 this.spec = e, this.props = {}, e.props && ds(e.props, this, this.props), this.key = e.key ? e.key.key : hs("plugin"); 3634 } 3635 getState(e) { 3636 return e[this.key]; 3637 } 3638 }; 3639 const _n = Object.create(null); 3640 function hs(n) { 3641 return n in _n ? n + "$" + ++_n[n] : (_n[n] = 0, n + "$"); 3642 } 3643 de = class { 3644 constructor(e = "key"){ 3645 this.key = hs(e); 3646 } 3647 get(e) { 3648 return e.config.pluginsByKey[this.key]; 3649 } 3650 getState(e) { 3651 return e[this.key]; 3652 } 3653 }; 3654 const ps = (n, e)=>n.selection.empty ? !1 : (e && e(n.tr.deleteSelection().scrollIntoView()), !0); 3655 function ms(n, e) { 3656 let { $cursor: t } = n.selection; 3657 return !t || (e ? !e.endOfTextblock("backward", n) : t.parentOffset > 0) ? null : t; 3658 } 3659 const gs = (n, e, t)=>{ 3660 let r = ms(n, t); 3661 if (!r) return !1; 3662 let i = Br(r); 3663 if (!i) { 3664 let s = r.blockRange(), l = s && ht(s); 3665 return l == null ? !1 : (e && e(n.tr.lift(s, l).scrollIntoView()), !0); 3666 } 3667 let o = i.nodeBefore; 3668 if (Ts(n, i, e, -1)) return !0; 3669 if (r.parent.content.size == 0 && (at(o, "end") || T.isSelectable(o))) for(let s = r.depth;; s--){ 3670 let l = An(n.doc, r.before(s), r.after(s), b.empty); 3671 if (l && l.slice.size < l.to - l.from) { 3672 if (e) { 3673 let a = n.tr.step(l); 3674 a.setSelection(at(o, "end") ? D.findFrom(a.doc.resolve(a.mapping.map(i.pos, -1)), -1) : T.create(a.doc, i.pos - o.nodeSize)), e(a.scrollIntoView()); 3675 } 3676 return !0; 3677 } 3678 if (s == 1 || r.node(s - 1).childCount > 1) break; 3679 } 3680 return o.isAtom && i.depth == r.depth - 1 ? (e && e(n.tr.delete(i.pos - o.nodeSize, i.pos).scrollIntoView()), !0) : !1; 3681 }, fc = (n, e, t)=>{ 3682 let r = ms(n, t); 3683 if (!r) return !1; 3684 let i = Br(r); 3685 return i ? ys(n, i, e) : !1; 3686 }, uc = (n, e, t)=>{ 3687 let r = bs(n, t); 3688 if (!r) return !1; 3689 let i = Pr(r); 3690 return i ? ys(n, i, e) : !1; 3691 }; 3692 function ys(n, e, t) { 3693 let r = e.nodeBefore, i = r, o = e.pos - 1; 3694 for(; !i.isTextblock; o--){ 3695 if (i.type.spec.isolating) return !1; 3696 let f = i.lastChild; 3697 if (!f) return !1; 3698 i = f; 3699 } 3700 let s = e.nodeAfter, l = s, a = e.pos + 1; 3701 for(; !l.isTextblock; a++){ 3702 if (l.type.spec.isolating) return !1; 3703 let f = l.firstChild; 3704 if (!f) return !1; 3705 l = f; 3706 } 3707 let c = An(n.doc, o, a, b.empty); 3708 if (!c || c.from != o || c instanceof P && c.slice.size >= a - o) return !1; 3709 if (t) { 3710 let f = n.tr.step(c); 3711 f.setSelection(v.create(f.doc, o)), t(f.scrollIntoView()); 3712 } 3713 return !0; 3714 } 3715 function at(n, e, t = !1) { 3716 for(let r = n; r; r = e == "start" ? r.firstChild : r.lastChild){ 3717 if (r.isTextblock) return !0; 3718 if (t && r.childCount != 1) return !1; 3719 } 3720 return !1; 3721 }
vendor: 4,671 bytes, lines 3722-3828
3722 const ks = (n, e, t)=>{ 3723 let { $head: r, empty: i } = n.selection, o = r; 3724 if (!i) return !1; 3725 if (r.parent.isTextblock) { 3726 if (t ? !t.endOfTextblock("backward", n) : r.parentOffset > 0) return !1; 3727 o = Br(r); 3728 } 3729 let s = o && o.nodeBefore; 3730 return !s || !T.isSelectable(s) ? !1 : (e && e(n.tr.setSelection(T.create(n.doc, o.pos - s.nodeSize)).scrollIntoView()), !0); 3731 }; 3732 function Br(n) { 3733 if (!n.parent.type.spec.isolating) for(let e = n.depth - 1; e >= 0; e--){ 3734 if (n.index(e) > 0) return n.doc.resolve(n.before(e + 1)); 3735 if (n.node(e).type.spec.isolating) break; 3736 } 3737 return null; 3738 } 3739 function bs(n, e) { 3740 let { $cursor: t } = n.selection; 3741 return !t || (e ? !e.endOfTextblock("forward", n) : t.parentOffset < t.parent.content.size) ? null : t; 3742 } 3743 const xs = (n, e, t)=>{ 3744 let r = bs(n, t); 3745 if (!r) return !1; 3746 let i = Pr(r); 3747 if (!i) return !1; 3748 let o = i.nodeAfter; 3749 if (Ts(n, i, e, 1)) return !0; 3750 if (r.parent.content.size == 0 && (at(o, "start") || T.isSelectable(o))) { 3751 let s = An(n.doc, r.before(), r.after(), b.empty); 3752 if (s && s.slice.size < s.to - s.from) { 3753 if (e) { 3754 let l = n.tr.step(s); 3755 l.setSelection(at(o, "start") ? D.findFrom(l.doc.resolve(l.mapping.map(i.pos)), 1) : T.create(l.doc, l.mapping.map(i.pos))), e(l.scrollIntoView()); 3756 } 3757 return !0; 3758 } 3759 } 3760 return o.isAtom && i.depth == r.depth - 1 ? (e && e(n.tr.delete(i.pos, i.pos + o.nodeSize).scrollIntoView()), !0) : !1; 3761 }, Ss = (n, e, t)=>{ 3762 let { $head: r, empty: i } = n.selection, o = r; 3763 if (!i) return !1; 3764 if (r.parent.isTextblock) { 3765 if (t ? !t.endOfTextblock("forward", n) : r.parentOffset < r.parent.content.size) return !1; 3766 o = Pr(r); 3767 } 3768 let s = o && o.nodeAfter; 3769 return !s || !T.isSelectable(s) ? !1 : (e && e(n.tr.setSelection(T.create(n.doc, o.pos)).scrollIntoView()), !0); 3770 }; 3771 function Pr(n) { 3772 if (!n.parent.type.spec.isolating) for(let e = n.depth - 1; e >= 0; e--){ 3773 let t = n.node(e); 3774 if (n.index(e) + 1 < t.childCount) return n.doc.resolve(n.after(e + 1)); 3775 if (t.type.spec.isolating) break; 3776 } 3777 return null; 3778 } 3779 const dc = (n, e)=>{ 3780 let t = n.selection, r = t instanceof T, i; 3781 if (r) { 3782 if (t.node.isTextblock || !Xe(n.doc, t.from)) return !1; 3783 i = t.from; 3784 } else if (i = Dn(n.doc, t.from, -1), i == null) return !1; 3785 if (e) { 3786 let o = n.tr.join(i); 3787 r && o.setSelection(T.create(o.doc, i - n.doc.resolve(i).nodeBefore.nodeSize)), e(o.scrollIntoView()); 3788 } 3789 return !0; 3790 }, hc = (n, e)=>{ 3791 let t = n.selection, r; 3792 if (t instanceof T) { 3793 if (t.node.isTextblock || !Xe(n.doc, t.to)) return !1; 3794 r = t.to; 3795 } else if (r = Dn(n.doc, t.to, 1), r == null) return !1; 3796 return e && e(n.tr.join(r).scrollIntoView()), !0; 3797 }, pc = (n, e)=>{ 3798 let { $from: t, $to: r } = n.selection, i = t.blockRange(r), o = i && ht(i); 3799 return o == null ? !1 : (e && e(n.tr.lift(i, o).scrollIntoView()), !0); 3800 }, ws = (n, e)=>{ 3801 let { $head: t, $anchor: r } = n.selection; 3802 return !t.parent.type.spec.code || !t.sameParent(r) ? !1 : (e && e(n.tr.insertText(` 3803`).scrollIntoView()), !0); 3804 }; 3805 function zr(n) { 3806 for(let e = 0; e < n.edgeCount; e++){ 3807 let { type: t } = n.edge(e); 3808 if (t.isTextblock && !t.hasRequiredAttrs()) return t; 3809 } 3810 return null; 3811 } 3812 const mc = (n, e)=>{ 3813 let { $head: t, $anchor: r } = n.selection; 3814 if (!t.parent.type.spec.code || !t.sameParent(r)) return !1; 3815 let i = t.node(-1), o = t.indexAfter(-1), s = zr(i.contentMatchAt(o)); 3816 if (!s || !i.canReplaceWith(o, o, s)) return !1; 3817 if (e) { 3818 let l = t.after(), a = n.tr.replaceWith(l, l, s.createAndFill()); 3819 a.setSelection(D.near(a.doc.resolve(l), 1)), e(a.scrollIntoView()); 3820 } 3821 return !0; 3822 }, Ms = (n, e)=>{ 3823 let t = n.selection, { $from: r, $to: i } = t; 3824 if (t instanceof ee || r.parent.inlineContent || i.parent.inlineContent) return !1; 3825 let o = zr(i.parent.contentMatchAt(i.indexAfter())); 3826 if (!o || !o.isTextblock) return !1; 3827 if (e) { 3828 let s = (!r.parentOffset && i.index() < i.parent.childCount ? r : i
3828).pos, l = n.tr.insert(s, o.createAndFill()); 3829 l.setSelection(v.create(l.doc, s + 1)), e(l.scrollIntoView()); 3830 } 3831 return !0; 3832 }, Cs = (n, e)=>{ 3833 let { $cursor: t } = n.selection; 3834 if (!t || t.parent.content.size) return !1; 3835 if (t.depth > 1 && t.after() != t.end(-1)) { 3836 let o = t.before(); 3837 if (be(n.doc, o)) return e && e(n.tr.split(o).scrollIntoView()), !0; 3838 } 3839 let r = t.blockRange(), i = r && ht(r); 3840 return i == null ? !1 : (e && e(n.tr.lift(r, i).scrollIntoView()), !0); 3841 }; 3842 function gc(n) { 3843 return (e, t)=>{ 3844 if (e.selection instanceof T && e.selection.node.isBlock) { 3845 let { $from: h } = e.selection; 3846 return !h.parentOffset || !be(e.doc, h.pos) ? !1 : (t && t(e.tr.split(h.pos).scrollIntoView()), !0); 3847 } 3848 if (!e.selection.$from.depth) return !1; 3849 let r = e.tr; 3850 !e.selection.empty && (e.selection instanceof v || e.selection instanceof ee) && r.deleteSelection(); 3851 let { $from: i } = r.selection, o = r.steps.length, s = [], l, a, c = !1, f = !1; 3852 for(let h = i.depth;; h--)if (i.node(h).isBlock) { 3853 c = i.end(h) == i.pos + (i.depth - h), f = i.start(h) == i.pos - (i.depth - h), a = zr(i.node(h - 1).contentMatchAt(i.indexAfter(h - 1))), s.unshift(c && a ? { 3854 type: a 3855 } : null), l = h; 3856 break; 3857 } else { 3858 if (h == 1) return !1; 3859 s.unshift(null); 3860 } 3861 let u = i.pos, d = be(r.doc, u, s.length, s); 3862 if (d || (s[0] = a ? { 3863 type: a 3864 } : null, d = be(r.doc, u, s.length, s)), !d) return !1; 3865 if (r.split(u, s.length, s), !c && f && i.node(l).type != a) { 3866 let h = r.mapping.slice(o), p = h.map(i.before(l)), m = r.doc.resolve(p); 3867 a && i.node(l - 1).canReplaceWith(m.index(), m.index() + 1, a) && r.setNodeMarkup(h.map(i.before(l)), a); 3868 } 3869 return t && t(r.scrollIntoView()), !0; 3870 }; 3871 } 3872 const yc = gc(), kc = (n, e)=>{ 3873 let { $from: t, to: r } = n.selection, i, o = t.sharedDepth(r); 3874 return o == 0 ? !1 : (i = t.before(o), e && e(n.tr.setSelection(T.create(n.doc, i))), !0); 3875 }; 3876 function bc(n, e, t) { 3877 let r = e.nodeBefore, i = e.nodeAfter, o = e.index(); 3878 return !r || !i || !r.type.compatibleContent(i.type) ? !1 : !r.content.size && e.parent.canReplace(o - 1, o) ? (t && t(n.tr.delete(e.pos - r.nodeSize, e.pos).scrollIntoView()), !0) : !e.parent.canReplace(o, o + 1) || !(i.isTextblock || Xe(n.doc, e.pos)) ? !1 : (t && t(n.tr.join(e.pos).scrollIntoView()), !0); 3879 } 3880 function Ts(n, e, t, r) { 3881 let i = e.nodeBefore, o = e.nodeAfter, s, l, a = i.type.spec.isolating || o.type.spec.isolating; 3882 if (!a && bc(n, e, t)) return !0; 3883 let c = !a && e.parent.canReplace(e.index(), e.index() + 1); 3884 if (c && (s = (l = i.contentMatchAt(i.childCount)).findWrapping(o.type)) && l.matchType(s[0] || o.type).validEnd) { 3885 if (t) { 3886 let h = e.pos + o.nodeSize, p = k.empty; 3887 for(let y = s.length - 1; y >= 0; y--)p = k.from(s[y].create(null, p)); 3888 p = k.from(i.copy(p)); 3889 let m = n.tr.step(new L(e.pos - 1, h, e.pos, h, new b(p, 1, 0), s.length, !0)), g = m.doc.resolve(h + 2 * s.length); 3890 g.nodeAfter && g.nodeAfter.type == i.type && Xe(m.doc, g.pos) && m.join(g.pos), t(m.scrollIntoView()); 3891 } 3892 return !0; 3893 } 3894 let f = o.type.spec.isolating || r > 0 && a ? null : D.findFrom(e, 1), u = f && f.$from.blockRange(f.$to), d = u && ht(u); 3895 if (d != null && d >= e.depth) return t && t(n.tr.lift(u, d).scrollIntoView()), !0;
vendor: 72,892 bytes, lines 3896-5540
3896 if (c && at(o, "start", !0) && at(i, "end")) { 3897 let h = i, p = []; 3898 for(; p.push(h), !h.isTextblock;)h = h.lastChild; 3899 let m = o, g = 1; 3900 for(; !m.isTextblock; m = m.firstChild)g++; 3901 if (h.canReplace(h.childCount, h.childCount, m.content)) { 3902 if (t) { 3903 let y = k.empty; 3904 for(let M = p.length - 1; M >= 0; M--)y = k.from(p[M].copy(y)); 3905 let x = n.tr.step(new L(e.pos - p.length, e.pos + o.nodeSize, e.pos + g, e.pos + o.nodeSize - g, new b(y, p.length, 0), 0, !0)); 3906 t(x.scrollIntoView()); 3907 } 3908 return !0; 3909 } 3910 } 3911 return !1; 3912 } 3913 function vs(n) { 3914 return function(e, t) { 3915 let r = e.selection, i = n < 0 ? r.$from : r.$to, o = i.depth; 3916 for(; i.node(o).isInline;){ 3917 if (!o) return !1; 3918 o--; 3919 } 3920 return i.node(o).isTextblock ? (t && t(e.tr.setSelection(v.create(e.doc, n < 0 ? i.start(o) : i.end(o)))), !0) : !1; 3921 }; 3922 } 3923 const xc = vs(-1), Sc = vs(1); 3924 function wc(n, e = null) { 3925 return function(t, r) { 3926 let { $from: i, $to: o } = t.selection, s = i.blockRange(o), l = s && ns(s, n, e); 3927 return l ? (r && r(t.tr.wrap(s, l).scrollIntoView()), !0) : !1; 3928 }; 3929 } 3930 function vi(n, e = null) { 3931 return function(t, r) { 3932 let i = !1; 3933 for(let o = 0; o < t.selection.ranges.length && !i; o++){ 3934 let { $from: { pos: s }, $to: { pos: l } } = t.selection.ranges[o]; 3935 t.doc.nodesBetween(s, l, (a, c)=>{ 3936 if (i) return !1; 3937 if (!(!a.isTextblock || a.hasMarkup(n, e))) if (a.type == n) i = !0; 3938 else { 3939 let f = t.doc.resolve(c), u = f.index(); 3940 i = f.parent.canReplaceWith(u, u + 1, n); 3941 } 3942 }); 3943 } 3944 if (!i) return !1; 3945 if (r) { 3946 let o = t.tr; 3947 for(let s = 0; s < t.selection.ranges.length; s++){ 3948 let { $from: { pos: l }, $to: { pos: a } } = t.selection.ranges[s]; 3949 o.setBlockType(l, a, n, e); 3950 } 3951 r(o.scrollIntoView()); 3952 } 3953 return !0; 3954 }; 3955 } 3956 function Fr(...n) { 3957 return function(e, t, r) { 3958 for(let i = 0; i < n.length; i++)if (n[i](e, t, r)) return !0; 3959 return !1; 3960 }; 3961 } 3962 Fr(ps, gs, ks); 3963 Fr(ps, xs, Ss); 3964 Fr(ws, Ms, Cs, yc); 3965 typeof navigator < "u" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os < "u" && os.platform && os.platform() == "darwin"; 3966 function Mc(n, e = null) { 3967 return function(t, r) { 3968 let { $from: i, $to: o } = t.selection, s = i.blockRange(o); 3969 if (!s) return !1; 3970 let l = r ? t.tr : null; 3971 return Cc(l, s, n, e) ? (r && r(l.scrollIntoView()), !0) : !1; 3972 }; 3973 } 3974 function Cc(n, e, t, r = null) { 3975 let i = !1, o = e, s = e.$from.doc; 3976 if (e.depth >= 2 && e.$from.node(e.depth - 1).type.compatibleContent(t) && e.startIndex == 0) { 3977 if (e.$from.index(e.depth - 1) == 0) return !1; 3978 let a = s.resolve(e.start - 2); 3979 o = new fn(a, a, e.depth), e.endIndex < e.parent.childCount && (e = new fn(e.$from, s.resolve(e.$to.end(e.depth)), e.depth)), i = !0; 3980 } 3981 let l = ns(o, t, r, e); 3982 return l ? (n && Tc(n, e, l, i, t), !0) : !1; 3983 } 3984 function Tc(n, e, t, r, i) { 3985 let o = k.empty; 3986 for(let f = t.length - 1; f >= 0; f--)o = k.from(t[f].type.create(t[f].attrs, o)); 3987 n.step(new L(e.start - (r ? 2 : 0), e.end, e.start, e.end, new b(o, 0, 0), t.length, !0)); 3988 let s = 0; 3989 for(let f = 0; f < t.length; f++)t[f].type == i && (s = f + 1); 3990 let l = t.length - s, a = e.start + t.length - (r ? 2 : 0), c = e.parent; 3991 for(let f = e.startIndex, u = e.endIndex, d = !0; f < u; f++, d = !1)!d && be(n.doc, a, l) && (n.split(a, l), a += 2 * l), a += c.child(f).nodeSize; 3992 return n; 3993 } 3994 function vc(n) { 3995 return function(e, t) { 3996 let { $from: r, $to: i } = e.selection, o = r.blockRange(i, (s)=>s.childCount > 0 && s.firstChild.type == n); 3997 return o ? t ? r.node(o.depth - 1).type == n ? Oc(e, t, n, o) : Nc(e, t, o) : !0 : !1; 3998 }; 3999 } 4000 function Oc(n, e, t, r) { 4001 let i = n.tr, o = r.end, s = r.$to.end(r.depth); 4002 o < s && (i.step(new L(o - 1, s, o, s, new b(k.from(t.create(null, r.parent.copy())), 1, 0), 1, !0)), r = new fn(i.doc.resolve(r.$from.pos), i.doc.resolve(s), r.depth)); 4003 const l = ht(r); 4004 if (l == null) return !1; 4005 i.lift(r, l); 4006 let a = i.doc.resolve(i.mapping.map(o, -1) - 1); 4007 return Xe(i.doc, a.pos) && a.nodeBefore.type == a.nodeAfter.type && i.join(a.pos), e(i.scrollIntoView()), !0; 4008 } 4009 function Nc(n, e, t) { 4010 let r = n.tr, i = t.parent; 4011 for(let h = t.end, p = t.endIndex - 1, m = t.startIndex; p > m; p--)h -= i.child(p).nodeSize, r.delete(h - 1, h + 1); 4012 let o = r.doc.resolve(t.start), s = o.nodeAfter; 4013 if (r.mapping.map(t.end) != t.start + o.nodeAfter.nodeSize) return !1; 4014 let l = t.startIndex == 0, a = t.endIndex == i.childCount, c = o.node(-1), f = o.index(-1); 4015 if (!c.canReplace(f + (l ? 0 : 1), f + 1, s.content.append(a ? k.empty : k.from(i)))) return !1; 4016 let u = o.pos, d = u + s.nodeSize; 4017 return r.step(new L(u - (l ? 1 : 0), d + (a ? 1 : 0), u + 1, d - 1, new b((l ? k.empty : k.from(i.copy(k.empty))).append(a ? k.empty : k.from(i.copy(k.empty))), l ? 0 : 1, a ? 0 : 1), l ? 0 : 1)), e(r.scrollIntoView()), !0; 4018 } 4019 function Ec(n) { 4020 return function(e, t) { 4021 let { $from: r, $to: i } = e.selection, o = r.blockRange(i, (c)=>c.childCount > 0 && c.firstChild.type == n); 4022 if (!o) return !1; 4023 let s = o.startIndex; 4024 if (s == 0) return !1; 4025 let l = o.parent, a = l.child(s - 1); 4026 if (a.type != n) return !1; 4027 if (t) { 4028 let c = a.lastChild && a.lastChild.type == l.type, f = k.from(c ? n.create() : null), u = new b(k.from(n.create(null, k.from(l.type.create(null, f)))), c ? 3 : 1, 0), d = o.start, h = o.end; 4029 t(e.tr.step(new L(d - (c ? 3 : 1), h, d, h, u, 1, !0)).scrollIntoView()); 4030 } 4031 return !0; 4032 }; 4033 } 4034 const j = function(n) { 4035 for(var e = 0;; e++)if (n = n.previousSibling, !n) return e; 4036 }, ct = function(n) { 4037 let e = n.assignedSlot || n.parentNode; 4038 return e && e.nodeType == 11 ? e.host : e; 4039 }; 4040 let pr = null; 4041 const pe = function(n, e, t) { 4042 let r = pr || (pr = document.createRange()); 4043 return r.setEnd(n, t ?? n.nodeValue.length), r.setStart(n, e || 0), r; 4044 }, Dc = function() { 4045 pr = null; 4046 }, Ye = function(n, e, t, r) { 4047 return t && (Oi(n, e, t, r, -1) || Oi(n, e, t, r, 1)); 4048 }, Ac = /^(img|br|input|textarea|hr)$/i; 4049 function Oi(n, e, t, r, i) { 4050 for(var o;;){ 4051 if (n == t && e == r) return !0; 4052 if (e == (i < 0 ? 0 : ne(n))) { 4053 let s = n.parentNode; 4054 if (!s || s.nodeType != 1 || Lt(n) || Ac.test(n.nodeName) || n.contentEditable == "false") return !1; 4055 e = j(n) + (i < 0 ? 0 : 1), n = s; 4056 } else if (n.nodeType == 1) { 4057 let s = n.childNodes[e + (i < 0 ? -1 : 0)]; 4058 if (s.nodeType == 1 && s.contentEditable == "false") if (!((o = s.pmViewDesc) === null || o === void 0) && o.ignoreForSelection) e += i; 4059 else return !1; 4060 else n = s, e = i < 0 ? ne(n) : 0; 4061 } else return !1; 4062 } 4063 } 4064 function ne(n) { 4065 return n.nodeType == 3 ? n.nodeValue.length : n.childNodes.length; 4066 } 4067 function Ic(n, e) { 4068 for(;;){ 4069 if (n.nodeType == 3 && e) return n; 4070 if (n.nodeType == 1 && e > 0) { 4071 if (n.contentEditable == "false") return null; 4072 n = n.childNodes[e - 1], e = ne(n); 4073 } else if (n.parentNode && !Lt(n)) e = j(n), n = n.parentNode; 4074 else return null; 4075 } 4076 } 4077 function Rc(n, e) { 4078 for(;;){ 4079 if (n.nodeType == 3 && e < n.nodeValue.length) return n; 4080 if (n.nodeType == 1 && e < n.childNodes.length) { 4081 if (n.contentEditable == "false") return null; 4082 n = n.childNodes[e], e = 0; 4083 } else if (n.parentNode && !Lt(n)) e = j(n) + 1, n = n.parentNode; 4084 else return null; 4085 } 4086 } 4087 function Bc(n, e, t) { 4088 for(let r = e == 0, i = e == ne(n); r || i;){ 4089 if (n == t) return !0; 4090 let o = j(n); 4091 if (n = n.parentNode, !n) return !1; 4092 r = r && o == 0, i = i && o == ne(n); 4093 } 4094 } 4095 function Lt(n) { 4096 let e; 4097 for(let t = n; t && !(e = t.pmViewDesc); t = t.parentNode); 4098 return e && e.node && e.node.isBlock && (e.dom == n || e.contentDOM == n); 4099 } 4100 const Rn = function(n) { 4101 return n.focusNode && Ye(n.focusNode, n.focusOffset, n.anchorNode, n.anchorOffset); 4102 }; 4103 function Pe(n, e) { 4104 let t = document.createEvent("Event"); 4105 return t.initEvent("keydown", !0, !0), t.keyCode = n, t.key = t.code = e, t; 4106 } 4107 function Pc(n) { 4108 let e = n.activeElement; 4109 for(; e && e.shadowRoot;)e = e.shadowRoot.activeElement; 4110 return e; 4111 } 4112 function zc(n, e, t) { 4113 if (n.caretPositionFromPoint) try { 4114 let r = n.caretPositionFromPoint(e, t); 4115 if (r) return { 4116 node: r.offsetNode, 4117 offset: Math.min(ne(r.offsetNode), r.offset) 4118 }; 4119 } catch {} 4120 if (n.caretRangeFromPoint) { 4121 let r = n.caretRangeFromPoint(e, t); 4122 if (r) return { 4123 node: r.startContainer, 4124 offset: Math.min(ne(r.startContainer), r.startOffset) 4125 }; 4126 } 4127 } 4128 const ue = typeof navigator < "u" ? navigator : null, Ni = typeof document < "u" ? document : null, Ie = ue && ue.userAgent || "", mr = /Edge\/(\d+)/.exec(Ie), Os = /MSIE \d/.exec(Ie), gr = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ie), G = !!(Os || gr || mr), Oe = Os ? document.documentMode : gr ? +gr[1] : mr ? +mr[1] : 0, ie = !G && /gecko\/(\d+)/i.test(Ie); 4129 ie && +(/Firefox\/(\d+)/.exec(Ie) || [ 4130 0, 4131 0 4132 ])[1]; 4133 const yr = !G && /Chrome\/(\d+)/.exec(Ie), J = !!yr, Ns = yr ? +yr[1] : 0, K = !G && !!ue && /Apple Computer/.test(ue.vendor), ft = K && (/Mobile\/\w+/.test(Ie) || !!ue && ue.maxTouchPoints > 2), te = ft || (ue ? /Mac/.test(ue.platform) : !1), Es = ue ? /Win/.test(ue.platform) : !1, ge = /Android \d/.test(Ie), Vt = !!Ni && "webkitFontSmoothing" in Ni.documentElement.style, Fc = Vt ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [ 4134 0, 4135 0 4136 ])[1] : 0; 4137 function Lc(n) { 4138 let e = n.defaultView && n.defaultView.visualViewport; 4139 return e ? { 4140 left: 0, 4141 right: e.width, 4142 top: 0, 4143 bottom: e.height 4144 } : { 4145 left: 0, 4146 right: n.documentElement.clientWidth, 4147 top: 0, 4148 bottom: n.documentElement.clientHeight 4149 }; 4150 } 4151 function he(n, e) { 4152 return typeof n == "number" ? n : n[e]; 4153 } 4154 function Vc(n) { 4155 let e = n.getBoundingClientRect(), t = e.width / n.offsetWidth || 1, r = e.height / n.offsetHeight || 1; 4156 return { 4157 left: e.left, 4158 right: e.left + n.clientWidth * t, 4159 top: e.top, 4160 bottom: e.top + n.clientHeight * r 4161 }; 4162 } 4163 function Ei(n, e, t) { 4164 if (!kr(e) && e.left == 0) return; 4165 let r = n.someProp("scrollThreshold") || 0, i = n.someProp("scrollMargin") || 5, o = n.dom.ownerDocument; 4166 for(let s = t || n.dom; s;){ 4167 if (s.nodeType != 1) { 4168 s = ct(s); 4169 continue; 4170 } 4171 let l = s, a = l == o.body, c = a ? Lc(o) : Vc(l), f = 0, u = 0; 4172 if (e.top < c.top + he(r, "top") ? u = -(c.top - e.top + he(i, "top")) : e.bottom > c.bottom - he(r, "bottom") && (u = e.bottom - e.top > c.bottom - c.top ? e.top + he(i, "top") - c.top : e.bottom - c.bottom + he(i, "bottom")), e.left < c.left + he(r, "left") ? f = -(c.left - e.left + he(i, "left")) : e.right > c.right - he(r, "right") && (f = e.right - c.right + he(i, "right")), f || u) if (a) o.defaultView.scrollBy(f, u); 4173 else { 4174 let h = l.scrollLeft, p = l.scrollTop; 4175 u && (l.scrollTop += u), f && (l.scrollLeft += f); 4176 let m = l.scrollLeft - h, g = l.scrollTop - p; 4177 e = { 4178 left: e.left - m, 4179 top: e.top - g, 4180 right: e.right - m, 4181 bottom: e.bottom - g 4182 }; 4183 } 4184 let d = a ? "fixed" : getComputedStyle(s).position; 4185 if (/^(fixed|sticky)$/.test(d)) break; 4186 s = d == "absolute" ? s.offsetParent : ct(s); 4187 } 4188 } 4189 function $c(n) { 4190 let e = n.dom.getBoundingClientRect(), t = Math.max(0, e.top), r, i; 4191 for(let o = (e.left + e.right) / 2, s = t + 1; s < Math.min(innerHeight, e.bottom); s += 5){ 4192 let l = n.root.elementFromPoint(o, s); 4193 if (!l || l == n.dom || !n.dom.contains(l)) continue; 4194 let a = l.getBoundingClientRect(); 4195 if (a.top >= t - 20) { 4196 r = l, i = a.top; 4197 break; 4198 } 4199 } 4200 return { 4201 refDOM: r, 4202 refTop: i, 4203 stack: Ds(n.dom) 4204 }; 4205 } 4206 function Ds(n) { 4207 let e = [], t = n.ownerDocument; 4208 for(let r = n; r && (e.push({ 4209 dom: r, 4210 top: r.scrollTop, 4211 left: r.scrollLeft 4212 }), n != t); r = ct(r)); 4213 return e; 4214 } 4215 function jc({ refDOM: n, refTop: e, stack: t }) { 4216 let r = n ? n.getBoundingClientRect().top : 0; 4217 As(t, r == 0 ? 0 : r - e); 4218 } 4219 function As(n, e) { 4220 for(let t = 0; t < n.length; t++){ 4221 let { dom: r, top: i, left: o } = n[t]; 4222 r.scrollTop != i + e && (r.scrollTop = i + e), r.scrollLeft != o && (r.scrollLeft = o); 4223 } 4224 } 4225 let Qe = null; 4226 function Wc(n) { 4227 if (n.setActive) return n.setActive(); 4228 if (Qe) return n.focus(Qe); 4229 let e = Ds(n); 4230 n.focus(Qe == null ? { 4231 get preventScroll () { 4232 return Qe = { 4233 preventScroll: !0 4234 }, !0; 4235 } 4236 } : void 0), Qe || (Qe = !1, As(e, 0)); 4237 } 4238 function Is(n, e) { 4239 let t, r = 2e8, i, o = 0, s = e.top, l = e.top, a, c; 4240 for(let f = n.firstChild, u = 0; f; f = f.nextSibling, u++){ 4241 let d; 4242 if (f.nodeType == 1) d = f.getClientRects(); 4243 else if (f.nodeType == 3) d = pe(f).getClientRects(); 4244 else continue; 4245 for(let h = 0; h < d.length; h++){ 4246 let p = d[h]; 4247 if (p.top <= s && p.bottom >= l) { 4248 s = Math.max(p.bottom, s), l = Math.min(p.top, l); 4249 let m = p.left > e.left ? p.left - e.left : p.right < e.left ? e.left - p.right : 0; 4250 if (m < r) { 4251 t = f, r = m, i = m && t.nodeType == 3 ? { 4252 left: p.right < e.left ? p.right : p.left, 4253 top: e.top 4254 } : e, f.nodeType == 1 && m && (o = u + (e.left >= (p.left + p.right) / 2 ? 1 : 0)); 4255 continue; 4256 } 4257 } else p.top > e.top && !a && p.left <= e.left && p.right >= e.left && (a = f, c = { 4258 left: Math.max(p.left, Math.min(p.right, e.left)), 4259 top: p.top 4260 }); 4261 !t && (e.left >= p.right && e.top >= p.top || e.left >= p.left && e.top >= p.bottom) && (o = u + 1); 4262 } 4263 } 4264 return !t && a && (t = a, i = c, r = 0), t && t.nodeType == 3 ? Jc(t, i) : !t || r && t.nodeType == 1 ? { 4265 node: n, 4266 offset: o 4267 } : Is(t, i); 4268 } 4269 function Jc(n, e) { 4270 let t = n.nodeValue.length, r = document.createRange(), i; 4271 for(let o = 0; o < t; o++){ 4272 r.setEnd(n, o + 1), r.setStart(n, o); 4273 let s = we(r, 1); 4274 if (s.top != s.bottom && Lr(e, s)) { 4275 i = { 4276 node: n, 4277 offset: o + (e.left >= (s.left + s.right) / 2 ? 1 : 0) 4278 }; 4279 break; 4280 } 4281 } 4282 return r.detach(), i || { 4283 node: n, 4284 offset: 0 4285 }; 4286 } 4287 function Lr(n, e) { 4288 return n.left >= e.left - 1 && n.left <= e.right + 1 && n.top >= e.top - 1 && n.top <= e.bottom + 1; 4289 } 4290 function qc(n, e) { 4291 let t = n.parentNode; 4292 return t && /^li$/i.test(t.nodeName) && e.left < n.getBoundingClientRect().left ? t : n; 4293 } 4294 function Kc(n, e, t) { 4295 let { node: r, offset: i } = Is(e, t), o = -1; 4296 if (r.nodeType == 1 && !r.firstChild) { 4297 let s = r.getBoundingClientRect(); 4298 o = s.left != s.right && t.left > (s.left + s.right) / 2 ? 1 : -1; 4299 } 4300 return n.docView.posFromDOM(r, i, o); 4301 } 4302 function Hc(n, e, t, r) { 4303 let i = -1; 4304 for(let o = e, s = !1; o != n.dom;){ 4305 let l = n.docView.nearestDesc(o, !0), a; 4306 if (!l) return null; 4307 if (l.dom.nodeType == 1 && (l.node.isBlock && l.parent || !l.contentDOM) && ((a = l.dom.getBoundingClientRect()).width || a.height) && (l.node.isBlock && l.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName) && (!s && a.left > r.left || a.top > r.top ? i = l.posBefore : (!s && a.right < r.left || a.bottom < r.top) && (i = l.posAfter), s = !0), !l.contentDOM && i < 0 && !l.node.isText)) return (l.node.isBlock ? r.top < (a.top + a.bottom) / 2 : r.left < (a.left + a.right) / 2) ? l.posBefore : l.posAfter; 4308 o = l.dom.parentNode; 4309 } 4310 return i > -1 ? i : n.docView.posFromDOM(e, t, -1); 4311 } 4312 function Rs(n, e, t) { 4313 let r = n.childNodes.length; 4314 if (r && t.top < t.bottom) for(let i = Math.max(0, Math.min(r - 1, Math.floor(r * (e.top - t.top) / (t.bottom - t.top)) - 2)), o = i;;){ 4315 let s = n.childNodes[o]; 4316 if (s.nodeType == 1) { 4317 let l = s.getClientRects(); 4318 for(let a = 0; a < l.length; a++){ 4319 let c = l[a]; 4320 if (Lr(e, c)) return Rs(s, e, c); 4321 } 4322 } 4323 if ((o = (o + 1) % r) == i) break; 4324 } 4325 return n; 4326 } 4327 function _c(n, e) { 4328 let t = n.dom.ownerDocument, r, i = 0, o = zc(t, e.left, e.top); 4329 o && ({ node: r, offset: i } = o); 4330 let s = (n.root.elementFromPoint ? n.root : t).elementFromPoint(e.left, e.top), l; 4331 if (!s || !n.dom.contains(s.nodeType != 1 ? s.parentNode : s)) { 4332 let c = n.dom.getBoundingClientRect(); 4333 if (!Lr(e, c) || (s = Rs(n.dom, e, c), !s)) return null; 4334 } 4335 if (K) for(let c = s; r && c; c = ct(c))c.draggable && (r = void 0); 4336 if (s = qc(s, e), r) { 4337 if (ie && r.nodeType == 1 && (i = Math.min(i, r.childNodes.length), i < r.childNodes.length)) { 4338 let f = r.childNodes[i], u; 4339 f.nodeName == "IMG" && (u = f.getBoundingClientRect()).right <= e.left && u.bottom > e.top && i++; 4340 } 4341 let c; 4342 Vt && i && r.nodeType == 1 && (c = r.childNodes[i - 1]).nodeType == 1 && c.contentEditable == "false" && c.getBoundingClientRect().top >= e.top && i--, r == n.dom && i == r.childNodes.length - 1 && r.lastChild.nodeType == 1 && e.top > r.lastChild.getBoundingClientRect().bottom ? l = n.state.doc.content.size : (i == 0 || r.nodeType != 1 || r.childNodes[i - 1].nodeName != "BR") && (l = Hc(n, r, i, e)); 4343 } 4344 l == null && (l = Kc(n, s, e)); 4345 let a = n.docView.nearestDesc(s, !0); 4346 return { 4347 pos: l, 4348 inside: a ? a.posAtStart - a.border : -1 4349 }; 4350 } 4351 function kr(n) { 4352 return n.top < n.bottom || n.left < n.right; 4353 } 4354 function we(n, e) { 4355 let t = n.getClientRects(); 4356 if (t.length) { 4357 let r = t[e < 0 ? 0 : t.length - 1]; 4358 if (kr(r)) return r; 4359 } 4360 return Array.prototype.find.call(t, kr) || n.getBoundingClientRect(); 4361 } 4362 const Uc = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; 4363 function Bs(n, e, t) { 4364 let { node: r, offset: i, atom: o } = n.docView.domFromPos(e, t < 0 ? -1 : 1), s = Vt || ie; 4365 if (r.nodeType == 3) if (s && (Uc.test(r.nodeValue) || (t < 0 ? !i : i == r.nodeValue.length))) { 4366 let a = we(pe(r, i, i), t); 4367 if (ie && i && /\s/.test(r.nodeValue[i - 1]) && i < r.nodeValue.length) { 4368 let c = we(pe(r, i - 1, i - 1), -1); 4369 if (c.top == a.top) { 4370 let f = we(pe(r, i, i + 1), -1); 4371 if (f.top != a.top) return pt(f, f.left < c.left); 4372 } 4373 } 4374 return a; 4375 } else { 4376 let a = i, c = i, f = t < 0 ? 1 : -1; 4377 return t < 0 && !i ? (c++, f = -1) : t >= 0 && i == r.nodeValue.length ? (a--, f = 1) : t < 0 ? a-- : c++, pt(we(pe(r, a, c), f), f < 0); 4378 } 4379 if (!n.state.doc.resolve(e - (o || 0)).parent.inlineContent) { 4380 if (o == null && i && (t < 0 || i == ne(r))) { 4381 let a = r.childNodes[i - 1]; 4382 if (a.nodeType == 1) return Un(a.getBoundingClientRect(), !1); 4383 } 4384 if (o == null && i < ne(r)) { 4385 let a = r.childNodes[i]; 4386 if (a.nodeType == 1) return Un(a.getBoundingClientRect(), !0); 4387 } 4388 return Un(r.getBoundingClientRect(), t >= 0); 4389 } 4390 if (o == null && i && (t < 0 || i == ne(r))) { 4391 let a = r.childNodes[i - 1], c = a.nodeType == 3 ? pe(a, ne(a) - (s ? 0 : 1)) : a.nodeType == 1 && (a.nodeName != "BR" || !a.nextSibling) ? a : null; 4392 if (c) return pt(we(c, 1), !1); 4393 } 4394 if (o == null && i < ne(r)) { 4395 let a = r.childNodes[i]; 4396 for(; a.pmViewDesc && a.pmViewDesc.ignoreForCoords;)a = a.nextSibling; 4397 let c = a ? a.nodeType == 3 ? pe(a, 0, s ? 0 : 1) : a.nodeType == 1 ? a : null : null; 4398 if (c) return pt(we(c, -1), !0); 4399 } 4400 return pt(we(r.nodeType == 3 ? pe(r) : r, -t), t >= 0); 4401 } 4402 function pt(n, e) { 4403 if (n.width == 0) return n; 4404 let t = e ? n.left : n.right; 4405 return { 4406 top: n.top, 4407 bottom: n.bottom, 4408 left: t, 4409 right: t 4410 }; 4411 } 4412 function Un(n, e) { 4413 if (n.height == 0) return n; 4414 let t = e ? n.top : n.bottom; 4415 return { 4416 top: t, 4417 bottom: t, 4418 left: n.left, 4419 right: n.right 4420 }; 4421 } 4422 function Ps(n, e, t) { 4423 let r = n.state, i = n.root.activeElement; 4424 r != e && n.updateState(e), i != n.dom && n.focus(); 4425 try { 4426 return t(); 4427 } finally{ 4428 r != e && n.updateState(r), i != n.dom && i && i.focus(); 4429 } 4430 } 4431 function Yc(n, e, t) { 4432 let r = e.selection, i = t == "up" ? r.$from : r.$to; 4433 return Ps(n, e, ()=>{ 4434 let { node: o } = n.docView.domFromPos(i.pos, t == "up" ? -1 : 1); 4435 for(;;){ 4436 let l = n.docView.nearestDesc(o, !0); 4437 if (!l) break; 4438 if (l.node.isBlock) { 4439 o = l.contentDOM || l.dom; 4440 break; 4441 } 4442 o = l.dom.parentNode; 4443 } 4444 let s = Bs(n, i.pos, 1); 4445 for(let l = o.firstChild; l; l = l.nextSibling){ 4446 let a; 4447 if (l.nodeType == 1) a = l.getClientRects(); 4448 else if (l.nodeType == 3) a = pe(l, 0, l.nodeValue.length).getClientRects(); 4449 else continue; 4450 for(let c = 0; c < a.length; c++){ 4451 let f = a[c]; 4452 if (f.bottom > f.top + 1 && (t == "up" ? s.top - f.top > (f.bottom - s.top) * 2 : f.bottom - s.bottom > (s.bottom - f.top) * 2)) return !1; 4453 } 4454 } 4455 return !0; 4456 }); 4457 } 4458 const Gc = /[\u0590-\u08ac]/; 4459 function Xc(n, e, t) { 4460 let { $head: r } = e.selection; 4461 if (!r.parent.isTextblock) return !1; 4462 let i = r.parentOffset, o = !i, s = i == r.parent.content.size, l = n.domSelection(); 4463 return l ? !Gc.test(r.parent.textContent) || !l.modify ? t == "left" || t == "backward" ? o : s : Ps(n, e, ()=>{ 4464 let { focusNode: a, focusOffset: c, anchorNode: f, anchorOffset: u } = n.domSelectionRange(), d = l.caretBidiLevel; 4465 l.modify("move", t, "character"); 4466 let h = r.depth ? n.docView.domAfterPos(r.before()) : n.dom, { focusNode: p, focusOffset: m } = n.domSelectionRange(), g = p && !h.contains(p.nodeType == 1 ? p : p.parentNode) || a == p && c == m; 4467 try { 4468 l.collapse(f, u), a && (a != f || c != u) && l.extend && l.extend(a, c); 4469 } catch {} 4470 return d != null && (l.caretBidiLevel = d), g; 4471 }) : r.pos == r.start() || r.pos == r.end(); 4472 } 4473 let Di = null, Ai = null, Ii = !1; 4474 function Qc(n, e, t) { 4475 return Di == e && Ai == t ? Ii : (Di = e, Ai = t, Ii = t == "up" || t == "down" ? Yc(n, e, t) : Xc(n, e, t)); 4476 } 4477 const oe = 0, Ri = 1, Fe = 2, le = 3; 4478 class $t { 4479 constructor(e, t, r, i){ 4480 this.parent = e, this.children = t, this.dom = r, this.contentDOM = i, this.dirty = oe, r.pmViewDesc = this; 4481 } 4482 matchesWidget(e) { 4483 return !1; 4484 } 4485 matchesMark(e) { 4486 return !1; 4487 } 4488 matchesNode(e, t, r) { 4489 return !1; 4490 } 4491 matchesHack(e) { 4492 return !1; 4493 } 4494 parseRule(e) { 4495 return null; 4496 } 4497 stopEvent(e) { 4498 return !1; 4499 } 4500 get size() { 4501 let e = 0; 4502 for(let t = 0; t < this.children.length; t++)e += this.children[t].size; 4503 return e; 4504 } 4505 get border() { 4506 return 0; 4507 } 4508 destroy() { 4509 this.parent = void 0, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0); 4510 for(let e = 0; e < this.children.length; e++)this.children[e].destroy(); 4511 } 4512 posBeforeChild(e) { 4513 for(let t = 0, r = this.posAtStart;; t++){ 4514 let i = this.children[t]; 4515 if (i == e) return r; 4516 r += i.size; 4517 } 4518 } 4519 get posBefore() { 4520 return this.parent.posBeforeChild(this); 4521 } 4522 get posAtStart() { 4523 return this.parent ? this.parent.posBeforeChild(this) + this.border : 0; 4524 } 4525 get posAfter() { 4526 return this.posBefore + this.size; 4527 } 4528 get posAtEnd() { 4529 return this.posAtStart + this.size - 2 * this.border; 4530 } 4531 localPosFromDOM(e, t, r) { 4532 if (this.contentDOM && this.contentDOM.contains(e.nodeType == 1 ? e : e.parentNode)) if (r < 0) { 4533 let o, s; 4534 if (e == this.contentDOM) o = e.childNodes[t - 1]; 4535 else { 4536 for(; e.parentNode != this.contentDOM;)e = e.parentNode; 4537 o = e.previousSibling; 4538 } 4539 for(; o && !((s = o.pmViewDesc) && s.parent == this);)o = o.previousSibling; 4540 return o ? this.posBeforeChild(s) + s.size : this.posAtStart; 4541 } else { 4542 let o, s; 4543 if (e == this.contentDOM) o = e.childNodes[t]; 4544 else { 4545 for(; e.parentNode != this.contentDOM;)e = e.parentNode; 4546 o = e.nextSibling; 4547 } 4548 for(; o && !((s = o.pmViewDesc) && s.parent == this);)o = o.nextSibling; 4549 return o ? this.posBeforeChild(s) : this.posAtEnd; 4550 } 4551 let i; 4552 if (e == this.dom && this.contentDOM) i = t > j(this.contentDOM); 4553 else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) i = e.compareDocumentPosition(this.contentDOM) & 2; 4554 else if (this.dom.firstChild) { 4555 if (t == 0) for(let o = e;; o = o.parentNode){ 4556 if (o == this.dom) { 4557 i = !1; 4558 break; 4559 } 4560 if (o.previousSibling) break; 4561 } 4562 if (i == null && t == e.childNodes.length) for(let o = e;; o = o.parentNode){ 4563 if (o == this.dom) { 4564 i = !0; 4565 break; 4566 } 4567 if (o.nextSibling) break; 4568 } 4569 } 4570 return i ?? r > 0 ? this.posAtEnd : this.posAtStart; 4571 } 4572 nearestDesc(e, t = !1) { 4573 for(let r = !0, i = e; i; i = i.parentNode){ 4574 let o = this.getDesc(i), s; 4575 if (o && (!t || o.node)) if (r && (s = o.nodeDOM) && !(s.nodeType == 1 ? s.contains(e.nodeType == 1 ? e : e.parentNode) : s == e)) r = !1; 4576 else return o; 4577 } 4578 } 4579 getDesc(e) { 4580 let t = e.pmViewDesc; 4581 for(let r = t; r; r = r.parent)if (r == this) return t; 4582 } 4583 posFromDOM(e, t, r) { 4584 for(let i = e; i; i = i.parentNode){ 4585 let o = this.getDesc(i); 4586 if (o) return o.localPosFromDOM(e, t, r); 4587 } 4588 return -1; 4589 } 4590 descAt(e) { 4591 for(let t = 0, r = 0; t < this.children.length; t++){ 4592 let i = this.children[t], o = r + i.size; 4593 if (r == e && o != r) { 4594 for(; !i.border && i.children.length;)for(let s = 0; s < i.children.length; s++){ 4595 let l = i.children[s]; 4596 if (l.size) { 4597 i = l; 4598 break; 4599 } 4600 } 4601 return i; 4602 } 4603 if (e < o) return i.descAt(e - r - i.border); 4604 r = o; 4605 } 4606 } 4607 domFromPos(e, t) { 4608 if (!this.contentDOM) return { 4609 node: this.dom, 4610 offset: 0, 4611 atom: e + 1 4612 }; 4613 let r = 0, i = 0; 4614 for(let o = 0; r < this.children.length; r++){ 4615 let s = this.children[r], l = o + s.size; 4616 if (l > e || s instanceof Fs) { 4617 i = e - o; 4618 break; 4619 } 4620 o = l; 4621 } 4622 if (i) return this.children[r].domFromPos(i - this.children[r].border, t); 4623 for(let o; r && !(o = this.children[r - 1]).size && o instanceof zs && o.side >= 0; r--); 4624 if (t <= 0) { 4625 let o, s = !0; 4626 for(; o = r ? this.children[r - 1] : null, !(!o || o.dom.parentNode == this.contentDOM); r--, s = !1); 4627 return o && t && s && !o.border && !o.domAtom ? o.domFromPos(o.size, t) : { 4628 node: this.contentDOM, 4629 offset: o ? j(o.dom) + 1 : 0 4630 }; 4631 } else { 4632 let o, s = !0; 4633 for(; o = r < this.children.length ? this.children[r] : null, !(!o || o.dom.parentNode == this.contentDOM); r++, s = !1); 4634 return o && s && !o.border && !o.domAtom ? o.domFromPos(0, t) : { 4635 node: this.contentDOM, 4636 offset: o ? j(o.dom) : this.contentDOM.childNodes.length 4637 }; 4638 } 4639 } 4640 parseRange(e, t, r = 0) { 4641 if (this.children.length == 0) return { 4642 node: this.contentDOM, 4643 from: e, 4644 to: t, 4645 fromOffset: 0, 4646 toOffset: this.contentDOM.childNodes.length 4647 }; 4648 let i = -1, o = -1; 4649 for(let s = r, l = 0;; l++){ 4650 let a = this.children[l], c = s + a.size; 4651 if (i == -1 && e <= c) { 4652 let f = s + a.border; 4653 if (e >= f && t <= c - a.border && a.node && a.contentDOM && this.contentDOM.contains(a.contentDOM)) return a.parseRange(e, t, f); 4654 e = s; 4655 for(let u = l; u > 0; u--){ 4656 let d = this.children[u - 1]; 4657 if (d.size && d.dom.parentNode == this.contentDOM && !d.emptyChildAt(1)) { 4658 i = j(d.dom) + 1; 4659 break; 4660 } 4661 e -= d.size; 4662 } 4663 i == -1 && (i = 0); 4664 } 4665 if (i > -1 && (c > t || l == this.children.length - 1)) { 4666 t = c; 4667 for(let f = l + 1; f < this.children.length; f++){ 4668 let u = this.children[f]; 4669 if (u.size && u.dom.parentNode == this.contentDOM && !u.emptyChildAt(-1)) { 4670 o = j(u.dom); 4671 break; 4672 } 4673 t += u.size; 4674 } 4675 o == -1 && (o = this.contentDOM.childNodes.length); 4676 break; 4677 } 4678 s = c; 4679 } 4680 return { 4681 node: this.contentDOM, 4682 from: e, 4683 to: t, 4684 fromOffset: i, 4685 toOffset: o 4686 }; 4687 } 4688 emptyChildAt(e) { 4689 if (this.border || !this.contentDOM || !this.children.length) return !1; 4690 let t = this.children[e < 0 ? 0 : this.children.length - 1]; 4691 return t.size == 0 || t.emptyChildAt(e); 4692 } 4693 domAfterPos(e) { 4694 let { node: t, offset: r } = this.domFromPos(e, 0); 4695 if (t.nodeType != 1 || r == t.childNodes.length) throw new RangeError("No node after pos " + e); 4696 return t.childNodes[r]; 4697 } 4698 setSelection(e, t, r, i = !1) { 4699 let o = Math.min(e, t), s = Math.max(e, t); 4700 for(let h = 0, p = 0; h < this.children.length; h++){ 4701 let m = this.children[h], g = p + m.size; 4702 if (o > p && s < g) return m.setSelection(e - p - m.border, t - p - m.border, r, i); 4703 p = g; 4704 } 4705 let l = this.domFromPos(e, e ? -1 : 1), a = t == e ? l : this.domFromPos(t, t ? -1 : 1), c = r.root.getSelection(), f = r.domSelectionRange(), u = !1; 4706 if ((ie || K) && e == t) { 4707 let { node: h, offset: p } = l; 4708 if (h.nodeType == 3) { 4709 if (u = !!(p && h.nodeValue[p - 1] == ` 4710`), u && p == h.nodeValue.length) for(let m = h, g; m; m = m.parentNode){ 4711 if (g = m.nextSibling) { 4712 g.nodeName == "BR" && (l = a = { 4713 node: g.parentNode, 4714 offset: j(g) + 1 4715 }); 4716 break; 4717 } 4718 let y = m.pmViewDesc; 4719 if (y && y.node && y.node.isBlock) break; 4720 } 4721 } else { 4722 let m = h.childNodes[p - 1]; 4723 u = m && (m.nodeName == "BR" || m.contentEditable == "false"); 4724 } 4725 } 4726 if (ie && f.focusNode && f.focusNode != a.node && f.focusNode.nodeType == 1) { 4727 let h = f.focusNode.childNodes[f.focusOffset]; 4728 h && h.contentEditable == "false" && (i = !0); 4729 } 4730 if (!(i || u && K) && Ye(l.node, l.offset, f.anchorNode, f.anchorOffset) && Ye(a.node, a.offset, f.focusNode, f.focusOffset)) return; 4731 let d = !1; 4732 if ((c.extend || e == t) && !(u && ie)) { 4733 c.collapse(l.node, l.offset); 4734 try { 4735 e != t && c.extend(a.node, a.offset), d = !0; 4736 } catch {} 4737 } 4738 if (!d) { 4739 if (e > t) { 4740 let p = l; 4741 l = a, a = p; 4742 } 4743 let h = document.createRange(); 4744 h.setEnd(a.node, a.offset), h.setStart(l.node, l.offset), c.removeAllRanges(), c.addRange(h); 4745 } 4746 } 4747 ignoreMutation(e) { 4748 return !this.contentDOM && e.type != "selection"; 4749 } 4750 get contentLost() { 4751 return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM); 4752 } 4753 markDirty(e, t) { 4754 for(let r = 0, i = 0; i < this.children.length; i++){ 4755 let o = this.children[i], s = r + o.size; 4756 if (r == s ? e <= s && t >= r : e < s && t > r) { 4757 let l = r + o.border, a = s - o.border; 4758 if (e >= l && t <= a) { 4759 this.dirty = e == r || t == s ? Fe : Ri, e == l && t == a && (o.contentLost || o.dom.parentNode != this.contentDOM) ? o.dirty = le : o.markDirty(e - l, t - l); 4760 return; 4761 } else o.dirty = o.dom == o.contentDOM && o.dom.parentNode == this.contentDOM && !o.children.length ? Fe : le; 4762 } 4763 r = s; 4764 } 4765 this.dirty = Fe; 4766 } 4767 markParentsDirty() { 4768 let e = 1; 4769 for(let t = this.parent; t; t = t.parent, e++){ 4770 let r = e == 1 ? Fe : Ri; 4771 t.dirty < r && (t.dirty = r); 4772 } 4773 } 4774 get domAtom() { 4775 return !1; 4776 } 4777 get ignoreForCoords() { 4778 return !1; 4779 } 4780 get ignoreForSelection() { 4781 return !1; 4782 } 4783 isText(e) { 4784 return !1; 4785 } 4786 } 4787 class zs extends $t { 4788 constructor(e, t, r, i){ 4789 let o, s = t.type.toDOM; 4790 if (typeof s == "function" && (s = s(r, ()=>{ 4791 if (!o) return i; 4792 if (o.parent) return o.parent.posBeforeChild(o); 4793 })), !t.type.spec.raw) { 4794 if (s.nodeType != 1) { 4795 let l = document.createElement("span"); 4796 l.appendChild(s), s = l; 4797 } 4798 s.hasAttribute("contenteditable") || (s.contentEditable = "false"), s.classList.add("ProseMirror-widget"); 4799 } 4800 super(e, [], s, null), this.widget = t, this.widget = t, o = this; 4801 } 4802 matchesWidget(e) { 4803 return this.dirty == oe && e.type.eq(this.widget.type); 4804 } 4805 parseRule() { 4806 return { 4807 ignore: !0 4808 }; 4809 } 4810 stopEvent(e) { 4811 let t = this.widget.spec.stopEvent; 4812 return t ? t(e) : !1; 4813 } 4814 ignoreMutation(e) { 4815 return e.type != "selection" || this.widget.spec.ignoreSelection; 4816 } 4817 destroy() { 4818 this.widget.type.destroy(this.dom), super.destroy(); 4819 } 4820 get domAtom() { 4821 return !0; 4822 } 4823 get ignoreForSelection() { 4824 return !!this.widget.type.spec.relaxedSide; 4825 } 4826 get side() { 4827 return this.widget.type.side; 4828 } 4829 } 4830 class Zc extends $t { 4831 constructor(e, t, r, i){ 4832 super(e, [], t, null), this.textDOM = r, this.text = i; 4833 } 4834 get size() { 4835 return this.text.length; 4836 } 4837 localPosFromDOM(e, t) { 4838 return e != this.textDOM ? this.posAtStart + (t ? this.size : 0) : this.posAtStart + t; 4839 } 4840 domFromPos(e) { 4841 return { 4842 node: this.textDOM, 4843 offset: e 4844 }; 4845 } 4846 ignoreMutation(e) { 4847 return e.type === "characterData" && e.target.nodeValue == e.oldValue; 4848 } 4849 } 4850 class Ne extends $t { 4851 constructor(e, t, r, i, o){ 4852 super(e, [], r, i), this.mark = t, this.spec = o; 4853 } 4854 static create(e, t, r, i) { 4855 let o = i.nodeViews[t.type.name], s = o && o(t, i, r); 4856 return (!s || !s.dom) && (s = Ge.renderSpec(document, t.type.spec.toDOM(t, r), null, t.attrs)), new Ne(e, t, s.dom, s.contentDOM || s.dom, s); 4857 } 4858 parseRule() { 4859 return this.dirty & le || this.mark.type.spec.reparseInView ? null : { 4860 mark: this.mark.type.name, 4861 attrs: this.mark.attrs, 4862 contentElement: this.contentDOM 4863 }; 4864 } 4865 matchesMark(e) { 4866 return this.dirty != le && this.mark.eq(e); 4867 } 4868 markDirty(e, t) { 4869 if (super.markDirty(e, t), this.dirty != oe) { 4870 let r = this.parent; 4871 for(; !r.node;)r = r.parent; 4872 r.dirty < this.dirty && (r.dirty = this.dirty), this.dirty = oe; 4873 } 4874 } 4875 slice(e, t, r) { 4876 let i = Ne.create(this.parent, this.mark, !0, r), o = this.children, s = this.size; 4877 t < s && (o = xr(o, t, s, r)), e > 0 && (o = xr(o, 0, e, r)); 4878 for(let l = 0; l < o.length; l++)o[l].parent = i; 4879 return i.children = o, i; 4880 } 4881 ignoreMutation(e) { 4882 return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e); 4883 } 4884 destroy() { 4885 this.spec.destroy && this.spec.destroy(), super.destroy(); 4886 } 4887 } 4888 class Ee extends $t { 4889 constructor(e, t, r, i, o, s, l){ 4890 super(e, [], o, s), this.node = t, this.outerDeco = r, this.innerDeco = i, this.nodeDOM = l; 4891 } 4892 static create(e, t, r, i, o, s) { 4893 let l = o.nodeViews[t.type.name], a, c = l && l(t, o, ()=>{ 4894 if (!a) return s; 4895 if (a.parent) return a.parent.posBeforeChild(a); 4896 }, r, i), f = c && c.dom, u = c && c.contentDOM; 4897 if (t.isText) { 4898 if (!f) f = document.createTextNode(t.text); 4899 else if (f.nodeType != 3) throw new RangeError("Text must be rendered as a DOM text node"); 4900 } else f || ({ dom: f, contentDOM: u } = Ge.renderSpec(document, t.type.spec.toDOM(t), null, t.attrs)); 4901 !u && !t.isText && f.nodeName != "BR" && (f.hasAttribute("contenteditable") || (f.contentEditable = "false"), t.type.spec.draggable && (f.draggable = !0)); 4902 let d = f; 4903 return f = $s(f, r, t), c ? a = new ef(e, t, r, i, f, u || null, d, c) : t.isText ? new Bn(e, t, r, i, f, d) : new Ee(e, t, r, i, f, u || null, d); 4904 } 4905 parseRule(e) { 4906 if (this.node.type.spec.reparseInView) return null; 4907 let t = { 4908 node: this.node.type.name, 4909 attrs: this.node.attrs 4910 }; 4911 if (this.node.type.whitespace == "pre" && (t.preserveWhitespace = "full"), !this.contentDOM) t.getContent = ()=>this.node.content; 4912 else if (!this.contentLost) t.contentElement = this.contentDOM; 4913 else { 4914 for(let r = this.children.length - 1; r >= 0; r--){ 4915 let i = this.children[r]; 4916 if (this.dom.contains(i.dom.parentNode)) { 4917 t.contentElement = i.dom.parentNode; 4918 break; 4919 } 4920 } 4921 if (!t.contentElement) { 4922 let r = e && e.find((i)=>i.nodeType == 1 && e.indexOf(i.parentNode) < 0 && this.dom.contains(i)); 4923 r ? t.contentElement = r : t.getContent = ()=>k.empty; 4924 } 4925 } 4926 return t; 4927 } 4928 matchesNode(e, t, r) { 4929 return this.dirty == oe && e.eq(this.node) && hn(t, this.outerDeco) && r.eq(this.innerDeco); 4930 } 4931 get size() { 4932 return this.node.nodeSize; 4933 } 4934 get border() { 4935 return this.node.isLeaf ? 0 : 1; 4936 } 4937 updateChildren(e, t) { 4938 let r = this.node.inlineContent, i = t, o = e.composing ? this.localCompositionInfo(e, t) : null, s = o && o.pos > -1 ? o : null, l = o && o.pos < 0, a = new nf(this, s && s.node, e); 4939 sf(this.node, this.innerDeco, (c, f, u)=>{ 4940 c.spec.marks ? a.syncToMarks(c.spec.marks, r, e, f) : c.type.side >= 0 && !u && a.syncToMarks(f == this.node.childCount ? I.none : this.node.child(f).marks, r, e, f), a.placeWidget(c, e, i); 4941 }, (c, f, u, d)=>{ 4942 a.syncToMarks(c.marks, r, e, d); 4943 let h; 4944 a.findNodeMatch(c, f, u, d) || l && e.state.selection.from > i && e.state.selection.to < i + c.nodeSize && (h = a.findIndexWithChild(o.node)) > -1 && a.updateNodeAt(c, f, u, h, e) || a.updateNextNode(c, f, u, e, d, i) || a.addNode(c, f, u, e, i), i += c.nodeSize; 4945 }), a.syncToMarks([], r, e, 0), this.node.isTextblock && a.addTextblockHacks(), a.destroyRest(), (a.changed || this.dirty == Fe) && (s && this.protectLocalComposition(e, s), Ls(this.contentDOM, this.children, e), ft && lf(this.dom)); 4946 } 4947 localCompositionInfo(e, t) { 4948 let { from: r, to: i } = e.state.selection; 4949 if (!(e.state.selection instanceof v) || r < t || i > t + this.node.content.size) return null; 4950 let o = e.input.compositionNode; 4951 if (!o || !this.dom.contains(o.parentNode)) return null; 4952 if (this.node.inlineContent) { 4953 let s = o.nodeValue, l = af(this.node.content, s, r - t, i - t); 4954 return l < 0 ? null : { 4955 node: o, 4956 pos: l, 4957 text: s 4958 }; 4959 } else return { 4960 node: o, 4961 pos: -1, 4962 text: "" 4963 }; 4964 } 4965 protectLocalComposition(e, { node: t, pos: r, text: i }) { 4966 if (this.getDesc(t)) return; 4967 let o = t; 4968 for(; o.parentNode != this.contentDOM; o = o.parentNode){ 4969 for(; o.previousSibling;)o.parentNode.removeChild(o.previousSibling); 4970 for(; o.nextSibling;)o.parentNode.removeChild(o.nextSibling); 4971 o.pmViewDesc && (o.pmViewDesc = void 0); 4972 } 4973 let s = new Zc(this, o, t, i); 4974 e.input.compositionNodes.push(s), this.children = xr(this.children, r, r + i.length, e, s); 4975 } 4976 update(e, t, r, i) { 4977 return this.dirty == le || !e.sameMarkup(this.node) ? !1 : (this.updateInner(e, t, r, i), !0); 4978 } 4979 updateInner(e, t, r, i) { 4980 this.updateOuterDeco(t), this.node = e, this.innerDeco = r, this.contentDOM && this.updateChildren(i, this.posAtStart), this.dirty = oe; 4981 } 4982 updateOuterDeco(e) { 4983 if (hn(e, this.outerDeco)) return; 4984 let t = this.nodeDOM.nodeType != 1, r = this.dom; 4985 this.dom = Vs(this.dom, this.nodeDOM, br(this.outerDeco, this.node, t), br(e, this.node, t)), this.dom != r && (r.pmViewDesc = void 0, this.dom.pmViewDesc = this), this.outerDeco = e; 4986 } 4987 selectNode() { 4988 this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.nodeDOM.draggable = !0)); 4989 } 4990 deselectNode() { 4991 this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.nodeDOM.removeAttribute("draggable")); 4992 } 4993 get domAtom() { 4994 return this.node.isAtom; 4995 } 4996 } 4997 function Bi(n, e, t, r, i) { 4998 $s(r, e, n); 4999 let o = new Ee(void 0, n, e, t, r, r, r); 5000 return o.contentDOM && o.updateChildren(i, 0), o; 5001 } 5002 class Bn extends Ee { 5003 constructor(e, t, r, i, o, s){ 5004 super(e, t, r, i, o, null, s); 5005 } 5006 parseRule() { 5007 let e = this.nodeDOM.parentNode; 5008 for(; e && e != this.dom && !e.pmIsDeco;)e = e.parentNode; 5009 return { 5010 skip: e || !0 5011 }; 5012 } 5013 update(e, t, r, i) { 5014 return this.dirty == le || this.dirty != oe && !this.inParent() || !e.sameMarkup(this.node) ? !1 : (this.updateOuterDeco(t), (this.dirty != oe || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = e.text, i.trackWrites == this.nodeDOM && (i.trackWrites = null)), this.node = e, this.dirty = oe, !0); 5015 } 5016 inParent() { 5017 let e = this.parent.contentDOM; 5018 for(let t = this.nodeDOM; t; t = t.parentNode)if (t == e) return !0; 5019 return !1; 5020 } 5021 domFromPos(e) { 5022 return { 5023 node: this.nodeDOM, 5024 offset: e 5025 }; 5026 } 5027 localPosFromDOM(e, t, r) { 5028 return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, r); 5029 } 5030 ignoreMutation(e) { 5031 return e.type != "characterData" && e.type != "selection"; 5032 } 5033 slice(e, t, r) { 5034 let i = this.node.cut(e, t), o = document.createTextNode(i.text); 5035 return new Bn(this.parent, i, this.outerDeco, this.innerDeco, o, o); 5036 } 5037 markDirty(e, t) { 5038 super.markDirty(e, t), this.dom != this.nodeDOM && (e == 0 || t == this.nodeDOM.nodeValue.length) && (this.dirty = le); 5039 } 5040 get domAtom() { 5041 return !1; 5042 } 5043 isText(e) { 5044 return this.node.text == e; 5045 } 5046 } 5047 class Fs extends $t { 5048 parseRule() { 5049 return { 5050 ignore: !0 5051 }; 5052 } 5053 matchesHack(e) { 5054 return this.dirty == oe && this.dom.nodeName == e; 5055 } 5056 get domAtom() { 5057 return !0; 5058 } 5059 get ignoreForCoords() { 5060 return this.dom.nodeName == "IMG"; 5061 } 5062 } 5063 class ef extends Ee { 5064 constructor(e, t, r, i, o, s, l, a){ 5065 super(e, t, r, i, o, s, l), this.spec = a; 5066 } 5067 update(e, t, r, i) { 5068 if (this.dirty == le) return !1; 5069 if (this.spec.update && (this.node.type == e.type || this.spec.multiType)) { 5070 let o = this.spec.update(e, t, r); 5071 return o && this.updateInner(e, t, r, i), o; 5072 } else return !this.contentDOM && !e.isLeaf ? !1 : super.update(e, t, r, i); 5073 } 5074 selectNode() { 5075 this.spec.selectNode ? this.spec.selectNode() : super.selectNode(); 5076 } 5077 deselectNode() { 5078 this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode(); 5079 } 5080 setSelection(e, t, r, i) { 5081 this.spec.setSelection ? this.spec.setSelection(e, t, r.root) : super.setSelection(e, t, r, i); 5082 } 5083 destroy() { 5084 this.spec.destroy && this.spec.destroy(), super.destroy(); 5085 } 5086 stopEvent(e) { 5087 return this.spec.stopEvent ? this.spec.stopEvent(e) : !1; 5088 } 5089 ignoreMutation(e) { 5090 return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e); 5091 } 5092 } 5093 function Ls(n, e, t) { 5094 let r = n.firstChild, i = !1; 5095 for(let o = 0; o < e.length; o++){ 5096 let s = e[o], l = s.dom; 5097 if (l.parentNode == n) { 5098 for(; l != r;)r = Pi(r), i = !0; 5099 r = r.nextSibling; 5100 } else i = !0, n.insertBefore(l, r); 5101 if (s instanceof Ne) { 5102 let a = r ? r.previousSibling : n.lastChild; 5103 Ls(s.contentDOM, s.children, t), r = a ? a.nextSibling : n.firstChild; 5104 } 5105 } 5106 for(; r;)r = Pi(r), i = !0; 5107 i && t.trackWrites == n && (t.trackWrites = null); 5108 } 5109 const Ct = function(n) { 5110 n && (this.nodeName = n); 5111 }; 5112 Ct.prototype = Object.create(null); 5113 const Le = [ 5114 new Ct 5115 ]; 5116 function br(n, e, t) { 5117 if (n.length == 0) return Le; 5118 let r = t ? Le[0] : new Ct, i = [ 5119 r 5120 ]; 5121 for(let o = 0; o < n.length; o++){ 5122 let s = n[o].type.attrs; 5123 if (s) { 5124 s.nodeName && i.push(r = new Ct(s.nodeName)); 5125 for(let l in s){ 5126 let a = s[l]; 5127 a != null && (t && i.length == 1 && i.push(r = new Ct(e.isInline ? "span" : "div")), l == "class" ? r.class = (r.class ? r.class + " " : "") + a : l == "style" ? r.style = (r.style ? r.style + ";" : "") + a : l != "nodeName" && (r[l] = a)); 5128 } 5129 } 5130 } 5131 return i; 5132 } 5133 function Vs(n, e, t, r) { 5134 if (t == Le && r == Le) return e; 5135 let i = e; 5136 for(let o = 0; o < r.length; o++){ 5137 let s = r[o], l = t[o]; 5138 if (o) { 5139 let a; 5140 l && l.nodeName == s.nodeName && i != n && (a = i.parentNode) && a.nodeName.toLowerCase() == s.nodeName || (a = document.createElement(s.nodeName), a.pmIsDeco = !0, a.appendChild(i), l = Le[0]), i = a; 5141 } 5142 tf(i, l || Le[0], s); 5143 } 5144 return i; 5145 } 5146 function tf(n, e, t) { 5147 for(let r in e)r != "class" && r != "style" && r != "nodeName" && !(r in t) && n.removeAttribute(r); 5148 for(let r in t)r != "class" && r != "style" && r != "nodeName" && t[r] != e[r] && n.setAttribute(r, t[r]); 5149 if (e.class != t.class) { 5150 let r = e.class ? e.class.split(" ").filter(Boolean) : [], i = t.class ? t.class.split(" ").filter(Boolean) : []; 5151 for(let o = 0; o < r.length; o++)i.indexOf(r[o]) == -1 && n.classList.remove(r[o]); 5152 for(let o = 0; o < i.length; o++)r.indexOf(i[o]) == -1 && n.classList.add(i[o]); 5153 n.classList.length == 0 && n.removeAttribute("class"); 5154 } 5155 if (e.style != t.style) { 5156 if (e.style) { 5157 let r = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, i; 5158 for(; i = r.exec(e.style);)n.style.removeProperty(i[1]); 5159 } 5160 t.style && (n.style.cssText += t.style); 5161 } 5162 } 5163 function $s(n, e, t) { 5164 return Vs(n, n, Le, br(e, t, n.nodeType != 1)); 5165 } 5166 function hn(n, e) { 5167 if (n.length != e.length) return !1; 5168 for(let t = 0; t < n.length; t++)if (!n[t].type.eq(e[t].type)) return !1; 5169 return !0; 5170 } 5171 function Pi(n) { 5172 let e = n.nextSibling; 5173 return n.parentNode.removeChild(n), e; 5174 } 5175 class nf { 5176 constructor(e, t, r){ 5177 this.lock = t, this.view = r, this.index = 0, this.stack = [], this.changed = !1, this.top = e, this.preMatch = rf(e.node.content, e); 5178 } 5179 destroyBetween(e, t) { 5180 if (e != t) { 5181 for(let r = e; r < t; r++)this.top.children[r].destroy(); 5182 this.top.children.splice(e, t - e), this.changed = !0; 5183 } 5184 } 5185 destroyRest() { 5186 this.destroyBetween(this.index, this.top.children.length); 5187 } 5188 syncToMarks(e, t, r, i) { 5189 let o = 0, s = this.stack.length >> 1, l = Math.min(s, e.length); 5190 for(; o < l && (o == s - 1 ? this.top : this.stack[o + 1 << 1]).matchesMark(e[o]) && e[o].type.spec.spanning !== !1;)o++; 5191 for(; o < s;)this.destroyRest(), this.top.dirty = oe, this.index = this.stack.pop(), this.top = this.stack.pop(), s--; 5192 for(; s < e.length;){ 5193 this.stack.push(this.top, this.index + 1); 5194 let a = -1, c = this.top.children.length; 5195 i < this.preMatch.index && (c = Math.min(this.index + 3, c)); 5196 for(let f = this.index; f < c; f++){ 5197 let u = this.top.children[f]; 5198 if (u.matchesMark(e[s]) && !this.isLocked(u.dom)) { 5199 a = f; 5200 break; 5201 } 5202 } 5203 if (a < 0 && this.index < this.top.children.length) { 5204 let f = this.top.children[this.index]; 5205 f instanceof Ne && f.dirty != le && f.mark.type == e[s].type && f.spec.update && !this.isLocked(f.dom) && f.spec.update(e[s]) && (f.mark = e[s], a = this.index, this.changed = !0); 5206 } 5207 if (a > -1) a > this.index && (this.changed = !0, this.destroyBetween(this.index, a)), this.top = this.top.children[this.index]; 5208 else { 5209 let f = Ne.create(this.top, e[s], t, r); 5210 this.top.children.splice(this.index, 0, f), this.top = f, this.changed = !0; 5211 } 5212 this.index = 0, s++; 5213 } 5214 } 5215 findNodeMatch(e, t, r, i) { 5216 let o = -1, s; 5217 if (i >= this.preMatch.index && (s = this.preMatch.matches[i - this.preMatch.index]).parent == this.top && s.matchesNode(e, t, r)) o = this.top.children.indexOf(s, this.index); 5218 else for(let l = this.index, a = Math.min(this.top.children.length, l + 5); l < a; l++){ 5219 let c = this.top.children[l]; 5220 if (c.matchesNode(e, t, r) && !this.preMatch.matched.has(c)) { 5221 o = l; 5222 break; 5223 } 5224 } 5225 return o < 0 ? !1 : (this.destroyBetween(this.index, o), this.index++, !0); 5226 } 5227 updateNodeAt(e, t, r, i, o) { 5228 let s = this.top.children[i]; 5229 return s.dirty == le && s.dom == s.contentDOM && (s.dirty = Fe), s.update(e, t, r, o) ? (this.destroyBetween(this.index, i), this.index++, !0) : !1; 5230 } 5231 findIndexWithChild(e) { 5232 for(;;){ 5233 let t = e.parentNode; 5234 if (!t) return -1; 5235 if (t == this.top.contentDOM) { 5236 let r = e.pmViewDesc; 5237 if (r) { 5238 for(let i = this.index; i < this.top.children.length; i++)if (this.top.children[i] == r) return i; 5239 } 5240 return -1; 5241 } 5242 e = t; 5243 } 5244 } 5245 updateNextNode(e, t, r, i, o, s) { 5246 for(let l = this.index; l < this.top.children.length; l++){ 5247 let a = this.top.children[l]; 5248 if (a instanceof Ee) { 5249 let c = this.preMatch.matched.get(a); 5250 if (c != null && c != o) return !1; 5251 let f = a.dom, u, d = this.isLocked(f) && !(e.isText && a.node && a.node.isText && a.nodeDOM.nodeValue == e.text && a.dirty != le && hn(t, a.outerDeco)); 5252 if (!d && a.update(e, t, r, i)) return this.destroyBetween(this.index, l), a.dom != f && (this.changed = !0), this.index++, !0; 5253 if (!d && (u = this.recreateWrapper(a, e, t, r, i, s))) return this.destroyBetween(this.index, l), this.top.children[this.index] = u, u.contentDOM && (u.dirty = Fe, u.updateChildren(i, s + 1), u.dirty = oe), this.changed = !0, this.index++, !0; 5254 break; 5255 } 5256 } 5257 return !1; 5258 } 5259 recreateWrapper(e, t, r, i, o, s) { 5260 if (e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !hn(r, e.outerDeco) || !i.eq(e.innerDeco)) return null; 5261 let l = Ee.create(this.top, t, r, i, o, s); 5262 if (l.contentDOM) { 5263 l.children = e.children, e.children = []; 5264 for (let a of l.children)a.parent = l; 5265 } 5266 return e.destroy(), l; 5267 } 5268 addNode(e, t, r, i, o) { 5269 let s = Ee.create(this.top, e, t, r, i, o); 5270 s.contentDOM && s.updateChildren(i, o + 1), this.top.children.splice(this.index++, 0, s), this.changed = !0; 5271 } 5272 placeWidget(e, t, r) { 5273 let i = this.index < this.top.children.length ? this.top.children[this.index] : null; 5274 if (i && i.matchesWidget(e) && (e == i.widget || !i.widget.type.toDOM.parentNode)) this.index++; 5275 else { 5276 let o = new zs(this.top, e, t, r); 5277 this.top.children.splice(this.index++, 0, o), this.changed = !0; 5278 } 5279 } 5280 addTextblockHacks() { 5281 let e = this.top.children[this.index - 1], t = this.top; 5282 for(; e instanceof Ne;)t = e, e = t.children[t.children.length - 1]; 5283 (!e || !(e instanceof Bn) || /\n$/.test(e.node.text) || this.view.requiresGeckoHackNode && /\s$/.test(e.node.text)) && ((K || J) && e && e.dom.contentEditable == "false" && this.addHackNode("IMG", t), this.addHackNode("BR", this.top)); 5284 } 5285 addHackNode(e, t) { 5286 if (t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e)) this.index++; 5287 else { 5288 let r = document.createElement(e); 5289 e == "IMG" && (r.className = "ProseMirror-separator", r.alt = ""), e == "BR" && (r.className = "ProseMirror-trailingBreak"); 5290 let i = new Fs(this.top, [], r, null); 5291 t != this.top ? t.children.push(i) : t.children.splice(this.index++, 0, i), this.changed = !0; 5292 } 5293 } 5294 isLocked(e) { 5295 return this.lock && (e == this.lock || e.nodeType == 1 && e.contains(this.lock.parentNode)); 5296 } 5297 } 5298 function rf(n, e) { 5299 let t = e, r = t.children.length, i = n.childCount, o = new Map, s = []; 5300 e: for(; i > 0;){ 5301 let l; 5302 for(;;)if (r) { 5303 let c = t.children[r - 1]; 5304 if (c instanceof Ne) t = c, r = c.children.length; 5305 else { 5306 l = c, r--; 5307 break; 5308 } 5309 } else { 5310 if (t == e) break e; 5311 r = t.parent.children.indexOf(t), t = t.parent; 5312 } 5313 let a = l.node; 5314 if (a) { 5315 if (a != n.child(i - 1)) break; 5316 --i, o.set(l, i), s.push(l); 5317 } 5318 } 5319 return { 5320 index: i, 5321 matched: o, 5322 matches: s.reverse() 5323 }; 5324 } 5325 function of(n, e) { 5326 return n.type.side - e.type.side; 5327 } 5328 function sf(n, e, t, r) { 5329 let i = e.locals(n), o = 0; 5330 if (i.length == 0) { 5331 for(let c = 0; c < n.childCount; c++){ 5332 let f = n.child(c); 5333 r(f, i, e.forChild(o, f), c), o += f.nodeSize; 5334 } 5335 return; 5336 } 5337 let s = 0, l = [], a = null; 5338 for(let c = 0;;){ 5339 let f, u; 5340 for(; s < i.length && i[s].to == o;){ 5341 let g = i[s++]; 5342 g.widget && (f ? (u || (u = [ 5343 f 5344 ])).push(g) : f = g); 5345 } 5346 if (f) if (u) { 5347 u.sort(of); 5348 for(let g = 0; g < u.length; g++)t(u[g], c, !!a); 5349 } else t(f, c, !!a); 5350 let d, h; 5351 if (a) h = -1, d = a, a = null; 5352 else if (c < n.childCount) h = c, d = n.child(c++); 5353 else break; 5354 for(let g = 0; g < l.length; g++)l[g].to <= o && l.splice(g--, 1); 5355 for(; s < i.length && i[s].from <= o && i[s].to > o;)l.push(i[s++]); 5356 let p = o + d.nodeSize; 5357 if (d.isText) { 5358 let g = p; 5359 s < i.length && i[s].from < g && (g = i[s].from); 5360 for(let y = 0; y < l.length; y++)l[y].to < g && (g = l[y].to); 5361 g < p && (a = d.cut(g - o), d = d.cut(0, g - o), p = g, h = -1); 5362 } else for(; s < i.length && i[s].to < p;)s++; 5363 let m = d.isInline && !d.isLeaf ? l.filter((g)=>!g.inline) : l.slice(); 5364 r(d, m, e.forChild(o, d), h), o = p; 5365 } 5366 } 5367 function lf(n) { 5368 if (n.nodeName == "UL" || n.nodeName == "OL") { 5369 let e = n.style.cssText; 5370 n.style.cssText = e + "; list-style: square !important", window.getComputedStyle(n).listStyle, n.style.cssText = e; 5371 } 5372 } 5373 function af(n, e, t, r) { 5374 for(let i = 0, o = 0; i < n.childCount && o <= r;){ 5375 let s = n.child(i++), l = o; 5376 if (o += s.nodeSize, !s.isText) continue; 5377 let a = s.text; 5378 for(; i < n.childCount;){ 5379 let c = n.child(i++); 5380 if (o += c.nodeSize, !c.isText) break; 5381 a += c.text; 5382 } 5383 if (o >= t) { 5384 if (o >= r && a.slice(r - e.length - l, r - l) == e) return r - e.length; 5385 let c = l < r ? a.lastIndexOf(e, r - l - 1) : -1; 5386 if (c >= 0 && c + e.length + l >= t) return l + c; 5387 if (t == r && a.length >= r + e.length - l && a.slice(r - l, r - l + e.length) == e) return r; 5388 } 5389 } 5390 return -1; 5391 } 5392 function xr(n, e, t, r, i) { 5393 let o = []; 5394 for(let s = 0, l = 0; s < n.length; s++){ 5395 let a = n[s], c = l, f = l += a.size; 5396 c >= t || f <= e ? o.push(a) : (c < e && o.push(a.slice(0, e - c, r)), i && (o.push(i), i = void 0), f > t && o.push(a.slice(t - c, a.size, r))); 5397 } 5398 return o; 5399 } 5400 function Vr(n, e = null) { 5401 let t = n.domSelectionRange(), r = n.state.doc; 5402 if (!t.focusNode) return null; 5403 let i = n.docView.nearestDesc(t.focusNode), o = i && i.size == 0, s = n.docView.posFromDOM(t.focusNode, t.focusOffset, 1); 5404 if (s < 0) return null; 5405 let l = r.resolve(s), a, c; 5406 if (Rn(t)) { 5407 for(a = s; i && !i.node;)i = i.parent; 5408 let u = i.node; 5409 if (i && u.isAtom && T.isSelectable(u) && i.parent && !(u.isInline && Bc(t.focusNode, t.focusOffset, i.dom))) { 5410 let d = i.posBefore; 5411 c = new T(s == d ? l : r.resolve(d)); 5412 } 5413 } else { 5414 if (t instanceof n.dom.ownerDocument.defaultView.Selection && t.rangeCount > 1) { 5415 let u = s, d = s; 5416 for(let h = 0; h < t.rangeCount; h++){ 5417 let p = t.getRangeAt(h); 5418 u = Math.min(u, n.docView.posFromDOM(p.startContainer, p.startOffset, 1)), d = Math.max(d, n.docView.posFromDOM(p.endContainer, p.endOffset, -1)); 5419 } 5420 if (u < 0) return null; 5421 [a, s] = d == n.state.selection.anchor ? [ 5422 d, 5423 u 5424 ] : [ 5425 u, 5426 d 5427 ], l = r.resolve(s); 5428 } else a = n.docView.posFromDOM(t.anchorNode, t.anchorOffset, 1); 5429 if (a < 0) return null; 5430 } 5431 let f = r.resolve(a); 5432 if (!c) { 5433 let u = e == "pointer" || n.state.selection.head < l.pos && !o ? 1 : -1; 5434 c = $r(n, f, l, u); 5435 } 5436 return c; 5437 } 5438 function js(n) { 5439 return n.editable ? n.hasFocus() : Js(n) && document.activeElement && document.activeElement.contains(n.dom); 5440 } 5441 function xe(n, e = !1) { 5442 let t = n.state.selection; 5443 if (Ws(n, t), !js(n)) return; 5444 let r = n.input.mouseDown; 5445 if (!e && J && r) { 5446 let i = n.domSelectionRange(), o = n.domObserver.currentSelection; 5447 if (i.anchorNode && o.anchorNode && Ye(i.anchorNode, i.anchorOffset, o.anchorNode, o.anchorOffset) && r.delaySelUpdate()) { 5448 n.domObserver.setCurSelection(); 5449 return; 5450 } 5451 } 5452 if (n.domObserver.disconnectSelection(), n.cursorWrapper) ff(n); 5453 else { 5454 let { anchor: i, head: o } = t, s, l; 5455 zi && !(t instanceof v) && (t.$from.parent.inlineContent || (s = Fi(n, t.from)), !t.empty && !t.$from.parent.inlineContent && (l = Fi(n, t.to))), n.docView.setSelection(i, o, n, e), zi && (s && Li(s), l && Li(l)), t.visible ? n.dom.classList.remove("ProseMirror-hideselection") : (n.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && cf(n)); 5456 } 5457 n.domObserver.setCurSelection(), n.domObserver.connectSelection(); 5458 } 5459 const zi = K || J && Ns < 63; 5460 function Fi(n, e) { 5461 let { node: t, offset: r } = n.docView.domFromPos(e, 0), i = r < t.childNodes.length ? t.childNodes[r] : null, o = r ? t.childNodes[r - 1] : null; 5462 if (K && i && i.contentEditable == "false") return Yn(i); 5463 if ((!i || i.contentEditable == "false") && (!o || o.contentEditable == "false")) { 5464 if (i) return Yn(i); 5465 if (o) return Yn(o); 5466 } 5467 } 5468 function Yn(n) { 5469 return n.contentEditable = "true", K && n.draggable && (n.draggable = !1, n.wasDraggable = !0), n; 5470 } 5471 function Li(n) { 5472 n.contentEditable = "false", n.wasDraggable && (n.draggable = !0, n.wasDraggable = null); 5473 } 5474 function cf(n) { 5475 let e = n.dom.ownerDocument; 5476 e.removeEventListener("selectionchange", n.input.hideSelectionGuard); 5477 let t = n.domSelectionRange(), r = t.anchorNode, i = t.anchorOffset; 5478 e.addEventListener("selectionchange", n.input.hideSelectionGuard = ()=>{ 5479 (t.anchorNode != r || t.anchorOffset != i) && (e.removeEventListener("selectionchange", n.input.hideSelectionGuard), setTimeout(()=>{ 5480 (!js(n) || n.state.selection.visible) && n.dom.classList.remove("ProseMirror-hideselection"); 5481 }, 20)); 5482 }); 5483 } 5484 function ff(n) { 5485 let e = n.domSelection(); 5486 if (!e) return; 5487 let t = n.cursorWrapper.dom, r = t.nodeName == "IMG"; 5488 r ? e.collapse(t.parentNode, j(t) + 1) : e.collapse(t, 0), !r && !n.state.selection.visible && G && Oe <= 11 && (t.disabled = !0, t.disabled = !1); 5489 } 5490 function Ws(n, e) { 5491 if (e instanceof T) { 5492 let t = n.docView.descAt(e.from); 5493 t != n.lastSelectedViewDesc && (Vi(n), t && t.selectNode(), n.lastSelectedViewDesc = t); 5494 } else Vi(n); 5495 } 5496 function Vi(n) { 5497 n.lastSelectedViewDesc && (n.lastSelectedViewDesc.parent && n.lastSelectedViewDesc.deselectNode(), n.lastSelectedViewDesc = void 0); 5498 } 5499 function $r(n, e, t, r) { 5500 return n.someProp("createSelectionBetween", (i)=>i(n, e, t)) || v.between(e, t, r); 5501 } 5502 function $i(n) { 5503 return n.editable && !n.hasFocus() ? !1 : Js(n); 5504 } 5505 function Js(n) { 5506 let e = n.domSelectionRange(); 5507 if (!e.anchorNode) return !1; 5508 try { 5509 return n.dom.contains(e.anchorNode.nodeType == 3 ? e.anchorNode.parentNode : e.anchorNode) && (n.editable || n.dom.contains(e.focusNode.nodeType == 3 ? e.focusNode.parentNode : e.focusNode)); 5510 } catch { 5511 return !1; 5512 } 5513 } 5514 function uf(n) { 5515 let e = n.docView.domFromPos(n.state.selection.anchor, 0), t = n.domSelectionRange(); 5516 return Ye(e.node, e.offset, t.anchorNode, t.anchorOffset); 5517 } 5518 function Sr(n, e) { 5519 let { $anchor: t, $head: r } = n.selection, i = e > 0 ? t.max(r) : t.min(r), o = i.parent.inlineContent ? i.depth ? n.doc.resolve(e > 0 ? i.after() : i.before()) : null : i; 5520 return o && D.findFrom(o, e); 5521 } 5522 function Me(n, e) { 5523 return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()), !0; 5524 } 5525 function ji(n, e, t) { 5526 let r = n.state.selection; 5527 if (r instanceof v) if (t.indexOf("s") > -1) { 5528 let { $head: i } = r, o = i.textOffset ? null : e < 0 ? i.nodeBefore : i.nodeAfter; 5529 if (!o || o.isText || !o.isLeaf) return !1; 5530 let s = n.state.doc.resolve(i.pos + o.nodeSize * (e < 0 ? -1 : 1)); 5531 return Me(n, new v(r.$anchor, s)); 5532 } else if (r.empty) { 5533 if (n.endOfTextblock(e > 0 ? "forward" : "backward")) { 5534 let i = Sr(n.state, e); 5535 return i && i instanceof T ? Me(n, i) : !1; 5536 } else if (!(te && t.indexOf("m") > -1)) { 5537 let i = r.$head, o = i.textOffset ? null : e < 0 ? i.nodeBefore : i.nodeAfter, s; 5538 if (!o || o.isText) return !1; 5539 let l = e < 0 ? i.pos - o.nodeSize : i.pos; 5540 return o.isAtom || (s = n.docView.descAt(l)) && !s.contentDOM ? T.isSelectable(
5540o) ? Me(n, new T(e < 0 ? n.state.doc.resolve(i.pos - o.nodeSize) : i)) : Vt ? Me(n, new v(n.state.doc.resolve(e < 0 ? l : l + o.nodeSize))) : !1 : !1; 5541 } 5542 } else return !1; 5543 else { 5544 if (r instanceof T && r.node.isInline) return Me(n, new v(e > 0 ? r.$to : r.$from)); 5545 { 5546 let i = Sr(n.state, e); 5547 return i ? Me(n, i) : !1; 5548 } 5549 } 5550 } 5551 function pn(n) { 5552 return n.nodeType == 3 ? n.nodeValue.length : n.childNodes.length; 5553 } 5554 function Tt(n, e) { 5555 let t = n.pmViewDesc; 5556 return t && t.size == 0 && (e < 0 || n.nextSibling || n.nodeName != "BR"); 5557 } 5558 function Ze(n, e) { 5559 return e < 0 ? df(n) : hf(n); 5560 } 5561 function df(n) { 5562 let e = n.domSelectionRange(), t = e.focusNode, r = e.focusOffset; 5563 if (!t) return; 5564 let i, o, s = !1; 5565 for(ie && t.nodeType == 1 && r < pn(t) && Tt(t.childNodes[r], -1) && (s = !0);;)if (r > 0) { 5566 if (t.nodeType != 1) break; 5567 { 5568 let l = t.childNodes[r - 1]; 5569 if (Tt(l, -1)) i = t, o = --r; 5570 else if (l.nodeType == 3) t = l, r = t.nodeValue.length; 5571 else break; 5572 } 5573 } else { 5574 if (qs(t)) break; 5575 { 5576 let l = t.previousSibling; 5577 for(; l && Tt(l, -1);)i = t.parentNode, o = j(l), l = l.previousSibling; 5578 if (l) t = l, r = pn(t); 5579 else { 5580 if (t = t.parentNode, t == n.dom) break; 5581 r = 0; 5582 } 5583 } 5584 } 5585 s ? wr(n, t, r) : i && wr(n, i, o); 5586 } 5587 function hf(n) { 5588 let e = n.domSelectionRange(), t = e.focusNode, r = e.focusOffset; 5589 if (!t) return; 5590 let i = pn(t), o, s; 5591 for(;;)if (r < i) { 5592 if (t.nodeType != 1) break; 5593 let l = t.childNodes[r]; 5594 if (Tt(l, 1)) o = t, s = ++r; 5595 else break; 5596 } else { 5597 if (qs(t)) break; 5598 { 5599 let l = t.nextSibling; 5600 for(; l && Tt(l, 1);)o = l.parentNode, s = j(l) + 1, l = l.nextSibling; 5601 if (l) t = l, r = 0, i = pn(t); 5602 else { 5603 if (t = t.parentNode, t == n.dom) break; 5604 r = i = 0; 5605 } 5606 } 5607 } 5608 o && wr(n, o, s); 5609 } 5610 function qs(n) { 5611 let e = n.pmViewDesc; 5612 return e && e.node && e.node.isBlock; 5613 } 5614 function pf(n, e) { 5615 for(; n && e == n.childNodes.length && !Lt(n);)e = j(n) + 1, n = n.parentNode; 5616 for(; n && e < n.childNodes.length;){ 5617 let t = n.childNodes[e]; 5618 if (t.nodeType == 3) return t; 5619 if (t.nodeType == 1 && t.contentEditable == "false") break; 5620 n = t, e = 0; 5621 } 5622 } 5623 function mf(n, e) { 5624 for(; n && !e && !Lt(n);)e = j(n), n = n.parentNode; 5625 for(; n && e;){ 5626 let t = n.childNodes[e - 1]; 5627 if (t.nodeType == 3) return t; 5628 if (t.nodeType == 1 && t.contentEditable == "false") break; 5629 n = t, e = n.childNodes.length; 5630 } 5631 } 5632 function wr(n, e, t) { 5633 if (e.nodeType != 3) { 5634 let o, s; 5635 (s = pf(e, t)) ? (e = s, t = 0) : (o = mf(e, t)) && (e = o, t = o.nodeValue.length); 5636 } 5637 let r = n.domSelection(); 5638 if (!r) return; 5639 if (Rn(r)) { 5640 let o = document.createRange(); 5641 o.setEnd(e, t), o.setStart(e, t), r.removeAllRanges(), r.addRange(o); 5642 } else r.extend && r.extend(e, t); 5643 n.domObserver.setCurSelection(); 5644 let { state: i } = n; 5645 setTimeout(()=>{ 5646 n.state == i && xe(n); 5647 }, 50); 5648 } 5649 function Wi(n, e) { 5650 let t = n.state.doc.resolve(e); 5651 if (!(J || Es) && t.parent.inlineContent) { 5652 let i = n.coordsAtPos(e); 5653 if (e > t.start()) { 5654 let o = n.coordsAtPos(e - 1), s = (o.top + o.bottom) / 2; 5655 if (s > i.top && s < i.bottom && Math.abs(o.left - i.left) > 1) return o.left < i.left ? "ltr" : "rtl";
vendor: 10,072 bytes, lines 5656-5896
5656 } 5657 if (e < t.end()) { 5658 let o = n.coordsAtPos(e + 1), s = (o.top + o.bottom) / 2; 5659 if (s > i.top && s < i.bottom && Math.abs(o.left - i.left) > 1) return o.left > i.left ? "ltr" : "rtl"; 5660 } 5661 } 5662 return getComputedStyle(n.dom).direction == "rtl" ? "rtl" : "ltr"; 5663 } 5664 function Ji(n, e, t) { 5665 let r = n.state.selection; 5666 if (r instanceof v && !r.empty || t.indexOf("s") > -1 || te && t.indexOf("m") > -1) return !1; 5667 let { $from: i, $to: o } = r; 5668 if (!i.parent.inlineContent || n.endOfTextblock(e < 0 ? "up" : "down")) { 5669 let s = Sr(n.state, e); 5670 if (s && s instanceof T) return Me(n, s); 5671 } 5672 if (!i.parent.inlineContent) { 5673 let s = e < 0 ? i : o, l = r instanceof ee ? D.near(s, e) : D.findFrom(s, e); 5674 return l ? Me(n, l) : !1; 5675 } 5676 return !1; 5677 } 5678 function qi(n, e) { 5679 if (!(n.state.selection instanceof v)) return !0; 5680 let { $head: t, $anchor: r, empty: i } = n.state.selection; 5681 if (!t.sameParent(r)) return !0; 5682 if (!i) return !1; 5683 if (n.endOfTextblock(e > 0 ? "forward" : "backward")) return !0; 5684 let o = !t.textOffset && (e < 0 ? t.nodeBefore : t.nodeAfter); 5685 if (o && !o.isText) { 5686 let s = n.state.tr; 5687 return e < 0 ? s.delete(t.pos - o.nodeSize, t.pos) : s.delete(t.pos, t.pos + o.nodeSize), n.dispatch(s), !0; 5688 } 5689 return !1; 5690 } 5691 function Ki(n, e, t) { 5692 n.domObserver.stop(), e.contentEditable = t, n.domObserver.start(); 5693 } 5694 function gf(n) { 5695 if (!K || n.state.selection.$head.parentOffset > 0) return !1; 5696 let { focusNode: e, focusOffset: t } = n.domSelectionRange(); 5697 if (e && e.nodeType == 1 && t == 0 && e.firstChild && e.firstChild.contentEditable == "false") { 5698 let r = e.firstChild; 5699 Ki(n, r, "true"), setTimeout(()=>Ki(n, r, "false"), 20); 5700 } 5701 return !1; 5702 } 5703 function yf(n) { 5704 let e = ""; 5705 return n.ctrlKey && (e += "c"), n.metaKey && (e += "m"), n.altKey && (e += "a"), n.shiftKey && (e += "s"), e; 5706 } 5707 function kf(n, e) { 5708 let t = e.keyCode, r = yf(e); 5709 if (t == 8 || te && t == 72 && r == "c") return qi(n, -1) || Ze(n, -1); 5710 if (t == 46 && !e.shiftKey || te && t == 68 && r == "c") return qi(n, 1) || Ze(n, 1); 5711 if (t == 13 || t == 27) return !0; 5712 if (t == 37 || te && t == 66 && r == "c") { 5713 let i = t == 37 ? Wi(n, n.state.selection.from) == "ltr" ? -1 : 1 : -1; 5714 return ji(n, i, r) || Ze(n, i); 5715 } else if (t == 39 || te && t == 70 && r == "c") { 5716 let i = t == 39 ? Wi(n, n.state.selection.from) == "ltr" ? 1 : -1 : 1; 5717 return ji(n, i, r) || Ze(n, i); 5718 } else { 5719 if (t == 38 || te && t == 80 && r == "c") return Ji(n, -1, r) || Ze(n, -1); 5720 if (t == 40 || te && t == 78 && r == "c") return gf(n) || Ji(n, 1, r) || Ze(n, 1); 5721 if (r == (te ? "m" : "c") && (t == 66 || t == 73 || t == 89 || t == 90)) return !0; 5722 } 5723 return !1; 5724 } 5725 function jr(n, e) { 5726 n.someProp("transformCopied", (h)=>{ 5727 e = h(e, n); 5728 }); 5729 let t = [], { content: r, openStart: i, openEnd: o } = e; 5730 for(; i > 1 && o > 1 && r.childCount == 1 && r.firstChild.childCount == 1;){ 5731 i--, o--; 5732 let h = r.firstChild; 5733 t.push(h.type.name, h.attrs != h.type.defaultAttrs ? h.attrs : null), r = h.content; 5734 } 5735 let s = n.someProp("clipboardSerializer") || Ge.fromSchema(n.state.schema), l = Gs(), a = l.createElement("div"); 5736 a.appendChild(s.serializeFragment(r, { 5737 document: l 5738 })); 5739 let c = a.firstChild, f, u = 0; 5740 for(; c && c.nodeType == 1 && (f = Ys[c.nodeName.toLowerCase()]);){ 5741 for(let h = f.length - 1; h >= 0; h--){ 5742 let p = l.createElement(f[h]); 5743 for(; a.firstChild;)p.appendChild(a.firstChild); 5744 a.appendChild(p), u++; 5745 } 5746 c = a.firstChild; 5747 } 5748 c && c.nodeType == 1 && c.setAttribute("data-pm-slice", `${i} ${o}${u ? ` -${u}` : ""} ${JSON.stringify(t)}`); 5749 let d = n.someProp("clipboardTextSerializer", (h)=>h(e, n)) || e.content.textBetween(0, e.content.size, ` 5750 5751`); 5752 return { 5753 dom: a, 5754 text: d, 5755 slice: e 5756 }; 5757 } 5758 function Ks(n, e, t, r, i) { 5759 let o = i.parent.type.spec.code, s, l; 5760 if (!t && !e) return null; 5761 let a = !!e && (r || o || !t); 5762 if (a) { 5763 if (n.someProp("transformPastedText", (d)=>{ 5764 e = d(e, o || r, n); 5765 }), o) return l = new b(k.from(n.state.schema.text(e.replace(/\r\n?/g, ` 5766`))), 0, 0), n.someProp("transformPasted", (d)=>{ 5767 l = d(l, n, !0); 5768 }), l; 5769 let u = n.someProp("clipboardTextParser", (d)=>d(e, i, r, n)); 5770 if (u) l = u; 5771 else { 5772 let d = i.marks(), { schema: h } = n.state, p = Ge.fromSchema(h); 5773 s = document.createElement("div"), e.split(/(?:\r\n?|\n)+/).forEach((m)=>{ 5774 let g = s.appendChild(document.createElement("p")); 5775 m && g.appendChild(p.serializeNode(h.text(m, d))); 5776 }); 5777 } 5778 } else n.someProp("transformPastedHTML", (u)=>{ 5779 t = u(t, n); 5780 }), s = wf(t), Vt && Mf(s); 5781 let c = s && s.querySelector("[data-pm-slice]"), f = c && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice") || ""); 5782 if (f && f[3]) for(let u = +f[3]; u > 0; u--){ 5783 let d = s.firstChild; 5784 for(; d && d.nodeType != 1;)d = d.nextSibling; 5785 if (!d) break; 5786 s = d; 5787 } 5788 if (l || (l = (n.someProp("clipboardParser") || n.someProp("domParser") || wt.fromSchema(n.state.schema)).parseSlice(s, { 5789 preserveWhitespace: !!(a || f), 5790 context: i, 5791 ruleFromNode (d) { 5792 return d.nodeName == "BR" && !d.nextSibling && d.parentNode && !bf.test(d.parentNode.nodeName) ? { 5793 ignore: !0 5794 } : null; 5795 } 5796 })), f) l = Cf(Hi(l, +f[1], +f[2]), f[4]); 5797 else if (l = b.maxOpen(xf(l.content, i), !0), l.openStart || l.openEnd) { 5798 let u = 0, d = 0; 5799 for(let h = l.content.firstChild; u < l.openStart && !h.type.spec.isolating; u++, h = h.firstChild); 5800 for(let h = l.content.lastChild; d < l.openEnd && !h.type.spec.isolating; d++, h = h.lastChild); 5801 l = Hi(l, u, d); 5802 } 5803 return n.someProp("transformPasted", (u)=>{ 5804 l = u(l, n, a); 5805 }), l; 5806 } 5807 const bf = /^(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; 5808 function xf(n, e) { 5809 if (n.childCount < 2) return n; 5810 for(let t = e.depth; t >= 0; t--){ 5811 let i = e.node(t).contentMatchAt(e.index(t)), o, s = []; 5812 if (n.forEach((l)=>{ 5813 if (!s) return; 5814 let a = i.findWrapping(l.type), c; 5815 if (!a) return s = null; 5816 if (c = s.length && o.length && _s(a, o, l, s[s.length - 1], 0)) s[s.length - 1] = c; 5817 else { 5818 s.length && (s[s.length - 1] = Us(s[s.length - 1], o.length)); 5819 let f = Hs(l, a); 5820 s.push(f), i = i.matchType(f.type), o = a; 5821 } 5822 }), s) return k.from(s); 5823 } 5824 return n; 5825 } 5826 function Hs(n, e, t = 0) { 5827 for(let r = e.length - 1; r >= t; r--)n = e[r].create(null, k.from(n)); 5828 return n; 5829 } 5830 function _s(n, e, t, r, i) { 5831 if (i < n.length && i < e.length && n[i] == e[i]) { 5832 let o = _s(n, e, t, r.lastChild, i + 1); 5833 if (o) return r.copy(r.content.replaceChild(r.childCount - 1, o)); 5834 if (r.contentMatchAt(r.childCount).matchType(i == n.length - 1 ? t.type : n[i + 1])) return r.copy(r.content.append(k.from(Hs(t, n, i + 1)))); 5835 } 5836 } 5837 function Us(n, e) { 5838 if (e == 0) return n; 5839 let t = n.content.replaceChild(n.childCount - 1, Us(n.lastChild, e - 1)), r = n.contentMatchAt(n.childCount).fillBefore(k.empty, !0); 5840 return n.copy(t.append(r)); 5841 } 5842 function Mr(n, e, t, r, i, o) { 5843 let s = e < 0 ? n.firstChild : n.lastChild, l = s.content; 5844 return n.childCount > 1 && (o = 0), i < r - 1 && (l = Mr(l, e, t, r, i + 1, o)), i >= t && (l = e < 0 ? s.contentMatchAt(0).fillBefore(l, o <= i).append(l) : l.append(s.contentMatchAt(s.childCount).fillBefore(k.empty, !0))), n.replaceChild(e < 0 ? 0 : n.childCount - 1, s.copy(l)); 5845 } 5846 function Hi(n, e, t) { 5847 return e < n.openStart && (n = new b(Mr(n.content, -1, e, n.openStart, 0, n.openEnd), e, n.openEnd)), t < n.openEnd && (n = new b(Mr(n.content, 1, t, n.openEnd, 0, 0), n.openStart, t)), n; 5848 } 5849 const Ys = { 5850 thead: [ 5851 "table" 5852 ], 5853 tbody: [ 5854 "table" 5855 ], 5856 tfoot: [ 5857 "table" 5858 ], 5859 caption: [ 5860 "table" 5861 ], 5862 colgroup: [ 5863 "table" 5864 ], 5865 col: [ 5866 "table", 5867 "colgroup" 5868 ], 5869 tr: [ 5870 "table", 5871 "tbody" 5872 ], 5873 td: [ 5874 "table", 5875 "tbody", 5876 "tr" 5877 ], 5878 th: [ 5879 "table", 5880 "tbody", 5881 "tr" 5882 ] 5883 }; 5884 function Gs() { 5885 return document.implementation.createHTMLDocument("title"); 5886 } 5887 let mt = null; 5888 function Sf(n) { 5889 let e = window.trustedTypes; 5890 if (!e) return n; 5891 if (!mt) { 5892 if (mt = e.defaultPolicy) try { 5893 return mt.createHTML(n); 5894 } catch {} 5895 mt = e.createPolicy("ProseMirrorClipboard", { 5896 createHTML: (t)=>t
5897 }); 5898 } 5899 return mt.createHTML(n); 5900 } 5901 function wf(n) { 5902 let e = /^(\s*<meta [^>]*>)*/.exec(n); 5903 e && (n = n.slice(e[0].length)); 5904 let t = Gs(), r = t.body, i = /<([a-z][^>\s]+)/i.exec(n), o; 5905 if ((o = i && Ys[i[1].toLowerCase()]) && (n = o.map((s)=>"<" + s + ">").join("") + n + o.map((s)=>"</" + s + ">").reverse().join("")), r.innerHTML = Sf(n), o) for(let s = 0; s < o.length; s++)r = r.querySelector(o[s]) || r; 5906 for(let s = 0; s < t.styleSheets.length; s++){ 5907 let l = t.styleSheets[s]; 5908 for(let a = 0; a < l.rules.length; a++){ 5909 let c = l.rules[a]; 5910 if (c instanceof CSSStyleRule) { 5911 let f = r.querySelectorAll(c.selectorText); 5912 for(let u = 0; u < f.length; u++)f[u].style.cssText += c.style.cssText; 5913 } 5914 } 5915 } 5916 return r; 5917 } 5918 function Mf(n) { 5919 let e = n.querySelectorAll(J ? "span:not([class]):not([style])" : "span.Apple-converted-space"); 5920 for(let t = 0; t < e.length; t++){ 5921 let r = e[t]; 5922 r.childNodes.length == 1 && r.textContent == "Â " && r.parentNode && r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "), r); 5923 } 5924 } 5925 function Cf(n, e) { 5926 if (!n.size) return n; 5927 let t = n.content.firstChild.type.schema, r; 5928 try { 5929 r = JSON.parse(e); 5930 } catch { 5931 return n; 5932 } 5933 let { content: i, openStart: o, openEnd: s } = n; 5934 for(let l = r.length - 2; l >= 0; l -= 2){ 5935 let a = t.nodes[r[l]]; 5936 if (!a || a.hasRequiredAttrs()) break; 5937 try { 5938 a.checkAttrs(r[l + 1]); 5939 } catch { 5940 break; 5941 } 5942 i = k.from(a.create(r[l + 1], i)), o++, s++; 5943 } 5944 return new b(i, o, s); 5945 } 5946 const U = {}, Y = {}, Tf = { 5947 touchstart: !0, 5948 touchmove: !0 5949 }; 5950 class vf { 5951 constructor(){ 5952 this.shiftKey = !1, this.mouseDown = null, this.lastKeyCode = null, this.lastKeyCodeTime = 0, this.lastClick = { 5953 time: 0, 5954 x: 0, 5955 y: 0, 5956 type: "", 5957 button: 0 5958 }, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastIOSEnter = 0, this.lastIOSEnterFallbackTimeout = -1, this.lastFocus = 0, this.lastTouch = 0, this.lastChromeDelete = 0, this.composing = !1, this.compositionNode = null, this.composingTimeout = -1, this.compositionNodes = [], this.compositionEndedAt = -2e8, this.compositionID = 1, this.badSafariComposition = !1, this.compositionPendingChanges = 0, this.domChangeCount = 0, this.eventHandlers = Object.create(null), this.hideSelectionGuard = null; 5959 } 5960 } 5961 function Of(n) { 5962 for(let e in U){ 5963 let t = U[e]; 5964 n.dom.addEventListener(e, n.input.eventHandlers[e] = (r)=>{ 5965 Ef(n, r) && !Wr(n, r) && (n.editable || !(r.type in Y)) && t(n, r); 5966 }, Tf[e] ? { 5967 passive: !0 5968 } : void 0); 5969 } 5970 K && n.dom.addEventListener("input", ()=>null), Cr(n); 5971 } 5972 function ye(n, e) { 5973 n.input.lastSelectionOrigin = e, n.input.lastSelectionTime = Date.now(); 5974 } 5975 function Nf(n) { 5976 n.input.mouseDown && n.input.mouseDown.done(), n.domObserver.stop(); 5977 for(let e in n.input.eventHandlers)n.dom.removeEventListener(e, n.input.eventHandlers[e]); 5978 clearTimeout(n.input.composingTimeout), clearTimeout(n.input.lastIOSEnterFallbackTimeout); 5979 } 5980 function Cr(n) { 5981 n.someProp("handleDOMEvents", (e)=>{ 5982 for(let t in e)n.input.eventHandlers[t] || n.dom.addEventListener(t, n.input.eventHandlers[t] = (r)=>Wr(n, r)); 5983 }); 5984 } 5985 function Wr(n, e) { 5986 return n.someProp("handleDOMEvents", (t)=>{ 5987 let r = t[e.type]; 5988 return r ? r(n, e) || e.defaultPrevented : !1; 5989 }); 5990 } 5991 function Ef(n, e) { 5992 if (!e.bubbles) return !0; 5993 if (e.defaultPrevented) return !1; 5994 for(let t = e.target; t != n.dom; t = t.parentNode)if (!t || t.nodeType == 11 || t.pmViewDesc && t.pmViewDesc.stopEvent(e)) return !1; 5995 return !0; 5996 } 5997 function Df(n, e) { 5998 !Wr(n, e) && U[e.type] && (n.editable || !(e.type in Y)) && U[e.type](n, e); 5999 } 6000 Y.keydown = (n, e)=>{ 6001 let t = e; 6002 if (n.input.shiftKey = t.keyCode == 16 || t.shiftKey, !el(n) && (n.input.lastKeyCode = t.keyCode, n.input.lastKeyCodeTime = Date.now(), !(ge && J && t.keyCode == 13))) if (t.keyCode != 229 && n.domObserver.forceFlush(), ft && t.keyCode == 13 && !t.ctrlKey && !t.altKey && !t.metaKey) { 6003 let r = Date.now(); 6004 n.input.lastIOSEnter = r, n.input.lastIOSEnterFallbackTimeout = setTimeout(()=>{ 6005 n.input.lastIOSEnter == r && (n.someProp("handleKeyDown", (i)=>i(n, Pe(13, "Enter"))), n.input.lastIOSEnter = 0); 6006 }, 200); 6007 } else n.someProp("handleKeyDown", (r)=>r(n, t)) || kf(n, t) ? t.preventDefault() : ye(n, "key"); 6008 }; 6009 Y.keyup = (n, e)=>{ 6010 e.keyCode == 16 && (n.input.shiftKey = !1); 6011 }; 6012 Y.keypress = (n, e)=>{ 6013 let t = e; 6014 if (el(n) || !t.charCode || t.ctrlKey && !t.altKey || te && t.metaKey) return; 6015 if (n.someProp("handleKeyPress", (i)=>i(n, t))) { 6016 t.preventDefault(); 6017 return; 6018 } 6019 let r = n.state.selection; 6020 if (!(r instanceof v) || !r.$from.sameParent(r.$to)) { 6021 let i = String.fromCharCode(t.charCode), o = ()=>n.state.tr.insertText(i).scrollIntoView(); 6022 !/[\r\n]/.test(i) && !n.someProp("handleTextInput", (s)=>s(n, r.$from.pos, r.$to.pos, i, o)) && n.dispatch(o()), t.preventDefault(); 6023 } 6024 }; 6025 function jt(n) { 6026 return { 6027 left: n.clientX, 6028 top: n.clientY 6029 }; 6030 } 6031 function Af(n, e) { 6032 let t = e.x - n.clientX, r = e.y - n.clientY; 6033 return t * t + r * r < 100; 6034 } 6035 function Jr(n, e, t, r, i) { 6036 if (r == -1) return !1; 6037 let o = n.state.doc.resolve(r); 6038 for(let s = o.depth + 1; s > 0; s--)if (n.someProp(e, (l)=>s > o.depth ? l(n, t, o.nodeAfter, o.before(s), i, !0) : l(n, t, o.node(s), o.before(s), i, !1))) return !0; 6039 return !1; 6040 } 6041 function Wt(n, e, t) { 6042 if (n.focused || n.focus(), n.state.selection.eq(e)) return; 6043 let r = n.state.tr.setSelection(e); 6044 r.setMeta("pointer", !0), n.dispatch(r); 6045 } 6046 function If(n, e) { 6047 if (e == -1) return !1; 6048 let t = n.state.doc.resolve(e), r = t.nodeAfter; 6049 return r && r.isAtom && T.isSelectable(r) ? (Wt(n, new T(t)), !0) : !1; 6050 } 6051 function Rf(n, e) { 6052 if (e == -1) return !1; 6053 let t = n.state.selection, r, i; 6054 t instanceof T && (r = t.node); 6055 let o = n.state.doc.resolve(e); 6056 for(let s = o.depth + 1; s > 0; s--){ 6057 let l = s > o.depth ? o.nodeAfter : o.node(s); 6058 if (T.isSelectable(l)) { 6059 r && t.$from.depth > 0 && s >= t.$from.depth && o.before(t.$from.depth + 1) == t.$from.pos ? i = o.before(t.$from.depth) : i = o.before(s); 6060 break; 6061 } 6062 }
6063 return i != null ? (Wt(n, T.create(n.state.doc, i)), !0) : !1; 6064 } 6065 function Bf(n, e, t, r, i) { 6066 return Jr(n, "handleClickOn", e, t, r) || n.someProp("handleClick", (o)=>o(n, e, r)) || (i ? Rf(n, t) : If(n, t)); 6067 } 6068 function Pf(n, e, t, r) { 6069 return Jr(n, "handleDoubleClickOn", e, t, r) || n.someProp("handleDoubleClick", (i)=>i(n, e, r)); 6070 } 6071 function zf(n, e, t, r) { 6072 return Jr(n, "handleTripleClickOn", e, t, r) || n.someProp("handleTripleClick", (i)=>i(n, e, r)) || Ff(n, t, r); 6073 } 6074 function Ff(n, e, t) { 6075 if (t.button != 0) return !1; 6076 let r = Xs(n, e, !0), i = n.state.doc; 6077 return r ? (Wt(n, r), r instanceof v && i.eq(n.state.doc) && (n.input.mouseDown = new Vf(n, r)), !0) : !1; 6078 } 6079 function Xs(n, e, t) { 6080 let r = n.state.doc; 6081 if (e == -1) return r.inlineContent ? v.create(r, 0, r.content.size) : null; 6082 let i = r.resolve(e); 6083 for(let o = i.depth + 1; o > 0; o--){ 6084 let s = o > i.depth ? i.nodeAfter : i.node(o), l = i.before(o); 6085 if (s.inlineContent) return v.create(r, l + 1, l + 1 + s.content.size); 6086 if (t && T.isSelectable(s)) return T.create(r, l); 6087 } 6088 return null; 6089 } 6090 function qr(n) { 6091 return mn(n); 6092 } 6093 const Qs = te ? "metaKey" : "ctrlKey"; 6094 U.mousedown = (n, e)=>{ 6095 let t = e; 6096 n.input.shiftKey = t.shiftKey; 6097 let r = qr(n), i = Date.now(), o = "singleClick"; 6098 i - n.input.lastClick.time < 500 && Af(t, n.input.lastClick) && !t[Qs] && n.input.lastClick.button == t.button && (n.input.lastClick.type == "singleClick" ? o = "doubleClick" : n.input.lastClick.type == "doubleClick" && (o = "tripleClick")), n.input.lastClick = { 6099 time: i, 6100 x: t.clientX, 6101 y: t.clientY, 6102 type: o, 6103 button: t.button 6104 }, n.input.mouseDown && n.input.mouseDown.done(); 6105 let s = n.posAtCoords(jt(t)); 6106 s && (o == "singleClick" ? n.input.mouseDown = new Lf(n, s, t, !!r) : (o == "doubleClick" ? Pf : zf)(n, s.pos, s.inside, t) ? t.preventDefault() : ye(n, "pointer")); 6107 }; 6108 class Zs { 6109 constructor(e){ 6110 this.view = e, this.mightDrag = null, e.root.addEventListener("mouseup", this.up = this.up.bind(this)), e.root.addEventListener("mousemove", this.move = this.move.bind(this)); 6111 } 6112 up(e) { 6113 this.done(); 6114 } 6115 move(e) { 6116 e.buttons == 0 && this.done(); 6117 } 6118 done() { 6119 this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.view.input.mouseDown == this && (this.view.input.mouseDown = null); 6120 } 6121 delaySelUpdate() { 6122 return !1; 6123 } 6124 } 6125 class Lf extends Zs { 6126 constructor(e, t, r, i){ 6127 super(e), this.pos = t, this.event = r, this.flushed = i, this.delayedSelectionSync = !1, this.startDoc = e.state.doc, this.selectNode = !!r[Qs], this.allowDefault = r.shiftKey; 6128 let o, s; 6129 if (t.inside > -1) o = e.state.doc.nodeAt(t.inside), s = t.inside; 6130 else { 6131 let f = e.state.doc.resolve(t.pos); 6132 o = f.parent, s = f.depth ? f.before() : 0; 6133 } 6134 const l = i ? null : r.target, a = l ? e.docView.nearestDesc(l, !0) : null; 6135 this.target = a && a.nodeDOM.nodeType == 1 ? a.nodeDOM : null; 6136 let { selection: c } = e.state; 6137 r.button == 0 && (o.type.spec.draggable && o.type.spec.selectable !== !1 || c instanceof T && c.from <= s && c.to > s) && (this.mightDrag = { 6138 node: o, 6139 pos: s, 6140 addAttr: !!(this.target && !this.target.draggable), 6141 setUneditable: !!(this.target && ie && !this.target.hasAttribute("contentEditable")) 6142 }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(()=>{ 6143 this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false"); 6144 }, 20), this.view.domObserver.start()), ye(e, "pointer"); 6145 } 6146 done() { 6147 super.done(), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(()=>{ 6148 this.view.isDestroyed || xe(this.view); 6149 }); 6150 } 6151 up(e) { 6152 if (this.done(), !this.view.dom.contains(e.target)) return; 6153 let t = this.pos; 6154 this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(jt(e))), this.updateAllowDefault(e), this.allowDefault || !t ? ye(this.view, "pointer") : Bf(this.view, t.pos, t.inside, e, this.selectNode) ? e.preventDefault() : e.button == 0 && (this.flushed || K && this.mightDrag && !this.mightDrag.node.isAtom || J && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (Wt(this.view, D.near(this.view.state.doc.resolve(t.pos))), e.preventDefault()) : ye(this.view, "pointer"); 6155 } 6156 move(e) { 6157 this.updateAllowDefault(e), ye(this.view, "pointer"), super.move(e); 6158 } 6159 updateAllowDefault(e) { 6160 !this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = !0); 6161 } 6162 delaySelUpdate() { 6163 return this.allowDefault ? (this.delayedSelectionSync = !0, !0) : !1; 6164 } 6165 } 6166 class Vf extends Zs { 6167 constructor(e, t){ 6168 super(e), this.startSelection = t, this.startDoc = e.state.doc; 6169 } 6170 move(e) { 6171 if (e.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) { 6172 this.done(); 6173 return; 6174 } 6175 e.preventDefault(), ye(this.view, "pointer"); 6176 let t = this.view.posAtCoords(jt(e)), r = t && Xs(this.view, t.inside, !1); 6177 if (!r) return; 6178 let { doc: i } = this.view.state, o = this.startSelection, [s, l] = r.from < o.from ? [ 6179 o.to, 6180 r.from 6181 ] : [ 6182 o.from, 6183 r.to 6184 ]; 6185 Wt(this.view, v.create(i, s, l)); 6186 } 6187 } 6188 U.touchstart = (n)=>{ 6189 n.input.lastTouch = Date.now(), qr(n), ye(n, "pointer"); 6190 }; 6191 U.touchmove = (n)=>{ 6192 n.input.lastTouch = Date.now(), ye(n, "pointer"); 6193 };
vendor: 5,769 bytes, lines 6194-6296
6194 U.contextmenu = (n)=>qr(n); 6195 function el(n, e) { 6196 return n.composing ? !0 : K && Math.abs(Date.now() - n.input.compositionEndedAt) < 500 ? (n.input.compositionEndedAt = -2e8, !0) : !1; 6197 } 6198 const $f = ge ? 5e3 : -1; 6199 Y.compositionstart = Y.compositionupdate = (n)=>{ 6200 if (!n.composing) { 6201 n.domObserver.flush(); 6202 let { state: e } = n, t = e.selection.$to; 6203 if (e.selection instanceof v && (e.storedMarks || !t.textOffset && t.parentOffset && t.nodeBefore.marks.some((r)=>r.type.spec.inclusive === !1) || J && Es && jf(n))) n.markCursor = n.state.storedMarks || t.marks(), mn(n, !0), n.markCursor = null; 6204 else if (mn(n, !e.selection.empty), ie && e.selection.empty && t.parentOffset && !t.textOffset && t.nodeBefore.marks.length) { 6205 let r = n.domSelectionRange(); 6206 for(let i = r.focusNode, o = r.focusOffset; i && i.nodeType == 1 && o != 0;){ 6207 let s = o < 0 ? i.lastChild : i.childNodes[o - 1]; 6208 if (!s) break; 6209 if (s.nodeType == 3) { 6210 let l = n.domSelection(); 6211 l && l.collapse(s, s.nodeValue.length); 6212 break; 6213 } else i = s, o = -1; 6214 } 6215 } 6216 n.input.composing = !0; 6217 } 6218 tl(n, $f); 6219 }; 6220 function jf(n) { 6221 let { focusNode: e, focusOffset: t } = n.domSelectionRange(); 6222 if (!e || e.nodeType != 1 || t >= e.childNodes.length) return !1; 6223 let r = e.childNodes[t]; 6224 return r.nodeType == 1 && r.contentEditable == "false"; 6225 } 6226 Y.compositionend = (n, e)=>{ 6227 n.composing && (n.input.composing = !1, n.input.compositionEndedAt = Date.now(), n.input.compositionPendingChanges = n.domObserver.pendingRecords().length ? n.input.compositionID : 0, n.input.compositionNode = null, n.input.badSafariComposition ? n.domObserver.forceFlush() : n.input.compositionPendingChanges && Promise.resolve().then(()=>n.domObserver.flush()), n.input.compositionID++, tl(n, 20)); 6228 }; 6229 function tl(n, e) { 6230 clearTimeout(n.input.composingTimeout), e > -1 && (n.input.composingTimeout = setTimeout(()=>mn(n), e)); 6231 } 6232 function nl(n) { 6233 for(n.composing && (n.input.composing = !1, n.input.compositionEndedAt = Date.now()); n.input.compositionNodes.length > 0;)n.input.compositionNodes.pop().markParentsDirty(); 6234 } 6235 function Wf(n) { 6236 let e = n.domSelectionRange(); 6237 if (!e.focusNode) return null; 6238 let t = Ic(e.focusNode, e.focusOffset), r = Rc(e.focusNode, e.focusOffset); 6239 if (t && r && t != r) { 6240 let i = r.pmViewDesc, o = n.domObserver.lastChangedTextNode; 6241 if (t == o || r == o) return o; 6242 if (!i || !i.isText(r.nodeValue)) return r; 6243 if (n.input.compositionNode == r) { 6244 let s = t.pmViewDesc; 6245 if (!(!s || !s.isText(t.nodeValue))) return r; 6246 } 6247 } 6248 return t || r; 6249 } 6250 function mn(n, e = !1) { 6251 if (!(ge && n.domObserver.flushingSoon >= 0)) { 6252 if (n.domObserver.forceFlush(), nl(n), e || n.docView && n.docView.dirty) { 6253 let t = Vr(n), r = n.state.selection; 6254 return t && !t.eq(r) ? n.dispatch(n.state.tr.setSelection(t)) : (n.markCursor || e) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? n.dispatch(n.state.tr.deleteSelection()) : n.updateState(n.state), !0; 6255 } 6256 return !1; 6257 } 6258 } 6259 function Jf(n, e) { 6260 if (!n.dom.parentNode) return; 6261 let t = n.dom.parentNode.appendChild(document.createElement("div")); 6262 t.appendChild(e), t.style.cssText = "position: fixed; left: -10000px; top: 10px"; 6263 let r = getSelection(), i = document.createRange(); 6264 i.selectNodeContents(e), n.dom.blur(), r.removeAllRanges(), r.addRange(i), setTimeout(()=>{ 6265 t.parentNode && t.parentNode.removeChild(t), n.focus(); 6266 }, 50); 6267 } 6268 const Rt = G && Oe < 15 || ft && Fc < 604; 6269 U.copy = Y.cut = (n, e)=>{ 6270 let t = e, r = n.state.selection, i = t.type == "cut"; 6271 if (r.empty) return; 6272 let o = Rt ? null : t.clipboardData, s = r.content(), { dom: l, text: a } = jr(n, s); 6273 o ? (t.preventDefault(), o.clearData(), o.setData("text/html", l.innerHTML), o.setData("text/plain", a)) : Jf(n, l), i && n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut")); 6274 }; 6275 function qf(n) { 6276 return n.openStart == 0 && n.openEnd == 0 && n.content.childCount == 1 ? n.content.firstChild : null; 6277 } 6278 function Kf(n, e) { 6279 if (!n.dom.parentNode) return; 6280 let t = n.input.shiftKey || n.state.selection.$from.parent.type.spec.code, r = n.dom.parentNode.appendChild(document.createElement(t ? "textarea" : "div")); 6281 t || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus(); 6282 let i = n.input.shiftKey && n.input.lastKeyCode != 45; 6283 setTimeout(()=>{ 6284 n.focus(), r.parentNode && r.parentNode.removeChild(r), t ? Bt(n, r.value, null, i, e) : Bt(n, r.textContent, r.innerHTML, i, e); 6285 }, 50); 6286 } 6287 function Bt(n, e, t, r, i) { 6288 let o = Ks(n, e, t, r, n.state.selection.$from); 6289 if (n.someProp("handlePaste", (a)=>a(n, i, o || b.empty))) return !0; 6290 if (!o) return !1; 6291 let s = qf(o), l = s ? n.state.tr.replaceSelectionWith(s, r) : n.state.tr.replaceSelection(o); 6292 return n.dispatch(l.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0; 6293 } 6294 function rl(n) { 6295 let e = n.getData("text/plain") || n.getData("Text"); 6296 if (e) return e;
6297 let t = n.getData("text/uri-list"); 6298 return t ? t.replace(/\r?\n/g, " ") : ""; 6299 } 6300 Y.paste = (n, e)=>{ 6301 let t = e; 6302 if (n.composing && !ge) return; 6303 let r = Rt ? null : t.clipboardData, i = n.input.shiftKey && n.input.lastKeyCode != 45; 6304 r && Bt(n, rl(r), r.getData("text/html"), i, t) ? t.preventDefault() : Kf(n, t); 6305 }; 6306 class il { 6307 constructor(e, t, r){ 6308 this.slice = e, this.move = t, this.node = r; 6309 } 6310 } 6311 const Hf = te ? "altKey" : "ctrlKey"; 6312 function ol(n, e) { 6313 let t; 6314 return n.someProp("dragCopies", (r)=>{ 6315 t = t || r(e); 6316 }), t != null ? !t : !e[Hf]; 6317 } 6318 U.dragstart = (n, e)=>{ 6319 let t = e, r = n.input.mouseDown; 6320 if (r && r.done(), !t.dataTransfer) return; 6321 let i = n.state.selection, o = i.empty ? null : n.posAtCoords(jt(t)), s; 6322 if (!(o && o.pos >= i.from && o.pos <= (i instanceof T ? i.to - 1 : i.to))) { 6323 if (r && r.mightDrag) s = T.create(n.state.doc, r.mightDrag.pos); 6324 else if (t.target && t.target.nodeType == 1) { 6325 let u = n.docView.nearestDesc(t.target, !0); 6326 u && u.node.type.spec.draggable && u != n.docView && (s = T.create(n.state.doc, u.posBefore)); 6327 } 6328 } 6329 let l = (s || n.state.selection).content(), { dom: a, text: c, slice: f } = jr(n, l); 6330 (!t.dataTransfer.files.length || !J || Ns > 120) && t.dataTransfer.clearData(), t.dataTransfer.setData(Rt ? "Text" : "text/html", a.innerHTML), t.dataTransfer.effectAllowed = "copyMove", Rt || t.dataTransfer.setData("text/plain", c), n.dragging = new il(f, ol(n, t), s); 6331 }; 6332 U.dragend = (n)=>{ 6333 let e = n.dragging; 6334 window.setTimeout(()=>{ 6335 n.dragging == e && (n.dragging = null); 6336 }, 50); 6337 }; 6338 Y.dragover = Y.dragenter = (n, e)=>e.preventDefault(); 6339 Y.drop = (n, e)=>{ 6340 try { 6341 _f(n, e, n.dragging); 6342 } finally{ 6343 n.dragging = null; 6344 } 6345 }; 6346 function _f(n, e, t) { 6347 if (!e.dataTransfer) return; 6348 let r = n.posAtCoords(jt(e)); 6349 if (!r) return; 6350 let i = n.state.doc.resolve(r.pos), o = t && t.slice; 6351 o ? n.someProp("transformPasted", (h)=>{ 6352 o = h(o, n, !1); 6353 }) : o = Ks(n, rl(e.dataTransfer), Rt ? null : e.dataTransfer.getData("text/html"), !1, i); 6354 let s = !!(t && ol(n, e)); 6355 if (n.someProp("handleDrop", (h)=>h(n, e, o || b.empty, s))) { 6356 e.preventDefault(); 6357 return; 6358 } 6359 if (!o) return; 6360 e.preventDefault(); 6361 let l = o ? Za(n.state.doc, i.pos, o) : i.pos; 6362 l == null && (l = i.pos); 6363 let a = n.state.tr; 6364 if (s) { 6365 let { node: h } = t; 6366 h ? h.replace(a) : a.deleteSelection(); 6367 } 6368 let c = a.mapping.map(l), f = o.openStart == 0 && o.openEnd == 0 && o.content.childCount == 1, u = a.doc; 6369 if (f ? a.replaceRangeWith(c, c, o.content.firstChild) : a.replaceRange(c, c, o), a.doc.eq(u)) return; 6370 let d = a.doc.resolve(c); 6371 if (f && T.isSelectable(o.content.firstChild) && d.nodeAfter && d.nodeAfter.sameMarkup(o.content.firstChild)) a.setSelection(new T(d)); 6372 else { 6373 let h = a.mapping.map(l); 6374 a.mapping.maps[a.mapping.maps.length - 1].forEach((p, m, g, y)=>h = y), a.setSelection($r(n, d, a.doc.resolve(h))); 6375 } 6376 n.focus(), n.dispatch(a.setMeta("uiEvent", "drop")); 6377 } 6378 U.focus = (n)=>{ 6379 n.input.lastFocus = Date.now(), n.focused || (n.domObserver.stop(), n.dom.classList.add("ProseMirror-focused"), n.domObserver.start(), n.focused = !0, setTimeout(()=>{ 6380 n.docView && n.hasFocus() && !n.domObserver.currentSelection.eq(n.domSelectionRange()) && xe(n); 6381 }, 20)); 6382 }; 6383 U.blur = (n, e)=>{ 6384 let t = e; 6385 n.focused && (n.domObserver.stop(), n.dom.classList.remove("ProseMirror-focused"), n.domObserver.start(), t.relatedTarget && n.dom.contains(t.relatedTarget) && n.domObserver.currentSelection.clear(), n.focused = !1); 6386 }; 6387 U.beforeinput = (n, e)=>{ 6388 if (ge && e.inputType == "deleteContentBackward") { 6389 n.domObserver.flushSoon(); 6390 let { domChangeCount: r }
vendor: 53,457 bytes, lines 6390-7574
6390 = n.input; 6391 setTimeout(()=>{ 6392 if (n.input.domChangeCount != r || (n.dom.blur(), n.focus(), n.someProp("handleKeyDown", (o)=>o(n, Pe(8, "Backspace"))))) return; 6393 let { $cursor: i } = n.state.selection; 6394 i && i.pos > 0 && n.dispatch(n.state.tr.delete(i.pos - 1, i.pos).scrollIntoView()); 6395 }, 50); 6396 } 6397 }; 6398 for(let n in Y)U[n] = Y[n]; 6399 function Pt(n, e) { 6400 if (n == e) return !0; 6401 for(let t in n)if (n[t] !== e[t]) return !1; 6402 for(let t in e)if (!(t in n)) return !1; 6403 return !0; 6404 } 6405 class gn { 6406 constructor(e, t){ 6407 this.toDOM = e, this.spec = t || qe, this.side = this.spec.side || 0; 6408 } 6409 map(e, t, r, i) { 6410 let { pos: o, deleted: s } = e.mapResult(t.from + i, this.side < 0 ? -1 : 1); 6411 return s ? null : new se(o - r, o - r, this); 6412 } 6413 valid() { 6414 return !0; 6415 } 6416 eq(e) { 6417 return this == e || e instanceof gn && (this.spec.key && this.spec.key == e.spec.key || this.toDOM == e.toDOM && Pt(this.spec, e.spec)); 6418 } 6419 destroy(e) { 6420 this.spec.destroy && this.spec.destroy(e); 6421 } 6422 } 6423 class De { 6424 constructor(e, t){ 6425 this.attrs = e, this.spec = t || qe; 6426 } 6427 map(e, t, r, i) { 6428 let o = e.map(t.from + i, this.spec.inclusiveStart ? -1 : 1) - r, s = e.map(t.to + i, this.spec.inclusiveEnd ? 1 : -1) - r; 6429 return o >= s ? null : new se(o, s, this); 6430 } 6431 valid(e, t) { 6432 return t.from < t.to; 6433 } 6434 eq(e) { 6435 return this == e || e instanceof De && Pt(this.attrs, e.attrs) && Pt(this.spec, e.spec); 6436 } 6437 static is(e) { 6438 return e.type instanceof De; 6439 } 6440 destroy() {} 6441 } 6442 class Kr { 6443 constructor(e, t){ 6444 this.attrs = e, this.spec = t || qe; 6445 } 6446 map(e, t, r, i) { 6447 let o = e.mapResult(t.from + i, 1); 6448 if (o.deleted) return null; 6449 let s = e.mapResult(t.to + i, -1); 6450 return s.deleted || s.pos <= o.pos ? null : new se(o.pos - r, s.pos - r, this); 6451 } 6452 valid(e, t) { 6453 let { index: r, offset: i } = e.content.findIndex(t.from), o; 6454 return i == t.from && !(o = e.child(r)).isText && i + o.nodeSize == t.to; 6455 } 6456 eq(e) { 6457 return this == e || e instanceof Kr && Pt(this.attrs, e.attrs) && Pt(this.spec, e.spec); 6458 } 6459 destroy() {} 6460 } 6461 se = class { 6462 constructor(e, t, r){ 6463 this.from = e, this.to = t, this.type = r; 6464 } 6465 copy(e, t) { 6466 return new se(e, t, this.type); 6467 } 6468 eq(e, t = 0) { 6469 return this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to; 6470 } 6471 map(e, t, r) { 6472 return this.type.map(e, this, t, r); 6473 } 6474 static widget(e, t, r) { 6475 return new se(e, e, new gn(t, r)); 6476 } 6477 static inline(e, t, r, i) { 6478 return new se(e, t, new De(r, i)); 6479 } 6480 static node(e, t, r, i) { 6481 return new se(e, t, new Kr(r, i)); 6482 } 6483 get spec() { 6484 return this.type.spec; 6485 } 6486 get inline() { 6487 return this.type instanceof De; 6488 } 6489 get widget() { 6490 return this.type instanceof gn; 6491 } 6492 }; 6493 const nt = [], qe = {}; 6494 z = class { 6495 constructor(e, t){ 6496 this.local = e.length ? e : nt, this.children = t.length ? t : nt; 6497 } 6498 static create(e, t) { 6499 return t.length ? yn(t, e, 0, qe) : q; 6500 } 6501 find(e, t, r) { 6502 let i = []; 6503 return this.findInner(e ?? 0, t ?? 1e9, i, 0, r), i; 6504 } 6505 findInner(e, t, r, i, o) { 6506 for(let s = 0; s < this.local.length; s++){ 6507 let l = this.local[s]; 6508 l.from <= t && l.to >= e && (!o || o(l.spec)) && r.push(l.copy(l.from + i, l.to + i)); 6509 } 6510 for(let s = 0; s < this.children.length; s += 3)if (this.children[s] < t && this.children[s + 1] > e) { 6511 let l = this.children[s] + 1; 6512 this.children[s + 2].findInner(e - l, t - l, r, i + l, o); 6513 } 6514 } 6515 map(e, t, r) { 6516 return this == q || e.maps.length == 0 ? this : this.mapInner(e, t, 0, 0, r || qe); 6517 } 6518 mapInner(e, t, r, i, o) { 6519 let s; 6520 for(let l = 0; l < this.local.length; l++){ 6521 let a = this.local[l].map(e, r, i); 6522 a && a.type.valid(t, a) ? (s || (s = [])).push(a) : o.onRemove && o.onRemove(this.local[l].spec); 6523 } 6524 return this.children.length ? Uf(this.children, s || [], e, t, r, i, o) : s ? new z(s.sort(Ke), nt) : q; 6525 } 6526 add(e, t) { 6527 return t.length ? this == q ? z.create(e, t) : this.addInner(e, t, 0) : this; 6528 } 6529 addInner(e, t, r) { 6530 let i, o = 0; 6531 e.forEach((l, a)=>{ 6532 let c = a + r, f; 6533 if (f = ll(t, l, c)) { 6534 for(i || (i = this.children.slice()); o < i.length && i[o] < a;)o += 3; 6535 i[o] == a ? i[o + 2] = i[o + 2].addInner(l, f, c + 1) : i.splice(o, 0, a, a + l.nodeSize, yn(f, l, c + 1, qe)), o += 3; 6536 } 6537 }); 6538 let s = sl(o ? al(t) : t, -r); 6539 for(let l = 0; l < s.length; l++)s[l].type.valid(e, s[l]) || s.splice(l--, 1); 6540 return new z(s.length ? this.local.concat(s).sort(Ke) : this.local, i || this.children); 6541 } 6542 remove(e) { 6543 return e.length == 0 || this == q ? this : this.removeInner(e, 0); 6544 } 6545 removeInner(e, t) { 6546 let r = this.children, i = this.local; 6547 for(let o = 0; o < r.length; o += 3){ 6548 let s, l = r[o] + t, a = r[o + 1] + t; 6549 for(let f = 0, u; f < e.length; f++)(u = e[f]) && u.from > l && u.to < a && (e[f] = null, (s || (s = [])).push(u)); 6550 if (!s) continue; 6551 r == this.children && (r = this.children.slice()); 6552 let c = r[o + 2].removeInner(s, l + 1); 6553 c != q ? r[o + 2] = c : (r.splice(o, 3), o -= 3); 6554 } 6555 if (i.length) { 6556 for(let o = 0, s; o < e.length; o++)if (s = e[o]) for(let l = 0; l < i.length; l++)i[l].eq(s, t) && (i == this.local && (i = this.local.slice()), i.splice(l--, 1)); 6557 } 6558 return r == this.children && i == this.local ? this : i.length || r.length ? new z(i, r) : q; 6559 } 6560 forChild(e, t) { 6561 if (this == q) return this; 6562 if (t.isLeaf) return z.empty; 6563 let r, i; 6564 for(let l = 0; l < this.children.length; l += 3)if (this.children[l] >= e) { 6565 this.children[l] == e && (r = this.children[l + 2]); 6566 break; 6567 } 6568 let o = e + 1, s = o + t.content.size; 6569 for(let l = 0; l < this.local.length; l++){ 6570 let a = this.local[l]; 6571 if (a.from < s && a.to > o && a.type instanceof De) { 6572 let c = Math.max(o, a.from) - o, f = Math.min(s, a.to) - o; 6573 c < f && (i || (i = [])).push(a.copy(c, f)); 6574 } 6575 } 6576 if (i) { 6577 let l = new z(i.sort(Ke), nt); 6578 return r ? new Ce([ 6579 l, 6580 r 6581 ]) : l; 6582 } 6583 return r || q; 6584 } 6585 eq(e) { 6586 if (this == e) return !0; 6587 if (!(e instanceof z) || this.local.length != e.local.length || this.children.length != e.children.length) return !1; 6588 for(let t = 0; t < this.local.length; t++)if (!this.local[t].eq(e.local[t])) return !1; 6589 for(let t = 0; t < this.children.length; t += 3)if (this.children[t] != e.children[t] || this.children[t + 1] != e.children[t + 1] || !this.children[t + 2].eq(e.children[t + 2])) return !1; 6590 return !0; 6591 } 6592 locals(e) { 6593 return Hr(this.localsInner(e)); 6594 } 6595 localsInner(e) { 6596 if (this == q) return nt; 6597 if (e.inlineContent || !this.local.some(De.is)) return this.local; 6598 let t = []; 6599 for(let r = 0; r < this.local.length; r++)this.local[r].type instanceof De || t.push(this.local[r]); 6600 return t; 6601 } 6602 forEachSet(e) { 6603 e(this); 6604 } 6605 }; 6606 z.empty = new z([], []); 6607 z.removeOverlap = Hr; 6608 const q = z.empty; 6609 class Ce { 6610 constructor(e){ 6611 this.members = e; 6612 } 6613 map(e, t) { 6614 const r = this.members.map((i)=>i.map(e, t, qe)); 6615 return Ce.from(r); 6616 } 6617 forChild(e, t) { 6618 if (t.isLeaf) return z.empty; 6619 let r = []; 6620 for(let i = 0; i < this.members.length; i++){ 6621 let o = this.members[i].forChild(e, t); 6622 o != q && (o instanceof Ce ? r = r.concat(o.members) : r.push(o)); 6623 } 6624 return Ce.from(r); 6625 } 6626 eq(e) { 6627 if (!(e instanceof Ce) || e.members.length != this.members.length) return !1; 6628 for(let t = 0; t < this.members.length; t++)if (!this.members[t].eq(e.members[t])) return !1; 6629 return !0; 6630 } 6631 locals(e) { 6632 let t, r = !0; 6633 for(let i = 0; i < this.members.length; i++){ 6634 let o = this.members[i].localsInner(e); 6635 if (o.length) if (!t) t = o; 6636 else { 6637 r && (t = t.slice(), r = !1); 6638 for(let s = 0; s < o.length; s++)t.push(o[s]); 6639 } 6640 } 6641 return t ? Hr(r ? t : t.sort(Ke)) : nt; 6642 } 6643 static from(e) { 6644 switch(e.length){ 6645 case 0: 6646 return q; 6647 case 1: 6648 return e[0]; 6649 default: 6650 return new Ce(e.every((t)=>t instanceof z) ? e : e.reduce((t, r)=>t.concat(r instanceof z ? r : r.members), [])); 6651 } 6652 } 6653 forEachSet(e) { 6654 for(let t = 0; t < this.members.length; t++)this.members[t].forEachSet(e); 6655 } 6656 } 6657 function Uf(n, e, t, r, i, o, s) { 6658 let l = n.slice(); 6659 for(let c = 0, f = o; c < t.maps.length; c++){ 6660 let u = 0; 6661 t.maps[c].forEach((d, h, p, m)=>{ 6662 let g = m - p - (h - d); 6663 for(let y = 0; y < l.length; y += 3){ 6664 let x = l[y + 1]; 6665 if (x < 0 || d > x + f - u) continue; 6666 let M = l[y] + f - u; 6667 h >= M ? l[y + 1] = d <= M ? -2 : -1 : d >= f && g && (l[y] += g, l[y + 1] += g); 6668 } 6669 u += g; 6670 }), f = t.maps[c].map(f, -1); 6671 } 6672 let a = !1; 6673 for(let c = 0; c < l.length; c += 3)if (l[c + 1] < 0) { 6674 if (l[c + 1] == -2) { 6675 a = !0, l[c + 1] = -1; 6676 continue; 6677 } 6678 let f = t.map(n[c] + o), u = f - i; 6679 if (u < 0 || u >= r.content.size) { 6680 a = !0; 6681 continue; 6682 } 6683 let d = t.map(n[c + 1] + o, -1), h = d - i, { index: p, offset: m } = r.content.findIndex(u), g = r.maybeChild(p); 6684 if (g && m == u && m + g.nodeSize == h) { 6685 let y = l[c + 2].mapInner(t, g, f + 1, n[c] + o + 1, s); 6686 y != q ? (l[c] = u, l[c + 1] = h, l[c + 2] = y) : (l[c + 1] = -2, a = !0); 6687 } else a = !0; 6688 } 6689 if (a) { 6690 let c = Yf(l, n, e, t, i, o, s), f = yn(c, r, 0, s); 6691 e = f.local; 6692 for(let u = 0; u < l.length; u += 3)l[u + 1] < 0 && (l.splice(u, 3), u -= 3); 6693 for(let u = 0, d = 0; u < f.children.length; u += 3){ 6694 let h = f.children[u]; 6695 for(; d < l.length && l[d] < h;)d += 3; 6696 l.splice(d, 0, f.children[u], f.children[u + 1], f.children[u + 2]); 6697 } 6698 } 6699 return new z(e.sort(Ke), l); 6700 } 6701 function sl(n, e) { 6702 if (!e || !n.length) return n; 6703 let t = []; 6704 for(let r = 0; r < n.length; r++){ 6705 let i = n[r]; 6706 t.push(new se(i.from + e, i.to + e, i.type)); 6707 } 6708 return t; 6709 } 6710 function Yf(n, e, t, r, i, o, s) { 6711 function l(a, c) { 6712 for(let f = 0; f < a.local.length; f++){ 6713 let u = a.local[f].map(r, i, c); 6714 u ? t.push(u) : s.onRemove && s.onRemove(a.local[f].spec); 6715 } 6716 for(let f = 0; f < a.children.length; f += 3)l(a.children[f + 2], a.children[f] + c + 1); 6717 } 6718 for(let a = 0; a < n.length; a += 3)n[a + 1] == -1 && l(n[a + 2], e[a] + o + 1); 6719 return t; 6720 } 6721 function ll(n, e, t) { 6722 if (e.isLeaf) return null; 6723 let r = t + e.nodeSize, i = null; 6724 for(let o = 0, s; o < n.length; o++)(s = n[o]) && s.from > t && s.to < r && ((i || (i = [])).push(s), n[o] = null); 6725 return i; 6726 } 6727 function al(n) { 6728 let e = []; 6729 for(let t = 0; t < n.length; t++)n[t] != null && e.push(n[t]); 6730 return e; 6731 } 6732 function yn(n, e, t, r) { 6733 let i = [], o = !1; 6734 e.forEach((l, a)=>{ 6735 let c = ll(n, l, a + t); 6736 if (c) { 6737 o = !0; 6738 let f = yn(c, l, t + a + 1, r); 6739 f != q && i.push(a, a + l.nodeSize, f); 6740 } 6741 }); 6742 let s = sl(o ? al(n) : n, -t).sort(Ke); 6743 for(let l = 0; l < s.length; l++)s[l].type.valid(e, s[l]) || (r.onRemove && r.onRemove(s[l].spec), s.splice(l--, 1)); 6744 return s.length || i.length ? new z(s, i) : q; 6745 } 6746 function Ke(n, e) { 6747 return n.from - e.from || n.to - e.to; 6748 } 6749 function Hr(n) { 6750 let e = n; 6751 for(let t = 0; t < e.length - 1; t++){ 6752 let r = e[t]; 6753 if (r.from != r.to) for(let i = t + 1; i < e.length; i++){ 6754 let o = e[i]; 6755 if (o.from == r.from) { 6756 o.to != r.to && (e == n && (e = n.slice()), e[i] = o.copy(o.from, r.to), _i(e, i + 1, o.copy(r.to, o.to))); 6757 continue; 6758 } else { 6759 o.from < r.to && (e == n && (e = n.slice()), e[t] = r.copy(r.from, o.from), _i(e, i, r.copy(o.from, r.to))); 6760 break; 6761 } 6762 } 6763 } 6764 return e; 6765 } 6766 function _i(n, e, t) { 6767 for(; e < n.length && Ke(t, n[e]) > 0;)e++; 6768 n.splice(e, 0, t); 6769 } 6770 function Gn(n) { 6771 let e = []; 6772 return n.someProp("decorations", (t)=>{ 6773 let r = t(n.state); 6774 r && r != q && e.push(r); 6775 }), n.cursorWrapper && e.push(z.create(n.state.doc, [ 6776 n.cursorWrapper.deco 6777 ])), Ce.from(e); 6778 } 6779 const Gf = { 6780 childList: !0, 6781 characterData: !0, 6782 characterDataOldValue: !0, 6783 attributes: !0, 6784 attributeOldValue: !0, 6785 subtree: !0 6786 }, Xf = G && Oe <= 11; 6787 class Qf { 6788 constructor(){ 6789 this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0; 6790 } 6791 set(e) { 6792 this.anchorNode = e.anchorNode, this.anchorOffset = e.anchorOffset, this.focusNode = e.focusNode, this.focusOffset = e.focusOffset; 6793 } 6794 clear() { 6795 this.anchorNode = this.focusNode = null; 6796 } 6797 eq(e) { 6798 return e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset; 6799 } 6800 } 6801 class Zf { 6802 constructor(e, t){ 6803 this.view = e, this.handleDOMChange = t, this.queue = [], this.flushingSoon = -1, this.observer = null, this.currentSelection = new Qf, this.onCharData = null, this.suppressingSelectionUpdates = !1, this.lastChangedTextNode = null, this.observer = window.MutationObserver && new window.MutationObserver((r)=>{ 6804 for(let i = 0; i < r.length; i++)this.queue.push(r[i]); 6805 G && Oe <= 11 && r.some((i)=>i.type == "childList" && i.removedNodes.length || i.type == "characterData" && i.oldValue.length > i.target.nodeValue.length) ? this.flushSoon() : K && e.composing && r.some((i)=>i.type == "childList" && i.target.nodeName == "TR") ? (e.input.badSafariComposition = !0, this.flushSoon()) : this.flush(); 6806 }), Xf && (this.onCharData = (r)=>{ 6807 this.queue.push({ 6808 target: r.target, 6809 type: "characterData", 6810 oldValue: r.prevValue 6811 }), this.flushSoon(); 6812 }), this.onSelectionChange = this.onSelectionChange.bind(this); 6813 } 6814 flushSoon() { 6815 this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(()=>{ 6816 this.flushingSoon = -1, this.flush(); 6817 }, 20)); 6818 } 6819 forceFlush() { 6820 this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush()); 6821 } 6822 start() { 6823 this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, Gf)), this.onCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection(); 6824 } 6825 stop() { 6826 if (this.observer) { 6827 let e = this.observer.takeRecords(); 6828 if (e.length) { 6829 for(let t = 0; t < e.length; t++)this.queue.push(e[t]); 6830 window.setTimeout(()=>this.flush(), 20); 6831 } 6832 this.observer.disconnect(); 6833 } 6834 this.onCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection(); 6835 } 6836 connectSelection() { 6837 this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange); 6838 } 6839 disconnectSelection() { 6840 this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange); 6841 } 6842 suppressSelectionUpdates() { 6843 this.suppressingSelectionUpdates = !0, setTimeout(()=>this.suppressingSelectionUpdates = !1, 50); 6844 } 6845 onSelectionChange() { 6846 if ($i(this.view)) { 6847 if (this.suppressingSelectionUpdates) return xe(this.view); 6848 if (G && Oe <= 11 && !this.view.state.selection.empty) { 6849 let e = this.view.domSelectionRange(); 6850 if (e.focusNode && Ye(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset)) return this.flushSoon(); 6851 } 6852 this.flush(); 6853 } 6854 } 6855 setCurSelection() { 6856 this.currentSelection.set(this.view.domSelectionRange()); 6857 } 6858 ignoreSelectionChange(e) { 6859 if (!e.focusNode) return !0; 6860 let t = new Set, r; 6861 for(let o = e.focusNode; o; o = ct(o))t.add(o); 6862 for(let o = e.anchorNode; o; o = ct(o))if (t.has(o)) { 6863 r = o; 6864 break; 6865 } 6866 let i = r && this.view.docView.nearestDesc(r); 6867 if (i && i.ignoreMutation({ 6868 type: "selection", 6869 target: r.nodeType == 3 ? r.parentNode : r 6870 })) return this.setCurSelection(), !0; 6871 } 6872 pendingRecords() { 6873 if (this.observer) for (let e of this.observer.takeRecords())this.queue.push(e); 6874 return this.queue; 6875 } 6876 flush() { 6877 let { view: e } = this; 6878 if (!e.docView || this.flushingSoon > -1) return; 6879 let t = this.pendingRecords(); 6880 t.length && (this.queue = []); 6881 let r = e.domSelectionRange(), i = !this.suppressingSelectionUpdates && !this.currentSelection.eq(r) && $i(e) && !this.ignoreSelectionChange(r), o = -1, s = -1, l = !1, a = []; 6882 if (e.editable) for(let f = 0; f < t.length; f++){ 6883 let u = this.registerMutation(t[f], a); 6884 u && (o = o < 0 ? u.from : Math.min(u.from, o), s = s < 0 ? u.to : Math.max(u.to, s), u.typeOver && (l = !0)); 6885 } 6886 if (a.some((f)=>f.nodeName == "BR") && (e.input.lastKeyCode == 8 || e.input.lastKeyCode == 46 || J && (e.composing || e.input.compositionEndedAt > Date.now() - 50) && t.some((f)=>f.type == "childList" && f.removedNodes.length))) { 6887 for (let f of a)if (f.nodeName == "BR" && f.parentNode) { 6888 let u = f.nextSibling; 6889 for(; u && u.nodeType == 1;){ 6890 if (u.contentEditable == "false") { 6891 f.parentNode.removeChild(f); 6892 break; 6893 } 6894 u = u.firstChild; 6895 } 6896 } 6897 } else if (ie && a.length) { 6898 let f = a.filter((u)=>u.nodeName == "BR"); 6899 if (f.length == 2) { 6900 let [u, d] = f; 6901 u.parentNode && u.parentNode.parentNode == d.parentNode ? d.remove() : u.remove(); 6902 } else { 6903 let { focusNode: u } = this.currentSelection; 6904 for (let d of f){ 6905 let h = d.parentNode; 6906 h && h.nodeName == "LI" && (!u || nu(e, u) != h) && d.remove(); 6907 } 6908 } 6909 } 6910 let c = null; 6911 o < 0 && i && e.input.lastFocus > Date.now() - 200 && Math.max(e.input.lastTouch, e.input.lastClick.time) < Date.now() - 300 && Rn(r) && (c = Vr(e)) && c.eq(D.near(e.state.doc.resolve(0), 1)) ? (e.input.lastFocus = 0, xe(e), this.currentSelection.set(r), e.scrollToSelection()) : (o > -1 || i) && (o > -1 && (e.docView.markDirty(o, s), eu(e)), e.input.badSafariComposition && (e.input.badSafariComposition = !1, ru(e, a)), this.handleDOMChange(o, s, l, a), e.docView && e.docView.dirty ? e.updateState(e.state) : this.currentSelection.eq(r) || xe(e), this.currentSelection.set(r)); 6912 } 6913 registerMutation(e, t) { 6914 if (t.indexOf(e.target) > -1) return null; 6915 let r = this.view.docView.nearestDesc(e.target); 6916 if (e.type == "attributes" && (r == this.view.docView || e.attributeName == "contenteditable" || e.attributeName == "style" && !e.oldValue && !e.target.getAttribute("style")) || !r || r.ignoreMutation(e)) return null; 6917 if (e.type == "childList") { 6918 for(let f = 0; f < e.addedNodes.length; f++){ 6919 let u = e.addedNodes[f]; 6920 t.push(u), u.nodeType == 3 && (this.lastChangedTextNode = u); 6921 } 6922 if (r.contentDOM && r.contentDOM != r.dom && !r.contentDOM.contains(e.target)) return { 6923 from: r.posBefore, 6924 to: r.posAfter 6925 }; 6926 let i = e.previousSibling, o = e.nextSibling; 6927 if (G && Oe <= 11 && e.addedNodes.length) for(let f = 0; f < e.addedNodes.length; f++){ 6928 let { previousSibling: u, nextSibling: d } = e.addedNodes[f]; 6929 (!u || Array.prototype.indexOf.call(e.addedNodes, u) < 0) && (i = u), (!d || Array.prototype.indexOf.call(e.addedNodes, d) < 0) && (o = d); 6930 } 6931 let s = i && i.parentNode == e.target ? j(i) + 1 : 0, l = r.localPosFromDOM(e.target, s, -1), a = o && o.parentNode == e.target ? j(o) : e.target.childNodes.length, c = r.localPosFromDOM(e.target, a, 1); 6932 return { 6933 from: l, 6934 to: c 6935 }; 6936 } else return e.type == "attributes" ? { 6937 from: r.posAtStart - r.border, 6938 to: r.posAtEnd + r.border 6939 } : (this.lastChangedTextNode = e.target, { 6940 from: r.posAtStart, 6941 to: r.posAtEnd, 6942 typeOver: e.target.nodeValue == e.oldValue 6943 }); 6944 } 6945 } 6946 let Ui = new WeakMap, Yi = !1; 6947 function eu(n) { 6948 if (!Ui.has(n) && (Ui.set(n, null), [ 6949 "normal", 6950 "nowrap", 6951 "pre-line" 6952 ].indexOf(getComputedStyle(n.dom).whiteSpace) !== -1)) { 6953 if (n.requiresGeckoHackNode = ie, Yi) return; 6954 console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."), Yi = !0; 6955 } 6956 } 6957 function Gi(n, e) { 6958 let t = e.startContainer, r = e.startOffset, i = e.endContainer, o = e.endOffset, s = n.domAtPos(n.state.selection.anchor); 6959 return Ye(s.node, s.offset, i, o) && ([t, r, i, o] = [ 6960 i, 6961 o, 6962 t, 6963 r 6964 ]), { 6965 anchorNode: t, 6966 anchorOffset: r, 6967 focusNode: i, 6968 focusOffset: o 6969 }; 6970 } 6971 function tu(n, e) { 6972 if (e.getComposedRanges) { 6973 let i = e.getComposedRanges(n.root)[0]; 6974 if (i) return Gi(n, i); 6975 } 6976 let t; 6977 function r(i) { 6978 i.preventDefault(), i.stopImmediatePropagation(), t = i.getTargetRanges()[0]; 6979 } 6980 return n.dom.addEventListener("beforeinput", r, !0), document.execCommand("indent"), n.dom.removeEventListener("beforeinput", r, !0), t ? Gi(n, t) : null; 6981 } 6982 function nu(n, e) { 6983 for(let t = e.parentNode; t && t != n.dom; t = t.parentNode){ 6984 let r = n.docView.nearestDesc(t, !0); 6985 if (r && r.node.isBlock) return t; 6986 } 6987 return null; 6988 } 6989 function ru(n, e) { 6990 var t; 6991 let { focusNode: r, focusOffset: i } = n.domSelectionRange(); 6992 for (let o of e)if (((t = o.parentNode) === null || t === void 0 ? void 0 : t.nodeName) == "TR") { 6993 let s = o.nextSibling; 6994 for(; s && s.nodeName != "TD" && s.nodeName != "TH";)s = s.nextSibling; 6995 if (s) { 6996 let l = s; 6997 for(;;){ 6998 let a = l.firstChild; 6999 if (!a || a.nodeType != 1 || a.contentEditable == "false" || /^(BR|IMG)$/.test(a.nodeName)) break; 7000 l = a; 7001 } 7002 l.insertBefore(o, l.firstChild), r == o && n.domSelection().collapse(o, i); 7003 } else o.parentNode.removeChild(o); 7004 } 7005 } 7006 function iu(n, e, t, r) { 7007 let { node: i, fromOffset: o, toOffset: s, from: l, to: a } = n.docView.parseRange(e, t), c = n.domSelectionRange(), f, u = c.anchorNode; 7008 if (u && n.dom.contains(u.nodeType == 1 ? u : u.parentNode) && (f = [ 7009 { 7010 node: u, 7011 offset: c.anchorOffset 7012 } 7013 ], Rn(c) || f.push({ 7014 node: c.focusNode, 7015 offset: c.focusOffset 7016 })), J && n.input.lastKeyCode === 8) for(let y = s; y > o; y--){ 7017 let x = i.childNodes[y - 1], M = x.pmViewDesc; 7018 if (x.nodeName == "BR" && !M) { 7019 s = y; 7020 break; 7021 } 7022 if (!M || M.size) break; 7023 } 7024 let d = n.state.doc, h = n.someProp("domParser") || wt.fromSchema(n.state.schema), p = d.resolve(l), m = null, g = h.parse(i, { 7025 topNode: p.parent, 7026 topMatch: p.parent.contentMatchAt(p.index()), 7027 topOpen: !0, 7028 from: o, 7029 to: s, 7030 preserveWhitespace: p.parent.type.whitespace == "pre" ? "full" : !0, 7031 findPositions: f, 7032 ruleFromNode: ou(r), 7033 context: p 7034 }); 7035 if (f && f[0].pos != null) { 7036 let y = f[0].pos, x = f[1] && f[1].pos; 7037 x == null && (x = y), m = { 7038 anchor: y + l, 7039 head: x + l 7040 }; 7041 } 7042 return { 7043 doc: g, 7044 sel: m, 7045 from: l, 7046 to: a 7047 }; 7048 } 7049 const ou = (n)=>(e)=>{ 7050 let t = e.pmViewDesc; 7051 if (t) return t.parseRule(n); 7052 if (e.nodeName == "BR" && e.parentNode) { 7053 if (K && /^(ul|ol)$/i.test(e.parentNode.nodeName)) { 7054 let r = document.createElement("div"); 7055 return r.appendChild(document.createElement("li")), { 7056 skip: r 7057 }; 7058 } else if (e.parentNode.lastChild == e || K && /^(tr|table)$/i.test(e.parentNode.nodeName)) return { 7059 ignore: !0 7060 }; 7061 } else if (e.nodeName == "IMG" && e.getAttribute("mark-placeholder")) return { 7062 ignore: !0 7063 }; 7064 return null; 7065 }, su = /^(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; 7066 function lu(n, e, t, r, i) { 7067 let o = n.input.compositionPendingChanges || (n.composing ? n.input.compositionID : 0); 7068 if (n.input.compositionPendingChanges = 0, e < 0) { 7069 let C = n.input.lastSelectionTime > Date.now() - 50 ? n.input.lastSelectionOrigin : null, E = Vr(n, C); 7070 if (E && !n.state.selection.eq(E)) { 7071 if (J && ge && n.input.lastKeyCode === 13 && Date.now() - 100 < n.input.lastKeyCodeTime && n.someProp("handleKeyDown", (_)=>_(n, Pe(13, "Enter")))) return; 7072 let A = n.state.tr.setSelection(E); 7073 C == "pointer" ? A.setMeta("pointer", !0) : C == "key" && A.scrollIntoView(), o && A.setMeta("composition", o), n.dispatch(A); 7074 } 7075 return; 7076 } 7077 let s = n.state.doc.resolve(e), l = s.sharedDepth(t); 7078 e = s.before(l + 1), t = n.state.doc.resolve(t).after(l + 1); 7079 let a = n.state.selection, c = iu(n, e, t, i), f = n.state.doc, u = f.slice(c.from, c.to), d, h; 7080 n.input.lastKeyCode === 8 && Date.now() - 100 < n.input.lastKeyCodeTime ? (d = n.state.selection.to, h = "end") : (d = n.state.selection.from, h = "start"), n.input.lastKeyCode = null; 7081 let p = fu(u.content, c.doc.content, c.from, d, h); 7082 if (p && n.input.domChangeCount++, (ft && n.input.lastIOSEnter > Date.now() - 225 || ge) && i.some((C)=>C.nodeType == 1 && !su.test(C.nodeName)) && (!p || p.endA >= p.endB) && n.someProp("handleKeyDown", (C)=>C(n, Pe(13, "Enter")))) { 7083 n.input.lastIOSEnter = 0; 7084 return; 7085 } 7086 if (!p) if (r && a instanceof v && !a.empty && a.$head.sameParent(a.$anchor) && !n.composing && !(c.sel && c.sel.anchor != c.sel.head)) p = { 7087 start: a.from, 7088 endA: a.to, 7089 endB: a.to 7090 }; 7091 else { 7092 if (c.sel) { 7093 let C = Xi(n, n.state.doc, c.sel); 7094 if (C && !C.eq(n.state.selection)) { 7095 let E = n.state.tr.setSelection(C); 7096 o && E.setMeta("composition", o), n.dispatch(E); 7097 } 7098 } 7099 return; 7100 } 7101 n.state.selection.from < n.state.selection.to && p.start == p.endB && n.state.selection instanceof v && (p.start > n.state.selection.from && p.start <= n.state.selection.from + 2 && n.state.selection.from >= c.from ? p.start = n.state.selection.from : p.endA < n.state.selection.to && p.endA >= n.state.selection.to - 2 && n.state.selection.to <= c.to && (p.endB += n.state.selection.to - p.endA, p.endA = n.state.selection.to)), G && Oe <= 11 && p.endB == p.start + 1 && p.endA == p.start && p.start > c.from && c.doc.textBetween(p.start - c.from - 1, p.start - c.from + 1) == " Â " && (p.start--, p.endA--, p.endB--); 7102 let m = c.doc.resolveNoCache(p.start - c.from), g = c.doc.resolveNoCache(p.endB - c.from), y = f.resolve(p.start), x = m.sameParent(g) && m.parent.inlineContent && y.end() >= p.endA; 7103 if ((ft && n.input.lastIOSEnter > Date.now() - 225 && (!x || i.some((C)=>C.nodeName == "DIV" || C.nodeName == "P")) || !x && m.pos < c.doc.content.size && (!m.sameParent(g) || !m.parent.inlineContent) && m.pos < g.pos && !/\S/.test(c.doc.textBetween(m.pos, g.pos, "", ""))) && n.someProp("handleKeyDown", (C)=>C(n, Pe(13, "Enter")))) { 7104 n.input.lastIOSEnter = 0; 7105 return; 7106 } 7107 if (n.state.selection.anchor > p.start && cu(f, p.start, p.endA, m, g) && n.someProp("handleKeyDown", (C)=>C(n, Pe(8, "Backspace")))) { 7108 ge && J && n.domObserver.suppressSelectionUpdates(); 7109 return; 7110 } 7111 J && p.endB == p.start && (n.input.lastChromeDelete = Date.now()), ge && !x && m.start() != g.start() && g.parentOffset == 0 && m.depth == g.depth && c.sel && c.sel.anchor == c.sel.head && c.sel.head == p.endA && (p.endB -= 2, g = c.doc.resolveNoCache(p.endB - c.from), setTimeout(()=>{ 7112 n.someProp("handleKeyDown", function(C) { 7113 return C(n, Pe(13, "Enter")); 7114 }); 7115 }, 20)); 7116 let M = p.start, w = p.endA, N = (C)=>{ 7117 let E = C || n.state.tr.replace(M, w, c.doc.slice(p.start - c.from, p.endB - c.from)); 7118 if (c.sel) { 7119 let A = Xi(n, E.doc, c.sel); 7120 A && !(J && n.composing && A.empty && (p.start != p.endB || n.input.lastChromeDelete < Date.now() - 100) && (A.head == M || A.head == E.mapping.map(w) - 1) || G && A.empty && A.head == M) && E.setSelection(A); 7121 } 7122 return o && E.setMeta("composition", o), E.scrollIntoView(); 7123 }, O; 7124 if (x) if (m.pos == g.pos) { 7125 G && Oe <= 11 && m.parentOffset == 0 && (n.domObserver.suppressSelectionUpdates(), setTimeout(()=>xe(n), 20)); 7126 let C = N(n.state.tr.delete(M, w)), E = f.resolve(p.start).marksAcross(f.resolve(p.endA)); 7127 E && C.ensureMarks(E), n.dispatch(C); 7128 } else if (p.endA == p.endB && (O = au(m.parent.content.cut(m.parentOffset, g.parentOffset), y.parent.content.cut(y.parentOffset, p.endA - y.start())))) { 7129 let C = N(n.state.tr); 7130 O.type == "add" ? C.addMark(M, w, O.mark) : C.removeMark(M, w, O.mark), n.dispatch(C); 7131 } else if (m.parent.child(m.index()).isText && m.index() == g.index() - (g.textOffset ? 0 : 1)) { 7132 let C = m.parent.textBetween(m.parentOffset, g.parentOffset), E = ()=>N(n.state.tr.insertText(C, M, w)); 7133 n.someProp("handleTextInput", (A)=>A(n, M, w, C, E)) || n.dispatch(E()); 7134 } else n.dispatch(N()); 7135 else n.dispatch(N()); 7136 } 7137 function Xi(n, e, t) { 7138 return Math.max(t.anchor, t.head) > e.content.size ? null : $r(n, e.resolve(t.anchor), e.resolve(t.head)); 7139 } 7140 function au(n, e) { 7141 let t = n.firstChild.marks, r = e.firstChild.marks, i = t, o = r, s, l, a; 7142 for(let f = 0; f < r.length; f++)i = r[f].removeFromSet(i); 7143 for(let f = 0; f < t.length; f++)o = t[f].removeFromSet(o); 7144 if (i.length == 1 && o.length == 0) l = i[0], s = "add", a = (f)=>f.mark(l.addToSet(f.marks)); 7145 else if (i.length == 0 && o.length == 1) l = o[0], s = "remove", a = (f)=>f.mark(l.removeFromSet(f.marks)); 7146 else return null; 7147 let c = []; 7148 for(let f = 0; f < e.childCount; f++)c.push(a(e.child(f))); 7149 if (k.from(c).eq(n)) return { 7150 mark: l, 7151 type: s 7152 }; 7153 } 7154 function cu(n, e, t, r, i) { 7155 if (t - e <= i.pos - r.pos || Xn(r, !0, !1) < i.pos) return !1; 7156 let o = n.resolve(e); 7157 if (!r.parent.isTextblock) { 7158 let l = o.nodeAfter; 7159 return l != null && t == e + l.nodeSize; 7160 } 7161 if (o.parentOffset < o.parent.content.size || !o.parent.isTextblock) return !1; 7162 let s = n.resolve(Xn(o, !0, !0)); 7163 return !s.parent.isTextblock || s.pos > t || Xn(s, !0, !1) < t ? !1 : r.parent.content.cut(r.parentOffset).eq(s.parent.content); 7164 } 7165 function Xn(n, e, t) { 7166 let r = n.depth, i = e ? n.end() : n.pos; 7167 for(; r > 0 && (e || n.indexAfter(r) == n.node(r).childCount);)r--, i++, e = !1; 7168 if (t) { 7169 let o = n.node(r).maybeChild(n.indexAfter(r)); 7170 for(; o && !o.isLeaf;)o = o.firstChild, i++; 7171 } 7172 return i; 7173 } 7174 function fu(n, e, t, r, i) { 7175 let o = n.findDiffStart(e, t), s = t + n.size, l = t + e.size; 7176 if (o == null) return null; 7177 let { a, b: c } = n.findDiffEnd(e, s, l); 7178 if (i == "end") { 7179 let f = Math.max(0, o - Math.min(a, c)); 7180 r -= a + f - o; 7181 } 7182 if (a < o && s < l) { 7183 let f = r <= o && r >= a ? o - r : 0; 7184 o -= f, c = o + (c - a), a = o; 7185 } else if (c < o) { 7186 let f = r <= o && r >= c ? o - r : 0; 7187 o -= f, a = o + (a - c), c = o; 7188 } 7189 return { 7190 start: o, 7191 endA: a, 7192 endB: c 7193 }; 7194 } 7195 class cl { 7196 constructor(e, t){ 7197 this._root = null, this.focused = !1, this.trackWrites = null, this.mounted = !1, this.markCursor = null, this.cursorWrapper = null, this.lastSelectedViewDesc = void 0, this.input = new vf, this.prevDirectPlugins = [], this.pluginViews = [], this.requiresGeckoHackNode = !1, this.dragging = null, this._props = t, this.state = t.state, this.directPlugins = t.plugins || [], this.directPlugins.forEach(no), this.dispatch = this.dispatch.bind(this), this.dom = e && e.mount || document.createElement("div"), e && (e.appendChild ? e.appendChild(this.dom) : typeof e == "function" ? e(this.dom) : e.mount && (this.mounted = !0)), this.editable = eo(this), Zi(this), this.nodeViews = to(this), this.docView = Bi(this.state.doc, Qi(this), Gn(this), this.dom, this), this.domObserver = new Zf(this, (r, i, o, s)=>lu(this, r, i, o, s)), this.domObserver.start(), Of(this), this.updatePluginViews(); 7198 } 7199 get composing() { 7200 return this.input.composing; 7201 } 7202 get props() { 7203 if (this._props.state != this.state) { 7204 let e = this._props; 7205 this._props = {}; 7206 for(let t in e)this._props[t] = e[t]; 7207 this._props.state = this.state; 7208 } 7209 return this._props; 7210 } 7211 update(e) { 7212 e.handleDOMEvents != this._props.handleDOMEvents && Cr(this); 7213 let t = this._props; 7214 this._props = e, e.plugins && (e.plugins.forEach(no), this.directPlugins = e.plugins), this.updateStateInner(e.state, t); 7215 } 7216 setProps(e) { 7217 let t = {}; 7218 for(let r in this._props)t[r] = this._props[r]; 7219 t.state = this.state; 7220 for(let r in e)t[r] = e[r]; 7221 this.update(t); 7222 } 7223 updateState(e) { 7224 this.updateStateInner(e, this._props); 7225 } 7226 updateStateInner(e, t) { 7227 var r; 7228 let i = this.state, o = !1, s = !1; 7229 e.storedMarks && this.composing && (nl(this), s = !0), this.state = e; 7230 let l = i.plugins != e.plugins || this._props.plugins != t.plugins; 7231 if (l || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews) { 7232 let h = to(this); 7233 du(h, this.nodeViews) && (this.nodeViews = h, o = !0); 7234 } 7235 (l || t.handleDOMEvents != this._props.handleDOMEvents) && Cr(this), this.editable = eo(this), Zi(this); 7236 let a = Gn(this), c = Qi(this), f = i.plugins != e.plugins && !i.doc.eq(e.doc) ? "reset" : e.scrollToSelection > i.scrollToSelection ? "to selection" : "preserve", u = o || !this.docView.matchesNode(e.doc, c, a); 7237 (u || !e.selection.eq(i.selection)) && (s = !0); 7238 let d = f == "preserve" && s && this.dom.style.overflowAnchor == null && $c(this); 7239 if (s) { 7240 this.domObserver.stop(); 7241 let h = u && (G || J) && !this.composing && !i.selection.empty && !e.selection.empty && uu(i.selection, e.selection); 7242 if (u) { 7243 let m = J ? this.trackWrites = this.domSelectionRange().focusNode : null; 7244 this.composing && (this.input.compositionNode = Wf(this)), (o || !this.docView.update(e.doc, c, a, this)) && (this.docView.updateOuterDeco(c), this.docView.destroy(), this.docView = Bi(e.doc, c, a, this.dom, this)), m && (!this.trackWrites || !this.dom.contains(this.trackWrites)) && (h = !0); 7245 } 7246 let p = this.input.mouseDown; 7247 h || !(p && this.domObserver.currentSelection.eq(this.domSelectionRange()) && uf(this) && p.delaySelUpdate()) ? xe(this, h) : (Ws(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start(); 7248 } 7249 this.updatePluginViews(i), !((r = this.dragging) === null || r === void 0) && r.node && !i.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, i), f == "reset" ? this.dom.scrollTop = 0 : f == "to selection" ? this.scrollToSelection() : d && jc(d); 7250 } 7251 scrollToSelection() { 7252 let e = this.domSelectionRange().focusNode; 7253 if (!(!e || !this.dom.contains(e.nodeType == 1 ? e : e.parentNode))) { 7254 if (!this.someProp("handleScrollToSelection", (t)=>t(this))) if (this.state.selection instanceof T) { 7255 let t = this.docView.domAfterPos(this.state.selection.from); 7256 t.nodeType == 1 && Ei(this, t.getBoundingClientRect(), e); 7257 } else Ei(this, this.coordsAtPos(this.state.selection.head, 1), e); 7258 } 7259 } 7260 destroyPluginViews() { 7261 let e; 7262 for(; e = this.pluginViews.pop();)e.destroy && e.destroy(); 7263 } 7264 updatePluginViews(e) { 7265 if (!e || e.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) { 7266 this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews(); 7267 for(let t = 0; t < this.directPlugins.length; t++){ 7268 let r = this.directPlugins[t]; 7269 r.spec.view && this.pluginViews.push(r.spec.view(this)); 7270 } 7271 for(let t = 0; t < this.state.plugins.length; t++){ 7272 let r = this.state.plugins[t]; 7273 r.spec.view && this.pluginViews.push(r.spec.view(this)); 7274 } 7275 } else for(let t = 0; t < this.pluginViews.length; t++){ 7276 let r = this.pluginViews[t]; 7277 r.update && r.update(this, e); 7278 } 7279 } 7280 updateDraggedNode(e, t) { 7281 let r = e.node, i = -1; 7282 if (r.from < this.state.doc.content.size && this.state.doc.nodeAt(r.from) == r.node) i = r.from; 7283 else { 7284 let o = r.from + (this.state.doc.content.size - t.doc.content.size); 7285 (o > 0 && o < this.state.doc.content.size && this.state.doc.nodeAt(o)) == r.node && (i = o); 7286 } 7287 this.dragging = new il(e.slice, e.move, i < 0 ? void 0 : T.create(this.state.doc, i)); 7288 } 7289 someProp(e, t) { 7290 let r = this._props && this._props[e], i; 7291 if (r != null && (i = t ? t(r) : r)) return i; 7292 for(let s = 0; s < this.directPlugins.length; s++){ 7293 let l = this.directPlugins[s].props[e]; 7294 if (l != null && (i = t ? t(l) : l)) return i; 7295 } 7296 let o = this.state.plugins; 7297 if (o) for(let s = 0; s < o.length; s++){ 7298 let l = o[s].props[e]; 7299 if (l != null && (i = t ? t(l) : l)) return i; 7300 } 7301 } 7302 hasFocus() { 7303 if (G) { 7304 let e = this.root.activeElement; 7305 if (e == this.dom) return !0; 7306 if (!e || !this.dom.contains(e)) return !1; 7307 for(; e && this.dom != e && this.dom.contains(e);){ 7308 if (e.contentEditable == "false") return !1; 7309 e = e.parentElement; 7310 } 7311 return !0; 7312 } 7313 return this.root.activeElement == this.dom; 7314 } 7315 focus() { 7316 this.domObserver.stop(), this.editable && Wc(this.dom), xe(this), this.domObserver.start(); 7317 } 7318 get root() { 7319 let e = this._root; 7320 if (e == null) { 7321 for(let t = this.dom.parentNode; t; t = t.parentNode)if (t.nodeType == 9 || t.nodeType == 11 && t.host) return t.getSelection || (Object.getPrototypeOf(t).getSelection = ()=>t.ownerDocument.getSelection()), this._root = t; 7322 } 7323 return e || document; 7324 } 7325 updateRoot() { 7326 this._root = null; 7327 } 7328 posAtCoords(e) { 7329 return _c(this, e); 7330 } 7331 coordsAtPos(e, t = 1) { 7332 return Bs(this, e, t); 7333 } 7334 domAtPos(e, t = 0) { 7335 return this.docView.domFromPos(e, t); 7336 } 7337 nodeDOM(e) { 7338 let t = this.docView.descAt(e); 7339 return t ? t.nodeDOM : null; 7340 } 7341 posAtDOM(e, t, r = -1) { 7342 let i = this.docView.posFromDOM(e, t, r); 7343 if (i == null) throw new RangeError("DOM position not inside the editor"); 7344 return i; 7345 } 7346 endOfTextblock(e, t) { 7347 return Qc(this, t || this.state, e); 7348 } 7349 pasteHTML(e, t) { 7350 return Bt(this, "", e, !1, t || new ClipboardEvent("paste")); 7351 } 7352 pasteText(e, t) { 7353 return Bt(this, e, null, !0, t || new ClipboardEvent("paste")); 7354 } 7355 serializeForClipboard(e) { 7356 return jr(this, e); 7357 } 7358 destroy() { 7359 this.docView && (Nf(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], Gn(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null, Dc()); 7360 } 7361 get isDestroyed() { 7362 return this.docView == null; 7363 } 7364 dispatchEvent(e) { 7365 return Df(this, e); 7366 } 7367 domSelectionRange() { 7368 let e = this.domSelection(); 7369 return e ? K && this.root.nodeType === 11 && Pc(this.dom.ownerDocument) == this.dom && tu(this, e) || e : { 7370 focusNode: null, 7371 focusOffset: 0, 7372 anchorNode: null, 7373 anchorOffset: 0 7374 }; 7375 } 7376 domSelection() { 7377 return this.root.getSelection(); 7378 } 7379 } 7380 cl.prototype.dispatch = function(n) { 7381 let e = this._props.dispatchTransaction; 7382 e ? e.call(this, n) : this.updateState(this.state.apply(n)); 7383 }; 7384 function Qi(n) { 7385 let e = Object.create(null); 7386 return e.class = "ProseMirror", e.contenteditable = String(n.editable), n.someProp("attributes", (t)=>{ 7387 if (typeof t == "function" && (t = t(n.state)), t) for(let r in t)r == "class" ? e.class += " " + t[r] : r == "style" ? e.style = (e.style ? e.style + ";" : "") + t[r] : !e[r] && r != "contenteditable" && r != "nodeName" && (e[r] = String(t[r])); 7388 }), e.translate || (e.translate = "no"), [ 7389 se.node(0, n.state.doc.content.size, e) 7390 ]; 7391 } 7392 function Zi(n) { 7393 if (n.markCursor) { 7394 let e = document.createElement("img"); 7395 e.className = "ProseMirror-separator", e.setAttribute("mark-placeholder", "true"), e.setAttribute("alt", ""), n.cursorWrapper = { 7396 dom: e, 7397 deco: se.widget(n.state.selection.from, e, { 7398 raw: !0, 7399 marks: n.markCursor 7400 }) 7401 }; 7402 } else n.cursorWrapper = null; 7403 } 7404 function eo(n) { 7405 return !n.someProp("editable", (e)=>e(n.state) === !1); 7406 } 7407 function uu(n, e) { 7408 let t = Math.min(n.$anchor.sharedDepth(n.head), e.$anchor.sharedDepth(e.head)); 7409 return n.$anchor.start(t) != e.$anchor.start(t); 7410 } 7411 function to(n) { 7412 let e = Object.create(null); 7413 function t(r) { 7414 for(let i in r)Object.prototype.hasOwnProperty.call(e, i) || (e[i] = r[i]); 7415 } 7416 return n.someProp("nodeViews", t), n.someProp("markViews", t), e; 7417 } 7418 function du(n, e) { 7419 let t = 0, r = 0; 7420 for(let i in n){ 7421 if (n[i] != e[i]) return !0; 7422 t++; 7423 } 7424 for(let i in e)r++; 7425 return t != r; 7426 } 7427 function no(n) { 7428 if (n.spec.state || n.spec.filterTransaction || n.spec.appendTransaction) throw new RangeError("Plugins passed directly to the view must not have a state component"); 7429 } 7430 var Ae = { 7431 8: "Backspace", 7432 9: "Tab", 7433 10: "Enter", 7434 12: "NumLock", 7435 13: "Enter", 7436 16: "Shift", 7437 17: "Control", 7438 18: "Alt", 7439 20: "CapsLock", 7440 27: "Escape", 7441 32: " ", 7442 33: "PageUp", 7443 34: "PageDown", 7444 35: "End", 7445 36: "Home", 7446 37: "ArrowLeft", 7447 38: "ArrowUp", 7448 39: "ArrowRight", 7449 40: "ArrowDown", 7450 44: "PrintScreen", 7451 45: "Insert", 7452 46: "Delete", 7453 59: ";", 7454 61: "=", 7455 91: "Meta", 7456 92: "Meta", 7457 106: "*", 7458 107: "+", 7459 108: ",", 7460 109: "-", 7461 110: ".", 7462 111: "/", 7463 144: "NumLock", 7464 145: "ScrollLock", 7465 160: "Shift", 7466 161: "Shift", 7467 162: "Control", 7468 163: "Control", 7469 164: "Alt", 7470 165: "Alt", 7471 173: "-", 7472 186: ";", 7473 187: "=", 7474 188: ",", 7475 189: "-", 7476 190: ".", 7477 191: "/", 7478 192: "`", 7479 219: "[", 7480 220: "\\", 7481 221: "]", 7482 222: "'" 7483 }, kn = { 7484 48: ")", 7485 49: "!", 7486 50: "@", 7487 51: "#", 7488 52: "$", 7489 53: "%", 7490 54: "^", 7491 55: "&", 7492 56: "*", 7493 57: "(", 7494 59: ":", 7495 61: "+", 7496 173: "_", 7497 186: ":", 7498 187: "+", 7499 188: "<", 7500 189: "_", 7501 190: ">", 7502 191: "?", 7503 192: "~", 7504 219: "{", 7505 220: "|", 7506 221: "}", 7507 222: '"' 7508 }, hu = typeof navigator < "u" && /Mac/.test(navigator.platform), pu = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent); 7509 for(var W = 0; W < 10; W++)Ae[48 + W] = Ae[96 + W] = String(W); 7510 for(var W = 1; W <= 24; W++)Ae[W + 111] = "F" + W; 7511 for(var W = 65; W <= 90; W++)Ae[W] = String.fromCharCode(W + 32), kn[W] = String.fromCharCode(W); 7512 for(var Qn in Ae)kn.hasOwnProperty(Qn) || (kn[Qn] = Ae[Qn]); 7513 function mu(n) { 7514 var e = hu && n.metaKey && n.shiftKey && !n.ctrlKey && !n.altKey || pu && n.shiftKey && n.key && n.key.length == 1 || n.key == "Unidentified", t = !e && n.key || (n.shiftKey ? kn : Ae)[n.keyCode] || n.key || "Unidentified"; 7515 return t == "Esc" && (t = "Escape"), t == "Del" && (t = "Delete"), t == "Left" && (t = "ArrowLeft"), t == "Up" && (t = "ArrowUp"), t == "Right" && (t = "ArrowRight"), t == "Down" && (t = "ArrowDown"), t; 7516 } 7517 const gu = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), yu = typeof navigator < "u" && /Win/.test(navigator.platform); 7518 function ku(n) { 7519 let e = n.split(/-(?!$)/), t = e[e.length - 1]; 7520 t == "Space" && (t = " "); 7521 let r, i, o, s; 7522 for(let l = 0; l < e.length - 1; l++){ 7523 let a = e[l]; 7524 if (/^(cmd|meta|m)$/i.test(a)) s = !0; 7525 else if (/^a(lt)?$/i.test(a)) r = !0; 7526 else if (/^(c|ctrl|control)$/i.test(a)) i = !0; 7527 else if (/^s(hift)?$/i.test(a)) o = !0; 7528 else if (/^mod$/i.test(a)) gu ? s = !0 : i = !0; 7529 else throw new Error("Unrecognized modifier name: " + a); 7530 } 7531 return r && (t = "Alt-" + t), i && (t = "Ctrl-" + t), s && (t = "Meta-" + t), o && (t = "Shift-" + t), t; 7532 } 7533 function bu(n) { 7534 let e = Object.create(null); 7535 for(let t in n)e[ku(t)] = n[t]; 7536 return e; 7537 } 7538 function Zn(n, e, t = !0) { 7539 return e.altKey && (n = "Alt-" + n), e.ctrlKey && (n = "Ctrl-" + n), e.metaKey && (n = "Meta-" + n), t && e.shiftKey && (n = "Shift-" + n), n; 7540 } 7541 function xu(n) { 7542 return new X({ 7543 props: { 7544 handleKeyDown: Su(n) 7545 } 7546 }); 7547 } 7548 function Su(n) { 7549 let e = bu(n); 7550 return function(t, r) { 7551 let i = mu(r), o, s = e[Zn(i, r)]; 7552 if (s && s(t.state, t.dispatch, t)) return !0; 7553 if (i.length == 1 && i != " ") { 7554 if (r.shiftKey) { 7555 let l = e[Zn(i, r, !1)]; 7556 if (l && l(t.state, t.dispatch, t)) return !0; 7557 } 7558 if ((r.altKey || r.metaKey || r.ctrlKey) && !(yu && r.ctrlKey && r.altKey) && (o = Ae[r.keyCode]) && o != i) { 7559 let l = e[Zn(o, r)]; 7560 if (l && l(t.state, t.dispatch, t)) return !0; 7561 } 7562 } 7563 return !1; 7564 }; 7565 } 7566 function Pn(n) { 7567 const { state: e, transaction: t } = n; 7568 let { selection: r } = t, { doc: i } = t, { storedMarks: o } = t; 7569 return { 7570 ...e, 7571 apply: e.apply.bind(e), 7572 applyTransaction: e.applyTransaction.bind(e), 7573 plugins: e.plugins, 7574 schema: e.schema,
7575 reconfigure: e.reconfigure.bind(e), 7576 toJSON: e.toJSON.bind(e), 7577 get storedMarks () { 7578 return o; 7579 }, 7580 get selection () { 7581 return r; 7582 }, 7583 get doc () { 7584 return i; 7585 }, 7586 get tr () { 7587 return r = t.selection, i = t.doc, o = t.storedMarks, t; 7588 } 7589 }; 7590 } 7591 var st = class fl { 7592 constructor(e){ 7593 this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state; 7594 } 7595 get hasCustomState() { 7596 return !!this.customState; 7597 } 7598 get state() { 7599 return this.customState || this.editor.state; 7600 } 7601 get commands() { 7602 const { rawCommands: e, editor: t, state: r } = this, { view: i } = t, { tr: o } = r, s = this.buildProps(o); 7603 return Object.fromEntries(Object.entries(e).map(([l, a])=>[ 7604 l, 7605 (...f)=>{ 7606 const u = a(...f)(s); 7607 return !o.getMeta("preventDispatch") && !this.hasCustomState && i.dispatch(o), u; 7608 } 7609 ])); 7610 } 7611 get chain() { 7612 return ()=>this.createChain(); 7613 } 7614 get can() { 7615 return ()=>this.createCan(); 7616 } 7617 createChain(e, t = !0) { 7618 const { rawCommands: r, editor: i, state: o } = this, { view: s } = i, l = [], a = !!e, c = e || o.tr, f = ()=>(!a && t && !c.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(c), l.every((d)=>d === !0)), u = { 7619 ...Object.fromEntries(Object.entries(r).map(([d, h])=>[ 7620 d, 7621 (...m)=>{ 7622 const g = this.buildProps(c, t), y = h(...m)(g); 7623 return l.push(y), u; 7624 } 7625 ])), 7626 run: f 7627 }; 7628 return u; 7629 } 7630 static createFakeChain() { 7631 const e = new Proxy({}, { 7632 get: (t, r)=>{ 7633 if (r !== "then") return r === "run" ? ()=>!1 : ()=>e; 7634 } 7635 }); 7636 return e; 7637 } 7638 createCan(e) { 7639 const { rawCommands: t, state: r } = this, i = !1, o = e || r.tr, s = this.buildProps(o, i); 7640 return { 7641 ...Object.fromEntries(Object.entries(t).map(([l, a])=>[ 7642 l, 7643 (...c)=>a(...c)({ 7644 ...s, 7645 dispatch: void 0 7646 }) 7647 ])), 7648 chain: ()=>this.createChain(o, i) 7649 }; 7650 } 7651 static createFallbackCan() { 7652 const e = fl.createFakeChain(); 7653 return new Proxy({ 7654 chain: ()=>e 7655 }, { 7656 get: (t, r)=>{ 7657 if (r !== "then") return r === "chain" ? t.chain : ()=>!1; 7658 } 7659 }); 7660 } 7661 buildProps(e, t = !0) { 7662 const { rawCommands: r, editor: i, state: o } = this, { view: s } = i, l = { 7663 tr: e, 7664 editor: i, 7665 view: s, 7666 state: Pn({ 7667 state: o, 7668 transaction: e 7669 }), 7670 dispatch: t ? ()=>{} : void 0, 7671 chain: ()=>this.createChain(e, t), 7672 can: ()=>this.createCan(e), 7673 get commands () { 7674 return Object.fromEntries(Object.entries(r).map(([a, c])=>[ 7675 a, 7676 (...f)=>c(...f)(l) 7677 ])); 7678 } 7679 }; 7680 return l; 7681 } 7682 }; 7683 const wu = ()=>({ editor: n, view: e })=>(requestAnimationFrame(()=>{ 7684 if (!n.isDestroyed) { 7685 var t; 7686 e.dom.blur(), (t = window) === null || t === void 0 || (t = t.getSelection()) === null || t === void 0 || t.removeAllRanges(); 7687 } 7688 }), !0), Mu = (n = !0)=>({ commands: e })=>e.setContent("", { 7689 emitUpdate: n 7690 }), Cu = ()=>({ state: n, tr: e, dispatch: t })=>{ 7691 const { selection: r } = e, { ranges: i } = r;
7692 return t && i.forEach(({ $from: o, $to: s })=>{ 7693 n.doc.nodesBetween(o.pos, s.pos, (l, a)=>{ 7694 if (l.type.isText) return; 7695 const { doc: c, mapping: f } = e, u = c.resolve(f.map(a)), d = c.resolve(f.map(a + l.nodeSize)), h = u.blockRange(d); 7696 if (!h) return; 7697 const p = ht(h); 7698 if (l.type.isTextblock) { 7699 const { defaultType: m } = u.parent.contentMatchAt(u.index()); 7700 e.setNodeMarkup(h.start, m); 7701 } 7702 (p || p === 0) && e.lift(h, p); 7703 }); 7704 }), !0; 7705 }, Tu = (n)=>(e)=>n(e), vu = ()=>({ state: n, dispatch: e })=>Ms(n, e), Ou = (n, e)=>({ editor: t, tr: r })=>{ 7706 const { state: i } = t, o = i.doc.slice(n.from, n.to); 7707 r.deleteRange(n.from, n.to); 7708 const s = r.mapping.map(e); 7709 return r.insert(s, o.content), r.setSelection(new v(r.doc.resolve(Math.max(s - 1, 0)))), !0; 7710 }, Nu = ()=>({ tr: n, dispatch: e })=>{ 7711 const { selection: t } = n, r = t.$anchor.node(); 7712 if (r.content.size > 0) return !1; 7713 const i = n.selection.$anchor; 7714 for(let o = i.depth; o > 0; o -= 1)if (i.node(o).type === r.type) { 7715 if (e) { 7716 const s = i.before(o), l = i.after(o); 7717 n.delete(s, l).scrollIntoView(); 7718 } 7719 return !0; 7720 } 7721 return !1; 7722 }; 7723 function V(n, e) { 7724 if (typeof n == "string") { 7725 if (!e.nodes[n]) throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`); 7726 return e.nodes[n]; 7727 } 7728 return n; 7729 } 7730 const Eu = (n)=>({ tr: e, state: t, dispatch: r })=>{ 7731 const i = V(n, t.schema), o = e.selection.$anchor; 7732 for(let s = o.depth; s > 0; s -= 1)if (o.node(s).type === i) { 7733 if (r) { 7734 const l = o.before(s), a = o.after(s); 7735 e.delete(l, a).scrollIntoView(); 7736 } 7737 return !0; 7738 } 7739 return !1; 7740 }, Du = (n)=>({ tr: e, dispatch: t })=>{ 7741 const { from: r, to: i } = n; 7742 return t && e.delete(r, i), !0; 7743 }, Au = (n)=>n.content ? /^text(\*|\+)/.test(n.content) : !1, ro = (n, e, t)=>{ 7744 if (!n.parent.isInline || t === "left" && n.pos > n.start() || t === "right" && n.pos < n.end()) return n.pos; 7745 const r = e.nodes[n.parent.type.name].spec; 7746 return Au(r) ? t === "left" ? n.start() - 1 : n.end() + 1 : n.pos; 7747 }, Iu = (n, e, t)=>({ 7748 from: ro(n, t, "left"), 7749 to: ro(e, t, "right") 7750 }), Ru = ()=>({ state: n, dispatch: e })=>{ 7751 if (n.selection.empty) return !1; 7752 if (e) { 7753 const t = n.tr, { ranges: r } = n.selection, i = t.steps.length; 7754 r.forEach((o)=>{ 7755 const s = t.mapping.slice(i), l = t.doc.resolve(s.map(o.$from.pos)), a = t.doc.resolve(s.map(o.$to.pos)), { from: c, to: f } = Iu(l, a, n.schema); 7756 t.deleteRange(c, f); 7757 }), t.selection.empty || t.setSelection(v.near(t.doc.resolve(t.selection.from))), t.scrollIntoView(), e(t); 7758 } 7759 return !0; 7760 }, Bu = ()=>({ commands: n })=>n.keyboardShortcut("Enter"), Pu = ()=>({ state: n, dispatch: e })=>mc(n, e); 7761 function _r(n) { 7762 return Object.prototype.toString.call(n) === "[object RegExp]"; 7763 } 7764 function bn(n, e, t = { 7765 strict: !0 7766 }) { 7767 const r = Object.keys(e); 7768 return r.length ? r.every((i)=>t.strict ? e[i] === n[i] : _r(e[i]) ? e[i].test(n[i]) : e[i] === n[i]) : !0; 7769 } 7770 function ul(n, e, t = {}) { 7771 return n.find((r)=>r.type === e && bn(Object.fromEntries(Object.keys(t).map((i)=>[ 7772 i, 7773 r.attrs[i] 7774 ])), t)); 7775 } 7776 function io(n, e, t = {}) { 7777 return !!ul(n, e, t); 7778 } 7779 function dl(n, e, t) { 7780 if (!n || !e) return; 7781 let r = n.parent.childAfter(n.parentOffset); 7782 if ((!r.node || !r.node.marks.some((a)=>a.type === e)) && (r = n.parent.childBefore(n.parentOffset)), !r.node || !r.node.marks.some((a)=>a.type === e)) return; 7783 if (!t) { 7784 const a = r.node.marks.find((c)=>c.type === e); 7785 a && (t = a.attrs); 7786 } 7787 if (!ul([ 7788 ...r.node.marks 7789 ], e, t)) return; 7790 let i = r.index, o = n.start() + r.offset, s = i + 1, l = o + r.node.nodeSize; 7791 for(; i > 0 && io([ 7792 ...n.parent.child(i - 1).marks 7793 ], e, t);)i -= 1, o -= n.parent.child(i).nodeSize; 7794 for(; s < n.parent.childCount && io([ 7795 ...n.parent.child(s).marks 7796 ], e, t);)l += n.parent.child(s).nodeSize, s += 1; 7797 return { 7798 from: o, 7799 to: l 7800 }; 7801 } 7802 function Se(n, e) { 7803 if (typeof n == "string") { 7804 if (!e.marks[n]) throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`); 7805 return e.marks[n]; 7806 } 7807 return n; 7808 } 7809 const zu = (n, e)=>({ tr: t, state: r, dispatch: i })=>{ 7810 const o = Se(n, r.schema), { doc: s, selection: l } = t, { $from: a, from: c, to: f } = l; 7811 if (i) { 7812 const u = dl(a, o, e); 7813 if (u && u.from <= c && u.to >= f) { 7814 const d = v.create(s, u.from, u.to); 7815 t.setSelection(d); 7816 } 7817 } 7818 return !0; 7819 }, Fu = (n)=>(e)=>{ 7820 const t = typeof n == "function" ? n(e) : n; 7821 for(let r = 0; r < t.length; r += 1)if (t[r](e)) return !0; 7822 return !1; 7823 }; 7824 function hl(n) { 7825 return n instanceof v; 7826 } 7827 function Ve(n = 0, e = 0, t = 0) { 7828 return Math.min(Math.max(n, e), t); 7829 } 7830 function Tr(n, e = null) { 7831 if (!e) return null; 7832 const t = D.atStart(n), r = D.atEnd(n); 7833 if (e === "start" || e === !0) return t; 7834 if (e === "end") return r; 7835 const i = t.from, o = r.to; 7836 return e === "all" ? v.create(n, Ve(0, i, o), Ve(n.content.size, i, o)) : v.create(n, Ve(e, i, o), Ve(e, i, o)); 7837 } 7838 function oo() { 7839 return [ 7840 "Android" 7841 ].includes(navigator.platform) || /android/i.test(navigator.userAgent); 7842 } 7843 function xn() { 7844 return [ 7845 "iPad Simulator", 7846 "iPhone Simulator", 7847 "iPod Simulator", 7848 "iPad", 7849 "iPhone", 7850 "iPod" 7851 ].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document; 7852 } 7853 function Lu() { 7854 return typeof navigator < "u" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1; 7855 } 7856 const Vu = (n = null, e = {})=>({ editor: t, view: r, tr: i, dispatch: o })=>{ 7857 e = { 7858 scrollIntoView: !0, 7859 ...e 7860 }; 7861 const s = ()=>{ 7862 (xn() || oo()) && r.dom.focus(), Lu() && !xn() && !oo() && r.dom.focus({ 7863 preventScroll: !0 7864 }), requestAnimationFrame(()=>{ 7865 t.isDestroyed || (r.focus(), e?.scrollIntoView && t.commands.scrollIntoView()); 7866 }); 7867 }; 7868 try { 7869 if (r.hasFocus() && n === null || n === !1) return !0; 7870 } catch { 7871 return !1; 7872 } 7873 if (o && n === null && !hl(t.state.selection)) return s(), !0; 7874 const l = Tr(i.doc, n) || t.state.selection, a = t.state.selection.eq(l); 7875 return o && (a || i.setSelection(l), a && i.storedMarks && i.setStoredMarks(i.storedMarks), s()), !0; 7876 }, $u = (n, e)=>(t)=>n.every((r, i)=>e(r, { 7877 ...t, 7878 index: i 7879 })), ju = (n, e)=>({ tr: t, commands: r })=>r.insertContentAt({ 7880 from: t.selection.from, 7881 to: t.selection.to 7882 }, n, e), pl = (n)=>{ 7883 const e = n.childNodes; 7884 for(let t = e.length - 1; t >= 0; t -= 1){ 7885 const r = e[t];
7886 r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? n.removeChild(r) : r.nodeType === 1 && pl(r); 7887 } 7888 return n; 7889 }; 7890 function Xt(n) { 7891 if (typeof window > "u") throw new Error("[tiptap error]: there is no window object available, so this function cannot be used"); 7892 const e = `<body>${n}</body>`, t = new window.DOMParser().parseFromString(e, "text/html").body; 7893 return pl(t); 7894 } 7895 function ml(n) { 7896 return typeof n?.nodesBetween == "function"; 7897 } 7898 function ut(n, e, t) { 7899 if (ml(n)) return n; 7900 const r = typeof n == "object" && n !== null; 7901 t = { 7902 slice: !0, 7903 parseOptions: {}, 7904 ...t 7905 }; 7906 const i = typeof n == "string"; 7907 if (r) try { 7908 if (Array.isArray(n) && n.length > 0) return k.fromArray(n.map((s)=>e.nodeFromJSON(s))); 7909 const o = e.nodeFromJSON(n); 7910 return t.errorOnInvalidContent && o.check(), o; 7911 } catch (o) { 7912 if (t.errorOnInvalidContent) throw new Error("[tiptap error]: Invalid JSON content", { 7913 cause: o 7914 }); 7915 return console.warn("[tiptap warn]: Invalid content.", "Passed value:", n, "Error:", o), ut("", e, t); 7916 } 7917 if (i) { 7918 if (t.errorOnInvalidContent) { 7919 let s = !1, l = ""; 7920 const a = new Dr({ 7921 topNode: e.spec.topNode, 7922 marks: e.spec.marks, 7923 nodes: e.spec.nodes.append({ 7924 __tiptap__private__unknown__catch__all__node: { 7925 content: "inline*", 7926 group: "block", 7927 parseDOM: [ 7928 { 7929 tag: "*", 7930 getAttrs: (c)=>(s = !0, l = typeof c == "string" ? c : c.outerHTML, null) 7931 } 7932 ] 7933 } 7934 }) 7935 }); 7936 if (t.slice ? wt.fromSchema(a).parseSlice(Xt(n), t.parseOptions) : wt.fromSchema(a).parse(Xt(n), t.parseOptions), t.errorOnInvalidContent && s) throw new Error("[tiptap error]: Invalid HTML content", { 7937 cause: new Error(`Invalid element found: ${l}`) 7938 }); 7939 } 7940 const o = wt.fromSchema(e); 7941 return t.slice ? o.parseSlice(Xt(n), t.parseOptions).content : o.parse(Xt(n), t.parseOptions); 7942 } 7943 return ut("", e, t); 7944 } 7945 function gl(n) { 7946 return !("type" in n); 7947 } 7948 function yl(n, e, t) { 7949 const r = n.steps.length - 1; 7950 if (r < e) return; 7951 const i = n.steps[r]; 7952 if (!(i instanceof P || i instanceof L)) return; 7953 const o = n.mapping.maps[r]; 7954 let s = 0; 7955 o.forEach((l, a, c, f)=>{ 7956 s === 0 && (s = f); 7957 }), n.setSelection(D.near(n.doc.resolve(s), t)); 7958 } 7959 const Wu = (n, e, t)=>({ tr: r, dispatch: i, editor: o })=>{ 7960 if (i) { 7961 t = { 7962 parseOptions: o.options.parseOptions, 7963 updateSelection: !0, 7964 applyInputRules: !1, 7965 applyPasteRules: !1, 7966 ...t 7967 }; 7968 let l; 7969 const a = (g)=>{ 7970 o.emit("contentError", { 7971 editor: o, 7972 error: g, 7973 disableCollaboration: ()=>{ 7974 "collaboration" in o.storage && typeof o.storage.collaboration == "object" && o.storage.collaboration && (o.storage.collaboration.isDisabled = !0); 7975 } 7976 }); 7977 }, c = { 7978 preserveWhitespace: "full", 7979 ...t.parseOptions 7980 }; 7981 if (!t.errorOnInvalidContent && !o.options.enableContentCheck && o.options.emitContentError) try { 7982 ut(e, o.schema, { 7983 parseOptions: c, 7984 errorOnInvalidContent: !0 7985 }); 7986 } catch (g) { 7987 a(g); 7988 } 7989 try { 7990 var s; 7991 l = ut(e, o.schema, { 7992 parseOptions: c, 7993 errorOnInvalidContent: (s = t.errorOnInvalidContent) !== null && s !== void 0 ? s : o.options.enableContentCheck 7994 }); 7995 } catch (g) { 7996 return a(g), !1; 7997 } 7998 let { from: f, to: u } = typeof n == "number" ? { 7999 from: n, 8000 to: n 8001 } : { 8002 from: n.from, 8003 to: n.to 8004 }, d = !0, h = !0; 8005 const p = gl(l) ? l.content : [ 8006 l 8007 ];
8008 if (p.forEach((g)=>{ 8009 g.check(), d = d ? g.isText && g.marks.length === 0 : !1, h = h ? g.isBlock : !1; 8010 }), f === u && h) { 8011 const { parent: g } = r.doc.resolve(f); 8012 g.isTextblock && !g.type.spec.code && !g.childCount && (f -= 1, u += 1); 8013 } 8014 let m; 8015 if (d) Array.isArray(e) ? m = e.map((g)=>g.text || "").join("") : ml(e) ? m = p.map((g)=>{ 8016 var y; 8017 return (y = g.text) !== null && y !== void 0 ? y : ""; 8018 }).join("") : typeof e == "object" && e && e.text ? m = e.text : m = e, r.insertText(m, f, u); 8019 else { 8020 m = k.from(p); 8021 const g = r.doc.resolve(f), y = g.node(), x = g.parentOffset === 0, M = y.isText || y.isTextblock, w = y.content.size > 0; 8022 x && M && w && h && (f = Math.max(0, f - 1)), r.replaceWith(f, u, p); 8023 } 8024 t.updateSelection && yl(r, r.steps.length - 1, -1), t.applyInputRules && r.setMeta("applyInputRules", { 8025 from: f, 8026 text: m 8027 }), t.applyPasteRules && r.setMeta("applyPasteRules", { 8028 from: f, 8029 text: m 8030 }); 8031 } 8032 return !0; 8033 }; 8034 function kl(n) { 8035 for(let e = 0; e < n.edgeCount; e += 1){ 8036 const { type: t } = n.edge(e); 8037 if (t.isTextblock && !t.hasRequiredAttrs()) return t; 8038 } 8039 return null; 8040 } 8041 const Ju = (n = {})=>({ tr: e, dispatch: t, editor: r })=>{ 8042 const { pos: i, attrs: o, content: s, updateSelection: l = !0 } = n; 8043 let a; 8044 typeof i == "number" ? a = e.doc.resolve(i) : i ? a = i : a = e.selection.$from; 8045 const c = kl(a.parent.contentMatchAt(a.index())); 8046 if (!c) return !1; 8047 const f = Object.keys(c.spec.attrs || {}), u = o ? Object.fromEntries(Object.entries(o).filter(([h])=>f.includes(h))) : {}; 8048 let d; 8049 if (s) { 8050 const h = ut(s, r.schema); 8051 d = c.createAndFill(u, h); 8052 } else d = c.createAndFill(u); 8053 return d ? (t && (e.insert(a.pos, d), l && yl(e, e.steps.length - 1, -1)), !0) : !1; 8054 }, qu = ()=>({ state: n, dispatch: e })=>dc(n, e), Ku = ()=>({ state: n, dispatch: e })=>hc(n, e), Hu = ()=>({ state: n, dispatch: e })=>gs(n, e), _u = ()=>({ state: n, dispatch: e })=>xs(n, e), Uu = ()=>({ state: n, dispatch: e, tr: t })=>{ 8055 try { 8056 const r = Dn(n.doc, n.selection.$from.pos, -1); 8057 return r == null ? !1 : (t.join(r, 2), e && e(t), !0); 8058 } catch { 8059 return !1; 8060 } 8061 }, Yu = ()=>({ state: n, dispatch: e, tr: t })=>{ 8062 try { 8063 const r = Dn(n.doc, n.selection.$from.pos, 1); 8064 return r == null ? !1 : (t.join(r, 2), e && e(t), !0); 8065 } catch { 8066 return !1; 8067 } 8068 }, Gu = ()=>({ state: n, dispatch: e })=>fc(n, e), Xu = ()=>({ state: n, dispatch: e })=>uc(n, e); 8069 function bl() { 8070 return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1; 8071 } 8072 function Qu(n) { 8073 const e = n.split(/-(?!$)/); 8074 let t = e[e.length - 1]; 8075 t === "Space" && (t = " "); 8076 let r, i, o, s; 8077 for(let l = 0; l < e.length - 1; l += 1){ 8078 const a = e[l]; 8079 if (/^(cmd|meta|m)$/i.test(a)) s = !0; 8080 else if (/^a(lt)?$/i.test(a)) r = !0; 8081 else if (/^(c|ctrl|control)$/i.test(a)) i = !0; 8082 else if (/^s(hift)?$/i.test(a)) o = !0; 8083 else if (/^mod$/i.test(a)) xn() || bl() ? s = !0 : i = !0; 8084 else throw new Error(`Unrecognized modifier name: ${a}`); 8085 } 8086 return r && (t = `Alt-${t}`), i && (t = `Ctrl-${t}`), s && (t = `Meta-${t}`), o && (t = `Shift-${t}`), t; 8087 } 8088 const Zu = (n)=>({ editor: e, view: t, tr: r, dispatch: i })=>{ 8089 const o = Qu(n).split(/-(?!$)/), s = o.find((c)=>![ 8090 "Alt", 8091 "Ctrl", 8092 "Meta", 8093 "Shift" 8094 ].includes(c)), l = new KeyboardEvent("keydown", { 8095 key: s === "Space" ? " " : s, 8096 altKey: o.includes("Alt"), 8097 ctrlKey: o.includes("Ctrl"), 8098 metaKey: o.includes("Meta"),
8099 shiftKey: o.includes("Shift"), 8100 bubbles: !0, 8101 cancelable: !0 8102 }), a = e.captureTransaction(()=>{ 8103 t.someProp("handleKeyDown", (c)=>c(t, l)); 8104 }); 8105 return a?.steps.forEach((c)=>{ 8106 const f = c.map(r.mapping); 8107 f && i && r.maybeStep(f); 8108 }), !0; 8109 }; 8110 function zt(n, e, t = {}) { 8111 const { from: r, to: i, empty: o } = n.selection, s = e ? V(e, n.schema) : null, l = []; 8112 n.doc.nodesBetween(r, i, (f, u)=>{ 8113 if (f.isText) return; 8114 const d = Math.max(r, u), h = Math.min(i, u + f.nodeSize); 8115 l.push({ 8116 node: f, 8117 from: d, 8118 to: h 8119 }); 8120 }); 8121 const a = i - r, c = l.filter((f)=>s ? s.name === f.node.type.name : !0).filter((f)=>bn(f.node.attrs, t, { 8122 strict: !1 8123 })); 8124 return o ? !!c.length : c.reduce((f, u)=>f + u.to - u.from, 0) >= a; 8125 } 8126 const ed = (n, e = {})=>({ state: t, dispatch: r })=>zt(t, V(n, t.schema), e) ? pc(t, r) : !1, td = ()=>({ state: n, dispatch: e })=>Cs(n, e), nd = (n)=>({ state: e, dispatch: t })=>{ 8127 const r = V(n, e.schema); 8128 return vc(r)(e, t); 8129 }, rd = ()=>({ state: n, dispatch: e })=>ws(n, e); 8130 function zn(n, e) { 8131 return e.nodes[n] ? "node" : e.marks[n] ? "mark" : null; 8132 } 8133 function so(n, e) { 8134 const t = typeof e == "string" ? [ 8135 e 8136 ] : e; 8137 return Object.keys(n).reduce((r, i)=>(t.includes(i) || (r[i] = n[i]), r), {}); 8138 } 8139 const id = (n, e)=>({ tr: t, state: r, dispatch: i })=>{ 8140 let o = null, s = null; 8141 const l = zn(typeof n == "string" ? n : n.name, r.sc
8141hema); 8142 if (!l) return !1; 8143 l === "node" && (o = V(n, r.schema)), l === "mark" && (s = Se(n, r.schema)); 8144 let a = !1; 8145 return t.selection.ranges.forEach((c)=>{ 8146 r.doc.nodesBetween(c.$from.pos, c.$to.pos, (f, u)=>{ 8147 o && o === f.type && (a = !0, i && t.setNodeMarkup(u, void 0, so(f.attrs, e))), s && f.marks.length && f.marks.forEach((d)=>{ 8148 s === d.type && (a = !0, i && t.addMark(u, u + f.nodeSize, s.create(so(d.attrs, e)))); 8149 }); 8150 }); 8151 }), a; 8152 }, od = ()=>({ tr: n, dispatch: e })=>(e && n.scrollIntoView(), !0), sd = ()=>({ tr: n, dispatch: e })=>{ 8153 if (e) { 8154 const t = new ee(n.doc); 8155 n.setSelection(t); 8156 } 8157 return !0; 8158 }, ld = ()=>({ state: n, dispatch: e })=>ks(n, e), ad = ()=>({ state: n, dispatch: e })=>Ss(n, e), cd = ()=>({ state: n, dispatch: e })=>kc(n, e), fd = ()=>({ state: n, dispatch: e })=>Sc(n, e), ud = ()=>({ state: n, dispatch: e })=>xc(n, e); 8159 function vr(n, e, t = {}, r = {}) { 8160 return ut(n, e, { 8161 slice: !1, 8162 parseOptions: t, 8163 errorOnInvalidContent: r.errorOnInvalidContent 8164 }); 8165 } 8166 const dd = (n, { errorOnInvalidContent: e, emitUpdate: t = !0, parseOptions: r = {} } = {})=>({ editor: i, tr: o, dispatch: s, commands: l })=>{ 8167 const { doc: a } = o; 8168 if (r.preserveWhitespace !== "full") { 8169 const c = vr(n, i.schema, r, { 8170 errorOnInvalidContent: e ?? i.options.enableContentCheck 8171 }); 8172 if (s) { 8173 const f = gl(c) ? c.content : [ 8174 c 8175 ]; 8176 o.replaceWith(0, a.content.size, f).setMeta("preventUpdate", !t); 8177 } 8178 return !0; 8179 } 8180 return s && o.setMeta("preventUpdate", !t), l.insertContentAt({ 8181 from: 0, 8182 to: a.content.size 8183 }, n, { 8184 parseOptions: r, 8185 errorOnInvalidContent: e ?? i.options.enableContentCheck 8186 }); 8187 }; 8188 function xl(n, e) { 8189 const t = Se(e, n.schema), { from: r, to: i, empty: o } = n.selection, s = []; 8190 o ? (n.storedMarks && s.push(...n.storedMarks), s.push(...n.selection.$head.marks())) : n.doc.nodesBetween(r, i, (a)=>{ 8191 s.push(...a.marks); 8192 }); 8193 const l = s.find((a)=>a.type.name === t.name); 8194 return l ? { 8195 ...l.attrs 8196 } : {}; 8197 } 8198 function hd(n, e) { 8199 const t = new us(n); 8200 return e.forEach((r)=>{ 8201 r.steps.forEach((i)=>{ 8202 t.step(i); 8203 }); 8204 }), t; 8205 } 8206 function pd(n, e) { 8207 for(let t = n.depth; t > 0; t -= 1){ 8208 const r = n.node(t); 8209 if (e(r)) return { 8210 pos: t > 0 ? n.before(t) : 0, 8211 start: n.start(t), 8212 depth: t, 8213 node: r 8214 }; 8215 } 8216 } 8217 function Jt(n) { 8218 return (e)=>pd(e.$from, n); 8219 } 8220 function S(n, e, t) { 8221 return n.config[e] === void 0 && n.parent ? S(n.parent, e, t) : typeof n.config[e] == "function" ? n.config[e].bind({ 8222 ...t, 8223 parent: n.parent ? S(n.parent, e, t) : null 8224 }) : n.config[e]; 8225 } 8226 function Ur(n) { 8227 return n.map((e)=>{ 8228 const t = S(e, "addExtensions", { 8229 name: e.name, 8230 options: e.options, 8231 storage: e.storage 8232 }); 8233 return t ? [ 8234 e, 8235 ...Ur(t()) 8236 ] : e; 8237 }).flat(10); 8238 } 8239 function Yr(n, e) { 8240 const t = Ge.fromSchema(e).serializeFragment(n), r = document.implementation.createHTMLDocument().createElement("div"); 8241 return r.appendChild(t), r.innerHTML; 8242 } 8243 function Sl(n) { 8244 return typeof n == "function"; 8245 } 8246 function R(n, e = void 0, ...t) { 8247 return Sl(n) ? e ? n.bind(e)(...t) : n(...t) : n; 8248 } 8249 function md(n = {}) { 8250 return Object.keys(n).length === 0 && n.constructor === Object; 8251 } 8252 function dt(n) { 8253 return { 8254 baseExtensions: n.filter((e)=>
8254e.type === "extension"), 8255 nodeExtensions: n.filter((e)=>e.type === "node"), 8256 markExtensions: n.filter((e)=>e.type === "mark") 8257 }; 8258 } 8259 function wl(n) { 8260 const e = [], { nodeExtensions: t, markExtensions: r } = dt(n), i = [ 8261 ...t, 8262 ...r 8263 ], o = { 8264 default: null, 8265 validate: void 0, 8266 rendered: !0, 8267 renderHTML: null, 8268 parseHTML: null, 8269 keepOnSplit: !0, 8270 isRequired: !1 8271 }, s = t.filter((c)=>c.name !== "text").map((c)=>c.name), l = r.map((c)=>c.name), a = [ 8272 ...s, 8273 ...l 8274 ]; 8275 return n.forEach((c)=>{ 8276 const f = S(c, "addGlobalAttributes", { 8277 name: c.name, 8278 options: c.options, 8279 storage: c.storage, 8280 extensions: i 8281 }); 8282 f && f().forEach((u)=>{ 8283 let d; 8284 Array.isArray(u.types) ? d = u.types : u.types === "*" ? d = a : u.types === "nodes" ? d = s : u.types === "marks" ? d = l : d = [], d.forEach((h)=>{ 8285 Object.entries(u.attributes).forEach(([p, m])=>{ 8286 e.push({ 8287 type: h, 8288 name: p, 8289 attribute: { 8290 ...o, 8291 ...m 8292 } 8293 }); 8294 }); 8295 }); 8296 }); 8297 }), i.forEach((c)=>{ 8298 const f = S(c, "addAttributes", { 8299 name: c.name, 8300 options: c.options, 8301 storage: c.storage 8302 }); 8303 if (!f) return; 8304 const u = f(); 8305 Object.entries(u).forEach(([d, h])=>{ 8306 const p = { 8307 ...o, 8308 ...h 8309 }; 8310 typeof p?.default == "function" && (p.default = p.default()), p?.isRequired && p?.default === void 0 && delete p.default, e.push({ 8311 type: c.name, 8312 name: d, 8313 attribute: p 8314 }); 8315 }); 8316 }), e; 8317 } 8318 function gd(n) { 8319 const e = []; 8320 let t = "", r = !1, i = !1, o = 0; 8321 const s = n.length; 8322 for(let l = 0; l < s; l += 1){ 8323 const a = n[l]; 8324 if (a === "'" && !i) { 8325 r = !r, t += a; 8326 continue; 8327 } 8328 if (a === '"' && !r) { 8329 i = !i, t += a; 8330 continue; 8331 } 8332 if (!r && !i) { 8333 if (a === "(") { 8334 o += 1, t += a; 8335 continue; 8336 } 8337 if (a === ")" && o > 0) { 8338 o -= 1, t += a; 8339 continue; 8340 } 8341 if (a === ";" && o === 0) { 8342 e.push(t), t = ""; 8343 continue; 8344 } 8345 } 8346 t += a; 8347 } 8348 return t && e.push(t), e; 8349 } 8350 function lo(n) { 8351 const e = [], t = gd(n || ""), r = t.length; 8352 for(let i = 0; i < r; i += 1){ 8353 const o = t[i], s = o.indexOf(":"); 8354 if (s === -1) continue; 8355 const l = o.slice(0, s).trim(), a = o.slice(s + 1).trim(); 8356 l && a && e.push([ 8357 l, 8358 a 8359 ]); 8360 } 8361 return e; 8362 } 8363 function yd(...n) { 8364 return n.filter((e)=>!!e).reduce((e, t)=>{ 8365 const r = { 8366 ...e 8367 }; 8368 return Object.entries(t).forEach(([i, o])=>{ 8369 if (i === "__proto__") { 8370 Object.defineProperty(r, i, { 8371 configurable: !0, 8372 enumerable: !0, 8373 value: o, 8374 writable: !0 8375 }); 8376 return; 8377 } 8378 if (!r[i]) { 8379 r[i] = o; 8380 return; 8381 } 8382 if (i === "class") { 8383 const s = o ? String(o).split(" ") : [], l = r[i] ? r[i].split(" ") : [], a = s.filter((c)=>!l.includes(c)); 8384 r[i] = [ 8385 ...l, 8386 ...a 8387 ].join(" "); 8388 } else if (i === "style") { 8389 const s = new Map([ 8390 ...lo(r[i]), 8391 ...lo(o) 8392 ]); 8393 r[i] = Array.from(s.entries()).map(([l, a])=>`${l}: ${a}`).join("; "); 8394 } else r[i] = o; 8395 }), r; 8396 }, {}); 8397 } 8398 function Sn(n, e) { 8399 return e.filter((t)=>t.type === n.type.name).filter((t)=>t.attribute.rendered).map((t)=>t.attribute.renderHTML ? t.attribute.renderHTML(n.attrs) || {} : { 8400 [t.name]: n.attrs[t.name] 8401 }).reduce((t, r)=>yd(t, r), {}); 8402 } 8403 function kd(n) { 8404 return typeof n != "string" ? n : n.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(n) : n === "true" ? !0 : n === "fal
8404se" ? !1 : n; 8405 } 8406 function ao(n, e) { 8407 return "style" in n ? n : { 8408 ...n, 8409 getAttrs: (t)=>{ 8410 const r = n.getAttrs ? n.getAttrs(t) : n.attrs; 8411 if (r === !1) return !1; 8412 const i = e.reduce((o, s)=>{ 8413 const l = s.attribute.parseHTML ? s.attribute.parseHTML(t) : kd(t.getAttribute(s.name)); 8414 return l == null ? o : { 8415 ...o, 8416 [s.name]: l 8417 }; 8418 }, {}); 8419 return { 8420 ...r, 8421 ...i 8422 }; 8423 } 8424 }; 8425 } 8426 function co(n) { 8427 return Object.fromEntries(Object.entries(n).filter(([e, t])=>e === "attrs" && md(t) ? !1 : t != null)); 8428 } 8429 function fo(n) { 8430 var e, t; 8431 const r = {}; 8432 return !(!(n == null || (e = n.attribute) === null || e === void 0) && e.isRequired) && "default" in (n?.attribute || {}) && (r.default = n.attribute.default), (n == null || (t = n.attribute) === null || t === void 0 ? void 0 : t.validate) !== void 0 && (r.validate = n.attribute.validate), [ 8433 n.name, 8434 r 8435 ]; 8436 } 8437 function Ml(n, e) { 8438 var t; 8439 const r = wl(n), { nodeExtensions: i, markExtensions: o } = dt(n), s = (t = i.find((c)=>S(c, "topNode"))) === null || t === void 0 ? void 0 : t.name, l = Object.fromEntries(i.map((c)=>{ 8440 const f = r.filter((g)=>g.type === c.name), u = { 8441 name: c.name, 8442 options: c.options, 8443 storage: c.storage, 8444 editor: e 8445 }, d = co({ 8446 ...n.reduce((g, y)=>{ 8447 const x = S(y, "extendNodeSchema", u); 8448 return { 8449 ...g, 8450 ...x ? x(c) : {} 8451 }; 8452 }, {}), 8453 content: R(S(c, "content", u)), 8454 marks: R(S(c, "marks", u)), 8455 group: R(S(c, "group", u)), 8456 inline: R(S(c, "inline", u)), 8457 atom: R(S(c, "atom", u)), 8458 selectable: R(S(c, "selectable", u)), 8459 draggable: R(S(c, "draggable", u)), 8460 code: R(S(c, "code", u)), 8461 whitespace: R(S(c, "whitespace", u)), 8462 linebreakReplacement: R(S(c, "linebreakReplacement", u)), 8463 defining: R(S(c, "defining", u)), 8464 isolating: R(S(c, "isolating", u)), 8465 attrs: Object.fromEntries(f.map(fo)) 8466 }), h = R(S(c, "parseHTML", u)); 8467 h && (d.parseDOM = h.map((g)=>ao(g, f))); 8468 const p = S(c, "renderHTML", u); 8469 p && (d.toDOM = (g)=>p({ 8470 node: g, 8471 HTMLAttributes: Sn(g, f) 8472 })); 8473 const m = S(c, "renderText", u); 8474 return m && (d.toText = m), [ 8475 c.name, 8476 d 8477 ]; 8478 })), a = Object.fromEntries(o.map((c)=>{ 8479 const f = r.filter((m)=>m.type === c.name), u = { 8480 name: c.name, 8481 options: c.options, 8482 storage: c.storage, 8483 editor: e 8484 }, d = co({ 8485 ...n.reduce((m, g)=>{ 8486 const y = S(g, "extendMarkSchema", u); 8487 return { 8488 ...m, 8489 ...y ? y(c) : {} 8490 }; 8491 }, {}), 8492 inclusive: R(S(c, "inclusive", u)), 8493 excludes: R(S(c, "excludes", u)), 8494 group: R(S(c, "group", u)), 8495 spanning: R(S(c, "spanning", u)), 8496 code: R(S(c, "code", u)), 8497 attrs: Object.fromEntries(f.map(fo)) 8498 }), h = R(S(c, "parseHTML", u)); 8499 h && (d.parseDOM = h.map((m)=>ao(m, f))); 8500 const p = S(c, "renderHTML", u); 8501 return p && (d.toDOM = (m)=>p({ 8502 mark: m, 8503 HTMLAttributes: Sn(m, f) 8504 })), [ 8505 c.name, 8506 d 8507 ]; 8508 })); 8509 return new Dr({ 8510 topNode: s, 8511 nodes: l, 8512 marks: a 8513 }); 8514 } 8515 function bd(n) { 8516 const e = n.filter((t, r)=>n.indexOf(t) !== r); 8517 return Array.from(new Set(e)); 8518 } 8519 function vt(n) { 8520 return n.sort((t, r)=>{ 8521 const i = S(t, "priority") || 100, o = S(r, "priority") || 100; 8522 return i > o ? -1 : i < o ? 1 : 0; 8523 }); 8524 } 8525 function Gr(n) { 8526 const e = vt(Ur(n)), t = bd(e.map((r)=>r.name)); 8527 return t.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map((r)=>`'${r}'`).join(", ")}]. This can lead to issues.`), e; 8528 } 8529 qp = function(n, e) { 8530 return Ml(Gr(n), e); 8531 }; 8532 function Cl(n, e, t) { 8533 const { from: r, to: i } = e, { blockSeparator: o = ` 8534
8535`, textSerializers: s = {} } = t || {}; 8536 let l = ""; 8537 return n.nodesBetween(r, i, (a, c, f, u)=>{ 8538 a.isBlock && c > r && (l += o); 8539 const d = s?.[a.type.name]; 8540 if (d) return f && (l += d({ 8541 node: a, 8542 pos: c, 8543 parent: f, 8544 index: u, 8545 range: e 8546 })), !1; 8547 if (a.isText) { 8548 var h; 8549 l += a == null || (h = a.text) === null || h === void 0 ? void 0 : h.slice(Math.max(r, c) - c, i - c); 8550 } 8551 }), l; 8552 } 8553 function xd(n, e) { 8554 return Cl(n, { 8555 from: 0, 8556 to: n.content.size 8557 }, e); 8558 } 8559 function Tl(n) { 8560 return Object.fromEntries(Object.entries(n.nodes).filter(([, e])=>e.spec.toText).map(([e, t])=>[ 8561 e, 8562 t.spec.toText 8563 ])); 8564 } 8565 function Sd(n, e) { 8566 const t = V(e, n.schema), { from: r, to: i } = n.selection, o = []; 8567 n.doc.nodesBetween(r, i, (l)=>{ 8568 o.push(l); 8569 }); 8570 const s = o.reverse().find((l)=>l.type.name === t.name); 8571 return s ? { 8572 ...s.attrs 8573 } : {}; 8574 } 8575 function wd(n, e) { 8576 const t = zn(typeof e == "string" ? e : e.name, n.schema); 8577 return t === "node" ? Sd(n, e) : t === "mark" ? xl(n, e) : {}; 8578 } 8579 function Md(n, e = JSON.stringify) { 8580 const t = {}; 8581 return n.filter((r)=>{ 8582 const i = e(r); 8583 return Object.prototype.hasOwnProperty.call(t, i) ? !1 : t[i] = !0; 8584 }); 8585 } 8586 function Cd(n) { 8587 const e = Md(n); 8588 return e.length === 1 ? e : e.filter((t, r)=>!e.filter((i, o)=>o !== r).some((i)=>t.oldRange.from >= i.oldRange.from && t.oldRange.to <= i.oldRange.to && t.newRange.from >= i.newRange.from && t.newRange.to <= i.newRange.to)); 8589 } 8590 function vl(n) { 8591 const { mapping: e, steps: t } = n, r = []; 8592 return e.maps.forEach((i, o)=>{ 8593 const s = []; 8594 if (i.ranges.length) i.forEach((l, a)=>{ 8595 s.push({ 8596 from: l, 8597 to: a 8598 }); 8599 }); 8600 else { 8601 const { from: l, to: a } = t[o]; 8602 if (l === void 0 || a === void 0) return; 8603 s.push({ 8604 from: l, 8605 to: a 8606 }); 8607 } 8608 s.forEach(({ from: l, to: a })=>{ 8609 const c = e.slice(o).map(l, -1), f = e.slice(o).map(a), u = e.invert().map(c, -1), d = e.invert().map(f); 8610 r.push({ 8611 oldRange: { 8612 from: u, 8613 to: d 8614 }, 8615 newRange: { 8616 from: c, 8617 to: f 8618 } 8619 }); 8620 }); 8621 }), Cd(r); 8622 } 8623 function et(n, e) { 8624 return e.nodes[n] || e.marks[n] || null; 8625 } 8626 function on(n, e, t) { 8627 return Object.fromEntries(Object.entries(t).filter(([r])=>{ 8628 const i = n.find((o)=>o.type === e && o.name === r); 8629 return i ? i.attribute.keepOnSplit : !1; 8630 })); 8631 } 8632 const Td = (n, e = 500)=>{ 8633 let t = ""; 8634 const r = n.parentOffset; 8635 return n.parent.nodesBetween(Math.max(0, r - e), r, (i, o, s, l)=>{ 8636 var a, c; 8637 const f = ((a = (c = i.type.spec).toText) === null || a === void 0 ? void 0 : a.call(c, { 8638 node: i, 8639 pos: o, 8640 parent: s, 8641 index: l 8642 })) || i.textContent || "%leaf%"; 8643 t += i.isAtom && !i.isText ? f : f.slice(0, Math.max(0, r - o)); 8644 }), t; 8645 }; 8646 function Or(n, e, t = {}) { 8647 const { empty: r, ranges: i } = n.selection, o = e ? Se(e, n.schema) : null; 8648 if (r) return !!(n.storedMarks || n.selection.$from.marks()).filter((f)=>o ? o.name === f.type.name : !0).find((f)=>bn(f.attrs, t, { 8649 strict: !1 8650 })); 8651 let s = 0; 8652 const l = []; 8653 if (i.forEach(({ $from: f, $to: u })=>{ 8654 const d = f.pos, h = u.pos; 8655 n.doc.nodesBetween(d, h, (p, m)=>{
8656 if (o && p.inlineContent && !p.type.allowsMarkType(o)) return !1; 8657 if (!p.isText && !p.marks.length) return; 8658 const g = Math.max(d, m), y = Math.min(h, m + p.nodeSize), x = y - g; 8659 s += x, l.push(...p.marks.map((M)=>({ 8660 mark: M, 8661 from: g, 8662 to: y 8663 }))); 8664 }); 8665 }), s === 0) return !1; 8666 const a = l.filter((f)=>o ? o.name === f.mark.type.name : !0).filter((f)=>bn(f.mark.attrs, t, { 8667 strict: !1 8668 })).reduce((f, u)=>f + u.to - u.from, 0), c = l.filter((f)=>o ? f.mark.type !== o && f.mark.type.excludes(o) : !0).reduce((f, u)=>f + u.to - u.from, 0); 8669 return (a > 0 ? a + c : a) >= s; 8670 } 8671 function vd(n, e, t = {}) { 8672 if (!e) return zt(n, null, t) || Or(n, null, t); 8673 const r = zn(e, n.schema); 8674 return r === "node" ? zt(n, e, t) : r === "mark" ? Or(n, e, t) : !1; 8675 } 8676 function uo(n, e) { 8677 return Array.isArray(e) ? e.some((t)=>(typeof t == "string" ? t : t.name) === n.name) : e; 8678 } 8679 function er(n, e) { 8680 const { nodeExtensions: t } = dt(e), r = t.find((o)=>o.name === n); 8681 if (!r) return !1; 8682 const i = R(S(r, "group", { 8683 name: r.name, 8684 options: r.options, 8685 storage: r.storage 8686 })); 8687 return typeof i != "string" ? !1 : i.split(" ").includes("list"); 8688 } 8689 function Xr(n, { checkChildren: e = !0, ignoreWhitespace: t = !1 } = {}) { 8690 if (t) { 8691 if (n.type.name === "hardBreak") return !0; 8692 if (n.isText) { 8693 var r; 8694 return !/\S/.test((r = n.text) !== null && r !== void 0 ? r : ""); 8695 } 8696 } 8697 if (n.isText) return !n.text; 8698 if (n.isAtom || n.isLeaf) return !1; 8699 if (n.content.childCount === 0) return !0; 8700 if (e) { 8701 let i = !0; 8702 return n.content.forEach((o)=>{ 8703 i !== !1 && (Xr(o, { 8704 ignoreWhitespace: t, 8705 checkChildren: e 8706 }) || (i = !1)); 8707 }), i; 8708 } 8709 return !1; 8710 } 8711 var Ol = class Nl { 8712 constructor(e){ 8713 this.position = e; 8714 } 8715 static fromJSON(e) { 8716 return new Nl(e.position); 8717 } 8718 toJSON() { 8719 return { 8720 position: this.position 8721 }; 8722 } 8723 }; 8724 function Od(n, e) { 8725 const t = e.mapping.mapResult(n.position); 8726 return { 8727 position: new Ol(t.pos), 8728 mapResult: t 8729 }; 8730 } 8731 function Nd(n) { 8732 return new Ol(n); 8733 } 8734 function Ed(n, e, t) { 8735 const { selection: r } = e; 8736 let i = null; 8737 if (hl(r) && (i = r.$cursor), i) { 8738 var o; 8739 const l = (o = n.storedMarks) !== null && o !== void 0 ? o : i.marks(); 8740 return i.parent.type.allowsMarkType(t) && (!!t.isInSet(l) || !l.some((a)=>a.type.excludes(t))); 8741 } 8742 const { ranges: s } = r; 8743 return s.some(({ $from: l, $to: a })=>{ 8744 let c = l.depth === 0 ? n.doc.inlineContent && n.doc.type.allowsMarkType(t) : !1; 8745 return n.doc.nodesBetween(l.pos, a.pos, (f, u, d)=>{ 8746 if (c) return !1; 8747 if (f.isInline) { 8748 const h = !d || d.type.allowsMarkType(t), p = !!t.isInSet(f.marks) || !f.marks.some((m)=>m.type.excludes(t)); 8749 c = h && p; 8750 } 8751 return !c; 8752 }), c; 8753 }); 8754 } 8755 const Dd = (n, e = {})=>({ tr: t, state: r, dispatch: i })=>{ 8756 const { selection: o } = t, { empty: s, ranges: l } = o, a = Se(n, r.schema); 8757 if (i) if (s) { 8758 const c = xl(r, a); 8759 t.addStoredMark(a.create({ 8760 ...c, 8761 ...e 8762 })); 8763 } else l.forEach((c)=>{ 8764 const f = c.$from.pos, u = c.$to.pos; 8765 r.doc.nodesBetween(f, u, (d, h)=>{ 8766 const p = Math.max(h, f), m = Math.min(h + d.nodeSize, u); 8767 d.marks.find((g)=>g.type === a) ? d.marks.forEach((g)=>{ 8768 a === g.type && t.addMark(p, m, a.create({ 8769 ...g.attrs, 8770 ...e 8771 })); 8772 }) : t.addMark(p, m, a.create(e)); 8773 }); 8774 }); 8775 return Ed(r, t, a); 8776 }, Ad = (n, e)=>({ tr: t })=>(t.setMeta(n, e), !0), Id = (n, e = {})=>({ state: t, dispatch: r, chain: i })=>{ 8777 const o = V(n, t.schema); 8778 let s; 8779 return t.selection.$anchor.sameParent(t.selection.$head) && (s = t.selection.$anchor.parent.attrs), o.isTextblock ? i().command(({ commands: l })=>vi(o, { 8780 ...s, 8781 ...e 8782 })(t) ? !0 : l.clearNodes()).command(({ state: l })=>vi(o, { 8783 ...s, 8784 ...e 8785 })(l, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1); 8786 }, Rd = (n)=>({ tr: e, dispatch: t })=>{ 8787 if (t) { 8788 const { doc: r } = e, i = Ve(n, 0, r.content.size), o = T.create(r, i); 8789 e.setSelection(o); 8790 } 8791 return !0; 8792 }, Bd = (n, e)=>({ tr: t, state: r, dispatch: i })=>{ 8793 const { selection: o } = r; 8794 let s, l; 8795 return typeof e == "number" ? (s = e, l = e) : e && "from" in e && "to" in e ? (s = e.from, l = e.to) : (s = o.from, l = o.to), i && t.doc.nodesBetween(s, l, (a, c)=>{ 8796 a.isText || t.setNodeMarkup(c, void 0, { 8797 ...a.attrs, 8798 dir: n 8799 }); 8800 }), !0; 8801 }, Pd = (n)=>({ tr: e, dispatch: t })=>{ 8802 if (t) { 8803 const { doc: r } = e, { from: i, to: o } = typeof n == "number" ? { 8804 from: n, 8805 to: n 8806 } : n, s = v.atStart(r).from, l = v.atEnd(r).to, a = Ve(i, s, l), c = Ve(o, s, l), f = v.create(r, a, c); 8807 e.setSelection(f); 8808 } 8809 return !0; 8810 }, zd = (n)=>({ state: e, dispatch: t })=>{ 8811 const r = V(n, e.schema); 8812 return Ec(r)(e, t); 8813 }; 8814 function ho(n, e) { 8815 const t = n.storedMarks || n.selection.$to.parentOffset && n.selection.$from.marks(); 8816 if (t) { 8817 const r = t.filter((i)=>e?.includes(i.type.name)); 8818 n.tr.ensureMarks(r); 8819 } 8820 } 8821 const Fd = ({ keepMarks: n = !0 } = {})=>({ tr: e, state: t, dispatch: r, editor: i })=>{ 8822 const { selection: o, doc: s } = e, { $from: l, $to: a } = o, c = i.extensionManager.attributes, f = on(c, l.node().type.name, l.node().attrs); 8823 if (o instanceof T && o.node.isBlock) return !l.parentOffset || !be(s, l.pos) ? !1 : (r && (n && ho(t, i.extensionManager.splittableMarks), e.split(l.pos).scrollIntoView()), !0); 8824 if (!l.parent.isBlock) return !1; 8825 const u = a.parentOffset === a.parent.content.size, d = l.depth === 0 ? void 0 : kl(l.node(-1).contentMatchAt(l.indexAfter(-1))); 8826 let h = u && d ? [ 8827 { 8828 type: d, 8829 attrs: f 8830 } 8831 ] : void 0, p = be(e.doc, e.mapping.map(l.pos), 1, h); 8832 if (!h && !p && be(e.doc, e.mapping.map(l.pos), 1, d ? [ 8833 { 8834 type: d 8835 } 8836 ] : void 0) && (p = !0, h = d ? [ 8837 { 8838 type: d, 8839 attrs: f 8840 } 8841 ] : void 0), r) { 8842 if (p && (o instanceof v && e.deleteSelection(), e.split(e.mapping.map(l.pos), 1, h), d && !u && !l.parentOffset && l.parent.type !== d)) { 8843 const m = e.mapping.map(l.before()), g = e.doc.resolve(m); 8844 l.node(-1).canReplaceWith(g.index(), g.index() + 1, d) && e.setNodeMarkup(e.mapping.map(l.before()), d); 8845 } 8846 n && ho(t, i.extensionManager.splittableMarks), e.scrollIntoView(); 8847 } 8848 return p; 8849 }, Ld = (n, e = {})=>({ tr: t, state: r, dispatch: i, editor: o })=>{ 8850 const s = V(n, r.schema), { $from: l, $to: a } = r.selection, c = r.selection.node; 8851 if (c && c.isBlock || l.depth < 2 || !l.sameParent(a)) return !1; 8852 const f = l.node(-1); 8853 if (f.type !== s) return !1; 8854 const u = o.extensionManager.attributes; 8855 if (l.parent.content.size === 0 && l.node(-1).childCount === l.indexAfter(-1)) { 8856 if (l.depth === 2 || l.node(-3).type !== s || l.index(-2) !== l.node(-2).childCount - 1) return !1; 8857 if (i) { 8858 var d; 8859 let y = k.empty; 8860 const x = l.index(-1) ? 1 : l.index(-2) ? 2 : 3; 8861 for(let E = l.depth - x; E >= l.depth - 3; E -= 1)y = k.from(l.node(E).copy(y)); 8862 const M = l.indexAfter(-1) < l.node(-2).childCount ? 1 : l.indexAfter(-2) < l.node(-3).childCount ? 2 : 3, w = { 8863 ...on(u, l.node().type.name, l.node().attrs), 8864 ...e 8865 }, N = ((d = s.contentMatch.defaultType) === null || d === void 0 ? void 0 : d.
8865createAndFill(w)) || void 0; 8866 y = y.append(k.from(s.createAndFill(null, N) || void 0)); 8867 const O = l.before(l.depth - (x - 1)); 8868 t.replace(O, l.after(-M), new b(y, 4 - x, 0)); 8869 let C = -1; 8870 t.doc.nodesBetween(O, t.doc.content.size, (E, A)=>{ 8871 if (C > -1) return !1; 8872 E.isTextblock && E.content.size === 0 && (C = A + 1); 8873 }), C > -1 && t.setSelection(v.near(t.doc.resolve(C))), t.scrollIntoView(); 8874 } 8875 return !0; 8876 } 8877 const h = a.pos === l.end() ? f.contentMatchAt(0).defaultType : null, p = { 8878 ...on(u, f.type.name, f.attrs), 8879 ...e 8880 }, m = { 8881 ...on(u, l.node().type.name, l.node().attrs), 8882 ...e 8883 }; 8884 t.delete(l.pos, a.pos); 8885 const g = h ? [ 8886 { 8887 type: s, 8888 attrs: p 8889 }, 8890 { 8891 type: h, 8892 attrs: m 8893 } 8894 ] : [ 8895 { 8896 type: s, 8897 attrs: p 8898 } 8899 ]; 8900 if (!be(t.doc, l.pos, 2)) return !1; 8901 if (i) { 8902 const { selection: y, storedMarks: x } = r, { splittableMarks: M } = o.extensionManager, w = x || y.$to.parentOffset && y.$from.marks(); 8903 if (t.split(l.pos, 2, g).scrollIntoView(), !w || !i) return !0; 8904 const N = w.filter((O)=>M.includes(O.type.name)); 8905 t.ensureMarks(N); 8906 } 8907 return !0; 8908 }; 8909 function po(n) { 8910 return !n || n === "1" ? null : n; 8911 } 8912 function El(n, e) { 8913 return po(n) === po(e); 8914 } 8915 const tr = (n, e)=>{ 8916 const t = Jt((o)=>o.type === e)(n.selection); 8917 if (!t) return !0; 8918 const r = n.doc.resolve(Math.max(0, t.pos - 1)).before(t.depth); 8919 if (r === void 0) return !0; 8920 const i = n.doc.nodeAt(r); 8921 return !(t.node.type === i?.type && Xe(n.doc, t.pos)) || !El(t.node.attrs.type, i?.attrs.type) || n.join(t.pos), !0; 8922 }, nr = (n, e)=>{ 8923 const t = Jt((o)=>o.type === e)(n.selection); 8924 if (!t) return !0; 8925 const r = n.doc.resolve(t.start).after(t.depth); 8926 if (r === void 0) return !0; 8927 const i = n.doc.nodeAt(r); 8928 return !(t.node.type === i?.type && Xe(n.doc, r)) || !El(t.node.attrs.type, i?.attrs.type) || n.join(r), !0; 8929 }; 8930 function Vd(n) { 8931 const e = n.doc, t = e.firstChild; 8932 if (!t) return null; 8933 const r = e.resolve(1), i = e.resolve(t.nodeSize - 1); 8934 return v.between(r, i); 8935 } 8936 const $d = (n, e, t, r = {})=>({ editor: i, tr: o, state: s, dispatch: l, chain: a, commands: c, c
8936an: f })=>{ 8937 const { extensions: u, splittableMarks: d } = i.extensionManager, h = V(n, s.schema), p = V(e, s.schema), { selection: m, storedMarks: g } = s, { $from: y, $to: x } = m, M = y.blockRange(x), w = g || m.$to.parentOffset && m.$from.marks(); 8938 if (!M) return !1; 8939 const N = Jt((Be)=>er(Be.type.name, u))(m), O = m.from === 0 && m.to === s.doc.content.size, C = s.doc.content.content, E = C.length === 1 ? C[0] : null, A = O && E && er(E.type.name, u) ? { 8940 node: E, 8941 pos: 0 8942 } : null, _ = N ?? A, Re = !!N && M.depth >= 1 && M.depth - N.depth <= 1, qt = !!A; 8943 if ((Re || qt) && _) { 8944 if (_.node.type === h) return O && qt ? a().command(({ tr: Be, dispatch: Kt })=>{ 8945 const Ht = Vd(Be); 8946 return Ht ? (Be.setSelection(Ht), Kt && Kt(Be), !0) : !1; 8947 }).liftListItem(p).run() : c.liftListItem(p); 8948 if (er(_.node.type.name, u) && h.validContent(_.node.content)) return a().command(()=>(o.setNodeMarkup(_.pos, h), !0)).command(()=>tr(o, h)).command(()=>nr(o, h)).run(); 8949 } 8950 return !t || !w || !l ? a().command(()=>f().wrapInList(h, r) ? !0 : c.clearNodes()).wrapInList(h, r).command(()=>tr(o, h)).command(()=>nr(o, h)).run() : a().command(()=>{ 8951 const Be = f().wrapInList(h, r), Kt = w.filter((Ht)=>
8951d.includes(Ht.type.name)); 8952 return o.ensureMarks(Kt), Be ? !0 : c.clearNodes(); 8953 }).wrapInList(h, r).command(()=>tr(o, h)).command(()=>nr(o, h)).run(); 8954 }, jd = (n, e = {}, t = {})=>({ state: r, commands: i })=>{ 8955 const { extendEmptyMarkRange: o = !1 } = t, s = Se(n, r.schema); 8956 return Or(r, s, e) ? i.unsetMark(s, { 8957 extendEmptyMarkRange: o 8958 }) : i.setMark(s, e); 8959 }, Wd = (n, e, t = {})=>({ state: r, commands: i })=>{ 8960 const o = V(n, r.schema), s = V(e, r.schema), l = zt(r, o, t); 8961 let a; 8962 return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), l ? i.setNode(s, a) : i.setNode(o, { 8963 ...a, 8964 ...t 8965 }); 8966 }, Jd = (n, e = {})=>({ state: t, commands: r })=>{ 8967 const i = V(n, t.schema); 8968 return zt(t, i, e) ? r.lift(i) : r.wrapIn(i, e); 8969 }, qd = ()=>({ state: n, dispatch: e })=>{ 8970 const t = n.plugins; 8971 for(let r = 0; r < t.length; r += 1){ 8972 const i = t[r]; 8973 let o; 8974 if (i.spec.isInputRules && (o = i.getState(n))) { 8975 if (e) { 8976 const s = n.tr, l = o.transform; 8977 for(let a = l.steps.length - 1; a >= 0; a -= 1)s.step(l.steps[a].invert(l.docs[a])); 8978 if (o.text) { 8979 const a = s.doc.resolve(o.from).marks(); 8980 s.replaceWith(o.from, o.to, n.schema.text(o.text, a)); 8981 } else s.delete(o.from, o.to); 8982 } 8983 return !0; 8984 } 8985 } 8986 return !1; 8987 }, Kd = (n = {})=>({ tr: e, dispatch: t, editor: r })=>{ 8988 const { ignoreClearable: i = !1 } = n, { selection: o } = e, { empty: s, ranges: l } = o; 8989 if (s) return !0; 8990 const { nonClearableMarks: a } = r.extensionManager; 8991 if (t) { 8992 const c = Object.values(r.schema.marks).filter((f)=>i || !a.includes(f.name)); 8993 l.forEach((f)=>{ 8994 for (const u of c)e.removeMark(f.$from.pos, f.$to.pos, u); 8995 }); 8996 } 8997 return !0; 8998 }, Hd = (n, e = {})=>({ tr: t, state: r, dispatch: i })=>{ 8999 const { extendEmptyMarkRange: o = !1 } = e, { selection: s } = t, l = Se(n, r.schema), { $from: a, empty: c, ranges: f } = s; 9000 if (!i) return !0; 9001 if (c && o) { 9002 var u; 9003 let { from: d, to: h } = s; 9004 const p = dl(a, l, (u = a.marks().find((m)=>m.type === l)) === null || u === void 0 ? void 0 : u.attrs); 9005 p && (d = p.from, h = p.to), t.removeMark(d, h, l); 9006 } else f.forEach((d)=>{ 9007 t.removeMark(d.$from.pos, d.$to.pos, l); 9008 }); 9009 return t.removeStoredMark(l), !0; 9010 }, _d = (n)=>({ tr: e, state: t, dispatch: r })=>{ 9011 const { selection: i } = t; 9012 let o, s; 9013 return typeof n == "number" ? (o = n, s = n) : n && "from" in n && "to" in n ? (o = n.from, s = n.to) : (o = i.from, s = i.to), r && e.doc.nodesBetween(o, s, (l, a)=>{ 9014 if (l.isText) return; 9015 const c = { 9016 ...l.attrs 9017 }; 9018 delete c.dir, e.setNodeMarkup(a, void 0, c); 9019 }), !0; 9020 }, Ud = (n, e = {})=>({ tr: t, state: r, dispatch: i })=>{ 9021 let o = null, s = null; 9022 const l = zn(typeof n == "string" ? n : n.name, r.sc
9022hema); 9023 if (!l) return !1; 9024 l === "node" && (o = V(n, r.schema)), l === "mark" && (s = Se(n, r.schema)); 9025 let a = !1; 9026 return t.selection.ranges.forEach((c)=>{ 9027 const f = c.$from.pos, u = c.$to.pos; 9028 let d, h, p, m; 9029 t.selection.empty ? r.doc.nodesBetween(f, u, (g, y)=>{ 9030 o && o === g.type && (a = !0, p = Math.max(y, f), m = Math.min(y + g.nodeSize, u), d = y, h = g); 9031 }) : r.doc.nodesBetween(f, u, (g, y)=>{ 9032 y < f && o && o === g.type && (a = !0, p = Math.max(y, f), m = Math.min(y + g.nodeSize, u), d = y, h = g), y >= f && y <= u && (o && o === g.type && (a = !0, i && t.setNodeMarkup(y, void 0, { 9033 ...g.attrs, 9034 ...e 9035 })), s && g.marks.length && g.marks.forEach((x)=>{ 9036 if (s === x.type && (a = !0, i)) { 9037 const M = Math.max(y, f), w = Math.min(y + g.nodeSize, u); 9038 t.addMark(M, w, s.create({ 9039 ...x.attrs, 9040 ...e 9041 })); 9042 } 9043 })); 9044 }), h && (d !== void 0 && i && t.setNodeMarkup(d, void 0, { 9045 ...h.attrs, 9046 ...e 9047 }), s && h.marks.length && h.marks.forEach((g)=>{ 9048 s === g.type && i && t.addMark(p, m, s.create({ 9049 ...g.attrs, 9050 ...e 9051 })); 9052 })); 9053 }), a; 9054 }, rt = new de("__tiptap_decorations__"), Yd = (n)=>({ tr: e, dispatch: t })=>(t && e.setMeta(rt, { 9055 type: "force", 9056 name: n 9057 }), !0), Gd = (n, e = {})=>({ state: t, dispatch: r })=>{ 9058 const i = V(n, t.schema); 9059 return wc(i, e)(t, r); 9060 }, Xd = (n, e = {})=>({ state: t, dispatch: r })=>{ 9061 const i = V(n, t.schema); 9062 return Mc(i, e)(t, r); 9063 }; 9064 var Qd = ha({ 9065 blur: ()=>wu, 9066 clearContent: ()=>Mu, 9067 clearNodes: ()=>Cu, 9068 command: ()=>Tu, 9069 createParagraphNear: ()=>vu, 9070 cut: ()=>Ou, 9071 deleteCurrentNode: ()=>Nu, 9072 deleteNode: ()=>Eu, 9073 deleteRange: ()=>Du, 9074 deleteSelection: ()=>Ru, 9075 enter: ()=>Bu, 9076 exitCode: ()=>Pu, 9077 extendMarkRange: ()=>zu, 9078 first: ()=>Fu, 9079 focus: ()=>Vu, 9080 forEach: ()=>$u, 9081 insertContent: ()=>ju, 9082 insertContentAt: ()=>Wu, 9083 insertDefaultBlock: ()=>Ju, 9084 joinBackward: ()=>Hu, 9085 joinDown: ()=>Ku, 9086 joinForward: ()=>_u, 9087 joinItemBackward: ()=>Uu, 9088 joinItemForward: ()=>Yu, 9089 joinTextblockBackward: ()=>Gu, 9090 joinTextblockForward: ()=>Xu, 9091 joinUp: ()=>qu, 9092 keyboardShortcut: ()=>Zu, 9093 lift: ()=>ed, 9094 liftEmptyBlock: ()=>td, 9095 liftListItem: ()=>nd, 9096 newlineInCode: ()=>rd, 9097 resetAttributes: ()=>id, 9098 scrollIntoView: ()=>od, 9099 selectAll: ()=>sd, 9100 selectNodeBackward: ()=>ld, 9101 selectNodeForward: ()=>ad, 9102 selectParentNode: ()=>cd, 9103 selectTextblockEnd: ()=>fd, 9104 selectTextblockStart: ()=>ud, 9105 setContent: ()=>dd, 9106 setMark: ()=>Dd, 9107 setMeta: ()=>Ad, 9108 setNode: ()=>Id, 9109 setNodeSelection: ()=>Rd, 9110 setTextDirection: ()=>Bd, 9111 setTextSelection: ()=>Pd, 9112 sinkListItem: ()=>zd, 9113 splitBlock: ()=>Fd, 9114 splitListItem: ()=>Ld, 9115 toggleList: ()=>$d, 9116 toggleMark: ()=>jd, 9117 toggleNode: ()=>Wd, 9118 toggleWrap: ()=>Jd, 9119 undoInputRule: ()=>qd, 9120 unsetAllMarks: ()=>Kd, 9121 unsetMark: ()=>Hd, 9122 unsetTextDirection: ()=>_d, 9123 updateAttributes: ()=>Ud, 9124 updateDecorations: ()=>Yd, 9125 wrapIn: ()=>Gd, 9126 wrapInList: ()=>Xd 9127 }); 9128 const gt = new WeakMap; 9129 function Zd(n, e) { 9130 var t; 9131 gt.set(n, ((t = gt.get(n)) !== null && t !== void 0 ? t : 0) + 1); 9132 try { 9133 return e(); 9134 } finally{ 9135 var r; 9136 const i = ((r = gt.get(n)) !== null && r !== void 0 ? r : 1)
9136- 1; 9137 i > 0 ? gt.set(n, i) : gt.delete(n); 9138 } 9139 } 9140 var eh = class { 9141 constructor(){ 9142 this.callbacks = {}; 9143 } 9144 on(n, e) { 9145 return this.callbacks[n] || (this.callbacks[n] = []), this.callbacks[n].push(e), this; 9146 } 9147 emit(n, ...e) { 9148 const t = this.callbacks[n]; 9149 return t && t.forEach((r)=>r.apply(this, e)), this; 9150 } 9151 off(n, e) { 9152 const t = this.callbacks[n]; 9153 return t && (e ? this.callbacks[n] = t.filter((r)=>r !== e) : delete this.callbacks[n]), this; 9154 } 9155 once(n, e) { 9156 const t = (...r)=>{ 9157 this.off(n, t), e.apply(this, r); 9158 }; 9159 return this.on(n, t); 9160 } 9161 removeAllListeners() { 9162 this.callbacks = {}; 9163 } 9164 }; 9165 function th(n) { 9166 return n.kind === "widget"; 9167 } 9168 function Dl(n, e) { 9169 const t = [], r = new Set; 9170 for (const i of n)i.kind === "widget" && th(i) && r.add(i.key), t.push(i.toPMDecoration(e)); 9171 return { 9172 decorations: t, 9173 widgetKeys: r 9174 }; 9175 } 9176 function nh(n, e, t) { 9177 const { decorations: r, widgetKeys: i } = Dl(e, t); 9178 return { 9179 set: z.create(n, r), 9180 widgetKeys: i 9181 }; 9182 } 9183 function Al({ position: n, from: e, to: t, docSize: r }) { 9184 return n < e ? !1 : n < t ? !0 : n === t && t === r; 9185 } 9186 function rh({ decorations: n, from: e, to: t, docSize: r, extensionName: i, warnedExtensions: o }) { 9187 return n.filter((s)=>Al({ 9188 position: s.anchor, 9189 from: e, 9190 to: t, 9191 docSize: r 9192 }) ? !0 : (s.anchor === t || o.has(i) || (o.add(i), console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${e}, ${t}). It was ignored.`)), !1)); 9193 } 9194 function ih(n) { 9195 var e; 9196 const t = (e = n.spec) === null || e === void 0 ? void 0 : e.key; 9197 return typeof t == "string" ? t : void 0; 9198 } 9199 function Il(n) { 9200 return n.jsonID === "attr"; 9201 } 9202 function oh(n) { 9203 let e = !1;
9204 if (n.getMap().forEach(()=>{ 9205 e = !0; 9206 }), e || Il(n)) return !0; 9207 const t = n; 9208 return typeof t.from == "number" && typeof t.to == "number"; 9209 } 9210 function sh(n, e) { 9211 let t = null, r = 0, i = 0; 9212 for(let o = 0; o < n.childCount && !(i > e.to); o += 1){ 9213 const s = i + n.child(o).nodeSize; 9214 s >= e.from && (t === null && (t = i), r = s), i = s; 9215 } 9216 return t === null ? null : { 9217 from: t, 9218 to: r 9219 }; 9220 } 9221 function lh(n, e) { 9222 if (n.steps.some((o)=>!oh(o))) return { 9223 type: "full" 9224 }; 9225 const t = vl(n).map(({ newRange: o })=>o); 9226 n.steps.forEach((o, s)=>{ 9227 if (!Il(o)) return; 9228 const l = n.mapping.slice(s); 9229 t.push({ 9230 from: l.map(o.pos, -1), 9231 to: l.map(o.pos + 1) 9232 }); 9233 }); 9234 const r = []; 9235 for (const o of t){ 9236 const s = sh(e, o); 9237 s && r.push(s); 9238 } 9239 r.sort((o, s)=>o.from - s.from); 9240 const i = []; 9241 for (const o of r){ 9242 const s = i[i.length - 1]; 9243 s && o.from <= s.to ? s.to = Math.max(s.to, o.to) : i.push({ 9244 ...o 9245 }); 9246 } 9247 return { 9248 type: "ranges", 9249 ranges: i 9250 }; 9251 } 9252 function Rl(n, e, t, r) { 9253 return n.map(e, t, { 9254 onRemove: (i)=>{ 9255 const o = i?.key; 9256 typeof o == "string" && r.delete(o); 9257 } 9258 }); 9259 } 9260 function ah(n, e, t) { 9261 var r, i; 9262 const o = (r = e.decorationSetsByExtension[n]) !== null && r !== void 0 ? r : z.empty, s = new Set((i = e.widgetKeysByExtension[n]) !== null && i !== void 0 ? i : []); 9263 return { 9264 set: Rl(o, t.mapping, t.doc, s), 9265 widgetKeys: s 9266 }; 9267 } 9268 function mo(n, e) { 9269 const t = Object.values(e).flatMap((r)=>r.find()); 9270 return z.create(n, t); 9271 } 9272 function go(n) { 9273 const e = new Set; 9274 for (const t of Object.values(n))for (const r of t)e.add(r); 9275 return e; 9276 } 9277 function ch(n, e) { 9278 var t; 9279 switch((t = e.update) !== null && t !== void 0 ? t : "document"){ 9280 case "document": 9281 if (e.createInRange) throw new Error(`[tiptap error]: Extension "${n}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`); 9282 return; 9283 case "changedRanges": 9284 if (!e.createInRange) throw new Error(`[tiptap error]: Extension "${n}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`); 9285 return; 9286 case "manual": 9287 if (e.createInRange) throw new Error(`[tiptap error]: Extension "${n}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`); 9288 if (e.shouldUpdate) throw new Error(`[tiptap error]: Extension "${n}" cannot combine the "manual" decoration update strategy with shouldUpdate().`); 9289 return; 9290 default: 9291 throw new Error(`[tiptap error]: Extension "${n}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`); 9292 } 9293 } 9294 function fh(n, e, t) { 9295 return t ? !0 : n.update === "manual" ? !1 : n.shouldUpdate ? n.shouldUpdate(e) : e.tr.docChanged; 9296 } 9297 const uh = new Set; 9298 var dh = class { 9299 constructor(n){ 9300 this.warnedWidgetKeys = new Set, this.warnedOutOfRangeExtensions = new Set, this.handleBeforeTransaction = ({ nextState: e })=>{ 9301 const t = rt.getState(e); 9302 t && this.warnDuplicateWidgetKeys(t); 9303 }, this.editor = n.editor, this.entries = this.resolveEntries(n.entries), this.entries.forEach(({ name: e, spec: t })=>ch(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction); 9304 } 9305 destroy() { 9306 this.editor.off("beforeTransaction", this.handleBeforeTransaction); 9307 } 9308 liveWidgetKeys() { 9309 var n, e; 9310 return (n = (e = rt.getState(this.editor.state)) === null || e === void 0 ? void 0 : e.widgetKeys) !== null && n !== void 0 ? n : uh; 9311 } 9312 get mountedView() { 9313 return this.editor.isDestroyed ? null : this.editor.view; 9314 } 9315 resolveEntries(n) { 9316 const e = []; 9317 for (const { name: t, addDecorations: r } of n){ 9318 const i = r(); 9319 i && e.push({ 9320 name: t, 9321 spec: i 9322 }); 9323 } 9324 return e; 9325 } 9326 createPlugin() { 9327 const { editor: n, entries: e } = this; 9328 return new X({ 9329 key: rt, 9330 state: { 9331 init: (t, r)=>{ 9332 const i = {}, o = {}; 9333 for (const { name: l, spec: a } of e){ 9334 const { set: c, widgetKeys: f } = this.buildFullSet(l, a, r); 9335 i[l] = c, o[l] = f; 9336 } 9337 const s = { 9338 decorationSetsByExtension: i, 9339 widgetKeysByExtension: o, 9340 mergedDecorationSet: this.buildMergedSet(r.doc, i), 9341 widgetKeys: go(o) 9342 }; 9343 return this.warnDuplicateWidgetKeys(s), s; 9344 }, 9345 apply: (t, r, i, o)=>{ 9346 const s = t.getMeta(rt), l = s?.type === "force" && !s.name, a = s?.type === "force" ? s.name : void 0, c = {}, f = {}, u = new Set; 9347 return Zd(n, ()=>{ 9348 for (const { name: d, spec: h } of e){ 9349 const p = l || a === d; 9350 if (fh(h, { 9351 editor: n, 9352 tr: t, 9353 oldState: i, 9354 newState: o 9355 }, p)) if (h.update === "changedRanges" && t.docChanged && !p) { 9356 const m = this.applyChangedRangesRecompute(d, h, r, t, o); 9357 c[d] = m.set, f[d] = m.widgetKeys, u.add(d); 9358 } else { 9359 const { set: m, widgetKeys: g } = this.buildFullSet(d, h, o); 9360 c[d] = m, f[d] = g, u.add(d); 9361 } 9362 else { 9363 const m = ah(d, r, t); 9364 c[d] = m.set, f[d] = m.widgetKeys; 9365 } 9366 } 9367 }), u.size === 0 && !t.docChanged ? r : { 9368 decorationSetsByExtension: c, 9369 widgetKeysByExtension: f, 9370 mergedDecorationSet: this.mergeAfterApply({
9371 entries: e, 9372 previous: r, 9373 tr: t, 9374 decorationSetsByExtension: c, 9375 recomputedNames: u 9376 }), 9377 widgetKeys: go(f) 9378 }; 9379 } 9380 }, 9381 props: { 9382 decorations (t) { 9383 var r, i; 9384 return (r = (i = rt.getState(t)) === null || i === void 0 ? void 0 : i.mergedDecorationSet) !== null && r !== void 0 ? r : z.empty; 9385 } 9386 } 9387 }); 9388 } 9389 applyChangedRangesRecompute(n, e, t, r, i) { 9390 const o = lh(r, i.doc); 9391 return o.type === "full" ? this.buildFullSet(n, e, i) : this.rebuildRanges(n, e, t, r, i, o.ranges); 9392 } 9393 rebuildRanges(n, e, t, r, i, o) { 9394 var s, l; 9395 const a = (s = t.decorationSetsByExtension[n]) !== null && s !== void 0 ? s : z.empty, c = new Set((l = t.widgetKeysByExtension[n]) !== null && l !== void 0 ? l : []); 9396 let f = Rl(a, r.mapping, r.doc, c); 9397 const u = i.doc.content.size; 9398 for (const { from: d, to: h } of o){ 9399 const p = f.find(d, h).filter((y)=>Al({ 9400 position: y.from, 9401 from: d, 9402 to: h, 9403 docSize: u 9404 })); 9405 for (const y of p){ 9406 const x = ih(y); 9407 x && c.delete(x); 9408 } 9409 f = f.remove(p); 9410 const { decorations: m, widgetKeys: g } = Dl(rh({ 9411 decorations: this.runCreate(n, "createInRange", ()=>e.createInRange({ 9412 editor: this.editor, 9413 state: i, 9414 view: this.mountedView, 9415 from: d, 9416 to: h 9417 })), 9418 from: d, 9419 to: h, 9420 docSize: u, 9421 extensionName: n, 9422 warnedExtensions: this.warnedOutOfRangeExtensions 9423 }), n); 9424 f = f.add(i.doc, m); 9425 for (const y of g)c.add(y); 9426 } 9427 return { 9428 set: f, 9429 widgetKeys: c 9430 }; 9431 } 9432 buildFullSet(n, e, t) { 9433 const r = this.runCreate(n, "create", ()=>e.create({ 9434 editor: this.editor, 9435 state: t, 9436 view: this.mountedView 9437 })); 9438 return nh(t.doc, r, n); 9439 } 9440 runCreate(n, e, t) { 9441 try { 9442 return t(); 9443 } catch (r) { 9444 return console.error(`[tiptap error]: Extension "${n}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`, r), []; 9445 } 9446 } 9447 warnDuplicateWidgetKeys(n) {} 9448 buildMergedSet(n, e) { 9449 const t = Object.keys(e); 9450 return t.length === 1 ? e[t[0]] : mo(n, e); 9451 } 9452 mergeAfterApply({ entries: n, previous: e, tr: t, decorationSetsByExtension: r, recomputedNames: i }) { 9453 return n.length === 1 ? r[n[0].name] : i.size === 0 ? e.mergedDecorationSet.map(t.mapping, t.doc) : mo(t.doc, r); 9454 } 9455 }; 9456 function hh(n, e, t) { 9457 const r = document.querySelector("style[data-tiptap-style]"); 9458 if (r !== null) return r; 9459 const i = document.createElement("style"); 9460 return e && i.setAttribute("nonce", e), i.setAttribute("data-tiptap-style", ""), i.innerHTML = n, document.getElementsByTagName("head")[0].appendChild(i), i; 9461 } 9462 function ph(n) { 9463 return typeof n == "number"; 9464 } 9465 function mh(n) { 9466 return Object.prototype.toString.call(n).slice(8, -1); 9467 } 9468 function Qt(n) { 9469 return mh(n) !== "Object" ? !1 : n.constructor === Object && Object.getPrototypeOf(n) === Object.prototype; 9470 } 9471 function Bl(n, e) { 9472 const t = { 9473 ...n 9474 }; 9475 return Qt(n) && Qt(e) && Object.keys(e).forEach((r)=>{ 9476 Qt(e[r]) && Qt(n[r]) ? t[r] = Bl(n[r], e[r]) : t[r] = e[r]; 9477 }), t; 9478 } 9479 function gh(n, e, t = {}) { 9480 const { state: r } = e, { doc: i, tr: o } = r, s = n; 9481 i.descendants((l, a)=>{ 9482 const c = o.mapping.map(a), f = o.mapping.map(a) + l.nodeSize; 9483 let u = null; 9484 if (l.marks.forEach((h)=>{ 9485 if (h !== s) return !1; 9486 u = h; 9487 }), !u) return; 9488 let d = !1; 9489 if (Object.keys(t).forEach((h)=>{ 9490 t[h] !== u.attrs[h] && (d = !0); 9491 }), d) { 9492 const h = n.type.create({ 9493 ...n.attrs, 9494 ...t 9495 }); 9496 o.removeMark(c, f, n.type), o.addMark(c, f, h); 9497 } 9498 }), o.docChanged && e.view.dispatch(o); 9499 } 9500 const yh = (n, e)=>{ 9501 if (_r(e)) return e.exec(n); 9502 const t = e(n); 9503 if (!t) return null; 9504 const r = [ 9505 t.text 9506 ]; 9507 return r.index = t.index, r.input = n, r.data = t.data, t.replaceWith && (t.text.includes(t.replaceWith) || console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'), r.push(t.replaceWith)), r; 9508 }; 9509 function Zt(n) { 9510 var e; 9511 const { editor: t, from: r, to: i, text: o, rules: s, plugin: l } = n, { view: a } = t; 9512 if (a.composing) return !1; 9513 const c = a.state.doc.resolve(r); 9514 if (c.parent.type.spec.code || !((e = c.nodeBefore || c.nodeAfter) === null || e === void 0) && e.marks.find((d)=>d.type.spec.code)) return !1; 9515 let f = !1; 9516 const u = Td(c) + o;
9517 return s.forEach((d)=>{ 9518 if (f) return; 9519 const h = yh(u, d.find); 9520 if (!h) return; 9521 const p = h[0].length - o.length; 9522 if (p > 0) { 9523 const N = c.parentOffset - p; 9524 if (N < 0 || c.parent.textBetween(N, c.parentOffset) !== h[0].slice(0, p)) return; 9525 } 9526 const m = a.state.tr, g = Pn({ 9527 state: a.state, 9528 transaction: m 9529 }), y = { 9530 from: r - (h[0].length - o.length), 9531 to: i 9532 }, { commands: x, chain: M, can: w } = new st({ 9533 editor: t, 9534 state: g 9535 }); 9536 d.handler({ 9537 state: g, 9538 range: y, 9539 match: h, 9540 commands: x, 9541 chain: M, 9542 can: w 9543 }) === null || !m.steps.length || (d.undoable && m.setMeta(l, { 9544 transform: m, 9545 from: r, 9546 to: i, 9547 text: o 9548 }), a.dispatch(m), f = !0); 9549 }), f; 9550 } 9551 function kh(n) { 9552 const { editor: e, rules: t } = n, r = new X({ 9553 state: { 9554 init () { 9555 return null; 9556 }, 9557 apply (i, o, s) { 9558 const l = i.getMeta(r); 9559 if (l) return l; 9560 const a = i.getMeta("applyInputRules"); 9561 return a && setTimeout(()=>{ 9562 let { text: c } = a; 9563 typeof c == "string" ? c = c : c = Yr(k.from(c), s.schema); 9564 const { from: f } = a, u = f + c.length; 9565 Zt({ 9566 editor: e, 9567 from: f, 9568 to: u, 9569 text: c, 9570 rules: t, 9571 plugin: r 9572 }); 9573 }), i.selectionSet || i.docChanged ? null : o; 9574 } 9575 }, 9576 props: { 9577 handleTextInput (i, o, s, l) { 9578 return Zt({ 9579 editor: e, 9580 from: o, 9581 to: s, 9582 text: l, 9583 rules: t, 9584 plugin: r 9585 }); 9586 }, 9587 handleDOMEvents: { 9588 compositionend: (i)=>(setTimeout(()=>{ 9589 const { $cursor: o } = i.state.selection; 9590 o && Zt({ 9591 editor: e, 9592 from: o.pos, 9593 to: o.pos, 9594 text: "", 9595 rules: t, 9596 plugin: r 9597 }); 9598 }), !1) 9599 }, 9600 handleKeyDown (i, o) { 9601 if (o.key !== "Enter") return !1; 9602 const { $cursor: s } = i.state.selection; 9603 return s ? Zt({ 9604 editor: e, 9605 from: s.pos, 9606 to: s.pos, 9607 text: ` 9608`, 9609 rules: t, 9610 plugin: r 9611 }) : !1; 9612 } 9613 }, 9614 isInputRules: !0 9615 }); 9616 return r; 9617 } 9618 var Qr = class { 9619 constructor(n = {}){ 9620 this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { 9621 name: this.name 9622 }, this.config = { 9623 ...this.config, 9624 ...n 9625 }, this.name = this.config.name; 9626 } 9627 get options() { 9628 return { 9629 ...R(S(this, "addOptions", { 9630 name: this.name 9631 })) 9632 }; 9633 } 9634 get storage() { 9635 return { 9636 ...R(S(this, "addStorage", { 9637 name: this.name, 9638 options: this.options 9639 })) 9640 }; 9641 } 9642 configure(n = {}) { 9643 const e = this.extend({ 9644 ...this.config, 9645 addOptions: ()=>Bl(this.options, n) 9646 }); 9647 return e.name = this.name, e.parent = this.parent, this.child = null, e; 9648 } 9649 extend(n = {}) { 9650 const e = new this.constructor({ 9651 ...this.config, 9652 ...n 9653 }); 9654 return e.parent = this, this.child = e, e.name = "name" in n ? n.name : e.parent.name, e; 9655 } 9656 }, sn = class Pl extends Qr { 9657 constructor(...e){ 9658 super(...e), this.type = "mark"; 9659 } 9660 static create(e = {}) { 9661 const t = typeof e == "function" ? e() : e; 9662 return new Pl(t); 9663 } 9664 static handleExit({ editor: e, mark: t }) { 9665 const { tr: r } = e.state, i = e.state.selection.$from; 9666 if (i.pos === i.end()) { 9667 const o = i.marks(); 9668 if (!o.find((l)=>l?.type.name === t.name)) return !1; 9669 const s = o.find((l)=>l?.type.name === t.name); 9670 return s && r.removeStoredMark(s), r.insertText(" ", i.pos), e.view.dispatch(r), !0; 9671 } 9672 return !1; 9673 } 9674 configure(e) { 9675 return super.configure(e); 9676 } 9677 extend(e) { 9678 const t = typeof e == "function" ? e() : e; 9679 return super.extend(t); 9680 } 9681 }; 9682 const bh = (n, e, t)=>{ 9683 if (_r(e)) return [ 9684 ...n.matchAll(e) 9685 ]; 9686 const r = e(n, t); 9687 return r ? r.map((i)=>{ 9688 const o = [ 9689 i.text 9690 ]; 9691 return o.index = i.index, o.input = n, o.data = i.data, i.replaceWith && (i.text.includes(i.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), o.push(i.replaceWith)), o; 9692 }) : []; 9693 }; 9694 function xh(n) { 9695 const { editor: e, state: t, from: r, to: i, rule: o, pasteEvent: s, dropEvent: l } = n, { commands: a, chain: c, can: f } = new st({ 9696 editor: e, 9697 state: t 9698 }), u = []; 9699 return t.doc.nodesBetween(r, i, (d, h)=>{ 9700 var p, m, g, y; 9701 if (!((p = d.type) === null || p === void 0 || (p = p.spec) === null || p === void 0) && p.code || !(d.isText || d.isTextblock || d.isInline)) return; 9702 const x = (m = (g = (y = d.content) === null || y === void 0 ? void 0 : y.size) !== null && g !== void 0 ? g : d.nodeSize) !== null && m !== void 0 ? m : 0, M = Math.max(r, h), w = Math.min(i, h + x); 9703 if (M >= w) return; 9704 const N = d.isText ? d.text || "" : d.textBetween(M - h, w - h, void 0, "");
9705 bh(N, o.find, s).forEach((O)=>{ 9706 if (O.index === void 0) return; 9707 const C = M + O.index + 1, E = C + O[0].length, A = { 9708 from: t.tr.mapping.map(C), 9709 to: t.tr.mapping.map(E) 9710 }, _ = o.handler({ 9711 state: t, 9712 range: A, 9713 match: O, 9714 commands: a, 9715 chain: c, 9716 can: f, 9717 pasteEvent: s, 9718 dropEvent: l 9719 }); 9720 u.push(_); 9721 }); 9722 }), u.every((d)=>d !== null); 9723 } 9724 let en = null; 9725 const Sh = (n)=>{ 9726 var e; 9727 const t = new ClipboardEvent("paste", { 9728 clipboardData: new DataTransfer 9729 }); 9730 return (e = t.clipboardData) === null || e === void 0 || e.setData("text/html", n), t; 9731 }; 9732 function wh(n) { 9733 const { editor: e, rules: t } = n; 9734 let r = null, i = !1, o = !1, s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, l; 9735 try { 9736 l = typeof DragEvent < "u" ? new DragEvent("drop") : null; 9737 } catch { 9738 l = null; 9739 } 9740 const a = ({ state: c, from: f, to: u, rule: d, pasteEvt: h })=>{ 9741 const p = c.tr, m = Pn({ 9742 state: c, 9743 transaction: p 9744 }); 9745 if (!(!xh({ 9746 editor: e, 9747 state: m, 9748 from: Math.max(f - 1, 0), 9749 to: u.b - 1, 9750 rule: d, 9751 pasteEvent: h, 9752 dropEvent: l 9753 }) || !p.steps.length)) { 9754 try { 9755 l = typeof DragEvent < "u" ? new DragEvent("drop") : null; 9756 } catch { 9757 l = null; 9758 } 9759 return s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, p; 9760 } 9761 }; 9762 return t.map((c)=>new X({ 9763 view (f) { 9764 const u = (h)=>{ 9765 var p; 9766 r = !((p = f.dom.parentElement) === null || p === void 0) && p.contains(h.target) ? f.dom.parentElement : null, r && (en = e); 9767 }, d = ()=>{ 9768 en && (en = null); 9769 }; 9770 return window.addEventListener("dragstart", u), window.addEventListener("dragend", d), { 9771 destroy () { 9772 window.removeEventListener("dragstart", u), window.removeEventListener("dragend", d); 9773 } 9774 }; 9775 }, 9776 props: { 9777 handleDOMEvents: { 9778 drop: (f, u)=>{ 9779 if (o = r === f.dom.parentElement, l = u, !o) { 9780 const d = en; 9781 d?.isEditable && setTimeout(()=>{ 9782 const h = d.state.selection; 9783 h && d.commands.deleteRange({ 9784 from: h.from, 9785 to: h.to 9786 }); 9787 }, 10); 9788 } 9789 return !1; 9790 }, 9791 paste: (f, u)=>{ 9792 var d; 9793 const h = (d = u.clipboardData) === null || d === void 0 ? void 0 : d.getData("text/html"); 9794 return s = u, i = !!h?.includes("data-pm-slice"), !1; 9795 } 9796 } 9797 }, 9798 appendTransaction: (f, u, d)=>{ 9799 const h = f[0], p = h.getMeta("uiEvent") === "paste" && !i, m = h.getMeta("uiEvent") === "drop" && !o, g = h.getMeta("applyPasteRules"), y = !!g; 9800 if (!p && !m && !y) return; 9801 if (y) { 9802 let { text: w } = g; 9803 typeof w == "string" ? w = w : w = Yr(k.from(w), d.schema); 9804 const { from: N } = g, O = N + w.length, C = Sh(w); 9805 return a({ 9806 rule: c, 9807 state: d, 9808 from: N, 9809 to: { 9810 b: O 9811 }, 9812 pasteEvt: C 9813 }); 9814 } 9815 const x = u.doc.content.findDiffStart(d.doc.content), M = u.doc.content.findDiffEnd(d.doc.content); 9816 if (!(!ph(x) || !M || x === M.b)) return a({ 9817 rule: c, 9818 state: d, 9819 from: x, 9820 to: M, 9821 pasteEvt: s 9822 }); 9823 } 9824 })); 9825 } 9826 var Fn = class { 9827 constructor(n, e){ 9828 this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = e, this.baseExtensions = n, this.extensions = Gr(n), this.schema = Ml(this.extensions, e), this.setupExtensions(); 9829 } 9830 get commands() { 9831 return this.extensions.reduce((n, e)=>{ 9832 const t = S(e, "addCommands", { 9833 name: e.name, 9834 options: e.options, 9835 storage: this.editor.extensionStorage[e.name], 9836 editor: this.editor, 9837 type: et(e.name, this.schema) 9838 }); 9839 return t ? { 9840 ...n, 9841 ...t() 9842 } : n; 9843 }, {}); 9844 } 9845 get plugins() { 9846 const { editor: n } = this, e = vt([ 9847 ...this.extensions 9848 ].reverse()).flatMap((r)=>{ 9849 const i = { 9850 name: r.name, 9851 options: r.options, 9852 storage: this.editor.extensionStorage[r.name], 9853 editor: n, 9854 type: et(r.name, this.schema) 9855 }, o = [], s = S(r, "addKeyboardShortcuts", i); 9856 let l = {}; 9857 if (r.type === "mark" && S(r, "exitable", i) && (l.ArrowRight = ()=>sn.handleExit({ 9858 editor: n, 9859 mark: r 9860 })), s) { 9861 const d = Object.fromEntries(Object.entries(s()).map(([h, p])=>[ 9862 h, 9863 ()=>p({ 9864 editor: n 9865 }) 9866 ])); 9867 l = { 9868 ...l, 9869 ...d 9870 }; 9871 } 9872 const a = xu(l); 9873 o.push(a); 9874 const c = S(r, "addInputRules", i); 9875 if (uo(r, n.options.enableInputRules) && c) { 9876 const d = c(); 9877 if (d && d.length) { 9878 const h = kh({ 9879 editor: n, 9880 rules: d 9881 }), p = Array.isArray(h) ? h : [ 9882 h 9883 ]; 9884 o.push(...p); 9885 } 9886 } 9887 const f = S(r, "addPasteRules", i); 9888 if (uo(r, n.options.enablePasteRules) && f) { 9889 const d = f(); 9890 if (d && d.length) { 9891 const h = wh({ 9892 editor: n, 9893 rules: d 9894 }); 9895 o.push(...h); 9896 } 9897 } 9898 const u = S(r, "addProseMirrorPlugins", i); 9899 if (u) { 9900 const d = u(); 9901 o.push(...d); 9902 } 9903 return o; 9904 }), t = this.createDecorationPlugin(); 9905 return t && e.push(t), e; 9906 } 9907 createDecorationPlugin() { 9908 var n; 9909 const { editor: e } = this; 9910 (n = this.decorationManager) === null || n === void 0 || n.destroy(); 9911 const t = []; 9912 return this.extensions.forEach((r)=>{ 9913 const i = S(r, "addDecorations", { 9914 name: r.name, 9915 options: r.options, 9916 storage: this.editor.extensionStorage[r.name], 9917 editor: e, 9918 type: et(r.name, this.schema) 9919 }); 9920 i && t.push({ 9921 name: r.name, 9922 addDecorations: i 9923 }); 9924 }), this.decorationManager = new dh({ 9925 editor: e,
9926 entries: t 9927 }), this.decorationManager.plugin; 9928 } 9929 get attributes() { 9930 return wl(this.extensions); 9931 } 9932 get nodeViews() { 9933 const { editor: n } = this, { nodeExtensions: e } = dt(this.extensions); 9934 return Object.fromEntries(e.filter((t)=>!!S(t, "addNodeView")).map((t)=>{ 9935 const r = this.attributes.filter((l)=>l.type === t.name), i = S(t, "addNodeView", { 9936 name: t.name, 9937 options: t.options, 9938 storage: this.editor.extensionStorage[t.name], 9939 editor: n, 9940 type: V(t.name, this.schema) 9941 }); 9942 if (!i) return []; 9943 const o = i(); 9944 if (!o) return []; 9945 const s = (l, a, c, f, u)=>{ 9946 const d = Sn(l, r); 9947 return o({ 9948 node: l, 9949 view: a, 9950 getPos: c, 9951 decorations: f, 9952 innerDecorations: u, 9953 editor: n, 9954 extension: t, 9955 HTMLAttributes: d 9956 }); 9957 }; 9958 return [ 9959 t.name, 9960 s 9961 ]; 9962 })); 9963 } 9964 dispatchTransaction(n) { 9965 const { editor: e } = this; 9966 return vt([ 9967 ...this.extensions 9968 ].reverse()).reduceRight((t, r)=>{ 9969 const i = { 9970 name: r.name, 9971 options: r.options, 9972 storage: this.editor.extensionStorage[r.name], 9973 editor: e, 9974 type: et(r.name, this.schema) 9975 }, o = S(r, "dispatchTransaction", i); 9976 return o ? (s)=>{ 9977 o.call(i, { 9978 transaction: s, 9979 next: t 9980 }); 9981 } : t; 9982 }, n); 9983 } 9984 transformPastedHTML(n) { 9985 const { editor: e } = this; 9986 return vt([ 9987 ...this.extensions 9988 ]).reduce((t, r)=>{ 9989 const i = { 9990 name: r.name, 9991 options: r.options, 9992 storage: this.editor.extensionStorage[r.name], 9993 editor: e, 9994 type: et(r.name, this.schema) 9995 }, o = S(r, "transformPastedHTML", i); 9996 return o ? (s, l)=>{ 9997 const a = t(s, l); 9998 return o.call(i, a); 9999 } : t; 10000 }, n || ((t)=>t)); 10001 } 10002 get markViews() { 10003 const { editor: n } = this, { markExtensions: e } = dt(this.extensions); 10004 return Object.fromEntries(e.filter((t)=>!!S(t, "addMarkView")).map((t)=>{ 10005 const r = this.attributes.filter((s)=>s.type === t.name), i = S(t, "addMarkView", { 10006 name: t.name, 10007 options: t.options, 10008 storage: this.editor.extensionStorage[t.name], 10009 editor: n, 10010 type: Se(t.name, this.schema) 10011 }); 10012 if (!i) return []; 10013 const o = (s, l, a)=>{ 10014 const c = Sn(s, r); 10015 return i()({ 10016 mark: s, 10017 view: l, 10018 inline: a, 10019 editor: n, 10020 extension: t, 10021 HTMLAttributes: c, 10022 updateAttributes: (f)=>{ 10023 gh(s, n, f); 10024 } 10025 }); 10026 }; 10027 return [ 10028 t.name, 10029 o 10030 ]; 10031 })); 10032 } 10033 destroy() { 10034 var n; 10035 (n = this.decorationManager) === null || n === void 0 || n.destroy(), this.extensions.forEach((e)=>{ 10036 let t = e; 10037 for(; t.parent;){ 10038 const r = t.parent; 10039 r.child === t && (r.child = null), t = r; 10040 } 10041 }), this.extensions = [], this.baseExtensions = [], this.decorationManager = null, this.schema = null, this.editor = null; 10042 } 10043 setupExtensions() { 10044 const n = this.extensions; 10045 this.editor.extensionStorage = Object.fromEntries(n.map((e)=>[ 10046 e.name, 10047 e.storage
10048 ])), n.forEach((e)=>{ 10049 const t = { 10050 name: e.name, 10051 options: e.options, 10052 storage: this.editor.extensionStorage[e.name], 10053 editor: this.editor, 10054 type: et(e.name, this.schema) 10055 }; 10056 if (e.type === "mark") { 10057 var r, i; 10058 (!((r = R(S(e, "keepOnSplit", t))) !== null && r !== void 0) || r) && this.splittableMarks.push(e.name), !((i = R(S(e, "clearable", t))) !== null && i !== void 0) || i || this.nonClearableMarks.push(e.name); 10059 } 10060 const o = S(e, "onBeforeCreate", t), s = S(e, "onCreate", t), l = S(e, "onUpdate", t), a = S(e, "onSelectionUpdate", t), c = S(e, "onTransaction", t), f = S(e, "onFocus", t), u = S(e, "onBlur", t), d = S(e, "onDestroy", t); 10061 o && this.editor.on("beforeCreate", o), s && this.editor.on("create", s), l && this.editor.on("update", l), a && this.editor.on("selectionUpdate", a), c && this.editor.on("transaction", c), f && this.editor.on("focus", f), u && this.editor.on("blur", u), d && this.editor.on("destroy", d); 10062 }); 10063 } 10064 }; 10065 Fn.resolve = Gr; 10066 Fn.sort = vt; 10067 Fn.flatten = Ur; 10068 var ae = class zl extends Qr { 10069 constructor(...e){ 10070 super(...e), this.type = "extension"; 10071 } 10072 static create(e = {}) { 10073 const t = typeof e == "function" ? e() : e; 10074 return new zl(t); 10075 } 10076 configure(e) { 10077 return super.configure(e); 10078 } 10079 extend(e) { 10080 const t = typeof e == "function" ? e() : e; 10081 return super.extend(t); 10082 } 10083 }; 10084 const Mh = ae.create({ 10085 name: "clipboardTextSerializer", 10086 addOptions () { 10087 return { 10088 blockSeparator: void 0 10089 }; 10090 }, 10091 addProseMirrorPlugins () { 10092 return [ 10093 new X({ 10094 key: new de("clipboardTextSerializer"), 10095 props: { 10096 clipboardTextSerializer: ()=>{ 10097 const { editor: n } = this, { state: e, schema: t } = n, { doc: r, selection: i } = e, o = Tl(t), { blockSeparator: s } = this.options, l = { 10098 ...s !== void 0 ? { 10099 blockSeparator: s 10100 } : {}, 10101 textSerializers: o 10102 }; 10103 return [ 10104 ...i.ranges 10105 ].sort((a, c)=>a.$from.pos - c.$from.pos).map(({ $from: a, $to: c })=>Cl(r, { 10106 from: a.pos, 10107 to: c.pos 10108 }, l)).join(s ?? ` 10109 10110`); 10111 } 10112 } 10113 }) 10114 ]; 10115 } 10116 }), Ch = ae.create({ 10117 name: "commands", 10118 addCommands () { 10119 return { 10120 ...Qd 10121 }; 10122 } 10123 }), Th = ae.create({ 10124 name: "delete", 10125 onUpdate ({ transaction: n, appendedTransactions: e }) { 10126 var t, r; 10127 const i = ()=>{ 10128 var o, s, l; 10129 if ((o = (s = this.editor.options.coreExtensionOptions) === null || s === void 0 || (s = s.delete) === null || s === void 0 || (l = s.filterTransaction) === null || l === void 0 ? void 0 : l.call(s, n)) !== null && o !== void 0 ? o : n.getMeta("y-sync$")) return; 10130 const a = hd(n.before, [ 10131 n, 10132 ...e 10133 ]); 10134 vl(a).forEach((f)=>{ 10135 a.mapping.mapResult(f.oldRange.from).deletedAfter && a.mapping.mapResult(f.oldRange.to).deletedBefore && a.before.nodesBetween(f.oldRange.from, f.oldRange.to, (u, d)=>{ 10136 const h = d + u.nodeSize - 2, p = f.oldRange.from <= d && h <= f.oldRange.to; 10137 this.editor.emit("delete", { 10138 type: "node", 10139 node: u, 10140 from: d, 10141 to: h, 10142 newFrom: a.mapping.map(d), 10143 newTo: a.mapping.map(h), 10144 deletedRange: f.oldRange, 10145 newRange: f.newRange, 10146 partial: !p, 10147 editor: this.editor, 10148 transaction: n, 10149 combinedTransform: a 10150 }); 10151 }); 10152 }); 10153 const c = a.mapping; 10154 a.steps.forEach((f, u)=>{ 10155 if (f instanceof re) { 10156 var d, h; 10157 const p = c.slice(u).map(f.from, -1), m = c.slice(u).map(f.to), g = c.invert().map(p, -1), y = c.invert().map(m), x = p > 0 ? (d = a.doc.nodeAt(p - 1)) === null || d === void 0 ? void 0 : d.marks.some((w)=>w.eq(f.mark)) : !1, M = (h = a.doc.nodeAt(m)) === null || h === void 0 ? void 0 : h.marks.some((w)=>w.eq(f.mark)); 10158 this.editor.emit("delete", { 10159 type: "mark", 10160 mark: f.mark, 10161 from: f.from, 10162 to: f.to, 10163 deletedRange: { 10164 from: g, 10165 to: y 10166 }, 10167 newRange: { 10168 from: p, 10169 to: m 10170 }, 10171 partial: !!(M || x), 10172 editor: this.editor, 10173 transaction: n, 10174 combinedTransform: a 10175 }); 10176 } 10177 }); 10178 }; 10179 !((t = (r = this.editor.options.coreExtensionOptions) === null || r === void 0 || (r = r.delete) === null || r === void 0 ? void 0 : r.async) !== null && t !== void 0) || t ? setTimeout(i, 0) : i(); 10180 } 10181 }), vh = ae.create({ 10182 name: "drop", 10183 addProseMirrorPlugins () { 10184 return [ 10185 new X({ 10186 key: new de("tiptapDrop"), 10187 props: { 10188 handleDrop: (n, e, t, r)=>{ 10189 this.editor.emit("drop", { 10190 editor: this.editor, 10191 event: e, 10192 slice: t, 10193 moved: r 10194 }); 10195 } 10196 } 10197 }) 10198 ]; 10199 } 10200 }), Oh = ae.create({ 10201 name: "editable", 10202 addProseMirrorPlugins () { 10203 return [ 10204 new X({ 10205 key: new de("editable"), 10206 props: { 10207 editable: ()=>this.editor.options.editable 10208 } 10209 }) 10210 ]; 10211 } 10212 }), Nh = new de("focusEvents"), Eh = ae.create({ 10213 name: "focusEvents", 10214 addProseMirrorPlugins () { 10215 const { editor: n } = this; 10216 return [ 10217 new X({ 10218 key: Nh, 10219 props: { 10220 handleDOMEvents: { 10221 focus: (e, t)=>{ 10222 n.isFocused = !0; 10223 const r = n.state.tr.setMeta("focus", { 10224 event: t 10225 }).setMeta("addToHistory", !1); 10226 return e.dispatch(r), !1; 10227 }, 10228 blur: (e, t)=>{ 10229 n.isFocused = !1; 10230 const r = n.state.tr.setMeta("blur", { 10231 event: t 10232 }).setMeta("addToHistory", !1); 10233 return e.dispatch(r), !1; 10234 } 10235 } 10236 } 10237 }) 10238 ]; 10239 } 10240 }), Dh = ae.create({ 10241 name: "keymap", 10242 addKeyboardShortcuts () { 10243 const n = ()=>this.editor.commands.first(({ commands: s })=>[ 10244 ()=>s.undoInputRule(), 10245 ()=>s.command(({ tr: l })=>{ 10246 const { selection: a, doc: c } = l, { empty: f, $anchor: u } = a, { pos: d, parent: h } = u, p = u.parent.isTextblock && d > 0 ? l.doc.resolve(d - 1) : u, m = p.parent.type.spec.isolating, g = u.pos - u.parentOffset, y = m && p.parent.childCount === 1 ? g === u.pos : D.atStart(c).from === d; 10247 return !f || !h.type.isTextblock || h.textContent.length || !y || y && u.parent.type.name === "paragraph" ? !1 : s.clearNodes(); 10248 }), 10249 ()=>s.deleteSelection(), 10250 ()=>s.joinBackward(), 10251 ()=>s.selectNodeBackward() 10252 ]), e = ()=>this.editor.commands.first(({ commands: s })=>[ 10253 ()=>s.deleteSelection(), 10254 ()=>s.deleteCurrentNode(), 10255 ()=>s.joinForward(), 10256 ()=>s.selectNodeForward() 10257 ]), r = { 10258 Enter: ()=>this.editor.commands.first(({ commands: s })=>[ 10259 ()=>s.newlineInCode(), 10260 ()=>s.createParagraphNear(), 10261 ()=>s.liftEmptyBlock(), 10262 ()=>s.splitBlock() 10263 ]), 10264 "Mod-Enter": ()=>this.editor.commands.exitCode(), 10265 Backspace: n, 10266 "Mod-Backspace": n, 10267 "Shift-Backspace": n, 10268 Delete: e, 10269 "Mod-Delete": e, 10270 "Mod-a": ()=>this.editor.commands.selectAll() 10271 }, i = { 10272 ...r 10273 }, o = { 10274 ...r, 10275 "Ctrl-h": n,
10276 "Alt-Backspace": n, 10277 "Ctrl-d": e, 10278 "Ctrl-Alt-Backspace": e, 10279 "Alt-Delete": e, 10280 "Alt-d": e, 10281 "Ctrl-a": ()=>this.editor.commands.selectTextblockStart(), 10282 "Ctrl-e": ()=>this.editor.commands.selectTextblockEnd() 10283 }; 10284 return xn() || bl() ? o : i; 10285 }, 10286 addProseMirrorPlugins () { 10287 return [ 10288 new X({ 10289 key: new de("clearDocument"), 10290 appendTransaction: (n, e, t)=>{ 10291 if (n.some((h)=>h.getMeta("composition"))) return; 10292 const r = n.some((h)=>h.docChanged) && !e.doc.eq(t.doc), i = n.some((h)=>h.getMeta("preventClearDocument")); 10293 if (!r || i) return; 10294 const { empty: o, from: s, to: l } = e.selection, a = D.atStart(e.doc).from, c = D.atEnd(e.doc).to; 10295 if (o || !(s === a && l === c) || !Xr(t.doc)) return; 10296 const f = t.tr, u = Pn({ 10297 state: t, 10298 transaction: f 10299 }), { commands: d } = new st({ 10300 editor: this.editor, 10301 state: u 10302 }); 10303 if (d.clearNodes(), !!f.steps.length) return f; 10304 } 10305 }) 10306 ]; 10307 } 10308 }), Ah = ae.create({ 10309 name: "paste", 10310 addProseMirrorPlugins () { 10311 return [ 10312 new X({ 10313 key: new de("tiptapPaste"), 10314 props: { 10315 handlePaste: (n, e, t)=>{ 10316 this.editor.emit("paste", { 10317 editor: this.editor, 10318 event: e, 10319 slice: t 10320 }); 10321 } 10322 } 10323 }) 10324 ]; 10325 } 10326 }), Ih = ae.create({ 10327 name: "tabindex", 10328 addOptions () { 10329 return { 10330 value: void 0 10331 }; 10332 }, 10333 addProseMirrorPlugins () { 10334 return [ 10335 new X({ 10336 key: new de("tabindex"), 10337 props: { 10338 attributes: ()=>{ 10339 var n; 10340 return !this.editor.isEditable && this.options.value === void 0 ? {} : { 10341 tabindex: (n = this.options.value) !== null && n !== void 0 ? n : "0" 10342 }; 10343 } 10344 } 10345 }) 10346 ]; 10347 } 10348 }), Rh = ae.create({ 10349 name: "textDirection", 10350 addOptions () { 10351 return { 10352 direction: void 0 10353 }; 10354 }, 10355 addGlobalAttributes () { 10356 if (!this.options.direction) return []; 10357 const { nodeExtensions: n } = dt(this.extensions); 10358 return [ 10359 { 10360 types: n.filter((e)=>e.name !== "text").map((e)=>e.name), 10361 attributes: { 10362 dir: { 10363 default: this.options.direction, 10364 parseHTML: (e)=>{ 10365 const t = e.getAttribute("dir"); 10366 return t && (t === "ltr" || t === "rtl" || t === "auto") ? t : this.options.direction; 10367 }, 10368 renderHTML: (e)=>e.dir ? { 10369 dir: e.dir 10370 } : {} 10371 } 10372 } 10373 } 10374 ]; 10375 }, 10376 addProseMirrorPlugins () { 10377 return [ 10378 new X({ 10379 key: new de("textDirection"), 10380 props: { 10381 attributes: ()=>{ 10382 const n = this.options.direction; 10383 return n ? { 10384 dir: n 10385 } : {}; 10386 } 10387 } 10388 }) 10389 ]; 10390 } 10391 }); 10392 let yo = !1; 10393 function Bh(n) { 10394 if (yo) return; 10395 yo = !0; 10396 let e; 10397 try { 10398 e = P.fromJSON(n, { 10399 from: 0, 10400 to: 0 10401 }).slice.content; 10402 } catch { 10403 return; 10404 } 10405 e instanceof k || console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler."); 10406 } 10407 var Ph = class xt { 10408 get name() {
10409 return this.node.type.name; 10410 } 10411 constructor(e, t, r = !1, i = null){ 10412 this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = e, this.editor = t, this.currentNode = i; 10413 } 10414 get node() { 10415 return this.currentNode || this.resolvedPos.node(); 10416 } 10417 get element() { 10418 return this.editor.view.domAtPos(this.pos).node; 10419 } 10420 get depth() { 10421 var e; 10422 return (e = this.actualDepth) !== null && e !== void 0 ? e : this.resolvedPos.depth; 10423 } 10424 get pos() { 10425 return this.resolvedPos.pos; 10426 } 10427 get content() { 10428 return this.node.content; 10429 } 10430 set content(e) { 10431 let t = this.from, r = this.to; 10432 if (this.isBlock) { 10433 if (this.content.size === 0) { 10434 console.error(`You canât set content on a block node. Tried to set content on ${this.name} at ${this.pos}`); 10435 return; 10436 } 10437 t = this.from + 1, r = this.to - 1; 10438 } 10439 this.editor.commands.insertContentAt({ 10440 from: t, 10441 to: r 10442 }, e); 10443 } 10444 get attributes() { 10445 return this.node.attrs; 10446 } 10447 get textContent() { 10448 return this.node.textContent; 10449 } 10450 get size() { 10451 return this.node.nodeSize; 10452 } 10453 get from() { 10454 return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth); 10455 } 10456 get range() { 10457 return { 10458 from: this.from, 10459 to: this.to 10460 }; 10461 } 10462 get to() { 10463 return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1); 10464 } 10465 get parent() { 10466 if (this.depth === 0) return null; 10467 const e = this.resolvedPos.start(this.resolvedPos.depth - 1), t = this.resolvedPos.doc.resolve(e); 10468 return new xt(t, this.editor); 10469 } 10470 get before() { 10471 let e = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2)); 10472 return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.from - 3)), new xt(e, this.editor); 10473 } 10474 get after() { 10475 let e = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1)); 10476 return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.to + 3)), new xt(e, this.editor); 10477 } 10478 get children() { 10479 const e = []; 10480 return this.node.content.forEach((t, r)=>{ 10481 const i = t.isBlock && !t.isTextblock, o = t.isAtom && !t.isText, s = t.isInline, l = this.pos + r + (o ? 0 : 1); 10482 if (l < 0 || l > this.resolvedPos.doc.nodeSize - 2) return; 10483 const a = this.resolvedPos.doc.resolve(l); 10484 if (!i && !s && a.depth <= this.depth) return; 10485 const c = new xt(a, this.editor, i, i || s ? t : null); 10486 i && (c.actualDepth = this.depth + 1), e.push(c); 10487 }), e; 10488 } 10489 get firstChild() { 10490 return this.children[0] || null; 10491 } 10492 get lastChild() { 10493 const e = this.children; 10494 return e[e.length - 1] || null; 10495 } 10496 closest(e, t = {}) { 10497 let r = null, i = this.parent; 10498 for(; i && !r;){ 10499 if (i.node.type.name === e) if (Object.keys(t).length > 0) { 10500 const o = i.node.attrs, s = Object.keys(t); 10501 for(let l = 0; l < s.length; l += 1){ 10502 const a = s[l]; 10503 if (o[a] !== t[a]) break; 10504 } 10505 } else r = i; 10506 i = i.parent; 10507 } 10508 return r; 10509 } 10510 querySelector(e, t = {}) { 10511 return this.querySelectorAll(e, t, !0)[0] || null; 10512 } 10513 querySelectorAll(e, t = {}, r = !1) { 10514 let i = []; 10515 if (!this.children || this.children.length === 0) return i; 10516 const o = Object.keys(t);
10517 return this.children.forEach((s)=>{ 10518 r && i.length > 0 || (s.node.type.name === e && o.every((l)=>t[l] === s.node.attrs[l]) && i.push(s), !(r && i.length > 0) && (i = i.concat(s.querySelectorAll(e, t, r)))); 10519 }), i; 10520 } 10521 setAttribute(e) { 10522 const { tr: t } = this.editor.state; 10523 t.setNodeMarkup(this.from, void 0, { 10524 ...this.node.attrs, 10525 ...e 10526 }), this.editor.view.dispatch(t); 10527 } 10528 }; 10529 const zh = `.ProseMirror { 10530 position: relative; 10531} 10532 10533.ProseMirror { 10534 word-wrap: break-word; 10535 white-space: pre-wrap; 10536 white-space: break-spaces; 10537 -webkit-font-variant-ligatures: none; 10538 font-variant-ligatures: none; 10539 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 10540} 10541 10542.ProseMirror [contenteditable="false"] { 10543 white-space: normal; 10544} 10545 10546.ProseMirror [contenteditable="false"] [contenteditable="true"] { 10547 white-space: pre-wrap; 10548} 10549 10550.ProseMirror pre { 10551 white-space: pre-wrap; 10552} 10553 10554img.ProseMirror-separator { 10555 display: inline !important; 10556 border: none !important; 10557 margin: 0 !important; 10558 width: 0 !important; 10559 height: 0 !important; 10560} 10561 10562.ProseMirror-gapcursor { 10563 display: none; 10564 pointer-events: none; 10565 position: absolute; 10566 margin: 0; 10567} 10568 10569.ProseMirror-gapcursor:after { 10570 content: ""; 10571 display: block; 10572 position: absolute; 10573 top: -2px; 10574 width: 20px; 10575 border-top: 1px solid black; 10576 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 10577} 10578 10579@keyframes ProseMirror-cursor-blink { 10580 to { 10581 visibility: hidden; 10582 } 10583} 10584 10585.ProseMirror-hideselection *::selection { 10586 background: transparent; 10587} 10588 10589.ProseMirror-hideselection *::-moz-selection { 10590 background: transparent; 10591} 10592 10593.ProseMirror-hideselection * { 10594 caret-color: transparent; 10595} 10596 10597.ProseMirror-focused .ProseMirror-gapcursor { 10598 display: block; 10599}`; 10600 let Q; 10601 Fh = class extends eh { 10602 constructor(n = {}){ 10603 super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.hasWarnedStaleDecorationRead = !1, this.options = { 10604 element: typeof document < "u" ? document.createElement("div") : null, 10605 content: "", 10606 injectCSS: !0, 10607 injectNonce: void 0, 10608 extensions: [], 10609 autofocus: !1, 10610 editable: !0, 10611 textDirection: void 0, 10612 editorProps: {}, 10613 parseOptions: {}, 10614 coreExtensionOptions: {}, 10615 enableInputRules: !0, 10616 enablePasteRules: !0, 10617 enableCoreExtensions: !0, 10618 enableContentCheck: !1, 10619 emitContentError: !1, 10620 onBeforeCreate: ()=>null, 10621 onCreate: ()=>null, 10622 onMount: ()=>null, 10623 onUnmount: ()=>null, 10624 onUpdate: ()=>null, 10625 onSelectionUpdate: ()=>null, 10626 onTransaction: ()=>null, 10627 onFocus: ()=>null, 10628 onBlur: ()=>null, 10629 onDestroy: ()=>null, 10630 onContentError: ({ error: t })=>{ 10631 throw t; 10632 }, 10633 onPaste: ()=>null, 10634 onDrop: ()=>null, 10635 onDelete: ()=>null, 10636 enableExtensionDispatchTransaction: !0 10637 }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = { 10638 getUpdatedPosition: Od, 10639 createMappablePosition: Nd 10640 }, this.setOptions(n), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { 10641 editor: this 10642 }), this.on("mount", this.options.onMount), this.on("unmount", this.options.onUnmount), this.on("contentError", this.options.onContentError), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: t, slice: r, moved: i })=>this.options.onDrop(t, r, i)), this.on("paste", ({ event: t, slice: r })=>this.options.onPaste(t, r)), this.on("delete", this.options.onDelete); 10643 const e = this.createDoc(); 10644 if (!this.editorState) { 10645 const t = Tr(e, this.options.autofocus); 10646 this.editorState = ze.create({ 10647 doc: e, 10648 schema: this.schema, 10649 selection: t || void 0 10650 }); 10651 } 10652 Bh(this.schema), this.options.element && this.mount(this.options.element); 10653 } 10654 mount(n) { 10655 if (typeof document > "u") throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
10656 this.createView(n), this.emit("mount", { 10657 editor: this 10658 }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(()=>{ 10659 this.isDestroyed || (this.options.autofocus !== !1 && this.options.autofocus !== null && this.commands.focus(this.options.autofocus), this.emit("create", { 10660 editor: this 10661 }), this.isInitialized = !0); 10662 }, 0); 10663 } 10664 unmount() { 10665 if (this.editorView) { 10666 this.editorState = this.editorView.state; 10667 const n = this.editorView.dom; 10668 n?.editor && delete n.editor, this.editorView.destroy(); 10669 } 10670 if (this.editorView = null, this.isInitialized = !1, this.css && !document.querySelectorAll(`.${this.className}`).length) try { 10671 typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css); 10672 } catch (n) { 10673 console.warn("Failed to remove CSS element:", n); 10674 } 10675 this.css = null, this.emit("unmount", { 10676 editor: this 10677 }); 10678 } 10679 get storage() { 10680 return this.extensionStorage; 10681 } 10682 get commands() { 10683 return this.commandManager.commands; 10684 } 10685 chain() { 10686 return this.commandManager ? this.commandManager.chain() : st.createFakeChain(); 10687 } 10688 can() { 10689 return this.commandManager ? this.commandManager.can() : st.createFallbackCan(); 10690 } 10691 injectCSS() { 10692 this.options.injectCSS && typeof document < "u" && (this.css = hh(zh, this.options.injectNonce)); 10693 } 10694 setOptions(n = {}) { 10695 this.options = { 10696 ...this.options, 10697 ...n 10698 }, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state)); 10699 } 10700 setEditable(n, e = !0) { 10701 this.setOptions({ 10702 editable: n 10703 }), e && this.emit("update", { 10704 editor: this, 10705 transaction: this.state.tr, 10706 appendedTransactions: [] 10707 }); 10708 } 10709 get isEditable() { 10710 return this.options.editable && this.view && this.view.editable; 10711 } 10712 get view() { 10713 return this.editorView ? this.editorView : new Proxy({ 10714 state: this.editorState, 10715 updateState: (n)=>{ 10716 this.editorState = n; 10717 }, 10718 dispatch: (n)=>{ 10719 this.dispatchTransaction(n); 10720 }, 10721 composing: !1, 10722 dragging: null, 10723 editable: !0, 10724 isDestroyed: !1 10725 }, { 10726 get: (n, e)=>{ 10727 if (this.editorView) return this.editorView[e]; 10728 if (e === "state") return this.editorState; 10729 if (e in n) return Reflect.get(n, e); 10730 throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`); 10731 } 10732 }); 10733 } 10734 get state() { 10735 return this.editorView && (this.editorState = this.view.state), this.editorState; 10736 } 10737 registerPlugin(n, e) { 10738 const t = Sl(e) ? e(n, [ 10739 ...this.state.plugins 10740 ]) : [ 10741 ...this.state.plugins, 10742 n 10743 ], r = this.state.reconfigure({ 10744 plugins: t 10745 }); 10746 return this.view.updateState(r), r; 10747 } 10748 unregisterPlugin(n) { 10749 if (this.isDestroyed) return; 10750 const e = this.state.plugins; 10751 let t = e; 10752 if ([].concat(n).forEach((i)=>{ 10753 const o = typeof i == "string" ? `${i}$` : i.key; 10754 t = t.filter((s)=>!s.key.startsWith(o)); 10755 }), e.length === t.length) return; 10756 const r = this.state.reconfigure({ 10757 plugins: t 10758 }); 10759 return this.view.updateState(r), r; 10760 } 10761 createExtensionManager() { 10762 var n, e; 10763 const t = [ 10764 ...this.options.enableCoreExtensions ? [ 10765 Oh, 10766 Mh.configure({ 10767 blockSeparator: (n = this.options.coreExtensionOptions) === null || n === void 0 || (n = n.clipboardTextSeri
10767alizer) === null || n === void 0 ? void 0 : n.blockSeparator 10768 }), 10769 Ch, 10770 Eh, 10771 Dh, 10772 Ih.configure({ 10773 value: (e = this.options.coreExtensionOptions) === null || e === void 0 || (e = e.tabindex) === null || e === void 0 ? void 0 : e.value 10774 }), 10775 vh, 10776 Ah, 10777 Th, 10778 Rh.configure({ 10779 direction: this.options.textDirection 10780 }) 10781 ].filter((r)=>typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[r.name] !== !1 : !0) : [], 10782 ...this.options.extensions 10783 ].filter((r)=>[ 10784 "extension", 10785 "node", 10786 "mark" 10787 ].includes(r?.type)); 10788 this.extensionManager = new Fn(t, this); 10789 } 10790 createCommandManager() { 10791 this.commandManager = new st({ 10792 editor: this 10793 }); 10794 } 10795 createSchema() { 10796 this.schema = this.extensionManager.schema; 10797 } 10798 createDoc() { 10799 let n; 10800 try { 10801 n = vr(this.options.content, this.schema, this.options.parseOptions, { 10802 errorOnInvalidContent: this.options.enableContentCheck 10803 }); 10804 } catch (e) { 10805 if (!(e instanceof Error) || ![ 10806 "[tiptap error]: Invalid JSON content", 10807 "[tiptap error]: Invalid HTML content" 10808 ].includes(e.message)) throw e; 10809 const t = vr(this.options.content, this.schema, this.options.parseOptions, { 10810 errorOnInvalidContent: !1 10811 }); 10812 return this.editorState = ze.create({ 10813 doc: t, 10814 schema: this.schema, 10815 selection: Tr(t, this.options.autofocus) || void 0 10816 }), this.emit("contentError", { 10817 editor: this, 10818 error: e, 10819 disableCollaboration: ()=>{ 10820 "collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((r)=>r.name !== "collaboration"), this.createExtensionManager(); 10821 } 10822 }), this.editorState.doc; 10823 } 10824 return n; 10825 } 10826 createView(n) { 10827 const { editorProps: e, enableExtensionDispatchTransaction: t } = this.options, r = e.dispatchTransaction || this.dispatchTransaction.bind(this), i = t ? this.extensionManager.dispatchTransaction(r) : r, o = e.transformPastedHTML, s = this.extensionManager.transformPastedHTML(o); 10828 this.editorView = new cl(n, { 10829 ...e, 10830 attributes: { 10831 role: "textbox", 10832 ...e?.attributes 10833 }, 10834 dispatchTransaction: i, 10835 transformPastedHTML: s, 10836 state: this.editorState, 10837 markViews: this.extensionManager.markViews, 10838 nodeViews: this.extensionManager.nodeViews 10839 }); 10840 const l = this.state.reconfigure({ 10841 plugins: this.extensionManager.plugins 10842 }); 10843 this.view.updateState(l), this.prependClass(), this.injectCSS(); 10844 const a = this.view.dom; 10845 a.editor = this; 10846 } 10847 createNodeViews() { 10848 this.view.isDestroyed || this.view.setProps({ 10849 markViews: this.extensionManager.markViews, 10850 nodeViews: this.extensionManager.nodeViews 10851 }); 10852 } 10853 prependClass() { 10854 this.view.dom.className = `${this.className} ${this.view.dom.className}`; 10855 } 10856 captureTransaction(n) { 10857 this.isCapturingTransaction = !0, n(), this.isCapturingTransaction = !1; 10858 const e = this.capturedTransaction; 10859 return this.capturedTransaction = null, e; 10860 } 10861 dispatchTransaction(n) { 10862 if (this.view.isDestroyed) return; 10863 if (this.isCapturingTransaction) { 10864 if (!this.capturedTransaction) { 10865 this.capturedTransaction = n; 10866 return; 10867 } 10868 n.steps.forEach((c)=>{ 10869 var f; 10870 return (f = this.capturedTransaction) === null || f === void 0 ? void 0 : f.step(c); 10871 }); 10872 return; 10873 } 10874 const { state: e, transactions: t } = this.state.applyTransaction(n), r = !this.state.selection.eq(e.selection), i = t.includes(n), o = this.state;
10875 if (this.emit("beforeTransaction", { 10876 editor: this, 10877 transaction: n, 10878 nextState: e 10879 }), !i) return; 10880 this.view.updateState(e), this.emit("transaction", { 10881 editor: this, 10882 transaction: n, 10883 appendedTransactions: t.slice(1) 10884 }), r && this.emit("selectionUpdate", { 10885 editor: this, 10886 transaction: n 10887 }); 10888 const s = t.findLast((c)=>c.getMeta("focus") || c.getMeta("blur")), l = s?.getMeta("focus"), a = s?.getMeta("blur"); 10889 l && this.emit("focus", { 10890 editor: this, 10891 event: l.event, 10892 transaction: s 10893 }), a && this.emit("blur", { 10894 editor: this, 10895 event: a.event, 10896 transaction: s 10897 }), !(n.getMeta("preventUpdate") || !t.some((c)=>c.docChanged) || o.doc.eq(e.doc)) && this.emit("update", { 10898 editor: this, 10899 transaction: n, 10900 appendedTransactions: t.slice(1) 10901 }); 10902 } 10903 getAttributes(n) { 10904 return wd(this.state, n); 10905 } 10906 isActive(n, e) { 10907 const t = typeof n == "string" ? n : null, r = typeof n == "string" ? e : n; 10908 return vd(this.state, t, r); 10909 } 10910 getJSON() { 10911 return this.state.doc.toJSON(); 10912 } 10913 getHTML() { 10914 return Yr(this.state.doc.content, this.schema); 10915 } 10916 getText(n) { 10917 const { blockSeparator: e = ` 10918 10919`, textSerializers: t = {} } = n || {}; 10920 return xd(this.state.doc, { 10921 blockSeparator: e, 10922 textSerializers: { 10923 ...Tl(this.schema), 10924 ...t 10925 } 10926 }); 10927 } 10928 get isEmpty() { 10929 return Xr(this.state.doc); 10930 } 10931 destroy() { 10932 this.destroyed || (this.destroyed = !0, this.emit("destroy"), this.unmount(), this.removeAllListeners(), this.extensionManager.destroy(), this.extensionManager = null, this.schema = null, this.commandManager = null, this.extensionStorage = {}); 10933 } 10934 get isDestroyed() { 10935 var n, e; 10936 return (n = (e = this.editorView) === null || e === void 0 ? void 0 : e.isDestroyed) !== null && n !== void 0 ? n : !0; 10937 } 10938 $node(n, e) { 10939 var t; 10940 return ((t = this.$doc) === null || t === void 0 ? void 0 : t.querySelector(n, e)) || null; 10941 } 10942 $nodes(n, e) { 10943 var t; 10944 return ((t = this.$doc) === null || t === void 0 ? void 0 : t.querySelectorAll(n, e)) || null; 10945 } 10946 $pos(n) { 10947 const e = this.state.doc.resolve(n), t = n > 0 && e.nodeAfter && !e.nodeAfter.isText && e.nodeAfter.isAtom ? e.nodeAfter : null; 10948 return new Ph(e, this, !1, t); 10949 } 10950 get $doc() { 10951 return this.$pos(0); 10952 } 10953 }; 10954 Q = class Fl extends Qr { 10955 constructor(...e){ 10956 super(...e), this.type = "node"; 10957 } 10958 static create(e = {}) { 10959 const t = typeof e == "function" ? e() : e; 10960 return new Fl(t); 10961 } 10962 configure(e) { 10963 return super.configure(e); 10964 } 10965 extend(e) { 10966 const t = typeof e == "function" ? e() : e; 10967 return super.extend(t); 10968 } 10969 }; 10970 class Ll { 10971 nodeMappings; 10972 markMappings; 10973 unknownBlock; 10974 unknownLeaf; 10975 unknownMark; 10976 schema; 10977 constructor(e){ 10978 const t = Lh(e); 10979 Vh(t.nodes); 10980 const r = { 10981 attrs: { 10982 unknownMarks: { 10983 default: null 10984 } 10985 }, 10986 toDOM () { 10987 return [ 10988 "span", 10989 { 10990 "data-unknown-mark": !0 10991 } 10992 ]; 10993 } 10994 }; 10995 t.marks != null ? t.marks.unknownMark = r : t.marks = { 10996 unknownMark: r 10997 }, t.nodes.unknownLeaf = { 10998 inline: !0, 10999 attrs: { 11000 isAmgBlock: { 11001 default: !0 11002 }, 11003 unknownBlock: { 11004 default: null 11005 } 11006 }, 11007 group: "inline", 11008 toDOM () { 11009 return document.createTextNode("u{fffc}"); 11010 } 11011 }; 11012 const i = new Dr(t), o = [], s = []; 11013 let l = null; 11014 for (const [a, c] of Object.entries(t.nodes)){ 11015 const f = c.automerge; 11016 if (f != null) { 11017 if (f.unknownBlock) { 11018 if (l != null) throw new Error("only one node can be marked as unknownBlock"); 11019 l = i.nodes[a]; 11020 } 11021 if (f.block != null) if (typeof f.block == "string") { 11022 const u = { 11023 blockName: f.block, 11024 outer: null, 11025 content: i.nodes[a], 11026 isEmbed: f.isEmbed || !1 11027 }; 11028 f.attrParsers != null && (u.attrParsers = f.attrParsers), o.push(u); 11029 } else for (const [u, d] of Object.entries(f.block.within)){ 11030 if (i.nodes[u] == null) throw new Error(`${c.name} references an unknown outer node 11031 ${u} in its within block mapping`); 11032 o.push({ 11033 blockName: d, 11034 outer: i.nodes[u], 11035 content: i.nodes[a] 11036 }); 11037 } 11038 } 11039 } 11040 for (const [a, c] of Object.entries(t.marks || {})){ 11041 const f = c.automerge; 11042 if (f != null && f.markName != null) { 11043 let u; 11044 f.parsers != null ? u = f.parsers : u = { 11045 fromAutomerge: ()=>({}), 11046 fromProsemirror: ()=>!0 11047 }, s.push({ 11048 automergeMarkName: f.markName, 11049 prosemirrorMark: i.marks[a], 11050 parsers: u 11051 }); 11052 } 11053 } 11054 if (l == null) throw new Error(`no unknown block specified: one node must be marked as the unknownblock 11055by setting the automerge.unknownBlock property to true`); 11056 this.unknownMark = i.marks.unknownMark, this.nodeMappings = o, this.markMappings = s, this.unknownLeaf = i.nodes.unknownLeaf, this.unknownBlock = l, this.schema = i; 11057 } 11058 expandConfig(e) { 11059 return this.markMappings.find((r)=>r.prosemirrorMark.name === e)?.prosemirrorMark.spec.inclusive ?? !0 ? "both" : "none"; 11060 } 11061 updateSpansConfig() { 11062 const e = { 11063 defaultExpand: "both", 11064 perMarkExpand: {} 11065 }, t = {}; 11066 for (const r of this.markMappings)t[r.automergeMarkName] = r.prosemirrorMark.spec.inclusive ?? !0 ? "both" : "none"; 11067 return e.perMarkExpand = t, e; 11068 } 11069 } 11070 function Lh(n) { 11071 const e = {}; 11072 for (const [r, i] of Object.entries(n.nodes)){ 11073 const o = Object.assign({}, i); 11074 i.attrs != null && (o.attrs = Object.assign({}, i.attrs)), e[r] = o; 11075 } 11076 const t = {}; 11077 if (n.marks != null) for (const [r, i] of Object.entries(n.marks)){ 11078 const o = Object.assign({}, i); 11079 i.attrs != null && (o.attrs = Object.assign({}, i.attrs)), t[r] = o; 11080 } 11081 return { 11082 nodes: e, 11083 marks: t 11084 }; 11085 } 11086 function Vh(n) { 11087 for (const [e, t] of Object.entries(n))e !== "text" && (t.attrs == null ? t.attrs = { 11088 isAmgBlock: { 11089 default: !1 11090 }, 11091 unknownAttrs: { 11092 default: null 11093 } 11094 } : (t.attrs.isAmgBlock = { 11095 default: !1 11096 }, t.attrs.unknownAttrs = { 11097 default: null 11098 })), t.automerge?.unknownBlock && (t.attrs == null ? t.attrs = { 11099 unknownParentBlock: { 11100 default: null 11101 }, 11102 unknownBlock: { 11103 default: null 11104 } 11105 } : (t.attrs.unknownParentBlock = { 11106 default: null 11107 }, t.attrs.unknownBlock = { 11108 default: null 11109 })); 11110 return n; 11111 } 11112 function Vl(n, e) { 11113 const t = {}; 11114 return e.forEach((r)=>{ 11115 const i = n.markMappings.find((o)=>o.prosemirrorMark === r.type); 11116 if (i != null) t[i.automergeMarkName] = i.parsers.fromProsemirror(r); 11117 else if (r.type === n.unknownMark) for (const [o, s] of Object.entries(r.attrs.unknownMarks))t[o] = s; 11118 }), t; 11119 } 11120 function Zr(n, e) { 11121 const t = {}; 11122 let r = !1; 11123 const i = []; 11124 for (const [o, s] of Object.entries(e)){ 11125 if (s == null) continue; 11126 const l = n.markMappings.find((a)=>a.automergeMarkName === o); 11127 l == null ? (t[o] = s, r = !0) : i.push(l.prosemirrorMark.create(l.parsers.fromAutomerge(s))); 11128 } 11129 return r && i.push(n.unknownMark.create({ 11130 unknownMarks: t 11131 })), i; 11132 } 11133 const $h = [ 11134 "p", 11135 0 11136 ], jh = [ 11137 "blockquote", 11138 0 11139 ], Wh = [ 11140 "hr" 11141 ], Jh = [ 11142 "pre", 11143 [ 11144 "code", 11145 0 11146 ] 11147 ], qh = [ 11148 "em", 11149 0 11150 ], Kh = [ 11151 "strong", 11152 0 11153 ], Hh = [ 11154 "code", 11155 0 11156 ], _h = [ 11157 "ol", 11158 0 11159 ], Uh = [ 11160 "ul", 11161 0 11162 ], Yh = [ 11163 "li", 11164 0 11165 ], Gh = { 11166 nodes: { 11167 doc: { 11168 content: "block+" 11169 }, 11170 paragraph: { 11171 automerge: { 11172 block: "paragraph" 11173 }, 11174 content: "inline*", 11175 group: "block", 11176 parseDOM: [ 11177 { 11178 tag: "p" 11179 } 11180 ], 11181 toDOM () { 11182 return $h; 11183 } 11184 }, 11185 unknownBlock: { 11186 automerge: { 11187 unknownBlock: !0 11188 }, 11189 group: "block", 11190 content: "block+", 11191 parseDOM: [ 11192 { 11193 tag: "div", 11194 attrs: { 11195 "data-unknown-block": "true" 11196 } 11197 } 11198 ], 11199 toDOM () { 11200 return [ 11201 "div", 11202 { 11203 "data-unknown-block": "true" 11204 }, 11205 0 11206 ]; 11207 } 11208 }, 11209 blockquote: { 11210 automerge: { 11211 block: "blockquote" 11212 }, 11213 content: "block+", 11214 group: "block", 11215 defining: !0, 11216 parseDOM: [ 11217 { 11218 tag: "blockquote" 11219 } 11220 ], 11221 toDOM () { 11222 return jh; 11223 } 11224 }, 11225 horizontal_rule: { 11226 group: "block", 11227 parseDOM: [ 11228 { 11229 tag: "hr" 11230 } 11231 ], 11232 toDOM () { 11233 return Wh; 11234 } 11235 }, 11236 heading: { 11237 automerge: { 11238 block: "heading", 11239 attrParsers: { 11240 fromAutomerge: (n)=>({ 11241 level: n.attrs.level 11242 }), 11243 fromProsemirror: (n)=>({ 11244 level: n.attrs.level 11245 }) 11246 } 11247 }, 11248 attrs: { 11249 level: { 11250 default: 1 11251 } 11252 }, 11253 content: "inline*", 11254 group: "block", 11255 defining: !0, 11256 parseDOM: [ 11257 { 11258 tag: "h1", 11259 attrs: { 11260 level: 1 11261 } 11262 }, 11263 { 11264 tag: "h2", 11265 attrs: { 11266 level: 2 11267 } 11268 }, 11269 { 11270 tag: "h3", 11271 attrs: { 11272 level: 3 11273 } 11274 }, 11275 { 11276 tag: "h4", 11277 attrs: { 11278 level: 4 11279 } 11280 }, 11281 { 11282 tag: "h5", 11283 attrs: { 11284 level: 5 11285 } 11286 }, 11287 { 11288 tag: "h6", 11289 attrs: { 11290 level: 6 11291 } 11292 } 11293 ], 11294 toDOM (n) { 11295 return [ 11296 "h" + n.attrs.level, 11297 0 11298 ]; 11299 } 11300 }, 11301 code_block: { 11302 automerge: { 11303 block: "code-block" 11304 }, 11305 content: "text*", 11306 marks: "", 11307 group: "block", 11308 code: !0, 11309 defining: !0, 11310 parseDOM: [ 11311 { 11312 tag: "pre", 11313 preserveWhitespace: "full" 11314 } 11315 ], 11316 toDOM () { 11317 return Jh; 11318 } 11319 }, 11320 text: { 11321 group: "inline" 11322 }, 11323 image: { 11324 automerge: { 11325 block: "image", 11326 isEmbed: !0, 11327 attrParsers: { 11328 fromAutomerge: (n)=>({ 11329 src: n.attrs.src?.toString() || null, 11330 alt: n.attrs.alt, 11331 title: n.attrs.title 11332 }), 11333 fromProsemirror: (n)=>({ 11334 src: new Te(n.attrs.src), 11335 alt: n.attrs.alt, 11336 title: n.attrs.title 11337 }) 11338 } 11339 }, 11340 inline: !0, 11341 attrs: { 11342 src: {}, 11343 alt: { 11344 default: null 11345 }, 11346 title: { 11347 default: null 11348 } 11349 }, 11350 group: "inline", 11351 draggable: !0, 11352 parseDOM: [ 11353 { 11354 tag: "img[src]", 11355 getAttrs (n) { 11356 return { 11357 src: n.getAttribute("src"), 11358 title: n.getAttribute("title"), 11359 alt: n.getAttribute("alt") 11360 }; 11361 } 11362 } 11363 ], 11364 toDOM (n) { 11365 const { src: e, alt: t, title: r } = n.attrs; 11366 return [ 11367 "img", 11368 { 11369 src: e, 11370 alt: t, 11371 title: r 11372 } 11373 ]; 11374 } 11375 }, 11376 ordered_list: { 11377 group: "block", 11378 content: "list_item+", 11379
11379 attrs: { 11380 order: { 11381 default: 1 11382 } 11383 }, 11384 parseDOM: [ 11385 { 11386 tag: "ol", 11387 getAttrs (n) { 11388 return { 11389 order: n.hasAttribute("start") ? +n.getAttribute("start") : 1 11390 }; 11391 } 11392 } 11393 ], 11394 toDOM (n) { 11395 return n.attrs.order == 1 ? _h : [ 11396 "ol", 11397 { 11398 start: n.attrs.order 11399 }, 11400 0 11401 ]; 11402 } 11403 }, 11404 bullet_list: { 11405 content: "list_item+", 11406 group: "block", 11407 parseDOM: [ 11408 { 11409 tag: "ul" 11410 } 11411 ], 11412 toDOM () { 11413 return Uh; 11414 } 11415 }, 11416 list_item: { 11417 automerge: { 11418 block: { 11419 within: { 11420 ordered_list: "ordered-list-item", 11421 bullet_list: "unordered-list-item" 11422 } 11423 } 11424 }, 11425 content: "paragraph block*", 11426 parseDOM: [ 11427 { 11428 tag: "li" 11429 } 11430 ], 11431 toDOM () { 11432 return Yh; 11433 }, 11434 defining: !0 11435 }, 11436 aside: { 11437 automerge: { 11438 block: "aside" 11439 }, 11440 content: "block+", 11441 group: "block", 11442 defining: !0, 11443 parseDOM: [ 11444 { 11445 tag: "aside" 11446 } 11447 ], 11448 toDOM () { 11449 return [ 11450 "aside", 11451 0 11452 ]; 11453 } 11454 } 11455 }, 11456 marks: { 11457 link: { 11458 attrs: { 11459 href: {}, 11460 title: { 11461 default: null 11462 } 11463 }, 11464 inclusive: !1, 11465 parseDOM: [ 11466 { 11467 tag: "a[href]", 11468 getAttrs (n) { 11469 return { 11470 href: n.getAttribute("href"), 11471 title: n.getAttribute("title") 11472 }; 11473 } 11474 } 11475 ], 11476 toDOM (n) { 11477 const { href: e, title: t } = n.attrs; 11478 return [ 11479 "a", 11480 { 11481 href: e, 11482 title: t 11483 }, 11484 0 11485 ]; 11486 }, 11487 automerge: { 11488 markName: "link", 11489 parsers: { 11490 fromAutomerge: (n)=>{ 11491 if (typeof n == "string") try { 11492 const e = JSON.parse(n); 11493 return { 11494 href: e.href || "", 11495 title: e.title || "" 11496 }; 11497 } catch { 11498 console.warn("failed to parse link mark as JSON"); 11499 } 11500 return { 11501 href: "", 11502 title: "" 11503 }; 11504 }, 11505 fromProsemirror: (n)=>JSON.stringify({ 11506 href: n.attrs.href, 11507 title: n.attrs.title 11508 }) 11509 } 11510 } 11511 }, 11512 em: { 11513 parseDOM: [ 11514 { 11515 tag: "i" 11516 }, 11517 { 11518 tag: "em" 11519 }, 11520 { 11521 style: "font-style=italic" 11522 }, 11523 { 11524 style: "font-style=normal", 11525 clearMark: (n)=>n.type.name == "em" 11526 } 11527 ], 11528 toDOM () { 11529 return qh; 11530 }, 11531 automerge: { 11532 markName: "em" 11533 } 11534 }, 11535 strong: { 11536 parseDOM: [ 11537 { 11538 tag: "strong" 11539 }, 11540 { 11541 tag: "b", 11542 getAttrs: (n)=>n.style.fontWeight != "normal" && null 11543 }, 11544 { 11545 style: "font-weight=400", 11546 clearMark: (n)=>n.type.name == "strong" 11547 }, 11548 { 11549 style: "font-weight", 11550 getAttrs: (n)=>/^(bold(er)?|[5-9]\d{2,})$/.test(n) && null 11551 } 11552 ], 11553 toDOM () { 11554 return Kh; 11555 }, 11556 automerge: { 11557 markName: "strong" 11558 } 11559 }, 11560 code: { 11561 parseDOM: [ 11562 { 11563 tag: "code" 11564 } 11565 ], 11566 toDOM () { 11567 return Hh; 11568 } 11569 } 11570 } 11571 }; 11572 new Ll(Gh); 11573 function Xh(n) { 11574 const { type: e, parents: t, attrs: r, isEmbed: i } = n; 11575 let o; 11576 Nn(e) ? o = e : o = new Te("paragraph"); 11577 const s = {}; 11578 if (r && typeof r == "object") for (const [c, f] of Object.entries(r))s[c] = f; 11579 let l; 11580 return Qh(t) ? l = t : l = [], { 11581 type: o, 11582 parents: l, 11583 attrs: s, 11584 isEmbed: !!i 11585 }; 11586 } 11587 function Qh(n) { 11588 if (!Array.isArray(n)) return !1; 11589 for (const e of n)if (!Nn(e)) return !1; 11590 return !0; 11591 } 11592 function Zh(n) { 11593 return n.type === "text" ? { 11594 type: "text", 11595 value: n.value, 11596 marks: n.marks 11597 } : { 11598 type: "block", 11599 value: Xh(n.value) 11600 }; 11601 } 11602 ei = function(n, e) { 11603 const t = ti(n, e), r = [ 11604 { 11605 tag: "doc", 11606 attrs: {}, 11607 children: [] 11608 } 11609 ]; 11610 let i = null; 11611 for (const o of t){ 11612 if (o.type === "openTag") { 11613 const s = Object.assign({}, i, o.attrs); 11614 r.push({ 11615 tag: o.tag, 11616 attrs: s, 11617 children: [] 11618 }); 11619 } else if (o.type === "closeTag") { 11620 const { children: s, attrs: l, tag: a } = r.pop(), c = rr(n.schema, a, l, s); 11621 r[r.length - 1].children.push(c); 11622 } else if (o.type === "leafNode") r[r.length - 1].children.push(rr(n.schema, o.tag, i || {}, [])); 11623 else if (o.type === "text") { 11624 const s = Zr(n, o.marks); 11625 r[r.length - 1].children.push(n.schema.text(o.text, s)); 11626 } 11627 o.type === "block" ? (i = { 11628 isAmgBlock: !0, 11629 ...o.block.attrs 11630 }, o.isUnknown && (i.unknownBlock = o.block)) : i = null; 11631 } 11632 if (r.length !== 1) throw new Error("Invalid stack length"); 11633 { 11634 const { children: o, attrs: s, tag: l } = r[0]; 11635 return rr(n.schema, l, s, o); 11636 } 11637 }; 11638 function rr(n, e, t, r) { 11639 const i = {}, o = {}; 11640 let s = !1; 11641 for (const l of Object.keys(t)){ 11642 if (l === "isAmgBlock" || l === "unknownBlock" || l === "unknownAttrs") { 11643 i[l] = t[l]; 11644 continue; 11645 } 11646 n.nodes[e]?.spec?.attrs?.[l] != null ? i[l] = t[l] : (s = !0, o[l] = t[l]); 11647 } 11648 return s && (i.unknownAttrs = o), n.node(e, i, r); 11649 } 11650 wn = function(n, e, t) { 11651 const r = $l(ti(n, e)); 11652 let i = null; 11653 for (const o of r){ 11654 if (o.before.amIdx >= t && i != null) return i; 11655 if (o.event.type === "openTag") n.schema.nodes[o.event.tag].isTextblock && (i = o.after.pmIdx); 11656 else if (o.event.type === "leafNode") i = o.after.pmIdx; 11657 else if (o.event.type === "text" && (i = o.after.pmIdx, o.after.amIdx >= t && o.before.amIdx + o.event.text.length >= t)) { 11658 const s = t - o.before.amIdx; 11659 return o.before.pmIdx + s - 1; 11660 } 11661 } 11662 return i; 11663 }; 11664 function* $l(n) { 11665 let e = 0, t = -1; 11666 for(;;){ 11667 const r = n.next(); 11668 if (r.done) return; 11669 const i = r.value, o = { 11670 amIdx: t, 11671 pmIdx: e 11672 }; 11673 i.type === "openTag" && i.tag !== "doc" || i.type === "closeTag" && i.tag !== "doc" || i.type === "leafNode" ? e += 1 : i.type === "text" ? (t += i.text.length, e += i.text.length) : i.type === "block" && (t += 1), yield { 11674 event: i, 11675 before: o, 11676 after: { 11677 amIdx: t, 11678 pmIdx: e 11679 } 11680 }; 11681 } 11682 } 11683 function* ep(n, e) { 11684 const t = [ 11685 { 11686 node: e, 11687 parent: null, 11688 indexInParent: 0, 11689 numChildrenInParent: e.childCount, 11690 type: "node" 11691 } 11692 ], r = []; 11693 for(; t.length > 0;){ 11694 const i = t.pop(); 11695 if (i == null) return; 11696 if (i.type === "node") { 11697 const o = i.node; 11698 if (o.isText) { 11699 const s = Vl(n, o.marks); 11700 yield { 11701 type: "text", 11702 text: o.text, 11703 marks: s 11704 }; 11705 } else { 11706 const s = tp(n, o, r, i.indexInParent, i.numChildrenInParent), l = s != null ? "explicit" : "render-only"; 11707 if (s != null) { 11708 const { block: a, isUnknown: c } = s; 11709 yield { 11710 type: "block", 11711 isUnknown: c, 11712 block: a 11713 }; 11714 } 11715 if (o.isLeaf) yield { 11716 type: "leafNode", 11717 tag: o.type.name, 11718 role: l 11719 }; 11720 else { 11721 yield { 11722 type: "openTag", 11723 tag: o.type.name, 11724 role: l 11725 }, r.push(o), t.push({ 11726 type: "closeTag", 11727 tag: o.type.name, 11728 role: l 11729 }); 11730 for(let a = o.childCount - 1; a >= 0; a--)t.push({ 11731 parent: o, 11732 indexInParent: a, 11733 numChildrenInParent: o.childCount, 11734 type: "node", 11735 node: o.child(a) 11736 }); 11737 } 11738 } 11739 } else i.type === "closeTag" && r.pop(), yield i; 11740 } 11741 } 11742 function tp(n, e, t, r, i) { 11743 if (e.attrs.unknownBlock != null) return { 11744 isUnknown: !0, 11745 block: e.attrs.unknownBlock 11746 }; 11747 const o = jl(n, e, t); 11748 if (o == null) { 11749 if (e.attrs.isAmgBlock) throw new Error("no mapping found for node which is marked as a block"); 11750 return null; 11751 } 11752 const s = o.attrParsers?.fromProsemirror(e) || {}; 11753 if (e.attrs.unknownAttrs != null) for (const l of Object.keys(e.attrs.unknownAttrs))s[l] = e.attrs.unknownAttrs[l]; 11754 if (e.attrs.isAmgBlock) return { 11755 isUnknown: !1, 11756 block: { 11757 type: o.blockName,
11758 parents: ir(n, t, e), 11759 attrs: s, 11760 isEmbed: o.isEmbed || !1 11761 } 11762 }; 11763 if (o && o.isEmbed) return { 11764 isUnknown: !1, 11765 block: { 11766 type: o.blockName, 11767 parents: ir(n, t, e), 11768 attrs: s, 11769 isEmbed: !0 11770 } 11771 }; 11772 { 11773 const l = rp(e); 11774 if (l != null) { 11775 const c = o.content.contentMatch.fillBefore(k.from([ 11776 l.first 11777 ]), !0); 11778 if (c == null) throw new Error("schema could not find wrapping"); 11779 if (c.eq(l.contentBeforeFirst)) return null; 11780 } 11781 let a = !1; 11782 if (e.isTextblock || e.isInline) { 11783 const c = t[t.length - 1]; 11784 c == null || c.type === n.schema.nodes.doc && i > 1 ? a = !0 : c.type.contentMatch.defaultType === e.type && r === 0 && !e.attrs.isAmgBlock || (a = !0); 11785 } else np(e) && (a = !0); 11786 return a ? { 11787 isUnknown: o.content === n.unknownBlock, 11788 block: { 11789 type: o.blockName, 11790 parents: ir(n, t, e), 11791 attrs: s, 11792 isEmbed: o.isEmbed || !1 11793 } 11794 } : null; 11795 } 11796 } 11797 function np(n) { 11798 for(let e = 0; e < n.childCount; e++)if (n.child(e).isTextblock) return !0; 11799 return !1; 11800 } 11801 function rp(n) { 11802 let e = 0, t = null; 11803 const r = []; 11804 for(let i = 0; i < n.childCount; i++){ 11805 const o = n.child(i); 11806 let s = !1; 11807 if (o.attrs.isAmgBlock ? s = !0 : o.descendants((l)=>l.attrs.isAmgBlock ? (s = !0, !1) : !0), s && (e++, t == null && (t = o)), t == null && r.push(o), e > 1) break; 11808 } 11809 return e > 0 ? { 11810 contentBeforeFirst: k.from(r), 11811 first: t 11812 } : null; 11813 } 11814 function jl(n, e, t) { 11815 if (e.type === n.unknownBlock && e.attrs.unknownParentBlock) return { 11816 blockName: e.attrs.unknownParentBlock, 11817 content: e.type, 11818 outer: null, 11819 isEmbed: !1 11820 }; 11821 const r = n.nodeMappings.filter((s)=>s.content === e.type); 11822 if (r.length === 0) return null; 11823 const i = t[t.length - 1]; 11824 let o = r[0]; 11825 for (const s of r)if (i != null && s.outer === i.type) { 11826 o = s; 11827 break; 11828 } 11829 return o; 11830 } 11831 function ir(n, e, t) { 11832 const r = []; 11833 for (const [i, o] of e.entries()){ 11834 if (i === e.length - 1 && o.isTextblock && !o.attrs.isAmgBlock && t.isText) continue; 11835 const s = jl(n, o, e.slice(0, i)); 11836 s != null && r.push(s.blockName); 11837 } 11838 return r; 11839 } 11840 function* ti(n, e) { 11841 const t = e.map(Zh); 11842 if (t.length === 0) return yield* [ 11843 { 11844 type: "openTag", 11845 tag: "paragraph", 11846 role: "render-only" 11847 }, 11848 { 11849 type: "closeTag", 11850 tag: "paragraph", 11851 role: "render-only" 11852 } 11853 ]; 11854 const r = new ip(n); 11855 for (const i of t)i.type === "block" ? yield* r.newBlock(i.value) : yield* r.newText(i.value, i.marks || {}); 11856 yield* r.finish(); 11857 } 11858 class ip { 11859 adapter; 11860 lastBlock = null; 11861 stack = []; 11862 topMatch; 11863 constructor(e){ 11864 this.adapter = e, this.stack = [], this.topMatch = this.adapter.schema.nodes.doc.contentMatch; 11865 } 11866 set currentMatch(e) { 11867 if (e === null) throw new Error("Match cannot be null"); 11868 this.stack.length > 0 ? this.stack[this.stack.length - 1].lastMatch = e : this.topMatch = e; 11869 } 11870 get currentMatch() { 11871 return this.stack.length > 0 ? this.stack[this.stack.length - 1].lastMatch : this.topMatch; 11872 } 11873 *newBlock(e) { 11874 if (e.isEmbed) { 11875 const { content: s } = Mn(this.adapter, e.type.val, e.isEmbed), l = this.currentMatch.findWrapping(s); 11876 if (l) for(let a = 0; a < l.length; a++)yield this.pushNode(l[a], null, "render-only"); 11877 this.currentMatch = this.currentMatch.matchType(s), yield ko(this.adapter, e), yield { 11878 type: "leafNode", 11879 tag: s.name, 11880 role: "explicit" 11881 }; 11882 return; 11883 } 11884 const t = op(this.adapter, e); 11885 let r = 0; 11886 for(; r < t.length && r < this.stack.length && this.stack[r].node === t[r].type;)r++; 11887 const i = this.stack.splice(r); 11888 for (const { node: s, role: l, lastMatch: a } of i.toReversed())yield* this.finishStackFrame({ 11889 node: s, 11890 role: l, 11891 lastMatch: a 11892 }), yield { 11893 type: "closeTag", 11894 tag: s.name, 11895 role: l 11896 }; 11897 for(let s = r; s < t.length; s++){ 11898 const { type: l, attrs: a } = t[s]; 11899 yield* this.fillBefore(l), yield this.pushNode(l, a, "render-only"); 11900 } 11901 yield ko(this.adapter, e); 11902 const { content: o } = Mn(this.adapter, e.type.val, e.isEmbed || !1); 11903 yield this.pushNode(o, null, "explicit"); 11904 } 11905 pushNode(e, t, r) { 11906 return this.currentMatch = this.currentMatch.matchType(e), this.stack.push({ 11907 node: e, 11908 role: r, 11909 lastMatch: e.contentMatch 11910 }), { 11911 type: "openTag", 11912 tag: e.name, 11913 role: r, 11914 ...t && { 11915 attrs: t 11916 } 11917 }; 11918 } 11919 *newText(e, t) { 11920 const r = this.currentMatch.findWrapping(this.adapter.schema.nodes.text); 11921 if (r) for(let i = 0; i < r.length; i++)yield this.pushNode(r[i], null, "render-only"); 11922 this.currentMatch = this.currentMatch.matchType(this.adapter.schema.nodes.text), yield { 11923 type: "text", 11924 text: e, 11925 marks: t 11926 }; 11927 } 11928 *finish() { 11929 for (const { node: e, role: t, lastMatch: r } of this.stack.toReversed())yield* this.finishStackFrame({ 11930 node: e, 11931 role: t, 11932 lastMatch: r 11933 }), yield { 11934 type: "closeTag", 11935 tag: e.name, 11936 role: t 11937 }; 11938 } 11939 *fillBefore(e) { 11940 const t = this.currentMatch.fillBefore(k.from(e.create())); 11941 t != null && (yield* this.emitFragment(t), this.currentMatch = this.currentMatch.matchFragment(t)); 11942 } 11943 *emitFragment(e) { 11944 const t = []; 11945 for(let r = e.childCount - 1; r >= 0; r--)t.push({ 11946 type: "open", 11947 node: e.child(r) 11948 }); 11949 for(; t.length > 0;){ 11950 const r = t.pop(); 11951 if (r == null) return; 11952 if (r.type === "open") if (yield { 11953 type: "openTag",
11954 tag: r.node.type.name, 11955 role: "render-only" 11956 }, r.node.isText) yield { 11957 type: "text", 11958 text: r.node.text, 11959 marks: {} 11960 }, yield { 11961 type: "closeTag", 11962 tag: r.node.type.name, 11963 role: "render-only" 11964 }; 11965 else { 11966 t.push({ 11967 type: "close", 11968 node: r.node.type 11969 }); 11970 for(let i = r.node.childCount - 1; i >= 0; i--)t.push({ 11971 type: "open", 11972 node: r.node.child(i) 11973 }); 11974 } 11975 else yield { 11976 type: "closeTag", 11977 tag: r.node.name, 11978 role: "render-only" 11979 }; 11980 } 11981 } 11982 *finishStackFrame(e) { 11983 const t = e.lastMatch.fillBefore(k.empty, !0); 11984 t && (yield* this.emitFragment(t)); 11985 } 11986 } 11987 function op(n, e) { 11988 const t = []; 11989 for (const i of e.parents){ 11990 const { outer: o, content: s, attrs: l } = Mn(n, i.val, !1); 11991 o != null && t.push({ 11992 type: o, 11993 attrs: null 11994 }), t.push({ 11995 type: s, 11996 attrs: l || null 11997 }); 11998 } 11999 const { outer: r } = Mn(n, e.type.val, e.isEmbed || !1); 12000 return r != null && t.push({ 12001 type: r, 12002 attrs: null 12003 }), t; 12004 } 12005 function ko(n, e) { 12006 const t = n.nodeMappings.find((i)=>i.blockName === e.type.val), r = { 12007 ...e.attrs 12008 }; 12009 for (const [i, o] of Object.entries(r))Nn(o) && (r[i] = o.val); 12010 return { 12011 type: "block", 12012 isUnknown: t == null, 12013 block: { 12014 attrs: r, 12015 parents: e.parents.map((i)=>i.val), 12016 type: e.type.val, 12017 isEmbed: e.isEmbed || !1 12018 } 12019 }; 12020 } 12021 ni = function(n, e, { from: t, to: r }) { 12022 const i = $l(ti(n, e)); 12023 let o = null, s = null, l = null, a = null; 12024 for(t === 0 && (o = 0); l == null || l <= r || o == null || s == null;){ 12025 const c = i.next(); 12026 if (c.done) break; 12027 const f = c.value; 12028 if (l = f.after.pmIdx, a = f.after.amIdx, o == null) { 12029 if (f.after.pmIdx < t) continue; 12030 if (f.event.type === "text") if (f.before.pmIdx > t) o = Math.max(f.before.amIdx, 0) + 1; 12031 else if (f.before.pmIdx + f.event.text.length > t) { 12032 const u = t - f.before.pmIdx; 12033 o = f.before.amIdx + u + 1; 12034 } else o = Math.max(f.after.amIdx, 0) + 1; 12035 else f.after.pmIdx >= t && (o = f.after.amIdx + 1); 12036 } 12037 if (s == null) { 12038 if (f.after.pmIdx < r) continue; 12039 if (f.event.type === "text") { 12040 if (f.before.pmIdx >= r) s = f.before.amIdx + 1; 12041 else if (f.before.pmIdx + f.event.text.length > r) { 12042 const u = r - f.before.pmIdx; 12043 s = f.before.amIdx + u + 1; 12044 } 12045 } else f.before.pmIdx >= r && (s = f.before.amIdx + 1); 12046 } 12047 } 12048 if (o != null) return s == null && (s = a ? a + 1 : o), { 12049 start: o, 12050 end: s 12051 }; 12052 { 12053 const c = a ? a + 1 : 0; 12054 return { 12055 start: c, 12056 end: c 12057 }; 12058 } 12059 }; 12060 function Wl(n, e) { 12061 const t = ep(n, e), r = []; 12062 for (const i of t)if (i.type == "block") { 12063 const o = { 12064 ...i.block.attrs 12065 }; 12066 delete o.isAmgBlock, r.push({ 12067 type: "block", 12068 value: { 12069 type: new Te(i.block.type), 12070 parents: i.block.parents.map((s)=>new Te(s)), 12071 attrs: o, 12072 isEmbed: i.block.isEmbed 12073 } 12074 }); 12075 } else i.type == "text" && r.push({ 12076 type: "text", 12077 value: i.text, 12078 marks: i.marks 12079 }); 12080 return r; 12081 } 12082 function Mn(n, e, t) { 12083 const r = n.nodeMappings.find((i)=>i.blockName === e); 12084 return r == null ? t ? { 12085 outer: null, 12086 content: n.unknownLeaf 12087 } : { 12088 outer: null, 12089 content: n.unknownBlock, 12090 attrs: { 12091 unknownParentBlock: e 12092 } 12093 } : { 12094 outer: r.outer, 12095 content: r.content 12096 }; 12097 } 12098 function sp(n, e, t, r, i, o) { 12099 let s = []; 12100 function l() { 12101 s.length > 0 && (fp(n, e, s, r, o), s = []); 12102 } 12103 for (const a of t){ 12104 const c = a.toJSON().stepType; 12105 if (c === "addMark") { 12106 s.push(a); 12107 continue; 12108 } else l(); 12109 lp(n, e, c, a, r, i, o); 12110 const f = a.apply(i).doc; 12111 if (f == null) throw new Error("Could not apply step to document"); 12112 i = f, e = it(r, o); 12113 } 12114 l(); 12115 } 12116 function lp(n, e, t, r, i, o, s) { 12117 t === "replace" ? ap(n, e, r, i, s, o) : t === "replaceAround" ? cp(n, r, i, o, s) : t === "removeMark" && up(n, e, r, i, s); 12118 } 12119 function ap(n, e, t, r, i, o) { 12120 if (t.slice.content.childCount === 1 && t.slice.content.firstChild?.isText) { 12121 const a = ni(n, e, { 12122 from: t.from, 12123 to: t.to 12124 }); 12125 if (a == null) throw new Error(`Could not find range (${t.from}, ${t.to}) in render tree`); 12126 let { start: c, end: f } = a; 12127 c > f && ([c, f] = [ 12128 f, 12129 c 12130 ]); 12131 const u = f - c; 12132 Ql(r, i, c, u, t.slice.content.firstChild.text); 12133 const d = t.slice.content.firstChild.marks, h = t.slice.content.firstChild.text.length; 12134 dp(n, r, i, c, h, d); 12135 return; 12136 } 12137 const s = t.apply(o).doc; 12138 if (s == null) throw new Error("Could not apply step to document"); 12139 const l = Wl(n, s); 12140 No(r, i, l, n.updateSpansConfig()); 12141 } 12142 function cp(n, e, t, r, i) { 12143 const o = e.apply(r).doc; 12144 if (o == null) throw new Error("Could not apply step to document"); 12145 const s = Wl(n, o); 12146 No(t, i, s, n.updateSpansConfig()); 12147 } 12148 function fp(n, e, t, r, i) { 12149 const s = t.map((l)=>{ 12150 const a = ni(n, e, { 12151 from: l.from, 12152 to: l.to 12153 }); 12154 if (a == null) throw new Error(`Could not find range (${l.from}, ${l.to}) in render tree`); 12155 const c = l.mark.type.name, f = l.mark.type.spec.inclusive ? "both" : "none", u = hp(l.mark.type, l.mark.attrs); 12156 return { 12157 range: a, 12158 markName: c, 12159 expand: f, 12160 value: u 12161 }; 12162 }).reduce((l, a)=>{ 12163 const c = l[l.length - 1]; 12164 if (c == null) return [ 12165 a 12166 ]; 12167 if (c.markName === a.markName && c.expand === a.expand && c.value === a.value) { 12168 if (c.range.end === a.range.start) return c.range.end = a.range.end, l; 12169 if (e.slice(c.range.end, a.range.start).every((u)=>u.type === "block")) return c.range.end = a.range.end, l; 12170 } 12171 return l.push(a), l; 12172 }, []); 12173 for (const l of s)Oo(r, i, { 12174 start: l.range.start, 12175 end: l.range.end, 12176 expand: l.expand 12177 }, l.markName, l.value); 12178 } 12179 function up(n, e, t, r, i) { 12180 const o = ni(n, e, { 12181 from: t.from, 12182 to: t.to 12183 }); 12184 if (o == null) throw new Error(`Could not find range (${t.from}, ${t.to}) in render tree`); 12185 const { start: s, end: l } = o; 12186 if (s == null || l == null) throw new Error(`Could not find step.from (${t.from}) or step.to (${t.to}) in render tree`); 12187 const a = t.mark.type.name, c = t.mark.type.spec.inclusive ? "both" : "none"; 12188 Eo(r, i, { 12189 start: s, 12190 end: l, 12191 expand: c 12192 }, a); 12193 } 12194 function dp(n, e, t, r, i, o) { 12195 const s = Zl(e, t, r), l = Vl(n, o), a = new Set(Object.keys(l)), c = new Set(Object.keys(s)); 12196 for (const f of a)if (!c.has(f) || l[f] !== s[f]) { 12197 const u = o.find((d)=>d.type.name === f)?.type.spec.inclusive ?? !0 ? "both" : "none"; 12198 Oo(e, t, { 12199 start: r, 12200 end: r + i, 12201 expand: u 12202 }, f, l[f]); 12203 } 12204 for (const f of c)n.markMappings.find((d)=>d.automergeMarkName === f) != null && (a.has(f) || Eo(e, t, { 12205 start: r, 12206 end: r + i, 12207 expand: "both" 12208 }, f)); 12209 } 12210 function hp(n, e) { 12211 return n.name === "link" ? JSON.stringify(e) : (n.name === "strong" || n.name === "em" || n.name === "code", !0); 12212 } 12213 function Ln(n, e) { 12214 if (n.length !== e.length) return !1; 12215 for(let t = 0; t < n.length; t++)if (n[t] !== e[t]) return !1; 12216 return !0; 12217 } 12218 function Jl(n, e) { 12219 if (n.length > e.length) return !1; 12220 for(let t = 0; t < n.length; t++)if (n[t] !== e[t]) return !1; 12221 return !0; 12222 } 12223 function ln(n, e, t) { 12224 if (Ln(n, t.path)) { 12225 if (t.action === "mark") for (const r of t.marks)mp(e, r); 12226 } else if (Jl(n, t.path)) if (t.path.length === n.length + 1) t.action === "insert" ? kp(e, t) : t.action === "del" ? gp(e, t) : t.action === "splice" && pp(e, t); 12227 else { 12228 const r = t.path[n.length]; 12229 if (typeof r != "number") throw console.error(`Invalid path: ${t.path}`), new Error("Invalid path: expected number when patching spans"); 12230 const i = ql(e, r); 12231 if (i == null) throw new Error("Invalid path: unable to find block at index"); 12232 yp(n, t, i); 12233 } 12234 } 12235 function pp(n, e) { 12236 let t = 0; 12237 const r = e.path[e.path.length - 1]; 12238 if (typeof r != "number") return; 12239 let i = 0; 12240 for(; i < n.length;){ 12241 const o = n[i]; 12242 if (o.type === "text") if (t <= r && t + o.value.length > r) { 12243 const s = r - t, l = o.value.slice(0, s), a = o.value.slice(s); 12244 if ($e(o.marks, e.marks)) o.value = l + e.value + a; 12245 else { 12246 const c = [], f = n[i - 1]; 12247 l.length === 0 && f && f.type === "text" && $e(f.marks, e.marks) ? f.value += e.value : (l.length > 0 && c.push(ke({ 12248 value: l, 12249 marks: o.marks 12250 })), c.push(ke({ 12251 value: e.value, 12252 marks: e.marks 12253 }))), a.length > 0 && c.push(ke({ 12254 value: a, 12255 marks: o.marks 12256 })), n.splice(i, 1, ...c); 12257 } 12258 return; 12259 } else t += o.value.length, i += 1; 12260 else { 12261 if (t === r) { 12262 const s = n[i - 1]; 12263 if (s != null && s.type === "text" && $e(s.marks, e.marks)) s.value += e.value; 12264 else { 12265 const l = { 12266 type: "text", 12267 value: e.value 12268 }; 12269 e.marks != null && (l.marks = e.marks), n.splice(i, 0, l); 12270 } 12271 return; 12272 } 12273 t += 1, i += 1; 12274 } 12275 } 12276 if (t === r) { 12277 const o = n[n.length - 1]; 12278 if (o && o.type === "text" && $e(o.marks || {}, e.marks || {})) o.value += e.value; 12279 else { 12280 const s = { 12281 type: "text", 12282 value: e.value 12283 }; 12284 e.marks != null && (s.marks = e.marks), n.push(s); 12285 } 12286 } 12287 } 12288 function mp(n, e) { 12289 let t = 0, r = 0; 12290 for(; r < n.length;){ 12291 const i = n[r]; 12292 if (i.type === "text") { 12293 const o = t, s = t + i.value.length; 12294 if (o < e.end && s > e.start) { 12295 const l = Math.max(0, e.start - o), a = Math.min(i.value.length, e.end - o); 12296 l > 0 ? (n.splice(r, 1, ke({ 12297 value: i.value.slice(0, l), 12298 marks: i.marks 12299 }), ke({ 12300 value: i.value.slice(l, a), 12301 marks: { 12302 ...i.marks, 12303 [e.name]: e.value 12304 } 12305 })), r++) : n[r] = ke({ 12306 value: i.value.slice(0, a), 12307 marks: { 12308 ...i.marks, 12309 [e.name]: e.value 12310 } 12311 }), a < i.value.length && n.splice(r + 1, 0, ke({ 12312 value: i.value.slice(a), 12313 marks: i.marks 12314 })); 12315 const c = n[r - 1]; 12316 let f = n[r]; 12317 r > 0 && c.type === "text" && f.type === "text" && $e(c.marks, f.marks) ? (c.value += f.value, n.splice(r, 1)) : r++; 12318 const u = n[r + 1]; 12319 f = n[r], r < n.length - 1 && u.type === "text" && f.type === "text" && $e(u.marks, f.marks) && (f.value += u.value, n.splice(r + 1, 1)); 12320 } else r++; 12321 t += i.value.length; 12322 } else r++, t += 1; 12323 } 12324 } 12325 function gp(n, e) { 12326 const t = e.path[e.path.length - 1]; 12327 if (typeof t != "number") throw new Error("Invalid path: expected number when deleting spans"); 12328 const r = t + (e.length || 1); 12329 let i = 0, o = 0, s = 0; 12330 function l(a) { 12331 const c = n[a - 1], f = n[a]; 12332 if (c && c.type === "text" && f && f.type === "text" && $e(c.marks, f.marks)) { 12333 const u = c.value.length; 12334 return c.value += f.value, n.splice(a, 1), u; 12335 } 12336 } 12337 for(; s < n.length && i < r - t;){ 12338 const a = n[s], c = r - i; 12339 if (a.type === "text") { 12340 const f = o, u = o + a.value.length; 12341 if (f >= t && u <= c) n.splice(s, 1), i += a.value.length, l(s); 12342 else if (f < c && u > t) { 12343 const d = Math.max(0, t - f), h = Math.min(a.value.length, c - f); 12344 d > 0 && h < a.value.length ? (n.splice(s, 1, ke({ 12345 value: a.value.slice(0, d), 12346 marks: a.marks 12347 }), ke({ 12348 value: a.value.slice(h), 12349 marks: a.marks 12350 })), s++, o += d, i += h - d) : d > 0 ? (i += a.value.length - d, a.value = a.value.slice(0, d)) : h < a.value.length && (i += h, a.value = a.value.slice(h)); 12351 const p = l(s); 12352 p ? o -= p : (s++, o += a.value.length); 12353 } else o += a.value.length, s++; 12354 } else if (a.type === "block") if (o >= t && o < c) { 12355 n.splice(s, 1), i += 1; 12356 const f = l(s); 12357 f && (s--, o -= f); 12358 } else o++, s++; 12359 } 12360 } 12361 function yp(n, e, t) { 12362 const r = e.path.slice(n.length + 1); 12363 if (e.action === "put") { 12364 const i = tn(t, r.slice(0, -1)), o = e.path[e.path.length - 1]; 12365 i[o] = Cn(e.value); 12366 } else if (e.action === "insert") { 12367 const i = tn(t, r.slice(0, -2)), o = r.pop(), s = r.pop(), l = i[s]; 12368 if (!Array.isArray(l)) throw new Error("Invalid path: expected array when inserting"); 12369 l.splice(o, 0, ...Cn(e.values)); 12370 } else if (e.action === "splice") { 12371 const i = tn(t, r.slice(0, -2)), o = r.pop(), s = r.pop(), l = i[s], a = l.slice(0, o) + e.value + l.slice(o); 12372 i[s] = a; 12373 } else if (e.action === "del") { 12374
12374 const i = tn(t, r.slice(0, -1)), o = e.path[e.path.length - 1]; 12375 delete i[o]; 12376 } 12377 } 12378 function Cn(n) { 12379 if (Array.isArray(n)) return n.map(Cn); 12380 if (Nn(n)) return n; 12381 if (n instanceof Date) return new Date(n.getTime()); 12382 if (typeof n == "object" && n !== null) { 12383 const e = {}; 12384 for (const t of Object.keys(n))e[t] = Cn(n[t]); 12385 return e; 12386 } else return n; 12387 } 12388 function tn(n, e) { 12389 let t = n; 12390 for (const r of e){ 12391 if (typeof t != "object") throw new Error("Invalid path: expected object when resolving target"); 12392 t = t[r]; 12393 } 12394 return t; 12395 } 12396 function kp(n, e) { 12397 let t = 0, r = 0; 12398 const i = e.path[e.path.length - 1]; 12399 if (typeof i != "number") throw new Error(`Invalid patch path, expected a number got ", ${e.path[e.path.length - 1]}`); 12400 const o = []; 12401 for (const s of e.values){ 12402 if (!s || typeof s != "object") throw new Error("Invalid patch: expected object when inserting"); 12403 if (Object.keys(s).length !== 0) throw new Error("Invalid patch: unexpected nonempty object when inserting"); 12404 o.push({ 12405 type: "block", 12406 value: {} 12407 }); 12408 } 12409 for(; t < i && r < n.length;){ 12410 const s = n[r]; 12411 if (s.type == "text") { 12412 if (s.value.length + t > i) { 12413 const l = i - t, a = s.value.slice(0, l), c = s.value.slice(l); 12414 s.value = a, n.splice(r + 1, 0, ...o), n.splice(r + o.length + 1, 0, { 12415 type: "text", 12416 value: c 12417 }); 12418 return; 12419 } 12420 t += s.value.length; 12421 } else t += 1; 12422 r += 1; 12423 } 12424 n.splice(r, 0, ...o); 12425 } 12426 function ql(n, e) { 12427 let t = 0; 12428 for (const r of n)if (r.type === "block") { 12429 if (t === e) return r.value; 12430 t += 1; 12431 } else t += r.value.length; 12432 return null; 12433 } 12434 function $e(n, e) { 12435 if (n === e) return !0; 12436 if (!n || !e || Object.keys(n).length !== Object.keys(e).length) return !1; 12437 for(const t in n)if (n[t] !== e[t]) return !1; 12438 return !0; 12439 } 12440 function ke({ value: n, marks: e }) { 12441 const t = { 12442 type: "text", 12443 value: n 12444 }; 12445 return e != null && (t.marks = e), t; 12446 } 12447 function Kl(n, e, t, r, i) { 12448 const o = Cp(r, t); 12449 let s = i; 12450 for (const l of o)if (l.type === "text") for (const a of l.patches)if (a.action === "splice") s = bp(n, e, a, r, s), ln(r, e, a); 12451 else if (a.action === "del") { 12452 const c = a.path[a.path.length - 1]; 12453 ql(e, c) != null ? s = bo(n, r, e, c, [ 12454 a 12455 ], s) : s = xp(n, e, a, r, s), ln(r, e, a); 12456 } else a.action === "mark" && (s = Sp(n, e, a, r, s), ln(r, e, a)); 12457 else s = bo(n, r, e, l.index, l.patches, s); 12458 return s; 12459 } 12460 function bp(n, e, t, r, i) { 12461 const o = Hl(r, t.path); 12462 if (o === null) return i; 12463 const s = wn(n, e, o); 12464 if (s == null) throw new Error("Invalid index"); 12465 const l = Mp(n, t.value, t.marks); 12466 return i = i.step(new P(s, s, new b(l, 0, 0))), i; 12467 } 12468 function xp(n, e, t, r, i) { 12469 const o = Hl(r, t.path); 12470 if (o === null) return i; 12471 const s = wn(n, e, o); 12472 if (s == null) throw new Error("Invalid index"); 12473 const l = s + (t.length || 1); 12474 return i.delete(s, l); 12475 } 12476 function Sp(n, e, t, r, i) { 12477 if (Ln(t.path, r)) for (const o of t.marks){ 12478 const s = wn(n, e, o.start), l = wn(n, e, o.end); 12479 if (s == null || l == null) throw new Error("Invalid index"); 12480 if (o.value == null) { 12481 const a = n.markMappings.find((f)=>f.automergeMarkName === o.name), c = a ? a.prosemirrorMark : n.unknownMark; 12482 i = i.removeMark(s, l, c); 12483 } else { 12484 const a = Zr(n, { 12485 [o.name]: o.value 12486 }); 12487 for (const c of a)i = i.addMark(s, l, c); 12488 } 12489 } 12490 return i; 12491 } 12492 function bo(n, e, t, r, i, o) { 12493 for (const m of i)ln(e, t, m); 12494 const s = ei(n, t), l = wp(o.doc.content, s.content); 12495 if (l == null) return o; 12496 const a = s.resolve(l.start), c = s.resolve(l.endB), f = o.doc.resolve(l.start), u = a.sameParent(c) && a.parent.inlineContent && f.end() >= l.endA, d = l.start, h = l.endA; 12497 let p = !1; 12498 if (u) {
12499 if (a.pos == c.pos) p = !0, o = o.delete(d, h); 12500 else if (a.parent.child(a.index()).isText && a.index() == c.index() - (c.textOffset ? 0 : 1)) { 12501 p = !0; 12502 const m = a.parent.textBetween(a.parentOffset, c.parentOffset); 12503 o = o.insertText(m, d, h); 12504 } 12505 } 12506 return p || (o = o.replace(d, h, s.slice(l.start, l.endB))), o; 12507 } 12508 function wp(n, e) { 12509 let t = n.findDiffStart(e); 12510 if (t == null) return null; 12511 let { a: r, b: i } = n.findDiffEnd(e); 12512 return r < t && n.size < e.size ? (t && t < e.size && xo(e.textBetween(t - 1, t + 1)) && (t -= 1), i = t + (i - r), r = t) : i < t && (t && t < n.size && xo(n.textBetween(t - 1, t + 1)) && (t -= 1), r = t + (r - i), i = t), { 12513 start: t, 12514 endA: r, 12515 endB: i 12516 }; 12517 } 12518 function xo(n) { 12519 if (n.length != 2) return !1; 12520 const e = n.charCodeAt(0), t = n.charCodeAt(1); 12521 return e >= 56320 && e <= 57343 && t >= 55296 && t <= 56319; 12522 } 12523 function Hl(n, e) { 12524 if (e.length !== n.length + 1) return null; 12525 for(let r = 0; r < n.length; r++)if (n[r] !== e[r]) return null; 12526 const t = e[e.length - 1]; 12527 return typeof t == "number" ? t : null; 12528 } 12529 function Mp(n, e, t) { 12530 let r; 12531 return t != null && (r = Zr(n, t)), k.from(n.schema.text(e, r)); 12532 } 12533 function Cp(n, e) { 12534 const t = []; 12535 let r = { 12536 type: "gatheringText", 12537 gathered: [] 12538 }; 12539 function i() { 12540 r.type === "gatheringBlock" ? t.push({ 12541 type: "block", 12542 index: r.index, 12543 patches: r.gathered 12544 }) : r.type === "gatheringText" && t.push({ 12545 type: "text", 12546 patches: r.gathered 12547 }), r = { 12548 type: "transitioning" 12549 }; 12550 } 12551 for (const o of e)if (Jl(n, o.path)) if (Ln(n, o.path) && o.action === "mark") r.type === "gatheringText" ? r.gathered.push(o) : (i(), r = { 12552 type: "gatheringText", 12553 gathered: [ 12554 o 12555 ] 12556 }); 12557 else if (o.path.length === n.length + 1) { 12558 const s = o.path[o.path.length - 1]; 12559 typeof s == "number" && (o.action === "splice" || o.action === "del" ? r.type === "gatheringText" ? r.gathered.push(o) : (i(), r = { 12560 type: "gatheringText", 12561 gathered: [ 12562 o 12563 ] 12564 }) : o.action === "insert" && (i(), r = { 12565 type: "gatheringBlock", 12566 index: s, 12567 gathered: [ 12568 o 12569 ] 12570 })); 12571 } else { 12572 const s = o.path[n.length]; 12573 if (typeof s != "number") continue; 12574 r.type === "gatheringBlock" && r.index === s ? r.gathered.push(o) : (i(), r = { 12575 type: "gatheringBlock", 12576 index: s, 12577 gathered: [ 12578 o 12579 ] 12580 }); 12581 } 12582 return i(), t; 12583 } 12584 function Tp({ adapter: n, path: e, before: t, after: r, patches: i, state: o }) { 12585 const s = Ot(t), l = it(ea(r, s), e), a = Kl(n, l, i, e, o.tr); 12586 return a.setMeta("addToHistory", !1), a; 12587 } 12588 function vp(n) { 12589 let e = n.schema.cached.changeSetIDs || (n.schema.cached.changeSetIDs = Object.create(null)), t = e[n.name]; 12590 return t == null && (e[n.name] = t = Object.keys(n.schema.nodes).indexOf(n.name) + 1), t; 12591 } 12592 const _l = { 12593 encodeCharacter: (n)=>n, 12594 encodeNodeStart: (n)=>n.type.name, 12595 encodeNodeEnd: (n)=>-vp(n.type), 12596 compareTokens: (n, e)=>n === e 12597 }; 12598 function Nr(n, e, t, r, i) { 12599 for(let o = 0, s = 0; o < n.childCount; o++){ 12600 let l = n.child(o), a = s + l.nodeSize, c = Math.max(s, t), f = Math.min(a, r); 12601 if (c < f) if (l.isText) for(let u = c; u < f; u++)i.push(e.encodeCharacter(l.text.charCodeAt(u - s), l.marks)); 12602 else l.isLeaf ? i.push(e.encodeNodeStart(l)) : (c == s && i.push(e.encodeNodeStart(l)), Nr(l.content, e, Math.max(s + 1, c
12602) - s - 1, Math.min(a - 1, f) - s - 1, i), f == a && i.push(e.encodeNodeEnd(l))); 12603 s = a; 12604 } 12605 return i; 12606 } 12607 const Ul = 2500; 12608 function Op(n, e) { 12609 return Math.min(15, Math.max(2, Math.floor(Math.max(n, e) / 10))); 12610 } 12611 function Yl(n, e, t, r = _l) { 12612 if (Math.max(t.toA - t.fromA, t.toB, t.fromB) > Ul) return [ 12613 t 12614 ]; 12615 let i = Nr(n, r, t.fromA, t.toA, []), o = Nr(e, r, t.fromB, t.toB, []); 12616 return Np(i, o, t, r.compareTokens); 12617 } 12618 function Np(n, e, t, r) { 12619 let i = 0, o = n.length, s = e.length; 12620 for(; i < n.length && i < e.length && r(n[i], e[i]);)i++; 12621 if (i == n.length && i == e.length) return []; 12622 for(; o > i && s > i && r(n[o - 1], e[s - 1]);)o--, s--; 12623 if (o == i || s == i || o == s && o == i + 1) return [ 12624 t.slice(i, o, i, s) 12625 ]; 12626 let l = o - i, a = s - i, c = Math.min(Ul, l + a), f = [], u = new Int16Array((c + 1) * 2).fill(-1); 12627 for(let d = 0; d <= c; d++){ 12628 for(let h = -d; h <= d; h += 2){ 12629 let p = u[h + 1 + c], m = u[h - 1 + c], g = p < m ? m : p + 1, y = g + h; 12630 for(; g < l && y < a && r(n[i + g], e[i + y]);)g++, y++; 12631 if (u[h + c] = g, g >= l && y >= a) { 12632 let x = [], M = Op(o - i, s - i), w = -1, N = -1, O = -1, C = -1, E = (A, _, Re, qt)=>{ 12633 w > -1 && w < _ + M ? (w = A, O = Re) : (w > -1 && x.push(t.slice(w, N, O, C)), w = A, N = _, O = Re, C = qt); 12634 }; 12635 for(let A = d - 1; A >= 0; A--){ 12636 let _ = u[h + 1 + c], Re = u[h - 1 + c]; 12637 _ < Re ? (h--, g = Re + i, y = g + h, E(g, g, y, y + 1)) : (h++, g = _ + i, y = g + h, E(g, g + 1, y, y)), u = f[A >> 1]; 12638 } 12639 return w > -1 && x.push(t.slice(w, N, O, C)), x.reverse(); 12640 } 12641 } 12642 d % 2 == 0 && f.push(u.slice()); 12643 } 12644 return [ 12645 t 12646 ]; 12647 } 12648 class B { 12649 constructor(e, t){ 12650 this.length = e, this.data = t; 12651 } 12652 cut(e) { 12653 return e == this.length ? this : new B(e, this.data); 12654 } 12655 static slice(e, t, r) { 12656 if (t == r) return B.none; 12657 if (t == 0 && r == B.len(e)) return e; 12658 let i = []; 12659 for(let o = 0, s = 0; s < r; o++){ 12660 let l = e[o], a = s + l.length, c = Math.min(r, a) - Math.max(t, s); 12661 c > 0 && i.push(l.cut(c)), s = a; 12662 } 12663 return i; 12664 } 12665 static join(e, t, r) { 12666 if (e.length == 0) return t; 12667 if (t.length == 0) return e; 12668 let i = r(e[e.length - 1].data, t[0].data); 12669 if (i == null) return e.concat(t); 12670 let o = e.slice(0, e.length - 1); 12671 o.push(new B(e[e.length - 1].length + t[0].length, i)); 12672 for(let s = 1; s < t.length; s++)o.push(t[s]); 12673 return o; 12674 } 12675 static len(e) { 12676 let t = 0; 12677 for(let r = 0; r < e.length; r++)t += e[r].length; 12678 return t; 12679 } 12680 } 12681 B.none = []; 12682 class fe { 12683 constructor(e, t, r, i, o, s){ 12684 this.fromA = e, this.toA = t, this.fromB = r, this.toB = i, this.deleted = o, this.inserted = s; 12685 } 12686 get lenA() { 12687 return this.toA - this.fromA; 12688 } 12689 get lenB() { 12690 return this.toB - this.fromB; 12691 } 12692 slice(e, t, r, i) { 12693 return e == 0 && r == 0 && t == this.toA - this.fromA && i == this.toB - this.fromB ? this : new fe(this.fromA + e, this.fromA + t, this.fromB + r, this.fromB + i, B.slice(this.deleted, e, t), B.slice(this.inserted, r, i)); 12694 } 12695 static merge(e, t, r) { 12696 if (e.length == 0) return t; 12697 if (t.length == 0) return e; 12698 let i = []; 12699 for(let o = 0, s = 0, l = e[0], a = t[0];;){ 12700 if (!l && !a) return i; 12701 if (l && (!a || l.toB < a.fromA)) { 12702 let c = s ? t[s - 1].toB - t[s - 1].toA : 0; 12703 i.push(c == 0 ? l : new fe(l.fromA, l.toA, l.fromB + c, l.toB + c, l.deleted, l.inserted)), l = o++ == e.length ? null : e[o]; 12704 } else if (a && (!l || a.toA < l.fromB)) { 12705 let c = o ? e[o - 1].toB - e[o - 1].toA : 0; 12706 i.push(c == 0 ? a : new fe(a.fromA - c, a.toA - c, a.fromB, a.toB, a.deleted, a.inserted)), a = s++ == t.length ? null : t[s]; 12707 } else { 12708 let c = Math.min(l.fromB, a.fromA), f = Math.min(l.fromA, a.fromA - (o ? e[o - 1].toB - e[o - 1].toA : 0)), u = f, d = Math.min(a.fromB, l.fromB + (s ? t[s - 1].toB - t[s - 1].toA : 0)), h = d, p = B.none, m = B.none, g = !1, y = !1; 12709 for(;;){ 12710 let x = l ? c >= l.fromB ? l.toB : l.fromB : 2e8, M = a ? c >= a.fromA ? a.toA : a.fromA : 2e8, w = Math.min(x, M), N = l && c >= l.fromB, O = a && c >= a.fromA; 12711 if (!N && !O) break; 12712 N && c == l.fromB && !g && (p = B.join(p, l.deleted, r), u += l.lenA, g = !0), N && !O && (m = B.join(m, B.slice(l.inserted, c - l.fromB, w - l.fromB), r), h += w - c), O && c == a.fromA && !y && (m = B.join(m, a.inserted, r), h += a.lenB, y = !0), O && !N && (p = B.join(p, B.slice(a.deleted, c - a.fromA, w - a.fromA), r), u += w - c), N && w == l.toB && (l = o++ == e.length ? null : e[o], g = !1), O && w == a.toA && (a = s++ == t.length ? null : t[s], y = !1), c = w; 12713 } 12714 (f < u || d < h) && i.push(new fe(f, u, d, h, p, m)); 12715 } 12716 } 12717 } 12718 static fromJSON(e) { 12719 return new fe(e.fromA, e.toA, e.fromB, e.toB, e.deleted.map((t)=>new B(t.length, t.data)), e.inserted.map((t)=>new B(t.length, t.data))); 12720 } 12721 toJSON() { 12722 return this; 12723 } 12724 } 12725 let Ep; 12726 try { 12727 Ep = new RegExp("[\\p{Alphabetic}_]", "u"); 12728 } catch {} 12729 class He { 12730 constructor(e, t){ 12731 this.config = e, this.changes = t; 12732 } 12733 addSteps(e, t, r) { 12734 let i = []; 12735 for(let a = 0; a < t.length; a++){ 12736 let c = Array.isArray(r) ? r[a] : r, f = 0;
12737 t[a].forEach((u, d, h, p)=>{ 12738 i.push(new fe(u + f, d + f, h, p, u == d ? B.none : [ 12739 new B(d - u, c) 12740 ], h == p ? B.none : [ 12741 new B(p - h, c) 12742 ])), f = p - h - (d - u); 12743 }); 12744 } 12745 if (i.length == 0) return this; 12746 let o = Er(i, this.config.combine), s = fe.merge(this.changes, o, this.config.combine), l = s; 12747 for(let a = 0; a < l.length; a++){ 12748 let c = l[a]; 12749 if (c.fromA == c.toA || c.fromB == c.toB || !o.some((u)=>u.toB > c.fromB && u.fromB < c.toB)) continue; 12750 let f = Yl(this.config.doc.content, e.content, c, this.config.encoder); 12751 f.length == 1 && f[0].fromB == 0 && f[0].toB == c.toB - c.fromB || (l == s && (l = s.slice()), f.length == 1 ? l[a] = f[0] : (l.splice(a, 1, ...f), a += f.length - 1)); 12752 } 12753 return new He(this.config, l); 12754 } 12755 get startDoc() { 12756 return this.config.doc; 12757 } 12758 map(e) { 12759 let t = (r)=>{ 12760 let i = e(r); 12761 return i === r.data ? r : new B(r.length, i); 12762 }; 12763 return new He(this.config, this.changes.map((r)=>new fe(r.fromA, r.toA, r.fromB, r.toB, r.deleted.map(t), r.inserted.map(t)))); 12764 } 12765 changedRange(e, t) { 12766 if (e == this) return null; 12767 let r = t && Dp(t), i = r ? r.toB - r.fromB - (r.toA - r.fromA) : 0; 12768 function o(u) { 12769 return !r || u <= r.fromA ? u : u + i; 12770 } 12771 let s = r ? r.fromB : 2e8, l = r ? r.toB : -2e8; 12772 function a(u, d = u) { 12773 s = Math.min(u, s), l = Math.max(d, l); 12774 } 12775 let c = this.changes, f = e.changes; 12776 for(let u = 0, d = 0; u < c.length && d < f.length;){ 12777 let h = c[u], p = f[d]; 12778 h && p && Ap(h, p, o) ? (u++, d++) : p && (!h || o(h.fromB) >= p.fromB) ? (a(p.fromB, p.toB), d++) : (a(o(h.fromB), o(h.toB)), u++); 12779 } 12780 return s <= l ? { 12781 from: s, 12782 to: l 12783 } : null; 12784 } 12785 static create(e, t = (o, s)=>o === s ? o : null, r = _l, i = []) { 12786 return new He({ 12787 combine: t, 12788 doc: e, 12789 encoder: r 12790 }, i); 12791 } 12792 } 12793 He.computeDiff = Yl; 12794 function Er(n, e, t = 0, r = n.length) { 12795 if (r == t + 1) return [ 12796 n[t] 12797 ]; 12798 let i = t + r >> 1; 12799 return fe.merge(Er(n, e, t, i), Er(n, e, i, r), e); 12800 } 12801 function So(n) { 12802 let e = 2e8, t = -2e8; 12803 for(let r = 0; r < n.length; r++){ 12804 let i = n[r]; 12805 e != 2e8 && (e = i.map(e, -1), t = i.map(t, 1)), i.forEach((o, s, l, a)=>{ 12806 e = Math.min(e, l), t = Math.max(t, a); 12807 }); 12808 } 12809 return e == 2e8 ? null : { 12810 from: e, 12811 to: t 12812 }; 12813 } 12814 function Dp(n) { 12815 let e = So(n); 12816 if (!e) return null; 12817 let t = So(n.map((r)=>r.invert()).reverse()); 12818 return { 12819 fromA: t.from, 12820 toA: t.to, 12821 fromB: e.from, 12822 toB: e.to 12823 }; 12824 } 12825 function Ap(n, e, t) { 12826 return t(n.fromB) == e.fromB && t(n.toB) == e.toB && wo(n.deleted, e.deleted) && wo(n.inserted, e.inserted); 12827 } 12828 function wo(n, e) { 12829 if (n.length != e.length) return !1; 12830 for(let t = 0; t < n.length; t++)if (n[t].length != e[t].length || n[t].data !== e[t].data) return !1; 12831 return !0; 12832 } 12833 const Ip = new de("automerge-sync"), Rp = ({ adapter: n, handle: e, path: t })=>{ 12834 let r = !1; 12835 return new X({ 12836 key: Ip, 12837 view: (o)=>{ 12838 const s = ({ doc: l, patches: a, patchInfo: c })=>{ 12839 if (r) return; 12840 const f = Tp({ 12841 adapter: n, 12842 path: t, 12843 before: c.before, 12844 after: l, 12845 patches: a, 12846 state: o.state 12847 }); 12848 r = !0, o.dispatch(f), r = !1; 12849 }; 12850 return e.on("change", s), { 12851 destroy () { 12852 e.off("change", s); 12853 } 12854 }; 12855 }, 12856 appendTransaction (o, s, l) { 12857 if (r || (o = o.filter((O)=>O.docChanged), o.length === 0)) return; 12858 const a = e.doc(), c = Ot(a), f = it(a, t); 12859 r = !0, e.change((O)=>{ 12860 for (const C of o){ 12861 const E = it(O, t); 12862 sp(n, E, C.steps, O, C.docs[0], t); 12863 } 12864 }), r = !1; 12865 const u = e.doc(), d = Ot(u), h = it(u, t); 12866 if (Ln(c, d)) return; 12867 const p = Do(u, c, d), m = Kl(n, f, p, t, s.tr); 12868 let g = He.create(s.doc); 12869 g = g.addSteps(s.doc, m.mapping.maps, void 0); 12870 let y = He.create(s.doc); 12871 for (const O of o)y = y.addSteps(O.docs[0], O.mapping.maps, void 0); 12872 const x = y.changedRange(g); 12873 if (!x || x.from === x.to) return;
12874 const w = ei(n, h).slice(x.from, x.to), N = l.tr; 12875 N.replace(x.from, x.to, w); 12876 try { 12877 N.setSelection(D.fromJSON(N.doc, l.selection.toJSON())); 12878 } catch (O) { 12879 if (!(O instanceof RangeError)) throw O; 12880 } 12881 return N.setStoredMarks(l.storedMarks), N; 12882 } 12883 }); 12884 }; 12885 class Bp { 12886 constructor(e, t, r = {}){ 12887 this.validate = t, this.options = r, t(e), this.current = jn(e, r.actorId ? { 12888 actor: r.actorId 12889 } : void 0); 12890 } 12891 current; 12892 listeners = new Set; 12893 receiving = !1; 12894 get isApplyingRemote() { 12895 return this.receiving; 12896 } 12897 doc() { 12898 return this.current; 12899 } 12900 on(e, t) { 12901 this.listeners.add(t); 12902 } 12903 off(e, t) { 12904 this.listeners.delete(t); 12905 } 12906 change(e) { 12907 if (this.options.canChange?.() === !1) throw new Error("This report section is read-only."); 12908 this.publish(ta(jn(this.current, { 12909 actor: ri(this.current) 12910 }), e), "change"); 12911 } 12912 receive(e) { 12913 const [t] = na(jn(this.current, { 12914 actor: ri(this.current) 12915 }), e); 12916 this.receiving = !0; 12917 try { 12918 this.publish(t, "applyChanges"); 12919 } finally{ 12920 this.receiving = !1; 12921 } 12922 } 12923 save() { 12924 return ra(this.current); 12925 } 12926 publish(e, t) { 12927 this.validate(e); 12928 const r = this.current, i = Do(e, Ot(r), Ot(e)); 12929 this.current = e; 12930 const o = { 12931 before: r, 12932 after: e, 12933 source: t 12934 }; 12935 for (const s of this.listeners)s({ 12936 handle: this, 12937 doc: e, 12938 patches: i, 12939 patchInfo: o 12940 }); 12941 } 12942 } 12943 let Pp, Mo, Vn, zp, vn; 12944 Pp = [ 12945 "paragraph", 12946 "heading", 12947 "ordered-list-item", 12948 "unordered-list-item", 12949 "__ext__armm_table", 12950 "__ext__armm_table_row", 12951 "__ext__armm_table_cell", 12952 "__ext__armm_hard_break", 12953 "__ext__armm_photo_reference" 12954 ]; 12955 Mo = oa(Pp); 12956 Vn = Ft({ 12957 href: Nt().min(1).max(2048), 12958 title: Nt().max(500) 12959 }).strict(); 12960 Tn = Ft({ 12961 level: sr().int().min(1).max(3) 12962 }); 12963 zp = Ft({ 12964 rows: sr().int().min(1).max(12), 12965 columns: sr().int().min(1).max(8) 12966 }).strict(); 12967 vn = Ft({ 12968 photoId: Nt().min(1).max(128), 12969 label: Nt().min(1).max(200) 12970 }).strict(); 12971 function On(n) { 12972 if (n !== n.trim() || Array.from(n).some((e)=>e.charCodeAt(0) <= 32 || e.charCodeAt(0) === 127)) return !1; 12973 try { 12974 const e = new URL(n); 12975 return [ 12976 "https:", 12977 "http:", 12978 "mailto:" 12979 ].includes(e.protocol) && !e.username && !e.password; 12980 } catch { 12981 return !1; 12982 } 12983 } 12984 function Gl(n) { 12985 if (typeof n != "string") throw new Error("The link is not supported."); 12986 const e = Vn.parse(JSON.parse(n)); 12987 if (!On(e.href)) throw new Error("Use an http, https or email link without embedded credentials."); 12988 return e; 12989 } 12990 Xl = function(n) { 12991 for (const [e, t] of Object.entries(n)){ 12992 if (e === "link") { 12993 Gl(t); 12994 continue; 12995 } 12996 if (![ 12997 "strong", 12998 "em", 12999 "underline" 13000 ].includes(e) || t !== !0) throw new Error("Unsupported text formatting."); 13001 } 13002 }; 13003 Ft({ 13004 type: Mo, 13005 parents: ca(Mo).max(16), 13006 attrs: la(Nt(), aa()), 13007 isEmbed: sa().optional() 13008 }).strict(); 13009 Kp = function(n, e, t) { 13010 const r = zp.parse({ 13011 rows: e, 13012 columns: t 13013 }), i = { 13014 type: "table", 13015 content: Array.from({ 13016 length: r.rows 13017 }, ()=>({ 13018 type: "tableRow", 13019 content: Array.from({ 13020 length: r.columns 13021 }, ()=>({ 13022 type: "tableCell", 13023 content: [ 13024 { 13025 type: "paragraph" 13026 } 13027 ] 13028 })) 13029 })) 13030 }; 13031 return n.chain().focus().insertContent(i).run(); 13032 }; 13033 function $n(n) { 13034 return Jt((e)=>
13034e.type.name === "table")(n.state.selection); 13035 } 13036 Hp = function(n) { 13037 if (!n.isEditable) return !1; 13038 const e = n.state.selection, t = $n(n) ?? (e instanceof T && e.node.type.name === "table" ? { 13039 node: e.node, 13040 pos: e.from 13041 } : null); 13042 return t ? n.chain().focus().deleteRange({ 13043 from: t.pos, 13044 to: t.pos + t.node.nodeSize 13045 }).run() : !1; 13046 }; 13047 _p = function(n) { 13048 const e = $n(n); 13049 if (!e || e.node.childCount >= 12) return !1; 13050 const t = e.node.child(0).childCount, r = Array.from({ 13051 length: t 13052 }, ()=>n.schema.nodes.tableCell.create(null, n.schema.nodes.paragraph.create())); 13053 return n.commands.insertContentAt(e.pos + e.node.nodeSize - 1, n.schema.nodes.tableRow.create(null, r).toJSON()); 13054 }; 13055 Up = function(n) { 13056 const e = $n(n); 13057 if (!e) return !1; 13058 const t = []; 13059 let r = !1; 13060 return e.node.forEach((i, o)=>{ 13061 i.childCount >= 8 && (r = !0), t.push(e.pos + o + i.nodeSize); 13062 }), r ? !1 : n.commands.command(({ tr: i })=>{ 13063 for (const o of t.reverse())i.insert(o, n.schema.nodes.tableCell.create(null, n.schema.nodes.paragraph.create())); 13064 return !0; 13065 }); 13066 }; 13067 function Co(n, e) { 13068 const t = Jt((s)=>s.type.name === "tableCell")(n.state.selection), r = $n(n); 13069 if (!r || !t) return !1; 13070 const i = []; 13071 r.node.descendants((s, l)=>{ 13072 s.type.name === "tableCell" && i.push(r.pos + 1 + l); 13073 }); 13074 const o = i[i.indexOf(t.pos) + e]; 13075 return o === void 0 ? !1 : n.commands.setTextSelection(o + 2); 13076 } 13077 let ce, or; 13078 ce = { 13079 isAmgBlock: { 13080 default: !1, 13081 rendered: !1 13082 }, 13083 unknownAttrs: { 13084 default: null, 13085 rendered: !1 13086 } 13087 }; 13088 or = { 13089 ...ce, 13090 isAmgBlock: { 13091 default: !0, 13092 rendered: !1 13093 } 13094 }; 13095 Fp = [ 13096 Q.create({ 13097 name: "doc", 13098 topNode: !0, 13099 content: "block+", 13100 addAttributes: ()=>ce 13101 }), 13102 Q.create({ 13103 name: "paragraph", 13104 group: "block", 13105 content: "inline*", 13106 addAttributes: ()=>({ 13107 ...ce, 13108 unknownParentBlock: { 13109 default: null, 13110 rendered: !1 13111 }, 13112 unknownBlock: { 13113 default: null, 13114 rendered: !1 13115 } 13116 }), 13117 parseHTML: ()=>[ 13118 { 13119 tag: "p" 13120 } 13121 ], 13122 renderHTML: ()=>[ 13123 "p", 13124 0 13125 ] 13126 }), 13127 Q.create({ 13128 name: "heading", 13129 group: "block", 13130 content: "inline*", 13131 defining: !0, 13132 addAttributes: ()=>({ 13133 ...ce, 13134 level: { 13135 default: 1, 13136 rendered: !1 13137 } 13138 }), 13139 parseHTML: ()=>[ 13140 1, 13141 2, 13142 3 13143 ].map((n)=>({ 13144 tag: `h${n}`, 13145 attrs: { 13146 level: n 13147 } 13148 })), 13149 renderHTML: ({ node: n })=>[ 13150 `h${Tn.parse(n.attrs).level}`, 13151 0 13152 ] 13153 }), 13154 Q.create({ 13155 name: "bulletList", 13156 group: "block list", 13157 content: "listItem+", 13158 addAttributes: ()=>ce, 13159 parseHTML: ()=>[ 13160 { 13161 tag: "ul" 13162 } 13163 ], 13164 renderHTML: ()=>[ 13165 "ul", 13166 0 13167 ] 13168 }), 13169 Q.create({ 13170 name: "orderedList", 13171 group: "block list", 13172 content: "listItem+", 13173 addAttributes: ()=>ce, 13174 parseHTML: ()=>[ 13175 { 13176 tag: "ol" 13177 } 13178 ], 13179 renderHTML: ()=>[ 13180 "ol", 13181 0 13182 ] 13183 }), 13184 Q.create({ 13185 name: "listItem", 13186 content: "paragraph block*", 13187 defining: !0, 13188 addAttributes: ()=>ce, 13189 parseHTML: ()=>[ 13190 { 13191 tag: "li" 13192 } 13193 ], 13194 renderHTML: ()=>[ 13195 "li", 13196 0 13197 ] 13198 }), 13199 Q.create({ 13200 name: "table", 13201 group: "block", 13202 content: "tableRow+", 13203 isolating: !0, 13204 addAttributes: ()=>or, 13205 parseHTML: ()=>[ 13206 { 13207 tag: "table", 13208 contentElement: "tbody" 13209 } 13210 ], 13211 renderHTML: ()=>[ 13212 "table", 13213 [ 13214 "tbody", 13215 0 13216 ] 13217 ] 13218 }), 13219 Q.create({ 13220 name: "tableRow", 13221 content: "tableCell+", 13222 addAttributes: ()=>or, 13223 parseHTML: ()=>[ 13224 { 13225 tag: "tr" 13226 } 13227 ], 13228 renderHTML: ()=>[ 13229 "tr", 13230 0 13231 ] 13232 }), 13233 Q.create({ 13234 name: "tableCell", 13235 content: "block+", 13236 isolating: !0, 13237 addAttributes: ()=>or, 13238 parseHTML: ()=>[ 13239 { 13240 tag: "td" 13241 } 13242 ], 13243 renderHTML: ()=>[ 13244 "td", 13245 0 13246 ] 13247 }), 13248 Q.create({ 13249 name: "hardBreak", 13250 inline: !0, 13251 group: "inline", 13252 atom: !0, 13253 selectable: !1, 13254 addAttributes: ()=>ce, 13255 parseHTML: ()=>[ 13256 { 13257 tag: "br" 13258 } 13259 ], 13260 renderHTML: ()=>[ 13261 "br" 13262 ] 13263 }), 13264 Q.create({ 13265 name: "photoReference", 13266 inline: !0, 13267 group: "inline", 13268 atom: !0, 13269 addAttributes: ()=>({ 13270 ...ce, 13271 photoId: { 13272 default: "", 13273 rendered: !1 13274 }, 13275 label: { 13276 default: "Photograph", 13277 rendered: !1 13278 } 13279 }), 13280 renderHTML: ({ node: n })=>{ 13281 const e = vn.parse({ 13282 photoId: n.attrs.photoId, 13283 label: n.attrs.label 13284 }); 13285 return [ 13286 "span", 13287 { 13288 "data-report-photo": e.photoId, 13289 class: "report-photo-reference" 13290 }, 13291 `Photograph: ${e.label}` 13292 ]; 13293 } 13294 }), 13295 Q.create({ 13296 name: "text", 13297 group: "inline" 13298 }), 13299 Q.create({ 13300 name: "unknownLeaf", 13301 inline: !0, 13302 group: "inline", 13303 atom: !0, 13304 addAttributes: ()=>({ 13305 ...ce, 13306 unknownBlock: { 13307 default: null, 13308 rendered: !1 13309 } 13310 }), 13311 renderHTML: ()=>[ 13312 "span", 13313 { 13314 "data-unsupported-content": "true" 13315 } 13316 ] 13317 }), 13318 ...[ 13319 [ 13320 "strong", 13321 "strong" 13322 ], 13323 [ 13324 "em", 13325 "em" 13326 ], 13327 [ 13328 "underline", 13329 "u" 13330 ] 13331 ].map(([n, e])=>sn.create({ 13332 name: n, 13333 parseHTML: ()=>[ 13334 { 13335 tag: e 13336 } 13337 ], 13338 renderHTML: ()=>[ 13339 e, 13340 0 13341 ] 13342 })), 13343 sn.create({ 13344 name: "link", 13345 inclusive: !1, 13346 addAttributes: ()=>({ 13347 href: { 13348 default: "" 13349 }, 13350 title: { 13351 default: "" 13352 } 13353 }), 13354 parseHTML: ()=>[ 13355 { 13356 tag: "a[href]", 13357 getAttrs: (n)=>{ 13358 const e = n.getAttribute("href"); 13359 return e !== null && On(e) ? null : !1; 13360 } 13361 } 13362 ], 13363 renderHTML: ({ mark: n })=>{ 13364 const e = Vn.parse(n.attrs); 13365 if (!On(e.href)) throw new Error("Unsafe report link."); 13366 return [ 13367 "a", 13368 { 13369 ...e, 13370 target: "_blank", 13371 rel: "noopener noreferrer" 13372 }, 13373 0 13374 ]; 13375 } 13376 }), 13377 sn.create({ 13378 name: "unknownMark", 13379 addAttributes: ()=>({ 13380 unknownMarks: { 13381 default: null, 13382 rendered: !1 13383 } 13384 }), 13385 renderHTML: ()=>[ 13386 "span", 13387 0 13388 ] 13389 }), 13390 ae.create({ 13391 name: "reportKeyboard", 13392 addKeyboardShortcuts () { 13393 return { 13394 "Mod-b": ()=>this.editor.commands.toggleMark("strong"), 13395 "Mod-i": ()=>this.editor.commands.toggleMark("em"), 13396 "Mod-u": ()=>this.editor.commands.toggleMark("underline"), 13397 Enter: ()=>this.editor.commands.splitListItem("listItem"), 13398 Tab: ()=>Co(this.editor, 1) || this.editor.commands.sinkListItem("listItem"), 13399 "Shift-Tab": ()=>Co(this.editor, -1) || this.editor.commands.liftListItem("listItem"), 13400 "Shift-Enter": ()=>this.editor.commands.insertContent({ 13401 type: "hardBreak" 13402 }) 13403 }; 13404 } 13405 }) 13406 ]; 13407 Lp = class extends Ll { 13408 constructor(e){ 13409 super({ 13410 nodes: { 13411 doc: e.nodes.doc.spec, 13412 paragraph: { 13413 ...e.nodes.paragraph.spec, 13414 automerge: { 13415 block: "paragraph", 13416 unknownBlock: !0 13417 } 13418 }, 13419 heading: { 13420 ...e.nodes.heading.spec, 13421 automerge: { 13422 block: "heading", 13423 attrParsers: { 13424 fromProsemirror: (t)=>Tn.parse(t.attrs), 13425 fromAutomerge: (t)=>Tn.parse(t.attrs) 13426 } 13427 } 13428 }, 13429 bulletList: e.nodes.bulletList.spec, 13430 orderedList: e.nodes.orderedList.spec, 13431 listItem: { 13432 ...e.nodes.listItem.spec, 13433 automerge: { 13434 block: { 13435 within: { 13436 orderedList: "ordered-list-item", 13437 bulletList: "unordered-list-item" 13438 } 13439 } 13440 } 13441 }, 13442 table: { 13443 ...e.nodes.table.spec, 13444 automerge: { 13445 block: "__ext__armm_table" 13446 } 13447 }, 13448 tableRow: { 13449 ...e.nodes.tableRow.spec, 13450 automerge: { 13451 block: "__ext__armm_table_row" 13452 } 13453 }, 13454 tableCell: { 13455 ...e.nodes.tableCell.spec, 13456 automerge: { 13457 block: "__ext__armm_table_cell" 13458 } 13459 }, 13460 hardBreak: { 13461 ...e.nodes.hardBreak.spec, 13462 automerge: { 13463 block: "__ext__armm_hard_break", 13464 isEmbed: !0 13465 } 13466 }, 13467 photoReference: {
13468 ...e.nodes.photoReference.spec, 13469 automerge: { 13470 block: "__ext__armm_photo_reference", 13471 isEmbed: !0, 13472 attrParsers: { 13473 fromProsemirror: (t)=>{ 13474 const r = vn.parse({ 13475 photoId: t.attrs.photoId, 13476 label: t.attrs.label 13477 }); 13478 return { 13479 photoId: new Te(r.photoId), 13480 label: new Te(r.label) 13481 }; 13482 }, 13483 fromAutomerge: (t)=>{ 13484 const r = t.attrs.photoId, i = t.attrs.label; 13485 if (!(r instanceof Te) || !(i instanceof Te)) throw new Error("Invalid photograph reference."); 13486 return vn.parse({ 13487 photoId: r.toString(), 13488 label: i.toString() 13489 }); 13490 } 13491 } 13492 } 13493 }, 13494 text: e.nodes.text.spec 13495 }, 13496 marks: { 13497 strong: { 13498 ...e.marks.strong.spec, 13499 automerge: { 13500 markName: "strong" 13501 } 13502 }, 13503 em: { 13504 ...e.marks.em.spec, 13505 automerge: { 13506 markName: "em" 13507 } 13508 }, 13509 underline: { 13510 ...e.marks.underline.spec, 13511 automerge: { 13512 markName: "underline" 13513 } 13514 }, 13515 link: { 13516 ...e.marks.link.spec, 13517 automerge: { 13518 markName: "link", 13519 parsers: { 13520 fromAutomerge: Gl, 13521 fromProsemirror: (t)=>JSON.stringify(Vn.parse(t.attrs)) 13522 } 13523 } 13524 } 13525 } 13526 }), this.schema = e, this.nodeMappings = this.nodeMappings.map((t)=>({ 13527 ...t, 13528 content: e.nodes[t.content.name], 13529 outer: t.outer ? e.nodes[t.outer.name] : null 13530 })), this.markMappings = this.markMappings.map((t)=>({ 13531 ...t, 13532 prosemirrorMark: e.marks[t.prosemirrorMark.name] 13533 })), this.unknownBlock = e.nodes.paragraph, this.unknownLeaf = e.nodes.unknownLeaf, this.unknownMark = e.marks.unknownMark; 13534 } 13535 }; 13536 To = function(n) { 13537 n.check(), n.descendants((e)=>{ 13538 if (![ 13539 "paragraph", 13540 "heading", 13541 "bulletList", 13542 "orderedList", 13543 "listItem", 13544 "table", 13545 "tableRow", 13546 "tableCell", 13547 "hardBreak", 13548 "photoReference", 13549 "text" 13550 ].includes(e.type.name) || e.attrs.unknownBlock != null || e.attrs.unknownParentBlock != null || e.attrs.unknownAttrs != null || e.marks.some((t)=>![ 13551 "strong", 13552 "em", 13553 "underline", 13554 "link" 13555 ].includes(t.type.name))) throw new Error("This content needs an editor capability that is not yet available. The original content has been retained."); 13556 e.type.name === "heading" && Tn.parse(e.attrs), e.type.name === "photoReference" && vn.parse({ 13557 photoId: e.attrs.photoId, 13558 label: e.attrs.label 13559 }); 13560 for (const t of e.marks)Xl({
13561 [t.type.name]: t.type.name === "link" ? JSON.stringify(Vn.parse(t.attrs)) : !0 13562 }); 13563 }); 13564 }; 13565 function Vp(n) { 13566 return Array.from(new DOMParser().parseFromString(n, "text/html").body.querySelectorAll("*")).every((e)=>e.tagName === "A" ? On(e.getAttribute("href") ?? "") && Array.from(e.attributes).every((t)=>[ 13567 "href", 13568 "title", 13569 "target", 13570 "rel" 13571 ].includes(t.name)) : [ 13572 "P", 13573 "STRONG", 13574 "EM", 13575 "U", 13576 "H1", 13577 "H2", 13578 "H3", 13579 "UL", 13580 "OL", 13581 "LI", 13582 "TABLE", 13583 "TBODY", 13584 "TR", 13585 "TD", 13586 "BR" 13587 ].includes(e.tagName) && e.attributes.length === 0); 13588 } 13589 function vo(n, e) { 13590 return !n.readOnly && (e || n.canEdit?.() !== !1); 13591 } 13592 function $p(n) { 13593 for (const e of n)if (![ 13594 me, 13595 re, 13596 P, 13597 L 13598 ].some((t)=>e instanceof t)) throw new Error("This editing operation is not available yet. Your existing text has been retained."); 13599 } 13600 Yp = function(n) { 13601 const e = new Fh({ 13602 element: n.element, 13603 extensions: Fp, 13604 injectCSS: !1, 13605 enableContentCheck: !0, 13606 editable: !n.readOnly, 13607 editorProps: { 13608 attributes: { 13609 "aria-label": "Inspection narrative", 13610 role: "textbox", 13611 "aria-multiline": "true" 13612 }, 13613 handlePaste (s, l) { 13614 const a = l.clipboardData?.getData("text/html"); 13615 return l.clipboardData?.files.length || a && !Vp(a) ? (n.onUnsupportedContent?.("This paste includes unsupported formatting or attachments. Paste as plain text, or add photographs through this reportâs Photographs section. Your existing text has been retained."), !0) : !1; 13616 }, 13617 handleDOMEvents: { 13618 drop (s, l) { 13619 return l.preventDefault(), n.onUnsupportedContent?.("Drag and drop is not available in the preview. Your existing text has been retained."), !0; 13620 } 13621 } 13622 } 13623 }), t = new Lp(e.schema), r = (s)=>{ 13624 if (typeof s.text != "string") throw new Error("This content needs an editor capability that is not yet available. The original content has been retained."); 13625 const l = it(s, [ 13626 "text" 13627 ]); 13628 try { 13629 for (const a of l)a.type === "text" && Xl(a.marks ?? {}); 13630 return ei(t, l); 13631 } catch (a) { 13632 throw new Error("This content needs an editor capability that is not yet available. The original content has been retained.", { 13633 cause: a 13634 }); 13635 } 13636 }; 13637 let i; 13638 try { 13639 i = new Bp(n.initialDocument ?? ia({ 13640 text: n.initialText ?? "" 13641 }), (s)=>To(r(s)), { 13642 actorId: n.actorId, 13643 canChange: ()=>vo(n, !1) 13644 }), e.commands.setContent(r(i.doc()).toJSON()); 13645 } catch (s) { 13646 throw e.destroy(), s; 13647 } 13648 e.registerPlugin(new X({ 13649 filterTransaction (s) { 13650 if (s.docChanged && !vo(n, i.isApplyingRemote)) return !1; 13651 try { 13652 return $p(s.steps), To(s.doc), !0; 13653 } catch (l) { 13654 return n.onUnsupportedContent?.(da(l)), !1; 13655 } 13656 } 13657 })), n.readOnly || e.registerPlugin(Rp({ 13658 adapter: t, 13659 handle: i, 13660 path: [ 13661 "text" 13662 ] 13663 })); 13664 const o = ()=>n.onChange?.(i.save()); 13665 return n.readOnly || i.on("change", o), { 13666 editor: e, 13667 handle: i, 13668 adapter: t, 13669 destroy () { 13670 i.off("change", o), e.destroy(); 13671 } 13672 }; 13673 }; 13674}); 13675export { z as D, Fh as E, Tn as N, de as P, Lp as R, Dr as S, wn as a, ni as b, Yp as c, Xl as d, To as e, _p as f, qp as g, Up as h, Kp as i, Hp as j, X as k, se as l, Jp as n, ei as p, Fp as r, __tla };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.