Plugin Directory

Changeset 3374099


Ignore:
Timestamp:
10/07/2025 03:23:47 AM (5 months ago)
Author:
inc2734
Message:

Version up. v11.0.3

Location:
snow-monkey-editor/trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • snow-monkey-editor/trunk/dist/js/editor.asset.php

    r3274014 r3374099  
    1 <?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-preferences', 'wp-rich-text'), 'version' => '838587cedcd5eaa6f6ca');
     1<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-preferences', 'wp-rich-text'), 'version' => '85d5d5f767986326c6e9');
  • snow-monkey-editor/trunk/dist/js/editor.js

    r3274014 r3374099  
    1 (()=>{var e={558:e=>{"use strict";var t=function(e){return parseInt(e,16)};e.exports=function(e,o){var n,s,r=function(e){return"#"===e.charAt(0)?e.slice(1):e}(e),a=function(e){var o=e.g,n=e.b,s=e.a;return{r:t(e.r),g:t(o),b:t(n),a:+(t(s)/255).toFixed(2)}}({r:(s=3===(n=r).length||4===n.length)?"".concat(n.slice(0,1)).concat(n.slice(0,1)):n.slice(0,2),g:s?"".concat(n.slice(1,2)).concat(n.slice(1,2)):n.slice(2,4),b:s?"".concat(n.slice(2,3)).concat(n.slice(2,3)):n.slice(4,6),a:(s?"".concat(n.slice(3,4)).concat(n.slice(3,4)):n.slice(6,8))||"ff"});return function(e,t){var o,n=e.r,s=e.g,r=e.b,a=e.a,i=(o=t,!isNaN(parseFloat(o))&&isFinite(o)?t:a);return"rgba(".concat(n,", ").concat(s,", ").concat(r,", ").concat(i,")")}(a,o)}},919:e=>{e.exports=function(e){if("string"!=typeof e)throw new Error("color has to be type of `string`");if("#"===e.substr(0,1))return{hex:e,alpha:1};var t=e.replace(/\s+/g,""),o=/(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|1.0*|0??\.([0-9]{0,})))??\)/.exec(t);if(!o)throw new Error("given color ("+e+") isn't a valid rgb or rgba color");var n=parseInt(o[3],10),s=parseInt(o[4],10),r=parseInt(o[5],10),a=o[6]?/([0-9\.]+)/.exec(o[6])[0]:"1",i=(r|s<<8|n<<16|1<<24).toString(16).slice(1);return"."===a.substr(0,1)&&(a=parseFloat("0"+a)),a=parseFloat(Math.round(100*a))/100,{hex:"#"+i.toString(16),alpha:a}}},942:(e,t)=>{var o;!function(){"use strict";var n={}.hasOwnProperty;function s(){for(var e="",t=0;t<arguments.length;t++){var o=arguments[t];o&&(e=a(e,r(o)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return s.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var o in e)n.call(e,o)&&e[o]&&(t=a(t,o));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(s.default=s,e.exports=s):void 0===(o=function(){return s}.apply(t,[]))||(e.exports=o)}()}},t={};function o(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e={};o.r(e),o.d(e,{settings:()=>_});var t={};o.r(t),o.d(t,{settings:()=>B});var n={};o.r(n),o.d(n,{settings:()=>z});var s={};o.r(s),o.d(s,{settings:()=>V});var r={};o.r(r),o.d(r,{settings:()=>J});var a={};o.r(a),o.d(a,{settings:()=>ee});var i={};o.r(i),o.d(i,{settings:()=>ae});var l={};o.r(l),o.d(l,{settings:()=>be});var c={};o.r(c),o.d(c,{settings:()=>Ce});var m={};o.r(m),o.d(m,{settings:()=>je});const u=window.lodash,d=window.wp.blockEditor,g=window.wp.components,p=window.wp.richText,h=window.wp.i18n,b=window.ReactJSXRuntime,v=(0,b.jsx)("svg",{role:"img",focusable:"false",width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M13.982,16.711c-0.744,1.441 -2.248,2.428 -3.982,2.428c-1.735,0 -3.238,-0.986 -3.983,-2.428c0.909,-1.213 2.355,-2.002 3.983,-2.002c1.629,0 3.074,0.789 3.982,2.002Zm-0.748,-7.657c-0.314,2.56 1.248,2.919 1.248,5.603c0,0.467 -0.072,0.918 -0.205,1.344c-1.037,-1.203 -2.57,-1.967 -4.277,-1.967c-1.708,0 -3.24,0.764 -4.277,1.967c-0.133,-0.426 -0.205,-0.877 -0.205,-1.344c0,-2.684 1.563,-3.043 1.247,-5.603c-0.362,-2.928 -4.315,-2.465 -4.315,-5.334c0,-1.579 1.279,-2.858 2.858,-2.858c1.709,0 2.765,1.558 4.692,1.558c1.926,0 2.982,-1.558 4.691,-1.558c1.578,0 2.857,1.279 2.857,2.858c0.001,2.869 -3.952,2.406 -4.314,5.334Zm-4.677,-4.947l-0.708,0c0,0.498 -0.403,0.9 -0.901,0.9c-0.498,0 -0.901,-0.402 -0.901,-0.9l-0.708,0c0,0.889 0.72,1.609 1.609,1.609c0.889,0 1.609,-0.72 1.609,-1.609Zm0.979,7.141c0,-0.312 -0.253,-0.568 -0.566,-0.568c-0.313,0 -0.567,0.256 -0.567,0.568c0,0.312 0.254,0.566 0.567,0.566c0.313,0 0.566,-0.253 0.566,-0.566Zm2.062,0c0,-0.312 -0.254,-0.568 -0.568,-0.568c-0.312,0 -0.566,0.256 -0.566,0.568c0,0.312 0.254,0.566 0.566,0.566c0.314,0 0.568,-0.253 0.568,-0.566Zm3.062,-7.141l-0.707,0c0,0.498 -0.404,0.9 -0.9,0.9c-0.498,0 -0.902,-0.402 -0.902,-0.9l-0.707,0c0,0.889 0.721,1.609 1.609,1.609c0.886,0.001 1.607,-0.72 1.607,-1.609Z"})}),x={position:"bottom left",variant:"alternate"};(0,p.registerFormatType)("snow-monkey-editor/dropdown",{title:"buttons",tagName:"sme-dropdown",className:null,edit:()=>(0,b.jsx)(d.BlockFormatControls,{children:(0,b.jsx)("div",{className:"block-editor-format-toolbar",children:(0,b.jsxs)(g.ToolbarGroup,{children:[(0,b.jsx)(g.Slot,{name:"SnowMonkey.ToolbarControls",children:e=>0!==e.length&&(0,b.jsx)(g.ToolbarItem,{children:t=>(0,b.jsx)(g.DropdownMenu,{icon:v,label:(0,h.__)("Snow Monkey Editor Controls","snow-monkey-editor"),toggleProps:t,controls:(0,u.orderBy)(e.map((([{props:e}])=>e)),"title"),popoverProps:x})})}),["sme-font-size","sme-letter-spacing","sme-line-height","sme-text-color","sme-text-gradient","sme-bg-color","sme-highlighter","sme-badge"].map((e=>(0,b.jsx)(g.Slot,{name:`SnowMonkey.ToolbarControls.${e}`},e)))]})})})});const C=e=>{if(!e)return;const{name:t,settings:o}=e;(0,p.registerFormatType)(t,o)},y=window.wp.data,f=window.wp.element,k=window.wp.keycodes;function w({name:e,shortcutType:t,shortcutCharacter:o,...n}){let s,r="SnowMonkey.ToolbarControls";return e&&(r+=`.${e}`),t&&o&&(s=k.displayShortcut[t](o)),(0,b.jsx)(g.Fill,{name:r,children:(0,b.jsx)(g.ToolbarButton,{...n,shortcut:s})})}const j=(0,h.__)("Remove formatting","snow-monkey-editor"),_={name:"snow-monkey-editor/remove-fomatting",title:j,tagName:"span",className:"sme-remove-fomatting",edit:({value:e,onChange:t})=>{const o=(0,y.useSelect)((e=>e("core/rich-text").getFormatTypes()),[]),n=(0,f.useCallback)((()=>{if(0<o.length){let n=e;o.forEach((e=>{n=(0,p.removeFormat)(n,e.name)})),t({...n})}}),[e,o]);return(0,b.jsx)(w,{icon:"editor-removeformatting",title:j,onClick:n})}};var S=o(942),R=o.n(S);const N=({name:e,value:t,onChange:o,onReset:n})=>{const[s]=(0,d.useSettings)("typography.fontSizes"),r=(0,f.useMemo)((()=>function(e,t,o){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const s=n.attributes.style;if(s)return s.replace(new RegExp("^font-size:\\s*"),"");const r=n.attributes.class;if(r){let e=r.replace(/.*has-([^\s]*)-font-size.*/,"$1"),t=(0,u.find)(o,{slug:e});if(!t&&(e=e.replace(/(\d)-([^\d])/,"$1$2",e),t=(0,u.find)(o,{slug:e}),!t))return;return t.size}}(e,t,s)),[e,t]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d.FontSizePicker,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,value:r,onChange:o,fontSizes:s}),(0,b.jsx)(g.Button,{disabled:void 0===t,variant:"secondary",size:"small",onClick:n,children:(0,h.__)("Reset")})]})},F=(0,g.withSpokenMessages)((({name:e,value:t,onChange:o,onClose:n,onReset:s,contentRef:r,settings:a})=>{const i=(0,p.useAnchor)({editableContentElement:r.current,settings:a}),l=(0,d.useCachedTruthy)(i.getBoundingClientRect());return i.getBoundingClientRect=()=>l,(0,b.jsx)(g.Popover,{anchor:i,onClose:n,className:"sme-popover sme-popover--inline-font-size components-inline-color-popover",children:(0,b.jsx)("fieldset",{children:(0,b.jsx)(N,{name:e,value:t,onChange:o,onReset:s})})})})),A="snow-monkey-editor/font-size",M=(0,h.__)("Font size","snow-monkey-editor"),B={name:A,title:M,tagName:"span",className:"sme-font-size",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a]=(0,d.useSettings)("typography.fontSizes"),[i,l]=(0,f.useState)(!1);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-font-size":void 0,title:M,className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{l(!i)},icon:(0,b.jsx)(g.Icon,{icon:"editor-textcolor"})},n?"sme-font-size":"sme-font-size-not-active"),i&&(0,b.jsx)(F,{name:A,activeAttributes:s,value:t,onClose:()=>l(!1),onReset:()=>{l(!1),o((0,p.removeFormat)(t,A))},onChange:e=>{if(e){let n;if((0,u.isString)(e)||a[0]&&(0,u.isString)(a[0].size))n=e;else{if(!(0,u.isNumber)(e))return;n=`${e}px`}const s=(0,u.find)(a,{size:e});o((0,p.applyFormat)(t,{type:A,attributes:s?{class:(0,d.getFontSizeClass)(s.slug)}:{style:`font-size: ${n}`}}))}else o((0,p.removeFormat)(t,A))},contentRef:r,settings:B})]})}},O=({name:e,title:t,value:o,onChange:n,onReset:s})=>{const r=(0,f.useMemo)((()=>function(e,t){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const n=o.attributes?.style;return n?parseFloat(n.replace(new RegExp("^letter-spacing:\\s*"),"").replace("rem","")):void 0}(e,o)),[e,o]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(g.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:t,value:r,onChange:n,min:"0",max:"2",step:"0.1",initialPosition:void 0}),(0,b.jsx)(g.Button,{disabled:void 0===o,variant:"secondary",isSmall:!0,onClick:s,children:(0,h.__)("Reset")})]})},T=(0,g.withSpokenMessages)((({name:e,title:t,value:o,onChange:n,onClose:s,onReset:r,contentRef:a,settings:i})=>{const l=(0,p.useAnchor)({editableContentElement:a.current,settings:i}),c=(0,d.useCachedTruthy)(l.getBoundingClientRect());return l.getBoundingClientRect=()=>c,(0,b.jsx)(g.Popover,{anchor:l,onClose:s,className:"sme-popover sme-popover--inline-letter-spacing components-inline-color-popover",children:(0,b.jsx)("fieldset",{children:(0,b.jsx)(O,{name:e,title:t,value:o,onChange:n,onReset:r})})})})),P="snow-monkey-editor/letter-spacing",E=(0,h.__)("Letter spacing","snow-monkey-editor"),z={name:P,title:E,tagName:"span",className:"sme-letter-spacing",attributes:{style:"style"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i]=(0,f.useState)(!1);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-letter-spacing":void 0,title:E,className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{i(!a)},icon:(0,b.jsx)(g.Icon,{icon:"controls-pause"})},n?"sme-letter-spacing":"sme-letter-spacing-not-active"),a&&(0,b.jsx)(T,{name:P,title:E,activeAttributes:s,value:t,onClose:()=>{i(!1)},onReset:()=>{i(!1),o((0,p.removeFormat)(t,P))},onChange:e=>{o((0,p.applyFormat)(t,{type:P,attributes:{style:`letter-spacing: ${e}rem`}}))},contentRef:r,settings:z})]})}},I=({name:e,title:t,value:o,onChange:n,onReset:s})=>{const r=(0,f.useMemo)((()=>function(e,t){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const n=o.attributes.style;return n?parseFloat(n.replace(new RegExp("^line-height:\\s*"),"")):void 0}(e,o)),[e,o]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(g.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:t,value:r,onChange:n,min:"0",max:"5",step:"0.1",initialPosition:void 0}),(0,b.jsx)(g.Button,{disabled:void 0===o,variant:"secondary",isSmall:!0,onClick:s,children:(0,h.__)("Reset")})]})},$=(0,g.withSpokenMessages)((({name:e,title:t,value:o,onChange:n,onClose:s,onReset:r,contentRef:a,settings:i})=>{const l=(0,p.useAnchor)({editableContentElement:a.current,settings:i}),c=(0,d.useCachedTruthy)(l.getBoundingClientRect());return l.getBoundingClientRect=()=>c,(0,b.jsx)(g.Popover,{anchor:l,onClose:s,className:"sme-popover sme-popover--inline-line-height components-inline-color-popover",children:(0,b.jsx)("fieldset",{children:(0,b.jsx)(I,{name:e,title:t,value:o,onChange:n,onReset:r})})})})),H="snow-monkey-editor/line-height",L=(0,h.__)("Line height","snow-monkey-editor"),V={name:H,title:L,tagName:"span",className:"sme-line-height",attributes:{style:"style"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i]=(0,f.useState)(!1);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-line-height":void 0,title:L,className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{i(!a)},icon:(0,b.jsx)(g.Icon,{icon:"editor-insertmore"})},n?"sme-line-height":"sme-line-height-not-active"),a&&(0,b.jsx)($,{name:H,title:L,activeAttributes:s,value:t,onClose:()=>{i(!1)},onReset:()=>{i(!1),o((0,p.removeFormat)(t,H))},onChange:e=>{o((0,p.applyFormat)(t,{type:H,attributes:{style:`line-height: ${e}`}}))},contentRef:r,settings:V})]})}};function G(e,t,o){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const s=n.attributes.style;if(s)return s.replace(new RegExp("^color:\\s*"),"");const r=n.attributes.class;if(r){const e=r.replace(/.*has-([^\s]*)-color.*/,"$1");return(0,d.getColorObjectByAttributeValues)(o,e).color}}const Z=({name:e,value:t,onChange:o})=>{const[n,s,r]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),a=(0,f.useMemo)((()=>[...n||[],...s||[],...r||[]]),[n,s,r]),i=(0,f.useMemo)((()=>G(e,t,a)),[e,t,a]);return(0,b.jsx)(d.__experimentalColorGradientControl,{label:(0,h.__)("Color","snow-monkey-editor"),colorValue:i,onColorChange:o,...(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},D=(0,g.withSpokenMessages)((({name:e,value:t,onChange:o,onClose:n,contentRef:s,settings:r})=>{const a=(0,p.useAnchor)({editableContentElement:s.current,settings:r}),i=(0,d.useCachedTruthy)(a.getBoundingClientRect());return a.getBoundingClientRect=()=>i,(0,b.jsx)(g.Popover,{anchor:a,value:t,onClose:n,className:"sme-popover sme-popover--inline-color components-inline-color-popover",children:(0,b.jsx)(Z,{name:e,value:t,onChange:o})})})),U="snow-monkey-editor/text-color",q=(0,h.__)("Text color","snow-monkey-editor"),J={name:U,title:q,tagName:"span",className:"sme-text-color",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i,l]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),c=(0,f.useMemo)((()=>[...a||[],...i||[],...l||[]]),[a,i,l]),[m,u]=(0,f.useState)(!1),h=(0,f.useMemo)((()=>G(U,t,c)),[t,c]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-text-color":void 0,title:q,style:{color:h},className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{u(!m)},icon:(0,b.jsx)(g.Icon,{icon:"edit"})},n?"sme-text-color":"sme-text-color-not-active"),m&&(0,b.jsx)(D,{name:U,activeAttributes:s,value:t,onClose:()=>u(!1),onChange:e=>{if(e){const n=(0,d.getColorObjectByColorValue)(c,e);o((0,p.applyFormat)(t,{type:U,attributes:n?{class:(0,d.getColorClassName)("color",n.slug)}:{style:`color: ${e}`}}))}else o((0,p.removeFormat)(t,U)),u(!1)},contentRef:r,settings:J})]})}};function X(e,t,o){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const s=n.attributes?.style;if(s)return s.replace(new RegExp("^background-image:\\s*"),"");const r=n.attributes?.class;if(r){let e=r.replace(/.*has-([^\s]*)-gradient-background.*/,"$1"),t=(0,u.find)(o,{slug:e});if(!t&&(e=e.replace(/(\d)-([^\d])/,"$1$2",e),t=(0,u.find)(o,{slug:e}),!t))return;return t.gradient}}const K=({name:e,value:t,onChange:o})=>{const[n,s,r]=(0,d.useSettings)("color.gradients.custom","color.gradients.theme","color.gradients.default"),a=(0,f.useMemo)((()=>[...n||[],...s||[],...r||[]]),[n,s,r]),i=(0,f.useMemo)((()=>X(e,t,a)),[e,t,a]);return(0,b.jsx)(d.__experimentalColorGradientControl,{label:(0,h.__)("Color","snow-monkey-editor"),gradientValue:i,onGradientChange:o,...(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},Q=(0,g.withSpokenMessages)((({name:e,value:t,onChange:o,onClose:n,contentRef:s,settings:r})=>{const a=(0,p.useAnchor)({editableContentElement:s.current,settings:r}),i=(0,d.useCachedTruthy)(a.getBoundingClientRect());return a.getBoundingClientRect=()=>i,(0,b.jsx)(g.Popover,{anchor:a,onClose:n,className:"sme-popover sme-popover--inline-gradient components-inline-gradient-popover",children:(0,b.jsx)(K,{name:e,value:t,onChange:o})})})),W="snow-monkey-editor/text-gradient",Y=(0,h.__)("Text gradient","snow-monkey-editor"),ee={name:W,title:Y,tagName:"span",className:"sme-text-gradient",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i,l]=(0,d.useSettings)("color.gradients.custom","color.gradients.theme","color.gradients.default"),c=(0,f.useMemo)((()=>[...a||[],...i||[],...l||[]]),[a,i,l]),[m,u]=(0,f.useState)(!1),h=(0,f.useMemo)((()=>X(W,t,c)),[t,c]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-text-gradient":void 0,title:Y,style:{"--sme--gradient":h},className:R()("sme-toolbar-button","sme-toolbar-button--text-gradient",{"is-pressed":!!n}),onClick:()=>{u(!m)},icon:(0,b.jsx)(g.Icon,{icon:"edit"})},n?"sme-text-gradient":"sme-text-gradient-not-active"),m&&(0,b.jsx)(Q,{name:W,activeAttributes:s,value:t,onClose:()=>u(!1),onChange:e=>{if(e){const n=(0,d.getGradientSlugByValue)(c,e);o((0,p.applyFormat)(t,{type:W,attributes:n?{class:(0,d.__experimentalGetGradientClass)(n)}:{style:`background-image: ${e}`}}))}else o((0,p.removeFormat)(t,W)),u(!1)},contentRef:r,settings:ee})]})}};function te(e,t,o){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const s=n.attributes.style;if(s)return s.replace(new RegExp("^background-color:\\s*"),"");const r=n.attributes.class;if(r){const e=r.replace(/.*has-([^\s]*)-background-color.*/,"$1");return(0,d.getColorObjectByAttributeValues)(o,e).color}}const oe=({name:e,value:t,onChange:o})=>{const[n,s,r]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),a=(0,f.useMemo)((()=>[...n||[],...s||[],...r||[]]),[n,s,r]),i=(0,f.useMemo)((()=>te(e,t,a)),[e,t,a]);return(0,b.jsx)(d.__experimentalColorGradientControl,{label:(0,h.__)("Color","snow-monkey-editor"),colorValue:i,onColorChange:o,...(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},ne=(0,g.withSpokenMessages)((({name:e,value:t,onChange:o,onClose:n,contentRef:s,settings:r})=>{const a=(0,p.useAnchor)({editableContentElement:s.current,settings:r}),i=(0,d.useCachedTruthy)(a.getBoundingClientRect());return a.getBoundingClientRect=()=>i,(0,b.jsx)(g.Popover,{anchor:a,onClose:n,className:"sme-popover sme-popover--inline-background-color components-inline-color-popover",children:(0,b.jsx)(oe,{name:e,value:t,onChange:o})})})),se="snow-monkey-editor/bg-color",re=(0,h.__)("Background color","snow-monkey-editor"),ae={name:se,title:re,tagName:"span",className:"sme-bg-color",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i,l]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),c=(0,f.useMemo)((()=>[...a||[],...i||[],...l||[]]),[a,i,l]),[m,u]=(0,f.useState)(!1),h=(0,f.useMemo)((()=>te(se,t,c)),[t,c]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-bg-color":void 0,title:re,style:{color:h},className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{u(!m)},icon:(0,b.jsx)(g.Icon,{icon:"tag"})},n?"sme-bg-color":"sme-bg-color-not-active"),m&&(0,b.jsx)(ne,{name:se,activeAttributes:s,value:t,onClose:()=>u(!1),onChange:e=>{if(e){const n=(0,d.getColorObjectByColorValue)(c,e);o((0,p.applyFormat)(t,{type:se,attributes:n?{class:(0,d.getColorClassName)("background-color",n.slug)}:{style:`background-color: ${e}`}}))}else o((0,p.removeFormat)(t,se)),u(!1)},contentRef:r,settings:ae})]})}};var ie=o(558),le=o.n(ie),ce=o(919),me=o.n(ce);function ue(e,t){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const n=o.attributes.style;if(!n)return;const s=n.match(/(#[0-9A-F]{3,6}) /i);if(s)return s;const r=n.match(/,\s*?(rgba?\([^)]+\)) /i);return r?function(e){if(!e||4===e.length)return e;const t=e.match(/^#([0-9A-F])\1([0-9A-F])\1([0-9A-F])\1$/i);return t?`#${t[1].slice(0,1)}${t[2].slice(0,1)}${t[3].slice(0,1)}`:e}(me()(r[1]).hex):void 0}const de=({name:e,value:t,onChange:o})=>{const[n,s,r]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),a=(0,f.useMemo)((()=>[...n||[],...s||[],...r||[]]),[n,s,r]),i=(0,f.useMemo)((()=>ue(e,t)),[e,t,a]);return(0,b.jsx)(d.__experimentalColorGradientControl,{label:(0,h.__)("Color","snow-monkey-editor"),colorValue:i,onColorChange:o,...(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},ge=(0,g.withSpokenMessages)((({name:e,value:t,onChange:o,onClose:n,contentRef:s,settings:r})=>{const a=(0,p.useAnchor)({editableContentElement:s.current,settings:r}),i=(0,d.useCachedTruthy)(a.getBoundingClientRect());return a.getBoundingClientRect=()=>i,(0,b.jsx)(g.Popover,{anchor:a,onClose:n,className:"sme-popover sme-popover--inline-color components-inline-color-popover",children:(0,b.jsx)(de,{name:e,value:t,onChange:o})})})),pe="snow-monkey-editor/highlighter",he=(0,h.__)("Highlighter","snow-monkey-editor"),be={name:pe,title:he,tagName:"span",className:"sme-highlighter",attributes:{style:"style"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i,l]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),c=(0,f.useMemo)((()=>[...a||[],...i||[],...l||[]]),[a,i,l]),[m,u]=(0,f.useState)(!1),h=(0,f.useMemo)((()=>ue(pe,t)),[t,c]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-highlighter":void 0,title:he,style:{color:h},className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{u(!m)},icon:(0,b.jsx)(g.Icon,{icon:"tag"})},n?"sme-highlighter":"sme-highlighter-not-active"),m&&(0,b.jsx)(ge,{name:pe,activeAttributes:s,value:t,onClose:()=>u(!1),onChange:e=>{e?(e.match(/^#/)&&(e=le()(e,.5)),o((0,p.applyFormat)(t,{type:pe,attributes:{style:`background-image: linear-gradient(transparent 60%, ${e} 60%)`}}))):(o((0,p.removeFormat)(t,pe)),u(!1))},contentRef:r,settings:be})]})}},ve="snow-monkey-editor/badge",xe=(0,h.__)("Badge","snow-monkey-editor"),Ce={name:ve,title:xe,tagName:"span",className:"sme-badge",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:o,isActive:n,activeAttributes:s,contentRef:r}=e,[a,i,l]=(0,d.useSettings)("color.palette.custom","color.palette.theme","color.palette.default"),c=(0,f.useMemo)((()=>[...a||[],...i||[],...l||[]]),[a,i,l]),[m,u]=(0,f.useState)(!1),h=(0,f.useMemo)((()=>te(ve,t,c)),[t,c]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{name:n?"sme-badge":void 0,title:xe,style:{color:h},className:R()("sme-toolbar-button",{"is-pressed":!!n}),onClick:()=>{u(!m)},icon:(0,b.jsx)(g.Icon,{icon:"tag"})},n?"sme-badge":"sme-badge-not-active"),m&&(0,b.jsx)(ne,{name:ve,activeAttributes:s,value:t,onClose:()=>u(!1),onChange:e=>{if(e){const n=(0,d.getColorObjectByColorValue)(c,e);o((0,p.applyFormat)(t,{type:ve,attributes:n?{class:(0,d.getColorClassName)("background-color",n.slug)}:{style:`background-color: ${e}`}}))}else o((0,p.removeFormat)(t,ve)),u(!1)},contentRef:r,settings:Ce})]})}},ye="snow-monkey-editor/br",fe=(0,h.__)("Line break per screen size","snow-monkey-editor"),ke={type:ye,innerHTML:"<br />"};function we({value:e,onChange:t,activeObjectAttributes:o,contentRef:n}){const s=e.replacements.slice()?.[e.start]?.attributes?.class,[r,a]=(0,f.useState)(!!s?.match(/sme-br--disable:desktop/)),[i,l]=(0,f.useState)(!!s?.match(/sme-br--disable:tablet/)),[c,m]=(0,f.useState)(!!s?.match(/sme-br--disable:mobile/)),u=(0,p.useAnchor)({editableContentElement:n.current,settings:je}),d=(0,f.useCallback)((n=>{a(!n);const s=e.replacements.slice();s[e.start]={...ke,attributes:{...o,class:R()({"sme-br--disable:desktop":!n,"sme-br--disable:tablet":i,"sme-br--disable:mobile":c})}},t({...e,replacements:s})}),[i,c]),v=(0,f.useCallback)((n=>{l(!n);const s=e.replacements.slice();s[e.start]={...ke,attributes:{...o,class:R()({"sme-br--disable:desktop":r,"sme-br--disable:tablet":!n,"sme-br--disable:mobile":c})}},t({...e,replacements:s})}),[r,c]),x=(0,f.useCallback)((n=>{m(!n);const s=e.replacements.slice();s[e.start]={...ke,attributes:{...o,class:R()({"sme-br--disable:desktop":r,"sme-br--disable:tablet":i,"sme-br--disable:mobile":!n})}},t({...e,replacements:s})}),[r,i]);return(0,b.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:u,className:"sme-popover sme-popover--inline-br",children:(0,b.jsxs)("div",{style:{width:"260px"},children:[(0,b.jsx)(g.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,h.__)("Line breaks when on the desktop","snow-monkey-editor"),checked:!r,onChange:d,disabled:i&&c}),(0,b.jsx)(g.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,h.__)("Line breaks when on the tablet","snow-monkey-editor"),checked:!i,onChange:v,disabled:r&&c}),(0,b.jsx)(g.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,h.__)("Line breaks when on the mobile","snow-monkey-editor"),checked:!c,onChange:x,disabled:r&&i})]})})}const je={name:ye,title:fe,tagName:"span",className:"sme-br",attributes:{class:"class"},interactive:!0,contentEditable:!1,edit:function({value:e,onChange:t,onFocus:o,isObjectActive:n,activeObjectAttributes:s,contentRef:r}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{icon:(0,b.jsx)("span",{className:"dashicon",children:(0,b.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0224 5.25C18.4366 5.25 18.7724 5.58579 18.7724 6V15C18.7724 15.4142 18.4366 15.75 18.0224 15.75L18.0112 15.7499L18 15.75H10.0784V19L4.5 14.8349L10.0784 10.6699V14.25H17.2724V6C17.2724 5.58579 17.6082 5.25 18.0224 5.25Z",fill:"currentColor"})})}),title:fe,onClick:()=>{const n=(0,p.insertObject)(e,{...ke},e.end,e.end);n.start=n.end-1,t(n),o()},isActive:n}),n&&(0,b.jsx)(we,{value:e,onChange:t,activeObjectAttributes:s,contentRef:r})]})}};C(e),C(t),C(n),C(s),C(r),C(a),C(i),C(l),C(c),C(m);const _e=window.wp.compose,Se=window.wp.hooks;(0,Se.addFilter)("editor.BlockListBlock","snow-monkey-editor/ordered-list/orderd-styles",(0,_e.createHigherOrderComponent)((e=>t=>{const{attributes:o,name:n}=t?.block,{start:s,reversed:r,ordered:a,className:i}=o;return"core/list"!==n?(0,b.jsx)(e,{...t}):(i?.match("is-style-sme-ordered-list-square")||i?.match("is-style-sme-ordered-list-circle"))&&a?(0,b.jsx)(e,{...t,wrapperProps:{...t.wrapperProps,style:{...t.wrapperProps?.style,counterReset:r?`sme-count ${s+1}`:"sme-count "+(s-1)}}}):(0,b.jsx)(e,{...t})}),"withSnowMonkeyEditorOrderdListOrderdStyles"));const Re=window.wp.blocks,Ne=window.wp.preferences;const Fe="snow-monkey-editor/preferences",Ae=["allowedBlocks","content","templateLock","placeholder"],Me=e=>!(({name:e}={})=>!(0,Re.hasBlockSupport)(e,"snowmonkeyeditor.blockPresets"))(e)&&(!!function(e,t){if(!e||!Object.keys(e).length)return!1;const o=function(e){return(0,Se.applyFilters)("SnowMonkeyEditor.extension.allowedRoles",["administrator","editor","author","contributor"],e)}(t);return 0<e.roles.filter((e=>-1<o.indexOf(e))).length}(snowmonkeyeditor?.currentUser,"block-presets")&&!!(0,Re.getBlockType)(e.name)),Be=(0,_e.createHigherOrderComponent)((e=>((0,y.dispatch)(Ne.store).setDefaults(Fe,{blockPresets:{}}),t=>{if(!Me(t))return(0,b.jsx)(e,{...t});const{name:o,attributes:n,setAttributes:s}=t,[r,a]=(0,f.useState)(void 0),[i,l]=(0,f.useState)(0),c=(0,y.useSelect)((e=>e(Ne.store).get(Fe,"blockPresets")),[]),m=c?.[o],u=(0,Re.getBlockSupport)(o,"snowmonkeyeditor.blockPresets"),p=u?.ignore||[],v=({blockName:e,presetName:t,preset:o})=>(0,b.jsxs)("div",{className:"sme-editor-block-presets__preset",children:[(0,b.jsx)(g.Button,{onClick:()=>{const t=(0,Re.getBlockType)(e),n={};Object.keys(t.attributes).forEach((e=>{n[e]=void 0})),Ae.forEach((e=>{delete n[e],delete o[e]})),p.forEach((e=>{delete n[e],delete o[e]})),s({...n,...o})},variant:"secondary",children:t}),(0,b.jsx)(g.Button,{label:(0,h.__)("Remove this preset","snow-monkey-editor"),onClick:()=>{const o={...c};delete o?.[e]?.[t],(0,y.dispatch)(Ne.store).set(Fe,"blockPresets",o),l(i+1)},variant:"tertiary",children:"x"})]});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e,{...t}),(0,b.jsx)(d.InspectorControls,{children:(0,b.jsxs)(g.PanelBody,{title:(0,h.__)("Presets","snow-monkey-editor"),children:[!!m&&!!Object.values(m)&&(0,b.jsx)("div",{className:"sme-editor-block-presets",children:Object.values(m).map(((e,t)=>{const n=Object.keys(m)[t];return(0,b.jsx)(v,{blockName:o,presetName:n,preset:e},t)}))}),(0,b.jsxs)("div",{className:"sme-editor-block-presets-inserter",children:[(0,b.jsx)("h3",{className:"sme-editor-block-presets-inserter__title",children:(0,h.__)("Save current settings as a preset","snow-monkey-editor")}),(0,b.jsxs)("div",{className:"sme-editor-block-presets-inserter__control",children:[(0,b.jsx)(g.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,value:r||"",placeholder:(0,h.__)("Input the preset name.","snow-monkey-editor"),onChange:e=>a(e)}),(0,b.jsx)(g.Button,{variant:"primary",disabled:!r,onClick:async()=>{const e={...n};Ae.forEach((t=>{delete e[t]})),p.forEach((t=>{delete e[t]}));const t={...c,[o]:{...m,[r]:{...e}}};(0,y.dispatch)(Ne.store).set(Fe,"blockPresets",t),a(void 0)},children:(0,h.__)("Save","snow-monkey-editor")})]})]})]})})]})})),"withInspectorControl");(0,Se.addFilter)("editor.BlockEdit","snow-monkey-editor/block-presets/with-inspector-controls",Be,100),(0,Se.addFilter)("blocks.registerBlockType","snow-monkey-editor/block-presets/support",((e,t)=>{let o=!1;return"core/button"===t?o={ignore:["url","title","text","linkTarget","rel"]}:"core/cover"===t?o={ignore:["url"]}:"core/list"===t?o={ignore:["values"]}:"core/paragraph"!==t&&"core/group"!==t&&"core/columns"!==t&&"core/column"!==t&&"core/heading"!==t||(o=!0),!1===o?e:{...e,supports:{...e.supports,snowmonkeyeditor:{blockPresets:o}}}}))})()})();
     1(()=>{var e={558:e=>{"use strict";var t=function(e){return parseInt(e,16)};e.exports=function(e,n){var o,s,r=function(e){return"#"===e.charAt(0)?e.slice(1):e}(e),a=function(e){var n=e.g,o=e.b,s=e.a;return{r:t(e.r),g:t(n),b:t(o),a:+(t(s)/255).toFixed(2)}}({r:(s=3===(o=r).length||4===o.length)?"".concat(o.slice(0,1)).concat(o.slice(0,1)):o.slice(0,2),g:s?"".concat(o.slice(1,2)).concat(o.slice(1,2)):o.slice(2,4),b:s?"".concat(o.slice(2,3)).concat(o.slice(2,3)):o.slice(4,6),a:(s?"".concat(o.slice(3,4)).concat(o.slice(3,4)):o.slice(6,8))||"ff"});return function(e,t){var n,o=e.r,s=e.g,r=e.b,a=e.a,i=(n=t,!isNaN(parseFloat(n))&&isFinite(n)?t:a);return"rgba(".concat(o,", ").concat(s,", ").concat(r,", ").concat(i,")")}(a,n)}},919:e=>{e.exports=function(e){if("string"!=typeof e)throw new Error("color has to be type of `string`");if("#"===e.substr(0,1))return{hex:e,alpha:1};var t=e.replace(/\s+/g,""),n=/(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|1.0*|0??\.([0-9]{0,})))??\)/.exec(t);if(!n)throw new Error("given color ("+e+") isn't a valid rgb or rgba color");var o=parseInt(n[3],10),s=parseInt(n[4],10),r=parseInt(n[5],10),a=n[6]?/([0-9\.]+)/.exec(n[6])[0]:"1",i=(r|s<<8|o<<16|1<<24).toString(16).slice(1);return"."===a.substr(0,1)&&(a=parseFloat("0"+a)),a=parseFloat(Math.round(100*a))/100,{hex:"#"+i.toString(16),alpha:a}}},942:(e,t)=>{var n;!function(){"use strict";var o={}.hasOwnProperty;function s(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=a(e,r(n)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return s.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)o.call(e,n)&&e[n]&&(t=a(t,n));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(s.default=s,e.exports=s):void 0===(n=function(){return s}.apply(t,[]))||(e.exports=n)}()}},t={};function n(o){var s=t[o];if(void 0!==s)return s.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e={};n.r(e),n.d(e,{settings:()=>_});var t={};n.r(t),n.d(t,{settings:()=>O});var o={};n.r(o),n.d(o,{settings:()=>I});var s={};n.r(s),n.d(s,{settings:()=>V});var r={};n.r(r),n.d(r,{settings:()=>J});var a={};n.r(a),n.d(a,{settings:()=>ee});var i={};n.r(i),n.d(i,{settings:()=>ae});var l={};n.r(l),n.d(l,{settings:()=>he});var c={};n.r(c),n.d(c,{settings:()=>fe});var m={};n.r(m),n.d(m,{settings:()=>we});const u=window.lodash,d=window.wp.blockEditor,g=window.wp.components,p=window.wp.richText,b=window.wp.i18n,h=window.ReactJSXRuntime,v=(0,h.jsx)("svg",{role:"img",focusable:"false",width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,h.jsx)("path",{d:"M13.982,16.711c-0.744,1.441 -2.248,2.428 -3.982,2.428c-1.735,0 -3.238,-0.986 -3.983,-2.428c0.909,-1.213 2.355,-2.002 3.983,-2.002c1.629,0 3.074,0.789 3.982,2.002Zm-0.748,-7.657c-0.314,2.56 1.248,2.919 1.248,5.603c0,0.467 -0.072,0.918 -0.205,1.344c-1.037,-1.203 -2.57,-1.967 -4.277,-1.967c-1.708,0 -3.24,0.764 -4.277,1.967c-0.133,-0.426 -0.205,-0.877 -0.205,-1.344c0,-2.684 1.563,-3.043 1.247,-5.603c-0.362,-2.928 -4.315,-2.465 -4.315,-5.334c0,-1.579 1.279,-2.858 2.858,-2.858c1.709,0 2.765,1.558 4.692,1.558c1.926,0 2.982,-1.558 4.691,-1.558c1.578,0 2.857,1.279 2.857,2.858c0.001,2.869 -3.952,2.406 -4.314,5.334Zm-4.677,-4.947l-0.708,0c0,0.498 -0.403,0.9 -0.901,0.9c-0.498,0 -0.901,-0.402 -0.901,-0.9l-0.708,0c0,0.889 0.72,1.609 1.609,1.609c0.889,0 1.609,-0.72 1.609,-1.609Zm0.979,7.141c0,-0.312 -0.253,-0.568 -0.566,-0.568c-0.313,0 -0.567,0.256 -0.567,0.568c0,0.312 0.254,0.566 0.567,0.566c0.313,0 0.566,-0.253 0.566,-0.566Zm2.062,0c0,-0.312 -0.254,-0.568 -0.568,-0.568c-0.312,0 -0.566,0.256 -0.566,0.568c0,0.312 0.254,0.566 0.566,0.566c0.314,0 0.568,-0.253 0.568,-0.566Zm3.062,-7.141l-0.707,0c0,0.498 -0.404,0.9 -0.9,0.9c-0.498,0 -0.902,-0.402 -0.902,-0.9l-0.707,0c0,0.889 0.721,1.609 1.609,1.609c0.886,0.001 1.607,-0.72 1.607,-1.609Z"})}),x={position:"bottom left",variant:"alternate"};(0,p.registerFormatType)("snow-monkey-editor/dropdown",{title:"buttons",tagName:"sme-dropdown",className:null,edit:()=>(0,h.jsx)(d.BlockFormatControls,{children:(0,h.jsx)("div",{className:"block-editor-format-toolbar",children:(0,h.jsxs)(g.ToolbarGroup,{children:[(0,h.jsx)(g.Slot,{name:"SnowMonkey.ToolbarControls",children:e=>0!==e.length&&(0,h.jsx)(g.ToolbarItem,{children:t=>(0,h.jsx)(g.DropdownMenu,{icon:v,label:(0,b.__)("Snow Monkey Editor Controls","snow-monkey-editor"),toggleProps:t,controls:(0,u.orderBy)(e.map((([{props:e}])=>e)),"title"),popoverProps:x})})}),["sme-font-size","sme-letter-spacing","sme-line-height","sme-text-color","sme-text-gradient","sme-bg-color","sme-highlighter","sme-badge"].map((e=>(0,h.jsx)(g.Slot,{name:`SnowMonkey.ToolbarControls.${e}`},e)))]})})})});const f=e=>{if(!e)return;const{name:t,settings:n}=e;(0,p.registerFormatType)(t,n)},y=window.wp.data,C=window.wp.element,k=window.wp.keycodes;function j({name:e,shortcutType:t,shortcutCharacter:n,...o}){let s,r="SnowMonkey.ToolbarControls";return e&&(r+=`.${e}`),t&&n&&(s=k.displayShortcut[t](n)),(0,h.jsx)(g.Fill,{name:r,children:(0,h.jsx)(g.ToolbarButton,{...o,shortcut:s})})}const w=(0,b.__)("Remove formatting","snow-monkey-editor"),_={name:"snow-monkey-editor/remove-fomatting",title:w,tagName:"span",className:"sme-remove-fomatting",edit:({value:e,onChange:t})=>{const n=(0,y.useSelect)((e=>e("core/rich-text").getFormatTypes()),[]),o=(0,C.useCallback)((()=>{if(0<n.length){let o=e;n.forEach((e=>{o=(0,p.removeFormat)(o,e.name)})),t({...o})}}),[e,n]);return(0,h.jsx)(j,{icon:"editor-removeformatting",title:w,onClick:o})}};var S=n(942),N=n.n(S);const F=({name:e,value:t,onChange:n,onReset:o})=>{const[s]=(0,d.useSettings)("typography.fontSizes"),r=(0,C.useMemo)((()=>function(e,t,n){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const s=o.attributes.style;if(s)return s.replace(new RegExp("^font-size:\\s*"),"");const r=o.attributes.class;if(r){let e=r.replace(/.*has-([^\s]*)-font-size.*/,"$1"),t=(0,u.find)(n,{slug:e});if(!t&&(e=e.replace(/(\d)-([^\d])/,"$1$2",e),t=(0,u.find)(n,{slug:e}),!t))return;return t.size}}(e,t,s)),[e,t]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d.FontSizePicker,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,value:r,onChange:n,fontSizes:s}),(0,h.jsx)(g.Button,{disabled:void 0===t,variant:"secondary",size:"small",onClick:o,children:(0,b.__)("Reset")})]})},R=({name:e,value:t,onChange:n,onReset:o,contentRef:s,settings:r})=>{const a=(0,p.useAnchor)({editableContentElement:s.current,settings:r});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:a,className:"sme-popover sme-popover--inline-font-size components-inline-color-popover",children:(0,h.jsx)("fieldset",{children:(0,h.jsx)(F,{name:e,value:t,onChange:n,onReset:o})})})},A="snow-monkey-editor/font-size",M=(0,b.__)("Font size","snow-monkey-editor"),O={name:A,title:M,tagName:"span",className:"sme-font-size",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,[r]=(0,d.useSettings)("typography.fontSizes"),[a,i]=(0,C.useState)(!1),l=(0,C.useCallback)((()=>{i(!0)}),[i]),c=(0,C.useCallback)((()=>{i(!1)}),[i]);return(0,C.useEffect)((()=>{c()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-font-size":void 0,title:M,className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:l,icon:(0,h.jsx)(g.Icon,{icon:"editor-textcolor"})},o?"sme-font-size":"sme-font-size-not-active"),a&&(0,h.jsx)(R,{name:A,value:t,onReset:()=>{n((0,p.removeFormat)(t,A)),c()},onChange:e=>{if(e){let o;if((0,u.isString)(e)||r[0]&&(0,u.isString)(r[0].size))o=e;else{if(!(0,u.isNumber)(e))return;o=`${e}px`}const s=(0,u.find)(r,{size:e});n((0,p.applyFormat)(t,{type:A,attributes:s?{class:(0,d.getFontSizeClass)(s.slug)}:{style:`font-size: ${o}`}}))}else n((0,p.removeFormat)(t,A)),c()},contentRef:s,settings:{...O,isActive:o}})]})}},B=({name:e,title:t,value:n,onChange:o,onReset:s})=>{const r=(0,C.useMemo)((()=>function(e,t){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const o=n.attributes?.style;return o?parseFloat(o.replace(new RegExp("^letter-spacing:\\s*"),"").replace("rem","")):void 0}(e,n)),[e,n]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(g.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:t,value:r,onChange:o,min:"0",max:"2",step:"0.1",initialPosition:void 0}),(0,h.jsx)(g.Button,{disabled:void 0===n,variant:"secondary",onClick:s,children:(0,b.__)("Reset")})]})},E=({name:e,title:t,value:n,onChange:o,onReset:s,contentRef:r,settings:a})=>{const i=(0,p.useAnchor)({editableContentElement:r.current,settings:a});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:i,className:"sme-popover sme-popover--inline-letter-spacing components-inline-color-popover",children:(0,h.jsx)("fieldset",{children:(0,h.jsx)(B,{name:e,title:t,value:n,onChange:o,onReset:s})})})},P="snow-monkey-editor/letter-spacing",z=(0,b.__)("Letter spacing","snow-monkey-editor"),I={name:P,title:z,tagName:"span",className:"sme-letter-spacing",attributes:{style:"style"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,[r,a]=(0,C.useState)(!1),i=(0,C.useCallback)((()=>{a(!0)}),[a]),l=(0,C.useCallback)((()=>{a(!1)}),[a]);return(0,C.useEffect)((()=>{l()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-letter-spacing":void 0,title:z,className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:i,icon:(0,h.jsx)(g.Icon,{icon:"controls-pause"})},o?"sme-letter-spacing":"sme-letter-spacing-not-active"),r&&(0,h.jsx)(E,{name:P,title:z,value:t,onReset:()=>{n((0,p.removeFormat)(t,P)),l()},onChange:e=>{n((0,p.applyFormat)(t,{type:P,attributes:{style:`letter-spacing: ${e}rem`}}))},contentRef:s,settings:{...I,isActive:o}})]})}},T=({name:e,title:t,value:n,onChange:o,onReset:s})=>{const r=(0,C.useMemo)((()=>function(e,t){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const o=n.attributes.style;return o?parseFloat(o.replace(new RegExp("^line-height:\\s*"),"")):void 0}(e,n)),[e,n]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(g.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:t,value:r,onChange:o,min:"0",max:"5",step:"0.1",initialPosition:void 0}),(0,h.jsx)(g.Button,{disabled:void 0===n,variant:"secondary",onClick:s,children:(0,b.__)("Reset")})]})},$=({name:e,title:t,value:n,onChange:o,onReset:s,contentRef:r,settings:a})=>{const i=(0,p.useAnchor)({editableContentElement:r.current,settings:a});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:i,className:"sme-popover sme-popover--inline-line-height components-inline-color-popover",children:(0,h.jsx)("fieldset",{children:(0,h.jsx)(T,{name:e,title:t,value:n,onChange:o,onReset:s})})})},H="snow-monkey-editor/line-height",L=(0,b.__)("Line height","snow-monkey-editor"),V={name:H,title:L,tagName:"span",className:"sme-line-height",attributes:{style:"style"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,[r,a]=(0,C.useState)(!1),i=(0,C.useCallback)((()=>{a(!0)}),[a]),l=(0,C.useCallback)((()=>{a(!1)}),[a]);return(0,C.useEffect)((()=>{l()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-line-height":void 0,title:L,className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:i,icon:(0,h.jsx)(g.Icon,{icon:"editor-insertmore"})},o?"sme-line-height":"sme-line-height-not-active"),r&&(0,h.jsx)($,{name:H,title:L,value:t,onReset:()=>{n((0,p.removeFormat)(t,H)),l()},onChange:e=>{n((0,p.applyFormat)(t,{type:H,attributes:{style:`line-height: ${e}`}}))},contentRef:s,settings:{...V,isActive:o}})]})}};function G(e,t,n){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const s=o.attributes.style;if(s)return s.replace(new RegExp("^color:\\s*"),"");const r=o.attributes.class;if(r){const e=r.replace(/.*has-([^\s]*)-color.*/,"$1");return(0,d.getColorObjectByAttributeValues)(n,e).color}}const Z=({name:e,value:t,onChange:n})=>{const o=(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),s=(0,C.useMemo)((()=>G(e,t,o?.colors)),[e,t,o?.colors]);return(0,h.jsx)(d.__experimentalColorGradientControl,{label:(0,b.__)("Color","snow-monkey-editor"),colorValue:s,onColorChange:n,...o,__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},D=({name:e,value:t,onChange:n,contentRef:o,settings:s})=>{const r=(0,p.useAnchor)({editableContentElement:o.current,settings:s});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:r,className:"sme-popover sme-popover--inline-color components-inline-color-popover",children:(0,h.jsx)(Z,{name:e,value:t,onChange:n})})},U="snow-monkey-editor/text-color",q=(0,b.__)("Text color","snow-monkey-editor"),J={name:U,title:q,tagName:"span",className:"sme-text-color",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,r=(0,y.useSelect)((e=>{var t;return null!==(t=e(d.store).getSettings()?.colors)&&void 0!==t?t:[]}),[]),a=(0,C.useMemo)((()=>G(U,t,r)),[t,r]),[i,l]=(0,C.useState)(!1),c=(0,C.useCallback)((()=>{l(!0)}),[l]),m=(0,C.useCallback)((()=>{l(!1)}),[l]);return(0,C.useEffect)((()=>{m()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-text-color":void 0,title:q,style:{color:a},className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:c,icon:(0,h.jsx)(g.Icon,{icon:"edit"})},o?"sme-text-color":"sme-text-color-not-active"),i&&(0,h.jsx)(D,{name:U,value:t,onChange:e=>{if(e){const o=(0,d.getColorObjectByColorValue)(r,e);n((0,p.applyFormat)(t,{type:U,attributes:o?{class:(0,d.getColorClassName)("color",o.slug)}:{style:`color: ${e}`}}))}else n((0,p.removeFormat)(t,U)),m()},contentRef:s,settings:{...J,isActive:o}})]})}};function X(e,t,n){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const s=o.attributes?.style;if(s)return s.replace(new RegExp("^background-image:\\s*"),"");const r=o.attributes?.class;if(r){let e=r.replace(/.*has-([^\s]*)-gradient-background.*/,"$1"),t=(0,u.find)(n,{slug:e});if(!t&&(e=e.replace(/(\d)-([^\d])/,"$1$2",e),t=(0,u.find)(n,{slug:e}),!t))return;return t.gradient}}const K=({name:e,value:t,onChange:n})=>{const o=(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),s=(0,C.useMemo)((()=>X(e,t,o?.gradients)),[e,t,o?.gradients]);return(0,h.jsx)(d.__experimentalColorGradientControl,{label:(0,b.__)("Color","snow-monkey-editor"),gradientValue:s,onGradientChange:n,...o,__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},Q=({name:e,value:t,onChange:n,contentRef:o,settings:s})=>{const r=(0,p.useAnchor)({editableContentElement:o.current,settings:s});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:r,className:"sme-popover sme-popover--inline-gradient components-inline-gradient-popover",children:(0,h.jsx)(K,{name:e,value:t,onChange:n})})},W="snow-monkey-editor/text-gradient",Y=(0,b.__)("Text gradient","snow-monkey-editor"),ee={name:W,title:Y,tagName:"span",className:"sme-text-gradient",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,r=(0,y.useSelect)((e=>{var t;return null!==(t=e(d.store).getSettings()?.gradients)&&void 0!==t?t:[]}),[]),a=(0,C.useMemo)((()=>X(W,t,r)),[t,r]),[i,l]=(0,C.useState)(!1),c=(0,C.useCallback)((()=>{l(!0)}),[l]),m=(0,C.useCallback)((()=>{l(!1)}),[l]);return(0,C.useEffect)((()=>{m()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-text-gradient":void 0,title:Y,style:{"--sme--gradient":a},className:N()("sme-toolbar-button","sme-toolbar-button--text-gradient",{"is-pressed":!!o}),onClick:c,icon:(0,h.jsx)(g.Icon,{icon:"edit"})},o?"sme-text-gradient":"sme-text-gradient-not-active"),i&&(0,h.jsx)(Q,{name:W,value:t,onChange:e=>{if(e){const o=(0,d.getGradientSlugByValue)(r,e);n((0,p.applyFormat)(t,{type:W,attributes:o?{class:(0,d.__experimentalGetGradientClass)(o)}:{style:`background-image: ${e}`}}))}else n((0,p.removeFormat)(t,W)),m()},contentRef:s,settings:{...ee,isActive:o}})]})}};function te(e,t,n){const o=(0,p.getActiveFormat)(t,e);if(!o)return;const s=o.attributes.style;if(s)return s.replace(new RegExp("^background-color:\\s*"),"");const r=o.attributes.class;if(r){const e=r.replace(/.*has-([^\s]*)-background-color.*/,"$1");return(0,d.getColorObjectByAttributeValues)(n,e).color}}const ne=({name:e,value:t,onChange:n})=>{const o=(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),s=(0,C.useMemo)((()=>te(e,t,o?.colors)),[e,t,o?.colors]);return(0,h.jsx)(d.__experimentalColorGradientControl,{label:(0,b.__)("Color","snow-monkey-editor"),colorValue:s,onColorChange:n,...o,__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},oe=({name:e,value:t,onChange:n,contentRef:o,settings:s})=>{const r=(0,p.useAnchor)({editableContentElement:o.current,settings:s});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:r,className:"sme-popover sme-popover--inline-background-color components-inline-color-popover",children:(0,h.jsx)(ne,{name:e,value:t,onChange:n})})},se="snow-monkey-editor/bg-color",re=(0,b.__)("Background color","snow-monkey-editor"),ae={name:se,title:re,tagName:"span",className:"sme-bg-color",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,r=(0,y.useSelect)((e=>{var t;return null!==(t=e(d.store).getSettings()?.colors)&&void 0!==t?t:[]}),[]),a=(0,C.useMemo)((()=>te(se,t,r)),[t,r]),[i,l]=(0,C.useState)(!1),c=(0,C.useCallback)((()=>{l(!0)}),[l]),m=(0,C.useCallback)((()=>{l(!1)}),[l]);return(0,C.useEffect)((()=>{m()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-bg-color":void 0,title:re,style:{color:a},className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:c,icon:(0,h.jsx)(g.Icon,{icon:"tag"})},o?"sme-bg-color":"sme-bg-color-not-active"),i&&(0,h.jsx)(oe,{name:se,value:t,onChange:e=>{if(e){const o=(0,d.getColorObjectByColorValue)(r,e);n((0,p.applyFormat)(t,{type:se,attributes:o?{class:(0,d.getColorClassName)("background-color",o.slug)}:{style:`background-color: ${e}`}}))}else n((0,p.removeFormat)(t,se)),m()},contentRef:s,settings:{...ae,isActive:o}})]})}};var ie=n(558),le=n.n(ie),ce=n(919),me=n.n(ce);function ue(e,t){const n=(0,p.getActiveFormat)(t,e);if(!n)return;const o=n.attributes.style;if(!o)return;const s=o.match(/(#[0-9A-F]{3,6}) /i);if(s)return s;const r=o.match(/,\s*?(rgba?\([^)]+\)) /i);return r?function(e){if(!e||4===e.length)return e;const t=e.match(/^#([0-9A-F])\1([0-9A-F])\1([0-9A-F])\1$/i);return t?`#${t[1].slice(0,1)}${t[2].slice(0,1)}${t[3].slice(0,1)}`:e}(me()(r[1]).hex):void 0}const de=({name:e,value:t,onChange:n})=>{const o=(0,d.__experimentalUseMultipleOriginColorsAndGradients)(),s=(0,C.useMemo)((()=>ue(e,t)),[e,t,o?.colors]);return(0,h.jsx)(d.__experimentalColorGradientControl,{label:(0,b.__)("Color","snow-monkey-editor"),colorValue:s,onColorChange:n,...o,__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0})},ge=({name:e,value:t,onChange:n,contentRef:o,settings:s})=>{const r=(0,p.useAnchor)({editableContentElement:o.current,settings:s});return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:r,className:"sme-popover sme-popover--inline-color components-inline-color-popover",children:(0,h.jsx)(de,{name:e,value:t,onChange:n})})},pe="snow-monkey-editor/highlighter",be=(0,b.__)("Highlighter","snow-monkey-editor"),he={name:pe,title:be,tagName:"span",className:"sme-highlighter",attributes:{style:"style"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,r=(0,y.useSelect)((e=>{var t;return null!==(t=e(d.store).getSettings()?.colors)&&void 0!==t?t:[]}),[]),a=(0,C.useMemo)((()=>ue(pe,t)),[t,r]),[i,l]=(0,C.useState)(!1),c=(0,C.useCallback)((()=>{l(!0)}),[l]),m=(0,C.useCallback)((()=>{l(!1)}),[l]);return(0,C.useEffect)((()=>{m()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-highlighter":void 0,title:be,style:{color:a},className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:c,icon:(0,h.jsx)(g.Icon,{icon:"tag"})},o?"sme-highlighter":"sme-highlighter-not-active"),i&&(0,h.jsx)(ge,{name:pe,value:t,onChange:e=>{e?(e.match(/^#/)&&(e=le()(e,.5)),n((0,p.applyFormat)(t,{type:pe,attributes:{style:`background-image: linear-gradient(transparent 60%, ${e} 60%)`}}))):(n((0,p.removeFormat)(t,pe)),m())},contentRef:s,settings:{...he,isActive:o}})]})}},ve="snow-monkey-editor/badge",xe=(0,b.__)("Badge","snow-monkey-editor"),fe={name:ve,title:xe,tagName:"span",className:"sme-badge",attributes:{style:"style",class:"class"},edit:e=>{const{value:t,onChange:n,isActive:o,contentRef:s}=e,r=(0,y.useSelect)((e=>{var t;return null!==(t=e(d.store).getSettings()?.colors)&&void 0!==t?t:[]}),[]),a=(0,C.useMemo)((()=>te(ve,t,r)),[t,r]),[i,l]=(0,C.useState)(!1),c=(0,C.useCallback)((()=>{l(!0)}),[l]),m=(0,C.useCallback)((()=>{l(!1)}),[l]);return(0,C.useEffect)((()=>{m()}),[t.start]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{name:o?"sme-badge":void 0,title:xe,style:{color:a},className:N()("sme-toolbar-button",{"is-pressed":!!o}),onClick:c,icon:(0,h.jsx)(g.Icon,{icon:"tag"})},o?"sme-badge":"sme-badge-not-active"),i&&(0,h.jsx)(oe,{value:t,onChange:e=>{if(e){const o=(0,d.getColorObjectByColorValue)(r,e);n((0,p.applyFormat)(t,{type:ve,attributes:o?{class:(0,d.getColorClassName)("background-color",o.slug)}:{style:`background-color: ${e}`}}))}else n((0,p.removeFormat)(t,ve)),m()},contentRef:s,settings:{...fe,isActive:o}})]})}},ye="snow-monkey-editor/br",Ce=(0,b.__)("Line break per screen size","snow-monkey-editor"),ke={type:ye,innerHTML:"<br />"};function je({value:e,onChange:t,activeObjectAttributes:n,contentRef:o}){const s=e.replacements.slice()?.[e.start]?.attributes?.class,[r,a]=(0,C.useState)(!!s?.match(/sme-br--disable:desktop/)),[i,l]=(0,C.useState)(!!s?.match(/sme-br--disable:tablet/)),[c,m]=(0,C.useState)(!!s?.match(/sme-br--disable:mobile/)),u=(0,p.useAnchor)({editableContentElement:o.current,settings:we}),d=(0,C.useCallback)((o=>{a(!o);const s=e.replacements.slice();s[e.start]={...ke,attributes:{...n,class:N()({"sme-br--disable:desktop":!o,"sme-br--disable:tablet":i,"sme-br--disable:mobile":c})}},t({...e,replacements:s})}),[i,c]),v=(0,C.useCallback)((o=>{l(!o);const s=e.replacements.slice();s[e.start]={...ke,attributes:{...n,class:N()({"sme-br--disable:desktop":r,"sme-br--disable:tablet":!o,"sme-br--disable:mobile":c})}},t({...e,replacements:s})}),[r,c]),x=(0,C.useCallback)((o=>{m(!o);const s=e.replacements.slice();s[e.start]={...ke,attributes:{...n,class:N()({"sme-br--disable:desktop":r,"sme-br--disable:tablet":i,"sme-br--disable:mobile":!o})}},t({...e,replacements:s})}),[r,i]);return(0,h.jsx)(g.Popover,{placement:"bottom",shift:!0,focusOnMount:!1,anchor:u,className:"sme-popover sme-popover--inline-br",children:(0,h.jsxs)("div",{style:{width:"260px"},children:[(0,h.jsx)(g.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,b.__)("Line breaks when on the desktop","snow-monkey-editor"),checked:!r,onChange:d,disabled:i&&c}),(0,h.jsx)(g.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,b.__)("Line breaks when on the tablet","snow-monkey-editor"),checked:!i,onChange:v,disabled:r&&c}),(0,h.jsx)(g.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,b.__)("Line breaks when on the mobile","snow-monkey-editor"),checked:!c,onChange:x,disabled:r&&i})]})})}const we={name:ye,title:Ce,tagName:"span",className:"sme-br",attributes:{class:"class"},interactive:!0,contentEditable:!1,edit:function({value:e,onChange:t,onFocus:n,isObjectActive:o,activeObjectAttributes:s,contentRef:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(j,{icon:(0,h.jsx)("span",{className:"dashicon",children:(0,h.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,h.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0224 5.25C18.4366 5.25 18.7724 5.58579 18.7724 6V15C18.7724 15.4142 18.4366 15.75 18.0224 15.75L18.0112 15.7499L18 15.75H10.0784V19L4.5 14.8349L10.0784 10.6699V14.25H17.2724V6C17.2724 5.58579 17.6082 5.25 18.0224 5.25Z",fill:"currentColor"})})}),title:Ce,onClick:()=>{const o=(0,p.insertObject)(e,{...ke},e.end,e.end);o.start=o.end-1,t(o),n()}}),o&&(0,h.jsx)(je,{value:e,onChange:t,activeObjectAttributes:s,contentRef:r})]})}};f(e),f(t),f(o),f(s),f(r),f(a),f(i),f(l),f(c),f(m);const _e=window.wp.compose,Se=window.wp.hooks;(0,Se.addFilter)("editor.BlockListBlock","snow-monkey-editor/ordered-list/orderd-styles",(0,_e.createHigherOrderComponent)((e=>t=>{const{attributes:n,name:o}=t?.block,{start:s,reversed:r,ordered:a,className:i}=n;return"core/list"!==o?(0,h.jsx)(e,{...t}):(i?.match("is-style-sme-ordered-list-square")||i?.match("is-style-sme-ordered-list-circle"))&&a?(0,h.jsx)(e,{...t,wrapperProps:{...t.wrapperProps,style:{...t.wrapperProps?.style,counterReset:r?`sme-count ${s+1}`:"sme-count "+(s-1)}}}):(0,h.jsx)(e,{...t})}),"withSnowMonkeyEditorOrderdListOrderdStyles"));const Ne=window.wp.blocks,Fe=window.wp.preferences;const Re="snow-monkey-editor/preferences",Ae=["allowedBlocks","content","templateLock","placeholder"],Me=e=>!(({name:e}={})=>!(0,Ne.hasBlockSupport)(e,"snowmonkeyeditor.blockPresets"))(e)&&(!!function(e,t){if(!e||!Object.keys(e).length)return!1;const n=function(e){return(0,Se.applyFilters)("SnowMonkeyEditor.extension.allowedRoles",["administrator","editor","author","contributor"],e)}(t);return 0<e.roles.filter((e=>-1<n.indexOf(e))).length}(snowmonkeyeditor?.currentUser,"block-presets")&&!!(0,Ne.getBlockType)(e.name)),Oe=(0,_e.createHigherOrderComponent)((e=>((0,y.dispatch)(Fe.store).setDefaults(Re,{blockPresets:{}}),t=>{if(!Me(t))return(0,h.jsx)(e,{...t});const{name:n,attributes:o,setAttributes:s}=t,[r,a]=(0,C.useState)(void 0),[i,l]=(0,C.useState)(0),c=(0,y.useSelect)((e=>e(Fe.store).get(Re,"blockPresets")),[]),m=c?.[n],u=(0,Ne.getBlockSupport)(n,"snowmonkeyeditor.blockPresets"),p=u?.ignore||[],v=({blockName:e,presetName:t,preset:n})=>(0,h.jsxs)("div",{className:"sme-editor-block-presets__preset",children:[(0,h.jsx)(g.Button,{onClick:()=>{const t=(0,Ne.getBlockType)(e),o={};Object.keys(t.attributes).forEach((e=>{o[e]=void 0})),Ae.forEach((e=>{delete o[e],delete n[e]})),p.forEach((e=>{delete o[e],delete n[e]})),s({...o,...n})},variant:"secondary",children:t}),(0,h.jsx)(g.Button,{label:(0,b.__)("Remove this preset","snow-monkey-editor"),onClick:()=>{const n={...c};delete n?.[e]?.[t],(0,y.dispatch)(Fe.store).set(Re,"blockPresets",n),l(i+1)},variant:"tertiary",children:"x"})]});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(e,{...t}),(0,h.jsx)(d.InspectorControls,{children:(0,h.jsxs)(g.PanelBody,{title:(0,b.__)("Presets","snow-monkey-editor"),children:[!!m&&!!Object.values(m)&&(0,h.jsx)("div",{className:"sme-editor-block-presets",children:Object.values(m).map(((e,t)=>{const o=Object.keys(m)[t];return(0,h.jsx)(v,{blockName:n,presetName:o,preset:e},t)}))}),(0,h.jsxs)("div",{className:"sme-editor-block-presets-inserter",children:[(0,h.jsx)("h3",{className:"sme-editor-block-presets-inserter__title",children:(0,b.__)("Save current settings as a preset","snow-monkey-editor")}),(0,h.jsxs)("div",{className:"sme-editor-block-presets-inserter__control",children:[(0,h.jsx)(g.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,value:r||"",placeholder:(0,b.__)("Input the preset name.","snow-monkey-editor"),onChange:e=>a(e)}),(0,h.jsx)(g.Button,{variant:"primary",disabled:!r,onClick:async()=>{const e={...o};Ae.forEach((t=>{delete e[t]})),p.forEach((t=>{delete e[t]}));const t={...c,[n]:{...m,[r]:{...e}}};(0,y.dispatch)(Fe.store).set(Re,"blockPresets",t),a(void 0)},children:(0,b.__)("Save","snow-monkey-editor")})]})]})]})})]})})),"withInspectorControl");(0,Se.addFilter)("editor.BlockEdit","snow-monkey-editor/block-presets/with-inspector-controls",Oe,100),(0,Se.addFilter)("blocks.registerBlockType","snow-monkey-editor/block-presets/support",((e,t)=>{let n=!1;return"core/button"===t?n={ignore:["url","title","text","linkTarget","rel"]}:"core/cover"===t?n={ignore:["url"]}:"core/list"===t?n={ignore:["values"]}:"core/paragraph"!==t&&"core/group"!==t&&"core/columns"!==t&&"core/column"!==t&&"core/heading"!==t||(n=!0),!1===n?e:{...e,supports:{...e.supports,snowmonkeyeditor:{blockPresets:n}}}}))})()})();
  • snow-monkey-editor/trunk/readme.txt

    r3308832 r3374099  
    55Requires at least: 6.8
    66Tested up to: 6.8
    7 Stable tag: 11.0.2
     7Stable tag: 11.0.3
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    194194== Changelog ==
    195195
     196= 11.0.3 =
     197* Fixed an issue where the formatting popover would not follow the page scroll.
     198
    196199= 11.0.2 =
    197200* Adjusted the display position of the block extension settings panel popover.
  • snow-monkey-editor/trunk/snow-monkey-editor.php

    r3308832 r3374099  
    22/**
    33 * Plugin name: Snow Monkey Editor
    4  * Version: 11.0.2
     4 * Version: 11.0.3
    55 * Description: Extends gutenberg block editor
    66 * Author: inc2734
  • snow-monkey-editor/trunk/src/format/badge/editor.js

    r3254519 r3374099  
    22
    33import {
    4     useSettings,
    54    getColorClassName,
    65    getColorObjectByColorValue,
     6    store as blockEditorStore,
    77} from '@wordpress/block-editor';
    88
    99import { Icon } from '@wordpress/components';
    10 import { useState, useMemo } from '@wordpress/element';
     10import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
     11import { useSelect } from '@wordpress/data';
    1112import { removeFormat, applyFormat } from '@wordpress/rich-text';
    1213import { __ } from '@wordpress/i18n';
     
    2324
    2425const Edit = ( props ) => {
    25     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     26    const { value, onChange, isActive, contentRef } = props;
    2627
    27     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    28         'color.palette.custom',
    29         'color.palette.theme',
    30         'color.palette.default'
     28    const colors = useSelect(
     29        ( select ) => select( blockEditorStore ).getSettings()?.colors ?? [],
     30        []
    3131    );
    3232
    33     const colors = useMemo(
    34         () => [
    35             ...( userPalette || [] ),
    36             ...( themePalette || [] ),
    37             ...( defaultPalette || [] ),
    38         ],
    39         [ userPalette, themePalette, defaultPalette ]
     33    const activeColor = useMemo(
     34        () => getActiveBackgroundColor( name, value, colors ),
     35        [ value, colors ]
    4036    );
    4137
    4238    const [ isAddingColor, setIsAddingColor ] = useState( false );
    4339
    44     const activeColor = useMemo( () => {
    45         return getActiveBackgroundColor( name, value, colors );
    46     }, [ value, colors ] );
     40    const openModal = useCallback( () => {
     41        setIsAddingColor( true );
     42    }, [ setIsAddingColor ] );
     43
     44    const closeModal = useCallback( () => {
     45        setIsAddingColor( false );
     46    }, [ setIsAddingColor ] );
     47
     48    useEffect( () => {
     49        closeModal();
     50    }, [ value.start ] );
    4751
    4852    return (
     
    5660                    'is-pressed': !! isActive,
    5761                } ) }
    58                 onClick={ () => {
    59                     setIsAddingColor( ! isAddingColor );
    60                 } }
     62                onClick={ openModal }
    6163                icon={ <Icon icon="tag" /> }
    6264            />
     
    6466            { isAddingColor && (
    6567                <InlineColorUI
    66                     name={ name }
    67                     activeAttributes={ activeAttributes }
    6868                    value={ value }
    69                     onClose={ () => setIsAddingColor( false ) }
    7069                    onChange={ ( newValue ) => {
    7170                        if ( !! newValue ) {
     
    9291                        } else {
    9392                            onChange( removeFormat( value, name ) );
    94                             setIsAddingColor( false );
     93                            closeModal();
    9594                        }
    9695                    } }
    9796                    contentRef={ contentRef }
    98                     settings={ settings }
     97                    settings={ { ...settings, isActive } }
    9998                />
    10099            ) }
  • snow-monkey-editor/trunk/src/format/bg-color/editor.js

    r3254519 r3374099  
    22
    33import {
    4     useSettings,
    54    getColorClassName,
    65    getColorObjectByColorValue,
     6    store as blockEditorStore,
    77} from '@wordpress/block-editor';
    88
    99import { Icon } from '@wordpress/components';
    10 import { useState, useMemo } from '@wordpress/element';
     10import { useSelect } from '@wordpress/data';
     11import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
    1112import { removeFormat, applyFormat } from '@wordpress/rich-text';
    1213import { __ } from '@wordpress/i18n';
     
    2324
    2425const Edit = ( props ) => {
    25     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     26    const { value, onChange, isActive, contentRef } = props;
    2627
    27     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    28         'color.palette.custom',
    29         'color.palette.theme',
    30         'color.palette.default'
     28    const colors = useSelect(
     29        ( select ) => select( blockEditorStore ).getSettings()?.colors ?? [],
     30        []
    3131    );
    3232
    33     const colors = useMemo(
    34         () => [
    35             ...( userPalette || [] ),
    36             ...( themePalette || [] ),
    37             ...( defaultPalette || [] ),
    38         ],
    39         [ userPalette, themePalette, defaultPalette ]
     33    const activeColor = useMemo(
     34        () => getActiveBackgroundColor( name, value, colors ),
     35        [ value, colors ]
    4036    );
    4137
    4238    const [ isAddingColor, setIsAddingColor ] = useState( false );
    4339
    44     const activeColor = useMemo( () => {
    45         return getActiveBackgroundColor( name, value, colors );
    46     }, [ value, colors ] );
     40    const openModal = useCallback( () => {
     41        setIsAddingColor( true );
     42    }, [ setIsAddingColor ] );
     43
     44    const closeModal = useCallback( () => {
     45        setIsAddingColor( false );
     46    }, [ setIsAddingColor ] );
     47
     48    useEffect( () => {
     49        closeModal();
     50    }, [ value.start ] );
    4751
    4852    return (
     
    5660                    'is-pressed': !! isActive,
    5761                } ) }
    58                 onClick={ () => {
    59                     setIsAddingColor( ! isAddingColor );
    60                 } }
     62                onClick={ openModal }
    6163                icon={ <Icon icon="tag" /> }
    6264            />
     
    6567                <InlineColorUI
    6668                    name={ name }
    67                     activeAttributes={ activeAttributes }
    6869                    value={ value }
    69                     onClose={ () => setIsAddingColor( false ) }
    7070                    onChange={ ( newValue ) => {
    7171                        if ( !! newValue ) {
     
    9292                        } else {
    9393                            onChange( removeFormat( value, name ) );
    94                             setIsAddingColor( false );
     94                            closeModal();
    9595                        }
    9696                    } }
    9797                    contentRef={ contentRef }
    98                     settings={ settings }
     98                    settings={ { ...settings, isActive } }
    9999                />
    100100            ) }
  • snow-monkey-editor/trunk/src/format/br/editor.js

    r3222617 r3374099  
    211211                    onFocus();
    212212                } }
    213                 isActive={ isObjectActive }
    214213            />
    215214
  • snow-monkey-editor/trunk/src/format/component/inline-background-color.js

    r3254519 r3374099  
    11import {
    22    getColorObjectByAttributeValues,
    3     useCachedTruthy,
    4     useSettings,
    53    __experimentalColorGradientControl as ColorGradientControl,
    64    __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
     
    86
    97import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    10 import { withSpokenMessages, Popover } from '@wordpress/components';
     8import { Popover } from '@wordpress/components';
    119import { useMemo } from '@wordpress/element';
    1210import { __ } from '@wordpress/i18n';
     
    4038
    4139const ColorPicker = ( { name, value, onChange } ) => {
    42     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    43         'color.palette.custom',
    44         'color.palette.theme',
    45         'color.palette.default'
    46     );
    47 
    48     const colors = useMemo(
    49         () => [
    50             ...( userPalette || [] ),
    51             ...( themePalette || [] ),
    52             ...( defaultPalette || [] ),
    53         ],
    54         [ userPalette, themePalette, defaultPalette ]
    55     );
     40    const multipleOriginColorsAndGradients =
     41        useMultipleOriginColorsAndGradients();
    5642
    5743    const activeBackgroundColor = useMemo(
    58         () => getActiveBackgroundColor( name, value, colors ),
    59         [ name, value, colors ]
     44        () =>
     45            getActiveBackgroundColor(
     46                name,
     47                value,
     48                multipleOriginColorsAndGradients?.colors
     49            ),
     50        [ name, value, multipleOriginColorsAndGradients?.colors ]
    6051    );
    6152
     
    6556            colorValue={ activeBackgroundColor }
    6657            onColorChange={ onChange }
    67             { ...useMultipleOriginColorsAndGradients() }
     58            { ...multipleOriginColorsAndGradients }
    6859            __experimentalHasMultipleOrigins={ true }
    6960            __experimentalIsRenderedInSidebar={ true }
     
    7667    value,
    7768    onChange,
    78     onClose,
    7969    contentRef,
    8070    settings,
     
    8575    } );
    8676
    87     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    88     popoverAnchor.getBoundingClientRect = () => cachedRect;
    89 
    9077    return (
    9178        <Popover
     79            placement="bottom"
     80            shift={ true }
     81            focusOnMount={ false }
    9282            anchor={ popoverAnchor }
    93             onClose={ onClose }
    9483            className="sme-popover sme-popover--inline-background-color components-inline-color-popover"
    9584        >
     
    9988};
    10089
    101 export default withSpokenMessages( InlineBackgroundColorUI );
     90export default InlineBackgroundColorUI;
  • snow-monkey-editor/trunk/src/format/component/inline-color.js

    r3254519 r3374099  
    11import {
    22    getColorObjectByAttributeValues,
    3     useCachedTruthy,
    4     useSettings,
    53    __experimentalColorGradientControl as ColorGradientControl,
    64    __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
     
    86
    97import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    10 import { withSpokenMessages, Popover } from '@wordpress/components';
     8import { Popover } from '@wordpress/components';
    119import { useMemo } from '@wordpress/element';
    1210import { __ } from '@wordpress/i18n';
     
    3432
    3533const ColorPicker = ( { name, value, onChange } ) => {
    36     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    37         'color.palette.custom',
    38         'color.palette.theme',
    39         'color.palette.default'
    40     );
    41 
    42     const colors = useMemo(
    43         () => [
    44             ...( userPalette || [] ),
    45             ...( themePalette || [] ),
    46             ...( defaultPalette || [] ),
    47         ],
    48         [ userPalette, themePalette, defaultPalette ]
    49     );
     34    const multipleOriginColorsAndGradients =
     35        useMultipleOriginColorsAndGradients();
    5036
    5137    const activeColor = useMemo(
    52         () => getActiveColor( name, value, colors ),
    53         [ name, value, colors ]
     38        () =>
     39            getActiveColor(
     40                name,
     41                value,
     42                multipleOriginColorsAndGradients?.colors
     43            ),
     44        [ name, value, multipleOriginColorsAndGradients?.colors ]
    5445    );
    5546
     
    5950            colorValue={ activeColor }
    6051            onColorChange={ onChange }
    61             { ...useMultipleOriginColorsAndGradients() }
     52            { ...multipleOriginColorsAndGradients }
    6253            __experimentalHasMultipleOrigins={ true }
    6354            __experimentalIsRenderedInSidebar={ true }
     
    6657};
    6758
    68 const InlineColorUI = ( {
    69     name,
    70     value,
    71     onChange,
    72     onClose,
    73     contentRef,
    74     settings,
    75 } ) => {
     59const InlineColorUI = ( { name, value, onChange, contentRef, settings } ) => {
    7660    const popoverAnchor = useAnchor( {
    7761        editableContentElement: contentRef.current,
     
    7963    } );
    8064
    81     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    82     popoverAnchor.getBoundingClientRect = () => cachedRect;
    83 
    8465    return (
    8566        <Popover
     67            placement="bottom"
     68            shift={ true }
     69            focusOnMount={ false }
    8670            anchor={ popoverAnchor }
    87             value={ value }
    88             onClose={ onClose }
    8971            className="sme-popover sme-popover--inline-color components-inline-color-popover"
    9072        >
     
    9476};
    9577
    96 export default withSpokenMessages( InlineColorUI );
     78export default InlineColorUI;
  • snow-monkey-editor/trunk/src/format/component/inline-font-size.js

    r3274014 r3374099  
    33import {
    44    FontSizePicker as BaseFontSizePicker,
    5     useCachedTruthy,
    65    useSettings,
    76} from '@wordpress/block-editor';
    87
    98import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    10 import { withSpokenMessages, Popover, Button } from '@wordpress/components';
     9import { Popover, Button } from '@wordpress/components';
    1110import { useMemo } from '@wordpress/element';
    1211import { __ } from '@wordpress/i18n';
     
    7978    value,
    8079    onChange,
    81     onClose,
    8280    onReset,
    8381    contentRef,
     
    8987    } );
    9088
    91     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    92     popoverAnchor.getBoundingClientRect = () => cachedRect;
    93 
    9489    return (
    9590        <Popover
     91            placement="bottom"
     92            shift={ true }
     93            focusOnMount={ false }
    9694            anchor={ popoverAnchor }
    97             onClose={ onClose }
    9895            className="sme-popover sme-popover--inline-font-size components-inline-color-popover"
    9996        >
     
    110107};
    111108
    112 export default withSpokenMessages( InlineFontSizeUI );
     109export default InlineFontSizeUI;
  • snow-monkey-editor/trunk/src/format/component/inline-gradient.js

    r3254519 r3374099  
    22
    33import {
    4     useSettings,
    5     useCachedTruthy,
    64    __experimentalColorGradientControl as ColorGradientControl,
    75    __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
     
    97
    108import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    11 
    12 import { withSpokenMessages, Popover } from '@wordpress/components';
     9import { Popover } from '@wordpress/components';
    1310import { useMemo } from '@wordpress/element';
    1411import { __ } from '@wordpress/i18n';
     
    5047
    5148const GradientPicker = ( { name, value, onChange } ) => {
    52     const [ userGradients, themeGradients, defaultGradients ] = useSettings(
    53         'color.gradients.custom',
    54         'color.gradients.theme',
    55         'color.gradients.default'
    56     );
    57 
    58     const gradients = useMemo(
    59         () => [
    60             ...( userGradients || [] ),
    61             ...( themeGradients || [] ),
    62             ...( defaultGradients || [] ),
    63         ],
    64         [ userGradients, themeGradients, defaultGradients ]
    65     );
     49    const multipleOriginColorsAndGradients =
     50        useMultipleOriginColorsAndGradients();
    6651
    6752    const activeGradient = useMemo(
    68         () => getActiveGradient( name, value, gradients ),
    69         [ name, value, gradients ]
     53        () =>
     54            getActiveGradient(
     55                name,
     56                value,
     57                multipleOriginColorsAndGradients?.gradients
     58            ),
     59        [ name, value, multipleOriginColorsAndGradients?.gradients ]
    7060    );
    7161
     
    7565            gradientValue={ activeGradient }
    7666            onGradientChange={ onChange }
    77             { ...useMultipleOriginColorsAndGradients() }
     67            { ...multipleOriginColorsAndGradients }
    7868            __experimentalHasMultipleOrigins={ true }
    7969            __experimentalIsRenderedInSidebar={ true }
     
    8676    value,
    8777    onChange,
    88     onClose,
    8978    contentRef,
    9079    settings,
     
    9584    } );
    9685
    97     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    98     popoverAnchor.getBoundingClientRect = () => cachedRect;
    99 
    10086    return (
    10187        <Popover
     88            placement="bottom"
     89            shift={ true }
     90            focusOnMount={ false }
    10291            anchor={ popoverAnchor }
    103             onClose={ onClose }
    10492            className="sme-popover sme-popover--inline-gradient components-inline-gradient-popover"
    10593        >
     
    113101};
    114102
    115 export default withSpokenMessages( InlineGradientUI );
     103export default InlineGradientUI;
  • snow-monkey-editor/trunk/src/format/component/inline-highlighter.js

    r3254519 r3374099  
    22
    33import {
    4     useCachedTruthy,
    5     useSettings,
    64    __experimentalColorGradientControl as ColorGradientControl,
    75    __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
     
    97
    108import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    11 
    12 import { withSpokenMessages, Popover } from '@wordpress/components';
     9import { Popover } from '@wordpress/components';
    1310import { useMemo } from '@wordpress/element';
    1411import { __ } from '@wordpress/i18n';
     
    3936
    4037const ColorPicker = ( { name, value, onChange } ) => {
    41     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    42         'color.palette.custom',
    43         'color.palette.theme',
    44         'color.palette.default'
    45     );
    46 
    47     const colors = useMemo(
    48         () => [
    49             ...( userPalette || [] ),
    50             ...( themePalette || [] ),
    51             ...( defaultPalette || [] ),
    52         ],
    53         [ userPalette, themePalette, defaultPalette ]
    54     );
     38    const multipleOriginColorsAndGradients =
     39        useMultipleOriginColorsAndGradients();
    5540
    5641    const activeColor = useMemo(
    57         () => getActiveColor( name, value, colors ),
    58         [ name, value, colors ]
     42        () =>
     43            getActiveColor(
     44                name,
     45                value,
     46                multipleOriginColorsAndGradients?.colors
     47            ),
     48        [ name, value, multipleOriginColorsAndGradients?.colors ]
    5949    );
    6050
     
    6454            colorValue={ activeColor }
    6555            onColorChange={ onChange }
    66             { ...useMultipleOriginColorsAndGradients() }
     56            { ...multipleOriginColorsAndGradients }
    6757            __experimentalHasMultipleOrigins={ true }
    6858            __experimentalIsRenderedInSidebar={ true }
     
    7161};
    7262
    73 const InlineColorUI = ( {
    74     name,
    75     value,
    76     onChange,
    77     onClose,
    78     contentRef,
    79     settings,
    80 } ) => {
     63const InlineColorUI = ( { name, value, onChange, contentRef, settings } ) => {
    8164    const popoverAnchor = useAnchor( {
    8265        editableContentElement: contentRef.current,
     
    8467    } );
    8568
    86     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    87     popoverAnchor.getBoundingClientRect = () => cachedRect;
    88 
    8969    return (
    9070        <Popover
     71            placement="bottom"
     72            shift={ true }
     73            focusOnMount={ false }
    9174            anchor={ popoverAnchor }
    92             onClose={ onClose }
    9375            className="sme-popover sme-popover--inline-color components-inline-color-popover"
    9476        >
     
    9880};
    9981
    100 export default withSpokenMessages( InlineColorUI );
     82export default InlineColorUI;
  • snow-monkey-editor/trunk/src/format/component/inline-letter-spacing.js

    r3274014 r3374099  
    1 import {
    2     RangeControl,
    3     withSpokenMessages,
    4     Popover,
    5     Button,
    6 } from '@wordpress/components';
    7 
     1import { RangeControl, Popover, Button } from '@wordpress/components';
    82import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    9 
    10 import { useCachedTruthy } from '@wordpress/block-editor';
    113import { useMemo } from '@wordpress/element';
    124import { __ } from '@wordpress/i18n';
     
    5446                disabled={ value === undefined }
    5547                variant="secondary"
    56                 isSmall
    5748                onClick={ onReset }
    5849            >
     
    6859    value,
    6960    onChange,
    70     onClose,
    7161    onReset,
    7262    contentRef,
     
    7868    } );
    7969
    80     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    81     popoverAnchor.getBoundingClientRect = () => cachedRect;
    82 
    8370    return (
    8471        <Popover
     72            placement="bottom"
     73            shift={ true }
     74            focusOnMount={ false }
    8575            anchor={ popoverAnchor }
    86             onClose={ onClose }
    8776            className="sme-popover sme-popover--inline-letter-spacing components-inline-color-popover"
    8877        >
     
    10089};
    10190
    102 export default withSpokenMessages( InlineLetterSpacingUI );
     91export default InlineLetterSpacingUI;
  • snow-monkey-editor/trunk/src/format/component/inline-line-height.js

    r3274014 r3374099  
    1 import {
    2     RangeControl,
    3     withSpokenMessages,
    4     Popover,
    5     Button,
    6 } from '@wordpress/components';
    7 
     1import { RangeControl, Popover, Button } from '@wordpress/components';
    82import { getActiveFormat, useAnchor } from '@wordpress/rich-text';
    9 
    10 import { useCachedTruthy } from '@wordpress/block-editor';
    113import { useMemo } from '@wordpress/element';
    124import { __ } from '@wordpress/i18n';
     
    4941                disabled={ value === undefined }
    5042                variant="secondary"
    51                 isSmall
    5243                onClick={ onReset }
    5344            >
     
    6354    value,
    6455    onChange,
    65     onClose,
    6656    onReset,
    6757    contentRef,
     
    7363    } );
    7464
    75     const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
    76     popoverAnchor.getBoundingClientRect = () => cachedRect;
    77 
    7865    return (
    7966        <Popover
     67            placement="bottom"
     68            shift={ true }
     69            focusOnMount={ false }
    8070            anchor={ popoverAnchor }
    81             onClose={ onClose }
    8271            className="sme-popover sme-popover--inline-line-height components-inline-color-popover"
    8372        >
     
    9584};
    9685
    97 export default withSpokenMessages( InlineLineHeightUI );
     86export default InlineLineHeightUI;
  • snow-monkey-editor/trunk/src/format/font-size/editor.js

    r3069302 r3374099  
    44import { useSettings, getFontSizeClass } from '@wordpress/block-editor';
    55import { Icon } from '@wordpress/components';
    6 import { useState } from '@wordpress/element';
     6import { useCallback, useEffect, useState } from '@wordpress/element';
    77import { removeFormat, applyFormat } from '@wordpress/rich-text';
    88import { __ } from '@wordpress/i18n';
     
    1515
    1616const Edit = ( props ) => {
    17     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     17    const { value, onChange, isActive, contentRef } = props;
    1818
    1919    const [ fontSizes ] = useSettings( 'typography.fontSizes' );
    2020    const [ isAddingFontSize, setIsAddingFontSize ] = useState( false );
     21
     22    const openModal = useCallback( () => {
     23        setIsAddingFontSize( true );
     24    }, [ setIsAddingFontSize ] );
     25
     26    const closeModal = useCallback( () => {
     27        setIsAddingFontSize( false );
     28    }, [ setIsAddingFontSize ] );
     29
     30    useEffect( () => {
     31        closeModal();
     32    }, [ value.start ] );
    2133
    2234    return (
     
    2941                    'is-pressed': !! isActive,
    3042                } ) }
    31                 onClick={ () => {
    32                     setIsAddingFontSize( ! isAddingFontSize );
    33                 } }
     43                onClick={ openModal }
    3444                icon={ <Icon icon="editor-textcolor" /> }
    3545            />
     
    3848                <InlineFontSizeUI
    3949                    name={ name }
    40                     activeAttributes={ activeAttributes }
    4150                    value={ value }
    42                     onClose={ () => setIsAddingFontSize( false ) }
    4351                    onReset={ () => {
    44                         setIsAddingFontSize( false );
    4552                        onChange( removeFormat( value, name ) );
     53                        closeModal();
    4654                    } }
    4755                    onChange={ ( newValue ) => {
     
    8189                        } else {
    8290                            onChange( removeFormat( value, name ) );
     91                            closeModal();
    8392                        }
    8493                    } }
    8594                    contentRef={ contentRef }
    86                     settings={ settings }
     95                    settings={ { ...settings, isActive } }
    8796                />
    8897            ) }
  • snow-monkey-editor/trunk/src/format/highlighter/editor.js

    r3254519 r3374099  
    22import hexToRgba from 'hex-to-rgba';
    33
    4 import { useSettings } from '@wordpress/block-editor';
     4import { store as blockEditorStore } from '@wordpress/block-editor';
    55import { Icon } from '@wordpress/components';
    6 import { useState, useMemo } from '@wordpress/element';
     6import { useSelect } from '@wordpress/data';
     7import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
    78import { removeFormat, applyFormat } from '@wordpress/rich-text';
    89import { __ } from '@wordpress/i18n';
     
    1920
    2021const Edit = ( props ) => {
    21     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     22    const { value, onChange, isActive, contentRef } = props;
    2223
    23     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    24         'color.palette.custom',
    25         'color.palette.theme',
    26         'color.palette.default'
     24    const colors = useSelect(
     25        ( select ) => select( blockEditorStore ).getSettings()?.colors ?? [],
     26        []
    2727    );
    2828
    29     const colors = useMemo(
    30         () => [
    31             ...( userPalette || [] ),
    32             ...( themePalette || [] ),
    33             ...( defaultPalette || [] ),
    34         ],
    35         [ userPalette, themePalette, defaultPalette ]
     29    const activeColor = useMemo(
     30        () => getActiveColor( name, value, colors ),
     31        [ value, colors ]
    3632    );
    3733
    3834    const [ isAddingColor, setIsAddingColor ] = useState( false );
    3935
    40     const activeColor = useMemo( () => {
    41         return getActiveColor( name, value, colors );
    42     }, [ value, colors ] );
     36    const openModal = useCallback( () => {
     37        setIsAddingColor( true );
     38    }, [ setIsAddingColor ] );
     39
     40    const closeModal = useCallback( () => {
     41        setIsAddingColor( false );
     42    }, [ setIsAddingColor ] );
     43
     44    useEffect( () => {
     45        closeModal();
     46    }, [ value.start ] );
    4347
    4448    return (
     
    5458                    'is-pressed': !! isActive,
    5559                } ) }
    56                 onClick={ () => {
    57                     setIsAddingColor( ! isAddingColor );
    58                 } }
     60                onClick={ openModal }
    5961                icon={ <Icon icon="tag" /> }
    6062            />
     
    6365                <InlineColorUI
    6466                    name={ name }
    65                     activeAttributes={ activeAttributes }
    6667                    value={ value }
    67                     onClose={ () => setIsAddingColor( false ) }
    6868                    onChange={ ( newValue ) => {
    6969                        if ( !! newValue ) {
     
    8282                        } else {
    8383                            onChange( removeFormat( value, name ) );
    84                             setIsAddingColor( false );
     84                            closeModal();
    8585                        }
    8686                    } }
    8787                    contentRef={ contentRef }
    88                     settings={ settings }
     88                    settings={ { ...settings, isActive } }
    8989                />
    9090            ) }
  • snow-monkey-editor/trunk/src/format/letter-spacing/editor.js

    r2812617 r3374099  
    22
    33import { Icon } from '@wordpress/components';
    4 import { useState } from '@wordpress/element';
     4import { useCallback, useEffect, useState } from '@wordpress/element';
    55import { removeFormat, applyFormat } from '@wordpress/rich-text';
    66import { __ } from '@wordpress/i18n';
     
    1313
    1414const Edit = ( props ) => {
    15     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     15    const { value, onChange, isActive, contentRef } = props;
    1616
    1717    const [ isAddingLetterSpacing, setIsAddingLetterSpacing ] =
    1818        useState( false );
     19
     20    const openModal = useCallback( () => {
     21        setIsAddingLetterSpacing( true );
     22    }, [ setIsAddingLetterSpacing ] );
     23
     24    const closeModal = useCallback( () => {
     25        setIsAddingLetterSpacing( false );
     26    }, [ setIsAddingLetterSpacing ] );
     27
     28    useEffect( () => {
     29        closeModal();
     30    }, [ value.start ] );
    1931
    2032    return (
     
    3143                    'is-pressed': !! isActive,
    3244                } ) }
    33                 onClick={ () => {
    34                     setIsAddingLetterSpacing( ! isAddingLetterSpacing );
    35                 } }
     45                onClick={ openModal }
    3646                icon={ <Icon icon="controls-pause" /> }
    3747            />
     
    4151                    name={ name }
    4252                    title={ title }
    43                     activeAttributes={ activeAttributes }
    4453                    value={ value }
    45                     onClose={ () => {
    46                         setIsAddingLetterSpacing( false );
    47                     } }
    4854                    onReset={ () => {
    49                         setIsAddingLetterSpacing( false );
    5055                        onChange( removeFormat( value, name ) );
     56                        closeModal();
    5157                    } }
    5258                    onChange={ ( newValue ) => {
     
    6167                    } }
    6268                    contentRef={ contentRef }
    63                     settings={ settings }
     69                    settings={ { ...settings, isActive } }
    6470                />
    6571            ) }
  • snow-monkey-editor/trunk/src/format/line-height/editor.js

    r2812617 r3374099  
    22
    33import { Icon } from '@wordpress/components';
    4 import { useState } from '@wordpress/element';
     4import { useCallback, useEffect, useState } from '@wordpress/element';
    55import { removeFormat, applyFormat } from '@wordpress/rich-text';
    66import { __ } from '@wordpress/i18n';
     
    1313
    1414const Edit = ( props ) => {
    15     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     15    const { value, onChange, isActive, contentRef } = props;
    1616
    1717    const [ isAddingLineHeight, setIsAddingLineHeight ] = useState( false );
     18
     19    const openModal = useCallback( () => {
     20        setIsAddingLineHeight( true );
     21    }, [ setIsAddingLineHeight ] );
     22
     23    const closeModal = useCallback( () => {
     24        setIsAddingLineHeight( false );
     25    }, [ setIsAddingLineHeight ] );
     26
     27    useEffect( () => {
     28        closeModal();
     29    }, [ value.start ] );
    1830
    1931    return (
     
    2840                    'is-pressed': !! isActive,
    2941                } ) }
    30                 onClick={ () => {
    31                     setIsAddingLineHeight( ! isAddingLineHeight );
    32                 } }
     42                onClick={ openModal }
    3343                icon={ <Icon icon="editor-insertmore" /> }
    3444            />
     
    3848                    name={ name }
    3949                    title={ title }
    40                     activeAttributes={ activeAttributes }
    4150                    value={ value }
    42                     onClose={ () => {
    43                         setIsAddingLineHeight( false );
    44                     } }
    4551                    onReset={ () => {
    46                         setIsAddingLineHeight( false );
    4752                        onChange( removeFormat( value, name ) );
     53                        closeModal();
    4854                    } }
    4955                    onChange={ ( newValue ) => {
     
    5864                    } }
    5965                    contentRef={ contentRef }
    60                     settings={ settings }
     66                    settings={ { ...settings, isActive } }
    6167                />
    6268            ) }
  • snow-monkey-editor/trunk/src/format/text-color/editor.js

    r3254519 r3374099  
    22
    33import {
    4     useSettings,
    54    getColorClassName,
    65    getColorObjectByColorValue,
     6    store as blockEditorStore,
    77} from '@wordpress/block-editor';
    88
    99import { Icon } from '@wordpress/components';
    10 import { useState, useMemo } from '@wordpress/element';
     10import { useSelect } from '@wordpress/data';
     11import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
    1112import { removeFormat, applyFormat } from '@wordpress/rich-text';
    1213import { __ } from '@wordpress/i18n';
     
    2324
    2425const Edit = ( props ) => {
    25     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     26    const { value, onChange, isActive, contentRef } = props;
    2627
    27     const [ userPalette, themePalette, defaultPalette ] = useSettings(
    28         'color.palette.custom',
    29         'color.palette.theme',
    30         'color.palette.default'
     28    const colors = useSelect(
     29        ( select ) => select( blockEditorStore ).getSettings()?.colors ?? [],
     30        []
    3131    );
    3232
    33     const colors = useMemo(
    34         () => [
    35             ...( userPalette || [] ),
    36             ...( themePalette || [] ),
    37             ...( defaultPalette || [] ),
    38         ],
    39         [ userPalette, themePalette, defaultPalette ]
     33    const activeColor = useMemo(
     34        () => getActiveColor( name, value, colors ),
     35        [ value, colors ]
    4036    );
    4137
    4238    const [ isAddingColor, setIsAddingColor ] = useState( false );
    4339
    44     const activeColor = useMemo( () => {
    45         return getActiveColor( name, value, colors );
    46     }, [ value, colors ] );
     40    const openModal = useCallback( () => {
     41        setIsAddingColor( true );
     42    }, [ setIsAddingColor ] );
     43
     44    const closeModal = useCallback( () => {
     45        setIsAddingColor( false );
     46    }, [ setIsAddingColor ] );
     47
     48    useEffect( () => {
     49        closeModal();
     50    }, [ value.start ] );
    4751
    4852    return (
     
    5862                    'is-pressed': !! isActive,
    5963                } ) }
    60                 onClick={ () => {
    61                     setIsAddingColor( ! isAddingColor );
    62                 } }
     64                onClick={ openModal }
    6365                icon={ <Icon icon="edit" /> }
    6466            />
     
    6769                <InlineColorUI
    6870                    name={ name }
    69                     activeAttributes={ activeAttributes }
    7071                    value={ value }
    71                     onClose={ () => setIsAddingColor( false ) }
    7272                    onChange={ ( newValue ) => {
    7373                        if ( !! newValue ) {
     
    9494                        } else {
    9595                            onChange( removeFormat( value, name ) );
    96                             setIsAddingColor( false );
     96                            closeModal();
    9797                        }
    9898                    } }
    9999                    contentRef={ contentRef }
    100                     settings={ settings }
     100                    settings={ { ...settings, isActive } }
    101101                />
    102102            ) }
  • snow-monkey-editor/trunk/src/format/text-gradient/editor.js

    r3254519 r3374099  
    22
    33import {
    4     useSettings,
    54    getGradientSlugByValue,
    65    __experimentalGetGradientClass,
     6    store as blockEditorStore,
    77} from '@wordpress/block-editor';
    88
    99import { Icon } from '@wordpress/components';
    10 import { useState, useMemo } from '@wordpress/element';
     10import { useSelect } from '@wordpress/data';
     11import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
    1112import { removeFormat, applyFormat } from '@wordpress/rich-text';
    1213import { __ } from '@wordpress/i18n';
     
    2324
    2425const Edit = ( props ) => {
    25     const { value, onChange, isActive, activeAttributes, contentRef } = props;
     26    const { value, onChange, isActive, contentRef } = props;
    2627
    27     const [ userGradients, themeGradients, defaultGradients ] = useSettings(
    28         'color.gradients.custom',
    29         'color.gradients.theme',
    30         'color.gradients.default'
     28    const gradients = useSelect(
     29        ( select ) => select( blockEditorStore ).getSettings()?.gradients ?? [],
     30        []
    3131    );
    32 
    33     const gradients = useMemo(
    34         () => [
    35             ...( userGradients || [] ),
    36             ...( themeGradients || [] ),
    37             ...( defaultGradients || [] ),
    38         ],
    39         [ userGradients, themeGradients, defaultGradients ]
    40     );
    41 
    42     const [ isAddingGradient, setIsAddingGradient ] = useState( false );
    4332
    4433    const activeGradient = useMemo( () => {
    4534        return getActiveGradient( name, value, gradients );
    4635    }, [ value, gradients ] );
     36
     37    const [ isAddingGradient, setIsAddingGradient ] = useState( false );
     38
     39    const openModal = useCallback( () => {
     40        setIsAddingGradient( true );
     41    }, [ setIsAddingGradient ] );
     42
     43    const closeModal = useCallback( () => {
     44        setIsAddingGradient( false );
     45    }, [ setIsAddingGradient ] );
     46
     47    useEffect( () => {
     48        closeModal();
     49    }, [ value.start ] );
    4750
    4851    return (
     
    6467                    }
    6568                ) }
    66                 onClick={ () => {
    67                     setIsAddingGradient( ! isAddingGradient );
    68                 } }
     69                onClick={ openModal }
    6970                icon={ <Icon icon="edit" /> }
    7071            />
     
    7374                <InlineGradientUI
    7475                    name={ name }
    75                     activeAttributes={ activeAttributes }
    7676                    value={ value }
    77                     onClose={ () => setIsAddingGradient( false ) }
    7877                    onChange={ ( newValue ) => {
    7978                        if ( !! newValue ) {
     
    9998                        } else {
    10099                            onChange( removeFormat( value, name ) );
    101                             setIsAddingGradient( false );
     100                            closeModal();
    102101                        }
    103102                    } }
    104103                    contentRef={ contentRef }
    105                     settings={ settings }
     104                    settings={ { ...settings, isActive } }
    106105                />
    107106            ) }
  • snow-monkey-editor/trunk/vendor/composer/platform_check.php

    r2899739 r3374099  
    2020        }
    2121    }
    22     trigger_error(
    23         'Composer detected issues in your platform: ' . implode(' ', $issues),
    24         E_USER_ERROR
     22    throw new \RuntimeException(
     23        'Composer detected issues in your platform: ' . implode(' ', $issues)
    2524    );
    2625}
Note: See TracChangeset for help on using the changeset viewer.