Plugin Directory

Changeset 3092549


Ignore:
Timestamp:
05/25/2024 08:00:45 PM (19 months ago)
Author:
Webaxones
Message:

Update to version 1.5.9 from GitHub

Location:
consistency
Files:
2 added
40 edited
1 copied

Legend:

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

    r3092051 r3092549  
    1 <?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-i18n', 'wp-notices', 'wp-plugins'), 'version' => '39581bcb252f47209402');
     1<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-i18n', 'wp-notices', 'wp-plugins'), 'version' => '2291d62ab83f3f59c1f5');
  • consistency/tags/1.5.9/build/index.js

    r3092051 r3092549  
    1 (()=>{"use strict";var e={n:n=>{var t=n&&n.__esModule?()=>n.default:()=>n;return e.d(t,{a:t}),t},d:(n,t)=>{for(var s in t)e.o(t,s)&&!e.o(n,s)&&Object.defineProperty(n,s,{enumerable:!0,get:t[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);const n=window.wp.plugins,t=window.wp.data,s=window.wp.domReady;var o=e.n(s);const c=window.React,r=window.wp.i18n,a=window.wp.editPost,i=window.wp.components,l=()=>(0,c.createElement)(i.Icon,{icon:(0,c.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,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,c.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),d=window.wp.coreData,u=window.wp.notices,p=e=>{const{settingSlug:n,settingName:s,settingDescription:o}=e,{currentUser:a}=(0,t.useSelect)((e=>({currentUser:e(d.store).getCurrentUser()})),[]),l=a&&a.id,[p,_]=(0,d.useEntityProp)("root","user","meta",l),{saveEditedEntityRecord:g}=(0,t.useDispatch)(d.store),{createNotice:y}=(0,t.useDispatch)(u.store);return(0,c.createElement)(i.ToggleControl,{label:s,help:(0,c.createElement)("span",{dangerouslySetInnerHTML:o}),checked:p?.consistency_plugin_user_settings?.find((e=>e.slug===n))?.value||!1,onChange:e=>{let t=p?.consistency_plugin_user_settings.map((t=>n===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===n))||t.push({slug:n,value:e}),_({...p,consistency_plugin_user_settings:t}),g("root","user",l,{...p,meta:t}),y((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}})},_=()=>(0,c.createElement)(i.Panel,{className:"UserSettingPanel"},(0,c.createElement)(i.PanelHeader,null,(0,c.createElement)("strong",null,(0,r.__)("Settings for my account","consistency"))),(0,c.createElement)("div",{style:{padding:16}},(0,c.createElement)(i.PanelRow,null,(0,c.createElement)(p,{settingSlug:"on_the_fly",settingName:(0,r.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable on-the-fly autocorrect for my account","consistency")}})),(0,c.createElement)(i.PanelRow,null,(0,c.createElement)(p,{settingSlug:"on_paste",settingName:(0,r.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable autocorrect on paste for my account","consistency")}})))),{getEntityRecord:g}=(0,t.select)("core"),y=[{slug:"quote",name:(0,r.__)("Straight quote","consistency"),description:(0,r.__)("Replaces straight quotes with curved quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"punctuation"},{slug:"2hyphens",name:(0,r.__)("Two hyphens","consistency"),description:(0,r.__)("Replaces 2 hyphens with em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code>—</code></span>",mask:/(?:\-)\-/,replace:"—",nbMoved:-1,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"punctuation"},{slug:"ordinalNumberSuffix",name:(0,r.__)("Ordinal number suffix","consistency"),description:(0,r.__)("Add HTML tag sup to ordinal number suffix","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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"punctuation"},{slug:"regularToCurlyQuotes",name:(0,r.__)("Curly quotes","consistency"),description:(0,r.__)("Replaces regular 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,locales:["en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"punctuation"},{slug:"regularToGermanQuotes",name:(0,r.__)("Regular quotes to german","consistency"),description:(0,r.__)("Replaces regular 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,locales:["de_DE","de_AT","ro_RO"],category:"punctuation"},{slug:"regularToGermanBookStyleQuotes",name:(0,r.__)("Regular quotes to german book-style quotes","consistency"),description:(0,r.__)("Replaces regular 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,locales:["de_DE","de_AT"],category:"punctuation"},{slug:"regularToFrenchQuotes",name:(0,r.__)("Regular quotes to french","consistency"),description:(0,r.__)("Replaces regular quotes with french quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,locales:["fr_FR","fr_BE"],category:"punctuation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,r.__)("Regular quotes to french quotes without spaces","consistency"),description:(0,r.__)("Replaces regular 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,locales:["de_CH"],category:"punctuation"},{slug:"curlyToFrenchQuotes",name:(0,r.__)("Curly quotes to french quotes","consistency"),description:(0,r.__)("Replaces curly quotes with french quotes:","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,locales:["fr_FR","fr_BE"],category:"punctuation"},{slug:"breakingSpace",name:(0,r.__)("Breaking space","consistency"),description:sprintf((0,r.__)("Replaces 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,locales:["fr_FR","fr_BE"],category:"space"},{slug:"noSpaceBefore",name:(0,r.__)("No space before","consistency"),description:sprintf((0,r.__)("Adds 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,locales:["fr_FR","fr_BE"],category:"space"},{slug:"spaceBefore",name:(0,r.__)("Space before","consistency"),description:(0,r.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,locales:["en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"space"},{slug:"noBreakingSpaceAfter",name:(0,r.__)("No breaking space after","consistency"),description:sprintf((0,r.__)("Adds 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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,r.__)("No non breaking space after","consistency"),description:(0,r.__)("Adds a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | |&nbsp;)/,replace:"$1 ",nbMoved:0,locales:["fr_FR","fr_BE"],category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,r.__)("First sentence letter not capitalized","consistency"),description:(0,r.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"case"},{slug:"etcThreeDots",name:(0,r.__)('3 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 3 dots placed after the abbreviation "etc" with a point:',"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,locales:["fr_FR","fr_BE"],category:"ellipsis"},{slug:"etcTwoDots",name:(0,r.__)('2 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 2 dots placed after the abbreviation "etc" with a point:',"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,locales:["en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"ellipsis"},{slug:"etcEllipsis",name:(0,r.__)('ellipsis following "etc"',"consistency"),description:(0,r.__)('Replaces ellipsis placed after the abbreviation "etc" with a point:',"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,locales:["fr_FR","fr_BE"],category:"ellipsis"},{slug:"ellipsis",name:(0,r.__)("Ellipsis","consistency"),description:(0,r.__)("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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"ellipsis"},{slug:"symbolBasedOn1Character",name:(0,r.__)("Symbol based on 1 character","consistency"),description:(0,r.__)("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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"symbol"},{slug:"symbolBasedOn2Characters",name:(0,r.__)("Symbol based on 2 characters","consistency"),description:(0,r.__)("Replaces 2-character abbreviations in parentheses with a symbol","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:-3,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"symbol"},{slug:"fractions",name:(0,r.__)("Fractions","consistency"),description:(0,r.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>3/5</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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"symbol"}],m=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],b=["core/paragraph","core/heading","core/quote","core/list-item","core/read-more"],{getBlock:f}=(0,t.select)("core/block-editor"),{updateBlock:h}=(0,t.dispatch)("core/block-editor"),{getBlockName:k,getBlockAttributes:v}=(0,t.select)("core/block-editor"),w=e=>{const n=(()=>{const e=g("root","site");return e?.language||"en_US"})(),t=y?.find((n=>n.slug===e));return!(void 0===t||!t?.locales?.includes(n))},E=e=>{const{settingSlug:n,settingName:s,settingDescription:o}=e;if(!w(n))return"";const[a,l]=(0,d.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:p}=(0,t.useDispatch)(d.store),{createNotice:_}=(0,t.useDispatch)(u.store);return(0,c.createElement)(i.PanelRow,null,(0,c.createElement)(i.ToggleControl,{label:s,help:(0,c.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.find((e=>e.slug===n))?.value||!1,onChange:e=>{let t=a.map((t=>n===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===n))||t.push({slug:n,value:e}),l(t),p("root","site",void 0,t),_((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}}))},A=[{slug:"punctuation",label:(0,r.__)("Punctuation","consistency"),description:(0,r.__)("Fixes related to punctuation.","consistency")},{slug:"space",label:(0,r.__)("Spaces","consistency"),description:(0,r.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,r.__)("Case","consistency"),description:(0,r.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,r.__)("Ellipsis","consistency"),description:(0,r.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,r.__)("Symbols","consistency"),description:(0,r.__)("Fixes related to symbols.","consistency")}],C=()=>(0,c.createElement)(i.Panel,{className:"GlobalSettingPanel"},(0,c.createElement)(i.PanelHeader,null,(0,c.createElement)("strong",null,(0,r.__)("Global correction rules","consistency"))),[...A].map(((e,n)=>(0,c.createElement)(i.PanelBody,{key:n,title:(0,r.__)(e.label,"consistency"),initialOpen:!1},[...y].filter((n=>n.category===e.slug)).map(((e,n)=>(0,c.createElement)(E,{key:n,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:R}=(0,t.select)("core"),{getBlock:x,getBlocks:B,getBlockAttributes:S,getSelectionStart:F,isTyping:M}=(0,t.select)("core/block-editor"),{updateBlock:T,selectionChange:P,updateBlockAttributes:$}=(0,t.dispatch)("core/block-editor"),U=n=>{const{currentBlockId:t,isPasting:s,settings:o}=n;let c=y.filter((e=>!0===o?.find((n=>n.slug===e.slug))?.value));const r=x(t);if(!(e=>{const n=k(e);return!!b.includes(n)})(t)||!(e=>{const n=v(e);return!(!n||!n.hasOwnProperty("content")||""===n.content)})(t))return;let a=S(t),i=!1;Object.entries(c).forEach((([n,o])=>{if(!w(o.slug)||i)return;e.g.consistencyLoop++,(n=>{e.g.consistencyLoop>=100&&(n=>{const t=f(n);h(n,{...t,attributes:{...t.attributes,content:t.attributes.content.slice(-2)}}),e.g.consistency_loop=0,console.log("Consistency - a memory leak has occured during the fix of the following block:",t)})(n)})(t);let c,l=o.replace,d="",u="",p=0,_=a.content,g=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(_),y=!1;if(M()||(y=o.mask.test(g)),M()){c=F(r.name),p=c?.offset||0;const e=(e=>{const n=document.querySelector(`#block-${e}`);if(null===n)return;const t=document.getSelection(),s=t?.getRangeAt(0);if(!s.collapsed)return;const o=s.cloneRange(),c=document.createTextNode("\0");o.insertNode(c);let r=n?.innerHTML?.indexOf("\0");c.parentNode.removeChild(c),n.normalize();const a=(n?.innerHTML.match(/&nbsp;/g)||[]).length;return a>0&&(r=r-6*a+a),r})(t)||p,n=g.match(o.mask);if(null===n||0===n.length)return;const s=n[0].length||1;d=_.substring(0,e-s),u=_.substring(e-s,_.length),y=o.mask.test(g)&&o.mask.test(u)}y&&((e=>!!m.includes(e.slug))(o)&&(l=((e,n,t)=>{const s=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(`${s}`,"g"),i=new RegExp(`${o}`,"g");return(n.match(a)||[]).length===(n.match(i)||[]).length?s+c:r+o})(o,_)),0!==p&&(_=d+u.replace(o.mask,l)),0===p&&(_=_.replace(o.mask,o.replace)),e.g.previousFixCanceled?e.g.previousFixCanceled=!1:(e.g.previousFixCanceled||(T(t,{...r,attributes:{...r.attributes,content:_}}),i=!0),0===p||s||(o.nbMoved<0&&P(t,c.attributeKey,p+o.nbMoved,p+o.nbMoved),o.nbMoved>0&&P(t,c.attributeKey,p+1+o.nbMoved,p+o.nbMoved),0===o.nbMoved&&P(t,c.attributeKey,p,p))))})),e.g.consistencyLoop=0},{getSelectedBlockClientId:q,isTyping:N,getBlockAttributes:O}=(0,t.select)("core/block-editor");(0,n.registerPlugin)("consistency-custom-sidebar",{render:()=>{const e=R("create","users");return(0,c.createElement)(c.Fragment,null,(0,c.createElement)(a.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,r.__)("Consistency","consistency"),icon:l},(0,c.createElement)(_,null),e&&(0,c.createElement)(C,null)),(0,c.createElement)(a.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,r.__)("Consistency Settings","consistency")))}}),o()((()=>{e.g.consistencyLoop=0,e.g.previousFixCanceledContent="",e.g.previousFixCanceled=!1,e.g.contentPasted=!1,document.querySelector("#editor")?.addEventListener("paste",(n=>{e.g.contentPasted=!0})),document.querySelector("#editor")?.addEventListener("keydown",(n=>{90===n.keyCode&&(n.ctrlKey||n.metaKey)&&(e.g.previousFixCanceled=!0,n.preventDefault())})),(0,t.subscribe)((()=>{const{onTheFly:n,onPaste:s}=(()=>{const e={onTheFly:!1,onPaste:!1},n=(0,t.select)(d.store).getCurrentUser(),s=g("root","user",n?.id||0,"consistency_plugin_user_settings"),o=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=o?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=o?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!n&&!s)return;const o=(()=>{const e=g("root","site"),n=e?.consistency_plugin_settings;return n})();if(void 0===o)return;if(e.g.contentPasted&&s)return void(n=>{const{settings:t}=n;let s=y.filter((e=>!0===t?.find((n=>n.slug===e.slug))?.value));const o=B(),c=o.flatMap((({innerBlocks:e,...n})=>e.map((e=>({...n,...e}))))),r=o.reduce(((e,n)=>{let t=n.attributes?.content;return b.includes(n.name)&&void 0!==t?(Object.entries(s).forEach((([e,n])=>{if(w(n.slug)){if(m.includes(n.slug)){const e=n.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],s=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");t=t.replaceAll(s,n.replace)}if(!m.includes(n.slug)){const e=n.mask.toString(),s=new RegExp(e.substring(1,e.length-1),"g");t=t.replaceAll(s,n.replace)}}})),void 0!==t&&(e[n.clientId]={content:t}),e):e}),{});Object.keys(r).length>0&&e.g.contentPasted&&(e.g.contentPasted=!1,$(Object.keys(r),r,!0)),e.g.contentPasted=!1,c.forEach((e=>{if(!b.includes(e.name))return;const n=e.clientId;e?.clientId&&U({currentBlockId:n,theRegs:s,isPasting:!0})}))})({settings:o});const c=q();if(null===c||e.g.contentPasted||!n)return;const r=O(c);r.hasOwnProperty("content")&&e.g.previousFixCanceledContent===r.content||(e.g.previousFixCanceledContent=r.content,N()&&U({currentBlockId:c,isPasting:!1,settings:o}))}))}))})();
     1(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const t=window.wp.plugins,n=window.wp.data,s=window.wp.domReady;var c=e.n(s);const o=window.React,r=window.wp.i18n,a=window.wp.editPost,i=window.wp.components,l=()=>(0,o.createElement)(i.Icon,{icon:(0,o.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,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,o.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),u=window.wp.coreData,p=window.wp.notices,d=e=>{const{settingSlug:t,settingName:s,settingDescription:c}=e,{currentUser:a}=(0,n.useSelect)((e=>({currentUser:e(u.store).getCurrentUser()})),[]),l=a&&a.id,[d,g]=(0,u.useEntityProp)("root","user","meta",l),{saveEditedEntityRecord:y}=(0,n.useDispatch)(u.store),{createNotice:m}=(0,n.useDispatch)(p.store);return(0,o.createElement)(i.ToggleControl,{label:s,help:(0,o.createElement)("span",{dangerouslySetInnerHTML:c}),checked:d?.consistency_plugin_user_settings?.find((e=>e.slug===t))?.value||!1,onChange:e=>{let n=d?.consistency_plugin_user_settings.map((n=>t===n.slug?{...n,value:e}:n));n?.find((e=>e.slug===t))||n.push({slug:t,value:e}),g({...d,consistency_plugin_user_settings:n}),y("root","user",l,{...d,meta:n}),m((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}})},g=()=>(0,o.createElement)(i.Panel,{className:"UserSettingPanel"},(0,o.createElement)(i.PanelHeader,null,(0,o.createElement)("strong",null,(0,r.__)("Settings for my account","consistency"))),(0,o.createElement)("div",{style:{padding:16}},(0,o.createElement)(i.PanelRow,null,(0,o.createElement)(d,{settingSlug:"on_the_fly",settingName:(0,r.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable on-the-fly autocorrect for my account","consistency")}})),(0,o.createElement)(i.PanelRow,null,(0,o.createElement)(d,{settingSlug:"on_paste",settingName:(0,r.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable autocorrect on paste for my account","consistency")}})))),{getEntityRecord:y}=(0,n.select)("core"),m=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],_=["core/paragraph","core/heading","core/quote","core/list-item","core/read-more"],{getBlock:b}=(0,n.select)("core/block-editor"),{updateBlock:h}=(0,n.dispatch)("core/block-editor"),{getBlockName:f,getBlockAttributes:k}=(0,n.select)("core/block-editor"),w=e=>{const t=(()=>{const e=y("root","site");return e?.language||"en_US"})();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},v=e=>{const{settingSlug:t,settingName:s,settingDescription:c}=e;if(!w(t))return"";const[a,l]=(0,u.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:d}=(0,n.useDispatch)(u.store),{createNotice:g}=(0,n.useDispatch)(p.store);return(0,o.createElement)(i.PanelRow,null,(0,o.createElement)(i.ToggleControl,{label:s,help:(0,o.createElement)("span",{dangerouslySetInnerHTML:c}),checked:a?.find((e=>e.slug===t))?.value||!1,onChange:e=>{let n=a.map((n=>t===n.slug?{...n,value:e}:n));n?.find((e=>e.slug===t))||n.push({slug:t,value:e}),l(n),d("root","site",void 0,n),g((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}}))},x=[{slug:"quote",name:(0,r.__)("Straight quote","consistency"),description:(0,r.__)("Replaces straight quotes with curved quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"punctuation"},{slug:"2hyphens",name:(0,r.__)("Two hyphens","consistency"),description:(0,r.__)("Replaces 2 hyphens with em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code>—</code></span>",mask:/(?:\-)\-/,replace:"—",nbMoved:-1,category:"punctuation"},{slug:"ordinalNumberSuffix",name:(0,r.__)("Ordinal number suffix","consistency"),description:(0,r.__)("Add HTML tag sup to ordinal number suffix","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:"punctuation"},{slug:"regularToCurlyQuotes",name:(0,r.__)("Curly quotes","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"regularToGermanQuotes",name:(0,r.__)("Regular quotes to german","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"regularToGermanBookStyleQuotes",name:(0,r.__)("Regular quotes to german book-style quotes","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"regularToFrenchQuotes",name:(0,r.__)("Regular quotes to french","consistency"),description:(0,r.__)("Replaces regular quotes with french quotes:","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:"punctuation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,r.__)("Regular quotes to french quotes without spaces","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"curlyToFrenchQuotes",name:(0,r.__)("Curly quotes to french quotes","consistency"),description:(0,r.__)("Replaces curly quotes with french quotes:","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:"punctuation"},{slug:"breakingSpace",name:(0,r.__)("Breaking space","consistency"),description:sprintf((0,r.__)("Replaces 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,r.__)("No space before","consistency"),description:sprintf((0,r.__)("Adds 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,r.__)("Space before","consistency"),description:(0,r.__)("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,r.__)("No breaking space after","consistency"),description:sprintf((0,r.__)("Adds 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,r.__)("No non breaking space after","consistency"),description:(0,r.__)("Adds 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,r.__)("First sentence letter not capitalized","consistency"),description:(0,r.__)("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,r.__)('3 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 3 dots placed after the abbreviation "etc" with a point:',"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,r.__)('2 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 2 dots placed after the abbreviation "etc" with a point:',"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,r.__)('Ellipsis following "etc"',"consistency"),description:(0,r.__)('Replaces ellipsis placed after the abbreviation "etc" with a point:',"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,r.__)("Ellipsis","consistency"),description:(0,r.__)("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,r.__)("Symbol in a circle","consistency"),description:(0,r.__)("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,r.__)("Symbol in small caps and superscript style","consistency"),description:(0,r.__)("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,r.__)("Fractions","consistency"),description:(0,r.__)("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,r.__)("Percentages","consistency"),description:(0,r.__)("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),n=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+n;case"0/00":return"‰"+n;case"0/000":return"‱"+n;default:return" "+n}},nbMoved:e=>{switch(e.substring(0,e.length-1)){case"0/0":return-2;case"0/00":return-3;case"0/000":return-4;default:return 0}},category:"symbol"}],E=[{slug:"punctuation",label:(0,r.__)("Punctuation","consistency"),description:(0,r.__)("Fixes related to punctuation.","consistency")},{slug:"space",label:(0,r.__)("Spaces","consistency"),description:(0,r.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,r.__)("Case","consistency"),description:(0,r.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,r.__)("Ellipsis","consistency"),description:(0,r.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,r.__)("Symbols","consistency"),description:(0,r.__)("Fixes related to symbols.","consistency")}],S=()=>(0,o.createElement)(i.Panel,{className:"GlobalSettingPanel"},(0,o.createElement)(i.PanelHeader,null,(0,o.createElement)("strong",null,(0,r.__)("Global correction rules","consistency"))),[...E].map(((e,t)=>(0,o.createElement)(i.PanelBody,{key:t,title:(0,r.__)(e.label,"consistency"),initialOpen:!1},[...x].filter((t=>t.category===e.slug)).map(((e,t)=>(0,o.createElement)(v,{key:t,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:C}=(0,n.select)("core"),{getBlock:R,getBlocks:P,getBlockAttributes:M,getSelectionStart:$,isTyping:q}=(0,n.select)("core/block-editor"),{updateBlock:T,selectionChange:B,updateBlockAttributes:F}=(0,n.dispatch)("core/block-editor"),z=t=>{const{currentBlockId:n,isPasting:s,settings:c}=t;let o=x.filter((e=>!0===c?.find((t=>t.slug===e.slug))?.value));const r=R(n);if(!(e=>{const t=f(e);return!!_.includes(t)})(n)||!(e=>{const t=k(e);return!(!t||!t.hasOwnProperty("content")||""===t.content)})(n))return;let a=M(n),i=!1;Object.entries(o).forEach((([t,c])=>{if(!w(c.slug)||i)return;e.g.consistencyLoop++,(t=>{e.g.consistencyLoop>=100&&(t=>{const n=b(t);h(t,{...n,attributes:{...n.attributes,content:n.attributes.content.slice(-2)}}),e.g.consistency_loop=0,console.log("Consistency - a memory leak has occured during the fix of the following block:",n)})(t)})(n);let o,l=c.replace,u="",p="",d=0,g=a.content,y=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(g),_=!1;if(q()||(_=c.mask.test(y)),q()){o=$(r.name),d=o?.offset||0;const e=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const n=document.getSelection(),s=n?.getRangeAt(0);if(!s.collapsed)return;const c=s.cloneRange(),o=document.createTextNode("\0");c.insertNode(o);let r=t?.innerHTML?.indexOf("\0");o.parentNode.removeChild(o),t.normalize();const a=(t?.innerHTML.match(/&nbsp;/g)||[]).length;return a>0&&(r=r-6*a+a),r})(n)||d,t=y.match(c.mask);if(null===t||0===t.length)return;const s=t[0].length||1;u=g.substring(0,e-s),p=g.substring(e-s,g.length),_=c.mask.test(y)&&c.mask.test(p)}if(!_)return;if((e=>!!m.includes(e.slug))(c)&&(l=((e,t,n)=>{const s=e.replace.charAt(0),c=e.replace.charAt(e.replace.length-1),o=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(`${s}`,"g"),i=new RegExp(`${c}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?s+o:r+c})(c,g)),0!==d&&(g=u+p.replace(c.mask,l)),0===d&&(g=g.replace(c.mask,c.replace)),e.g.previousFixCanceled)return void(e.g.previousFixCanceled=!1);if(e.g.previousFixCanceled||(T(n,{...r,attributes:{...r.attributes,content:g}}),i=!0),0===d||s)return;const f="function"==typeof c.nbMoved?c.nbMoved(p):c.nbMoved;f<0&&B(n,o.attributeKey,d+f,d+f),f>0&&B(n,o.attributeKey,d+1+f,d+f),0===f&&B(n,o.attributeKey,d,d)})),e.g.consistencyLoop=0},{getSelectedBlockClientId:L,isTyping:A,getBlockAttributes:N}=(0,n.select)("core/block-editor");(0,t.registerPlugin)("consistency-custom-sidebar",{render:()=>{const e=C("create","users");return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(a.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,r.__)("Consistency","consistency"),icon:l},(0,o.createElement)(g,null),e&&(0,o.createElement)(S,null)),(0,o.createElement)(a.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,r.__)("Consistency Settings","consistency")))}}),c()((()=>{e.g.consistencyLoop=0,e.g.previousFixCanceledContent="",e.g.previousFixCanceled=!1,e.g.contentPasted=!1,document.querySelector("#editor")?.addEventListener("paste",(t=>{e.g.contentPasted=!0})),document.querySelector("#editor")?.addEventListener("keydown",(t=>{90===t.keyCode&&(t.ctrlKey||t.metaKey)&&(e.g.previousFixCanceled=!0,t.preventDefault())})),(0,n.subscribe)((()=>{const{onTheFly:t,onPaste:s}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,n.select)(u.store).getCurrentUser(),s=y("root","user",t?.id||0,"consistency_plugin_user_settings"),c=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=c?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=c?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!t&&!s)return;const c=(()=>{const e=y("root","site"),t=e?.consistency_plugin_settings;return t})();if(void 0===c)return;if(e.g.contentPasted&&s)return void(t=>{const{settings:n}=t;let s=x.filter((e=>!0===n?.find((t=>t.slug===e.slug))?.value));const c=P(),o=c.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),r=c.reduce(((e,t)=>{let n=t.attributes?.content;return _.includes(t.name)&&void 0!==n?(Object.entries(s).forEach((([e,t])=>{if(w(t.slug)){if(m.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],s=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");n=n.replaceAll(s,t.replace)}if(!m.includes(t.slug)){const e=t.mask.toString(),s=new RegExp(e.substring(1,e.length-1),"g");n=n.replaceAll(s,t.replace)}}})),void 0!==n&&(e[t.clientId]={content:n}),e):e}),{});Object.keys(r).length>0&&e.g.contentPasted&&(e.g.contentPasted=!1,F(Object.keys(r),r,!0)),e.g.contentPasted=!1,o.forEach((e=>{if(!_.includes(e.name))return;const t=e.clientId;e?.clientId&&z({currentBlockId:t,theRegs:s,isPasting:!0})}))})({settings:c});const o=L();if(null===o||e.g.contentPasted||!t)return;const r=N(o);r.hasOwnProperty("content")&&e.g.previousFixCanceledContent===r.content||(e.g.previousFixCanceledContent=r.content,A()&&z({currentBlockId:o,isPasting:!1,settings:c}))}))}))})();
  • consistency/tags/1.5.9/consistency.php

    r3092051 r3092549  
    44 * Plugin URI:        https://www.webaxones.com
    55 * Description:       Fixes typographical consistency
    6  * Version:           1.5.8
     6 * Version:           1.5.9
    77 * Requires at least: 6.1
    88 * Requires PHP:      7.4
  • consistency/tags/1.5.9/includes/Asset/Asset.php

    r2857933 r3092549  
    88use const Webaxones\Consistency\PLUGIN_PATH;
    99use const Webaxones\Consistency\PLUGIN_URL;
     10use Webaxones\Consistency\Config\LocalizedRules;
    1011
    1112/**
     
    4142            true
    4243        );
     44
     45        // Convert dash style locales code to undescore style for JS
     46        $locales = LocalizedRules::$list;
     47        $locales = array_map(
     48            function ( $value ) {
     49                return array_map(
     50                    function ( $value ) {
     51                        return str_replace( '-', '_', $value );
     52                    },
     53                    $value
     54                );
     55            },
     56            $locales
     57        );
     58
     59        // Pass localized rules to the script
     60        $localizedRules = 'const localesByRules = ' . json_encode( $locales );
     61        wp_add_inline_script(
     62            Plugin::PREFIX . '-editor-script',
     63            $localizedRules,
     64            'before'
     65        );
     66   
    4367        wp_set_script_translations( Plugin::PREFIX . '-editor-script', 'consistency' );
    4468    }
  • consistency/tags/1.5.9/includes/Config/Rules.php

    r3092051 r3092549  
    66
    77use Webaxones\Consistency\Utils\Contracts\ValueInterface;
     8use Webaxones\Consistency\Config\LocalizedRules;
    89
    910/**
     
    1920    protected array $languages = [
    2021        'af', 'am', 'ar', 'arg', 'ary', 'as', 'az', 'azb', 'bel', 'bg-BG', 'bn-BD', 'bo', 'bs-BA', 'ca', 'ceb', 'ckb', 'cs-CZ', 'cy', 'da-DK', 'de-AT', 'de-CH', 'de-CH-informal', 'de-DE', 'de-DE-formal', 'dsb', 'dzo', 'el', 'en-AU', 'en-CA', 'en-GB', 'en-NZ', 'en-US', 'en-ZA', 'eo', 'es-AR', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-ES', 'es-GT', 'es-MX', 'es-PE', 'es-PR', 'es-UY', 'es-VE', 'et', 'eu', 'fa-AF', 'fa-IR', 'fi', 'fr-BE', 'fr-CA', 'fr-FR', 'fur', 'fy', 'gd', 'gl-ES', 'gu', 'haz', 'he-IL', 'hi-IN', 'hr', 'hsb', 'hu-HU', 'hy', 'id-ID', 'is-IS', 'it-IT', 'ja', 'jv-ID', 'kab', 'ka-GE', 'kk', 'km', 'kn', 'ko-KR', 'lo', 'lt-LT', 'lv', 'mk-MK', 'ml-IN', 'mn', 'mr', 'ms-MY', 'my-MM', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nl-NL-formal', 'nn-NO', 'oci', 'pa-IN', 'pl-PL', 'ps', 'pt-AO', 'pt-BR', 'pt-PT', 'pt-PT-ao90', 'rhg', 'ro-RO', 'ru-RU', 'sah', 'si-LK', 'skr', 'sk-SK', 'sl-SI', 'snd', 'sq', 'sr-RS', 'sv-SE', 'sw', 'szl', 'tah', 'ta-IN', 'ta-LK', 'te', 'th', 'tl', 'tr-TR', 'tt-RU', 'ug-CN', 'uk', 'ur', 'uz-UZ', 'vi', 'zh-CN', 'zh-HK', 'zh-TW',
    21     ];
    22 
    23     /**
    24      * All the rules with the languages where they are active
    25      *
    26      * @var array
    27      */
    28     protected array $localizedRules = [
    29         'quote'                              => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    30         '2hyphens'                           => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    31         'ordinalNumberSuffix'                => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    32         'regularToCurlyQuotes'               => [ 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    33         'regularToGermanQuotes'              => [ 'de-DE', 'de-AT', 'ro-RO' ],
    34         'regularToGermanBookStyleQuotes'     => [ 'de-DE', 'de-AT' ],
    35         'regularToFrenchQuotes'              => [ 'fr-FR', 'fr-BE' ],
    36         'regularToFrenchQuotesWithoutSpaces' => [ 'de-CH' ],
    37         'curlyToFrenchQuotes'                => [ 'fr-FR', 'fr-BE' ],
    38         'breakingSpace'                      => [ 'fr-FR', 'fr-BE' ],
    39         'noSpaceBefore'                      => [ 'fr-FR', 'fr-BE' ],
    40         'spaceBefore'                        => [ 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    41         'noBreakingSpaceAfter'               => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    42         'noNonBreakingSpaceAfter'            => [ 'fr-FR', 'fr-BE' ],
    43         'capitalizeFirstSentenceLetter'      => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    44         'etcThreeDots'                       => [ 'fr-FR', 'fr-BE' ],
    45         'etcTwoDots'                         => [ 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    46         'etcEllipsis'                        => [ 'fr-FR', 'fr-BE' ],
    47         'ellipsis'                           => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    48         'symbolBasedOn1Character'            => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    49         'symbolBasedOn2Characters'           => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    50         'fractions'                          => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    5122    ];
    5223
     
    9465    protected function setRules(): array
    9566    {
    96         foreach ( $this->localizedRules as $key => $value ) {
     67        foreach ( LocalizedRules::$list as $key => $value ) {
    9768            $this->rules[] = [
    9869                'slug'  => $key,
  • consistency/tags/1.5.9/includes/Plugin.php

    r3092051 r3092549  
    3131    protected static function setConstants(): void
    3232    {
    33         defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5.8' );
     33        defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5.9' );
    3434        defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) );
    3535        defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) );
     
    4747    {
    4848        self::setConstants();
    49 
    5049        $hooks = new Hook();
    51 
     50   
    5251        // Add main script
    5352        $assets = new Asset();
  • consistency/tags/1.5.9/package-lock.json

    r3084549 r3092549  
    11{
    22    "name": "consistency",
    3     "version": "1.5.1",
     3    "version": "1.5.8",
    44    "lockfileVersion": 3,
    55    "requires": true,
     
    77        "": {
    88            "name": "consistency",
    9             "version": "1.5.1",
     9            "version": "1.5.8",
    1010            "license": "ISC",
    1111            "devDependencies": {
  • consistency/tags/1.5.9/package.json

    r3092051 r3092549  
    11{
    22    "name": "consistency",
    3     "version": "1.5.8",
     3    "version": "1.5.9",
    44    "description": "",
    55    "main": "index.js",
  • consistency/tags/1.5.9/readme.md

    r3091663 r3092549  
    3131Remember to unfold the panel to see the rules. 
    3232
    33 ![image](https://user-images.githubusercontent.com/17084006/216155475-0a85f34d-89dc-4365-9aed-23ca401dde14.png)
    34 
    3533
    3634
    3735## Description
    3836
    39 The purpose of this plugin is to provide a tool allowing administrators to define typographical rules in order to maintain typographical consistency in the text contents entered on the editor.
    40 The corrections are automatic and are made during the entry as well as on a copy paste.
     37The purpose of this plugin is to provide a tool allowing administrators to define typographical rules in order to maintain typographical consistency in the text contents entered on the editor. 
     38> [!IMPORTANT]The corrections are automatic and are made during the entry as well as on a copy paste. 
     39
    4140Autocorrect rules can be enabled/disabled by any user.
    4241Autocorrect is available on pages, posts and custom post types (if their configuration allows Rest API usage)
     
    4443Currently, the AutoCorrects offered are as follows:
    4544
    46 ### English language corrections
     45| Name | Description | Example | Locales |
     46| --- | --- | :---: | --- |
     47| *Straight quote* | Replaces straight quotes with curved quotes | `'` → `'` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     48| *Two hyphens* | Replaces 2 hyphens with em dash | `--` → `—` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     49| *Ordinal number suffix* | Add HTML tag sup to ordinal number suffix | `1st` → 1<sup>st</sup> | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     50| *Curly quotes* | Replaces regular quotes with curly quotes | `" "` → `“ ”` | `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     51| *Regular quotes to german* | Replaces regular quotes with german quotes | `" "` → `„ “` | `de_DE` `de_AT` `ro_RO` |
     52| *Regular quotes to german book-style quotes* | Replaces regular quotes with german book-style quotes | `" "` → `» «` | `de_DE` `de_AT` |
     53| *Regular quotes to french* | Replaces regular quotes with french quotes | `" "` → `«   »` | `fr_FR` `fr_BE` |
     54| *Regular quotes to french quotes without spaces* | Replaces regular quotes with french quotes without spaces | `" "` → `« »` | `de_CH` |
     55| *Curly quotes to french quotes* | Replaces curly quotes with french quotes | `“ ”` → `«   »` | `fr_FR` `fr_BE` |
     56| *Breaking space* | Replaces a breaking space followed by a character from this list with a non-breaking space: | `? ! : ; » € $ £ ¥ ₽ 元 %` | `fr_FR` `fr_BE` |
     57| *No space before* | Adds a non-breaking space before a character from this list having no space before: | `? ! : ; » € $ £ ¥ ₽ 元 %` | `fr_FR` `fr_BE` |
     58| *Space before* | Remove any space preceding a character from this list: | `? ! : ; %` | `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     59| *No breaking space after* | Adds a breaking space after a character from this list when followed with another character: | `, … ) ]` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     60| *No non breaking space after* | Adds a non-breaking space after open french quote having no space after | `«` → `« ` | `fr_FR` `fr_BE` |
     61| *First sentence letter not capitalized* | Capitalize the first letter of a sentence | `a é ș` → `A É Ș` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     62| *3 dots following "etc"* | Replaces 3 dots placed after the abbreviation "etc" with a point | `etc...` → `etc.` | `fr_FR` `fr_BE` |
     63| *2 dots following "etc"* | Replaces 2 dots placed after the abbreviation "etc" with a point | `etc..` → `etc.` | `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     64| *Ellipsis following "etc"* | Replaces ellipsis placed after the abbreviation "etc" with a point | `etc…` → `etc.` | `fr_FR` `fr_BE` |
     65| *Ellipsis* | Replaces 3 dots with ellipsis | `...` → `…` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     66| *Symbol in a circle* | Replaces 1 character placed in parentheses with a symbol | `(c) (p) (r)` → `© ℗ ®` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     67| *Symbol in small caps and superscript style* | Replaces 2-character abbreviations with a symbol in small caps and superscript style | `tm sm md mc` → `™ ℠ 🅫 🅪` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     68| *Fractions* | Replaces fractions with fraction symbols | `1/2 3/5 1/9` → `½ ⅗ ⅑` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     69| *Percentages* | Replaces percentages with percentages symbols | `0/0 0/00 0/000` → `% ‰ ‱` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
    4770
    48 - **Straight quote**: Replaces straight quotes with curved quotes
    49 - **Ellipsis**: Replaces 3 dots with ellipsis
    50 - **Two hyphens**: Replaces 2 hyphens with em dash
    51 - **Ordinal number suffix**: Add HTML tag sup to ordinal number suffix
    52 - **Regular quotes to curly**: Replaces regular quotes with curly quotes
    53 - **No breaking space after**: Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    54 - **Space before**: Remove any space preceding a character from this list (? ! : ; %)
    55 - **First sentence letter not capitalized**: Capitalize the first letter of a sentence
    56 - etc.
    57 
    58 ### French language corrections
    59 
    60 - **Straight quote**: Replaces straight quotes with curved quotes
    61 - **Ellipsis**: Replaces 3 dots with ellipsis
    62 - **Two hyphens**: Replaces 2 hyphens with em dash
    63 - **Ordinal number suffix**: Add HTML tag sup to ordinal number suffix
    64 - **Regular quotes to French**: Replaces regular quotes with French quotes
    65 - **Breaking space**: Replaces a breaking space followed by a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) with a non-breaking space
    66 - **No space before**: Adds a non-breaking space before a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) having no space before
    67 - **No breaking space after**: Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    68 - **No non-breaking space after**: Adds a non-breaking space after open french quote having no space after
    69 - **First sentence letter not capitalized**: Capitalize the first letter of a sentence
    70 - etc.
    71 
    72 **Ctrl+Z** or **Cmd+Z** right after a correction disables the correction for the next keystroke. It is thus possible to force the non-correction of a character.
     71    
     72> [!TIP]
     73> **Ctrl+Z** or **Cmd+Z** right after a correction disables the correction for the next keystroke. It is thus possible to force the non-correction of a character.
    7374
    7475Technically, rules are saved in the `wp_options` table, while active/inactive states are saved as user meta data in `wp_usermeta` table.
     
    7778Settings are directly in a plugin sidebar under the Block Editor: no more searching for an options page, always available and discreet.
    7879
    79 The locales supported by this plugin are:
    80 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO'
    81 
    8280## Smoke tests
    8381
  • consistency/tags/1.5.9/readme.txt

    r3092051 r3092549  
    44Requires at least: 6.1
    55Tested up to: 6.5.2
    6 Stable tag: 1.5.8
     6Stable tag: 1.5.9
    77Requires PHP: 7.4
    88License: GPL-3.0-or-later
     
    1515Do you see the typographic corrector in your word processor that formats what you type in real time? Well, it's the same idea but with Gutenberg.
    1616
    17 The purpose of this plugin is to provide a tool allowing administrators to define typographical rules in order to maintain typographical consistency in the text contents entered on the editor.
    18 The corrections are automatic and are made during the entry as well as on a copy paste.
    19 Autocorrect rules can be enabled/disabled by any user.
    20 Autocorrect is available on pages, posts and custom post types (if their configuration allows Rest API usage)
     17This WordPress plugin is designed to help administrators enforce consistent typography in text content entered in the editor.
     18Corrections are applied automatically both during text entry and when pasting text.
     19Users can enable or disable autocorrect rules as needed.
     20Autocorrect is available for pages, posts, and custom post types (if they are configured to use the Rest API).
    2121
    22 Currently, the AutoCorrects offered are as follows:
     22Automatic fixes are listed on [the plugin repository on github](https://github.com/webaxones/consistency/).
    2323
    24 For the English language
    2524
    26 - "Straight quote": Replaces straight quotes with curved quotes
    27 - "Ellipsis": Replaces 3 dots with ellipsis
    28 - "Two hyphens": Replaces 2 hyphens with em dash
    29 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix
    30 - "Regular quotes to curly": Replaces regular quotes with curly quotes
    31 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    32 - "Space before": Remove any space preceding a character from this list (? ! : ; %)
    33 - "First sentence letter not capitalized": Capitalize the first letter of a sentence
    34 - etc.
    35 
    36 For the French language
    37 
    38 - "Straight quote": Replaces straight quotes with curved quotes
    39 - "Ellipsis": Replaces 3 dots with ellipsis
    40 - "Two hyphens": Replaces 2 hyphens with em dash
    41 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix
    42 - "Regular quotes to French": Replaces regular quotes with French quotes
    43 - "Breaking space": Replaces a breaking space followed by a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) with a non-breaking space
    44 - "No space before": Adds a non-breaking space before a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) having no space before
    45 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    46 - "No non-breaking space after": Adds a non-breaking space after open french quote having no space after
    47 - "First sentence letter not capitalized": Capitalize the first letter of a sentence
    48 - etc.
    4925
    5026Ctrl+Z or Cmd+Z right after a correction disables the correction for the next keystroke
     
    6945
    7046== Changelog ==
     47
     48= 1.5.9 =
     49* Add rule for percentages symbols
     50* Refactor some code
     51* Actualise Readme
    7152
    7253= 1.5.8 =
  • consistency/tags/1.5.9/src/app/checks.js

    r3086094 r3092549  
    1515 */
    1616import { getCurrentLocale } from './data'
    17 import { rules } from '../config/rules'
    1817import { regsWithPair } from '../config/regsWithPair'
    1918import { processedBlocks } from '../config/processedBlocks'
     
    3231
    3332    const currentLocale = getCurrentLocale()
    34     const theRegex = rules?.find( x => x.slug === settingSlug )
    35 
    36     if ( undefined !== theRegex && theRegex?.locales?.includes( currentLocale ) ) {
    37         return true
     33    if ( localesByRules !== undefined && localesByRules.hasOwnProperty( settingSlug ) ) {
     34        return localesByRules[settingSlug].includes( currentLocale )
    3835    }
    39 
    4036    return false
    4137
  • consistency/tags/1.5.9/src/app/fixes.js

    r3091983 r3092549  
    9797            firstPart = blockContent.substring( 0, cursorPositionInsideHTML - lengthToGoBack )
    9898            lastPart = blockContent.substring( cursorPositionInsideHTML - lengthToGoBack, blockContent.length )
    99 
     99   
    100100            // If first part of the string matches but not the lastPart, it means that a character has been typed uncorrected voluntarily before, so it should not be taken into account
    101101            isConcerned = reg.mask.test( textContent ) && reg.mask.test( lastPart )
     
    104104        // Stop correction if block content isn't concerned by the regex
    105105        if ( ! isConcerned ) return
     106       
    106107        // Pairing characters need specific process for the replacement
    107108        if ( regDealWithPair( reg ) ) {
     
    137138        if ( 0 === cursorPosition || isPasting ) return
    138139
     140        // Get the number of characters moved by the replacement: needed for cursor repositioning
     141        // If the number depends on the replaced string length, we use a function to get it
     142        const nbMoved = typeof reg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved
     143
    139144        // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back
    140145        // Eg: ... replaced with … removes 2 characters
    141         if ( reg.nbMoved < 0 ) {
    142             // selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition - 1, cursorPosition + reg.nbMoved )
    143             selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + reg.nbMoved, cursorPosition + reg.nbMoved )
     146        if ( nbMoved < 0 ) {
     147            selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + nbMoved, cursorPosition + nbMoved )
    144148        }
    145149       
    146150        // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward
    147151        // Eg: "" replaced with «  » adds 2 characters
    148         if ( reg.nbMoved > 0 ) {
    149             selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + 1 + reg.nbMoved, cursorPosition + reg.nbMoved )
    150         }
    151 
    152         if ( 0 === reg.nbMoved ) {
     152        if ( nbMoved > 0 ) {
     153            selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + 1 + nbMoved, cursorPosition + nbMoved )
     154        }
     155
     156        if ( 0 === nbMoved ) {
    153157            selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition, cursorPosition )
    154158        }
  • consistency/tags/1.5.9/src/config/rules.js

    r3092051 r3092549  
    2121        replace: '’', // replacement string
    2222        nbMoved: 0, // number of characters less or more during replacement
    23         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ], // concerned locales
    2423        category: 'punctuation' // category of the setting
    2524    },
     
    3332        replace: '—',
    3433        nbMoved: -1,
    35         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    3634        category: 'punctuation'
    3735    },
     
    4543        replace: '$1<sup>$2<\/sup>$3',
    4644        nbMoved: 0,
    47         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    4845        category: 'punctuation'
    4946    },
     
    5754        replace: '“$1”',
    5855        nbMoved: 0,
    59         locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    6056        category: 'punctuation'
    6157    },
     
    6965        replace: '„$1“',
    7066        nbMoved: 0,
    71         locales: [ 'de_DE', 'de_AT', 'ro_RO' ],
    7267        category: 'punctuation'
    7368    },
     
    8176        replace: '»$1«',
    8277        nbMoved: 0,
    83         locales: [ 'de_DE', 'de_AT' ],
    8478        category: 'punctuation'
    8579    },
     
    8983        name: __( 'Regular quotes to french', 'consistency' ),
    9084        description: __( 'Replaces regular quotes with french quotes:', 'consistency' )
    91             + `<span aria-hidden='true' style='display:block;'><code>" "</code> <span style='font-size:20px'>→</span> <code>« »</code></span>`,
     85            + `<span aria-hidden='true' style='display:block;'><code>" "</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>`,
    9286        mask: /"/, // specific mask with specific process
    9387        replace: '« $1 »',
    9488        nbMoved: 1,
    95         locales: [ 'fr_FR', 'fr_BE' ],
    9689        category: 'punctuation'
    9790    },
     
    10598        replace: '«$1»',
    10699        nbMoved: 0,
    107         locales: [ 'de_CH' ],
    108100        category: 'punctuation'
    109101    },
     
    113105        name: __( 'Curly quotes to french quotes', 'consistency' ),
    114106        description: __( 'Replaces curly quotes with french quotes:', 'consistency' )
    115             + `<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>`,
     107            + `<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>`,
    116108        mask: /“.*?”/, // specific mask with specific process
    117109        replace: matched => { return `« ${matched.substring( 1, matched.length - 1 )} »` },
    118110        nbMoved: 0,
    119         locales: [ 'fr_FR', 'fr_BE' ],
    120111        category: 'punctuation'
    121112    },
     
    129120        replace: ' $1',
    130121        nbMoved: 0,
    131         locales: [ 'fr_FR', 'fr_BE' ],
    132122        category: 'space'
    133123    },
     
    141131        replace: ' $1',
    142132        nbMoved: 1,
    143         locales: [ 'fr_FR', 'fr_BE' ],
    144133        category: 'space'
    145134    },
     
    153142        replace: '$2',
    154143        nbMoved: -1,
    155         locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    156144        category: 'space'
    157145    },
     
    165153        replace: '$1 $2',
    166154        nbMoved: 1,
    167         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    168155        category: 'space'
    169156    },
     
    176163        replace: '$1 ',
    177164        nbMoved: 0,
    178         locales: [ 'fr_FR', 'fr_BE' ],
    179165        category: 'space'
    180166    },
     
    187173        replace: matched => matched.toUpperCase(),
    188174        nbMoved: 0,
    189         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    190175        category: 'case'
    191176    },
     
    199184        replace: matched => { return matched.substring(0, 3) + '.' },
    200185        nbMoved: -2,
    201         locales: [ 'fr_FR', 'fr_BE' ],
    202186        category: 'ellipsis'
    203187    },
     
    211195        replace: matched => { return matched.substring(0, 2) + '.' },
    212196        nbMoved: -1,
    213         locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    214197        category: 'ellipsis'
    215198    },
     
    217200        // Replaces etc… with etc.
    218201        slug: 'etcEllipsis',
    219         name: __( 'ellipsis following "etc"', 'consistency' ),
     202        name: __( 'Ellipsis following "etc"', 'consistency' ),
    220203        description: __( 'Replaces ellipsis placed after the abbreviation "etc" with a point:', 'consistency' )
    221204        + `<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>`,
     
    223206        replace: matched => { return matched.substring(0, 3) + '.' },
    224207        nbMoved: 0,
    225         locales: [ 'fr_FR', 'fr_BE' ],
    226208        category: 'ellipsis'
    227209    },
     
    235217        replace: '…',
    236218        nbMoved: -2,
    237         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    238219        category: 'ellipsis'
    239220    },
    240221    {
    241222        // Replaces a character from this list [c p r] when enclosed in parentheses with a symbol
    242         slug: 'symbolBasedOn1Character',
    243         name: __( 'Symbol based on 1 character', 'consistency' ),
     223        slug: 'symbolInACircle',
     224        name: __( 'Symbol in a circle', 'consistency' ),
    244225        description: __( 'Replaces 1 character placed in parentheses with a symbol', 'consistency' )
    245226            + `<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>`,
     
    257238        },
    258239        nbMoved: -2,
    259         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    260240        category: 'symbol'
    261241    },
    262242    {
    263         // Replaces a character from this list [md tm mc sm] when enclosed in parentheses with a symbol
    264         slug: 'symbolBasedOn2Characters',
    265         name: __( 'Symbol based on 2 characters', 'consistency' ),
    266         description: __( 'Replaces 2-character abbreviations in parentheses with a symbol', 'consistency' )
    267         + `<span aria-hidden='true' style='display:block;'><code>(tm) (sm) (md) (mc)</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>`,
    268         mask: /(\(tm|\(sm|\(md|\(mc)(\))/,
     243        // Replaces a character from this list [md tm mc sm] with a symbol in small caps and superscript style
     244        slug: 'symbolInSmallCapsAndSuperscriptStyle',
     245        name: __( 'Symbol in small caps and superscript style', 'consistency' ),
     246        description: __( 'Replaces 2-character abbreviations with a symbol in small caps and superscript style', 'consistency' )
     247        + `<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>`,
     248        mask: /(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,
    269249        replace: matched => {
    270250            switch ( matched ) {
    271                 case '(tm)':
     251                case 'tm':
    272252                    return '™'
    273                 case '(sm)':
     253                case 'sm':
    274254                    return '℠'
    275                 case '(md)':
     255                case 'md':
    276256                    return '🅫'
    277                 case '(mc)':
     257                case 'mc':
    278258                    return '🅪'
    279259                default:
     
    281261            }
    282262        },
    283         nbMoved: -3,
    284         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
     263        nbMoved: -1,
    285264        category: 'symbol'
    286265    },
     
    290269        name: __( 'Fractions', 'consistency' ),
    291270        description: __( 'Replaces fractions with fraction symbols:', 'consistency' )
    292             + `<span aria-hidden='true' style='display:block;'><code>3/5</code> <span style='font-size:20px'>→</span> <code>⅗</code></span>`,
     271            + `<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>`,
    293272        mask: /[1-9]\/[1-9]/,
    294273        replace: matched => {
     
    333312        },
    334313        nbMoved: -2,
    335         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
     314        category: 'symbol'
     315    },
     316    {
     317        // Replaces fractions with a fraction symbol
     318        slug: 'percentages',
     319        name: __( 'Percentages', 'consistency' ),
     320        description: __( 'Replaces percentages with percentages symbols:', 'consistency' )
     321            + `<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>`,
     322        mask: /(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,
     323        replace: matched => {
     324            const matchedFirstPart = matched.substring( 0, matched.length - 1 )
     325            const matchedLastPart = matched.substring( matched.length - 1, matched.length )
     326            switch ( matchedFirstPart ) {
     327                case '0/0':
     328                    return '%' + matchedLastPart
     329                case '0/00':
     330                    return '‰' + matchedLastPart
     331                case '0/000':
     332                    return '‱' + matchedLastPart
     333                default:
     334                    return ' ' + matchedLastPart
     335            }
     336        },
     337        nbMoved: lastPart => {
     338            const replacedString = lastPart.substring( 0, lastPart.length - 1 )
     339            switch ( replacedString ) {
     340                case '0/0':
     341                    return -2
     342                case '0/00':
     343                    return -3
     344                case '0/000':
     345                    return -4
     346                default:
     347                    return 0
     348            }
     349         },
    336350        category: 'symbol'
    337351    },
  • consistency/tags/1.5.9/vendor/autoload.php

    r3084555 r3092549  
    33// autoload.php @generated by Composer
    44
     5if (PHP_VERSION_ID < 50600) {
     6    if (!headers_sent()) {
     7        header('HTTP/1.1 500 Internal Server Error');
     8    }
     9    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
     10    if (!ini_get('display_errors')) {
     11        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
     12            fwrite(STDERR, $err);
     13        } elseif (!headers_sent()) {
     14            echo $err;
     15        }
     16    }
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
     21}
     22
    523require_once __DIR__ . '/composer/autoload_real.php';
    624
  • consistency/tags/1.5.9/vendor/composer/ClassLoader.php

    r3084555 r3092549  
    4343class ClassLoader
    4444{
    45     /** @var ?string */
     45    /** @var \Closure(string):void */
     46    private static $includeFile;
     47
     48    /** @var string|null */
    4649    private $vendorDir;
    4750
    4851    // PSR-4
    4952    /**
    50      * @var array[]
    51      * @psalm-var array<string, array<string, int>>
     53     * @var array<string, array<string, int>>
    5254     */
    5355    private $prefixLengthsPsr4 = array();
    5456    /**
    55      * @var array[]
    56      * @psalm-var array<string, array<int, string>>
     57     * @var array<string, list<string>>
    5758     */
    5859    private $prefixDirsPsr4 = array();
    5960    /**
    60      * @var array[]
    61      * @psalm-var array<string, string>
     61     * @var list<string>
    6262     */
    6363    private $fallbackDirsPsr4 = array();
     
    6565    // PSR-0
    6666    /**
    67      * @var array[]
    68      * @psalm-var array<string, array<string, string[]>>
     67     * List of PSR-0 prefixes
     68     *
     69     * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
     70     *
     71     * @var array<string, array<string, list<string>>>
    6972     */
    7073    private $prefixesPsr0 = array();
    7174    /**
    72      * @var array[]
    73      * @psalm-var array<string, string>
     75     * @var list<string>
    7476     */
    7577    private $fallbackDirsPsr0 = array();
     
    7981
    8082    /**
    81      * @var string[]
    82      * @psalm-var array<string, string>
     83     * @var array<string, string>
    8384     */
    8485    private $classMap = array();
     
    8889
    8990    /**
    90      * @var bool[]
    91      * @psalm-var array<string, bool>
     91     * @var array<string, bool>
    9292     */
    9393    private $missingClasses = array();
    9494
    95     /** @var ?string */
     95    /** @var string|null */
    9696    private $apcuPrefix;
    9797
    9898    /**
    99      * @var self[]
     99     * @var array<string, self>
    100100     */
    101101    private static $registeredLoaders = array();
    102102
    103103    /**
    104      * @param ?string $vendorDir
     104     * @param string|null $vendorDir
    105105     */
    106106    public function __construct($vendorDir = null)
    107107    {
    108108        $this->vendorDir = $vendorDir;
    109     }
    110 
    111     /**
    112      * @return string[]
     109        self::initializeIncludeClosure();
     110    }
     111
     112    /**
     113     * @return array<string, list<string>>
    113114     */
    114115    public function getPrefixes()
     
    122123
    123124    /**
    124      * @return array[]
    125      * @psalm-return array<string, array<int, string>>
     125     * @return array<string, list<string>>
    126126     */
    127127    public function getPrefixesPsr4()
     
    131131
    132132    /**
    133      * @return array[]
    134      * @psalm-return array<string, string>
     133     * @return list<string>
    135134     */
    136135    public function getFallbackDirs()
     
    140139
    141140    /**
    142      * @return array[]
    143      * @psalm-return array<string, string>
     141     * @return list<string>
    144142     */
    145143    public function getFallbackDirsPsr4()
     
    149147
    150148    /**
    151      * @return string[] Array of classname => path
    152      * @psalm-return array<string, string>
     149     * @return array<string, string> Array of classname => path
    153150     */
    154151    public function getClassMap()
     
    158155
    159156    /**
    160      * @param string[] $classMap Class to filename map
    161      * @psalm-param array<string, string> $classMap
     157     * @param array<string, string> $classMap Class to filename map
    162158     *
    163159     * @return void
     
    176172     * appending or prepending to the ones previously set for this prefix.
    177173     *
    178      * @param string          $prefix  The prefix
    179      * @param string[]|string $paths   The PSR-0 root directories
    180      * @param bool            $prepend Whether to prepend the directories
     174     * @param string              $prefix  The prefix
     175     * @param list<string>|string $paths   The PSR-0 root directories
     176     * @param bool                $prepend Whether to prepend the directories
    181177     *
    182178     * @return void
     
    184180    public function add($prefix, $paths, $prepend = false)
    185181    {
     182        $paths = (array) $paths;
    186183        if (!$prefix) {
    187184            if ($prepend) {
    188185                $this->fallbackDirsPsr0 = array_merge(
    189                     (array) $paths,
     186                    $paths,
    190187                    $this->fallbackDirsPsr0
    191188                );
     
    193190                $this->fallbackDirsPsr0 = array_merge(
    194191                    $this->fallbackDirsPsr0,
    195                     (array) $paths
     192                    $paths
    196193                );
    197194            }
     
    202199        $first = $prefix[0];
    203200        if (!isset($this->prefixesPsr0[$first][$prefix])) {
    204             $this->prefixesPsr0[$first][$prefix] = (array) $paths;
     201            $this->prefixesPsr0[$first][$prefix] = $paths;
    205202
    206203            return;
     
    208205        if ($prepend) {
    209206            $this->prefixesPsr0[$first][$prefix] = array_merge(
    210                 (array) $paths,
     207                $paths,
    211208                $this->prefixesPsr0[$first][$prefix]
    212209            );
     
    214211            $this->prefixesPsr0[$first][$prefix] = array_merge(
    215212                $this->prefixesPsr0[$first][$prefix],
    216                 (array) $paths
     213                $paths
    217214            );
    218215        }
     
    223220     * appending or prepending to the ones previously set for this namespace.
    224221     *
    225      * @param string          $prefix  The prefix/namespace, with trailing '\\'
    226      * @param string[]|string $paths   The PSR-4 base directories
    227      * @param bool            $prepend Whether to prepend the directories
     222     * @param string              $prefix  The prefix/namespace, with trailing '\\'
     223     * @param list<string>|string $paths   The PSR-4 base directories
     224     * @param bool                $prepend Whether to prepend the directories
    228225     *
    229226     * @throws \InvalidArgumentException
     
    233230    public function addPsr4($prefix, $paths, $prepend = false)
    234231    {
     232        $paths = (array) $paths;
    235233        if (!$prefix) {
    236234            // Register directories for the root namespace.
    237235            if ($prepend) {
    238236                $this->fallbackDirsPsr4 = array_merge(
    239                     (array) $paths,
     237                    $paths,
    240238                    $this->fallbackDirsPsr4
    241239                );
     
    243241                $this->fallbackDirsPsr4 = array_merge(
    244242                    $this->fallbackDirsPsr4,
    245                     (array) $paths
     243                    $paths
    246244                );
    247245            }
     
    253251            }
    254252            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
    255             $this->prefixDirsPsr4[$prefix] = (array) $paths;
     253            $this->prefixDirsPsr4[$prefix] = $paths;
    256254        } elseif ($prepend) {
    257255            // Prepend directories for an already registered namespace.
    258256            $this->prefixDirsPsr4[$prefix] = array_merge(
    259                 (array) $paths,
     257                $paths,
    260258                $this->prefixDirsPsr4[$prefix]
    261259            );
     
    264262            $this->prefixDirsPsr4[$prefix] = array_merge(
    265263                $this->prefixDirsPsr4[$prefix],
    266                 (array) $paths
     264                $paths
    267265            );
    268266        }
     
    273271     * replacing any others previously set for this prefix.
    274272     *
    275      * @param string          $prefix The prefix
    276      * @param string[]|string $paths  The PSR-0 base directories
     273     * @param string              $prefix The prefix
     274     * @param list<string>|string $paths  The PSR-0 base directories
    277275     *
    278276     * @return void
     
    291289     * replacing any others previously set for this namespace.
    292290     *
    293      * @param string          $prefix The prefix/namespace, with trailing '\\'
    294      * @param string[]|string $paths  The PSR-4 base directories
     291     * @param string              $prefix The prefix/namespace, with trailing '\\'
     292     * @param list<string>|string $paths  The PSR-4 base directories
    295293     *
    296294     * @throws \InvalidArgumentException
     
    426424    {
    427425        if ($file = $this->findFile($class)) {
    428             includeFile($file);
     426            $includeFile = self::$includeFile;
     427            $includeFile($file);
    429428
    430429            return true;
     
    477476
    478477    /**
    479      * Returns the currently registered loaders indexed by their corresponding vendor directories.
    480      *
    481      * @return self[]
     478     * Returns the currently registered loaders keyed by their corresponding vendor directories.
     479     *
     480     * @return array<string, self>
    482481     */
    483482    public static function getRegisteredLoaders()
     
    556555        return false;
    557556    }
     557
     558    /**
     559     * @return void
     560     */
     561    private static function initializeIncludeClosure()
     562    {
     563        if (self::$includeFile !== null) {
     564            return;
     565        }
     566
     567        /**
     568         * Scope isolated include.
     569         *
     570         * Prevents access to $this/self from included files.
     571         *
     572         * @param  string $file
     573         * @return void
     574         */
     575        self::$includeFile = \Closure::bind(static function($file) {
     576            include $file;
     577        }, null, null);
     578    }
    558579}
    559 
    560 /**
    561  * Scope isolated include.
    562  *
    563  * Prevents access to $this/self from included files.
    564  *
    565  * @param  string $file
    566  * @return void
    567  * @private
    568  */
    569 function includeFile($file)
    570 {
    571     include $file;
    572 }
  • consistency/tags/1.5.9/vendor/composer/autoload_classmap.php

    r3084555 r3092549  
    33// autoload_classmap.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
     
    99    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    1010    'Webaxones\\Consistency\\Asset\\Asset' => $baseDir . '/includes/Asset/Asset.php',
     11    'Webaxones\\Consistency\\Config\\LocalizedRules' => $baseDir . '/includes/Config/LocalizedRules.php',
    1112    'Webaxones\\Consistency\\Config\\RestSchema' => $baseDir . '/includes/Config/RestSchema.php',
    1213    'Webaxones\\Consistency\\Config\\Rules' => $baseDir . '/includes/Config/Rules.php',
  • consistency/tags/1.5.9/vendor/composer/autoload_namespaces.php

    r3084555 r3092549  
    33// autoload_namespaces.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • consistency/tags/1.5.9/vendor/composer/autoload_psr4.php

    r3084555 r3092549  
    33// autoload_psr4.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • consistency/tags/1.5.9/vendor/composer/autoload_real.php

    r3084555 r3092549  
    2626
    2727        spl_autoload_register(array('ComposerAutoloaderInit2f7e358677dd7dd5194d994145b49327', 'loadClassLoader'), true, true);
    28         self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    2929        spl_autoload_unregister(array('ComposerAutoloaderInit2f7e358677dd7dd5194d994145b49327', 'loadClassLoader'));
    3030
    31         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    32         if ($useStaticLoader) {
    33             require __DIR__ . '/autoload_static.php';
    34 
    35             call_user_func(\Composer\Autoload\ComposerStaticInit2f7e358677dd7dd5194d994145b49327::getInitializer($loader));
    36         } else {
    37             $map = require __DIR__ . '/autoload_namespaces.php';
    38             foreach ($map as $namespace => $path) {
    39                 $loader->set($namespace, $path);
    40             }
    41 
    42             $map = require __DIR__ . '/autoload_psr4.php';
    43             foreach ($map as $namespace => $path) {
    44                 $loader->setPsr4($namespace, $path);
    45             }
    46 
    47             $classMap = require __DIR__ . '/autoload_classmap.php';
    48             if ($classMap) {
    49                 $loader->addClassMap($classMap);
    50             }
    51         }
     31        require __DIR__ . '/autoload_static.php';
     32        call_user_func(\Composer\Autoload\ComposerStaticInit2f7e358677dd7dd5194d994145b49327::getInitializer($loader));
    5233
    5334        $loader->register(true);
  • consistency/tags/1.5.9/vendor/composer/autoload_static.php

    r3084555 r3092549  
    2424        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
    2525        'Webaxones\\Consistency\\Asset\\Asset' => __DIR__ . '/../..' . '/includes/Asset/Asset.php',
     26        'Webaxones\\Consistency\\Config\\LocalizedRules' => __DIR__ . '/../..' . '/includes/Config/LocalizedRules.php',
    2627        'Webaxones\\Consistency\\Config\\RestSchema' => __DIR__ . '/../..' . '/includes/Config/RestSchema.php',
    2728        'Webaxones\\Consistency\\Config\\Rules' => __DIR__ . '/../..' . '/includes/Config/Rules.php',
  • consistency/trunk/build/index.asset.php

    r3092051 r3092549  
    1 <?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-i18n', 'wp-notices', 'wp-plugins'), 'version' => '39581bcb252f47209402');
     1<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-i18n', 'wp-notices', 'wp-plugins'), 'version' => '2291d62ab83f3f59c1f5');
  • consistency/trunk/build/index.js

    r3092051 r3092549  
    1 (()=>{"use strict";var e={n:n=>{var t=n&&n.__esModule?()=>n.default:()=>n;return e.d(t,{a:t}),t},d:(n,t)=>{for(var s in t)e.o(t,s)&&!e.o(n,s)&&Object.defineProperty(n,s,{enumerable:!0,get:t[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);const n=window.wp.plugins,t=window.wp.data,s=window.wp.domReady;var o=e.n(s);const c=window.React,r=window.wp.i18n,a=window.wp.editPost,i=window.wp.components,l=()=>(0,c.createElement)(i.Icon,{icon:(0,c.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,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,c.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,c.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),d=window.wp.coreData,u=window.wp.notices,p=e=>{const{settingSlug:n,settingName:s,settingDescription:o}=e,{currentUser:a}=(0,t.useSelect)((e=>({currentUser:e(d.store).getCurrentUser()})),[]),l=a&&a.id,[p,_]=(0,d.useEntityProp)("root","user","meta",l),{saveEditedEntityRecord:g}=(0,t.useDispatch)(d.store),{createNotice:y}=(0,t.useDispatch)(u.store);return(0,c.createElement)(i.ToggleControl,{label:s,help:(0,c.createElement)("span",{dangerouslySetInnerHTML:o}),checked:p?.consistency_plugin_user_settings?.find((e=>e.slug===n))?.value||!1,onChange:e=>{let t=p?.consistency_plugin_user_settings.map((t=>n===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===n))||t.push({slug:n,value:e}),_({...p,consistency_plugin_user_settings:t}),g("root","user",l,{...p,meta:t}),y((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}})},_=()=>(0,c.createElement)(i.Panel,{className:"UserSettingPanel"},(0,c.createElement)(i.PanelHeader,null,(0,c.createElement)("strong",null,(0,r.__)("Settings for my account","consistency"))),(0,c.createElement)("div",{style:{padding:16}},(0,c.createElement)(i.PanelRow,null,(0,c.createElement)(p,{settingSlug:"on_the_fly",settingName:(0,r.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable on-the-fly autocorrect for my account","consistency")}})),(0,c.createElement)(i.PanelRow,null,(0,c.createElement)(p,{settingSlug:"on_paste",settingName:(0,r.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable autocorrect on paste for my account","consistency")}})))),{getEntityRecord:g}=(0,t.select)("core"),y=[{slug:"quote",name:(0,r.__)("Straight quote","consistency"),description:(0,r.__)("Replaces straight quotes with curved quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"punctuation"},{slug:"2hyphens",name:(0,r.__)("Two hyphens","consistency"),description:(0,r.__)("Replaces 2 hyphens with em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code>—</code></span>",mask:/(?:\-)\-/,replace:"—",nbMoved:-1,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"punctuation"},{slug:"ordinalNumberSuffix",name:(0,r.__)("Ordinal number suffix","consistency"),description:(0,r.__)("Add HTML tag sup to ordinal number suffix","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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"punctuation"},{slug:"regularToCurlyQuotes",name:(0,r.__)("Curly quotes","consistency"),description:(0,r.__)("Replaces regular 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,locales:["en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"punctuation"},{slug:"regularToGermanQuotes",name:(0,r.__)("Regular quotes to german","consistency"),description:(0,r.__)("Replaces regular 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,locales:["de_DE","de_AT","ro_RO"],category:"punctuation"},{slug:"regularToGermanBookStyleQuotes",name:(0,r.__)("Regular quotes to german book-style quotes","consistency"),description:(0,r.__)("Replaces regular 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,locales:["de_DE","de_AT"],category:"punctuation"},{slug:"regularToFrenchQuotes",name:(0,r.__)("Regular quotes to french","consistency"),description:(0,r.__)("Replaces regular quotes with french quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,locales:["fr_FR","fr_BE"],category:"punctuation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,r.__)("Regular quotes to french quotes without spaces","consistency"),description:(0,r.__)("Replaces regular 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,locales:["de_CH"],category:"punctuation"},{slug:"curlyToFrenchQuotes",name:(0,r.__)("Curly quotes to french quotes","consistency"),description:(0,r.__)("Replaces curly quotes with french quotes:","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,locales:["fr_FR","fr_BE"],category:"punctuation"},{slug:"breakingSpace",name:(0,r.__)("Breaking space","consistency"),description:sprintf((0,r.__)("Replaces 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,locales:["fr_FR","fr_BE"],category:"space"},{slug:"noSpaceBefore",name:(0,r.__)("No space before","consistency"),description:sprintf((0,r.__)("Adds 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,locales:["fr_FR","fr_BE"],category:"space"},{slug:"spaceBefore",name:(0,r.__)("Space before","consistency"),description:(0,r.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,locales:["en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"space"},{slug:"noBreakingSpaceAfter",name:(0,r.__)("No breaking space after","consistency"),description:sprintf((0,r.__)("Adds 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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,r.__)("No non breaking space after","consistency"),description:(0,r.__)("Adds a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | |&nbsp;)/,replace:"$1 ",nbMoved:0,locales:["fr_FR","fr_BE"],category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,r.__)("First sentence letter not capitalized","consistency"),description:(0,r.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"case"},{slug:"etcThreeDots",name:(0,r.__)('3 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 3 dots placed after the abbreviation "etc" with a point:',"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,locales:["fr_FR","fr_BE"],category:"ellipsis"},{slug:"etcTwoDots",name:(0,r.__)('2 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 2 dots placed after the abbreviation "etc" with a point:',"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,locales:["en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB"],category:"ellipsis"},{slug:"etcEllipsis",name:(0,r.__)('ellipsis following "etc"',"consistency"),description:(0,r.__)('Replaces ellipsis placed after the abbreviation "etc" with a point:',"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,locales:["fr_FR","fr_BE"],category:"ellipsis"},{slug:"ellipsis",name:(0,r.__)("Ellipsis","consistency"),description:(0,r.__)("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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"ellipsis"},{slug:"symbolBasedOn1Character",name:(0,r.__)("Symbol based on 1 character","consistency"),description:(0,r.__)("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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"symbol"},{slug:"symbolBasedOn2Characters",name:(0,r.__)("Symbol based on 2 characters","consistency"),description:(0,r.__)("Replaces 2-character abbreviations in parentheses with a symbol","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:-3,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"symbol"},{slug:"fractions",name:(0,r.__)("Fractions","consistency"),description:(0,r.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>3/5</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,locales:["fr_FR","fr_BE","en_US","en_AU","en_CA","en_NZ","en_ZA","en_GB","de_DE","de_AT","de_CH","ro_RO"],category:"symbol"}],m=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],b=["core/paragraph","core/heading","core/quote","core/list-item","core/read-more"],{getBlock:f}=(0,t.select)("core/block-editor"),{updateBlock:h}=(0,t.dispatch)("core/block-editor"),{getBlockName:k,getBlockAttributes:v}=(0,t.select)("core/block-editor"),w=e=>{const n=(()=>{const e=g("root","site");return e?.language||"en_US"})(),t=y?.find((n=>n.slug===e));return!(void 0===t||!t?.locales?.includes(n))},E=e=>{const{settingSlug:n,settingName:s,settingDescription:o}=e;if(!w(n))return"";const[a,l]=(0,d.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:p}=(0,t.useDispatch)(d.store),{createNotice:_}=(0,t.useDispatch)(u.store);return(0,c.createElement)(i.PanelRow,null,(0,c.createElement)(i.ToggleControl,{label:s,help:(0,c.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.find((e=>e.slug===n))?.value||!1,onChange:e=>{let t=a.map((t=>n===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===n))||t.push({slug:n,value:e}),l(t),p("root","site",void 0,t),_((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}}))},A=[{slug:"punctuation",label:(0,r.__)("Punctuation","consistency"),description:(0,r.__)("Fixes related to punctuation.","consistency")},{slug:"space",label:(0,r.__)("Spaces","consistency"),description:(0,r.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,r.__)("Case","consistency"),description:(0,r.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,r.__)("Ellipsis","consistency"),description:(0,r.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,r.__)("Symbols","consistency"),description:(0,r.__)("Fixes related to symbols.","consistency")}],C=()=>(0,c.createElement)(i.Panel,{className:"GlobalSettingPanel"},(0,c.createElement)(i.PanelHeader,null,(0,c.createElement)("strong",null,(0,r.__)("Global correction rules","consistency"))),[...A].map(((e,n)=>(0,c.createElement)(i.PanelBody,{key:n,title:(0,r.__)(e.label,"consistency"),initialOpen:!1},[...y].filter((n=>n.category===e.slug)).map(((e,n)=>(0,c.createElement)(E,{key:n,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:R}=(0,t.select)("core"),{getBlock:x,getBlocks:B,getBlockAttributes:S,getSelectionStart:F,isTyping:M}=(0,t.select)("core/block-editor"),{updateBlock:T,selectionChange:P,updateBlockAttributes:$}=(0,t.dispatch)("core/block-editor"),U=n=>{const{currentBlockId:t,isPasting:s,settings:o}=n;let c=y.filter((e=>!0===o?.find((n=>n.slug===e.slug))?.value));const r=x(t);if(!(e=>{const n=k(e);return!!b.includes(n)})(t)||!(e=>{const n=v(e);return!(!n||!n.hasOwnProperty("content")||""===n.content)})(t))return;let a=S(t),i=!1;Object.entries(c).forEach((([n,o])=>{if(!w(o.slug)||i)return;e.g.consistencyLoop++,(n=>{e.g.consistencyLoop>=100&&(n=>{const t=f(n);h(n,{...t,attributes:{...t.attributes,content:t.attributes.content.slice(-2)}}),e.g.consistency_loop=0,console.log("Consistency - a memory leak has occured during the fix of the following block:",t)})(n)})(t);let c,l=o.replace,d="",u="",p=0,_=a.content,g=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(_),y=!1;if(M()||(y=o.mask.test(g)),M()){c=F(r.name),p=c?.offset||0;const e=(e=>{const n=document.querySelector(`#block-${e}`);if(null===n)return;const t=document.getSelection(),s=t?.getRangeAt(0);if(!s.collapsed)return;const o=s.cloneRange(),c=document.createTextNode("\0");o.insertNode(c);let r=n?.innerHTML?.indexOf("\0");c.parentNode.removeChild(c),n.normalize();const a=(n?.innerHTML.match(/&nbsp;/g)||[]).length;return a>0&&(r=r-6*a+a),r})(t)||p,n=g.match(o.mask);if(null===n||0===n.length)return;const s=n[0].length||1;d=_.substring(0,e-s),u=_.substring(e-s,_.length),y=o.mask.test(g)&&o.mask.test(u)}y&&((e=>!!m.includes(e.slug))(o)&&(l=((e,n,t)=>{const s=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(`${s}`,"g"),i=new RegExp(`${o}`,"g");return(n.match(a)||[]).length===(n.match(i)||[]).length?s+c:r+o})(o,_)),0!==p&&(_=d+u.replace(o.mask,l)),0===p&&(_=_.replace(o.mask,o.replace)),e.g.previousFixCanceled?e.g.previousFixCanceled=!1:(e.g.previousFixCanceled||(T(t,{...r,attributes:{...r.attributes,content:_}}),i=!0),0===p||s||(o.nbMoved<0&&P(t,c.attributeKey,p+o.nbMoved,p+o.nbMoved),o.nbMoved>0&&P(t,c.attributeKey,p+1+o.nbMoved,p+o.nbMoved),0===o.nbMoved&&P(t,c.attributeKey,p,p))))})),e.g.consistencyLoop=0},{getSelectedBlockClientId:q,isTyping:N,getBlockAttributes:O}=(0,t.select)("core/block-editor");(0,n.registerPlugin)("consistency-custom-sidebar",{render:()=>{const e=R("create","users");return(0,c.createElement)(c.Fragment,null,(0,c.createElement)(a.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,r.__)("Consistency","consistency"),icon:l},(0,c.createElement)(_,null),e&&(0,c.createElement)(C,null)),(0,c.createElement)(a.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,r.__)("Consistency Settings","consistency")))}}),o()((()=>{e.g.consistencyLoop=0,e.g.previousFixCanceledContent="",e.g.previousFixCanceled=!1,e.g.contentPasted=!1,document.querySelector("#editor")?.addEventListener("paste",(n=>{e.g.contentPasted=!0})),document.querySelector("#editor")?.addEventListener("keydown",(n=>{90===n.keyCode&&(n.ctrlKey||n.metaKey)&&(e.g.previousFixCanceled=!0,n.preventDefault())})),(0,t.subscribe)((()=>{const{onTheFly:n,onPaste:s}=(()=>{const e={onTheFly:!1,onPaste:!1},n=(0,t.select)(d.store).getCurrentUser(),s=g("root","user",n?.id||0,"consistency_plugin_user_settings"),o=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=o?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=o?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!n&&!s)return;const o=(()=>{const e=g("root","site"),n=e?.consistency_plugin_settings;return n})();if(void 0===o)return;if(e.g.contentPasted&&s)return void(n=>{const{settings:t}=n;let s=y.filter((e=>!0===t?.find((n=>n.slug===e.slug))?.value));const o=B(),c=o.flatMap((({innerBlocks:e,...n})=>e.map((e=>({...n,...e}))))),r=o.reduce(((e,n)=>{let t=n.attributes?.content;return b.includes(n.name)&&void 0!==t?(Object.entries(s).forEach((([e,n])=>{if(w(n.slug)){if(m.includes(n.slug)){const e=n.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],s=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");t=t.replaceAll(s,n.replace)}if(!m.includes(n.slug)){const e=n.mask.toString(),s=new RegExp(e.substring(1,e.length-1),"g");t=t.replaceAll(s,n.replace)}}})),void 0!==t&&(e[n.clientId]={content:t}),e):e}),{});Object.keys(r).length>0&&e.g.contentPasted&&(e.g.contentPasted=!1,$(Object.keys(r),r,!0)),e.g.contentPasted=!1,c.forEach((e=>{if(!b.includes(e.name))return;const n=e.clientId;e?.clientId&&U({currentBlockId:n,theRegs:s,isPasting:!0})}))})({settings:o});const c=q();if(null===c||e.g.contentPasted||!n)return;const r=O(c);r.hasOwnProperty("content")&&e.g.previousFixCanceledContent===r.content||(e.g.previousFixCanceledContent=r.content,N()&&U({currentBlockId:c,isPasting:!1,settings:o}))}))}))})();
     1(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const t=window.wp.plugins,n=window.wp.data,s=window.wp.domReady;var c=e.n(s);const o=window.React,r=window.wp.i18n,a=window.wp.editPost,i=window.wp.components,l=()=>(0,o.createElement)(i.Icon,{icon:(0,o.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,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,o.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,o.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),u=window.wp.coreData,p=window.wp.notices,d=e=>{const{settingSlug:t,settingName:s,settingDescription:c}=e,{currentUser:a}=(0,n.useSelect)((e=>({currentUser:e(u.store).getCurrentUser()})),[]),l=a&&a.id,[d,g]=(0,u.useEntityProp)("root","user","meta",l),{saveEditedEntityRecord:y}=(0,n.useDispatch)(u.store),{createNotice:m}=(0,n.useDispatch)(p.store);return(0,o.createElement)(i.ToggleControl,{label:s,help:(0,o.createElement)("span",{dangerouslySetInnerHTML:c}),checked:d?.consistency_plugin_user_settings?.find((e=>e.slug===t))?.value||!1,onChange:e=>{let n=d?.consistency_plugin_user_settings.map((n=>t===n.slug?{...n,value:e}:n));n?.find((e=>e.slug===t))||n.push({slug:t,value:e}),g({...d,consistency_plugin_user_settings:n}),y("root","user",l,{...d,meta:n}),m((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}})},g=()=>(0,o.createElement)(i.Panel,{className:"UserSettingPanel"},(0,o.createElement)(i.PanelHeader,null,(0,o.createElement)("strong",null,(0,r.__)("Settings for my account","consistency"))),(0,o.createElement)("div",{style:{padding:16}},(0,o.createElement)(i.PanelRow,null,(0,o.createElement)(d,{settingSlug:"on_the_fly",settingName:(0,r.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable on-the-fly autocorrect for my account","consistency")}})),(0,o.createElement)(i.PanelRow,null,(0,o.createElement)(d,{settingSlug:"on_paste",settingName:(0,r.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,r.__)("Enable/disable autocorrect on paste for my account","consistency")}})))),{getEntityRecord:y}=(0,n.select)("core"),m=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],_=["core/paragraph","core/heading","core/quote","core/list-item","core/read-more"],{getBlock:b}=(0,n.select)("core/block-editor"),{updateBlock:h}=(0,n.dispatch)("core/block-editor"),{getBlockName:f,getBlockAttributes:k}=(0,n.select)("core/block-editor"),w=e=>{const t=(()=>{const e=y("root","site");return e?.language||"en_US"})();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},v=e=>{const{settingSlug:t,settingName:s,settingDescription:c}=e;if(!w(t))return"";const[a,l]=(0,u.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:d}=(0,n.useDispatch)(u.store),{createNotice:g}=(0,n.useDispatch)(p.store);return(0,o.createElement)(i.PanelRow,null,(0,o.createElement)(i.ToggleControl,{label:s,help:(0,o.createElement)("span",{dangerouslySetInnerHTML:c}),checked:a?.find((e=>e.slug===t))?.value||!1,onChange:e=>{let n=a.map((n=>t===n.slug?{...n,value:e}:n));n?.find((e=>e.slug===t))||n.push({slug:t,value:e}),l(n),d("root","site",void 0,n),g((0,r.__)("info","consistency"),e?sprintf((0,r.__)('"%1$s" Correction is enabled',"consistency"),s):sprintf((0,r.__)('"%1$s" Correction is disabled',"consistency"),s),{isDismissible:!0,type:"snackbar",speak:!0})}}))},x=[{slug:"quote",name:(0,r.__)("Straight quote","consistency"),description:(0,r.__)("Replaces straight quotes with curved quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"punctuation"},{slug:"2hyphens",name:(0,r.__)("Two hyphens","consistency"),description:(0,r.__)("Replaces 2 hyphens with em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code>—</code></span>",mask:/(?:\-)\-/,replace:"—",nbMoved:-1,category:"punctuation"},{slug:"ordinalNumberSuffix",name:(0,r.__)("Ordinal number suffix","consistency"),description:(0,r.__)("Add HTML tag sup to ordinal number suffix","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:"punctuation"},{slug:"regularToCurlyQuotes",name:(0,r.__)("Curly quotes","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"regularToGermanQuotes",name:(0,r.__)("Regular quotes to german","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"regularToGermanBookStyleQuotes",name:(0,r.__)("Regular quotes to german book-style quotes","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"regularToFrenchQuotes",name:(0,r.__)("Regular quotes to french","consistency"),description:(0,r.__)("Replaces regular quotes with french quotes:","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:"punctuation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,r.__)("Regular quotes to french quotes without spaces","consistency"),description:(0,r.__)("Replaces regular 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:"punctuation"},{slug:"curlyToFrenchQuotes",name:(0,r.__)("Curly quotes to french quotes","consistency"),description:(0,r.__)("Replaces curly quotes with french quotes:","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:"punctuation"},{slug:"breakingSpace",name:(0,r.__)("Breaking space","consistency"),description:sprintf((0,r.__)("Replaces 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,r.__)("No space before","consistency"),description:sprintf((0,r.__)("Adds 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,r.__)("Space before","consistency"),description:(0,r.__)("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,r.__)("No breaking space after","consistency"),description:sprintf((0,r.__)("Adds 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,r.__)("No non breaking space after","consistency"),description:(0,r.__)("Adds 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,r.__)("First sentence letter not capitalized","consistency"),description:(0,r.__)("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,r.__)('3 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 3 dots placed after the abbreviation "etc" with a point:',"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,r.__)('2 dots following "etc"',"consistency"),description:(0,r.__)('Replaces 2 dots placed after the abbreviation "etc" with a point:',"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,r.__)('Ellipsis following "etc"',"consistency"),description:(0,r.__)('Replaces ellipsis placed after the abbreviation "etc" with a point:',"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,r.__)("Ellipsis","consistency"),description:(0,r.__)("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,r.__)("Symbol in a circle","consistency"),description:(0,r.__)("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,r.__)("Symbol in small caps and superscript style","consistency"),description:(0,r.__)("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,r.__)("Fractions","consistency"),description:(0,r.__)("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,r.__)("Percentages","consistency"),description:(0,r.__)("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),n=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+n;case"0/00":return"‰"+n;case"0/000":return"‱"+n;default:return" "+n}},nbMoved:e=>{switch(e.substring(0,e.length-1)){case"0/0":return-2;case"0/00":return-3;case"0/000":return-4;default:return 0}},category:"symbol"}],E=[{slug:"punctuation",label:(0,r.__)("Punctuation","consistency"),description:(0,r.__)("Fixes related to punctuation.","consistency")},{slug:"space",label:(0,r.__)("Spaces","consistency"),description:(0,r.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,r.__)("Case","consistency"),description:(0,r.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,r.__)("Ellipsis","consistency"),description:(0,r.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,r.__)("Symbols","consistency"),description:(0,r.__)("Fixes related to symbols.","consistency")}],S=()=>(0,o.createElement)(i.Panel,{className:"GlobalSettingPanel"},(0,o.createElement)(i.PanelHeader,null,(0,o.createElement)("strong",null,(0,r.__)("Global correction rules","consistency"))),[...E].map(((e,t)=>(0,o.createElement)(i.PanelBody,{key:t,title:(0,r.__)(e.label,"consistency"),initialOpen:!1},[...x].filter((t=>t.category===e.slug)).map(((e,t)=>(0,o.createElement)(v,{key:t,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:C}=(0,n.select)("core"),{getBlock:R,getBlocks:P,getBlockAttributes:M,getSelectionStart:$,isTyping:q}=(0,n.select)("core/block-editor"),{updateBlock:T,selectionChange:B,updateBlockAttributes:F}=(0,n.dispatch)("core/block-editor"),z=t=>{const{currentBlockId:n,isPasting:s,settings:c}=t;let o=x.filter((e=>!0===c?.find((t=>t.slug===e.slug))?.value));const r=R(n);if(!(e=>{const t=f(e);return!!_.includes(t)})(n)||!(e=>{const t=k(e);return!(!t||!t.hasOwnProperty("content")||""===t.content)})(n))return;let a=M(n),i=!1;Object.entries(o).forEach((([t,c])=>{if(!w(c.slug)||i)return;e.g.consistencyLoop++,(t=>{e.g.consistencyLoop>=100&&(t=>{const n=b(t);h(t,{...n,attributes:{...n.attributes,content:n.attributes.content.slice(-2)}}),e.g.consistency_loop=0,console.log("Consistency - a memory leak has occured during the fix of the following block:",n)})(t)})(n);let o,l=c.replace,u="",p="",d=0,g=a.content,y=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(g),_=!1;if(q()||(_=c.mask.test(y)),q()){o=$(r.name),d=o?.offset||0;const e=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const n=document.getSelection(),s=n?.getRangeAt(0);if(!s.collapsed)return;const c=s.cloneRange(),o=document.createTextNode("\0");c.insertNode(o);let r=t?.innerHTML?.indexOf("\0");o.parentNode.removeChild(o),t.normalize();const a=(t?.innerHTML.match(/&nbsp;/g)||[]).length;return a>0&&(r=r-6*a+a),r})(n)||d,t=y.match(c.mask);if(null===t||0===t.length)return;const s=t[0].length||1;u=g.substring(0,e-s),p=g.substring(e-s,g.length),_=c.mask.test(y)&&c.mask.test(p)}if(!_)return;if((e=>!!m.includes(e.slug))(c)&&(l=((e,t,n)=>{const s=e.replace.charAt(0),c=e.replace.charAt(e.replace.length-1),o=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(`${s}`,"g"),i=new RegExp(`${c}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?s+o:r+c})(c,g)),0!==d&&(g=u+p.replace(c.mask,l)),0===d&&(g=g.replace(c.mask,c.replace)),e.g.previousFixCanceled)return void(e.g.previousFixCanceled=!1);if(e.g.previousFixCanceled||(T(n,{...r,attributes:{...r.attributes,content:g}}),i=!0),0===d||s)return;const f="function"==typeof c.nbMoved?c.nbMoved(p):c.nbMoved;f<0&&B(n,o.attributeKey,d+f,d+f),f>0&&B(n,o.attributeKey,d+1+f,d+f),0===f&&B(n,o.attributeKey,d,d)})),e.g.consistencyLoop=0},{getSelectedBlockClientId:L,isTyping:A,getBlockAttributes:N}=(0,n.select)("core/block-editor");(0,t.registerPlugin)("consistency-custom-sidebar",{render:()=>{const e=C("create","users");return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(a.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,r.__)("Consistency","consistency"),icon:l},(0,o.createElement)(g,null),e&&(0,o.createElement)(S,null)),(0,o.createElement)(a.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,r.__)("Consistency Settings","consistency")))}}),c()((()=>{e.g.consistencyLoop=0,e.g.previousFixCanceledContent="",e.g.previousFixCanceled=!1,e.g.contentPasted=!1,document.querySelector("#editor")?.addEventListener("paste",(t=>{e.g.contentPasted=!0})),document.querySelector("#editor")?.addEventListener("keydown",(t=>{90===t.keyCode&&(t.ctrlKey||t.metaKey)&&(e.g.previousFixCanceled=!0,t.preventDefault())})),(0,n.subscribe)((()=>{const{onTheFly:t,onPaste:s}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,n.select)(u.store).getCurrentUser(),s=y("root","user",t?.id||0,"consistency_plugin_user_settings"),c=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=c?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=c?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!t&&!s)return;const c=(()=>{const e=y("root","site"),t=e?.consistency_plugin_settings;return t})();if(void 0===c)return;if(e.g.contentPasted&&s)return void(t=>{const{settings:n}=t;let s=x.filter((e=>!0===n?.find((t=>t.slug===e.slug))?.value));const c=P(),o=c.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),r=c.reduce(((e,t)=>{let n=t.attributes?.content;return _.includes(t.name)&&void 0!==n?(Object.entries(s).forEach((([e,t])=>{if(w(t.slug)){if(m.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],s=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");n=n.replaceAll(s,t.replace)}if(!m.includes(t.slug)){const e=t.mask.toString(),s=new RegExp(e.substring(1,e.length-1),"g");n=n.replaceAll(s,t.replace)}}})),void 0!==n&&(e[t.clientId]={content:n}),e):e}),{});Object.keys(r).length>0&&e.g.contentPasted&&(e.g.contentPasted=!1,F(Object.keys(r),r,!0)),e.g.contentPasted=!1,o.forEach((e=>{if(!_.includes(e.name))return;const t=e.clientId;e?.clientId&&z({currentBlockId:t,theRegs:s,isPasting:!0})}))})({settings:c});const o=L();if(null===o||e.g.contentPasted||!t)return;const r=N(o);r.hasOwnProperty("content")&&e.g.previousFixCanceledContent===r.content||(e.g.previousFixCanceledContent=r.content,A()&&z({currentBlockId:o,isPasting:!1,settings:c}))}))}))})();
  • consistency/trunk/consistency.php

    r3092051 r3092549  
    44 * Plugin URI:        https://www.webaxones.com
    55 * Description:       Fixes typographical consistency
    6  * Version:           1.5.8
     6 * Version:           1.5.9
    77 * Requires at least: 6.1
    88 * Requires PHP:      7.4
  • consistency/trunk/includes/Asset/Asset.php

    r2857933 r3092549  
    88use const Webaxones\Consistency\PLUGIN_PATH;
    99use const Webaxones\Consistency\PLUGIN_URL;
     10use Webaxones\Consistency\Config\LocalizedRules;
    1011
    1112/**
     
    4142            true
    4243        );
     44
     45        // Convert dash style locales code to undescore style for JS
     46        $locales = LocalizedRules::$list;
     47        $locales = array_map(
     48            function ( $value ) {
     49                return array_map(
     50                    function ( $value ) {
     51                        return str_replace( '-', '_', $value );
     52                    },
     53                    $value
     54                );
     55            },
     56            $locales
     57        );
     58
     59        // Pass localized rules to the script
     60        $localizedRules = 'const localesByRules = ' . json_encode( $locales );
     61        wp_add_inline_script(
     62            Plugin::PREFIX . '-editor-script',
     63            $localizedRules,
     64            'before'
     65        );
     66   
    4367        wp_set_script_translations( Plugin::PREFIX . '-editor-script', 'consistency' );
    4468    }
  • consistency/trunk/includes/Config/Rules.php

    r3092051 r3092549  
    66
    77use Webaxones\Consistency\Utils\Contracts\ValueInterface;
     8use Webaxones\Consistency\Config\LocalizedRules;
    89
    910/**
     
    1920    protected array $languages = [
    2021        'af', 'am', 'ar', 'arg', 'ary', 'as', 'az', 'azb', 'bel', 'bg-BG', 'bn-BD', 'bo', 'bs-BA', 'ca', 'ceb', 'ckb', 'cs-CZ', 'cy', 'da-DK', 'de-AT', 'de-CH', 'de-CH-informal', 'de-DE', 'de-DE-formal', 'dsb', 'dzo', 'el', 'en-AU', 'en-CA', 'en-GB', 'en-NZ', 'en-US', 'en-ZA', 'eo', 'es-AR', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-ES', 'es-GT', 'es-MX', 'es-PE', 'es-PR', 'es-UY', 'es-VE', 'et', 'eu', 'fa-AF', 'fa-IR', 'fi', 'fr-BE', 'fr-CA', 'fr-FR', 'fur', 'fy', 'gd', 'gl-ES', 'gu', 'haz', 'he-IL', 'hi-IN', 'hr', 'hsb', 'hu-HU', 'hy', 'id-ID', 'is-IS', 'it-IT', 'ja', 'jv-ID', 'kab', 'ka-GE', 'kk', 'km', 'kn', 'ko-KR', 'lo', 'lt-LT', 'lv', 'mk-MK', 'ml-IN', 'mn', 'mr', 'ms-MY', 'my-MM', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nl-NL-formal', 'nn-NO', 'oci', 'pa-IN', 'pl-PL', 'ps', 'pt-AO', 'pt-BR', 'pt-PT', 'pt-PT-ao90', 'rhg', 'ro-RO', 'ru-RU', 'sah', 'si-LK', 'skr', 'sk-SK', 'sl-SI', 'snd', 'sq', 'sr-RS', 'sv-SE', 'sw', 'szl', 'tah', 'ta-IN', 'ta-LK', 'te', 'th', 'tl', 'tr-TR', 'tt-RU', 'ug-CN', 'uk', 'ur', 'uz-UZ', 'vi', 'zh-CN', 'zh-HK', 'zh-TW',
    21     ];
    22 
    23     /**
    24      * All the rules with the languages where they are active
    25      *
    26      * @var array
    27      */
    28     protected array $localizedRules = [
    29         'quote'                              => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    30         '2hyphens'                           => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    31         'ordinalNumberSuffix'                => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    32         'regularToCurlyQuotes'               => [ 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    33         'regularToGermanQuotes'              => [ 'de-DE', 'de-AT', 'ro-RO' ],
    34         'regularToGermanBookStyleQuotes'     => [ 'de-DE', 'de-AT' ],
    35         'regularToFrenchQuotes'              => [ 'fr-FR', 'fr-BE' ],
    36         'regularToFrenchQuotesWithoutSpaces' => [ 'de-CH' ],
    37         'curlyToFrenchQuotes'                => [ 'fr-FR', 'fr-BE' ],
    38         'breakingSpace'                      => [ 'fr-FR', 'fr-BE' ],
    39         'noSpaceBefore'                      => [ 'fr-FR', 'fr-BE' ],
    40         'spaceBefore'                        => [ 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    41         'noBreakingSpaceAfter'               => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    42         'noNonBreakingSpaceAfter'            => [ 'fr-FR', 'fr-BE' ],
    43         'capitalizeFirstSentenceLetter'      => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    44         'etcThreeDots'                       => [ 'fr-FR', 'fr-BE' ],
    45         'etcTwoDots'                         => [ 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB' ],
    46         'etcEllipsis'                        => [ 'fr-FR', 'fr-BE' ],
    47         'ellipsis'                           => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    48         'symbolBasedOn1Character'            => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    49         'symbolBasedOn2Characters'           => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    50         'fractions'                          => [ 'fr-FR', 'fr-BE', 'en-US', 'en-AU', 'en-CA', 'en-NZ', 'en-ZA', 'en-GB', 'de-DE', 'de-AT', 'de-CH', 'ro-RO' ],
    5122    ];
    5223
     
    9465    protected function setRules(): array
    9566    {
    96         foreach ( $this->localizedRules as $key => $value ) {
     67        foreach ( LocalizedRules::$list as $key => $value ) {
    9768            $this->rules[] = [
    9869                'slug'  => $key,
  • consistency/trunk/includes/Plugin.php

    r3092051 r3092549  
    3131    protected static function setConstants(): void
    3232    {
    33         defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5.8' );
     33        defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5.9' );
    3434        defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) );
    3535        defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) );
     
    4747    {
    4848        self::setConstants();
    49 
    5049        $hooks = new Hook();
    51 
     50   
    5251        // Add main script
    5352        $assets = new Asset();
  • consistency/trunk/package-lock.json

    r3084549 r3092549  
    11{
    22    "name": "consistency",
    3     "version": "1.5.1",
     3    "version": "1.5.8",
    44    "lockfileVersion": 3,
    55    "requires": true,
     
    77        "": {
    88            "name": "consistency",
    9             "version": "1.5.1",
     9            "version": "1.5.8",
    1010            "license": "ISC",
    1111            "devDependencies": {
  • consistency/trunk/package.json

    r3092051 r3092549  
    11{
    22    "name": "consistency",
    3     "version": "1.5.8",
     3    "version": "1.5.9",
    44    "description": "",
    55    "main": "index.js",
  • consistency/trunk/readme.md

    r3091663 r3092549  
    3131Remember to unfold the panel to see the rules. 
    3232
    33 ![image](https://user-images.githubusercontent.com/17084006/216155475-0a85f34d-89dc-4365-9aed-23ca401dde14.png)
    34 
    3533
    3634
    3735## Description
    3836
    39 The purpose of this plugin is to provide a tool allowing administrators to define typographical rules in order to maintain typographical consistency in the text contents entered on the editor.
    40 The corrections are automatic and are made during the entry as well as on a copy paste.
     37The purpose of this plugin is to provide a tool allowing administrators to define typographical rules in order to maintain typographical consistency in the text contents entered on the editor. 
     38> [!IMPORTANT]The corrections are automatic and are made during the entry as well as on a copy paste. 
     39
    4140Autocorrect rules can be enabled/disabled by any user.
    4241Autocorrect is available on pages, posts and custom post types (if their configuration allows Rest API usage)
     
    4443Currently, the AutoCorrects offered are as follows:
    4544
    46 ### English language corrections
     45| Name | Description | Example | Locales |
     46| --- | --- | :---: | --- |
     47| *Straight quote* | Replaces straight quotes with curved quotes | `'` → `'` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     48| *Two hyphens* | Replaces 2 hyphens with em dash | `--` → `—` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     49| *Ordinal number suffix* | Add HTML tag sup to ordinal number suffix | `1st` → 1<sup>st</sup> | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     50| *Curly quotes* | Replaces regular quotes with curly quotes | `" "` → `“ ”` | `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     51| *Regular quotes to german* | Replaces regular quotes with german quotes | `" "` → `„ “` | `de_DE` `de_AT` `ro_RO` |
     52| *Regular quotes to german book-style quotes* | Replaces regular quotes with german book-style quotes | `" "` → `» «` | `de_DE` `de_AT` |
     53| *Regular quotes to french* | Replaces regular quotes with french quotes | `" "` → `«   »` | `fr_FR` `fr_BE` |
     54| *Regular quotes to french quotes without spaces* | Replaces regular quotes with french quotes without spaces | `" "` → `« »` | `de_CH` |
     55| *Curly quotes to french quotes* | Replaces curly quotes with french quotes | `“ ”` → `«   »` | `fr_FR` `fr_BE` |
     56| *Breaking space* | Replaces a breaking space followed by a character from this list with a non-breaking space: | `? ! : ; » € $ £ ¥ ₽ 元 %` | `fr_FR` `fr_BE` |
     57| *No space before* | Adds a non-breaking space before a character from this list having no space before: | `? ! : ; » € $ £ ¥ ₽ 元 %` | `fr_FR` `fr_BE` |
     58| *Space before* | Remove any space preceding a character from this list: | `? ! : ; %` | `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     59| *No breaking space after* | Adds a breaking space after a character from this list when followed with another character: | `, … ) ]` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     60| *No non breaking space after* | Adds a non-breaking space after open french quote having no space after | `«` → `« ` | `fr_FR` `fr_BE` |
     61| *First sentence letter not capitalized* | Capitalize the first letter of a sentence | `a é ș` → `A É Ș` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     62| *3 dots following "etc"* | Replaces 3 dots placed after the abbreviation "etc" with a point | `etc...` → `etc.` | `fr_FR` `fr_BE` |
     63| *2 dots following "etc"* | Replaces 2 dots placed after the abbreviation "etc" with a point | `etc..` → `etc.` | `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` |
     64| *Ellipsis following "etc"* | Replaces ellipsis placed after the abbreviation "etc" with a point | `etc…` → `etc.` | `fr_FR` `fr_BE` |
     65| *Ellipsis* | Replaces 3 dots with ellipsis | `...` → `…` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     66| *Symbol in a circle* | Replaces 1 character placed in parentheses with a symbol | `(c) (p) (r)` → `© ℗ ®` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     67| *Symbol in small caps and superscript style* | Replaces 2-character abbreviations with a symbol in small caps and superscript style | `tm sm md mc` → `™ ℠ 🅫 🅪` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     68| *Fractions* | Replaces fractions with fraction symbols | `1/2 3/5 1/9` → `½ ⅗ ⅑` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
     69| *Percentages* | Replaces percentages with percentages symbols | `0/0 0/00 0/000` → `% ‰ ‱` | `fr_FR` `fr_BE` `en_US` `en_AU` `en_CA` `en_NZ` `en_ZA` `en_GB` `de_DE` `de_AT` `de_CH` `ro_RO` |
    4770
    48 - **Straight quote**: Replaces straight quotes with curved quotes
    49 - **Ellipsis**: Replaces 3 dots with ellipsis
    50 - **Two hyphens**: Replaces 2 hyphens with em dash
    51 - **Ordinal number suffix**: Add HTML tag sup to ordinal number suffix
    52 - **Regular quotes to curly**: Replaces regular quotes with curly quotes
    53 - **No breaking space after**: Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    54 - **Space before**: Remove any space preceding a character from this list (? ! : ; %)
    55 - **First sentence letter not capitalized**: Capitalize the first letter of a sentence
    56 - etc.
    57 
    58 ### French language corrections
    59 
    60 - **Straight quote**: Replaces straight quotes with curved quotes
    61 - **Ellipsis**: Replaces 3 dots with ellipsis
    62 - **Two hyphens**: Replaces 2 hyphens with em dash
    63 - **Ordinal number suffix**: Add HTML tag sup to ordinal number suffix
    64 - **Regular quotes to French**: Replaces regular quotes with French quotes
    65 - **Breaking space**: Replaces a breaking space followed by a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) with a non-breaking space
    66 - **No space before**: Adds a non-breaking space before a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) having no space before
    67 - **No breaking space after**: Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    68 - **No non-breaking space after**: Adds a non-breaking space after open french quote having no space after
    69 - **First sentence letter not capitalized**: Capitalize the first letter of a sentence
    70 - etc.
    71 
    72 **Ctrl+Z** or **Cmd+Z** right after a correction disables the correction for the next keystroke. It is thus possible to force the non-correction of a character.
     71    
     72> [!TIP]
     73> **Ctrl+Z** or **Cmd+Z** right after a correction disables the correction for the next keystroke. It is thus possible to force the non-correction of a character.
    7374
    7475Technically, rules are saved in the `wp_options` table, while active/inactive states are saved as user meta data in `wp_usermeta` table.
     
    7778Settings are directly in a plugin sidebar under the Block Editor: no more searching for an options page, always available and discreet.
    7879
    79 The locales supported by this plugin are:
    80 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO'
    81 
    8280## Smoke tests
    8381
  • consistency/trunk/readme.txt

    r3092051 r3092549  
    44Requires at least: 6.1
    55Tested up to: 6.5.2
    6 Stable tag: 1.5.8
     6Stable tag: 1.5.9
    77Requires PHP: 7.4
    88License: GPL-3.0-or-later
     
    1515Do you see the typographic corrector in your word processor that formats what you type in real time? Well, it's the same idea but with Gutenberg.
    1616
    17 The purpose of this plugin is to provide a tool allowing administrators to define typographical rules in order to maintain typographical consistency in the text contents entered on the editor.
    18 The corrections are automatic and are made during the entry as well as on a copy paste.
    19 Autocorrect rules can be enabled/disabled by any user.
    20 Autocorrect is available on pages, posts and custom post types (if their configuration allows Rest API usage)
     17This WordPress plugin is designed to help administrators enforce consistent typography in text content entered in the editor.
     18Corrections are applied automatically both during text entry and when pasting text.
     19Users can enable or disable autocorrect rules as needed.
     20Autocorrect is available for pages, posts, and custom post types (if they are configured to use the Rest API).
    2121
    22 Currently, the AutoCorrects offered are as follows:
     22Automatic fixes are listed on [the plugin repository on github](https://github.com/webaxones/consistency/).
    2323
    24 For the English language
    2524
    26 - "Straight quote": Replaces straight quotes with curved quotes
    27 - "Ellipsis": Replaces 3 dots with ellipsis
    28 - "Two hyphens": Replaces 2 hyphens with em dash
    29 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix
    30 - "Regular quotes to curly": Replaces regular quotes with curly quotes
    31 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    32 - "Space before": Remove any space preceding a character from this list (? ! : ; %)
    33 - "First sentence letter not capitalized": Capitalize the first letter of a sentence
    34 - etc.
    35 
    36 For the French language
    37 
    38 - "Straight quote": Replaces straight quotes with curved quotes
    39 - "Ellipsis": Replaces 3 dots with ellipsis
    40 - "Two hyphens": Replaces 2 hyphens with em dash
    41 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix
    42 - "Regular quotes to French": Replaces regular quotes with French quotes
    43 - "Breaking space": Replaces a breaking space followed by a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) with a non-breaking space
    44 - "No space before": Adds a non-breaking space before a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) having no space before
    45 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character
    46 - "No non-breaking space after": Adds a non-breaking space after open french quote having no space after
    47 - "First sentence letter not capitalized": Capitalize the first letter of a sentence
    48 - etc.
    4925
    5026Ctrl+Z or Cmd+Z right after a correction disables the correction for the next keystroke
     
    6945
    7046== Changelog ==
     47
     48= 1.5.9 =
     49* Add rule for percentages symbols
     50* Refactor some code
     51* Actualise Readme
    7152
    7253= 1.5.8 =
  • consistency/trunk/src/app/checks.js

    r3086094 r3092549  
    1515 */
    1616import { getCurrentLocale } from './data'
    17 import { rules } from '../config/rules'
    1817import { regsWithPair } from '../config/regsWithPair'
    1918import { processedBlocks } from '../config/processedBlocks'
     
    3231
    3332    const currentLocale = getCurrentLocale()
    34     const theRegex = rules?.find( x => x.slug === settingSlug )
    35 
    36     if ( undefined !== theRegex && theRegex?.locales?.includes( currentLocale ) ) {
    37         return true
     33    if ( localesByRules !== undefined && localesByRules.hasOwnProperty( settingSlug ) ) {
     34        return localesByRules[settingSlug].includes( currentLocale )
    3835    }
    39 
    4036    return false
    4137
  • consistency/trunk/src/app/fixes.js

    r3091983 r3092549  
    9797            firstPart = blockContent.substring( 0, cursorPositionInsideHTML - lengthToGoBack )
    9898            lastPart = blockContent.substring( cursorPositionInsideHTML - lengthToGoBack, blockContent.length )
    99 
     99   
    100100            // If first part of the string matches but not the lastPart, it means that a character has been typed uncorrected voluntarily before, so it should not be taken into account
    101101            isConcerned = reg.mask.test( textContent ) && reg.mask.test( lastPart )
     
    104104        // Stop correction if block content isn't concerned by the regex
    105105        if ( ! isConcerned ) return
     106       
    106107        // Pairing characters need specific process for the replacement
    107108        if ( regDealWithPair( reg ) ) {
     
    137138        if ( 0 === cursorPosition || isPasting ) return
    138139
     140        // Get the number of characters moved by the replacement: needed for cursor repositioning
     141        // If the number depends on the replaced string length, we use a function to get it
     142        const nbMoved = typeof reg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved
     143
    139144        // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back
    140145        // Eg: ... replaced with … removes 2 characters
    141         if ( reg.nbMoved < 0 ) {
    142             // selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition - 1, cursorPosition + reg.nbMoved )
    143             selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + reg.nbMoved, cursorPosition + reg.nbMoved )
     146        if ( nbMoved < 0 ) {
     147            selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + nbMoved, cursorPosition + nbMoved )
    144148        }
    145149       
    146150        // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward
    147151        // Eg: "" replaced with «  » adds 2 characters
    148         if ( reg.nbMoved > 0 ) {
    149             selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + 1 + reg.nbMoved, cursorPosition + reg.nbMoved )
    150         }
    151 
    152         if ( 0 === reg.nbMoved ) {
     152        if ( nbMoved > 0 ) {
     153            selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition + 1 + nbMoved, cursorPosition + nbMoved )
     154        }
     155
     156        if ( 0 === nbMoved ) {
    153157            selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition, cursorPosition )
    154158        }
  • consistency/trunk/src/config/rules.js

    r3092051 r3092549  
    2121        replace: '’', // replacement string
    2222        nbMoved: 0, // number of characters less or more during replacement
    23         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ], // concerned locales
    2423        category: 'punctuation' // category of the setting
    2524    },
     
    3332        replace: '—',
    3433        nbMoved: -1,
    35         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    3634        category: 'punctuation'
    3735    },
     
    4543        replace: '$1<sup>$2<\/sup>$3',
    4644        nbMoved: 0,
    47         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    4845        category: 'punctuation'
    4946    },
     
    5754        replace: '“$1”',
    5855        nbMoved: 0,
    59         locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    6056        category: 'punctuation'
    6157    },
     
    6965        replace: '„$1“',
    7066        nbMoved: 0,
    71         locales: [ 'de_DE', 'de_AT', 'ro_RO' ],
    7267        category: 'punctuation'
    7368    },
     
    8176        replace: '»$1«',
    8277        nbMoved: 0,
    83         locales: [ 'de_DE', 'de_AT' ],
    8478        category: 'punctuation'
    8579    },
     
    8983        name: __( 'Regular quotes to french', 'consistency' ),
    9084        description: __( 'Replaces regular quotes with french quotes:', 'consistency' )
    91             + `<span aria-hidden='true' style='display:block;'><code>" "</code> <span style='font-size:20px'>→</span> <code>« »</code></span>`,
     85            + `<span aria-hidden='true' style='display:block;'><code>" "</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>`,
    9286        mask: /"/, // specific mask with specific process
    9387        replace: '« $1 »',
    9488        nbMoved: 1,
    95         locales: [ 'fr_FR', 'fr_BE' ],
    9689        category: 'punctuation'
    9790    },
     
    10598        replace: '«$1»',
    10699        nbMoved: 0,
    107         locales: [ 'de_CH' ],
    108100        category: 'punctuation'
    109101    },
     
    113105        name: __( 'Curly quotes to french quotes', 'consistency' ),
    114106        description: __( 'Replaces curly quotes with french quotes:', 'consistency' )
    115             + `<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>`,
     107            + `<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>«   »</code></span>`,
    116108        mask: /“.*?”/, // specific mask with specific process
    117109        replace: matched => { return `« ${matched.substring( 1, matched.length - 1 )} »` },
    118110        nbMoved: 0,
    119         locales: [ 'fr_FR', 'fr_BE' ],
    120111        category: 'punctuation'
    121112    },
     
    129120        replace: ' $1',
    130121        nbMoved: 0,
    131         locales: [ 'fr_FR', 'fr_BE' ],
    132122        category: 'space'
    133123    },
     
    141131        replace: ' $1',
    142132        nbMoved: 1,
    143         locales: [ 'fr_FR', 'fr_BE' ],
    144133        category: 'space'
    145134    },
     
    153142        replace: '$2',
    154143        nbMoved: -1,
    155         locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    156144        category: 'space'
    157145    },
     
    165153        replace: '$1 $2',
    166154        nbMoved: 1,
    167         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    168155        category: 'space'
    169156    },
     
    176163        replace: '$1 ',
    177164        nbMoved: 0,
    178         locales: [ 'fr_FR', 'fr_BE' ],
    179165        category: 'space'
    180166    },
     
    187173        replace: matched => matched.toUpperCase(),
    188174        nbMoved: 0,
    189         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    190175        category: 'case'
    191176    },
     
    199184        replace: matched => { return matched.substring(0, 3) + '.' },
    200185        nbMoved: -2,
    201         locales: [ 'fr_FR', 'fr_BE' ],
    202186        category: 'ellipsis'
    203187    },
     
    211195        replace: matched => { return matched.substring(0, 2) + '.' },
    212196        nbMoved: -1,
    213         locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],
    214197        category: 'ellipsis'
    215198    },
     
    217200        // Replaces etc… with etc.
    218201        slug: 'etcEllipsis',
    219         name: __( 'ellipsis following "etc"', 'consistency' ),
     202        name: __( 'Ellipsis following "etc"', 'consistency' ),
    220203        description: __( 'Replaces ellipsis placed after the abbreviation "etc" with a point:', 'consistency' )
    221204        + `<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>`,
     
    223206        replace: matched => { return matched.substring(0, 3) + '.' },
    224207        nbMoved: 0,
    225         locales: [ 'fr_FR', 'fr_BE' ],
    226208        category: 'ellipsis'
    227209    },
     
    235217        replace: '…',
    236218        nbMoved: -2,
    237         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    238219        category: 'ellipsis'
    239220    },
    240221    {
    241222        // Replaces a character from this list [c p r] when enclosed in parentheses with a symbol
    242         slug: 'symbolBasedOn1Character',
    243         name: __( 'Symbol based on 1 character', 'consistency' ),
     223        slug: 'symbolInACircle',
     224        name: __( 'Symbol in a circle', 'consistency' ),
    244225        description: __( 'Replaces 1 character placed in parentheses with a symbol', 'consistency' )
    245226            + `<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>`,
     
    257238        },
    258239        nbMoved: -2,
    259         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
    260240        category: 'symbol'
    261241    },
    262242    {
    263         // Replaces a character from this list [md tm mc sm] when enclosed in parentheses with a symbol
    264         slug: 'symbolBasedOn2Characters',
    265         name: __( 'Symbol based on 2 characters', 'consistency' ),
    266         description: __( 'Replaces 2-character abbreviations in parentheses with a symbol', 'consistency' )
    267         + `<span aria-hidden='true' style='display:block;'><code>(tm) (sm) (md) (mc)</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>`,
    268         mask: /(\(tm|\(sm|\(md|\(mc)(\))/,
     243        // Replaces a character from this list [md tm mc sm] with a symbol in small caps and superscript style
     244        slug: 'symbolInSmallCapsAndSuperscriptStyle',
     245        name: __( 'Symbol in small caps and superscript style', 'consistency' ),
     246        description: __( 'Replaces 2-character abbreviations with a symbol in small caps and superscript style', 'consistency' )
     247        + `<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>`,
     248        mask: /(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,
    269249        replace: matched => {
    270250            switch ( matched ) {
    271                 case '(tm)':
     251                case 'tm':
    272252                    return '™'
    273                 case '(sm)':
     253                case 'sm':
    274254                    return '℠'
    275                 case '(md)':
     255                case 'md':
    276256                    return '🅫'
    277                 case '(mc)':
     257                case 'mc':
    278258                    return '🅪'
    279259                default:
     
    281261            }
    282262        },
    283         nbMoved: -3,
    284         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
     263        nbMoved: -1,
    285264        category: 'symbol'
    286265    },
     
    290269        name: __( 'Fractions', 'consistency' ),
    291270        description: __( 'Replaces fractions with fraction symbols:', 'consistency' )
    292             + `<span aria-hidden='true' style='display:block;'><code>3/5</code> <span style='font-size:20px'>→</span> <code>⅗</code></span>`,
     271            + `<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>`,
    293272        mask: /[1-9]\/[1-9]/,
    294273        replace: matched => {
     
    333312        },
    334313        nbMoved: -2,
    335         locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],
     314        category: 'symbol'
     315    },
     316    {
     317        // Replaces fractions with a fraction symbol
     318        slug: 'percentages',
     319        name: __( 'Percentages', 'consistency' ),
     320        description: __( 'Replaces percentages with percentages symbols:', 'consistency' )
     321            + `<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>`,
     322        mask: /(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,
     323        replace: matched => {
     324            const matchedFirstPart = matched.substring( 0, matched.length - 1 )
     325            const matchedLastPart = matched.substring( matched.length - 1, matched.length )
     326            switch ( matchedFirstPart ) {
     327                case '0/0':
     328                    return '%' + matchedLastPart
     329                case '0/00':
     330                    return '‰' + matchedLastPart
     331                case '0/000':
     332                    return '‱' + matchedLastPart
     333                default:
     334                    return ' ' + matchedLastPart
     335            }
     336        },
     337        nbMoved: lastPart => {
     338            const replacedString = lastPart.substring( 0, lastPart.length - 1 )
     339            switch ( replacedString ) {
     340                case '0/0':
     341                    return -2
     342                case '0/00':
     343                    return -3
     344                case '0/000':
     345                    return -4
     346                default:
     347                    return 0
     348            }
     349         },
    336350        category: 'symbol'
    337351    },
  • consistency/trunk/vendor/autoload.php

    r3084555 r3092549  
    33// autoload.php @generated by Composer
    44
     5if (PHP_VERSION_ID < 50600) {
     6    if (!headers_sent()) {
     7        header('HTTP/1.1 500 Internal Server Error');
     8    }
     9    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
     10    if (!ini_get('display_errors')) {
     11        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
     12            fwrite(STDERR, $err);
     13        } elseif (!headers_sent()) {
     14            echo $err;
     15        }
     16    }
     17    trigger_error(
     18        $err,
     19        E_USER_ERROR
     20    );
     21}
     22
    523require_once __DIR__ . '/composer/autoload_real.php';
    624
  • consistency/trunk/vendor/composer/ClassLoader.php

    r3084555 r3092549  
    4343class ClassLoader
    4444{
    45     /** @var ?string */
     45    /** @var \Closure(string):void */
     46    private static $includeFile;
     47
     48    /** @var string|null */
    4649    private $vendorDir;
    4750
    4851    // PSR-4
    4952    /**
    50      * @var array[]
    51      * @psalm-var array<string, array<string, int>>
     53     * @var array<string, array<string, int>>
    5254     */
    5355    private $prefixLengthsPsr4 = array();
    5456    /**
    55      * @var array[]
    56      * @psalm-var array<string, array<int, string>>
     57     * @var array<string, list<string>>
    5758     */
    5859    private $prefixDirsPsr4 = array();
    5960    /**
    60      * @var array[]
    61      * @psalm-var array<string, string>
     61     * @var list<string>
    6262     */
    6363    private $fallbackDirsPsr4 = array();
     
    6565    // PSR-0
    6666    /**
    67      * @var array[]
    68      * @psalm-var array<string, array<string, string[]>>
     67     * List of PSR-0 prefixes
     68     *
     69     * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
     70     *
     71     * @var array<string, array<string, list<string>>>
    6972     */
    7073    private $prefixesPsr0 = array();
    7174    /**
    72      * @var array[]
    73      * @psalm-var array<string, string>
     75     * @var list<string>
    7476     */
    7577    private $fallbackDirsPsr0 = array();
     
    7981
    8082    /**
    81      * @var string[]
    82      * @psalm-var array<string, string>
     83     * @var array<string, string>
    8384     */
    8485    private $classMap = array();
     
    8889
    8990    /**
    90      * @var bool[]
    91      * @psalm-var array<string, bool>
     91     * @var array<string, bool>
    9292     */
    9393    private $missingClasses = array();
    9494
    95     /** @var ?string */
     95    /** @var string|null */
    9696    private $apcuPrefix;
    9797
    9898    /**
    99      * @var self[]
     99     * @var array<string, self>
    100100     */
    101101    private static $registeredLoaders = array();
    102102
    103103    /**
    104      * @param ?string $vendorDir
     104     * @param string|null $vendorDir
    105105     */
    106106    public function __construct($vendorDir = null)
    107107    {
    108108        $this->vendorDir = $vendorDir;
    109     }
    110 
    111     /**
    112      * @return string[]
     109        self::initializeIncludeClosure();
     110    }
     111
     112    /**
     113     * @return array<string, list<string>>
    113114     */
    114115    public function getPrefixes()
     
    122123
    123124    /**
    124      * @return array[]
    125      * @psalm-return array<string, array<int, string>>
     125     * @return array<string, list<string>>
    126126     */
    127127    public function getPrefixesPsr4()
     
    131131
    132132    /**
    133      * @return array[]
    134      * @psalm-return array<string, string>
     133     * @return list<string>
    135134     */
    136135    public function getFallbackDirs()
     
    140139
    141140    /**
    142      * @return array[]
    143      * @psalm-return array<string, string>
     141     * @return list<string>
    144142     */
    145143    public function getFallbackDirsPsr4()
     
    149147
    150148    /**
    151      * @return string[] Array of classname => path
    152      * @psalm-return array<string, string>
     149     * @return array<string, string> Array of classname => path
    153150     */
    154151    public function getClassMap()
     
    158155
    159156    /**
    160      * @param string[] $classMap Class to filename map
    161      * @psalm-param array<string, string> $classMap
     157     * @param array<string, string> $classMap Class to filename map
    162158     *
    163159     * @return void
     
    176172     * appending or prepending to the ones previously set for this prefix.
    177173     *
    178      * @param string          $prefix  The prefix
    179      * @param string[]|string $paths   The PSR-0 root directories
    180      * @param bool            $prepend Whether to prepend the directories
     174     * @param string              $prefix  The prefix
     175     * @param list<string>|string $paths   The PSR-0 root directories
     176     * @param bool                $prepend Whether to prepend the directories
    181177     *
    182178     * @return void
     
    184180    public function add($prefix, $paths, $prepend = false)
    185181    {
     182        $paths = (array) $paths;
    186183        if (!$prefix) {
    187184            if ($prepend) {
    188185                $this->fallbackDirsPsr0 = array_merge(
    189                     (array) $paths,
     186                    $paths,
    190187                    $this->fallbackDirsPsr0
    191188                );
     
    193190                $this->fallbackDirsPsr0 = array_merge(
    194191                    $this->fallbackDirsPsr0,
    195                     (array) $paths
     192                    $paths
    196193                );
    197194            }
     
    202199        $first = $prefix[0];
    203200        if (!isset($this->prefixesPsr0[$first][$prefix])) {
    204             $this->prefixesPsr0[$first][$prefix] = (array) $paths;
     201            $this->prefixesPsr0[$first][$prefix] = $paths;
    205202
    206203            return;
     
    208205        if ($prepend) {
    209206            $this->prefixesPsr0[$first][$prefix] = array_merge(
    210                 (array) $paths,
     207                $paths,
    211208                $this->prefixesPsr0[$first][$prefix]
    212209            );
     
    214211            $this->prefixesPsr0[$first][$prefix] = array_merge(
    215212                $this->prefixesPsr0[$first][$prefix],
    216                 (array) $paths
     213                $paths
    217214            );
    218215        }
     
    223220     * appending or prepending to the ones previously set for this namespace.
    224221     *
    225      * @param string          $prefix  The prefix/namespace, with trailing '\\'
    226      * @param string[]|string $paths   The PSR-4 base directories
    227      * @param bool            $prepend Whether to prepend the directories
     222     * @param string              $prefix  The prefix/namespace, with trailing '\\'
     223     * @param list<string>|string $paths   The PSR-4 base directories
     224     * @param bool                $prepend Whether to prepend the directories
    228225     *
    229226     * @throws \InvalidArgumentException
     
    233230    public function addPsr4($prefix, $paths, $prepend = false)
    234231    {
     232        $paths = (array) $paths;
    235233        if (!$prefix) {
    236234            // Register directories for the root namespace.
    237235            if ($prepend) {
    238236                $this->fallbackDirsPsr4 = array_merge(
    239                     (array) $paths,
     237                    $paths,
    240238                    $this->fallbackDirsPsr4
    241239                );
     
    243241                $this->fallbackDirsPsr4 = array_merge(
    244242                    $this->fallbackDirsPsr4,
    245                     (array) $paths
     243                    $paths
    246244                );
    247245            }
     
    253251            }
    254252            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
    255             $this->prefixDirsPsr4[$prefix] = (array) $paths;
     253            $this->prefixDirsPsr4[$prefix] = $paths;
    256254        } elseif ($prepend) {
    257255            // Prepend directories for an already registered namespace.
    258256            $this->prefixDirsPsr4[$prefix] = array_merge(
    259                 (array) $paths,
     257                $paths,
    260258                $this->prefixDirsPsr4[$prefix]
    261259            );
     
    264262            $this->prefixDirsPsr4[$prefix] = array_merge(
    265263                $this->prefixDirsPsr4[$prefix],
    266                 (array) $paths
     264                $paths
    267265            );
    268266        }
     
    273271     * replacing any others previously set for this prefix.
    274272     *
    275      * @param string          $prefix The prefix
    276      * @param string[]|string $paths  The PSR-0 base directories
     273     * @param string              $prefix The prefix
     274     * @param list<string>|string $paths  The PSR-0 base directories
    277275     *
    278276     * @return void
     
    291289     * replacing any others previously set for this namespace.
    292290     *
    293      * @param string          $prefix The prefix/namespace, with trailing '\\'
    294      * @param string[]|string $paths  The PSR-4 base directories
     291     * @param string              $prefix The prefix/namespace, with trailing '\\'
     292     * @param list<string>|string $paths  The PSR-4 base directories
    295293     *
    296294     * @throws \InvalidArgumentException
     
    426424    {
    427425        if ($file = $this->findFile($class)) {
    428             includeFile($file);
     426            $includeFile = self::$includeFile;
     427            $includeFile($file);
    429428
    430429            return true;
     
    477476
    478477    /**
    479      * Returns the currently registered loaders indexed by their corresponding vendor directories.
    480      *
    481      * @return self[]
     478     * Returns the currently registered loaders keyed by their corresponding vendor directories.
     479     *
     480     * @return array<string, self>
    482481     */
    483482    public static function getRegisteredLoaders()
     
    556555        return false;
    557556    }
     557
     558    /**
     559     * @return void
     560     */
     561    private static function initializeIncludeClosure()
     562    {
     563        if (self::$includeFile !== null) {
     564            return;
     565        }
     566
     567        /**
     568         * Scope isolated include.
     569         *
     570         * Prevents access to $this/self from included files.
     571         *
     572         * @param  string $file
     573         * @return void
     574         */
     575        self::$includeFile = \Closure::bind(static function($file) {
     576            include $file;
     577        }, null, null);
     578    }
    558579}
    559 
    560 /**
    561  * Scope isolated include.
    562  *
    563  * Prevents access to $this/self from included files.
    564  *
    565  * @param  string $file
    566  * @return void
    567  * @private
    568  */
    569 function includeFile($file)
    570 {
    571     include $file;
    572 }
  • consistency/trunk/vendor/composer/autoload_classmap.php

    r3084555 r3092549  
    33// autoload_classmap.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
     
    99    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    1010    'Webaxones\\Consistency\\Asset\\Asset' => $baseDir . '/includes/Asset/Asset.php',
     11    'Webaxones\\Consistency\\Config\\LocalizedRules' => $baseDir . '/includes/Config/LocalizedRules.php',
    1112    'Webaxones\\Consistency\\Config\\RestSchema' => $baseDir . '/includes/Config/RestSchema.php',
    1213    'Webaxones\\Consistency\\Config\\Rules' => $baseDir . '/includes/Config/Rules.php',
  • consistency/trunk/vendor/composer/autoload_namespaces.php

    r3084555 r3092549  
    33// autoload_namespaces.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • consistency/trunk/vendor/composer/autoload_psr4.php

    r3084555 r3092549  
    33// autoload_psr4.php @generated by Composer
    44
    5 $vendorDir = dirname(dirname(__FILE__));
     5$vendorDir = dirname(__DIR__);
    66$baseDir = dirname($vendorDir);
    77
  • consistency/trunk/vendor/composer/autoload_real.php

    r3084555 r3092549  
    2626
    2727        spl_autoload_register(array('ComposerAutoloaderInit2f7e358677dd7dd5194d994145b49327', 'loadClassLoader'), true, true);
    28         self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    2929        spl_autoload_unregister(array('ComposerAutoloaderInit2f7e358677dd7dd5194d994145b49327', 'loadClassLoader'));
    3030
    31         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    32         if ($useStaticLoader) {
    33             require __DIR__ . '/autoload_static.php';
    34 
    35             call_user_func(\Composer\Autoload\ComposerStaticInit2f7e358677dd7dd5194d994145b49327::getInitializer($loader));
    36         } else {
    37             $map = require __DIR__ . '/autoload_namespaces.php';
    38             foreach ($map as $namespace => $path) {
    39                 $loader->set($namespace, $path);
    40             }
    41 
    42             $map = require __DIR__ . '/autoload_psr4.php';
    43             foreach ($map as $namespace => $path) {
    44                 $loader->setPsr4($namespace, $path);
    45             }
    46 
    47             $classMap = require __DIR__ . '/autoload_classmap.php';
    48             if ($classMap) {
    49                 $loader->addClassMap($classMap);
    50             }
    51         }
     31        require __DIR__ . '/autoload_static.php';
     32        call_user_func(\Composer\Autoload\ComposerStaticInit2f7e358677dd7dd5194d994145b49327::getInitializer($loader));
    5233
    5334        $loader->register(true);
  • consistency/trunk/vendor/composer/autoload_static.php

    r3084555 r3092549  
    2424        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
    2525        'Webaxones\\Consistency\\Asset\\Asset' => __DIR__ . '/../..' . '/includes/Asset/Asset.php',
     26        'Webaxones\\Consistency\\Config\\LocalizedRules' => __DIR__ . '/../..' . '/includes/Config/LocalizedRules.php',
    2627        'Webaxones\\Consistency\\Config\\RestSchema' => __DIR__ . '/../..' . '/includes/Config/RestSchema.php',
    2728        'Webaxones\\Consistency\\Config\\Rules' => __DIR__ . '/../..' . '/includes/Config/Rules.php',
Note: See TracChangeset for help on using the changeset viewer.