react-substance
Version:
A React implementation of the Substance editor library.
9 lines • 214 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactSubstance=e(require("react")):t.ReactSubstance=e(t.React)}(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";var i=n(61)["default"];e.__esModule=!0;var r=n(104),o=i(r);e.SubstanceEditor=o["default"]},function(t,e,n){"use strict";var i={};i.isEqual=n(218),i.isObject=n(8),i.isArray=n(5),i.isString=n(55),i.isNumber=n(219),i.isBoolean=n(216),i.isFunction=n(93),i.cloneDeep=n(215),i.clone=n(214),i.isEmpty=n(217),i.bind=n(169),i.delay=n(171),i.debounce=n(170),i.extend=n(222),i.omit=n(223),i.last=n(158),i.first=n(156),i.compact=n(154),i.uniq=n(160),i.intersection=n(157),i.union=n(159),i.without=n(161),i.each=n(164),i.filter=n(162),i.includes=n(165),i.find=n(163),i.map=n(77),i.pluck=n(167),i.indexBy=n(166),i.sortBy=n(168),i.capitalize=n(225),i.isArrayEqual=function(t,e){if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!=e.length)return!1;for(var n=0;n<t.length;++n)if(t[n]!==e[n])return!1;return!0},i.deleteFromArray=function(t,e){for(var n=0;n<t.length;n++)t[n]===e&&(t.splice(n,1),n--)},i.deepclone=function(t){return null===t||void 0===t?t:i.isFunction(t.clone)?t.clone():i.deepclone(t)},i.deepclone=i.cloneDeep,i.getRelativeOffset=function(t,e){var n=t.offset(),i=e.offset();return n.left-=i.left,n.top-=i.top,n},i.uuid=n(35),t.exports=i},function(t,e,n){"use strict";var i=n(1),r={},o=function(t,e){var n=function(){this.__className__=e.displayName||e.name,t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};e.displayName?n.displayName=e.displayName:e.name&&(n.displayName=e.name),r.inherit(n,t);for(var i in e)if(e.hasOwnProperty(i)){if("name"===i)continue;n.prototype[i]=e[i]}return n["static"].name=e.name,n};r.initClass=function(t){!t.Prototype||t.prototype instanceof t.Prototype||(t.prototype=new t.Prototype,t.prototype.constructor=t),t["static"]=t["static"]||{},t.extend=t.extend||i.bind(o,null,t)},r.inherit=function(t,e){if(t.prototype instanceof e)throw new Error("Target already inherits from origin");var n=t.prototype.constructor,s=t.Prototype;t["super"]=e,s?(s.prototype=e.prototype,t.prototype=new s,t.prototype.constructor=t):t.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),t.prototype["super"]=e.prototype,r.initClass(e),t["static"]=Object.create(e["static"]),t.extend=i.bind(o,null,t)},r.mixin=function(t,e){var n,i=e.prototype;e.Prototype&&(i=new e.Prototype);for(n in i)"constructor"!==n&&i.hasOwnProperty(n)&&(t.prototype[n]=i[n]);if(r.initClass(t),e["static"])for(n in e["static"])e["static"].hasOwnProperty(n)&&(t["static"][n]=e["static"][n]);else r.initClass(e)},t.exports=r},function(t,e,n){"use strict";var i=n(1),r={};i.extend(r,n(1)),i.extend(r,n(2)),r.OO=n(2),r.PathAdapter=n(21),r.EventEmitter=n(27),r.Error=n(119),r.Registry=n(34),r.Factory=n(120),i.extend(r,n(121)),t.exports=r},function(t,e,n){"use strict";function i(t,e){if(!t&&"root"!==t)throw new Error("Contract: every component needs to have a parent.");this.__id__=l++,e=e||{},this.refs={},this.parent=t,this.children=[],this.context=this._getContext(),this._key=e._key,this._htmlProps={classNames:e.classNames||"",attributes:e.attributes||{},style:e.style||{}},this._setProps(e.props),this.initialize&&(console.warn("Component.initialize() has been deprecated. Use Component.didInitialize() instead."),this.initialize()),this.didInitialize(),this._setState(this.getInitialState()),this.actionHandlers={},this._data={attributes:{},style:{},handlers:{},props:{},children:[]}}function r(){this.attributes={},this.style={},this.handlers={},this.props={},this.children=[]}function o(t){r.call(this),this.type="element",this.tagName=t}function s(t){r.call(this),this.type="component",this.ComponentClass=t}var a,c,h,u=n(2),f=n(1),l=0;i.Prototype=function(){this.getChildContext=function(){return this.childContext||{}},this.didInitialize=function(){},this.getInitialState=function(){return{}},this.getParent=function(){return this.parent},this.render=function(){return i.$$("div")},this.shouldRerender=function(t,e){return!f.isEqual(t,this.props)||!f.isEqual(e,this.state)},this.rerender=function(){this._render(this.render())},this.mount=function(t){return this._render(this.render()),t.append(this.$el),c(t[0])&&this.triggerDidMount(),this},this.triggerDidMount=function(){this.didMount(),f.each(this.children,function(t){t.triggerDidMount()})},this.didMount=function(){},this.unmount=function(){return this.triggerWillUnmount(),this.$el.remove(),this},this.isMounted=function(){return this.$el?c(this.$el[0]):!1},this.triggerWillUnmount=function(){f.each(this.children,function(t){t.triggerWillUnmount()}),this.willUnmount()},this.willUnmount=function(){},this.send=function(t){for(var e=this;e;){if(e.actionHandlers[t])return e.actionHandlers[t].apply(e,Array.prototype.slice.call(arguments,1));e=e.getParent()}throw new Error("No component handled action: "+t)},this.actions=function(t){f.each(t,function(t,e){var n=t.bind(this);this.actionHandlers[e]=n},this)},this.setState=function(t){var e=this.shouldRerender(this.getProps(),t);this.willUpdateState(t),this._setState(t),this.didUpdateState(),e&&this.rerender()},this.extendState=function(t){t=f.extend({},this.state,t),this.setState(t)},this.getState=function(){return this.state},this.willUpdateState=function(t){},this.didUpdateState=function(){},this.setProps=function(t){var e=this.shouldRerender(t,this.getState());this.willReceiveProps(t),this._setProps(t),this.didReceiveProps(),e&&this.rerender()},this.getProps=function(){return this.props},this.willReceiveProps=function(t){},this.didReceiveProps=function(){},this.addClass=function(t){return this._data.addClass(t),this.$el&&this.$el.addClass(t),this},this.removeClass=function(t){return this._data.removeClass(t),this.$el&&this.$el.removeClass(t),this},this.toggleClass=function(t){return this._data.toggleClass(t),this.$el&&this.$el.toggleClass(t),this},this.attr=function(){return this._data.attr.apply(this._data,arguments),this.$el&&this.$el.attr.apply(this.$el,arguments),this},this.removeAttr=function(){return this._data.removeAttr.apply(this._data,arguments),this.$el&&this.$el.removeAttr.apply(this.$el,arguments),this},this.css=function(t){return t&&(this._data.css(t),this.$el.css(t)),this},this.append=function(t){var e=this.isMounted(),n=this._compileComponent(t,{refs:this.refs});return this._data.append(t),e&&n.triggerDidMount(),this.$el.append(n.$el),this.children.push(n),this},this.insertAt=function(t,e){var n=this.isMounted(),i=this._compileComponent(e,{refs:this.refs});return this._data.insertAt(t,e),n&&i.triggerDidMount(),i.$el.insertBefore(this.children[t].$el),this.children.splice(t,0,i),this},this.removeAt=function(t){return this._data.removeAt(t),this.children[t].unmount(),this},this.empty=function(){this._data.children=[],this.$el.empty();for(var t=0;t<this.children.length;t++)this.children[t].unmount();return this};var t=function(t){for(var e={},n=0;n<t.length;n++){var i=t[n],r=i._key;r&&(e[r]=i)}return e};this._createElement=function(t,e){var n=$("<"+t.tagName+">");return n.addClass(this._htmlProps.classNames),n.addClass(t.classNames),n.attr(this._htmlProps.attributes),n.attr(t.attributes),n.css(this._htmlProps.style),t.style&&n.css(t.style),f.each(t.handlers,function(t,i){n.on(i,t.bind(e.owner))},this),n},this._updateElement=function(t,e,n){var i=this.$el,r=e.classNames,o=t.classNames;r!==o&&(i.removeClass(r),i.addClass(o));var s=e.attributes,a=t.attributes;if(!f.isEqual(s,a)){var c=Object.keys(s);i.removeAttr(c.join(" ")),i.attr(a)}return f.isEqual(e.style,t.style)||t.style&&i.css(t.style),f.isEqual(e.handlers,t.handlers)||(f.each(e.handlers,function(t,e){i.off(e)}),f.each(t.handlers,function(t,e){i.on(e,t.bind(n.owner))},this)),i},this._render=function(e,n){function r(t,e){t.triggerWillUnmount(),t.$el.replaceWith(e.$el[0])}function o(t,e){t instanceof i.Container?t._render(e):t.setProps(e.props)}if("element"!==e.type){if(e instanceof $)throw new Error("Your render() method accidently return a jQuery instance instead of a VirtualComponent created $$.");throw new Error("Component.render() must return one html element: e.g., $$('div')")}n||(n={owner:this,refs:{}});var s=this._data;if(this.$el?this._updateElement(e,s,n):this.$el=this._createElement(e,n),this._simple_)return void this._renderSimple(e,n);var a=this.$el[0],h=c(a),u=s.children,l=e.children;if(f.isEqual(u,l))return void(this._data=e);for(var d=t(s.children,"old"),p=t(e.children),g=0,m=0,v=0,y=this.children,x=[];m<u.length||v<l.length;){var w=a.childNodes[g],b=u[m],C=l[v],_=null,S=y[m];if(!b){for(var E=v;E<l.length;E++)_=this._compileComponent(l[E],n),h&&_.triggerDidMount(),this.$el.append(_.$el),x.push(_);break}if(!C){for(var O=m;O<u.length;O++)y[O].unmount();break}if(w!==S.$el[0])throw new Error("Assertion failed: DOM structure is not as expected.");var T=C._key,N=b._key;if(N&&T)if(N===T)_=S,o(_,C),g++,m++,v++;else if(!d[T]&&p[N])_=this._compileComponent(C,n),_.$el.insertBefore(w),h&&_.triggerDidMount(),g++,v++;else{if(d[T]||p[N]){if(d[T]&&!p[N]){S.unmount(),m++;continue}throw d[T]&&p[N]?new Error("Swapping positions of persisted components not supported!"):new Error("Assertion failed: should not reach this statement.")}_=this._compileComponent(C,n),r(S,_),h&&_.triggerDidMount(),g++,v++,m++}else if(T){if(d[T]){S.unmount(),m++;continue}_=this._compileComponent(C,n),r(S,_),h&&_.triggerDidMount(),g++,m++,v++}else N?(_=this._compileComponent(C,n),p[N]?_.$el.insertBefore(w):(r(S,_),m++),h&&_.triggerDidMount(),g++,v++):("text"===C.type&&"text"===b.type&&C.props.text===b.props.text?_=S:(_=this._compileComponent(C,n),r(S,_),h&&_.triggerDidMount()),g++,m++,v++);_._key&&(n.refs[_._key]=_),x.push(_)}Object.keys(n.refs).length>0?delete this._simple_:this._simple_=!0,this.children=x,this.refs=f.clone(n.refs),this._data=e},this._renderSimple=function(t,e){for(var n=0;n<this.children.length;n++)this.children[n].unmount();for(var i=c(this.$el[0]),r=[],o=0;o<t.children.length;o++){var s=this._compileComponent(t.children[o],e);i&&s.triggerDidMount(),this.$el.append(s.$el),r.push(s)}Object.keys(e.refs).length>0?delete this._simple_:this._simple_=!0,this.refs=e.refs,this.children=r,this._data=t},this._compileComponent=function(t,e){var n;switch(t.type){case"text":n=new i.Text(this,t.props.text),n._render();break;case"element":n=new i.HtmlElement(this,t.tagName,t),n._render(t,e);break;case"component":n=new t.ComponentClass(this,t),n._render(n.render());break;default:throw new Error("Illegal state.")}return t._key&&(e.refs[t._key]=n),n},this._getContext=function(){var t=this.getParent(),e=t.context||{};return t.getChildContext?f.extend(e,t.getChildContext()):e},this._setProps=function(t){this.props=t||{},Object.freeze(this.props)},this._setState=function(t){this.state=t||{},Object.freeze(this.state)}},u.initClass(i),i.Root=function(t){i.call(this,"root",t)},u.inherit(i.Root,i),i.Container=function(t,e){i.call(this,t,e)},i.Container.Prototype=function(){},u.inherit(i.Container,i),i.HtmlElement=function(t,e,n){this.tagName=e,i.Container.call(this,t,n)},u.inherit(i.HtmlElement,i.Container),i.Text=function(t,e){i.call(this,t),this.text=e},i.Text.Prototype=function(){this._render=function(){if(this.$el)this.$el[0].textContent=this.text;else{var t=document.createTextNode(this.text);this.$el=$(t)}}},u.inherit(i.Text,i),r.Prototype=function(){this.key=function(t){return this._key=t,this},this.append=function(){var t,e=this._getChildren();if(1===arguments.length){var n=arguments[0];if(!n)return this;f.isArray(n)?(t=n,i.$$.prepareChildren(t),Array.prototype.push.apply(e,t)):f.isString(n)?e.push(new h(n)):e.push(n)}else t=Array.prototype.slice.call(arguments,0),i.$$.prepareChildren(t),Array.prototype.push.apply(e,t);return this},this._getChildren=function(){return this.children},this.insertAt=function(t,e){return this.children.splice(t,0,e),this},this.removeAt=function(t){return this.children.splice(t,1),this},this.addClass=function(t){return this.classNames||(this.classNames=""),this.classNames+=" "+t,this},this.removeClass=function(t){var e=this.classNames.split(/\s+/);return e=f.without(e,t),this.classNames=e.join(" "),this},this.toggleClass=function(t){var e=this.classNames.split(/\s+/);return e.indexOf(t)>=0?e=f.without(e,t):e.push(t),this.classNames=e.join(" "),this},this.addProps=function(t){return f.extend(this.props,t),this},this.attr=function(t){return 2===arguments.length?this.attributes[arguments[0]]=arguments[1]:f.extend(this.attributes,t),this},this.removeAttr=function(t){return f.isString(t)?delete this.attributes[t]:this.attributes=f.omit(this.attributes,t),this},this.on=function(t,e){if(2!==arguments.length||!f.isString(t)||!f.isFunction(e))throw new Error("Illegal arguments for $$.on(event, handler).");return this.handlers[t]=e,this},this.css=function(t){return this.style||(this.style={}),f.extend(this.style,t),this}},u.initClass(r),u.inherit(o,r),s.Prototype=function(){this._getChildren=function(){return this.props.children||(this.props.children=[]),this.props.children}},u.inherit(s,r),h=function(t){r.call(this),this.type="text",this.props={text:t}},i.$$=function(){var t=null;if(f.isString(arguments[0])){if(1!==arguments.length)throw new Error("Illegal usage of Component.$$.");t=new o(arguments[0])}else{if(!(f.isFunction(arguments[0])&&arguments[0].prototype instanceof i))throw new Error("Illegal usage of Component.$$.");if(arguments.length<1||arguments.length>2)throw new Error("Illegal usage of Component.$$.");t=new s(arguments[0]),2===arguments.length&&t.addProps(arguments[1])}return t},i.$$.prepareChildren=function(t){for(var e=0;e<t.length;e++)f.isString(t[e])&&(t[e]=new h(t[e]))},a=function(t){return 9===t.nodeType},c=function(t){for(;t;){if(a(t))return!0;t=t.parentNode}return!1},i.mount=function(t,e){var n,r={context:null,refs:{}};switch(t.type){case"text":n=new i.Text("root",t.props.text),n._render();break;case"element":n=new i.HtmlElement("root",t.tagName,t),n._render(t,r);break;case"component":n=new t.ComponentClass("root",t),n._render(n.render());break;default:throw new Error("Illegal state.")}return e.append(n.$el),c(e[0])&&n.triggerDidMount(),n},i.VirtualTextNode=h,t.exports=i},function(t,e,n){var i=n(7),r=n(11),o=n(12),s="[object Array]",a=Object.prototype,c=a.toString,h=r(h=Array.isArray)&&h,u=h||function(t){return o(t)&&i(t.length)&&c.call(t)==s||!1};t.exports=u},function(t,e,n){"use strict";var i=n(3),r=n(13),o=r.Node.extend({displayName:"DocumentNode",name:"node",attach:function(t){this.document=t,this.didAttach(t)},detach:function(){var t=this.document;i.each(this.constructor.schema,function(e,n){t.getEventProxy("path").remove([this.id,n],this)}),this.document=null,this.didDetach(t)},didAttach:function(){},didDetach:function(){},isAttached:function(){return null!==this.document},getDocument:function(){return this.document},hasParent:function(){return!!this.parent},getParent:function(){return this.document.get(this.parent)},getRoot:function(){for(var t=this;t.hasParent();)t=t.getParent();return t},getComponents:function(){var t=this.constructor["static"].components||[];return 0===t.length&&console.warn("Contract: a node must define its editable properties.",this.constructor["static"].name),t},isExternal:function(){return this.constructor["static"].external},toHtml:function(t,e){return this.constructor["static"].toHtml(this,t,e)},connect:function(t,e){i.each(e,function(t,e){var n=/([a-zA-Z_0-9]+):changed/.exec(e);if(n){var i=n[1];this.constructor["static"].schema[i]&&this.getDocument().getEventProxy("path").add([this.id,i],this,this._onPropertyChange.bind(this,i))}}),r.Node.prototype.connect.apply(this,arguments)},disconnect:function(){r.Node.prototype.disconnect.apply(this,arguments)},_onPropertyChange:function(t){var e=[t+":changed"].concat(Array.prototype.slice.call(arguments,1));this.emit.apply(this,e)}});o.initNodeClass=r.Node.initNodeClass,o["static"].toHtml=function(t,e){var n=$("<div itemscope>").attr("data-id",t.id).attr("data-type",t.type);return i.each(t.properties,function(i,r){var o=$("<div>").attr("itemprop",r);"string"===t.getPropertyType?o[0].appendChild(e.annotatedText([t.id,r])):o.text(i),n.append(o)}),n},o["static"].external=!1,t.exports=o},function(t,e){function n(t){return"number"==typeof t&&t>-1&&t%1==0&&i>=t}var i=Math.pow(2,53)-1;t.exports=n},function(t,e){function n(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}t.exports=n},function(t,e,n){function i(t){r.EventEmitter.call(this),this.context=t,this.state={disabled:!0,active:!1}}var r=n(3);i.Prototype=function(){this.needsEnabledSurface=!0,this.getName=function(){return this.constructor["static"].name},this.getSurface=function(){return this.surface},this.getDocument=function(){var t=this.getSurface();return t?t.getDocument():void 0},this.getContainer=function(){var t=this.getSurface();return t?t.getContainer():void 0},this.setToolState=function(t){var e=this.state;this.state=t,this.emit("toolstate:changed",t,this,e)},this.getToolState=function(){return this.state},this.isEnabled=function(){return!this.state.disabled},this.isDisabled=function(){return this.state.disabled},this.setEnabled=function(){this.setToolState({disabled:!1,active:!1})},this.setDisabled=function(){this.setToolState({disabled:!0,active:!1})},this.disableTool=function(){console.error("DEPRECATED: use tool.setDisabled()"),this.setDisabled()},this.setSelected=function(){this.setToolState({disabled:!1,active:!0})},this.update=function(t,e){return this.surface=t,this.needsEnabledSurface&&!t.isEnabled()?this.setDisabled():void 0},this.updateToolState=function(t,e){return this.update(e,t)}},r.inherit(i,r.EventEmitter),t.exports=i},function(t,e,n){"use strict";var i=n(1),r=function(t,e,n){if(n){var r=t.getIndex("annotations"),o=r.get(e.path);i.each(o,function(i){var r=e.offset,o=i.startOffset,s=i.endOffset,a=o,c=s;(o>r||r===o)&&(a+=n),(s>r||r===s&&!i.isExternal())&&(c+=n),a!==o&&t.set([i.id,"startOffset"],a),c!==s&&t.set([i.id,"endOffset"],c)}),r=t.getIndex("container-annotation-anchors");var s=r.get(e.path);i.each(s,function(i){var r=e.offset,o=i.offset,s=!1;if((o>r||r===o&&!e.after)&&(o+=n,s=!0),s){var a=i.isStart?"startOffset":"endOffset";t.set([i.id,a],o)}})}},o=function(t,e,n,r){if(n!==r){var o=t.getIndex("annotations"),s=o.get(e),a=r-n;i.each(s,function(e){var i=n,o=r,s=e.startOffset,c=e.endOffset,h=s,u=c;s>=o?(h-=a,u-=a,t.set([e.id,"startOffset"],h),t.set([e.id,"endOffset"],u)):(s>=i&&(h=s-Math.min(o-i,s-i)),c>=i&&(u=c-Math.min(o-i,c-i)),s!==c&&h===u?t["delete"](e.id):(s!==h&&t.set([e.id,"startOffset"],h),c!==u&&t.set([e.id,"endOffset"],u)))}),o=t.getIndex("container-annotation-anchors");var c=o.get(e),h=[];i.each(c,function(e){h.push(e.id);var i=n,o=r,s=e.offset,c=!1;if(s>=o)s-=a,c=!0;else if(s>=i){var u=s-Math.min(o-i,s-i);s!==u&&(s=u,c=!0)}if(c){var f=e.isStart?"startOffset":"endOffset";t.set([e.id,f],s)}}),i.each(i.uniq(h),function(e){var n=t.get(e),i=n.getSelection();i.isCollapsed()&&(console.log("...deleting container annotation because it has collapsed"+e),t["delete"](e))})}},s=function(t,e,n,r,o){var s=t.getIndex("annotations"),a=s.get(e,n);i.each(a,function(e){var s,a,c=n>e.startOffset&&n<e.endOffset,h=e.startOffset,u=e.endOffset;if(c){if(e.canSplit()){var f=i.clone(e.properties);f.id=i.uuid(e.type+"_"),f.startOffset=o,f.endOffset=o+e.endOffset-n,f.path=r,t.create(f)}s=e.startOffset,a=n,a===s?t["delete"](e.id):(s!==h&&t.set([e.id,"startOffset"],s),a!==u&&t.set([e.id,"endOffset"],a))}else e.startOffset>=n&&(s=o+e.startOffset-n,a=o+e.endOffset-n,t.set([e.id,"path"],r),t.set([e.id,"startOffset"],s),t.set([e.id,"endOffset"],a))}),s=t.getIndex("container-annotation-anchors");var c=s.get(e),h=[];i.each(c,function(e){h.push(e.id);var i=e.offset;if(i>=n){var s=e.isStart?"startPath":"endPath",a=e.isStart?"startOffset":"endOffset";t.set([e.id,s],r),t.set([e.id,a],o+e.offset-n)}}),i.each(i.uniq(h),function(e){var n=t.get(e),i=n.getSelection();i.isCollapsed()&&(console.log("...deleting container annotation because it has collapsed"+e),t["delete"](e))})};t.exports={insertedText:r,deletedText:o,transferAnnotations:s}},function(t,e,n){function i(t){return null==t?!1:u.call(t)==s?f.test(h.call(t)):o(t)&&a.test(t)||!1}var r=n(226),o=n(12),s="[object Function]",a=/^\[object .+?Constructor\]$/,c=Object.prototype,h=Function.prototype.toString,u=c.toString,f=RegExp("^"+r(u).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=i},function(t,e){function n(t){return t&&"object"==typeof t||!1}t.exports=n},function(t,e,n){"use strict";var i=n(65);i.Incremental=n(122),i.Node=n(36),i.Schema=n(125),i.Index=n(124),t.exports=i},function(t,e,n){function i(t,e,n){var i=typeof t;return"function"==i?"undefined"!=typeof e&&h(t)?a(t,e,n):t:null==t?c:"object"==i?r(t):"undefined"==typeof e?s(t+""):o(t+"",e)}var r=n(185),o=n(186),s=n(87),a=n(15),c=n(58),h=n(206);t.exports=i},function(t,e,n){function i(t,e,n){if("function"!=typeof t)return r;if("undefined"==typeof e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 3:return function(n,i,r){return t.call(e,n,i,r)};case 4:return function(n,i,r,o){return t.call(e,n,i,r,o)};case 5:return function(n,i,r,o,s){return t.call(e,n,i,r,o,s)}}return function(){return t.apply(e,arguments)}}var r=n(58);t.exports=i},function(t,e,n){var i=n(7),r=n(11),o=n(8),s=n(212),a=r(a=Object.keys)&&a,c=a?function(t){if(t)var e=t.constructor,n=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&n&&i(n)?s(t):o(t)?a(t):[]}:s;t.exports=c},function(t,e,n){"use strict";var i=n(3),r=n(6),o=r.extend({displayName:"Annotation",name:"annotation",properties:{path:["array","string"],startOffset:"number",endOffset:"number"},canSplit:function(){return!0},getSelection:function(){return this.getDocument().createSelection({type:"property",path:this.path,startOffset:this.startOffset,endOffset:this.endOffset})},updateRange:function(t,e){if(!e.isPropertySelection())throw new Error("Cannot change to ContainerAnnotation.");i.isEqual(this.startPath,e.start.path)||t.set([this.id,"path"],e.start.path),this.startOffset!==e.start.offset&&t.set([this.id,"startOffset"],e.start.offset),this.endOffset!==e.end.offset&&t.set([this.id,"endOffset"],e.end.offset)},getText:function(){var t=this.getDocument();if(!t)return console.warn("Trying to use an Annotation which is not attached to the document."),"";var e=t.get(this.path);return e.substring(this.startOffset,this.endOffset)},setActive:function(t){this.active!==t&&(this.active=t,this.emit("active",t))}});o["static"].isInline=!0,o["static"].toHtml=function(t,e,n){var i=t.id,r=t.constructor["static"].tagName||"span",o=$("<"+r+">").attr("id",i).append(n);return o},Object.defineProperties(o.prototype,{startPath:{get:function(){return this.path}},endPath:{get:function(){return this.path}}}),t.exports=o},function(t,e,n){"use strict";var i=n(129);i.Schema=n(131),i.Node=n(6),i.Annotation=n(17),i.Container=n(68),i.ContainerAnnotation=n(22),i.TextNode=n(23),i.Coordinate=n(39),i.Range=n(41),i.Selection=n(19),i.nullSelection=i.Selection.nullSelection,i.PropertySelection=n(40),i.ContainerSelection=n(69),i.TableSelection=n(74),i.Annotator=n(37),i.AnnotationUpdates=n(10),i.HtmlImporter=n(71),i.HtmlExporter=n(70),i.ClipboardImporter=n(38),i.ClipboardExporter=n(67),i.Include=n(137),i.Paragraph=n(139),i.Codeblock=n(134),i.Blockquote=n(133),i.Heading=n(136),i.Emphasis=n(135),i.Strong=n(140),i.Link=n(138),i.Table=n(141),i.TableSection=n(145),i.TableRow=n(144),i.TableCell=n(142),i.List=n(72),i.ListItem=n(73),i.Transformations=n(149),t.exports=i},function(t,e,n){"use strict";function i(){}var r=n(3);i.Prototype=function(){this.getRanges=function(){return[]},this.isNull=function(){return!1},this.isMultiSeletion=function(){return!1},this.isPropertySelection=function(){return!1},this.isContainerSelection=function(){return!1},this.isTableSelection=function(){return!1},this.isCollapsed=function(){return!0},this.isReverse=function(){return!1},this.equals=function(t){return this===t?!0:t?this.isNull()!==t.isNull()?!1:!0:!1},this.toString=function(){return"null"}},r.initClass(i);var o=function(){};o.Prototype=function(){this.isNull=function(){return!0}},r.inherit(o,i),i.nullSelection=Object.freeze(new o),t.exports=i},function(t,e,n){function i(t,e){var n=t?t.length:0;if(!o(n))return r(t,e);for(var i=-1,a=s(t);++i<n&&e(a[i],i,a)!==!1;);return t}var r=n(86),o=n(7),s=n(54);t.exports=i},function(t,e,n){"use strict";function i(t){t&&(this.root=t)}var r=n(1),o=n(2);i.Prototype=function(){this.childrenScope=!1,this.getRoot=function(){return this.root||this},this._resolve=function(t,e){for(var n=t.length-1,i=this.getRoot(),r=0;n>r;r++){var o=t[r];if(void 0===i[o]){if(!e)return void 0;i[o]={},this.childrenScope&&(i[o].children={})}i=i[o],this.childrenScope&&(i=i.children)}return i},this.get=function(t){if(r.isString(t))return this[t];if(t&&0!==t.length){var e=t[t.length-1],n=this._resolve(t);return n?n[e]:void 0}return this.getRoot()},this.set=function(t,e){if(r.isString(t))this[t]=e;else{var n=t[t.length-1];this._resolve(t,!0)[n]=e}},this["delete"]=function(t,e){if(r.isString(t))delete this[t];else{var n=t[t.length-1],i=this._resolve(t);if(e&&!i||!i[n])throw new Error("Invalid path.");delete i[n]}},this.clear=function(){var t=this.getRoot();for(var e in t)t.hasOwnProperty(e)&&delete t[e]},this._traverse=function(t,e,n,i){for(var r in t)if(t.hasOwnProperty(r)&&"__values__"!==r){var o=e.concat([r]);n.call(i,o,t[r]),this._traverse(t[r],o,n,i)}},this.traverse=function(t,e){this._traverse(this.getRoot(),[],t,e)}},o.initClass(i),i.Arrays=function(){i.apply(this,arguments)},i.Arrays.Prototype=function(){this.get=function(t){if(r.isString(t))return this[t];if(t&&0!==t.length){var e=t[t.length-1],n=this._resolve(t);return n&&n[e]?n[e].__values__:void 0}return this.getRoot()},this.add=function(t,e){var n=t[t.length-1],i=this._resolve(t,!0);i[n]||(i[n]={__values__:[]});var r=i[n].__values__;r.push(e)},this.remove=function(t,e){var n=this.get(t);n?r.deleteFromArray(n,e):console.warn("Warning: trying to remove a value for an unknown path.",t,e)},this.removeAll=function(t){var e=this.get(t);e.splice(0,e.length)},this.set=function(){throw new Error("This method is not available for PathAdapter.Arrays")},this._traverse=function(t,e,n,i){for(var r in t)if(t.hasOwnProperty(r))if("__values__"===r)n.call(i,e,t.__values__);else{var o=e.concat([r]);this._traverse(t[r],o,n,i)}}},o.inherit(i.Arrays,i),t.exports=i},function(t,e,n){"use strict";var i=n(1),r=n(2),o=n(27),s=n(6),a=n(19),c=n(21),h=s.extend({displayName:"ContainerAnnotation",name:"container_annotation",properties:{container:"string",startPath:["array","string"],startOffset:"number",endPath:["array","string"],endOffset:"number"},getStartAnchor:function(){return this._startAnchor||(this._startAnchor=new h.Anchor(this,"isStart")),this._startAnchor},getEndAnchor:function(){return this._endAnchor||(this._endAnchor=new h.Anchor(this)),this._endAnchor},getSelection:function(){var t=this.getDocument();return t?t.createSelection({type:"container",containerId:this.container,startPath:this.startPath,startOffset:this.startOffset,endPath:this.endPath,endOffset:this.endOffset}):(console.warn("Trying to use a ContainerAnnotation which is not attached to the document."),a.nullSelection())},getText:function(){var t=this.getDocument();return t?t.getTextForSelection(this.getSelection()):(console.warn("Trying to use a ContainerAnnotation which is not attached to the document."),"")},updateRange:function(t,e){if(!e.isContainerSelection())throw new Error("Cannot change to ContainerAnnotation.");i.isEqual(this.startPath,e.start.path)||t.set([this.id,"startPath"],e.start.path),this.startOffset!==e.start.offset&&t.set([this.id,"startOffset"],e.start.offset),i.isEqual(this.endPath,e.end.path)||t.set([this.id,"endPath"],e.end.path),this.endOffset!==e.end.offset&&t.set([this.id,"endOffset"],e.end.offset)},setActive:function(t){this.active!==t&&(this.active=t,this.emit("active",t),i.each(this.fragments,function(e){e.emit("active",t)}))},getFragments:function(){this._fragments||(this._fragments=new c);var t,e=[],n=this.getDocument(),r=this.getStartAnchor(),o=this.getEndAnchor(),s=n.get(this.container);if(i.isEqual(r.path,o.path))t=this._fragments.get(r.path),t?"property"===!t.mode&&(t.mode="property"):(t=new h.Fragment(this,r.path,"property"),this._fragments.set(t.path,t)),e.push(t);else{var a=n.get(r.path),u=s.getComponent(r.path),f=s.getComponent(o.path);if(!u||!f)throw new Error("Could not find components of AbstractContainerAnnotation");t=this._fragments.get(r.path),t?"start"!==t.mode&&(t.mode="start"):(t=new h.Fragment(this,r.path,"start"),this._fragments.set(t.path,t)),e.push(t);for(var l=u.idx+1;l<f.idx;l++){var d=s.getComponentAt(l);a=n.get(d.path),t=this._fragments.get(d.path),t?"inner"!==t.mode&&(t.mode="inner"):(t=new h.Fragment(this,d.path,"inner"),this._fragments.set(t.path,t)),e.push(t)}t=this._fragments.get(o.path),t?"end"!==t.mode&&(t.mode="end"):(t=new h.Fragment(this,o.path,"end"),this._fragments.set(t.path,t)),e.push(t)}return this.fragments=e,e}});h.Anchor=function(t,e){o.call(this),this.type="container-annotation-anchor",this.anno=t,this.node=t,this.id=t.id,this.container=t.container,this.isStart=!!e,Object.freeze(this)},h.Anchor.Prototype=function(){i.extend(this,o.prototype),this.zeroWidth=!0,this.getTypeNames=function(){return[this.type]}},r.initClass(h.Anchor),h.Fragment=function(t,e,n){o.call(this),this.type="container_annotation_fragment",this.anno=t,this.id=t.id,this.path=e,this.mode=n},h.Fragment.Prototype=function(){i.extend(this,o.prototype),this.getTypeNames=function(){return[this.type]}},r.initClass(h.Fragment),Object.defineProperties(h.Fragment.prototype,{startOffset:{get:function(){return"start"===this.mode||"property"===this.mode?this.anno.startOffset:0},set:function(){throw new Error("Immutable!")}},endOffset:{get:function(){var t=this.anno.getDocument(),e=t.get(this.path),n=e.length;return"end"===this.mode||"property"===this.mode?this.anno.endOffset:n},set:function(){throw new Error("Immutable!")}},active:{get:function(){return this.anno.active},set:function(){throw new Error("Immutable!")}}}),h.Fragment["static"].level=Number.MAX_VALUE,Object.defineProperties(h.Anchor.prototype,{path:{get:function(){return this.isStart?this.node.startPath:this.node.endPath},set:function(){throw new Error("Immutable!")}},offset:{get:function(){return this.isStart?this.node.startOffset:this.node.endOffset},set:function(){throw new Error("Immutable!")}}}),t.exports=h},function(t,e,n){"use strict";var i=n(6),r=i.extend({displayName:"TextNode",name:"text",properties:{content:"string"},getTextPath:function(){return[this.id,"content"]},getText:function(){return this.content}});r["static"].components=["content"],t.exports=r},function(t,e,n){"use strict";function i(t,e){var n=e.selection;return e=n.isCollapsed()?h(t,e):n.isPropertySelection()?r(t,e):o(t,e)}function r(t,e){var n=e.selection.getRange(),i=n.start.path,r=n.start.offset,o=n.end.offset;return t.update(i,{"delete":{start:r,end:o}}),l.deletedText(t,i,r,o),e.selection=t.createSelection({type:"property",path:i,startOffset:r}),e}function o(t,e){var n,i,r,o=e.selection,h=o.containerId,l=o.getRange(),d=a(t,o);e.selection=null;for(var p=t.get(h),g=p.getPosition(d[0].node.id),m=d.length-1;m>=0;m--)n=d[m],i=n.node,n.isFully?u(t,c.extend({},e,{nodeId:i.id})):s(t,c.extend({},e,{nodeSel:n}));if(d[0].isFully){e.selection=null;for(var v=1;v<d.length;v++)if(n=d[v],!n.isFully){e.selection=t.createSelection({type:"property",path:n.components[0].path,startOffset:0});break}null===e.selection&&(r=t.getSchema().getDefaultTextType(),i={type:r,id:c.uuid(r),content:""
},t.create(i),p.show(i.id,g),e.selection=t.createSelection({type:"property",path:[i.id,"content"],startOffset:0}))}else e.selection=t.createSelection({type:"property",path:l.start.path,startOffset:l.start.offset});if(d.length>1){var y=d[0],x=d[d.length-1];if(y.isFully||x.isFully);else{var w=c.last(x.components),b=f(t,c.extend({},e,{selection:e.selection,containerId:h,path:w.path,direction:"left"}));e.selection=b.selection}}return p=t.get(h),0===p.nodes.length&&(r=t.getSchema().getDefaultTextType(),i={type:r,id:c.uuid(r),content:""},t.create(i),p.show(i.id,0),e.selection=t.createSelection({type:"property",path:[i.id,"content"],startOffset:0})),e}function s(t,e){for(var n=e.nodeSel,i=n.components,o=i.length,s=0;o>s;s++){var a=i[s],h=0,u=t.get(a.path).length;0===s&&(h=n.startOffset),s===o-1&&(u=n.endOffset),r(t,c.extend({},e,{selection:t.createSelection({type:"property",path:a.path,startOffset:h,endOffset:u})}))}}function a(t,e){for(var n=[],i={},r=e.getRange(),o=t.get(e.containerId),s=o.getComponentsForRange(r),a=0;a<s.length;a++){var c=s[a],h=t.get(c.rootId);if(!h)throw new Error("Illegal state: expecting a component to have a proper root node id set.");var u,f=h.id;i[f]||(u={node:h,isFully:!0,components:[]},i[f]=u,n.push(u)),u=i[f],u.components.push(c)}var l=s[0],d=s[s.length-1],p=n[0],g=n[n.length-1],m=t.get(l.path).length,v=t.get(d.path).length;return(r.start.offset>0||l.hasPrevious()&&l.getPrevious().rootId===l.rootId)&&(p.isFully=!1,p.startOffset=r.start.offset,1===n.length?p.endOffset=r.end.offset:p.endOffset=m),n.length>1&&(r.end.offset<v||d.hasNext()&&d.getNext().rootId===d.rootId)&&(g.isFully=!1,g.startOffset=0,g.endOffset=r.end.offset),n}var c=n(1),h=n(75),u=n(44),f=n(45),l=n(10);t.exports=i},function(t,e,n){function i(t){var e=o(t)?t.length:void 0;return r(e)&&c.call(t)==s||!1}var r=n(7),o=n(12),s="[object Arguments]",a=Object.prototype,c=a.toString;t.exports=i},function(t,e,n){"use strict";function i(){o.apply(this,arguments)}var r=n(2),o=n(4),s=o.$$,a=n(37),c=n(102);i.Prototype=function(){this.render=function(){var t=this.context.componentRegistry,e=this.getDocument(),n=this.getPath(),i=e.get(n)||"",r=this.getAnnotations(),o=s(this.props.tagName||"span").addClass("text-property").attr({"data-path":this.props.path.join("."),spellCheck:!1}).css({whiteSpace:"pre-wrap"}),h=new a,u={};return h.onText=function(t,e){e&&e.length>0&&t.append(e)},h.onEnter=function(n){var i=n.node,r=i.id;u[r]||(u[r]=0),u[r]=u[r]+1;var o;o=t.contains(i.type)?t.get(i.type):c;var a=s(o,{doc:e,node:i});return"container_annotation_fragment"===i.type?(a.addClass(i.anno.getTypeNames().join(" ").replace(/_/g,"-")),a.addClass("annotation-fragment")):"container-annotation-anchor"===i.type&&(a.addClass(i.anno.getTypeNames().join(" ").replace(/_/g,"-")),a.addClass("anchor"),a.addClass(i.isStart?"start-anchor":"end-anchor")),a},h.onExit=function(t,e,n){n.append(e)},h.start(o,i,r),o.append(s("br")),o},this.didMount=function(){var t=this.props.doc;t.getEventProxy("path").add(this.props.path,this,this.textPropertyDidChange)},this.willUnmount=function(){var t=this.props.doc;t.getEventProxy("path").remove(this.props.path,this)},this.getAnnotations=function(){return this.context.surface.getAnnotationsForProperty(this.props.path)},this.getHighlights=function(){return this.context.getHighlightedNodes?this.context.getHighlightedNodes():[]},this.textPropertyDidChange=function(){this.rerender()},this.getContainer=function(){return this.getSurface().getContainer()},this.getDocument=function(){return this.props.doc},this.getPath=function(){return this.props.path},this.getElement=function(){return this.$el[0]},this.getSurface=function(){return this.context.surface}},r.inherit(i,o),t.exports=i},function(t,e,n){"use strict";function i(){this.__events__={}}var r=n(2);i.Prototype=function(){function t(t,e){if("string"==typeof t){if(void 0===e||null===e)throw new Error('Method name "'+t+'" has no context.');if(!(t in e))throw new Error('Method not found: "'+t+'"');if("function"!=typeof e[t])throw new Error('Property "'+t+'" is not a function')}else if("function"!=typeof t)throw new Error("Invalid callback. Function or method name expected.")}function e(t,e){return e.priority-t.priority}this._on=function(e,n,i,r){var o;return t(n,i),o=this.__events__.hasOwnProperty(e)?this.__events__[e]:this.__events__[e]=[],o.push({method:n,context:i||null,priority:r}),this},this._off=function(e,n,i){var r,o;if(1===arguments.length)return delete this.__events__[e],this;if(t(n,i),!(e in this.__events__&&this.__events__[e].length))return this;for(arguments.length<3&&(i=null),o=this.__events__[e],r=o.length;r--;)o[r].method===n&&o[r].context===i&&o.splice(r,1);return 0===o.length&&delete this.__events__[e],this},this._connect=function(t,n,i){var r=0;3===arguments.length&&(r=i.priority||r);for(var o in n){var s=n[o];this._on(o,s,t,r)}return this.__events__[o].sort(e),this},this._disconnect=function(t){var e,n,i;for(n in this.__events__)for(i=this.__events__[n],e=i.length;e--;)i[e]&&i[e].context===t&&this._off(n,i[e].method,t);return this},this.emit=function(t){if(t in this.__events__){for(var e=this.__events__[t].slice(),n=Array.prototype.slice.call(arguments,1),i=0,r=e.length;r>i;i++){var o=e[i];o.method.apply(o.context,n)}return!0}return!1},this.connect=function(t,e,n){return this._connect.apply(this,arguments)},this.disconnect=function(t){return this._disconnect(t)},this.on=function(t,n,i,r){var o=0;4===arguments.length&&(o=r.priority||o),this._on(t,n,i,o),this.__events__[t].sort(e)},this.off=function(t,e,n){return this._off.apply(this,arguments)}},r.initClass(i),t.exports=i},function(t,e){function n(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}t.exports=n},function(t,e,n){function i(t,e,n){if(e!==e)return r(t,n);for(var i=(n||0)-1,o=t.length;++i<o;)if(t[i]===e)return i;return-1}var r=n(202);t.exports=i},function(t,e){function n(t,e){return t=+t,e=null==e?i:e,t>-1&&t%1==0&&e>t}var i=Math.pow(2,53)-1;t.exports=n},function(t,e,n){function i(t,e,n){if(!s(n))return!1;var i=typeof e;if("number"==i)var a=n.length,c=o(a)&&r(e,a);else c="string"==i&&e in n;if(c){var h=n[e];return t===t?t===h:h!==h}return!1}var r=n(30),o=n(7),s=n(8);t.exports=i},function(t,e,n){"use strict";function i(){}var r=n(3);i.Prototype=function(){this.isOperation=!0},r.initClass(i),t.exports=i},function(t,e,n){function i(t){s.call(this,t)}var r=n(1),o=n(2),s=n(9);i.Prototype=function(){this.disabledModes=[],this.splitContainerSelections=!1,this.getAnnotationType=function(){if(this.constructor["static"].name)return this.constructor["static"].name;throw new Error("Contract: AnnotationTool.static.name should be associated to a document annotation type.")},this.afterCreate=function(){},this.afterFusion=function(){},this.afterRemove=function(){},this.afterTruncate=function(){},this.afterExpand=function(){},this.canCreate=function(t,e){return 0===t.length&&!e.isCollapsed()},this.canFusion=function(t,e){return t.length>=2&&!e.isCollapsed()},this.canRemove=function(t,e){if(1!==t.length)return!1;var n=t[0].getSelection();return e.isInsideOf(n)},this.canExpand=function(t,e){if(1!==t.length)return!1;var n=t[0].getSelection();return e.overlaps(n)&&!e.isInsideOf(n)},this.canTruncate=function(t,e){if(1!==t.length)return!1;var n=t[0].getSelection();return(e.isLeftAlignedWith(n)||e.isRightAlignedWith(n))&&!e.equals(n)&&!e.isCollapsed()},this.update=function(t,e){if(this.surface=t,this.needsEnabledSurface&&!t.isEnabled()||e.isNull())return this.setDisabled();var n,i=this.getDocument(),o=this.getAnnotationType(),s=this.isContainerAnno();if(s)n=i.getContainerAnnotationsForSelection(e,this.getContainer(),{type:o});else{if(!e.isPropertySelection()&&!this.splitContainerSelections)return this.setDisabled();n=i.getAnnotationsForSelection(e,{type:o})}var a={surface:t,disabled:!1,active:!1,mode:null,sel:e,annos:n};return this.canCreate(n,e)?a.mode="create":this.canFusion(n,e)?a.mode="fusion":this.canTruncate(n,e)?(a.active=!0,a.mode="truncate"):this.canRemove(n,e)?(a.active=!0,a.mode="remove"):this.canExpand(n,e)&&(a.mode="expand"),!a.mode||r.includes(this.disabledModes,a.mode)?this.setDisabled():void this.setToolState(a)},this.performAction=function(){var t=this.getToolState();if(t.sel&&t.mode&&!t.sel.isNull())switch(t.mode){case"create":return this.handleCreate(t);case"fusion":return this.handleFusion(t);case"remove":return this.handleRemove(t);case"truncate":return this.handleTruncate(t);case"expand":return this.handleExpand(t)}},this.handleCreate=function(t){var e,n=t.sel;n.isNull()||(this.surface.transaction({selection:n},function(t,i){return e=this.createAnnotationForSelection(t,n),i},this),this.afterCreate(e))},this.getAnnotationData=function(){return{}},this.isContainerAnno=function(){var t=this.getDocument(),e=t.getSchema();return e.isInstanceOf(this.getAnnotationType(),"container_annotation")},this._createPropertyAnnotations=function(t,e){var n,i=this.getAnnotationType();e.isPropertySelection()?n=[]:e.isContainerSelection()&&(n=e.splitIntoPropertySelections());for(var o=0;o<n.length;o++){var s={id:r.uuid(i),type:i};r.extend(s,this.getAnnotationData()),s.path=n[o].getPath(),s.startOffset=n[o].getStartOffset(),s.endOffset=n[o].getEndOffset(),t.create(s)}},this.createAnnotationForSelection=function(t,e){if(this.splitContainerSelections&&e.isContainerSelection())return this._createPropertyAnnotations(t,e);var n=this.getAnnotationType(),i={id:r.uuid(n),type:n};if(r.extend(i,this.getAnnotationData()),this.isContainerAnno()){i.startPath=e.start.path,i.endPath=e.end.path;var o=this.surface.getEditor().getContainerId();if(!o)throw"Container could not be determined";i.container=o}else{if(!e.isPropertySelection())throw new Error("Illegal state: can not apply ContainerSelection");i.path=e.getPath()}return i.startOffset=e.getStartOffset(),i.endOffset=e.getEndOffset(),t.create(i)},this.handleFusion=function(t){var e=t.sel;this.surface.transaction({selection:e},function(n,i){return r.each(t.annos,function(t){e=e.expand(t.getSelection())}),r.each(t.annos,function(t){n["delete"](t.id)}),this.createAnnotationForSelection(n,e),this.afterFusion(),i.selection=e,i},this)},this.handleRemove=function(t){var e=t.sel;this.surface.transaction({selection:e},function(e,n){var i=t.annos[0].id;return e["delete"](i),this.afterRemove(),n},this)},this.handleTruncate=function(t){var e=t.sel;this.surface.transaction({selection:e},function(n,i){var r=t.annos[0],o=r.getSelection(),s=o.truncate(e);return r.updateRange(n,s),this.afterTruncate(),i},this)},this.handleExpand=function(t){var e=t.sel;this.surface.transaction({selection:e},function(n,i){var r=t.annos[0],o=r.getSelection(),s=o.expand(e);return r.updateRange(n,s),this.afterExpand(),i},this)}},o.inherit(i,s),t.exports=i},function(t,e,n){"use strict";function i(){this.entries={},this.names=[]}var r=n(2);i.Prototype=function(){this.contains=function(t){return!!this.entries[t]},this.add=function(t,e){this.contains(t)&&this.remove(t),this.entries[t]=e,this.names.push(t)},this.remove=function(t){var e=this.names.indexOf(t);e>=0&&this.names.splice(e,1),delete this.entries[t]},this.clear=function(){this.names=[],this.entries=[]},this.get=function(t){var e=this.entries[t];return e||console.error("No entry with name",t),e},this.each=function(t,e){for(var n=0;n<this.names.length;n++){var i=this.names[n],r=t.call(e,this.entries[i],i);if(r===!1)break}}},r.initClass(i),t.exports=i},function(t,e){/*!
Math.uuid.js (v1.4)
http://www.broofa.com
mailto:robert@broofa.com
Copyright (c) 2010 Robert Kieffer
Dual licensed under the MIT and GPL licenses.
*/
t.exports=function n(t,e){t&&"_"!==t[t.length-1]&&(t=t.concat("_"));var i,r="0123456789abcdefghijklmnopqrstuvwxyz".split(""),n=[],o=16;if(e=e||32)for(i=0;e>i;i++)n[i]=r[0|Math.random()*o];else{var s;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",i=0;36>i;i++)n[i]||(s=0|16*Math.random(),n[i]=r[19==i?3&s|8:s])}return(t?t:"")+n.join("")}},function(t,e,n){"use strict";function i(t){a.call(this),this.properties=o.extend({},this.getDefaultProperties(),t),this.properties.type=this.constructor["static"].name,this.properties.id=this.properties.id||s(this.properties.type)}var r=n(2),o=n(1),s=n(35),a=n(27);i.Prototype=function(){this.toJSON=function(){return this.properties},this.getDefaultProperties=function(){},this.isInstanceOf=function(t){return i.isInstanceOf(this.constructor,t)},this.getTypeNames=function(){for(var t=[],e=this.constructor["static"];e&&"node"!==e.name;)t.push(e.name),e=Object.getPrototypeOf(e);return t},this.getPropertyType=function(t){var e=this.constructor["static"].schema;return e[t]}},r.inherit(i,a),i["static"].name="node",i["static"].schema={type:"string",id:"string"},i["static"].readOnlyProperties=["type","id"],i.isInstanceOf=function(t,e){for(var n=t["static"];n&&"node"!==n.name;){if(n&&n.name===e)return!0;n=Object.getPrototypeOf(n)}return!1},i["static"].isInstanceOf=i.isInstanceOf;var c,h=function(t,e,n){var i,r;i=function(){return this.properties[e]},r=n?function(){throw new Error("Property "+e+" is readonly!")}:function(t){return this.properties[e]=t,this};var o={get:i,set:r};Object.defineProperty(t,e,o)},u=function(t){var e=t.prototype;if(t["static"].schema)for(var n=Object.keys(t["static"].schema),i=0;i<n.length;i++){var r=n[i];if(!e.hasOwnProperty(r)){var o=t["static"].readOnlyProperties&&t["static"].readOnlyProperties.indexOf(r)>0;h(e,r,o)}}},f=function(t){var e=t["static"].schema,n=Object.getPrototypeOf(t["static"]),i=n.schema;i&&(t["static"].schema=o.extend(Object.create(i),e))},l=function(t){t.extend=o.bind(c,null,t),u(t),f(t),t.type=t["static"].name};c=function(t,e){var n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};r.inherit(n,t);for(var i in e)if(e.hasOwnProperty(i)){if("name"===i||"properties"===i)continue;n.prototype[i]=e[i]}return n["static"].name=e.name,n["static"].schema=e.properties,l(n),n},l(i),i.initNodeClass=l,t.exports=i},function(t,e,n){"use strict";var i=n(3),r=1,o=-1,s=-2,a=function(t){i.extend(this,t)};a.Prototype=function(){var t=function(t,e){if(t.pos<e.pos)return-1;if(t.pos>e.pos)return 1;if(t.id===e.id)return e.mode-t.mode;if(t.mode<e.mode)return-1;if(t.mode>e.mode)return 1;if(t.mode===r){if(t.level<e.level)return-1;if(t.level>e.level)return 1}if(t.mode===o){if(t.level>e.level)return-1;if(t.level<e.level)return 1}return 0},e=function(t){var e=[];return i.each(t,function(t){if(t.zeroWidth)e.push({pos:t.offset,mode:s,id:t.id,level:Number.MAX_VALUE,type:"anchor",node:t});else{var n=t.constructor["static"].level||1e3;e.push({pos:t.startOffset,mode:r,level:n,id:t.id,type:t.type,node:t}),e.push({pos:t.endOffset,mode:o,level:n,id:t.id,type:t.type,node:t})}}),e};this.onText=function(){},this.onEnter=function(){return null},this.onExit=function(){},this.enter=function(t,e){return this.onEnter(t,e)},this.exit=function(t,e,n){this.onExit(t,e,n)},this.createText=function(t,e){e.length>0&&this.onText(t,e)},this.start=function(n,i,a){var c=this,h=e.call(this,a);h.sort(t.bind(this));for(var u=[{context:n,entry:null}],f=0,l=0;l<h.length;l++){var d=h[l];this.createText(u[u.length-1].context,i.substring(f,d.pos)),f=d.pos;var p,g;if(d.mode===r||d.mode===s){for(p=1;p<u.length&&!(d.level<u[p].entry.level);p++);for(g=u.length-1;g>=p;g--)this.exit(u[g].entry,u[g].context,u[g-1].context);for(u.splice(p,0,{entry:d}),g=p;g<u.length;g++)u[g].context=c.enter(u[g].entry,u[g-1].context)}if(d.mode===o||d.mode===s){for(p=1;p<u.length&&u[p].entry.node!==d.node;p++);for(g=u.length-1;g>=p;g--)this.exit(u[g].entry,u[g].context,u[g-1].context);for(u.splice(p,1),g=p;g<u.length;g++)u[g].context=c.enter(u[g].entry,u[g-1].context)}}this.createText(n,i.substring(f))}},i.initClass(a),t.exports=a},function(t,e,n){function i(t){if(!t.schema)throw new Error("Missing argument: config.schema is required.");r.extend(t,{trimWhitespaces:!0,REMOVE_INNER_WS:!0}),i["super"].call(this,t)}var r=n(1),o=n(2),s=n(71),a=n(43).CLIPBOARD_CONTAINER_ID;i.Prototype=function(){this.convert=function(t,e){this.initialize(e,t);var n=t.find("body");n=this.sanitizeBody(n),this.convertContainer(n,a),this.finish()},this.sanitizeBody=function(t){var e=t.find("b > p");return e.length&&(t=$(e[0].parentNode)),t},this.checkQuality=function(t){var e=t.find("body");return e.children("b").children("p").length?!0:e.children("p").length?!0:e.find("* p").length?!1:e.children("a,b,i,strong,italic").length?!0:!1}},o.inherit(i,s),t.exports=i},function(t,e,n){"use strict";function i(t,e,n){if(this.path=t,this.offset=e,this.after=n,!o.isArray(t))throw new Error("Invalid arguments: path should be an array.");if(!o.isNumber(e)||0>e)throw new Error("Invalid arguments: offset must be a positive number.");Object.isFrozen(t)||Object.freeze(t),Object.freeze(this)}var r=n(2),o=n(1);i.Prototype=function(){this.equals=function(t){return t===this||o.isArrayEqual(t.path,this.path)&&t.offset===this.offset},this.withCharPos=function(t){return new i(this.path,t)},this.getNodeId=function(){return this.path[0]},this.getPath=function(){return this.path},this.getOffset=function(){return this.offset}},r.initClass(i),t.exports=i},function(t,e,n){"use strict";function i(t){var e=t.path,n=t.startOffset,i=t.endOffset||t.startOffset;if(!e||!r.isNumber(n))throw new Error("Invalid arguments: `path` and `startOffset` are mandatory");this.range=new c(new a(e,n),new a(e,i)),this.reverse=t.reverse,this._internal={},Object.freeze(this)}var r=n(1),o=n(2),s=n(19),a=n(39),c=n(41);i.Prototype=function(){r.extend(this,s.prototype),this.toJSON=function(){return{type:"property",path:this.path,startOffset:this.startOffset,endOffset:this.endOffset,reverse:this.reverse}},this.attach=function(t){return this._internal.doc=t,this},this.isNull=function(){return!1},this.getRanges=function(){return[this.range]},this.getRange=function(){return this.range},this.isCollapsed=function(){return this.range.isCollapsed()},this.isReverse=function(){return this.reverse},this.isPropertySelection=function(){return!0},this.isMultiSeletion=function(){