wpmind/build/editor.js

5 lines
73 KiB
JavaScript
Raw Normal View History

2023-10-26 21:22:56 +03:00
!function(){"use strict";var e,t={181:function(e,t,n){var r={};n.r(r),n.d(r,{getSettingsPageURL:function(){return p},isConnected:function(){return u}});var s={};n.r(s),n.d(s,{getHighlightBlocks:function(){return g}});var i={};n.r(i),n.d(i,{removeHighlightBlocks:function(){return f},setHighlightBlocks:function(){return m}});var o={};n.r(o),n.d(o,{close:function(){return ie},open:function(){return se},requestAI:function(){return ge},reset:function(){return me},setContext:function(){return ae},setError:function(){return de},setInput:function(){return le},setInsertionPlace:function(){return ce},setLoading:function(){return pe},setResponse:function(){return he},setScreen:function(){return ue},toggle:function(){return oe}});var l={};n.r(l),n.d(l,{getContext:function(){return be},getError:function(){return ye},getInput:function(){return ke},getInsertionPlace:function(){return we},getLoading:function(){return _e},getResponse:function(){return Ee},getScreen:function(){return xe},isOpen:function(){return fe}});const{connected:a,settingsPageURL:c}=window.mindData;function u(){return"1"===a}function p(){return c}var h=window.wp.data;const d=(0,h.createReduxStore)("mind",{selectors:r,reducer(e){return e}});(0,h.register)(d);function g(e){return e?.highlightBlocks||[]}function m(e){return{type:"SET_HIGHLIGHT_BLOCKS",highlightBlocks:e}}function f(e){return{type:"REMOVE_HIGHLIGHT_BLOCKS",removeBlocks:e}}const k=(0,h.createReduxStore)("mind/blocks",{reducer:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{highlightBlocks:[]},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case"SET_HIGHLIGHT_BLOCKS":if(t.highlightBlocks&&t.highlightBlocks.length)return{...e,highlightBlocks:[...e.highlightBlocks,...t.highlightBlocks]};break;case"REMOVE_HIGHLIGHT_BLOCKS":if(e.highlightBlocks&&e.highlightBlocks.length&&t.removeBlocks&&t.removeBlocks.length)return{...e,highlightBlocks:e.highlightBlocks.filter((e=>!t.removeBlocks.includes(e)))}}return e},selectors:s,actions:i});(0,h.register)(k);let b={async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const w=/[&<>"']/,x=new RegExp(w.source,"g"),_=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,E=new RegExp(_.source,"g"),y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},v=e=>y[e];function S(e,t){if(t){if(w.test(e))return e.replace(x,v)}else if(_.test(e))return e.replace(E,v);return e}const C=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function O(e){return e.replace(C,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const A=/(^|[^\[])\^/g;function F(e,t){e="string"==typeof e?e:e.source,t=t||"";const n={replace:(t,r)=>(r=(r=r.source||r).replace(A,"$1"),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}const $=/[^\w:]/g,I=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(e,t,n){if(e){let e;try{e=decodeURIComponent(O(n)).replace($,"").toLowerCase()}catch(e){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!I.test(n)&&(n=function(e,t){T[" "+e]||(z.test(e)?T[" "+e]=e+"/":T[" "+e]=D(e,"/",!0));const n=-1===(e=T[" "+e]).indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(P,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(M,"$1")+t:e+t}(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}const T={},z=/^[^:]+:\/*[^/]*$/,P=/^([^:]+:)[\s\S]*$/,M=/^([^:]+:\/*[^/]*)[\s\S]*$/,B={exec:function(){}};function j(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"})).split(/ \|/);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n}function D(e,t,n){const r=e.l
// translators: %s - tone.
(0,te.__)("Change tone to %s","mind"),e[0]))}},(0,Se.createElement)(Se.RawHTML,null,Zt(e[1]))))))))),(0,Se.createElement)(Ce.DropdownMenu,{icon:(0,Se.createElement)(Nt,null),iconPosition:"left",toggleProps:{children:(0,Se.createElement)(Se.Fragment,null,(0,te.__)("Translate","mind"),(0,Se.createElement)(bt,null))},popoverProps:{placement:"right-end",className:"mind-toolbar-dropdown"},className:"mind-toolbar-dropdown-toggle"},(()=>(0,Se.createElement)(Se.Fragment,null,(0,Se.createElement)(Ce.MenuGroup,{label:(0,te.__)("Select Language","@@text_domain")},Gt.map((e=>(0,Se.createElement)(Ce.MenuItem,{key:e[0],onClick:()=>{i((0,te.sprintf)(
// translators: %s - tone.
(0,te.__)("Translate to %s","mind"),e[0]))}},(0,Se.createElement)(Se.RawHTML,null,Zt(e[1]))))))))))))))}const Wt=(0,mt.createHigherOrderComponent)((e=>function(t){var n;return n=t,Ht.includes(n.name)?(0,Se.createElement)(Se.Fragment,null,(0,Se.createElement)(e,t),(0,Se.createElement)(gt.BlockControls,{group:"other"},(0,Se.createElement)(Qt,null))):(0,Se.createElement)(e,t)}),"withToolbarControl");(0,dt.addFilter)("editor.BlockEdit","mind/block-toolbar-toggle",Wt);var Vt=window.lodash;const{elementContext:Kt,__unstableElementContext:Xt}=gt.BlockList,Jt=Kt||Xt;function Yt(e){const{styles:t}=e,n=(0,Se.useMemo)((()=>{const e=(0,gt.transformStyles)([{css:t}],".editor-styles-wrapper");let n="";return(0,Vt.map)((0,Vt.compact)(e),(e=>{n+=e})),n}),[t]),r=(0,Se.useContext)(Jt);return n&&r&&(0,Se.createPortal)((0,Se.createElement)("style",{dangerouslySetInnerHTML:{__html:n}}),r)}const en=["core/paragraph","core/list","core/code","core/preformatted","core/quote","core/blockquote"],tn=(0,mt.createHigherOrderComponent)((e=>function(t){const{name:n,clientId:r}=t,[s,i]=(0,Se.useState)(!1),{removeHighlightBlocks:o}=(0,h.useDispatch)("mind/blocks"),{highlightBlocks:l}=(0,h.useSelect)((e=>{const{getHighlightBlocks:t}=e("mind/blocks");return{highlightBlocks:t()}})),a=en.includes(n)&&l&&l.length&&l.includes(r);return(0,Se.useEffect)((()=>{a&&setTimeout((()=>{i(!0),setTimeout((()=>{i(!1),o([r])}),3e3)}),3e3)}),[a,r,o]),a?(0,Se.createElement)(Se.Fragment,null,(0,Se.createElement)(e,t),(0,Se.createElement)(Yt,{styles:`\n\t\t\t\t\t\t\t[data-block="${r}"] {\n\t\t\t\t\t\t\t\tbackground-color: rgba(228, 85, 223, 0.1);\n\t\t\t\t\t\t\t\tbox-shadow: 0 0 0 0.75rem rgba(228, 85, 223, 0.1);\n\t\t\t\t\t\t\t\t${s?"transition: 3s background-color, 3s box-shadow;":""}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t${s?`\n\t\t\t\t\t\t\t\t\t\t[data-block="${r}"] {\n\t\t\t\t\t\t\t\t\t\t\tbackground-color: rgba(228, 85, 223, 0);\n\t\t\t\t\t\t\t\t\t\t\tbox-shadow: 0 0 0 0.75rem rgba(228, 85, 223, 0);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t`:""}\n\t\t\t\t\t\t`})):(0,Se.createElement)(e,t)}),"withMindAIEditorStyles");(0,dt.addFilter)("editor.BlockEdit","mind/editor-styles",tn);const nn=(0,te.getLocaleData)(),rn="Type / to choose a block",sn=nn&&void 0!==nn[rn]?nn[rn]:rn;(0,te.setLocaleData)({[rn]:[`${sn}... Press \`space\` for AI`]},"default");const on=(0,mt.createHigherOrderComponent)((e=>function(t){const{name:n,attributes:r}=t,{content:s}=r,i=(0,mt.usePrevious)(s),{open:o,setInsertionPlace:l}=(0,h.useDispatch)("mind/popup");return(0,Se.useEffect)((()=>{"core/paragraph"!==n||i||" "!==s||(o(),l("selected-blocks"))}),[n,i,s,o,l]),(0,Se.createElement)(e,t)}),"withMindAI");(0,dt.addFilter)("editor.BlockEdit","mind/open-popup",on);const ln="mind-post-toolbar-toggle";function an(){const{toggle:e}=(0,h.useDispatch)("mind/popup");return(0,Se.createElement)("button",{type:"button",className:"components-button components-icon-button",onClick:t=>{t.preventDefault(),e()}},(0,Se.createElement)(Ge,null),(0,te.__)("Open Mind","@@text_domain"))}Fe()((()=>{(0,h.subscribe)((0,Vt.throttle)((()=>{if(document.querySelector(`.${ln}`))return;const e=document.querySelector(".edit-post-header__toolbar");e&&(e=>{const t=document.createElement("div");t.classList.add(ln),e.appendChild(t),(0,Se.createRoot)(t).render((0,Se.createElement)(an,null))})(e)}),200,{trailing:!0}))}))}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.m=t,e=[],r.O=function(t,n,s,i){if(!n){var o=1/0;for(u=0;u<e.length;u++){n=e[u][0],s=e[u][1],i=e[u][2];for(var l=!0,a=0;a<n.length;a++)(!1&i||o>=i)&&Object.keys(r.O).every((function(e){return r.O[e](n[a])}))?n.splice(a--,1):(l=!1,i<o&&(o=i));if(l){e.splice(u--,1);var c=s();void 0!==c&&(t=c)}}return t}i=i||0;for(var u=e.length;u>0&&e[u-1][2]>i;u--)e[u]=e[u-1];e[u]=[n,s,i]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){retu