UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 1.11 kB
var d=Object.defineProperty;var m=(e,o)=>d(e,"name",{value:o,configurable:!0});import p from"./icon.svg.js";import{Config as u}from"jodit/esm/config.js";import{trim as g}from"jodit/esm/core/helpers/index.js";import{Plugin as f}from"jodit/esm/core/plugin/index.js";import{isEditorEmpty as v}from"jodit/esm/plugins/placeholder/placeholder.js";import{JoditPro as h}from"../../jodit-pro.js";u.prototype.controls.google={tooltip:"Google search",icon:p,isDisabled(e){return v(e.editor)},command:"startSearch"};const c=class c extends f{constructor(){super(...arguments),this.buttons=[{name:"google",group:"search"}]}afterInit(o){o.registerCommand("startSearch",{exec:m(()=>{var i,n,s;let r;const{s:l}=o;if(l.isCollapsed()?r=(n=(i=l.current())===null||i===void 0?void 0:i.parentElement)===null||n===void 0?void 0:n.innerText:r=(s=l.sel)===null||s===void 0?void 0:s.toString(),r){const a="https://www.google.com/search?q="+encodeURIComponent(g(r));window.open(a,"_blank")}},"exec")})}beforeDestruct(o){}};m(c,"googleSearch");let t=c;t.requires=["license"],h.plugins.add("google-search",t);export{t as googleSearch};