From cdd83641518d9b20e81f71e6a30bfe73866df2e8 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 6 Feb 2021 13:38:33 +0100 Subject: Added prosemirror deps --- resources/prosemirror.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 resources/prosemirror.js (limited to 'resources') diff --git a/resources/prosemirror.js b/resources/prosemirror.js new file mode 100644 index 0000000..94ad215 --- /dev/null +++ b/resources/prosemirror.js @@ -0,0 +1,2 @@ +!function(){"use strict";function s(t){this.content=t}s.prototype={constructor:s,find:function(t){for(var e=0;e>1}},s.from=function(t){if(t instanceof s)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new s(e)};var p=s;var I=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;nthis.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(t<=o)return o==t||0"},I.prototype.toStringInner=function(){return this.content.join(", ")},I.prototype.toJSON=function(){return this.content.length?this.content.map(function(t){return t.toJSON()}):null},I.fromJSON=function(t,e){if(!e)return I.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new I(e.map(t.nodeFromJSON))},I.fromArray=function(t){if(!t.length)return I.empty;for(var e,n=0,r=0;rthis.type.rank&&((e=e||t.slice(0,r)).push(this),n=!0),e&&e.push(o)}}return e=e||t.slice(),n||e.push(this),e},c.prototype.removeFromSet=function(t){for(var e=0;et.depth)throw new o("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new o("Inconsistent open depths");return function t(e,n,r,o){var i=e.index(o),s=e.node(o);{if(i==n.index(o)&&on?i++:t.textOffset&&(u(t.nodeAfter,r),i++));for(var a=i;ao&&h(t,e,o+1),s=r.depth>o&&h(n,r,o+1),a=[];return f(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(l(i,s),u(d(i,m(t,e,n,r,o+1)),a)):(i&&u(d(i,v(t,e,o+1)),a),f(e,n,o,a),s&&u(d(s,v(n,r,o+1)),a)),f(r,null,o,a),new I(a)}function v(t,e,n){var r=[];return f(null,t,n,r),t.depth>n&&u(d(h(t,e,n+1),v(t,e,n+1)),r),f(e,null,n,r),new I(r)}function g(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),o=n-1;0<=o;o--)r=e.node(o).copy(I.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}e.size.get=function(){return this.content.size-this.openStart-this.openEnd},N.prototype.insertAt=function(t,e){var n=function t(e,n,r,o){var i=e.findIndex(n);var s=i.index;var a=i.offset;var c=e.maybeChild(s);if(a==n||c.isText)return o&&!o.canReplace(s,s,r)?null:e.cut(0,n).append(r).append(e.cut(n));var l=t(c.content,n-a-1,r);return l&&e.replaceChild(s,c.copy(l))}(this.content,t+this.openStart,e,null);return n&&new N(n,this.openStart,this.openEnd)},N.prototype.removeBetween=function(t,e){return new N(function t(e,n,r){var o=e.findIndex(n);var i=o.index;var s=o.offset;var a=e.maybeChild(i);var c=e.findIndex(r);var l=c.index;var p=c.offset;if(s==n||a.isText){if(p!=r&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,n).append(e.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(t(a.content,n-s-1,r-s-1)))}(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},N.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},N.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},N.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return 0=t)return e;return 0},y.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.posthis.pos?t:this},y.prototype.min=function(t){return t.pos>1},A.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[1+e]}},A.prototype.toString=function(){var o=[];return function t(e){o.push(e);for(var n=1;n"+o.indexOf(t.next[r+1]);return n}).join("\n")},Object.defineProperties(A.prototype,R),A.empty=new A(!0);var z=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},P={next:{configurable:!0}};function _(t){for(var e=[];e.push(function(t){var e=[];for(;e.push(function(t){for(var e=function(e){{if(e.eat("(")){var t=_(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];-1t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},Q.schemaRules=function(n){var o=[];function r(t){for(var e=null==t.priority?50:t.priority,n=0;ni.length)&&(n=o,!(e=i).length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;sthis.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},nt.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},nt.prototype.sync=function(t){for(var e=this.open;0<=e;e--)if(this.nodes[e]==t)return void(this.open=e)},rt.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;0<=e;e--){for(var n=this.nodes[e].content,r=n.length-1;0<=r;r--)t+=n[r].nodeSize;e&&t++}return t},nt.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;nn.pos?null:new i(e.pos,n.pos,r,o,this.slice,this.insert,this.structure)},i.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},i.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new i(e.from,e.to,e.gapFrom,e.gapTo,N.fromJSON(t,e.slice),e.insert,!!e.structure)},i}(yt);function St(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;0=n.pos?null:new o(e.pos,n.pos,this.mark)},o.prototype.merge=function(t){if(t instanceof o&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new o(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},o.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},o.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new o(e.from,e.to,t.markFromJSON(e.mark))},o}(yt);yt.jsonID("addMark",zt);var Pt=function(r){function o(t,e,n){r.call(this),this.from=t,this.to=e,this.mark=n}return r&&(o.__proto__=r),((o.prototype=Object.create(r&&r.prototype)).constructor=o).prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new N(Rt(n.content,function(t){return t.mark(e.mark.removeFromSet(t.marks))}),n.openStart,n.openEnd);return bt.fromReplace(t,this.from,this.to,r)},o.prototype.invert=function(){return new zt(this.from,this.to,this.mark)},o.prototype.map=function(t){var e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new o(e.pos,n.pos,this.mark)},o.prototype.merge=function(t){if(t instanceof o&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new o(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},o.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},o.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new o(e.from,e.to,t.markFromJSON(e.mark))},o}(yt);function _t(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=N.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Bt(o,i,r)?new kt(e,n,r):new Vt(o,i,r).fit()}function Bt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}yt.jsonID("removeMark",Pt),mt.prototype.addMark=function(c,l,p){var e=this,h=[],u=[],f=null,d=null;return this.doc.nodesBetween(c,l,function(t,e,n){if(t.isInline){var r=t.marks;if(!p.isInSet(r)&&n.type.allowsMarkType(p.type)){for(var o=Math.max(e,c),i=Math.min(e+t.nodeSize,l),s=p.addToSet(r),a=0;ae.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;o==e.start(r)&&n.push(r)}return n}$t.depth.get=function(){return this.frontier.length-1},Vt.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;for(var i=this.placed,s=r.depth,a=o.depth;s&&a&&1==i.childCount;)i=i.firstChild.content,s--,a--;var c=new N(i,s,a);return-1=e.size-r?n+1:0)),!0)},Vt.prototype.dropNode=function(){var t,e=this.unplaced,n=e.content,r=e.openStart,o=e.openEnd,i=Lt(n,r);i.childCount<=1&&0n;)this.closeFrontierNode();if(i)for(var s=0;se.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=qt(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},Vt.prototype.openFrontierNode=function(t,e,n){var r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=qt(this.placed,this.depth,I.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},Vt.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(I.empty,!0);t.childCount&&(this.placed=qt(this.placed,this.frontier.length,t))},Object.defineProperties(Vt.prototype,$t),mt.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var r=this.doc.resolve(t),o=this.doc.resolve(e);if(Bt(r,o,n))return this.step(new kt(t,e,n));var i=Jt(r,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(r.depth+1);i.unshift(s);for(var a=r.depth,c=r.pos-1;0M));C--){var O=i[C];C<0||(t=r.before(O),e=o.after(O))}return this},mt.prototype.replaceRangeWith=function(t,e,n){var r;return n.isInline||t!=e||!this.doc.resolve(t).parent.content.size||null!=(r=At(this.doc,t,n.type))&&(t=e=r),this.replaceRange(t,e,new N(I.from(n),0,0))},mt.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=Jt(n,r),i=0;in.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)};var Wt=Object.freeze({__proto__:null,AddMarkStep:zt,MapResult:ht,Mapping:ft,RemoveMarkStep:Pt,ReplaceAroundStep:xt,ReplaceStep:kt,Step:yt,StepMap:ut,StepResult:bt,Transform:mt,TransformError:dt,canJoin:Tt,canSplit:Nt,dropPoint:It,findWrapping:Ct,insertPoint:At,joinPoint:Et,liftTarget:Mt,replaceStep:_t}),Kt=Object.create(null),Ht=function(t,e,n){this.ranges=n||[new Gt(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},Ut={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};Ut.anchor.get=function(){return this.$anchor.pos},Ut.head.get=function(){return this.$head.pos},Ut.from.get=function(){return this.$from.pos},Ut.to.get=function(){return this.$to.pos},Ut.$from.get=function(){return this.ranges[0].$from},Ut.$to.get=function(){return this.ranges[0].$to},Ut.empty.get=function(){for(var t=this.ranges,e=0;em.bottom-Re(s,"bottom")&&(g=e.bottom-m.bottom+Re(a,"bottom")),e.leftm.right-Re(s,"right")&&(v=e.right-m.right+Re(a,"right")),(v||g)&&(d?c.defaultView.scrollBy(v,g):(p=l.scrollLeft,h=l.scrollTop,g&&(l.scrollTop+=g),v&&(l.scrollLeft+=v),u=l.scrollLeft-p,f=l.scrollTop-h,e={left:e.left-u,top:e.top-f,right:e.right-u,bottom:e.bottom-f})),d)break}}function Pe(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=Ce(t));return e}function _e(t,e){for(var n=0;n=a){s=Math.max(u.bottom,s),a=Math.min(u.top,a);var f=u.left>e.left?u.left-e.left:u.right=(u.left+u.right)/2?1:0));continue}}!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(i=l+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:Ve(n,r)}function $e(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Fe(t,e){var n,r,o=t.root;if(o.caretPositionFromPoint)try{var i=o.caretPositionFromPoint(e.left,e.top);i&&(n=i.offsetNode,u=i.offset)}catch(t){}n||!o.caretRangeFromPoint||(r=o.caretRangeFromPoint(e.left,e.top))&&(n=r.startContainer,u=r.startOffset);var s,a,c,l,p,h,u,f,d,m,v,g,y,w,b=o.elementFromPoint(e.left,e.top+1);if(!b||!t.dom.contains(1!=b.nodeType?b.parentNode:b)){var k=t.dom.getBoundingClientRect();if(!$e(e,k))return null;if(!(b=function t(e,n,r){var o=e.childNodes.length;if(o&&r.tope.top&&u++),n==t.dom&&u==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=u&&1==n.nodeType&&"BR"==n.childNodes[u-1].nodeName||(s=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right(m.left+m.right)/2?1:-1),s=f.docView.posFromDOM(g,y,w));var x=t.docView.nearestDesc(b,!0);return{pos:s,inside:x?x.posAtStart-x.border:-1}}function qe(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var Le=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function je(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=xe.webkit||xe.gecko;if(3==o.nodeType){if(!s||!Le.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,l=n<0?1:-1;return n<0&&!i?(c++,l=-1):0<=n&&i==o.nodeValue.length?(a--,l=1):n<0?a--:c++,Je(qe(Ne(o,a,c),l),l<0)}var p=qe(Ne(o,i,i),n);if(xe.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&is.top&&("up"==c?s.bottomn.bottom-1))return!1}}return!0})):function(i,t,s){var a=t.selection.$head;if(!a.parent.isTextblock)return!1;var e=a.parentOffset,n=!e,r=e==a.parent.content.size,c=getSelection();return He.test(a.parent.textContent)&&c.modify?Ke(i,t,function(){var t=c.getRangeAt(0),e=c.focusNode,n=c.focusOffset,r=c.caretBidiLevel;c.modify("move",s,"character");var o=!(a.depth?i.docView.domAfterPos(a.before()):i.dom).contains(1==c.focusNode.nodeType?c.focusNode:c.focusNode.parentNode)||e==c.focusNode&&n==c.focusOffset;return c.removeAllRanges(),c.addRange(t),null!=r&&(c.caretBidiLevel=r),o}):"left"==s||"backward"==s?n:r}(t,e,n));var a,r,c,o,l}function Ye(t,e,n,r){this.parent=t,this.children=e,((this.dom=n).pmViewDesc=this).contentDOM=r,this.dirty=0}var Ze={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0}};Ye.prototype.matchesWidget=function(){return!1},Ye.prototype.matchesMark=function(){return!1},Ye.prototype.matchesNode=function(){return!1},Ye.prototype.matchesHack=function(){return!1},Ze.beforePosition.get=function(){return!1},Ye.prototype.parseRule=function(){return null},Ye.prototype.stopEvent=function(){return!1},Ze.size.get=function(){for(var t=0,e=0;ei;)l.push(o[c++]);var y=i+m.nodeSize;if(m.isText){var w=y;ce+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&0e&&3==t.childNodes[e].nodeType)return t.childNodes[e];t=t.childNodes[e-1],e=Ee(t)}else{if(!(1==t.nodeType&&e=n)return a+p}}}return-1}(this.node.content,a,r-e,o-e);return c<0?null:{node:s,pos:c,text:a}}}},f.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var s=new nn(this,i,n,o);t.compositionNodes.push(s),this.children=wn(this.children,r,r+o.length,t,s)}},f.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)},f.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},f.prototype.updateOuterDeco=function(t){var e,n;mn(t,this.outerDeco)||(e=1!=this.nodeDOM.nodeType,n=this.dom,this.dom=fn(this.dom,this.nodeDOM,un(this.outerDeco,this.node,e),un(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t)},f.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},f.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},t.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(f.prototype,t),f}(Ye);function sn(t,e,n,r,o){return dn(r,e,t),new on(null,t,e,n,r,r,r,o,0)}var an=function(a){function i(t,e,n,r,o,i,s){a.call(this,t,e,n,r,o,null,i,s)}a&&(i.__proto__=a);var t={domAtom:{configurable:!0}};return((i.prototype=Object.create(a&&a.prototype)).constructor=i).prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},i.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,!(this.dirty=0))},i.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},i.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},i.prototype.localPosFromDOM=function(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):a.prototype.localPosFromDOM.call(this,t,e,n)},i.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},i.prototype.slice=function(t,e,n){var r=this.node.cut(t,e),o=document.createTextNode(r.text);return new i(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)},t.domAtom.get=function(){return!1},Object.defineProperties(i.prototype,t),i}(on),cn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t);var n={domAtom:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(Ye),ln=function(p){function t(t,e,n,r,o,i,s,a,c,l){p.call(this,t,e,n,r,o,i,s,c,l),this.spec=a}return p&&(t.__proto__=p),((t.prototype=Object.create(p&&p.prototype)).constructor=t).prototype.update=function(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){var o=this.spec.update(t,e);return o&&this.updateInner(t,e,n,r),o}return!(!this.contentDOM&&!t.isLeaf)&&p.prototype.update.call(this,t,e,n,r)},t.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():p.prototype.selectNode.call(this)},t.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():p.prototype.deselectNode.call(this)},t.prototype.setSelection=function(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):p.prototype.setSelection.call(this,t,e,n,r)},t.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),p.prototype.destroy.call(this)},t.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},t.prototype.ignoreMutation=function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):p.prototype.ignoreMutation.call(this,t)},t}(on);function pn(t){t&&(this.nodeName=t)}pn.prototype=Object.create(null);var hn=[new pn];function un(t,e,n){if(0==t.length)return hn;for(var r=n?hn[0]:new pn,o=[r],i=0;i=this.preMatchOffset?this.preMatched[t-this.preMatchOffset]:null},gn.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n>1,i=Math.min(o,t.length);rthis.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index]):(s=rn.create(this.top,t[o],e,n),this.top.children.splice(this.index,0,s),this.top=s,this.changed=!0),this.index=0,o++}},gn.prototype.findNodeMatch=function(t,e,n,r){var o=-1,i=r<0?void 0:this.getPreMatch(r),s=this.top.children;if(i&&i.matchesNode(t,e,n))o=s.indexOf(i);else for(var a=this.index,c=Math.min(s.length,a+5);aDate.now()-50?e.lastSelectionOrigin:null,a=bn(e,s);a&&!e.state.selection.eq(a)&&(i=e.state.tr.setSelection(a),"pointer"==s?i.setMeta("pointer",!0):"key"==s&&i.scrollIntoView(),e.dispatch(i))}else{var c=e.state.doc.resolve(t),l=c.sharedDepth(n);t=c.before(l+1),n=e.state.doc.resolve(n).after(l+1);var p,h,u=e.state.selection,f=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,l=t.root.getSelection(),p=null,h=l.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(p=[{node:h,offset:l.anchorOffset}],Ae(l)||p.push({node:l.focusNode,offset:l.focusOffset})),xe.chrome&&8===t.lastKeyCode)for(var u=s;iDate.now()-225&&o.some(function(t){return"DIV"==t.nodeName||"P"==t.nodeName})&&e.someProp("handleKeyDown",function(t){return t(e,Ie(13,"Enter"))})?void(e.lastIOSEnter=0):void(!f.sel||(y=Wn(e,e.state.doc,f.sel))&&!y.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(y)));else w={start:u.from,endA:u.to,endB:u.to};e.domChangeCount++,e.state.selection.frome.state.selection.from&&w.start<=e.state.selection.from+2?w.start=e.state.selection.from:w.endA=e.state.selection.to-2&&(w.endB+=e.state.selection.to-w.endA,w.endA=e.state.selection.to)),xe.ie&&xe.ie_version<=11&&w.endB==w.start+1&&w.endA==w.start&&w.start>f.from&&"  "==f.doc.textBetween(w.start-f.from-1,w.start-f.from+1)&&(w.start--,w.endA--,w.endB--);var b,k=f.doc.resolveNoCache(w.start-f.from),x=f.doc.resolveNoCache(w.endB-f.from),S=k.sameParent(x)&&k.parent.inlineContent;if((xe.ios&&e.lastIOSEnter>Date.now()-225&&(!S||o.some(function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))||!S&&k.posw.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Kn(r,!0,!1)n||Kn(s,!0,!1)e.content.size?null:Tn(t,e.resolve(n.anchor),e.resolve(n.head))}function Kn(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;0]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=Zn().createElement("div"),o=/(?:]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(n=o&&Xn[o[1].toLowerCase()])&&(t=n.map(function(t){return"<"+t+">"}).join("")+t+n.map(function(t){return""}).reverse().join(""),i=n.length);r.innerHTML=t;for(var s=0;st.target.nodeValue.length})?n.flushSoon():n.flush()}),this.currentSelection=new tr,nr&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1}rr.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){t.flushingSoon=-1,t.flush()},20))},rr.prototype.forceFlush=function(){-1i.depth?t(n,r,i.nodeAfter,i.before(e),o,!0):t(n,r,i.node(e),i.before(e),o,!1)}))return{v:!0}}(s);if(a)return a.v}return!1}function fr(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function dr(e,n,t,r,o){return ur(e,"handleClickOn",n,t,r)||e.someProp("handleClick",function(t){return t(e,n,r)})||(o?function(t,e){if(-1==e)return;var n,r,o=t.state.selection;o instanceof Yt&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;0i.depth?i.nodeAfter:i.node(s);if(Yt.isSelectable(a)){r=n&&0=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(fr(t,Yt.create(t.state.doc,r),"pointer"),!0)}:function(t,e){if(-1==e)return;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Yt.isSelectable(r))&&(fr(t,new Yt(n),"pointer"),!0)})(e,t)}function mr(e,n,t,r){return ur(e,"handleTripleClickOn",n,t,r)||e.someProp("handleTripleClick",function(t){return t(e,n,r)})||function(t,e){var n=t.state.doc;if(-1==e)return!!n.inlineContent&&(fr(t,Qt.create(n,0,n.content.size),"pointer"),!0);for(var r=n.resolve(e),o=r.depth+1;0r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)fr(t,Qt.create(n,s+1,s+1+i.content.size),"pointer");else{if(!Yt.isSelectable(i))continue;fr(t,Yt.create(n,s),"pointer")}return!0}}(e,t)}function vr(t){return Sr(t)}sr.keydown=function(e,n){var t;e.shiftKey=16==n.keyCode||n.shiftKey,wr(e,n)||(e.domObserver.forceFlush(),e.lastKeyCode=n.keyCode,e.lastKeyCodeTime=Date.now(),!xe.ios||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey?e.someProp("handleKeyDown",function(t){return t(e,n)})||Ln(e,n)?n.preventDefault():cr(e,"key"):(t=Date.now(),e.lastIOSEnter=t,e.lastIOSEnterFallbackTimeout=setTimeout(function(){e.lastIOSEnter==t&&(e.someProp("handleKeyDown",function(t){return t(e,Ie(13,"Enter"))}),e.lastIOSEnter=0)},200)))},sr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},sr.keypress=function(e,n){var r,o;wr(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||xe.mac&&n.metaKey||(e.someProp("handleKeyPress",function(t){return t(e,n)})?n.preventDefault():(r=e.state.selection)instanceof Qt&&r.$from.sameParent(r.$to)||(o=String.fromCharCode(n.charCode),e.someProp("handleTextInput",function(t){return t(e,r.$from.pos,r.$to.pos,o)})||e.dispatch(e.state.tr.insertText(o).scrollIntoView()),n.preventDefault()))};var gr=xe.mac?"metaKey":"ctrlKey";ir.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n,r,o,i,s=vr(t),a=Date.now(),c="singleClick";a-t.lastClick.time<500&&(n=e,r=t.lastClick,o=r.x-n.clientX,i=r.y-n.clientY,o*o+i*i<100)&&!e[gr]&&("singleClick"==t.lastClick.type?c="doubleClick":"doubleClick"==t.lastClick.type&&(c="tripleClick")),t.lastClick={time:a,x:e.clientX,y:e.clientY,type:c};var l=t.posAtCoords(hr(e));l&&("singleClick"==c?t.mouseDown=new yr(t,l,e,s):("doubleClick"==c?function(e,n,t,r){return ur(e,"handleDoubleClickOn",n,t,r)||e.someProp("handleDoubleClick",function(t){return t(e,n,r)})}:mr)(t,l.pos,l.inside,e)?e.preventDefault():cr(t,"pointer"))};var yr=function(t,e,n,r){var o,i,s,a=this;this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[gr],this.allowDefault=n.shiftKey,s=-1=r.from&&o.pos<=(r instanceof Yt?r.to-1:r.to)))if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(Yt.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);if(!i||!i.node.type.spec.draggable||i==t.docView)return;t.dispatch(t.state.tr.setSelection(Yt.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=Hn(t,s),c=a.dom,l=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(Mr?"Text":"text/html",c.innerHTML),Mr||e.dataTransfer.setData("text/plain",l),t.dragging=new Or(s,!e[Nr])}},ir.dragend=function(t){var e=t.dragging;window.setTimeout(function(){t.dragging==e&&(t.dragging=null)},50)},sr.dragover=sr.dragenter=function(t,e){return e.preventDefault()},sr.drop=function(e,n){var t,r,o,i,s,a,c,l,p,h,u,f=e.dragging;e.dragging=null,n.dataTransfer&&(!(t=e.posAtCoords(hr(n)))||(r=e.state.doc.resolve(t.pos))&&(o=f&&f.slice||Un(e,n.dataTransfer.getData(Mr?"Text":"text/plain"),Mr?null:n.dataTransfer.getData("text/html"),!1,r),i=f&&!n[Nr],e.someProp("handleDrop",function(t){return t(e,n,o||N.empty,i)})?n.preventDefault():o&&(n.preventDefault(),null==(s=o?It(e.state.doc,r.pos,o):r.pos)&&(s=r.pos),a=e.state.tr,i&&a.deleteSelection(),c=a.mapping.map(s),l=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,p=a.doc,l?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(p)||(h=a.doc.resolve(c),l&&Yt.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild)?a.setSelection(new Yt(h)):(u=a.mapping.map(s),a.mapping.maps[a.mapping.maps.length-1].forEach(function(t,e,n,r){return u=r}),a.setSelection(Tn(e,h,a.doc.resolve(u)))),e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))))))},ir.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&kn(t)},20))},ir.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},ir.beforeinput=function(e,t){var n;xe.chrome&&xe.android&&"deleteContentBackward"==t.inputType&&(n=e.domChangeCount,setTimeout(function(){var t;e.domChangeCount==n&&(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",function(t){return t(e,Ie(8,"Backspace"))})||(t=e.state.selection.$cursor)&&0=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a,c=0;ct&&(a=this.children[c]+1,this.children[c+2].findInner(t-a,e-a,n,r+a,o))}},Br.prototype.map=function(t,e,n){return this==Vr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||_r)},Br.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s=l[o]+c?l[o+1]=-1:a<=n&&(s=r-n-(e-t))&&(l[o]+=s,l[o+1]+=s))}},s=0;s=r.content.size){p=!0;continue}var d,m=n.map(t[h+1]+c,-1)-a,v=r.content.findIndex(f),g=v.index,y=v.offset,w=r.maybeChild(g);w&&y==f&&y+w.nodeSize==m?(d=l[h+2].mapInner(n,w,u+1,t[h]+c+1,o))!=Vr?(l[h]=f,l[h+1]=m,l[h+2]=d):(l[h+1]=-2,p=!0):p=!0}if(p){var b=jr(function(t,e,s,a,c,n,l){for(var r=0;rc&&i.to=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;ai&&p.type instanceof Ar&&((c=Math.max(i,p.from)-i)<(l=Math.min(s,p.to)-i)&&(r=r||[]).push(p.copy(c,l)))}if(r){var h=new Br(r.sort(Jr));return n?new $r([h,n]):h}return n||Vr},Br.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Br)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;en&&r.too.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(t.doc,c,a);!p&&t.selection.eq(o.selection)||(s=!0);var h,u,f,d,m,v,g,y,w,b,k,x,S,M,C="preserve"==l&&s&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:Pe(t.dom)}}(this);s&&(this.domObserver.stop(),h=p&&(xe.ie||xe.chrome)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&(v=o.selection,g=t.selection,y=Math.min(v.$anchor.sharedDepth(v.head),g.$anchor.sharedDepth(g.head)),v.$anchor.start(y)!=g.$anchor.start(y)),p&&(u=xe.chrome?this.trackWrites=this.root.getSelection().focusNode:null,!i&&this.docView.update(t.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=sn(t.doc,c,a,this.dom,this)),u&&!this.trackWrites&&(h=!0)),h||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(d=(f=this).docView.domFromPos(f.state.selection.anchor,0),m=f.root.getSelection(),Se(d.node,d.offset,m.anchorNode,m.anchorOffset)))?kn(this,h):(On(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()),this.updatePluginViews(o),"reset"==l?this.dom.scrollTop=0:"to selection"==l?(w=this.root.getSelection().focusNode,this.someProp("handleScrollToSelection",function(t){return t(r)})||(t.selection instanceof Yt?ze(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),w):ze(this,this.coordsAtPos(t.selection.head,1),w))):C&&(k=(b=C).refDOM,x=b.refTop,S=b.stack,M=k?k.getBoundingClientRect().top:0,_e(S,0==M?0:M-x))},Ur.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},Ur.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins)for(var e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},ro="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),oo="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),io="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),so="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ao="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),co=ro&&(so||+ro[1]<57)||io&&so,lo=0;lo<10;lo++)eo[48+lo]=eo[96+lo]=String(lo);for(lo=1;lo<=24;lo++)eo[lo+111]="F"+lo;for(lo=65;lo<=90;lo++)eo[lo]=String.fromCharCode(lo+32),no[lo]=String.fromCharCode(lo);for(var po in eo)no.hasOwnProperty(po)||(no[po]=eo[po]);var ho="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function uo(t){var e=Object.create(null);for(var n in t)e[function(t){var e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var a=0;a=this.length))return this.getInner(t)},Io.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)},Io.prototype.map=function(n,t,e){void 0===t&&(t=0),void 0===e&&(e=this.length);var r=[];return this.forEach(function(t,e){return r.push(n(t,e))},t,e),r},Io.from=function(t){return t instanceof Io?t:t&&t.length?new zo(t):Io.empty};var zo=function(e){function n(t){e.call(this),this.values=t}e&&(n.__proto__=e);var t={length:{configurable:!0},depth:{configurable:!0}};return((n.prototype=Object.create(e&&e.prototype)).constructor=n).prototype.flatten=function(){return this.values},n.prototype.sliceInner=function(t,e){return 0==t&&e==this.length?this:new n(this.values.slice(t,e))},n.prototype.getInner=function(t){return this.values[t]},n.prototype.forEachInner=function(t,e,n,r){for(var o=e;o=Math.max(this.right.depth,t.depth)+1?new r(this.left,new r(this.right,t)):new r(this,t)},r}(Io),_o=Io,Bo=function(t,e){this.items=t,this.eventCount=e};Bo.prototype.popEvent=function(t,e){var o=this;if(0==this.eventCount)return null;for(var i,s,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}e&&(i=this.remapping(a,this.items.length),s=i.maps.length);var c,l,p=t.tr,h=[],u=[];return this.items.forEach(function(t,e){return t.step?(i?(u.push(new Vo(t.map)),(n=t.step.map(i.slice(s)))&&p.maybeStep(n).doc&&(r=p.mapping.maps[p.mapping.maps.length-1],h.push(new Vo(r,null,null,h.length+u.length))),s--,r&&i.appendMap(r,s)):p.maybeStep(t.step),t.selection?(c=i?t.selection.map(i.slice(s)):t.selection,l=new Bo(o.items.slice(0,a).append(u.reverse().concat(h)),o.eventCount-1),!1):void 0):(i||(i=o.remapping(a,e+1),s=i.maps.length),s--,void u.push(t));var n,r},this.items.length,0),{remaining:l,transform:p,selection:c}},Bo.prototype.addTransform=function(t,e,n,r){for(var o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null,c=0;c=r?o.maps.length-t.mirrorOffset:null;o.appendMap(t.map,n)},r,t),o},Bo.prototype.addMaps=function(t){return 0==this.eventCount?this:new Bo(this.items.append(t.map(function(t){return new Vo(t)})),this.eventCount)},Bo.prototype.rebased=function(i,t){if(!this.eventCount)return this;var s=[],e=Math.max(0,this.items.length-t),a=i.mapping,c=i.steps.length,l=this.eventCount;this.items.forEach(function(t){t.selection&&l--},e);var p=t;this.items.forEach(function(t){var e,n,r,o=a.getMirror(--p);null!=o&&(c=Math.min(c,o),e=a.maps[o],t.step?(n=i.steps[o].invert(i.docs[o]),(r=t.selection&&t.selection.map(a.slice(p+1,o)))&&l++,s.push(new Vo(e,n,r))):s.push(new Vo(e)))},e);for(var n=[],r=t;r=r[n]&&(o=!0)}),o}(n,t.prevRanges)),c=s?jo(t.prevRanges,n.mapping):Lo(n.mapping.maps[n.steps.length-1]);return new $o(t.done.addTransform(n,a?e.selection.getBookmark():null,r,Ho(e)),Bo.empty,c,n.time)}function Lo(t){var o=[];return t.forEach(function(t,e,n,r){return o.push(n,r)}),o}function jo(t,e){if(!t)return null;for(var n=[],r=0;r=e.depth)return n&&n(t.tr.lift(d,m).scrollIntoView()),1;if(a&&s.isTextblock&&ni(i,"end")){for(var v=i,g=[];g.push(v),!v.isTextblock;)v=v.lastChild;if(v.canReplace(v.childCount,v.childCount,s.content)){if(n){for(var y=I.empty,w=g.length-1;0<=w;w--)y=I.from(g[w].copy(y));n(t.tr.step(new xt(e.pos-g.length,e.pos+s.nodeSize,e.pos+1,e.pos+s.nodeSize-1,new N(y,g.length,0),0,!0)).scrollIntoView())}return 1}}}}function bi(a,c){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&Ct(i,a,c);return!!s&&(e&&e(t.tr.wrap(i,s).scrollIntoView()),!0)}}function ki(s,a){return function(o,t){var e=o.selection,n=e.from,r=e.to,i=!1;return o.doc.nodesBetween(n,r,function(t,e){return!i&&void(t.isTextblock&&!t.hasMarkup(s,a)&&(i=t.type==s||(r=(n=o.doc.resolve(e)).index(),n.parent.canReplaceWith(r,r+1,s))));var n,r}),!!i&&(t&&t(o.tr.setBlockType(n,r,s,a).scrollIntoView()),!0)}}function xi(x,S){return function(t,e){var n=t.selection,r=n.empty,o=n.$cursor,i=n.ranges;if(r&&!o||!function(i,s,a){for(var t=0;t=r.depth-3;l--)a=I.from(r.node(l).copy(a));a=a.append(I.from(d.createAndFill()));var p=t.tr.replace(r.before(c?null:-1),r.after(-3),new N(a,c?3:2,2));p.setSelection(t.selection.constructor.near(p.doc.resolve(r.pos+(c?3:2)))),e(p.scrollIntoView())}return!0}var h=o.pos==r.end()?s.contentMatchAt(0).defaultType:null,u=t.tr.delete(r.pos,o.pos),f=h&&[null,{type:h}];return!!Nt(u.doc,r.pos,2,f)&&(e&&e(u.split(r.pos,2,f).scrollIntoView()),!0)}}function Yi(s){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o,function(t){return t.childCount&&t.firstChild.type==s});return!!i&&(!e||(r.node(i.depth-1).type==s?function(t,e,n,r){var o=t.tr,i=r.end,s=r.$to.end(r.depth);ithis.maxHeight&&(this.maxHeight=this.menu.offsetHeight,this.menu.style.minHeight=this.maxHeight+"px"))},$s.prototype.updateScrollCursor=function(){var t,e,n,r,o,i=this.editorView.root.getSelection();!i.focusNode||(e=(t=i.getRangeAt(0).getClientRects())[((n=i).anchorNode!=n.focusNode?n.anchorNode.compareDocumentPosition(n.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING:n.anchorOffset>n.focusOffset)?0:t.length-1])&&(r=this.menu.getBoundingClientRect(),e.topr.top&&((o=function(t){for(var e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}(this.wrapper))&&(o.scrollTop-=r.bottom-e.top)))},$s.prototype.updateFloat=function(t){var e,n,r=this.wrapper,o=r.getBoundingClientRect(),i=t?Math.max(0,t.getBoundingClientRect().top):0;this.floating?o.top>=i||o.bottomwindow.innerHeight?"none":"",t&&(this.menu.style.top=i+"px")):o.top=this.menu.offsetHeight+10&&(this.floating=!0,n=this.menu.getBoundingClientRect(),this.menu.style.left=n.left+"px",this.menu.style.width=n.width+"px",t&&(this.menu.style.top=i+"px"),this.menu.style.position="fixed",this.spacer=fs("div",{class:Bs+"-spacer",style:"height: "+n.height+"px"}),r.insertBefore(this.spacer,this.menu))},$s.prototype.destroy=function(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)};var Fs=Object.freeze({__proto__:null,Dropdown:Ss,DropdownSubmenu:Os,MenuItem:ys,blockTypeItem:Ps,icons:Ts,joinUpItem:Ds,liftItem:Es,menuBar:Vs,redoItem:Rs,renderGrouped:Ns,selectParentNodeItem:As,undoItem:Is,wrapItem:zs}),qs="ProseMirror-prompt";function Ls(e){var n=document.body.appendChild(document.createElement("div"));n.className=qs;function t(t){n.contains(t.target)||r()}setTimeout(function(){return window.addEventListener("mousedown",t)},50);var r=function(){window.removeEventListener("mousedown",t),n.parentNode&&n.parentNode.removeChild(n)},o=[];for(var i in e.fields)o.push(e.fields[i].render());var s=document.createElement("button");s.type="submit",s.className=qs+"-submit",s.textContent="OK";var a=document.createElement("button");a.type="button",a.className=qs+"-cancel",a.textContent="Cancel",a.addEventListener("click",r);var c=n.appendChild(document.createElement("form"));e.title&&(c.appendChild(document.createElement("h5")).textContent=e.title),o.forEach(function(t){c.appendChild(document.createElement("div")).appendChild(t)});var l=c.appendChild(document.createElement("div"));l.className=qs+"-buttons",l.appendChild(s),l.appendChild(document.createTextNode(" ")),l.appendChild(a);var p=n.getBoundingClientRect();n.style.top=(window.innerHeight-p.height)/2+"px",n.style.left=(window.innerWidth-p.width)/2+"px";function h(){var t=function(t,e){var n=Object.create(null),r=0;for(var o in t){var i=t[o],s=e[r++],a=i.read(s),c=i.validate(a);if(c)return function(t,e){var n=t.parentNode,r=n.appendChild(document.createElement("div"));r.style.left=t.offsetLeft+t.offsetWidth+2+"px",r.style.top=t.offsetTop-5+"px",r.className="ProseMirror-invalid",r.textContent=e,setTimeout(function(){return n.removeChild(r)},1500)}(s,c),null;n[o]=i.clean(a)}return n}(e.fields,o);t&&(r(),e.callback(t))}c.addEventListener("submit",function(t){t.preventDefault(),h()}),c.addEventListener("keydown",function(t){27==t.keyCode?(t.preventDefault(),r()):13!=t.keyCode||t.ctrlKey||t.metaKey||t.shiftKey?9==t.keyCode&&window.setTimeout(function(){n.contains(document.activeElement)||r()},500):(t.preventDefault(),h())});var u=c.elements[0];u&&u.focus()}function js(t){this.options=t}js.prototype.read=function(t){return t.value},js.prototype.validateType=function(){},js.prototype.validate=function(t){return!t&&this.options.required?"Required field":this.validateType(t)||this.options.validate&&this.options.validate(t)},js.prototype.clean=function(t){return this.options.clean?this.options.clean(t):t};var Js=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.render=function(){var t=document.createElement("input");return t.type="text",t.placeholder=this.options.label,t.value=this.options.value||"",t.autocomplete="off",t},e}(js);function Ws(t,e){for(var n=t.selection.$from,r=n.depth;0<=r;r--){var o=n.index(r);if(n.node(r).canReplaceWith(o,o,e))return!0}return!1}function Ks(e,t){var n={label:t.title,run:e};for(var r in t)n[r]=t[r];return t.enable&&!0!==t.enable||t.select||(n[t.enable?"enable":"select"]=function(t){return e(t)}),new ys(n)}function Hs(t,e){var n=t.selection,r=n.from,o=n.$from,i=n.to;return n.empty?e.isInSet(t.storedMarks||o.marks()):t.doc.rangeHasMark(r,i,e)}function Us(e,t){var n={active:function(t){return Hs(t,e)},enable:!0};for(var r in t)n[r]=t[r];return Ks(xi(e),n)}function Gs(t,e){return Ks(Qi(t,e.attrs),e)}function Qs(t){var e,r,a,n,o={};if((e=t.marks.strong)&&(o.toggleStrong=Us(e,{title:"Toggle strong style",icon:Ts.strong})),(e=t.marks.em)&&(o.toggleEm=Us(e,{title:"Toggle emphasis",icon:Ts.em})),(e=t.marks.code)&&(o.toggleCode=Us(e,{title:"Toggle code font",icon:Ts.code})),(e=t.marks.link)&&(o.toggleLink=(r=e,new ys({title:"Add or remove link",icon:Ts.link,active:function(t){return Hs(t,r)},enable:function(t){return!t.selection.empty},run:function(t,e,n){if(Hs(t,r))return xi(r)(t,e),!0;Ls({title:"Create a link",fields:{href:new Js({label:"Link target",required:!0}),title:new Js({label:"Title"})},callback:function(t){xi(r,t)(n.state,n.dispatch),n.focus()}})}}))),(e=t.nodes.image)&&(o.insertImage=(a=e,new ys({title:"Insert image",label:"Image",enable:function(t){return Ws(t,a)},run:function(t,e,n){var r=t.selection,o=r.from,i=r.to,s=null;t.selection instanceof Yt&&t.selection.node.type==a&&(s=t.selection.node.attrs),Ls({title:"Insert image",fields:{src:new Js({label:"Location",required:!0,value:s&&s.src}),title:new Js({label:"Title",value:s&&s.title}),alt:new Js({label:"Description",value:s?s.alt:t.doc.textBetween(o,i," ")})},callback:function(t){n.dispatch(n.state.tr.replaceSelectionWith(a.createAndFill(t))),n.focus()}})}}))),(e=t.nodes.bullet_list)&&(o.wrapBulletList=Gs(e,{title:"Wrap in bullet list",icon:Ts.bulletList})),(e=t.nodes.ordered_list)&&(o.wrapOrderedList=Gs(e,{title:"Wrap in ordered list",icon:Ts.orderedList})),(e=t.nodes.blockquote)&&(o.wrapBlockQuote=zs(e,{title:"Wrap in block quote",icon:Ts.blockquote})),(e=t.nodes.paragraph)&&(o.makeParagraph=Ps(e,{title:"Change to paragraph",label:"Plain"})),(e=t.nodes.code_block)&&(o.makeCodeBlock=Ps(e,{title:"Change to code block",label:"Code"})),e=t.nodes.heading)for(var i=1;i<=10;i++)o["makeHead"+i]=Ps(e,{title:"Change to heading "+i,label:"Level "+i,attrs:{level:i}});(e=t.nodes.horizontal_rule)&&(n=e,o.insertHorizontalRule=new ys({title:"Insert horizontal rule",label:"Horizontal rule",enable:function(t){return Ws(t,n)},run:function(t,e){e(t.tr.replaceSelectionWith(n.create()))}}));function s(t){return t.filter(function(t){return t})}return o.insertMenu=new Ss(s([o.insertImage,o.insertHorizontalRule]),{label:"Insert"}),o.typeMenu=new Ss(s([o.makeParagraph,o.makeCodeBlock,o.makeHead1&&new Os(s([o.makeHead1,o.makeHead2,o.makeHead3,o.makeHead4,o.makeHead5,o.makeHead6]),{label:"Heading"})]),{label:"Type..."}),o.inlineMenu=[s([o.toggleStrong,o.toggleEm,o.toggleCode,o.toggleLink])],o.blockMenu=[s([o.wrapBulletList,o.wrapOrderedList,o.wrapBlockQuote,Ds,Es,As])],o.fullMenu=o.inlineMenu.concat([[o.insertMenu,o.typeMenu]],[[Is,Rs]],o.blockMenu),o}var Xs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Ys(t,r){var e,n,o,i,s={};function a(t,e){if(r){var n=r[t];if(!1===n)return;n&&(t=n)}s[t]=e}if(a("Mod-z",Xo),a("Shift-Mod-z",Yo),a("Backspace",xo),Xs||a("Mod-y",Yo),a("Alt-ArrowUp",ci),a("Alt-ArrowDown",li),a("Mod-BracketLeft",pi),a("Escape",gi),(e=t.marks.strong)&&(a("Mod-b",xi(e)),a("Mod-B",xi(e))),(e=t.marks.em)&&(a("Mod-i",xi(e)),a("Mod-I",xi(e))),(e=t.marks.code)&&a("Mod-`",xi(e)),(e=t.nodes.bullet_list)&&a("Shift-Ctrl-8",Qi(e)),(e=t.nodes.ordered_list)&&a("Shift-Ctrl-9",Qi(e)),(e=t.nodes.blockquote)&&a("Ctrl->",bi(e)),(e=t.nodes.hard_break)&&(n=e,a("Mod-Enter",o=Si(fi,function(t,e){return e(t.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0})),a("Shift-Enter",o),Xs&&a("Ctrl-Enter",o)),(e=t.nodes.list_item)&&(a("Enter",Xi(e)),a("Mod-[",Yi(e)),a("Mod-]",Zi(e))),(e=t.nodes.paragraph)&&a("Shift-Ctrl-0",ki(e)),(e=t.nodes.code_block)&&a("Shift-Ctrl-\\",ki(e)),e=t.nodes.heading)for(var c=1;c<=6;c++)a("Shift-Ctrl-"+c,ki(e,{level:c}));return(e=t.nodes.horizontal_rule)&&(i=e,a("Mod-_",function(t,e){return e(t.tr.replaceSelectionWith(i.create()).scrollIntoView()),!0})),s}function Zs(t){var e,n,r=Do.concat(Mo,So);return(e=t.nodes.blockquote)&&r.push(Eo(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&r.push(Eo(/^(\d+)\.\s$/,e,function(t){return{order:+t[1]}},function(t,e){return e.childCount+e.attrs.order==+t[1]})),(e=t.nodes.bullet_list)&&r.push(Eo(/^\s*([-+*])\s$/,e)),(e=t.nodes.code_block)&&r.push(Ao(/^```$/,e)),(e=t.nodes.heading)&&r.push((n=e,Ao(new RegExp("^(#{1,"+6+"})\\s$"),n,function(t){return{level:t[1].length}}))),bo({rules:r})}var ta=Object.freeze({__proto__:null,buildInputRules:Zs,buildKeymap:Ys,buildMenuItems:Qs,exampleSetup:function(t){var e=[Zs(t.schema),mo(Ys(t.schema,t.mapKeys)),mo(Di),es(),as()];return!1!==t.menuBar&&e.push(Vs({floating:!1!==t.floatingMenu,content:t.menuContent||Qs(t.schema).fullMenu})),!1!==t.history&&e.push(Qo()),e.concat(new ue({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}});window.PM={model:ct,transform:Wt,state:ke,view:to,keymap:go,inputrules:Ro,history:Zo,commands:Ei,schema_basic:Li,schema_list:ts,dropcursor:rs,menu:Fs,example_setup:ta,gapcursor:us}}(); + -- cgit v1.2.3