{"version":3,"file":"parchment.umd.cjs","sources":["../src/scope.ts","../src/attributor/attributor.ts","../src/error.ts","../src/registry.ts","../src/attributor/class.ts","../src/attributor/style.ts","../src/attributor/store.ts","../src/blot/abstract/shadow.ts","../src/blot/abstract/leaf.ts","../src/collection/linked-list.ts","../src/blot/abstract/parent.ts","../src/blot/inline.ts","../src/blot/block.ts","../src/blot/abstract/container.ts","../src/blot/embed.ts","../src/blot/scroll.ts","../src/blot/text.ts"],"sourcesContent":["enum Scope {\n TYPE = (1 << 2) - 1, // 0011 Lower two bits\n LEVEL = ((1 << 2) - 1) << 2, // 1100 Higher two bits\n\n ATTRIBUTE = (1 << 0) | LEVEL, // 1101\n BLOT = (1 << 1) | LEVEL, // 1110\n INLINE = (1 << 2) | TYPE, // 0111\n BLOCK = (1 << 3) | TYPE, // 1011\n\n BLOCK_BLOT = BLOCK & BLOT, // 1010\n INLINE_BLOT = INLINE & BLOT, // 0110\n BLOCK_ATTRIBUTE = BLOCK & ATTRIBUTE, // 1001\n INLINE_ATTRIBUTE = INLINE & ATTRIBUTE, // 0101\n\n ANY = TYPE | LEVEL,\n}\n\nexport default Scope;\n","import Scope from '../scope.js';\n\nexport interface AttributorOptions {\n scope?: Scope;\n whitelist?: string[];\n}\n\nexport default class Attributor {\n public static keys(node: HTMLElement): string[] {\n return Array.from(node.attributes).map((item: Attr) => item.name);\n }\n\n public scope: Scope;\n public whitelist: string[] | undefined;\n\n constructor(\n public readonly attrName: string,\n public readonly keyName: string,\n options: AttributorOptions = {},\n ) {\n const attributeBit = Scope.TYPE & Scope.ATTRIBUTE;\n this.scope =\n options.scope != null\n ? // Ignore type bits, force attribute bit\n (options.scope & Scope.LEVEL) | attributeBit\n : Scope.ATTRIBUTE;\n if (options.whitelist != null) {\n this.whitelist = options.whitelist;\n }\n }\n\n public add(node: HTMLElement, value: any): boolean {\n if (!this.canAdd(node, value)) {\n return false;\n }\n node.setAttribute(this.keyName, value);\n return true;\n }\n\n public canAdd(_node: HTMLElement, value: any): boolean {\n if (this.whitelist == null) {\n return true;\n }\n if (typeof value === 'string') {\n return this.whitelist.indexOf(value.replace(/[\"']/g, '')) > -1;\n } else {\n return this.whitelist.indexOf(value) > -1;\n }\n }\n\n public remove(node: HTMLElement): void {\n node.removeAttribute(this.keyName);\n }\n\n public value(node: HTMLElement): any {\n const value = node.getAttribute(this.keyName);\n if (this.canAdd(node, value) && value) {\n return value;\n }\n return '';\n }\n}\n","export default class ParchmentError extends Error {\n public message: string;\n public name: string;\n public stack!: string;\n\n constructor(message: string) {\n message = '[Parchment] ' + message;\n super(message);\n this.message = message;\n this.name = this.constructor.name;\n }\n}\n","import Attributor from './attributor/attributor.js';\nimport {\n type Blot,\n type BlotConstructor,\n type Root,\n} from './blot/abstract/blot.js';\nimport ParchmentError from './error.js';\nimport Scope from './scope.js';\n\nexport type RegistryDefinition = Attributor | BlotConstructor;\n\nexport interface RegistryInterface {\n create(scroll: Root, input: Node | string | Scope, value?: any): Blot;\n query(query: string | Node | Scope, scope: Scope): RegistryDefinition | null;\n register(...definitions: any[]): any;\n}\n\nexport default class Registry implements RegistryInterface {\n public static blots = new WeakMap();\n\n public static find(node?: Node | null, bubble = false): Blot | null {\n if (node == null) {\n return null;\n }\n if (this.blots.has(node)) {\n return this.blots.get(node) || null;\n }\n if (bubble) {\n let parentNode: Node | null = null;\n try {\n parentNode = node.parentNode;\n } catch (err) {\n // Probably hit a permission denied error.\n // A known case is in Firefox, event targets can be anonymous DIVs\n // inside an input element.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=208427\n return null;\n }\n return this.find(parentNode, bubble);\n }\n return null;\n }\n\n private attributes: { [key: string]: Attributor } = {};\n private classes: { [key: string]: BlotConstructor } = {};\n private tags: { [key: string]: BlotConstructor } = {};\n private types: { [key: string]: RegistryDefinition } = {};\n\n public create(scroll: Root, input: Node | string | Scope, value?: any): Blot {\n const match = this.query(input);\n if (match == null) {\n throw new ParchmentError(`Unable to create ${input} blot`);\n }\n const blotClass = match as BlotConstructor;\n const node =\n // @ts-expect-error Fix me later\n input instanceof Node || input.nodeType === Node.TEXT_NODE\n ? input\n : blotClass.create(value);\n\n const blot = new blotClass(scroll, node as Node, value);\n Registry.blots.set(blot.domNode, blot);\n return blot;\n }\n\n public find(node: Node | null, bubble = false): Blot | null {\n return Registry.find(node, bubble);\n }\n\n public query(\n query: string | Node | Scope,\n scope: Scope = Scope.ANY,\n ): RegistryDefinition | null {\n let match;\n if (typeof query === 'string') {\n match = this.types[query] || this.attributes[query];\n // @ts-expect-error Fix me later\n } else if (query instanceof Text || query.nodeType === Node.TEXT_NODE) {\n match = this.types.text;\n } else if (typeof query === 'number') {\n if (query & Scope.LEVEL & Scope.BLOCK) {\n match = this.types.block;\n } else if (query & Scope.LEVEL & Scope.INLINE) {\n match = this.types.inline;\n }\n } else if (query instanceof Element) {\n const names = (query.getAttribute('class') || '').split(/\\s+/);\n names.some((name) => {\n match = this.classes[name];\n if (match) {\n return true;\n }\n return false;\n });\n match = match || this.tags[query.tagName];\n }\n if (match == null) {\n return null;\n }\n if (\n 'scope' in match &&\n scope & Scope.LEVEL & match.scope &&\n scope & Scope.TYPE & match.scope\n ) {\n return match;\n }\n return null;\n }\n\n public register(...definitions: RegistryDefinition[]): RegistryDefinition[] {\n return definitions.map((definition) => {\n const isBlot = 'blotName' in definition;\n const isAttr = 'attrName' in definition;\n if (!isBlot && !isAttr) {\n throw new ParchmentError('Invalid definition');\n } else if (isBlot && definition.blotName === 'abstract') {\n throw new ParchmentError('Cannot register abstract class');\n }\n const key = isBlot\n ? definition.blotName\n : isAttr\n ? definition.attrName\n : (undefined as never); // already handled by above checks\n this.types[key] = definition;\n\n if (isAttr) {\n if (typeof definition.keyName === 'string') {\n this.attributes[definition.keyName] = definition;\n }\n } else if (isBlot) {\n if (definition.className) {\n this.classes[definition.className] = definition;\n }\n if (definition.tagName) {\n if (Array.isArray(definition.tagName)) {\n definition.tagName = definition.tagName.map((tagName: string) => {\n return tagName.toUpperCase();\n });\n } else {\n definition.tagName = definition.tagName.toUpperCase();\n }\n const tagNames = Array.isArray(definition.tagName)\n ? definition.tagName\n : [definition.tagName];\n tagNames.forEach((tag: string) => {\n if (this.tags[tag] == null || definition.className == null) {\n this.tags[tag] = definition;\n }\n });\n }\n }\n return definition;\n });\n }\n}\n","import Attributor from './attributor.js';\n\nfunction match(node: HTMLElement, prefix: string): string[] {\n const className = node.getAttribute('class') || '';\n return className\n .split(/\\s+/)\n .filter((name) => name.indexOf(`${prefix}-`) === 0);\n}\n\nclass ClassAttributor extends Attributor {\n public static keys(node: HTMLElement): string[] {\n return (node.getAttribute('class') || '')\n .split(/\\s+/)\n .map((name) => name.split('-').slice(0, -1).join('-'));\n }\n\n public add(node: HTMLElement, value: any): boolean {\n if (!this.canAdd(node, value)) {\n return false;\n }\n this.remove(node);\n node.classList.add(`${this.keyName}-${value}`);\n return true;\n }\n\n public remove(node: HTMLElement): void {\n const matches = match(node, this.keyName);\n matches.forEach((name) => {\n node.classList.remove(name);\n });\n if (node.classList.length === 0) {\n node.removeAttribute('class');\n }\n }\n\n public value(node: HTMLElement): any {\n const result = match(node, this.keyName)[0] || '';\n const value = result.slice(this.keyName.length + 1); // +1 for hyphen\n return this.canAdd(node, value) ? value : '';\n }\n}\n\nexport default ClassAttributor;\n","import Attributor from './attributor.js';\n\nfunction camelize(name: string): string {\n const parts = name.split('-');\n const rest = parts\n .slice(1)\n .map((part: string) => part[0].toUpperCase() + part.slice(1))\n .join('');\n return parts[0] + rest;\n}\n\nclass StyleAttributor extends Attributor {\n public static keys(node: HTMLElement): string[] {\n return (node.getAttribute('style') || '').split(';').map((value) => {\n const arr = value.split(':');\n return arr[0].trim();\n });\n }\n\n public add(node: HTMLElement, value: any): boolean {\n if (!this.canAdd(node, value)) {\n return false;\n }\n // @ts-expect-error Fix me later\n node.style[camelize(this.keyName)] = value;\n return true;\n }\n\n public remove(node: HTMLElement): void {\n // @ts-expect-error Fix me later\n node.style[camelize(this.keyName)] = '';\n if (!node.getAttribute('style')) {\n node.removeAttribute('style');\n }\n }\n\n public value(node: HTMLElement): any {\n // @ts-expect-error Fix me later\n const value = node.style[camelize(this.keyName)];\n return this.canAdd(node, value) ? value : '';\n }\n}\n\nexport default StyleAttributor;\n","import type { Formattable } from '../blot/abstract/blot.js';\nimport Registry from '../registry.js';\nimport Scope from '../scope.js';\nimport Attributor from './attributor.js';\nimport ClassAttributor from './class.js';\nimport StyleAttributor from './style.js';\n\nclass AttributorStore {\n private attributes: { [key: string]: Attributor } = {};\n private domNode: HTMLElement;\n\n constructor(domNode: HTMLElement) {\n this.domNode = domNode;\n this.build();\n }\n\n public attribute(attribute: Attributor, value: any): void {\n // verb\n if (value) {\n if (attribute.add(this.domNode, value)) {\n if (attribute.value(this.domNode) != null) {\n this.attributes[attribute.attrName] = attribute;\n } else {\n delete this.attributes[attribute.attrName];\n }\n }\n } else {\n attribute.remove(this.domNode);\n delete this.attributes[attribute.attrName];\n }\n }\n\n public build(): void {\n this.attributes = {};\n const blot = Registry.find(this.domNode);\n if (blot == null) {\n return;\n }\n const attributes = Attributor.keys(this.domNode);\n const classes = ClassAttributor.keys(this.domNode);\n const styles = StyleAttributor.keys(this.domNode);\n attributes\n .concat(classes)\n .concat(styles)\n .forEach((name) => {\n const attr = blot.scroll.query(name, Scope.ATTRIBUTE);\n if (attr instanceof Attributor) {\n this.attributes[attr.attrName] = attr;\n }\n });\n }\n\n public copy(target: Formattable): void {\n Object.keys(this.attributes).forEach((key) => {\n const value = this.attributes[key].value(this.domNode);\n target.format(key, value);\n });\n }\n\n public move(target: Formattable): void {\n this.copy(target);\n Object.keys(this.attributes).forEach((key) => {\n this.attributes[key].remove(this.domNode);\n });\n this.attributes = {};\n }\n\n public values(): { [key: string]: any } {\n return Object.keys(this.attributes).reduce(\n (attributes: { [key: string]: any }, name: string) => {\n attributes[name] = this.attributes[name].value(this.domNode);\n return attributes;\n },\n {},\n );\n }\n}\n\nexport default AttributorStore;\n","import ParchmentError from '../../error.js';\nimport Registry from '../../registry.js';\nimport Scope from '../../scope.js';\nimport type {\n Blot,\n BlotConstructor,\n Formattable,\n Parent,\n Root,\n} from './blot.js';\n\nclass ShadowBlot implements Blot {\n public static blotName = 'abstract';\n public static className: string;\n public static requiredContainer: BlotConstructor;\n public static scope: Scope;\n public static tagName: string | string[];\n\n public static create(rawValue?: unknown): Node {\n if (this.tagName == null) {\n throw new ParchmentError('Blot definition missing tagName');\n }\n let node: HTMLElement;\n let value: string | number | undefined;\n if (Array.isArray(this.tagName)) {\n if (typeof rawValue === 'string') {\n value = rawValue.toUpperCase();\n if (parseInt(value, 10).toString() === value) {\n value = parseInt(value, 10);\n }\n } else if (typeof rawValue === 'number') {\n value = rawValue;\n }\n if (typeof value === 'number') {\n node = document.createElement(this.tagName[value - 1]);\n } else if (value && this.tagName.indexOf(value) > -1) {\n node = document.createElement(value);\n } else {\n node = document.createElement(this.tagName[0]);\n }\n } else {\n node = document.createElement(this.tagName);\n }\n if (this.className) {\n node.classList.add(this.className);\n }\n return node;\n }\n\n public prev: Blot | null;\n public next: Blot | null;\n // @ts-expect-error Fix me later\n public parent: Parent;\n\n // Hack for accessing inherited static methods\n get statics(): any {\n return this.constructor;\n }\n constructor(\n public scroll: Root,\n public domNode: Node,\n ) {\n Registry.blots.set(domNode, this);\n this.prev = null;\n this.next = null;\n }\n\n public attach(): void {\n // Nothing to do\n }\n\n public clone(): Blot {\n const domNode = this.domNode.cloneNode(false);\n return this.scroll.create(domNode);\n }\n\n public detach(): void {\n if (this.parent != null) {\n this.parent.removeChild(this);\n }\n Registry.blots.delete(this.domNode);\n }\n\n public deleteAt(index: number, length: number): void {\n const blot = this.isolate(index, length);\n blot.remove();\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n const blot = this.isolate(index, length);\n if (this.scroll.query(name, Scope.BLOT) != null && value) {\n blot.wrap(name, value);\n } else if (this.scroll.query(name, Scope.ATTRIBUTE) != null) {\n const parent = this.scroll.create(this.statics.scope) as Parent &\n Formattable;\n blot.wrap(parent);\n parent.format(name, value);\n }\n }\n\n public insertAt(index: number, value: string, def?: any): void {\n const blot =\n def == null\n ? this.scroll.create('text', value)\n : this.scroll.create(value, def);\n const ref = this.split(index);\n this.parent.insertBefore(blot, ref || undefined);\n }\n\n public isolate(index: number, length: number): Blot {\n const target = this.split(index);\n if (target == null) {\n throw new Error('Attempt to isolate at end');\n }\n target.split(length);\n return target;\n }\n\n public length(): number {\n return 1;\n }\n\n public offset(root: Blot = this.parent): number {\n if (this.parent == null || this === root) {\n return 0;\n }\n return this.parent.children.offset(this) + this.parent.offset(root);\n }\n\n public optimize(_context?: { [key: string]: any }): void {\n if (\n this.statics.requiredContainer &&\n !(this.parent instanceof this.statics.requiredContainer)\n ) {\n this.wrap(this.statics.requiredContainer.blotName);\n }\n }\n\n public remove(): void {\n if (this.domNode.parentNode != null) {\n this.domNode.parentNode.removeChild(this.domNode);\n }\n this.detach();\n }\n\n public replaceWith(name: string | Blot, value?: any): Blot {\n const replacement =\n typeof name === 'string' ? this.scroll.create(name, value) : name;\n if (this.parent != null) {\n this.parent.insertBefore(replacement, this.next || undefined);\n this.remove();\n }\n return replacement;\n }\n\n public split(index: number, _force?: boolean): Blot | null {\n return index === 0 ? this : this.next;\n }\n\n public update(\n _mutations: MutationRecord[],\n _context: { [key: string]: any },\n ): void {\n // Nothing to do by default\n }\n\n public wrap(name: string | Parent, value?: any): Parent {\n const wrapper =\n typeof name === 'string'\n ? (this.scroll.create(name, value) as Parent)\n : name;\n if (this.parent != null) {\n this.parent.insertBefore(wrapper, this.next || undefined);\n }\n if (typeof wrapper.appendChild !== 'function') {\n throw new ParchmentError(`Cannot wrap ${name}`);\n }\n wrapper.appendChild(this);\n return wrapper;\n }\n}\n\nexport default ShadowBlot;\n","import Scope from '../../scope.js';\nimport type { Leaf } from './blot.js';\nimport ShadowBlot from './shadow.js';\n\nclass LeafBlot extends ShadowBlot implements Leaf {\n public static scope = Scope.INLINE_BLOT;\n\n /**\n * Returns the value represented by domNode if it is this Blot's type\n * No checking that domNode can represent this Blot type is required so\n * applications needing it should check externally before calling.\n */\n public static value(_domNode: Node): any {\n return true;\n }\n\n /**\n * Given location represented by node and offset from DOM Selection Range,\n * return index to that location.\n */\n public index(node: Node, offset: number): number {\n if (\n this.domNode === node ||\n this.domNode.compareDocumentPosition(node) &\n Node.DOCUMENT_POSITION_CONTAINED_BY\n ) {\n return Math.min(offset, 1);\n }\n return -1;\n }\n\n /**\n * Given index to location within blot, return node and offset representing\n * that location, consumable by DOM Selection Range\n */\n public position(index: number, _inclusive?: boolean): [Node, number] {\n const childNodes: Node[] = Array.from(this.parent.domNode.childNodes);\n let offset = childNodes.indexOf(this.domNode);\n if (index > 0) {\n offset += 1;\n }\n return [this.parent.domNode, offset];\n }\n\n /**\n * Return value represented by this blot\n * Should not change without interaction from API or\n * user change detectable by update()\n */\n public value(): any {\n return {\n [this.statics.blotName]: this.statics.value(this.domNode) || true,\n };\n }\n}\n\nexport default LeafBlot;\n","import type LinkedNode from './linked-node.js';\n\nclass LinkedList {\n public head: T | null;\n public tail: T | null;\n public length: number;\n\n constructor() {\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n public append(...nodes: T[]): void {\n this.insertBefore(nodes[0], null);\n if (nodes.length > 1) {\n const rest = nodes.slice(1);\n this.append(...rest);\n }\n }\n\n public at(index: number): T | null {\n const next = this.iterator();\n let cur = next();\n while (cur && index > 0) {\n index -= 1;\n cur = next();\n }\n return cur;\n }\n\n public contains(node: T): boolean {\n const next = this.iterator();\n let cur = next();\n while (cur) {\n if (cur === node) {\n return true;\n }\n cur = next();\n }\n return false;\n }\n\n public indexOf(node: T): number {\n const next = this.iterator();\n let cur = next();\n let index = 0;\n while (cur) {\n if (cur === node) {\n return index;\n }\n index += 1;\n cur = next();\n }\n return -1;\n }\n\n public insertBefore(node: T | null, refNode: T | null): void {\n if (node == null) {\n return;\n }\n this.remove(node);\n node.next = refNode;\n if (refNode != null) {\n node.prev = refNode.prev;\n if (refNode.prev != null) {\n refNode.prev.next = node;\n }\n refNode.prev = node;\n if (refNode === this.head) {\n this.head = node;\n }\n } else if (this.tail != null) {\n this.tail.next = node;\n node.prev = this.tail;\n this.tail = node;\n } else {\n node.prev = null;\n this.head = this.tail = node;\n }\n this.length += 1;\n }\n\n public offset(target: T): number {\n let index = 0;\n let cur = this.head;\n while (cur != null) {\n if (cur === target) {\n return index;\n }\n index += cur.length();\n cur = cur.next as T;\n }\n return -1;\n }\n\n public remove(node: T): void {\n if (!this.contains(node)) {\n return;\n }\n if (node.prev != null) {\n node.prev.next = node.next;\n }\n if (node.next != null) {\n node.next.prev = node.prev;\n }\n if (node === this.head) {\n this.head = node.next as T;\n }\n if (node === this.tail) {\n this.tail = node.prev as T;\n }\n this.length -= 1;\n }\n\n public iterator(curNode: T | null = this.head): () => T | null {\n // TODO use yield when we can\n return (): T | null => {\n const ret = curNode;\n if (curNode != null) {\n curNode = curNode.next as T;\n }\n return ret;\n };\n }\n\n public find(index: number, inclusive = false): [T | null, number] {\n const next = this.iterator();\n let cur = next();\n while (cur) {\n const length = cur.length();\n if (\n index < length ||\n (inclusive &&\n index === length &&\n (cur.next == null || cur.next.length() !== 0))\n ) {\n return [cur, index];\n }\n index -= length;\n cur = next();\n }\n return [null, 0];\n }\n\n public forEach(callback: (cur: T) => void): void {\n const next = this.iterator();\n let cur = next();\n while (cur) {\n callback(cur);\n cur = next();\n }\n }\n\n public forEachAt(\n index: number,\n length: number,\n callback: (cur: T, offset: number, length: number) => void,\n ): void {\n if (length <= 0) {\n return;\n }\n const [startNode, offset] = this.find(index);\n let curIndex = index - offset;\n const next = this.iterator(startNode);\n let cur = next();\n while (cur && curIndex < index + length) {\n const curLength = cur.length();\n if (index > curIndex) {\n callback(\n cur,\n index - curIndex,\n Math.min(length, curIndex + curLength - index),\n );\n } else {\n callback(cur, 0, Math.min(curLength, index + length - curIndex));\n }\n curIndex += curLength;\n cur = next();\n }\n }\n\n public map(callback: (cur: T) => any): any[] {\n return this.reduce((memo: T[], cur: T) => {\n memo.push(callback(cur));\n return memo;\n }, []);\n }\n\n public reduce(callback: (memo: M, cur: T) => M, memo: M): M {\n const next = this.iterator();\n let cur = next();\n while (cur) {\n memo = callback(memo, cur);\n cur = next();\n }\n return memo;\n }\n}\n\nexport default LinkedList;\n","import LinkedList from '../../collection/linked-list.js';\nimport ParchmentError from '../../error.js';\nimport Scope from '../../scope.js';\nimport type { Blot, BlotConstructor, Parent, Root } from './blot.js';\nimport ShadowBlot from './shadow.js';\n\nfunction makeAttachedBlot(node: Node, scroll: Root): Blot {\n const found = scroll.find(node);\n if (found) return found;\n try {\n return scroll.create(node);\n } catch (e) {\n const blot = scroll.create(Scope.INLINE);\n Array.from(node.childNodes).forEach((child: Node) => {\n blot.domNode.appendChild(child);\n });\n if (node.parentNode) {\n node.parentNode.replaceChild(blot.domNode, node);\n }\n blot.attach();\n return blot;\n }\n}\n\nclass ParentBlot extends ShadowBlot implements Parent {\n /**\n * Whitelist array of Blots that can be direct children.\n */\n public static allowedChildren?: BlotConstructor[];\n\n /**\n * Default child blot to be inserted if this blot becomes empty.\n */\n public static defaultChild?: BlotConstructor;\n public static uiClass = '';\n\n public children!: LinkedList;\n public domNode!: HTMLElement;\n public uiNode: HTMLElement | null = null;\n\n constructor(scroll: Root, domNode: Node) {\n super(scroll, domNode);\n this.build();\n }\n\n public appendChild(other: Blot): void {\n this.insertBefore(other);\n }\n\n public attach(): void {\n super.attach();\n this.children.forEach((child) => {\n child.attach();\n });\n }\n\n public attachUI(node: HTMLElement): void {\n if (this.uiNode != null) {\n this.uiNode.remove();\n }\n this.uiNode = node;\n if (ParentBlot.uiClass) {\n this.uiNode.classList.add(ParentBlot.uiClass);\n }\n this.uiNode.setAttribute('contenteditable', 'false');\n this.domNode.insertBefore(this.uiNode, this.domNode.firstChild);\n }\n\n /**\n * Called during construction, should fill its own children LinkedList.\n */\n public build(): void {\n this.children = new LinkedList();\n // Need to be reversed for if DOM nodes already in order\n Array.from(this.domNode.childNodes)\n .filter((node: Node) => node !== this.uiNode)\n .reverse()\n .forEach((node: Node) => {\n try {\n const child = makeAttachedBlot(node, this.scroll);\n this.insertBefore(child, this.children.head || undefined);\n } catch (err) {\n if (err instanceof ParchmentError) {\n return;\n } else {\n throw err;\n }\n }\n });\n }\n\n public deleteAt(index: number, length: number): void {\n if (index === 0 && length === this.length()) {\n return this.remove();\n }\n this.children.forEachAt(index, length, (child, offset, childLength) => {\n child.deleteAt(offset, childLength);\n });\n }\n\n public descendant(\n criteria: new (...args: any[]) => T,\n index: number,\n ): [T | null, number];\n public descendant(\n criteria: (blot: Blot) => boolean,\n index: number,\n ): [Blot | null, number];\n public descendant(criteria: any, index = 0): [Blot | null, number] {\n const [child, offset] = this.children.find(index);\n if (\n (criteria.blotName == null && criteria(child)) ||\n (criteria.blotName != null && child instanceof criteria)\n ) {\n return [child as any, offset];\n } else if (child instanceof ParentBlot) {\n return child.descendant(criteria, offset);\n } else {\n return [null, -1];\n }\n }\n\n public descendants(\n criteria: new (...args: any[]) => T,\n index?: number,\n length?: number,\n ): T[];\n public descendants(\n criteria: (blot: Blot) => boolean,\n index?: number,\n length?: number,\n ): Blot[];\n public descendants(\n criteria: any,\n index = 0,\n length: number = Number.MAX_VALUE,\n ): Blot[] {\n let descendants: Blot[] = [];\n let lengthLeft = length;\n this.children.forEachAt(\n index,\n length,\n (child: Blot, childIndex: number, childLength: number) => {\n if (\n (criteria.blotName == null && criteria(child)) ||\n (criteria.blotName != null && child instanceof criteria)\n ) {\n descendants.push(child);\n }\n if (child instanceof ParentBlot) {\n descendants = descendants.concat(\n child.descendants(criteria, childIndex, lengthLeft),\n );\n }\n lengthLeft -= childLength;\n },\n );\n return descendants;\n }\n\n public detach(): void {\n this.children.forEach((child) => {\n child.detach();\n });\n super.detach();\n }\n\n public enforceAllowedChildren(): void {\n let done = false;\n this.children.forEach((child: Blot) => {\n if (done) {\n return;\n }\n const allowed = this.statics.allowedChildren.some(\n (def: BlotConstructor) => child instanceof def,\n );\n if (allowed) {\n return;\n }\n if (child.statics.scope === Scope.BLOCK_BLOT) {\n if (child.next != null) {\n this.splitAfter(child);\n }\n if (child.prev != null) {\n this.splitAfter(child.prev);\n }\n child.parent.unwrap();\n done = true;\n } else if (child instanceof ParentBlot) {\n child.unwrap();\n } else {\n child.remove();\n }\n });\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n this.children.forEachAt(index, length, (child, offset, childLength) => {\n child.formatAt(offset, childLength, name, value);\n });\n }\n\n public insertAt(index: number, value: string, def?: any): void {\n const [child, offset] = this.children.find(index);\n if (child) {\n child.insertAt(offset, value, def);\n } else {\n const blot =\n def == null\n ? this.scroll.create('text', value)\n : this.scroll.create(value, def);\n this.appendChild(blot);\n }\n }\n\n public insertBefore(childBlot: Blot, refBlot?: Blot | null): void {\n if (childBlot.parent != null) {\n childBlot.parent.children.remove(childBlot);\n }\n let refDomNode: Node | null = null;\n this.children.insertBefore(childBlot, refBlot || null);\n childBlot.parent = this;\n if (refBlot != null) {\n refDomNode = refBlot.domNode;\n }\n if (\n this.domNode.parentNode !== childBlot.domNode ||\n this.domNode.nextSibling !== refDomNode\n ) {\n this.domNode.insertBefore(childBlot.domNode, refDomNode);\n }\n childBlot.attach();\n }\n\n public length(): number {\n return this.children.reduce((memo, child) => {\n return memo + child.length();\n }, 0);\n }\n\n public moveChildren(targetParent: Parent, refNode?: Blot | null): void {\n this.children.forEach((child) => {\n targetParent.insertBefore(child, refNode);\n });\n }\n\n public optimize(context?: { [key: string]: any }): void {\n super.optimize(context);\n this.enforceAllowedChildren();\n if (this.uiNode != null && this.uiNode !== this.domNode.firstChild) {\n this.domNode.insertBefore(this.uiNode, this.domNode.firstChild);\n }\n if (this.children.length === 0) {\n if (this.statics.defaultChild != null) {\n const child = this.scroll.create(this.statics.defaultChild.blotName);\n this.appendChild(child);\n // TODO double check if necessary\n // child.optimize(context);\n } else {\n this.remove();\n }\n }\n }\n\n public path(index: number, inclusive = false): [Blot, number][] {\n const [child, offset] = this.children.find(index, inclusive);\n const position: [Blot, number][] = [[this, index]];\n if (child instanceof ParentBlot) {\n return position.concat(child.path(offset, inclusive));\n } else if (child != null) {\n position.push([child, offset]);\n }\n return position;\n }\n\n public removeChild(child: Blot): void {\n this.children.remove(child);\n }\n\n public replaceWith(name: string | Blot, value?: any): Blot {\n const replacement =\n typeof name === 'string' ? this.scroll.create(name, value) : name;\n if (replacement instanceof ParentBlot) {\n this.moveChildren(replacement);\n }\n return super.replaceWith(replacement);\n }\n\n public split(index: number, force = false): Blot | null {\n if (!force) {\n if (index === 0) {\n return this;\n }\n if (index === this.length()) {\n return this.next;\n }\n }\n const after = this.clone() as ParentBlot;\n if (this.parent) {\n this.parent.insertBefore(after, this.next || undefined);\n }\n this.children.forEachAt(index, this.length(), (child, offset, _length) => {\n const split = child.split(offset, force);\n if (split != null) {\n after.appendChild(split);\n }\n });\n return after;\n }\n\n public splitAfter(child: Blot): Parent {\n const after = this.clone() as ParentBlot;\n while (child.next != null) {\n after.appendChild(child.next);\n }\n if (this.parent) {\n this.parent.insertBefore(after, this.next || undefined);\n }\n return after;\n }\n\n public unwrap(): void {\n if (this.parent) {\n this.moveChildren(this.parent, this.next || undefined);\n }\n this.remove();\n }\n\n public update(\n mutations: MutationRecord[],\n _context: { [key: string]: any },\n ): void {\n const addedNodes: Node[] = [];\n const removedNodes: Node[] = [];\n mutations.forEach((mutation) => {\n if (mutation.target === this.domNode && mutation.type === 'childList') {\n addedNodes.push(...mutation.addedNodes);\n removedNodes.push(...mutation.removedNodes);\n }\n });\n removedNodes.forEach((node: Node) => {\n // Check node has actually been removed\n // One exception is Chrome does not immediately remove IFRAMEs\n // from DOM but MutationRecord is correct in its reported removal\n if (\n node.parentNode != null &&\n // @ts-expect-error Fix me later\n node.tagName !== 'IFRAME' &&\n document.body.compareDocumentPosition(node) &\n Node.DOCUMENT_POSITION_CONTAINED_BY\n ) {\n return;\n }\n const blot = this.scroll.find(node);\n if (blot == null) {\n return;\n }\n if (\n blot.domNode.parentNode == null ||\n blot.domNode.parentNode === this.domNode\n ) {\n blot.detach();\n }\n });\n addedNodes\n .filter((node) => {\n return node.parentNode === this.domNode && node !== this.uiNode;\n })\n .sort((a, b) => {\n if (a === b) {\n return 0;\n }\n if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {\n return 1;\n }\n return -1;\n })\n .forEach((node) => {\n let refBlot: Blot | null = null;\n if (node.nextSibling != null) {\n refBlot = this.scroll.find(node.nextSibling);\n }\n const blot = makeAttachedBlot(node, this.scroll);\n if (blot.next !== refBlot || blot.next == null) {\n if (blot.parent != null) {\n blot.parent.removeChild(this);\n }\n this.insertBefore(blot, refBlot || undefined);\n }\n });\n this.enforceAllowedChildren();\n }\n}\n\nexport default ParentBlot;\n","import Attributor from '../attributor/attributor.js';\nimport AttributorStore from '../attributor/store.js';\nimport Scope from '../scope.js';\nimport type {\n Blot,\n BlotConstructor,\n Formattable,\n Parent,\n Root,\n} from './abstract/blot.js';\nimport LeafBlot from './abstract/leaf.js';\nimport ParentBlot from './abstract/parent.js';\n\n// Shallow object comparison\nfunction isEqual(\n obj1: Record,\n obj2: Record,\n): boolean {\n if (Object.keys(obj1).length !== Object.keys(obj2).length) {\n return false;\n }\n for (const prop in obj1) {\n if (obj1[prop] !== obj2[prop]) {\n return false;\n }\n }\n return true;\n}\n\nclass InlineBlot extends ParentBlot implements Formattable {\n public static allowedChildren: BlotConstructor[] = [InlineBlot, LeafBlot];\n public static blotName = 'inline';\n public static scope = Scope.INLINE_BLOT;\n public static tagName: string | string[] = 'SPAN';\n\n static create(value?: unknown) {\n return super.create(value) as HTMLElement;\n }\n\n public static formats(domNode: HTMLElement, scroll: Root): any {\n const match = scroll.query(InlineBlot.blotName);\n if (\n match != null &&\n domNode.tagName === (match as BlotConstructor).tagName\n ) {\n return undefined;\n } else if (typeof this.tagName === 'string') {\n return true;\n } else if (Array.isArray(this.tagName)) {\n return domNode.tagName.toLowerCase();\n }\n return undefined;\n }\n\n protected attributes: AttributorStore;\n\n constructor(scroll: Root, domNode: Node) {\n super(scroll, domNode);\n this.attributes = new AttributorStore(this.domNode);\n }\n\n public format(name: string, value: any): void {\n if (name === this.statics.blotName && !value) {\n this.children.forEach((child) => {\n if (!(child instanceof InlineBlot)) {\n child = child.wrap(InlineBlot.blotName, true);\n }\n this.attributes.copy(child as InlineBlot);\n });\n this.unwrap();\n } else {\n const format = this.scroll.query(name, Scope.INLINE);\n if (format == null) {\n return;\n }\n if (format instanceof Attributor) {\n this.attributes.attribute(format, value);\n } else if (\n value &&\n (name !== this.statics.blotName || this.formats()[name] !== value)\n ) {\n this.replaceWith(name, value);\n }\n }\n }\n\n public formats(): { [index: string]: any } {\n const formats = this.attributes.values();\n const format = this.statics.formats(this.domNode, this.scroll);\n if (format != null) {\n formats[this.statics.blotName] = format;\n }\n return formats;\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n if (\n this.formats()[name] != null ||\n this.scroll.query(name, Scope.ATTRIBUTE)\n ) {\n const blot = this.isolate(index, length) as InlineBlot;\n blot.format(name, value);\n } else {\n super.formatAt(index, length, name, value);\n }\n }\n\n public optimize(context: { [key: string]: any }): void {\n super.optimize(context);\n const formats = this.formats();\n if (Object.keys(formats).length === 0) {\n return this.unwrap(); // unformatted span\n }\n const next = this.next;\n if (\n next instanceof InlineBlot &&\n next.prev === this &&\n isEqual(formats, next.formats())\n ) {\n next.moveChildren(this);\n next.remove();\n }\n }\n\n public replaceWith(name: string | Blot, value?: any): Blot {\n const replacement = super.replaceWith(name, value) as InlineBlot;\n this.attributes.copy(replacement);\n return replacement;\n }\n\n public update(\n mutations: MutationRecord[],\n context: { [key: string]: any },\n ): void {\n super.update(mutations, context);\n const attributeChanged = mutations.some(\n (mutation) =>\n mutation.target === this.domNode && mutation.type === 'attributes',\n );\n if (attributeChanged) {\n this.attributes.build();\n }\n }\n\n public wrap(name: string | Parent, value?: any): Parent {\n const wrapper = super.wrap(name, value);\n if (wrapper instanceof InlineBlot) {\n this.attributes.move(wrapper);\n }\n return wrapper;\n }\n}\n\nexport default InlineBlot;\n","import Attributor from '../attributor/attributor.js';\nimport AttributorStore from '../attributor/store.js';\nimport Scope from '../scope.js';\nimport type {\n Blot,\n BlotConstructor,\n Formattable,\n Root,\n} from './abstract/blot.js';\nimport LeafBlot from './abstract/leaf.js';\nimport ParentBlot from './abstract/parent.js';\nimport InlineBlot from './inline.js';\n\nclass BlockBlot extends ParentBlot implements Formattable {\n public static blotName = 'block';\n public static scope = Scope.BLOCK_BLOT;\n public static tagName: string | string[] = 'P';\n public static allowedChildren: BlotConstructor[] = [\n InlineBlot,\n BlockBlot,\n LeafBlot,\n ];\n\n static create(value?: unknown) {\n return super.create(value) as HTMLElement;\n }\n\n public static formats(domNode: HTMLElement, scroll: Root): any {\n const match = scroll.query(BlockBlot.blotName);\n if (\n match != null &&\n domNode.tagName === (match as BlotConstructor).tagName\n ) {\n return undefined;\n } else if (typeof this.tagName === 'string') {\n return true;\n } else if (Array.isArray(this.tagName)) {\n return domNode.tagName.toLowerCase();\n }\n }\n\n protected attributes: AttributorStore;\n\n constructor(scroll: Root, domNode: Node) {\n super(scroll, domNode);\n this.attributes = new AttributorStore(this.domNode);\n }\n\n public format(name: string, value: any): void {\n const format = this.scroll.query(name, Scope.BLOCK);\n if (format == null) {\n return;\n } else if (format instanceof Attributor) {\n this.attributes.attribute(format, value);\n } else if (name === this.statics.blotName && !value) {\n this.replaceWith(BlockBlot.blotName);\n } else if (\n value &&\n (name !== this.statics.blotName || this.formats()[name] !== value)\n ) {\n this.replaceWith(name, value);\n }\n }\n\n public formats(): { [index: string]: any } {\n const formats = this.attributes.values();\n const format = this.statics.formats(this.domNode, this.scroll);\n if (format != null) {\n formats[this.statics.blotName] = format;\n }\n return formats;\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n if (this.scroll.query(name, Scope.BLOCK) != null) {\n this.format(name, value);\n } else {\n super.formatAt(index, length, name, value);\n }\n }\n\n public insertAt(index: number, value: string, def?: any): void {\n if (def == null || this.scroll.query(value, Scope.INLINE) != null) {\n // Insert text or inline\n super.insertAt(index, value, def);\n } else {\n const after = this.split(index);\n if (after != null) {\n const blot = this.scroll.create(value, def);\n after.parent.insertBefore(blot, after);\n } else {\n throw new Error('Attempt to insertAt after block boundaries');\n }\n }\n }\n\n public replaceWith(name: string | Blot, value?: any): Blot {\n const replacement = super.replaceWith(name, value) as BlockBlot;\n this.attributes.copy(replacement);\n return replacement;\n }\n\n public update(\n mutations: MutationRecord[],\n context: { [key: string]: any },\n ): void {\n super.update(mutations, context);\n const attributeChanged = mutations.some(\n (mutation) =>\n mutation.target === this.domNode && mutation.type === 'attributes',\n );\n if (attributeChanged) {\n this.attributes.build();\n }\n }\n}\n\nexport default BlockBlot;\n","import Scope from '../../scope.js';\nimport BlockBlot from '../block.js';\nimport ParentBlot from './parent.js';\n\nclass ContainerBlot extends ParentBlot {\n public static blotName = 'container';\n public static scope = Scope.BLOCK_BLOT;\n public static tagName: string | string[];\n\n public prev!: BlockBlot | ContainerBlot | null;\n public next!: BlockBlot | ContainerBlot | null;\n\n public checkMerge(): boolean {\n return (\n this.next !== null && this.next.statics.blotName === this.statics.blotName\n );\n }\n\n public deleteAt(index: number, length: number): void {\n super.deleteAt(index, length);\n this.enforceAllowedChildren();\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n super.formatAt(index, length, name, value);\n this.enforceAllowedChildren();\n }\n\n public insertAt(index: number, value: string, def?: any): void {\n super.insertAt(index, value, def);\n this.enforceAllowedChildren();\n }\n\n public optimize(context: { [key: string]: any }): void {\n super.optimize(context);\n if (this.children.length > 0 && this.next != null && this.checkMerge()) {\n this.next.moveChildren(this);\n this.next.remove();\n }\n }\n}\n\nexport default ContainerBlot;\n","import type { Formattable, Root } from './abstract/blot.js';\nimport LeafBlot from './abstract/leaf.js';\n\nclass EmbedBlot extends LeafBlot implements Formattable {\n public static formats(_domNode: HTMLElement, _scroll: Root): any {\n return undefined;\n }\n\n public format(name: string, value: any): void {\n // super.formatAt wraps, which is what we want in general,\n // but this allows subclasses to overwrite for formats\n // that just apply to particular embeds\n super.formatAt(0, this.length(), name, value);\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n if (index === 0 && length === this.length()) {\n this.format(name, value);\n } else {\n super.formatAt(index, length, name, value);\n }\n }\n\n public formats(): { [index: string]: any } {\n return this.statics.formats(this.domNode, this.scroll);\n }\n}\n\nexport default EmbedBlot;\n","import Registry, { type RegistryDefinition } from '../registry.js';\nimport Scope from '../scope.js';\nimport type { Blot, BlotConstructor, Root } from './abstract/blot.js';\nimport ContainerBlot from './abstract/container.js';\nimport ParentBlot from './abstract/parent.js';\nimport BlockBlot from './block.js';\n\nconst OBSERVER_CONFIG = {\n attributes: true,\n characterData: true,\n characterDataOldValue: true,\n childList: true,\n subtree: true,\n};\n\nconst MAX_OPTIMIZE_ITERATIONS = 100;\n\nclass ScrollBlot extends ParentBlot implements Root {\n public static blotName = 'scroll';\n public static defaultChild = BlockBlot;\n public static allowedChildren: BlotConstructor[] = [BlockBlot, ContainerBlot];\n public static scope = Scope.BLOCK_BLOT;\n public static tagName = 'DIV';\n\n public observer: MutationObserver;\n\n constructor(\n public registry: Registry,\n node: HTMLDivElement,\n ) {\n // @ts-expect-error scroll is the root with no parent\n super(null, node);\n this.scroll = this;\n this.build();\n this.observer = new MutationObserver((mutations: MutationRecord[]) => {\n this.update(mutations);\n });\n this.observer.observe(this.domNode, OBSERVER_CONFIG);\n this.attach();\n }\n\n public create(input: Node | string | Scope, value?: any): Blot {\n return this.registry.create(this, input, value);\n }\n\n public find(node: Node | null, bubble = false): Blot | null {\n const blot = this.registry.find(node, bubble);\n if (!blot) {\n return null;\n }\n if (blot.scroll === this) {\n return blot;\n }\n return bubble ? this.find(blot.scroll.domNode.parentNode, true) : null;\n }\n\n public query(\n query: string | Node | Scope,\n scope: Scope = Scope.ANY,\n ): RegistryDefinition | null {\n return this.registry.query(query, scope);\n }\n\n public register(...definitions: RegistryDefinition[]) {\n return this.registry.register(...definitions);\n }\n\n public build(): void {\n if (this.scroll == null) {\n return;\n }\n super.build();\n }\n\n public detach(): void {\n super.detach();\n this.observer.disconnect();\n }\n\n public deleteAt(index: number, length: number): void {\n this.update();\n if (index === 0 && length === this.length()) {\n this.children.forEach((child) => {\n child.remove();\n });\n } else {\n super.deleteAt(index, length);\n }\n }\n\n public formatAt(\n index: number,\n length: number,\n name: string,\n value: any,\n ): void {\n this.update();\n super.formatAt(index, length, name, value);\n }\n\n public insertAt(index: number, value: string, def?: any): void {\n this.update();\n super.insertAt(index, value, def);\n }\n\n public optimize(context?: { [key: string]: any }): void;\n public optimize(\n mutations: MutationRecord[],\n context: { [key: string]: any },\n ): void;\n public optimize(mutations: any = [], context: any = {}): void {\n super.optimize(context);\n const mutationsMap = context.mutationsMap || new WeakMap();\n // We must modify mutations directly, cannot make copy and then modify\n let records = Array.from(this.observer.takeRecords());\n // Array.push currently seems to be implemented by a non-tail recursive function\n // so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());\n while (records.length > 0) {\n mutations.push(records.pop());\n }\n const mark = (blot: Blot | null, markParent = true): void => {\n if (blot == null || blot === this) {\n return;\n }\n if (blot.domNode.parentNode == null) {\n return;\n }\n if (!mutationsMap.has(blot.domNode)) {\n mutationsMap.set(blot.domNode, []);\n }\n if (markParent) {\n mark(blot.parent);\n }\n };\n const optimize = (blot: Blot): void => {\n // Post-order traversal\n if (!mutationsMap.has(blot.domNode)) {\n return;\n }\n if (blot instanceof ParentBlot) {\n blot.children.forEach(optimize);\n }\n mutationsMap.delete(blot.domNode);\n blot.optimize(context);\n };\n let remaining = mutations;\n for (let i = 0; remaining.length > 0; i += 1) {\n if (i >= MAX_OPTIMIZE_ITERATIONS) {\n throw new Error('[Parchment] Maximum optimize iterations reached');\n }\n remaining.forEach((mutation: MutationRecord) => {\n const blot = this.find(mutation.target, true);\n if (blot == null) {\n return;\n }\n if (blot.domNode === mutation.target) {\n if (mutation.type === 'childList') {\n mark(this.find(mutation.previousSibling, false));\n Array.from(mutation.addedNodes).forEach((node: Node) => {\n const child = this.find(node, false);\n mark(child, false);\n if (child instanceof ParentBlot) {\n child.children.forEach((grandChild: Blot) => {\n mark(grandChild, false);\n });\n }\n });\n } else if (mutation.type === 'attributes') {\n mark(blot.prev);\n }\n }\n mark(blot);\n });\n this.children.forEach(optimize);\n remaining = Array.from(this.observer.takeRecords());\n records = remaining.slice();\n while (records.length > 0) {\n mutations.push(records.pop());\n }\n }\n }\n\n public update(\n mutations?: MutationRecord[],\n context: { [key: string]: any } = {},\n ): void {\n mutations = mutations || this.observer.takeRecords();\n const mutationsMap = new WeakMap();\n mutations\n .map((mutation: MutationRecord) => {\n const blot = this.find(mutation.target, true);\n if (blot == null) {\n return null;\n }\n if (mutationsMap.has(blot.domNode)) {\n mutationsMap.get(blot.domNode).push(mutation);\n return null;\n } else {\n mutationsMap.set(blot.domNode, [mutation]);\n return blot;\n }\n })\n .forEach((blot: Blot | null) => {\n if (blot != null && blot !== this && mutationsMap.has(blot.domNode)) {\n blot.update(mutationsMap.get(blot.domNode) || [], context);\n }\n });\n context.mutationsMap = mutationsMap;\n if (mutationsMap.has(this.domNode)) {\n super.update(mutationsMap.get(this.domNode), context);\n }\n this.optimize(mutations, context);\n }\n}\n\nexport default ScrollBlot;\n","import Scope from '../scope.js';\nimport type { Blot, Leaf, Root } from './abstract/blot.js';\nimport LeafBlot from './abstract/leaf.js';\n\nclass TextBlot extends LeafBlot implements Leaf {\n public static readonly blotName = 'text';\n public static scope = Scope.INLINE_BLOT;\n\n public static create(value: string): Text {\n return document.createTextNode(value);\n }\n\n public static value(domNode: Text): string {\n return domNode.data;\n }\n\n public domNode!: Text;\n protected text: string;\n\n constructor(scroll: Root, node: Node) {\n super(scroll, node);\n this.text = this.statics.value(this.domNode);\n }\n\n public deleteAt(index: number, length: number): void {\n this.domNode.data = this.text =\n this.text.slice(0, index) + this.text.slice(index + length);\n }\n\n public index(node: Node, offset: number): number {\n if (this.domNode === node) {\n return offset;\n }\n return -1;\n }\n\n public insertAt(index: number, value: string, def?: any): void {\n if (def == null) {\n this.text = this.text.slice(0, index) + value + this.text.slice(index);\n this.domNode.data = this.text;\n } else {\n super.insertAt(index, value, def);\n }\n }\n\n public length(): number {\n return this.text.length;\n }\n\n public optimize(context: { [key: string]: any }): void {\n super.optimize(context);\n this.text = this.statics.value(this.domNode);\n if (this.text.length === 0) {\n this.remove();\n } else if (this.next instanceof TextBlot && this.next.prev === this) {\n this.insertAt(this.length(), (this.next as TextBlot).value());\n this.next.remove();\n }\n }\n\n public position(index: number, _inclusive = false): [Node, number] {\n return [this.domNode, index];\n }\n\n public split(index: number, force = false): Blot | null {\n if (!force) {\n if (index === 0) {\n return this;\n }\n if (index === this.length()) {\n return this.next;\n }\n }\n const after = this.scroll.create(this.domNode.splitText(index));\n this.parent.insertBefore(after, this.next || undefined);\n this.text = this.statics.value(this.domNode);\n return after;\n }\n\n public update(\n mutations: MutationRecord[],\n _context: { [key: string]: any },\n ): void {\n if (\n mutations.some((mutation) => {\n return (\n mutation.type === 'characterData' && mutation.target === this.domNode\n );\n })\n ) {\n this.text = this.statics.value(this.domNode);\n }\n }\n\n public value(): string {\n return this.text;\n }\n}\n\nexport default TextBlot;\n"],"names":["Scope","match","ClassAttributor","StyleAttributor","ParentBlot","AttributorStore","LeafBlot","InlineBlot","BlockBlot","ContainerBlot"],"mappings":"oRAAK,IAAA,OAAAA,SACHA,OAAAA,OAAA,KAAQ,CAAR,EAAA,OACAA,OAAAA,OAAA,MAAU,EAAV,EAAA,QAEAA,OAAAA,OAAA,UAAa,EAAb,EAAA,YACAA,OAAAA,OAAA,KAAQ,EAAR,EAAA,OACAA,OAAAA,OAAA,OAAU,CAAV,EAAA,SACAA,OAAAA,OAAA,MAAS,EAAT,EAAA,QAEAA,OAAAA,OAAA,WAAa,EAAb,EAAA,aACAA,OAAAA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