diff --git a/package.json b/package.json index 9298475..b8bfaaa 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "lazypipe": "^1.0.1", "mobile-detect": "^1.3.6", "nightwatch": "^0.9.13", + "popper.js": "^1.9.6", "postcss-import": "^9.1.0", "prosemirror-commands": "^0.20.0", "prosemirror-example-setup": "^0.20.0", diff --git a/simpla-text-editor.html b/simpla-text-editor.html index 45375f8..9a3b595 100644 --- a/simpla-text-editor.html +++ b/simpla-text-editor.html @@ -6,5 +6,5 @@ t.size?new Bt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Bt.from(t);for(var n=0;n>1}},Bt.from=function(t){if(t instanceof Bt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Bt(e)};var Ch=Bt,Th=zp,Rh=Th.Fragment,Eh=jp,Nh=Eh.Mark,Ah=function(t,e,n){this.nodeType=t,this.elements=e,this.inlineContent=n},Dh={isLeaf:{}};Dh.isLeaf.get=function(){return 0==this.elements.length},Ah.prototype.start=function(t){return new Ph(this,t,0,0)},Ah.prototype.atType=function(t,e,n,r){var o=this;void 0===r&&(r=Nh.none);for(var i=0;i/.exec(e.slice(o));c&&(o+=c[0].length);var p=/^(?:([+*?])|\{\s*(\d+|\.\w+)\s*(,\s*(\d+|\.\w+)?)?\s*\})/.exec(e.slice(o));p&&(o+=p[0].length);for(var h=Jt(t.schema,s[1]?[s[1]]:s[2].split(/\s*\|\s*/)),f=0;f=0;g--){var w=r[g];if(w.min!=w.max&&w.overlaps(y))throw new SyntaxError("Possibly ambiguous overlapping adjacent content expressions in '"+e+"'");if(0!=w.min)break}r.push(y)}return new Ah(t,r,!!i)},Ah.gatherMarks=function(t,e){for(var n=[],r=0;r-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n},Object.defineProperties(Ah.prototype,Dh);var zh=Ah,Ih=function(t,e,n,r,o){this.nodeTypes=t,this.attrs=e,this.marks=n,this.min=r,this.max=o};Ih.prototype.matchesType=function(t,e,n,r,o){var i=this;if(-1==this.nodeTypes.indexOf(t))return!1;if(this.attrs){if(!e)return!1;for(var s in i.attrs)if(e[s]!=jt(i.attrs[s],r,o))return!1}if(!0===this.marks)return!0;if(!1===this.marks)return 0==n.length;for(var a=0;a-1})},Ih.prototype.allowsMark=function(t){return!0===this.marks||this.marks&&this.marks.indexOf(t)>-1};var Ph=function(t,e,n,r){this.expr=t,this.attrs=e,this.index=n,this.count=r},Fh={element:{},nextElement:{}};Fh.element.get=function(){return this.expr.elements[this.index]},Fh.nextElement.get=function(){for(var t=this,e=this.index,n=this.count;en)return r;n=0}},Ph.prototype.move=function(t,e){return new Ph(this.expr,this.attrs,t,e)},Ph.prototype.resolveValue=function(t){return t instanceof Bh?jt(t,this.attrs,this.expr):t},Ph.prototype.matchNode=function(t){return this.matchType(t.type,t.attrs,t.marks)},Ph.prototype.matchType=function(t,e,n){var r=this;void 0===n&&(n=Nh.none);for(var o=this,i=o.index,s=o.count;is?null:Rh.from(o);i=i.move(i.index+1,0)}}},Ph.prototype.possibleContent=function(){for(var t=this,e=[],n=this.index,r=this.count;nr)break}return e},Ph.prototype.allowsMark=function(t){return this.element.allowsMark(t)},Ph.prototype.findWrapping=function(t,e,n){for(var r=Object.create(null),o={match:this,via:null},i=[o];i.length;){var s=i.shift(),a=s.match;if(a.matchType(t,e,n)){for(var c=[],p=s;p!=o;p=p.via)c.push({type:p.match.expr.nodeType,attrs:p.match.attrs});return c.reverse()}for(var h=a.possibleContent(),f=0;f-1};var rf=nf,of=function(t){var e=this;this.spec={};for(var n in t)e.spec[n]=t[n];this.spec.nodes=$h.from(t.nodes),this.spec.marks=$h.from(t.marks),this.nodes=Yh.compile(this.spec.nodes,this),this.marks=nf.compile(this.spec.marks,this);for(var r in e.nodes){if(r in e.marks)throw new RangeError(r+" can not be both a node and a mark");var o=e.nodes[r];o.contentExpr=Xh.parse(o,e.spec.nodes.get(r).content||"")}for(var i in e.marks){var s=e.marks[i],a=s.spec.excludes;s.excluded=null==a?[s]:""==a?[]:Xh.gatherMarks(e,a.split(" "))}this.cached=Object.create(null),this.cached.wrappings=Object.create(null),this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"]};of.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Yh))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},of.prototype.text=function(t,e){var n=this.nodes.text;return new Wh(n,n.defaultAttrs,t,Uh.setFrom(e))},of.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},of.prototype.nodeFromJSON=function(t){return Vh.fromJSON(this,t)},of.prototype.markFromJSON=function(t){return Uh.fromJSON(this,t)},of.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var sf=of,af={NodeType:Zh,MarkType:rf,Schema:sf},cf=zp,pf=cf.Fragment,hf=Gp,ff=hf.Slice,uf=jp,lf=uf.Mark,df=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach(function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})};df.prototype.parse=function(t,e){void 0===e&&(e={});var n=new Sf(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},df.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new Sf(this,e,!0);return n.addAll(t,null,e.from,e.to),ff.maxOpen(n.finish())},df.prototype.matchTag=function(t,e){for(var n=this,r=0;r=0;i--){var s=o.nodes[i],a=s.findWrapping(t,e);if(a&&(!n||n.length>a.length)&&(n=a,r=s,!a.length))break;if(s.solid)break}if(!n)return!1;this.sync(r);for(var c=0;cthis.open){for(this.marks=lf.none;n>this.open;n--)e.nodes[n-1].content.push(e.nodes[n].finish(t));this.nodes.length=this.open+1}},Sf.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},Sf.prototype.sync=function(t){for(var e=this,n=this.open;n>=0;n--)if(e.nodes[n]==t)return void(e.open=n)},bf.currentPos.get=function(){var t=this;this.closeExtra();for(var e=0,n=this.open;n>=0;n--){for(var r=t.nodes[n].content,o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e},Sf.prototype.findAtPoint=function(t,e){var n=this;if(this.find)for(var r=0;r=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var p=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!p||p.name!=c&&-1==p.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},Object.defineProperties(Sf.prototype,bf);var Mf={DOMParser:mf},Of=function(t,e){this.nodes=t||{},this.marks=e||{}};Of.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=te(e).createDocumentFragment());var o=n,i=null;return t.forEach(function(t){if(i||t.marks.length){i||(i=[]);for(var n=0;n=0;o--){var i=n.serializeMark(t.marks[o],e);i.appendChild(r),r=i}return r},Of.prototype.serializeMark=function(t,e){return void 0===e&&(e={}),this.renderStructure(this.marks[t.type.name](t),null,e)},Of.renderSpec=function(t,e){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};var n=t.createElement(e[0]),r=null,o=e[1],i=1;if(o&&"object"==typeof o&&null==o.nodeType&&!Array.isArray(o)){i=2;for(var s in o)"style"==s?n.style.cssText=o[s]:null!=o[s]&&n.setAttribute(s,o[s])}for(var a=i;ai)throw new RangeError("Content hole must be the only child of its parent node");return{dom:n,contentDOM:n}}var p=Of.renderSpec(t,c),h=p.dom,f=p.contentDOM;if(n.appendChild(h),f){if(r)throw new RangeError("Multiple content holes");r=f}}return{dom:n,contentDOM:r}},Of.prototype.renderStructure=function(t,e,n){var r=Of.renderSpec(te(n),t),o=r.dom,i=r.contentDOM;if(i){if(!e||e.isLeaf)throw new RangeError("Content hole not allowed in a mark or leaf node spec");n.onContent?n.onContent(e,i,n):this.serializeFragment(e.content,n,i)}return o},Of.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new Of(this.nodesFromSchema(t),this.marksFromSchema(t)))},Of.nodesFromSchema=function(t){var e=Zt(t.nodes);return e.text||(e.text=function(t){return t.text}),e},Of.marksFromSchema=function(t){return Zt(t.marks)};var Cf=Of,Tf={DOMSerializer:Cf},Rf=t(function(t,e){e.Node=Oh.Node;var n;n=ah,e.ResolvedPos=n.ResolvedPos,e.NodeRange=n.NodeRange,e.Fragment=zp.Fragment;var r;r=Gp,e.Slice=r.Slice,e.ReplaceError=r.ReplaceError,e.Mark=jp.Mark;var o;o=af,e.Schema=o.Schema,e.NodeType=o.NodeType,e.MarkType=o.MarkType;var i;i=jh,e.ContentMatch=i.ContentMatch,e.DOMParser=Mf.DOMParser,e.DOMSerializer=Tf.DOMSerializer}),Ef=Rf,Nf=Ef.Slice,Af=Ef.Fragment,Df=Object.create(null),zf=function(t,e,n){this.ranges=n||[new Ff(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},If={anchor:{},head:{},from:{},to:{},$from:{},$to:{},empty:{}};If.anchor.get=function(){return this.$anchor.pos},If.head.get=function(){return this.$head.pos},If.from.get=function(){return this.$from.pos},If.to.get=function(){return this.$to.pos},If.$from.get=function(){return this.ranges[0].$from},If.$to.get=function(){return this.ranges[0].$to},If.empty.get=function(){for(var t=this.ranges,e=0;e=0;o--){var i=e<0?ee(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):ee(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},zf.near=function(t,e){void 0===e&&(e=1);var n=this.findFrom(t,e)||this.findFrom(t,-e);if(!n)throw new RangeError("Searching for selection in invalid document "+t.node(0));return n},zf.atStart=function(t,e){return ee(t,t,0,0,1,e)},zf.atEnd=function(t,e){return ee(t,t,t.content.size,t.childCount,-1,e)},zf.fromJSON=function(t,e){var n=Df[e.type];return n?n.fromJSON(t,e):this.backwardsCompatFromJSON(t,e)},zf.backwardsCompatFromJSON=function(t,e){if(null!=e.anchor)return Bf.fromJSON(t,e);if(null!=e.node)return $f.fromJSON(t,{anchor:e.node,head:e.after});throw new RangeError("Unrecognized JSON data "+JSON.stringify(e))},zf.jsonID=function(t,e){if(t in Df)throw new RangeError("Duplicate use of selection JSON ID "+t);return Df[t]=e,e.prototype.jsonID=t,e},zf.prototype.getBookmark=function(){return Bf.between(this.anchor,this.head).getBookmark()},Object.defineProperties(zf.prototype,If);var Pf=zf;zf.prototype.visible=!0;var Ff=function(t,e){this.$from=t,this.$to=e},Lf=Ff,Bf=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){void 0===n&&(n=Nf.empty),t.prototype.replace.call(this,e,n),n==Nf.empty&&this.$from.parentOffset=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i?n=r:(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor,n.post)break;var p=r.ranges[a+i],h=r.ranges[a+s],f=c+p;if(t<=f){var u=p?t==c?-1:t==f?1:e:e,l=c+o+(u<0?0:h);if(n)return l;var d=re(a/3,t-c);return new Xf(l,e<0?t!=c:t!=f,d)}o+=h-p}return n?t+o:new Xf(t+o)},Qf.prototype.touches=function(t,e){for(var n=this,r=0,o=oe(e),i=this.inverted?2:1,s=this.inverted?1:2,a=0;at)break;var p=n.ranges[a+i];if(t<=c+p&&a==3*o)return!0;r+=n.ranges[a+s]-p}return!1},Qf.prototype.forEach=function(t){for(var e=this,n=this.inverted?2:1,r=this.inverted?1:2,o=0,i=0;o=0;n--){var o=t.getMirror(n);e.appendMap(t.maps[n].invert(),null!=o&&o>n?r-o-1:null)}},tu.prototype.invert=function(){ var t=new tu;return t.appendMappingInverted(this),t},tu.prototype.map=function(t,e){var n=this;if(this.mirror)return this._map(t,e,!0);for(var r=this.from;rs&&h0},au.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(au.prototype,cu);var pu=au,hu={TransformError:su,Transform:pu},fu=Rf,uu=fu.ReplaceError,lu=nu,du=lu.StepMap,mu=Object.create(null),vu=function(){};vu.prototype.apply=function(t){return se()},vu.prototype.getMap=function(){return du.empty},vu.prototype.invert=function(t){return se()},vu.prototype.map=function(t){return se()},vu.prototype.merge=function(t){return null},vu.prototype.offset=function(t){return se()},vu.prototype.toJSON=function(){var t=this,e={stepType:this.jsonID};for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];e[n]=r&&r.toJSON?r.toJSON():r}return e},vu.fromJSON=function(t,e){return mu[e.stepType].fromJSON(t,e)},vu.jsonID=function(t,e){if(t in mu)throw new RangeError("Duplicate use of step JSON ID "+t);return mu[t]=e,e.prototype.jsonID=t,e};var yu=vu,gu=function(t,e){this.doc=t,this.failed=e};gu.ok=function(t){return new gu(t,null)},gu.fail=function(t){return new gu(null,t)},gu.fromReplace=function(t,e,n,r){try{return gu.ok(t.replace(e,n,r))}catch(t){if(t instanceof uu)return gu.fail(t.message);throw t}};var wu=gu,xu={Step:yu,StepResult:wu},ku=Rf,Su=ku.Slice,bu=xu,Mu=bu.Step,Ou=bu.StepResult,Cu=nu,Tu=Cu.StepMap,Ru=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&ae(t,this.from,this.to)?Ou.fail("Structure replace would overwrite content"):Ou.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new Tu([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure!=this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openRight||t.slice.openLeft){if(t.to!=this.from||this.slice.openLeft||t.slice.openRight)return null;var n=this.slice.size+t.slice.size==0?Su.empty:new Su(t.slice.content.append(this.slice.content),t.slice.openLeft,this.slice.openRight);return new e(t.from,this.to,n,this.structure)}var r=this.slice.size+t.slice.size==0?Su.empty:new Su(this.slice.content.append(t.slice.content),this.slice.openLeft,t.slice.openRight);return new e(this.from,this.to+(t.to-t.from),r,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.prototype.offset=function(t){return new e(this.from+t,this.to+t,this.slice,this.structure)},e.fromJSON=function(t,n){return new e(n.from,n.to,Su.fromJSON(t,n.slice),!!n.structure)},e}(Mu),Eu=Ru;Mu.jsonID("replace",Ru);var Nu=function(t){function e(e,n,r,o,i,s,a){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(ae(t,this.from,this.gapFrom)||ae(t,this.gapTo,this.to)))return Ou.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openLeft||e.openRight)return Ou.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?Ou.fromReplace(t,this.from,this.to,n):Ou.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new Tu([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||or.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,slice:this.slice.toJSON()};return this.structure&&(t.structure=!0),!0},e.prototype.offset=function(t){return new e(this.from+t,this.to+t,this.gapFrom+t,this.gapTo+t,this.slice,this.insert,this.structure)},e.fromJSON=function(t,n){return new e(n.from,n.to,n.gapFrom,n.gapTo,Su.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(Mu),Au=Nu;Mu.jsonID("replaceAround",Nu);var Du={ReplaceStep:Eu,ReplaceAroundStep:Au},zu=Rf,Iu=zu.Slice,Pu=zu.Fragment,Fu=hu,Lu=Fu.Transform,Bu=Du,_u=Bu.ReplaceStep,ju=Bu.ReplaceAroundStep,$u=pe;Lu.prototype.lift=function(t,e){for(var n=t.$from,r=t.$to,o=t.depth,i=n.before(o+1),s=r.after(o+1),a=i,c=s,p=Pu.empty,h=0,f=o,u=!1;f>e;f--)u||n.index(f)>0?(u=!0,p=Pu.from(n.node(f).copy(p)),h++):a--;for(var l=Pu.empty,d=0,m=o,v=!1;m>e;m--)v||r.after(m+1)=0;r--)n=Pu.from(e[r].type.create(e[r].attrs,n));var o=t.start,i=t.end;return this.step(new ju(o,i,o,i,new Iu(n,0,0),e.length,!0))},Lu.prototype.setBlockType=function(t,e,n,r){var o=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var i=this.steps.length;return this.doc.nodesBetween(t,e,function(t,e){if(t.isTextblock&&!t.hasMarkup(n,r)){o.clearNonMatching(o.mapping.slice(i).map(e,1),n.contentExpr.start(r));var s=o.mapping.slice(i),a=s.map(e,1),c=s.map(e+t.nodeSize,1);return o.step(new ju(a,c,a+1,c-1,new Iu(Pu.from(n.create(r)),0,0),1,!0)),!1}}),this},Lu.prototype.setNodeType=function(t,e,n,r){var o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");e||(e=o.type);var i=e.create(n,null,r||o.marks);if(o.isLeaf)return this.replaceWith(t,t+o.nodeSize,i);if(!e.validContent(o.content,n))throw new RangeError("Invalid content for node type "+e.name);return this.step(new ju(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Iu(Pu.from(i),0,0),1,!0))};var Vu=le;Lu.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),o=Pu.empty,i=Pu.empty,s=r.depth,a=r.depth-e,c=e-1;s>a;s--,c--){o=Pu.from(r.node(s).copy(o));var p=n&&n[c];i=Pu.from(p?p.type.create(p.attrs,i):r.node(s).copy(i))}return this.step(new _u(t,t,new Iu(o.append(i),e,e,!0)))};var Wu=de,qu=ve;Lu.prototype.join=function(t,e){void 0===e&&(e=1);var n=new _u(t-e,t+e,Iu.empty,!0);return this.step(n)};var Ku=ye,Hu={liftTarget:$u,findWrapping:Ju,canSplit:Vu,canJoin:Wu,joinPoint:qu,insertPoint:Ku},Uu=Rf,Gu=Uu.Fragment,Xu=Uu.Slice,Yu=xu,Qu=Yu.Step,Zu=Yu.StepResult,tl=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new Xu(ge(n.content,function(t,n,r){return n.contentMatchAt(r+1).allowsMark(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t},o),n.openLeft,n.openRight);return Zu.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new nl(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.offset=function(t){return new e(this.from+t,this.to+t,this.mark)},e.fromJSON=function(t,n){return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Qu),el=tl;Qu.jsonID("addMark",tl);var nl=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new Xu(ge(n.content,function(t){return t.mark(e.mark.removeFromSet(t.marks))}),n.openLeft,n.openRight);return Zu.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new tl(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.offset=function(t){return new e(this.from+t,this.to+t,this.mark)},e.fromJSON=function(t,n){return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Qu),rl=nl;Qu.jsonID("removeMark",nl);var ol={AddMarkStep:el,RemoveMarkStep:rl},il=Rf,sl=il.MarkType,al=il.Slice,cl=il.Fragment,pl=hu,hl=pl.Transform,fl=ol,ul=fl.AddMarkStep,ll=fl.RemoveMarkStep,dl=Du,ml=dl.ReplaceStep;hl.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,function(r,c,p,h){if(r.isInline){var f=r.marks;if(n.isInSet(f)||!p.contentMatchAt(h+1).allowsMark(n.type))a=s=null;else{var u=Math.max(c,t),l=Math.min(c+r.nodeSize,e),d=n.type.isInSet(f);d?s&&s.mark.eq(d)?s.to=l:o.push(s=new ll(u,l,d)):s=null,a?a.to=l:i.push(a=new ul(u,l,n))}}}),o.forEach(function(t){return r.step(t)}),i.forEach(function(t){return r.step(t)}),this},hl.prototype.removeMark=function(t,e,n){var r=this;void 0===n&&(n=null);var o=[],i=0;return this.doc.nodesBetween(t,e,function(r,s){if(r.isInline){i++;var a=null;if(n instanceof sl){var c=n.isInSet(r.marks);c&&(a=[c])}else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length)for(var p=Math.min(s+r.nodeSize,e),h=0;h=0;o--)n.step(r[o]);return this},hl.prototype.clearNonMatching=function(t,e){for(var n=this,r=this.doc.nodeAt(t),o=[],i=t+1,s=0;s=0;u--)n.step(o[u]);return this};var vl=Rf,yl=vl.Fragment,gl=vl.Slice,wl=Du,xl=wl.ReplaceStep,kl=wl.ReplaceAroundStep,Sl=hu,bl=Sl.Transform,Ml=Hu,Ol=Ml.insertPoint;bl.prototype.replaceRange=function(t,e,n){var r=this;if(!n.size)return this.deleteRange(t,e);var o=this.doc.resolve(t),i=this.doc.resolve(e);if(Ee(o,i,n))return this.step(new xl(t,e,n));var s=xe(o,this.doc.resolve(e)),a=0;0==s[s.length-1]&&s.pop(),s.unshift(o.depth+1);for(var c=o.depth;c>0&&!o.node(c).type.spec.defining;c--){var p=s.indexOf(c,1);p>-1&&(a=p)}for(var h=[],f=n.openLeft,u=n.content,l=0;;l++){var d=u.firstChild;if(h.push(d),l==n.openLeft)break;u=d.content}f>0&&h[f-1].type.spec.defining?f-=1:f>=2&&h[f-1].isTextblock&&h[f-2].type.spec.defining&&(f-=2);for(var m=n.openLeft;m>=0;m--){var v=(m+f+1)%(n.openLeft+1),y=h[v];if(y)for(var g=0;go.depth?e:i.after(w),new gl(we(n.content,0,n.openLeft,v),v,n.openRight))}}return this.replace(t,e,n)},bl.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var r=Ol(this.doc,t,n.type,n.attrs);null!=r&&(t=e=r)}return this.replaceRange(t,e,new gl(yl.from(n),0,0))},bl.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=xe(n,r),i=0;i0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1)))){t=n.before(s),e=r.after(s);break}}return this.delete(t,e)},bl.prototype.delete=function(t,e){return this.replace(t,e,gl.empty)};var Cl=ke;bl.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=gl.empty);var r=ke(this.doc,t,e,n);return r&&this.step(r),this},bl.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new gl(yl.from(n),0,0))},bl.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var Tl={replaceStep:Cl},Rl=t(function(t,e){var n;n=hu,e.Transform=n.Transform,e.TransformError=n.TransformError;var r;r=xu,e.Step=r.Step,e.StepResult=r.StepResult;var o;o=Hu,e.joinPoint=o.joinPoint,e.canJoin=o.canJoin,e.canSplit=o.canSplit,e.insertPoint=o.insertPoint,e.liftTarget=o.liftTarget,e.findWrapping=o.findWrapping;var i;i=nu,e.StepMap=i.StepMap,e.MapResult=i.MapResult,e.Mapping=i.Mapping;var s;s=ol,e.AddMarkStep=s.AddMarkStep,e.RemoveMarkStep=s.RemoveMarkStep;var a;a=Du,e.ReplaceStep=a.ReplaceStep,e.ReplaceAroundStep=a.ReplaceAroundStep;var c;c=Tl,e.replaceStep=c.replaceStep}),El=Rl,Nl=El.Transform,Al=Rf,Dl=Al.Mark,zl=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{},selectionSet:{},storedMarksSet:{},isGeneric:{},scrolledIntoView:{}};return n.selection.get=function(){return this.curSelectionFor0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return Dl.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||n.$from.marks(n.to>n.from))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=r.text(t,this.storedMarks||this.doc.resolve(e).marks(n>e));return this.replaceRangeWith(e,n,o)},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){var t=this;for(var e in t.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},Object.defineProperties(e.prototype,n),e}(Nl),Il=zl,Pl={Transaction:Il},Fl=Rf,Ll=Fl.Node,Bl=Hf,_l=Bl.Selection,jl=Pl,$l=jl.Transaction,Jl=function(t,e,n){this.name=t,this.init=Be(e.init,n),this.apply=Be(e.apply,n)},Vl=[new Jl("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new Jl("selection",{init:function(t,e){return t.selection||_l.atStart(e.doc)},apply:function(t){return t.selection}}),new Jl("storedMarks",{init:function(){return null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Jl("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],Wl=function(t,e){var n=this;this.schema=t,this.fields=Vl.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach(function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new Jl(t.key,t.spec.state,t))})},ql=function(t){this.config=t},Kl={schema:{},plugins:{},tr:{}};Kl.schema.get=function(){return this.config.schema},Kl.plugins.get=function(){return this.config.plugins},ql.prototype.apply=function(t){return this.applyTransaction(t).state},ql.prototype.filterTransaction=function(t,e){var n=this;void 0===e&&(e=-1);for(var r=0;r-1&&Ul.splice(e,1)},Object.defineProperties(ql.prototype,Kl);var Hl=ql,Ul=[],Gl={EditorState:Hl},Xl=function(t){this.props={},t.props&&_e(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:je("plugin")};Xl.prototype.getState=function(t){return t[this.key]};var Yl=Xl,Ql=Object.create(null),Zl=function(t){void 0===t&&(t="key"),this.key=je(t)};Zl.prototype.get=function(t){return t.config.pluginsByKey[this.key]},Zl.prototype.getState=function(t){return t[this.key]};var td=Zl,ed={Plugin:Yl,PluginKey:td},nd=t(function(t,e){var n;n=Hf,e.Selection=n.Selection,e.SelectionRange=n.SelectionRange,e.TextSelection=n.TextSelection,e.NodeSelection=n.NodeSelection,e.AllSelection=n.AllSelection,e.Transaction=Pl.Transaction,e.EditorState=Gl.EditorState;var r;r=ed,e.Plugin=r.Plugin,e.PluginKey=r.PluginKey}),rd=t(function(t){var e=t.exports={};if("undefined"!=typeof navigator){var n=/Edge\/(\d+)/.exec(navigator.userAgent),r=/MSIE \d/.test(navigator.userAgent),o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);e.mac=/Mac/.test(navigator.platform);var i=e.ie=!!(r||o||n);e.ie_version=r?document.documentMode||6:o?+o[1]:n?+n[1]:null,e.gecko=!i&&/gecko\/\d/i.test(navigator.userAgent),e.ios=!i&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),e.webkit=!i&&"WebkitAppearance"in document.documentElement.style,e.chrome=!i&&/Chrome/.test(navigator.userAgent)}}),od=t(function(t,e){function n(t,e,n,i,a){for(;;){if(t==n&&e==i)return!0;if(e==(a<0?0:r(t))){var c=t.parentNode;if(1!=c.nodeType||o(c))return!1;e=s(t)+(a<0?0:1),t=c}else{if(1!=t.nodeType)return!1;t=t.childNodes[e+(a<0?-1:0)],e=a<0?r(t):0}}}function r(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function o(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}var i=rd,s=e.domIndex=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e};e.parentNode=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},e.textRange=function(t,e,n){var r=document.createRange();return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},e.isEquivalentPosition=function(t,e,r,o){return r&&(n(t,e,r,o,-1)||n(t,e,r,o,1))},e.selectionCollapsed=function(t){var e=t.isCollapsed;return e&&i.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e}}),id=od,sd=id.textRange,ad=id.parentNode,cd=Je,pd=Ve,hd=We,fd=Xe,ud=Qe,ld=/[\u0590-\u08ac]/,dd=null,md=null,vd=!1,yd=nn,gd={scrollRectIntoView:cd,storeScrollPos:pd,resetScrollPos:hd,posAtCoords:fd,coordsAtPos:ud,endOfTextblock:yd},wd=Rf,xd=wd.DOMSerializer,kd=wd.Fragment,Sd=od,bd=Sd.domIndex,Md=Sd.isEquivalentPosition,Od=rd,Cd=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},Td={size:{},border:{},posBefore:{},posAtStart:{},posAfter:{},posAtEnd:{},contentLost:{}};Cd.prototype.matchesWidget=function(){return!1},Cd.prototype.matchesMark=function(){return!1},Cd.prototype.matchesNode=function(){return!1},Cd.prototype.matchesHack=function(){return!1},Cd.prototype.parseRule=function(){return null},Cd.prototype.stopEvent=function(){return!1},Td.size.get=function(){for(var t=this,e=0,n=0;n0:c)?this.posAtEnd:this.posAtStart},Cd.prototype.nearestDesc=function(t,e){for(var n=this,r=!0,o=t;o;o=o.parentNode){var i=n.getDesc(o);if(i&&(!e||i.node)){if(!r||!i.nodeDOM||(1==i.nodeDOM.nodeType?i.nodeDOM.contains(t):i.nodeDOM==t))return i;r=!1}}},Cd.prototype.getDesc=function(t){for(var e=this,n=t.pmViewDesc,r=n;r;r=r.parent)if(r==e)return n},Cd.prototype.posFromDOM=function(t,e,n){for(var r=this,o=t;;o=o.parentNode){var i=r.getDesc(o);if(i)return i.localPosFromDOM(t,e,n)}},Cd.prototype.descAt=function(t){for(var e=this,n=0,r=0;n=h&&e<=p-c.border&&c.node&&c.contentDOM&&r.contentDOM.contains(c.contentDOM))return c.parseRange(t-h,e-h,n+h);t=n+s;for(var f=a;f>0;f--){var u=r.children[f-1];if(u.size&&u.dom.parentNode==r.contentDOM&&!u.emptyChildAt(1)){o=bd(u.dom)+1;break}t-=u.size}-1==o&&(o=0)}if(o>-1&&e<=p){e=n+p;for(var l=a+1;la&&ie){var d=h;h=f,f=d}l.setEnd(f.node,f.offset),l.setStart(h.node,h.offset)}u.removeAllRanges(),u.addRange(l),u.extend&&u.extend(f.node,f.offset)}},Cd.prototype.ignoreMutation=function(t){return!this.contentDOM},Td.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},Cd.prototype.markDirty=function(t,e){for(var n=this,r=0,o=0;o=r:tr){var a=r+i.border,c=s-i.border;if(t>=a&&e<=c)return n.dirty=t==r||e==s?2:1,void(t==a&&e==c&&i.contentLost?i.dirty=3:i.markDirty(t-a,e-a));i.dirty=3}r=s}this.dirty=2},Object.defineProperties(Cd.prototype,Td);var Rd=[],Ed=function(t){function e(e,n){t.call(this,e,Rd,n.type.widget,null),this.widget=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e}(Cd),Nd=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.parseRule=function(){for(var e,n=this.dom.firstChild;n;n=n.nextSibling){var r=void 0;if(3==n.nodeType){var o=n.nodeValue.replace(/\ufeff/g,"");if(!o)continue;r=document.createTextNode(o)}else{if("\ufeff"==n.textContent)continue;r=n.cloneNode(!0)}e||(e=document.createDocumentFragment()),e.appendChild(r)}return e?{skip:e}:t.prototype.parseRule.call(this)},e.prototype.ignoreMutation=function(){return!1},e}(Ed),Ad=function(t){function e(e,n,r){t.call(this,e,[],r,r),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r){var o=dn(r)[n.type.name],i=o&&o(n,r);return new e(t,n,i&&i.dom||xd.renderSpec(document,n.type.spec.toDOM(n)).dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty>1,s=Math.min(i,t.length);o=0;n--){var r=e.seen[n];if(r.state==t)return r}},nm.prototype.track=function(t,e,n){var r=this.seen.length<200?this.find(t):null;r&&this.seen.push(new em(r,e.docChanged?e.mapping:null,n))},nm.prototype.getMapping=function(t,e){var n=this.find(t);if(!n)return null;for(var r=[],o=n;o;o=o.prev)o.mapping&&r.push(o.mapping);for(var i=e||new tm,s=r.length-1;s>=0;s--)i.appendMapping(r[s]);return i};var rm=nm,om={TrackMappings:rm},im=nd,sm=im.TextSelection,am=im.NodeSelection,cm=rd,pm=od,hm=pm.selectionCollapsed,fm=function(t){var e=this;this.view=t,this.lastAnchorNode=this.lastHeadNode=this.lastAnchorOffset=this.lastHeadOffset=null,this.lastSelection=t.state.selection,this.ignoreUpdates=!1,this.poller=Nn(this),t.dom.addEventListener("focus",function(){return e.poller.start()}),t.dom.addEventListener("blur",function(){return e.poller.stop()}),t.editable||this.poller.start()};fm.prototype.destroy=function(){this.poller.stop()},fm.prototype.poll=function(t){this.poller.poll(t)},fm.prototype.editableChanged=function(){this.view.editable?Bn(this.view)||this.poller.stop():this.poller.start()},fm.prototype.domChanged=function(){var t=this.view.root.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastHeadNode||t.focusOffset!=this.lastHeadOffset},fm.prototype.storeDOMState=function(t){var e=this.view.root.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastHeadNode=e.focusNode,this.lastHeadOffset=e.focusOffset,this.lastSelection=t},fm.prototype.clearDOMState=function(){this.lastAnchorNode=this.lastSelection=null},fm.prototype.readFromDOM=function(t){if(!this.ignoreUpdates&&this.domChanged()&&Bn(this.view)&&(this.view.inDOMChange||this.view.domObserver.flush(),!this.view.inDOMChange)){var e=this.view.root.getSelection(),n=this.view.state.doc,r=this.view.docView.nearestDesc(e.focusNode);if(!r.size)return void this.storeDOMState();var o,i,s=this.view.docView.posFromDOM(e.focusNode,e.focusOffset),a=n.resolve(s);if(hm(e)){for(o=a;r&&!r.node;)r=r.parent;if(r&&r.node.isAtom&&am.isSelectable(r.node)){var c=r.posAtStart;i=new am(s==c?a:n.resolve(c))}}else o=n.resolve(this.view.docView.posFromDOM(e.anchorNode,e.anchorOffset));if(!i){var p="pointer"==t||this.view.state.selection.headDate.now()-50?e.curOrigin:null)}};lm.prototype.poll=function(t){this.curOrigin=t,this.originTime=Date.now()},lm.prototype.start=function(){this.listening||(document.addEventListener("selectionchange",this.readFunc),this.listening=!0,Bn(this.reader.view)&&this.readFunc())},lm.prototype.stop=function(){this.listening&&(document.removeEventListener("selectionchange",this.readFunc),this.listening=!1)};var dm=function(t){this.polling=null,this.reader=t,this.pollFunc=this.doPoll.bind(this,null)};dm.prototype.doPoll=function(t){var e=this.reader.view;e.focused||!e.editable?(this.reader.readFromDOM(t),this.polling=setTimeout(this.pollFunc,100)):this.polling=null},dm.prototype.poll=function(t){clearTimeout(this.polling),this.polling=setTimeout(t?this.doPoll.bind(this,t):this.pollFunc,0)},dm.prototype.start=function(){null==this.polling&&this.poll()},dm.prototype.stop=function(){clearTimeout(this.polling),this.polling=null};var mm=An,vm=Ln,ym={SelectionReader:um,selectionToDOM:mm,selectionBetween:vm},gm=Rf,wm=gm.Fragment,xm=gm.DOMParser,km=nd,Sm=km.Selection,bm=Rl,Mm=bm.Mapping,Om=om,Cm=Om.TrackMappings,Tm=ym,Rm=Tm.selectionBetween,Em=od,Nm=Em.selectionCollapsed,Am=function(t,e){var n=this;this.view=t,this.state=t.state,this.composing=e,this.from=this.to=null,this.timeout=e?null:setTimeout(function(){return n.finish()},20),this.trackMappings=new Cm(t.state),this.mapping=new Mm,this.mappingTo=t.state};Am.prototype.addRange=function(t,e){null==this.from?(this.from=t,this.to=e):(this.from=Math.min(t,this.from),this.to=Math.max(e,this.to))},Am.prototype.changedRange=function(){if(null==this.from)return Vn(this.state.selection);var t=this.state.doc.resolve(Math.min(this.from,this.state.selection.from)),e=this.state.doc.resolve(this.to),n=t.sharedDepth(this.to);return{from:t.before(n+1),to:e.after(n+1)}},Am.prototype.markDirty=function(t){null==this.from?this.view.docView.markDirty((t=t||this.changedRange()).from,t.to):this.view.docView.markDirty(this.from,this.to)},Am.prototype.stateUpdated=function(t){return this.trackMappings.getMapping(t,this.mapping)?(this.trackMappings.destroy(),this.trackMappings=new Cm(t),this.mappingTo=t,!0):(this.markDirty(),this.destroy(),!1)},Am.prototype.finish=function(t){if(clearTimeout(this.timeout),!this.composing||t){this.view.domObserver.flush();var e=this.changedRange();this.markDirty(e),this.destroy(),qn(this.view,this.mapping,this.state,e),this.view.docView.dirty&&this.view.updateState(this.view.state)}},Am.prototype.destroy=function(){clearTimeout(this.timeout),this.trackMappings.destroy(),this.view.inDOMChange=null},Am.prototype.compositionEnd=function(){var t=this;this.composing&&(this.composing=!1,this.timeout=setTimeout(function(){return t.finish()},50))},Am.start=function(t,e){return t.inDOMChange?e&&(clearTimeout(t.inDOMChange.timeout),t.inDOMChange.composing=!0):t.inDOMChange=new Am(t,e),t.inDOMChange};var Dm=Am,zm={DOMChange:Dm},Im=Rf,Pm=Im.Slice,Fm=Im.Fragment,Lm=Im.DOMParser,Bm=Im.DOMSerializer,_m=Yn,jm=Qn,$m={thead:"table",colgroup:"table",col:"table colgroup",tr:"table tbody",td:"table tbody tr",th:"table tbody tr"},Jm=null,Vm={serializeForClipboard:_m,parseFromClipboard:jm},Wm=rd,qm=zm,Km=qm.DOMChange,Hm=od,Um=Hm.domIndex,Gm={childList:!0,characterData:!0,attributes:!0,subtree:!0},Xm=Wm.ie&&Wm.ie_version<=11,Ym=function(t){var e=this;this.view=t,this.observer=window.MutationObserver&&new window.MutationObserver(function(t){return e.registerMutations(t)}),Xm&&(this.onCharData=function(t){return e.registerMutation({target:t.target,type:"characterData"})})};Ym.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Gm),Xm&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData)},Ym.prototype.stop=function(){this.observer&&(this.flush(),this.observer.disconnect()),Xm&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData)},Ym.prototype.flush=function(){this.observer&&this.registerMutations(this.observer.takeRecords())},Ym.prototype.registerMutations=function(t){for(var e=this,n=0;n=500||!ur(e,Sv)||e[Mv]?"singleClick":o-bv.time>=600||!ur(e,bv)?"doubleClick":"tripleClick",bv=Sv,Sv={time:o,x:e.clientX,y:e.clientY};var i=t.posAtCoords(fr(e));i&&("singleClick"==n?t.mouseDown=new Ov(t,i,e,r):("doubleClick"==n?gr:wr)(t,i.pos,i.inside,e)?e.preventDefault():t.selectionReader.poll("pointer"))};var Ov=function(t,e,n,r){var o=this;this.view=t,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[Mv],this.allowDefault=n.shiftKey;var i,s;if(e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{var a=t.state.doc.resolve(e.pos);i=a.parent,s=a.depth?a.before():0}this.mightDrag=null,(i.type.spec.draggable&&!1!==i.type.spec.selectable||t.state.selection instanceof nv&&s==t.state.selection.from)&&(this.mightDrag={node:i,pos:s}),this.target=r?null:n.target,this.target&&this.mightDrag&&(this.view.domObserver.stop(),this.target.draggable=!0,ov.gecko&&(this.setContentEditable=!this.target.hasAttribute("contentEditable"))&&setTimeout(function(){return o.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),t.selectionReader.poll("pointer")};Ov.prototype.done=function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.target.draggable=!1,ov.gecko&&this.setContentEditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start())},Ov.prototype.up=function(t){this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)&&(this.allowDefault?this.view.selectionReader.poll("pointer"):yr(this.view,this.pos.pos,this.pos.inside,t,this.selectNode)?t.preventDefault():this.flushed?(dr(this.view,ev.near(this.view.state.doc.resolve(this.pos.pos)),"pointer"),t.preventDefault()):this.view.selectionReader.poll("pointer"))},Ov.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),this.view.selectionReader.poll("pointer")},vv.touchdown=function(t){kr(t),t.selectionReader.poll("pointer")},vv.contextmenu=function(t,e){kr(t);var n=t.posAtCoords(fr(e));n&&t.someProp("handleContextMenu",function(r){return r(t,n.pos,e)})&&e.preventDefault()},yv.compositionstart=yv.compositionupdate=function(t){cv.start(t,!0)},yv.compositionend=function(t,e){if(!t.inDOMChange){if(!e.data)return;cv.start(t,!0)}t.inDOMChange.compositionEnd()},yv.input=function(t){return cv.start(t)};var Cv=ov.ie||ov.ios;vv.copy=yv.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=Cv?null:e.clipboardData,i=n.content(),s=fv(t,i);o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",i.content.textBetween(0,i.content.size,"\n\n"))):Sr(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView())}},yv.paste=function(t,e){var n=Cv?null:e.clipboardData;n&&Or(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():Mr(t,e)};var Tv=function(t,e){this.slice=t,this.move=e};vv.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var r=t.state.selection,o=r.empty?null:t.posAtCoords(fr(e));if(o&&o.pos>=r.from&&o.pos<=r.to);else{if(!n||!n.mightDrag)return;t.dispatch(t.state.tr.setSelection(nv.create(t.state.doc,n.mightDrag.pos)))}var i=t.state.selection.content(),s=fv(t,i);e.dataTransfer.clearData(),e.dataTransfer.setData("text/html",s.innerHTML),e.dataTransfer.setData("text/plain",i.content.textBetween(0,i.content.size,"\n\n")),t.dragging=new Tv(i,!e.ctrlKey)}},vv.dragend=function(t){window.setTimeout(function(){return t.dragging=null},50)},yv.dragover=yv.dragenter=function(t,e){return e.preventDefault()},yv.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.state.doc.resolve(t.posAtCoords(fr(e)).pos);if(r){var o=n&&n.slice||hv(t,e.dataTransfer.getData("text/plain"),e.dataTransfer.getData("text/html"),!1,r);if(o&&(e.preventDefault(),!t.someProp("handleDrop",e,o,n&&n.move))){var i=Cr(o,t.state.doc.resolve(r.pos)),s=t.state.tr;n&&n.move&&s.deleteSelection();var a=s.mapping.map(i),c=0==o.openLeft&&0==o.openRight&&1==o.content.childCount;c?s.replaceRangeWith(a,a,o.content.firstChild):s.replaceRange(a,a,o);var p=s.doc.resolve(a);c&&nv.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild)?s.setSelection(new nv(p)):s.setSelection(mv(t,p,s.doc.resolve(s.mapping.map(i)))),t.focus(),t.dispatch(s)}}}},vv.focus=function(t,e){t.focused||(t.dom.classList.add("ProseMirror-focused"),t.focused=!0),t.someProp("onFocus",function(n){n(t,e)})},vv.blur=function(t,e){t.focused&&(t.dom.classList.remove("ProseMirror-focused"),t.focused=!1),t.someProp("onBlur",function(n){n(t,e)})};for(var Rv in yv)vv[Rv]=yv[Rv];var Ev={initInput:gv,destroyInput:wv,ensureListeners:xv,dispatchEvent:kv},Nv=function(t,e){if(this.spec=e||Bv,!this.spec.raw){if(1!=t.nodeType){var n=document.createElement("span");n.appendChild(t),t=n}t.contentEditable=!1,t.classList.add("ProseMirror-widget")}this.widget=t};Nv.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,"left"==this.spec.associative?-1:1),i=o.pos;return o.deleted?null:new Iv(i-n,i-n,this)},Nv.prototype.valid=function(){return!0},Nv.prototype.eq=function(t){return this==t||t instanceof Nv&&(this.widget==t.widget||this.spec.key)&&Tr(this.spec,t.spec)};var Av=!1,Dv=function(t,e){this.spec=e||Bv,this.attrs=t,e&&(e.inclusiveLeft||e.inclusiveRight)&&(e.inclusiveStart||(e.inclusiveStart=e.inclusiveLeft),e.inclusiveEnd||(e.inclusiveEnd=e.inclusiveRight),!Av&&"undefined"!=typeof console&&console.warn&&(Av=!0,console.warn("The inclusiveLeft and inclusiveRight options to inline decorations are now called inclusiveStart and inclusiveEnd")))};Dv.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Iv(o,i,this)},Dv.prototype.valid=function(t,e){return e.from=t&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;at){var c=o.children[a]+1;o.children[a+2].findInner(t-c,e-c,n,r+c)}},_v.prototype.map=function(t,e,n){return this==$v||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Bv)},_v.prototype.mapInner=function(t,e,n,r,o){for(var i,s=this,a=0;aa&&h.to=t){n.children[i]==t&&(r=n.children[i+2]);break}for(var s=t+1,a=s+e.content.size,c=0;cs&&p.type instanceof Dv){var h=Math.max(s,p.from)-s,f=Math.min(a,p.to)-s;he.scrollToSelection||e.config!=t.config,p=!this.docView.matchesNode(t.doc,a,o),h=p||!t.selection.eq(e.selection)||this.selectionReader.domChanged(),u=!c&&h&&y(this);h&&(this.domObserver.stop(),p&&(this.docView.update(t.doc,a,o,this)||(this.docView.destroy(),this.docView=x(t.doc,a,o,this.dom,this)),this.selectionReader.clearDOMState()),R(this),this.domObserver.start()),r!=this.editable&&this.selectionReader.editableChanged(),this.updatePluginViews(e),c?t.selection instanceof f?l(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect()):l(this,this.coordsAtPos(t.selection.head)):u&&g(u)}},D.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},D.prototype.updatePluginViews=function(t){var e=this,n=this.state.plugins;if(t&&t.plugins==n)for(var r=0;r=e?ky.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},ky.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},ky.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},ky.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(e,n){return r.push(t(e,n))},e,n),r},ky.from=function(t){return t instanceof ky?t:t&&t.length?new Sy(t):ky.empty};var Sy=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{},depth:{}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var o=this,i=e;i=n;i--)if(!1===t(o.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(ky);ky.empty=new Sy([]);var by=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return to&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(e>o&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(n,o)-o,r+o))&&(!(n=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(ky),My=ky,Oy=My,Cy=Wc,Ty=Cy.Mapping,Ry=gp,Ey=Ry.Plugin,Ny=Ry.PluginKey,Ay=function(t,e){this.items=t,this.eventCount=e};Ay.prototype.popEvent=function(t,e){var n=this;if(0==this.eventCount)return null;for(var r=this.items.length;;r--){if(n.items.get(r-1).selection){--r;break}}var o,i;e&&(o=this.remapping(r,this.items.length),i=o.maps.length);var s,a,c=t.tr,p=[],h=[];return this.items.forEach(function(t,e){if(!t.step)return o||(o=n.remapping(r,e+1),i=o.maps.length),i--,void h.push(t);if(o){h.push(new Dy(t.map));var f,u=t.step.map(o.slice(i));u&&c.maybeStep(u).doc&&(f=c.mapping.maps[c.mapping.maps.length-1],p.push(new Dy(f,null,null,p.length+h.length))),i--,f&&o.appendMap(f,i)}else c.maybeStep(t.step);return t.selection?(s=o?t.selection.map(o.slice(i)):t.selection,a=new Ay(n.items.slice(0,r).append(h.reverse().concat(p)),n.eventCount-1),!1):void 0},this.items.length,0),{remaining:a,transform:c,selection:s}},Ay.prototype.addTransform=function(t,e,n){for(var r=[],o=this.eventCount+(e?1:0),i=this.items,s=!n.preserveItems&&i.length?i.get(i.length-1):null,a=0;aIy&&(i=mo(i,f),o-=f),new Ay(i.append(r),o)},Ay.prototype.remapping=function(t,e){var n=[],r=[];return this.items.forEach(function(e,o){if(null!=e.mirrorOffset){o-e.mirrorOffset>=t&&r.push(n.length-e.mirrorOffset,n.length)}n.push(e.map)},t,e),new Ty(n,r)},Ay.prototype.addMaps=function(t){return 0==this.eventCount?this:new Ay(this.items.append(t.map(function(t){return new Dy(t)})),this.eventCount)},Ay.prototype.rebased=function(t,e){if(!this.eventCount)return this;var n=[],r=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount,a=e;this.items.forEach(function(e){var r=o.getMirror(--a);if(null!=r){i=Math.min(i,r);var c=o.maps[r];if(e.step){var p=t.steps[r].invert(t.docs[r]),h=e.selection&&e.selection.map(o.slice(a,r));n.push(new Dy(c,p,h))}else e.selection&&s--,n.push(new Dy(c))}},r);for(var c=[],p=e;p500&&(f=f.compress(this.items.length-n.length)),f},Ay.prototype.emptyItemCount=function(){var t=0;return this.items.forEach(function(e){e.step||t++}),t},Ay.prototype.compress=function(t){void 0===t&&(t=this.items.length);var e=this.remapping(0,t),n=e.maps.length,r=[],o=0;return this.items.forEach(function(i,s){if(s>=t)r.push(i),i.selection&&o++;else if(i.step){var a=i.step.map(e.slice(n)),c=a&&a.getMap();if(n--,c&&e.appendMap(c,n),a){var p=i.selection&&i.selection.map(e.slice(n));p&&o++;var h,f=new Dy(c.invert(),a,p),u=r.length-1;(h=r.length&&r[u].merge(f))?r[u]=h:r.push(f)}}else i.map&&n--},this.items.length,0),new Ay(Oy.from(r.reverse()),o)},Ay.empty=new Ay(Oy.empty,0);var Dy=function(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r};Dy.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new Dy(e.getMap().invert(),e,this.selection)}};for(var zy=function(t,e,n,r){this.done=t,this.undone=e,this.prevMap=n,this.prevTime=r},Iy=20,Py=new Ny("history"),Fy=new Ny("closeHistory"),Ly=wo,By=xo,_y=ko,jy={"Mod-z":By,"Shift-Mod-z":_y},$y={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},Jy={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:";",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Vy="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Wy=Vy&&+Vy[1]<57,qy=0;qy<10;qy++)$y[48+qy]=$y[96+qy]=String(qy);for(var qy=1;qy<=24;qy++)$y[qy+111]="F"+qy;for(var qy=65;qy<=90;qy++)$y[qy]=String.fromCharCode(qy+32),Jy[qy]=String.fromCharCode(qy);for(var Ky in $y)Jy.hasOwnProperty(Ky)||(Jy[Ky]=$y[Ky]);var Hy=Mo;Mo.base=$y,Mo.shift=Jy;var Uy=Hy,Gy=gp,Xy=Gy.Plugin,Yy="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Qy=Ro,Zy=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},tg=function(){function t(t,e){for(var n=0;n*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return["p",0]}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:function(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return["hr"]}},heading:{attrs:{level:{default:1}},content:"inline<_>*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:function(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return["pre",["code",0]]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){return["img",t.attrs]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}},sg=ig,ag={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:function(t){return["a",t.attrs]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:function(t){return"italic"==t&&null}}],toDOM:function(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!=t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return["strong"]}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return["code"]}}},cg=ag,pg=(new og({nodes:ig,marks:ag}),{content:"block+"}),hg={content:"inline<_>*"},fg=sg.paragraph,ug=sg.hard_break,lg={group:"inline",toDOM:function(t){return t.text}},dg=function(){},mg=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Zy(this,t);var r=n.dom,o=n.inline,i=void 0!==o&&o,s=n.formatters,a=void 0===s?[]:s,c=n.editableCallback,p=void 0===c?dg:c,h=n.selectCallback,f=void 0===h?dg:h,u=n.inputCallback,l=void 0===u?dg:u,d=n.placeholder,m=void 0===d?"":d,v=n.formatterChangedCallback,y=void 0===v?dg:v,g=void 0,w=void 0,x=void 0,k=void 0,S=void 0,b=void 0,M=void 0,O=void 0;k=function(){return e.view.root.getSelection()},g=function(t){return!!t.keyCommand},w=function(t){return Do({schema:b,formatter:t,callback:y})},x=function(t){return zo({schema:b,formatter:t})},b=Io({inline:i,formatters:a}),S=[Kr({text:m}),Hr({callback:l}),Ao({callback:f,getSelection:k}),No({inline:i,schema:b}),Ly()].concat(ng(a.map(w)),ng(a.filter(g).map(x))),this._parser=Vs.fromSchema(b),this._serializer=Ws.fromSchema(b),this._inline=i,this._dom=r,O=this._parser.parse(r),M=xp.create({doc:O,schema:b,plugins:S}),this._view=new Gv({mount:r},{editable:p,state:M}),this.commands=a.reduce(function(t,e){var n=e.getCommand({schema:b});return Object.assign({},t,eg({},e.name,n))},{})}return tg(t,[{key:"getHTML",value:function(){var t=this._serializer.serializeFragment(this.state.doc.content),e=document.createElement("div");return e.appendChild(t),e.innerHTML}},{key:"setHTML",value:function(t){var e=document.createElement("div"),n=this.state.doc,r=void 0;e.innerHTML=t,r=this._parser.parseSlice(e,{preserveWhitespace:!0}),this.view.dispatch(this.state.tr.replace(0,n.content.size,r))}},{key:"runCommand",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.commands[t];if(!n)throw new Error("Command "+t+" not found.");return n(e)(this.state,this.view.dispatch)}},{key:"inline",get:function(){return this._inline}},{key:"view",get:function(){return this._view}},{key:"state",get:function(){return this.view&&this.view.state}},{key:"schema",get:function(){return this.state&&this.state.schema}},{key:"dom",get:function(){return this._dom}}]),t}(),vg=cg.em,yg=cg.strong,gg=cg.link,wg={parseDOM:[{tag:"u"},{style:"font-style",getAttrs:function(t){if("underline"===t)return!0}}],toDOM:function(){return["u"]}},xg=function(t,e){var n=t.doc,r=t.selection,o=r.from,i=r.to;return n.rangeHasMark(o,i,e)},kg=function(t,e,n,r){var o=null;return t.nodesBetween(e,n,function(t){for(var e=t.marks,n=0,i=e.length;!o&&n \ No newline at end of file +D.prototype.destroy=function(){this.docView&&(b(this),this.destroyPluginViews(),this.selectionReader.destroy(),this.mounted?(this.docView.update(this.state.doc,[],A(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},D.prototype.dispatchEvent=function(t){return M(this,t)},D.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e(t):this.updateState(this.state.apply(t))},Object.defineProperties(D.prototype,z),e.EditorView=D}),Hv=Kv.Decoration,Uv=Kv.DecorationSet,Gv=Kv.EditorView,Xv="simpla-text-placeholder",Yv="data-placeholder",Qv="\n."+Xv+" {\ndisplay: inline-block;\ncursor: text;\n}\n."+Xv+"::before {\ncontent: attr("+Yv+");\nopacity: 0.5;\n}",Zv=new Sp("placeholder"),ty=Wc,ey=ty.joinPoint,ny=ty.canJoin,ry=ty.liftTarget,oy=ty.canSplit,iy=ty.ReplaceAroundStep,sy=$s,ay=sy.Slice,cy=sy.Fragment,py=gp,hy=py.Selection,fy=py.TextSelection,uy=py.NodeSelection,ly=py.AllSelection,dy=eo,my=fo,vy=uo,yy={Enter:uo(to,no,ro,oo),"Mod-Enter":eo,Backspace:uo(Ur,Gr),"Mod-Backspace":uo(Ur,Gr),Delete:uo(Ur,Xr),"Mod-Delete":uo(Ur,Xr),"Alt-ArrowUp":Yr,"Alt-ArrowDown":Qr,"Mod-BracketLeft":Zr,Escape:io,"Mod-a":so};if("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform()){var gy={"Ctrl-h":yy.Backspace,"Alt-Backspace":yy["Mod-Backspace"],"Ctrl-d":yy.Delete,"Ctrl-Alt-Backspace":yy["Mod-Delete"],"Alt-Delete":yy["Mod-Delete"],"Alt-d":yy["Mod-Delete"]};for(var wy in gy)yy[wy]=gy[wy]}var xy=yy,ky=function(){};ky.prototype.append=function(t){return t.length?(t=ky.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},ky.prototype.prepend=function(t){return t.length?ky.from(t).append(this):this},ky.prototype.appendInner=function(t){return new by(this,t)},ky.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?ky.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},ky.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},ky.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},ky.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(e,n){return r.push(t(e,n))},e,n),r},ky.from=function(t){return t instanceof ky?t:t&&t.length?new Sy(t):ky.empty};var Sy=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{},depth:{}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var o=this,i=e;i=n;i--)if(!1===t(o.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(ky);ky.empty=new Sy([]);var by=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return to&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(e>o&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(n,o)-o,r+o))&&(!(n=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(ky),My=ky,Oy=My,Cy=Wc,Ty=Cy.Mapping,Ry=gp,Ey=Ry.Plugin,Ny=Ry.PluginKey,Ay=function(t,e){this.items=t,this.eventCount=e};Ay.prototype.popEvent=function(t,e){var n=this;if(0==this.eventCount)return null;for(var r=this.items.length;;r--){if(n.items.get(r-1).selection){--r;break}}var o,i;e&&(o=this.remapping(r,this.items.length),i=o.maps.length);var s,a,c=t.tr,p=[],h=[];return this.items.forEach(function(t,e){if(!t.step)return o||(o=n.remapping(r,e+1),i=o.maps.length),i--,void h.push(t);if(o){h.push(new Dy(t.map));var f,u=t.step.map(o.slice(i));u&&c.maybeStep(u).doc&&(f=c.mapping.maps[c.mapping.maps.length-1],p.push(new Dy(f,null,null,p.length+h.length))),i--,f&&o.appendMap(f,i)}else c.maybeStep(t.step);return t.selection?(s=o?t.selection.map(o.slice(i)):t.selection,a=new Ay(n.items.slice(0,r).append(h.reverse().concat(p)),n.eventCount-1),!1):void 0},this.items.length,0),{remaining:a,transform:c,selection:s}},Ay.prototype.addTransform=function(t,e,n){for(var r=[],o=this.eventCount+(e?1:0),i=this.items,s=!n.preserveItems&&i.length?i.get(i.length-1):null,a=0;aIy&&(i=mo(i,f),o-=f),new Ay(i.append(r),o)},Ay.prototype.remapping=function(t,e){var n=[],r=[];return this.items.forEach(function(e,o){if(null!=e.mirrorOffset){o-e.mirrorOffset>=t&&r.push(n.length-e.mirrorOffset,n.length)}n.push(e.map)},t,e),new Ty(n,r)},Ay.prototype.addMaps=function(t){return 0==this.eventCount?this:new Ay(this.items.append(t.map(function(t){return new Dy(t)})),this.eventCount)},Ay.prototype.rebased=function(t,e){if(!this.eventCount)return this;var n=[],r=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount,a=e;this.items.forEach(function(e){var r=o.getMirror(--a);if(null!=r){i=Math.min(i,r);var c=o.maps[r];if(e.step){var p=t.steps[r].invert(t.docs[r]),h=e.selection&&e.selection.map(o.slice(a,r));n.push(new Dy(c,p,h))}else e.selection&&s--,n.push(new Dy(c))}},r);for(var c=[],p=e;p500&&(f=f.compress(this.items.length-n.length)),f},Ay.prototype.emptyItemCount=function(){var t=0;return this.items.forEach(function(e){e.step||t++}),t},Ay.prototype.compress=function(t){void 0===t&&(t=this.items.length);var e=this.remapping(0,t),n=e.maps.length,r=[],o=0;return this.items.forEach(function(i,s){if(s>=t)r.push(i),i.selection&&o++;else if(i.step){var a=i.step.map(e.slice(n)),c=a&&a.getMap();if(n--,c&&e.appendMap(c,n),a){var p=i.selection&&i.selection.map(e.slice(n));p&&o++;var h,f=new Dy(c.invert(),a,p),u=r.length-1;(h=r.length&&r[u].merge(f))?r[u]=h:r.push(f)}}else i.map&&n--},this.items.length,0),new Ay(Oy.from(r.reverse()),o)},Ay.empty=new Ay(Oy.empty,0);var Dy=function(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r};Dy.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new Dy(e.getMap().invert(),e,this.selection)}};for(var zy=function(t,e,n,r){this.done=t,this.undone=e,this.prevMap=n,this.prevTime=r},Iy=20,Py=new Ny("history"),Fy=new Ny("closeHistory"),Ly=wo,By=xo,_y=ko,jy={"Mod-z":By,"Shift-Mod-z":_y},$y={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},Jy={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:";",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Vy="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Wy=Vy&&+Vy[1]<57,qy=0;qy<10;qy++)$y[48+qy]=$y[96+qy]=String(qy);for(var qy=1;qy<=24;qy++)$y[qy+111]="F"+qy;for(var qy=65;qy<=90;qy++)$y[qy]=String.fromCharCode(qy+32),Jy[qy]=String.fromCharCode(qy);for(var Ky in $y)Jy.hasOwnProperty(Ky)||(Jy[Ky]=$y[Ky]);var Hy=Mo;Mo.base=$y,Mo.shift=Jy;var Uy=Hy,Gy=gp,Xy=Gy.Plugin,Yy="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Qy=Ro,Zy=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},tg=function(){function t(t,e){for(var n=0;n*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return["p",0]}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:function(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return["hr"]}},heading:{attrs:{level:{default:1}},content:"inline<_>*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:function(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return["pre",["code",0]]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){return["img",t.attrs]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}},sg=ig,ag={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:function(t){return["a",t.attrs]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:function(t){return"italic"==t&&null}}],toDOM:function(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!=t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return["strong"]}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return["code"]}}},cg=ag,pg=(new og({nodes:ig,marks:ag}),{content:"block+"}),hg={content:"inline<_>*"},fg=sg.paragraph,ug=sg.hard_break,lg={group:"inline",toDOM:function(t){return t.text}},dg=function(){},mg=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Zy(this,t);var r=n.dom,o=n.inline,i=void 0!==o&&o,s=n.formatters,a=void 0===s?[]:s,c=n.editableCallback,p=void 0===c?dg:c,h=n.selectCallback,f=void 0===h?dg:h,u=n.inputCallback,l=void 0===u?dg:u,d=n.placeholder,m=void 0===d?"":d,v=n.formatterChangedCallback,y=void 0===v?dg:v,g=void 0,w=void 0,x=void 0,k=void 0,S=void 0,b=void 0,M=void 0,O=void 0;k=function(){return e.view.root.getSelection()},g=function(t){return!!t.keyCommand},w=function(t){return Do({schema:b,formatter:t,callback:y})},x=function(t){return zo({schema:b,formatter:t})},b=Io({inline:i,formatters:a}),S=[Kr({text:m}),Hr({callback:l}),Ao({callback:f,getSelection:k}),No({inline:i,schema:b}),Ly()].concat(ng(a.map(w)),ng(a.filter(g).map(x))),this._parser=Vs.fromSchema(b),this._serializer=Ws.fromSchema(b),this._inline=i,this._dom=r,O=this._parser.parse(r),M=xp.create({doc:O,schema:b,plugins:S}),this._view=new Gv({mount:r},{editable:p,state:M}),this.commands=a.reduce(function(t,e){var n=e.getCommand({schema:b});return Object.assign({},t,eg({},e.name,n))},{})}return tg(t,[{key:"getHTML",value:function(){var t=this._serializer.serializeFragment(this.state.doc.content),e=document.createElement("div");return e.appendChild(t),e.innerHTML}},{key:"setHTML",value:function(t){var e=document.createElement("div"),n=this.state.doc,r=void 0;e.innerHTML=t,r=this._parser.parseSlice(e,{preserveWhitespace:!0}),this.view.dispatch(this.state.tr.replace(0,n.content.size,r))}},{key:"runCommand",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.commands[t];if(!n)throw new Error("Command "+t+" not found.");return n(e)(this.state,this.view.dispatch)}},{key:"inline",get:function(){return this._inline}},{key:"view",get:function(){return this._view}},{key:"state",get:function(){return this.view&&this.view.state}},{key:"schema",get:function(){return this.state&&this.state.schema}},{key:"dom",get:function(){return this._dom}}]),t}(),vg=cg.em,yg=cg.strong,gg=cg.link,wg={parseDOM:[{tag:"u"},{style:"font-style",getAttrs:function(t){if("underline"===t)return!0}}],toDOM:function(){return["u"]}},xg=function(t,e){var n=t.doc,r=t.selection,o=r.from,i=r.to;return n.rangeHasMark(o,i,e)},kg=function(t,e,n,r){var o=null;return t.nodesBetween(e,n,function(t){for(var e=t.marks,n=0,i=e.length;!o&&n \ No newline at end of file diff --git a/src/behaviors/toolbar-placement.js b/src/behaviors/toolbar-placement.js new file mode 100644 index 0000000..5e9cd8c --- /dev/null +++ b/src/behaviors/toolbar-placement.js @@ -0,0 +1,61 @@ +import Popper from 'popper.js'; +import MobileDetect from 'mobile-detect'; + +const GUTTER = 5, + detect = new MobileDetect(window.navigator.userAgent), + IS_MOBILE = !!(detect.mobile() || detect.tablet()); + +export default { + properties: { + range: { + type: Object, + value: null, + observer: 'hoverOverRange' + }, + + mobile: { + type: Boolean, + reflectToAttribute: true, + value: IS_MOBILE + } + }, + + attached() { + let getRect = () => { + if (this.range) { + return this.range.getBoundingClientRect(); + } + + return { top: 0, left: 0, right: 0, bottom: 0, width: 0, height: 0 }; + }; + + this._popper = new Popper({ + getBoundingClientRect() { + return getRect(); + }, + + get clientWidth() { + return getRect().width; + }, + + get clientHeight() { + return getRect().height; + } + }, this, { + placement: 'top', + modifiers: { offset: { offset: `0,${GUTTER}` } } + }); + }, + + hoverOverRange(range) { + this.hidden = !range; + + if (!range || IS_MOBILE) { + return; + } + + if (this._popper) { + this._popper.scheduleUpdate(); + } + } +} diff --git a/src/simpla-text-editor.html b/src/simpla-text-editor.html index fae5063..3edea72 100644 --- a/src/simpla-text-editor.html +++ b/src/simpla-text-editor.html @@ -174,42 +174,28 @@