dootask/public/js/build/quill-delta.aa5a2fca.js
2024-05-01 23:22:56 +08:00

3 lines
9.4 KiB
JavaScript
Vendored

import{b as R}from"./@traptitech.b6e72224.js";import{d as q}from"./fast-diff.f17881f3.js";import{l as P}from"./lodash.clonedeep.3aa4ac4d.js";import{l as C}from"./lodash.isequal.9a7d0450.js";var T={exports:{}},N={};Object.defineProperty(N,"__esModule",{value:!0});const _=P.exports,S=C.exports;var I;(function(j){function u(r={},f={},y=!1){typeof r!="object"&&(r={}),typeof f!="object"&&(f={});let m=_(f);y||(m=Object.keys(m).reduce((a,h)=>(m[h]!=null&&(a[h]=m[h]),a),{}));for(const a in r)r[a]!==void 0&&f[a]===void 0&&(m[a]=r[a]);return Object.keys(m).length>0?m:void 0}j.compose=u;function l(r={},f={}){typeof r!="object"&&(r={}),typeof f!="object"&&(f={});const y=Object.keys(r).concat(Object.keys(f)).reduce((m,a)=>(S(r[a],f[a])||(m[a]=f[a]===void 0?null:f[a]),m),{});return Object.keys(y).length>0?y:void 0}j.diff=l;function k(r={},f={}){r=r||{};const y=Object.keys(f).reduce((m,a)=>(f[a]!==r[a]&&r[a]!==void 0&&(m[a]=f[a]),m),{});return Object.keys(r).reduce((m,a)=>(r[a]!==f[a]&&f[a]===void 0&&(m[a]=null),m),y)}j.invert=k;function O(r,f,y=!1){if(typeof r!="object")return f;if(typeof f!="object")return;if(!y)return f;const m=Object.keys(f).reduce((a,h)=>(r[h]===void 0&&(a[h]=f[h]),a),{});return Object.keys(m).length>0?m:void 0}j.transform=O})(I||(I={}));N.default=I;var v={};Object.defineProperty(v,"__esModule",{value:!0});var M;(function(j){function u(l){return typeof l.delete=="number"?l.delete:typeof l.retain=="number"?l.retain:typeof l.retain=="object"&&l.retain!==null?1:typeof l.insert=="string"?l.insert.length:1}j.length=u})(M||(M={}));v.default=M;var A={};Object.defineProperty(A,"__esModule",{value:!0});const $=v;class U{constructor(u){this.ops=u,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(u){u||(u=1/0);const l=this.ops[this.index];if(l){const k=this.offset,O=$.default.length(l);if(u>=O-k?(u=O-k,this.index+=1,this.offset=0):this.offset+=u,typeof l.delete=="number")return{delete:u};{const r={};return l.attributes&&(r.attributes=l.attributes),typeof l.retain=="number"?r.retain=u:typeof l.retain=="object"&&l.retain!==null?r.retain=l.retain:typeof l.insert=="string"?r.insert=l.insert.substr(k,u):r.insert=l.insert,r}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?$.default.length(this.ops[this.index])-this.offset:1/0}peekType(){const u=this.ops[this.index];return u?typeof u.delete=="number"?"delete":typeof u.retain=="number"||typeof u.retain=="object"&&u.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{const u=this.offset,l=this.index,k=this.next(),O=this.ops.slice(this.index);return this.offset=u,this.index=l,[k].concat(O)}}else return[]}}A.default=U;(function(j,u){Object.defineProperty(u,"__esModule",{value:!0}),u.AttributeMap=u.OpIterator=u.Op=void 0;const l=q,k=P.exports,O=C.exports,r=N;u.AttributeMap=r.default;const f=v;u.Op=f.default;const y=A;u.OpIterator=y.default;const m=String.fromCharCode(0),a=(L,e)=>{if(typeof L!="object"||L===null)throw new Error(`cannot retain a ${typeof L}`);if(typeof e!="object"||e===null)throw new Error(`cannot retain a ${typeof e}`);const t=Object.keys(L)[0];if(!t||t!==Object.keys(e)[0])throw new Error(`embed types not matched: ${t} != ${Object.keys(e)[0]}`);return[t,L[t],e[t]]};class h{constructor(e){Array.isArray(e)?this.ops=e:e!=null&&Array.isArray(e.ops)?this.ops=e.ops:this.ops=[]}static registerEmbed(e,t){this.handlers[e]=t}static unregisterEmbed(e){delete this.handlers[e]}static getHandler(e){const t=this.handlers[e];if(!t)throw new Error(`no handlers for embed type "${e}"`);return t}insert(e,t){const n={};return typeof e=="string"&&e.length===0?this:(n.insert=e,t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(n.attributes=t),this.push(n))}delete(e){return e<=0?this:this.push({delete:e})}retain(e,t){if(typeof e=="number"&&e<=0)return this;const n={retain:e};return t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(n.attributes=t),this.push(n)}push(e){let t=this.ops.length,n=this.ops[t-1];if(e=k(e),typeof n=="object"){if(typeof e.delete=="number"&&typeof n.delete=="number")return this.ops[t-1]={delete:n.delete+e.delete},this;if(typeof n.delete=="number"&&e.insert!=null&&(t-=1,n=this.ops[t-1],typeof n!="object"))return this.ops.unshift(e),this;if(O(e.attributes,n.attributes)){if(typeof e.insert=="string"&&typeof n.insert=="string")return this.ops[t-1]={insert:n.insert+e.insert},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this;if(typeof e.retain=="number"&&typeof n.retain=="number")return this.ops[t-1]={retain:n.retain+e.retain},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this}}return t===this.ops.length?this.ops.push(e):this.ops.splice(t,0,e),this}chop(){const e=this.ops[this.ops.length-1];return e&&typeof e.retain=="number"&&!e.attributes&&this.ops.pop(),this}filter(e){return this.ops.filter(e)}forEach(e){this.ops.forEach(e)}map(e){return this.ops.map(e)}partition(e){const t=[],n=[];return this.forEach(s=>{(e(s)?t:n).push(s)}),[t,n]}reduce(e,t){return this.ops.reduce(e,t)}changeLength(){return this.reduce((e,t)=>t.insert?e+f.default.length(t):t.delete?e-t.delete:e,0)}length(){return this.reduce((e,t)=>e+f.default.length(t),0)}slice(e=0,t=1/0){const n=[],s=new y.default(this.ops);let i=0;for(;i<t&&s.hasNext();){let o;i<e?o=s.next(e-i):(o=s.next(t-i),n.push(o)),i+=f.default.length(o)}return new h(n)}compose(e){const t=new y.default(this.ops),n=new y.default(e.ops),s=[],i=n.peek();if(i!=null&&typeof i.retain=="number"&&i.attributes==null){let p=i.retain;for(;t.peekType()==="insert"&&t.peekLength()<=p;)p-=t.peekLength(),s.push(t.next());i.retain-p>0&&n.next(i.retain-p)}const o=new h(s);for(;t.hasNext()||n.hasNext();)if(n.peekType()==="insert")o.push(n.next());else if(t.peekType()==="delete")o.push(t.next());else{const p=Math.min(t.peekLength(),n.peekLength()),d=t.next(p),b=n.next(p);if(b.retain){const c={};if(typeof d.retain=="number")c.retain=typeof b.retain=="number"?p:b.retain;else if(typeof b.retain=="number")d.retain==null?c.insert=d.insert:c.retain=d.retain;else{const x=d.retain==null?"insert":"retain",[w,E,H]=a(d[x],b.retain),D=h.getHandler(w);c[x]={[w]:D.compose(E,H,x==="retain")}}const g=r.default.compose(d.attributes,b.attributes,typeof d.retain=="number");if(g&&(c.attributes=g),o.push(c),!n.hasNext()&&O(o.ops[o.ops.length-1],c)){const x=new h(t.rest());return o.concat(x).chop()}}else typeof b.delete=="number"&&(typeof d.retain=="number"||typeof d.retain=="object"&&d.retain!==null)&&o.push(b)}return o.chop()}concat(e){const t=new h(this.ops.slice());return e.ops.length>0&&(t.push(e.ops[0]),t.ops=t.ops.concat(e.ops.slice(1))),t}diff(e,t){if(this.ops===e.ops)return new h;const n=[this,e].map(d=>d.map(b=>{if(b.insert!=null)return typeof b.insert=="string"?b.insert:m;const c=d===e?"on":"with";throw new Error("diff() called "+c+" non-document")}).join("")),s=new h,i=l(n[0],n[1],t,!0),o=new y.default(this.ops),p=new y.default(e.ops);return i.forEach(d=>{let b=d[1].length;for(;b>0;){let c=0;switch(d[0]){case l.INSERT:c=Math.min(p.peekLength(),b),s.push(p.next(c));break;case l.DELETE:c=Math.min(b,o.peekLength()),o.next(c),s.delete(c);break;case l.EQUAL:c=Math.min(o.peekLength(),p.peekLength(),b);const g=o.next(c),x=p.next(c);O(g.insert,x.insert)?s.retain(c,r.default.diff(g.attributes,x.attributes)):s.push(x).delete(c);break}b-=c}}),s.chop()}eachLine(e,t=`
`){const n=new y.default(this.ops);let s=new h,i=0;for(;n.hasNext();){if(n.peekType()!=="insert")return;const o=n.peek(),p=f.default.length(o)-n.peekLength(),d=typeof o.insert=="string"?o.insert.indexOf(t,p)-p:-1;if(d<0)s.push(n.next());else if(d>0)s.push(n.next(d));else{if(e(s,n.next(1).attributes||{},i)===!1)return;i+=1,s=new h}}s.length()>0&&e(s,{},i)}invert(e){const t=new h;return this.reduce((n,s)=>{if(s.insert)t.delete(f.default.length(s));else{if(typeof s.retain=="number"&&s.attributes==null)return t.retain(s.retain),n+s.retain;if(s.delete||typeof s.retain=="number"){const i=s.delete||s.retain;return e.slice(n,n+i).forEach(p=>{s.delete?t.push(p):s.retain&&s.attributes&&t.retain(f.default.length(p),r.default.invert(s.attributes,p.attributes))}),n+i}else if(typeof s.retain=="object"&&s.retain!==null){const i=e.slice(n,n+1),o=new y.default(i.ops).next(),[p,d,b]=a(s.retain,o.insert),c=h.getHandler(p);return t.retain({[p]:c.invert(d,b)},r.default.invert(s.attributes,o.attributes)),n+1}}return n},0),t.chop()}transform(e,t=!1){if(t=!!t,typeof e=="number")return this.transformPosition(e,t);const n=e,s=new y.default(this.ops),i=new y.default(n.ops),o=new h;for(;s.hasNext()||i.hasNext();)if(s.peekType()==="insert"&&(t||i.peekType()!=="insert"))o.retain(f.default.length(s.next()));else if(i.peekType()==="insert")o.push(i.next());else{const p=Math.min(s.peekLength(),i.peekLength()),d=s.next(p),b=i.next(p);if(d.delete)continue;if(b.delete)o.push(b);else{const c=d.retain,g=b.retain;let x=typeof g=="object"&&g!==null?g:p;if(typeof c=="object"&&c!==null&&typeof g=="object"&&g!==null){const w=Object.keys(c)[0];if(w===Object.keys(g)[0]){const E=h.getHandler(w);E&&(x={[w]:E.transform(c[w],g[w],t)})}}o.retain(x,r.default.transform(d.attributes,b.attributes,t))}}return o.chop()}transformPosition(e,t=!1){t=!!t;const n=new y.default(this.ops);let s=0;for(;n.hasNext()&&s<=e;){const i=n.peekLength(),o=n.peekType();if(n.next(),o==="delete"){e-=Math.min(i,e-s);continue}else o==="insert"&&(s<e||!t)&&(e+=i);s+=i}return e}}h.Op=f.default,h.OpIterator=y.default,h.AttributeMap=r.default,h.handlers={},u.default=h,j.exports=h,j.exports.default=h})(T,T.exports);var G=R(T.exports);export{G as D,T as a};