Changeset 3092549
- Timestamp:
- 05/25/2024 08:00:45 PM (19 months ago)
- Location:
- consistency
- Files:
-
- 2 added
- 40 edited
- 1 copied
-
tags/1.5.9 (copied) (copied from consistency/trunk)
-
tags/1.5.9/build/index.asset.php (modified) (1 diff)
-
tags/1.5.9/build/index.js (modified) (1 diff)
-
tags/1.5.9/consistency.php (modified) (1 diff)
-
tags/1.5.9/includes/Asset/Asset.php (modified) (2 diffs)
-
tags/1.5.9/includes/Config/LocalizedRules.php (added)
-
tags/1.5.9/includes/Config/Rules.php (modified) (3 diffs)
-
tags/1.5.9/includes/Plugin.php (modified) (2 diffs)
-
tags/1.5.9/package-lock.json (modified) (2 diffs)
-
tags/1.5.9/package.json (modified) (1 diff)
-
tags/1.5.9/readme.md (modified) (3 diffs)
-
tags/1.5.9/readme.txt (modified) (3 diffs)
-
tags/1.5.9/src/app/checks.js (modified) (2 diffs)
-
tags/1.5.9/src/app/fixes.js (modified) (3 diffs)
-
tags/1.5.9/src/config/rules.js (modified) (24 diffs)
-
tags/1.5.9/vendor/autoload.php (modified) (1 diff)
-
tags/1.5.9/vendor/composer/ClassLoader.php (modified) (25 diffs)
-
tags/1.5.9/vendor/composer/autoload_classmap.php (modified) (2 diffs)
-
tags/1.5.9/vendor/composer/autoload_namespaces.php (modified) (1 diff)
-
tags/1.5.9/vendor/composer/autoload_psr4.php (modified) (1 diff)
-
tags/1.5.9/vendor/composer/autoload_real.php (modified) (1 diff)
-
tags/1.5.9/vendor/composer/autoload_static.php (modified) (1 diff)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/consistency.php (modified) (1 diff)
-
trunk/includes/Asset/Asset.php (modified) (2 diffs)
-
trunk/includes/Config/LocalizedRules.php (added)
-
trunk/includes/Config/Rules.php (modified) (3 diffs)
-
trunk/includes/Plugin.php (modified) (2 diffs)
-
trunk/package-lock.json (modified) (2 diffs)
-
trunk/package.json (modified) (1 diff)
-
trunk/readme.md (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/app/checks.js (modified) (2 diffs)
-
trunk/src/app/fixes.js (modified) (3 diffs)
-
trunk/src/config/rules.js (modified) (24 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/ClassLoader.php (modified) (25 diffs)
-
trunk/vendor/composer/autoload_classmap.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_namespaces.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_psr4.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_static.php (modified) (1 diff)
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:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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:/(«)(?! | | )/,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(/ /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:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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:/(«)(?! | | )/,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(/ /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 4 4 * Plugin URI: https://www.webaxones.com 5 5 * Description: Fixes typographical consistency 6 * Version: 1.5. 86 * Version: 1.5.9 7 7 * Requires at least: 6.1 8 8 * Requires PHP: 7.4 -
consistency/tags/1.5.9/includes/Asset/Asset.php
r2857933 r3092549 8 8 use const Webaxones\Consistency\PLUGIN_PATH; 9 9 use const Webaxones\Consistency\PLUGIN_URL; 10 use Webaxones\Consistency\Config\LocalizedRules; 10 11 11 12 /** … … 41 42 true 42 43 ); 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 43 67 wp_set_script_translations( Plugin::PREFIX . '-editor-script', 'consistency' ); 44 68 } -
consistency/tags/1.5.9/includes/Config/Rules.php
r3092051 r3092549 6 6 7 7 use Webaxones\Consistency\Utils\Contracts\ValueInterface; 8 use Webaxones\Consistency\Config\LocalizedRules; 8 9 9 10 /** … … 19 20 protected array $languages = [ 20 21 '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 active25 *26 * @var array27 */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' ],51 22 ]; 52 23 … … 94 65 protected function setRules(): array 95 66 { 96 foreach ( $this->localizedRulesas $key => $value ) {67 foreach ( LocalizedRules::$list as $key => $value ) { 97 68 $this->rules[] = [ 98 69 'slug' => $key, -
consistency/tags/1.5.9/includes/Plugin.php
r3092051 r3092549 31 31 protected static function setConstants(): void 32 32 { 33 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5. 8' );33 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5.9' ); 34 34 defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) ); 35 35 defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) ); … … 47 47 { 48 48 self::setConstants(); 49 50 49 $hooks = new Hook(); 51 50 52 51 // Add main script 53 52 $assets = new Asset(); -
consistency/tags/1.5.9/package-lock.json
r3084549 r3092549 1 1 { 2 2 "name": "consistency", 3 "version": "1.5. 1",3 "version": "1.5.8", 4 4 "lockfileVersion": 3, 5 5 "requires": true, … … 7 7 "": { 8 8 "name": "consistency", 9 "version": "1.5. 1",9 "version": "1.5.8", 10 10 "license": "ISC", 11 11 "devDependencies": { -
consistency/tags/1.5.9/package.json
r3092051 r3092549 1 1 { 2 2 "name": "consistency", 3 "version": "1.5. 8",3 "version": "1.5.9", 4 4 "description": "", 5 5 "main": "index.js", -
consistency/tags/1.5.9/readme.md
r3091663 r3092549 31 31 Remember to unfold the panel to see the rules. 32 32 33 34 35 33 36 34 37 35 ## Description 38 36 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. 37 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. 38 > [!IMPORTANT]The corrections are automatic and are made during the entry as well as on a copy paste. 39 41 40 Autocorrect rules can be enabled/disabled by any user. 42 41 Autocorrect is available on pages, posts and custom post types (if their configuration allows Rest API usage) … … 44 43 Currently, the AutoCorrects offered are as follows: 45 44 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` | 47 70 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. 73 74 74 75 Technically, rules are saved in the `wp_options` table, while active/inactive states are saved as user meta data in `wp_usermeta` table. … … 77 78 Settings are directly in a plugin sidebar under the Block Editor: no more searching for an options page, always available and discreet. 78 79 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 82 80 ## Smoke tests 83 81 -
consistency/tags/1.5.9/readme.txt
r3092051 r3092549 4 4 Requires at least: 6.1 5 5 Tested up to: 6.5.2 6 Stable tag: 1.5. 86 Stable tag: 1.5.9 7 7 Requires PHP: 7.4 8 8 License: GPL-3.0-or-later … … 15 15 Do 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. 16 16 17 Th e 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)17 This WordPress plugin is designed to help administrators enforce consistent typography in text content entered in the editor. 18 Corrections are applied automatically both during text entry and when pasting text. 19 Users can enable or disable autocorrect rules as needed. 20 Autocorrect is available for pages, posts, and custom post types (if they are configured to use the Rest API). 21 21 22 Currently, the AutoCorrects offered are as follows: 22 Automatic fixes are listed on [the plugin repository on github](https://github.com/webaxones/consistency/). 23 23 24 For the English language25 24 26 - "Straight quote": Replaces straight quotes with curved quotes27 - "Ellipsis": Replaces 3 dots with ellipsis28 - "Two hyphens": Replaces 2 hyphens with em dash29 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix30 - "Regular quotes to curly": Replaces regular quotes with curly quotes31 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character32 - "Space before": Remove any space preceding a character from this list (? ! : ; %)33 - "First sentence letter not capitalized": Capitalize the first letter of a sentence34 - etc.35 36 For the French language37 38 - "Straight quote": Replaces straight quotes with curved quotes39 - "Ellipsis": Replaces 3 dots with ellipsis40 - "Two hyphens": Replaces 2 hyphens with em dash41 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix42 - "Regular quotes to French": Replaces regular quotes with French quotes43 - "Breaking space": Replaces a breaking space followed by a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) with a non-breaking space44 - "No space before": Adds a non-breaking space before a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) having no space before45 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character46 - "No non-breaking space after": Adds a non-breaking space after open french quote having no space after47 - "First sentence letter not capitalized": Capitalize the first letter of a sentence48 - etc.49 25 50 26 Ctrl+Z or Cmd+Z right after a correction disables the correction for the next keystroke … … 69 45 70 46 == Changelog == 47 48 = 1.5.9 = 49 * Add rule for percentages symbols 50 * Refactor some code 51 * Actualise Readme 71 52 72 53 = 1.5.8 = -
consistency/tags/1.5.9/src/app/checks.js
r3086094 r3092549 15 15 */ 16 16 import { getCurrentLocale } from './data' 17 import { rules } from '../config/rules'18 17 import { regsWithPair } from '../config/regsWithPair' 19 18 import { processedBlocks } from '../config/processedBlocks' … … 32 31 33 32 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 ) 38 35 } 39 40 36 return false 41 37 -
consistency/tags/1.5.9/src/app/fixes.js
r3091983 r3092549 97 97 firstPart = blockContent.substring( 0, cursorPositionInsideHTML - lengthToGoBack ) 98 98 lastPart = blockContent.substring( cursorPositionInsideHTML - lengthToGoBack, blockContent.length ) 99 99 100 100 // 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 101 101 isConcerned = reg.mask.test( textContent ) && reg.mask.test( lastPart ) … … 104 104 // Stop correction if block content isn't concerned by the regex 105 105 if ( ! isConcerned ) return 106 106 107 // Pairing characters need specific process for the replacement 107 108 if ( regDealWithPair( reg ) ) { … … 137 138 if ( 0 === cursorPosition || isPasting ) return 138 139 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 139 144 // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back 140 145 // 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 ) 144 148 } 145 149 146 150 // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward 147 151 // 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 ) { 153 157 selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition, cursorPosition ) 154 158 } -
consistency/tags/1.5.9/src/config/rules.js
r3092051 r3092549 21 21 replace: '’', // replacement string 22 22 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 locales24 23 category: 'punctuation' // category of the setting 25 24 }, … … 33 32 replace: '—', 34 33 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' ],36 34 category: 'punctuation' 37 35 }, … … 45 43 replace: '$1<sup>$2<\/sup>$3', 46 44 nbMoved: 0, 47 locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],48 45 category: 'punctuation' 49 46 }, … … 57 54 replace: '“$1”', 58 55 nbMoved: 0, 59 locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],60 56 category: 'punctuation' 61 57 }, … … 69 65 replace: '„$1“', 70 66 nbMoved: 0, 71 locales: [ 'de_DE', 'de_AT', 'ro_RO' ],72 67 category: 'punctuation' 73 68 }, … … 81 76 replace: '»$1«', 82 77 nbMoved: 0, 83 locales: [ 'de_DE', 'de_AT' ],84 78 category: 'punctuation' 85 79 }, … … 89 83 name: __( 'Regular quotes to french', 'consistency' ), 90 84 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>`, 92 86 mask: /"/, // specific mask with specific process 93 87 replace: '« $1 »', 94 88 nbMoved: 1, 95 locales: [ 'fr_FR', 'fr_BE' ],96 89 category: 'punctuation' 97 90 }, … … 105 98 replace: '«$1»', 106 99 nbMoved: 0, 107 locales: [ 'de_CH' ],108 100 category: 'punctuation' 109 101 }, … … 113 105 name: __( 'Curly quotes to french quotes', 'consistency' ), 114 106 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>`, 116 108 mask: /“.*?”/, // specific mask with specific process 117 109 replace: matched => { return `« ${matched.substring( 1, matched.length - 1 )} »` }, 118 110 nbMoved: 0, 119 locales: [ 'fr_FR', 'fr_BE' ],120 111 category: 'punctuation' 121 112 }, … … 129 120 replace: ' $1', 130 121 nbMoved: 0, 131 locales: [ 'fr_FR', 'fr_BE' ],132 122 category: 'space' 133 123 }, … … 141 131 replace: ' $1', 142 132 nbMoved: 1, 143 locales: [ 'fr_FR', 'fr_BE' ],144 133 category: 'space' 145 134 }, … … 153 142 replace: '$2', 154 143 nbMoved: -1, 155 locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],156 144 category: 'space' 157 145 }, … … 165 153 replace: '$1 $2', 166 154 nbMoved: 1, 167 locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],168 155 category: 'space' 169 156 }, … … 176 163 replace: '$1 ', 177 164 nbMoved: 0, 178 locales: [ 'fr_FR', 'fr_BE' ],179 165 category: 'space' 180 166 }, … … 187 173 replace: matched => matched.toUpperCase(), 188 174 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' ],190 175 category: 'case' 191 176 }, … … 199 184 replace: matched => { return matched.substring(0, 3) + '.' }, 200 185 nbMoved: -2, 201 locales: [ 'fr_FR', 'fr_BE' ],202 186 category: 'ellipsis' 203 187 }, … … 211 195 replace: matched => { return matched.substring(0, 2) + '.' }, 212 196 nbMoved: -1, 213 locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],214 197 category: 'ellipsis' 215 198 }, … … 217 200 // Replaces etc… with etc. 218 201 slug: 'etcEllipsis', 219 name: __( ' ellipsis following "etc"', 'consistency' ),202 name: __( 'Ellipsis following "etc"', 'consistency' ), 220 203 description: __( 'Replaces ellipsis placed after the abbreviation "etc" with a point:', 'consistency' ) 221 204 + `<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>`, … … 223 206 replace: matched => { return matched.substring(0, 3) + '.' }, 224 207 nbMoved: 0, 225 locales: [ 'fr_FR', 'fr_BE' ],226 208 category: 'ellipsis' 227 209 }, … … 235 217 replace: '…', 236 218 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' ],238 219 category: 'ellipsis' 239 220 }, 240 221 { 241 222 // Replaces a character from this list [c p r] when enclosed in parentheses with a symbol 242 slug: 'symbol BasedOn1Character',243 name: __( 'Symbol based on 1 character', 'consistency' ),223 slug: 'symbolInACircle', 224 name: __( 'Symbol in a circle', 'consistency' ), 244 225 description: __( 'Replaces 1 character placed in parentheses with a symbol', 'consistency' ) 245 226 + `<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>`, … … 257 238 }, 258 239 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' ],260 240 category: 'symbol' 261 241 }, 262 242 { 263 // Replaces a character from this list [md tm mc sm] w hen enclosed in parentheses with a symbol264 slug: 'symbol BasedOn2Characters',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)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/, 269 249 replace: matched => { 270 250 switch ( matched ) { 271 case ' (tm)':251 case 'tm': 272 252 return '™' 273 case ' (sm)':253 case 'sm': 274 254 return '℠' 275 case ' (md)':255 case 'md': 276 256 return '🅫' 277 case ' (mc)':257 case 'mc': 278 258 return '🅪' 279 259 default: … … 281 261 } 282 262 }, 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, 285 264 category: 'symbol' 286 265 }, … … 290 269 name: __( 'Fractions', 'consistency' ), 291 270 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>`, 293 272 mask: /[1-9]\/[1-9]/, 294 273 replace: matched => { … … 333 312 }, 334 313 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 }, 336 350 category: 'symbol' 337 351 }, -
consistency/tags/1.5.9/vendor/autoload.php
r3084555 r3092549 3 3 // autoload.php @generated by Composer 4 4 5 if (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 5 23 require_once __DIR__ . '/composer/autoload_real.php'; 6 24 -
consistency/tags/1.5.9/vendor/composer/ClassLoader.php
r3084555 r3092549 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 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>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var string|null */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var array<string, self> 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param string|null $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 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 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @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 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 $paths = (array) $paths; 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @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 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 $paths = (array) $paths; 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 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> 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 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 } 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
consistency/tags/1.5.9/vendor/composer/autoload_classmap.php
r3084555 r3092549 3 3 // autoload_classmap.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 … … 9 9 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 10 10 'Webaxones\\Consistency\\Asset\\Asset' => $baseDir . '/includes/Asset/Asset.php', 11 'Webaxones\\Consistency\\Config\\LocalizedRules' => $baseDir . '/includes/Config/LocalizedRules.php', 11 12 'Webaxones\\Consistency\\Config\\RestSchema' => $baseDir . '/includes/Config/RestSchema.php', 12 13 'Webaxones\\Consistency\\Config\\Rules' => $baseDir . '/includes/Config/Rules.php', -
consistency/tags/1.5.9/vendor/composer/autoload_namespaces.php
r3084555 r3092549 3 3 // autoload_namespaces.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
consistency/tags/1.5.9/vendor/composer/autoload_psr4.php
r3084555 r3092549 3 3 // autoload_psr4.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
consistency/tags/1.5.9/vendor/composer/autoload_real.php
r3084555 r3092549 26 26 27 27 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__)); 29 29 spl_autoload_unregister(array('ComposerAutoloaderInit2f7e358677dd7dd5194d994145b49327', 'loadClassLoader')); 30 30 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)); 52 33 53 34 $loader->register(true); -
consistency/tags/1.5.9/vendor/composer/autoload_static.php
r3084555 r3092549 24 24 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 25 25 'Webaxones\\Consistency\\Asset\\Asset' => __DIR__ . '/../..' . '/includes/Asset/Asset.php', 26 'Webaxones\\Consistency\\Config\\LocalizedRules' => __DIR__ . '/../..' . '/includes/Config/LocalizedRules.php', 26 27 'Webaxones\\Consistency\\Config\\RestSchema' => __DIR__ . '/../..' . '/includes/Config/RestSchema.php', 27 28 '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:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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:/(«)(?! | | )/,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(/ /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:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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:/(«)(?! | | )/,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(/ /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 4 4 * Plugin URI: https://www.webaxones.com 5 5 * Description: Fixes typographical consistency 6 * Version: 1.5. 86 * Version: 1.5.9 7 7 * Requires at least: 6.1 8 8 * Requires PHP: 7.4 -
consistency/trunk/includes/Asset/Asset.php
r2857933 r3092549 8 8 use const Webaxones\Consistency\PLUGIN_PATH; 9 9 use const Webaxones\Consistency\PLUGIN_URL; 10 use Webaxones\Consistency\Config\LocalizedRules; 10 11 11 12 /** … … 41 42 true 42 43 ); 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 43 67 wp_set_script_translations( Plugin::PREFIX . '-editor-script', 'consistency' ); 44 68 } -
consistency/trunk/includes/Config/Rules.php
r3092051 r3092549 6 6 7 7 use Webaxones\Consistency\Utils\Contracts\ValueInterface; 8 use Webaxones\Consistency\Config\LocalizedRules; 8 9 9 10 /** … … 19 20 protected array $languages = [ 20 21 '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 active25 *26 * @var array27 */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' ],51 22 ]; 52 23 … … 94 65 protected function setRules(): array 95 66 { 96 foreach ( $this->localizedRulesas $key => $value ) {67 foreach ( LocalizedRules::$list as $key => $value ) { 97 68 $this->rules[] = [ 98 69 'slug' => $key, -
consistency/trunk/includes/Plugin.php
r3092051 r3092549 31 31 protected static function setConstants(): void 32 32 { 33 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5. 8' );33 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.5.9' ); 34 34 defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) ); 35 35 defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) ); … … 47 47 { 48 48 self::setConstants(); 49 50 49 $hooks = new Hook(); 51 50 52 51 // Add main script 53 52 $assets = new Asset(); -
consistency/trunk/package-lock.json
r3084549 r3092549 1 1 { 2 2 "name": "consistency", 3 "version": "1.5. 1",3 "version": "1.5.8", 4 4 "lockfileVersion": 3, 5 5 "requires": true, … … 7 7 "": { 8 8 "name": "consistency", 9 "version": "1.5. 1",9 "version": "1.5.8", 10 10 "license": "ISC", 11 11 "devDependencies": { -
consistency/trunk/package.json
r3092051 r3092549 1 1 { 2 2 "name": "consistency", 3 "version": "1.5. 8",3 "version": "1.5.9", 4 4 "description": "", 5 5 "main": "index.js", -
consistency/trunk/readme.md
r3091663 r3092549 31 31 Remember to unfold the panel to see the rules. 32 32 33 34 35 33 36 34 37 35 ## Description 38 36 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. 37 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. 38 > [!IMPORTANT]The corrections are automatic and are made during the entry as well as on a copy paste. 39 41 40 Autocorrect rules can be enabled/disabled by any user. 42 41 Autocorrect is available on pages, posts and custom post types (if their configuration allows Rest API usage) … … 44 43 Currently, the AutoCorrects offered are as follows: 45 44 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` | 47 70 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. 73 74 74 75 Technically, rules are saved in the `wp_options` table, while active/inactive states are saved as user meta data in `wp_usermeta` table. … … 77 78 Settings are directly in a plugin sidebar under the Block Editor: no more searching for an options page, always available and discreet. 78 79 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 82 80 ## Smoke tests 83 81 -
consistency/trunk/readme.txt
r3092051 r3092549 4 4 Requires at least: 6.1 5 5 Tested up to: 6.5.2 6 Stable tag: 1.5. 86 Stable tag: 1.5.9 7 7 Requires PHP: 7.4 8 8 License: GPL-3.0-or-later … … 15 15 Do 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. 16 16 17 Th e 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)17 This WordPress plugin is designed to help administrators enforce consistent typography in text content entered in the editor. 18 Corrections are applied automatically both during text entry and when pasting text. 19 Users can enable or disable autocorrect rules as needed. 20 Autocorrect is available for pages, posts, and custom post types (if they are configured to use the Rest API). 21 21 22 Currently, the AutoCorrects offered are as follows: 22 Automatic fixes are listed on [the plugin repository on github](https://github.com/webaxones/consistency/). 23 23 24 For the English language25 24 26 - "Straight quote": Replaces straight quotes with curved quotes27 - "Ellipsis": Replaces 3 dots with ellipsis28 - "Two hyphens": Replaces 2 hyphens with em dash29 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix30 - "Regular quotes to curly": Replaces regular quotes with curly quotes31 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character32 - "Space before": Remove any space preceding a character from this list (? ! : ; %)33 - "First sentence letter not capitalized": Capitalize the first letter of a sentence34 - etc.35 36 For the French language37 38 - "Straight quote": Replaces straight quotes with curved quotes39 - "Ellipsis": Replaces 3 dots with ellipsis40 - "Two hyphens": Replaces 2 hyphens with em dash41 - "Ordinal number suffix": Add HTML tag sup to ordinal number suffix42 - "Regular quotes to French": Replaces regular quotes with French quotes43 - "Breaking space": Replaces a breaking space followed by a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) with a non-breaking space44 - "No space before": Adds a non-breaking space before a character from this list (? ! : ; » € $ £ ¥ ₽ 元 %) having no space before45 - "No breaking space after": Adds a breaking space after a character from this list (, … ) ]) when followed with another character46 - "No non-breaking space after": Adds a non-breaking space after open french quote having no space after47 - "First sentence letter not capitalized": Capitalize the first letter of a sentence48 - etc.49 25 50 26 Ctrl+Z or Cmd+Z right after a correction disables the correction for the next keystroke … … 69 45 70 46 == Changelog == 47 48 = 1.5.9 = 49 * Add rule for percentages symbols 50 * Refactor some code 51 * Actualise Readme 71 52 72 53 = 1.5.8 = -
consistency/trunk/src/app/checks.js
r3086094 r3092549 15 15 */ 16 16 import { getCurrentLocale } from './data' 17 import { rules } from '../config/rules'18 17 import { regsWithPair } from '../config/regsWithPair' 19 18 import { processedBlocks } from '../config/processedBlocks' … … 32 31 33 32 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 ) 38 35 } 39 40 36 return false 41 37 -
consistency/trunk/src/app/fixes.js
r3091983 r3092549 97 97 firstPart = blockContent.substring( 0, cursorPositionInsideHTML - lengthToGoBack ) 98 98 lastPart = blockContent.substring( cursorPositionInsideHTML - lengthToGoBack, blockContent.length ) 99 99 100 100 // 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 101 101 isConcerned = reg.mask.test( textContent ) && reg.mask.test( lastPart ) … … 104 104 // Stop correction if block content isn't concerned by the regex 105 105 if ( ! isConcerned ) return 106 106 107 // Pairing characters need specific process for the replacement 107 108 if ( regDealWithPair( reg ) ) { … … 137 138 if ( 0 === cursorPosition || isPasting ) return 138 139 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 139 144 // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back 140 145 // 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 ) 144 148 } 145 149 146 150 // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward 147 151 // 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 ) { 153 157 selectionChange( currentBlockId, selectionStart.attributeKey, cursorPosition, cursorPosition ) 154 158 } -
consistency/trunk/src/config/rules.js
r3092051 r3092549 21 21 replace: '’', // replacement string 22 22 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 locales24 23 category: 'punctuation' // category of the setting 25 24 }, … … 33 32 replace: '—', 34 33 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' ],36 34 category: 'punctuation' 37 35 }, … … 45 43 replace: '$1<sup>$2<\/sup>$3', 46 44 nbMoved: 0, 47 locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],48 45 category: 'punctuation' 49 46 }, … … 57 54 replace: '“$1”', 58 55 nbMoved: 0, 59 locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],60 56 category: 'punctuation' 61 57 }, … … 69 65 replace: '„$1“', 70 66 nbMoved: 0, 71 locales: [ 'de_DE', 'de_AT', 'ro_RO' ],72 67 category: 'punctuation' 73 68 }, … … 81 76 replace: '»$1«', 82 77 nbMoved: 0, 83 locales: [ 'de_DE', 'de_AT' ],84 78 category: 'punctuation' 85 79 }, … … 89 83 name: __( 'Regular quotes to french', 'consistency' ), 90 84 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>`, 92 86 mask: /"/, // specific mask with specific process 93 87 replace: '« $1 »', 94 88 nbMoved: 1, 95 locales: [ 'fr_FR', 'fr_BE' ],96 89 category: 'punctuation' 97 90 }, … … 105 98 replace: '«$1»', 106 99 nbMoved: 0, 107 locales: [ 'de_CH' ],108 100 category: 'punctuation' 109 101 }, … … 113 105 name: __( 'Curly quotes to french quotes', 'consistency' ), 114 106 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>`, 116 108 mask: /“.*?”/, // specific mask with specific process 117 109 replace: matched => { return `« ${matched.substring( 1, matched.length - 1 )} »` }, 118 110 nbMoved: 0, 119 locales: [ 'fr_FR', 'fr_BE' ],120 111 category: 'punctuation' 121 112 }, … … 129 120 replace: ' $1', 130 121 nbMoved: 0, 131 locales: [ 'fr_FR', 'fr_BE' ],132 122 category: 'space' 133 123 }, … … 141 131 replace: ' $1', 142 132 nbMoved: 1, 143 locales: [ 'fr_FR', 'fr_BE' ],144 133 category: 'space' 145 134 }, … … 153 142 replace: '$2', 154 143 nbMoved: -1, 155 locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB', 'de_DE', 'de_AT', 'de_CH', 'ro_RO' ],156 144 category: 'space' 157 145 }, … … 165 153 replace: '$1 $2', 166 154 nbMoved: 1, 167 locales: [ 'fr_FR', 'fr_BE', 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],168 155 category: 'space' 169 156 }, … … 176 163 replace: '$1 ', 177 164 nbMoved: 0, 178 locales: [ 'fr_FR', 'fr_BE' ],179 165 category: 'space' 180 166 }, … … 187 173 replace: matched => matched.toUpperCase(), 188 174 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' ],190 175 category: 'case' 191 176 }, … … 199 184 replace: matched => { return matched.substring(0, 3) + '.' }, 200 185 nbMoved: -2, 201 locales: [ 'fr_FR', 'fr_BE' ],202 186 category: 'ellipsis' 203 187 }, … … 211 195 replace: matched => { return matched.substring(0, 2) + '.' }, 212 196 nbMoved: -1, 213 locales: [ 'en_US', 'en_AU', 'en_CA', 'en_NZ', 'en_ZA', 'en_GB' ],214 197 category: 'ellipsis' 215 198 }, … … 217 200 // Replaces etc… with etc. 218 201 slug: 'etcEllipsis', 219 name: __( ' ellipsis following "etc"', 'consistency' ),202 name: __( 'Ellipsis following "etc"', 'consistency' ), 220 203 description: __( 'Replaces ellipsis placed after the abbreviation "etc" with a point:', 'consistency' ) 221 204 + `<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>`, … … 223 206 replace: matched => { return matched.substring(0, 3) + '.' }, 224 207 nbMoved: 0, 225 locales: [ 'fr_FR', 'fr_BE' ],226 208 category: 'ellipsis' 227 209 }, … … 235 217 replace: '…', 236 218 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' ],238 219 category: 'ellipsis' 239 220 }, 240 221 { 241 222 // Replaces a character from this list [c p r] when enclosed in parentheses with a symbol 242 slug: 'symbol BasedOn1Character',243 name: __( 'Symbol based on 1 character', 'consistency' ),223 slug: 'symbolInACircle', 224 name: __( 'Symbol in a circle', 'consistency' ), 244 225 description: __( 'Replaces 1 character placed in parentheses with a symbol', 'consistency' ) 245 226 + `<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>`, … … 257 238 }, 258 239 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' ],260 240 category: 'symbol' 261 241 }, 262 242 { 263 // Replaces a character from this list [md tm mc sm] w hen enclosed in parentheses with a symbol264 slug: 'symbol BasedOn2Characters',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)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/, 269 249 replace: matched => { 270 250 switch ( matched ) { 271 case ' (tm)':251 case 'tm': 272 252 return '™' 273 case ' (sm)':253 case 'sm': 274 254 return '℠' 275 case ' (md)':255 case 'md': 276 256 return '🅫' 277 case ' (mc)':257 case 'mc': 278 258 return '🅪' 279 259 default: … … 281 261 } 282 262 }, 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, 285 264 category: 'symbol' 286 265 }, … … 290 269 name: __( 'Fractions', 'consistency' ), 291 270 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>`, 293 272 mask: /[1-9]\/[1-9]/, 294 273 replace: matched => { … … 333 312 }, 334 313 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 }, 336 350 category: 'symbol' 337 351 }, -
consistency/trunk/vendor/autoload.php
r3084555 r3092549 3 3 // autoload.php @generated by Composer 4 4 5 if (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 5 23 require_once __DIR__ . '/composer/autoload_real.php'; 6 24 -
consistency/trunk/vendor/composer/ClassLoader.php
r3084555 r3092549 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 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>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var string|null */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var array<string, self> 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param string|null $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 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 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @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 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 $paths = (array) $paths; 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @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 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 $paths = (array) $paths; 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 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> 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 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 } 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
consistency/trunk/vendor/composer/autoload_classmap.php
r3084555 r3092549 3 3 // autoload_classmap.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 … … 9 9 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 10 10 'Webaxones\\Consistency\\Asset\\Asset' => $baseDir . '/includes/Asset/Asset.php', 11 'Webaxones\\Consistency\\Config\\LocalizedRules' => $baseDir . '/includes/Config/LocalizedRules.php', 11 12 'Webaxones\\Consistency\\Config\\RestSchema' => $baseDir . '/includes/Config/RestSchema.php', 12 13 'Webaxones\\Consistency\\Config\\Rules' => $baseDir . '/includes/Config/Rules.php', -
consistency/trunk/vendor/composer/autoload_namespaces.php
r3084555 r3092549 3 3 // autoload_namespaces.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
consistency/trunk/vendor/composer/autoload_psr4.php
r3084555 r3092549 3 3 // autoload_psr4.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
consistency/trunk/vendor/composer/autoload_real.php
r3084555 r3092549 26 26 27 27 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__)); 29 29 spl_autoload_unregister(array('ComposerAutoloaderInit2f7e358677dd7dd5194d994145b49327', 'loadClassLoader')); 30 30 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)); 52 33 53 34 $loader->register(true); -
consistency/trunk/vendor/composer/autoload_static.php
r3084555 r3092549 24 24 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 25 25 'Webaxones\\Consistency\\Asset\\Asset' => __DIR__ . '/../..' . '/includes/Asset/Asset.php', 26 'Webaxones\\Consistency\\Config\\LocalizedRules' => __DIR__ . '/../..' . '/includes/Config/LocalizedRules.php', 26 27 'Webaxones\\Consistency\\Config\\RestSchema' => __DIR__ . '/../..' . '/includes/Config/RestSchema.php', 27 28 'Webaxones\\Consistency\\Config\\Rules' => __DIR__ . '/../..' . '/includes/Config/Rules.php',
Note: See TracChangeset
for help on using the changeset viewer.