jodit-pro
Version:
PRO Version of Jodit Editor
8 lines (7 loc) • 2.4 kB
JavaScript
var m=Object.defineProperty;var c=(s,e)=>m(s,"name",{value:e,configurable:!0});var a=function(s,e,i,n){var r=arguments.length,t=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,i):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(s,e,i,n);else for(var p=s.length-1;p>=0;p--)(l=s[p])&&(t=(r<3?l(t):r>3?l(e,i,t):l(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};import"./config.js";import*as b from"./langs/index.js";import g from"./show-blocks.svg.js";import{autobind as d,cache as u,cached as f}from"jodit/esm/core/decorators/index.js";import{Dom as y}from"jodit/esm/core/dom/dom.js";import{extendLang as w,getContainer as x}from"jodit/esm/core/global.js";import{Plugin as j}from"jodit/esm/core/plugin/index.js";import{Icon as v}from"jodit/esm/core/ui/icon.js";import{JoditPro as k}from"../../jodit-pro.js";function B(s){return`data:image/svg+xml;utf8,${escape(s)}`}c(B,"svgToUrl");const h=class h extends j{get style(){return x(this.jodit,h,"style",!0)}enable(){this.isEnabled=!0;const e=this.j.o.iframe?"body":".jodit-wysiwyg",{tagList:i,color:n}=this.j.o.showBlocks;this.style.innerHTML=i.map(r=>`${e} ${r}{
outline: 1px dashed ${n};
background-image: url("${B('<svg xmlns="http://www.w3.org/2000/svg" width="50px"><text dominant-baseline="hanging" text-anchor="end" style="fill: '+n+';font: 10px sans-serif" x="50px" y="0">'+r+"</text></svg>")}");
background-position: top 2px ${this.j.o.direction==="rtl"?"left":"right"} 4px;
background-repeat: no-repeat;
position: relative;
}`).join("")}disable(){this.isEnabled=!1;const e=f(this,"style");e&&(e.innerHTML="")}toggle(){this.isEnabled?this.disable():this.enable(),this.j.e.fire("updateToolbar")}constructor(e){super(e),this.buttons=[{name:"showBlocks",group:"state"}],this.isEnabled=!1,w(b),v.set("showBlocks",g)}afterInit(e){e.e.on("showBlocksEnabled",()=>this.isEnabled),e.registerCommand("enableShowBlocks",this.enable).registerCommand("disableShowBlocks",this.disable).registerCommand("toggleShowBlocks",this.toggle),this.j.o.showBlocks.enable&&this.enable()}beforeDestruct(e){this.disable(),y.safeRemove(f(this,"style"))}};c(h,"showBlocks");let o=h;o.requires=["license"],a([u],o.prototype,"style",null),a([d],o.prototype,"enable",null),a([d],o.prototype,"disable",null),a([d],o.prototype,"toggle",null),k.plugins.add("show-blocks",o);export{o as showBlocks};