UNPKG

29.6 kBSource Map (JSON)View Raw
1{"version":3,"file":"scroll.js","names":["ContainerBlot","LeafBlot","Scope","ScrollBlot","Delta","AttributeMap","Op","Emitter","Block","BlockEmbed","bubbleFormats","Break","Container","isLine","blot","isUpdatable","updateContent","Scroll","blotName","className","tagName","defaultChild","allowedChildren","constructor","registry","domNode","_ref","emitter","batch","optimize","enable","addEventListener","e","handleDragStart","batchStart","Array","isArray","batchEnd","mutations","update","emitMount","emit","events","SCROLL_BLOT_MOUNT","emitUnmount","SCROLL_BLOT_UNMOUNT","emitEmbedUpdate","change","SCROLL_EMBED_UPDATE","deleteAt","index","length","first","offset","line","last","ref","children","head","moveChildren","remove","enabled","arguments","undefined","setAttribute","formatAt","format","value","insertAt","def","scroll","query","BLOCK","create","statics","appendChild","endsWith","slice","embed","insertBefore","scope","INLINE_BLOT","wrapper","insertContents","delta","renderBlocks","deltaToRenderBlocks","concat","insert","pop","shift","shouldInsertNewlineChar","type","descendant","key","insertInlineContents","newlineCharLength","lineEndIndex","formats","attributes","diff","Object","keys","forEach","name","refBlot","refBlotOffset","find","split","renderBlock","block","createBlock","blockEmbed","isEnabled","getAttribute","leaf","path","lines","Number","MAX_VALUE","getLines","blotIndex","blotLength","lengthLeft","forEachAt","child","childIndex","childLength","push","context","SCROLL_OPTIMIZE","source","sources","USER","observer","takeRecords","filter","_ref2","target","SCROLL_BEFORE_UPDATE","SCROLL_UPDATE","updateEmbedAt","b","event","preventDefault","currentBlockDelta","op","splitted","text","INLINE","entries","_ref3","isBlockBlot","BLOT","_ref4","parent","inlineContents","reduce","isInlineEmbed"],"sources":["../../src/blots/scroll.ts"],"sourcesContent":["import { ContainerBlot, LeafBlot, Scope, ScrollBlot } from 'parchment';\nimport type { Blot, Parent, EmbedBlot, ParentBlot, Registry } from 'parchment';\nimport Delta, { AttributeMap, Op } from 'quill-delta';\nimport Emitter from '../core/emitter.js';\nimport type { EmitterSource } from '../core/emitter.js';\nimport Block, { BlockEmbed, bubbleFormats } from './block.js';\nimport Break from './break.js';\nimport Container from './container.js';\n\ntype RenderBlock =\n | {\n type: 'blockEmbed';\n attributes: AttributeMap;\n key: string;\n value: unknown;\n }\n | { type: 'block'; attributes: AttributeMap; delta: Delta };\n\nfunction isLine(blot: unknown): blot is Block | BlockEmbed {\n return blot instanceof Block || blot instanceof BlockEmbed;\n}\n\ninterface UpdatableEmbed {\n updateContent(change: unknown): void;\n}\n\nfunction isUpdatable(blot: Blot): blot is Blot & UpdatableEmbed {\n return typeof (blot as unknown as any).updateContent === 'function';\n}\n\nclass Scroll extends ScrollBlot {\n static blotName = 'scroll';\n static className = 'ql-editor';\n static tagName = 'DIV';\n static defaultChild = Block;\n static allowedChildren = [Block, BlockEmbed, Container];\n\n emitter: Emitter;\n batch: false | MutationRecord[];\n\n constructor(\n registry: Registry,\n domNode: HTMLDivElement,\n { emitter }: { emitter: Emitter },\n ) {\n super(registry, domNode);\n this.emitter = emitter;\n this.batch = false;\n this.optimize();\n this.enable();\n this.domNode.addEventListener('dragstart', (e) => this.handleDragStart(e));\n }\n\n batchStart() {\n if (!Array.isArray(this.batch)) {\n this.batch = [];\n }\n }\n\n batchEnd() {\n if (!this.batch) return;\n const mutations = this.batch;\n this.batch = false;\n this.update(mutations);\n }\n\n emitMount(blot: Blot) {\n this.emitter.emit(Emitter.events.SCROLL_BLOT_MOUNT, blot);\n }\n\n emitUnmount(blot: Blot) {\n this.emitter.emit(Emitter.events.SCROLL_BLOT_UNMOUNT, blot);\n }\n\n emitEmbedUpdate(blot: Blot, change: unknown) {\n this.emitter.emit(Emitter.events.SCROLL_EMBED_UPDATE, blot, change);\n }\n\n deleteAt(index: number, length: number) {\n const [first, offset] = this.line(index);\n const [last] = this.line(index + length);\n super.deleteAt(index, length);\n if (last != null && first !== last && offset > 0) {\n if (first instanceof BlockEmbed || last instanceof BlockEmbed) {\n this.optimize();\n return;\n }\n const ref =\n last.children.head instanceof Break ? null : last.children.head;\n // @ts-expect-error\n first.moveChildren(last, ref);\n // @ts-expect-error\n first.remove();\n }\n this.optimize();\n }\n\n enable(enabled = true) {\n this.domNode.setAttribute('contenteditable', enabled ? 'true' : 'false');\n }\n\n formatAt(index: number, length: number, format: string, value: unknown) {\n super.formatAt(index, length, format, value);\n this.optimize();\n }\n\n insertAt(index: number, value: string, def?: unknown) {\n if (index >= this.length()) {\n if (def == null || this.scroll.query(value, Scope.BLOCK) == null) {\n const blot = this.scroll.create(this.statics.defaultChild.blotName);\n this.appendChild(blot);\n if (def == null && value.endsWith('\\n')) {\n blot.insertAt(0, value.slice(0, -1), def);\n } else {\n blot.insertAt(0, value, def);\n }\n } else {\n const embed = this.scroll.create(value, def);\n this.appendChild(embed);\n }\n } else {\n super.insertAt(index, value, def);\n }\n this.optimize();\n }\n\n insertBefore(blot: Blot, ref?: Blot | null) {\n if (blot.statics.scope === Scope.INLINE_BLOT) {\n const wrapper = this.scroll.create(\n this.statics.defaultChild.blotName,\n ) as Parent;\n wrapper.appendChild(blot);\n super.insertBefore(wrapper, ref);\n } else {\n super.insertBefore(blot, ref);\n }\n }\n\n insertContents(index: number, delta: Delta) {\n const renderBlocks = this.deltaToRenderBlocks(\n delta.concat(new Delta().insert('\\n')),\n );\n const last = renderBlocks.pop();\n if (last == null) return;\n\n this.batchStart();\n\n const first = renderBlocks.shift();\n if (first) {\n const shouldInsertNewlineChar =\n first.type === 'block' &&\n (first.delta.length() === 0 ||\n (!this.descendant(BlockEmbed, index)[0] && index < this.length()));\n const delta =\n first.type === 'block'\n ? first.delta\n : new Delta().insert({ [first.key]: first.value });\n insertInlineContents(this, index, delta);\n const newlineCharLength = first.type === 'block' ? 1 : 0;\n const lineEndIndex = index + delta.length() + newlineCharLength;\n if (shouldInsertNewlineChar) {\n this.insertAt(lineEndIndex - 1, '\\n');\n }\n\n const formats = bubbleFormats(this.line(index)[0]);\n const attributes = AttributeMap.diff(formats, first.attributes) || {};\n Object.keys(attributes).forEach((name) => {\n this.formatAt(lineEndIndex - 1, 1, name, attributes[name]);\n });\n\n index = lineEndIndex;\n }\n\n let [refBlot, refBlotOffset] = this.children.find(index);\n if (renderBlocks.length) {\n if (refBlot) {\n refBlot = refBlot.split(refBlotOffset);\n refBlotOffset = 0;\n }\n\n renderBlocks.forEach((renderBlock) => {\n if (renderBlock.type === 'block') {\n const block = this.createBlock(\n renderBlock.attributes,\n refBlot || undefined,\n );\n insertInlineContents(block, 0, renderBlock.delta);\n } else {\n const blockEmbed = this.create(\n renderBlock.key,\n renderBlock.value,\n ) as EmbedBlot;\n this.insertBefore(blockEmbed, refBlot || undefined);\n Object.keys(renderBlock.attributes).forEach((name) => {\n blockEmbed.format(name, renderBlock.attributes[name]);\n });\n }\n });\n }\n\n if (last.type === 'block' && last.delta.length()) {\n const offset = refBlot\n ? refBlot.offset(refBlot.scroll) + refBlotOffset\n : this.length();\n insertInlineContents(this, offset, last.delta);\n }\n\n this.batchEnd();\n this.optimize();\n }\n\n isEnabled() {\n return this.domNode.getAttribute('contenteditable') === 'true';\n }\n\n leaf(index: number): [LeafBlot | null, number] {\n const last = this.path(index).pop();\n if (!last) {\n return [null, -1];\n }\n\n const [blot, offset] = last;\n return blot instanceof LeafBlot ? [blot, offset] : [null, -1];\n }\n\n line(index: number): [Block | BlockEmbed | null, number] {\n if (index === this.length()) {\n return this.line(index - 1);\n }\n // @ts-expect-error TODO: make descendant() generic\n return this.descendant(isLine, index);\n }\n\n lines(index = 0, length = Number.MAX_VALUE): (Block | BlockEmbed)[] {\n const getLines = (\n blot: ParentBlot,\n blotIndex: number,\n blotLength: number,\n ) => {\n let lines: (Block | BlockEmbed)[] = [];\n let lengthLeft = blotLength;\n blot.children.forEachAt(\n blotIndex,\n blotLength,\n (child, childIndex, childLength) => {\n if (isLine(child)) {\n lines.push(child);\n } else if (child instanceof ContainerBlot) {\n lines = lines.concat(getLines(child, childIndex, lengthLeft));\n }\n lengthLeft -= childLength;\n },\n );\n return lines;\n };\n return getLines(this, index, length);\n }\n\n optimize(context?: { [key: string]: any }): void;\n optimize(\n mutations?: MutationRecord[],\n context?: { [key: string]: any },\n ): void;\n optimize(mutations = [], context = {}) {\n if (this.batch) return;\n super.optimize(mutations, context);\n if (mutations.length > 0) {\n this.emitter.emit(Emitter.events.SCROLL_OPTIMIZE, mutations, context);\n }\n }\n\n path(index: number) {\n return super.path(index).slice(1); // Exclude self\n }\n\n remove() {\n // Never remove self\n }\n\n update(source?: EmitterSource): void;\n update(mutations?: MutationRecord[]): void;\n update(mutations?: MutationRecord[] | EmitterSource): void {\n if (this.batch) {\n if (Array.isArray(mutations)) {\n this.batch = this.batch.concat(mutations);\n }\n return;\n }\n let source: EmitterSource = Emitter.sources.USER;\n if (typeof mutations === 'string') {\n source = mutations;\n }\n if (!Array.isArray(mutations)) {\n mutations = this.observer.takeRecords();\n }\n mutations = mutations.filter(({ target }) => {\n const blot = this.find(target, true);\n return blot && !isUpdatable(blot);\n });\n if (mutations.length > 0) {\n this.emitter.emit(Emitter.events.SCROLL_BEFORE_UPDATE, source, mutations);\n }\n super.update(mutations.concat([])); // pass copy\n if (mutations.length > 0) {\n this.emitter.emit(Emitter.events.SCROLL_UPDATE, source, mutations);\n }\n }\n\n updateEmbedAt(index: number, key: string, change: unknown) {\n // Currently it only supports top-level embeds (BlockEmbed).\n // We can update `ParentBlot` in parchment to support inline embeds.\n const [blot] = this.descendant((b: Blot) => b instanceof BlockEmbed, index);\n if (blot && blot.statics.blotName === key && isUpdatable(blot)) {\n blot.updateContent(change);\n }\n }\n\n protected handleDragStart(event: DragEvent) {\n event.preventDefault();\n }\n\n private deltaToRenderBlocks(delta: Delta) {\n const renderBlocks: RenderBlock[] = [];\n\n let currentBlockDelta = new Delta();\n delta.forEach((op) => {\n const insert = op?.insert;\n if (!insert) return;\n if (typeof insert === 'string') {\n const splitted = insert.split('\\n');\n splitted.slice(0, -1).forEach((text) => {\n currentBlockDelta.insert(text, op.attributes);\n renderBlocks.push({\n type: 'block',\n delta: currentBlockDelta,\n attributes: op.attributes ?? {},\n });\n currentBlockDelta = new Delta();\n });\n const last = splitted[splitted.length - 1];\n if (last) {\n currentBlockDelta.insert(last, op.attributes);\n }\n } else {\n const key = Object.keys(insert)[0];\n if (!key) return;\n if (this.query(key, Scope.INLINE)) {\n currentBlockDelta.push(op);\n } else {\n if (currentBlockDelta.length()) {\n renderBlocks.push({\n type: 'block',\n delta: currentBlockDelta,\n attributes: {},\n });\n }\n currentBlockDelta = new Delta();\n renderBlocks.push({\n type: 'blockEmbed',\n key,\n value: insert[key],\n attributes: op.attributes ?? {},\n });\n }\n }\n });\n\n if (currentBlockDelta.length()) {\n renderBlocks.push({\n type: 'block',\n delta: currentBlockDelta,\n attributes: {},\n });\n }\n\n return renderBlocks;\n }\n\n private createBlock(attributes: AttributeMap, refBlot?: Blot) {\n let blotName: string | undefined;\n const formats: AttributeMap = {};\n\n Object.entries(attributes).forEach(([key, value]) => {\n const isBlockBlot = this.query(key, Scope.BLOCK & Scope.BLOT) != null;\n if (isBlockBlot) {\n blotName = key;\n } else {\n formats[key] = value;\n }\n });\n\n const block = this.create(\n blotName || this.statics.defaultChild.blotName,\n blotName ? attributes[blotName] : undefined,\n ) as ParentBlot;\n\n this.insertBefore(block, refBlot || undefined);\n\n const length = block.length();\n Object.entries(formats).forEach(([key, value]) => {\n block.formatAt(0, length, key, value);\n });\n\n return block;\n }\n}\n\nfunction insertInlineContents(\n parent: ParentBlot,\n index: number,\n inlineContents: Delta,\n) {\n inlineContents.reduce((index, op) => {\n const length = Op.length(op);\n let attributes = op.attributes || {};\n if (op.insert != null) {\n if (typeof op.insert === 'string') {\n const text = op.insert;\n parent.insertAt(index, text);\n const [leaf] = parent.descendant(LeafBlot, index);\n const formats = bubbleFormats(leaf);\n attributes = AttributeMap.diff(formats, attributes) || {};\n } else if (typeof op.insert === 'object') {\n const key = Object.keys(op.insert)[0]; // There should only be one key\n if (key == null) return index;\n parent.insertAt(index, key, op.insert[key]);\n const isInlineEmbed = parent.scroll.query(key, Scope.INLINE) != null;\n if (isInlineEmbed) {\n const [leaf] = parent.descendant(LeafBlot, index);\n const formats = bubbleFormats(leaf);\n attributes = AttributeMap.diff(formats, attributes) || {};\n }\n }\n }\n Object.keys(attributes).forEach((key) => {\n parent.formatAt(index, length, key, attributes[key]);\n });\n return index + length;\n }, index);\n}\n\nexport default Scroll;\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,UAAU,QAAQ,WAAW;AAEtE,OAAOC,KAAK,IAAIC,YAAY,EAAEC,EAAE,QAAQ,aAAa;AACrD,OAAOC,OAAO,MAAM,oBAAoB;AAExC,OAAOC,KAAK,IAAIC,UAAU,EAAEC,aAAa,QAAQ,YAAY;AAC7D,OAAOC,KAAK,MAAM,YAAY;AAC9B,OAAOC,SAAS,MAAM,gBAAgB;AAWtC,SAASC,MAAMA,CAACC,IAAa,EAA8B;EACzD,OAAOA,IAAI,YAAYN,KAAK,IAAIM,IAAI,YAAYL,UAAU;AAC5D;AAMA,SAASM,WAAWA,CAACD,IAAU,EAAiC;EAC9D,OAAO,OAAQA,IAAI,CAAoBE,aAAa,KAAK,UAAU;AACrE;AAEA,MAAMC,MAAM,SAASd,UAAU,CAAC;EAC9B,OAAOe,QAAQ,GAAG,QAAQ;EAC1B,OAAOC,SAAS,GAAG,WAAW;EAC9B,OAAOC,OAAO,GAAG,KAAK;EACtB,OAAOC,YAAY,GAAGb,KAAK;EAC3B,OAAOc,eAAe,GAAG,CAACd,KAAK,EAAEC,UAAU,EAAEG,SAAS,CAAC;EAKvDW,WAAWA,CACTC,QAAkB,EAClBC,OAAuB,EAAAC,IAAA,EAEvB;IAAA,IADA;MAAEC;IAA8B,CAAC,GAAAD,IAAA;IAEjC,KAAK,CAACF,QAAQ,EAAEC,OAAO,CAAC;IACxB,IAAI,CAACE,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,KAAK,GAAG,KAAK;IAClB,IAAI,CAACC,QAAQ,CAAC,CAAC;IACf,IAAI,CAACC,MAAM,CAAC,CAAC;IACb,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