{"version":3,"file":"UserColor-BkdfbBTJ.chunk.mjs","sources":["../node_modules/lib0/eventloop.js","../node_modules/lib0/mutex.js","../node_modules/lib0/diff.js","../node_modules/lib0/hash/sha256.js","../node_modules/@tiptap/y-tiptap/dist/y-tiptap.js","../node_modules/@tiptap/extension-collaboration/dist/index.js","../node_modules/@tiptap/extension-node-range/dist/index.js","../node_modules/@tiptap/extension-drag-handle/dist/index.js","../node_modules/@tiptap/extension-drag-handle-vue-3/dist/index.js","../node_modules/vue-material-design-icons/DragVertical.vue","../src/components/Editor/FloatingButtons.vue","../src/composables/useVisibility.ts","../src/components/Editor/TableOfContents/TableOfContentsEntry.vue","../src/components/Editor/TableOfContents/TableOfContents.vue","../node_modules/vue-material-design-icons/PinOutline.vue","../src/components/Editor/TableOfContents/TocDesktop.vue","../src/components/Editor/TableOfContents/TocMobile.vue","../src/components/Editor/TableOfContents/TocOutlineEntry.vue","../src/components/Editor/TableOfContents/TocOutline.vue","../src/components/Editor/TableOfContents/TocContainer.vue","../src/composables/useAnnotationsHidden.ts","../src/components/Editor/ContentContainer.vue","../src/components/Editor/EditorWrapper.vue","../src/apis/attach.ts","../src/components/Editor/MediaHandler.vue","../src/components/Editor/MainContainer.vue","../src/composables/useEditorWidth.ts","../node_modules/@tiptap/extension-collaboration-caret/dist/index.js","../src/extensions/CollaborationCaret.ts","../src/extensions/FocusTrap.js","../src/nodes/PlainTableDocument.js","../src/extensions/PlainTable.js","../src/nodes/CodeBlockPlainText.js","../src/nodes/PlainTextDocument.js","../src/extensions/PlainText.js","../src/extensions/tracking/models.js","../src/extensions/tracking/TrackState.js","../src/extensions/UserColor.js"],"sourcesContent":["/* global requestIdleCallback, requestAnimationFrame, cancelIdleCallback, cancelAnimationFrame */\n\nimport * as time from './time.js'\n\n/**\n * Utility module to work with EcmaScript's event loop.\n *\n * @module eventloop\n */\n\n/**\n * @type {Array<function>}\n */\nlet queue = []\n\nconst _runQueue = () => {\n  for (let i = 0; i < queue.length; i++) {\n    queue[i]()\n  }\n  queue = []\n}\n\n/**\n * @param {function():void} f\n */\nexport const enqueue = f => {\n  queue.push(f)\n  if (queue.length === 1) {\n    setTimeout(_runQueue, 0)\n  }\n}\n\n/**\n * @typedef {Object} TimeoutObject\n * @property {function} TimeoutObject.destroy\n */\n\n/**\n * @param {function(number):void} clearFunction\n */\nconst createTimeoutClass = clearFunction => class TT {\n  /**\n   * @param {number} timeoutId\n   */\n  constructor (timeoutId) {\n    this._ = timeoutId\n  }\n\n  destroy () {\n    clearFunction(this._)\n  }\n}\n\nconst Timeout = createTimeoutClass(clearTimeout)\n\n/**\n * @param {number} timeout\n * @param {function} callback\n * @return {TimeoutObject}\n */\nexport const timeout = (timeout, callback) => new Timeout(setTimeout(callback, timeout))\n\nconst Interval = createTimeoutClass(clearInterval)\n\n/**\n * @param {number} timeout\n * @param {function} callback\n * @return {TimeoutObject}\n */\nexport const interval = (timeout, callback) => new Interval(setInterval(callback, timeout))\n\n/* c8 ignore next */\nexport const Animation = createTimeoutClass(arg => typeof requestAnimationFrame !== 'undefined' && cancelAnimationFrame(arg))\n\n/**\n * @param {function(number):void} cb\n * @return {TimeoutObject}\n */\n/* c8 ignore next */\nexport const animationFrame = cb => typeof requestAnimationFrame === 'undefined' ? timeout(0, cb) : new Animation(requestAnimationFrame(cb))\n\n/* c8 ignore next */\n// @ts-ignore\nconst Idle = createTimeoutClass(arg => typeof cancelIdleCallback !== 'undefined' && cancelIdleCallback(arg))\n\n/**\n * Note: this is experimental and is probably only useful in browsers.\n *\n * @param {function} cb\n * @return {TimeoutObject}\n */\n/* c8 ignore next 2 */\n// @ts-ignore\nexport const idleCallback = cb => typeof requestIdleCallback !== 'undefined' ? new Idle(requestIdleCallback(cb)) : timeout(1000, cb)\n\n/**\n * @param {number} timeout Timeout of the debounce action\n * @param {number} triggerAfter Optional. Trigger callback after a certain amount of time\n *                              without waiting for debounce.\n */\nexport const createDebouncer = (timeout, triggerAfter = -1) => {\n  let timer = -1\n  /**\n   * @type {number?}\n    */\n  let lastCall = null\n  /**\n   * @param {((...args: any)=>void)?} cb function to trigger after debounce. If null, it will reset the\n   *                         debounce.\n   */\n  return cb => {\n    clearTimeout(timer)\n    if (cb) {\n      if (triggerAfter >= 0) {\n        const now = time.getUnixTime()\n        if (lastCall === null) lastCall = now\n        if (now - lastCall > triggerAfter) {\n          lastCall = null\n          timer = /** @type {any} */ (setTimeout(cb, 0))\n          return\n        }\n      }\n      timer = /** @type {any} */ (setTimeout(() => { lastCall = null; cb() }, timeout))\n    } else {\n      lastCall = null\n    }\n  }\n}\n","/**\n * Mutual exclude for JavaScript.\n *\n * @module mutex\n */\n\n/**\n * @callback mutex\n * @param {function():void} cb Only executed when this mutex is not in the current stack\n * @param {function():void} [elseCb] Executed when this mutex is in the current stack\n */\n\n/**\n * Creates a mutual exclude function with the following property:\n *\n * ```js\n * const mutex = createMutex()\n * mutex(() => {\n *   // This function is immediately executed\n *   mutex(() => {\n *     // This function is not executed, as the mutex is already active.\n *   })\n * })\n * ```\n *\n * @return {mutex} A mutual exclude function\n * @public\n */\nexport const createMutex = () => {\n  let token = true\n  return (f, g) => {\n    if (token) {\n      token = false\n      try {\n        f()\n      } finally {\n        token = true\n      }\n    } else if (g !== undefined) {\n      g()\n    }\n  }\n}\n","/**\n * Efficient diffs.\n *\n * @module diff\n */\n\nimport { equalityStrict } from './function.js'\n\n/**\n * A SimpleDiff describes a change on a String.\n *\n * ```js\n * console.log(a) // the old value\n * console.log(b) // the updated value\n * // Apply changes of diff (pseudocode)\n * a.remove(diff.index, diff.remove) // Remove `diff.remove` characters\n * a.insert(diff.index, diff.insert) // Insert `diff.insert`\n * a === b // values match\n * ```\n *\n * @template {string|Array<any>} T\n * @typedef {Object} SimpleDiff\n * @property {Number} index The index where changes were applied\n * @property {Number} remove The number of characters to delete starting\n *                                  at `index`.\n * @property {T} insert The new text to insert at `index` after applying\n */\n\nconst highSurrogateRegex = /[\\uD800-\\uDBFF]/\nconst lowSurrogateRegex = /[\\uDC00-\\uDFFF]/\n\n/**\n * Create a diff between two strings. This diff implementation is highly\n * efficient, but not very sophisticated.\n *\n * @function\n *\n * @param {string} a The old version of the string\n * @param {string} b The updated version of the string\n * @return {SimpleDiff<string>} The diff description.\n */\nexport const simpleDiffString = (a, b) => {\n  let left = 0 // number of same characters counting from left\n  let right = 0 // number of same characters counting from right\n  while (left < a.length && left < b.length && a[left] === b[left]) {\n    left++\n  }\n  // If the last same character is a high surrogate, we need to rollback to the previous character\n  if (left > 0 && highSurrogateRegex.test(a[left - 1])) left--\n  while (right + left < a.length && right + left < b.length && a[a.length - right - 1] === b[b.length - right - 1]) {\n    right++\n  }\n  // If the last same character is a low surrogate, we need to rollback to the previous character\n  if (right > 0 && lowSurrogateRegex.test(a[a.length - right])) right--\n  return {\n    index: left,\n    remove: a.length - left - right,\n    insert: b.slice(left, b.length - right)\n  }\n}\n\n/**\n * @todo Remove in favor of simpleDiffString\n * @deprecated\n */\nexport const simpleDiff = simpleDiffString\n\n/**\n * Create a diff between two arrays. This diff implementation is highly\n * efficient, but not very sophisticated.\n *\n * Note: This is basically the same function as above. Another function was created so that the runtime\n * can better optimize these function calls.\n *\n * @function\n * @template T\n *\n * @param {Array<T>} a The old version of the array\n * @param {Array<T>} b The updated version of the array\n * @param {function(T, T):boolean} [compare]\n * @return {SimpleDiff<Array<T>>} The diff description.\n */\nexport const simpleDiffArray = (a, b, compare = equalityStrict) => {\n  let left = 0 // number of same characters counting from left\n  let right = 0 // number of same characters counting from right\n  while (left < a.length && left < b.length && compare(a[left], b[left])) {\n    left++\n  }\n  while (right + left < a.length && right + left < b.length && compare(a[a.length - right - 1], b[b.length - right - 1])) {\n    right++\n  }\n  return {\n    index: left,\n    remove: a.length - left - right,\n    insert: b.slice(left, b.length - right)\n  }\n}\n\n/**\n * Diff text and try to diff at the current cursor position.\n *\n * @param {string} a\n * @param {string} b\n * @param {number} cursor This should refer to the current left cursor-range position\n */\nexport const simpleDiffStringWithCursor = (a, b, cursor) => {\n  let left = 0 // number of same characters counting from left\n  let right = 0 // number of same characters counting from right\n  // Iterate left to the right until we find a changed character\n  // First iteration considers the current cursor position\n  while (\n    left < a.length &&\n    left < b.length &&\n    a[left] === b[left] &&\n    left < cursor\n  ) {\n    left++\n  }\n  // If the last same character is a high surrogate, we need to rollback to the previous character\n  if (left > 0 && highSurrogateRegex.test(a[left - 1])) left--\n  // Iterate right to the left until we find a changed character\n  while (\n    right + left < a.length &&\n    right + left < b.length &&\n    a[a.length - right - 1] === b[b.length - right - 1]\n  ) {\n    right++\n  }\n  // If the last same character is a low surrogate, we need to rollback to the previous character\n  if (right > 0 && lowSurrogateRegex.test(a[a.length - right])) right--\n  // Try to iterate left further to the right without caring about the current cursor position\n  while (\n    right + left < a.length &&\n    right + left < b.length &&\n    a[left] === b[left]\n  ) {\n    left++\n  }\n  if (left > 0 && highSurrogateRegex.test(a[left - 1])) left--\n  return {\n    index: left,\n    remove: a.length - left - right,\n    insert: b.slice(left, b.length - right)\n  }\n}\n","/**\n * @module sha256\n * Spec: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\n * Resources:\n * - https://web.archive.org/web/20150315061807/http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf\n */\n\nimport * as binary from '../binary.js'\n\n/**\n * @param {number} w - a 32bit uint\n * @param {number} shift\n */\nconst rotr = (w, shift) => (w >>> shift) | (w << (32 - shift))\n\n/**\n * Helper for SHA-224 & SHA-256. See 4.1.2.\n * @param {number} x\n */\nconst sum0to256 = x => rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22)\n\n/**\n * Helper for SHA-224 & SHA-256. See 4.1.2.\n * @param {number} x\n */\nconst sum1to256 = x => rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25)\n\n/**\n * Helper for SHA-224 & SHA-256. See 4.1.2.\n * @param {number} x\n */\nconst sigma0to256 = x => rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3\n\n/**\n * Helper for SHA-224 & SHA-256. See 4.1.2.\n * @param {number} x\n */\nconst sigma1to256 = x => rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10\n\n// @todo don't init these variables globally\n\n/**\n * See 4.2.2: Constant for sha256 & sha224\n * These words represent the first thirty-two bits of the fractional parts of\n * the cube roots of the first sixty-four prime numbers. In hex, these constant words are (from left to\n * right)\n */\nconst K = new Uint32Array([\n  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n  0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n  0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n  0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n  0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n])\n\n/**\n * See 5.3.3. Initial hash value.\n *\n * These words were obtained by taking the first thirty-two bits of the fractional parts of the\n * square roots of the first eight prime numbers.\n *\n * @todo shouldn't be a global variable\n */\nconst HINIT = new Uint32Array([\n  0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n])\n\n// time to beat: (large value < 4.35s)\n\nclass Hasher {\n  constructor () {\n    const buf = new ArrayBuffer(64 + 64 * 4)\n    // Init working variables using a single arraybuffer\n    this._H = new Uint32Array(buf, 0, 8)\n    this._H.set(HINIT)\n    // \"Message schedule\" - a working variable\n    this._W = new Uint32Array(buf, 64, 64)\n  }\n\n  _updateHash () {\n    const H = this._H\n    const W = this._W\n    for (let t = 16; t < 64; t++) {\n      W[t] = sigma1to256(W[t - 2]) + W[t - 7] + sigma0to256(W[t - 15]) + W[t - 16]\n    }\n    let a = H[0]\n    let b = H[1]\n    let c = H[2]\n    let d = H[3]\n    let e = H[4]\n    let f = H[5]\n    let g = H[6]\n    let h = H[7]\n    for (let tt = 0, T1, T2; tt < 64; tt++) {\n      T1 = (h + sum1to256(e) + ((e & f) ^ (~e & g)) + K[tt] + W[tt]) >>> 0\n      T2 = (sum0to256(a) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0\n      h = g\n      g = f\n      f = e\n      e = (d + T1) >>> 0\n      d = c\n      c = b\n      b = a\n      a = (T1 + T2) >>> 0\n    }\n    H[0] += a\n    H[1] += b\n    H[2] += c\n    H[3] += d\n    H[4] += e\n    H[5] += f\n    H[6] += g\n    H[7] += h\n  }\n\n  /**\n   * Returns a 32-byte hash.\n   *\n   * @param {Uint8Array} data\n   */\n  digest (data) {\n    let i = 0\n    for (; i + 56 <= data.length;) {\n      // write data in big endianess\n      let j = 0\n      for (; j < 16 && i + 3 < data.length; j++) {\n        this._W[j] = data[i++] << 24 | data[i++] << 16 | data[i++] << 8 | data[i++]\n      }\n      if (i % 64 !== 0) { // there is still room to write partial content and the ending bit.\n        this._W.fill(0, j, 16)\n        while (i < data.length) {\n          this._W[j] |= data[i] << ((3 - (i % 4)) * 8)\n          i++\n        }\n        this._W[j] |= binary.BIT8 << ((3 - (i % 4)) * 8)\n      }\n      this._updateHash()\n    }\n    // same check as earlier - the ending bit has been written\n    const isPaddedWith1 = i % 64 !== 0\n    this._W.fill(0, 0, 16)\n    let j = 0\n    for (; i < data.length; j++) {\n      for (let ci = 3; ci >= 0 && i < data.length; ci--) {\n        this._W[j] |= data[i++] << (ci * 8)\n      }\n    }\n    // Write padding of the message. See 5.1.2.\n    if (!isPaddedWith1) {\n      this._W[j - (i % 4 === 0 ? 0 : 1)] |= binary.BIT8 << ((3 - (i % 4)) * 8)\n    }\n    // write length of message (size in bits) as 64 bit uint\n    // @todo test that this works correctly\n    this._W[14] = data.byteLength / binary.BIT30 // same as data.byteLength >>> 30 - but works on floats\n    this._W[15] = data.byteLength * 8\n    this._updateHash()\n    // correct H endianness to use big endiannes and return a Uint8Array\n    const dv = new Uint8Array(32)\n    for (let i = 0; i < this._H.length; i++) {\n      for (let ci = 0; ci < 4; ci++) {\n        dv[i * 4 + ci] = this._H[i] >>> (3 - ci) * 8\n      }\n    }\n    return dv\n  }\n}\n\n/**\n * Returns a 32-byte hash.\n *\n * @param {Uint8Array} data\n */\nexport const digest = data => new Hasher().digest(data)\n","import * as Y from 'yjs';\nimport { Item, ContentType, Text, XmlElement, UndoManager } from 'yjs';\nimport { DecorationSet, Decoration } from 'prosemirror-view';\nimport { PluginKey, Plugin, TextSelection, AllSelection, NodeSelection, Selection } from 'prosemirror-state';\nimport 'y-protocols/awareness';\nimport { createMutex } from 'lib0/mutex';\nimport * as PModel from 'prosemirror-model';\nimport { Fragment, Node } from 'prosemirror-model';\nimport * as math from 'lib0/math';\nimport * as object from 'lib0/object';\nimport * as set from 'lib0/set';\nimport { simpleDiff } from 'lib0/diff';\nimport * as error from 'lib0/error';\nimport * as random from 'lib0/random';\nimport * as environment from 'lib0/environment';\nimport * as dom from 'lib0/dom';\nimport * as eventloop from 'lib0/eventloop';\nimport * as map from 'lib0/map';\nimport * as sha256 from 'lib0/hash/sha256';\nimport * as buf from 'lib0/buffer';\nimport { ReplaceStep } from 'prosemirror-transform';\n\n/**\n * The unique prosemirror plugin key for syncPlugin\n *\n * @public\n */\nconst ySyncPluginKey = new PluginKey('y-sync');\n\n/**\n * The unique prosemirror plugin key for undoPlugin\n *\n * @public\n */\nconst yUndoPluginKey = new PluginKey('y-undo');\n\n/**\n * The unique prosemirror plugin key for cursorPlugin\n *\n * @public\n */\nconst yCursorPluginKey = new PluginKey('yjs-cursor');\n\n/**\n * Custom function to transform sha256 hash to N byte\n *\n * @param {Uint8Array} digest\n */\nconst _convolute = digest => {\n  const N = 6;\n  for (let i = N; i < digest.length; i++) {\n    digest[i % N] = digest[i % N] ^ digest[i];\n  }\n  return digest.slice(0, N)\n};\n\n/**\n * @param {any} json\n */\nconst hashOfJSON = (json) => buf.toBase64(_convolute(sha256.digest(buf.encodeAny(json))));\n\n/**\n * @module bindings/prosemirror\n */\n\n/**\n * @typedef {Object} BindingMetadata\n * @property {ProsemirrorMapping} BindingMetadata.mapping\n * @property {Map<import('prosemirror-model').MarkType, boolean>} BindingMetadata.isOMark - is overlapping mark\n */\n\n/**\n * @return BindingMetadata\n */\nconst createEmptyMeta = () => ({\n  mapping: new Map(),\n  isOMark: new Map()\n});\n\n/**\n * @param {Y.Item} item\n * @param {Y.Snapshot} [snapshot]\n */\nconst isVisible = (item, snapshot) =>\n  snapshot === undefined\n    ? !item.deleted\n    : (snapshot.sv.has(item.id.client) && /** @type {number} */\n      (snapshot.sv.get(item.id.client)) > item.id.clock &&\n      !Y.isDeleted(snapshot.ds, item.id));\n\n/**\n * Either a node if type is YXmlElement or an Array of text nodes if YXmlText\n * @typedef {Map<Y.AbstractType<any>, PModel.Node | Array<PModel.Node>>} ProsemirrorMapping\n */\n\n/**\n * @typedef {Object} ColorDef\n * @property {string} ColorDef.light\n * @property {string} ColorDef.dark\n */\n\n/**\n * @typedef {Object} YSyncOpts\n * @property {Array<ColorDef>} [YSyncOpts.colors]\n * @property {Map<string,ColorDef>} [YSyncOpts.colorMapping]\n * @property {Y.PermanentUserData|null} [YSyncOpts.permanentUserData]\n * @property {ProsemirrorMapping} [YSyncOpts.mapping]\n * @property {function} [YSyncOpts.onFirstRender] Fired when the content from Yjs is initially rendered to ProseMirror\n */\n\n/**\n * @type {Array<ColorDef>}\n */\nconst defaultColors = [{ light: '#ecd44433', dark: '#ecd444' }];\n\n/**\n * @param {Map<string,ColorDef>} colorMapping\n * @param {Array<ColorDef>} colors\n * @param {string} user\n * @return {ColorDef}\n */\nconst getUserColor = (colorMapping, colors, user) => {\n  // @todo do not hit the same color twice if possible\n  if (!colorMapping.has(user)) {\n    if (colorMapping.size < colors.length) {\n      const usedColors = set.create();\n      colorMapping.forEach((color) => usedColors.add(color));\n      colors = colors.filter((color) => !usedColors.has(color));\n    }\n    colorMapping.set(user, random.oneOf(colors));\n  }\n  return /** @type {ColorDef} */ (colorMapping.get(user))\n};\n\n/**\n * This plugin listens to changes in prosemirror view and keeps yXmlState and view in sync.\n *\n * This plugin also keeps references to the type and the shared document so other plugins can access it.\n * @param {Y.XmlFragment} yXmlFragment\n * @param {YSyncOpts} opts\n * @return {any} Returns a prosemirror plugin that binds to this type\n */\nconst ySyncPlugin = (yXmlFragment, {\n  colors = defaultColors,\n  colorMapping = new Map(),\n  permanentUserData = null,\n  onFirstRender = () => {},\n  mapping\n} = {}) => {\n  let initialContentChanged = false;\n  const binding = new ProsemirrorBinding(yXmlFragment, mapping);\n  const plugin = new Plugin({\n    props: {\n      editable: (state) => {\n        const syncState = ySyncPluginKey.getState(state);\n        return syncState.snapshot == null && syncState.prevSnapshot == null\n      }\n    },\n    key: ySyncPluginKey,\n    state: {\n      /**\n       * @returns {any}\n       */\n      init: (_initargs, _state) => {\n        return {\n          type: yXmlFragment,\n          doc: yXmlFragment.doc,\n          binding,\n          snapshot: null,\n          prevSnapshot: null,\n          isChangeOrigin: false,\n          isUndoRedoOperation: false,\n          addToHistory: true,\n          colors,\n          colorMapping,\n          permanentUserData\n        }\n      },\n      apply: (tr, pluginState) => {\n        const change = tr.getMeta(ySyncPluginKey);\n        if (change !== undefined) {\n          pluginState = Object.assign({}, pluginState);\n          for (const key in change) {\n            pluginState[key] = change[key];\n          }\n        }\n        pluginState.addToHistory = tr.getMeta('addToHistory') !== false;\n        // always set isChangeOrigin. If undefined, this is not change origin.\n        pluginState.isChangeOrigin = change !== undefined &&\n          !!change.isChangeOrigin;\n        pluginState.isUndoRedoOperation = change !== undefined && !!change.isChangeOrigin && !!change.isUndoRedoOperation;\n        if (binding.prosemirrorView !== null) {\n          if (\n            change !== undefined &&\n            (change.snapshot != null || change.prevSnapshot != null)\n          ) {\n            // snapshot changed, rerender next\n            eventloop.timeout(0, () => {\n              if (binding.prosemirrorView == null) {\n                return\n              }\n              if (change.restore == null) {\n                binding._renderSnapshot(\n                  change.snapshot,\n                  change.prevSnapshot,\n                  pluginState\n                );\n              } else {\n                binding._renderSnapshot(\n                  change.snapshot,\n                  change.snapshot,\n                  pluginState\n                );\n                // reset to current prosemirror state\n                delete pluginState.restore;\n                delete pluginState.snapshot;\n                delete pluginState.prevSnapshot;\n                binding.mux(() => {\n                  binding._prosemirrorChanged(\n                    binding.prosemirrorView.state.doc\n                  );\n                });\n              }\n            });\n          }\n        }\n        return pluginState\n      }\n    },\n    view: (view) => {\n      binding.initView(view);\n      if (mapping == null) {\n        // force rerender to update the bindings mapping\n        binding._forceRerender();\n      }\n      onFirstRender();\n      return {\n        update: () => {\n          const pluginState = plugin.getState(view.state);\n          if (\n            pluginState.snapshot == null && pluginState.prevSnapshot == null\n          ) {\n            if (\n              // If the content doesn't change initially, we don't render anything to Yjs\n              // If the content was cleared by a user action, we want to catch the change and\n              // represent it in Yjs\n              initialContentChanged ||\n              view.state.doc.content.findDiffStart(\n                view.state.doc.type.createAndFill().content\n              ) !== null\n            ) {\n              initialContentChanged = true;\n              if (\n                pluginState.addToHistory === false &&\n                !pluginState.isChangeOrigin\n              ) {\n                const yUndoPluginState = yUndoPluginKey.getState(view.state);\n                /**\n                 * @type {Y.UndoManager}\n                 */\n                const um = yUndoPluginState && yUndoPluginState.undoManager;\n                if (um) {\n                  um.stopCapturing();\n                }\n              }\n              binding.mux(() => {\n                /** @type {Y.Doc} */ (pluginState.doc).transact((tr) => {\n                  tr.meta.set('addToHistory', pluginState.addToHistory);\n                  binding._prosemirrorChanged(view.state.doc);\n                }, ySyncPluginKey);\n              });\n            }\n          }\n        },\n        destroy: () => {\n          binding.destroy();\n        }\n      }\n    }\n  });\n  return plugin\n};\n\n/**\n * Resolves one text-selection endpoint after a remote update. Falls back to\n * content-based matching when the Yjs resolution is missing or lands in the\n * wrong block, and keeps the Yjs resolution when the fallback finds nothing.\n *\n * @param {import('prosemirror-model').Node} newDoc\n * @param {import('prosemirror-model').Node} oldDoc\n * @param {number|null|undefined} oldAbs\n * @param {number|null} resolved\n * @return {number|null}\n */\nconst recoverSelectionEndpoint = (newDoc, oldDoc, oldAbs, resolved) => {\n  if (oldAbs == null) {\n    return resolved\n  }\n  const misresolved = resolved === null ||\n    (oldAbs > 1 && resolved <= 1) ||\n    isMisresolvedAfterStructuralChange(oldDoc, newDoc, oldAbs, resolved);\n  if (!misresolved) {\n    return resolved\n  }\n  const recovered = findAbsolutePositionAfterStructuralChange(oldDoc, newDoc, oldAbs);\n  return recovered !== null ? recovered : resolved\n};\n\n/**\n * @param {import('prosemirror-state').Transaction} tr\n * @param {ReturnType<typeof getRelativeSelection>} relSel\n * @param {ProsemirrorBinding} binding\n * @param {import('prosemirror-model').Node} [oldDoc]\n */\nconst restoreRelativeSelection = (tr, relSel, binding, oldDoc) => {\n  if (relSel !== null && relSel.anchor !== null && relSel.head !== null) {\n    if (relSel.type === 'all') {\n      tr.setSelection(new AllSelection(tr.doc));\n    } else if (relSel.type === 'node') {\n      const anchor = relativePositionToAbsolutePosition(\n        binding.doc,\n        binding.type,\n        relSel.anchor,\n        binding.mapping\n      );\n      // anchor is null when the referenced node was deleted or moved out of\n      // binding.type by a remote update; resolving null would throw.\n      if (anchor !== null) {\n        tr.setSelection(createSafeNodeSelection(tr, anchor));\n      }\n    } else if (relSel.type === 'nodeRange') {\n      const anchor = relativePositionToAbsolutePosition(\n        binding.doc,\n        binding.type,\n        relSel.anchor,\n        binding.mapping\n      );\n      const head = relativePositionToAbsolutePosition(\n        binding.doc,\n        binding.type,\n        relSel.head,\n        binding.mapping\n      );\n      const selection = createSafeNodeRangeSelection(tr, anchor, head, relSel.depth);\n      if (selection !== null) {\n        tr.setSelection(selection);\n      }\n    } else {\n      let anchor = relativePositionToAbsolutePosition(\n        binding.doc,\n        binding.type,\n        relSel.anchor,\n        binding.mapping\n      );\n      let head = relativePositionToAbsolutePosition(\n        binding.doc,\n        binding.type,\n        relSel.head,\n        binding.mapping\n      );\n      if (oldDoc != null) {\n        anchor = recoverSelectionEndpoint(tr.doc, oldDoc, relSel.absAnchor, anchor);\n        head = recoverSelectionEndpoint(tr.doc, oldDoc, relSel.absHead, head);\n      }\n      // Collapse to the surviving endpoint instead of dropping the selection;\n      // an unset selection maps through the full-doc replace to the doc start.\n      if (anchor === null) {\n        anchor = head;\n      }\n      if (head === null) {\n        head = anchor;\n      }\n      if (anchor !== null && head !== null) {\n        tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));\n      }\n    }\n  }\n};\n\n/**\n * @param {import('prosemirror-state').Transaction} tr\n * @param {number} pos\n * @returns {import('prosemirror-state').Selection}\n *\n * Creates a NodeSelection if the position points to a valid node, otherwise\n * creates a TextSelection near the position.\n */\nconst createSafeNodeSelection = (tr, pos) => {\n  const $pos = tr.doc.resolve(pos);\n  if ($pos.nodeAfter) {\n    return NodeSelection.create(tr.doc, pos)\n  } else {\n    return TextSelection.near($pos)\n  }\n};\n\n/**\n * Safely reconstructs a NodeRangeSelection from resolved absolute positions.\n *\n * @param {import('prosemirror-state').Transaction} tr - The transaction whose document provides resolved positions.\n * @param {number|null} anchor - Absolute document position marking the start (boundary) of the node range.\n *        Use `relativePositionToAbsolutePosition` before calling this function.\n * @param {number|null} head - Absolute document position marking the end (boundary) of the node range.\n *        Use `relativePositionToAbsolutePosition` before calling this function.\n * @param {number|undefined} depth - The nesting depth at which the range operates (e.g. 0 for\n *        top-level blocks, 1 for blocks nested inside a wrapper). Passed through to\n *        `Selection.fromJSON`; ignored by `@tiptap/extension-node-range` < v2.29 but\n *        properly stored starting from that version.\n * @returns {import('prosemirror-state').Selection|null} Reconstructed selection, or null if\n *          anchor/head could not be resolved.\n */\nconst createSafeNodeRangeSelection = (tr, anchor, head, depth) => {\n  if (anchor === null || head === null) {\n    return null\n  }\n  const clampedAnchor = Math.min(Math.max(anchor, 0), tr.doc.content.size);\n  const clampedHead = Math.min(Math.max(head, 0), tr.doc.content.size);\n  try {\n    const selection = Selection.fromJSON(tr.doc, {\n      type: 'nodeRange',\n      anchor: clampedAnchor,\n      head: clampedHead,\n      depth\n    });\n    if (!selection.ranges.length) {\n      return TextSelection.near(tr.doc.resolve(clampedAnchor))\n    }\n    return selection\n  } catch (e) {\n    return TextSelection.near(tr.doc.resolve(clampedAnchor))\n  }\n};\n\n/**\n * @param {ProsemirrorBinding} pmbinding\n * @param {import('prosemirror-state').EditorState} state\n */\nconst getRelativeSelection = (pmbinding, state) => {\n  const type = /** @type {any} */ (state.selection).jsonID;\n  return {\n    type,\n    // `depth` is only meaningful for NodeRangeSelection; undefined for every other type.\n    depth: type === 'nodeRange' ? /** @type {any} */ (state.selection).depth : undefined,\n    anchor: absolutePositionToRelativePosition(\n      state.selection.anchor,\n      pmbinding.type,\n      pmbinding.mapping\n    ),\n    head: absolutePositionToRelativePosition(\n      state.selection.head,\n      pmbinding.type,\n      pmbinding.mapping\n    ),\n    absAnchor: state.selection.anchor,\n    absHead: state.selection.head\n  }\n};\n\n/**\n * Binding for prosemirror.\n *\n * @protected\n */\nclass ProsemirrorBinding {\n  /**\n   * @param {Y.XmlFragment} yXmlFragment The bind source\n   * @param {ProsemirrorMapping} mapping\n   */\n  constructor (yXmlFragment, mapping = new Map()) {\n    this.type = yXmlFragment;\n    /**\n     * this will be set once the view is created\n     * @type {any}\n     */\n    this.prosemirrorView = null;\n    this.mux = createMutex();\n    this.mapping = mapping;\n    /**\n     * Is overlapping mark - i.e. mark does not exclude itself.\n     *\n     * @type {Map<import('prosemirror-model').MarkType, boolean>}\n     */\n    this.isOMark = new Map();\n    this._observeFunction = this._typeChanged.bind(this);\n    /**\n     * @type {Y.Doc}\n     */\n    // @ts-ignore\n    this.doc = yXmlFragment.doc;\n    /**\n     * current selection as relative positions in the Yjs model\n     */\n    this.beforeTransactionSelection = null;\n    this.beforeAllTransactions = () => {\n      if (this.beforeTransactionSelection === null && this.prosemirrorView != null) {\n        this.beforeTransactionSelection = getRelativeSelection(\n          this,\n          this.prosemirrorView.state\n        );\n      }\n    };\n    this.afterAllTransactions = () => {\n      this.beforeTransactionSelection = null;\n    };\n    this._domSelectionInView = null;\n  }\n\n  /**\n   * Create a transaction for changing the prosemirror state.\n   *\n   * @returns\n   */\n  get _tr () {\n    return this.prosemirrorView.state.tr.setMeta('addToHistory', false)\n  }\n\n  _isLocalCursorInView () {\n    if (!this.prosemirrorView.hasFocus()) return false\n    if (environment.isBrowser && this._domSelectionInView === null) {\n      // Calculate the domSelectionInView and clear by next tick after all events are finished\n      eventloop.timeout(0, () => {\n        this._domSelectionInView = null;\n      });\n      this._domSelectionInView = this._isDomSelectionInView();\n    }\n    return this._domSelectionInView\n  }\n\n  _isDomSelectionInView () {\n    const selection = this.prosemirrorView._root.getSelection();\n\n    if (selection == null || selection.anchorNode == null) return false\n\n    const range = this.prosemirrorView._root.createRange();\n    range.setStart(selection.anchorNode, selection.anchorOffset);\n    range.setEnd(selection.focusNode, selection.focusOffset);\n\n    // This is a workaround for an edgecase where getBoundingClientRect will\n    // return zero values if the selection is collapsed at the start of a newline\n    // see reference here: https://stackoverflow.com/a/59780954\n    const rects = range.getClientRects();\n    if (rects.length === 0) {\n      // probably buggy newline behavior, explicitly select the node contents\n      if (range.startContainer && range.collapsed) {\n        range.selectNodeContents(range.startContainer);\n      }\n    }\n\n    const bounding = range.getBoundingClientRect();\n    const documentElement = dom.doc.documentElement;\n\n    return bounding.bottom >= 0 && bounding.right >= 0 &&\n      bounding.left <=\n        (window.innerWidth || documentElement.clientWidth || 0) &&\n      bounding.top <= (window.innerHeight || documentElement.clientHeight || 0)\n  }\n\n  /**\n   * @param {Y.Snapshot} snapshot\n   * @param {Y.Snapshot} prevSnapshot\n   */\n  renderSnapshot (snapshot, prevSnapshot) {\n    if (!prevSnapshot) {\n      prevSnapshot = Y.createSnapshot(Y.createDeleteSet(), new Map());\n    }\n    this.prosemirrorView.dispatch(\n      this._tr.setMeta(ySyncPluginKey, { snapshot, prevSnapshot })\n    );\n  }\n\n  unrenderSnapshot () {\n    this.mapping.clear();\n    this.mux(() => {\n      const fragmentContent = this.type.toArray().map((t) =>\n        createNodeFromYElement(\n          /** @type {Y.XmlElement} */ (t),\n          this.prosemirrorView.state.schema,\n          this\n        )\n      ).filter((n) => n !== null);\n      // @ts-ignore\n      const tr = this._tr.replace(\n        0,\n        this.prosemirrorView.state.doc.content.size,\n        new PModel.Slice(PModel.Fragment.from(fragmentContent), 0, 0)\n      );\n      tr.setMeta(ySyncPluginKey, { snapshot: null, prevSnapshot: null });\n      this.prosemirrorView.dispatch(tr);\n    });\n  }\n\n  _forceRerender () {\n    this.mapping.clear();\n    this.mux(() => {\n      // If this is a forced rerender, this might neither happen as a pm change nor within a Yjs\n      // transaction. Then the \"before selection\" doesn't exist. In this case, we need to create a\n      // relative position before replacing content. Fixes #126\n      const sel = this.beforeTransactionSelection !== null ? null : this.prosemirrorView.state.selection;\n      const fragmentContent = this.type.toArray().map((t) =>\n        createNodeFromYElement(\n          /** @type {Y.XmlElement} */ (t),\n          this.prosemirrorView.state.schema,\n          this\n        )\n      ).filter((n) => n !== null);\n      // @ts-ignore\n      const tr = this._tr.replace(\n        0,\n        this.prosemirrorView.state.doc.content.size,\n        new PModel.Slice(PModel.Fragment.from(fragmentContent), 0, 0)\n      );\n      if (sel) {\n        /**\n         * If the Prosemirror document we just created from this.type is\n         * smaller than the previous document, the selection might be\n         * out of bound, which would make Prosemirror throw an error.\n         */\n        const clampedAnchor = math.min(math.max(sel.anchor, 0), tr.doc.content.size);\n        const clampedHead = math.min(math.max(sel.head, 0), tr.doc.content.size);\n\n        tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));\n      }\n      this.prosemirrorView.dispatch(\n        tr.setMeta(ySyncPluginKey, { isChangeOrigin: true, binding: this })\n      );\n    });\n  }\n\n  /**\n   * @param {Y.Snapshot|Uint8Array} snapshot\n   * @param {Y.Snapshot|Uint8Array} prevSnapshot\n   * @param {Object} pluginState\n   */\n  _renderSnapshot (snapshot, prevSnapshot, pluginState) {\n    /**\n     * The document that contains the full history of this document.\n     * @type {Y.Doc}\n     */\n    let historyDoc = this.doc;\n    let historyType = this.type;\n    if (!snapshot) {\n      snapshot = Y.snapshot(this.doc);\n    }\n    if (snapshot instanceof Uint8Array || prevSnapshot instanceof Uint8Array) {\n      if (!(snapshot instanceof Uint8Array) || !(prevSnapshot instanceof Uint8Array)) {\n        // expected both snapshots to be v2 updates\n        error.unexpectedCase();\n      }\n      historyDoc = new Y.Doc({ gc: false });\n      Y.applyUpdateV2(historyDoc, prevSnapshot);\n      prevSnapshot = Y.snapshot(historyDoc);\n      Y.applyUpdateV2(historyDoc, snapshot);\n      snapshot = Y.snapshot(historyDoc);\n      if (historyType._item === null) {\n        /**\n         * If is a root type, we need to find the root key in the initial document\n         * and use it to get the history type.\n         */\n        const rootKey = Array.from(this.doc.share.keys()).find(\n          (key) => this.doc.share.get(key) === this.type\n        );\n        historyType = historyDoc.getXmlFragment(rootKey);\n      } else {\n        /**\n         * If it is a sub type, we use the item id to find the history type.\n         */\n        const historyStructs =\n          historyDoc.store.clients.get(historyType._item.id.client) ?? [];\n        const itemIndex = Y.findIndexSS(\n          historyStructs,\n          historyType._item.id.clock\n        );\n        const item = /** @type {Y.Item} */ (historyStructs[itemIndex]);\n        const content = /** @type {Y.ContentType} */ (item.content);\n        historyType = /** @type {Y.XmlFragment} */ (content.type);\n      }\n    }\n    // clear mapping because we are going to rerender\n    this.mapping.clear();\n    this.mux(() => {\n      historyDoc.transact((transaction) => {\n        // before rendering, we are going to sanitize ops and split deleted ops\n        // if they were deleted by seperate users.\n        /**\n         * @type {Y.PermanentUserData}\n         */\n        const pud = pluginState.permanentUserData;\n        if (pud) {\n          pud.dss.forEach((ds) => {\n            Y.iterateDeletedStructs(transaction, ds, (_item) => {});\n          });\n        }\n        /**\n         * @param {'removed'|'added'} type\n         * @param {Y.ID} id\n         */\n        const computeYChange = (type, id) => {\n          const user = type === 'added'\n            ? pud.getUserByClientId(id.client)\n            : pud.getUserByDeletedId(id);\n          return {\n            user,\n            type,\n            color: getUserColor(\n              pluginState.colorMapping,\n              pluginState.colors,\n              user\n            )\n          }\n        };\n        // Create document fragment and render\n        const fragmentContent = Y.typeListToArraySnapshot(\n          historyType,\n          new Y.Snapshot(prevSnapshot.ds, snapshot.sv)\n        ).map((t) => {\n          if (\n            !t._item.deleted || isVisible(t._item, snapshot) ||\n            isVisible(t._item, prevSnapshot)\n          ) {\n            return createNodeFromYElement(\n              t,\n              this.prosemirrorView.state.schema,\n              { mapping: new Map(), isOMark: new Map() },\n              snapshot,\n              prevSnapshot,\n              computeYChange\n            )\n          } else {\n            // No need to render elements that are not visible by either snapshot.\n            // If a client adds and deletes content in the same snapshot the element is not visible by either snapshot.\n            return null\n          }\n        }).filter((n) => n !== null);\n        // @ts-ignore\n        const tr = this._tr.replace(\n          0,\n          this.prosemirrorView.state.doc.content.size,\n          new PModel.Slice(PModel.Fragment.from(fragmentContent), 0, 0)\n        );\n        this.prosemirrorView.dispatch(\n          tr.setMeta(ySyncPluginKey, { isChangeOrigin: true })\n        );\n      }, ySyncPluginKey);\n    });\n  }\n\n  /**\n   * @param {Array<Y.YEvent<any>>} events\n   * @param {Y.Transaction} transaction\n   */\n  _typeChanged (events, transaction) {\n    if (this.prosemirrorView == null) return\n    const syncState = ySyncPluginKey.getState(this.prosemirrorView.state);\n    if (\n      events.length === 0 || syncState.snapshot != null ||\n      syncState.prevSnapshot != null\n    ) {\n      // drop out if snapshot is active\n      this.renderSnapshot(syncState.snapshot, syncState.prevSnapshot);\n      return\n    }\n    this.mux(() => {\n      /**\n       * @param {any} _\n       * @param {Y.AbstractType<any>} type\n       */\n      const delType = (_, type) => this.mapping.delete(type);\n      Y.iterateDeletedStructs(\n        transaction,\n        transaction.deleteSet,\n        (struct) => {\n          if (struct.constructor === Y.Item) {\n            const type = /** @type {Y.ContentType} */ (/** @type {Y.Item} */ (struct).content).type;\n            type && this.mapping.delete(type);\n          }\n        }\n      );\n      transaction.changed.forEach(delType);\n      transaction.changedParentTypes.forEach(delType);\n      // Rebuild the full Y↔PM mapping so relative cursor positions resolve against\n      // current node sizes after structural changes (e.g. drag-and-drop block moves).\n      this.mapping.clear();\n      const fragmentContent = this.type.toArray().map((t) =>\n        createNodeIfNotExists(\n          /** @type {Y.XmlElement | Y.XmlHook} */ (t),\n          this.prosemirrorView.state.schema,\n          this\n        )\n      ).filter((n) => n !== null);\n      const oldDoc = this.prosemirrorView.state.doc;\n      // @ts-ignore\n      let tr = this._tr.replace(\n        0,\n        this.prosemirrorView.state.doc.content.size,\n        new PModel.Slice(PModel.Fragment.from(fragmentContent), 0, 0)\n      );\n      restoreRelativeSelection(tr, this.beforeTransactionSelection, this, oldDoc);\n      tr = tr.setMeta(ySyncPluginKey, { isChangeOrigin: true, isUndoRedoOperation: transaction.origin instanceof Y.UndoManager });\n      if (\n        this.beforeTransactionSelection !== null && this._isLocalCursorInView()\n      ) {\n        tr.scrollIntoView();\n      }\n      this.prosemirrorView.dispatch(tr);\n    });\n  }\n\n  /**\n   * @param {import('prosemirror-model').Node} doc\n   */\n  _prosemirrorChanged (doc) {\n    this.doc.transact(() => {\n      updateYFragment(this.doc, this.type, doc, this);\n      this.beforeTransactionSelection = getRelativeSelection(\n        this,\n        this.prosemirrorView.state\n      );\n    }, ySyncPluginKey);\n  }\n\n  /**\n   * View is ready to listen to changes. Register observers.\n   * @param {any} prosemirrorView\n   */\n  initView (prosemirrorView) {\n    if (this.prosemirrorView != null) this.destroy();\n    this.prosemirrorView = prosemirrorView;\n    this.doc.on('beforeAllTransactions', this.beforeAllTransactions);\n    this.doc.on('afterAllTransactions', this.afterAllTransactions);\n    this.type.observeDeep(this._observeFunction);\n  }\n\n  destroy () {\n    if (this.prosemirrorView == null) return\n    this.prosemirrorView = null;\n    this.type.unobserveDeep(this._observeFunction);\n    this.doc.off('beforeAllTransactions', this.beforeAllTransactions);\n    this.doc.off('afterAllTransactions', this.afterAllTransactions);\n  }\n}\n\n/**\n * @private\n * @param {Y.XmlElement | Y.XmlHook} el\n * @param {PModel.Schema} schema\n * @param {BindingMetadata} meta\n * @param {Y.Snapshot} [snapshot]\n * @param {Y.Snapshot} [prevSnapshot]\n * @param {function('removed' | 'added', Y.ID):any} [computeYChange]\n * @return {PModel.Node | null}\n */\nconst createNodeIfNotExists = (\n  el,\n  schema,\n  meta,\n  snapshot,\n  prevSnapshot,\n  computeYChange\n) => {\n  const node = /** @type {PModel.Node} */ (meta.mapping.get(el));\n  if (node === undefined) {\n    if (el instanceof Y.XmlElement) {\n      return createNodeFromYElement(\n        el,\n        schema,\n        meta,\n        snapshot,\n        prevSnapshot,\n        computeYChange\n      )\n    } else {\n      throw error.methodUnimplemented() // we are currently not handling hooks\n    }\n  }\n  return node\n};\n\n/**\n * @private\n * @param {Y.XmlElement} el\n * @param {any} schema\n * @param {BindingMetadata} meta\n * @param {Y.Snapshot} [snapshot]\n * @param {Y.Snapshot} [prevSnapshot]\n * @param {function('removed' | 'added', Y.ID):any} [computeYChange]\n * @return {PModel.Node | null} Returns node if node could be created. Otherwise it deletes the yjs type and returns null\n */\nconst createNodeFromYElement = (\n  el,\n  schema,\n  meta,\n  snapshot,\n  prevSnapshot,\n  computeYChange\n) => {\n  const children = [];\n  /**\n   * @param {Y.XmlElement | Y.XmlText} type\n   */\n  const createChildren = (type) => {\n    if (type instanceof Y.XmlElement) {\n      const n = createNodeIfNotExists(\n        type,\n        schema,\n        meta,\n        snapshot,\n        prevSnapshot,\n        computeYChange\n      );\n      if (n !== null) {\n        children.push(n);\n      }\n    } else {\n      // If the next ytext exists and was created by us, move the content to the current ytext.\n      // This is a fix for #160 -- duplication of characters when two Y.Text exist next to each\n      // other.\n      const nextytext = /** @type {Y.ContentType} */ (type._item.right?.content)?.type;\n      if (nextytext instanceof Y.Text && !nextytext._item.deleted && nextytext._item.id.client === nextytext.doc.clientID) {\n        type.applyDelta([\n          { retain: type.length },\n          ...nextytext.toDelta()\n        ]);\n        nextytext.doc.transact(tr => {\n          nextytext._item.delete(tr);\n        });\n      }\n      // now create the prosemirror text nodes\n      const ns = createTextNodesFromYText(\n        type,\n        schema,\n        meta,\n        snapshot,\n        prevSnapshot,\n        computeYChange\n      );\n      if (ns !== null) {\n        ns.forEach((textchild) => {\n          if (textchild !== null) {\n            children.push(textchild);\n          }\n        });\n      }\n    }\n  };\n  if (snapshot === undefined || prevSnapshot === undefined) {\n    el.toArray().forEach(createChildren);\n  } else {\n    Y.typeListToArraySnapshot(el, new Y.Snapshot(prevSnapshot.ds, snapshot.sv))\n      .forEach(createChildren);\n  }\n  try {\n    const attrs = el.getAttributes(snapshot);\n    if (snapshot !== undefined) {\n      if (!isVisible(/** @type {Y.Item} */ (el._item), snapshot)) {\n        attrs.ychange = computeYChange\n          ? computeYChange('removed', /** @type {Y.Item} */ (el._item).id)\n          : { type: 'removed' };\n      } else if (!isVisible(/** @type {Y.Item} */ (el._item), prevSnapshot)) {\n        attrs.ychange = computeYChange\n          ? computeYChange('added', /** @type {Y.Item} */ (el._item).id)\n          : { type: 'added' };\n      }\n    }\n    const node = schema.node(el.nodeName, attrs, children);\n    meta.mapping.set(el, node);\n    return node\n  } catch (e) {\n    // an error occured while creating the node. This is probably a result of a concurrent action.\n    /** @type {Y.Doc} */ (el.doc).transact((transaction) => {\n      /** @type {Y.Item} */ (el._item).delete(transaction);\n    }, ySyncPluginKey);\n    meta.mapping.delete(el);\n    return null\n  }\n};\n\n/**\n * @private\n * @param {Y.XmlText} text\n * @param {import('prosemirror-model').Schema} schema\n * @param {BindingMetadata} _meta\n * @param {Y.Snapshot} [snapshot]\n * @param {Y.Snapshot} [prevSnapshot]\n * @param {function('removed' | 'added', Y.ID):any} [computeYChange]\n * @return {Array<PModel.Node>|null}\n */\nconst createTextNodesFromYText = (\n  text,\n  schema,\n  _meta,\n  snapshot,\n  prevSnapshot,\n  computeYChange\n) => {\n  const nodes = [];\n  const deltas = text.toDelta(snapshot, prevSnapshot, computeYChange);\n  try {\n    for (let i = 0; i < deltas.length; i++) {\n      const delta = deltas[i];\n      nodes.push(schema.text(delta.insert, attributesToMarks(delta.attributes, schema)));\n    }\n  } catch (e) {\n    // an error occured while creating the node. This is probably a result of a concurrent action.\n    /** @type {Y.Doc} */ (text.doc).transact((transaction) => {\n      /** @type {Y.Item} */ (text._item).delete(transaction);\n    }, ySyncPluginKey);\n    return null\n  }\n  // @ts-ignore\n  return nodes\n};\n\n/**\n * @private\n * @param {Array<any>} nodes prosemirror node\n * @param {BindingMetadata} meta\n * @return {Y.XmlText}\n */\nconst createTypeFromTextNodes = (nodes, meta) => {\n  const type = new Y.XmlText();\n  const delta = nodes.map((node) => ({\n    // @ts-ignore\n    insert: node.text,\n    attributes: marksToAttributes(node.marks, meta)\n  }));\n  type.applyDelta(delta);\n  meta.mapping.set(type, nodes);\n  return type\n};\n\n/**\n * @private\n * @param {any} node prosemirror node\n * @param {BindingMetadata} meta\n * @return {Y.XmlElement}\n */\nconst createTypeFromElementNode = (node, meta) => {\n  const type = new Y.XmlElement(node.type.name);\n  for (const key in node.attrs) {\n    const val = node.attrs[key];\n    if (val !== null && key !== 'ychange') {\n      type.setAttribute(key, val);\n    }\n  }\n  type.insert(\n    0,\n    normalizePNodeContent(node).map((n) =>\n      createTypeFromTextOrElementNode(n, meta)\n    )\n  );\n  meta.mapping.set(type, node);\n  return type\n};\n\n/**\n * @private\n * @param {PModel.Node|Array<PModel.Node>} node prosemirror text node\n * @param {BindingMetadata} meta\n * @return {Y.XmlElement|Y.XmlText}\n */\nconst createTypeFromTextOrElementNode = (node, meta) =>\n  node instanceof Array\n    ? createTypeFromTextNodes(node, meta)\n    : createTypeFromElementNode(node, meta);\n\n/**\n * @param {any} val\n */\nconst isObject = (val) => typeof val === 'object' && val !== null;\n\n/**\n * @param {any} pattrs\n * @param {any} yattrs\n */\nconst equalAttrs = (pattrs, yattrs) => {\n  const keys = Object.keys(pattrs).filter((key) => pattrs[key] !== null);\n  let eq =\n    keys.length ===\n      Object.keys(yattrs).filter((key) => yattrs[key] !== null).length;\n  for (let i = 0; i < keys.length && eq; i++) {\n    const key = keys[i];\n    const l = pattrs[key];\n    const r = yattrs[key];\n    eq = key === 'ychange' || l === r ||\n      (isObject(l) && isObject(r) && equalAttrs(l, r));\n  }\n  return eq\n};\n\n/**\n * @typedef {Array<Array<PModel.Node>|PModel.Node>} NormalizedPNodeContent\n */\n\n/**\n * @param {any} pnode\n * @return {NormalizedPNodeContent}\n */\nconst normalizePNodeContent = (pnode) => {\n  const c = pnode.content.content;\n  const res = [];\n  for (let i = 0; i < c.length; i++) {\n    const n = c[i];\n    if (n.isText) {\n      const textNodes = [];\n      for (let tnode = c[i]; i < c.length && tnode.isText; tnode = c[++i]) {\n        textNodes.push(tnode);\n      }\n      i--;\n      res.push(textNodes);\n    } else {\n      res.push(n);\n    }\n  }\n  return res\n};\n\n/**\n * @param {Y.XmlText} ytext\n * @param {Array<any>} ptexts\n */\nconst equalYTextPText = (ytext, ptexts) => {\n  const delta = ytext.toDelta();\n  return delta.length === ptexts.length &&\n    delta.every(/** @type {(d:any,i:number) => boolean} */ (d, i) =>\n      d.insert === /** @type {any} */ (ptexts[i]).text &&\n      object.keys(d.attributes || {}).length === ptexts[i].marks.length &&\n      object.every(d.attributes, (attr, /** @type {string} */ yattrname) => {\n        const markname = yattr2markname(yattrname);\n        const pmarks = ptexts[i].marks;\n\n        const pmark = pmarks.find(/** @param {any} mark */ mark => mark.type.name === markname);\n\n        // Ensure the pmark is present in the ptexts before checking equality. When replacing a mark with another mark\n        // the pmark will be missing from the ptexts and the equalAttrs will throw an error.\n        if (!pmark) {\n          return false\n        }\n\n        return equalAttrs(attr, pmarks.find(/** @param {any} mark */ mark => mark.type.name === markname)?.attrs)\n      })\n    )\n};\n\n/**\n * @param {Y.XmlElement|Y.XmlText|Y.XmlHook} ytype\n * @param {any|Array<any>} pnode\n */\nconst equalYTypePNode = (ytype, pnode) => {\n  if (\n    ytype instanceof Y.XmlElement && !(pnode instanceof Array) &&\n    matchNodeName(ytype, pnode)\n  ) {\n    const normalizedContent = normalizePNodeContent(pnode);\n    return ytype._length === normalizedContent.length &&\n      equalAttrs(ytype.getAttributes(), pnode.attrs) &&\n      ytype.toArray().every((ychild, i) =>\n        equalYTypePNode(ychild, normalizedContent[i])\n      )\n  }\n  return ytype instanceof Y.XmlText && pnode instanceof Array &&\n    equalYTextPText(ytype, pnode)\n};\n\n/**\n * For a given Y type and ProseMirror node content, check if the ProseMirror node content is the same as the mapped ProseMirror node content.\n *\n * @param {PModel.Node | Array<PModel.Node> | undefined} mapped The ProseMirror node content that is mapped to the Y type.\n * @param {PModel.Node | Array<PModel.Node>} pcontent The ProseMirror node content to compare against the mapped content.\n * @returns {boolean} Returns true if the mapped content is the same as the ProseMirror node content, false otherwise.\n */\nconst mappedIdentity = (mapped, pcontent) =>\n  mapped === pcontent ||\n  (mapped instanceof Array && pcontent instanceof Array &&\n    mapped.length === pcontent.length && mapped.every((a, i) =>\n    pcontent[i] === a\n  ));\n\n/**\n * @typedef {{ yIndex: number, pIndex: number, yChild: Y.XmlElement | Y.XmlText | Y.XmlHook }} MappedChildAnchor\n */\n\n/**\n * Find mapped children that retain their relative order after a move.\n *\n * @param {Array<Y.XmlElement | Y.XmlText | Y.XmlHook>} yChildren\n * @param {NormalizedPNodeContent} pChildren\n * @param {BindingMetadata} meta\n * @return {Array<MappedChildAnchor>}\n */\nconst findMappedChildAnchors = (yChildren, pChildren, meta) => {\n  const pChildIndices = new Map();\n  pChildren.forEach((pChild, index) => {\n    if (!pChildIndices.has(pChild)) {\n      pChildIndices.set(pChild, index);\n    }\n  });\n  const candidates = [];\n\n  yChildren.forEach((yChild, yIndex) => {\n    const mapped = meta.mapping.get(yChild);\n    const pIndex = pChildIndices.get(mapped);\n    if (pIndex !== undefined && mappedIdentity(mapped, pChildren[pIndex])) {\n      candidates.push({ yIndex, pIndex, yChild });\n    }\n  });\n  if (candidates.length === 0) {\n    return []\n  }\n\n  const predecessors = new Array(candidates.length);\n  const tails = [];\n  for (let index = 0; index < candidates.length; index++) {\n    let low = 0;\n    let high = tails.length;\n    while (low < high) {\n      const middle = (low + high) >> 1;\n      if (candidates[tails[middle]].pIndex < candidates[index].pIndex) {\n        low = middle + 1;\n      } else {\n        high = middle;\n      }\n    }\n    predecessors[index] = low > 0 ? tails[low - 1] : -1;\n    tails[low] = index;\n  }\n\n  const anchors = [];\n  for (let index = tails[tails.length - 1]; index !== -1; index = predecessors[index]) {\n    anchors.push(candidates[index]);\n  }\n  return anchors.reverse()\n};\n\n/**\n * @param {Y.XmlFragment} yDomFragment\n * @param {number} index\n * @param {number} length\n * @param {BindingMetadata} meta\n */\nconst deleteYChildren = (yDomFragment, index, length, meta) => {\n  if (length > 0) {\n    yDomFragment.slice(index, index + length).forEach(type => meta.mapping.delete(type));\n    yDomFragment.delete(index, length);\n  }\n};\n\n/**\n * @param {Y.XmlFragment} yDomFragment\n * @param {number} index\n * @param {NormalizedPNodeContent} pChildren\n * @param {number} start\n * @param {number} end\n * @param {BindingMetadata} meta\n */\nconst insertPChildren = (yDomFragment, index, pChildren, start, end, meta) => {\n  if (start < end) {\n    const children = [];\n    for (let childIndex = start; childIndex < end; childIndex++) {\n      children.push(createTypeFromTextOrElementNode(pChildren[childIndex], meta));\n    }\n    yDomFragment.insert(index, children);\n  }\n};\n\n/**\n * Updates a Y child in place when it still lines up with the ProseMirror child.\n * Recreating it instead would drop concurrent remote edits on that child.\n *\n * @param {{ transact: Function }} y\n * @param {Y.XmlElement | Y.XmlText | Y.XmlHook} yChild\n * @param {PModel.Node | Array<PModel.Node>} pChild\n * @param {BindingMetadata} meta\n * @return {boolean}\n */\nconst updateMatchingYChild = (y, yChild, pChild, meta) => {\n  if (yChild instanceof Y.XmlText && pChild instanceof Array) {\n    if (equalYTextPText(yChild, pChild)) {\n      meta.mapping.set(yChild, pChild);\n    } else {\n      updateYText(yChild, pChild, meta);\n    }\n    return true\n  }\n  if (yChild instanceof Y.XmlElement && !(pChild instanceof Array) && matchNodeName(yChild, pChild)) {\n    if (equalYTypePNode(yChild, pChild)) {\n      meta.mapping.set(yChild, pChild);\n    } else {\n      updateYFragment(y, yChild, pChild, meta);\n    }\n    return true\n  }\n  return false\n};\n\n/**\n * Reconciles the children between two anchors by position, then deletes or\n * inserts to make up the length difference.\n *\n * @param {{ transact: Function }} y\n * @param {Y.XmlFragment} yDomFragment\n * @param {NormalizedPNodeContent} pChildren\n * @param {Array<Y.XmlElement | Y.XmlText | Y.XmlHook>} yChildren\n * @param {number} yStart\n * @param {number} yEnd\n * @param {number} pStart\n * @param {number} pEnd\n * @param {BindingMetadata} meta\n */\nconst reconcileUnanchoredChildren = (\n  y,\n  yDomFragment,\n  pChildren,\n  yChildren,\n  yStart,\n  yEnd,\n  pStart,\n  pEnd,\n  meta\n) => {\n  const matchingChildren = math.min(yEnd - yStart, pEnd - pStart);\n  for (let index = 0; index < matchingChildren; index++) {\n    const yChild = yChildren[yStart + index];\n    const pChild = pChildren[pStart + index];\n    if (!updateMatchingYChild(y, yChild, pChild, meta)) {\n      deleteYChildren(yDomFragment, pStart + index, 1, meta);\n      insertPChildren(yDomFragment, pStart + index, pChildren, pStart + index, pStart + index + 1, meta);\n    }\n  }\n  deleteYChildren(yDomFragment, pStart + matchingChildren, yEnd - yStart - matchingChildren, meta);\n  insertPChildren(yDomFragment, pStart + matchingChildren, pChildren, pStart + matchingChildren, pEnd, meta);\n};\n\n/**\n * Reconciles a fragment whose children were reordered, keeping the Y types of the\n * anchors. The left/right diff in `updateYFragment` mismatches on both ends after\n * a move, so it rebuilds the middle and drops text that is still being edited.\n *\n * @param {{ transact: Function }} y\n * @param {Y.XmlFragment} yDomFragment\n * @param {NormalizedPNodeContent} pChildren\n * @param {Array<Y.XmlElement | Y.XmlText | Y.XmlHook>} yChildren\n * @param {BindingMetadata} meta\n * @return {boolean}\n */\nconst reconcileMappedChildren = (y, yDomFragment, pChildren, yChildren, meta) => {\n  const anchors = findMappedChildAnchors(yChildren, pChildren, meta);\n  // A move needs two anchors with at least one of them at a new index; less than\n  // that is a plain edit. Mismatched kinds cannot be updated in place.\n  if (\n    anchors.length < 2 ||\n    !anchors.some(anchor => anchor.yIndex !== anchor.pIndex) ||\n    anchors.some(anchor => {\n      const pChild = pChildren[anchor.pIndex];\n      return !(\n        (anchor.yChild instanceof Y.XmlText && pChild instanceof Array) ||\n        (anchor.yChild instanceof Y.XmlElement && !(pChild instanceof Array))\n      )\n    })\n  ) {\n    return false\n  }\n\n  let yIndex = 0;\n  let pIndex = 0;\n  for (const anchor of anchors) {\n    reconcileUnanchoredChildren(\n      y,\n      yDomFragment,\n      pChildren,\n      yChildren,\n      yIndex,\n      anchor.yIndex,\n      pIndex,\n      anchor.pIndex,\n      meta\n    );\n\n    const pChild = pChildren[anchor.pIndex];\n    updateMatchingYChild(y, anchor.yChild, pChild, meta);\n    yIndex = anchor.yIndex + 1;\n    pIndex = anchor.pIndex + 1;\n  }\n\n  reconcileUnanchoredChildren(\n    y,\n    yDomFragment,\n    pChildren,\n    yChildren,\n    yIndex,\n    yChildren.length,\n    pIndex,\n    pChildren.length,\n    meta\n  );\n  return true\n};\n\n/**\n * @param {Y.XmlElement} ytype\n * @param {PModel.Node} pnode\n * @param {BindingMetadata} meta\n * @return {{ foundMappedChild: boolean, equalityFactor: number }}\n */\nconst computeChildEqualityFactor = (ytype, pnode, meta) => {\n  const yChildren = ytype.toArray();\n  const pChildren = normalizePNodeContent(pnode);\n  const pChildCnt = pChildren.length;\n  const yChildCnt = yChildren.length;\n  const minCnt = math.min(yChildCnt, pChildCnt);\n  let left = 0;\n  let right = 0;\n  let foundMappedChild = false;\n  for (; left < minCnt; left++) {\n    const leftY = yChildren[left];\n    const leftP = pChildren[left];\n    if (mappedIdentity(meta.mapping.get(leftY), leftP)) {\n      foundMappedChild = true; // definite (good) match!\n    } else if (!equalYTypePNode(leftY, leftP)) {\n      break\n    }\n  }\n  for (; left + right < minCnt; right++) {\n    const rightY = yChildren[yChildCnt - right - 1];\n    const rightP = pChildren[pChildCnt - right - 1];\n    if (mappedIdentity(meta.mapping.get(rightY), rightP)) {\n      foundMappedChild = true;\n    } else if (!equalYTypePNode(rightY, rightP)) {\n      break\n    }\n  }\n  return {\n    equalityFactor: left + right,\n    foundMappedChild\n  }\n};\n\n/**\n * @param {Y.Text} ytext\n */\nconst ytextTrans = (ytext) => {\n  let str = '';\n  /**\n   * @type {Y.Item|null}\n   */\n  let n = ytext._start;\n  const nAttrs = {};\n  while (n !== null) {\n    if (!n.deleted) {\n      if (n.countable && n.content instanceof Y.ContentString) {\n        str += n.content.str;\n      } else if (n.content instanceof Y.ContentFormat) {\n        nAttrs[n.content.key] = null;\n      }\n    }\n    n = n.right;\n  }\n  return {\n    str,\n    nAttrs\n  }\n};\n\n/**\n * @todo test this more\n *\n * @param {Y.Text} ytext\n * @param {Array<any>} ptexts\n * @param {BindingMetadata} meta\n */\nconst updateYText = (ytext, ptexts, meta) => {\n  meta.mapping.set(ytext, ptexts);\n  const { nAttrs, str } = ytextTrans(ytext);\n  const content = ptexts.map((p) => ({\n    insert: /** @type {any} */ (p).text,\n    attributes: Object.assign({}, nAttrs, marksToAttributes(p.marks, meta))\n  }));\n  const { insert, remove, index } = simpleDiff(\n    str,\n    content.map((c) => c.insert).join('')\n  );\n  ytext.delete(index, remove);\n  ytext.insert(index, insert);\n  ytext.applyDelta(\n    content.map((c) => ({ retain: c.insert.length, attributes: c.attributes }))\n  );\n};\n\nconst hashedMarkNameRegex = /(.*)(--[a-zA-Z0-9+/=]{8})$/;\n/**\n * @param {string} attrName\n */\nconst yattr2markname = attrName => hashedMarkNameRegex.exec(attrName)?.[1] ?? attrName;\n\n/**\n * @todo move this to markstoattributes\n *\n * @param {Object<string, any>} attrs\n * @param {import('prosemirror-model').Schema} schema\n */\nconst attributesToMarks = (attrs, schema) => {\n  /**\n   * @type {Array<import('prosemirror-model').Mark>}\n   */\n  const marks = [];\n  for (const markName in attrs) {\n    // remove hashes if necessary\n    marks.push(schema.mark(yattr2markname(markName), attrs[markName]));\n  }\n  return marks\n};\n\n/**\n * @param {Array<import('prosemirror-model').Mark>} marks\n * @param {BindingMetadata} meta\n */\nconst marksToAttributes = (marks, meta) => {\n  const pattrs = {};\n  marks.forEach((mark) => {\n    if (mark.type.name !== 'ychange') {\n      const isOverlapping = map.setIfUndefined(meta.isOMark, mark.type, () => !mark.type.excludes(mark.type));\n      pattrs[isOverlapping ? `${mark.type.name}--${hashOfJSON(mark.toJSON())}` : mark.type.name] = mark.attrs;\n    }\n  });\n  return pattrs\n};\n\n/**\n * Update a yDom node by syncing the current content of the prosemirror node.\n *\n * This is a y-prosemirror internal feature that you can use at your own risk.\n *\n * @private\n * @unstable\n *\n * @param {{transact: Function}} y\n * @param {Y.XmlFragment} yDomFragment\n * @param {any} pNode\n * @param {BindingMetadata} meta\n */\nconst updateYFragment = (y, yDomFragment, pNode, meta) => {\n  if (\n    yDomFragment instanceof Y.XmlElement &&\n    yDomFragment.nodeName !== pNode.type.name\n  ) {\n    throw new Error('node name mismatch!')\n  }\n  meta.mapping.set(yDomFragment, pNode);\n  // update attributes\n  if (yDomFragment instanceof Y.XmlElement) {\n    const yDomAttrs = yDomFragment.getAttributes();\n    const pAttrs = pNode.attrs;\n    for (const key in pAttrs) {\n      if (pAttrs[key] !== null) {\n        if (yDomAttrs[key] !== pAttrs[key] && key !== 'ychange') {\n          yDomFragment.setAttribute(key, pAttrs[key]);\n        }\n      } else {\n        yDomFragment.removeAttribute(key);\n      }\n    }\n    // remove all keys that are no longer in pAttrs\n    for (const key in yDomAttrs) {\n      if (pAttrs[key] === undefined) {\n        yDomFragment.removeAttribute(key);\n      }\n    }\n  }\n  // update children\n  const pChildren = normalizePNodeContent(pNode);\n  const pChildCnt = pChildren.length;\n  const yChildren = yDomFragment.toArray();\n  const yChildCnt = yChildren.length;\n  const minCnt = math.min(pChildCnt, yChildCnt);\n  if (reconcileMappedChildren(y, yDomFragment, pChildren, yChildren, meta)) {\n    return\n  }\n  let left = 0;\n  let right = 0;\n  // find number of matching elements from left\n  for (; left < minCnt; left++) {\n    const leftY = yChildren[left];\n    const leftP = pChildren[left];\n    if (!mappedIdentity(meta.mapping.get(leftY), leftP)) {\n      if (equalYTypePNode(leftY, leftP)) {\n        // update mapping\n        meta.mapping.set(leftY, leftP);\n      } else {\n        break\n      }\n    }\n  }\n  // find number of matching elements from right\n  for (; right + left + 1 < minCnt; right++) {\n    const rightY = yChildren[yChildCnt - right - 1];\n    const rightP = pChildren[pChildCnt - right - 1];\n    if (!mappedIdentity(meta.mapping.get(rightY), rightP)) {\n      if (equalYTypePNode(rightY, rightP)) {\n        // update mapping\n        meta.mapping.set(rightY, rightP);\n      } else {\n        break\n      }\n    }\n  }\n  y.transact(() => {\n    // try to compare and update\n    while (yChildCnt - left - right > 0 && pChildCnt - left - right > 0) {\n      const leftY = yChildren[left];\n      const leftP = pChildren[left];\n      const rightY = yChildren[yChildCnt - right - 1];\n      const rightP = pChildren[pChildCnt - right - 1];\n      if (leftY instanceof Y.XmlText && leftP instanceof Array) {\n        if (!equalYTextPText(leftY, leftP)) {\n          updateYText(leftY, leftP, meta);\n        }\n        left += 1;\n      } else {\n        let updateLeft = leftY instanceof Y.XmlElement &&\n          matchNodeName(leftY, leftP);\n        let updateRight = rightY instanceof Y.XmlElement &&\n          matchNodeName(rightY, rightP);\n        if (updateLeft && updateRight) {\n          // decide which which element to update\n          const equalityLeft = computeChildEqualityFactor(\n            /** @type {Y.XmlElement} */ (leftY),\n            /** @type {PModel.Node} */ (leftP),\n            meta\n          );\n          const equalityRight = computeChildEqualityFactor(\n            /** @type {Y.XmlElement} */ (rightY),\n            /** @type {PModel.Node} */ (rightP),\n            meta\n          );\n          if (\n            equalityLeft.foundMappedChild && !equalityRight.foundMappedChild\n          ) {\n            updateRight = false;\n          } else if (\n            !equalityLeft.foundMappedChild && equalityRight.foundMappedChild\n          ) {\n            updateLeft = false;\n          } else if (\n            equalityLeft.equalityFactor < equalityRight.equalityFactor\n          ) {\n            updateLeft = false;\n          } else {\n            updateRight = false;\n          }\n        }\n        if (updateLeft) {\n          updateYFragment(\n            y,\n            /** @type {Y.XmlFragment} */ (leftY),\n            /** @type {PModel.Node} */ (leftP),\n            meta\n          );\n          left += 1;\n        } else if (updateRight) {\n          updateYFragment(\n            y,\n            /** @type {Y.XmlFragment} */ (rightY),\n            /** @type {PModel.Node} */ (rightP),\n            meta\n          );\n          right += 1;\n        } else {\n          meta.mapping.delete(yDomFragment.get(left));\n          yDomFragment.delete(left, 1);\n          yDomFragment.insert(left, [\n            createTypeFromTextOrElementNode(leftP, meta)\n          ]);\n          left += 1;\n        }\n      }\n    }\n    const yDelLen = yChildCnt - left - right;\n    if (\n      yChildCnt === 1 && pChildCnt === 0 && yChildren[0] instanceof Y.XmlText\n    ) {\n      meta.mapping.delete(yChildren[0]);\n      // Edge case handling https://github.com/yjs/y-prosemirror/issues/108\n      // Only delete the content of the Y.Text to retain remote changes on the same Y.Text object\n      yChildren[0].delete(0, yChildren[0].length);\n    } else if (yDelLen > 0) {\n      yDomFragment.slice(left, left + yDelLen).forEach(type => meta.mapping.delete(type));\n      yDomFragment.delete(left, yDelLen);\n    }\n    if (left + right < pChildCnt) {\n      const ins = [];\n      for (let i = left; i < pChildCnt - right; i++) {\n        ins.push(createTypeFromTextOrElementNode(pChildren[i], meta));\n      }\n      yDomFragment.insert(left, ins);\n    }\n  }, ySyncPluginKey);\n};\n\n/**\n * @function\n * @param {Y.XmlElement} yElement\n * @param {any} pNode Prosemirror Node\n */\nconst matchNodeName = (yElement, pNode) =>\n  !(pNode instanceof Array) && yElement.nodeName === pNode.type.name;\n\n/**\n * Either a node if type is YXmlElement or an Array of text nodes if YXmlText\n * @typedef {Map<Y.AbstractType, Node | Array<Node>>} ProsemirrorMapping\n */\n\n/**\n * Is null if no timeout is in progress.\n * Is defined if a timeout is in progress.\n * Maps from view\n * @type {Map<EditorView, Map<any, any>>|null}\n */\nlet viewsToUpdate = null;\n\nclass MetaEntry {\n  /**\n   * @param {EditorView} view\n   * @param {any} key\n   * @param {any} value\n   */\n  constructor (view, key, value) {\n    this.view = view;\n    this.key = key;\n    this.value = value;\n  }\n\n  apply () {\n    const syncState = ySyncPluginKey.getState(this.view.state);\n    if (syncState && syncState.binding && !syncState.binding.isDestroyed) {\n      const tr = this.view.state.tr;\n      tr.setMeta(this.key, this.value);\n      this.view.dispatch(tr);\n    }\n  }\n}\n\nclass MetaEntriesQueue {\n  /**\n   * @param {Array<MetaEntry>} [entries=[]]\n   */\n  constructor (entries = []) {\n    this.entries = entries;\n  }\n\n  /**\n   * @return {MetaEntry|undefined}\n   */\n  getFirst () {\n    return this.entries[0]\n  }\n\n  /**\n   * @return {MetaEntry|undefined}\n   */\n  dequeueFirst () {\n    return this.entries.shift()\n  }\n\n  /**\n   * @return {boolean}\n   */\n  isEmpty () {\n    return this.entries.length === 0\n  }\n\n  static fromViewsToUpdate () {\n    const ups = /** @type {Map<EditorView, Map<any, any>>} */ (viewsToUpdate);\n    viewsToUpdate = null;\n    const entries = [];\n    ups.forEach((metas, view) => {\n      metas.forEach((value, key) => {\n        entries.push(new MetaEntry(view, key, value));\n      });\n    });\n    return new MetaEntriesQueue(entries)\n  }\n}\n\n/**\n * Dispatch queued plugin metadata in order, retrying only the remaining\n * entries if a transaction becomes stale while the async queue is flushing.\n *\n * Cursor awareness updates are decoration-only refreshes. If a real document\n * transaction lands before one of these queued meta transactions is applied,\n * ProseMirror can reject it with a RangeError. In that case we reschedule the\n * remaining entries on the next tick. If the first remaining entry fails again\n * on retry, we drop that entry and continue with the rest of the queue instead\n * of retrying forever or crashing the editor.\n *\n * @param {MetaEntriesQueue} [metaEntries=MetaEntriesQueue.fromViewsToUpdate()]\n * @param {boolean} [isRetry=false]\n */\nconst updateMetas = (metaEntries = MetaEntriesQueue.fromViewsToUpdate(), isRetry = false) => {\n  let isFirst = true;\n  while (!metaEntries.isEmpty()) {\n    const metaEntry = metaEntries.getFirst();\n    try {\n      metaEntry.apply();\n    } catch (err) {\n      // ProseMirror throws a RangeError when this transaction was created from\n      // an older state and another transaction changed the document before this\n      // meta-only dispatch was applied (\"Applying a mismatched transaction\").\n      if (err instanceof RangeError) {\n        if (isRetry && isFirst) {\n          // Drop the repeatedly stale entry so the queue can continue flushing.\n          metaEntries.dequeueFirst();\n        }\n        if (!metaEntries.isEmpty()) {\n          eventloop.timeout(0, () => updateMetas(metaEntries, true));\n        }\n        return\n      }\n      throw err\n    }\n    isFirst = false;\n    metaEntries.dequeueFirst();\n  }\n};\n\nconst setMeta = (view, key, value) => {\n  if (!viewsToUpdate) {\n    viewsToUpdate = new Map();\n    // Awareness listeners can fire in bursts, so batch them into one tick.\n    eventloop.timeout(0, updateMetas);\n  }\n  map.setIfUndefined(viewsToUpdate, view, map.create).set(key, value);\n};\n\n/**\n * Transforms a Prosemirror based absolute position to a Yjs Cursor (relative position in the Yjs model).\n *\n * @param {number} pos\n * @param {Y.XmlFragment} type\n * @param {ProsemirrorMapping} mapping\n * @return {any} relative position\n */\nconst absolutePositionToRelativePosition = (pos, type, mapping) => {\n  if (pos === 0) {\n    return Y.createRelativePositionFromTypeIndex(type, 0, -1)\n  }\n  /**\n   * @type {any}\n   */\n  let n = type._first === null ? null : /** @type {Y.ContentType} */ (type._first.content).type;\n  while (n !== null && type !== n) {\n    if (n instanceof Y.XmlText) {\n      if (n._length >= pos) {\n        return Y.createRelativePositionFromTypeIndex(n, pos, -1)\n      } else {\n        pos -= n._length;\n      }\n      if (n._item !== null && n._item.next !== null) {\n        n = /** @type {Y.ContentType} */ (n._item.next.content).type;\n      } else {\n        do {\n          n = n._item === null ? null : n._item.parent;\n          pos--;\n        } while (n !== type && n !== null && n._item !== null && n._item.next === null)\n        if (n !== null && n !== type) {\n          // @ts-gnore we know that n.next !== null because of above loop conditition\n          n = n._item === null ? null : /** @type {Y.ContentType} */ (/** @type Y.Item */ (n._item.next).content).type;\n        }\n      }\n    } else {\n      const pNodeSize = /** @type {any} */ (mapping.get(n) || { nodeSize: 0 }).nodeSize;\n      if (n._first !== null && pos < pNodeSize) {\n        n = /** @type {Y.ContentType} */ (n._first.content).type;\n        pos--;\n      } else {\n        if (pos === 1 && n._length === 0 && pNodeSize > 1) {\n          // edge case, should end in this paragraph\n          return new Y.RelativePosition(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)\n        }\n        pos -= pNodeSize;\n        if (n._item !== null && n._item.next !== null) {\n          n = /** @type {Y.ContentType} */ (n._item.next.content).type;\n        } else {\n          if (pos === 0) {\n            // set to end of n.parent\n            n = n._item === null ? n : n._item.parent;\n            return new Y.RelativePosition(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)\n          }\n          do {\n            n = /** @type {Y.Item} */ (n._item).parent;\n            pos--;\n          } while (n !== type && /** @type {Y.Item} */ (n._item).next === null)\n          // if n is null at this point, we have an unexpected case\n          if (n !== type) {\n            // We know that n._item.next is defined because of above loop condition\n            n = /** @type {Y.ContentType} */ (/** @type {Y.Item} */ (/** @type {Y.Item} */ (n._item).next).content).type;\n          }\n        }\n      }\n    }\n    if (n === null) {\n      throw error.unexpectedCase()\n    }\n    if (pos === 0 && n.constructor !== Y.XmlText && n !== type) { // TODO: set to <= 0\n      return createRelativePosition(n._item.parent, n._item)\n    }\n  }\n  return Y.createRelativePositionFromTypeIndex(type, type._length, -1)\n};\n\n/**\n * Item-id based relative positions can misresolve to the document start after\n * block reorder during collaborative drag-and-drop.\n *\n * @param {Y.Doc} y\n * @param {Y.RelativePosition} relPos\n * @param {number|null} absPos\n * @return {boolean}\n */\nconst isMisresolvedTextPosition = (y, relPos, absPos) => {\n  if (absPos === null) {\n    return false\n  }\n  const decoded = Y.createAbsolutePositionFromRelativePosition(relPos, y);\n  return decoded !== null &&\n    decoded.type instanceof Y.XmlText &&\n    relPos.item !== null &&\n    absPos <= 1\n};\n\nconst createRelativePosition = (type, item) => {\n  let typeid = null;\n  let tname = null;\n  if (type._item === null) {\n    tname = Y.findRootTypeKey(type);\n  } else {\n    typeid = Y.createID(type._item.id.client, type._item.id.clock);\n  }\n  return new Y.RelativePosition(typeid, tname, item.id)\n};\n\n/**\n * @param {Y.Doc} y\n * @param {Y.XmlFragment} documentType Top level type that is bound to pView\n * @param {any} relPos Encoded Yjs based relative position\n * @param {ProsemirrorMapping} mapping\n * @return {null|number}\n */\nconst relativePositionToAbsolutePosition = (y, documentType, relPos, mapping) => {\n  const decodedPos = Y.createAbsolutePositionFromRelativePosition(relPos, y);\n  if (decodedPos === null || (decodedPos.type !== documentType && !Y.isParentOf(documentType, decodedPos.type._item))) {\n    return null\n  }\n  let type = decodedPos.type;\n  let pos = 0;\n  if (type.constructor === Y.XmlText) {\n    pos = decodedPos.index;\n  } else if (type._item === null || !type._item.deleted) {\n    let n = type._first;\n    let i = 0;\n    while (i < type._length && i < decodedPos.index && n !== null) {\n      if (!n.deleted) {\n        const t = /** @type {Y.ContentType} */ (n.content).type;\n        i++;\n        if (t instanceof Y.XmlText) {\n          pos += t._length;\n        } else {\n          const mapped = mapping.get(t);\n          if (mapped == null) {\n            return null\n          }\n          pos += /** @type {any} */ (mapped).nodeSize;\n        }\n      }\n      n = /** @type {Y.Item} */ (n.right);\n    }\n    pos += 1; // increase because we go out of n\n  }\n  while (type !== documentType && type._item !== null) {\n    // @ts-ignore\n    const parent = type._item.parent;\n    // @ts-ignore\n    if (parent._item === null || !parent._item.deleted) {\n      pos += 1; // the start tag\n      let n = /** @type {Y.AbstractType} */ (parent)._first;\n      // now iterate until we found type\n      while (n !== null) {\n        const contentType = /** @type {Y.ContentType} */ (n.content).type;\n        if (contentType === type) {\n          break\n        }\n        if (!n.deleted) {\n          if (contentType instanceof Y.XmlText) {\n            pos += contentType._length;\n          } else {\n            const mapped = mapping.get(contentType);\n            if (mapped == null) {\n              return null\n            }\n            pos += /** @type {any} */ (mapped).nodeSize;\n          }\n        }\n        n = n.right;\n      }\n    }\n    type = /** @type {Y.AbstractType} */ (parent);\n  }\n  const absPos = pos - 1; // we don't count the most outer tag, because it is a fragment\n  if (isMisresolvedTextPosition(y, relPos, absPos)) {\n    return null\n  }\n  return absPos\n};\n\n/**\n * Shallow attrs comparison. Attr values are primitives in most schemas;\n * non-primitive values fail the check and callers fall back to text matching.\n *\n * @param {Object<string, any>} a\n * @param {Object<string, any>} b\n * @return {boolean}\n */\nconst attrsEqual = (a, b) => {\n  if (a === b) {\n    return true\n  }\n  const aKeys = Object.keys(a);\n  return aKeys.length === Object.keys(b).length && aKeys.every((k) => a[k] === b[k])\n};\n\n/**\n * Returns true when any attr deviates from its spec default or has none.\n * Default-only attrs cannot tell same-type siblings apart.\n *\n * @param {import('prosemirror-model').Node} node\n * @return {boolean}\n */\nconst hasDistinctiveAttrs = (node) => {\n  const specAttrs = node.type.spec.attrs || {};\n  return Object.keys(node.attrs).some((key) => {\n    const spec = specAttrs[key];\n    return spec == null ||\n      !Object.prototype.hasOwnProperty.call(spec, 'default') ||\n      spec.default !== node.attrs[key]\n  })\n};\n\n/**\n * Remaps a position into a matched block by walking the same child-index path\n * it had in the old block. A raw byte offset would overshoot into a sibling\n * inner textblock when the old block contains local keystrokes that are not\n * yet part of the rebuilt document.\n *\n * @param {import('prosemirror-model').ResolvedPos} $oldPos\n * @param {number} newBlockStart\n * @param {import('prosemirror-model').Node} newBlock\n * @return {number|null}\n */\nconst remapIntoBlock = ($oldPos, newBlockStart, newBlock) => {\n  let pos = newBlockStart + 1;\n  let node = newBlock;\n  for (let depth = 1; depth < $oldPos.depth; depth++) {\n    const idx = $oldPos.index(depth);\n    if (idx >= node.childCount) {\n      return null\n    }\n    for (let i = 0; i < idx; i++) {\n      pos += node.child(i).nodeSize;\n    }\n    pos += 1;\n    node = node.child(idx);\n    if (node.type !== $oldPos.node(depth + 1).type) {\n      return null\n    }\n  }\n  if (!node.isTextblock) {\n    return null\n  }\n  return pos + Math.min($oldPos.parentOffset, node.content.size)\n};\n\n/**\n * @param {import('prosemirror-model').Node} oldDoc\n * @param {import('prosemirror-model').Node} newDoc\n * @param {number} absPos\n * @return {number|null}\n */\nconst findAbsolutePositionAfterStructuralChange = (oldDoc, newDoc, absPos) => {\n  let pos = 0;\n  let targetIdx = 0;\n  for (; targetIdx < oldDoc.childCount; targetIdx++) {\n    const child = oldDoc.child(targetIdx);\n    if (pos + child.nodeSize > absPos) {\n      break\n    }\n    pos += child.nodeSize;\n  }\n  if (targetIdx >= oldDoc.childCount) {\n    return null\n  }\n  const targetChild = oldDoc.child(targetIdx);\n  const $oldPos = oldDoc.resolve(absPos);\n\n  /**\n   * @param {number} newBlockStart\n   * @param {import('prosemirror-model').Node} newBlock\n   * @return {number|null}\n   */\n  const place = (newBlockStart, newBlock) => {\n    // Positions between top-level blocks carry no inner path; clamp them just\n    // inside the matched block like the previous raw-offset remap did.\n    if ($oldPos.depth === 0) {\n      const remapped = newBlockStart + (absPos - pos);\n      const contentStart = newBlockStart + 1;\n      const contentEnd = newBlockStart + newBlock.nodeSize - 1;\n      return Math.max(contentStart, Math.min(remapped, contentEnd))\n    }\n    return remapIntoBlock($oldPos, newBlockStart, newBlock)\n  };\n\n  /**\n   * Finds the Nth block in newDoc matching `pred`, where N is the number of\n   * matching blocks in oldDoc up to and including the target block.\n   *\n   * @param {function(import('prosemirror-model').Node): boolean} pred\n   * @param {boolean} requireUnique\n   * @return {number|null}\n   */\n  const findByPredicate = (pred, requireUnique = false) => {\n    let occurrence = 0;\n    for (let i = 0; i <= targetIdx; i++) {\n      if (pred(oldDoc.child(i))) {\n        occurrence++;\n      }\n    }\n    let matchCount = 0;\n    let matchStart = -1;\n    let matchBlock = null;\n    let newPos = 0;\n    for (let i = 0; i < newDoc.childCount; i++) {\n      const child = newDoc.child(i);\n      if (pred(child)) {\n        matchCount++;\n        if (matchCount === occurrence) {\n          matchStart = newPos;\n          matchBlock = child;\n        }\n      }\n      newPos += child.nodeSize;\n    }\n    if (matchBlock === null || (requireUnique && (occurrence !== 1 || matchCount !== 1))) {\n      return null\n    }\n    return place(matchStart, matchBlock)\n  };\n\n  /**\n   * @param {import('prosemirror-model').Node} child\n   * @return {boolean}\n   */\n  const sameTypeAndAttrs = (child) =>\n    child.type === targetChild.type && attrsEqual(child.attrs, targetChild.attrs);\n  const oldText = targetChild.textContent;\n\n  const byAll = findByPredicate((child) => sameTypeAndAttrs(child) && child.textContent === oldText);\n  if (byAll !== null) {\n    return byAll\n  }\n\n  // Text must be matched before attrs: after a remote attr-only edit, the\n  // attrs pass would steer the cursor into a sibling that kept the old attrs.\n  const byText = findByPredicate(\n    (child) => child.type === targetChild.type && child.textContent === oldText\n  );\n  if (byText !== null) {\n    return byText\n  }\n\n  // In-flight local typing diverges the text between both docs. Distinctive\n  // attrs still identify the block; default-only attrs match every sibling.\n  if (hasDistinctiveAttrs(targetChild)) {\n    const byAttrs = findByPredicate(sameTypeAndAttrs, true);\n    if (byAttrs !== null) {\n      return byAttrs\n    }\n  }\n\n  // Trailing in-flight keystrokes leave a prefix relation between old and new\n  // text. Empty text is a prefix of everything and must never match.\n  return findByPredicate(\n    (child) => sameTypeAndAttrs(child) &&\n      oldText !== '' && child.textContent !== '' &&\n      (oldText.startsWith(child.textContent) || child.textContent.startsWith(oldText)),\n    true\n  )\n};\n\n/**\n * Returns true when a transaction changes block structure rather than only\n * editing inline content inside existing blocks.\n *\n * @param {import('prosemirror-state').Transaction} tr\n * @param {import('prosemirror-model').Node} oldDoc\n * @return {boolean}\n */\nconst isStructuralTransaction = (tr, oldDoc) => {\n  if (!tr.docChanged) {\n    return false\n  }\n  if (tr.doc.childCount !== oldDoc.childCount) {\n    return true\n  }\n  for (const step of tr.steps) {\n    if (step instanceof ReplaceStep) {\n      if (step.from === 0 && step.to === oldDoc.content.size) {\n        return true\n      }\n      if (step.slice.content.size > 0) {\n        let hasBlock = false;\n        step.slice.content.forEach((node) => {\n          if (node.isBlock) {\n            hasBlock = true;\n          }\n        });\n        if (hasBlock) {\n          return true\n        }\n      } else if (step.to > step.from) {\n        const $from = oldDoc.resolve(step.from);\n        const $to = oldDoc.resolve(step.to);\n        if ($from.depth === 0 && $to.depth === 0 && $from.index() !== $to.index()) {\n          return true\n        }\n      }\n    }\n  }\n  return false\n};\n\n/**\n * Detect stale relative positions after structural changes that resolve to the\n * wrong text block or to the start of the correct block.\n *\n * @param {import('prosemirror-model').Node} oldDoc\n * @param {import('prosemirror-model').Node} newDoc\n * @param {number} oldAbs\n * @param {number|null} resolvedAbs\n * @return {boolean}\n */\nconst isMisresolvedAfterStructuralChange = (oldDoc, newDoc, oldAbs, resolvedAbs) => {\n  if (resolvedAbs === null) {\n    return false\n  }\n  const $old = oldDoc.resolve(oldAbs);\n  const $new = newDoc.resolve(resolvedAbs);\n  if (!$old.parent.isTextblock) {\n    return false\n  }\n  // A textblock cursor cannot legitimately resolve into a non-textblock;\n  // a structural reorder replaced the block via delete + insert.\n  if (!$new.parent.isTextblock) {\n    return true\n  }\n  if ($old.parent.textContent !== $new.parent.textContent) {\n    return true\n  }\n  if ($old.parentOffset !== 0 && $new.parentOffset === 0) {\n    return true\n  }\n  const bothAtStart = $old.parentOffset === 0 && $new.parentOffset === 0;\n  // A changed offset, type or attrs hints at a same-text sibling. When all\n  // of them agree there is no signal left and the Yjs resolution must win.\n  const suspicious = $old.parentOffset !== $new.parentOffset ||\n    $old.parent.type !== $new.parent.type ||\n    !attrsEqual($old.parent.attrs, $new.parent.attrs);\n  if (bothAtStart || suspicious) {\n    const expected = findAbsolutePositionAfterStructuralChange(oldDoc, newDoc, oldAbs);\n    return expected !== null && expected !== resolvedAbs\n  }\n  return false\n};\n\n/**\n * Utility function for converting an Y.Fragment to a ProseMirror fragment.\n *\n * @param {Y.XmlFragment} yXmlFragment\n * @param {Schema} schema\n */\nconst yXmlFragmentToProseMirrorFragment = (yXmlFragment, schema) => {\n  const fragmentContent = yXmlFragment.toArray().map((t) =>\n    createNodeFromYElement(\n      /** @type {Y.XmlElement} */ (t),\n      schema,\n      createEmptyMeta()\n    )\n  ).filter((n) => n !== null);\n  return Fragment.fromArray(fragmentContent)\n};\n\n/**\n * Utility function for converting an Y.Fragment to a ProseMirror node.\n *\n * @param {Y.XmlFragment} yXmlFragment\n * @param {Schema} schema\n */\nconst yXmlFragmentToProseMirrorRootNode = (yXmlFragment, schema) =>\n  schema.topNodeType.create(null, yXmlFragmentToProseMirrorFragment(yXmlFragment, schema));\n\n/**\n * The initial ProseMirror content should be supplied by Yjs. This function transforms a Y.Fragment\n * to a ProseMirror Doc node and creates a mapping that is used by the sync plugin.\n *\n * @param {Y.XmlFragment} yXmlFragment\n * @param {Schema} schema\n *\n * @todo deprecate mapping property\n */\nconst initProseMirrorDoc = (yXmlFragment, schema) => {\n  const meta = createEmptyMeta();\n  const fragmentContent = yXmlFragment.toArray().map((t) =>\n    createNodeFromYElement(\n      /** @type {Y.XmlElement} */ (t),\n      schema,\n      meta\n    )\n  ).filter((n) => n !== null);\n  const doc = schema.topNodeType.create(null, Fragment.fromArray(fragmentContent));\n  return { doc, meta, mapping: meta.mapping }\n};\n\n/**\n * Utility method to convert a Prosemirror Doc Node into a Y.Doc.\n *\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param {Node} doc\n * @param {string} xmlFragment\n * @return {Y.Doc}\n */\nfunction prosemirrorToYDoc (doc, xmlFragment = 'prosemirror') {\n  const ydoc = new Y.Doc();\n  const type = /** @type {Y.XmlFragment} */ (ydoc.get(xmlFragment, Y.XmlFragment));\n  if (!type.doc) {\n    return ydoc\n  }\n\n  prosemirrorToYXmlFragment(doc, type);\n  return type.doc\n}\n\n/**\n * Utility method to update an empty Y.XmlFragment with content from a Prosemirror Doc Node.\n *\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * Note: The Y.XmlFragment does not need to be part of a Y.Doc document at the time that this\n * method is called, but it must be added before any other operations are performed on it.\n *\n * @param {Node} doc prosemirror document.\n * @param {Y.XmlFragment} [xmlFragment] If supplied, an xml fragment to be\n *   populated from the prosemirror state; otherwise a new XmlFragment will be created.\n * @return {Y.XmlFragment}\n */\nfunction prosemirrorToYXmlFragment (doc, xmlFragment) {\n  const type = xmlFragment || new Y.XmlFragment();\n  const ydoc = type.doc ? type.doc : { transact: (transaction) => transaction(undefined) };\n  updateYFragment(ydoc, type, doc, { mapping: new Map(), isOMark: new Map() });\n  return type\n}\n\n/**\n * Utility method to convert Prosemirror compatible JSON into a Y.Doc.\n *\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param {Schema} schema\n * @param {any} state\n * @param {string} xmlFragment\n * @return {Y.Doc}\n */\nfunction prosemirrorJSONToYDoc (schema, state, xmlFragment = 'prosemirror') {\n  const doc = Node.fromJSON(schema, state);\n  return prosemirrorToYDoc(doc, xmlFragment)\n}\n\n/**\n * Utility method to convert Prosemirror compatible JSON to a Y.XmlFragment\n *\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param {Schema} schema\n * @param {any} state\n * @param {Y.XmlFragment} [xmlFragment] If supplied, an xml fragment to be\n *   populated from the prosemirror state; otherwise a new XmlFragment will be created.\n * @return {Y.XmlFragment}\n */\nfunction prosemirrorJSONToYXmlFragment (schema, state, xmlFragment) {\n  const doc = Node.fromJSON(schema, state);\n  return prosemirrorToYXmlFragment(doc, xmlFragment)\n}\n\n/**\n * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead\n *\n * Utility method to convert a Y.Doc to a Prosemirror Doc node.\n *\n * @param {Schema} schema\n * @param {Y.Doc} ydoc\n * @return {Node}\n */\nfunction yDocToProsemirror (schema, ydoc) {\n  const state = yDocToProsemirrorJSON(ydoc);\n  return Node.fromJSON(schema, state)\n}\n\n/**\n *\n * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead\n *\n * Utility method to convert a Y.XmlFragment to a Prosemirror Doc node.\n *\n * @param {Schema} schema\n * @param {Y.XmlFragment} xmlFragment\n * @return {Node}\n */\nfunction yXmlFragmentToProsemirror (schema, xmlFragment) {\n  const state = yXmlFragmentToProsemirrorJSON(xmlFragment);\n  return Node.fromJSON(schema, state)\n}\n\n/**\n *\n * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead\n *\n * Utility method to convert a Y.Doc to Prosemirror compatible JSON.\n *\n * @param {Y.Doc} ydoc\n * @param {string} xmlFragment\n * @return {Record<string, any>}\n */\nfunction yDocToProsemirrorJSON (\n  ydoc,\n  xmlFragment = 'prosemirror'\n) {\n  return yXmlFragmentToProsemirrorJSON(ydoc.getXmlFragment(xmlFragment))\n}\n\n/**\n * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead\n *\n * Utility method to convert a Y.Doc to Prosemirror compatible JSON.\n *\n * @param {Y.XmlFragment} xmlFragment The fragment, which must be part of a Y.Doc.\n * @return {Record<string, any>}\n */\nfunction yXmlFragmentToProsemirrorJSON (xmlFragment) {\n  const items = xmlFragment.toArray();\n\n  /**\n   * @param {Y.AbstractType} item\n   */\n  const serialize = item => {\n    /**\n     * @type {Object} NodeObject\n     * @property {string} NodeObject.type\n     * @property {Record<string, string>=} NodeObject.attrs\n     * @property {Array<NodeObject>=} NodeObject.content\n     */\n    let response;\n\n    // TODO: Must be a better way to detect text nodes than this\n    if (item instanceof Y.XmlText) {\n      const delta = item.toDelta();\n      response = delta.map(/** @param {any} d */ (d) => {\n        const text = {\n          type: 'text',\n          text: d.insert\n        };\n        if (d.attributes) {\n          text.marks = Object.keys(d.attributes).map((type_) => {\n            const attrs = d.attributes[type_];\n            const type = yattr2markname(type_);\n            const mark = {\n              type\n            };\n            if (Object.keys(attrs)) {\n              mark.attrs = attrs;\n            }\n            return mark\n          });\n        }\n        return text\n      });\n    } else if (item instanceof Y.XmlElement) {\n      response = {\n        type: item.nodeName\n      };\n\n      const attrs = item.getAttributes();\n      if (Object.keys(attrs).length) {\n        response.attrs = attrs;\n      }\n\n      const children = item.toArray();\n      if (children.length) {\n        response.content = children.map(serialize).flat();\n      }\n    } else {\n      // expected either Y.XmlElement or Y.XmlText\n      error.unexpectedCase();\n    }\n\n    return response\n  };\n\n  return {\n    type: 'doc',\n    content: items.map(serialize)\n  }\n}\n\n/**\n * Default awareness state filter\n *\n * @param {number} currentClientId current client id\n * @param {number} userClientId user client id\n * @param {any} _user user data\n * @return {boolean}\n */\nconst defaultAwarenessStateFilter = (\n  currentClientId,\n  userClientId,\n  _user\n) => currentClientId !== userClientId;\n\n/**\n * Default generator for a cursor element\n *\n * @param {any} user user data\n * @return {HTMLElement}\n */\nconst defaultCursorBuilder = (user) => {\n  const cursor = document.createElement('span');\n  cursor.classList.add('ProseMirror-yjs-cursor');\n  cursor.setAttribute('style', `border-color: ${user.color}`);\n  const userDiv = document.createElement('div');\n  userDiv.setAttribute('style', `background-color: ${user.color}`);\n  userDiv.insertBefore(document.createTextNode(user.name), null);\n  const nonbreakingSpace1 = document.createTextNode('\\u2060');\n  const nonbreakingSpace2 = document.createTextNode('\\u2060');\n  cursor.insertBefore(nonbreakingSpace1, null);\n  cursor.insertBefore(userDiv, null);\n  cursor.insertBefore(nonbreakingSpace2, null);\n  return cursor\n};\n\n/**\n * Default generator for the selection attributes\n *\n * @param {any} user user data\n * @return {import('prosemirror-view').DecorationAttrs}\n */\nconst defaultSelectionBuilder = (user) => {\n  return {\n    style: `background-color: ${user.color}70`,\n    class: 'ProseMirror-yjs-selection'\n  }\n};\n\nconst rxValidColor = /^#[0-9a-fA-F]{6}$/;\n\n/**\n * @param {any} state\n * @param {Awareness} awareness\n * @param {function(number, number, any):boolean} awarenessFilter\n * @param {(user: { name: string, color: string }, clientId: number) => Element} createCursor\n * @param {(user: { name: string, color: string }, clientId: number) => import('prosemirror-view').DecorationAttrs} createSelection\n * @return {any} DecorationSet\n */\nconst createDecorations = (\n  state,\n  awareness,\n  awarenessFilter,\n  createCursor,\n  createSelection\n) => {\n  const ystate = ySyncPluginKey.getState(state);\n  if (ystate == null || ystate.doc == null || ystate.binding == null) {\n    return DecorationSet.create(state.doc, [])\n  }\n  const y = ystate.doc;\n  const decorations = [];\n  if (\n    ystate.snapshot != null ||\n    ystate.prevSnapshot != null ||\n    ystate.binding.mapping.size === 0\n  ) {\n    // do not render cursors while snapshot is active\n    return DecorationSet.create(state.doc, [])\n  }\n  awareness.getStates().forEach((aw, clientId) => {\n    if (!awarenessFilter(y.clientID, clientId, aw)) {\n      return\n    }\n\n    // `aw` can be null when a client disconnects, so we guard against it\n    // before reading `cursor` to avoid a TypeError.\n    if (aw && aw.cursor != null) {\n      const user = aw.user || {};\n      if (user.color == null) {\n        user.color = '#ffa500';\n      } else if (!rxValidColor.test(user.color)) {\n        // We only support 6-digit RGB colors in y-prosemirror\n        console.warn('A user uses an unsupported color format', user);\n      }\n      if (user.name == null) {\n        user.name = `User: ${clientId}`;\n      }\n      let anchor = relativePositionToAbsolutePosition(\n        y,\n        ystate.type,\n        Y.createRelativePositionFromJSON(aw.cursor.anchor),\n        ystate.binding.mapping\n      );\n      let head = relativePositionToAbsolutePosition(\n        y,\n        ystate.type,\n        Y.createRelativePositionFromJSON(aw.cursor.head),\n        ystate.binding.mapping\n      );\n      if (anchor !== null && head !== null) {\n        const maxsize = math.max(state.doc.content.size - 1, 0);\n        anchor = math.min(anchor, maxsize);\n        head = math.min(head, maxsize);\n        decorations.push(\n          Decoration.widget(head, () => createCursor(user, clientId), {\n            key: clientId + '',\n            side: 10\n          })\n        );\n        const from = math.min(anchor, head);\n        const to = math.max(anchor, head);\n        decorations.push(\n          Decoration.inline(from, to, createSelection(user, clientId), {\n            inclusiveEnd: true,\n            inclusiveStart: false\n          })\n        );\n      }\n    }\n  });\n  return DecorationSet.create(state.doc, decorations)\n};\n\n/**\n * A prosemirror plugin that listens to awareness information on Yjs.\n * This requires that a `prosemirrorPlugin` is also bound to the prosemirror.\n *\n * @public\n * @param {Awareness} awareness\n * @param {object} opts\n * @param {function(any, any, any):boolean} [opts.awarenessStateFilter]\n * @param {(user: any, clientId: number) => HTMLElement} [opts.cursorBuilder]\n * @param {(user: any, clientId: number) => import('prosemirror-view').DecorationAttrs} [opts.selectionBuilder]\n * @param {function(any):any} [opts.getSelection]\n * @param {string} [cursorStateField] By default all editor bindings use the awareness 'cursor' field to propagate cursor information.\n * @return {any}\n */\nconst yCursorPlugin = (\n  awareness,\n  {\n    awarenessStateFilter = defaultAwarenessStateFilter,\n    cursorBuilder = defaultCursorBuilder,\n    selectionBuilder = defaultSelectionBuilder,\n    getSelection = (state) => state.selection\n  } = {},\n  cursorStateField = 'cursor'\n) =>\n  new Plugin({\n    key: yCursorPluginKey,\n    state: {\n      init (_, state) {\n        return createDecorations(\n          state,\n          awareness,\n          awarenessStateFilter,\n          cursorBuilder,\n          selectionBuilder\n        )\n      },\n      apply (tr, prevState, oldState, newState) {\n        const ystate = ySyncPluginKey.getState(newState);\n        const yCursorState = tr.getMeta(yCursorPluginKey);\n        const isRemoteChange = ystate && ystate.isChangeOrigin;\n        if (\n          tr.docChanged &&\n          !isRemoteChange &&\n          isStructuralTransaction(tr, oldState.doc)\n        ) {\n          // The ProseMirror document leads the Yjs mapping during local moves.\n          // Hide stale awareness until the collaborator publishes its new cursor.\n          return DecorationSet.empty\n        }\n        if (\n          isRemoteChange ||\n          (yCursorState && yCursorState.awarenessUpdated)\n        ) {\n          return createDecorations(\n            newState,\n            awareness,\n            awarenessStateFilter,\n            cursorBuilder,\n            selectionBuilder\n          )\n        }\n        if (tr.docChanged) {\n          return prevState.map(tr.mapping, tr.doc)\n        }\n        return prevState\n      }\n    },\n    props: {\n      decorations: (state) => {\n        return yCursorPluginKey.getState(state)\n      }\n    },\n    view: (view) => {\n      const awarenessListener = () => {\n        // @ts-ignore\n        if (view.docView) {\n          setMeta(view, yCursorPluginKey, { awarenessUpdated: true });\n        }\n      };\n      /**\n       * @param {import('prosemirror-view').EditorView} editorView\n       * @param {{ force?: boolean }} [opts]\n       */\n      const updateCursorInfo = (editorView, opts = {}) => {\n        const ystate = ySyncPluginKey.getState(editorView.state);\n        // `ystate` is undefined during sync-plugin init and Y.Doc transitions;\n        // reading from it here would throw and break cursor tracking for the view.\n        if (!ystate || !ystate.binding) return\n        // @note We make implicit checks when checking for the cursor property\n        const current = awareness.getLocalState() || {};\n        if (editorView.hasFocus()) {\n          const selection = getSelection(editorView.state);\n          /**\n           * @type {Y.RelativePosition}\n           */\n          const anchor = absolutePositionToRelativePosition(\n            selection.anchor,\n            ystate.type,\n            ystate.binding.mapping\n          );\n          /**\n           * @type {Y.RelativePosition}\n           */\n          const head = absolutePositionToRelativePosition(\n            selection.head,\n            ystate.type,\n            ystate.binding.mapping\n          );\n          if (\n            opts.force ||\n            current.cursor == null ||\n            !Y.compareRelativePositions(\n              Y.createRelativePositionFromJSON(current.cursor.anchor),\n              anchor\n            ) ||\n            !Y.compareRelativePositions(\n              Y.createRelativePositionFromJSON(current.cursor.head),\n              head\n            )\n          ) {\n            awareness.setLocalStateField(cursorStateField, {\n              anchor,\n              head\n            });\n          }\n        } else if (\n          current.cursor != null &&\n          relativePositionToAbsolutePosition(\n            ystate.doc,\n            ystate.type,\n            Y.createRelativePositionFromJSON(current.cursor.anchor),\n            ystate.binding.mapping\n          ) !== null\n        ) {\n          // delete cursor information if current cursor information is owned by this editor binding\n          awareness.setLocalStateField(cursorStateField, null);\n        }\n      };\n      const onFocusChange = () => updateCursorInfo(view);\n      awareness.on('change', awarenessListener);\n      view.dom.addEventListener('focusin', onFocusChange);\n      view.dom.addEventListener('focusout', onFocusChange);\n      return {\n        update: (editorView, prevState) => {\n          const ystate = ySyncPluginKey.getState(editorView.state);\n          const forceAwarenessUpdate = !!(\n            ystate?.isChangeOrigin &&\n            prevState?.doc &&\n            !prevState.doc.eq(editorView.state.doc)\n          );\n          updateCursorInfo(editorView, { force: forceAwarenessUpdate });\n        },\n        destroy: () => {\n          view.dom.removeEventListener('focusin', onFocusChange);\n          view.dom.removeEventListener('focusout', onFocusChange);\n          awareness.off('change', awarenessListener);\n          awareness.setLocalStateField(cursorStateField, null);\n        }\n      }\n    }\n  });\n\nconst undo = state => {\n  const undoManager = yUndoPluginKey.getState(state).undoManager;\n  if (undoManager != null) {\n    undoManager.undo();\n    return true\n  }\n};\n\nconst redo = state => {\n  const undoManager = yUndoPluginKey.getState(state).undoManager;\n  if (undoManager != null) {\n    undoManager.redo();\n    return true\n  }\n};\n\nconst defaultProtectedNodes = new Set(['paragraph']);\n\nconst defaultDeleteFilter = (item, protectedNodes) => !(item instanceof Item) ||\n!(item.content instanceof ContentType) ||\n!(item.content.type instanceof Text ||\n  (item.content.type instanceof XmlElement && protectedNodes.has(item.content.type.nodeName))) ||\nitem.content.type._length === 0;\n\nconst yUndoPlugin = ({ protectedNodes = defaultProtectedNodes, trackedOrigins = [], undoManager = null } = {}) => new Plugin({\n  key: yUndoPluginKey,\n  state: {\n    init: (initargs, state) => {\n      // TODO: check if plugin order matches and fix\n      const ystate = ySyncPluginKey.getState(state);\n      let _undoManager = undoManager;\n      if (!_undoManager) {\n        // Y.UndoManager registers a `doc.on('destroy', …)` listener in its\n        // constructor that UndoManager.destroy() never removes. When the doc\n        // outlives the editor (e.g. several editors sharing one provider), that\n        // listener keeps the UndoManager — and everything it references —\n        // reachable from the doc, leaking memory on every editor destroy.\n        // We only own the lifecycle of a manager we create here, so capture the\n        // listener(s) it adds and remove them when the plugin view is destroyed.\n        const doc = ystate.doc;\n        const destroyListenersBefore = new Set(doc ? doc._observers.get('destroy') : []);\n        _undoManager = new UndoManager(ystate.type, {\n          trackedOrigins: new Set([ySyncPluginKey].concat(trackedOrigins)),\n          deleteFilter: (item) => defaultDeleteFilter(item, protectedNodes),\n          captureTransaction: tr => tr.meta.get('addToHistory') !== false\n        });\n        const destroyListenersAfter = doc ? doc._observers.get('destroy') : new Set();\n        _undoManager._yTiptapDocDestroyListeners = Array.from(destroyListenersAfter || [])\n          .filter(listener => !destroyListenersBefore.has(listener));\n      }\n      return {\n        undoManager: _undoManager,\n        prevSel: null,\n        hasUndoOps: _undoManager.undoStack.length > 0,\n        hasRedoOps: _undoManager.redoStack.length > 0\n      }\n    },\n    /**\n     * @returns {any}\n     */\n    apply: (tr, val, oldState, state) => {\n      const binding = ySyncPluginKey.getState(state).binding;\n      const undoManager = val.undoManager;\n      const hasUndoOps = undoManager.undoStack.length > 0;\n      const hasRedoOps = undoManager.redoStack.length > 0;\n      if (binding) {\n        return {\n          undoManager,\n          prevSel: getRelativeSelection(binding, oldState),\n          hasUndoOps,\n          hasRedoOps\n        }\n      } else {\n        if (hasUndoOps !== val.hasUndoOps || hasRedoOps !== val.hasRedoOps) {\n          return Object.assign({}, val, {\n            hasUndoOps: undoManager.undoStack.length > 0,\n            hasRedoOps: undoManager.redoStack.length > 0\n          })\n        } else { // nothing changed\n          return val\n        }\n      }\n    }\n  },\n  view: view => {\n    const ystate = ySyncPluginKey.getState(view.state);\n    const undoManager = yUndoPluginKey.getState(view.state).undoManager;\n    undoManager.on('stack-item-added', ({ stackItem }) => {\n      const binding = ystate.binding;\n      if (binding) {\n        stackItem.meta.set(binding, yUndoPluginKey.getState(view.state).prevSel);\n      }\n    });\n    undoManager.on('stack-item-popped', ({ stackItem }) => {\n      const binding = ystate.binding;\n      if (binding) {\n        binding.beforeTransactionSelection = stackItem.meta.get(binding) || binding.beforeTransactionSelection;\n      }\n    });\n    return {\n      destroy: () => {\n        undoManager.destroy();\n        // Remove the doc 'destroy' listener Y.UndoManager fails to clean up\n        // (only for managers we created — see state.init above).\n        const leakedDestroyListeners = undoManager._yTiptapDocDestroyListeners;\n        if (leakedDestroyListeners && undoManager.doc) {\n          leakedDestroyListeners.forEach(listener => undoManager.doc.off('destroy', listener));\n          undoManager._yTiptapDocDestroyListeners = null;\n        }\n      }\n    }\n  }\n});\n\nexport { ProsemirrorBinding, absolutePositionToRelativePosition, createDecorations, defaultAwarenessStateFilter, defaultCursorBuilder, defaultDeleteFilter, defaultProtectedNodes, defaultSelectionBuilder, findAbsolutePositionAfterStructuralChange, getRelativeSelection, initProseMirrorDoc, isMisresolvedAfterStructuralChange, isMisresolvedTextPosition, isStructuralTransaction, isVisible, prosemirrorJSONToYDoc, prosemirrorJSONToYXmlFragment, prosemirrorToYDoc, prosemirrorToYXmlFragment, redo, relativePositionToAbsolutePosition, setMeta, undo, updateYFragment, yCursorPlugin, yCursorPluginKey, yDocToProsemirror, yDocToProsemirrorJSON, ySyncPlugin, ySyncPluginKey, yUndoPlugin, yUndoPluginKey, yXmlFragmentToProseMirrorFragment, yXmlFragmentToProseMirrorRootNode, yXmlFragmentToProsemirror, yXmlFragmentToProsemirrorJSON };\n//# sourceMappingURL=y-tiptap.js.map\n","import { Extension, MappablePosition, getUpdatedPosition as getUpdatedPosition$1 } from \"@tiptap/core\";\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport { absolutePositionToRelativePosition, redo, relativePositionToAbsolutePosition, undo, ySyncPlugin, ySyncPluginKey, yUndoPlugin, yUndoPluginKey } from \"@tiptap/y-tiptap\";\n//#region src/helpers/isChangeOrigin.ts\n/**\n* Checks if a transaction was originated from a Yjs change.\n* @param {Transaction} transaction - The transaction to check.\n* @returns {boolean} - True if the transaction was originated from a Yjs change, false otherwise.\n* @example\n* const transaction = new Transaction(doc)\n* const isOrigin = isChangeOrigin(transaction) // returns false\n*/\nfunction isChangeOrigin(transaction) {\n\treturn !!transaction.getMeta(ySyncPluginKey);\n}\n//#endregion\n//#region src/helpers/yRelativePosition.ts\n/**\n* Converts a Y.js relative position to a position in the Tiptap document.\n*/\nfunction getYAbsolutePosition(state, relativePos) {\n\tconst ystate = ySyncPluginKey.getState(state);\n\treturn relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;\n}\n/**\n* Converts a position in the Tiptap document to a Y.js relative position.\n*/\nfunction getYRelativePosition(state, absolutePos) {\n\tconst ystate = ySyncPluginKey.getState(state);\n\treturn absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping);\n}\n//#endregion\n//#region src/helpers/CollaborationMappablePosition.ts\n/**\n* A MappablePosition subclass that includes Y.js relative position information\n* to track positions in collaborative transactions.\n*/\nvar CollaborationMappablePosition = class CollaborationMappablePosition extends MappablePosition {\n\tconstructor(position, yRelativePosition) {\n\t\tsuper(position);\n\t\tthis.yRelativePosition = yRelativePosition;\n\t}\n\t/**\n\t* Creates a CollaborationMappablePosition from a JSON object.\n\t*/\n\tstatic fromJSON(json) {\n\t\treturn new CollaborationMappablePosition(json.position, json.yRelativePosition);\n\t}\n\t/**\n\t* Converts the CollaborationMappablePosition to a JSON object.\n\t*/\n\ttoJSON() {\n\t\treturn {\n\t\t\tposition: this.position,\n\t\t\tyRelativePosition: this.yRelativePosition\n\t\t};\n\t}\n};\n/**\n* Creates a MappablePosition from a position number.\n* This is the collaboration implementation that returns a CollaborationMappablePosition.\n*/\nfunction createMappablePosition(position, state) {\n\treturn new CollaborationMappablePosition(position, getYRelativePosition(state, position));\n}\n/**\n* Returns the new position after applying a transaction. Handles both Y.js\n* transactions and regular transactions.\n*/\nfunction getUpdatedPosition(position, transaction, state) {\n\tconst yRelativePosition = position instanceof CollaborationMappablePosition ? position.yRelativePosition : null;\n\tif (isChangeOrigin(transaction) && yRelativePosition) return {\n\t\tposition: new CollaborationMappablePosition(getYAbsolutePosition(state, yRelativePosition), yRelativePosition),\n\t\tmapResult: null\n\t};\n\tconst result = getUpdatedPosition$1(position, transaction);\n\tconst absolutePosition = result.position.position;\n\treturn {\n\t\tposition: new CollaborationMappablePosition(absolutePosition, yRelativePosition !== null && yRelativePosition !== void 0 ? yRelativePosition : getYRelativePosition(state, absolutePosition)),\n\t\tmapResult: result.mapResult\n\t};\n}\n//#endregion\n//#region src/collaboration.ts\n/**\n* This extension allows you to collaborate with others in real-time.\n* @see https://tiptap.dev/api/extensions/collaboration\n*/\nconst Collaboration = Extension.create({\n\tname: \"collaboration\",\n\tpriority: 1e3,\n\taddOptions() {\n\t\treturn {\n\t\t\tdocument: null,\n\t\t\tfield: \"default\",\n\t\t\tfragment: null,\n\t\t\tprovider: null\n\t\t};\n\t},\n\taddStorage() {\n\t\treturn { isDisabled: false };\n\t},\n\tonCreate() {\n\t\tif (this.editor.extensionManager.extensions.find((extension) => extension.name === \"undoRedo\")) console.warn(\"[tiptap warn]: \\\"@tiptap/extension-collaboration\\\" comes with its own history support and is not compatible with \\\"@tiptap/extension-undo-redo\\\".\");\n\t},\n\tonBeforeCreate() {\n\t\tthis.editor.utils.getUpdatedPosition = (position, transaction) => getUpdatedPosition(position, transaction, this.editor.state);\n\t\tthis.editor.utils.createMappablePosition = (position) => createMappablePosition(position, this.editor.state);\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tundo: () => ({ tr, state, dispatch }) => {\n\t\t\t\ttr.setMeta(\"preventDispatch\", true);\n\t\t\t\tif (yUndoPluginKey.getState(state).undoManager.undoStack.length === 0) return false;\n\t\t\t\tif (!dispatch) return true;\n\t\t\t\treturn undo(state);\n\t\t\t},\n\t\t\tredo: () => ({ tr, state, dispatch }) => {\n\t\t\t\ttr.setMeta(\"preventDispatch\", true);\n\t\t\t\tif (yUndoPluginKey.getState(state).undoManager.redoStack.length === 0) return false;\n\t\t\t\tif (!dispatch) return true;\n\t\t\t\treturn redo(state);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-z\": () => this.editor.commands.undo(),\n\t\t\t\"Mod-y\": () => this.editor.commands.redo(),\n\t\t\t\"Shift-Mod-z\": () => this.editor.commands.redo()\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst fragment = this.options.fragment ? this.options.fragment : this.options.document.getXmlFragment(this.options.field);\n\t\tconst yUndoPluginInstance = yUndoPlugin(this.options.yUndoOptions);\n\t\tconst originalUndoPluginView = yUndoPluginInstance.spec.view;\n\t\tyUndoPluginInstance.spec.view = (view) => {\n\t\t\tconst { undoManager } = yUndoPluginKey.getState(view.state);\n\t\t\tif (undoManager.restore) {\n\t\t\t\tundoManager.restore();\n\t\t\t\tundoManager.restore = () => {};\n\t\t\t}\n\t\t\tconst viewRet = originalUndoPluginView ? originalUndoPluginView(view) : void 0;\n\t\t\treturn { destroy: () => {\n\t\t\t\tconst hasUndoManSelf = undoManager.trackedOrigins.has(undoManager);\n\t\t\t\tconst observers = undoManager._observers;\n\t\t\t\tundoManager.restore = () => {\n\t\t\t\t\tif (hasUndoManSelf) undoManager.trackedOrigins.add(undoManager);\n\t\t\t\t\tundoManager.doc.on(\"afterTransaction\", undoManager.afterTransactionHandler);\n\t\t\t\t\tundoManager._observers = observers;\n\t\t\t\t};\n\t\t\t\tif (viewRet === null || viewRet === void 0 ? void 0 : viewRet.destroy) viewRet.destroy();\n\t\t\t} };\n\t\t};\n\t\tconst ySyncPluginOptions = {\n\t\t\t...this.options.ySyncOptions,\n\t\t\tonFirstRender: this.options.onFirstRender\n\t\t};\n\t\treturn [\n\t\t\tySyncPlugin(fragment, ySyncPluginOptions),\n\t\t\tyUndoPluginInstance,\n\t\t\tthis.editor.options.enableContentCheck && new Plugin({\n\t\t\t\tkey: new PluginKey(\"filterInvalidContent\"),\n\t\t\t\tfilterTransaction: (transaction) => {\n\t\t\t\t\tif (!isChangeOrigin(transaction)) return true;\n\t\t\t\t\tif (this.storage.isDisabled) return false;\n\t\t\t\t\tif (!transaction.docChanged) return true;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttransaction.doc.check();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.storage.isDisabled = true;\n\t\t\t\t\t\tthis.editor.emit(\"contentError\", {\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\teditor: this.editor,\n\t\t\t\t\t\t\tdisableCollaboration: () => {\n\t\t\t\t\t\t\t\tvar _fragment$doc;\n\t\t\t\t\t\t\t\t(_fragment$doc = fragment.doc) === null || _fragment$doc === void 0 || _fragment$doc.destroy();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t].filter(Boolean);\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Collaboration;\n//#endregion\nexport { Collaboration, CollaborationMappablePosition, createMappablePosition, src_default as default, getUpdatedPosition, isChangeOrigin };\n\n//# sourceMappingURL=index.js.map","import { Extension } from \"@tiptap/core\";\nimport { Plugin, PluginKey, Selection, SelectionRange } from \"@tiptap/pm/state\";\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\";\nimport { NodeRange as NodeRange$1 } from \"@tiptap/pm/model\";\n//#region src/helpers/getNodeRangeDecorations.ts\nfunction getNodeRangeDecorations(ranges) {\n\tif (!ranges.length) return DecorationSet.empty;\n\tconst decorations = [];\n\tconst doc = ranges[0].$from.node(0);\n\tranges.forEach((range) => {\n\t\tconst pos = range.$from.pos;\n\t\tconst node = range.$from.nodeAfter;\n\t\tif (!node) return;\n\t\tdecorations.push(Decoration.node(pos, pos + node.nodeSize, { class: \"ProseMirror-selectednoderange\" }));\n\t});\n\treturn DecorationSet.create(doc, decorations);\n}\n//#endregion\n//#region src/helpers/getSelectionRanges.ts\nfunction getNodeContentBounds(nodeStart, nodeSize, node) {\n\tconst contentOffset = node.isText || node.isAtom ? 0 : 1;\n\treturn {\n\t\tstart: nodeStart + contentOffset,\n\t\tend: nodeStart + nodeSize - contentOffset\n\t};\n}\n/**\n* Calculates node-aligned selection ranges between two resolved positions.\n*\n* The helper derives a suitable depth when none is provided and returns a\n* `SelectionRange` for each matching child node in the computed `NodeRange`.\n* Each returned range exposes `$from` as the resolved start position of the\n* node selection and `$to` as the resolved end position.\n*\n* @param $from The resolved anchor position where the selection starts.\n* @param $to The resolved head position where the selection ends.\n* @param depth An optional depth to force when creating the ProseMirror `NodeRange`.\n* When omitted, the depth is inferred from the shared depth of `$from` and `$to`.\n* @param options Optional behavior flags for how boundary nodes are handled.\n* @param options.extendOnBoundaryOverlap Whether touching only a node's start\n* or end content boundary should still include that node in the returned ranges.\n* @returns An array of `SelectionRange` objects for the nodes covered at the\n* computed depth.\n* @example\n* ```ts\n* const { $from, $to } = editor.state.selection\n* const ranges = getSelectionRanges($from, $to, undefined, {\n*   extendOnBoundaryOverlap: false,\n* })\n*\n* ranges.forEach(range => {\n*   console.log(range.$from.pos, range.$to.pos)\n* })\n* ```\n*/\nfunction getSelectionRanges($from, $to, depth, options = {}) {\n\tconst ranges = [];\n\tconst doc = $from.node(0);\n\tconst { extendOnBoundaryOverlap = true } = options;\n\tif (typeof depth === \"number\" && depth >= 0) {} else if ($from.sameParent($to)) depth = Math.max(0, $from.sharedDepth($to.pos) - 1);\n\telse depth = $from.sharedDepth($to.pos);\n\tconst nodeRange = new NodeRange$1($from, $to, depth);\n\tconst offset = nodeRange.depth === 0 ? 0 : doc.resolve(nodeRange.start).posAtIndex(0);\n\tnodeRange.parent.forEach((node, pos) => {\n\t\tconst from = offset + pos;\n\t\tconst to = from + node.nodeSize;\n\t\tconst contentBounds = getNodeContentBounds(from, node.nodeSize, node);\n\t\tconst overlapsNodeContent = extendOnBoundaryOverlap ? $to.pos >= contentBounds.start && $from.pos <= contentBounds.end : $to.pos > contentBounds.start && $from.pos < contentBounds.end;\n\t\tif (from < nodeRange.start || from >= nodeRange.end) return;\n\t\tif (!overlapsNodeContent) return;\n\t\tconst selectionRange = new SelectionRange(doc.resolve(from), doc.resolve(to));\n\t\tranges.push(selectionRange);\n\t});\n\treturn ranges;\n}\n//#endregion\n//#region src/helpers/NodeRangeBookmark.ts\nvar NodeRangeBookmark = class NodeRangeBookmark {\n\tconstructor(anchor, head, depth) {\n\t\tthis.anchor = anchor;\n\t\tthis.head = head;\n\t\tthis.depth = depth !== null && depth !== void 0 ? depth : 0;\n\t}\n\tmap(mapping) {\n\t\treturn new NodeRangeBookmark(mapping.map(this.anchor), mapping.map(this.head), this.depth);\n\t}\n\tresolve(doc) {\n\t\treturn new NodeRangeSelection(doc.resolve(this.anchor), doc.resolve(this.head), this.depth);\n\t}\n};\n//#endregion\n//#region src/helpers/NodeRangeSelection.ts\nvar NodeRangeSelection = class NodeRangeSelection extends Selection {\n\tconstructor($anchor, $head, depth, bias = 1) {\n\t\tconst { doc } = $anchor;\n\t\tconst isCursor = $anchor === $head;\n\t\tconst isCursorAtEnd = $anchor.pos === doc.content.size && $head.pos === doc.content.size;\n\t\tconst $correctedHead = isCursor && !isCursorAtEnd ? doc.resolve($head.pos + (bias > 0 ? 1 : -1)) : $head;\n\t\tconst $correctedAnchor = isCursor && isCursorAtEnd ? doc.resolve($anchor.pos - (bias > 0 ? 1 : -1)) : $anchor;\n\t\tconst ranges = getSelectionRanges($correctedAnchor.min($correctedHead), $correctedAnchor.max($correctedHead), depth);\n\t\tconst $rangeFrom = $correctedHead.pos >= $anchor.pos ? ranges[0].$from : ranges[ranges.length - 1].$to;\n\t\tconst $rangeTo = $correctedHead.pos >= $anchor.pos ? ranges[ranges.length - 1].$to : ranges[0].$from;\n\t\tsuper($rangeFrom, $rangeTo, ranges);\n\t\tthis.depth = depth;\n\t}\n\tget $to() {\n\t\treturn this.ranges[this.ranges.length - 1].$to;\n\t}\n\teq(other) {\n\t\treturn other instanceof NodeRangeSelection && other.$from.pos === this.$from.pos && other.$to.pos === this.$to.pos;\n\t}\n\tmap(doc, mapping) {\n\t\tconst $anchor = doc.resolve(mapping.map(this.anchor));\n\t\tconst $head = doc.resolve(mapping.map(this.head));\n\t\treturn new NodeRangeSelection($anchor, $head, this.depth);\n\t}\n\ttoJSON() {\n\t\treturn {\n\t\t\ttype: \"nodeRange\",\n\t\t\tanchor: this.anchor,\n\t\t\thead: this.head,\n\t\t\tdepth: this.depth\n\t\t};\n\t}\n\tget isForwards() {\n\t\treturn this.head >= this.anchor;\n\t}\n\tget isBackwards() {\n\t\treturn !this.isForwards;\n\t}\n\textendBackwards() {\n\t\tconst { doc } = this.$from;\n\t\tif (this.isForwards && this.ranges.length > 1) {\n\t\t\tconst ranges = this.ranges.slice(0, -1);\n\t\t\tconst $from = ranges[0].$from;\n\t\t\tconst $to = ranges[ranges.length - 1].$to;\n\t\t\treturn new NodeRangeSelection($from, $to, this.depth);\n\t\t}\n\t\tconst firstRange = this.ranges[0];\n\t\tconst $from = doc.resolve(Math.max(0, firstRange.$from.pos - 1));\n\t\treturn new NodeRangeSelection(this.$anchor, $from, this.depth);\n\t}\n\textendForwards() {\n\t\tconst { doc } = this.$from;\n\t\tif (this.isBackwards && this.ranges.length > 1) {\n\t\t\tconst ranges = this.ranges.slice(1);\n\t\t\tconst $from = ranges[0].$from;\n\t\t\tconst $to = ranges[ranges.length - 1].$to;\n\t\t\treturn new NodeRangeSelection($to, $from, this.depth);\n\t\t}\n\t\tconst lastRange = this.ranges[this.ranges.length - 1];\n\t\tconst $to = doc.resolve(Math.min(doc.content.size, lastRange.$to.pos + 1));\n\t\treturn new NodeRangeSelection(this.$anchor, $to, this.depth);\n\t}\n\tstatic fromJSON(doc, json) {\n\t\treturn new NodeRangeSelection(doc.resolve(json.anchor), doc.resolve(json.head), json.depth);\n\t}\n\tstatic create(doc, anchor, head, depth, bias = 1) {\n\t\treturn new this(doc.resolve(anchor), doc.resolve(head), depth, bias);\n\t}\n\tgetBookmark() {\n\t\treturn new NodeRangeBookmark(this.anchor, this.head, this.depth);\n\t}\n};\nNodeRangeSelection.prototype.visible = false;\ntry {\n\tSelection.jsonID(\"nodeRange\", NodeRangeSelection);\n} catch {}\n//#endregion\n//#region src/helpers/isNodeRangeSelection.ts\nfunction isNodeRangeSelection(value) {\n\treturn value instanceof NodeRangeSelection;\n}\n//#endregion\n//#region src/node-range.ts\nconst NodeRange = Extension.create({\n\tname: \"nodeRange\",\n\taddOptions() {\n\t\treturn {\n\t\t\tdepth: void 0,\n\t\t\tkey: \"Mod\"\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Shift-ArrowUp\": ({ editor }) => {\n\t\t\t\tconst { depth } = this.options;\n\t\t\t\tconst { view, state } = editor;\n\t\t\t\tconst { doc, selection, tr } = state;\n\t\t\t\tconst { anchor, head } = selection;\n\t\t\t\tif (!isNodeRangeSelection(selection)) {\n\t\t\t\t\tconst nodeRangeSelection = NodeRangeSelection.create(doc, anchor, head, depth, -1);\n\t\t\t\t\ttr.setSelection(nodeRangeSelection);\n\t\t\t\t\tview.dispatch(tr);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst nodeRangeSelection = selection.extendBackwards();\n\t\t\t\ttr.setSelection(nodeRangeSelection);\n\t\t\t\tview.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t\"Shift-ArrowDown\": ({ editor }) => {\n\t\t\t\tconst { depth } = this.options;\n\t\t\t\tconst { view, state } = editor;\n\t\t\t\tconst { doc, selection, tr } = state;\n\t\t\t\tconst { anchor, head } = selection;\n\t\t\t\tif (!isNodeRangeSelection(selection)) {\n\t\t\t\t\tconst nodeRangeSelection = NodeRangeSelection.create(doc, anchor, head, depth);\n\t\t\t\t\ttr.setSelection(nodeRangeSelection);\n\t\t\t\t\tview.dispatch(tr);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst nodeRangeSelection = selection.extendForwards();\n\t\t\t\ttr.setSelection(nodeRangeSelection);\n\t\t\t\tview.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t\"Mod-a\": ({ editor }) => {\n\t\t\t\tconst { depth } = this.options;\n\t\t\t\tconst { view, state } = editor;\n\t\t\t\tconst { doc, tr } = state;\n\t\t\t\tconst nodeRangeSelection = NodeRangeSelection.create(doc, 0, doc.content.size, depth);\n\t\t\t\ttr.setSelection(nodeRangeSelection);\n\t\t\t\tview.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\t},\n\tonSelectionUpdate() {\n\t\tconst { selection } = this.editor.state;\n\t\tif (isNodeRangeSelection(selection)) this.editor.view.dom.classList.add(\"ProseMirror-noderangeselection\");\n\t},\n\taddProseMirrorPlugins() {\n\t\tlet hideTextSelection = false;\n\t\tlet activeMouseSelection = false;\n\t\treturn [new Plugin({\n\t\t\tkey: new PluginKey(\"nodeRange\"),\n\t\t\tprops: {\n\t\t\t\tattributes: () => {\n\t\t\t\t\tif (hideTextSelection) return { class: \"ProseMirror-noderangeselection\" };\n\t\t\t\t\treturn { class: \"\" };\n\t\t\t\t},\n\t\t\t\thandleDOMEvents: { mousedown: (view, event) => {\n\t\t\t\t\tconst { key } = this.options;\n\t\t\t\t\tconst isMac = /Mac/.test(navigator.platform);\n\t\t\t\t\tconst isShift = !!event.shiftKey;\n\t\t\t\t\tconst isControl = !!event.ctrlKey;\n\t\t\t\t\tconst isAlt = !!event.altKey;\n\t\t\t\t\tconst isMeta = !!event.metaKey;\n\t\t\t\t\tif (key === null || key === void 0 || key === \"Shift\" && isShift || key === \"Control\" && isControl || key === \"Alt\" && isAlt || key === \"Meta\" && isMeta || key === \"Mod\" && (isMac ? isMeta : isControl)) activeMouseSelection = true;\n\t\t\t\t\tif (!activeMouseSelection) return false;\n\t\t\t\t\tdocument.addEventListener(\"mouseup\", () => {\n\t\t\t\t\t\tactiveMouseSelection = false;\n\t\t\t\t\t\tconst { state } = view;\n\t\t\t\t\t\tconst { doc, selection, tr } = state;\n\t\t\t\t\t\tconst { $anchor, $head } = selection;\n\t\t\t\t\t\tif ($anchor.sameParent($head)) return;\n\t\t\t\t\t\tconst nodeRangeSelection = NodeRangeSelection.create(doc, $anchor.pos, $head.pos, this.options.depth);\n\t\t\t\t\t\ttr.setSelection(nodeRangeSelection);\n\t\t\t\t\t\tview.dispatch(tr);\n\t\t\t\t\t}, { once: true });\n\t\t\t\t\treturn false;\n\t\t\t\t} },\n\t\t\t\tdecorations: (state) => {\n\t\t\t\t\tconst { selection } = state;\n\t\t\t\t\tconst isNodeRange = isNodeRangeSelection(selection);\n\t\t\t\t\thideTextSelection = false;\n\t\t\t\t\tif (!activeMouseSelection) {\n\t\t\t\t\t\tif (!isNodeRange) return null;\n\t\t\t\t\t\thideTextSelection = true;\n\t\t\t\t\t\treturn getNodeRangeDecorations(selection.ranges);\n\t\t\t\t\t}\n\t\t\t\t\tconst { $from, $to } = selection;\n\t\t\t\t\tif (!isNodeRange && $from.sameParent($to)) return null;\n\t\t\t\t\tconst nodeRanges = getSelectionRanges($from, $to, this.options.depth);\n\t\t\t\t\tif (!nodeRanges.length) return null;\n\t\t\t\t\thideTextSelection = true;\n\t\t\t\t\treturn getNodeRangeDecorations(nodeRanges);\n\t\t\t\t}\n\t\t\t}\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = NodeRange;\n//#endregion\nexport { NodeRange, NodeRangeSelection, src_default as default, getNodeRangeDecorations, getSelectionRanges, isNodeRangeSelection };\n\n//# sourceMappingURL=index.js.map","import { Extension, isFirefox } from \"@tiptap/core\";\nimport { computePosition } from \"@floating-ui/dom\";\nimport { isChangeOrigin } from \"@tiptap/extension-collaboration\";\nimport { NodeSelection, Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from \"@tiptap/y-tiptap\";\nimport { NodeRangeSelection, getSelectionRanges, isNodeRangeSelection } from \"@tiptap/extension-node-range\";\n//#region src/helpers/cloneElement.ts\nfunction getCSSText(element, properties) {\n\tconst style = getComputedStyle(element);\n\tif (properties) return properties.map((property) => property.trim()).filter((property) => property.length > 0).map((property) => `${property}:${style.getPropertyValue(property)};`).join(\"\");\n\tlet value = \"\";\n\tfor (let i = 0; i < style.length; i += 1) value += `${style[i]}:${style.getPropertyValue(style[i])};`;\n\treturn value;\n}\nfunction cloneElement(node, properties) {\n\tconst clonedNode = node.cloneNode(true);\n\tconst sourceElements = [node, ...Array.from(node.getElementsByTagName(\"*\"))];\n\tconst targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName(\"*\"))];\n\tsourceElements.forEach((sourceElement, index) => {\n\t\ttargetElements[index].style.cssText = getCSSText(sourceElement, properties);\n\t});\n\treturn clonedNode;\n}\n/**\n* All default rules.\n* Users can extend these or replace them entirely.\n*/\nconst defaultRules = [\n\t{\n\t\tid: \"listItemFirstChild\",\n\t\tevaluate: ({ parent, isFirst }) => {\n\t\t\tif (!isFirst) return 0;\n\t\t\tif (parent && [\"listItem\", \"taskItem\"].includes(parent.type.name)) return 1e3;\n\t\t\treturn 0;\n\t\t}\n\t},\n\t{\n\t\tid: \"listWrapperDeprioritize\",\n\t\tevaluate: ({ node }) => {\n\t\t\tconst listItemTypes = [\"listItem\", \"taskItem\"];\n\t\t\tconst firstChild = node.firstChild;\n\t\t\tif (firstChild && listItemTypes.includes(firstChild.type.name)) return 1e3;\n\t\t\treturn 0;\n\t\t}\n\t},\n\t{\n\t\tid: \"tableStructure\",\n\t\tevaluate: ({ node, parent }) => {\n\t\t\tif ([\n\t\t\t\t\"tableRow\",\n\t\t\t\t\"tableCell\",\n\t\t\t\t\"tableHeader\"\n\t\t\t].includes(node.type.name)) return 1e3;\n\t\t\tif (parent && parent.type.name === \"tableHeader\") return 1e3;\n\t\t\treturn 0;\n\t\t}\n\t},\n\t{\n\t\tid: \"inlineContent\",\n\t\tevaluate: ({ node }) => {\n\t\t\tif (node.isInline || node.isText) return 1e3;\n\t\t\treturn 0;\n\t\t}\n\t}\n];\n//#endregion\n//#region src/helpers/edgeDetection.ts\n/**\n* Default edge detection configuration.\n*/\nconst DEFAULT_EDGE_CONFIG = {\n\tedges: [\"left\", \"top\"],\n\tthreshold: 12,\n\tstrength: 500\n};\n/**\n* Normalizes edge detection presets or custom config into a full config object.\n* Partial configs are merged with defaults.\n*\n* @param input - The preset string or partial/full config\n* @returns A complete EdgeDetectionConfig\n*/\nfunction normalizeEdgeDetection(input) {\n\tif (input === void 0 || input === \"left\") return { ...DEFAULT_EDGE_CONFIG };\n\tif (input === \"right\") return {\n\t\tedges: [\"right\", \"top\"],\n\t\tthreshold: 12,\n\t\tstrength: 500\n\t};\n\tif (input === \"both\") return {\n\t\tedges: [\n\t\t\t\"left\",\n\t\t\t\"right\",\n\t\t\t\"top\"\n\t\t],\n\t\tthreshold: 12,\n\t\tstrength: 500\n\t};\n\tif (input === \"none\") return {\n\t\tedges: [],\n\t\tthreshold: 0,\n\t\tstrength: 0\n\t};\n\treturn {\n\t\t...DEFAULT_EDGE_CONFIG,\n\t\t...input\n\t};\n}\n/**\n* Determines if cursor is near specified edges of an element.\n*\n* @param coords - The cursor coordinates\n* @param element - The element to check against\n* @param config - The edge detection configuration\n* @returns True if the cursor is near any of the configured edges\n*/\nfunction isNearEdge(coords, element, config) {\n\tif (config.edges.length === 0) return false;\n\tconst rect = element.getBoundingClientRect();\n\tconst { threshold, edges } = config;\n\treturn edges.some((edge) => {\n\t\tif (edge === \"left\") return coords.x - rect.left < threshold;\n\t\tif (edge === \"right\") return rect.right - coords.x < threshold;\n\t\tif (edge === \"top\") return coords.y - rect.top < threshold;\n\t\tif (edge === \"bottom\") return rect.bottom - coords.y < threshold;\n\t\treturn false;\n\t});\n}\n/**\n* Calculates score deduction for edge proximity.\n* Deeper nodes get larger deductions when near edges,\n* making shallower (parent) nodes win.\n*\n* @param coords - The cursor coordinates\n* @param element - The element to check against (may be null)\n* @param config - The edge detection configuration\n* @param depth - The depth of the node in the document tree\n* @returns The score deduction to apply\n*/\nfunction calculateEdgeDeduction(coords, element, config, depth) {\n\tif (!element || config.edges.length === 0) return 0;\n\tif (isNearEdge(coords, element, config)) return config.strength * depth;\n\treturn 0;\n}\n//#endregion\n//#region src/helpers/scoring.ts\n/**\n* Base score for all nodes. Rules deduct from this score.\n* A node with score <= 0 is excluded from being a drag target.\n*/\nconst BASE_SCORE = 1e3;\n/**\n* Calculates the drag target score for a node.\n* Higher score = more likely to be selected.\n*\n* @param context - The rule context containing node information\n* @param rules - The rules to apply\n* @param edgeConfig - The edge detection configuration\n* @param coords - The cursor coordinates\n* @returns The calculated score, or -1 if the node is excluded\n*/\nfunction calculateScore(context, rules, edgeConfig, coords) {\n\tlet score = BASE_SCORE;\n\tlet excluded = false;\n\trules.every((rule) => {\n\t\tconst deduction = rule.evaluate(context);\n\t\tscore -= deduction;\n\t\tif (score <= 0) {\n\t\t\texcluded = true;\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\tif (excluded) return -1;\n\tconst dom = context.view.nodeDOM(context.pos);\n\tscore -= calculateEdgeDeduction(coords, dom, edgeConfig, context.depth);\n\tif (score <= 0) return -1;\n\treturn score;\n}\n//#endregion\n//#region src/helpers/findBestDragTarget.ts\n/**\n* Checks if any ancestor at or above the given depth is in the allowed list.\n*\n* @param $pos - The resolved position\n* @param depth - The current depth being checked\n* @param allowedTypes - The list of allowed node type names\n* @returns True if any ancestor is in the allowed list\n*/\nfunction hasAncestorOfType($pos, depth, allowedTypes) {\n\treturn Array.from({ length: depth }, (_, i) => depth - 1 - i).some((d) => allowedTypes.includes($pos.node(d).type.name));\n}\n/**\n* Finds the best drag target at the given coordinates using the scoring system.\n*\n* @param view - The editor view\n* @param coords - The cursor coordinates\n* @param options - The normalized nested options\n* @returns The best drag target, or null if none found\n*/\nfunction findBestDragTarget(view, coords, options) {\n\tif (!Number.isFinite(coords.x) || !Number.isFinite(coords.y)) return null;\n\tconst posInfo = view.posAtCoords({\n\t\tleft: coords.x,\n\t\ttop: coords.y\n\t});\n\tif (!posInfo) return null;\n\tconst { doc } = view.state;\n\tconst $pos = doc.resolve(posInfo.pos);\n\tconst rules = [];\n\tif (options.defaultRules) rules.push(...defaultRules);\n\trules.push(...options.rules);\n\tconst candidates = Array.from({ length: $pos.depth }, (_, i) => $pos.depth - i).map((depth) => {\n\t\tconst node = $pos.node(depth);\n\t\tconst nodePos = $pos.before(depth);\n\t\tif (options.allowedContainers && depth > 0) {\n\t\t\tif (!hasAncestorOfType($pos, depth, options.allowedContainers)) return null;\n\t\t}\n\t\tconst parent = depth > 0 ? $pos.node(depth - 1) : null;\n\t\tconst index = depth > 0 ? $pos.index(depth - 1) : 0;\n\t\tconst siblingCount = parent ? parent.childCount : 1;\n\t\tconst score = calculateScore({\n\t\t\tnode,\n\t\t\tpos: nodePos,\n\t\t\tdepth,\n\t\t\tparent,\n\t\t\tindex,\n\t\t\tisFirst: index === 0,\n\t\t\tisLast: index === siblingCount - 1,\n\t\t\t$pos,\n\t\t\tview\n\t\t}, rules, options.edgeDetection, coords);\n\t\tif (score < 0) return null;\n\t\treturn {\n\t\t\tnode,\n\t\t\tpos: nodePos,\n\t\t\tdepth,\n\t\t\tscore,\n\t\t\tdom: view.nodeDOM(nodePos)\n\t\t};\n\t}).filter((candidate) => candidate !== null);\n\tconst nodeAfter = $pos.nodeAfter;\n\tif (nodeAfter && nodeAfter.isAtom && !nodeAfter.isInline) {\n\t\tconst nodePos = posInfo.pos;\n\t\tconst depth = $pos.depth + 1;\n\t\tconst parent = $pos.parent;\n\t\tconst index = $pos.index();\n\t\tconst siblingCount = parent.childCount;\n\t\tlet inAllowedContainer = true;\n\t\tif (options.allowedContainers) inAllowedContainer = hasAncestorOfType($pos, depth, options.allowedContainers);\n\t\tif (inAllowedContainer) {\n\t\t\tconst score = calculateScore({\n\t\t\t\tnode: nodeAfter,\n\t\t\t\tpos: nodePos,\n\t\t\t\tdepth,\n\t\t\t\tparent,\n\t\t\t\tindex,\n\t\t\t\tisFirst: index === 0,\n\t\t\t\tisLast: index === siblingCount - 1,\n\t\t\t\t$pos,\n\t\t\t\tview\n\t\t\t}, rules, options.edgeDetection, coords);\n\t\t\tif (score >= 0) {\n\t\t\t\tconst dom = view.nodeDOM(nodePos);\n\t\t\t\tif (dom) candidates.push({\n\t\t\t\t\tnode: nodeAfter,\n\t\t\t\t\tpos: nodePos,\n\t\t\t\t\tdepth,\n\t\t\t\t\tscore,\n\t\t\t\t\tdom\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tif (candidates.length === 0) return null;\n\tcandidates.sort((a, b) => {\n\t\tif (b.score !== a.score) return b.score - a.score;\n\t\treturn b.depth - a.depth;\n\t});\n\tconst winner = candidates[0];\n\tif (!winner.dom) return null;\n\treturn {\n\t\tnode: winner.node,\n\t\tpos: winner.pos,\n\t\tdom: winner.dom\n\t};\n}\n//#endregion\n//#region src/helpers/findNextElementFromCursor.ts\n/**\n* Finds the draggable block element that is a direct child of view.dom.\n*\n* Direct children that are widget decorations rather than document content are\n* skipped — they are not draggable blocks, and treating them as such would\n* align the drag handle to the decoration (e.g. the page header) instead of the\n* actual first block on the page.\n*/\nfunction findClosestTopLevelBlock(element, view) {\n\tvar _pmViewDesc;\n\tlet current = element;\n\twhile ((current === null || current === void 0 ? void 0 : current.parentElement) && current.parentElement !== view.dom) current = current.parentElement;\n\tif ((current === null || current === void 0 ? void 0 : current.parentElement) !== view.dom) return;\n\tif (!((_pmViewDesc = current.pmViewDesc) === null || _pmViewDesc === void 0 ? void 0 : _pmViewDesc.node)) return;\n\treturn current;\n}\n/**\n* Checks if a DOMRect has valid, finite dimensions.\n*/\nfunction isValidRect(rect) {\n\treturn Number.isFinite(rect.top) && Number.isFinite(rect.bottom) && Number.isFinite(rect.left) && Number.isFinite(rect.right) && rect.width > 0 && rect.height > 0;\n}\n/**\n* Returns the bounding rect of the first or last child of `container` that has\n* a valid (non-zero) layout box.\n*\n* Some extensions insert zero-size widget decorations as the first/last child\n* of the editor — for example the Pages extension anchors its page-chrome\n* overlay in a zero-height `<div>` as the first child. Reading `firstElementChild`\n* / `lastElementChild` directly would yield an invalid rect and abort clamping,\n* so we skip over any edge children without a valid box.\n*/\nfunction edgeBlockRect(container, edge) {\n\tlet current = edge === \"first\" ? container.firstElementChild : container.lastElementChild;\n\twhile (current) {\n\t\tconst rect = current.getBoundingClientRect();\n\t\tif (isValidRect(rect)) return rect;\n\t\tcurrent = edge === \"first\" ? current.nextElementSibling : current.previousElementSibling;\n\t}\n\treturn null;\n}\n/**\n* Clamps coordinates to content bounds with O(1) layout reads\n*/\nfunction clampToContent(view, x, y, inset = 5) {\n\tif (!Number.isFinite(x) || !Number.isFinite(y)) return null;\n\tconst container = view.dom;\n\tconst topRect = edgeBlockRect(container, \"first\");\n\tconst botRect = edgeBlockRect(container, \"last\");\n\tif (!topRect || !botRect) return null;\n\tconst clampedY = Math.min(Math.max(topRect.top + inset, y), botRect.bottom - inset);\n\tconst epsilon = .5;\n\tconst sameLeft = Math.abs(topRect.left - botRect.left) < epsilon;\n\tconst sameRight = Math.abs(topRect.right - botRect.right) < epsilon;\n\tlet rowRect = topRect;\n\tif (sameLeft && sameRight) rowRect = topRect;\n\tconst clampedX = Math.min(Math.max(rowRect.left + inset, x), rowRect.right - inset);\n\tif (!Number.isFinite(clampedX) || !Number.isFinite(clampedY)) return null;\n\treturn {\n\t\tx: clampedX,\n\t\ty: clampedY\n\t};\n}\nconst findElementNextToCoords = (options) => {\n\tconst { x, y, editor, nestedOptions } = options;\n\tconst { view, state } = editor;\n\tconst clamped = clampToContent(view, x, y, 5);\n\tif (!clamped) return {\n\t\tresultElement: null,\n\t\tresultNode: null,\n\t\tpos: null\n\t};\n\tconst { x: clampedX, y: clampedY } = clamped;\n\tif (nestedOptions === null || nestedOptions === void 0 ? void 0 : nestedOptions.enabled) {\n\t\tconst target = findBestDragTarget(view, {\n\t\t\tx: clampedX,\n\t\t\ty: clampedY\n\t\t}, nestedOptions);\n\t\tif (!target) return {\n\t\t\tresultElement: null,\n\t\t\tresultNode: null,\n\t\t\tpos: null\n\t\t};\n\t\treturn {\n\t\t\tresultElement: target.dom,\n\t\t\tresultNode: target.node,\n\t\t\tpos: target.pos\n\t\t};\n\t}\n\tconst elements = view.root.elementsFromPoint(clampedX, clampedY);\n\tlet block;\n\tArray.prototype.some.call(elements, (el) => {\n\t\tif (!view.dom.contains(el)) return false;\n\t\tconst candidate = findClosestTopLevelBlock(el, view);\n\t\tif (candidate) {\n\t\t\tblock = candidate;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t});\n\tif (!block) {\n\t\tconst coords = view.posAtCoords({\n\t\t\tleft: clampedX,\n\t\t\ttop: clampedY\n\t\t});\n\t\tif (coords) {\n\t\t\tconst $pos = state.doc.resolve(coords.pos);\n\t\t\tconst depth = Math.min($pos.depth, 1);\n\t\t\tconst blockPos = depth > 0 ? $pos.before(depth) : $pos.pos;\n\t\t\tconst blockNode = state.doc.nodeAt(blockPos);\n\t\t\tif (blockNode) {\n\t\t\t\tconst dom = view.nodeDOM(blockPos);\n\t\t\t\treturn {\n\t\t\t\t\tresultElement: dom instanceof HTMLElement ? dom : null,\n\t\t\t\t\tresultNode: blockNode,\n\t\t\t\t\tpos: blockPos\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tresultElement: null,\n\t\t\tresultNode: null,\n\t\t\tpos: null\n\t\t};\n\t}\n\tlet pos;\n\ttry {\n\t\tpos = view.posAtDOM(block, 0);\n\t} catch {\n\t\treturn {\n\t\t\tresultElement: null,\n\t\t\tresultNode: null,\n\t\t\tpos: null\n\t\t};\n\t}\n\tconst node = state.doc.nodeAt(pos);\n\tif (!node) {\n\t\tconst resolvedPos = state.doc.resolve(pos);\n\t\tconst parent = resolvedPos.parent;\n\t\treturn {\n\t\t\tresultElement: block,\n\t\t\tresultNode: parent,\n\t\t\tpos: resolvedPos.start()\n\t\t};\n\t}\n\treturn {\n\t\tresultElement: block,\n\t\tresultNode: node,\n\t\tpos\n\t};\n};\n//#endregion\n//#region src/helpers/getDraggedBlockDir.ts\n/**\n* Resolves the DOM element that visually represents the dragged block.\n*/\nfunction getDraggedBlockElement(view, pos) {\n\tconst nodeDom = view.nodeDOM(pos);\n\tif (nodeDom instanceof Element && nodeDom !== view.dom) return nodeDom;\n\tconst { node, offset } = view.domAtPos(pos);\n\tconst child = node.childNodes[offset];\n\tif (child instanceof Element) return child;\n\tif (node instanceof Element) return node;\n\tif (node.nodeType === Node.TEXT_NODE && node.parentElement) return node.parentElement;\n\treturn null;\n}\n/**\n* Resolves the text direction (`dir` attribute value) for the block being\n* dragged. Uses `view.nodeDOM` first because it maps a ProseMirror position\n* directly to the block-level DOM element. Falls back to `view.domAtPos` with\n* proper child-at-offset resolution when `nodeDOM` doesn't return an element,\n* and ultimately to the editor root direction.\n*/\nfunction getDraggedBlockDir(view, pos) {\n\tconst draggedDom = getDraggedBlockElement(view, pos);\n\treturn (draggedDom ? getComputedStyle(draggedDom).direction : getComputedStyle(view.dom).direction) || \"ltr\";\n}\n//#endregion\n//#region src/helpers/removeNode.ts\nfunction removeNode(node) {\n\tvar _node$parentNode;\n\t(_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 || _node$parentNode.removeChild(node);\n}\n//#endregion\n//#region src/helpers/dragHandler.ts\nfunction getDragImageOffset(direction, wrapperWidth) {\n\treturn direction === \"rtl\" ? wrapperWidth : 0;\n}\nfunction shouldResetMargin(dragImageProperties) {\n\tif (!dragImageProperties) return true;\n\treturn !dragImageProperties.some((property) => {\n\t\tconst p = property.trim().toLowerCase();\n\t\treturn p === \"margin\" || p.startsWith(\"margin-\");\n\t});\n}\nfunction getDragHandleRanges(event, editor, nestedOptions, dragContext) {\n\tconst { doc } = editor.view.state;\n\tif ((nestedOptions === null || nestedOptions === void 0 ? void 0 : nestedOptions.enabled) && (dragContext === null || dragContext === void 0 ? void 0 : dragContext.node) && dragContext.pos >= 0) {\n\t\tconst nodeStart = dragContext.pos;\n\t\tconst nodeEnd = dragContext.pos + dragContext.node.nodeSize;\n\t\treturn [{\n\t\t\t$from: doc.resolve(nodeStart),\n\t\t\t$to: doc.resolve(nodeEnd)\n\t\t}];\n\t}\n\tconst result = findElementNextToCoords({\n\t\teditor,\n\t\tx: event.clientX,\n\t\ty: event.clientY,\n\t\tdirection: \"right\",\n\t\tnestedOptions\n\t});\n\tif (!result.resultNode || result.pos === null) return [];\n\tconst offset = result.resultNode.isText || result.resultNode.isAtom ? 0 : -1;\n\tconst $from = doc.resolve(result.pos);\n\tconst $to = doc.resolve(result.pos + result.resultNode.nodeSize + offset);\n\treturn getSelectionRanges($from, $to, 0, { extendOnBoundaryOverlap: false });\n}\nfunction dragHandler(event, editor, nestedOptions, dragContext, dragImageProperties) {\n\tconst { view } = editor;\n\tif (!event.dataTransfer) return;\n\tconst { empty, $from, $to } = view.state.selection;\n\tconst dragHandleRanges = getDragHandleRanges(event, editor, nestedOptions, dragContext);\n\tconst selectionRanges = getSelectionRanges($from, $to, 0, { extendOnBoundaryOverlap: false });\n\tconst isDragHandleWithinSelection = selectionRanges.some((range) => {\n\t\treturn dragHandleRanges.find((dragHandleRange) => {\n\t\t\treturn dragHandleRange.$from === range.$from && dragHandleRange.$to === range.$to;\n\t\t});\n\t});\n\tconst ranges = empty || !isDragHandleWithinSelection ? dragHandleRanges : selectionRanges;\n\tif (!ranges.length) return;\n\tconst { tr } = view.state;\n\tconst wrapper = document.createElement(\"div\");\n\tconst from = ranges[0].$from.pos;\n\tconst to = ranges[ranges.length - 1].$to.pos;\n\tconst direction = getDraggedBlockDir(view, from);\n\twrapper.setAttribute(\"dir\", direction);\n\tconst isNestedDrag = (nestedOptions === null || nestedOptions === void 0 ? void 0 : nestedOptions.enabled) && (dragContext === null || dragContext === void 0 ? void 0 : dragContext.node);\n\tconst isSingleBlock = ranges.length === 1;\n\tlet slice;\n\tlet selection;\n\tif (isNestedDrag && isSingleBlock) {\n\t\tslice = view.state.doc.slice(from, to);\n\t\tselection = NodeSelection.create(view.state.doc, from);\n\t} else {\n\t\tselection = NodeRangeSelection.create(view.state.doc, from, to);\n\t\tslice = selection.content();\n\t}\n\tconst resetMargin = shouldResetMargin(dragImageProperties);\n\tranges.forEach((range) => {\n\t\tconst element = getDraggedBlockElement(view, range.$from.pos);\n\t\tif (!element) return;\n\t\tconst clonedElement = cloneElement(element, dragImageProperties);\n\t\tif (resetMargin) clonedElement.style.margin = \"0\";\n\t\twrapper.append(clonedElement);\n\t});\n\twrapper.style.position = \"absolute\";\n\twrapper.style.top = \"-10000px\";\n\tdocument.body.append(wrapper);\n\tevent.dataTransfer.clearData();\n\tconst dragImageX = getDragImageOffset(direction, wrapper.getBoundingClientRect().width);\n\tevent.dataTransfer.setDragImage(wrapper, dragImageX, 0);\n\tlet cleanedUp = false;\n\tconst cleanupDragPreview = () => {\n\t\tif (cleanedUp) return;\n\t\tcleanedUp = true;\n\t\tremoveNode(wrapper);\n\t\tdocument.removeEventListener(\"drop\", cleanupDragPreview);\n\t\tdocument.removeEventListener(\"dragend\", cleanupDragPreview);\n\t};\n\tconst nodeSelection = selection instanceof NodeSelection ? selection : void 0;\n\tview.dragging = {\n\t\tslice,\n\t\tmove: true,\n\t\tnode: nodeSelection\n\t};\n\ttr.setSelection(selection);\n\tview.dispatch(tr);\n\tdocument.addEventListener(\"drop\", cleanupDragPreview);\n\tdocument.addEventListener(\"dragend\", cleanupDragPreview);\n}\n//#endregion\n//#region src/helpers/getOuterNode.ts\nconst getOuterNodePos = (doc, pos) => {\n\tconst resolvedPos = doc.resolve(pos);\n\tconst { depth } = resolvedPos;\n\tif (depth === 0) return pos;\n\treturn resolvedPos.pos - resolvedPos.parentOffset - 1;\n};\nconst getOuterNode = (doc, pos) => {\n\tconst node = doc.nodeAt(pos);\n\tconst resolvedPos = doc.resolve(pos);\n\tlet { depth } = resolvedPos;\n\tlet parent = node;\n\twhile (depth > 0) {\n\t\tconst currentNode = resolvedPos.node(depth);\n\t\tdepth -= 1;\n\t\tif (depth === 0) parent = currentNode;\n\t}\n\treturn parent;\n};\n//#endregion\n//#region src/helpers/nodeRangeDrop.ts\nfunction mapPendingRestoreAnchor(pendingRestore, tr, options) {\n\tif (!tr.docChanged) return pendingRestore;\n\tif (options.isChangeOrigin && pendingRestore.relativeAnchorPos != null) {\n\t\tconst newPos = options.getAbsolutePos(pendingRestore.relativeAnchorPos);\n\t\tif (!Number.isFinite(newPos) || newPos <= 0) return null;\n\t\treturn {\n\t\t\t...pendingRestore,\n\t\t\tanchorPos: newPos\n\t\t};\n\t}\n\tconst mappedResult = tr.mapping.mapResult(pendingRestore.anchorPos, 1);\n\tif (mappedResult.deleted) return null;\n\treturn {\n\t\t...pendingRestore,\n\t\tanchorPos: mappedResult.pos\n\t};\n}\nfunction sumNodeSizes(parent, from, to) {\n\tlet size = 0;\n\tfor (let i = from; i < to; i += 1) size += parent.child(i).nodeSize;\n\treturn size;\n}\nfunction getActiveDragRange(selection) {\n\tvar _selection$depth;\n\tif (!isNodeRangeSelection(selection)) return null;\n\treturn {\n\t\tanchorPos: selection.from,\n\t\tnodeCount: selection.ranges.length,\n\t\tdepth: (_selection$depth = selection.depth) !== null && _selection$depth !== void 0 ? _selection$depth : 0\n\t};\n}\n/**\n* Computes the position range of the freshly dropped blocks so a\n* `NodeRangeSelection` can be restored over them after a drag-and-drop.\n*/\nfunction getDroppedBlockRange(doc, anchorPos, nodeCount, depth) {\n\tconst $pos = doc.resolve(anchorPos);\n\tconst parent = $pos.node(depth);\n\tlet index = $pos.index(depth);\n\tif (index >= parent.childCount) index = Math.max(0, parent.childCount - nodeCount);\n\tconst count = Math.min(nodeCount, parent.childCount - index);\n\tif (count <= 0) return null;\n\tconst blockStart = $pos.start(depth) + sumNodeSizes(parent, 0, index);\n\treturn {\n\t\tanchor: blockStart,\n\t\thead: blockStart + sumNodeSizes(parent, index, index + count),\n\t\tcount\n\t};\n}\nfunction createDroppedNodeRangeSelection(doc, anchorPos, nodeCount, depth) {\n\ttry {\n\t\tconst range = getDroppedBlockRange(doc, anchorPos, nodeCount, depth);\n\t\tif (!range) return null;\n\t\tconst selection = NodeRangeSelection.create(doc, range.anchor, range.head, depth);\n\t\treturn selection.ranges.length === nodeCount ? selection : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n//#endregion\n//#region src/drag-handle-plugin.ts\nconst getRelativePos = (state, absolutePos) => {\n\tconst ystate = ySyncPluginKey.getState(state);\n\tif (!ystate) return null;\n\treturn absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping);\n};\nconst getAbsolutePos = (state, relativePos) => {\n\tconst ystate = ySyncPluginKey.getState(state);\n\tif (!ystate) return -1;\n\treturn relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;\n};\nconst getOuterDomNode = (view, domNode) => {\n\tlet tmpDomNode = domNode;\n\twhile (tmpDomNode === null || tmpDomNode === void 0 ? void 0 : tmpDomNode.parentNode) {\n\t\tif (tmpDomNode.parentNode === view.dom) break;\n\t\ttmpDomNode = tmpDomNode.parentNode;\n\t}\n\treturn tmpDomNode;\n};\nconst dragHandlePluginDefaultKey = new PluginKey(\"dragHandle\");\nconst DragHandlePlugin = ({ pluginKey = dragHandlePluginDefaultKey, element, editor, computePositionConfig, getReferencedVirtualElement, onNodeChange, onElementDragStart, onElementDragEnd, nestedOptions, dragImageProperties }) => {\n\tconst wrapper = document.createElement(\"div\");\n\tlet locked = false;\n\tlet currentNode = null;\n\tlet currentNodePos = -1;\n\tlet currentNodeRelPos;\n\tlet rafId = null;\n\tlet pendingMouseCoords = null;\n\tlet activeDragRange = null;\n\tlet pendingRestore = null;\n\tfunction clearDragRangeState() {\n\t\tactiveDragRange = null;\n\t\tpendingRestore = null;\n\t}\n\tfunction remapPendingRestore(tr, state) {\n\t\tif (!pendingRestore) return;\n\t\tpendingRestore = mapPendingRestoreAnchor(pendingRestore, tr, {\n\t\t\tisChangeOrigin: isChangeOrigin(tr),\n\t\t\tgetAbsolutePos: (relativePos) => getAbsolutePos(state, relativePos)\n\t\t});\n\t}\n\tfunction buildRestoreTransaction(state) {\n\t\tif (!pendingRestore) return null;\n\t\tconst nodeRangeSelection = createDroppedNodeRangeSelection(state.doc, pendingRestore.anchorPos, pendingRestore.nodeCount, pendingRestore.depth);\n\t\tif (!nodeRangeSelection) {\n\t\t\tpendingRestore = null;\n\t\t\tactiveDragRange = null;\n\t\t\treturn null;\n\t\t}\n\t\tclearDragRangeState();\n\t\treturn state.tr.setSelection(nodeRangeSelection);\n\t}\n\tfunction hideHandle() {\n\t\tif (!element) return;\n\t\telement.style.visibility = \"hidden\";\n\t\telement.style.pointerEvents = \"none\";\n\t}\n\tfunction showHandle() {\n\t\tif (!element) return;\n\t\tif (!editor.isEditable) {\n\t\t\thideHandle();\n\t\t\treturn;\n\t\t}\n\t\telement.style.visibility = \"\";\n\t\telement.style.pointerEvents = \"auto\";\n\t}\n\tfunction repositionDragHandle(dom) {\n\t\tconst virtualElement = (getReferencedVirtualElement === null || getReferencedVirtualElement === void 0 ? void 0 : getReferencedVirtualElement()) || { getBoundingClientRect: () => dom.getBoundingClientRect() };\n\t\tcomputePosition(virtualElement, element, computePositionConfig).then((val) => {\n\t\t\tObject.assign(element.style, {\n\t\t\t\tposition: val.strategy,\n\t\t\t\tleft: `${val.x}px`,\n\t\t\t\ttop: `${val.y}px`\n\t\t\t});\n\t\t});\n\t}\n\tfunction onDragStart(e) {\n\t\tonElementDragStart === null || onElementDragStart === void 0 || onElementDragStart(e);\n\t\tdragHandler(e, editor, nestedOptions, {\n\t\t\tnode: currentNode,\n\t\t\tpos: currentNodePos\n\t\t}, dragImageProperties);\n\t\tactiveDragRange = getActiveDragRange(editor.state.selection);\n\t\tif (element) element.dataset.dragging = \"true\";\n\t\tsetTimeout(() => {\n\t\t\tif (element) element.style.pointerEvents = \"none\";\n\t\t}, 0);\n\t}\n\tfunction onDragEnd(e) {\n\t\tonElementDragEnd === null || onElementDragEnd === void 0 || onElementDragEnd(e);\n\t\tactiveDragRange = null;\n\t\thideHandle();\n\t\tif (element) {\n\t\t\telement.style.pointerEvents = \"auto\";\n\t\t\telement.dataset.dragging = \"false\";\n\t\t}\n\t}\n\tfunction onDrop(e) {\n\t\tif (!e.target || !editor.view.dom.contains(e.target)) return;\n\t\tif (isFirefox()) {\n\t\t\tconst editorElement = editor.view.dom;\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tif (editorElement.isContentEditable) {\n\t\t\t\t\teditorElement.contentEditable = \"false\";\n\t\t\t\t\teditorElement.contentEditable = \"true\";\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (!activeDragRange || editor.view.state.selection.empty) return;\n\t\tconst anchorPos = editor.state.selection.from;\n\t\tconst relativeAnchorPos = getRelativePos(editor.state, anchorPos);\n\t\tpendingRestore = {\n\t\t\t...activeDragRange,\n\t\t\tanchorPos,\n\t\t\trelativeAnchorPos: relativeAnchorPos !== null && relativeAnchorPos !== void 0 ? relativeAnchorPos : void 0\n\t\t};\n\t\teditor.view.dispatch(editor.state.tr.setMeta(\"addToHistory\", false));\n\t}\n\tfunction cleanup() {\n\t\telement.removeEventListener(\"dragstart\", onDragStart);\n\t\telement.removeEventListener(\"dragend\", onDragEnd);\n\t\tdocument.removeEventListener(\"drop\", onDrop);\n\t\tif (rafId) {\n\t\t\tcancelAnimationFrame(rafId);\n\t\t\trafId = null;\n\t\t\tpendingMouseCoords = null;\n\t\t}\n\t\tclearDragRangeState();\n\t}\n\twrapper.appendChild(element);\n\treturn {\n\t\tunbind() {\n\t\t\tcleanup();\n\t\t},\n\t\tplugin: new Plugin({\n\t\t\tkey: typeof pluginKey === \"string\" ? new PluginKey(pluginKey) : pluginKey,\n\t\t\tstate: {\n\t\t\t\tinit() {\n\t\t\t\t\treturn { locked: false };\n\t\t\t\t},\n\t\t\t\tapply(tr, value, _oldState, state) {\n\t\t\t\t\tremapPendingRestore(tr, state);\n\t\t\t\t\tconst isLocked = tr.getMeta(\"lockDragHandle\");\n\t\t\t\t\tconst hideDragHandle = tr.getMeta(\"hideDragHandle\");\n\t\t\t\t\tif (isLocked !== void 0) locked = isLocked;\n\t\t\t\t\tif (hideDragHandle) {\n\t\t\t\t\t\thideHandle();\n\t\t\t\t\t\tlocked = false;\n\t\t\t\t\t\tcurrentNode = null;\n\t\t\t\t\t\tcurrentNodePos = -1;\n\t\t\t\t\t\tonNodeChange === null || onNodeChange === void 0 || onNodeChange({\n\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\tnode: null,\n\t\t\t\t\t\t\tpos: -1\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\t\t\t\t\tif (tr.docChanged && currentNodePos !== -1 && element) {\n\t\t\t\t\t\tif (isChangeOrigin(tr)) {\n\t\t\t\t\t\t\tconst newPos = getAbsolutePos(state, currentNodeRelPos);\n\t\t\t\t\t\t\tif (newPos !== currentNodePos) currentNodePos = newPos;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst newPos = tr.mapping.map(currentNodePos);\n\t\t\t\t\t\t\tif (newPos !== currentNodePos) {\n\t\t\t\t\t\t\t\tcurrentNodePos = newPos;\n\t\t\t\t\t\t\t\tcurrentNodeRelPos = getRelativePos(state, currentNodePos);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t},\n\t\t\tappendTransaction(_transactions, _oldState, newState) {\n\t\t\t\treturn buildRestoreTransaction(newState);\n\t\t\t},\n\t\t\tview: (view) => {\n\t\t\t\tvar _editor$view$dom$pare;\n\t\t\t\telement.draggable = true;\n\t\t\t\telement.style.pointerEvents = \"auto\";\n\t\t\t\telement.dataset.dragging = \"false\";\n\t\t\t\t(_editor$view$dom$pare = editor.view.dom.parentElement) === null || _editor$view$dom$pare === void 0 || _editor$view$dom$pare.appendChild(wrapper);\n\t\t\t\twrapper.style.pointerEvents = \"none\";\n\t\t\t\twrapper.style.position = \"absolute\";\n\t\t\t\twrapper.style.top = \"0\";\n\t\t\t\twrapper.style.left = \"0\";\n\t\t\t\twrapper.style.zIndex = \"10\";\n\t\t\t\telement.addEventListener(\"dragstart\", onDragStart);\n\t\t\t\telement.addEventListener(\"dragend\", onDragEnd);\n\t\t\t\tdocument.addEventListener(\"drop\", onDrop);\n\t\t\t\treturn {\n\t\t\t\t\tupdate(_, oldState) {\n\t\t\t\t\t\tif (!element) return;\n\t\t\t\t\t\tif (!editor.isEditable) {\n\t\t\t\t\t\t\thideHandle();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (locked) element.draggable = false;\n\t\t\t\t\t\telse element.draggable = true;\n\t\t\t\t\t\tif (view.state.doc.eq(oldState.doc) || currentNodePos === -1) return;\n\t\t\t\t\t\tlet domNode = view.nodeDOM(currentNodePos);\n\t\t\t\t\t\tdomNode = getOuterDomNode(view, domNode);\n\t\t\t\t\t\tif (domNode === view.dom) return;\n\t\t\t\t\t\tif ((domNode === null || domNode === void 0 ? void 0 : domNode.nodeType) !== 1) return;\n\t\t\t\t\t\tconst domNodePos = view.posAtDOM(domNode, 0);\n\t\t\t\t\t\tconst outerNode = getOuterNode(editor.state.doc, domNodePos);\n\t\t\t\t\t\tconst outerNodePos = getOuterNodePos(editor.state.doc, domNodePos);\n\t\t\t\t\t\tcurrentNode = outerNode;\n\t\t\t\t\t\tcurrentNodePos = outerNodePos;\n\t\t\t\t\t\tcurrentNodeRelPos = getRelativePos(view.state, currentNodePos);\n\t\t\t\t\t\tonNodeChange === null || onNodeChange === void 0 || onNodeChange({\n\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\tnode: currentNode,\n\t\t\t\t\t\t\tpos: currentNodePos\n\t\t\t\t\t\t});\n\t\t\t\t\t\trepositionDragHandle(domNode);\n\t\t\t\t\t},\n\t\t\t\t\tdestroy() {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tif (element) removeNode(wrapper);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t\tprops: { handleDOMEvents: {\n\t\t\t\tkeydown(view) {\n\t\t\t\t\tif (!element || locked) return false;\n\t\t\t\t\tif (view.hasFocus()) {\n\t\t\t\t\t\thideHandle();\n\t\t\t\t\t\tcurrentNode = null;\n\t\t\t\t\t\tcurrentNodePos = -1;\n\t\t\t\t\t\tonNodeChange === null || onNodeChange === void 0 || onNodeChange({\n\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\tnode: null,\n\t\t\t\t\t\t\tpos: -1\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\tmouseleave(_view, e) {\n\t\t\t\t\tif (locked) return false;\n\t\t\t\t\tif (e.target && !wrapper.contains(e.relatedTarget)) {\n\t\t\t\t\t\thideHandle();\n\t\t\t\t\t\tcurrentNode = null;\n\t\t\t\t\t\tcurrentNodePos = -1;\n\t\t\t\t\t\tonNodeChange === null || onNodeChange === void 0 || onNodeChange({\n\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\tnode: null,\n\t\t\t\t\t\t\tpos: -1\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\tmousemove(view, e) {\n\t\t\t\t\tif (!element || locked) return false;\n\t\t\t\t\tpendingMouseCoords = {\n\t\t\t\t\t\tx: e.clientX,\n\t\t\t\t\t\ty: e.clientY\n\t\t\t\t\t};\n\t\t\t\t\tif (rafId) return false;\n\t\t\t\t\trafId = requestAnimationFrame(() => {\n\t\t\t\t\t\trafId = null;\n\t\t\t\t\t\tif (!pendingMouseCoords) return;\n\t\t\t\t\t\tconst { x, y } = pendingMouseCoords;\n\t\t\t\t\t\tpendingMouseCoords = null;\n\t\t\t\t\t\tconst nodeData = findElementNextToCoords({\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\tdirection: \"right\",\n\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\tnestedOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!nodeData.resultElement) return;\n\t\t\t\t\t\tlet domNode = nodeData.resultElement;\n\t\t\t\t\t\tlet targetNode = nodeData.resultNode;\n\t\t\t\t\t\tlet targetPos = nodeData.pos;\n\t\t\t\t\t\tif (!(nestedOptions === null || nestedOptions === void 0 ? void 0 : nestedOptions.enabled)) {\n\t\t\t\t\t\t\tdomNode = getOuterDomNode(view, domNode);\n\t\t\t\t\t\t\tif (domNode === view.dom) return;\n\t\t\t\t\t\t\tif ((domNode === null || domNode === void 0 ? void 0 : domNode.nodeType) !== 1) return;\n\t\t\t\t\t\t\tconst domNodePos = view.posAtDOM(domNode, 0);\n\t\t\t\t\t\t\ttargetNode = getOuterNode(editor.state.doc, domNodePos);\n\t\t\t\t\t\t\ttargetPos = getOuterNodePos(editor.state.doc, domNodePos);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (targetNode !== currentNode) {\n\t\t\t\t\t\t\tvar _targetPos;\n\t\t\t\t\t\t\tcurrentNode = targetNode;\n\t\t\t\t\t\t\tcurrentNodePos = (_targetPos = targetPos) !== null && _targetPos !== void 0 ? _targetPos : -1;\n\t\t\t\t\t\t\tcurrentNodeRelPos = getRelativePos(view.state, currentNodePos);\n\t\t\t\t\t\t\tonNodeChange === null || onNodeChange === void 0 || onNodeChange({\n\t\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\t\tnode: currentNode,\n\t\t\t\t\t\t\t\tpos: currentNodePos\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\trepositionDragHandle(domNode);\n\t\t\t\t\t\t\tshowHandle();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} }\n\t\t})\n\t};\n};\n//#endregion\n//#region src/helpers/normalizeOptions.ts\n/**\n* Normalizes the nested options input into a complete configuration object.\n*\n* @param input - The nested option (boolean, object, or undefined)\n* @returns A fully normalized options object\n*\n* @example\n* // Simple enable\n* normalizeNestedOptions(true)\n* // Returns: { enabled: true, rules: [], defaultRules: true, ... }\n*\n* @example\n* // Custom config\n* normalizeNestedOptions({ rules: [myRule], edgeDetection: 'none' })\n* // Returns: { enabled: true, rules: [myRule], edgeDetection: { edges: [], ... } }\n*/\nfunction normalizeNestedOptions(input) {\n\tvar _input$rules, _input$defaultRules;\n\tif (input === false || input === void 0) return {\n\t\tenabled: false,\n\t\trules: [],\n\t\tdefaultRules: true,\n\t\tallowedContainers: void 0,\n\t\tedgeDetection: normalizeEdgeDetection(\"none\")\n\t};\n\tif (input === true) return {\n\t\tenabled: true,\n\t\trules: [],\n\t\tdefaultRules: true,\n\t\tallowedContainers: void 0,\n\t\tedgeDetection: normalizeEdgeDetection(\"left\")\n\t};\n\treturn {\n\t\tenabled: true,\n\t\trules: (_input$rules = input.rules) !== null && _input$rules !== void 0 ? _input$rules : [],\n\t\tdefaultRules: (_input$defaultRules = input.defaultRules) !== null && _input$defaultRules !== void 0 ? _input$defaultRules : true,\n\t\tallowedContainers: input.allowedContainers,\n\t\tedgeDetection: normalizeEdgeDetection(input.edgeDetection)\n\t};\n}\n//#endregion\n//#region src/drag-handle.ts\nconst defaultComputePositionConfig = {\n\tplacement: \"left-start\",\n\tstrategy: \"absolute\"\n};\nconst DragHandle = Extension.create({\n\tname: \"dragHandle\",\n\taddOptions() {\n\t\treturn {\n\t\t\trender() {\n\t\t\t\tconst element = document.createElement(\"div\");\n\t\t\t\telement.classList.add(\"drag-handle\");\n\t\t\t\treturn element;\n\t\t\t},\n\t\t\tcomputePositionConfig: {},\n\t\t\tlocked: false,\n\t\t\tonNodeChange: () => {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tonElementDragStart: void 0,\n\t\t\tonElementDragEnd: void 0,\n\t\t\tnested: false,\n\t\t\tdragImageProperties: void 0\n\t\t};\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tlockDragHandle: () => ({ editor }) => {\n\t\t\t\tthis.options.locked = true;\n\t\t\t\treturn editor.commands.setMeta(\"lockDragHandle\", this.options.locked);\n\t\t\t},\n\t\t\tunlockDragHandle: () => ({ editor }) => {\n\t\t\t\tthis.options.locked = false;\n\t\t\t\treturn editor.commands.setMeta(\"lockDragHandle\", this.options.locked);\n\t\t\t},\n\t\t\ttoggleDragHandle: () => ({ editor }) => {\n\t\t\t\tthis.options.locked = !this.options.locked;\n\t\t\t\treturn editor.commands.setMeta(\"lockDragHandle\", this.options.locked);\n\t\t\t}\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst element = this.options.render();\n\t\tconst nestedOptions = normalizeNestedOptions(this.options.nested);\n\t\treturn [DragHandlePlugin({\n\t\t\tcomputePositionConfig: {\n\t\t\t\t...defaultComputePositionConfig,\n\t\t\t\t...this.options.computePositionConfig\n\t\t\t},\n\t\t\tgetReferencedVirtualElement: this.options.getReferencedVirtualElement,\n\t\t\telement,\n\t\t\teditor: this.editor,\n\t\t\tonNodeChange: this.options.onNodeChange,\n\t\t\tonElementDragStart: this.options.onElementDragStart,\n\t\t\tonElementDragEnd: this.options.onElementDragEnd,\n\t\t\tnestedOptions,\n\t\t\tdragImageProperties: this.options.dragImageProperties\n\t\t}).plugin];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = DragHandle;\n//#endregion\nexport { DragHandle, DragHandlePlugin, src_default as default, defaultComputePositionConfig, defaultRules, dragHandlePluginDefaultKey, normalizeNestedOptions };\n\n//# sourceMappingURL=index.js.map","import { DragHandlePlugin, defaultComputePositionConfig, dragHandlePluginDefaultKey, normalizeNestedOptions } from \"@tiptap/extension-drag-handle\";\nimport { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from \"vue\";\n//#region src/DragHandle.ts\nconst DragHandle = defineComponent({\n\tname: \"DragHandleVue\",\n\tprops: {\n\t\tpluginKey: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: dragHandlePluginDefaultKey\n\t\t},\n\t\teditor: {\n\t\t\ttype: Object,\n\t\t\trequired: true\n\t\t},\n\t\tcomputePositionConfig: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({})\n\t\t},\n\t\tonNodeChange: {\n\t\t\ttype: Function,\n\t\t\tdefault: null\n\t\t},\n\t\tonElementDragStart: {\n\t\t\ttype: Function,\n\t\t\tdefault: null\n\t\t},\n\t\tonElementDragEnd: {\n\t\t\ttype: Function,\n\t\t\tdefault: null\n\t\t},\n\t\tclass: {\n\t\t\ttype: String,\n\t\t\tdefault: \"drag-handle\"\n\t\t},\n\t\tnested: {\n\t\t\ttype: [Boolean, Object],\n\t\t\tdefault: false\n\t\t}\n\t},\n\tsetup(props, { slots }) {\n\t\tconst root = ref(null);\n\t\tconst pluginHandle = shallowRef(null);\n\t\tconst initPlugin = () => {\n\t\t\tconst { editor, pluginKey, onNodeChange, onElementDragEnd, onElementDragStart, computePositionConfig, nested } = props;\n\t\t\tif (!root.value) return;\n\t\t\tif (!props.editor || props.editor.isDestroyed) return;\n\t\t\troot.value.style.visibility = \"hidden\";\n\t\t\tconst nestedOptions = normalizeNestedOptions(nested);\n\t\t\tconst init = DragHandlePlugin({\n\t\t\t\teditor,\n\t\t\t\telement: root.value,\n\t\t\t\tpluginKey,\n\t\t\t\tcomputePositionConfig: {\n\t\t\t\t\t...defaultComputePositionConfig,\n\t\t\t\t\t...computePositionConfig\n\t\t\t\t},\n\t\t\t\tonNodeChange,\n\t\t\t\tonElementDragStart,\n\t\t\t\tonElementDragEnd,\n\t\t\t\tnestedOptions\n\t\t\t});\n\t\t\tpluginHandle.value = init;\n\t\t\tprops.editor.registerPlugin(init.plugin);\n\t\t};\n\t\tconst destroyPlugin = () => {\n\t\t\tvar _pluginHandle$value$u, _pluginHandle$value;\n\t\t\tif (!pluginHandle.value) return;\n\t\t\tif (props.editor && !props.editor.isDestroyed) props.editor.unregisterPlugin(props.pluginKey);\n\t\t\t(_pluginHandle$value$u = (_pluginHandle$value = pluginHandle.value).unbind) === null || _pluginHandle$value$u === void 0 || _pluginHandle$value$u.call(_pluginHandle$value);\n\t\t\tpluginHandle.value = null;\n\t\t};\n\t\tonMounted(async () => {\n\t\t\tawait nextTick();\n\t\t\tinitPlugin();\n\t\t});\n\t\twatch(() => props.nested, () => {\n\t\t\tdestroyPlugin();\n\t\t\tinitPlugin();\n\t\t}, { deep: true });\n\t\tonBeforeUnmount(() => {\n\t\t\tdestroyPlugin();\n\t\t});\n\t\treturn () => {\n\t\t\tvar _slots$default;\n\t\t\treturn h(\"div\", {\n\t\t\t\tref: root,\n\t\t\t\tclass: props.class,\n\t\t\t\tstyle: { position: \"absolute\" },\n\t\t\t\t\"data-dragging\": \"false\"\n\t\t\t}, (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots));\n\t\t};\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = DragHandle;\n//#endregion\nexport { DragHandle, src_default as default };\n\n//# sourceMappingURL=index.js.map","<template>\n  <span v-bind=\"$attrs\"\n        :aria-hidden=\"title ? null : 'true'\"\n        :aria-label=\"title\"\n        class=\"material-design-icon drag-vertical-icon\"\n        role=\"img\"\n        @click=\"$emit('click', $event)\">\n    <svg :fill=\"fillColor\"\n         class=\"material-design-icon__svg\"\n         :width=\"size\"\n         :height=\"size\"\n         viewBox=\"0 0 24 24\">\n      <path d=\"M9,3H11V5H9V3M13,3H15V5H13V3M9,7H11V9H9V7M13,7H15V9H13V7M9,11H11V13H9V11M13,11H15V13H13V11M9,15H11V17H9V15M13,15H15V17H13V15M9,19H11V21H9V19M13,19H15V21H13V19Z\">\n        <title v-if=\"title\">{{ title }}</title>\n      </path>\n    </svg>\n  </span>\n</template>\n\n<script>\nexport default {\n  name: \"DragVerticalIcon\",\n  emits: ['click'],\n  props: {\n    title: {\n      type: String,\n    },\n    fillColor: {\n      type: String,\n      default: \"currentColor\"\n    },\n    size: {\n      type: Number,\n      default: 24\n    }\n  }\n}\n</script>","<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<DragHandle\n\t\t:editor=\"editor\"\n\t\tclass=\"floating-buttons\"\n\t\t:class=\"{\n\t\t\theading: isHeadingNode,\n\t\t\thidden: isHidden,\n\t\t}\"\n\t\t:onNodeChange=\"onNodeChange\">\n\t\t<NcButton\n\t\t\tvariant=\"tertiary-no-background\"\n\t\t\tsize=\"small\"\n\t\t\t:title=\"t('text', 'Insert below')\"\n\t\t\t:aria-label=\"t('text', 'Insert below')\"\n\t\t\t@click=\"onOpenSmartPicker\">\n\t\t\t<template #icon>\n\t\t\t\t<PlusIcon :size=\"16\" />\n\t\t\t</template>\n\t\t</NcButton>\n\t\t<NcButton\n\t\t\tvariant=\"tertiary-no-background\"\n\t\t\tsize=\"small\"\n\t\t\tclass=\"drag-button\"\n\t\t\t:title=\"t('text', 'Click for options, hold to drag')\"\n\t\t\t:aria-label=\"t('text', 'Click for options, hold to drag')\">\n\t\t\t<template #icon>\n\t\t\t\t<DragVerticalIcon :size=\"16\" />\n\t\t\t</template>\n\t\t</NcButton>\n\t</DragHandle>\n</template>\n\n<script>\nimport { t } from '@nextcloud/l10n'\nimport { DragHandle } from '@tiptap/extension-drag-handle-vue-3'\nimport NcButton from '@nextcloud/vue/components/NcButton'\nimport DragVerticalIcon from 'vue-material-design-icons/DragVertical.vue'\nimport PlusIcon from 'vue-material-design-icons/Plus.vue'\nimport { useEditor } from '../../composables/useEditor.ts'\n\nconst IGNORE_NODES = ['comment', 'commentItem', 'comments', 'footnote', 'footnotes']\n\nexport default {\n\tname: 'FloatingButtons',\n\n\tcomponents: {\n\t\tDragHandle,\n\t\tDragVerticalIcon,\n\t\tNcButton,\n\t\tPlusIcon,\n\t},\n\n\tsetup() {\n\t\tconst { editor } = useEditor()\n\t\treturn { editor }\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tnode: null,\n\t\t\tpos: -1,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tisHeadingNode() {\n\t\t\treturn this.node?.type.name === 'heading'\n\t\t},\n\n\t\tisHidden() {\n\t\t\treturn IGNORE_NODES.includes(this.node?.type.name)\n\t\t},\n\t},\n\n\tmethods: {\n\t\tonNodeChange({ node, pos }) {\n\t\t\tthis.node = node\n\t\t\tthis.pos = pos\n\t\t},\n\n\t\tonOpenSmartPicker() {\n\t\t\tif (!this.node || this.pos === -1) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Node has no children or just text children and no text content\n\t\t\tconst { schema } = this.editor\n\t\t\tconst emptyNode\n\t\t\t\t= this.node.textContent.trim() === ''\n\t\t\t\t\t&& (this.node.children.length === 0\n\t\t\t\t\t\t|| this.node.children.every((n) => n.type === schema.nodes.text))\n\n\t\t\t// Insert at the end of the node\n\t\t\tconst pos = emptyNode ? this.pos + 1 : this.pos + this.node.nodeSize\n\t\t\tthis.editor.chain().insertContentAt(pos, '/').focus().run()\n\t\t},\n\n\t\tt,\n\t},\n}\n</script>\n\n<style scoped lang=\"scss\">\n.floating-buttons {\n\tdisplay: flex;\n\n\t&.heading {\n\t\tleft: calc(-34px - 14px) !important;\n\t}\n\n\t&.hidden {\n\t\tdisplay: none;\n\t}\n}\n\n.drag-button {\n\tcursor: grab;\n\n\t:deep(span),\n\t:deep(svg) {\n\t\tcursor: grab !important;\n\t}\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { InjectionKey, Ref } from 'vue'\n\nimport {\n\tcomputed,\n\tinject,\n\tnextTick,\n\tonMounted,\n\tonUnmounted,\n\tprovide,\n\treadonly,\n\tshallowRef,\n} from 'vue'\nimport { logger } from '../helpers/logger.ts'\nimport { useEditor } from './useEditor.ts'\n\nexport const intersectionObserverKey = Symbol('text:intersection_observer') as InjectionKey<IntersectionObserver>\nexport const visibleIdsKey = Symbol('text:visibile_ids') as InjectionKey<\n\tRef<Set<string>>\n>\n\nconst intersectionObserverOptions = {\n\troot: null,\n\trootMargin: '0px 0px -50% 0px',\n\tthreshold: 0,\n}\n\n/**\n *\n */\nexport function provideIntersectionObserver() {\n\t// Vue2 does not support reactive sets.\n\t// So the shallow ref needs to be explicitely written every time the set changes.\n\tconst visibleIds = shallowRef<Set<string>>(new Set())\n\tconst update: IntersectionObserverCallback = (entries) => {\n\t\tconst ids = new Set(visibleIds.value)\n\t\tentries.forEach((entry) => {\n\t\t\tif (entry.isIntersecting) {\n\t\t\t\tids.add(entry.target.id)\n\t\t\t} else {\n\t\t\t\tids.delete(entry.target.id)\n\t\t\t}\n\t\t})\n\t\tvisibleIds.value = ids\n\t}\n\n\tconst intersectionObserver = new IntersectionObserver(\n\t\tupdate,\n\t\tintersectionObserverOptions,\n\t)\n\n\tonUnmounted(() => {\n\t\tintersectionObserver.disconnect()\n\t})\n\tprovide(intersectionObserverKey, intersectionObserver)\n\tprovide(visibleIdsKey, visibleIds)\n}\n\n/**\n *\n * @param id of the html element in the viewers dom\n */\nexport function useVisibility(id: string) {\n\tconst { editor } = useEditor()\n\tconst intersectionObserver = inject(intersectionObserverKey)!\n\tconst visibleIds = inject(visibleIdsKey)!\n\tlet observedEl: Element | null = null\n\n\tonMounted(() => {\n\t\tnextTick(() => {\n\t\t\tobservedEl = editor.view.dom.querySelector(`#${id}`)\n\t\t\tif (observedEl) {\n\t\t\t\tintersectionObserver.observe(observedEl)\n\t\t\t} else {\n\t\t\t\tlogger.warn(`Could not find element with id ${id}`)\n\t\t\t}\n\t\t})\n\t})\n\n\tonUnmounted(() => {\n\t\tvisibleIds.value.delete(id)\n\t\tvisibleIds.value = new Set(visibleIds.value) // trigger reactivity\n\t\tif (observedEl) {\n\t\t\tintersectionObserver.unobserve(observedEl)\n\t\t\tobservedEl = null\n\t\t}\n\t})\n\tconst visible = computed(() => visibleIds.value.has(id))\n\treturn { visible: readonly(visible) }\n}\n","<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<li\n\t\t:data-toc-level=\"heading.level\"\n\t\tclass=\"toc-list__item\"\n\t\t:class=\"{\n\t\t\tvisible,\n\t\t\t[`level${heading.level}`]: true,\n\t\t}\">\n\t\t<a\n\t\t\t:href=\"`#${heading.id}`\"\n\t\t\tclass=\"toc-list__item-link\"\n\t\t\t@click.prevent=\"goto(heading.id)\">\n\t\t\t{{ heading.text }}\n\t\t</a>\n\t</li>\n</template>\n\n<script setup>\nimport { nextTick, toRefs } from 'vue'\nimport { useEditor } from '../../../composables/useEditor.ts'\nimport { useVisibility } from '../../../composables/useVisibility.ts'\nconst props = defineProps({ heading: { type: Object, required: true } })\nconst emit = defineEmits(['clicked'])\nconst { heading } = toRefs(props)\nconst { visible } = useVisibility(heading.value.id)\nconst { editor } = useEditor()\n\n/**\n *\n * @param {string} id attribute of elemet to go to\n */\nfunction goto(id) {\n\tconst el = editor.view.dom.querySelector(`#${id}`)\n\tel?.scrollIntoView({ block: 'start', behavior: 'smooth' })\n\tnextTick(() => {\n\t\twindow.history.replaceState(window.history.state, '', `#${id}`)\n\t})\n\temit('clicked')\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.toc-list__item {\n\tcolor: var(--color-text-lighter);\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n\tpadding-inline-start: var(--padding-inline-start);\n\n\ta {\n\t\tcolor: var(--color-text-lighter);\n\t}\n\n\t// Only effective on the first visible line - see next selector.\n\t&.visible a {\n\t\tcolor: var(--color-main-text);\n\t}\n\n\t// All following visible lines use the default style.\n\t.visible ~ &.visible a {\n\t\tcolor: var(--color-text-lighter);\n\t}\n\n\ta:hover {\n\t\tcolor: var(--color-primary-element-hover);\n\t}\n\n\t&-link {\n\t\tscroll-margin-top: calc(\n\t\t\tvar(--default-clickable-area) + 4 * var(--default-grid-baseline)\n\t\t);\n\t}\n\n\t&.level1 {\n\t\t--padding-inline-start: calc(0 * var(--level-padding));\n\t\tfont-weight: 600;\n\t\t&:not(:nth-child(1)) {\n\t\t\tmargin-top: 0.5rem;\n\t\t}\n\t}\n\n\t@for $i from 2 through 6 {\n\t\t&.level#{$i} {\n\t\t\t--padding-inline-start: calc(#{$i - 1} * var(--level-padding));\n\t\t}\n\t}\n}\n</style>\n","<!--\n  - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<ul class=\"toc-list\">\n\t\t<TableOfContentsEntry\n\t\t\tv-for=\"heading in headings\"\n\t\t\t:key=\"heading.id\"\n\t\t\t:heading=\"heading\"\n\t\t\t@clicked=\"emit('headingClicked')\" />\n\t</ul>\n</template>\n\n<script setup>\nimport TableOfContentsEntry from './TableOfContentsEntry.vue'\nimport { useEditorHeadings } from '../../../composables/useEditorHeadings.ts'\n\nconst emit = defineEmits(['headingClicked'])\nconst { headings } = useEditorHeadings()\n</script>\n\n<style lang=\"scss\" scoped>\n.toc-list {\n\twidth: 100%;\n\tlist-style: none;\n\tfont-size: 0.9rem;\n\tpadding: 0;\n\t--level-padding: 12px;\n}\n</style>\n","<template>\n  <span v-bind=\"$attrs\"\n        :aria-hidden=\"title ? null : 'true'\"\n        :aria-label=\"title\"\n        class=\"material-design-icon pin-outline-icon\"\n        role=\"img\"\n        @click=\"$emit('click', $event)\">\n    <svg :fill=\"fillColor\"\n         class=\"material-design-icon__svg\"\n         :width=\"size\"\n         :height=\"size\"\n         viewBox=\"0 0 24 24\">\n      <path d=\"M16,12V4H17V2H7V4H8V12L6,14V16H11.2V22H12.8V16H18V14L16,12M8.8,14L10,12.8V4H14V12.8L15.2,14H8.8Z\">\n        <title v-if=\"title\">{{ title }}</title>\n      </path>\n    </svg>\n  </span>\n</template>\n\n<script>\nexport default {\n  name: \"PinOutlineIcon\",\n  emits: ['click'],\n  props: {\n    title: {\n      type: String,\n    },\n    fillColor: {\n      type: String,\n      default: \"currentColor\"\n    },\n    size: {\n      type: Number,\n      default: 24\n    }\n  }\n}\n</script>","<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div\n\t\tdata-text-el=\"editor-table-of-contents\"\n\t\tclass=\"editor__toc\"\n\t\t:class=\"{ 'editor__toc-closing': isClosing }\"\n\t\t@mouseleave=\"onMouseleave\"\n\t\t@animationend=\"onAnimationend\">\n\t\t<div class=\"editor__toc-header\">\n\t\t\t<NcButton\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tsize=\"small\"\n\t\t\t\t:title=\"buttonTitle\"\n\t\t\t\t:aria-label=\"buttonTitle\"\n\t\t\t\t@click=\"onButtonClick\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<CloseIcon v-if=\"keep\" :size=\"20\" />\n\t\t\t\t\t<PinOutlineIcon v-else :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t</NcButton>\n\t\t</div>\n\t\t<slot />\n\t</div>\n</template>\n\n<script lang=\"ts\">\nimport { emit } from '@nextcloud/event-bus'\nimport { t } from '@nextcloud/l10n'\nimport { defineComponent } from 'vue'\nimport NcButton from '@nextcloud/vue/components/NcButton'\nimport CloseIcon from 'vue-material-design-icons/Close.vue'\nimport PinOutlineIcon from 'vue-material-design-icons/PinOutline.vue'\nimport { useFileProps } from '../../../composables/useFileProps.ts'\n\nexport default defineComponent({\n\tname: 'TocDesktop',\n\tcomponents: {\n\t\tCloseIcon,\n\t\tPinOutlineIcon,\n\t\tNcButton,\n\t},\n\n\temits: ['close'],\n\n\tsetup() {\n\t\tconst { fileId } = useFileProps()\n\t\treturn { fileId }\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tkeep: false,\n\t\t\tisClosing: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tbuttonTitle() {\n\t\t\treturn this.keep\n\t\t\t\t? t('text', 'Close table of contents')\n\t\t\t\t: t('text', 'Pin table of contents')\n\t\t},\n\t},\n\n\tmethods: {\n\t\tonMouseleave() {\n\t\t\tif (!this.keep) {\n\t\t\t\tthis.close()\n\t\t\t}\n\t\t},\n\n\t\tonAnimationend(event: { animationName: string }) {\n\t\t\tif (event.animationName === 'fadeOutRight' && this.isClosing) {\n\t\t\t\tthis.isClosing = false\n\t\t\t\tthis.$emit('close')\n\t\t\t}\n\t\t},\n\n\t\tonButtonClick() {\n\t\t\tif (this.keep) {\n\t\t\t\tthis.keep = false\n\t\t\t\tthis.close()\n\t\t\t} else {\n\t\t\t\tthis.keep = true\n\t\t\t}\n\n\t\t\tif (this.fileId) {\n\t\t\t\temit('text:toc:pin', { fileId: this.fileId, keep: this.keep })\n\t\t\t}\n\t\t},\n\n\t\tclose() {\n\t\t\tthis.isClosing = true\n\t\t},\n\n\t\tt,\n\t},\n})\n</script>\n\n<style lang=\"scss\" scoped>\n.editor__toc {\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow-y: auto;\n\tanimation-name: fadeInRight;\n\tanimation-duration: var(--animation-slow);\n\n\tpadding: 12px;\n\tpadding-bottom: 24px;\n\twidth: 200px;\n\t// TODO: better max height\n\tmax-height: calc(100vh * 0.66);\n\tbackground-color: var(--color-main-background);\n\tborder: 2px solid var(--color-border);\n\tborder-radius: var(--border-radius-large);\n\n\t&-closing {\n\t\tanimation-name: fadeOutRight;\n\t}\n\n\t&-header {\n\t\tposition: sticky;\n\t\ttop: 0;\n\t\twidth: 100%;\n\t\tdisplay: flex;\n\t\tjustify-content: end;\n\t}\n}\n</style>\n","<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<NcModal\n\t\tsize=\"full\"\n\t\t:name=\"t('collectives', 'Table of contents')\"\n\t\t@close=\"$emit('close')\">\n\t\t<slot />\n\t</NcModal>\n</template>\n\n<script lang=\"ts\">\nimport { t } from '@nextcloud/l10n'\nimport { defineComponent } from 'vue'\nimport NcModal from '@nextcloud/vue/components/NcModal'\n\nexport default defineComponent({\n\tname: 'TocMobile',\n\tcomponents: {\n\t\tNcModal,\n\t},\n\n\temits: ['close'],\n\n\tmethods: {\n\t\tt,\n\t},\n})\n</script>\n\n<style lang=\"scss\" scoped>\n:deep(.modal-container__content) {\n\tpadding-block: 12px 0;\n\tpadding-inline: 12px 0;\n}\n</style>\n","<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div class=\"outline-line\" :class=\"[`level${heading.level}`, { visible }]\" />\n</template>\n\n<script setup>\nimport { toRefs } from 'vue'\nimport { useVisibility } from '../../../composables/useVisibility.ts'\nconst props = defineProps({ heading: { type: Object, required: true } })\nconst { heading } = toRefs(props)\nconst { visible } = useVisibility(heading.value.id)\n</script>\n","<!--\n  - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<a\n\t\tdata-text-el=\"editor-outline\"\n\t\tclass=\"editor__toc-outline\"\n\t\t@mouseenter=\"$emit('showToc')\"\n\t\t@click=\"$emit('showToc')\"\n\t\t@keydown.enter=\"$emit('showToc')\">\n\t\t<TocOutlineEntry\n\t\t\tv-for=\"heading in headings\"\n\t\t\t:key=\"heading.id\"\n\t\t\t:heading=\"heading\" />\n\t</a>\n</template>\n\n<script setup lang=\"ts\">\nimport TocOutlineEntry from './TocOutlineEntry.vue'\nimport { useEditorHeadings } from '../../../composables/useEditorHeadings.ts'\n\ndefineEmits<{ showToc: [] }>()\n\nconst { headings } = useEditorHeadings()\n</script>\n\n<style lang=\"scss\" scoped>\n.editor__toc-outline {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding-bottom: 12px;\n}\n\n.outline-line {\n\tbackground-color: var(--color-text-lighter);\n\theight: 2px;\n\twidth: 24px;\n\tborder-radius: 2px;\n\tmargin-inline-start: 0;\n\ttransition:\n\t\tbackground 0.2s,\n\t\tbox-shadow 0.2s;\n\n\t// only effective on the first line - see next selector\n\t&.visible {\n\t\tbackground-color: var(--color-main-text);\n\t\tbox-shadow: 0 0 3px var(--color-box-shadow);\n\t}\n\n\t// all following lines have the default style\n\t.visible ~ &.visible {\n\t\tbackground-color: var(--color-text-lighter);\n\t\tbox-shadow: none;\n\t}\n\n\t&.level2 {\n\t\twidth: 20px;\n\t\tmargin-inline-start: 4px;\n\t}\n\t&.level3 {\n\t\twidth: 16px;\n\t\tmargin-inline-start: 8px;\n\t}\n\t&.level4 {\n\t\twidth: 12px;\n\t\tmargin-inline-start: 12px;\n\t}\n\t&.level5 {\n\t\twidth: 8px;\n\t\tmargin-inline-start: 16px;\n\t}\n\t&.level6 {\n\t\twidth: 4px;\n\t\tmargin-inline-start: 20px;\n\t}\n}\n</style>\n","<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div class=\"editor__toc-container\">\n\t\t<!-- desktop -->\n\t\t<div v-if=\"!isMobile\" class=\"editor__toc-content\">\n\t\t\t<TocOutline\n\t\t\t\tv-if=\"!displayToc && headings.length > 1\"\n\t\t\t\t@showToc=\"setDisplayToc(true)\" />\n\t\t\t<TocDesktop v-else-if=\"displayToc\" @close=\"setDisplayToc(false)\">\n\t\t\t\t<TableOfContents />\n\t\t\t</TocDesktop>\n\t\t</div>\n\n\t\t<!-- mobile -->\n\t\t<TocMobile v-else-if=\"isMobile && displayToc\" @close=\"setDisplayToc(false)\">\n\t\t\t<TableOfContents\n\t\t\t\t:showClose=\"false\"\n\t\t\t\t@headingClicked=\"setDisplayToc(false)\" />\n\t\t</TocMobile>\n\t</div>\n</template>\n\n<script setup>\nimport { emit } from '@nextcloud/event-bus'\nimport { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'\nimport TableOfContents from './TableOfContents.vue'\nimport TocDesktop from './TocDesktop.vue'\nimport TocMobile from './TocMobile.vue'\nimport TocOutline from './TocOutline.vue'\nimport { useEditorHeadings } from '../../../composables/useEditorHeadings.ts'\nimport { provideIntersectionObserver } from '../../../composables/useVisibility.ts'\n\nprovideIntersectionObserver()\nconst { displayToc, headings } = useEditorHeadings()\nconst isMobile = useIsMobile()\n/**\n *\n * @param {boolean} visible - desired visibility\n */\nfunction setDisplayToc(visible) {\n\temit('text:toc:toggle', { visible })\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.editor__toc-container {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-end: 0;\n\tmax-width: 40px;\n\twidth: 40px;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: flex-end;\n}\n\n.editor__toc-content {\n\tposition: sticky;\n\t// Toolbar height + 34px\n\ttop: calc(var(--default-clickable-area) + 9px + 34px);\n\tmargin-top: calc(var(--default-clickable-area) + 9px + 34px);\n\tmargin-inline-end: 12px;\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { Editor } from '@tiptap/core'\n\nimport { onBeforeUnmount, ref } from 'vue'\n\n/**\n * @param editor the Tiptap editor object\n */\nexport function useAnnotationsHidden(editor: Editor) {\n\tconst hidden = ref(editor.storage.annotationsVisibility?.hidden || false)\n\tconst update = () => {\n\t\thidden.value = editor.storage.annotationsVisibility?.hidden || false\n\t}\n\teditor.on('transaction', update)\n\tonBeforeUnmount(() => editor.off('transaction', update))\n\treturn hidden\n}\n","<!--\n  - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div\n\t\tdata-text-el=\"editor-content-wrapper\"\n\t\tclass=\"editor__content-wrapper\"\n\t\t:class=\"{ 'editor--annotations-hidden': annotationsHidden }\">\n\t\t<slot />\n\t\t<FloatingButtons v-if=\"showFloatingButtons\" />\n\t\t<EditorContent\n\t\t\trole=\"document\"\n\t\t\tclass=\"editor__content text-editor__content\"\n\t\t\t:editor=\"editor\" />\n\t\t<TocContainer v-if=\"hasTableOfContents\" />\n\t</div>\n</template>\n\n<script>\nimport { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'\nimport { EditorContent } from '@tiptap/vue-3'\nimport FloatingButtons from './FloatingButtons.vue'\nimport TocContainer from './TableOfContents/TocContainer.vue'\nimport { useAnnotationsHidden } from '../../composables/useAnnotationsHidden.ts'\nimport { useEditor } from '../../composables/useEditor.ts'\nimport { useEditorFlags } from '../../composables/useEditorFlags.ts'\n\nexport default {\n\tname: 'ContentContainer',\n\tcomponents: {\n\t\tEditorContent,\n\t\tFloatingButtons,\n\t\tTocContainer,\n\t},\n\n\tprops: {\n\t\treadOnly: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t},\n\t},\n\n\tsetup() {\n\t\tconst isMobile = useIsMobile()\n\t\tconst { editor } = useEditor()\n\t\tconst { isRichEditor, isRichWorkspace, hasTableOfContents }\n\t\t\t= useEditorFlags()\n\t\tconst annotationsHidden = useAnnotationsHidden(editor)\n\t\treturn {\n\t\t\tannotationsHidden,\n\t\t\teditor,\n\t\t\tisMobile,\n\t\t\tisRichEditor,\n\t\t\tisRichWorkspace,\n\t\t\thasTableOfContents,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tshowFloatingButtons() {\n\t\t\treturn (\n\t\t\t\t!this.readOnly\n\t\t\t\t&& !this.isMobile\n\t\t\t\t&& this.isRichEditor\n\t\t\t\t&& !this.isRichWorkspace\n\t\t\t)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped lang=\"scss\">\n.editor__content-wrapper {\n\tdisplay: flex;\n\tflex-grow: 1;\n}\n\n.editor__content {\n\tflex-grow: 1;\n\tmax-width: var(--text-editor-max-width);\n\tmargin: 0 auto;\n\tposition: relative;\n\t:deep([contenteditable]) {\n\t\t// drop off obsolete server styles\n\t\tmargin: 0 !important;\n\t}\n}\n</style>\n","<!--\n  - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div\n\t\tclass=\"text-editor__wrapper\"\n\t\t:class=\"{\n\t\t\t'has-conflicts': isResolvingConflict,\n\t\t\t'is-rich-workspace': isRichWorkspace,\n\t\t\t'is-rich-editor': isRichEditor,\n\t\t}\">\n\t\t<slot />\n\t</div>\n</template>\n\n<script>\nimport { useEditorFlags } from '../../composables/useEditorFlags.ts'\nimport { READ_ONLY_ACTIONS } from './EditorWrapper.provider.js'\n\nexport default {\n\tname: 'EditorWrapper',\n\tprovide() {\n\t\tconst val = {}\n\n\t\tObject.defineProperties(val, {\n\t\t\t[READ_ONLY_ACTIONS]: {\n\t\t\t\tget: () => ({\n\t\t\t\t\ttoggle: this.readOnlyToggle,\n\t\t\t\t}),\n\t\t\t},\n\t\t})\n\n\t\treturn val\n\t},\n\n\tprops: {\n\t\tisResolvingConflict: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\t},\n\n\temits: ['readOnlyToggled'],\n\n\tsetup() {\n\t\tconst { isRichEditor, isRichWorkspace } = useEditorFlags()\n\t\treturn { isRichEditor, isRichWorkspace }\n\t},\n\n\tmethods: {\n\t\treadOnlyToggle() {\n\t\t\tthis.$emit('readOnlyToggled')\n\t\t},\n\t},\n}\n</script>\n\n<style scoped lang=\"scss\">\n.text-editor__wrapper {\n\tdisplay: flex;\n\tflex-grow: 1;\n\n\twidth: 100%;\n\n\t.ProseMirror {\n\t\tmargin-top: 0 !important;\n\t}\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { ShallowRef } from 'vue'\nimport type { Connection } from '../composables/useConnection.ts'\n\nimport axios from '@nextcloud/axios'\nimport { generateUrl } from '@nextcloud/router'\nimport { unref } from 'vue'\n\n/**\n * Upload an attachment to the server.\n *\n * @param connection the active connection.\n * @param file upload this file.\n */\nexport function uploadAttachment(\n\tconnection: ShallowRef<Connection> | Connection,\n\tfile: string | Blob,\n) {\n\tconst {\n\t\tdocumentId,\n\t\tsessionId,\n\t\tsessionToken,\n\t\tshareToken: token,\n\t} = unref(connection)\n\tconst formData = new FormData()\n\tformData.append('file', file)\n\tconst url = generateUrl('apps/text/attachment/upload?')\n\treturn axios.post(url, formData, {\n\t\theaders: { 'Content-Type': 'multipart/form-data' },\n\t\tparams: { documentId, sessionId, sessionToken, token },\n\t})\n}\n\n/**\n * Create a new attachment based on the given template\n *\n * @param connection the active connection\n * @param template create the attachment based on this\n * @param template.app app to create the attachment with\n * @param template.extension extension to use\n */\nexport function createAttachment(\n\tconnection: ShallowRef<Connection> | Connection,\n\ttemplate: { app: string, extension: string },\n) {\n\tconst { documentId, sessionId, sessionToken } = unref(connection)\n\tconst url = generateUrl('apps/text/attachment/create')\n\treturn axios.post(url, {\n\t\tdocumentId,\n\t\tsessionId,\n\t\tsessionToken,\n\t\tfileName: `${template.app}${template.extension}`,\n\t})\n}\n\n/**\n * Create a new attachment based on the given template\n *\n * @param connection the active connection\n * @param filePath path to the file on the server.\n */\nexport function insertAttachmentFile(\n\tconnection: ShallowRef<Connection> | Connection,\n\tfilePath: string,\n) {\n\tconst { documentId, sessionId, sessionToken } = unref(connection)\n\tconst url = generateUrl('apps/text/attachment/filepath')\n\treturn axios.post(url, {\n\t\tdocumentId,\n\t\tsessionId,\n\t\tsessionToken,\n\t\tfilePath,\n\t})\n}\n","<!--\n  - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div\n\t\tclass=\"editor editor-media-handler\"\n\t\tdata-text-el=\"editor-media-handler\"\n\t\t:class=\"{ draggedOver, 'is-mobile': isMobile }\"\n\t\t@image-paste=\"onPaste\"\n\t\t@dragover.prevent.stop=\"setDraggedOver(true, $event)\"\n\t\t@dragleave.prevent.stop=\"setDraggedOver(false, $event)\"\n\t\t@drop.prevent.stop=\"setDraggedOver(false, $event)\"\n\t\t@file-drop=\"onEditorDrop\">\n\t\t<input\n\t\t\tv-show=\"false\"\n\t\t\tref=\"attachmentFileInput\"\n\t\t\tdata-text-el=\"attachment-file-input\"\n\t\t\ttype=\"file\"\n\t\t\taccept=\"*/*\"\n\t\t\tmultiple\n\t\t\t@change=\"onAttachmentUploadFilePicked\">\n\t\t<slot />\n\t</div>\n</template>\n\n<script>\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { showError } from '@nextcloud/dialogs'\nimport { emit } from '@nextcloud/event-bus'\nimport { generateUrl } from '@nextcloud/router'\nimport { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'\nimport { ref } from 'vue'\nimport {\n\tcreateAttachment,\n\tinsertAttachmentFile,\n\tuploadAttachment,\n} from '../../apis/attach.ts'\nimport { useConnection } from '../../composables/useConnection.ts'\nimport { useEditor } from '../../composables/useEditor.ts'\nimport { useFileProps } from '../../composables/useFileProps.ts'\nimport { buildFilePicker } from '../../helpers/filePicker.js'\nimport { logger } from '../../helpers/logger.ts'\nimport {\n\tACTION_ATTACHMENT_PROMPT,\n\tACTION_CHOOSE_LOCAL_ATTACHMENT,\n\tACTION_CREATE_ATTACHMENT,\n\tSTATE_UPLOADING,\n} from './MediaHandler.provider.js'\n\nconst getDir = (val) => val.split('/').slice(0, -1).join('/')\n\nexport default {\n\tname: 'MediaHandler',\n\tprovide() {\n\t\tconst val = {}\n\n\t\tObject.defineProperties(val, {\n\t\t\t[ACTION_ATTACHMENT_PROMPT]: {\n\t\t\t\tget: () => this.showAttachmentPrompt,\n\t\t\t},\n\t\t\t[ACTION_CHOOSE_LOCAL_ATTACHMENT]: {\n\t\t\t\tget: () => this.chooseLocalFile,\n\t\t\t},\n\t\t\t[ACTION_CREATE_ATTACHMENT]: {\n\t\t\t\tget: () => this.createAttachment,\n\t\t\t},\n\t\t\t[STATE_UPLOADING]: {\n\t\t\t\tget: () => this.state,\n\t\t\t},\n\t\t})\n\n\t\treturn val\n\t},\n\n\tsetup() {\n\t\tconst { connection } = useConnection()\n\t\tconst isMobile = useIsMobile()\n\t\tconst { editor } = useEditor()\n\t\tconst { relativePath } = useFileProps()\n\t\tconst parentPath = (relativePath ?? '/').split('/').slice(0, -1).join('/')\n\t\tconst startPath = ref(parentPath)\n\t\treturn {\n\t\t\tconnection,\n\t\t\teditor,\n\t\t\tisMobile,\n\t\t\tstartPath,\n\t\t}\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tdraggedOver: false,\n\t\t\t// make it reactive to be used inject/provide\n\t\t\tstate: {\n\t\t\t\tisUploadingAttachments: false,\n\t\t\t},\n\t\t}\n\t},\n\n\tmethods: {\n\t\tsetDraggedOver(val, event) {\n\t\t\tif (event.dataTransfer.types.includes('Files')) {\n\t\t\t\tthis.draggedOver = val\n\t\t\t}\n\t\t},\n\n\t\tonPaste(e) {\n\t\t\tthis.uploadAttachmentFiles(e.detail.files)\n\t\t},\n\n\t\tonEditorDrop(e) {\n\t\t\tthis.uploadAttachmentFiles(e.detail.files, e.detail.position)\n\t\t},\n\n\t\tonAttachmentUploadFilePicked(event) {\n\t\t\tthis.uploadAttachmentFiles(event.target.files)\n\t\t\t// Clear input to ensure that the change event will be emitted if\n\t\t\t// the same file is picked again.\n\t\t\tevent.target.value = ''\n\t\t},\n\n\t\tchooseLocalFile() {\n\t\t\tthis.$refs.attachmentFileInput.click()\n\t\t},\n\n\t\tasync uploadAttachmentFiles(files, position = null) {\n\t\t\tif (!files) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.state.isUploadingAttachments = true\n\n\t\t\tconst uploadPromises = [...files].map((file) => {\n\t\t\t\treturn this.uploadAttachmentFile(file, position)\n\t\t\t})\n\n\t\t\treturn Promise.all(uploadPromises)\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tlogger.error('Uploading multiple attachments failed', { error })\n\t\t\t\t\tshowError(t('text', 'Uploading multiple attachments failed.'))\n\t\t\t\t})\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.state.isUploadingAttachments = false\n\t\t\t\t})\n\t\t},\n\n\t\tasync uploadAttachmentFile(file, position = null) {\n\t\t\tthis.state.isUploadingAttachments = true\n\n\t\t\treturn uploadAttachment(this.connection, file)\n\t\t\t\t.then((response) => {\n\t\t\t\t\tthis.insertAttachment(\n\t\t\t\t\t\tresponse.data?.name,\n\t\t\t\t\t\tresponse.data?.id,\n\t\t\t\t\t\tfile.type,\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\tresponse.data?.dirname,\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tlogger.error('Uploading attachment failed', { error })\n\t\t\t\t\tif (error.response?.data.error) {\n\t\t\t\t\t\tshowError(t('text', 'Uploading attachment failed: {error}', {\n\t\t\t\t\t\t\terror: error.response.data.error,\n\t\t\t\t\t\t}))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tshowError(t('text', 'Uploading attachment failed.'))\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.state.isUploadingAttachments = false\n\t\t\t\t})\n\t\t},\n\n\t\tasync showAttachmentPrompt() {\n\t\t\tconst currentUser = getCurrentUser()\n\t\t\tif (!currentUser) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlet filePath\n\t\t\ttry {\n\t\t\t\tconst filePicker = buildFilePicker(this.startPath, false)\n\t\t\t\tfilePath = await filePicker.pick()\n\t\t\t} catch {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (filePath) {\n\t\t\t\tthis.insertFromPath(filePath)\n\t\t\t}\n\t\t},\n\n\t\tinsertFromPath(filePath) {\n\t\t\tthis.startPath = getDir(filePath)\n\n\t\t\tthis.state.isUploadingAttachments = true\n\n\t\t\treturn insertAttachmentFile(this.connection, filePath)\n\t\t\t\t.then((response) => {\n\t\t\t\t\tthis.insertAttachment(\n\t\t\t\t\t\tresponse.data?.name,\n\t\t\t\t\t\tresponse.data?.id,\n\t\t\t\t\t\tresponse.data?.mimetype,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tresponse.data?.dirname,\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tlogger.error('Failed to insert from Files', { error })\n\t\t\t\t\tshowError(t('text', 'Failed to insert from Files'))\n\t\t\t\t})\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.state.isUploadingAttachments = false\n\t\t\t\t})\n\t\t},\n\n\t\tcreateAttachment(template) {\n\t\t\tthis.state.isUploadingAttachments = true\n\t\t\treturn createAttachment(this.connection, template)\n\t\t\t\t.then((response) => {\n\t\t\t\t\tthis.insertAttachmentPreview(response.data?.id)\n\t\t\t\t\temit('text:image-node:add', null)\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tlogger.error('Failed to create attachment', { error })\n\t\t\t\t\tshowError(t('text', 'Failed to create attachment'))\n\t\t\t\t})\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.state.isUploadingAttachments = false\n\t\t\t\t})\n\t\t},\n\n\t\tinsertAttachmentPreview(fileId) {\n\t\t\tconst url = new URL(generateUrl(`/f/${fileId}`), window.origin)\n\t\t\tconst href = url.href.replaceAll(' ', '%20')\n\t\t\tthis.editor.chain().focus().insertPreview(href).run()\n\t\t},\n\n\t\tinsertAttachment(name, fileId, mimeType, position = null, dirname = '') {\n\t\t\tconst sanitizedName = name.replace(\n\t\t\t\t/[\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069]/g,\n\t\t\t\t'',\n\t\t\t)\n\t\t\t// inspired by the fixedEncodeURIComponent function suggested in\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent\n\t\t\tconst src\n\t\t\t\t= dirname\n\t\t\t\t\t+ '/'\n\t\t\t\t\t+ encodeURIComponent(sanitizedName).replace(/[!'()*]/g, (c) => {\n\t\t\t\t\t\treturn '%' + c.charCodeAt(0).toString(16).toUpperCase()\n\t\t\t\t\t})\n\t\t\t// simply get rid of brackets to make sure link text is valid\n\t\t\t// as it does not need to be unique and matching the real file name\n\t\t\tconst alt = sanitizedName.replaceAll(/[[\\]]/g, '')\n\n\t\t\tconst chain = position\n\t\t\t\t? this.editor.chain().focus(position)\n\t\t\t\t: this.editor.chain()\n\n\t\t\tchain.setImage({ src, alt }).run()\n\n\t\t\tconst selection = this.editor.view.state.selection\n\t\t\tif (!selection.empty) {\n\t\t\t\t// If inserted image is first element, it is selected and would get overwritten by\n\t\t\t\t// subsequent editor inserts (see tiptap#3355). So unselect the image by placing\n\t\t\t\t// the cursor at the end of the selection.\n\t\t\t\tthis.editor.commands.focus(selection.to)\n\t\t\t}\n\n\t\t\t// Scroll image into view\n\t\t\tthis.editor.commands.scrollIntoView()\n\n\t\t\t// Store last inserted attachment src to focus it in ImageView.vue\n\t\t\tthis.editor.commands.setMeta('insertedAttachmentSrc', { src })\n\n\t\t\temit('text:image-node:add', null)\n\t\t},\n\t},\n}\n</script>\n","<!--\n  - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div class=\"editor\">\n\t\t<MediaHandler v-if=\"$editorUpload\" class=\"text-editor__main\">\n\t\t\t<slot />\n\t\t</MediaHandler>\n\t\t<slot v-else />\n\t</div>\n</template>\n\n<script>\nimport MediaHandler from './MediaHandler.vue'\nimport { useEditorUpload } from '../Editor.provider.ts'\n\nexport default {\n\tname: 'MainContainer',\n\tcomponents: {\n\t\tMediaHandler,\n\t},\n\n\tmixins: [useEditorUpload],\n}\n</script>\n\n<style scoped lang=\"scss\">\n.text-editor__main,\n.editor {\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex-grow: 1;\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n\tbackground-clip: padding-box;\n\tborder-radius: var(--border-radius);\n\tpadding: 0;\n\tposition: relative;\n\twidth: 100%;\n}\n\n.text-editor__main {\n\t&.is-mobile {\n\t\tflex-grow: 1;\n\t\tflex-direction: column-reverse;\n\t}\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\n/*\n * Handle the state of the full editor width toggle.\n *\n * If the css variable `--text-editor-max-width` is already set\n * for `document.body` it will be left as is and\n * no toggle will be shown in the text ui.\n * This way the collectives app handles it's per document width setting.\n *\n * Otherwise this composable handles the `is_full_width_editor` initial state.\n * It sets the css variable on the document accordingly.\n * The state is stored in a singleton to preserve and reuse it on the next mount.\n * It is persisted in the user settings across page reloads.\n *\n */\n\nimport type { InjectionKey, Ref } from 'vue'\n\nimport axios from '@nextcloud/axios'\nimport { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'\nimport { loadState } from '@nextcloud/initial-state'\nimport { generateUrl } from '@nextcloud/router'\nimport { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'\nimport { computed, inject, onUnmounted, provide, readonly, ref, watch } from 'vue'\nimport { useEditorFlags } from './useEditorFlags.ts'\n\n// Keep the current value around when leaving the editor and reopening\nlet valueSingleton = loadState('text', 'is_full_width_editor', false)\n\n// This is either the reactive value of the editor width toggle\n// or null if the width has already been set outside of text.\nexport const editorWidthKey = Symbol('text:editor:width') as InjectionKey<\n\tReadonly<Ref<boolean> | null>\n>\n\n// desktop: leave space for floating buttons and outline (2 * 40px) if necessary\n// wide screen: 80ch content, narrow screen: full width\nconst editorWidthDesktop = 'min(80ch, 100%)'\nconst editorWidthDesktopEnhanced = 'min(80ch, (100% - 2 * 40px))'\nconst fullEditorWidthDesktop = '100%'\nconst fullEditorWidthDesktopEnhanced = 'calc(100% - 2 * 40px)'\nconst editorWidthMobile = 'min(80ch, 100%)'\nconst fullEditorWidthMobile = '100%'\n\n/**\n * Detect if other apps (such as collectives) already configured texts max width.\n *\n * Check if document.body has a css variable `--text-editor-max-width` (either set or inherited).\n * Get the value set by text in the documentElement style.\n * If both values are set and match we assume text is handling the width.\n */\nfunction maxWidthSetOutsideOfText() {\n\tconst alreadySet = getComputedStyle(document.body).getPropertyValue('--text-editor-max-width')\n\tconst setByText = document.documentElement.style.getPropertyValue('--text-editor-max-width')\n\treturn Boolean(alreadySet) && alreadySet !== setByText\n}\n\n/**\n *\n * @param hasTableOfContents does the editor have a table of contents\n */\nexport function provideEditorWidth(hasTableOfContents = true) {\n\tconst isMobile = useIsMobile()\n\t// keep style that is already set - for example by collectives\n\tif (maxWidthSetOutsideOfText()) {\n\t\tprovide(editorWidthKey, null)\n\t\treturn { applyEditorWidth: () => {} }\n\t}\n\tconst isFullWidth = ref(valueSingleton)\n\tprovide(editorWidthKey, readonly(isFullWidth))\n\tconst onFullWidth = ({ value }: { value: boolean }) => {\n\t\tvalueSingleton = value\n\t\tisFullWidth.value = value\n\t}\n\tsubscribe('text:editor:full-width', onFullWidth)\n\tonUnmounted(() => {\n\t\tunsubscribe('text:editor:full-width', onFullWidth)\n\t})\n\tconst defaultEditorWidthDesktop = hasTableOfContents\n\t\t? editorWidthDesktopEnhanced\n\t\t: editorWidthDesktop\n\tconst defaultFullEditorWidthDesktop = hasTableOfContents\n\t\t? fullEditorWidthDesktopEnhanced\n\t\t: fullEditorWidthDesktop\n\tconst defaultEditorWidth = computed(() => isMobile.value ? editorWidthMobile : defaultEditorWidthDesktop)\n\tconst fullEditorWidth = computed(() => isMobile.value ? fullEditorWidthMobile : defaultFullEditorWidthDesktop)\n\tconst width = computed(() => isFullWidth.value ? fullEditorWidth.value : defaultEditorWidth.value)\n\tconst applyEditorWidth = () => {\n\t\tdocument.documentElement.style.setProperty(\n\t\t\t'--text-editor-max-width',\n\t\t\twidth.value,\n\t\t)\n\t}\n\twatch(width, applyEditorWidth)\n\treturn { applyEditorWidth }\n}\n\n/**\n *\n */\nexport function useEditorWidth() {\n\tconst isMobile = useIsMobile()\n\tconst { isRichWorkspace } = useEditorFlags()\n\n\t// This will be null if the width is already configured outside of text.\n\tconst isFullWidth = inject(editorWidthKey)\n\n\t// Disable if `editorWidthKey` got `null` injected or if in rich workspace or mobile view\n\tif (isFullWidth === null || isRichWorkspace || isMobile.value) {\n\t\treturn { canToggleWidth: false }\n\t}\n\tconst setFullWidth = (checked: boolean) => {\n\t\taxios.post(generateUrl('/apps/text/settings'), {\n\t\t\tkey: 'is_full_width_editor',\n\t\t\tvalue: checked ? '1' : '0',\n\t\t})\n\t\temit('text:editor:full-width', { value: checked })\n\t}\n\treturn { canToggleWidth: true, isFullWidth, setFullWidth }\n}\n","import { Extension } from \"@tiptap/core\";\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport { defaultSelectionBuilder, yCursorPlugin } from \"@tiptap/y-tiptap\";\n//#region src/collaboration-caret.ts\nconst awarenessStatesToArray = (states) => {\n\treturn Array.from(states.entries()).map(([key, value]) => {\n\t\tif (value && value.user) return {\n\t\t\tclientId: key,\n\t\t\t...value.user\n\t\t};\n\t\treturn { clientId: key };\n\t});\n};\nconst defaultOnUpdate = () => null;\n/**\n* This extension allows you to add collaboration carets to your editor.\n* @see https://tiptap.dev/api/extensions/collaboration-caret\n*/\nconst CollaborationCaret = Extension.create({\n\tname: \"collaborationCaret\",\n\tpriority: 999,\n\taddOptions() {\n\t\treturn {\n\t\t\tprovider: null,\n\t\t\tuser: {\n\t\t\t\tname: null,\n\t\t\t\tcolor: null\n\t\t\t},\n\t\t\trender: (user) => {\n\t\t\t\tconst cursor = document.createElement(\"span\");\n\t\t\t\tcursor.classList.add(\"collaboration-carets__caret\");\n\t\t\t\tcursor.setAttribute(\"style\", `border-color: ${user.color}`);\n\t\t\t\tconst label = document.createElement(\"div\");\n\t\t\t\tlabel.classList.add(\"collaboration-carets__label\");\n\t\t\t\tlabel.setAttribute(\"style\", `background-color: ${user.color}`);\n\t\t\t\tlabel.insertBefore(document.createTextNode(user.name), null);\n\t\t\t\tcursor.insertBefore(label, null);\n\t\t\t\treturn cursor;\n\t\t\t},\n\t\t\tselectionRender: defaultSelectionBuilder,\n\t\t\tonUpdate: defaultOnUpdate\n\t\t};\n\t},\n\tonCreate() {\n\t\tif (this.options.onUpdate !== defaultOnUpdate) console.warn(\"[tiptap warn]: DEPRECATED: The \\\"onUpdate\\\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\");\n\t\tif (!this.options.provider) throw new Error(\"The \\\"provider\\\" option is required for the CollaborationCaret extension\");\n\t},\n\taddStorage() {\n\t\treturn { users: [] };\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tupdateUser: (attributes) => () => {\n\t\t\t\tthis.options.provider.awareness.setLocalStateField(\"user\", attributes);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tuser: (attributes) => ({ editor }) => {\n\t\t\t\tconsole.warn(\"[tiptap warn]: DEPRECATED: The \\\"user\\\" command is deprecated. Please use \\\"updateUser\\\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\");\n\t\t\t\treturn editor.commands.updateUser(attributes);\n\t\t\t}\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst { provider } = this.options;\n\t\tconst storage = this.storage;\n\t\tconst user = this.options.user;\n\t\treturn [new Plugin({\n\t\t\tkey: new PluginKey(\"collaborationCaretAwarenessListener\"),\n\t\t\tview: () => {\n\t\t\t\tconst onAwarenessUpdate = () => {\n\t\t\t\t\tstorage.users = awarenessStatesToArray(provider.awareness.states);\n\t\t\t\t};\n\t\t\t\tprovider.awareness.setLocalStateField(\"user\", user);\n\t\t\t\tstorage.users = awarenessStatesToArray(provider.awareness.states);\n\t\t\t\tprovider.awareness.on(\"update\", onAwarenessUpdate);\n\t\t\t\treturn { destroy: () => {\n\t\t\t\t\tprovider.awareness.off(\"update\", onAwarenessUpdate);\n\t\t\t\t\tstorage.users = [];\n\t\t\t\t} };\n\t\t\t}\n\t\t}), yCursorPlugin(provider.awareness, {\n\t\t\tcursorBuilder: this.options.render,\n\t\t\tselectionBuilder: this.options.selectionRender\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = CollaborationCaret;\n//#endregion\nexport { CollaborationCaret, src_default as default };\n\n//# sourceMappingURL=index.js.map","/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { t } from '@nextcloud/l10n'\nimport { CollaborationCaret as TiptapCollaborationCaret } from '@tiptap/extension-collaboration-caret'\nimport { yCursorPlugin } from '@tiptap/y-tiptap'\n\nexport interface AwarenessUser {\n\tcolor: string\n\tname: string\n}\n\n/**\n * @param clientId The Yjs client ID\n */\nfunction showCaretLabel(clientId: number) {\n\tsetTimeout(() => {\n\t\tconst el = document.getElementById(`collaboration-carets__label__${clientId}`)\n\t\tif (!el) {\n\t\t\treturn\n\t\t}\n\n\t\tel.classList.add('collaboration-carets__label__active')\n\t\tsetTimeout(() => {\n\t\t\tel?.classList.remove('collaboration-carets__label__active')\n\t\t}, 50)\n\t}, 50)\n}\n\n/**\n * Unix timestamp in seconds.\n */\nfunction getTimestamp() {\n\treturn Math.floor(Date.now() / 1000)\n}\n\n/**\n * Render the caret decoration\n *\n * @param user the users awareness data\n * @param clientId not part of the tiptap type signature but provided by y-prosemirror\n */\nfunction render(user: AwarenessUser, clientId?: number): HTMLElement {\n\tconst cursor = document.createElement('span')\n\n\tcursor.classList.add('collaboration-carets__caret')\n\tcursor.setAttribute('style', `border-color: ${user.color}`)\n\n\tconst label = document.createElement('div')\n\tlabel.id = `collaboration-carets__label__${clientId}`\n\n\tlabel.classList.add('collaboration-carets__label')\n\tlabel.setAttribute('style', `background-color: ${user.color}`)\n\tconst text = document.createTextNode(user.name || t('text', 'Guest'))\n\tlabel.insertBefore(text, null)\n\tcursor.insertBefore(label, null)\n\n\treturn cursor\n}\n\nconst CollaborationCaret = TiptapCollaborationCaret.extend({\n\taddOptions() {\n\t\treturn {\n\t\t\t...this.parent?.(),\n\t\t\trender,\n\t\t}\n\t},\n\n\tonCreate() {\n\t\tthis.options.provider.awareness.on(\n\t\t\t'change',\n\t\t\t(\n\t\t\t\t{ added, updated }: { added: number[], updated: number[] },\n\t\t\t\torigin: unknown,\n\t\t\t) => {\n\t\t\t\tif (origin !== 'local') {\n\t\t\t\t\tfor (const clientId of [...added, ...updated]) {\n\t\t\t\t\t\tif (clientId !== this.options.provider.awareness.clientID) {\n\t\t\t\t\t\t\tshowCaretLabel(clientId)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t},\n\n\t// Flag own caret as active on undoable changes to the document state\n\tonTransaction({ transaction, editor }) {\n\t\tconst addToHistory = transaction.getMeta('addToHistory') ?? true\n\t\tconst pointer = transaction.getMeta('pointer')\n\t\tconst updated = transaction.docChanged\n\t\tif (updated && addToHistory && !pointer) {\n\t\t\teditor.commands.updateUser({\n\t\t\t\t...this.options.provider.awareness.getLocalState().user,\n\t\t\t\tlastUpdate: getTimestamp(),\n\t\t\t})\n\t\t}\n\t},\n\n\t// Override to stop tiptap from setting its own default user\n\taddProseMirrorPlugins() {\n\t\treturn [\n\t\t\tyCursorPlugin(this.options.provider.awareness, {\n\t\t\t\tcursorBuilder: this.options.render,\n\t\t\t\tselectionBuilder: this.options.selectionRender,\n\t\t\t}),\n\t\t]\n\t},\n})\n\nexport default CollaborationCaret\n","/**\n * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\n/* eslint-disable jsdoc/require-param-type */\n/* eslint-disable jsdoc/require-param-description */\n\nimport { Extension } from '@tiptap/core'\n\nlet ownPaused = false\n\n/**\n *\n * @param editor\n * @param extensionName\n */\nfunction checkHasExtension(editor, extensionName) {\n\treturn editor.extensionManager.extensions.some((extension) => extension.name === extensionName)\n}\n\n/**\n *\n * @param editor\n */\nfunction checkHasListExtension(editor) {\n\treturn (\n\t\tcheckHasExtension(editor, 'bulletList')\n\t\t|| checkHasExtension(editor, 'orderedList')\n\t\t|| checkHasExtension(editor, 'taskList')\n\t)\n}\n\n/**\n *\n * @param root0\n * @param root0.editor\n */\nfunction toggleFocusTrap({ editor }) {\n\tconst trapStack = window._nc_focus_trap ?? []\n\tconst activeTrap = trapStack[trapStack.length - 1]\n\n\tconst possibleEditorTabCommand\n\t\t= (checkHasListExtension(editor) && editor.can().sinkListItem('listItem'))\n\t\t\t|| (checkHasExtension(editor, 'table') && editor.can().goToNextCell())\n\t\t\t|| (checkHasExtension(editor, 'table') && editor.can().goToPreviousCell())\n\t\t\t|| (checkHasExtension(editor, 'codeBlock') && editor.isActive('codeBlock'))\n\n\tif (possibleEditorTabCommand) {\n\t\tactiveTrap?.pause()\n\t\townPaused = true\n\t} else {\n\t\tif (ownPaused) {\n\t\t\townPaused = false\n\t\t\tactiveTrap?.unpause()\n\t\t}\n\t}\n}\n\n/**\n *\n */\nfunction unpauseFocusTrap() {\n\tconst trapStack = window._nc_focus_trap ?? []\n\tconst activeTrap = trapStack[trapStack.length - 1]\n\n\tactiveTrap?.unpause()\n}\n\n/**\n * The viewer focus trap needs to be paused on the fly in order to properly handle tab commands in the editor,\n * as we have no control over if a tab key event is reaching the editor otherwise. This is because the focus trap\n * registeres a capture listener (https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#capture), so whenever we reach a tab command in the editor the focus trap will already have captured the event.\n *\n * We also cannot work around this by pushing our own focus trap to the stack, as the focus trap package does not offer any reliable way to programmatically focus the next element of the parent trap if we allow tabbing out of the editor.\n */\nconst FocusTrap = Extension.create({\n\tname: 'focustrap',\n\tonFocus: toggleFocusTrap,\n\tonBlur: unpauseFocusTrap,\n\tonSelectionUpdate: toggleFocusTrap,\n\tonTransaction: toggleFocusTrap,\n\tonUpdate: toggleFocusTrap,\n})\n\nexport default FocusTrap\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { Node } from '@tiptap/core'\n\nexport default Node.create({\n\tname: 'doc',\n\tcontent: 'table',\n})\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { Extension } from '@tiptap/core'\nimport Text from '@tiptap/extension-text'\nimport EditableTable from './../nodes/EditableTable.js'\nimport Paragraph from './../nodes/Paragraph.js'\nimport PlainTableDocument from './../nodes/PlainTableDocument.js'\nimport Keymap from './Keymap.js'\nimport Markdown from './Markdown.js'\n\nexport default Extension.create({\n\tname: 'PlainTable',\n\n\taddExtensions() {\n\t\treturn [Markdown, Paragraph, PlainTableDocument, EditableTable, Keymap, Text]\n\t},\n})\n","/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport TiptapCodeBlock from '@tiptap/extension-code-block'\nimport codeBlockShortcuts from './CodeBlock/codeBlockShortcuts.js'\n\nconst CodeBlockPlainText = TiptapCodeBlock.extend({\n\taddKeyboardShortcuts() {\n\t\treturn codeBlockShortcuts\n\t},\n})\n\nexport default CodeBlockPlainText\n","/**\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { Node } from '@tiptap/core'\n\nexport default Node.create({\n\tname: 'doc',\n\tcontent: 'block',\n})\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { Extension } from '@tiptap/core'\nimport Text from '@tiptap/extension-text'\nimport CodeBlockPlainText from './../nodes/CodeBlockPlainText.js'\nimport PlainTextDocument from './../nodes/PlainTextDocument.js'\nimport Keymap from './Keymap.js'\n\nexport default Extension.create({\n\tname: 'PlainText',\n\n\taddOptions() {\n\t\treturn {\n\t\t\t...this.parent?.(),\n\t\t\tlowlight: undefined,\n\t\t\tdefaultLanguage: 'plaintext',\n\t\t}\n\t},\n\n\taddExtensions() {\n\t\treturn [\n\t\t\tCodeBlockPlainText.configure({\n\t\t\t\tlowlight: this.options.lowlight,\n\t\t\t\tdefaultLanguage: this.options.defaultLanguage,\n\t\t\t\texitOnTripleEnter: false,\n\t\t\t}),\n\t\t\tKeymap,\n\t\t\tPlainTextDocument,\n\t\t\tText,\n\t\t]\n\t},\n})\n","/**\n * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nexport class Span {\n\tconstructor(from, to, author) {\n\t\tthis.from = from\n\t\tthis.to = to\n\t\tthis.author = author\n\t}\n}\n","/**\n * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\n/* eslint-disable @stylistic/max-statements-per-line */\n\nimport { Span } from './models.js'\n\n/*\n * This code is heavily inspired by the change tracking example of prosemirror\n * https://github.com/ProseMirror/website/blob/master/example/track/index.js\n */\n\n/**\n * @param {Array} map List of document ranges and corresponding authors\n * @param {object} transform ProseMirror transform object\n * @param {Array} clientIDs List of client IDs\n */\nfunction updateBlameMap(map, transform, clientIDs) {\n\tconst result = []\n\tconst mapping = transform.mapping\n\tfor (let i = 0; i < map.length; i++) {\n\t\tconst span = map[i]\n\t\tconst from = mapping.map(span.from, 1)\n\t\tconst to = mapping.map(span.to, -1)\n\t\tif (from < to) { result.push(new Span(from, to, span.author)) }\n\t}\n\n\tfor (let i = 0; i < mapping.maps.length; i++) {\n\t\tconst map = mapping.maps[i]\n\t\tconst after = mapping.slice(i + 1)\n\t\tmap.forEach((_s, _e, start, end) => {\n\t\t\tinsertIntoBlameMap(\n\t\t\t\tresult,\n\t\t\t\tafter.map(start, 1),\n\t\t\t\tafter.map(end, -1),\n\t\t\t\tclientIDs[i],\n\t\t\t)\n\t\t})\n\t}\n\n\treturn result\n}\n\n/**\n * @param {Array} map List of document ranges and corresponding authors\n * @param {number} from The lower bound of the selection's main range\n * @param {number} to The upper bound of the selection's main range\n * @param {number} author ClientID of the author\n */\nfunction insertIntoBlameMap(map, from, to, author) {\n\tif (from >= to) {\n\t\treturn\n\t}\n\tlet pos = 0\n\tlet next\n\tfor (; pos < map.length; pos++) {\n\t\tnext = map[pos]\n\t\tif (next.author === author) {\n\t\t\tif (next.to >= from) { break }\n\t\t} else if (next.to > from) {\n\t\t\t// Different author, not before\n\t\t\tif (next.from < from) {\n\t\t\t\t// Sticks out to the left (loop below will handle right side)\n\t\t\t\tconst left = new Span(next.from, from, next.author)\n\t\t\t\tif (next.to > to) { map.splice(pos++, 0, left) } else { map[pos++] = left }\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// eslint-ignore\n\twhile ((next = map[pos])) {\n\t\tif (next.author === author) {\n\t\t\tif (next.from > to) { break }\n\t\t\tfrom = Math.min(from, next.from)\n\t\t\tto = Math.max(to, next.to)\n\t\t\tmap.splice(pos, 1)\n\t\t} else {\n\t\t\tif (next.from >= to) { break }\n\t\t\tif (next.to > to) {\n\t\t\t\tmap[pos] = new Span(to, next.to, next.author)\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tmap.splice(pos, 1)\n\t\t\t}\n\t\t}\n\t}\n\n\tmap.splice(pos, 0, new Span(from, to, author))\n}\n\nexport default class TrackState {\n\tconstructor(blameMap) {\n\t\t// The blame map is a data structure that lists a sequence of\n\t\t// document ranges, along with the author that inserted them. This\n\t\t// can be used to, for example, highlight the part of the document\n\t\t// that was inserted by a author.\n\t\tthis.blameMap = blameMap\n\t}\n\n\t// Apply a transform to this state\n\tapplyTransform(transform) {\n\t\tconst clientID\n\t\t\t= transform.getMeta('clientID') ?? transform.steps.map(() => 'self')\n\t\tconst newBlame = updateBlameMap(this.blameMap, transform, clientID)\n\t\t// Create a new state—since these are part of the editor state, a\n\t\t// persistent data structure, they must not be mutated.\n\t\treturn new TrackState(newBlame)\n\t}\n}\n","/**\n * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { Extension } from '@tiptap/core'\nimport { Plugin } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\nimport { Span } from './tracking/models.js'\nimport TrackState from './tracking/TrackState.js'\n\nconst UserColor = Extension.create({\n\tname: 'users',\n\n\taddOptions() {\n\t\treturn {\n\t\t\tclientID: 0,\n\t\t\tcolor: (clientID) => {\n\t\t\t\treturn (\n\t\t\t\t\t'#'\n\t\t\t\t\t+ Math.floor(Math.abs(Math.sin(clientID) * 16777215) % 16777215).toString(16)\n\t\t\t\t\t+ 'aa'\n\t\t\t\t)\n\t\t\t},\n\t\t\tname: (clientID) => {\n\t\t\t\treturn 'Unknown user ' + clientID\n\t\t\t},\n\t\t}\n\t},\n\n\taddProseMirrorPlugins() {\n\t\tlet viewReference = null\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tclientID: this.options.clientID,\n\t\t\t\tcolor: this.options.color,\n\t\t\t\tname: this.options.name,\n\t\t\t\tview: (editorView) => {\n\t\t\t\t\tviewReference = editorView\n\t\t\t\t\treturn {}\n\t\t\t\t},\n\t\t\t\tstate: {\n\t\t\t\t\tinit(_, instance) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttracked: new TrackState(\n\t\t\t\t\t\t\t\t[new Span(0, instance.doc.content.size, null)],\n\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tdeco: DecorationSet.empty,\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tapply(tr, instance, oldState, state) {\n\t\t\t\t\t\tlet { tracked } = instance\n\t\t\t\t\t\tlet tState = this.getState(oldState).tracked\n\t\t\t\t\t\tif (tr.docChanged) {\n\t\t\t\t\t\t\tif (!tr.getMeta('clientID')) {\n\t\t\t\t\t\t\t\t// we have an undefined client id for own transactions\n\t\t\t\t\t\t\t\ttr.setMeta(\n\t\t\t\t\t\t\t\t\t'clientID',\n\t\t\t\t\t\t\t\t\ttr.steps.map(() => this.spec.clientID),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Don't apply transaction when in composition (Github issue #2871)\n\t\t\t\t\t\t\tif (!viewReference.composing) {\n\t\t\t\t\t\t\t\ttracked = tracked.applyTransform(tr)\n\t\t\t\t\t\t\t\ttState = tracked\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst decos = tState.blameMap\n\t\t\t\t\t\t\t.map((span) => {\n\t\t\t\t\t\t\t\tconst clientID = span.author\n\t\t\t\t\t\t\t\treturn Decoration.inline(span.from, span.to, {\n\t\t\t\t\t\t\t\t\tclass: 'author-annotation',\n\t\t\t\t\t\t\t\t\tstyle:\n\t\t\t\t\t\t\t\t\t\t'background-color: '\n\t\t\t\t\t\t\t\t\t\t+ this.spec.color(clientID)\n\t\t\t\t\t\t\t\t\t\t+ '66;',\n\t\t\t\t\t\t\t\t\ttitle: this.spec.name(clientID),\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.filter((dec) => dec !== null)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttracked,\n\t\t\t\t\t\t\tdeco: DecorationSet.create(state.doc, decos),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tprops: {\n\t\t\t\t\tdecorations(state) {\n\t\t\t\t\t\treturn this.getState(state).deco\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t]\n\t},\n})\n\nexport default UserColor\n"],"names":["createTimeoutClass","clearFunction","timeoutId","Timeout","timeout","callback","createMutex","token","f","g","highSurrogateRegex","lowSurrogateRegex","simpleDiffString","a","b","left","right","simpleDiff","rotr","w","shift","sum0to256","x","sum1to256","sigma0to256","sigma1to256","K","HINIT","Hasher","buf","H","W","t","c","d","e","h","tt","T1","T2","data","i","j","binary.BIT8","isPaddedWith1","ci","binary.BIT30","dv","digest","ySyncPluginKey","PluginKey","yUndoPluginKey","yCursorPluginKey","_convolute","hashOfJSON","json","buf.toBase64","sha256.digest","buf.encodeAny","isVisible","item","snapshot","Y.isDeleted","defaultColors","getUserColor","colorMapping","colors","user","usedColors","set.create","color","random.oneOf","ySyncPlugin","yXmlFragment","permanentUserData","onFirstRender","mapping","initialContentChanged","binding","ProsemirrorBinding","plugin","Plugin","state","syncState","_initargs","_state","tr","pluginState","change","key","eventloop.timeout","view","yUndoPluginState","um","recoverSelectionEndpoint","newDoc","oldDoc","oldAbs","resolved","isMisresolvedAfterStructuralChange","recovered","findAbsolutePositionAfterStructuralChange","restoreRelativeSelection","relSel","AllSelection","anchor","relativePositionToAbsolutePosition","createSafeNodeSelection","head","selection","createSafeNodeRangeSelection","TextSelection","pos","$pos","NodeSelection","depth","clampedAnchor","clampedHead","Selection","getRelativeSelection","pmbinding","type","absolutePositionToRelativePosition","environment.isBrowser","range","bounding","documentElement","dom.doc","prevSnapshot","Y.createSnapshot","Y.createDeleteSet","fragmentContent","createNodeFromYElement","n","PModel.Slice","PModel.Fragment","sel","math.min","math.max","historyDoc","historyType","Y.snapshot","error.unexpectedCase","Y.Doc","Y.applyUpdateV2","rootKey","historyStructs","itemIndex","Y.findIndexSS","transaction","pud","ds","Y.iterateDeletedStructs","_item","computeYChange","id","Y.typeListToArraySnapshot","Y.Snapshot","events","delType","_","struct","Y.Item","createNodeIfNotExists","Y.UndoManager","doc","updateYFragment","prosemirrorView","el","schema","meta","node","Y.XmlElement","error.methodUnimplemented","children","createChildren","nextytext","Y.Text","ns","createTextNodesFromYText","textchild","attrs","text","_meta","nodes","deltas","delta","attributesToMarks","createTypeFromTextNodes","Y.XmlText","marksToAttributes","createTypeFromElementNode","val","normalizePNodeContent","createTypeFromTextOrElementNode","isObject","equalAttrs","pattrs","yattrs","keys","eq","l","r","pnode","res","textNodes","tnode","equalYTextPText","ytext","ptexts","object.keys","object.every","attr","yattrname","markname","yattr2markname","pmarks","mark","equalYTypePNode","ytype","matchNodeName","normalizedContent","ychild","mappedIdentity","mapped","pcontent","findMappedChildAnchors","yChildren","pChildren","pChildIndices","pChild","index","candidates","yChild","yIndex","pIndex","predecessors","tails","low","high","middle","anchors","deleteYChildren","yDomFragment","length","insertPChildren","start","end","childIndex","updateMatchingYChild","y","updateYText","reconcileUnanchoredChildren","yStart","yEnd","pStart","pEnd","matchingChildren","reconcileMappedChildren","computeChildEqualityFactor","pChildCnt","yChildCnt","minCnt","foundMappedChild","leftY","leftP","rightY","rightP","ytextTrans","str","nAttrs","Y.ContentString","Y.ContentFormat","content","p","insert","remove","hashedMarkNameRegex","attrName","marks","markName","isOverlapping","map.setIfUndefined","pNode","yDomAttrs","pAttrs","updateLeft","updateRight","equalityLeft","equalityRight","yDelLen","ins","yElement","viewsToUpdate","MetaEntry","value","MetaEntriesQueue","entries","ups","metas","updateMetas","metaEntries","isRetry","isFirst","metaEntry","err","setMeta","map.create","Y.createRelativePositionFromTypeIndex","pNodeSize","Y.RelativePosition","Y.findRootTypeKey","createRelativePosition","isMisresolvedTextPosition","relPos","absPos","decoded","Y.createAbsolutePositionFromRelativePosition","typeid","tname","Y.createID","documentType","decodedPos","Y.isParentOf","parent","contentType","attrsEqual","aKeys","k","hasDistinctiveAttrs","specAttrs","spec","remapIntoBlock","$oldPos","newBlockStart","newBlock","idx","targetIdx","child","targetChild","place","remapped","contentStart","contentEnd","findByPredicate","pred","requireUnique","occurrence","matchCount","matchStart","matchBlock","newPos","sameTypeAndAttrs","oldText","byAll","byText","byAttrs","isStructuralTransaction","step","ReplaceStep","hasBlock","$from","$to","resolvedAbs","$old","$new","bothAtStart","suspicious","expected","defaultAwarenessStateFilter","currentClientId","userClientId","_user","defaultCursorBuilder","cursor","userDiv","nonbreakingSpace1","nonbreakingSpace2","defaultSelectionBuilder","rxValidColor","createDecorations","awareness","awarenessFilter","createCursor","createSelection","ystate","DecorationSet","decorations","aw","clientId","Y.createRelativePositionFromJSON","maxsize","Decoration","from","to","yCursorPlugin","awarenessStateFilter","cursorBuilder","selectionBuilder","getSelection","cursorStateField","prevState","oldState","newState","yCursorState","isRemoteChange","awarenessListener","updateCursorInfo","editorView","opts","current","Y.compareRelativePositions","onFocusChange","forceAwarenessUpdate","undo","undoManager","redo","defaultProtectedNodes","defaultDeleteFilter","protectedNodes","Item","ContentType","Text","XmlElement","yUndoPlugin","trackedOrigins","initargs","_undoManager","destroyListenersBefore","UndoManager","destroyListenersAfter","listener","hasUndoOps","hasRedoOps","stackItem","leakedDestroyListeners","isChangeOrigin","getYAbsolutePosition","relativePos","getYRelativePosition","absolutePos","CollaborationMappablePosition","MappablePosition","position","yRelativePosition","createMappablePosition","getUpdatedPosition","result","getUpdatedPosition$1","absolutePosition","Collaboration","Extension","extension","dispatch","fragment","yUndoPluginInstance","originalUndoPluginView","viewRet","hasUndoManSelf","observers","ySyncPluginOptions","error","_fragment$doc","getNodeRangeDecorations","ranges","getNodeContentBounds","nodeStart","nodeSize","contentOffset","getSelectionRanges","options","extendOnBoundaryOverlap","nodeRange","NodeRange$1","offset","contentBounds","overlapsNodeContent","selectionRange","SelectionRange","NodeRangeBookmark","NodeRangeSelection","$anchor","$head","bias","isCursor","isCursorAtEnd","$correctedHead","$correctedAnchor","$rangeFrom","$rangeTo","other","firstRange","lastRange","isNodeRangeSelection","editor","nodeRangeSelection","hideTextSelection","activeMouseSelection","event","isMac","isShift","isControl","isAlt","isMeta","isNodeRange","nodeRanges","getCSSText","element","properties","style","property","cloneElement","clonedNode","sourceElements","targetElements","sourceElement","defaultRules","listItemTypes","firstChild","DEFAULT_EDGE_CONFIG","normalizeEdgeDetection","input","isNearEdge","coords","config","rect","threshold","edges","edge","calculateEdgeDeduction","BASE_SCORE","calculateScore","context","rules","edgeConfig","score","excluded","rule","deduction","dom","hasAncestorOfType","allowedTypes","findBestDragTarget","posInfo","nodePos","siblingCount","candidate","nodeAfter","inAllowedContainer","winner","findClosestTopLevelBlock","_pmViewDesc","isValidRect","edgeBlockRect","container","clampToContent","inset","topRect","botRect","clampedY","epsilon","sameLeft","sameRight","rowRect","clampedX","findElementNextToCoords","nestedOptions","clamped","target","elements","block","blockPos","blockNode","resolvedPos","getDraggedBlockElement","nodeDom","getDraggedBlockDir","draggedDom","removeNode","_node$parentNode","getDragImageOffset","direction","wrapperWidth","shouldResetMargin","dragImageProperties","getDragHandleRanges","dragContext","nodeEnd","dragHandler","empty","dragHandleRanges","selectionRanges","isDragHandleWithinSelection","dragHandleRange","wrapper","isNestedDrag","isSingleBlock","slice","resetMargin","clonedElement","dragImageX","cleanedUp","cleanupDragPreview","nodeSelection","getOuterNodePos","getOuterNode","currentNode","mapPendingRestoreAnchor","pendingRestore","mappedResult","sumNodeSizes","size","getActiveDragRange","_selection$depth","getDroppedBlockRange","anchorPos","nodeCount","count","blockStart","createDroppedNodeRangeSelection","getRelativePos","getAbsolutePos","getOuterDomNode","domNode","tmpDomNode","dragHandlePluginDefaultKey","DragHandlePlugin","pluginKey","computePositionConfig","getReferencedVirtualElement","onNodeChange","onElementDragStart","onElementDragEnd","locked","currentNodePos","currentNodeRelPos","rafId","pendingMouseCoords","activeDragRange","clearDragRangeState","remapPendingRestore","buildRestoreTransaction","hideHandle","showHandle","repositionDragHandle","virtualElement","computePosition","onDragStart","onDragEnd","onDrop","isFirefox","editorElement","relativeAnchorPos","cleanup","_oldState","isLocked","hideDragHandle","_transactions","_editor$view$dom$pare","domNodePos","outerNode","outerNodePos","_view","nodeData","targetNode","targetPos","_targetPos","normalizeNestedOptions","_input$rules","_input$defaultRules","defaultComputePositionConfig","DragHandle","defineComponent","props","slots","root","ref","pluginHandle","shallowRef","initPlugin","nested","init","destroyPlugin","_pluginHandle$value$u","_pluginHandle$value","onMounted","nextTick","watch","onBeforeUnmount","_slots$default","_sfc_main","_hoisted_3","_createElementBlock","_mergeProps","_ctx","$props","_cache","$event","_createElementVNode","_openBlock","IGNORE_NODES","DragVerticalIcon","NcButton","PlusIcon","useEditor","_createBlock","_component_DragHandle","$setup","$options","_createVNode","_component_NcButton","_component_PlusIcon","_component_DragVerticalIcon","intersectionObserverKey","visibleIdsKey","intersectionObserverOptions","provideIntersectionObserver","visibleIds","update","ids","entry","intersectionObserver","onUnmounted","provide","useVisibility","inject","observedEl","logger","visible","computed","readonly","__props","emit","__emit","heading","toRefs","goto","_unref","_withModifiers","_toDisplayString","_hoisted_2","headings","useEditorHeadings","_hoisted_1","_Fragment","_renderList","TableOfContentsEntry","_sfc_main$8","CloseIcon","PinOutlineIcon","fileId","useFileProps","_normalizeClass","args","_withCtx","_component_CloseIcon","_component_PinOutlineIcon","_renderSlot","_sfc_main$7","NcModal","_component_NcModal","$emit","TocOutlineEntry","displayToc","isMobile","useIsMobile","setDisplayToc","TocMobile","TableOfContents","TocOutline","TocDesktop","useAnnotationsHidden","hidden","EditorContent","FloatingButtons","TocContainer","isRichEditor","isRichWorkspace","hasTableOfContents","useEditorFlags","_component_FloatingButtons","_component_EditorContent","_component_TocContainer","READ_ONLY_ACTIONS","uploadAttachment","connection","file","documentId","sessionId","sessionToken","unref","formData","url","generateUrl","axios","createAttachment","template","insertAttachmentFile","filePath","getDir","ACTION_ATTACHMENT_PROMPT","ACTION_CHOOSE_LOCAL_ATTACHMENT","ACTION_CREATE_ATTACHMENT","STATE_UPLOADING","useConnection","relativePath","parentPath","startPath","files","uploadPromises","showError","response","getCurrentUser","buildFilePicker","href","name","mimeType","dirname","sanitizedName","src","alt","$data","MediaHandler","useEditorUpload","_component_MediaHandler","valueSingleton","loadState","editorWidthKey","editorWidthDesktop","editorWidthDesktopEnhanced","fullEditorWidthDesktop","fullEditorWidthDesktopEnhanced","editorWidthMobile","fullEditorWidthMobile","maxWidthSetOutsideOfText","alreadySet","setByText","provideEditorWidth","isFullWidth","onFullWidth","subscribe","unsubscribe","defaultEditorWidthDesktop","defaultFullEditorWidthDesktop","defaultEditorWidth","fullEditorWidth","width","applyEditorWidth","useEditorWidth","checked","awarenessStatesToArray","states","defaultOnUpdate","CollaborationCaret","label","attributes","provider","storage","onAwarenessUpdate","showCaretLabel","getTimestamp","render","TiptapCollaborationCaret","added","updated","origin","addToHistory","pointer","ownPaused","checkHasExtension","extensionName","checkHasListExtension","toggleFocusTrap","trapStack","activeTrap","unpauseFocusTrap","FocusTrap","PlainTableDocument","Node","PlainTable","Markdown","Paragraph","EditableTable","Keymap","CodeBlockPlainText","TiptapCodeBlock","codeBlockShortcuts","PlainTextDocument","PlainText","Span","author","updateBlameMap","map","transform","clientIDs","span","after","_s","_e","insertIntoBlameMap","next","TrackState","blameMap","clientID","newBlame","viewReference","instance","tracked","tState","decos","dec"],"mappings":"k/CAwCA,MAAMA,GAAqBC,GAAiB,KAAS,CAInD,YAAaC,EAAW,CACtB,KAAK,EAAIA,CACX,CAEA,SAAW,CACTD,EAAc,KAAK,CAAC,CACtB,CACF,EAEME,GAAUH,GAAmB,YAAY,EAOlCI,GAAU,CAACA,EAASC,IAAa,IAAIF,GAAQ,WAAWE,EAAUD,CAAO,CAAC,EChC1EE,GAAc,IAAM,CAC/B,IAAIC,EAAQ,GACZ,MAAO,CAACC,EAAGC,IAAM,CACf,GAAIF,EAAO,CACTA,EAAQ,GACR,GAAI,CACFC,EAAC,CACH,QAAA,CACED,EAAQ,EACV,CACF,MAAWE,IAAM,QACfA,EAAC,CAEL,CACF,ECdMC,GAAqB,kBACrBC,GAAoB,kBAYbC,GAAmB,CAACC,EAAGC,IAAM,CACxC,IAAIC,EAAO,EACPC,EAAQ,EACZ,KAAOD,EAAOF,EAAE,QAAUE,EAAOD,EAAE,QAAUD,EAAEE,CAAI,IAAMD,EAAEC,CAAI,GAC7DA,IAIF,IADIA,EAAO,GAAKL,GAAmB,KAAKG,EAAEE,EAAO,CAAC,CAAC,GAAGA,IAC/CC,EAAQD,EAAOF,EAAE,QAAUG,EAAQD,EAAOD,EAAE,QAAUD,EAAEA,EAAE,OAASG,EAAQ,CAAC,IAAMF,EAAEA,EAAE,OAASE,EAAQ,CAAC,G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