tiptap-extensions
Version:
Extensions for tiptap
14 lines (11 loc) • 35.6 kB
JavaScript
/*!
* tiptap-extensions v1.32.1
* (c) 2020 überdosis GbR (limited liability)
* @license MIT
*/
/*!
* tiptap-extensions v1.32.1
* (c) 2020 überdosis GbR (limited liability)
* @license MIT
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("tiptap"),require("tiptap-commands"),require("lowlight/lib/core"),require("prosemirror-view"),require("prosemirror-utils"),require("prosemirror-state"),require("regenerator-runtime/runtime"),require("prosemirror-tables"),require("tiptap-utils"),require("prosemirror-transform"),require("prosemirror-collab"),require("prosemirror-history")):"function"==typeof define&&define.amd?define(["exports","tiptap","tiptap-commands","lowlight/lib/core","prosemirror-view","prosemirror-utils","prosemirror-state","regenerator-runtime/runtime","prosemirror-tables","tiptap-utils","prosemirror-transform","prosemirror-collab","prosemirror-history"],e):e((t=t||self).tiptapExtensions={},t.tiptap,t.tiptapCommands,t.low,t.prosemirrorView,t.prosemirrorUtils,t.prosemirrorState,null,t.prosemirrorTables,t.tiptapUtils,t.prosemirrorTransform,t.prosemirrorCollab,t.prosemirrorHistory)}(this,(function(t,e,n,r,o,i,a,u,c,s,l,f,p){"use strict";function d(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function y(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,e,n){return e&&y(t.prototype,e),n&&y(t,n),t}function m(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function k(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?v(Object(n),!0).forEach((function(e){m(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function b(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&O(t,e)}function w(t){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function O(t,e){return(O=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function x(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function D(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=w(t);if(e){var o=w(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return x(this,n)}}function M(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(t){return function(t){if(Array.isArray(t))return R(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return R(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(t,e):void 0}}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var T=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(){return n.toggleWrap(e,r.nodes.paragraph)}}},{key:"keys",value:function(t){var e=t.type;return{"Ctrl->":n.toggleWrap(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.wrappingInputRule(/^\s*>\s$/,e)]}},{key:"name",get:function(){return"blockquote"}},{key:"schema",get:function(){return{content:"block*",group:"block",defining:!0,draggable:!1,parseDOM:[{tag:"blockquote"}],toDOM:function(){return["blockquote",0]}}}}]),r}(e.Node),_=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(){return n.toggleList(e,r.nodes.list_item)}}},{key:"keys",value:function(t){var e=t.type,r=t.schema;return{"Shift-Ctrl-8":n.toggleList(e,r.nodes.list_item)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.wrappingInputRule(/^\s*([-+*])\s$/,e)]}},{key:"name",get:function(){return"bullet_list"}},{key:"schema",get:function(){return{content:"list_item+",group:"block",parseDOM:[{tag:"ul"}],toDOM:function(){return["ul",0]}}}}]),r}(e.Node),A=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(){return n.toggleBlockType(e,r.nodes.paragraph)}}},{key:"keys",value:function(t){var e=t.type;return{"Shift-Ctrl-\\":n.setBlockType(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.textblockTypeInputRule(/^```$/,e)]}},{key:"name",get:function(){return"code_block"}},{key:"schema",get:function(){return{content:"text*",marks:"",group:"block",code:!0,defining:!0,draggable:!1,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return["pre",["code",0]]}}}}]),r}(e.Node);function E(t){var e=t.doc,n=t.name,a=[],u=i.findBlockNodes(e).filter((function(t){return t.node.type.name===n}));return u.forEach((function(t){var e=t.pos+1;(function t(e){return e.reduce((function(e,n){return e.concat(Array.isArray(n)?t(n):n)}),[])})(function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.map((function(e){var r=[].concat(C(n),C(e.properties?e.properties.className:[]));return e.children?t(e.children,r):{text:e.value,classes:r}}))}(r.highlightAuto(t.node.textContent).value)).map((function(t){var n=e,r=n+t.text.length;return e=r,k(k({},t),{},{from:n,to:r})})).forEach((function(t){var e=o.Decoration.inline(t.from,t.to,{class:t.classes.join(" ")});a.push(e)}))})),o.DecorationSet.create(e,a)}function I(t){var n=t.name;return new e.Plugin({name:new e.PluginKey("highlight"),state:{init:function(t,e){return E({doc:e.doc,name:n})},apply:function(t,e,r,o){var a=r.selection.$head.parent.type.name,u=o.selection.$head.parent.type.name,c=i.findBlockNodes(r.doc).filter((function(t){return t.node.type.name===n})),s=i.findBlockNodes(o.doc).filter((function(t){return t.node.type.name===n}));return t.docChanged&&([a,u].includes(n)||s.length!==c.length)?E({doc:t.doc,name:n}):e.map(t.mapping,t.doc)}},props:{decorations:function(t){return this.getState(t)}}})}var N=function(t){b(o,t);var e=D(o);function o(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};g(this,o),t=e.call(this,n);try{Object.entries(t.options.languages).forEach((function(t){var e=M(t,2),n=e[0],o=e[1];r.registerLanguage(n,o)}))}catch(t){throw new Error("Invalid syntax highlight definitions: define at least one highlight.js language mapping")}return t}return h(o,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(){return n.toggleBlockType(e,r.nodes.paragraph)}}},{key:"keys",value:function(t){var e=t.type;return{"Shift-Ctrl-\\":n.setBlockType(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.textblockTypeInputRule(/^```$/,e)]}},{key:"name",get:function(){return"code_block"}},{key:"defaultOptions",get:function(){return{languages:{}}}},{key:"schema",get:function(){return{content:"text*",marks:"",group:"block",code:!0,defining:!0,draggable:!1,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return["pre",["code",0]]}}}},{key:"plugins",get:function(){return[I({name:this.name})]}}]),o}(e.Node),P=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type,r=n.chainCommands(n.exitCode,(function(t,n){return n(t.tr.replaceSelectionWith(e.create()).scrollIntoView()),!0}));return{"Mod-Enter":r,"Shift-Enter":r}}},{key:"name",get:function(){return"hard_break"}},{key:"schema",get:function(){return{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}}}]),r}(e.Node),j=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(t){return n.toggleBlockType(e,r.nodes.paragraph,t)}}},{key:"keys",value:function(t){var e=t.type;return this.options.levels.reduce((function(t,r){return k(k({},t),m({},"Shift-Ctrl-".concat(r),n.setBlockType(e,{level:r})))}),{})}},{key:"inputRules",value:function(t){var e=t.type;return this.options.levels.map((function(t){return n.textblockTypeInputRule(new RegExp("^(#{1,".concat(t,"})\\s$")),e,(function(){return{level:t}}))}))}},{key:"name",get:function(){return"heading"}},{key:"defaultOptions",get:function(){return{levels:[1,2,3,4,5,6]}}},{key:"schema",get:function(){return{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,draggable:!1,parseDOM:this.options.levels.map((function(t){return{tag:"h".concat(t),attrs:{level:t}}})),toDOM:function(t){return["h".concat(t.attrs.level),0]}}}}]),r}(e.Node),q=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type;return function(){return function(t,n){return n(t.tr.replaceSelectionWith(e.create()))}}}},{key:"inputRules",value:function(t){var e=t.type;return[n.nodeInputRule(/^(?:---|___\s|\*\*\*\s)$/,e)]}},{key:"name",get:function(){return"horizontal_rule"}},{key:"schema",get:function(){return{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return["hr"]}}}}]),r}(e.Node),$=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,L=function(t){b(o,t);var r=D(o);function o(){return g(this,o),r.apply(this,arguments)}return h(o,[{key:"commands",value:function(t){var e=t.type;return function(t){return function(n,r){var o=n.selection,i=o.$cursor?o.$cursor.pos:o.$to.pos,a=e.create(t);r(n.tr.insert(i,a))}}}},{key:"inputRules",value:function(t){var e=t.type;return[n.nodeInputRule($,e,(function(t){var e=M(t,4),n=e[1];return{src:e[2],alt:n,title:e[3]}}))]}},{key:"name",get:function(){return"image"}},{key:"schema",get:function(){return{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){return["img",t.attrs]}}}},{key:"plugins",get:function(){return[new e.Plugin({props:{handleDOMEvents:{drop:function(t,e){if(e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){var n=Array.from(e.dataTransfer.files).filter((function(t){return/image/i.test(t.type)}));if(0!==n.length){e.preventDefault();var r=t.state.schema,o=t.posAtCoords({left:e.clientX,top:e.clientY});n.forEach((function(e){var n=new FileReader;n.onload=function(e){var n=r.nodes.image.create({src:e.target.result}),i=t.state.tr.insert(o.pos,n);t.dispatch(i)},n.readAsDataURL(e)}))}}}}}})]}}]),o}(e.Node),B=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{Enter:n.splitListItem(e),Tab:n.sinkListItem(e),"Shift-Tab":n.liftListItem(e)}}},{key:"name",get:function(){return"list_item"}},{key:"schema",get:function(){return{content:"paragraph block*",defining:!0,draggable:!1,parseDOM:[{tag:"li"}],toDOM:function(){return["li",0]}}}}]),r}(e.Node);function H(t){var e=t.matcher,r=void 0===e?{char:"@",allowSpaces:!1,startOfLine:!1}:e,i=t.appendText,u=void 0===i?null:i,c=t.suggestionClass,s=void 0===c?"suggestion":c,l=t.command,f=void 0===l?function(){return!1}:l,p=t.items,g=void 0===p?[]:p,y=t.onEnter,h=void 0===y?function(){return!1}:y,m=t.onChange,v=void 0===m?function(){return!1}:m,b=t.onExit,w=void 0===b?function(){return!1}:b,O=t.onKeyDown,x=void 0===O?function(){return!1}:O,D=t.onFilter,M=void 0===D?function(t,e){return e?t.filter((function(t){return JSON.stringify(t).toLowerCase().includes(e.toLowerCase())})):t}:D;return new a.Plugin({key:new a.PluginKey("suggestions"),view:function(){var t,e,r=this;return{update:(t=regeneratorRuntime.mark((function t(e,o){var i,a,c,s,l,p,d,y,m,k,b,O,x;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=r.key.getState(o),a=r.key.getState(e.state),c=i.active&&a.active&&i.range.from!==a.range.from,s=!i.active&&a.active,l=i.active&&!a.active,p=!s&&!l&&i.query!==a.query,y=p&&!c,m=l||c,(d=s||c)||y||m){t.next=11;break}return t.abrupt("return");case 11:if(k=m?i:a,b=document.querySelector('[data-decoration-id="'.concat(k.decorationId,'"]')),O=b?{getBoundingClientRect:function(){return b.getBoundingClientRect()},clientWidth:b.clientWidth,clientHeight:b.clientHeight}:null,t.t0=e,t.t1=k.range,t.t2=k.query,t.t3=k.text,t.t4=b,t.t5=O,!y&&!d){t.next=36;break}if(t.t7=M,!Array.isArray(g)){t.next=26;break}t.t8=g,t.next=29;break;case 26:return t.next=28,g();case 28:t.t8=t.sent;case 29:return t.t9=t.t8,t.t10=k.query,t.next=33,(0,t.t7)(t.t9,t.t10);case 33:t.t6=t.sent,t.next=37;break;case 36:t.t6=[];case 37:t.t11=t.t6,t.t12=function(t){var r=t.range,o=t.attrs;f({range:r,attrs:o,schema:e.state.schema})(e.state,e.dispatch,e),u&&n.insertText(u)(e.state,e.dispatch,e)},x={view:t.t0,range:t.t1,query:t.t2,text:t.t3,decorationNode:t.t4,virtualNode:t.t5,items:t.t11,command:t.t12},m&&w(x),y&&v(x),d&&h(x);case 43:case"end":return t.stop()}}),t)})),e=function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){d(i,r,o,a,u,"next",t)}function u(t){d(i,r,o,a,u,"throw",t)}a(void 0)}))},function(t,n){return e.apply(this,arguments)})}},state:{init:function(){return{active:!1,range:{},query:null,text:null}},apply:function(t,e){var n,o,i,a,u,c,s,l=t.selection,f=k({},e);if(l.from===l.to){(l.from<e.range.from||l.from>e.range.to)&&(f.active=!1);var p=l.$from,d=(o=(n=r).char,i=void 0===o?"@":o,a=n.allowSpaces,u=void 0!==a&&a,c=n.startOfLine,s=void 0!==c&&c,function(t){if(t.depth<=0)return!1;for(var e,n="\\".concat(i),r=new RegExp("\\s".concat(n,"$")),o=s?"^":"",a=u?new RegExp("".concat(o).concat(n,".*?(?=\\s").concat(n,"|$)"),"gm"):new RegExp("".concat(o,"(?:^)?").concat(n,"[^\\s").concat(n,"]*"),"gm"),c=t.before(),l=t.end(),f=t.doc.textBetween(c,l,"\0","\0"),p=a.exec(f);null!==p;){var d=p.input.slice(Math.max(0,p.index-1),p.index);if(/^[\s\0]?$/.test(d)){var g=p.index+t.start(),y=g+p[0].length;u&&r.test(f.slice(y-1,y+1))&&(p[0]+=" ",y+=1),g<t.pos&&y>=t.pos&&(e={range:{from:g,to:y},query:p[0].slice(i.length),text:p[0]})}p=a.exec(f)}return e})(p),g=(Math.random()+1).toString(36).substr(2,5);d?(f.active=!0,f.decorationId=e.decorationId?e.decorationId:g,f.range=d.range,f.query=d.query,f.text=d.text):f.active=!1}else f.active=!1;return f.active||(f.decorationId=null,f.range={},f.query=null,f.text=null),f}},props:{handleKeyDown:function(t,e){var n=this.getState(t.state),r=n.active,o=n.range;return!!r&&x({view:t,event:e,range:o})},decorations:function(t){var e=this.getState(t),n=e.active,r=e.range,i=e.decorationId;return n?o.DecorationSet.create(t.doc,[o.Decoration.inline(r.from,r.to,{nodeName:"span",class:s,"data-decoration-id":i})]):null}}})}var z=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=this,r=t.schema;return function(t){return n.replaceText(null,r.nodes[e.name],t)}}},{key:"name",get:function(){return"mention"}},{key:"defaultOptions",get:function(){return{matcher:{char:"@",allowSpaces:!1,startOfLine:!1},mentionClass:"mention",suggestionClass:"mention-suggestion"}}},{key:"schema",get:function(){var t=this;return{attrs:{id:{},label:{}},group:"inline",inline:!0,selectable:!1,atom:!0,toDOM:function(e){return["span",{class:t.options.mentionClass,"data-mention-id":e.attrs.id},"".concat(t.options.matcher.char).concat(e.attrs.label)]},parseDOM:[{tag:"span[data-mention-id]",getAttrs:function(e){return{id:e.getAttribute("data-mention-id"),label:e.innerText.split(t.options.matcher.char).join("")}}}]}}},{key:"plugins",get:function(){var t=this;return[H({command:function(e){var r=e.range,o=e.attrs,i=e.schema;return n.replaceText(r,i.nodes[t.name],o)},appendText:" ",matcher:this.options.matcher,items:this.options.items,onEnter:this.options.onEnter,onChange:this.options.onChange,onExit:this.options.onExit,onKeyDown:this.options.onKeyDown,onFilter:this.options.onFilter,suggestionClass:this.options.suggestionClass})]}}]),r}(e.Node),W=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(){return n.toggleList(e,r.nodes.list_item)}}},{key:"keys",value:function(t){var e=t.type,r=t.schema;return{"Shift-Ctrl-9":n.toggleList(e,r.nodes.list_item)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.wrappingInputRule(/^(\d+)\.\s$/,e,(function(t){return{order:+t[1]}}),(function(t,e){return e.childCount+e.attrs.order===+t[1]}))]}},{key:"name",get:function(){return"ordered_list"}},{key:"schema",get:function(){return{attrs:{order:{default:1}},content:"list_item+",group:"block",parseDOM:[{tag:"ol",getAttrs:function(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM:function(t){return 1===t.attrs.order?["ol",0]:["ol",{start:t.attrs.order},0]}}}}]),r}(e.Node),K=c.tableNodes({tableGroup:"block",cellContent:"block+",cellAttributes:{background:{default:null,getFromDOM:function(t){return t.style.backgroundColor||null},setDOMAttr:function(t,e){if(t){var n={style:"".concat(e.style||"","background-color: ").concat(t,";")};Object.assign(e,n)}}}}}),V=function(t){b(n,t);var e=D(n);function n(){return g(this,n),e.apply(this,arguments)}return h(n,[{key:"commands",value:function(t){var e=t.schema;return{createTable:function(t){var n=t.rowsCount,r=t.colsCount,o=t.withHeaderRow;return function(t,u){var c=t.tr.selection.anchor+1,s=i.createTable(e,n,r,o),l=t.tr.replaceSelectionWith(s).scrollIntoView(),f=l.doc.resolve(c);l.setSelection(a.TextSelection.near(f)),u(l)}},addColumnBefore:function(){return c.addColumnBefore},addColumnAfter:function(){return c.addColumnAfter},deleteColumn:function(){return c.deleteColumn},addRowBefore:function(){return c.addRowBefore},addRowAfter:function(){return c.addRowAfter},deleteRow:function(){return c.deleteRow},deleteTable:function(){return c.deleteTable},toggleCellMerge:function(){return function(t,e){c.mergeCells(t,e)||c.splitCell(t,e)}},mergeCells:function(){return c.mergeCells},splitCell:function(){return c.splitCell},toggleHeaderColumn:function(){return c.toggleHeaderColumn},toggleHeaderRow:function(){return c.toggleHeaderRow},toggleHeaderCell:function(){return c.toggleHeaderCell},setCellAttr:function(){return c.setCellAttr},fixTables:function(){return c.fixTables}}}},{key:"keys",value:function(){return{Tab:c.goToNextCell(1),"Shift-Tab":c.goToNextCell(-1)}}},{key:"name",get:function(){return"table"}},{key:"defaultOptions",get:function(){return{resizable:!1}}},{key:"schema",get:function(){return K.table}},{key:"plugins",get:function(){return[].concat(C(this.options.resizable?[c.columnResizing()]:[]),[c.tableEditing()])}}]),n}(e.Node),F=function(t){b(n,t);var e=D(n);function n(){return g(this,n),e.apply(this,arguments)}return h(n,[{key:"name",get:function(){return"table_header"}},{key:"schema",get:function(){return K.table_header}}]),n}(e.Node),U=function(t){b(n,t);var e=D(n);function n(){return g(this,n),e.apply(this,arguments)}return h(n,[{key:"name",get:function(){return"table_cell"}},{key:"schema",get:function(){return K.table_cell}}]),n}(e.Node),G=function(t){b(n,t);var e=D(n);function n(){return g(this,n),e.apply(this,arguments)}return h(n,[{key:"name",get:function(){return"table_row"}},{key:"schema",get:function(){return K.table_row}}]),n}(e.Node),J=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{Enter:n.splitToDefaultListItem(e),Tab:this.options.nested?n.sinkListItem(e):function(){},"Shift-Tab":n.liftListItem(e)}}},{key:"name",get:function(){return"todo_item"}},{key:"defaultOptions",get:function(){return{nested:!1}}},{key:"view",get:function(){return{props:["node","updateAttrs","view"],methods:{onChange:function(){this.updateAttrs({done:!this.node.attrs.done})}},template:'\n <li :data-type="node.type.name" :data-done="node.attrs.done.toString()" data-drag-handle>\n <span class="todo-checkbox" contenteditable="false" @click="onChange"></span>\n <div class="todo-content" ref="content" :contenteditable="view.editable.toString()"></div>\n </li>\n '}}},{key:"schema",get:function(){var t=this;return{attrs:{done:{default:!1}},draggable:!0,content:this.options.nested?"(paragraph|todo_list)+":"paragraph+",toDOM:function(e){var n=e.attrs.done;return["li",{"data-type":t.name,"data-done":n.toString()},["span",{class:"todo-checkbox",contenteditable:"false"}],["div",{class:"todo-content"},0]]},parseDOM:[{priority:51,tag:'[data-type="'.concat(this.name,'"]'),getAttrs:function(t){return{done:"true"===t.getAttribute("data-done")}}}]}}}]),r}(e.Node),Z=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"commands",value:function(t){var e=t.type,r=t.schema;return function(){return n.toggleList(e,r.nodes.todo_item)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.wrappingInputRule(/^\s*(\[ \])\s$/,e)]}},{key:"name",get:function(){return"todo_list"}},{key:"schema",get:function(){var t=this;return{group:"block",content:"todo_item+",toDOM:function(){return["ul",{"data-type":t.name},0]},parseDOM:[{priority:51,tag:'[data-type="'.concat(this.name,'"]')}]}}}]),r}(e.Node),X=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{"Mod-b":n.toggleMark(e)}}},{key:"commands",value:function(t){var e=t.type;return function(){return n.toggleMark(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.markInputRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/,e)]}},{key:"pasteRules",value:function(t){var e=t.type;return[n.markPasteRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)/g,e)]}},{key:"name",get:function(){return"bold"}},{key:"schema",get:function(){return{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!==t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return["strong",0]}}}}]),r}(e.Mark),Y=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{"Mod-`":n.toggleMark(e)}}},{key:"commands",value:function(t){var e=t.type;return function(){return n.toggleMark(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.markInputRule(/(?:`)([^`]+)(?:`)$/,e)]}},{key:"pasteRules",value:function(t){var e=t.type;return[n.markPasteRule(/(?:`)([^`]+)(?:`)/g,e)]}},{key:"name",get:function(){return"code"}},{key:"schema",get:function(){return{excludes:"_",parseDOM:[{tag:"code"}],toDOM:function(){return["code",0]}}}}]),r}(e.Mark),Q=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{"Mod-i":n.toggleMark(e)}}},{key:"commands",value:function(t){var e=t.type;return function(){return n.toggleMark(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.markInputRule(/(?:^|[^_])(_([^_]+)_)$/,e),n.markInputRule(/(?:^|[^*])(\*([^*]+)\*)$/,e)]}},{key:"pasteRules",value:function(t){var e=t.type;return[n.markPasteRule(/_([^_]+)_/g,e),n.markPasteRule(/\*([^*]+)\*/g,e)]}},{key:"name",get:function(){return"italic"}},{key:"schema",get:function(){return{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:function(){return["em",0]}}}}]),r}(e.Mark),tt=function(t){b(o,t);var r=D(o);function o(){return g(this,o),r.apply(this,arguments)}return h(o,[{key:"commands",value:function(t){var e=t.type;return function(t){return t.href?n.updateMark(e,t):n.removeMark(e)}}},{key:"pasteRules",value:function(t){var e=t.type;return[n.pasteRule(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/gi,e,(function(t){return{href:t}}))]}},{key:"name",get:function(){return"link"}},{key:"defaultOptions",get:function(){return{openOnClick:!0,target:null}}},{key:"schema",get:function(){var t=this;return{attrs:{href:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),target:t.getAttribute("target")}}}],toDOM:function(e){return["a",k(k({},e.attrs),{},{rel:"noopener noreferrer nofollow",target:t.options.target}),0]}}}},{key:"plugins",get:function(){return this.options.openOnClick?[new e.Plugin({props:{handleClick:function(t,e,n){var r=t.state.schema,o=s.getMarkAttrs(t.state,r.marks.link);o.href&&n.target instanceof HTMLAnchorElement&&(n.stopPropagation(),window.open(o.href,o.target))}}})]:[]}}]),o}(e.Mark),et=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{"Mod-d":n.toggleMark(e)}}},{key:"commands",value:function(t){var e=t.type;return function(){return n.toggleMark(e)}}},{key:"inputRules",value:function(t){var e=t.type;return[n.markInputRule(/~([^~]+)~$/,e)]}},{key:"pasteRules",value:function(t){var e=t.type;return[n.markPasteRule(/~([^~]+)~/g,e)]}},{key:"name",get:function(){return"strike"}},{key:"schema",get:function(){return{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",getAttrs:function(t){return"line-through"===t}}],toDOM:function(){return["s",0]}}}}]),r}(e.Mark),nt=function(t){b(r,t);var e=D(r);function r(){return g(this,r),e.apply(this,arguments)}return h(r,[{key:"keys",value:function(t){var e=t.type;return{"Mod-u":n.toggleMark(e)}}},{key:"commands",value:function(t){var e=t.type;return function(){return n.toggleMark(e)}}},{key:"name",get:function(){return"underline"}},{key:"schema",get:function(){return{parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:function(t){return"underline"===t}}],toDOM:function(){return["u",0]}}}}]),r}(e.Mark),rt=function(t){b(n,t);var e=D(n);function n(){return g(this,n),e.apply(this,arguments)}return h(n,[{key:"init",value:function(){var t=this;this.getSendableSteps=this.debounce((function(e){var n=f.sendableSteps(e);n&&t.options.onSendable({editor:t.editor,sendable:{version:n.version,steps:n.steps.map((function(t){return t.toJSON()})),clientID:n.clientID}})}),this.options.debounce),this.editor.on("transaction",(function(e){var n=e.state;t.getSendableSteps(n)}))}},{key:"debounce",value:function(t,e){var n;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];n&&clearTimeout(n),n=setTimeout((function(){t.apply(void 0,o),n=null}),e)}}},{key:"name",get:function(){return"collaboration"}},{key:"defaultOptions",get:function(){var t=this;return{version:0,clientID:Math.floor(4294967295*Math.random()),debounce:250,onSendable:function(){},update:function(e){var n=e.steps,r=e.version,o=t.editor,i=o.state,a=o.view,u=o.schema;f.getVersion(i)>r||a.dispatch(f.receiveTransaction(i,n.map((function(t){return l.Step.fromJSON(u,t.step)})),n.map((function(t){return t.clientID}))))}}}},{key:"plugins",get:function(){return[f.collab({version:this.options.version,clientID:this.options.clientID})]}}]),n}(e.Extension),ot=function(t){b(r,t);var n=D(r);function r(){return g(this,r),n.apply(this,arguments)}return h(r,[{key:"name",get:function(){return"focus"}},{key:"defaultOptions",get:function(){return{className:"has-focus",nested:!1}}},{key:"plugins",get:function(){var t=this;return[new e.Plugin({props:{decorations:function(e){var n=e.doc,r=e.plugins,i=e.selection,a=r.find((function(t){return t.key.startsWith("editable$")})).props.editable()&&t.options.className,u=t.editor.focused,c=i.anchor,s=[];return!(!a||!u)&&(n.descendants((function(e,n){if(c>=n&&c<=n+e.nodeSize&&!e.isText){var r=o.Decoration.node(n,n+e.nodeSize,{class:t.options.className});s.push(r)}return t.options.nested})),o.DecorationSet.create(n,s))}}})]}}]),r}(e.Extension),it=function(t){b(n,t);var e=D(n);function n(){return g(this,n),e.apply(this,arguments)}return h(n,[{key:"keys",value:function(){return{"Mod-z":p.undo,"Mod-y":p.redo,"Shift-Mod-z":p.redo,"Mod-\u044f":p.undo,"Shift-Mod-\u044f":p.redo}}},{key:"commands",value:function(){return{undo:function(){return p.undo},redo:function(){return p.redo},undoDepth:function(){return p.undoDepth},redoDepth:function(){return p.redoDepth}}}},{key:"name",get:function(){return"history"}},{key:"defaultOptions",get:function(){return{depth:"",newGroupDelay:""}}},{key:"plugins",get:function(){return[p.history({depth:this.options.depth,newGroupDelay:this.options.newGroupDelay})]}}]),n}(e.Extension),at=function(t){b(r,t);var n=D(r);function r(){return g(this,r),n.apply(this,arguments)}return h(r,[{key:"name",get:function(){return"placeholder"}},{key:"defaultOptions",get:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",emptyNodeText:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0}}},{key:"plugins",get:function(){var t=this;return[new e.Plugin({props:{decorations:function(e){var n=e.doc,r=e.plugins,i=e.selection,a=r.find((function(t){return t.key.startsWith("editable$")})).props.editable()||!t.options.showOnlyWhenEditable,u=i.anchor,c=[],s=0===n.textContent.length;return!!a&&(n.descendants((function(e,n){var r=u>=n&&u<=n+e.nodeSize,i=0===e.content.size;if((r||!t.options.showOnlyCurrent)&&i){var a=[t.options.emptyNodeClass];s&&a.push(t.options.emptyEditorClass);var l=o.Decoration.node(n,n+e.nodeSize,{class:a.join(" "),"data-empty-text":"function"==typeof t.options.emptyNodeText?t.options.emptyNodeText(e):t.options.emptyNodeText});c.push(l)}return!1})),o.DecorationSet.create(n,c))}}})]}}]),r}(e.Extension),ut=function(t){b(r,t);var n=D(r);function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,r),(t=n.call(this,e)).results=[],t.searchTerm=null,t._updating=!1,t}return h(r,[{key:"commands",value:function(){var t=this;return{find:function(e){return t.find(e)},replace:function(e){return t.replace(e)},replaceAll:function(e){return t.replaceAll(e)},clearSearch:function(){return t.clear()}}}},{key:"_search",value:function(t){var e=this;this.results=[];var n=[],r=0;this.searchTerm&&(t.descendants((function(t,e){t.isText?n[r]?n[r]={text:n[r].text+t.text,pos:n[r].pos}:n[r]={text:t.text,pos:e}:r+=1})),n.forEach((function(t){for(var n,r=t.text,o=t.pos,i=e.findRegExp;(n=i.exec(r))&&""!==n[0];)e.results.push({from:o+n.index,to:o+n.index+n[0].length})})))}},{key:"replace",value:function(t){var e=this;return function(n,r){if(e.results[0]){var o=e.results[0],i=o.from,a=o.to;r(n.tr.insertText(t,i,a)),e.editor.commands.find(e.searchTerm)}}}},{key:"rebaseNextResult",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=e+1;if(!this.results[r])return null;var o=this.results[e],i=o.from,a=o.to,u=a-i-t.length+n,c=this.results[r],s=c.from,l=c.to;return this.results[r]={to:l-u,from:s-u},u}},{key:"replaceAll",value:function(t){var e=this;return function(n,r){var o,i=n.tr;e.results.length&&(e.results.forEach((function(n,r){var a=n.from,u=n.to;i.insertText(t,a,u),o=e.rebaseNextResult(t,r,o)})),r(i),e.editor.commands.find(e.searchTerm))}}},{key:"find",value:function(t){var e=this;return function(n,r){e.searchTerm=e.options.disableRegex?t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"):t,e.updateView(n,r)}}},{key:"clear",value:function(){var t=this;return function(e,n){t.searchTerm=null,t.updateView(e,n)}}},{key:"updateView",value:function(t,e){var n=t.tr;this._updating=!0,e(n),this._updating=!1}},{key:"createDeco",value:function(t){return this._search(t),this.decorations?o.DecorationSet.create(t,this.decorations):[]}},{key:"name",get:function(){return"search"}},{key:"defaultOptions",get:function(){return{autoSelectNext:!0,findClass:"find",searching:!1,caseSensitive:!1,disableRegex:!0,alwaysSearch:!1}}},{key:"findRegExp",get:function(){return RegExp(this.searchTerm,this.options.caseSensitive?"gu":"gui")}},{key:"decorations",get:function(){var t=this;return this.results.map((function(e){return o.Decoration.inline(e.from,e.to,{class:t.options.findClass})}))}},{key:"plugins",get:function(){var t=this;return[new e.Plugin({state:{init:function(){return o.DecorationSet.empty},apply:function(e,n){return t._updating||t.options.searching||e.docChanged&&t.options.alwaysSearch?t.createDeco(e.doc):e.docChanged?n.map(e.mapping,e.doc):n}},props:{decorations:function(t){return this.getState(t)}}})]}}]),r}(e.Extension),ct=function(t){b(r,t);var n=D(r);function r(){return g(this,r),n.apply(this,arguments)}return h(r,[{key:"name",get:function(){return"trailing_node"}},{key:"defaultOptions",get:function(){return{node:"paragraph",notAfter:["paragraph"]}}},{key:"plugins",get:function(){var t=this,n=new e.PluginKey(this.name),r=Object.entries(this.editor.schema.nodes).map((function(t){return M(t,2)[1]})).filter((function(e){return t.options.notAfter.includes(e.name)}));return[new e.Plugin({key:n,view:function(){return{update:function(e){var r=e.state;if(n.getState(r)){var o=r.doc,i=r.schema,a=r.tr,u=i.nodes[t.options.node],c=a.insert(o.content.size,u.create());e.dispatch(c)}}}},state:{init:function(t,e){var n=e.tr.doc.lastChild;return!s.nodeEqualsType({node:n,types:r})},apply:function(t,e){if(!t.docChanged)return e;var n=t.doc.lastChild;return!s.nodeEqualsType({node:n,types:r})}}})]}}]),r}(e.Extension);t.Blockquote=T,t.Bold=X,t.BulletList=_,t.Code=Y,t.CodeBlock=A,t.CodeBlockHighlight=N,t.Collaboration=rt,t.Focus=ot,t.HardBreak=P,t.Heading=j,t.Highlight=I,t.History=it,t.HorizontalRule=q,t.Image=L,t.Italic=Q,t.Link=tt,t.ListItem=B,t.Mention=z,t.OrderedList=W,t.Placeholder=at,t.Search=ut,t.Strike=et,t.Suggestions=H,t.Table=V,t.TableCell=U,t.TableHeader=F,t.TableRow=G,t.TodoItem=J,t.TodoList=Z,t.TrailingNode=ct,t.Underline=nt,Object.defineProperty(t,"__esModule",{value:!0})}));