UNPKG

@vaadin/rich-text-editor

Version:
8 lines 126 kB
/*! * Quill Editor v2.0.3 * https://quilljs.com * Copyright (c) 2017-2026, Slab * Copyright (c) 2014, Jason Chen * Copyright (c) 2013, salesforce.com */ !function(t,e){t.Quill=e()}(window,(function(){return function(){"use strict";var t={698:function(t,e,n){n.d(e,{Ay:function(){return a},Ji:function(){return h},zo:function(){return c}});var s=n(3),i=n(398),r=n(36),o=n(850),l=n(508);class a extends s.BlockBlot{cache={};delta(){return null==this.cache.delta&&(this.cache.delta=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.descendants(s.LeafBlot).reduce(((t,n)=>0===n.length()?t:t.insert(n.value(),h(n,{},e))),new i.Ay).insert("\n",h(t))}(this)),this.cache.delta}deleteAt(t,e){super.deleteAt(t,e),this.cache={}}formatAt(t,e,n,i){e<=0||(this.scroll.query(n,s.Scope.BLOCK)?t+e===this.length()&&this.format(n,i):super.formatAt(t,Math.min(e,this.length()-t-1),n,i),this.cache={})}insertAt(t,e,n){if(null!=n)return super.insertAt(t,e,n),void(this.cache={});if(0===e.length)return;const s=e.split("\n"),i=s.shift();i.length>0&&(t<this.length()-1||null==this.children.tail?super.insertAt(Math.min(t,this.length()-1),i):this.children.tail.insertAt(this.children.tail.length(),i),this.cache={});let r=this;s.reduce(((t,e)=>(r=r.split(t,!0),r.insertAt(0,e),e.length)),t+i.length)}insertBefore(t,e){const{head:n}=this.children;super.insertBefore(t,e),n instanceof r.A&&n.remove(),this.cache={}}length(){return null==this.cache.length&&(this.cache.length=super.length()+1),this.cache.length}moveChildren(t,e){super.moveChildren(t,e),this.cache={}}optimize(t){super.optimize(t),this.cache={}}path(t){return super.path(t,!0)}removeChild(t){super.removeChild(t),this.cache={}}split(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&(0===t||t>=this.length()-1)){const e=this.clone();return 0===t?(this.parent.insertBefore(e,this),this):(this.parent.insertBefore(e,this.next),e)}const n=super.split(t,e);return this.cache={},n}}a.blotName="block",a.tagName="P",a.defaultChild=r.A,a.allowedChildren=[r.A,o.A,s.EmbedBlot,l.A];class c extends s.EmbedBlot{attach(){super.attach(),this.attributes=new s.AttributorStore(this.domNode)}delta(){return(new i.Ay).insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const n=this.scroll.query(t,s.Scope.BLOCK_ATTRIBUTE);null!=n&&this.attributes.attribute(n,e)}formatAt(t,e,n,s){this.format(n,s)}insertAt(t,e,n){if(null!=n)return void super.insertAt(t,e,n);const s=e.split("\n"),i=s.pop(),r=s.map((t=>{const e=this.scroll.create(a.blotName);return e.insertAt(0,t),e})),o=this.split(t);r.forEach((t=>{this.parent.insertBefore(t,o)})),i&&this.parent.insertBefore(this.scroll.create("text",i),o)}}function h(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return null==t?e:("formats"in t&&"function"==typeof t.formats&&(e={...e,...t.formats()},n&&delete e["code-token"]),null==t.parent||"scroll"===t.parent.statics.blotName||t.parent.statics.scope!==t.statics.scope?e:h(t.parent,e,n))}c.scope=s.Scope.BLOCK_BLOT},36:function(t,e,n){var s=n(3);class i extends s.EmbedBlot{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}i.blotName="break",i.tagName="BR",e.A=i},580:function(t,e,n){var s=n(3);class i extends s.ContainerBlot{}e.A=i},541:function(t,e,n){var s=n(3),i=n(508);class r extends s.EmbedBlot{static blotName="cursor";static className="ql-cursor";static tagName="span";static CONTENTS="\ufeff";static value(){}constructor(t,e,n){super(t,e),this.selection=n,this.textNode=document.createTextNode(r.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){null!=this.parent&&this.parent.removeChild(this)}format(t,e){if(0!==this.savedLength)return void super.format(t,e);let n=this,i=0;for(;null!=n&&n.statics.scope!==s.Scope.BLOCK_BLOT;)i+=n.offset(n.parent),n=n.parent;null!=n&&(this.savedLength=r.CONTENTS.length,n.optimize(),n.formatAt(i,r.CONTENTS.length,t,e),this.savedLength=0)}index(t,e){return t===this.textNode?0:super.index(t,e)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||null==this.parent)return null;const t=this.selection.getNativeRange();for(;null!=this.domNode.lastChild&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);const e=this.prev instanceof i.A?this.prev:null,n=e?e.length():0,s=this.next instanceof i.A?this.next:null,o=s?s.text:"",{textNode:l}=this,a=l.data.split(r.CONTENTS).join("");let c;if(l.data=r.CONTENTS,e)c=e,(a||s)&&(e.insertAt(e.length(),a+o),s&&s.remove());else if(s)c=s,s.insertAt(0,a);else{const t=document.createTextNode(a);c=this.scroll.create(t),this.parent.insertBefore(c,this)}if(this.remove(),t){const i=(t,i)=>e&&t===e.domNode?i:t===l?n+i-1:s&&t===s.domNode?n+a.length+i:null,r=i(t.start.node,t.start.offset),o=i(t.end.node,t.end.offset);if(null!==r&&null!==o)return{startNode:c.domNode,startOffset:r,endNode:c.domNode,endOffset:o}}return null}update(t,e){if(t.some((t=>"characterData"===t.type&&t.target===this.textNode))){const t=this.restore();t&&(e.range=t)}}optimize(t){super.optimize(t);let{parent:e}=this;for(;e;){if("A"===e.domNode.tagName){this.savedLength=r.CONTENTS.length,e.isolate(this.offset(e),this.length()).unwrap(),this.savedLength=0;break}e=e.parent}}value(){return""}}e.A=r},746:function(t,e,n){var s=n(3),i=n(508);const r="\ufeff";class o extends s.EmbedBlot{constructor(t,e){super(t,e),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach((t=>{this.contentNode.appendChild(t)})),this.leftGuard=document.createTextNode(r),this.rightGuard=document.createTextNode(r),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(t,e){return t===this.leftGuard?0:t===this.rightGuard?1:super.index(t,e)}restore(t){let e,n=null;const s=t.data.split(r).join("");if(t===this.leftGuard)if(this.prev instanceof i.A){const t=this.prev.length();this.prev.insertAt(t,s),n={startNode:this.prev.domNode,startOffset:t+s.length}}else e=document.createTextNode(s),this.parent.insertBefore(this.scroll.create(e),this),n={startNode:e,startOffset:s.length};else t===this.rightGuard&&(this.next instanceof i.A?(this.next.insertAt(0,s),n={startNode:this.next.domNode,startOffset:s.length}):(e=document.createTextNode(s),this.parent.insertBefore(this.scroll.create(e),this.next),n={startNode:e,startOffset:s.length}));return t.data=r,n}update(t,e){t.forEach((t=>{if("characterData"===t.type&&(t.target===this.leftGuard||t.target===this.rightGuard)){const n=this.restore(t.target);n&&(e.range=n)}}))}}e.A=o},850:function(t,e,n){var s=n(3),i=n(36),r=n(508);class o extends s.InlineBlot{static allowedChildren=[o,i.A,s.EmbedBlot,r.A];static order=["cursor","inline","link","underline","strike","italic","bold","script","code"];static compare(t,e){const n=o.order.indexOf(t),s=o.order.indexOf(e);return n>=0||s>=0?n-s:t===e?0:t<e?-1:1}formatAt(t,e,n,i){if(o.compare(this.statics.blotName,n)<0&&this.scroll.query(n,s.Scope.BLOT)){const s=this.isolate(t,e);i&&s.wrap(n,i)}else super.formatAt(t,e,n,i)}optimize(t){if(super.optimize(t),this.parent instanceof o&&o.compare(this.statics.blotName,this.parent.statics.blotName)>0){const t=this.parent.isolate(this.offset(),this.length());this.moveChildren(t),t.wrap(this)}}}e.A=o},508:function(t,e,n){n.d(e,{A:function(){return i},X:function(){return o}});var s=n(3);class i extends s.TextBlot{}const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function o(t){return t.replace(/[&<>"']/g,(t=>r[t]))}},729:function(t,e,n){n.d(e,{default:function(){return B}});var s=n(543),i=n(698),r=n(36),o=n(580),l=n(541),a=n(746),c=n(850),h=n(3),u=n(398),d=n(200);function f(t){return t instanceof i.Ay||t instanceof i.zo}function p(t){return"function"==typeof t.updateContent}class m extends h.ScrollBlot{static blotName="scroll";static className="ql-editor";static tagName="DIV";static defaultChild=i.Ay;static allowedChildren=[i.Ay,i.zo,o.A];constructor(t,e,n){let{emitter:s}=n;super(t,e),this.emitter=s,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",(t=>this.handleDragStart(t)))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;const t=this.batch;this.batch=!1,this.update(t)}emitMount(t){this.emitter.emit(d.A.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(d.A.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,e){this.emitter.emit(d.A.events.SCROLL_EMBED_UPDATE,t,e)}deleteAt(t,e){const[n,s]=this.line(t),[o]=this.line(t+e);if(super.deleteAt(t,e),null!=o&&n!==o&&s>0){if(n instanceof i.zo||o instanceof i.zo)return void this.optimize();const t=o.children.head instanceof r.A?null:o.children.head;n.moveChildren(o,t),n.remove()}this.optimize()}enable(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.domNode.setAttribute("contenteditable",t?"true":"false")}formatAt(t,e,n,s){super.formatAt(t,e,n,s),this.optimize()}insertAt(t,e,n){if(t>=this.length())if(null==n||null==this.scroll.query(e,h.Scope.BLOCK)){const t=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(t),null==n&&e.endsWith("\n")?t.insertAt(0,e.slice(0,-1),n):t.insertAt(0,e,n)}else{const t=this.scroll.create(e,n);this.appendChild(t)}else super.insertAt(t,e,n);this.optimize()}insertBefore(t,e){if(t.statics.scope===h.Scope.INLINE_BLOT){const n=this.scroll.create(this.statics.defaultChild.blotName);n.appendChild(t),super.insertBefore(n,e)}else super.insertBefore(t,e)}insertContents(t,e){const n=this.deltaToRenderBlocks(e.concat((new u.Ay).insert("\n"))),s=n.pop();if(null==s)return;this.batchStart();const r=n.shift();if(r){const e="block"===r.type&&(0===r.delta.length()||!this.descendant(i.zo,t)[0]&&t<this.length()),n="block"===r.type?r.delta:(new u.Ay).insert({[r.key]:r.value});g(this,t,n);const s="block"===r.type?1:0,o=t+n.length()+s;e&&this.insertAt(o-1,"\n");const l=(0,i.Ji)(this.line(t)[0]),a=u.xb.diff(l,r.attributes)||{};Object.keys(a).forEach((t=>{this.formatAt(o-1,1,t,a[t])})),t=o}let[o,l]=this.children.find(t);n.length&&(o&&(o=o.split(l),l=0),n.forEach((t=>{if("block"===t.type)g(this.createBlock(t.attributes,o||void 0),0,t.delta);else{const e=this.create(t.key,t.value);this.insertBefore(e,o||void 0),Object.keys(t.attributes).forEach((n=>{e.format(n,t.attributes[n])}))}}))),"block"===s.type&&s.delta.length()&&g(this,o?o.offset(o.scroll)+l:this.length(),s.delta),this.batchEnd(),this.optimize()}isEnabled(){return"true"===this.domNode.getAttribute("contenteditable")}leaf(t){const e=this.path(t).pop();if(!e)return[null,-1];const[n,s]=e;return n instanceof h.LeafBlot?[n,s]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(f,t)}lines(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_VALUE;const n=(t,e,s)=>{let i=[],r=s;return t.children.forEachAt(e,s,((t,e,s)=>{f(t)?i.push(t):t instanceof h.ContainerBlot&&(i=i.concat(n(t,e,r))),r-=s})),i};return n(this,t,e)}optimize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.batch||(super.optimize(t,e),t.length>0&&this.emitter.emit(d.A.events.SCROLL_OPTIMIZE,t,e))}path(t){return super.path(t).slice(1)}remove(){}update(t){if(this.batch)return void(Array.isArray(t)&&(this.batch=this.batch.concat(t)));let e=d.A.sources.USER;"string"==typeof t&&(e=t),Array.isArray(t)||(t=this.observer.takeRecords()),(t=t.filter((t=>{let{target:e}=t;const n=this.find(e,!0);return n&&!p(n)}))).length>0&&this.emitter.emit(d.A.events.SCROLL_BEFORE_UPDATE,e,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(d.A.events.SCROLL_UPDATE,e,t)}updateEmbedAt(t,e,n){const[s]=this.descendant((t=>t instanceof i.zo),t);s&&s.statics.blotName===e&&p(s)&&s.updateContent(n)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){const e=[];let n=new u.Ay;return t.forEach((t=>{const s=t?.insert;if(s)if("string"==typeof s){const i=s.split("\n");i.slice(0,-1).forEach((s=>{n.insert(s,t.attributes),e.push({type:"block",delta:n,attributes:t.attributes??{}}),n=new u.Ay}));const r=i[i.length-1];r&&n.insert(r,t.attributes)}else{const i=Object.keys(s)[0];if(!i)return;this.query(i,h.Scope.INLINE)?n.push(t):(n.length()&&e.push({type:"block",delta:n,attributes:{}}),n=new u.Ay,e.push({type:"blockEmbed",key:i,value:s[i],attributes:t.attributes??{}}))}})),n.length()&&e.push({type:"block",delta:n,attributes:{}}),e}createBlock(t,e){let n;const s={};Object.entries(t).forEach((t=>{let[e,i]=t;null!=this.query(e,h.Scope.BLOCK&h.Scope.BLOT)?n=e:s[e]=i}));const i=this.create(n||this.statics.defaultChild.blotName,n?t[n]:void 0);this.insertBefore(i,e||void 0);const r=i.length();return Object.entries(s).forEach((t=>{let[e,n]=t;i.formatAt(0,r,e,n)})),i}}function g(t,e,n){n.reduce(((e,n)=>{const s=u.Op.length(n);let r=n.attributes||{};if(null!=n.insert)if("string"==typeof n.insert){const s=n.insert;t.insertAt(e,s);const[o]=t.descendant(h.LeafBlot,e),l=(0,i.Ji)(o);r=u.xb.diff(l,r)||{}}else if("object"==typeof n.insert){const s=Object.keys(n.insert)[0];if(null==s)return e;if(t.insertAt(e,s,n.insert[s]),null!=t.scroll.query(s,h.Scope.INLINE)){const[n]=t.descendant(h.LeafBlot,e),s=(0,i.Ji)(n);r=u.xb.diff(s,r)||{}}}return Object.keys(r).forEach((n=>{t.formatAt(e,s,n,r[n])})),e+s}),e)}var b=m,y=n(508),A=n(584),N=n(266);class v extends N.A{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};lastRecorded=0;ignoreChange=!1;stack={undo:[],redo:[]};currentRange=null;constructor(t,e){super(t,e),this.quill.on(s.Ay.events.EDITOR_CHANGE,((t,e,n,i)=>{t===s.Ay.events.SELECTION_CHANGE?e&&i!==s.Ay.sources.SILENT&&(this.currentRange=e):t===s.Ay.events.TEXT_CHANGE&&(this.ignoreChange||(this.options.userOnly&&i!==s.Ay.sources.USER?this.transform(e):this.record(e,n)),this.currentRange=x(this.currentRange,e))})),this.quill.keyboard.addBinding({key:"z",shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:["z","Z"],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:"y",shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener("beforeinput",(t=>{"historyUndo"===t.inputType?(this.undo(),t.preventDefault()):"historyRedo"===t.inputType&&(this.redo(),t.preventDefault())}))}change(t,e){if(0===this.stack[t].length)return;const n=this.stack[t].pop();if(!n)return;const i=this.quill.getContents(),r=n.delta.invert(i);this.stack[e].push({delta:r,range:x(n.range,r)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,s.Ay.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(t,e){if(0===t.ops.length)return;this.stack.redo=[];let n=t.invert(e),s=this.currentRange;const i=Date.now();if(this.lastRecorded+this.options.delay>i&&this.stack.undo.length>0){const t=this.stack.undo.pop();t&&(n=n.compose(t.delta),s=t.range)}else this.lastRecorded=i;0!==n.length()&&(this.stack.undo.push({delta:n,range:s}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(t){E(this.stack.undo,t),E(this.stack.redo,t)}undo(){this.change("undo","redo")}restoreSelection(t){if(t.range)this.quill.setSelection(t.range,s.Ay.sources.USER);else{const e=function(t,e){const n=e.reduce(((t,e)=>t+(e.delete||0)),0);let s=e.length()-n;return function(t,e){const n=e.ops[e.ops.length-1];return null!=n&&(null!=n.insert?"string"==typeof n.insert&&n.insert.endsWith("\n"):null!=n.attributes&&Object.keys(n.attributes).some((e=>null!=t.query(e,h.Scope.BLOCK))))}(t,e)&&(s-=1),s}(this.quill.scroll,t.delta);this.quill.setSelection(e,s.Ay.sources.USER)}}}function E(t,e){let n=e;for(let e=t.length-1;e>=0;e-=1){const s=t[e];t[e]={delta:n.transform(s.delta,!0),range:s.range&&x(s.range,n)},n=s.delta.transform(n),0===t[e].delta.length()&&t.splice(e,1)}}function x(t,e){if(!t)return t;const n=e.transformPosition(t.index);return{index:n,length:e.transformPosition(t.index+t.length)-n}}var L=n(123);class S extends N.A{constructor(t,e){super(t,e),t.root.addEventListener("drop",(e=>{e.preventDefault();let n=null;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(e.clientX,e.clientY);else if(document.caretPositionFromPoint){const t=document.caretPositionFromPoint(e.clientX,e.clientY);n=document.createRange(),n.setStart(t.offsetNode,t.offset),n.setEnd(t.offsetNode,t.offset)}const s=n&&t.selection.normalizeNative(n);if(s){const n=t.selection.normalizedToRange(s);e.dataTransfer?.files&&this.upload(n,e.dataTransfer.files)}}))}upload(t,e){const n=[];Array.from(e).forEach((t=>{t&&this.options.mimetypes?.includes(t.type)&&n.push(t)})),n.length>0&&this.options.handler.call(this,t,n)}}S.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(t,e){if(!this.quill.scroll.query("image"))return;const n=e.map((t=>new Promise((e=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.readAsDataURL(t)}))));Promise.all(n).then((e=>{const n=e.reduce(((t,e)=>t.insert({image:e})),(new u.Ay).retain(t.index).delete(t.length));this.quill.updateContents(n,d.A.sources.USER),this.quill.setSelection(t.index+e.length,d.A.sources.SILENT)}))}};var T=S;const k=["insertText","insertReplacementText"];class O extends N.A{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",(t=>{this.handleBeforeInput(t)})),/Android/i.test(navigator.userAgent)||t.on(s.Ay.events.COMPOSITION_BEFORE_START,(()=>{this.handleCompositionStart()}))}deleteRange(t){(0,L.Xo)({range:t,quill:this.quill})}replaceText(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(0===t.length)return!1;if(e){const n=this.quill.getFormat(t.index,1);this.deleteRange(t),this.quill.updateContents((new u.Ay).retain(t.index).insert(e,n),s.Ay.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,s.Ay.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!k.includes(t.inputType))return;const e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||!0===e.collapsed)return;const n=function(t){return"string"==typeof t.data?t.data:t.dataTransfer?.types.includes("text/plain")?t.dataTransfer.getData("text/plain"):null}(t);if(null==n)return;const s=this.quill.selection.normalizeNative(e),i=s?this.quill.selection.normalizedToRange(s):null;i&&this.replaceText(i,n)&&t.preventDefault()}handleCompositionStart(){const t=this.quill.getSelection();t&&this.replaceText(t)}}var w=O;const C=/Mac/i.test(navigator.platform);class q extends N.A{isListening=!1;selectionChangeDeadline=0;constructor(t,e){super(t,e),this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(t,e){let{line:n,event:i}=e;if(!(n instanceof h.ParentBlot&&n.uiNode))return!0;const r="rtl"===getComputedStyle(n.domNode).direction;return!!(r&&"ArrowRight"!==i.key||!r&&"ArrowLeft"!==i.key)||(this.quill.setSelection(t.index-1,t.length+(i.shiftKey?1:0),s.Ay.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",(t=>{!t.defaultPrevented&&(t=>"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowUp"===t.key||"ArrowDown"===t.key||"Home"===t.key||!(!C||"a"!==t.key||!0!==t.ctrlKey))(t)&&this.ensureListeningToSelectionChange()}))}ensureListeningToSelectionChange(){this.selectionChangeDeadline=Date.now()+100,this.isListening||(this.isListening=!0,document.addEventListener("selectionchange",(()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()}),{once:!0}))}handleSelectionChange(){const t=document.getSelection();if(!t)return;const e=t.getRangeAt(0);if(!0!==e.collapsed||0!==e.startOffset)return;const n=this.quill.scroll.find(e.startContainer);if(!(n instanceof h.ParentBlot&&n.uiNode))return;const s=document.createRange();s.setStartAfter(n.uiNode),s.setEndAfter(n.uiNode),t.removeAllRanges(),t.addRange(s)}}var R=q;s.Ay.register({"blots/block":i.Ay,"blots/block/embed":i.zo,"blots/break":r.A,"blots/container":o.A,"blots/cursor":l.A,"blots/embed":a.A,"blots/inline":c.A,"blots/scroll":b,"blots/text":y.A,"modules/clipboard":A.Ay,"modules/history":v,"modules/keyboard":L.Ay,"modules/uploader":T,"modules/input":w,"modules/uiNode":R});var B=s.Ay},200:function(t,e,n){n.d(e,{A:function(){return l}});class s{listener;context;once;constructor(t,e,n=!1){this.listener=t,this.context=e,this.once=n}}class i{static prefixed=!1;_events=Object.create(null);_eventsCount=0;#t(t,e,n,i){if("function"!=typeof e)throw new TypeError("The listener must be a function");const r=new s(e,n||this,i),o=this._events[t];return Array.isArray(o)?o.push(r):o?this._events[t]=[o,r]:(this._events[t]=r,this._eventsCount++),this}clearEvent(t){0==--this._eventsCount?this._events=Object.create(null):delete this._events[t]}eventNames(){return 0===this._eventsCount?[]:Reflect.ownKeys(this._events)}listeners(t){const e=this._events[t];return e?Array.isArray(e)?e.map((t=>t.listener)):[e.listener]:[]}listenerCount(t){const e=this._events[t];return e?Array.isArray(e)?e.length:1:0}emit(t,...e){const n=this._events[t];return!!n&&(Array.isArray(n)?n.slice(0).forEach((n=>{n.once&&this.removeListener(t,n.listener,void 0,!0),n.listener.call(n.context,...e)})):(n.once&&this.removeListener(t,n.listener,void 0,!0),n.listener.call(n.context,...e)),!0)}on(t,e,n){return this.#t(t,e,n,!1)}once(t,e,n){return this.#t(t,e,n,!0)}removeListener(t,e,n,s){const i=this._events[t];if(!i)return this;if(!e)return this.clearEvent(t),this;if(Array.isArray(i)){const r=[];i.forEach((t=>{(t.listener!==e||s&&!t.once||n&&t.context!==n)&&r.push(t)})),r.length?this._events[t]=1===r.length?r[0]:r:this.clearEvent(t)}else i.listener!==e||s&&!i.once||n&&i.context!==n||this.clearEvent(t);return this}removeAllListeners(t){return t?this._events[t]&&this.clearEvent(t):(this._events=Object.create(null),this._eventsCount=0),this}off(t,e,n,s){return this.removeListener(t,e,n,s)}addListener(t,e,n){return this.on(t,e,n)}}const r=(0,n(78).A)("quill:events"),o=[];["selectionchange","mousedown","mouseup","click"].forEach((t=>{document.addEventListener(t,(function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];o.forEach((t=>{t.handleDOM(...e)}))}))}));var l=class extends i{static events={EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_BLOT_MOUNT:"scroll-blot-mount",SCROLL_BLOT_UNMOUNT:"scroll-blot-unmount",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SCROLL_EMBED_UPDATE:"scroll-embed-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change",COMPOSITION_BEFORE_START:"composition-before-start",COMPOSITION_START:"composition-start",COMPOSITION_BEFORE_END:"composition-before-end",COMPOSITION_END:"composition-end"};static sources={API:"api",SILENT:"silent",USER:"user"};constructor(){super(),this.domListeners={},this.on("error",r.error)}connect(){o.push(this)}disconnect(){o.splice(o.indexOf(this),1)}emit(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return r.log.call(r,...e),super.emit(...e)}handleDOM(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++)n[s-1]=arguments[s];const i=t.composedPath()[0];(this.domListeners[t.type]||[]).forEach((e=>{let{node:s,handler:r}=e;(i===s||((t,e)=>{if(e.getRootNode()===document)return t.contains(e);for(;!t.contains(e);){const t=e.getRootNode();if(!t)return!1;const n=t.host;if(!n)return!1;e=n}return!0})(s,i))&&r(t,...n)}))}listenDOM(t,e,n){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:e,handler:n})}}},78:function(t,e){const n=["error","warn","log","info"];let s="warn";function i(t){if(s&&n.indexOf(t)<=n.indexOf(s)){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];console[t](...i)}}function r(t){return n.reduce(((e,n)=>(e[n]=i.bind(console,n,t),e)),{})}r.level=t=>{s=t},i.level=r.level,e.A=r},266:function(t,e){e.A=class{static DEFAULTS={};constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.quill=t,this.options=e}}},543:function(t,e,n){n.d(e,{Ay:function(){return B}});var s=n(3),i=n(398),r=n(698),o=n(36),l=n(541),a=n(508),c=n(298),h=n(857),u=n(697);const d=/^[ -~]*$/;function f(t,e,n){if(0===t.length){const[t]=g(n.pop());return e<=0?`</li></${t}>`:`</li></${t}>${f([],e-1,n)}`}const[{child:s,offset:i,length:r,indent:o,type:l},...a]=t,[c,h]=g(l);if(o>e)return n.push(l),o===e+1?`<${c}><li${h}>${p(s,i,r)}${f(a,o,n)}`:`<${c}><li>${f(t,e+1,n)}`;const u=n[n.length-1];if(o===e&&l===u)return`</li><li${h}>${p(s,i,r)}${f(a,o,n)}`;const[d]=g(n.pop());return`</li></${d}>${f(t,e-1,n)}`}function p(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("html"in t&&"function"==typeof t.html)return t.html(e,n);if(t instanceof a.A)return(0,a.X)(t.value().slice(e,e+n)).replaceAll(/ +/g,(t=>"&nbsp;".repeat(t.length-1)+" "));if(t instanceof s.ParentBlot){if("list-container"===t.statics.blotName){const s=[];return t.children.forEachAt(e,n,((t,e,n)=>{const i="formats"in t&&"function"==typeof t.formats?t.formats():{};s.push({child:t,offset:e,length:n,indent:i.indent||0,type:i.list})})),f(s,-1,[])}const s=[];if(t.children.forEachAt(e,n,((t,e,n)=>{s.push(p(t,e,n))})),i||"list"===t.statics.blotName)return s.join("");const{outerHTML:r,innerHTML:o}=t.domNode,[l,a]=r.split(`>${o}<`);return"<table"===l?`<table style="border: 1px solid #000;">${s.join("")}<${a}`:`${l}>${s.join("")}<${a}`}return t.domNode instanceof Element?t.domNode.outerHTML:""}function m(t,e){return Object.keys(e).reduce(((n,s)=>{if(null==t[s])return n;const i=e[s];return i===t[s]?n[s]=i:Array.isArray(i)?i.indexOf(t[s])<0?n[s]=i.concat([t[s]]):n[s]=i:n[s]=[i,t[s]],n}),{})}function g(t){const e="ordered"===t?"ol":"ul";switch(t){case"checked":return[e,' data-list="checked"'];case"unchecked":return[e,' data-list="unchecked"'];default:return[e,""]}}function b(t){return t.reduce(((t,e)=>{if("string"==typeof e.insert){const n=e.insert.replace(/\r\n/g,"\n").replace(/\r/g,"\n");return t.insert(n,e.attributes)}return t.push(e)}),new i.Ay)}function y(t,e){let{index:n,length:s}=t;return new c.Q(n+e,s)}var A=class{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();const n=b(t),o=new i.Ay;return function(t){const e=[];return t.forEach((t=>{"string"==typeof t.insert?t.insert.split("\n").forEach(((n,s)=>{s&&e.push({insert:"\n",attributes:t.attributes}),n&&e.push({insert:n,attributes:t.attributes})})):e.push(t)})),e}(n.ops.slice()).reduce(((t,n)=>{const l=i.Op.length(n);let c=n.attributes||{},h=!1,u=!1;if(null!=n.insert){if(o.retain(l),"string"==typeof n.insert){const o=n.insert;u=!o.endsWith("\n")&&(e<=t||!!this.scroll.descendant(r.zo,t)[0]),this.scroll.insertAt(t,o);const[l,a]=this.scroll.line(t);let h=Object.assign({},(0,r.Ji)(l));if(l instanceof r.Ay){const[t]=l.descendant(s.LeafBlot,a);t&&(h=Object.assign(h,(0,r.Ji)(t)))}c=i.xb.diff(h,c)||{}}else if("object"==typeof n.insert){const o=Object.keys(n.insert)[0];if(null==o)return t;const l=null!=this.scroll.query(o,s.Scope.INLINE);if(l)(e<=t||this.scroll.descendant(r.zo,t)[0])&&(u=!0);else if(t>0){const[e,n]=this.scroll.descendant(s.LeafBlot,t-1);e instanceof a.A?"\n"!==e.value()[n]&&(h=!0):e instanceof s.EmbedBlot&&e.statics.scope===s.Scope.INLINE_BLOT&&(h=!0)}if(this.scroll.insertAt(t,o,n.insert[o]),l){const[e]=this.scroll.descendant(s.LeafBlot,t);if(e){const t=Object.assign({},(0,r.Ji)(e));c=i.xb.diff(t,c)||{}}}}e+=l}else if(o.push(n),null!==n.retain&&"object"==typeof n.retain){const e=Object.keys(n.retain)[0];if(null==e)return t;this.scroll.updateEmbedAt(t,e,n.retain[e])}Object.keys(c).forEach((e=>{this.scroll.formatAt(t,l,e,c[e])}));const d=h?1:0,f=u?1:0;return e+=d+f,o.retain(d),o.delete(f),t+l+d+f}),0),o.reduce(((t,e)=>"number"==typeof e.delete?(this.scroll.deleteAt(t,e.delete),t):t+i.Op.length(e)),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(n)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update((new i.Ay).retain(t).delete(e))}formatLine(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.scroll.update(),Object.keys(n).forEach((s=>{this.scroll.lines(t,Math.max(e,1)).forEach((t=>{t.format(s,n[s])}))})),this.scroll.optimize();const s=(new i.Ay).retain(t).retain(e,(0,h.A)(n));return this.update(s)}formatText(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Object.keys(n).forEach((s=>{this.scroll.formatAt(t,e,s,n[s])}));const s=(new i.Ay).retain(t).retain(e,(0,h.A)(n));return this.update(s)}getContents(t,e){return this.delta.slice(t,t+e)}getDelta(){return this.scroll.lines().reduce(((t,e)=>t.concat(e.delta())),new i.Ay)}getFormat(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=[],i=[];0===e?this.scroll.path(t).forEach((t=>{const[e]=t;e instanceof r.Ay?n.push(e):e instanceof s.LeafBlot&&i.push(e)})):(n=this.scroll.lines(t,e),i=this.scroll.descendants(s.LeafBlot,t,e));const[o,l]=[n,i].map((t=>{const e=t.shift();if(null==e)return{};let n=(0,r.Ji)(e);for(;Object.keys(n).length>0;){const e=t.shift();if(null==e)return n;n=m((0,r.Ji)(e),n)}return n}));return{...o,...l}}getHTML(t,e){const[n,s]=this.scroll.line(t);if(n){const i=n.length();return n.length()>=s+e&&(0!==s||e!==i)?p(n,s,e,!0):p(this.scroll,t,e,!0)}return""}getText(t,e){return this.getContents(t,e).filter((t=>"string"==typeof t.insert)).map((t=>t.insert)).join("")}insertContents(t,e){const n=b(e),s=(new i.Ay).retain(t).concat(n);return this.scroll.insertContents(t,n),this.update(s)}insertEmbed(t,e,n){return this.scroll.insertAt(t,e,n),this.update((new i.Ay).retain(t).insert({[e]:n}))}insertText(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),this.scroll.insertAt(t,e),Object.keys(n).forEach((s=>{this.scroll.formatAt(t,e.length,s,n[s])})),this.update((new i.Ay).retain(t).insert(e,(0,h.A)(n)))}isBlank(){if(0===this.scroll.children.length)return!0;if(this.scroll.children.length>1)return!1;const t=this.scroll.children.head;if(t?.statics.blotName!==r.Ay.blotName)return!1;const e=t;return!(e.children.length>1)&&e.children.head instanceof o.A}removeFormat(t,e){const n=this.getText(t,e),[s,r]=this.scroll.line(t+e);let o=0,l=new i.Ay;null!=s&&(o=s.length()-r,l=s.delta().slice(r,r+o-1).insert("\n"));const a=this.getContents(t,e+o).diff((new i.Ay).insert(n).concat(l)),c=(new i.Ay).retain(t).concat(a);return this.applyDelta(c)}update(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;const s=this.delta;if(1===e.length&&"characterData"===e[0].type&&e[0].target.data.match(d)&&this.scroll.find(e[0].target)){const o=this.scroll.find(e[0].target),a=(0,r.Ji)(o),c=o.offset(this.scroll),h=e[0].oldValue.replace(l.A.CONTENTS,""),u=(new i.Ay).insert(h),d=(new i.Ay).insert(o.value()),f=n&&{oldRange:y(n.oldRange,-c),newRange:y(n.newRange,-c)};t=(new i.Ay).retain(c).concat(u.diff(d,f)).reduce(((t,e)=>e.insert?t.insert(e.insert,a):t.push(e)),new i.Ay),this.delta=s.compose(t)}else this.delta=this.getDelta(),t&&(0,u.A)(s.compose(t),this.delta)||(t=s.diff(this.delta,n));return t}},N=n(200),v=new WeakMap,E=n(78),x=n(266),L=n(746),S=class{isComposing=!1;constructor(t,e){this.scroll=t,this.emitter=e,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",(t=>{this.isComposing||this.handleCompositionStart(t)})),this.scroll.domNode.addEventListener("compositionend",(t=>{this.isComposing&&queueMicrotask((()=>{this.handleCompositionEnd(t)}))}))}handleCompositionStart(t){const e=t.target instanceof Node?this.scroll.find(t.target,!0):null;!e||e instanceof L.A||(this.emitter.emit(N.A.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(N.A.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(N.A.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(N.A.events.COMPOSITION_END,t),this.isComposing=!1}},T=n(609);const k=t=>{const e=t.getBoundingClientRect(),n="offsetWidth"in t&&Math.abs(e.width)/t.offsetWidth||1,s="offsetHeight"in t&&Math.abs(e.height)/t.offsetHeight||1;return{top:e.top,right:e.left+t.clientWidth*n,bottom:e.top+t.clientHeight*s,left:e.left}},O=t=>{const e=parseInt(t,10);return Number.isNaN(e)?0:e},w=(t,e,n,s,i,r)=>t<n&&e>s?0:t<n?-(n-t+i):e>s?e-t>s-n?t+i-n:e-s+r:0;const C=["block","break","cursor","inline","scroll","text"];const q=(0,E.A)("quill"),R=new s.Registry;s.ParentBlot.uiClass="ql-ui";class B{static DEFAULTS={bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:R,theme:"default"};static events=N.A.events;static sources=N.A.sources;static version="2.0.3";static imports={delta:i.Ay,parchment:s,"core/module":x.A,"core/theme":T.A};static debug(t){!0===t&&(t="log"),E.A.level(t)}static find(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return v.get(t)||R.find(t,e)}static import(t){return null==this.imports[t]&&q.error(`Cannot import ${t}. Are you sure it was registered?`),this.imports[t]}static register(){if("string"!=typeof(arguments.length<=0?void 0:arguments[0])){const t=arguments.length<=0?void 0:arguments[0],e=!!(arguments.length<=1?void 0:arguments[1]),n="attrName"in t?t.attrName:t.blotName;"string"==typeof n?this.register(`formats/${n}`,t,e):Object.keys(t).forEach((n=>{this.register(n,t[n],e)}))}else{const t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1],n=!!(arguments.length<=2?void 0:arguments[2]);null==this.imports[t]||n||q.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&"boolean"!=typeof e&&"abstract"!==e.blotName&&R.register(e),"function"==typeof e.register&&e.register(R)}}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.options=function(t,e){const n=I(t);if(!n)throw new Error("Invalid Quill container");const i=!e.theme||e.theme===B.DEFAULTS.theme?T.A:B.import(`themes/${e.theme}`);if(!i)throw new Error(`Invalid theme ${e.theme}. Did you register it?`);const{modules:r,...o}=B.DEFAULTS,{modules:l,...a}=i.DEFAULTS;let c=D(e.modules);null!=c&&c.toolbar&&c.toolbar.constructor!==Object&&(c={...c,toolbar:{container:c.toolbar}});const h={...D(r),...D(l),...c},u={...o,...M(a),...M(e)};let d=e.registry;return d?e.formats&&q.warn('Ignoring "formats" option because "registry" is specified'):d=e.formats?((t,e,n)=>{const i=new s.Registry;return C.forEach((t=>{const n=e.query(t);n&&i.register(n)})),t.forEach((t=>{let s=e.query(t);s||n.error(`Cannot register "${t}" specified in "formats" config. Are you sure it was registered?`);let r=0;for(;s;)if(i.register(s),s="blotName"in s?s.requiredContainer??null:null,r+=1,r>100){n.error(`Cycle detected in registering blot requiredContainer: "${t}"`);break}})),i})(e.formats,u.registry,q):u.registry,{...u,registry:d,container:n,theme:i,modules:Object.entries(h).reduce(((t,e)=>{let[n,s]=e;if(!s)return t;const i=B.import(`modules/${n}`);return null==i?(q.error(`Cannot load ${n} module. Are you sure you registered it?`),t):{...t,[n]:{...i.DEFAULTS||{},...s}}}),{}),bounds:I(u.bounds)}}(t,e),this.container=this.options.container,null==this.container)return void q.error("Invalid Quill container",t);this.options.debug&&B.debug(this.options.debug);const n=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",v.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new N.A;const r=s.ScrollBlot.blotName,o=this.options.registry.query(r);if(!o||!("blotName"in o))throw new Error(`Cannot initialize Quill without "${r}" blot`);if(this.scroll=new o(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new A(this.scroll),this.selection=new c.A(this.scroll,this.emitter),this.composition=new S(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.uploader=this.theme.addModule("uploader"),this.theme.addModule("input"),this.theme.addModule("uiNode"),this.theme.init(),this.emitter.on(N.A.events.EDITOR_CHANGE,(t=>{t===N.A.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())})),this.emitter.on(N.A.events.SCROLL_UPDATE,((t,e)=>{const n=this.selection.lastRange,[s]=this.selection.getRange(),i=n&&s?{oldRange:n,newRange:s}:void 0;U.call(this,(()=>this.editor.update(null,e,i)),t)})),this.emitter.on(N.A.events.SCROLL_EMBED_UPDATE,((t,e)=>{const n=this.selection.lastRange,[s]=this.selection.getRange(),r=n&&s?{oldRange:n,newRange:s}:void 0;U.call(this,(()=>{const n=(new i.Ay).retain(t.offset(this)).retain({[t.statics.blotName]:e});return this.editor.update(n,[],r)}),B.sources.USER)})),n){const t=this.clipboard.convert({html:`${n}<p><br></p>`,text:"\n"});this.setContents(t)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if("string"==typeof t){const e=t;(t=document.createElement("div")).classList.add(e)}return this.container.insertBefore(t,e),t}blur(){this.selection.setRange(null)}deleteText(t,e,n){return[t,e,,n]=_(t,e,n),U.call(this,(()=>this.editor.deleteText(t,e)),n,t,-1*e)}disable(){this.enable(!1)}editReadOnly(t){this.allowReadOnlyEdits=!0;const e=t();return this.allowReadOnlyEdits=!1,e}enable(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.scroll.enable(t),this.container.classList.toggle("ql-disabled",!t)}focus(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.selection.focus(),t.preventScroll||this.scrollSelectionIntoView()}format(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:N.A.sources.API;return U.call(this,(()=>{if(!this.hasFocus()){this.root.focus({preventScroll:!0});const t=this.selection.rangeToNative(this.selection.savedRange);this.selection.setNativeRange(...t)}const[n]=this.selection.getRange();let r=new i.Ay;if(null==n)return r;if(this.scroll.query(t,s.Scope.BLOCK))r=this.editor.formatLine(n.index,n.length,{[t]:e});else{if(0===n.length)return this.selection.format(t,e),r;r=this.editor.formatText(n.index,n.length,{[t]:e})}return this.setSelection(n,N.A.sources.SILENT),r}),n)}formatLine(t,e,n,s,i){let r;return[t,e,r,i]=_(t,e,n,s,i),U.call(this,(()=>this.editor.formatLine(t,e,r)),i,t,0)}formatText(t,e,n,s,i){let r;return[t,e,r,i]=_(t,e,n,s,i),U.call(this,(()=>this.editor.formatText(t,e,r)),i,t,0)}getBounds(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null;if(n="number"==typeof t?this.selection.getBounds(t,e):this.selection.getBounds(t.index,t.length),!n)return null;const s=this.container.getBoundingClientRect();return{bottom:n.bottom-s.top,height:n.height,left:n.left-s.left,right:n.right-s.left,top:n.top-s.top,width:n.width}}getContents(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getLength()-t;return[t,e]=_(t,e),this.editor.getContents(t,e)}getFormat(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.getSelection(!0),e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return"number"==typeof t?this.editor.getFormat(t,e):this.editor.getFormat(t.index,t.length)}getIndex(t){return t.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(t){return this.scroll.leaf(t)}getLine(t){return this.scroll.line(t)}getLines(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_VALUE;return"number"!=typeof t?this.scroll.lines(t.index,t.length):this.scroll.lines(t,e)}getModule(t){return this.theme.modules[t]}getSelection(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return"number"==typeof t&&(e=e??this.getLength()-t),[t,e]=_(t,e),this.editor.getHTML(t,e)}getText(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return"number"==typeof t&&(e=e??this.getLength()-t),[t,e]=_(t,e),this.editor.getText(t,e)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,e,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:B.sources.API;return U.call(this,(()=>this.editor.insertEmbed(t,e,n)),s,t)}insertText(t,e,n,s,i){let r;return[t,,r,i]=_(t,0,n,s,i),U.call(this,(()=>this.editor.insertText(t,e,r)),i,t,e.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(t,e,n){return[t,e,,n]=_(t,e,n),U.call(this,(()=>this.editor.removeFormat(t,e)),n,t)}scrollRectIntoView(t){((t,e)=>{const n=t.ownerDocument;let s=e,i=t;for(;i;){const t=i===n.body,e=t?{top:0,right:window.visualViewport?.width??n.documentElement.clientWidth,bottom:window.visualViewport?.height??n.documentElement.clientHeight,left:0}:k(i),o=getComputedStyle(i),l=w(s.left,s.right,e.left,e.right,O(o.scrollPaddingLeft),O(o.scrollPaddingRight)),a=w(s.top,s.bottom,e.top,e.bottom,O(o.scrollPaddingTop),O(o.scrollPaddingBottom));if(l||a)if(t)n.defaultView?.scrollBy(l,a);else{const{scrollLeft:t,scrollTop:e}=i;a&&(i.scrollTop+=a),l&&(i.scrollLeft+=l);const n=i.scrollLeft-t,r=i.scrollTop-e;s={left:s.left-n,top:s.top-r,right:s.right-n,bottom:s.bottom-r}}i=t||"fixed"===o.position?null:(r=i).parentElement||r.getRootNode().host||null}var r})(this.root,t)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){const t=this.selection.lastRange,e=t&&this.selection.getBounds(t.index,t.length);e&&this.scrollRectIntoView(e)}setContents(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:N.A.sources.API;return U.call(this,(()=>{t=new i.Ay(t);const e=this.getLength(),n=this.editor.deleteText(0,e),s=this.editor.insertContents(0,t),r=this.editor.deleteText(this.getLength()-1,1);return n.compose(s).compose(r)}),e)}setSelection(t,e,n){null==t?this.selection.setRange(null,e||B.sources.API):([t,e,,n]=_(t,e,n),this.selection.setRange(new c.Q(Math.max(0,t),e),n),n!==N.A.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:N.A.sources.API;const n=(new i.Ay).insert(t);return this.setContents(n,e)}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N.A.sources.USER;const e=this.scroll.update(t);return this.selection.update(t),e}updateContents(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:N.A.sources.API;return U.call(this,(()=>(t=new i.Ay(t),this.editor.applyDelta(t))),e,!0)}}function I(t){return"string"==typeof t?document.querySelector(t):t}function D(t){return Object.entries(t??{}).reduce(((t,e)=>{let[n,s]=e;return{...t,[n]:!0===s?{}:s}}),{})}function M(t){return Object.fromEntries(Object.entries(t).filter((t=>void 0!==t[1])))}function U(t,e,n,s){if(!this.isEnabled()&&e===N.A.sources.USER&&!this.allowReadOnlyEdits)return new i.Ay;let r=null==n?null:this.getSelection();const o=this.editor.delta,l=t();if(null!=r&&(!0===n&&(n=r.index),null==s?r=j(r,l,e):0!==s&&(r=j(r,n,s,e)),this.setSelection(r,N.A.sources.SILENT)),l.length()>0){const t=[N.A.events.TEXT_CHANGE,l,o,e];this.emitter.emit(N.A.events.EDITOR_CHANGE,...t),e!==N.A.sources.SILENT&&this.emitter.emit(...t)}return l}function _(t,e,n,s,i){let r={};return"number"==typeof t.index&&"number"==typeof t.length?"number"!=typeof e?(i=s,s=n,n=e,e=t.length,t=t.index):(e=t.length,t=t.index):"number"!=typeof e&&(i=s,s=n,n=e,e=0),"object"==typeof n?(r=n,i=s):"string"==typeof n&&(null!=s?r[n]=s:i=n),[t,e,r,i=i||N.A.sources.API]}function j(t,e,n,s){const i="number"==typeof n?n:0;if(null==t)return null;let r,o;return e&&"function"==typeof e.transformPosition?[r,o]=[t.index,t.index+t.length].map((t=>e.transformPosition(t,s!==N.A.sources.USER))):[r,o]=[t.index,t.index+t.length].map((t=>t<e||t===e&&s===N.A.sources.USER?t:i>=0?t+i:Math.max(e,t+i))),new c.Q(r,o-r)}},298:function(t,e,n){n.d(e,{Q:function(){return h}});var s=n(3),i=n(200),r=n(78),o=n(857),l=n(697);const a=(0,r.A)("quill:selection"),c=t=>{try{return"getSelection"in t&&"function"==typeof t.getSelection?t.getSelection():window.getSelection()}catch{return null}};class h{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.index=t,this.length=e}}function u(t,e){try{e.parentNode}catch(t){return!1}return t.contains(e)}e.A=class{constructor(t,e){this.emitter=e,this.scroll=t,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.rootDocument=this.root.getRootNode(),this.cursor=this.scroll.create("cursor",this),this.savedRange=new h(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",this.rootDocument,(()=>{this.mouseDown||this.composing||setTimeout(this.update.bind(this,i.A.sources.USER),1)})),this.emitter.on(i.A.events.SCROLL_BEFORE_UPDATE,(()=>{if(!this.hasFocus())return;const t=this.getNativeRange();null!=t&&t.start.node!==this.cursor.textNode&&this.emitter.once(i.A.events.SCROLL_UPDATE,((e,n)=>{try{this.root.contains(t.start.node)&&this.root.contains(t.end.node)&&this.setNativeRange(t.start.node,t.start.offset,t.end.node,t.end.offset);const s=n.some((t=>"characterData"===t.type||"childList"===t.type||"attributes"===t.type&&t.target===this.root));this.update(s?i.A.sources.SILENT:e)}catch(t){}}))})),this.emitter.on(i.A.events.SCROLL_OPTIMIZE,((t,e)=>{if(e.range){const{startNode:t,startOffset:n,endNode:s,endOffset:r}=e.range;this.setNativeRange(t,n,s,r),this.update(i.A.sources.SILENT)}})),this.update(i.A.sources.SILENT)}handleComposition(){this.emitter.on(i.A.events.COMPOSITION_BEFORE_START,(()=>{this.composing=!0})),this.emitter.on(i.A.events.COMPOSITION_END,(()=>{if(this.composing=!1,this.cursor.parent){const t=this.cursor.restore();if(!t)return;setTimeout((()=>{this.setNativeRange(t.startNode,t.startOffset,t.endNode,t.endOffset)}),1)}}))}handleDragging(){this.emitter.listenDOM("mousedown",document.body,(()=>{this.mouseDown=!0})),this.emitter.listenDOM("mouseup",document.body,(()=>{this.mouseDown=!1,this.update(i.A.sources.USER)}))}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(t,e){this.scroll.update();const n=this.getNativeRange();if(null!=n&&n.native.collapsed&&!this.scroll.query(t,s.Scope.BLOCK)){if(n.start.node!==this.cursor.textNode){const t=this.scroll.find(n.start.node,!1);if(null==t)return;if(t instanceof s.LeafBlot){const e=t.split(n.start.offset);t.parent.insertBefore(this.cursor,e)}else t.insertBefore(this.cursor,n.start.node);this.cursor.attach()}this.cursor.format(t,e),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this.scroll.length();let s;t=Math.min(t,n-1),e=Math.min(t+e,n-1)-t;let[i,r]=this.scroll.leaf(t);if(null==i)return null;if(e>0&&r===i.length()){const[e]=this.scroll.leaf(t+1);if(e){const[n]=this.scroll.line(t),[s]=this.scroll.line(t+1);n===s&&(i=e,r=0)}}[s,r]=i.position(r,!0);const o=document.createRange();if(e>0)return o.setStart(s,r),[i,r]=this.scroll.leaf(t+e),null==i?null:([s,r]=i.position(r,!0),o.setEnd(s,r),o.getBoundingClientRect());let l,a="left";if(s instanceof Text){if(!s.data.length)return null;r<s.data.length?(o.setStart(s,r),o.setEnd(s,r+1)):(o.setStart(s,r-1),o.setEnd(s,r),a="right"),l=o.getBoundingClientRect()}else{if(!(i.domNode instanceof Element))return null;l=i.domNode.getBoundingClientRect(),r>0&&(a="right")}return{bottom:l.top+l.height,height:l.height,left:l[a],right:l[a],top:l.top,width:0}}getNativeRange(){const t=(t=>{const e=c(t);return e?.anchorNode?!e||!("getComposedRanges"in e)||"function"!=typeof e.getComposedRanges||t instanceof ShadowRoot&&"getSelection"in t?e.getRangeAt(0):e.getComposedRanges(t)[0]:null})(this.rootDocument);if(null==t)return null;const e=this.normalizeNative(t);return a.info("getNativeRange",e),e}getRange(){const t=this.scroll.domNode;if("isConnected"in t&&!t.isConnected)return[null,null];const e=this.getNativeRange();return null==e?[null,null]:[this.normalizedToRange(e),e]}hasFocus(){const t=this.rootDocument;return t.activeElement===this.root||null!=t.activeElement&&u(this.root,t.activeElement)}normalizedToRange(t){const e=[[t.start.node,t.start.offset]];t.native.collapsed||e.push([t.end.node,t.end.offset]);const n=e.map((t=>{const[e,n]=t,i=this.scroll.find(e,!0),r=i.offset(this.scroll);return 0===n?r:i instanceof s.LeafBlot?r+i.index(e,n):r+i.length()})),i=Math.min(Math.max(...n),this.scroll.length()-1),r=Math.min(i,...n);return new h(r,i-r)}normalizeNative(t){if(!u(this.root,t.startContainer)||!t.collapsed&&!u(this.root,t.endContainer))return null;const e={start:{node:t.startContainer,offset:t.startOffset},end:{node:t.endContainer,offset:t.endOffset},native:t};return[e.start,e.end].forEach((t=>{let{node:e,offset:n