decarbone/site/plugins/kirby-writer-callout/index.js

2 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-02-13 15:40:11 +01:00
(function(){"use strict";function i(e){const t=window.panel.plugins.thirdParty;if(t.__marksInitialized)return;const n=t.marks;if(!n)return;const s=e.component("k-writer");e.component("k-writer",{extends:s,methods:{createMarks(){const l=s.options.methods.createMarks.call(this).filter(({name:r})=>!Object.keys(n).includes(r)),c=Object.entries(n).reduce((r,[d,m])=>(r[d]=new m,r),{});return[...l,...this.filterExtensions(c,this.marks)]}}}),t.__marksInitialized=!0}class a{constructor(t={}){this.options={...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 u extends a{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 o extends u{get button(){return{icon:"star",label:"Callout"}}commands(){return()=>this.toggle()}get name(){return"callout"}get schema(){return{parseDOM:[{tag:"span"}],toDOM:t=>["span",{...t.attrs,class:"callout"},0]}}}window.panel.plugin("adrienpayet/kirby-writer-callout",{use:[i],thirdParty:{marks:{...window.panel.plugins.thirdParty.marks||{},callout:o}}})})();