This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
1 lines (1 loc) · 7.04 KB
/
index.js
1
var j=Object.defineProperty,z=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var b=(u,o,d)=>o in u?j(u,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):u[o]=d,g=(u,o)=>{for(var d in o||(o={}))F.call(o,d)&&b(u,d,o[d]);if(v)for(var d of v(o))H.call(o,d)&&b(u,d,o[d]);return u},f=(u,o)=>z(u,W(o));(function(){"use strict";class u{constructor(t={}){this.options=g(g({},this.defaults),t)}init(){return null}bindEditor(t=null){this.editor=t}get name(){return null}get type(){return"extension"}get defaults(){return{}}plugins(){return[]}inputRules(){return[]}pasteRules(){return[]}keys(){return{}}}class o extends u{constructor(t={}){super(t)}get type(){return"node"}get schema(){return null}commands(){return{}}}class d extends o{get button(){return this.options.levels.map(t=>({id:`h${t}`,command:`h${t}`,icon:`h${t}`,label:window.panel.$t("toolbar.button.heading."+t),attrs:{level:t},name:this.name,when:["heading","paragraph"]}))}commands({type:t,schema:n,utils:r}){let i={toggleHeading:h=>r.toggleBlockType(t,n.nodes.paragraph,h)};return this.options.levels.forEach(h=>{i[`h${h}`]=()=>r.toggleBlockType(t,n.nodes.paragraph,{level:h})}),i}get defaults(){return{levels:[1,2,3,4,5,6]}}inputRules({type:t,utils:n}){return this.options.levels.map(r=>n.textblockTypeInputRule(new RegExp(`^(#{1,${r}})\\s$`),t,()=>({level:r})))}keys({type:t,utils:n}){return this.options.levels.reduce((r,i)=>f(g({},r),{[`Shift-Ctrl-${i}`]:n.setBlockType(t,{level:i})}),{})}get name(){return"heading"}get schema(){return{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,draggable:!1,parseDOM:this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}})),toDOM:t=>[`h${t.attrs.level}`,0]}}}function y(e){const t=window.panel.plugins.thirdParty;if(t.__nodesInitialized)return;const n=t.nodes;if(!n)return;const r=e.component("k-writer");e.component("k-writer",{extends:r,methods:{createNodes(){const i=r.options.methods.createNodes.call(this).filter(({name:a})=>!Object.keys(n).includes(a)),h=this.filterExtensions(Object.entries(n).reduce((a,[c,s])=>(a[c]=new s,a),{}),this.nodes);if(this&&this.nodes&&!this.nodes.includes("heading")){const a=this.nodes.reduce((c,s)=>{var m;const l=(m=s.matchAll(/h([1-6])/gu))==null?void 0:m.next();return l&&l.value&&l.value.length>1&&!c.includes(l.value[1])&&c.push(l.value[1]),c},[]);a.length>0&&h.push(new d({levels:a}))}return[...i,...h]}}}),t.__nodesInitialized=!0}class x extends o{get button(){return{id:this.name,icon:"quote",label:window.panel.$t("coralic.extendedWriter.nodes.largerParagraph"),name:this.name}}commands({type:t,schema:n,utils:r}){return{largerParagraph:i=>r.toggleBlockType(t,n.nodes.paragraph,i)}}get name(){return"largerParagraph"}get schema(){return{content:"inline*",group:"block",draggable:!1,parseDOM:[{tag:"div",getAttrs:()=>({class:"-larger-paragraph"})}],toDOM:()=>["div",{class:"-larger-paragraph"},0]}}}function $(e){const t=window.panel.plugins.thirdParty;if(t.__marksInitialized)return;const n=t.marks;if(!n)return;const r=e.component("k-writer");e.component("k-writer",{extends:r,methods:{createMarks(){const i=r.options.methods.createMarks.call(this).filter(({name:a})=>!Object.keys(n).includes(a)),h=Object.entries(n).reduce((a,[c,s])=>(a[c]=new s,a),{});return[...i,...this.filterExtensions(h,this.marks)]}}}),t.__marksInitialized=!0}class M extends u{constructor(t={}){super(t)}command(){return()=>{}}remove(){this.editor.removeMark(this.name)}get schema(){return null}get type(){return"mark"}toggle(){return this.editor.toggleMark(this.name)}update(t){this.editor.updateMark(this.name,t)}}class L extends M{get button(){return{icon:"star",label:window.panel.$t("coralic.extendedWriter.nodes.highlight")}}commands(){return()=>this.toggle()}get name(){return"highlight"}get schema(){return{parseDOM:[{tag:"mark"}],toDOM:t=>["mark",g({},t.attrs),0]}}}class O extends o{get defaults(){return{inline:!1}}get name(){return"doc"}get schema(){return{content:this.options.inline?"paragraph+":"block+"}}}class P extends O{get defaults(){return{nodes:["bulletList","orderedList"]}}get schema(){return{content:this.options.nodes instanceof Array?this.options.nodes.join("|"):"bulletList|orderedList"}}}var C=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("k-writer",e._b({ref:"input",staticClass:"k-list-input",attrs:{extensions:e.extensions,nodes:e.toolbarNodes,value:e.list},on:{input:e.onInput}},"k-writer",e.$props,!1))},N=[],q="";function B(e,t,n,r,i,h,a,c){var s=typeof e=="function"?e.options:e;t&&(s.render=t,s.staticRenderFns=n,s._compiled=!0),r&&(s.functional=!0),h&&(s._scopeId="data-v-"+h);var l;if(a?(l=function(p){p=p||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!p&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(p=__VUE_SSR_CONTEXT__),i&&i.call(this,p),p&&p._registeredComponents&&p._registeredComponents.add(a)},s._ssrRegister=l):i&&(l=c?function(){i.call(this,(s.functional?this.parent:this).$root.$options.shadowRoot)}:i),l)if(s.functional){s._injectStyles=l;var m=s.render;s.render=function(S,w){return l.call(w),m(S,w)}}else{var _=s.beforeCreate;s.beforeCreate=_?[].concat(_,l):[l]}return{exports:e,options:s}}const R={inheritAttrs:!1,props:{autofocus:Boolean,marks:{type:[Array,Boolean],default:!0},nodes:{type:[Array,Boolean],default:!0},value:String},data(){return{list:this.value,html:this.value}},computed:{toolbarNodes(){return this.nodes===!1?["bulletList"]:this.nodes===!0?["bulletList","orderedList"]:this.nodes},extensions(){return[new P({nodes:this.toolbarNodes,inline:!0})]}},watch:{value(e){e!==this.html&&(this.list=e,this.html=e)}},methods:{focus(){this.$refs.input.focus()},onInput(e){let n=new DOMParser().parseFromString(e,"text/html").querySelector("ul, ol");if(!n){this.$emit("input",this.list="");return}if(n.textContent.trim().length===0){this.$emit("input",this.list="");return}this.list=e,this.html=e.replace(/(<p>|<\/p>)/gi,""),this.$emit("input",this.html)}}},k={};var T=B(R,C,N,!1,D,null,null,null);function D(e){for(let t in k)this[t]=k[t]}var I=function(){return T.exports}();function A(e){const t=e.component("k-writer");e.component("k-writer",{extends:t,components:{"k-writer-toolbar":{extends:t.component("k-writer-toolbar"),computed:{hasVisibleButtons(){const r=Object.keys(this.nodeButtons);return r.length>1||r.length===1&&!(r.includes("bulletList")||r.includes("paragraph")||r.includes("orderedList"))}}}}});const n=e.component("k-list-field");e.component("k-list-field",{extends:n,props:{nodes:[Array,Boolean]}})}var U="";function E(e){e.component("k-writer",{extends:e.component("k-writer"),props:{align:"left"|"center"|"right"},mounted(){this.$el.classList.add("k-writer-text-align-"+(this.align||"left"))}}),e.component("k-writer-field",{extends:e.component("k-writer-field"),props:{align:"left"|"center"|"right"}})}window.panel.plugin("coralic/frohberger-writer-nodes",{use:[y,$,A,E],thirdParty:{nodes:f(g({},window.panel.plugins.thirdParty.nodes||{}),{largerParagraph:x}),marks:f(g({},window.panel.plugins.thirdParty.marks||{}),{highlight:L})},components:{"k-list-input":I}})})();