Plugin Directory

Changeset 3145550


Ignore:
Timestamp:
09/02/2024 04:58:42 PM (16 months ago)
Author:
Webaxones
Message:

Update to version 1.8.1 from GitHub

Location:
consistency
Files:
44 edited
1 copied

Legend:

Unmodified
Added
Removed
  • consistency/tags/1.8.1/build/index.asset.php

    r3142172 r3145550  
    1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => '525eca4ceb38a5bd7f50');
     1<?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => 'ab0245b936622e6790c8');
  • consistency/tags/1.8.1/build/index.js

    r3142172 r3145550  
    1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,isContentPastedRef:p}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),_=window.wp.richText,f=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof _.RichTextData,{getEntityRecord:v}=(0,p.select)("core"),{updateBlock:w}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=v("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=v("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},E=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],T=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | |&nbsp;)([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | |&nbsp;)/,replace:"$1 ",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],P=()=>{const e=(()=>{const e=v("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>W(e.slug))):e},F=()=>B.filter((e=>!0===P()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:R,getBlockAttributes:Q}=(0,p.select)("core/block-editor"),W=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},M=e=>{const t=T.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>P()?.find((t=>t.slug===e))?.value))},$=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!W(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:M(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},q=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],z=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...q].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)($,{key:s,settingSlug:e.slug,name:e.name,settingDescription:{__html:e.description}}))))))),{canUser:A}=(0,p.select)("core"),I=()=>{const e=A("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(z,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:D,getBlocks:L,getBlockAttributes:N,getSelectionStart:O,isTyping:G,getBlockSelectionStart:j}=(0,p.select)("core/block-editor"),{selectionChange:U,updateBlockAttributes:H}=(0,p.dispatch)("core/block-editor"),K=e=>{const{currentBlockId:t,isPasting:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,blocksToBeProcessed:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=R(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:c})||!(e=>{const t=Q(e);return!(!t||!t.hasOwnProperty("content")||!f(t.content)&&!k(t.content))})(t))return;let r=F();const a=D(t);let i=N(t),l=!1;Object.entries(r).forEach((([e,c])=>{if(l)return;let r,u=c.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(G()||(b=c.mask.test(h)),G()){r=O(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/&nbsp;/g)||[]).length;return l>0&&(i=a.replace(/&nbsp;/g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(c.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=c.mask.test(h)&&c.mask.test(d)}if(!b)return;if((e=>!!E.includes(e.slug))(c)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(c,m)),0!==y&&(m=p+d.replace(c.mask,u)),0===y&&(m=m.replace(c.mask,c.replace)),n)return void o(!1);if(n||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,_.create)({...n.content,text:o});c=new _.RichTextData(e)}return f(n.content)&&(c=o),void 0!==c&&(w(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m})),0===g||s)return;const v="function"==typeof c.nbMoved?c.nbMoved(d):c.nbMoved||0;let S=r.hasOwnProperty("attributeKey")?r.attributeKey:"content";v<0&&U(t,S,g+v,g+v),v>0&&U(t,S,g+1+v,g+v),0===v&&U(t,S,g,g)}))},{getSelectedBlockClientId:J,isTyping:V,getBlockAttributes:X}=(0,p.select)("core/block-editor"),Y=window.wp.blocks,Z=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,Y.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));t=t.filter((e=>!e.name.startsWith("kadence/")));const s=["core/html","core/freeform"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Processed blocks:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,isContentPastedRef:r}=(0,c.useContext)(i);void 0===r.current&&(r.current=!1),(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:a}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=v("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!a)return;const i=P();if(void 0===i)return;if(a&&!0===r.current)return r.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,localizedRuleSettings:n,blocksToBeProcessed:o}=e;let c=F();const r=L(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return o.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(E.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!E.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&H(Object.keys(i),i,!0),a.forEach((e=>{if(!o.includes(e.name))return;const n=e.clientId;e?.clientId&&K({currentBlockId:n,isPasting:!0,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,localizedRuleSettings:i,blocksToBeProcessed:o});const l=J();if(null===l||!c)return;const u=X(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),V()&&K({currentBlockId:l,isPasting:!1,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o})))}));return()=>c()}),[e,t,s,n,o,r])})(),(0,t.createElement)(I,null)),ee=()=>(0,t.createElement)(a,null,(0,t.createElement)(Z,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ee})}))})();
     1(()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)(0),d=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:p,isContentPastedRef:d}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),f=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof f.RichTextData,{getEntityRecord:w}=(0,p.select)("core"),{updateBlock:v}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | |&nbsp;)([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | |&nbsp;)/,replace:"$1 ",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],{getBlock:F,getBlocks:P,getBlockAttributes:R,getSelectionStart:Q,isTyping:W}=(0,p.select)("core/block-editor"),{selectionChange:M,updateBlockAttributes:$}=(0,p.dispatch)("core/block-editor"),A=()=>{const e=(()=>{const e=w("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>O(e.slug))):e},N=()=>B.filter((e=>!0===A()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:q,getBlockAttributes:z}=(0,p.select)("core/block-editor"),O=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},I=e=>{const t=E.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>A()?.find((t=>t.slug===e))?.value))},D=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!O(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:I(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},L=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],G=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...L].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)(D,{key:s,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:j}=(0,p.select)("core"),U=()=>{const e=j("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(G,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:H,getBlocks:K,getBlockAttributes:J,getSelectionStart:V,isTyping:X}=(0,p.select)("core/block-editor"),{updateBlockAttributes:Y}=(0,p.dispatch)("core/block-editor"),Z=e=>{const{currentBlockId:t,isPreviousFixCanceled:s,setPreviousFixCanceled:n,blocksToBeProcessed:o,cursorOffsetRef:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=q(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:o})||!(e=>{const t=z(e);return!(!t||!t.hasOwnProperty("content")||!_(t.content)&&!k(t.content))})(t))return;let r=N();const a=H(t);let i=J(t),l=!1;Object.entries(r).forEach((([e,o])=>{if(l)return;let r,u=o.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(X()||(b=o.mask.test(h)),X()){r=V(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/&nbsp;/g)||[]).length;return l>0&&(i=a.replace(/&nbsp;/g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(o.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=o.mask.test(h)&&o.mask.test(d)}if(!b)return;if((e=>!!T.includes(e.slug))(o)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(o,m)),0!==y&&(m=p+d.replace(o.mask,u)),0===y&&(m=m.replace(o.mask,o.replace)),s)return void n(!1);s||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,f.create)({...n.content,text:o});c=new f.RichTextData(e)}return _(n.content)&&(c=o),void 0!==c&&(v(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m}));const w="function"==typeof o.nbMoved?o.nbMoved(d):o.nbMoved||0;l&&(c.current=w)}))},{getSelectedBlockClientId:ee,isTyping:te,getBlockAttributes:se}=(0,p.select)("core/block-editor"),ne=window.wp.blocks,oe=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,ne.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));const s=["core/html"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Blocks that can be processed:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,cursorOffsetRef:r,isContentPastedRef:a}=(0,c.useContext)(i);r.current=r.current||0,a.current=a.current||!1,(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:i}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=w("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!i)return;if(void 0===A())return;if(i&&!0===a.current)return a.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o}=e;let c=N();const r=K(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return n.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(T.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!T.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&Y(Object.keys(i),i,!0),a.forEach((e=>{if(!n.includes(e.name))return;const c=e.clientId;e?.clientId&&Z({currentBlockId:c,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r});const l=ee();if(null===l||!c)return;const u=se(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),te()&&Z({currentBlockId:l,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r})))}));return()=>{c(),(e=>{const t=window.getSelection();if(!t)return;let s;1===t?.anchorNode?.nodeType&&(s=t.anchorNode?.firstChild?.length||0),3===t?.anchorNode?.nodeType&&(s=t.anchorOffset||0);const n=e>=0?s+e:s;if(1!==t?.anchorNode?.nodeType)if(3!==t?.anchorNode?.nodeType);else{const e=t.anchorNode;t.collapse(e,n)}else{const e=t.anchorNode?.firstChild||t.anchorNode?.childNodes[0];t.collapse(e,n)}})(r.current),r.current=0}}),[e,t,s,n,o,r,a])})(),(0,t.createElement)(U,null)),ce=()=>(0,t.createElement)(a,null,(0,t.createElement)(oe,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ce})}))})();
  • consistency/tags/1.8.1/consistency.php

    r3142172 r3145550  
    44 * Plugin URI:        https://www.webaxones.com
    55 * Description:       Fixes typographic and punctuation consistency
    6  * Version:           1.8.0
     6 * Version:           1.8.1
    77 * Requires at least: 6.1
    88 * Requires PHP:      7.4
  • consistency/tags/1.8.1/includes/Plugin.php

    r3142172 r3145550  
    3333    protected static function setConstants(): void
    3434    {
    35         defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.0' );
     35        defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.1' );
    3636        defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) );
    3737        defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) );
  • consistency/tags/1.8.1/includes/Utils/Concerns/ObjectArrayTrait.php

    r2857933 r3145550  
    2323            $array1,
    2424            $array2,
    25             function( $a, $b ) {
     25            function ( $a, $b ) {
    2626                return strcmp( $a['slug'], $b['slug'] );
    2727            }
  • consistency/tags/1.8.1/package.json

    r3142172 r3145550  
    11{
    22    "name": "consistency",
    3     "version": "1.8.0",
     3    "version": "1.8.1",
    44    "description": "",
    55    "main": "index.js",
  • consistency/tags/1.8.1/readme.txt

    r3142172 r3145550  
    44Requires at least: 6.1
    55Tested up to: 6.6
    6 Stable tag: 1.8.0
     6Stable tag: 1.8.1
    77Requires PHP: 7.4
    88License: GPL-3.0-or-later
     
    7070== Changelog ==
    7171
     72= 1.8.1 =
     73* Fix: Resolves incompatibilities with block plugins such as Kadence, GeneratePress, etc.
     74* Fix: Fix the names of enabled or disabled rules in the notices
     75
    7276= 1.8.0 =
    7377* Update: code refactoring (replace global variables with global context, some functions with custom hooks, and allow to process more blocks)
  • consistency/tags/1.8.1/src/app/checks.js

    r3142172 r3145550  
    6868
    6969    const blockAttributes = getBlockAttributes( currentBlockId )
    70 
     70   
    7171    if ( ! blockAttributes || ! blockAttributes.hasOwnProperty( 'content' ) ) return false
    7272
  • consistency/tags/1.8.1/src/app/fixes.js

    r3142172 r3145550  
    2020import { shouldProcessBlock, canProcessBlock, regDealWithPair } from './checks'
    2121
    22 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping, getBlockSelectionStart } = select( 'core/block-editor' )
    23 const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' )
    24 
     22const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' )
     23const { updateBlockAttributes } = dispatch( 'core/block-editor' )
    2524
    2625
     
    3029 * @param {Object} props - The props object.
    3130 * @param {string} props.currentBlockId - The ID of the current block.
    32  * @param {boolean} props.isPasting - Indicates if the content is being pasted.
    3331 * @param {boolean} props.isPreviousFixCanceled - Indicates if the previous fix was canceled.
    3432 * @param {function} props.setPreviousFixCanceled - The function to set the previous fix canceled state.
    3533 * @param {Array} props.blocksToBeProcessed - The blocks to be processed: we pass them as props to avoid using global context since we are not in a component.
     34 * @param {Ref} props.cursorOffsetRef - The reference to the cursor offset.
    3635 */
    3736export const fixIt = props => {
    3837
    39     const { currentBlockId, isPasting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } = props
     38    const { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props
    4039   
    4140    // Check if the current block should be processed and can be processed
     
    136135            contentUpdated = updateBlockTextContent( { block, currentBlockId, blockAttributes, blockContent } )
    137136        }
    138    
    139         // Cursor repositioning:
    140         if ( 0 === cursorPosition || isPasting ) return
    141137
    142138        // Get the number of characters moved by the replacement: needed for cursor repositioning.
     
    144140        const nbMoved = typeof reg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved || 0
    145141       
    146         let attributeKey = selectionStart.hasOwnProperty( 'attributeKey' ) ? selectionStart.attributeKey : 'content'
    147    
    148         // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back
    149         // Eg: ... replaced with … removes 2 characters
    150         if ( nbMoved < 0 ) {
    151             selectionChange( currentBlockId, attributeKey, cursorPosition + nbMoved, cursorPosition + nbMoved )
    152         }
    153        
    154         // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward
    155         // Eg: "" replaced with «  » adds 2 characters
    156         if ( nbMoved > 0 ) {
    157             selectionChange( currentBlockId, attributeKey, cursorPosition + 1 + nbMoved, cursorPosition + nbMoved )
    158         }
    159 
    160         if ( 0 === nbMoved ) {
    161             selectionChange( currentBlockId, attributeKey, cursorPosition, cursorPosition )
     142        // Set the cursor offset
     143        if ( contentUpdated ) {
     144            cursorOffsetRef.current = nbMoved
    162145        }
    163146
     
    167150
    168151/**
    169  * Fixes all blocks generated by pasting.
     152 * Fix all blocks generated by pasting based on the provided rules and blocks to be processed.
     153 *
     154 * @param {Object} props - The props object containing necessary data.
     155 * @param {boolean} props.isPreviousFixCanceled - Flag indicating if the previous fix was canceled.
     156 * @param {function} props.setPreviousFixCanceled - Function to set the flag indicating if the previous fix was canceled.
     157 * @param {Array} props.blocksToBeProcessed - Array of block names to be processed.
     158 * @param {Ref} props.cursorOffsetRef - Reference to the cursor offset.
    170159 */
    171160export const fixAll = props => {
    172161
    173     const { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed } = props
     162    const { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props
    174163
    175164    // Get the relevant rules
     
    224213
    225214    // Select all innerBlocks to trigger their correction, then deselect all by selecting the first block
    226     const isPasting = true
    227215    allInners.forEach( block => {
    228216
    229217        if ( ! blocksToBeProcessed.includes( block.name ) ) return
    230218        const currentBlockId = block.clientId
    231         block?.clientId && fixIt( { currentBlockId, isPasting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } )
     219        block?.clientId && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } )
    232220
    233221    } )
  • consistency/tags/1.8.1/src/app/helpers.js

    r3142172 r3145550  
    55 * @author Loïc Antignac.
    66 */
     7
     8import { select, dispatch } from '@wordpress/data'
     9const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' )
     10const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' )
    711
    812/**
     
    8185
    8286}
     87
     88/**
     89 * Moves the cursor to right position after fixing the content.
     90 * We use window.getSelection() and not the editor's selectionChange() to avoid to trigger a new state change.
     91 *
     92 * @returns {void}
     93 */
     94export const moveCursorToNewPosition = cursorOffset => {
     95
     96    const selection = window.getSelection()
     97   
     98    // Stop here if no selection or if the selection anchor node is null
     99    if ( ! selection ) return
     100
     101    // Get current cursor position
     102    let cursorPosition
     103
     104    // Element node case: we need to get the first text node from the element node
     105    if ( selection?.anchorNode?.nodeType === 1 ) {
     106        cursorPosition = selection.anchorNode?.firstChild?.length || 0
     107    }
     108
     109    // Text node case
     110    if ( selection?.anchorNode?.nodeType === 3 ) {
     111        cursorPosition = selection.anchorOffset || 0
     112    }
     113
     114    // If the cursorOffset is positive, newPosition equals cursorPosition + cursorOffset, else newPosition equals cursorPosition
     115    const newPosition = cursorOffset >= 0 ? cursorPosition + cursorOffset : cursorPosition
     116
     117    // Element node
     118    if ( selection?.anchorNode?.nodeType === 1 ) {
     119   
     120        // If the anchor node is an element node, we have to get the first text node from it
     121        const textNode = selection.anchorNode?.firstChild || selection.anchorNode?.childNodes[ 0 ]
     122        selection.collapse( textNode, newPosition )
     123        return
     124       
     125    }
     126
     127    // Text node
     128    if ( selection?.anchorNode?.nodeType === 3 ) {
     129   
     130        // If the anchor node is a text node, we have to get the parent element node
     131        const textNode = selection.anchorNode
     132        selection.collapse( textNode, newPosition )
     133        return
     134       
     135    }
     136
     137}
  • consistency/tags/1.8.1/src/components/ConsistencyPlugin.js

    r3142172 r3145550  
    3939
    4040    // Render the settings sidebar
    41     return (
    42         <SidebarSettings />
    43     )
     41    return (
     42        <SidebarSettings />
     43    )
    4444}
    4545
  • consistency/tags/1.8.1/src/components/GlobalSettingPanel.js

    r3142172 r3145550  
    4242                                    key={ key }
    4343                                    settingSlug={ rule.slug }
    44                                     name={ rule.name }
     44                                    settingName={ rule.name }
    4545                                    settingDescription={ {
    4646                                        __html: rule.description
  • consistency/tags/1.8.1/src/components/GlobalSettingToggle.js

    r3142172 r3145550  
    6363    }
    6464
    65     return(
     65    return(
    6666        <PanelRow>
    6767            <ToggleControl
     
    7373            />
    7474        </PanelRow>
    75     )
     75    )
    7676}
  • consistency/tags/1.8.1/src/components/LocaleLabel.js

    r3142172 r3145550  
    2727        : __( ' (all locales)', 'consistency' )
    2828
    29     return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> )
     29    return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> )
    3030}
  • consistency/tags/1.8.1/src/components/Settings.js

    r3142172 r3145550  
    2626    const isAdmin = canUser( 'create', 'users' )
    2727
    28     return(
    29         <>
     28    return(
     29        <>
    3030            <PluginSidebar
    31                 name='consistency-custom-sidebar'
    32                 title={ __( 'Consistency', 'consistency' ) }
     31                name='consistency-custom-sidebar'
     32                title={ __( 'Consistency', 'consistency' ) }
    3333                icon={ ConsistencyIcon }
    34             >
     34            >
    3535                <UserSettingPanel />
    3636                { isAdmin && <GlobalSettingPanel/> }
    37             </PluginSidebar>
    38             <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'>
     37            </PluginSidebar>
     38            <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'>
    3939                { __( 'Consistency Settings', 'consistency' ) }
    4040            </PluginSidebarMoreMenuItem>
    41         </>
    42     )
     41        </>
     42    )
    4343}
  • consistency/tags/1.8.1/src/components/UserSettingPanel.js

    r3142172 r3145550  
    2121 */
    2222const UserSettingPanel = () => (
    23     <Panel className='UserSettingPanel'>
     23    <Panel className='UserSettingPanel'>
    2424        <PanelHeader><strong>{ __( 'Settings for my account', 'consistency' ) }</strong><br/></PanelHeader>
    25         <div style={{ padding: 16 }}>
    26             <PanelRow>
    27                 <UserSettingToggle
    28                     settingSlug='on_the_fly'
    29                     settingName={ __( 'On-the-fly autocorrect', 'consistency' ) }
    30                     settingDescription={ {
    31                         __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' )
    32                         } }
    33                 />
    34             </PanelRow>
    35             <PanelRow>
    36                 <UserSettingToggle
    37                     settingSlug='on_paste'
    38                     settingName={ __( 'On paste autocorrect', 'consistency' ) }
    39                     settingDescription={ {
    40                         __html: __( 'Enable/disable autocorrect on paste', 'consistency' )
    41                         } }
    42                 />
    43             </PanelRow>
    44         </div>
    45     </Panel>
     25        <div style={{ padding: 16 }}>
     26            <PanelRow>
     27                <UserSettingToggle
     28                    settingSlug='on_the_fly'
     29                    settingName={ __( 'On-the-fly autocorrect', 'consistency' ) }
     30                    settingDescription={ {
     31                        __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' )
     32                        } }
     33                />
     34            </PanelRow>
     35            <PanelRow>
     36                <UserSettingToggle
     37                    settingSlug='on_paste'
     38                    settingName={ __( 'On paste autocorrect', 'consistency' ) }
     39                    settingDescription={ {
     40                        __html: __( 'Enable/disable autocorrect on paste', 'consistency' )
     41                        } }
     42                />
     43            </PanelRow>
     44        </div>
     45    </Panel>
    4646)
    4747
  • consistency/tags/1.8.1/src/components/UserSettingToggle.js

    r3142172 r3145550  
    5959    }
    6060
    61     return(
    62         <ToggleControl
    63             label={ settingName }
     61    return(
     62        <ToggleControl
     63            label={ settingName }
    6464            help={ ( <span dangerouslySetInnerHTML={ settingDescription } /> ) }
    65             checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false }
    66             onChange={ onSettingChanged }
    67         />
    68     )
     65            checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false }
     66            onChange={ onSettingChanged }
     67        />
     68    )
    6969}
  • consistency/tags/1.8.1/src/contexts/GlobalContext.js

    r3142172 r3145550  
    3030    // This variable is used to check if custom fields are active because the editor content is within an iframe when custom fields are inactive
    3131    const [ isEditorInIframe ] = useState( document.querySelector( 'iframe[name="editor-canvas"]' ) !== null )
     32
    3233    // This variable is used to avoid new fixes when the user is undoing a fix with CTRL/CMD Z
    3334    const [ isPreviousFixCanceled, setPreviousFixCanceled ] = useState( false )
     35
    3436    // This variable is used to store the content of the block to avoid fixing it if it has not changed since we check at every state change
    3537    const [ previousFixCanceledContent, setPreviousFixCanceledContent ] = useState( '' )
     38
    3639    // This variable is used to store the blocks allowed to be processed   
    3740    const [ blocksToBeProcessed, setBlocksToBeProcessed ] = useState( [] )
     41
     42    // This variable is used to store the number of characters lost or gained by the correction in order to move the cursor accordingly
     43    const cursorOffsetRef = useRef( 0 )
     44
    3845    // This ref is used to track if content has been past
    3946    const isContentPastedRef = useRef( false )
    4047
    4148    // Return the global provider
    42     return (
    43         <GlobalContext.Provider value={ {
    44             isEditorInIframe,
    45             isPreviousFixCanceled,
    46             setPreviousFixCanceled,
     49    return (
     50        <GlobalContext.Provider value={ {
     51            isEditorInIframe,
     52            isPreviousFixCanceled,
     53            setPreviousFixCanceled,
    4754            previousFixCanceledContent,
    48             setPreviousFixCanceledContent,
     55            setPreviousFixCanceledContent,
    4956            blocksToBeProcessed,
    5057            setBlocksToBeProcessed,
     58            cursorOffsetRef,
    5159            isContentPastedRef
    52         } }>
    53             { children }
    54         </GlobalContext.Provider>
    55     )
     60        } }>
     61            { children }
     62        </GlobalContext.Provider>
     63    )
    5664}
    5765
  • consistency/tags/1.8.1/src/hooks/useEditorEffects.js

    r3142172 r3145550  
    2121import { fixIt, fixAll } from '../app/fixes'
    2222import { fetchCurrentUserSettings } from '../app/data'
    23 import { getLocalizedRuleSettings } from '../app/helpers'
     23import { moveCursorToNewPosition, getLocalizedRuleSettings } from '../app/helpers'
    2424
    2525// Get the current selected block and its attributes
     
    3030     * Global variables in global context
    3131     */
    32     const {
     32    const {
    3333        isPreviousFixCanceled,
    34         setPreviousFixCanceled,
     34        setPreviousFixCanceled,
    3535        previousFixCanceledContent,
    36         setPreviousFixCanceledContent,
     36        setPreviousFixCanceledContent,
    3737        blocksToBeProcessed,
     38        cursorOffsetRef,
    3839        isContentPastedRef
    39     } = useContext( GlobalContext )
     40    } = useContext( GlobalContext )
     41
     42    // Initialize the cursorOffset variable if it is undefined
     43    cursorOffsetRef.current = cursorOffsetRef.current || 0
    4044
    4145    // Initialize the isContentPastedRef variable if it is undefined
    42     if ( isContentPastedRef.current === undefined ) {
    43         isContentPastedRef.current = false
    44     }
     46    isContentPastedRef.current = isContentPastedRef.current || false
    4547
    46     useEffect( () => {
     48    useEffect( () => {
    4749
    4850        // Let’s listen for state changes
    4951        const unsubscribe = subscribe( () => {
    5052
    51             // Get current user settings to check if we have to fix the content or to stop here
     53            // Get current user settings to check if we have to fix the content or to stop here
    5254            const { onTheFly, onPaste } = fetchCurrentUserSettings()
    53             if ( ! onTheFly && ! onPaste ) return
     55            if ( ! onTheFly && ! onPaste ) return
    5456
    55             // Get fixing rules from site entity global settings
     57            // Get fixing rules from site entity global settings
    5658            const localizedRuleSettings = getLocalizedRuleSettings()
    57             if ( localizedRuleSettings === undefined ) return
     59            if ( localizedRuleSettings === undefined ) return
    5860
    59             // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here
     61            // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here
    6062            if ( onPaste && isContentPastedRef.current === true ) {
    6163                isContentPastedRef.current = false
    62                 fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed } )
     64                fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } )
    6365                return
    64             }
     66            }
    6567
    6668            // Get current selected block
    67             const currentBlockId = getSelectedBlockClientId()
     69            const currentBlockId = getSelectedBlockClientId()
    6870
    6971            // Stop here if no block is selected or if fixing on the fly is disabled
    70             if ( currentBlockId === null || ! onTheFly ) return
     72            if ( currentBlockId === null || ! onTheFly ) return
    7173
    7274            // Don't try to fix block content if nothing has changed
     
    7981
    8082            // Store the block content to avoid fixing it twice at the next state change
    81             setPreviousFixCanceledContent( blockAttributes.content )
     83            setPreviousFixCanceledContent( blockAttributes.content )
    8284
    8385            // Fix the current selected block
    84             isTyping() && fixIt( { currentBlockId, isPasting: false, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } )
    85         } )
     86            isTyping() && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } )
     87
     88        } )
    8689
    8790        // Unsubscribe when the component is unmounted
    88         return () => unsubscribe()
     91        return () => {
     92            unsubscribe()
     93           
     94            // Move cursor to the new position
     95            moveCursorToNewPosition( cursorOffsetRef.current )
    8996
    90     }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, isContentPastedRef ] )
     97            // Reset cursorOffsetRef
     98            cursorOffsetRef.current = 0
     99        }
     100
     101    }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, cursorOffsetRef, isContentPastedRef ] )
    91102}
    92103
  • consistency/tags/1.8.1/src/hooks/usePasteEventHandler.js

    r3142172 r3145550  
    2727    const isPasteEventAttached = useRef( false )
    2828
    29     useEffect( () => {
     29    useEffect( () => {
    3030
    3131        // If the paste event has already been attached, return
     
    4949
    5050        // Get the target element depending on whether the editor is in an iframe or not
    51         const targetElement = isEditorInIframe
     51        const targetElement = isEditorInIframe
    5252            ? document.querySelector( 'iframe[name="editor-canvas"]' )
    5353            : document.querySelector( '#editor' )
    5454
    55         if ( ! targetElement ) return
     55        if ( ! targetElement ) return
    5656
    57         // Attach the paste event listener and get the cleanup function
    58         const cleanup = attachPasteEventListener( targetElement )
     57        // Attach the paste event listener and get the cleanup function
     58        const cleanup = attachPasteEventListener( targetElement )
    5959
    60         // If the iframe is already loaded, manually trigger the event listener attachment
    61         if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) {
    62             attachPasteEventListener( targetElement )
    63         }
     60        // If the iframe is already loaded, manually trigger the event listener attachment
     61        if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) {
     62            attachPasteEventListener( targetElement )
     63        }
    6464
    6565        // Update the ref to track if the paste event has been attached
    6666        isPasteEventAttached.current = true
    6767
    68         // Return the cleanup function to be called when the component unmounts or before the effect re-runs
    69         return cleanup
     68        // Return the cleanup function to be called when the component unmounts or before the effect re-runs
     69        return cleanup
    7070
    71     }, [ isEditorInIframe ] )
     71    }, [ isEditorInIframe ] )
    7272}
    7373
  • consistency/tags/1.8.1/src/hooks/useSetAllowedBlocks.js

    r3142172 r3145550  
    3030        } )
    3131       
    32         // Remove blocks beginning with kadence/ from the list since it doesn't work with them
    33         richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! block.name.startsWith( 'kadence/' ) )
    34 
    35         // Remove blocks from the list cause we don't want to alter them (core/html) or they don't work properly (core/freeform)
    36         const blocksToExclude = [ 'core/html', 'core/freeform' ]
     32        // Remove blocks from the list cause we don't want to alter them (core/html)
     33        const blocksToExclude = [ 'core/html' ]
    3734        richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! blocksToExclude.includes( block.name ) )
    3835       
    39         console.log( 'Consistency - Processed blocks:', richTextAndStringContentTypes );
     36        console.log( 'Consistency - Blocks that can be processed:', richTextAndStringContentTypes );
    4037       
    4138        // Set the blocks to be processed in the global context
  • consistency/tags/1.8.1/src/index.js

    r3142172 r3145550  
    2222
    2323const PluginWrapper = () => (
    24     <GlobalProvider>
    25         <ConsistencyPlugin />
    26     </GlobalProvider>
     24    <GlobalProvider>
     25        <ConsistencyPlugin />
     26    </GlobalProvider>
    2727)
    2828
    2929domReady( () => {
    30     registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } )
     30    registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } )
    3131} )
  • consistency/trunk/build/index.asset.php

    r3142172 r3145550  
    1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => '525eca4ceb38a5bd7f50');
     1<?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => 'ab0245b936622e6790c8');
  • consistency/trunk/build/index.js

    r3142172 r3145550  
    1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,isContentPastedRef:p}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),_=window.wp.richText,f=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof _.RichTextData,{getEntityRecord:v}=(0,p.select)("core"),{updateBlock:w}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=v("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=v("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},E=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],T=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | |&nbsp;)([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | |&nbsp;)/,replace:"$1 ",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],P=()=>{const e=(()=>{const e=v("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>W(e.slug))):e},F=()=>B.filter((e=>!0===P()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:R,getBlockAttributes:Q}=(0,p.select)("core/block-editor"),W=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},M=e=>{const t=T.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>P()?.find((t=>t.slug===e))?.value))},$=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!W(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:M(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},q=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],z=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...q].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)($,{key:s,settingSlug:e.slug,name:e.name,settingDescription:{__html:e.description}}))))))),{canUser:A}=(0,p.select)("core"),I=()=>{const e=A("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(z,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:D,getBlocks:L,getBlockAttributes:N,getSelectionStart:O,isTyping:G,getBlockSelectionStart:j}=(0,p.select)("core/block-editor"),{selectionChange:U,updateBlockAttributes:H}=(0,p.dispatch)("core/block-editor"),K=e=>{const{currentBlockId:t,isPasting:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,blocksToBeProcessed:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=R(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:c})||!(e=>{const t=Q(e);return!(!t||!t.hasOwnProperty("content")||!f(t.content)&&!k(t.content))})(t))return;let r=F();const a=D(t);let i=N(t),l=!1;Object.entries(r).forEach((([e,c])=>{if(l)return;let r,u=c.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(G()||(b=c.mask.test(h)),G()){r=O(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/&nbsp;/g)||[]).length;return l>0&&(i=a.replace(/&nbsp;/g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(c.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=c.mask.test(h)&&c.mask.test(d)}if(!b)return;if((e=>!!E.includes(e.slug))(c)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(c,m)),0!==y&&(m=p+d.replace(c.mask,u)),0===y&&(m=m.replace(c.mask,c.replace)),n)return void o(!1);if(n||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,_.create)({...n.content,text:o});c=new _.RichTextData(e)}return f(n.content)&&(c=o),void 0!==c&&(w(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m})),0===g||s)return;const v="function"==typeof c.nbMoved?c.nbMoved(d):c.nbMoved||0;let S=r.hasOwnProperty("attributeKey")?r.attributeKey:"content";v<0&&U(t,S,g+v,g+v),v>0&&U(t,S,g+1+v,g+v),0===v&&U(t,S,g,g)}))},{getSelectedBlockClientId:J,isTyping:V,getBlockAttributes:X}=(0,p.select)("core/block-editor"),Y=window.wp.blocks,Z=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,Y.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));t=t.filter((e=>!e.name.startsWith("kadence/")));const s=["core/html","core/freeform"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Processed blocks:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,isContentPastedRef:r}=(0,c.useContext)(i);void 0===r.current&&(r.current=!1),(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:a}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=v("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!a)return;const i=P();if(void 0===i)return;if(a&&!0===r.current)return r.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,localizedRuleSettings:n,blocksToBeProcessed:o}=e;let c=F();const r=L(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return o.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(E.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!E.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&H(Object.keys(i),i,!0),a.forEach((e=>{if(!o.includes(e.name))return;const n=e.clientId;e?.clientId&&K({currentBlockId:n,isPasting:!0,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,localizedRuleSettings:i,blocksToBeProcessed:o});const l=J();if(null===l||!c)return;const u=X(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),V()&&K({currentBlockId:l,isPasting:!1,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o})))}));return()=>c()}),[e,t,s,n,o,r])})(),(0,t.createElement)(I,null)),ee=()=>(0,t.createElement)(a,null,(0,t.createElement)(Z,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ee})}))})();
     1(()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)(0),d=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:p,isContentPastedRef:d}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),f=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof f.RichTextData,{getEntityRecord:w}=(0,p.select)("core"),{updateBlock:v}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | |&nbsp;)([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | |&nbsp;)/,replace:"$1 ",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],{getBlock:F,getBlocks:P,getBlockAttributes:R,getSelectionStart:Q,isTyping:W}=(0,p.select)("core/block-editor"),{selectionChange:M,updateBlockAttributes:$}=(0,p.dispatch)("core/block-editor"),A=()=>{const e=(()=>{const e=w("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>O(e.slug))):e},N=()=>B.filter((e=>!0===A()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:q,getBlockAttributes:z}=(0,p.select)("core/block-editor"),O=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},I=e=>{const t=E.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>A()?.find((t=>t.slug===e))?.value))},D=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!O(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:I(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},L=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],G=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...L].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)(D,{key:s,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:j}=(0,p.select)("core"),U=()=>{const e=j("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(G,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:H,getBlocks:K,getBlockAttributes:J,getSelectionStart:V,isTyping:X}=(0,p.select)("core/block-editor"),{updateBlockAttributes:Y}=(0,p.dispatch)("core/block-editor"),Z=e=>{const{currentBlockId:t,isPreviousFixCanceled:s,setPreviousFixCanceled:n,blocksToBeProcessed:o,cursorOffsetRef:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=q(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:o})||!(e=>{const t=z(e);return!(!t||!t.hasOwnProperty("content")||!_(t.content)&&!k(t.content))})(t))return;let r=N();const a=H(t);let i=J(t),l=!1;Object.entries(r).forEach((([e,o])=>{if(l)return;let r,u=o.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(X()||(b=o.mask.test(h)),X()){r=V(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/&nbsp;/g)||[]).length;return l>0&&(i=a.replace(/&nbsp;/g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(o.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=o.mask.test(h)&&o.mask.test(d)}if(!b)return;if((e=>!!T.includes(e.slug))(o)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(o,m)),0!==y&&(m=p+d.replace(o.mask,u)),0===y&&(m=m.replace(o.mask,o.replace)),s)return void n(!1);s||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,f.create)({...n.content,text:o});c=new f.RichTextData(e)}return _(n.content)&&(c=o),void 0!==c&&(v(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m}));const w="function"==typeof o.nbMoved?o.nbMoved(d):o.nbMoved||0;l&&(c.current=w)}))},{getSelectedBlockClientId:ee,isTyping:te,getBlockAttributes:se}=(0,p.select)("core/block-editor"),ne=window.wp.blocks,oe=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,ne.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));const s=["core/html"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Blocks that can be processed:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,cursorOffsetRef:r,isContentPastedRef:a}=(0,c.useContext)(i);r.current=r.current||0,a.current=a.current||!1,(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:i}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=w("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!i)return;if(void 0===A())return;if(i&&!0===a.current)return a.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o}=e;let c=N();const r=K(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return n.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(T.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!T.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&Y(Object.keys(i),i,!0),a.forEach((e=>{if(!n.includes(e.name))return;const c=e.clientId;e?.clientId&&Z({currentBlockId:c,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r});const l=ee();if(null===l||!c)return;const u=se(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),te()&&Z({currentBlockId:l,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r})))}));return()=>{c(),(e=>{const t=window.getSelection();if(!t)return;let s;1===t?.anchorNode?.nodeType&&(s=t.anchorNode?.firstChild?.length||0),3===t?.anchorNode?.nodeType&&(s=t.anchorOffset||0);const n=e>=0?s+e:s;if(1!==t?.anchorNode?.nodeType)if(3!==t?.anchorNode?.nodeType);else{const e=t.anchorNode;t.collapse(e,n)}else{const e=t.anchorNode?.firstChild||t.anchorNode?.childNodes[0];t.collapse(e,n)}})(r.current),r.current=0}}),[e,t,s,n,o,r,a])})(),(0,t.createElement)(U,null)),ce=()=>(0,t.createElement)(a,null,(0,t.createElement)(oe,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ce})}))})();
  • consistency/trunk/consistency.php

    r3142172 r3145550  
    44 * Plugin URI:        https://www.webaxones.com
    55 * Description:       Fixes typographic and punctuation consistency
    6  * Version:           1.8.0
     6 * Version:           1.8.1
    77 * Requires at least: 6.1
    88 * Requires PHP:      7.4
  • consistency/trunk/includes/Plugin.php

    r3142172 r3145550  
    3333    protected static function setConstants(): void
    3434    {
    35         defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.0' );
     35        defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.1' );
    3636        defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) );
    3737        defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) );
  • consistency/trunk/includes/Utils/Concerns/ObjectArrayTrait.php

    r2857933 r3145550  
    2323            $array1,
    2424            $array2,
    25             function( $a, $b ) {
     25            function ( $a, $b ) {
    2626                return strcmp( $a['slug'], $b['slug'] );
    2727            }
  • consistency/trunk/package.json

    r3142172 r3145550  
    11{
    22    "name": "consistency",
    3     "version": "1.8.0",
     3    "version": "1.8.1",
    44    "description": "",
    55    "main": "index.js",
  • consistency/trunk/readme.txt

    r3142172 r3145550  
    44Requires at least: 6.1
    55Tested up to: 6.6
    6 Stable tag: 1.8.0
     6Stable tag: 1.8.1
    77Requires PHP: 7.4
    88License: GPL-3.0-or-later
     
    7070== Changelog ==
    7171
     72= 1.8.1 =
     73* Fix: Resolves incompatibilities with block plugins such as Kadence, GeneratePress, etc.
     74* Fix: Fix the names of enabled or disabled rules in the notices
     75
    7276= 1.8.0 =
    7377* Update: code refactoring (replace global variables with global context, some functions with custom hooks, and allow to process more blocks)
  • consistency/trunk/src/app/checks.js

    r3142172 r3145550  
    6868
    6969    const blockAttributes = getBlockAttributes( currentBlockId )
    70 
     70   
    7171    if ( ! blockAttributes || ! blockAttributes.hasOwnProperty( 'content' ) ) return false
    7272
  • consistency/trunk/src/app/fixes.js

    r3142172 r3145550  
    2020import { shouldProcessBlock, canProcessBlock, regDealWithPair } from './checks'
    2121
    22 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping, getBlockSelectionStart } = select( 'core/block-editor' )
    23 const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' )
    24 
     22const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' )
     23const { updateBlockAttributes } = dispatch( 'core/block-editor' )
    2524
    2625
     
    3029 * @param {Object} props - The props object.
    3130 * @param {string} props.currentBlockId - The ID of the current block.
    32  * @param {boolean} props.isPasting - Indicates if the content is being pasted.
    3331 * @param {boolean} props.isPreviousFixCanceled - Indicates if the previous fix was canceled.
    3432 * @param {function} props.setPreviousFixCanceled - The function to set the previous fix canceled state.
    3533 * @param {Array} props.blocksToBeProcessed - The blocks to be processed: we pass them as props to avoid using global context since we are not in a component.
     34 * @param {Ref} props.cursorOffsetRef - The reference to the cursor offset.
    3635 */
    3736export const fixIt = props => {
    3837
    39     const { currentBlockId, isPasting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } = props
     38    const { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props
    4039   
    4140    // Check if the current block should be processed and can be processed
     
    136135            contentUpdated = updateBlockTextContent( { block, currentBlockId, blockAttributes, blockContent } )
    137136        }
    138    
    139         // Cursor repositioning:
    140         if ( 0 === cursorPosition || isPasting ) return
    141137
    142138        // Get the number of characters moved by the replacement: needed for cursor repositioning.
     
    144140        const nbMoved = typeof reg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved || 0
    145141       
    146         let attributeKey = selectionStart.hasOwnProperty( 'attributeKey' ) ? selectionStart.attributeKey : 'content'
    147    
    148         // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back
    149         // Eg: ... replaced with … removes 2 characters
    150         if ( nbMoved < 0 ) {
    151             selectionChange( currentBlockId, attributeKey, cursorPosition + nbMoved, cursorPosition + nbMoved )
    152         }
    153        
    154         // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward
    155         // Eg: "" replaced with «  » adds 2 characters
    156         if ( nbMoved > 0 ) {
    157             selectionChange( currentBlockId, attributeKey, cursorPosition + 1 + nbMoved, cursorPosition + nbMoved )
    158         }
    159 
    160         if ( 0 === nbMoved ) {
    161             selectionChange( currentBlockId, attributeKey, cursorPosition, cursorPosition )
     142        // Set the cursor offset
     143        if ( contentUpdated ) {
     144            cursorOffsetRef.current = nbMoved
    162145        }
    163146
     
    167150
    168151/**
    169  * Fixes all blocks generated by pasting.
     152 * Fix all blocks generated by pasting based on the provided rules and blocks to be processed.
     153 *
     154 * @param {Object} props - The props object containing necessary data.
     155 * @param {boolean} props.isPreviousFixCanceled - Flag indicating if the previous fix was canceled.
     156 * @param {function} props.setPreviousFixCanceled - Function to set the flag indicating if the previous fix was canceled.
     157 * @param {Array} props.blocksToBeProcessed - Array of block names to be processed.
     158 * @param {Ref} props.cursorOffsetRef - Reference to the cursor offset.
    170159 */
    171160export const fixAll = props => {
    172161
    173     const { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed } = props
     162    const { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props
    174163
    175164    // Get the relevant rules
     
    224213
    225214    // Select all innerBlocks to trigger their correction, then deselect all by selecting the first block
    226     const isPasting = true
    227215    allInners.forEach( block => {
    228216
    229217        if ( ! blocksToBeProcessed.includes( block.name ) ) return
    230218        const currentBlockId = block.clientId
    231         block?.clientId && fixIt( { currentBlockId, isPasting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } )
     219        block?.clientId && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } )
    232220
    233221    } )
  • consistency/trunk/src/app/helpers.js

    r3142172 r3145550  
    55 * @author Loïc Antignac.
    66 */
     7
     8import { select, dispatch } from '@wordpress/data'
     9const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' )
     10const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' )
    711
    812/**
     
    8185
    8286}
     87
     88/**
     89 * Moves the cursor to right position after fixing the content.
     90 * We use window.getSelection() and not the editor's selectionChange() to avoid to trigger a new state change.
     91 *
     92 * @returns {void}
     93 */
     94export const moveCursorToNewPosition = cursorOffset => {
     95
     96    const selection = window.getSelection()
     97   
     98    // Stop here if no selection or if the selection anchor node is null
     99    if ( ! selection ) return
     100
     101    // Get current cursor position
     102    let cursorPosition
     103
     104    // Element node case: we need to get the first text node from the element node
     105    if ( selection?.anchorNode?.nodeType === 1 ) {
     106        cursorPosition = selection.anchorNode?.firstChild?.length || 0
     107    }
     108
     109    // Text node case
     110    if ( selection?.anchorNode?.nodeType === 3 ) {
     111        cursorPosition = selection.anchorOffset || 0
     112    }
     113
     114    // If the cursorOffset is positive, newPosition equals cursorPosition + cursorOffset, else newPosition equals cursorPosition
     115    const newPosition = cursorOffset >= 0 ? cursorPosition + cursorOffset : cursorPosition
     116
     117    // Element node
     118    if ( selection?.anchorNode?.nodeType === 1 ) {
     119   
     120        // If the anchor node is an element node, we have to get the first text node from it
     121        const textNode = selection.anchorNode?.firstChild || selection.anchorNode?.childNodes[ 0 ]
     122        selection.collapse( textNode, newPosition )
     123        return
     124       
     125    }
     126
     127    // Text node
     128    if ( selection?.anchorNode?.nodeType === 3 ) {
     129   
     130        // If the anchor node is a text node, we have to get the parent element node
     131        const textNode = selection.anchorNode
     132        selection.collapse( textNode, newPosition )
     133        return
     134       
     135    }
     136
     137}
  • consistency/trunk/src/components/ConsistencyPlugin.js

    r3142172 r3145550  
    3939
    4040    // Render the settings sidebar
    41     return (
    42         <SidebarSettings />
    43     )
     41    return (
     42        <SidebarSettings />
     43    )
    4444}
    4545
  • consistency/trunk/src/components/GlobalSettingPanel.js

    r3142172 r3145550  
    4242                                    key={ key }
    4343                                    settingSlug={ rule.slug }
    44                                     name={ rule.name }
     44                                    settingName={ rule.name }
    4545                                    settingDescription={ {
    4646                                        __html: rule.description
  • consistency/trunk/src/components/GlobalSettingToggle.js

    r3142172 r3145550  
    6363    }
    6464
    65     return(
     65    return(
    6666        <PanelRow>
    6767            <ToggleControl
     
    7373            />
    7474        </PanelRow>
    75     )
     75    )
    7676}
  • consistency/trunk/src/components/LocaleLabel.js

    r3142172 r3145550  
    2727        : __( ' (all locales)', 'consistency' )
    2828
    29     return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> )
     29    return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> )
    3030}
  • consistency/trunk/src/components/Settings.js

    r3142172 r3145550  
    2626    const isAdmin = canUser( 'create', 'users' )
    2727
    28     return(
    29         <>
     28    return(
     29        <>
    3030            <PluginSidebar
    31                 name='consistency-custom-sidebar'
    32                 title={ __( 'Consistency', 'consistency' ) }
     31                name='consistency-custom-sidebar'
     32                title={ __( 'Consistency', 'consistency' ) }
    3333                icon={ ConsistencyIcon }
    34             >
     34            >
    3535                <UserSettingPanel />
    3636                { isAdmin && <GlobalSettingPanel/> }
    37             </PluginSidebar>
    38             <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'>
     37            </PluginSidebar>
     38            <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'>
    3939                { __( 'Consistency Settings', 'consistency' ) }
    4040            </PluginSidebarMoreMenuItem>
    41         </>
    42     )
     41        </>
     42    )
    4343}
  • consistency/trunk/src/components/UserSettingPanel.js

    r3142172 r3145550  
    2121 */
    2222const UserSettingPanel = () => (
    23     <Panel className='UserSettingPanel'>
     23    <Panel className='UserSettingPanel'>
    2424        <PanelHeader><strong>{ __( 'Settings for my account', 'consistency' ) }</strong><br/></PanelHeader>
    25         <div style={{ padding: 16 }}>
    26             <PanelRow>
    27                 <UserSettingToggle
    28                     settingSlug='on_the_fly'
    29                     settingName={ __( 'On-the-fly autocorrect', 'consistency' ) }
    30                     settingDescription={ {
    31                         __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' )
    32                         } }
    33                 />
    34             </PanelRow>
    35             <PanelRow>
    36                 <UserSettingToggle
    37                     settingSlug='on_paste'
    38                     settingName={ __( 'On paste autocorrect', 'consistency' ) }
    39                     settingDescription={ {
    40                         __html: __( 'Enable/disable autocorrect on paste', 'consistency' )
    41                         } }
    42                 />
    43             </PanelRow>
    44         </div>
    45     </Panel>
     25        <div style={{ padding: 16 }}>
     26            <PanelRow>
     27                <UserSettingToggle
     28                    settingSlug='on_the_fly'
     29                    settingName={ __( 'On-the-fly autocorrect', 'consistency' ) }
     30                    settingDescription={ {
     31                        __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' )
     32                        } }
     33                />
     34            </PanelRow>
     35            <PanelRow>
     36                <UserSettingToggle
     37                    settingSlug='on_paste'
     38                    settingName={ __( 'On paste autocorrect', 'consistency' ) }
     39                    settingDescription={ {
     40                        __html: __( 'Enable/disable autocorrect on paste', 'consistency' )
     41                        } }
     42                />
     43            </PanelRow>
     44        </div>
     45    </Panel>
    4646)
    4747
  • consistency/trunk/src/components/UserSettingToggle.js

    r3142172 r3145550  
    5959    }
    6060
    61     return(
    62         <ToggleControl
    63             label={ settingName }
     61    return(
     62        <ToggleControl
     63            label={ settingName }
    6464            help={ ( <span dangerouslySetInnerHTML={ settingDescription } /> ) }
    65             checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false }
    66             onChange={ onSettingChanged }
    67         />
    68     )
     65            checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false }
     66            onChange={ onSettingChanged }
     67        />
     68    )
    6969}
  • consistency/trunk/src/contexts/GlobalContext.js

    r3142172 r3145550  
    3030    // This variable is used to check if custom fields are active because the editor content is within an iframe when custom fields are inactive
    3131    const [ isEditorInIframe ] = useState( document.querySelector( 'iframe[name="editor-canvas"]' ) !== null )
     32
    3233    // This variable is used to avoid new fixes when the user is undoing a fix with CTRL/CMD Z
    3334    const [ isPreviousFixCanceled, setPreviousFixCanceled ] = useState( false )
     35
    3436    // This variable is used to store the content of the block to avoid fixing it if it has not changed since we check at every state change
    3537    const [ previousFixCanceledContent, setPreviousFixCanceledContent ] = useState( '' )
     38
    3639    // This variable is used to store the blocks allowed to be processed   
    3740    const [ blocksToBeProcessed, setBlocksToBeProcessed ] = useState( [] )
     41
     42    // This variable is used to store the number of characters lost or gained by the correction in order to move the cursor accordingly
     43    const cursorOffsetRef = useRef( 0 )
     44
    3845    // This ref is used to track if content has been past
    3946    const isContentPastedRef = useRef( false )
    4047
    4148    // Return the global provider
    42     return (
    43         <GlobalContext.Provider value={ {
    44             isEditorInIframe,
    45             isPreviousFixCanceled,
    46             setPreviousFixCanceled,
     49    return (
     50        <GlobalContext.Provider value={ {
     51            isEditorInIframe,
     52            isPreviousFixCanceled,
     53            setPreviousFixCanceled,
    4754            previousFixCanceledContent,
    48             setPreviousFixCanceledContent,
     55            setPreviousFixCanceledContent,
    4956            blocksToBeProcessed,
    5057            setBlocksToBeProcessed,
     58            cursorOffsetRef,
    5159            isContentPastedRef
    52         } }>
    53             { children }
    54         </GlobalContext.Provider>
    55     )
     60        } }>
     61            { children }
     62        </GlobalContext.Provider>
     63    )
    5664}
    5765
  • consistency/trunk/src/hooks/useEditorEffects.js

    r3142172 r3145550  
    2121import { fixIt, fixAll } from '../app/fixes'
    2222import { fetchCurrentUserSettings } from '../app/data'
    23 import { getLocalizedRuleSettings } from '../app/helpers'
     23import { moveCursorToNewPosition, getLocalizedRuleSettings } from '../app/helpers'
    2424
    2525// Get the current selected block and its attributes
     
    3030     * Global variables in global context
    3131     */
    32     const {
     32    const {
    3333        isPreviousFixCanceled,
    34         setPreviousFixCanceled,
     34        setPreviousFixCanceled,
    3535        previousFixCanceledContent,
    36         setPreviousFixCanceledContent,
     36        setPreviousFixCanceledContent,
    3737        blocksToBeProcessed,
     38        cursorOffsetRef,
    3839        isContentPastedRef
    39     } = useContext( GlobalContext )
     40    } = useContext( GlobalContext )
     41
     42    // Initialize the cursorOffset variable if it is undefined
     43    cursorOffsetRef.current = cursorOffsetRef.current || 0
    4044
    4145    // Initialize the isContentPastedRef variable if it is undefined
    42     if ( isContentPastedRef.current === undefined ) {
    43         isContentPastedRef.current = false
    44     }
     46    isContentPastedRef.current = isContentPastedRef.current || false
    4547
    46     useEffect( () => {
     48    useEffect( () => {
    4749
    4850        // Let’s listen for state changes
    4951        const unsubscribe = subscribe( () => {
    5052
    51             // Get current user settings to check if we have to fix the content or to stop here
     53            // Get current user settings to check if we have to fix the content or to stop here
    5254            const { onTheFly, onPaste } = fetchCurrentUserSettings()
    53             if ( ! onTheFly && ! onPaste ) return
     55            if ( ! onTheFly && ! onPaste ) return
    5456
    55             // Get fixing rules from site entity global settings
     57            // Get fixing rules from site entity global settings
    5658            const localizedRuleSettings = getLocalizedRuleSettings()
    57             if ( localizedRuleSettings === undefined ) return
     59            if ( localizedRuleSettings === undefined ) return
    5860
    59             // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here
     61            // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here
    6062            if ( onPaste && isContentPastedRef.current === true ) {
    6163                isContentPastedRef.current = false
    62                 fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed } )
     64                fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } )
    6365                return
    64             }
     66            }
    6567
    6668            // Get current selected block
    67             const currentBlockId = getSelectedBlockClientId()
     69            const currentBlockId = getSelectedBlockClientId()
    6870
    6971            // Stop here if no block is selected or if fixing on the fly is disabled
    70             if ( currentBlockId === null || ! onTheFly ) return
     72            if ( currentBlockId === null || ! onTheFly ) return
    7173
    7274            // Don't try to fix block content if nothing has changed
     
    7981
    8082            // Store the block content to avoid fixing it twice at the next state change
    81             setPreviousFixCanceledContent( blockAttributes.content )
     83            setPreviousFixCanceledContent( blockAttributes.content )
    8284
    8385            // Fix the current selected block
    84             isTyping() && fixIt( { currentBlockId, isPasting: false, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } )
    85         } )
     86            isTyping() && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } )
     87
     88        } )
    8689
    8790        // Unsubscribe when the component is unmounted
    88         return () => unsubscribe()
     91        return () => {
     92            unsubscribe()
     93           
     94            // Move cursor to the new position
     95            moveCursorToNewPosition( cursorOffsetRef.current )
    8996
    90     }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, isContentPastedRef ] )
     97            // Reset cursorOffsetRef
     98            cursorOffsetRef.current = 0
     99        }
     100
     101    }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, cursorOffsetRef, isContentPastedRef ] )
    91102}
    92103
  • consistency/trunk/src/hooks/usePasteEventHandler.js

    r3142172 r3145550  
    2727    const isPasteEventAttached = useRef( false )
    2828
    29     useEffect( () => {
     29    useEffect( () => {
    3030
    3131        // If the paste event has already been attached, return
     
    4949
    5050        // Get the target element depending on whether the editor is in an iframe or not
    51         const targetElement = isEditorInIframe
     51        const targetElement = isEditorInIframe
    5252            ? document.querySelector( 'iframe[name="editor-canvas"]' )
    5353            : document.querySelector( '#editor' )
    5454
    55         if ( ! targetElement ) return
     55        if ( ! targetElement ) return
    5656
    57         // Attach the paste event listener and get the cleanup function
    58         const cleanup = attachPasteEventListener( targetElement )
     57        // Attach the paste event listener and get the cleanup function
     58        const cleanup = attachPasteEventListener( targetElement )
    5959
    60         // If the iframe is already loaded, manually trigger the event listener attachment
    61         if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) {
    62             attachPasteEventListener( targetElement )
    63         }
     60        // If the iframe is already loaded, manually trigger the event listener attachment
     61        if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) {
     62            attachPasteEventListener( targetElement )
     63        }
    6464
    6565        // Update the ref to track if the paste event has been attached
    6666        isPasteEventAttached.current = true
    6767
    68         // Return the cleanup function to be called when the component unmounts or before the effect re-runs
    69         return cleanup
     68        // Return the cleanup function to be called when the component unmounts or before the effect re-runs
     69        return cleanup
    7070
    71     }, [ isEditorInIframe ] )
     71    }, [ isEditorInIframe ] )
    7272}
    7373
  • consistency/trunk/src/hooks/useSetAllowedBlocks.js

    r3142172 r3145550  
    3030        } )
    3131       
    32         // Remove blocks beginning with kadence/ from the list since it doesn't work with them
    33         richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! block.name.startsWith( 'kadence/' ) )
    34 
    35         // Remove blocks from the list cause we don't want to alter them (core/html) or they don't work properly (core/freeform)
    36         const blocksToExclude = [ 'core/html', 'core/freeform' ]
     32        // Remove blocks from the list cause we don't want to alter them (core/html)
     33        const blocksToExclude = [ 'core/html' ]
    3734        richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! blocksToExclude.includes( block.name ) )
    3835       
    39         console.log( 'Consistency - Processed blocks:', richTextAndStringContentTypes );
     36        console.log( 'Consistency - Blocks that can be processed:', richTextAndStringContentTypes );
    4037       
    4138        // Set the blocks to be processed in the global context
  • consistency/trunk/src/index.js

    r3142172 r3145550  
    2222
    2323const PluginWrapper = () => (
    24     <GlobalProvider>
    25         <ConsistencyPlugin />
    26     </GlobalProvider>
     24    <GlobalProvider>
     25        <ConsistencyPlugin />
     26    </GlobalProvider>
    2727)
    2828
    2929domReady( () => {
    30     registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } )
     30    registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } )
    3131} )
Note: See TracChangeset for help on using the changeset viewer.