Changeset 3184822
- Timestamp:
- 11/09/2024 11:05:30 AM (13 months ago)
- Location:
- consistency
- Files:
-
- 22 edited
- 1 copied
-
tags/1.8.2 (copied) (copied from consistency/trunk)
-
tags/1.8.2/build/index.asset.php (modified) (1 diff)
-
tags/1.8.2/build/index.js (modified) (1 diff)
-
tags/1.8.2/consistency.php (modified) (1 diff)
-
tags/1.8.2/includes/Plugin.php (modified) (1 diff)
-
tags/1.8.2/package.json (modified) (1 diff)
-
tags/1.8.2/readme.txt (modified) (2 diffs)
-
tags/1.8.2/src/app/checks.js (modified) (1 diff)
-
tags/1.8.2/src/app/fixes.js (modified) (10 diffs)
-
tags/1.8.2/src/app/helpers.js (modified) (6 diffs)
-
tags/1.8.2/src/app/utils.js (modified) (1 diff)
-
tags/1.8.2/src/config/rules.js (modified) (25 diffs)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/consistency.php (modified) (1 diff)
-
trunk/includes/Plugin.php (modified) (1 diff)
-
trunk/package.json (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/app/checks.js (modified) (1 diff)
-
trunk/src/app/fixes.js (modified) (10 diffs)
-
trunk/src/app/helpers.js (modified) (6 diffs)
-
trunk/src/app/utils.js (modified) (1 diff)
-
trunk/src/config/rules.js (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
consistency/tags/1.8.2/build/index.asset.php
r3145550 r3184822 1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => ' ab0245b936622e6790c8');1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => '71c2764f0435ef4fe22c'); -
consistency/tags/1.8.2/build/index.js
r3145550 r3184822 1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]), p=(0,c.useRef)(0),d=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:p,isContentPastedRef:d}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),f=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof f.RichTextData,{getEntityRecord:w}=(0,p.select)("core"),{updateBlock:v}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | | )/,replace:"$1 ",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],{getBlock:F,getBlocks:P,getBlockAttributes:R,getSelectionStart:Q,isTyping:W}=(0,p.select)("core/block-editor"),{selectionChange:M,updateBlockAttributes:$}=(0,p.dispatch)("core/block-editor"),A=()=>{const e=(()=>{const e=w("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>O(e.slug))):e},N=()=>B.filter((e=>!0===A()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:q,getBlockAttributes:z}=(0,p.select)("core/block-editor"),O=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},I=e=>{const t=E.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>A()?.find((t=>t.slug===e))?.value))},D=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!O(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:I(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},L=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],G=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...L].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)(D,{key:s,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:j}=(0,p.select)("core"),U=()=>{const e=j("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(G,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:H,getBlocks:K,getBlockAttributes:J,getSelectionStart:V,isTyping:X}=(0,p.select)("core/block-editor"),{updateBlockAttributes:Y}=(0,p.dispatch)("core/block-editor"),Z=e=>{const{currentBlockId:t,isPreviousFixCanceled:s,setPreviousFixCanceled:n,blocksToBeProcessed:o,cursorOffsetRef:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=q(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:o})||!(e=>{const t=z(e);return!(!t||!t.hasOwnProperty("content")||!_(t.content)&&!k(t.content))})(t))return;let r=N();const a=H(t);let i=J(t),l=!1;Object.entries(r).forEach((([e,o])=>{if(l)return;let r,u=o.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(X()||(b=o.mask.test(h)),X()){r=V(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/ /g)||[]).length;return l>0&&(i=a.replace(/ /g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(o.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=o.mask.test(h)&&o.mask.test(d)}if(!b)return;if((e=>!!T.includes(e.slug))(o)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(o,m)),0!==y&&(m=p+d.replace(o.mask,u)),0===y&&(m=m.replace(o.mask,o.replace)),s)return void n(!1);s||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,f.create)({...n.content,text:o});c=new f.RichTextData(e)}return _(n.content)&&(c=o),void 0!==c&&(v(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m}));const w="function"==typeof o.nbMoved?o.nbMoved(d):o.nbMoved||0;l&&(c.current=w)}))},{getSelectedBlockClientId:ee,isTyping:te,getBlockAttributes:se}=(0,p.select)("core/block-editor"),ne=window.wp.blocks,oe=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,ne.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));const s=["core/html"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Blocks that can be processed:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,cursorOffsetRef:r,isContentPastedRef:a}=(0,c.useContext)(i);r.current=r.current||0,a.current=a.current||!1,(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:i}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=w("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!i)return;if(void 0===A())return;if(i&&!0===a.current)return a.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o}=e;let c=N();const r=K(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return n.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(T.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!T.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&Y(Object.keys(i),i,!0),a.forEach((e=>{if(!n.includes(e.name))return;const c=e.clientId;e?.clientId&&Z({currentBlockId:c,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r});const l=ee();if(null===l||!c)return;const u=se(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),te()&&Z({currentBlockId:l,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r})))}));return()=>{c(),(e=>{const t=window.getSelection();if(!t)return;let s;1===t?.anchorNode?.nodeType&&(s=t.anchorNode?.firstChild?.length||0),3===t?.anchorNode?.nodeType&&(s=t.anchorOffset||0);const n=e>=0?s+e:s;if(1!==t?.anchorNode?.nodeType)if(3!==t?.anchorNode?.nodeType);else{const e=t.anchorNode;t.collapse(e,n)}else{const e=t.anchorNode?.firstChild||t.anchorNode?.childNodes[0];t.collapse(e,n)}})(r.current),r.current=0}}),[e,t,s,n,o,r,a])})(),(0,t.createElement)(U,null)),ce=()=>(0,t.createElement)(a,null,(0,t.createElement)(oe,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ce})}))})();1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),d=(0,c.useRef)(0),p=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:d,isContentPastedRef:p}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,d=window.wp.data,p=window.wp.components,y=()=>(0,t.createElement)(p.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),g=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,d.useSelect)((e=>({currentUser:e(g.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,g.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,d.useDispatch)(g.store),{createNotice:y}=(0,d.useDispatch)(m.store);return(0,t.createElement)(p.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),y((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},f=()=>(0,t.createElement)(p.Panel,{className:"UserSettingPanel"},(0,t.createElement)(p.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(p.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(p.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),b=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof b.RichTextData,{getEntityRecord:w}=(0,d.select)("core"),{updateBlock:v}=(0,d.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",format:"",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",format:"",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",format:"",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",format:"",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1$2$3",format:"superscript",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",format:"",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",format:"",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",format:"",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",format:"",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",format:"",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,format:"",nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",format:"",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",format:"",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",format:"",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",format:"",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | | )/,replace:"$1 ",format:"",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),format:"",nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",format:"",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",format:"",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",format:"",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",format:"",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},format:"",nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},format:"",nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},format:"",nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},format:"",nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],{getSelectionStart:F}=(0,d.select)("core/block-editor"),{selectionChange:P}=(0,d.dispatch)("core/block-editor"),R=()=>{const e=(()=>{const e=w("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>$(e.slug))):e},Q=()=>B.filter((e=>!0===R()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:W,getBlockAttributes:M}=(0,d.select)("core/block-editor"),$=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},N=e=>{const t=E.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>R()?.find((t=>t.slug===e))?.value))},q=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,d.useDispatch)(m.store);if(S()&&!$(s))return"";const[r,a]=(0,g.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,d.useDispatch)(g.store);return(0,t.createElement)(p.PanelRow,null,(0,t.createElement)(p.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:N(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},A=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],z=()=>(0,t.createElement)(p.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(p.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...A].map(((e,s)=>(0,t.createElement)(p.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)(q,{key:s,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:I}=(0,d.select)("core"),O=()=>{const e=I("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:y},(0,t.createElement)(f,null),e&&(0,t.createElement)(z,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:D,getBlocks:L,getBlockAttributes:G,getSelectionStart:j,isTyping:U}=(0,d.select)("core/block-editor"),{updateBlockAttributes:H,updateBlock:K}=(0,d.dispatch)("core/block-editor"),J=e=>{const{currentBlockId:t,isPreviousFixCanceled:s,setPreviousFixCanceled:n,blocksToBeProcessed:o,cursorOffsetRef:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=W(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:o})||!(e=>{const t=M(e);return!(!t||!t.hasOwnProperty("content")||!_(t.content)&&!k(t.content))})(t))return;let r=Q();const a=D(t);let i=G(t),l=!1;Object.entries(r).forEach((([e,o])=>{if(l)return;if(""!==o.format)return;i.content;let r,u=o.replace,d="",p="",y=0,g=0,m=("object"==typeof i.content&&i.content,"object"==typeof i.content?i.content.text:i.content),h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),f=!1;if(U()||(f=o.mask.test(h)),U()){r=j(),y=r?.offset||document.getSelection()?.anchorOffset||0,g=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/ /g)||[]).length;return l>0&&(i=a.replace(/ /g," ").indexOf("\0"),i=i-6*l+l),i})(t)||y;const e=h.match(o.mask);if(null===e||0===e.length)return;const s=e[0].length||1;d=h.substring(0,g-s),p=h.substring(g-s,h.length),f=o.mask.test(h)&&o.mask.test(p)}if(!f)return;if((e=>!!T.includes(e.slug))(o)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(o,m)),0!==g&&(m=d+p.replace(o.mask,u)),0===g&&(m=m.replace(o.mask,o.replace)),s)return void n(!1);s||""!==o.format||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,b.create)({...n.content,text:o});c=new b.RichTextData(e)}return _(n.content)&&(c=o),void 0!==c&&(v(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m}));const w="function"==typeof o.nbMoved?o.nbMoved(p):o.nbMoved||0;l&&(c.current=w)}))},{getSelectedBlockClientId:V,isTyping:X,getBlockAttributes:Y}=(0,d.select)("core/block-editor"),Z=window.wp.blocks,ee=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,Z.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));const s=["core/html"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Blocks that can be processed:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,cursorOffsetRef:r,isContentPastedRef:a}=(0,c.useContext)(i);r.current=r.current||0,a.current=a.current||!1,(0,c.useEffect)((()=>{const c=(0,d.subscribe)((()=>{const{onTheFly:c,onPaste:i}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,d.select)(g.store).getCurrentUser(),s=w("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!i)return;if(void 0===R())return;if(i&&!0===a.current)return a.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o}=e;let c=Q();const r=L(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return n.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(T.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!T.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&H(Object.keys(i),i,!0),a.forEach((e=>{if(!n.includes(e.name))return;const c=e.clientId;e?.clientId&&J({currentBlockId:c,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r});const l=V();if(null===l||!c)return;const u=Y(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),X()&&J({currentBlockId:l,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r})))}));return()=>{c(),(e=>{const t=window.getSelection(),s=F();if(!t)return;let n;if(null===t.anchorNode){if(null===s||null===s?.clientId)return;return n=s?.offset||0,void P(s.clientId,s.attributeKey,n+e,n+e)}1===t?.anchorNode?.nodeType&&(n=t.anchorNode?.firstChild?.length||0),3===t?.anchorNode?.nodeType&&(n=t.anchorOffset||0);const o=e>=0?n+e:n;if(1!==t?.anchorNode?.nodeType)if(3!==t?.anchorNode?.nodeType);else{const e=t.anchorNode;t.collapse(e,o)}else{const e=t.anchorNode?.firstChild||t.anchorNode?.childNodes[0];t.collapse(e,o)}})(r.current),r.current=0}}),[e,t,s,n,o,r,a])})(),(0,t.createElement)(O,null)),te=()=>(0,t.createElement)(a,null,(0,t.createElement)(ee,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:te})}))})(); -
consistency/tags/1.8.2/consistency.php
r3145550 r3184822 4 4 * Plugin URI: https://www.webaxones.com 5 5 * Description: Fixes typographic and punctuation consistency 6 * Version: 1.8. 16 * Version: 1.8.2 7 7 * Requires at least: 6.1 8 8 * Requires PHP: 7.4 -
consistency/tags/1.8.2/includes/Plugin.php
r3145550 r3184822 33 33 protected static function setConstants(): void 34 34 { 35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8. 1' );35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.2' ); 36 36 defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) ); 37 37 defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) ); -
consistency/tags/1.8.2/package.json
r3145550 r3184822 1 1 { 2 2 "name": "consistency", 3 "version": "1.8. 1",3 "version": "1.8.2", 4 4 "description": "", 5 5 "main": "index.js", -
consistency/tags/1.8.2/readme.txt
r3145550 r3184822 3 3 Tags: punctuation, typography, block editor, gutenberg 4 4 Requires at least: 6.1 5 Tested up to: 6. 66 Stable tag: 1.8. 15 Tested up to: 6.7 6 Stable tag: 1.8.2 7 7 Requires PHP: 7.4 8 8 License: GPL-3.0-or-later … … 70 70 == Changelog == 71 71 72 = 1.8.2 = 73 * Fix: Fix cursor repositionning which was buggy since wp6.6 74 * Fix: Disable number suffix correction while waiting to recode it using formats 75 * Add: Indicate compatibility with WordPress 6.7 76 72 77 = 1.8.1 = 73 78 * Fix: Resolves incompatibilities with block plugins such as Kadence, GeneratePress, etc. -
consistency/tags/1.8.2/src/app/checks.js
r3145550 r3184822 82 82 * Checks if the regex processes a pair 83 83 * 84 * @param {string} r egregex84 * @param {string} rule regex 85 85 * @return {boolean} Does the regex process a pair? 86 86 */ 87 export const regDealWithPair = r eg=> {87 export const regDealWithPair = rule => { 88 88 89 if ( pairedCharacterSlugs.includes( r eg.slug ) ) {89 if ( pairedCharacterSlugs.includes( rule.slug ) ) { 90 90 return true 91 91 } -
consistency/tags/1.8.2/src/app/fixes.js
r3145550 r3184822 10 10 */ 11 11 import { select, dispatch } from '@wordpress/data' 12 import { applyFormat } from '@wordpress/rich-text' 12 13 13 14 /** 14 15 * External dependencies 15 16 */ 16 import { getAllInnersFromParents, getOnlyTextFromBlockContent, getCursorPositionInInnerHTML } from './utils'17 import { getAllInnersFromParents, removeHTMLTagsFromBlockContent, getCursorPositionInInnerHTML } from './utils' 17 18 import { getReplacementStringForPairs, getLocalizedRules } from './helpers' 18 19 import { updateBlockTextContent } from './data' … … 21 22 22 23 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' ) 23 const { updateBlockAttributes } = dispatch( 'core/block-editor' )24 const { updateBlockAttributes, updateBlock } = dispatch( 'core/block-editor' ) 24 25 25 26 … … 54 55 55 56 // Loop on localized rules to check if the block content matches one regex 56 Object.entries( localizedRules ).forEach( ( [ _, r eg] ) => {57 Object.entries( localizedRules ).forEach( ( [ _, rule ] ) => { 57 58 58 59 // Stop correction if block content has already been updated 59 60 if ( contentUpdated ) return 60 61 61 let replaceWithThis = reg.replace 62 if ( rule.format !== '' ) return 63 64 const isRichTextValueObject = ( typeof blockAttributes.content === 'object' ) 65 66 let replaceWithThis = rule.replace 62 67 let firstPart = '' 63 68 let lastPart = '' … … 65 70 let cursorPositionInsideHTML = 0 66 71 let selectionStart 67 72 let richTextValueObject = ( typeof blockAttributes.content === 'object' ) ? blockAttributes.content : {} 68 73 let blockContent = ( typeof blockAttributes.content === 'object' ) ? blockAttributes.content.text : blockAttributes.content 69 74 70 75 // Remove 'code' 'pre' and 'kbd' and other HTML tags from block content 71 let textContent = getOnlyTextFromBlockContent( blockContent )76 let textContent = removeHTMLTagsFromBlockContent( blockContent ) 72 77 73 78 // Check if the block's text content matches the regex in the case of pasted content … … 75 80 let isConcerned = false 76 81 if ( ! isTyping() ) { 77 isConcerned = r eg.mask.test( textContent )82 isConcerned = rule.mask.test( textContent ) 78 83 } 79 84 … … 84 89 // Get cursor position in textContent (without tags): needed for further cursor repositioning 85 90 selectionStart = getSelectionStart() 86 87 91 cursorPosition = selectionStart?.offset || document.getSelection()?.anchorOffset || 0 88 92 … … 91 95 92 96 // If the rule depends on previous characters, we need to separate the string taking those characters into account 93 const captureGroups = textContent.match( r eg.mask )97 const captureGroups = textContent.match( rule.mask ) 94 98 95 99 if( null === captureGroups || 0 === captureGroups.length ) return … … 104 108 // it means that a character has been typed uncorrected voluntarily before with CTRL Z/CMD Z 105 109 // so it should not be taken into account 106 isConcerned = r eg.mask.test( textContent ) && reg.mask.test( lastPart )110 isConcerned = rule.mask.test( textContent ) && rule.mask.test( lastPart ) 107 111 } 108 112 109 113 // Stop correction if block content isn't concerned by the regex 110 114 if ( ! isConcerned ) return 111 115 112 116 // Pairing characters need specific process for the replacement 113 if ( regDealWithPair( r eg) ) {114 replaceWithThis = getReplacementStringForPairs( r eg, blockContent, replaceWithThis )117 if ( regDealWithPair( rule ) ) { 118 replaceWithThis = getReplacementStringForPairs( rule, blockContent, replaceWithThis ) 115 119 } 116 120 117 121 // Concat strings 118 122 if ( 0 !== cursorPositionInsideHTML ) { 119 blockContent = firstPart + lastPart.replace( r eg.mask, replaceWithThis )123 blockContent = firstPart + lastPart.replace( rule.mask, replaceWithThis ) 120 124 } 121 125 122 126 // Pasted content innerBlocks case: no selection, no cursor position so the whole block is fixed 123 127 if ( 0 === cursorPositionInsideHTML ) { 124 blockContent = blockContent.replace( r eg.mask, reg.replace )128 blockContent = blockContent.replace( rule.mask, rule.replace ) 125 129 } 126 130 … … 130 134 return 131 135 } 132 136 133 137 // Update block text content if previous fix was not canceled 134 if ( ! isPreviousFixCanceled ) {138 if ( ! isPreviousFixCanceled && rule.format === '' ) { 135 139 contentUpdated = updateBlockTextContent( { block, currentBlockId, blockAttributes, blockContent } ) 136 140 } 141 142 // Apply superscript Format to the replaced string for specific rules 143 // if ( ['ordinalNumberSuffix'].includes( rule.slug ) ) { 144 // contentUpdated = true 145 146 // const startPos = cursorPosition - 3 147 // const endPos = cursorPosition - 1 148 // const newFormat = applyFormat( 149 // richTextValueObject, 150 // { type: 'superscript' }, 151 // startPos, 152 // endPos 153 // ) 154 // const newAttributes = { 155 // ...blockAttributes, 156 // ...newFormat, 157 // } 158 159 // // updateBlock( currentBlockId, { 160 // // ...block, 161 // // attributes: { ...blockAttributes, newAttributes } 162 // // } ) 163 // } 137 164 138 165 // Get the number of characters moved by the replacement: needed for cursor repositioning. 139 166 // If the number depends on the replaced string length, we use a function to get it 140 const nbMoved = typeof r eg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved || 0167 const nbMoved = typeof rule.nbMoved === 'function' ? rule.nbMoved( lastPart ) : rule.nbMoved || 0 141 168 142 169 // Set the cursor offset … … 182 209 } 183 210 184 Object.entries( localizedRules ).forEach( ( [ _, r eg] ) => {211 Object.entries( localizedRules ).forEach( ( [ _, rule ] ) => { 185 212 186 213 // If the rule is a pair rule, we use a specific regex 187 if ( pairedCharacterSlugs.includes( r eg.slug ) ) {188 const singleCharacterOfPair = r eg.mask.toString().match( /(?<=\/).+?(?=\/)/g )[0]214 if ( pairedCharacterSlugs.includes( rule.slug ) ) { 215 const singleCharacterOfPair = rule.mask.toString().match( /(?<=\/).+?(?=\/)/g )[0] 189 216 const realReg = new RegExp( `(?<!\=)${singleCharacterOfPair}(?!>)([^${singleCharacterOfPair}]*)(?<!\=)${singleCharacterOfPair}(?!>)`, 'g' ) 190 newContent = newContent.replaceAll( realReg, r eg.replace )217 newContent = newContent.replaceAll( realReg, rule.replace ) 191 218 } 192 219 193 220 // If the rule is not a pair rule, we use the regex as it is 194 if ( ! pairedCharacterSlugs.includes( r eg.slug ) ) {195 const stringRegex = r eg.mask.toString()221 if ( ! pairedCharacterSlugs.includes( rule.slug ) ) { 222 const stringRegex = rule.mask.toString() 196 223 const regWithGlobalFlag = new RegExp( stringRegex.substring( 1, stringRegex.length - 1 ), 'g' ) 197 newContent = newContent.replaceAll( regWithGlobalFlag, r eg.replace )224 newContent = newContent.replaceAll( regWithGlobalFlag, rule.replace ) 198 225 } 199 226 -
consistency/tags/1.8.2/src/app/helpers.js
r3145550 r3184822 7 7 8 8 import { select, dispatch } from '@wordpress/data' 9 const { get Block, getBlocks, getBlockAttributes, getSelectionStart, isTyping} = select( 'core/block-editor' )10 const { selectionChange , updateBlockAttributes} = dispatch( 'core/block-editor' )9 const { getSelectionStart } = select( 'core/block-editor' ) 10 const { selectionChange } = dispatch( 'core/block-editor' ) 11 11 12 12 /** … … 25 25 * left and right separators are optionals 26 26 * 27 * @param {object} r egReplacement parameters27 * @param {object} rule Replacement parameters 28 28 * @param {string} fullBlockContent Full block string 29 29 * @param {string} replaceWithThis Replacement string 30 30 * @return {string} replaceWithThis Replacement string 31 31 */ 32 export const getReplacementStringForPairs = ( r eg, fullBlockContent, replaceWithThis ) => {32 export const getReplacementStringForPairs = ( rule, fullBlockContent, replaceWithThis ) => { 33 33 34 34 // Get the opening and closing characters of the pair 35 const openPairChar = r eg.replace.charAt( 0 )36 const closPairChar = r eg.replace.charAt( reg.replace.length - 1 )35 const openPairChar = rule.replace.charAt( 0 ) 36 const closPairChar = rule.replace.charAt( rule.replace.length - 1 ) 37 37 38 38 // Get left separator and right separators 39 const leftSep = r eg.replace.substring( 1, reg.replace.indexOf( '$' ) ) || ''39 const leftSep = rule.replace.substring( 1, rule.replace.indexOf( '$' ) ) || '' 40 40 41 41 let rightSep = '' 42 if ( 0 !== [ ...r eg.replace.matchAll( /[0-9]/g ) ].length ) {42 if ( 0 !== [ ...rule.replace.matchAll( /[0-9]/g ) ].length ) { 43 43 // Right separator begins after last number from last capturing group 44 rightSep = r eg.replace.substring( [ ...reg.replace.matchAll( /[0-9]/g ) ].pop()['index'] + 1, reg.replace.length -1 )44 rightSep = rule.replace.substring( [ ...rule.replace.matchAll( /[0-9]/g ) ].pop()['index'] + 1, rule.replace.length -1 ) 45 45 } 46 46 … … 80 80 export const getLocalizedRules = () => { 81 81 82 const localizedRules = rules.filter( r eg => true === getLocalizedRuleSettings()?.find( s => s.slug === reg.slug )?.value )82 const localizedRules = rules.filter( rule => true === getLocalizedRuleSettings()?.find( s => s.slug === rule.slug )?.value ) 83 83 84 84 return localizedRules … … 95 95 96 96 const selection = window.getSelection() 97 98 const selectionStart = getSelectionStart() 97 99 98 100 // Stop here if no selection or if the selection anchor node is null … … 101 103 // Get current cursor position 102 104 let cursorPosition 105 106 // window getSelection doesn't have what we need. Probably RichText case 107 if ( selection.anchorNode === null ) { 108 109 if ( selectionStart === null || selectionStart?.clientId === null ) { 110 return 111 } 112 113 cursorPosition = selectionStart?.offset || 0 114 selectionChange( selectionStart.clientId, selectionStart.attributeKey, cursorPosition + cursorOffset, cursorPosition + cursorOffset ) 115 return 116 } 103 117 104 118 // Element node case: we need to get the first text node from the element node … … 114 128 // If the cursorOffset is positive, newPosition equals cursorPosition + cursorOffset, else newPosition equals cursorPosition 115 129 const newPosition = cursorOffset >= 0 ? cursorPosition + cursorOffset : cursorPosition 116 130 117 131 // Element node 118 132 if ( selection?.anchorNode?.nodeType === 1 ) { -
consistency/tags/1.8.2/src/app/utils.js
r3142172 r3184822 29 29 * @returns {string} The extracted text content. 30 30 */ 31 export const getOnlyTextFromBlockContent = blockContent => {31 export const removeHTMLTagsFromBlockContent = blockContent => { 32 32 33 33 // Remove 'code' 'pre' and 'kbd' tags from block content -
consistency/tags/1.8.2/src/config/rules.js
r3142172 r3184822 21 21 mask: /\'/, // mask 22 22 replace: '’', // replacement string 23 format: '', // format to apply 23 24 nbMoved: 0, // number of characters less or more during replacement 24 25 category: 'apostrophe' // category of the setting … … 32 33 mask: /(?:\-)\-/, 33 34 replace: '–', 35 format: '', 34 36 nbMoved: -1, 35 37 category: 'dash' … … 43 45 mask: /(?:\–|\-\-)\-/, 44 46 replace: '—', 47 format: '', 45 48 nbMoved: lastPart => { 46 49 // Since we replace the string with a symbol, we must move the cursor to the left by the length of the replaced string minus 1 (1 for the symbol itself) … … 57 60 mask: /(?:\—|\–\-|\-\-\-)\-/, 58 61 replace: '⸺', 62 format: '', 59 63 nbMoved: lastPart => { 60 64 // Since we replace the string with a symbol, we must move the cursor to the left by the length of the replaced string minus 1 (1 for the symbol itself) … … 70 74 + `<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>`, 71 75 mask: /([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/, 72 replace: '$1<sup>$2<\/sup>$3', 76 replace: '$1$2$3', 77 format: 'superscript', 73 78 nbMoved: 0, 74 79 category: 'suffixe' … … 82 87 mask: /"/, // specific mask with specific process 83 88 replace: '“$1”', 89 format: '', 84 90 nbMoved: 0, 85 91 category: 'quotation' … … 93 99 mask: /"/, // specific mask with specific process 94 100 replace: '„$1“', 101 format: '', 95 102 nbMoved: 0, 96 103 category: 'quotation' … … 104 111 mask: /"/, // specific mask with specific process 105 112 replace: '»$1«', 113 format: '', 106 114 nbMoved: 0, 107 115 category: 'quotation' … … 115 123 mask: /"/, // specific mask with specific process 116 124 replace: '« $1 »', 125 format: '', 117 126 nbMoved: 1, 118 127 category: 'quotation' … … 126 135 mask: /"/, // specific mask with specific process 127 136 replace: '«$1»', 137 format: '', 128 138 nbMoved: 0, 129 139 category: 'quotation' … … 137 147 mask: /“.*?”/, // specific mask with specific process 138 148 replace: matched => { return `« ${matched.substring( 1, matched.length - 1 )} »` }, 149 format: '', 139 150 nbMoved: 0, 140 151 category: 'quotation' … … 148 159 mask: / ([\?|\!|\:|\;|\»|\€|\$|\£|\¥|\₽|\元|\%])/, 149 160 replace: ' $1', 161 format: '', 150 162 nbMoved: 0, 151 163 category: 'space' … … 159 171 mask: /(?<! | | )([\?|\!|\:|\»|\€|\$|\£|\¥|\₽|\元|\%])/, 160 172 replace: ' $1', 173 format: '', 161 174 nbMoved: 1, 162 175 category: 'space' … … 170 183 mask: /([ | ])(?=[\?|\!|\:|\;|\%])(.)/, 171 184 replace: '$2', 185 format: '', 172 186 nbMoved: -1, 173 187 category: 'space' … … 181 195 mask: /([\,|\…|\)|\]])(?! | |\.|\,|\d|$)(.)/, 182 196 replace: '$1 $2', 197 format: '', 183 198 nbMoved: 1, 184 199 category: 'space' … … 191 206 mask: /(«)(?! | | )/, 192 207 replace: '$1 ', 208 format: '', 193 209 nbMoved: 0, 194 210 category: 'space' … … 201 217 mask: /(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|\…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/, 202 218 replace: matched => matched.toUpperCase(), 219 format: '', 203 220 nbMoved: 0, 204 221 category: 'case' … … 212 229 mask: /etc(\.{3})/i, 213 230 replace: matched => { return matched.substring(0, 3) + '.' }, 231 format: '', 214 232 nbMoved: -2, 215 233 category: 'ellipsis' … … 223 241 mask: /etc(\.{2})/i, 224 242 replace: matched => { return matched.substring(0, 2) + '.' }, 243 format: '', 225 244 nbMoved: -1, 226 245 category: 'ellipsis' … … 234 253 mask: /etc(\.{3}|…)/i, 235 254 replace: matched => { return matched.substring(0, 3) + '.' }, 255 format: '', 236 256 nbMoved: 0, 237 257 category: 'ellipsis' … … 245 265 mask: /\.{3}/, 246 266 replace: '…', 267 format: '', 247 268 nbMoved: -2, 248 269 category: 'ellipsis' … … 266 287 return ' ' 267 288 }, 289 format: '', 268 290 nbMoved: -2, 269 291 category: 'symbol' … … 290 312 } 291 313 }, 314 format: '', 292 315 nbMoved: -1, 293 316 category: 'symbol' … … 340 363 } 341 364 }, 365 format: '', 342 366 nbMoved: -2, 343 367 category: 'symbol' … … 364 388 } 365 389 }, 390 format: '', 366 391 nbMoved: lastPart => { 367 392 // We remove the last character of the string because the regex check the character after the string to replace -
consistency/trunk/build/index.asset.php
r3145550 r3184822 1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => ' ab0245b936622e6790c8');1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => '71c2764f0435ef4fe22c'); -
consistency/trunk/build/index.js
r3145550 r3184822 1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]), p=(0,c.useRef)(0),d=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:p,isContentPastedRef:d}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),f=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof f.RichTextData,{getEntityRecord:w}=(0,p.select)("core"),{updateBlock:v}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | | )/,replace:"$1 ",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],{getBlock:F,getBlocks:P,getBlockAttributes:R,getSelectionStart:Q,isTyping:W}=(0,p.select)("core/block-editor"),{selectionChange:M,updateBlockAttributes:$}=(0,p.dispatch)("core/block-editor"),A=()=>{const e=(()=>{const e=w("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>O(e.slug))):e},N=()=>B.filter((e=>!0===A()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:q,getBlockAttributes:z}=(0,p.select)("core/block-editor"),O=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},I=e=>{const t=E.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>A()?.find((t=>t.slug===e))?.value))},D=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!O(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:I(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},L=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],G=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...L].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)(D,{key:s,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:j}=(0,p.select)("core"),U=()=>{const e=j("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(G,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:H,getBlocks:K,getBlockAttributes:J,getSelectionStart:V,isTyping:X}=(0,p.select)("core/block-editor"),{updateBlockAttributes:Y}=(0,p.dispatch)("core/block-editor"),Z=e=>{const{currentBlockId:t,isPreviousFixCanceled:s,setPreviousFixCanceled:n,blocksToBeProcessed:o,cursorOffsetRef:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=q(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:o})||!(e=>{const t=z(e);return!(!t||!t.hasOwnProperty("content")||!_(t.content)&&!k(t.content))})(t))return;let r=N();const a=H(t);let i=J(t),l=!1;Object.entries(r).forEach((([e,o])=>{if(l)return;let r,u=o.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(X()||(b=o.mask.test(h)),X()){r=V(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/ /g)||[]).length;return l>0&&(i=a.replace(/ /g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(o.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=o.mask.test(h)&&o.mask.test(d)}if(!b)return;if((e=>!!T.includes(e.slug))(o)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(o,m)),0!==y&&(m=p+d.replace(o.mask,u)),0===y&&(m=m.replace(o.mask,o.replace)),s)return void n(!1);s||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,f.create)({...n.content,text:o});c=new f.RichTextData(e)}return _(n.content)&&(c=o),void 0!==c&&(v(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m}));const w="function"==typeof o.nbMoved?o.nbMoved(d):o.nbMoved||0;l&&(c.current=w)}))},{getSelectedBlockClientId:ee,isTyping:te,getBlockAttributes:se}=(0,p.select)("core/block-editor"),ne=window.wp.blocks,oe=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,ne.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));const s=["core/html"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Blocks that can be processed:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,cursorOffsetRef:r,isContentPastedRef:a}=(0,c.useContext)(i);r.current=r.current||0,a.current=a.current||!1,(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:i}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=w("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!i)return;if(void 0===A())return;if(i&&!0===a.current)return a.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o}=e;let c=N();const r=K(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return n.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(T.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!T.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&Y(Object.keys(i),i,!0),a.forEach((e=>{if(!n.includes(e.name))return;const c=e.clientId;e?.clientId&&Z({currentBlockId:c,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r});const l=ee();if(null===l||!c)return;const u=se(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),te()&&Z({currentBlockId:l,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r})))}));return()=>{c(),(e=>{const t=window.getSelection();if(!t)return;let s;1===t?.anchorNode?.nodeType&&(s=t.anchorNode?.firstChild?.length||0),3===t?.anchorNode?.nodeType&&(s=t.anchorOffset||0);const n=e>=0?s+e:s;if(1!==t?.anchorNode?.nodeType)if(3!==t?.anchorNode?.nodeType);else{const e=t.anchorNode;t.collapse(e,n)}else{const e=t.anchorNode?.firstChild||t.anchorNode?.childNodes[0];t.collapse(e,n)}})(r.current),r.current=0}}),[e,t,s,n,o,r,a])})(),(0,t.createElement)(U,null)),ce=()=>(0,t.createElement)(a,null,(0,t.createElement)(oe,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ce})}))})();1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),d=(0,c.useRef)(0),p=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:d,isContentPastedRef:p}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,d=window.wp.data,p=window.wp.components,y=()=>(0,t.createElement)(p.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),g=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,d.useSelect)((e=>({currentUser:e(g.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,g.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,d.useDispatch)(g.store),{createNotice:y}=(0,d.useDispatch)(m.store);return(0,t.createElement)(p.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),y((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},f=()=>(0,t.createElement)(p.Panel,{className:"UserSettingPanel"},(0,t.createElement)(p.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(p.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(p.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),b=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof b.RichTextData,{getEntityRecord:w}=(0,d.select)("core"),{updateBlock:v}=(0,d.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",format:"",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",format:"",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",format:"",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",format:"",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1$2$3",format:"superscript",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",format:"",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",format:"",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",format:"",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",format:"",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",format:"",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,format:"",nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",format:"",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",format:"",nbMoved:1,category:"space"},{slug:"spaceBefore",name:(0,l.__)("Space Before","consistency"),description:(0,l.__)("Remove any space preceding a character from this list:","consistency")+"<span style='display:block;'><code>? ! : ; %</code></span>",mask:/([ | ])(?=[\?|\!|\:|\;|\%])(.)/,replace:"$2",format:"",nbMoved:-1,category:"space"},{slug:"noBreakingSpaceAfter",name:(0,l.__)("No Breaking Space After","consistency"),description:sprintf((0,l.__)("Add a breaking space after a character from this list:%1$s when followed with another character","consistency"),"<br /><code>, … ) ]</code><br />"),mask:/([\,|…|\)|\]])(?! | |\.|\,|\d|$)(.)/,replace:"$1 $2",format:"",nbMoved:1,category:"space"},{slug:"noNonBreakingSpaceAfter",name:(0,l.__)("No Non-Breaking Space After","consistency"),description:(0,l.__)("Add a non-breaking space after open french quote having no space after","consistency"),mask:/(«)(?! | | )/,replace:"$1 ",format:"",nbMoved:0,category:"space"},{slug:"capitalizeFirstSentenceLetter",name:(0,l.__)("First Sentence Letter","consistency"),description:(0,l.__)("Capitalize the first letter of a sentence","consistency"),mask:/(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/,replace:e=>e.toUpperCase(),format:"",nbMoved:0,category:"case"},{slug:"etcThreeDots",name:(0,l.__)('Three Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 3 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc...</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3})/i,replace:e=>e.substring(0,3)+".",format:"",nbMoved:-2,category:"ellipsis"},{slug:"etcTwoDots",name:(0,l.__)('Two Dots Following "etc"',"consistency"),description:(0,l.__)('Replace 2 dots placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc..</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{2})/i,replace:e=>e.substring(0,2)+".",format:"",nbMoved:-1,category:"ellipsis"},{slug:"etcEllipsis",name:(0,l.__)('Ellipsis Following "etc"',"consistency"),description:(0,l.__)('Replace the ellipsis placed after the abbreviation "etc" with a period:',"consistency")+"<span aria-hidden='true' style='display:block;'><code>etc…</code> <span style='font-size:20px'>→</span> <code>etc.</code></span>",mask:/etc(\.{3}|…)/i,replace:e=>e.substring(0,3)+".",format:"",nbMoved:0,category:"ellipsis"},{slug:"ellipsis",name:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Replaces 3 dots with ellipsis:","consistency")+"<span aria-hidden='true' style='display:block;'><code>...</code> <span style='font-size:20px'>→</span> <code>…</code></span>",mask:/\.{3}/,replace:"…",format:"",nbMoved:-2,category:"ellipsis"},{slug:"symbolInACircle",name:(0,l.__)("Symbol in a Circle","consistency"),description:(0,l.__)("Replaces 1 character placed in parentheses with a symbol","consistency")+"<span aria-hidden='true' style='display:block;'><code>(c) (p) (r)</code> <span style='font-size:20px'>→</span> <code>© ℗ ®</code></span>",mask:/(\([c|p|r])(\))/,replace:e=>{switch(e[1]){case"c":return"©";case"p":return"℗";case"r":return"®"}return" "},format:"",nbMoved:-2,category:"symbol"},{slug:"symbolInSmallCapsAndSuperscriptStyle",name:(0,l.__)("Symbol in Small Caps and Superscript Style","consistency"),description:(0,l.__)("Replaces 2-character abbreviations with a symbol in small caps and superscript style","consistency")+"<span aria-hidden='true' style='display:block;'><code>tm sm md mc</code> <span style='font-size:20px'>→</span> <code>™ ℠ 🅫 🅪</code></span>",mask:/(?<= | |\(|\[|\{|:|^)(tm|sm|md|mc)(?= | |\.|\,|\;|\:|\)|\]|\}|$)/,replace:e=>{switch(e){case"tm":return"™";case"sm":return"℠";case"md":return"🅫";case"mc":return"🅪";default:return" "}},format:"",nbMoved:-1,category:"symbol"},{slug:"fractions",name:(0,l.__)("Fractions","consistency"),description:(0,l.__)("Replaces fractions with fraction symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>1/2 3/5 1/9</code> <span style='font-size:20px'>→</span> <code>½ ⅗ ⅑</code></span>",mask:/[1-9]\/[1-9]/,replace:e=>{switch(e){case"1/4":return"¼";case"1/2":return"½";case"3/4":return"¾";case"1/3":return"⅓";case"2/3":return"⅔";case"1/5":return"⅕";case"2/5":return"⅖";case"3/5":return"⅗";case"4/5":return"⅘";case"1/6":return"⅙";case"5/6":return"⅚";case"1/8":return"⅛";case"3/8":return"⅜";case"5/8":return"⅝";case"7/8":return"⅞";case"1/7":return"⅐";case"1/9":return"⅑";default:return" "}},format:"",nbMoved:-2,category:"symbol"},{slug:"percentages",name:(0,l.__)("Percentages","consistency"),description:(0,l.__)("Replaces percentages with percentages symbols:","consistency")+"<span aria-hidden='true' style='display:block;'><code>0/0 0/00 0/000</code> <span style='font-size:20px'>→</span> <code>% ‰ ‱</code></span>",mask:/(0\/0|0\/00|0\/000)(?= | |\.|\,|\;|\:|\)|\]|\})(.)/,replace:e=>{const t=e.substring(0,e.length-1),s=e.substring(e.length-1,e.length);switch(t){case"0/0":return"%"+s;case"0/00":return"‰"+s;case"0/000":return"‱"+s;default:return" "+s}},format:"",nbMoved:e=>-(e.substring(0,e.length-1).length-1),category:"symbol"}],{getSelectionStart:F}=(0,d.select)("core/block-editor"),{selectionChange:P}=(0,d.dispatch)("core/block-editor"),R=()=>{const e=(()=>{const e=w("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>$(e.slug))):e},Q=()=>B.filter((e=>!0===R()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:W,getBlockAttributes:M}=(0,d.select)("core/block-editor"),$=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},N=e=>{const t=E.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>R()?.find((t=>t.slug===e))?.value))},q=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,d.useDispatch)(m.store);if(S()&&!$(s))return"";const[r,a]=(0,g.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,d.useDispatch)(g.store);return(0,t.createElement)(p.PanelRow,null,(0,t.createElement)(p.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:N(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},A=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],z=()=>(0,t.createElement)(p.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(p.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...A].map(((e,s)=>(0,t.createElement)(p.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)(q,{key:s,settingSlug:e.slug,settingName:e.name,settingDescription:{__html:e.description}}))))))),{canUser:I}=(0,d.select)("core"),O=()=>{const e=I("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:y},(0,t.createElement)(f,null),e&&(0,t.createElement)(z,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:D,getBlocks:L,getBlockAttributes:G,getSelectionStart:j,isTyping:U}=(0,d.select)("core/block-editor"),{updateBlockAttributes:H,updateBlock:K}=(0,d.dispatch)("core/block-editor"),J=e=>{const{currentBlockId:t,isPreviousFixCanceled:s,setPreviousFixCanceled:n,blocksToBeProcessed:o,cursorOffsetRef:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=W(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:o})||!(e=>{const t=M(e);return!(!t||!t.hasOwnProperty("content")||!_(t.content)&&!k(t.content))})(t))return;let r=Q();const a=D(t);let i=G(t),l=!1;Object.entries(r).forEach((([e,o])=>{if(l)return;if(""!==o.format)return;i.content;let r,u=o.replace,d="",p="",y=0,g=0,m=("object"==typeof i.content&&i.content,"object"==typeof i.content?i.content.text:i.content),h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),f=!1;if(U()||(f=o.mask.test(h)),U()){r=j(),y=r?.offset||document.getSelection()?.anchorOffset||0,g=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/ /g)||[]).length;return l>0&&(i=a.replace(/ /g," ").indexOf("\0"),i=i-6*l+l),i})(t)||y;const e=h.match(o.mask);if(null===e||0===e.length)return;const s=e[0].length||1;d=h.substring(0,g-s),p=h.substring(g-s,h.length),f=o.mask.test(h)&&o.mask.test(p)}if(!f)return;if((e=>!!T.includes(e.slug))(o)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(o,m)),0!==g&&(m=d+p.replace(o.mask,u)),0===g&&(m=m.replace(o.mask,o.replace)),s)return void n(!1);s||""!==o.format||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,b.create)({...n.content,text:o});c=new b.RichTextData(e)}return _(n.content)&&(c=o),void 0!==c&&(v(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m}));const w="function"==typeof o.nbMoved?o.nbMoved(p):o.nbMoved||0;l&&(c.current=w)}))},{getSelectedBlockClientId:V,isTyping:X,getBlockAttributes:Y}=(0,d.select)("core/block-editor"),Z=window.wp.blocks,ee=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,Z.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));const s=["core/html"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Blocks that can be processed:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,cursorOffsetRef:r,isContentPastedRef:a}=(0,c.useContext)(i);r.current=r.current||0,a.current=a.current||!1,(0,c.useEffect)((()=>{const c=(0,d.subscribe)((()=>{const{onTheFly:c,onPaste:i}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,d.select)(g.store).getCurrentUser(),s=w("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!i)return;if(void 0===R())return;if(i&&!0===a.current)return a.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o}=e;let c=Q();const r=L(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return n.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(T.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!T.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&H(Object.keys(i),i,!0),a.forEach((e=>{if(!n.includes(e.name))return;const c=e.clientId;e?.clientId&&J({currentBlockId:c,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:n,cursorOffsetRef:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r});const l=V();if(null===l||!c)return;const u=Y(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),X()&&J({currentBlockId:l,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o,cursorOffsetRef:r})))}));return()=>{c(),(e=>{const t=window.getSelection(),s=F();if(!t)return;let n;if(null===t.anchorNode){if(null===s||null===s?.clientId)return;return n=s?.offset||0,void P(s.clientId,s.attributeKey,n+e,n+e)}1===t?.anchorNode?.nodeType&&(n=t.anchorNode?.firstChild?.length||0),3===t?.anchorNode?.nodeType&&(n=t.anchorOffset||0);const o=e>=0?n+e:n;if(1!==t?.anchorNode?.nodeType)if(3!==t?.anchorNode?.nodeType);else{const e=t.anchorNode;t.collapse(e,o)}else{const e=t.anchorNode?.firstChild||t.anchorNode?.childNodes[0];t.collapse(e,o)}})(r.current),r.current=0}}),[e,t,s,n,o,r,a])})(),(0,t.createElement)(O,null)),te=()=>(0,t.createElement)(a,null,(0,t.createElement)(ee,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:te})}))})(); -
consistency/trunk/consistency.php
r3145550 r3184822 4 4 * Plugin URI: https://www.webaxones.com 5 5 * Description: Fixes typographic and punctuation consistency 6 * Version: 1.8. 16 * Version: 1.8.2 7 7 * Requires at least: 6.1 8 8 * Requires PHP: 7.4 -
consistency/trunk/includes/Plugin.php
r3145550 r3184822 33 33 protected static function setConstants(): void 34 34 { 35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8. 1' );35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.2' ); 36 36 defined( __NAMESPACE__ . '\PLUGIN_URL' ) || define( __NAMESPACE__ . '\PLUGIN_URL', plugin_dir_url( __DIR__ ) ); 37 37 defined( __NAMESPACE__ . '\PLUGIN_PATH' ) || define( __NAMESPACE__ . '\PLUGIN_PATH', plugin_dir_path( __DIR__ ) ); -
consistency/trunk/package.json
r3145550 r3184822 1 1 { 2 2 "name": "consistency", 3 "version": "1.8. 1",3 "version": "1.8.2", 4 4 "description": "", 5 5 "main": "index.js", -
consistency/trunk/readme.txt
r3145550 r3184822 3 3 Tags: punctuation, typography, block editor, gutenberg 4 4 Requires at least: 6.1 5 Tested up to: 6. 66 Stable tag: 1.8. 15 Tested up to: 6.7 6 Stable tag: 1.8.2 7 7 Requires PHP: 7.4 8 8 License: GPL-3.0-or-later … … 70 70 == Changelog == 71 71 72 = 1.8.2 = 73 * Fix: Fix cursor repositionning which was buggy since wp6.6 74 * Fix: Disable number suffix correction while waiting to recode it using formats 75 * Add: Indicate compatibility with WordPress 6.7 76 72 77 = 1.8.1 = 73 78 * Fix: Resolves incompatibilities with block plugins such as Kadence, GeneratePress, etc. -
consistency/trunk/src/app/checks.js
r3145550 r3184822 82 82 * Checks if the regex processes a pair 83 83 * 84 * @param {string} r egregex84 * @param {string} rule regex 85 85 * @return {boolean} Does the regex process a pair? 86 86 */ 87 export const regDealWithPair = r eg=> {87 export const regDealWithPair = rule => { 88 88 89 if ( pairedCharacterSlugs.includes( r eg.slug ) ) {89 if ( pairedCharacterSlugs.includes( rule.slug ) ) { 90 90 return true 91 91 } -
consistency/trunk/src/app/fixes.js
r3145550 r3184822 10 10 */ 11 11 import { select, dispatch } from '@wordpress/data' 12 import { applyFormat } from '@wordpress/rich-text' 12 13 13 14 /** 14 15 * External dependencies 15 16 */ 16 import { getAllInnersFromParents, getOnlyTextFromBlockContent, getCursorPositionInInnerHTML } from './utils'17 import { getAllInnersFromParents, removeHTMLTagsFromBlockContent, getCursorPositionInInnerHTML } from './utils' 17 18 import { getReplacementStringForPairs, getLocalizedRules } from './helpers' 18 19 import { updateBlockTextContent } from './data' … … 21 22 22 23 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' ) 23 const { updateBlockAttributes } = dispatch( 'core/block-editor' )24 const { updateBlockAttributes, updateBlock } = dispatch( 'core/block-editor' ) 24 25 25 26 … … 54 55 55 56 // Loop on localized rules to check if the block content matches one regex 56 Object.entries( localizedRules ).forEach( ( [ _, r eg] ) => {57 Object.entries( localizedRules ).forEach( ( [ _, rule ] ) => { 57 58 58 59 // Stop correction if block content has already been updated 59 60 if ( contentUpdated ) return 60 61 61 let replaceWithThis = reg.replace 62 if ( rule.format !== '' ) return 63 64 const isRichTextValueObject = ( typeof blockAttributes.content === 'object' ) 65 66 let replaceWithThis = rule.replace 62 67 let firstPart = '' 63 68 let lastPart = '' … … 65 70 let cursorPositionInsideHTML = 0 66 71 let selectionStart 67 72 let richTextValueObject = ( typeof blockAttributes.content === 'object' ) ? blockAttributes.content : {} 68 73 let blockContent = ( typeof blockAttributes.content === 'object' ) ? blockAttributes.content.text : blockAttributes.content 69 74 70 75 // Remove 'code' 'pre' and 'kbd' and other HTML tags from block content 71 let textContent = getOnlyTextFromBlockContent( blockContent )76 let textContent = removeHTMLTagsFromBlockContent( blockContent ) 72 77 73 78 // Check if the block's text content matches the regex in the case of pasted content … … 75 80 let isConcerned = false 76 81 if ( ! isTyping() ) { 77 isConcerned = r eg.mask.test( textContent )82 isConcerned = rule.mask.test( textContent ) 78 83 } 79 84 … … 84 89 // Get cursor position in textContent (without tags): needed for further cursor repositioning 85 90 selectionStart = getSelectionStart() 86 87 91 cursorPosition = selectionStart?.offset || document.getSelection()?.anchorOffset || 0 88 92 … … 91 95 92 96 // If the rule depends on previous characters, we need to separate the string taking those characters into account 93 const captureGroups = textContent.match( r eg.mask )97 const captureGroups = textContent.match( rule.mask ) 94 98 95 99 if( null === captureGroups || 0 === captureGroups.length ) return … … 104 108 // it means that a character has been typed uncorrected voluntarily before with CTRL Z/CMD Z 105 109 // so it should not be taken into account 106 isConcerned = r eg.mask.test( textContent ) && reg.mask.test( lastPart )110 isConcerned = rule.mask.test( textContent ) && rule.mask.test( lastPart ) 107 111 } 108 112 109 113 // Stop correction if block content isn't concerned by the regex 110 114 if ( ! isConcerned ) return 111 115 112 116 // Pairing characters need specific process for the replacement 113 if ( regDealWithPair( r eg) ) {114 replaceWithThis = getReplacementStringForPairs( r eg, blockContent, replaceWithThis )117 if ( regDealWithPair( rule ) ) { 118 replaceWithThis = getReplacementStringForPairs( rule, blockContent, replaceWithThis ) 115 119 } 116 120 117 121 // Concat strings 118 122 if ( 0 !== cursorPositionInsideHTML ) { 119 blockContent = firstPart + lastPart.replace( r eg.mask, replaceWithThis )123 blockContent = firstPart + lastPart.replace( rule.mask, replaceWithThis ) 120 124 } 121 125 122 126 // Pasted content innerBlocks case: no selection, no cursor position so the whole block is fixed 123 127 if ( 0 === cursorPositionInsideHTML ) { 124 blockContent = blockContent.replace( r eg.mask, reg.replace )128 blockContent = blockContent.replace( rule.mask, rule.replace ) 125 129 } 126 130 … … 130 134 return 131 135 } 132 136 133 137 // Update block text content if previous fix was not canceled 134 if ( ! isPreviousFixCanceled ) {138 if ( ! isPreviousFixCanceled && rule.format === '' ) { 135 139 contentUpdated = updateBlockTextContent( { block, currentBlockId, blockAttributes, blockContent } ) 136 140 } 141 142 // Apply superscript Format to the replaced string for specific rules 143 // if ( ['ordinalNumberSuffix'].includes( rule.slug ) ) { 144 // contentUpdated = true 145 146 // const startPos = cursorPosition - 3 147 // const endPos = cursorPosition - 1 148 // const newFormat = applyFormat( 149 // richTextValueObject, 150 // { type: 'superscript' }, 151 // startPos, 152 // endPos 153 // ) 154 // const newAttributes = { 155 // ...blockAttributes, 156 // ...newFormat, 157 // } 158 159 // // updateBlock( currentBlockId, { 160 // // ...block, 161 // // attributes: { ...blockAttributes, newAttributes } 162 // // } ) 163 // } 137 164 138 165 // Get the number of characters moved by the replacement: needed for cursor repositioning. 139 166 // If the number depends on the replaced string length, we use a function to get it 140 const nbMoved = typeof r eg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved || 0167 const nbMoved = typeof rule.nbMoved === 'function' ? rule.nbMoved( lastPart ) : rule.nbMoved || 0 141 168 142 169 // Set the cursor offset … … 182 209 } 183 210 184 Object.entries( localizedRules ).forEach( ( [ _, r eg] ) => {211 Object.entries( localizedRules ).forEach( ( [ _, rule ] ) => { 185 212 186 213 // If the rule is a pair rule, we use a specific regex 187 if ( pairedCharacterSlugs.includes( r eg.slug ) ) {188 const singleCharacterOfPair = r eg.mask.toString().match( /(?<=\/).+?(?=\/)/g )[0]214 if ( pairedCharacterSlugs.includes( rule.slug ) ) { 215 const singleCharacterOfPair = rule.mask.toString().match( /(?<=\/).+?(?=\/)/g )[0] 189 216 const realReg = new RegExp( `(?<!\=)${singleCharacterOfPair}(?!>)([^${singleCharacterOfPair}]*)(?<!\=)${singleCharacterOfPair}(?!>)`, 'g' ) 190 newContent = newContent.replaceAll( realReg, r eg.replace )217 newContent = newContent.replaceAll( realReg, rule.replace ) 191 218 } 192 219 193 220 // If the rule is not a pair rule, we use the regex as it is 194 if ( ! pairedCharacterSlugs.includes( r eg.slug ) ) {195 const stringRegex = r eg.mask.toString()221 if ( ! pairedCharacterSlugs.includes( rule.slug ) ) { 222 const stringRegex = rule.mask.toString() 196 223 const regWithGlobalFlag = new RegExp( stringRegex.substring( 1, stringRegex.length - 1 ), 'g' ) 197 newContent = newContent.replaceAll( regWithGlobalFlag, r eg.replace )224 newContent = newContent.replaceAll( regWithGlobalFlag, rule.replace ) 198 225 } 199 226 -
consistency/trunk/src/app/helpers.js
r3145550 r3184822 7 7 8 8 import { select, dispatch } from '@wordpress/data' 9 const { get Block, getBlocks, getBlockAttributes, getSelectionStart, isTyping} = select( 'core/block-editor' )10 const { selectionChange , updateBlockAttributes} = dispatch( 'core/block-editor' )9 const { getSelectionStart } = select( 'core/block-editor' ) 10 const { selectionChange } = dispatch( 'core/block-editor' ) 11 11 12 12 /** … … 25 25 * left and right separators are optionals 26 26 * 27 * @param {object} r egReplacement parameters27 * @param {object} rule Replacement parameters 28 28 * @param {string} fullBlockContent Full block string 29 29 * @param {string} replaceWithThis Replacement string 30 30 * @return {string} replaceWithThis Replacement string 31 31 */ 32 export const getReplacementStringForPairs = ( r eg, fullBlockContent, replaceWithThis ) => {32 export const getReplacementStringForPairs = ( rule, fullBlockContent, replaceWithThis ) => { 33 33 34 34 // Get the opening and closing characters of the pair 35 const openPairChar = r eg.replace.charAt( 0 )36 const closPairChar = r eg.replace.charAt( reg.replace.length - 1 )35 const openPairChar = rule.replace.charAt( 0 ) 36 const closPairChar = rule.replace.charAt( rule.replace.length - 1 ) 37 37 38 38 // Get left separator and right separators 39 const leftSep = r eg.replace.substring( 1, reg.replace.indexOf( '$' ) ) || ''39 const leftSep = rule.replace.substring( 1, rule.replace.indexOf( '$' ) ) || '' 40 40 41 41 let rightSep = '' 42 if ( 0 !== [ ...r eg.replace.matchAll( /[0-9]/g ) ].length ) {42 if ( 0 !== [ ...rule.replace.matchAll( /[0-9]/g ) ].length ) { 43 43 // Right separator begins after last number from last capturing group 44 rightSep = r eg.replace.substring( [ ...reg.replace.matchAll( /[0-9]/g ) ].pop()['index'] + 1, reg.replace.length -1 )44 rightSep = rule.replace.substring( [ ...rule.replace.matchAll( /[0-9]/g ) ].pop()['index'] + 1, rule.replace.length -1 ) 45 45 } 46 46 … … 80 80 export const getLocalizedRules = () => { 81 81 82 const localizedRules = rules.filter( r eg => true === getLocalizedRuleSettings()?.find( s => s.slug === reg.slug )?.value )82 const localizedRules = rules.filter( rule => true === getLocalizedRuleSettings()?.find( s => s.slug === rule.slug )?.value ) 83 83 84 84 return localizedRules … … 95 95 96 96 const selection = window.getSelection() 97 98 const selectionStart = getSelectionStart() 97 99 98 100 // Stop here if no selection or if the selection anchor node is null … … 101 103 // Get current cursor position 102 104 let cursorPosition 105 106 // window getSelection doesn't have what we need. Probably RichText case 107 if ( selection.anchorNode === null ) { 108 109 if ( selectionStart === null || selectionStart?.clientId === null ) { 110 return 111 } 112 113 cursorPosition = selectionStart?.offset || 0 114 selectionChange( selectionStart.clientId, selectionStart.attributeKey, cursorPosition + cursorOffset, cursorPosition + cursorOffset ) 115 return 116 } 103 117 104 118 // Element node case: we need to get the first text node from the element node … … 114 128 // If the cursorOffset is positive, newPosition equals cursorPosition + cursorOffset, else newPosition equals cursorPosition 115 129 const newPosition = cursorOffset >= 0 ? cursorPosition + cursorOffset : cursorPosition 116 130 117 131 // Element node 118 132 if ( selection?.anchorNode?.nodeType === 1 ) { -
consistency/trunk/src/app/utils.js
r3142172 r3184822 29 29 * @returns {string} The extracted text content. 30 30 */ 31 export const getOnlyTextFromBlockContent = blockContent => {31 export const removeHTMLTagsFromBlockContent = blockContent => { 32 32 33 33 // Remove 'code' 'pre' and 'kbd' tags from block content -
consistency/trunk/src/config/rules.js
r3142172 r3184822 21 21 mask: /\'/, // mask 22 22 replace: '’', // replacement string 23 format: '', // format to apply 23 24 nbMoved: 0, // number of characters less or more during replacement 24 25 category: 'apostrophe' // category of the setting … … 32 33 mask: /(?:\-)\-/, 33 34 replace: '–', 35 format: '', 34 36 nbMoved: -1, 35 37 category: 'dash' … … 43 45 mask: /(?:\–|\-\-)\-/, 44 46 replace: '—', 47 format: '', 45 48 nbMoved: lastPart => { 46 49 // Since we replace the string with a symbol, we must move the cursor to the left by the length of the replaced string minus 1 (1 for the symbol itself) … … 57 60 mask: /(?:\—|\–\-|\-\-\-)\-/, 58 61 replace: '⸺', 62 format: '', 59 63 nbMoved: lastPart => { 60 64 // Since we replace the string with a symbol, we must move the cursor to the left by the length of the replaced string minus 1 (1 for the symbol itself) … … 70 74 + `<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>`, 71 75 mask: /([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/, 72 replace: '$1<sup>$2<\/sup>$3', 76 replace: '$1$2$3', 77 format: 'superscript', 73 78 nbMoved: 0, 74 79 category: 'suffixe' … … 82 87 mask: /"/, // specific mask with specific process 83 88 replace: '“$1”', 89 format: '', 84 90 nbMoved: 0, 85 91 category: 'quotation' … … 93 99 mask: /"/, // specific mask with specific process 94 100 replace: '„$1“', 101 format: '', 95 102 nbMoved: 0, 96 103 category: 'quotation' … … 104 111 mask: /"/, // specific mask with specific process 105 112 replace: '»$1«', 113 format: '', 106 114 nbMoved: 0, 107 115 category: 'quotation' … … 115 123 mask: /"/, // specific mask with specific process 116 124 replace: '« $1 »', 125 format: '', 117 126 nbMoved: 1, 118 127 category: 'quotation' … … 126 135 mask: /"/, // specific mask with specific process 127 136 replace: '«$1»', 137 format: '', 128 138 nbMoved: 0, 129 139 category: 'quotation' … … 137 147 mask: /“.*?”/, // specific mask with specific process 138 148 replace: matched => { return `« ${matched.substring( 1, matched.length - 1 )} »` }, 149 format: '', 139 150 nbMoved: 0, 140 151 category: 'quotation' … … 148 159 mask: / ([\?|\!|\:|\;|\»|\€|\$|\£|\¥|\₽|\元|\%])/, 149 160 replace: ' $1', 161 format: '', 150 162 nbMoved: 0, 151 163 category: 'space' … … 159 171 mask: /(?<! | | )([\?|\!|\:|\»|\€|\$|\£|\¥|\₽|\元|\%])/, 160 172 replace: ' $1', 173 format: '', 161 174 nbMoved: 1, 162 175 category: 'space' … … 170 183 mask: /([ | ])(?=[\?|\!|\:|\;|\%])(.)/, 171 184 replace: '$2', 185 format: '', 172 186 nbMoved: -1, 173 187 category: 'space' … … 181 195 mask: /([\,|\…|\)|\]])(?! | |\.|\,|\d|$)(.)/, 182 196 replace: '$1 $2', 197 format: '', 183 198 nbMoved: 1, 184 199 category: 'space' … … 191 206 mask: /(«)(?! | | )/, 192 207 replace: '$1 ', 208 format: '', 193 209 nbMoved: 0, 194 210 category: 'space' … … 201 217 mask: /(^[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț])|(?<=[\.|\?|\!|\…] )[a-záàâäãåăçéèêëíìîïñóòôöõúùûüýÿæœșț]/, 202 218 replace: matched => matched.toUpperCase(), 219 format: '', 203 220 nbMoved: 0, 204 221 category: 'case' … … 212 229 mask: /etc(\.{3})/i, 213 230 replace: matched => { return matched.substring(0, 3) + '.' }, 231 format: '', 214 232 nbMoved: -2, 215 233 category: 'ellipsis' … … 223 241 mask: /etc(\.{2})/i, 224 242 replace: matched => { return matched.substring(0, 2) + '.' }, 243 format: '', 225 244 nbMoved: -1, 226 245 category: 'ellipsis' … … 234 253 mask: /etc(\.{3}|…)/i, 235 254 replace: matched => { return matched.substring(0, 3) + '.' }, 255 format: '', 236 256 nbMoved: 0, 237 257 category: 'ellipsis' … … 245 265 mask: /\.{3}/, 246 266 replace: '…', 267 format: '', 247 268 nbMoved: -2, 248 269 category: 'ellipsis' … … 266 287 return ' ' 267 288 }, 289 format: '', 268 290 nbMoved: -2, 269 291 category: 'symbol' … … 290 312 } 291 313 }, 314 format: '', 292 315 nbMoved: -1, 293 316 category: 'symbol' … … 340 363 } 341 364 }, 365 format: '', 342 366 nbMoved: -2, 343 367 category: 'symbol' … … 364 388 } 365 389 }, 390 format: '', 366 391 nbMoved: lastPart => { 367 392 // We remove the last character of the string because the regex check the character after the string to replace
Note: See TracChangeset
for help on using the changeset viewer.