diff --git a/widgets-built-min.js b/widgets-built-min.js index 1061664..9dd8ec5 100644 --- a/widgets-built-min.js +++ b/widgets-built-min.js @@ -6,7 +6,8 @@ var dom=this.renderContent(node,this.elt(tagName,tagAttrs));return this.options. for(var i=0;isame&&childA.text[childA.text.length-same-1]==childB.text[childB.text.length-same-1];)same++,offA--,offB--;break}if(offA-=childA.width,offB-=childB.width,childA.size||childB.size){pathA.push(offA),pathB.push(offB);var inner=findDiffEnd(childA.content,childB.content,pathA,pathB);if(inner)return inner;pathA.pop(),pathB.pop()}}else offA-=childA.width,offB-=childB.width}return{a:new _pos.Pos(pathA,offA),b:new _pos.Pos(pathB,offB)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findDiffStart=findDiffStart,exports.findDiffEnd=findDiffEnd;var _pos=require("./pos")},{"./pos":37}],32:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ModelError=void 0;var _error=require("../util/error");exports.ModelError=function(_ProseMirrorError){function ModelError(){return _classCallCheck(this,ModelError),_possibleConstructorReturn(this,Object.getPrototypeOf(ModelError).apply(this,arguments))}return _inherits(ModelError,_ProseMirrorError),ModelError}(_error.ProseMirrorError)},{"../util/error":52}],33:[function(require,module,exports){"use strict";function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;ipath.length,moreTo=to&&to.depth>path.length,start=moreFrom?from.path[path.length]:from?from.offset:0,end=moreTo?to.path[path.length]+1:to?to.offset:this.size,iter=this.iter(start,end);node=iter.next().value;){var startOffset=iter.offset-node.width;path.push(startOffset),node.nodesBetween(moreFrom&&startOffset==start?from:null,moreTo&&iter.offset==end?to:null,f,path,parent),path.pop()}}},{key:"sliceBetween",value:function(from,to){for(var node,depth=arguments.length<=2||void 0===arguments[2]?0:arguments[2],moreFrom=from&&from.depth>depth,moreTo=to&&to.depth>depth,start=moreFrom?from.path[depth]:from?from.offset:0,end=moreTo?to.path[depth]+1:to?to.offset:this.size,nodes=[],iter=this.iter(start,end);node=iter.next().value;){var passFrom=moreFrom&&iter.offset-node.width==start?from:null,passTo=moreTo&&iter.offset==end?to:null;(passFrom||passTo)&&(node=node.sliceBetween(passFrom,passTo,depth+1)),nodes.push(node)}return new this.constructor(nodes)}},{key:"textContent",get:function(){var text="";return this.forEach(function(n){return text+=n.textContent}),text}}],[{key:"fromJSON",value:function(schema,value){return value?this.fromArray(value.map(schema.nodeFromJSON)):emptyFragment}},{key:"fromArray",value:function(array){if(!array.length)return emptyFragment;for(var hasText=!1,joined=void 0,i=0;ioff||off>=this.content.length)&&_error.ModelError.raise("Offset "+off+" out of range"),this.content[off]}},{key:"forEach",value:function(f){for(var i=0;i0&&joinRight>0&&before.sameMarkup(after)?content.push(before.append(after.content,joinLeft-1,joinRight-1)):content.push(before.close(joinLeft-1,"end"),after.close(joinRight-1,"start")),Fragment.fromArray(content.concat(other.toArray(after.width)))}},{key:"toJSON",value:function(){return this.content.map(function(n){return n.toJSON()})}},{key:"size",get:function(){return this.content.length}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}}]),FlatFragment}(Fragment),emptyFragment=exports.emptyFragment=new FlatFragment([]),TextIterator=function(){function TextIterator(fragment,startOffset,endOffset){var pos=arguments.length<=3||void 0===arguments[3]?-1:arguments[3];_classCallCheck(this,TextIterator),this.frag=fragment,this.offset=startOffset,this.pos=pos,this.endOffset=endOffset}return _createClass(TextIterator,[{key:"copy",value:function(){return new this.constructor(this.frag,this.offset,this.endOffset,this.pos)}},{key:"atEnd",value:function(){return this.offset==this.endOffset}},{key:"next",value:function(){if(-1==this.pos){var start=this.init();if(start)return start}return this.offset==this.endOffset?iterEnd:this.advance()}},{key:"advance",value:function(){var node=this.frag.content[this.pos++],end=this.offset+node.width;return end>this.endOffset?(node=node.copy(node.text.slice(0,this.endOffset-this.offset)),this.offset=this.endOffset,node):(this.offset=end,node)}},{key:"init",value:function(){this.pos=0;for(var offset=0;offsetthis.offset){var sliceEnd=node.width;return end>this.endOffset&&(sliceEnd=this.endOffset-offset,end=this.endOffset),node=node.copy(node.text.slice(this.offset-offset,sliceEnd)),this.offset=end,node}offset=end}}}]),TextIterator}(),ReverseTextIterator=function(_TextIterator){function ReverseTextIterator(){return _classCallCheck(this,ReverseTextIterator),_possibleConstructorReturn(this,Object.getPrototypeOf(ReverseTextIterator).apply(this,arguments))}return _inherits(ReverseTextIterator,_TextIterator),_createClass(ReverseTextIterator,[{key:"advance",value:function(){var node=this.frag.content[--this.pos],end=this.offset-node.width;return endthis.offset;){var node=this.frag.content[--this.pos],end=offset-node.width;if(end==this.offset)break;if(endoff||off>=this.size)&&_error.ModelError.raise("Offset "+off+" out of range");for(var i=0,curOff=0;ioff)return child}}},{key:"forEach",value:function(f){for(var i=0,off=0;i=off)return{node:child,start:curOff};curOff=end}}},{key:"chunkAfter",value:function(off){off==this.size&&_error.ModelError.raise("No chunk after end of node");for(var i=0,curOff=0;ioff)return{node:child,start:curOff};curOff=end}}},{key:"slice",value:function(){var from=arguments.length<=0||void 0===arguments[0]?0:arguments[0],to=arguments.length<=1||void 0===arguments[1]?this.size:arguments[1];return from==to?emptyFragment:new TextFragment(this.toArray(from,to))}},{key:"replace",value:function(off,node){node.isText&&_error.ModelError.raise("Argument to replace should be a non-text node");for(var curNode=void 0,index=void 0,curOff=0;off>curOff;index++)curNode=this.content[index],curOff+=curNode.width;curNode.isText&&_error.ModelError.raise("Can not replace text content with replace method");var copy=this.content.slice();return copy[index]=node,new TextFragment(copy)}},{key:"appendInner",value:function(other,joinLeft,joinRight){var last=this.content.length-1,content=this.content.slice(0,last),before=this.content[last],after=other.firstChild,same=before.sameMarkup(after);return same&&before.isText?content.push(before.copy(before.text+after.text)):same&&joinLeft>0&&joinRight>0?content.push(before.append(after.content,joinLeft-1,joinRight-1)):content.push(before.close(joinLeft-1,"end"),after.close(joinRight-1,"start")),Fragment.fromArray(content.concat(other.toArray(after.width)))}},{key:"toJSON",value:function(){return this.content.map(function(n){return n.toJSON()})}},{key:"firstChild",get:function(){return this.size?this.content[0]:null}},{key:"lastChild",get:function(){return this.size?this.content[this.content.length-1]:null}}]),TextFragment}(Fragment);"undefined"!=typeof Symbol&&(Fragment.prototype[Symbol.iterator]=function(){return this.iter()},FlatIterator.prototype[Symbol.iterator]=TextIterator.prototype[Symbol.iterator]=function(){return this})},{"./error":32}],34:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _node=require("./node");Object.defineProperty(exports,"Node",{enumerable:!0,get:function(){return _node.Node}});var _fragment=require("./fragment");Object.defineProperty(exports,"Fragment",{enumerable:!0,get:function(){return _fragment.Fragment}}),Object.defineProperty(exports,"emptyFragment",{enumerable:!0,get:function(){return _fragment.emptyFragment}});var _mark=require("./mark");Object.defineProperty(exports,"Mark",{enumerable:!0,get:function(){return _mark.Mark}});var _schema=require("./schema");Object.defineProperty(exports,"SchemaSpec",{enumerable:!0,get:function(){return _schema.SchemaSpec}}),Object.defineProperty(exports,"Schema",{enumerable:!0,get:function(){return _schema.Schema}}),Object.defineProperty(exports,"SchemaError",{enumerable:!0,get:function(){return _schema.SchemaError}}),Object.defineProperty(exports,"NodeType",{enumerable:!0,get:function(){return _schema.NodeType}}),Object.defineProperty(exports,"Block",{enumerable:!0,get:function(){return _schema.Block}}),Object.defineProperty(exports,"Textblock",{enumerable:!0,get:function(){return _schema.Textblock}}),Object.defineProperty(exports,"Inline",{enumerable:!0,get:function(){return _schema.Inline}}),Object.defineProperty(exports,"Text",{enumerable:!0,get:function(){return _schema.Text}}),Object.defineProperty(exports,"MarkType",{enumerable:!0,get:function(){return _schema.MarkType}}),Object.defineProperty(exports,"Attribute",{enumerable:!0,get:function(){return _schema.Attribute}});var _defaultschema=require("./defaultschema");Object.defineProperty(exports,"defaultSchema",{enumerable:!0,get:function(){return _defaultschema.defaultSchema}}),Object.defineProperty(exports,"Doc",{enumerable:!0,get:function(){return _defaultschema.Doc}}),Object.defineProperty(exports,"BlockQuote",{enumerable:!0,get:function(){return _defaultschema.BlockQuote}}),Object.defineProperty(exports,"OrderedList",{enumerable:!0,get:function(){return _defaultschema.OrderedList}}),Object.defineProperty(exports,"BulletList",{enumerable:!0,get:function(){return _defaultschema.BulletList}}),Object.defineProperty(exports,"ListItem",{enumerable:!0,get:function(){return _defaultschema.ListItem}}),Object.defineProperty(exports,"HorizontalRule",{enumerable:!0,get:function(){return _defaultschema.HorizontalRule}}),Object.defineProperty(exports,"Paragraph",{enumerable:!0,get:function(){return _defaultschema.Paragraph}}),Object.defineProperty(exports,"Heading",{enumerable:!0,get:function(){return _defaultschema.Heading}}),Object.defineProperty(exports,"CodeBlock",{enumerable:!0,get:function(){return _defaultschema.CodeBlock}}),Object.defineProperty(exports,"Image",{enumerable:!0,get:function(){return _defaultschema.Image}}),Object.defineProperty(exports,"HardBreak",{enumerable:!0,get:function(){return _defaultschema.HardBreak}}),Object.defineProperty(exports,"CodeMark",{enumerable:!0,get:function(){return _defaultschema.CodeMark}}),Object.defineProperty(exports,"EmMark",{enumerable:!0,get:function(){return _defaultschema.EmMark}}),Object.defineProperty(exports,"StrongMark",{enumerable:!0,get:function(){return _defaultschema.StrongMark}}),Object.defineProperty(exports,"LinkMark",{enumerable:!0,get:function(){return _defaultschema.LinkMark}});var _pos=require("./pos");Object.defineProperty(exports,"Pos",{enumerable:!0,get:function(){return _pos.Pos}});var _diff=require("./diff");Object.defineProperty(exports,"findDiffStart",{enumerable:!0,get:function(){return _diff.findDiffStart}}),Object.defineProperty(exports,"findDiffEnd",{enumerable:!0,get:function(){return _diff.findDiffEnd}});var _error=require("./error");Object.defineProperty(exports,"ModelError",{enumerable:!0,get:function(){return _error.ModelError}})},{"./defaultschema":30,"./diff":31,"./error":32,"./fragment":33,"./mark":35,"./node":36,"./pos":37,"./schema":38}],35:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;ithis.type.rank)return set.slice(0,i).concat(this).concat(set.slice(i))}return set.concat(this)}},{key:"removeFromSet",value:function(set){for(var i=0;i=0;i--)str=marks[i].type.name+"("+str+")";return str}var _get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},_createClass=function(){function defineProperties(target,props){for(var i=0;i0&&(closedContent=this.content.close(depth-1,side))!=this.content?this.copy(closedContent):this}},{key:"path",value:function(_path){for(var i=0,node=this;i<_path.length;node=node.child(_path[i]),i++);return node}},{key:"nodeAfter",value:function(pos){var parent=this.path(pos.path);return pos.offset0?this:other}},{key:"min",value:function(other){return this.cmp(other)<0?this:other}},{key:"cmp",value:function(other){return other==this?0:Pos.cmp(this.path,this.offset,other.path,other.offset)}},{key:"shorten",value:function(){var to=arguments.length<=0||void 0===arguments[0]?null:arguments[0],offset=arguments.length<=1||void 0===arguments[1]?0:arguments[1];if(to>=this.depth){if(to==this.depth&&!offset)return new Pos(this.path,this.offset+offset);_error.ModelError.raise("Invalid shorten depth "+to+" for "+this)}return Pos.shorten(this.path,to,offset)}},{key:"move",value:function(by){return new Pos(this.path,this.offset+by)}},{key:"toPath",value:function(){var move=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return this.path.concat(this.offset+move)}},{key:"extend",value:function(pos){for(var path=this.path.slice(),add=this.offset,i=0;i=node.size)return!1;node=node.child(n)}}},{key:"toJSON",value:function(){return this}},{key:"depth",get:function(){return this.path.length}}],[{key:"cmp",value:function(pathA,offsetA,pathB,offsetB){for(var lenA=pathA.length,lenB=pathB.length,i=0,end=Math.min(lenA,lenB);end>i;i++){var diff=pathA[i]-pathB[i];if(0!=diff)return diff}return lenA>lenB?offsetB<=pathA[i]?1:-1:lenB>lenA?offsetA<=pathB[i]?-1:1:offsetA-offsetB}},{key:"samePath",value:function(pathA,pathB){if(pathA.length!=pathB.length)return!1;for(var i=0;i=0;i--)inner=conn[i].create(null,inner);return _fragment.Fragment.from(inner)}},{key:"contains",get:function(){return"block"}},{key:"isBlock",get:function(){return!0}},{key:"canBeEmpty",get:function(){return null==this.contains}}],[{key:"kinds",get:function(){return"block"}}]),Block}(NodeType),Inline=(exports.Textblock=function(_Block){function Textblock(){return _classCallCheck(this,Textblock),_possibleConstructorReturn(this,Object.getPrototypeOf(Textblock).apply(this,arguments))}return _inherits(Textblock,_Block),_createClass(Textblock,[{key:"contains",get:function(){return"inline"}},{key:"containsMarks",get:function(){return!0}},{key:"isTextblock",get:function(){return!0}},{key:"canBeEmpty",get:function(){return!0}}]),Textblock}(Block),exports.Inline=function(_NodeType2){function Inline(){return _classCallCheck(this,Inline),_possibleConstructorReturn(this,Object.getPrototypeOf(Inline).apply(this,arguments))}return _inherits(Inline,_NodeType2),_createClass(Inline,[{key:"isInline",get:function(){return!0}}],[{key:"kinds",get:function(){return"inline"}}]),Inline}(NodeType)),MarkType=(exports.Text=function(_Inline){function Text(){return _classCallCheck(this,Text),_possibleConstructorReturn(this,Object.getPrototypeOf(Text).apply(this,arguments))}return _inherits(Text,_Inline),_createClass(Text,[{key:"create",value:function(attrs,content,marks){return new _node.TextNode(this,this.computeAttrs(attrs,content),content,marks)}},{key:"selectable",get:function(){return!1}},{key:"isText",get:function(){return!0}}],[{key:"kinds",get:function(){return _get(Object.getPrototypeOf(Text),"kinds",this)+" text"}}]),Text}(Inline),exports.Attribute=function Attribute(){var options=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];_classCallCheck(this,Attribute),this["default"]=options["default"],this.compute=options.compute,this.label=options.label},exports.MarkType=function(_SchemaItem2){function MarkType(name,rank,schema){_classCallCheck(this,MarkType);var _this8=_possibleConstructorReturn(this,Object.getPrototypeOf(MarkType).call(this));_this8.name=name,_this8.freezeAttrs(),_this8.rank=rank,_this8.schema=schema;var defaults=_this8.getDefaultAttrs();return _this8.instance=defaults&&new _mark.Mark(_this8,defaults),_this8}return _inherits(MarkType,_SchemaItem2),_createClass(MarkType,[{key:"create",value:function(attrs){return!attrs&&this.instance?this.instance:new _mark.Mark(this,this.computeAttrs(attrs))}},{key:"removeFromSet",value:function(set){for(var i=0;ii;i++){var obj=i?this.marks:this.nodes;for(var tname in obj){var type=obj[tname],registry=type.registry,ns=registry&®istry[namespace];if(ns)for(var prop in ns){var value=ns[prop](type);null!=value&&f(prop,value,type,tname)}}}}}]),Schema}());exports.Schema=Schema},{"../util/error":52,"../util/obj":55,"./fragment":33,"./mark":35,"./node":36}],39:[function(require,module,exports){"use strict";function canBeLifted(doc,range){for(var content=[doc.path(range.from.path)],unwrap=!1;;){for(var parentDepth=-1,_loop=function(_node,i){content.some(function(inner){return!_node.type.canContainContent(inner.type)})||(parentDepth=i),_node=_node.child(range.from.path[i]),node=_node},node=doc,i=0;i-1)return{path:range.from.path.slice(0,parentDepth),unwrap:unwrap};if(unwrap||!content[0].isBlock)return null;content=content[0].content.slice(range.from.offset,range.to.offset),unwrap=!0}}function canLift(doc,from,to){var range=doc.siblingRange(from,to||from),found=canBeLifted(doc,range);return found?{found:found,range:range}:void 0}function canWrap(doc,from,to,type){var range=doc.siblingRange(from,to||from);if(range.from.offset==range.to.offset)return null;var parent=doc.path(range.from.path),around=parent.type.findConnection(type),inside=type.findConnection(parent.child(range.from.offset).type);return around&&inside?{range:range,around:around,inside:inside}:void 0}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj};Object.defineProperty(exports,"__esModule",{value:!0}),exports.canLift=canLift,exports.canWrap=canWrap;var _model=require("../model"),_transform=require("./transform"),_step=require("./step"),_tree=require("./tree"),_map=require("./map");_step.Step.define("ancestor",{apply:function(doc,step){var from=step.from,to=step.to;if(!(0,_tree.isFlatRange)(from,to))return null;for(var toParent=from.path,start=from.offset,end=to.offset,_step$param=step.param,_step$param$depth=_step$param.depth,depth=void 0===_step$param$depth?0:_step$param$depth,_step$param$types=_step$param.types,types=void 0===_step$param$types?[]:_step$param$types,_step$param$attrs=_step$param.attrs,attrs=void 0===_step$param$attrs?[]:_step$param$attrs,inner=doc.path(from.path),i=0;depth>i;i++){if(start>0||end=0;i--)node=types[i].create(attrs[i],node||content);newParent=parent.splice(start,end,_model.Fragment.from(node))}();if("object"===("undefined"==typeof _ret?"undefined":_typeof(_ret)))return _ret.v}else{if(!parent.type.canContainFragment(inner.content)||!inner.size&&0==start&&end==parent.size&&!parent.type.canBeEmpty)return null;newParent=parent.splice(start,end,inner.content)}for(var copy=doc.replaceDeep(toParent,newParent),toInner=toParent.slice(),i=0;i1||types.length>1){var posBefore=new _model.Pos(toParent,start),posAfter1=new _model.Pos(toParent,end),posAfter2=new _model.Pos(toParent,start+insertedSize),endOfInner=new _model.Pos(toInner,startOfInner.offset+(to.offset-from.offset));replaced=[new _map.ReplacedRange(posBefore,from,posBefore,startOfInner),new _map.ReplacedRange(to,posAfter1,endOfInner,posAfter2,posAfter1,posAfter2)]}var moved=[new _map.MovedRange(from,to.offset-from.offset,startOfInner)];return end-start!=insertedSize&&moved.push(new _map.MovedRange(new _model.Pos(toParent,end),parentSize-end,new _model.Pos(toParent,start+insertedSize))),new _step.StepResult(copy,new _map.PosMap(moved,replaced))},invert:function(step,oldDoc,map){var types=[],attrs=[];if(step.param.depth)for(var i=0;i0){this.split(pos,depth-d);for(var cut=range.from.path.length-depth,path=pos.path.slice(0,cut).concat(pos.path[cut]+1);path.lengthrange.from.offset;i--)this.join(new _model.Pos(range.from.path,i));for(var child,size=0,i=rangeNode.iter(range.from.offset,range.to.offset);child=i.next().value;)size+=child.size;var path=range.from.path.concat(range.from.offset);range={from:new _model.Pos(path,0),to:new _model.Pos(path,size)},++depth}return this.step("ancestor",range.from,range.to,null,{depth:depth}),this},_transform.Transform.prototype.wrap=function(from,to,type,wrapAttrs){var can=canWrap(this.doc,from,to,type);if(!can)return this;var range=can.range,around=can.around,inside=can.inside,types=around.concat(type).concat(inside),attrs=around.map(function(){return null}).concat(wrapAttrs).concat(inside.map(function(){return null}));if(this.step("ancestor",range.from,range.to,null,{types:types,attrs:attrs}),inside.length){for(var toInner=range.from.path.slice(),i=0;i0;i--)this.split(new _model.Pos(toInner,i),inside.length)}return this},_transform.Transform.prototype.setBlockType=function(from,to,type,attrs){var _this=this;return this.doc.nodesBetween(from,to||from,function(node,path){return node.isTextblock&&!node.hasMarkup(type,attrs)?(path=path.slice(),_this.clearMarkup(new _model.Pos(path,0),new _model.Pos(path,node.size),type),_this.step("ancestor",new _model.Pos(path,0),new _model.Pos(path,_this.doc.path(path).size),null,{depth:1,types:[type],attrs:[attrs]}),!1):void 0}),this},_transform.Transform.prototype.setNodeType=function(pos,type,attrs){var node=this.doc.nodeAfter(pos),path=pos.toPath();return this.step("ancestor",new _model.Pos(path,0),new _model.Pos(path,node.size),null,{depth:1,types:[type],attrs:[attrs]}),this}},{"../model":34,"./map":42,"./step":46,"./transform":47,"./tree":48}],40:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Remapping=exports.MapResult=exports.PosMap=exports.joinableBlocks=exports.joinPoint=exports.canWrap=exports.canLift=exports.StepResult=exports.Step=exports.Transform=void 0;var _transform=require("./transform");Object.defineProperty(exports,"Transform",{enumerable:!0,get:function(){return _transform.Transform}});var _step=require("./step");Object.defineProperty(exports,"Step",{enumerable:!0,get:function(){return _step.Step}}),Object.defineProperty(exports,"StepResult",{enumerable:!0,get:function(){return _step.StepResult}});var _ancestor=require("./ancestor");Object.defineProperty(exports,"canLift",{enumerable:!0,get:function(){return _ancestor.canLift}}),Object.defineProperty(exports,"canWrap",{enumerable:!0,get:function(){return _ancestor.canWrap}});var _join=require("./join");Object.defineProperty(exports,"joinPoint",{enumerable:!0,get:function(){return _join.joinPoint}}),Object.defineProperty(exports,"joinableBlocks",{enumerable:!0,get:function(){return _join.joinableBlocks; }});var _map=require("./map");Object.defineProperty(exports,"PosMap",{enumerable:!0,get:function(){return _map.PosMap}}),Object.defineProperty(exports,"MapResult",{enumerable:!0,get:function(){return _map.MapResult}}),Object.defineProperty(exports,"Remapping",{enumerable:!0,get:function(){return _map.Remapping}}),require("./mark"),require("./split"),require("./replace")},{"./ancestor":39,"./join":41,"./map":42,"./mark":43,"./replace":44,"./split":45,"./step":46,"./transform":47}],41:[function(require,module,exports){"use strict";function joinableBlocks(doc,pos){if(0==pos.offset)return!1;var parent=doc.path(pos.path);if(parent.isTextblock||pos.offset==parent.size)return!1;var type=parent.child(pos.offset-1).type;return!type.isTextblock&&type.contains&&type==parent.child(pos.offset).type}function joinPoint(doc,pos){for(var dir=arguments.length<=2||void 0===arguments[2]?-1:arguments[2];;){if(joinableBlocks(doc,pos))return pos;if(0==pos.depth)return null;pos=pos.shorten(null,0>dir?0:1)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.joinableBlocks=joinableBlocks,exports.joinPoint=joinPoint;var _model=require("../model"),_transform=require("./transform"),_step=require("./step"),_map=require("./map");_step.Step.define("join",{apply:function(doc,step){var before=doc.path(step.from.path),after=doc.path(step.to.path);if(step.from.offset0||!before.type.canContainFragment(after.content))return null;var pFrom=step.from.path,pTo=step.to.path,last=pFrom.length-1,offset=pFrom[last]+1;if(pFrom.length!=pTo.length||0==pFrom.length||offset!=pTo[last])return null;for(var i=0;last>i;i++)if(pFrom[i]!=pTo[i])return null;var targetPath=pFrom.slice(0,last),target=doc.path(targetPath),oldSize=target.size;if(target.type.locked)return null;var joined=before.append(after.content),copy=doc.replaceDeep(targetPath,target.splice(offset-1,offset+1,_model.Fragment.from(joined))),map=new _map.PosMap([new _map.MovedRange(step.to,after.size,step.from),new _map.MovedRange(new _model.Pos(targetPath,offset+1),oldSize-offset-1,new _model.Pos(targetPath,offset))],[new _map.ReplacedRange(step.from,step.to,step.from,step.from,step.to.shorten())]);return new _step.StepResult(copy,map)},invert:function(step,oldDoc){return new _step.Step("split",null,null,step.from,oldDoc.path(step.to.path).copy())}}),_transform.Transform.prototype.join=function(at){var parent=this.doc.path(at.path);return 0==at.offset||at.offset==parent.size||parent.isTextblock?this:(this.step("join",new _model.Pos(at.path.concat(at.offset-1),parent.child(at.offset-1).size),new _model.Pos(at.path.concat(at.offset),0)),this)}},{"../model":34,"./map":42,"./step":46,"./transform":47}],42:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function offsetFrom(base,pos){if(pos.path.length>base.path.length){for(var path=[pos.path[base.path.length]-base.offset],i=base.path.length+1;i=0&&(right=pos.cmp(side.to))<=0){var other=back?range.before:range.after;return new MapResult(0>bias?other.from:other.to,!(!left||!right),{rangeID:i,offset:offsetFrom(side.ref,pos)})}}for(var i=0;i=0&&_model.Pos.cmp(pos.path,pos.offset,start.path,start.offset+range.size)<=0){var dest=back?range.start:range.dest,depth=start.depth;if(pos.depth>depth){var offset=dest.offset+(pos.path[depth]-start.offset);return new MapResult(new _model.Pos(dest.path.concat(offset).concat(pos.path.slice(depth+1)),pos.offset))}return new MapResult(new _model.Pos(dest.path,dest.offset+(pos.offset-start.offset)))}}return new MapResult(pos)}var _createClass=function(){function defineProperties(target,props){for(var i=0;iid?this.head[-id-1]:this.tail[id]}},{key:"map",value:function map(pos,bias){for(var deleted=!1,i=-this.head.length;i=0;i--)this.step(delSteps[i]);return this}},{"../model":34,"./step":46,"./transform":47,"./tree":48}],44:[function(require,module,exports){"use strict";function findMovedChunks(oldNode,oldPath,newNode,startDepth){for(var moved=[],newPath=oldPath.path.slice(0,startDepth),depth=startDepth;;depth++){var joined=depth==oldPath.depth?0:1,cut=depth==oldPath.depth?oldPath.offset:oldPath.path[depth],afterCut=oldNode.size-cut,newOffset=newNode.size-afterCut,from=oldPath.shorten(depth,joined),to=new _model.Pos(newPath,newOffset+joined);if(from.cmp(to)&&moved.push(new _map.MovedRange(from,afterCut-joined,to)),!joined)return moved;oldNode=oldNode.child(cut),newNode=newNode.child(newOffset),newPath=newPath.concat(newOffset)}}function replace(node,from,to,root,repl){var depth=arguments.length<=5||void 0===arguments[5]?0:arguments[5];if(depth==root.length){var before=node.sliceBetween(null,from,depth),after=node.sliceBetween(to,null,depth),result=void 0;return before.type.canContainFragment(repl.content)?(result=repl.content.size?before.append(repl.content,from.depth-depth,repl.openLeft).append(after.content,repl.openRight,to.depth-depth):before.append(after.content,from.depth-depth,to.depth-depth),result.size||result.type.canBeEmpty||(result=result.copy(result.type.defaultContent())),{doc:result,moved:findMovedChunks(node,to,result,depth)}):null}var pos=root[depth],result=replace(node.child(pos),from,to,root,repl,depth+1);return result?{doc:node.replace(pos,result.doc),moved:result.moved}:null}function shiftFromStack(stack,depth){for(var shifted=stack[depth]=stack[depth].slice(1),i=depth-1;i>=0;i--)shifted=stack[i]=stack[i].replace(0,shifted)}function buildInserted(nodesLeft,source,start,end){for(var sliced=source.sliceBetween(start,end),nodesRight=[],node=sliced,i=0;i<=start.path.length;i++,node=node.firstChild)nodesRight.push(node);var same=(0,_tree.samePathDepth)(start,end),searchLeft=nodesLeft.length-1,searchRight=nodesRight.length-1,result=null,inner=nodesRight[searchRight];for(inner.isTextblock&&inner.size&&nodesLeft[searchLeft].isTextblock&&(result=nodesLeft[searchLeft--].copy(inner.content),--searchRight,shiftFromStack(nodesRight,searchRight));;searchRight--){for(var node=nodesRight[searchRight],type=node.type,matched=null,outside=same>=searchRight,i=searchLeft;i>=0;i--){var left=nodesLeft[i];if(outside?left.type.canContainContent(node.type):left.type==type){matched=i;break}}if(null!=matched)if(result)for(;searchLeft>=matched;){var wrap=nodesLeft[searchLeft],content=_model.Fragment.from(result);result=wrap.copy(searchLeft==matched?content.append(node.content):content),searchLeft--}else result=nodesLeft[matched].copy(node.content),searchLeft=matched-1;if(null!=matched||0==node.size){if(outside)break;shiftFromStack(nodesRight,searchRight-1)}}var repl={content:result?result.content:_model.emptyFragment,openLeft:start.depth-searchRight,openRight:end.depth-searchRight};return{repl:repl,depth:searchLeft+1}}function moveText(tr,doc,before,after){for(var root=(0,_tree.samePathDepth)(before,after),cutAt=after.shorten(null,1);cutAt.path.length>root&&1==doc.path(cutAt.path).size;)cutAt=cutAt.shorten(null,1);tr.split(cutAt,cutAt.path.length-root);for(var start=after,end=new _model.Pos(start.path,doc.path(start.path).size),parent=doc.path(start.path.slice(0,root)),wanted=parent.pathNodes(before.path.slice(root)),existing=parent.pathNodes(start.path.slice(root));wanted.length&&existing.length&&wanted[0].sameMarkup(existing[0]);)wanted.shift(),existing.shift();(existing.length||wanted.length)&&tr.step("ancestor",start,end,null,{depth:existing.length,types:wanted.map(function(n){return n.type}),attrs:wanted.map(function(n){return n.attrs})});for(var i=root;imaxDepth;)repl.content.size&&(repl={content:_model.Fragment.from(doc.path(from.path.slice(0,depth)).copy(repl.content)),openLeft:repl.openLeft+1,openRight:repl.openRight+1}),depth--}else repl=nullRepl,depth=maxDepth;var root=from.shorten(depth),docAfter=doc,after=to;if(repl.content.size||(0,_tree.replaceHasEffect)(doc,from,to)){var result=this.step("replace",from,to,root,repl);docAfter=result.doc,after=result.map.map(to).pos}if(!doc.path(to.path).isTextblock)return this;if(!(repl.content.size?source.path(end.path).isTextblock:doc.path(from.path).isTextblock))return this;var nodesAfter=doc.path(root.path).pathNodes(to.path.slice(depth)).slice(1),nodesBefore=void 0;if(repl.content.size){var inserted=repl.content;nodesBefore=[];for(var i=0;ioff;off++){var here=pos.shorten(pos.depth-off);here.offset&&here.offset0)return!0}return gapStart!=gapEnd?!0:canBeJoined(node,gapStart,Math.min(from.depth,to.depth)-depth)}node=node.child(from.path[depth])}}function samePathDepth(a,b){for(var i=0;;i++)if(i==a.path.length||i==b.path.length||a.path[i]!=b.path[i])return i}Object.defineProperty(exports,"__esModule",{value:!0}),exports.copyStructure=copyStructure,exports.copyInline=copyInline,exports.isFlatRange=isFlatRange,exports.replaceHasEffect=replaceHasEffect,exports.samePathDepth=samePathDepth;var _model=require("../model")},{"../model":34}],49:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function openPrompt(pm,content,options){var button=(0,_dom.elt)("button",{"class":"ProseMirror-prompt-close"}),wrapper=(0,_dom.elt)("div",{"class":"ProseMirror-prompt"},content,button),outerBox=pm.wrapper.getBoundingClientRect();if(pm.wrapper.appendChild(wrapper),options&&options.pos)wrapper.style.left=options.pos.left-outerBox.left+"px",wrapper.style.pos=options.pos.top-outerBox.top+"px";else{var blockBox=wrapper.getBoundingClientRect(),cX=Math.max(0,outerBox.left)+Math.min(window.innerWidth,outerBox.right)-blockBox.width,cY=Math.max(0,outerBox.top)+Math.min(window.innerHeight,outerBox.bottom)-blockBox.height;wrapper.style.left=cX/2-outerBox.left+"px",wrapper.style.top=cY/2-outerBox.top+"px"}var close=function close(){pm.off("interaction",close),wrapper.parentNode&&(wrapper.parentNode.removeChild(wrapper),options&&options.onClose&&options.onClose())};return button.addEventListener("click",close),pm.on("interaction",close),{close:close}}var _createClass=function(){function defineProperties(target,props){for(var i=0;i-1&&this.waiting.splice(index,1)}},{key:"force",value:function(){for(clearTimeout(this.timeout),this.lastForce=Date.now();this.waiting.length;)for(var i=0;iMIN_FLUSH_DELAY&&this.force()}}],[{key:"get",value:function(pm){return pm.mod.centralScheduler||(pm.mod.centralScheduler=new this(pm))}}]),CentralScheduler}();exports.UpdateScheduler=function(){function UpdateScheduler(pm,events,start){var _this=this;_classCallCheck(this,UpdateScheduler),this.pm=pm,this.start=start,this.events=events.split(" "),this.onEvent=this.onEvent.bind(this),this.events.forEach(function(event){return pm.on(event,_this.onEvent)})}return _createClass(UpdateScheduler,[{key:"detach",value:function(){var _this2=this;unscheduleDOMUpdate(this.pm,this.start),this.events.forEach(function(event){return _this2.pm.off(event,_this2.onEvent)})}},{key:"onEvent",value:function(){scheduleDOMUpdate(this.pm,this.start)}},{key:"force",value:function(){if(this.pm.operation)this.onEvent();else{unscheduleDOMUpdate(this.pm,this.start);for(var run=this.start;run;run=run());}}}]),UpdateScheduler}()},{}],52:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function functionName(f){var match=/^function (\w+)/.exec(f.toString());return match&&match[1]}var _createClass=function(){function defineProperties(target,props){for(var i=0;i1?_len-1:0),_key=1;_len>_key;_key++)args[_key-1]=arguments[_key];if(arr)for(var i=0;i1?_len2-1:0),_key2=1;_len2>_key2;_key2++)args[_key2-1]=arguments[_key2];for(var i=0;i0}}},{}],54:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i-1?this.content[found+1]=value:this.content.push(key,value)}},{key:"get",value:function(key){var found=this.find(key);return-1==found?void 0:this.content[found+1]}},{key:"has",value:function(key){return this.find(key)>-1}},{key:"find",value:function(key){for(var i=0;i0);i++);array.splice(i,0,elt)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=sortedInsert},{}],57:[function(require,module,exports){!function(mod){if("object"==typeof exports&&"object"==typeof module)module.exports=mod();else{if("function"==typeof define&&define.amd)return define([],mod);(this||window).browserKeymap=mod()}}(function(){"use strict";function keyName(event){if("keypress"==event.type)return"'"+String.fromCharCode(event.charCode)+"'";var base=keyNames[event.keyCode],name=base;return null==name||event.altGraphKey?null:(event.altKey&&"Alt"!=base&&(name="Alt-"+name),event.ctrlKey&&"Ctrl"!=base&&(name="Ctrl-"+name),event.metaKey&&"Cmd"!=base&&(name="Cmd-"+name),event.shiftKey&&"Shift"!=base&&(name="Shift-"+name),name)}function isModifierKey(name){return name=/[^-]*$/.exec(name)[0],"Ctrl"==name||"Alt"==name||"Shift"==name||"Mod"==name}function normalizeKeyName(name){for(var alt,ctrl,shift,cmd,parts=name.split(/-(?!'?$)/),result=parts[parts.length-1],i=0;ii;i++)keyNames[i+48]=keyNames[i+96]=String(i);for(var i=65;90>=i;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;12>=i;i++)keyNames[i+111]=keyNames[i+63235]="F"+i;return Keymap.prototype={normalize:function(name){return this.options.multi!==!1?name.split(/ +(?!\'$)/).map(normalizeKeyName):[normalizeKeyName(name)]},addBinding:function(keyname,value){for(var keys=this.normalize(keyname),i=0;i=0;i--){var name=keys.slice(0,i).join(" "),val=this.bindings[name];if("..."==val&&!this.unusedMulti(name))break;val&&delete this.bindings[name]}},unusedMulti:function(name){for(var binding in this.bindings)if(binding.length>name&&0==binding.indexOf(name)&&" "==binding.charAt(name.length))return!1;return!0},lookup:function(key,context){return this.options.call?this.options.call(key,context):this.bindings[key]},constructor:Keymap},Keymap.keyName=keyName,Keymap.isModifierKey=isModifierKey,Keymap.normalizeKeyName=normalizeKeyName,Keymap})},{}],58:[function(require,module,exports){"use strict";var _edit=require("prosemirror/dist/edit");require("prosemirror/dist/menu/tooltipmenu"),require("prosemirror/dist/menu/menubar"),require("prosemirror/dist/inputrules/autoinput");var _menu=require("prosemirror/dist/menu/menu"),_widgets=require("./widgets"),_utils=require("./utils"),_schema=require("./schema");window.pm=new _edit.ProseMirror({place:document.querySelector("#editor"),menuBar:{"float":!0,content:[_menu.inlineGroup,[_menu.blockGroup,_menu.textblockMenu],_widgets.alignGroup,[_widgets.contentInsertMenu,_widgets.questionInsertMenu],_menu.historyGroup]},schema:_schema.widgetSchema,commands:_schema.commands,autoInput:!0,doc:document.querySelector("#content"),docFormat:"dom"});(0,_utils.defineFileHandler)(function(files){console.log(files)})},{"./schema":59,"./utils":60,"./widgets":72,"prosemirror/dist/edit":11,"prosemirror/dist/inputrules/autoinput":24,"prosemirror/dist/menu/menu":27,"prosemirror/dist/menu/menubar":28,"prosemirror/dist/menu/tooltipmenu":29}],59:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.commands=exports.widgetSchema=void 0;var _edit=require("prosemirror/dist/edit"),_dom=require("prosemirror/dist/dom"),_model=require("prosemirror/dist/model"),_widgets=require("./widgets"),_menu=require("prosemirror/dist/menu/menu"),widgetSpec=new _model.SchemaSpec({doc:_model.Doc,blockquote:_model.BlockQuote,ordered_list:_model.OrderedList,bullet_list:_model.BulletList,list_item:_model.ListItem,paragraph:_model.Paragraph,heading:_model.Heading,text:_model.Text,hard_break:_model.HardBreak,input:_widgets.Input,checkbox:_widgets.CheckBox,radiobutton:_widgets.RadioButton,select:_widgets.Select,textfield:_widgets.TextField,textarea:_widgets.TextArea,question:_widgets.Question,textbox:_widgets.TextBox,choice:_widgets.Choice,multiplechoice:_widgets.MultipleChoice,scaledisplay:_widgets.ScaleDisplay,scale:_widgets.Scale,checkitem:_widgets.CheckItem,checklist:_widgets.CheckList,shortanswer:_widgets.ShortAnswer,essay:_widgets.Essay,selection:_widgets.Selection,horizontal_rule:_model.HorizontalRule,image:_widgets.Image,inlinemath:_widgets.InlineMath,blockmath:_widgets.BlockMath,website:_widgets.Website,carryforward:_widgets.CarryForward,spreadsheet:_widgets.SpreadSheet,leftalign:_widgets.LeftAlign,centeralign:_widgets.CenterAlign,rightalign:_widgets.RightAlign},{em:_model.EmMark,strong:_model.StrongMark,link:_model.LinkMark,code:_model.CodeMark,underline:_widgets.UnderlineMark,strikethrough:_widgets.StrikeThroughMark});exports.widgetSchema=new _model.Schema(widgetSpec);_menu.textblockMenu.options.label="Format";exports.commands=_edit.CommandSet["default"].update({selectParentNode:{menu:null},lift:{menu:null},"horizontal_rule:insert":{menu:{group:"content",rank:71,display:{type:"label",label:"Horizontal Rule"}}},"code:toggle":{menu:{group:"textblock",rank:99,display:{type:"label",label:"Code"}}}});(0,_dom.insertCSS)('\n \n.ProseMirror {\n width: 800px;\n min-height: 200px;\n}\n\n.ProseMirror-menu {\n background: white;\n color: black;\n}\n\ndiv.ProseMirror-dropdown-menu {\n position: absolute;\n background: white;\n color: black;\n border-radius: 6px;\n border: 1px solid silver;\n padding: 2px 2px;\n z-index: 15;\n}\n\ndiv.ProseMirror-dropdown-menu {\n cursor: pointer;\n padding: 0 1em 0 2px;\n}\n\ndiv.ProseMirror-menubar-inner {\n background: linear-gradient(to bottom, white, #0191C8);\n}\n\ndiv.ProseMirror-menu form {\n background: linear-gradient(to bottom, white, #0191C8);\n width: 300px;\n}\n\ndiv.ProseMirror-menu form select {\n width: 100px;\n background: white;\n}\n\ndiv.ProseMirror-menu input[type = "text"] {\n background: white;\n}\n\n')},{"./widgets":72,"prosemirror/dist/dom":1,"prosemirror/dist/edit":11,"prosemirror/dist/menu/menu":27,"prosemirror/dist/model":34}],60:[function(require,module,exports){"use strict";function defParser(type,tag,cls){type.register("parseDOM",tag,{rank:25,parse:function(dom,state){return dom.classList.contains(cls)?(console.log(dom),void state.insert(type)):!1}})}function getPosInParent(pm,pos,child){var i=0,parent=pm.doc.path(pos.path);return parent.forEach(function(node,start){i=node==child?start:0}),new _model.Pos(pos.path,i)}function nodeBefore(pm,pos){for(var before=void 0,cut=void 0,i=pos.path.length-1;!before&&i>=0;i--)pos.path[i]>0&&(cut=pos.shorten(i),before=pm.doc.path(cut.path).child(cut.offset-1));return{before:before,at:new _model.Pos(cut.path,cut.offset-1)}}function insertWidget(pm,pos,w){for(;;){if(0==pos.depth){pm.tr.insert(pos,w).apply(pm.apply.scroll);var side=getPosInParent(pm,pos,w),p=new _model.Pos(side.toPath(),0);return w.firstChild&&w.firstChild.isTextblock&&pm.setTextSelection(new _model.Pos(p.toPath(),0)),!0}pos=pos.shorten(null,1)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.selectedNodeAttr=exports.defParamsClick=exports.nameTitle=exports.namePattern=exports.defineFileHandler=exports.widgetParamHandler=void 0;var _params=require("./params");Object.defineProperty(exports,"widgetParamHandler",{enumerable:!0,get:function(){return _params.widgetParamHandler}}),Object.defineProperty(exports,"defineFileHandler",{enumerable:!0,get:function(){return _params.defineFileHandler}}),Object.defineProperty(exports,"namePattern",{enumerable:!0,get:function(){return _params.namePattern}}),Object.defineProperty(exports,"nameTitle",{enumerable:!0,get:function(){return _params.nameTitle}}),Object.defineProperty(exports,"defParamsClick",{enumerable:!0,get:function(){return _params.defParamsClick}}),Object.defineProperty(exports,"selectedNodeAttr",{enumerable:!0,get:function(){return _params.selectedNodeAttr}}),exports.defParser=defParser,exports.getPosInParent=getPosInParent,exports.nodeBefore=nodeBefore,exports.insertWidget=insertWidget;var _model=require("prosemirror/dist/model");require("prosemirror/dist/edit/selection")},{"./params":61,"prosemirror/dist/edit/selection":17,"prosemirror/dist/model":34}],61:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function defineFileHandler(handler){fhandler=handler}function getLastClicked(){return lastClicked}function openWidgetPrompt(wpp,options){var close=function close(){wpp.pm.off("interaction",close),dialog.parentNode&&(dialog.parentNode.removeChild(dialog),options&&options.onClose&&options.onClose())},submit=function(){var params=wpp.values();params&&(wpp.command.exec(wpp.pm,params),close())};wpp.pm.on("interaction",close);var save=(0,_dom.elt)("input",{name:"save",type:"button",value:"Save"});save.addEventListener("mousedown",function(e){submit()});var cancel=(0,_dom.elt)("input",{name:"cancel",type:"button",value:"Cancel"});cancel.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation(),close()});var buttons=(0,_dom.elt)("div",{"class":"widgetButtons"},save,cancel);wpp.form=(0,_dom.elt)("form",{"class":"widgetForm"},(0,_dom.elt)("h4",null,wpp.command.label+" Settings"),wpp.fields.map(function(f){return(0,_dom.elt)("div",null,f)}),buttons),wpp.form.addEventListener("keypress",function(e){13==e.keyCode&&(e.preventDefault(),e.stopPropagation(),save.click())});var dialog=(0,_dom.elt)("div",null,(0,_dom.elt)("div",{"class":"widgetDialog"}),wpp.form);return wpp.pm.wrapper.appendChild(dialog),{close:close}}function selectClickedNode(pm,e){var pos=(0,_dompos.selectableNodeAbove)(pm,e.target,{left:e.clientX,top:e.clientY},!0);if(!pos)return pm.sel.fastPoll();var _pm$selection=pm.selection,node=_pm$selection.node,from=_pm$selection.from;if(node&&pos.depth>=from.depth&&0==pos.shorten(from.depth).cmp(from)){if(0==from.depth)return pm.sel.fastPoll();pos=from.shorten()}pm.setNodeSelection(pos),lastClicked=e.target}function defParamsClick(type,cmdname){var spots=arguments.length<=2||void 0===arguments[2]?["topright"]:arguments[2];type.prototype.handleClick=function(pm,e,path,node){selectClickedNode(pm,e);var spotClicked=!1;if(spots.forEach(function(loc){var r=e.target.getBoundingClientRect();"all"==loc?spotClicked=!0:"topright"==loc?spotClicked=spotClicked||e.clientX>r.right-16&&e.clientYr.right-32&&e.clientY>r.bottom-32)}),spotClicked){var cmd=pm.commands[cmdname];return cmd?(cmd.exec(pm),!0):!1}}}function selectedNodeAttr(pm,type,name){var node=pm.selection.node;return node&&node.type==type?node.attrs[name]:void 0}function FileDragHover(e){e.stopPropagation(),e.preventDefault(),e.target.className="dragover"==e.type?"hover":""}function buildUploadForm(pm,field){var legend=(0,_dom.elt)("h4",null,"File Upload"),label=((0,_dom.elt)("input",{type:"hidden",id:"MAX_FILE_SIZE",name:"MAX_FILE_SIZE",value:"300000"}),(0,_dom.elt)("label",{"for":"fileselect"},"File to upload:")),fileselect=(0,_dom.elt)("input",{id:"fileselect",type:"file",name:"fileselect[]",multiple:"multiple"}),filedrag=(0,_dom.elt)("div",{id:"filedrag"},"or drop files here"),cancel=(0,_dom.elt)("input",{type:"button",value:"Cancel"});cancel.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),pm.wrapper.removeChild(form)});var saveFile=function(e){e.preventDefault(),e.stopPropagation(),FileDragHover(e);var files=e.target.files||e.dataTransfer.files;files&&(field.value=files[0].name),fhandler&&fhandler(files),pm.wrapper.removeChild(form)};fileselect.addEventListener("change",saveFile);var xhr=new XMLHttpRequest;xhr.upload&&(filedrag.addEventListener("dragover",FileDragHover),filedrag.addEventListener("dragleave",FileDragHover),filedrag.addEventListener("drop",saveFile),filedrag.style.display="block");var form=(0,_dom.elt)("form",{id:"upload",enctype:"multipart/form-data"},legend,(0,_dom.elt)("div",null,label,fileselect,filedrag),(0,_dom.elt)("div",null,cancel));pm.wrapper.appendChild(form)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0?pos.shorten():pos}function findAlignWrapper(pm,align){var _pm$selection=pm.selection,from=_pm$selection.from,to=_pm$selection.to,isLeft=(_pm$selection.node,"leftalign"==align.name),start=getTextblockPos(pm,from),parent=pm.doc.path(start.path);if(parent.type instanceof Align)return isLeft?pm.tr.lift(new _model.Pos(start.path,0),new _model.Pos(start.path,parent.size)).apply(pm.apply.scroll):pm.tr.setNodeType((0,_utils.getPosInParent)(pm,start.shorten(),parent),align,{"class":align.style}).apply(pm.apply.scroll);if(isLeft)return!1;var end=from.cmp(to)?getTextblockPos(pm,to):start;return pm.tr.wrap(start,end.move(1),align,{"class":align.style}).apply(pm.apply.scroll)}function alignApplies(pm,type){var _pm$selection2=pm.selection,from=_pm$selection2.from,isLeft=(_pm$selection2.to,_pm$selection2.node,"leftalign"==type.name),start=getTextblockPos(pm,from),parent=pm.doc.path(start.path);return!isLeft||parent.type instanceof Align?parent.type.name==type.name:!0}function defAlign(type,label,path){type.register("command","align",{run:function(pm){return findAlignWrapper(pm,this)},active:function(pm){return alignApplies(pm,this)},label:label,menu:{group:"align",rank:51,display:{type:"icon",width:8,height:8,path:path}}})}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0)return pm.tr["delete"](from,to).apply(pm.apply.scroll);var toCL=toCH.shorten(),cl=pm.doc.path(toCL.path),_nodeBefore=(0,_utils.nodeBefore)(pm,toCH),before=_nodeBefore.before;_nodeBefore.at;if(2==cl.size||before.type!=this||ch.lastChild.size>0)return!0;var tr=pm.tr["delete"](toCL,toCL.move(1)).apply();return renumber(pm,toCL),tr},keys:["Backspace(20)","Mod-Backspace(20)"]}),CheckList.register("command","insert",{label:"Check List",run:function(pm,name){var _pm$selection3=pm.selection,from=_pm$selection3.from,node=(_pm$selection3.to,_pm$selection3.node);if(node&&node.type==this){var tr=pm.tr.setNodeType(from,this,{name:name}).apply();return renumber(pm,_model.Pos.from(from.toPath().concat(from.offset),0)),tr}var choice_content=_model.Fragment.from([this.schema.nodes.checkbox.create({name:name,value:1}),this.schema.nodes.textbox.create()]),content=_model.Fragment.from([this.schema.nodes.paragraph.create(null,""),this.schema.nodes.checkitem.create({name:name,value:1},choice_content)]);return(0,_utils.insertWidget)(pm,from,this.create({name:name},content))},select:function(pm){return!0},menu:{group:"question",rank:70,display:{type:"label",label:"CheckList"}},params:[{name:"Name",attr:"name", -label:"Short ID",type:"text",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"name")},options:{pattern:_utils.namePattern,size:10,title:_utils.nameTitle}}]}),(0,_utils.defParamsClick)(CheckList,"checklist:insert"),(0,_dom.insertCSS)("\n\n.ProseMirror .widgets-checkitem input {\n float: left;\n}\n\n.ProseMirror .widgets-checkitem {\n cursor: text;\n}\n\n\n")},{"../../utils":60,"./question":84,"./textbox":88,"prosemirror/dist/dom":1,"prosemirror/dist/model":34}],81:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0)return pm.tr["delete"](from,to).apply(pm.apply.scroll);var toMC=toCH.shorten(),mc=pm.doc.path(toMC.path),_nodeBefore=(0,_utils.nodeBefore)(pm,toCH),before=_nodeBefore.before;_nodeBefore.at;if(2==mc.size||before.type!=this||ch.lastChild.size>0)return!0;var tr=pm.tr["delete"](toMC,toMC.move(1)).apply();return renumber(pm,toMC),tr},keys:["Backspace(20)","Mod-Backspace(20)"]}),MultipleChoice.register("command","insert",{label:"MultipleChoice",run:function(pm,name){var _pm$selection3=pm.selection,from=_pm$selection3.from,node=(_pm$selection3.to,_pm$selection3.node);if(node&&node.type==this){var tr=pm.tr.setNodeType(from,this,{name:name}).apply();return renumber(pm,_model.Pos.from(from.toPath().concat(from.offset),0)),tr}var choice_content=_model.Fragment.from([this.schema.nodes.radiobutton.create({name:name,value:1}),this.schema.nodes.textbox.create()]),content=_model.Fragment.from([this.schema.nodes.paragraph.create(null,""),this.schema.nodes.choice.create({name:name,value:1},choice_content)]);return(0,_utils.insertWidget)(pm,from,this.create({name:name},content))},select:function(pm){return!0},menu:{group:"question",rank:70,display:{type:"label",label:"MultipleChoice"}},params:[{name:"Name",attr:"name",label:"Short ID",type:"text",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"name")},options:{pattern:_utils.namePattern,size:10,title:_utils.nameTitle}}]}),(0,_utils.defParamsClick)(MultipleChoice,"multiplechoice:insert"),(0,_dom.insertCSS)("\n\n.widgets-choice input {\n float: left;\n}\n\n.ProseMirror .widgets-choice:hover {\n cursor: text;\n}\n\n")},{"../../utils":60,"./question":84,"prosemirror/dist/dom":1,"prosemirror/dist/model":34}],84:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Question=void 0;var _model=require("prosemirror/dist/model"),_dom=require("prosemirror/dist/dom"),_utils=require("../../utils"),Question=(require("prosemirror/dist/transform"),exports.Question=function(_Block){function Question(){return _classCallCheck(this,Question),_possibleConstructorReturn(this,Object.getPrototypeOf(Question).apply(this,arguments))}return _inherits(Question,_Block),Question}(_model.Block));(0,_utils.defParser)(Question,"div","widgets-question"),Question.prototype.serializeDOM=function(node,s){return(0,_dom.elt)("div",{"class":"widgets-question widgets-edit"},s.renderAs(node,"div",node.attrs))},Question.register("command","delete",{label:"delete text from question",run:function(pm){var _pm$selection=pm.selection,from=_pm$selection.from,para=(_pm$selection.to,_pm$selection.head,pm.doc.path(from.path));if(from.offset>0||"paragraph"!=para.type.name)return!1;from=from.shorten();var parent=pm.doc.path(from.path);return parent.type instanceof Question?parent.firstChild==para:!1},keys:["Backspace(10)","Mod-Backspace(10)"]}),Question.register("command","enter",{label:"process enter",run:function(pm){var _pm$selection2=pm.selection,from=_pm$selection2.from,node=_pm$selection2.node,para=pm.doc.path(from.path);if(node&&node.type instanceof Question){var _parent=pm.doc.path(from.path);if(_parent.lastChild==node||!_parent.child(from.offset+1).isTextblock){var side=from.move(1);pm.tr.insert(side,pm.schema.defaultTextblockType().create()).apply(pm.apply.scroll),pm.setTextSelection(new _model.Pos(side.toPath(),0))}return!0}if(from.offset>0||"paragraph"!=para.type.name)return!1;var parent=pm.doc.path(from.shorten().path);return parent.type instanceof Question},keys:["Enter(10)","Mod-Enter(10)"]}),(0,_dom.insertCSS)('\n \n.widgets-question {\n counter-increment: qcnt;\n border: 1px solid #DDD;\n border-radius: 4px;\n padding: 8px;\n margin-top: 1em;\n}\n\n.widgets-question:before {\n content: "Question " counter(qcnt) ".";\n font-size: 80%;\n font-weight: bold;\n// cursor: move;\n}\n\n.ProseMirror .widgets-question p:hover {\n cursor: text;\n}\n\n')},{"../../utils":60,"prosemirror/dist/dom":1,"prosemirror/dist/model":34,"prosemirror/dist/transform":40}],85:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},_createClass=function(){function defineProperties(target,props){for(var i=0;istartVal)for(var i=startVal;endVal>=i;i++){var _name=node.attrs.name+i;para.appendChild((0,_dom.elt)("span",{"class":"widgets-scaleitem"},(0,_dom.elt)("label",{"for":_name},i.toString()),(0,_dom.elt)("input",{id:_name,name:node.attrs.name,type:"radio",value:i})))}else for(var i=startVal;i>=endVal;i--)para.appendChild((0,_dom.elt)("span",{"class":"widgets-scaleitem"},(0,_dom.elt)("label",{"for":name},i.toString()),(0,_dom.elt)("input",{id:name,name:node.attrs.name,type:"radio",value:i})));return para.appendChild((0,_dom.elt)("span",null," "+node.attrs.endlabel)),para};var Scale=exports.Scale=function(_Question){function Scale(){return _classCallCheck(this,Scale),_possibleConstructorReturn(this,Object.getPrototypeOf(Scale).apply(this,arguments))}return _inherits(Scale,_Question),_createClass(Scale,[{key:"create",value:function(attrs,content,marks){var sd=this.schema.nodes.scaledisplay.create(attrs);if(content){var nodes=content.toArray();nodes.pop(),content=_model.Fragment.fromArray(nodes.concat(sd))}else content=_model.Fragment.from([this.schema.nodes.paragraph.create(null,""),sd]);return _get(Object.getPrototypeOf(Scale.prototype),"create",this).call(this,attrs,content,marks)}},{key:"attrs",get:function(){return{name:new _model.Attribute,startvalue:new _model.Attribute({"default":"1"}),startlabel:new _model.Attribute({"default":"low"}),endvalue:new _model.Attribute({"default":"10"}),endlabel:new _model.Attribute({"default":"high"}),"class":new _model.Attribute({"default":"widgets-scale"})}}}],[{key:"contains",get:function(){return"text"}}]),Scale}(_question.Question);(0,_utils.defParser)(Scale,"div","widgets-scale"),Scale.register("command","insert",{label:"Scale",run:function(pm,name,startvalue,startlabel,endvalue,endlabel){var _pm$selection=pm.selection,from=_pm$selection.from,node=(_pm$selection.to,_pm$selection.node);return node&&node.type==this?pm.tr.setNodeType(from,this,{name:name,startvalue:startvalue,startlabel:startlabel,endvalue:endvalue,endlabel:endlabel}).apply(pm.apply.scroll):(0,_utils.insertWidget)(pm,from,this.create({name:name,startvalue:startvalue,startlabel:startlabel,endvalue:endvalue,endlabel:endlabel}))},menu:{group:"question",rank:74,display:{type:"label",label:"Scale"}},params:[{name:"Name",attr:"name",label:"Short ID",type:"text",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"name")},options:{pattern:_utils.namePattern,size:10,title:_utils.nameTitle}},{label:"Start value",attr:"startvalue",type:"number","default":1,prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"startvalue")}},{name:"Start Label",attr:"startlabel",label:"Text on left",type:"text","default":"low",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"startlabel")}},{label:"End value",attr:"endvalue",type:"number","default":10,prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"endvalue")}},{name:"End Label",attr:"endlabel",label:"Text on right",type:"text","default":"high",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"endlabel")}}]}),(0,_utils.defParamsClick)(Scale,"scale:insert"),(0,_dom.insertCSS)("\n\n.widgets-scaleitem {\n display: inline-block;\n text-align: center;\n padding: 4px;\n}\n\n.widgets-scaleitem input {\n display: block;\n}\n\n.widgets-scale span {\n vertical-align: middle;\n font-weight: normal;\n}\n\n.widgets-scale div {\n display: inline-block;\n padding: 4px;\n background: #EEE;\n border-radius: 6px;\n border: 1px solid #AAA;\n}\n")},{"../../utils":60,"./question":84,"prosemirror/dist/dom":1,"prosemirror/dist/model":34}],86:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i-1&&this.waiting.splice(index,1)}},{key:"force",value:function(){for(clearTimeout(this.timeout),this.lastForce=Date.now();this.waiting.length;)for(var i=0;iMIN_FLUSH_DELAY&&this.force()}}],[{key:"get",value:function(pm){return pm.mod.centralScheduler||(pm.mod.centralScheduler=new this(pm))}}]),CentralScheduler}();exports.UpdateScheduler=function(){function UpdateScheduler(pm,events,start){var _this=this;_classCallCheck(this,UpdateScheduler),this.pm=pm,this.start=start,this.events=events.split(" "),this.onEvent=this.onEvent.bind(this),this.events.forEach(function(event){return pm.on(event,_this.onEvent)})}return _createClass(UpdateScheduler,[{key:"detach",value:function(){var _this2=this;unscheduleDOMUpdate(this.pm,this.start),this.events.forEach(function(event){return _this2.pm.off(event,_this2.onEvent)})}},{key:"onEvent",value:function(){scheduleDOMUpdate(this.pm,this.start)}},{key:"force",value:function(){if(this.pm.operation)this.onEvent();else{unscheduleDOMUpdate(this.pm,this.start);for(var run=this.start;run;run=run());}}}]),UpdateScheduler}()},{}],52:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function functionName(f){var match=/^function (\w+)/.exec(f.toString());return match&&match[1]}var _createClass=function(){function defineProperties(target,props){for(var i=0;i1?_len-1:0),_key=1;_len>_key;_key++)args[_key-1]=arguments[_key];if(arr)for(var i=0;i1?_len2-1:0),_key2=1;_len2>_key2;_key2++)args[_key2-1]=arguments[_key2];for(var i=0;i0}}},{}],54:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i-1?this.content[found+1]=value:this.content.push(key,value)}},{key:"get",value:function(key){var found=this.find(key);return-1==found?void 0:this.content[found+1]}},{key:"has",value:function(key){return this.find(key)>-1}},{key:"find",value:function(key){for(var i=0;i0);i++);array.splice(i,0,elt)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=sortedInsert},{}],57:[function(require,module,exports){!function(mod){if("object"==typeof exports&&"object"==typeof module)module.exports=mod();else{if("function"==typeof define&&define.amd)return define([],mod);(this||window).browserKeymap=mod()}}(function(){"use strict";function keyName(event){if("keypress"==event.type)return"'"+String.fromCharCode(event.charCode)+"'";var base=keyNames[event.keyCode],name=base;return null==name||event.altGraphKey?null:(event.altKey&&"Alt"!=base&&(name="Alt-"+name),event.ctrlKey&&"Ctrl"!=base&&(name="Ctrl-"+name),event.metaKey&&"Cmd"!=base&&(name="Cmd-"+name),event.shiftKey&&"Shift"!=base&&(name="Shift-"+name),name)}function isModifierKey(name){return name=/[^-]*$/.exec(name)[0],"Ctrl"==name||"Alt"==name||"Shift"==name||"Mod"==name}function normalizeKeyName(name){for(var alt,ctrl,shift,cmd,parts=name.split(/-(?!'?$)/),result=parts[parts.length-1],i=0;ii;i++)keyNames[i+48]=keyNames[i+96]=String(i);for(var i=65;90>=i;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;12>=i;i++)keyNames[i+111]=keyNames[i+63235]="F"+i;return Keymap.prototype={normalize:function(name){return this.options.multi!==!1?name.split(/ +(?!\'$)/).map(normalizeKeyName):[normalizeKeyName(name)]},addBinding:function(keyname,value){for(var keys=this.normalize(keyname),i=0;i=0;i--){var name=keys.slice(0,i).join(" "),val=this.bindings[name];if("..."==val&&!this.unusedMulti(name))break;val&&delete this.bindings[name]}},unusedMulti:function(name){for(var binding in this.bindings)if(binding.length>name&&0==binding.indexOf(name)&&" "==binding.charAt(name.length))return!1;return!0},lookup:function(key,context){return this.options.call?this.options.call(key,context):this.bindings[key]},constructor:Keymap},Keymap.keyName=keyName,Keymap.isModifierKey=isModifierKey,Keymap.normalizeKeyName=normalizeKeyName,Keymap})},{}],58:[function(require,module,exports){"use strict";var _edit=require("prosemirror/dist/edit");require("prosemirror/dist/menu/tooltipmenu"),require("prosemirror/dist/menu/menubar"),require("prosemirror/dist/inputrules/autoinput");var _menu=require("prosemirror/dist/menu/menu"),_widgets=require("./widgets"),_utils=require("./utils"),_schema=require("./schema");window.pm=new _edit.ProseMirror({place:document.querySelector("#editor"),menuBar:{"float":!0,content:[_menu.inlineGroup,[_menu.blockGroup,_menu.textblockMenu],_widgets.alignGroup,[_widgets.contentInsertMenu,_widgets.questionInsertMenu],_menu.historyGroup]},schema:_schema.widgetSchema,commands:_schema.commands,autoInput:!0,doc:document.querySelector("#content"),docFormat:"dom"});(0,_utils.defineFileHandler)(function(files){console.log(files)})},{"./schema":59,"./utils":60,"./widgets":73,"prosemirror/dist/edit":11,"prosemirror/dist/inputrules/autoinput":24,"prosemirror/dist/menu/menu":27,"prosemirror/dist/menu/menubar":28,"prosemirror/dist/menu/tooltipmenu":29}],59:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.commands=exports.widgetSchema=void 0;var _edit=require("prosemirror/dist/edit"),_dom=require("prosemirror/dist/dom"),_model=require("prosemirror/dist/model"),_widgets=require("./widgets"),_menu=require("prosemirror/dist/menu/menu"),widgetSpec=new _model.SchemaSpec({doc:_model.Doc,blockquote:_model.BlockQuote,ordered_list:_model.OrderedList,bullet_list:_model.BulletList,list_item:_model.ListItem,paragraph:_model.Paragraph,heading:_model.Heading,text:_model.Text,hard_break:_model.HardBreak,input:_widgets.Input,checkbox:_widgets.CheckBox,radiobutton:_widgets.RadioButton,select:_widgets.Select,textfield:_widgets.TextField,textarea:_widgets.TextArea,question:_widgets.Question,textbox:_widgets.TextBox,choice:_widgets.Choice,multiplechoice:_widgets.MultipleChoice,scaledisplay:_widgets.ScaleDisplay,scale:_widgets.Scale,checkitem:_widgets.CheckItem,checklist:_widgets.CheckList,shortanswer:_widgets.ShortAnswer,essay:_widgets.Essay,selection:_widgets.Selection,horizontal_rule:_model.HorizontalRule,image:_widgets.Image,inlinemath:_widgets.InlineMath,blockmath:_widgets.BlockMath,website:_widgets.Website,carryforward:_widgets.CarryForward,spreadsheet:_widgets.SpreadSheet,graph:_widgets.Graph,leftalign:_widgets.LeftAlign,centeralign:_widgets.CenterAlign,rightalign:_widgets.RightAlign},{em:_model.EmMark,strong:_model.StrongMark,link:_model.LinkMark,code:_model.CodeMark,underline:_widgets.UnderlineMark,strikethrough:_widgets.StrikeThroughMark});exports.widgetSchema=new _model.Schema(widgetSpec);_menu.textblockMenu.options.label="Format";exports.commands=_edit.CommandSet["default"].update({selectParentNode:{menu:null},lift:{menu:null},"horizontal_rule:insert":{menu:{group:"content",rank:71,display:{type:"label",label:"Horizontal Rule"}}},"code:toggle":{menu:{group:"textblock",rank:99,display:{type:"label",label:"Code"}}}});(0,_dom.insertCSS)('\n \n.ProseMirror {\n width: 800px;\n min-height: 200px;\n}\n\n.ProseMirror-menu {\n background: white;\n color: black;\n}\n\ndiv.ProseMirror-dropdown-menu {\n position: absolute;\n background: white;\n color: black;\n border-radius: 6px;\n border: 1px solid silver;\n padding: 2px 2px;\n z-index: 15;\n}\n\ndiv.ProseMirror-dropdown-menu {\n cursor: pointer;\n padding: 0 1em 0 2px;\n}\n\ndiv.ProseMirror-menubar-inner {\n background: linear-gradient(to bottom, white, #0191C8);\n}\n\ndiv.ProseMirror-menu form {\n background: linear-gradient(to bottom, white, #0191C8);\n width: 300px;\n}\n\ndiv.ProseMirror-menu form select {\n width: 100px;\n background: white;\n}\n\ndiv.ProseMirror-menu input[type = "text"] {\n background: white;\n}\n\n')},{"./widgets":73,"prosemirror/dist/dom":1,"prosemirror/dist/edit":11,"prosemirror/dist/menu/menu":27,"prosemirror/dist/model":34}],60:[function(require,module,exports){"use strict";function defParser(type,tag,cls){type.register("parseDOM",tag,{rank:25,parse:function(dom,state){return dom.classList.contains(cls)?void state.insert(type):!1}})}function getPosInParent(pm,pos,child){var i=0,parent=pm.doc.path(pos.path);return parent.forEach(function(node,start){i=node==child?start:0}),new _model.Pos(pos.path,i)}function nodeBefore(pm,pos){for(var before=void 0,cut=void 0,i=pos.path.length-1;!before&&i>=0;i--)pos.path[i]>0&&(cut=pos.shorten(i),before=pm.doc.path(cut.path).child(cut.offset-1));return{before:before,at:new _model.Pos(cut.path,cut.offset-1)}}function insertWidget(pm,pos,w){for(;;){if(0==pos.depth){pm.tr.insert(pos,w).apply(pm.apply.scroll);var side=getPosInParent(pm,pos,w),p=new _model.Pos(side.toPath(),0);return w.firstChild&&w.firstChild.isTextblock&&pm.setTextSelection(new _model.Pos(p.toPath(),0)),!0}pos=pos.shorten(null,1)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.selectedNodeAttr=exports.defParamsClick=exports.nameTitle=exports.namePattern=exports.defineFileHandler=exports.widgetParamHandler=void 0;var _params=require("./params");Object.defineProperty(exports,"widgetParamHandler",{enumerable:!0,get:function(){return _params.widgetParamHandler}}),Object.defineProperty(exports,"defineFileHandler",{enumerable:!0,get:function(){return _params.defineFileHandler}}),Object.defineProperty(exports,"namePattern",{enumerable:!0,get:function(){return _params.namePattern}}),Object.defineProperty(exports,"nameTitle",{enumerable:!0,get:function(){return _params.nameTitle}}),Object.defineProperty(exports,"defParamsClick",{enumerable:!0,get:function(){return _params.defParamsClick}}),Object.defineProperty(exports,"selectedNodeAttr",{enumerable:!0,get:function(){return _params.selectedNodeAttr}}),exports.defParser=defParser,exports.getPosInParent=getPosInParent,exports.nodeBefore=nodeBefore,exports.insertWidget=insertWidget;var _model=require("prosemirror/dist/model");require("prosemirror/dist/edit/selection")},{"./params":61,"prosemirror/dist/edit/selection":17,"prosemirror/dist/model":34}],61:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function defineFileHandler(handler){fhandler=handler}function getLastClicked(){return lastClicked}function openWidgetPrompt(wpp,options){var close=function close(){wpp.pm.off("interaction",close),dialog.parentNode&&(dialog.parentNode.removeChild(dialog),options&&options.onClose&&options.onClose())},submit=function(){var params=wpp.values();params&&(wpp.command.exec(wpp.pm,params),close())};wpp.pm.on("interaction",close);var save=(0,_dom.elt)("input",{name:"save",type:"button",value:"Save"});save.addEventListener("mousedown",function(e){submit()});var cancel=(0,_dom.elt)("input",{name:"cancel",type:"button",value:"Cancel"});cancel.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation(),close()});var buttons=(0,_dom.elt)("div",{"class":"widgetButtons"},save,cancel);wpp.form=(0,_dom.elt)("form",{"class":"widgetForm"},(0,_dom.elt)("h4",null,wpp.command.label+" Settings"),wpp.fields.map(function(f){return(0,_dom.elt)("div",null,f)}),buttons),wpp.form.addEventListener("keypress",function(e){13==e.keyCode&&(e.preventDefault(),e.stopPropagation(),save.click())});var dialog=(0,_dom.elt)("div",null,(0,_dom.elt)("div",{"class":"widgetDialog"}),wpp.form);return wpp.pm.wrapper.appendChild(dialog),{close:close}}function selectClickedNode(pm,e){var pos=(0,_dompos.selectableNodeAbove)(pm,e.target,{left:e.clientX,top:e.clientY},!0);if(!pos)return pm.sel.fastPoll();var _pm$selection=pm.selection,node=_pm$selection.node,from=_pm$selection.from;if(node&&pos.depth>=from.depth&&0==pos.shorten(from.depth).cmp(from)){if(0==from.depth)return pm.sel.fastPoll();pos=from.shorten()}pm.setNodeSelection(pos),lastClicked=e.target}function defParamsClick(type,cmdname){var spots=arguments.length<=2||void 0===arguments[2]?["topright"]:arguments[2];type.prototype.handleClick=function(pm,e,path,node){selectClickedNode(pm,e);var spotClicked=!1;if(spots.forEach(function(loc){var r=e.target.getBoundingClientRect();"all"==loc?spotClicked=!0:"topright"==loc?spotClicked=spotClicked||e.clientX>r.right-16&&e.clientYr.right-32&&e.clientY>r.bottom-32)}),spotClicked){var cmd=pm.commands[cmdname];return cmd?(cmd.exec(pm),!0):!1}}}function selectedNodeAttr(pm,type,name){var node=pm.selection.node;return node&&node.type==type?node.attrs[name]:void 0}function FileDragHover(e){e.stopPropagation(),e.preventDefault(),e.target.className="dragover"==e.type?"hover":""}function buildUploadForm(pm,field){var legend=(0,_dom.elt)("h4",null,"File Upload"),label=((0,_dom.elt)("input",{type:"hidden",id:"MAX_FILE_SIZE",name:"MAX_FILE_SIZE",value:"300000"}),(0,_dom.elt)("label",{"for":"fileselect"},"File to upload:")),fileselect=(0,_dom.elt)("input",{id:"fileselect",type:"file",name:"fileselect[]",multiple:"multiple"}),filedrag=(0,_dom.elt)("div",{id:"filedrag"},"or drop files here"),cancel=(0,_dom.elt)("input",{type:"button",value:"Cancel"});cancel.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),pm.wrapper.removeChild(form)});var saveFile=function(e){e.preventDefault(),e.stopPropagation(),FileDragHover(e);var files=e.target.files||e.dataTransfer.files;files&&(field.value=files[0].name),fhandler&&fhandler(files),pm.wrapper.removeChild(form)};fileselect.addEventListener("change",saveFile);var xhr=new XMLHttpRequest;xhr.upload&&(filedrag.addEventListener("dragover",FileDragHover),filedrag.addEventListener("dragleave",FileDragHover),filedrag.addEventListener("drop",saveFile),filedrag.style.display="block");var form=(0,_dom.elt)("form",{id:"upload",enctype:"multipart/form-data"},legend,(0,_dom.elt)("div",null,label,fileselect,filedrag),(0,_dom.elt)("div",null,cancel));pm.wrapper.appendChild(form)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0?pos.shorten():pos}function findAlignWrapper(pm,align){var _pm$selection=pm.selection,from=_pm$selection.from,to=_pm$selection.to,isLeft=(_pm$selection.node,"leftalign"==align.name),start=getTextblockPos(pm,from),parent=pm.doc.path(start.path);if(parent.type instanceof Align)return isLeft?pm.tr.lift(new _model.Pos(start.path,0),new _model.Pos(start.path,parent.size)).apply(pm.apply.scroll):pm.tr.setNodeType((0,_utils.getPosInParent)(pm,start.shorten(),parent),align,{"class":align.style}).apply(pm.apply.scroll);if(isLeft)return!1;var end=from.cmp(to)?getTextblockPos(pm,to):start;return pm.tr.wrap(start,end.move(1),align,{"class":align.style}).apply(pm.apply.scroll)}function alignApplies(pm,type){var _pm$selection2=pm.selection,from=_pm$selection2.from,isLeft=(_pm$selection2.to,_pm$selection2.node,"leftalign"==type.name),start=getTextblockPos(pm,from),parent=pm.doc.path(start.path);return!isLeft||parent.type instanceof Align?parent.type.name==type.name:!0}function defAlign(type,label,path){type.register("command","align",{run:function(pm){return findAlignWrapper(pm,this)},active:function(pm){return alignApplies(pm,this)},label:label,menu:{group:"align",rank:51,display:{type:"icon",width:8,height:8,path:path}}})}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0)return pm.tr["delete"](from,to).apply(pm.apply.scroll);var toCL=toCH.shorten(),cl=pm.doc.path(toCL.path),_nodeBefore=(0,_utils.nodeBefore)(pm,toCH),before=_nodeBefore.before;_nodeBefore.at;if(2==cl.size||before.type!=this||ch.lastChild.size>0)return!0;var tr=pm.tr["delete"](toCL,toCL.move(1)).apply();return renumber(pm,toCL),tr},keys:["Backspace(10)","Mod-Backspace(10)"]}),CheckList.register("command","insert",{label:"Check List",run:function(pm,name){var _pm$selection3=pm.selection,from=_pm$selection3.from,node=(_pm$selection3.to,_pm$selection3.node);if(node&&node.type==this){var tr=pm.tr.setNodeType(from,this,{name:name}).apply();return renumber(pm,_model.Pos.from(from.toPath().concat(from.offset),0)),tr}var choice_content=_model.Fragment.from([this.schema.nodes.checkbox.create({name:name,value:1}),this.schema.nodes.textbox.create()]),content=_model.Fragment.from([this.schema.nodes.paragraph.create(null,""),this.schema.nodes.checkitem.create({name:name,value:1},choice_content)]);return(0,_utils.insertWidget)(pm,from,this.create({name:name},content))},select:function(pm){return!0},menu:{group:"question",rank:70,display:{type:"label",label:"CheckList"}},params:[{name:"Name",attr:"name",label:"Short ID",type:"text",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"name")},options:{pattern:_utils.namePattern,size:10,title:_utils.nameTitle}}]}),(0,_utils.defParamsClick)(CheckList,"checklist:insert"),(0,_dom.insertCSS)("\n\n.ProseMirror .widgets-checkitem input {\n float: left;\n}\n\n.ProseMirror .widgets-checkitem {\n cursor: text;\n}\n\n\n")},{"../../utils":60,"./question":85,"./textbox":89,"prosemirror/dist/dom":1,"prosemirror/dist/model":34}],82:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0)return pm.tr["delete"](from,to).apply(pm.apply.scroll);var toMC=toCH.shorten(),mc=pm.doc.path(toMC.path),_nodeBefore=(0,_utils.nodeBefore)(pm,toCH),before=_nodeBefore.before;_nodeBefore.at;if(2==mc.size||before.type!=this||ch.lastChild.size>0)return!0;var tr=pm.tr["delete"](toMC,toMC.move(1)).apply();return renumber(pm,toMC),tr},keys:["Backspace(10)","Mod-Backspace(10)"]}),MultipleChoice.register("command","insert",{label:"MultipleChoice",run:function(pm,name){var _pm$selection3=pm.selection,from=_pm$selection3.from,node=(_pm$selection3.to,_pm$selection3.node);if(node&&node.type==this){var tr=pm.tr.setNodeType(from,this,{name:name}).apply();return renumber(pm,_model.Pos.from(from.toPath().concat(from.offset),0)),tr}var choice_content=_model.Fragment.from([this.schema.nodes.radiobutton.create({name:name,value:1}),this.schema.nodes.textbox.create()]),content=_model.Fragment.from([this.schema.nodes.paragraph.create(null,""),this.schema.nodes.choice.create({name:name,value:1},choice_content)]);return(0,_utils.insertWidget)(pm,from,this.create({name:name},content))},select:function(pm){return!0},menu:{group:"question",rank:70,display:{type:"label",label:"MultipleChoice"}},params:[{name:"Name",attr:"name",label:"Short ID",type:"text",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"name")},options:{pattern:_utils.namePattern,size:10,title:_utils.nameTitle}}]}),(0,_utils.defParamsClick)(MultipleChoice,"multiplechoice:insert"),(0,_dom.insertCSS)("\n\n.widgets-choice input {\n float: left;\n}\n\n.ProseMirror .widgets-choice:hover {\n cursor: text;\n}\n\n")},{"../../utils":60,"./question":85,"prosemirror/dist/dom":1,"prosemirror/dist/model":34}],85:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Question=void 0;var _model=require("prosemirror/dist/model"),_dom=require("prosemirror/dist/dom"),_utils=require("../../utils"),Question=(require("prosemirror/dist/transform"),exports.Question=function(_Block){function Question(){return _classCallCheck(this,Question),_possibleConstructorReturn(this,Object.getPrototypeOf(Question).apply(this,arguments))}return _inherits(Question,_Block),Question}(_model.Block));(0,_utils.defParser)(Question,"div","widgets-question"),Question.prototype.serializeDOM=function(node,s){return(0,_dom.elt)("div",{"class":"widgets-question widgets-edit"},s.renderAs(node,"div",node.attrs))},Question.register("command","delete",{label:"delete text from question",run:function(pm){var _pm$selection=pm.selection,from=_pm$selection.from,para=(_pm$selection.to,_pm$selection.head,pm.doc.path(from.path));if(from.offset>0||"paragraph"!=para.type.name)return!1;from=from.shorten();var parent=pm.doc.path(from.path);return parent.type instanceof Question?parent.firstChild==para:!1},keys:["Backspace(10)","Mod-Backspace(10)"]}),Question.register("command","enter",{label:"process enter",run:function(pm){var _pm$selection2=pm.selection,from=_pm$selection2.from,node=_pm$selection2.node,para=pm.doc.path(from.path);if(node&&node.type instanceof Question){var _parent=pm.doc.path(from.path);if(_parent.lastChild==node||!_parent.child(from.offset+1).isTextblock){var side=from.move(1);pm.tr.insert(side,pm.schema.defaultTextblockType().create()).apply(pm.apply.scroll),pm.setTextSelection(new _model.Pos(side.toPath(),0))}return!0}if(from.offset>0||"paragraph"!=para.type.name)return!1;var parent=pm.doc.path(from.shorten().path);return parent.type instanceof Question},keys:["Enter(10)","Mod-Enter(10)"]}),(0,_dom.insertCSS)('\n \n.widgets-question {\n counter-increment: qcnt;\n border: 1px solid #DDD;\n border-radius: 4px;\n padding: 8px;\n margin-top: 1em;\n}\n\n.widgets-question:before {\n content: "Question " counter(qcnt) ".";\n font-size: 80%;\n font-weight: bold;\n// cursor: move;\n}\n\n.ProseMirror .widgets-question p:hover {\n cursor: text;\n}\n\n')},{"../../utils":60,"prosemirror/dist/dom":1,"prosemirror/dist/model":34,"prosemirror/dist/transform":40}],86:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},_createClass=function(){function defineProperties(target,props){for(var i=0;istartVal)for(var i=startVal;endVal>=i;i++){var _name=node.attrs.name+i;para.appendChild((0,_dom.elt)("span",{"class":"widgets-scaleitem"},(0,_dom.elt)("label",{"for":_name},i.toString()),(0,_dom.elt)("input",{id:_name,name:node.attrs.name,type:"radio",value:i})))}else for(var i=startVal;i>=endVal;i--)para.appendChild((0,_dom.elt)("span",{"class":"widgets-scaleitem"},(0,_dom.elt)("label",{"for":name},i.toString()),(0,_dom.elt)("input",{id:name,name:node.attrs.name,type:"radio",value:i})));return para.appendChild((0,_dom.elt)("span",null," "+node.attrs.endlabel)),para};var Scale=exports.Scale=function(_Question){function Scale(){return _classCallCheck(this,Scale),_possibleConstructorReturn(this,Object.getPrototypeOf(Scale).apply(this,arguments))}return _inherits(Scale,_Question),_createClass(Scale,[{key:"create",value:function(attrs,content,marks){var sd=this.schema.nodes.scaledisplay.create(attrs);if(content){var nodes=content.toArray();nodes.pop(),content=_model.Fragment.fromArray(nodes.concat(sd))}else content=_model.Fragment.from([this.schema.nodes.paragraph.create(null,""),sd]);return _get(Object.getPrototypeOf(Scale.prototype),"create",this).call(this,attrs,content,marks)}},{key:"attrs",get:function(){return{name:new _model.Attribute,startvalue:new _model.Attribute({"default":"1"}),startlabel:new _model.Attribute({"default":"low"}),endvalue:new _model.Attribute({"default":"10"}),endlabel:new _model.Attribute({"default":"high"}),"class":new _model.Attribute({"default":"widgets-scale"})}}}],[{key:"contains",get:function(){return"text"}}]),Scale}(_question.Question);(0,_utils.defParser)(Scale,"div","widgets-scale"),Scale.register("command","insert",{label:"Scale",run:function(pm,name,startvalue,startlabel,endvalue,endlabel){var _pm$selection=pm.selection,from=_pm$selection.from,node=(_pm$selection.to,_pm$selection.node);return node&&node.type==this?pm.tr.setNodeType(from,this,{name:name,startvalue:startvalue,startlabel:startlabel,endvalue:endvalue,endlabel:endlabel}).apply(pm.apply.scroll):(0,_utils.insertWidget)(pm,from,this.create({name:name,startvalue:startvalue,startlabel:startlabel,endvalue:endvalue,endlabel:endlabel}))},menu:{group:"question",rank:74,display:{type:"label",label:"Scale"}},params:[{name:"Name",attr:"name",label:"Short ID",type:"text",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"name")},options:{pattern:_utils.namePattern,size:10,title:_utils.nameTitle}},{label:"Start value",attr:"startvalue",type:"number","default":1,prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"startvalue")}},{name:"Start Label",attr:"startlabel",label:"Text on left",type:"text","default":"low",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"startlabel")}},{label:"End value",attr:"endvalue",type:"number","default":10,prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"endvalue")}},{name:"End Label",attr:"endlabel",label:"Text on right",type:"text","default":"high",prefill:function(pm){return(0,_utils.selectedNodeAttr)(pm,this,"endlabel")}}]}),(0,_utils.defParamsClick)(Scale,"scale:insert"),(0,_dom.insertCSS)("\n\n.widgets-scaleitem {\n display: inline-block;\n text-align: center;\n padding: 4px;\n}\n\n.widgets-scaleitem input {\n display: block;\n}\n\n.widgets-scale span {\n vertical-align: middle;\n font-weight: normal;\n}\n\n.widgets-scale div {\n display: inline-block;\n padding: 4px;\n background: #EEE;\n border-radius: 6px;\n border: 1px solid #AAA;\n}\n")},{"../../utils":60,"./question":85,"prosemirror/dist/dom":1,"prosemirror/dist/model":34}],87:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i