Changeset 3145550
- Timestamp:
- 09/02/2024 04:58:42 PM (16 months ago)
- Location:
- consistency
- Files:
-
- 44 edited
- 1 copied
-
tags/1.8.1 (copied) (copied from consistency/trunk)
-
tags/1.8.1/build/index.asset.php (modified) (1 diff)
-
tags/1.8.1/build/index.js (modified) (1 diff)
-
tags/1.8.1/consistency.php (modified) (1 diff)
-
tags/1.8.1/includes/Plugin.php (modified) (1 diff)
-
tags/1.8.1/includes/Utils/Concerns/ObjectArrayTrait.php (modified) (1 diff)
-
tags/1.8.1/package.json (modified) (1 diff)
-
tags/1.8.1/readme.txt (modified) (2 diffs)
-
tags/1.8.1/src/app/checks.js (modified) (1 diff)
-
tags/1.8.1/src/app/fixes.js (modified) (6 diffs)
-
tags/1.8.1/src/app/helpers.js (modified) (2 diffs)
-
tags/1.8.1/src/components/ConsistencyPlugin.js (modified) (1 diff)
-
tags/1.8.1/src/components/GlobalSettingPanel.js (modified) (1 diff)
-
tags/1.8.1/src/components/GlobalSettingToggle.js (modified) (2 diffs)
-
tags/1.8.1/src/components/LocaleLabel.js (modified) (1 diff)
-
tags/1.8.1/src/components/Settings.js (modified) (1 diff)
-
tags/1.8.1/src/components/UserSettingPanel.js (modified) (1 diff)
-
tags/1.8.1/src/components/UserSettingToggle.js (modified) (1 diff)
-
tags/1.8.1/src/contexts/GlobalContext.js (modified) (1 diff)
-
tags/1.8.1/src/hooks/useEditorEffects.js (modified) (3 diffs)
-
tags/1.8.1/src/hooks/usePasteEventHandler.js (modified) (2 diffs)
-
tags/1.8.1/src/hooks/useSetAllowedBlocks.js (modified) (1 diff)
-
tags/1.8.1/src/index.js (modified) (1 diff)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/consistency.php (modified) (1 diff)
-
trunk/includes/Plugin.php (modified) (1 diff)
-
trunk/includes/Utils/Concerns/ObjectArrayTrait.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) (6 diffs)
-
trunk/src/app/helpers.js (modified) (2 diffs)
-
trunk/src/components/ConsistencyPlugin.js (modified) (1 diff)
-
trunk/src/components/GlobalSettingPanel.js (modified) (1 diff)
-
trunk/src/components/GlobalSettingToggle.js (modified) (2 diffs)
-
trunk/src/components/LocaleLabel.js (modified) (1 diff)
-
trunk/src/components/Settings.js (modified) (1 diff)
-
trunk/src/components/UserSettingPanel.js (modified) (1 diff)
-
trunk/src/components/UserSettingToggle.js (modified) (1 diff)
-
trunk/src/contexts/GlobalContext.js (modified) (1 diff)
-
trunk/src/hooks/useEditorEffects.js (modified) (3 diffs)
-
trunk/src/hooks/usePasteEventHandler.js (modified) (2 diffs)
-
trunk/src/hooks/useSetAllowedBlocks.js (modified) (1 diff)
-
trunk/src/index.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
consistency/tags/1.8.1/build/index.asset.php
r3142172 r3145550 1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => ' 525eca4ceb38a5bd7f50');1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => 'ab0245b936622e6790c8'); -
consistency/tags/1.8.1/build/index.js
r3142172 r3145550 1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)( !1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,isContentPastedRef:p}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),_=window.wp.richText,f=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof _.RichTextData,{getEntityRecord:v}=(0,p.select)("core"),{updateBlock:w}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=v("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=v("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},E=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],T=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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"}],P=()=>{const e=(()=>{const e=v("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>W(e.slug))):e},F=()=>B.filter((e=>!0===P()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:R,getBlockAttributes:Q}=(0,p.select)("core/block-editor"),W=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},M=e=>{const t=T.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>P()?.find((t=>t.slug===e))?.value))},$=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!W(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:M(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},q=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],z=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...q].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)($,{key:s,settingSlug:e.slug,name:e.name,settingDescription:{__html:e.description}}))))))),{canUser:A}=(0,p.select)("core"),I=()=>{const e=A("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(z,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:D,getBlocks:L,getBlockAttributes:N,getSelectionStart:O,isTyping:G,getBlockSelectionStart:j}=(0,p.select)("core/block-editor"),{selectionChange:U,updateBlockAttributes:H}=(0,p.dispatch)("core/block-editor"),K=e=>{const{currentBlockId:t,isPasting:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,blocksToBeProcessed:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=R(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:c})||!(e=>{const t=Q(e);return!(!t||!t.hasOwnProperty("content")||!f(t.content)&&!k(t.content))})(t))return;let r=F();const a=D(t);let i=N(t),l=!1;Object.entries(r).forEach((([e,c])=>{if(l)return;let r,u=c.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(G()||(b=c.mask.test(h)),G()){r=O(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/ /g)||[]).length;return l>0&&(i=a.replace(/ /g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(c.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=c.mask.test(h)&&c.mask.test(d)}if(!b)return;if((e=>!!E.includes(e.slug))(c)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(c,m)),0!==y&&(m=p+d.replace(c.mask,u)),0===y&&(m=m.replace(c.mask,c.replace)),n)return void o(!1);if(n||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,_.create)({...n.content,text:o});c=new _.RichTextData(e)}return f(n.content)&&(c=o),void 0!==c&&(w(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m})),0===g||s)return;const v="function"==typeof c.nbMoved?c.nbMoved(d):c.nbMoved||0;let S=r.hasOwnProperty("attributeKey")?r.attributeKey:"content";v<0&&U(t,S,g+v,g+v),v>0&&U(t,S,g+1+v,g+v),0===v&&U(t,S,g,g)}))},{getSelectedBlockClientId:J,isTyping:V,getBlockAttributes:X}=(0,p.select)("core/block-editor"),Y=window.wp.blocks,Z=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,Y.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));t=t.filter((e=>!e.name.startsWith("kadence/")));const s=["core/html","core/freeform"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Processed blocks:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,isContentPastedRef:r}=(0,c.useContext)(i);void 0===r.current&&(r.current=!1),(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:a}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=v("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!a)return;const i=P();if(void 0===i)return;if(a&&!0===r.current)return r.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,localizedRuleSettings:n,blocksToBeProcessed:o}=e;let c=F();const r=L(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return o.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(E.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!E.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&H(Object.keys(i),i,!0),a.forEach((e=>{if(!o.includes(e.name))return;const n=e.clientId;e?.clientId&&K({currentBlockId:n,isPasting:!0,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,localizedRuleSettings:i,blocksToBeProcessed:o});const l=J();if(null===l||!c)return;const u=X(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),V()&&K({currentBlockId:l,isPasting:!1,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o})))}));return()=>c()}),[e,t,s,n,o,r])})(),(0,t.createElement)(I,null)),ee=()=>(0,t.createElement)(a,null,(0,t.createElement)(Z,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ee})}))})();1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)(0),d=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:p,isContentPastedRef:d}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),f=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof f.RichTextData,{getEntityRecord:w}=(0,p.select)("core"),{updateBlock:v}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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})}))})(); -
consistency/tags/1.8.1/consistency.php
r3142172 r3145550 4 4 * Plugin URI: https://www.webaxones.com 5 5 * Description: Fixes typographic and punctuation consistency 6 * Version: 1.8. 06 * Version: 1.8.1 7 7 * Requires at least: 6.1 8 8 * Requires PHP: 7.4 -
consistency/tags/1.8.1/includes/Plugin.php
r3142172 r3145550 33 33 protected static function setConstants(): void 34 34 { 35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8. 0' );35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.1' ); 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.1/includes/Utils/Concerns/ObjectArrayTrait.php
r2857933 r3145550 23 23 $array1, 24 24 $array2, 25 function ( $a, $b ) {25 function ( $a, $b ) { 26 26 return strcmp( $a['slug'], $b['slug'] ); 27 27 } -
consistency/tags/1.8.1/package.json
r3142172 r3145550 1 1 { 2 2 "name": "consistency", 3 "version": "1.8. 0",3 "version": "1.8.1", 4 4 "description": "", 5 5 "main": "index.js", -
consistency/tags/1.8.1/readme.txt
r3142172 r3145550 4 4 Requires at least: 6.1 5 5 Tested up to: 6.6 6 Stable tag: 1.8. 06 Stable tag: 1.8.1 7 7 Requires PHP: 7.4 8 8 License: GPL-3.0-or-later … … 70 70 == Changelog == 71 71 72 = 1.8.1 = 73 * Fix: Resolves incompatibilities with block plugins such as Kadence, GeneratePress, etc. 74 * Fix: Fix the names of enabled or disabled rules in the notices 75 72 76 = 1.8.0 = 73 77 * Update: code refactoring (replace global variables with global context, some functions with custom hooks, and allow to process more blocks) -
consistency/tags/1.8.1/src/app/checks.js
r3142172 r3145550 68 68 69 69 const blockAttributes = getBlockAttributes( currentBlockId ) 70 70 71 71 if ( ! blockAttributes || ! blockAttributes.hasOwnProperty( 'content' ) ) return false 72 72 -
consistency/tags/1.8.1/src/app/fixes.js
r3142172 r3145550 20 20 import { shouldProcessBlock, canProcessBlock, regDealWithPair } from './checks' 21 21 22 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping, getBlockSelectionStart } = select( 'core/block-editor' ) 23 const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' ) 24 22 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' ) 23 const { updateBlockAttributes } = dispatch( 'core/block-editor' ) 25 24 26 25 … … 30 29 * @param {Object} props - The props object. 31 30 * @param {string} props.currentBlockId - The ID of the current block. 32 * @param {boolean} props.isPasting - Indicates if the content is being pasted.33 31 * @param {boolean} props.isPreviousFixCanceled - Indicates if the previous fix was canceled. 34 32 * @param {function} props.setPreviousFixCanceled - The function to set the previous fix canceled state. 35 33 * @param {Array} props.blocksToBeProcessed - The blocks to be processed: we pass them as props to avoid using global context since we are not in a component. 34 * @param {Ref} props.cursorOffsetRef - The reference to the cursor offset. 36 35 */ 37 36 export const fixIt = props => { 38 37 39 const { currentBlockId, isP asting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed} = props38 const { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props 40 39 41 40 // Check if the current block should be processed and can be processed … … 136 135 contentUpdated = updateBlockTextContent( { block, currentBlockId, blockAttributes, blockContent } ) 137 136 } 138 139 // Cursor repositioning:140 if ( 0 === cursorPosition || isPasting ) return141 137 142 138 // Get the number of characters moved by the replacement: needed for cursor repositioning. … … 144 140 const nbMoved = typeof reg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved || 0 145 141 146 let attributeKey = selectionStart.hasOwnProperty( 'attributeKey' ) ? selectionStart.attributeKey : 'content' 147 148 // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back 149 // Eg: ... replaced with … removes 2 characters 150 if ( nbMoved < 0 ) { 151 selectionChange( currentBlockId, attributeKey, cursorPosition + nbMoved, cursorPosition + nbMoved ) 152 } 153 154 // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward 155 // Eg: "" replaced with « » adds 2 characters 156 if ( nbMoved > 0 ) { 157 selectionChange( currentBlockId, attributeKey, cursorPosition + 1 + nbMoved, cursorPosition + nbMoved ) 158 } 159 160 if ( 0 === nbMoved ) { 161 selectionChange( currentBlockId, attributeKey, cursorPosition, cursorPosition ) 142 // Set the cursor offset 143 if ( contentUpdated ) { 144 cursorOffsetRef.current = nbMoved 162 145 } 163 146 … … 167 150 168 151 /** 169 * Fixes all blocks generated by pasting. 152 * Fix all blocks generated by pasting based on the provided rules and blocks to be processed. 153 * 154 * @param {Object} props - The props object containing necessary data. 155 * @param {boolean} props.isPreviousFixCanceled - Flag indicating if the previous fix was canceled. 156 * @param {function} props.setPreviousFixCanceled - Function to set the flag indicating if the previous fix was canceled. 157 * @param {Array} props.blocksToBeProcessed - Array of block names to be processed. 158 * @param {Ref} props.cursorOffsetRef - Reference to the cursor offset. 170 159 */ 171 160 export const fixAll = props => { 172 161 173 const { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed} = props162 const { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props 174 163 175 164 // Get the relevant rules … … 224 213 225 214 // Select all innerBlocks to trigger their correction, then deselect all by selecting the first block 226 const isPasting = true227 215 allInners.forEach( block => { 228 216 229 217 if ( ! blocksToBeProcessed.includes( block.name ) ) return 230 218 const currentBlockId = block.clientId 231 block?.clientId && fixIt( { currentBlockId, isP asting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed} )219 block?.clientId && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } ) 232 220 233 221 } ) -
consistency/tags/1.8.1/src/app/helpers.js
r3142172 r3145550 5 5 * @author Loïc Antignac. 6 6 */ 7 8 import { select, dispatch } from '@wordpress/data' 9 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' ) 10 const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' ) 7 11 8 12 /** … … 81 85 82 86 } 87 88 /** 89 * Moves the cursor to right position after fixing the content. 90 * We use window.getSelection() and not the editor's selectionChange() to avoid to trigger a new state change. 91 * 92 * @returns {void} 93 */ 94 export const moveCursorToNewPosition = cursorOffset => { 95 96 const selection = window.getSelection() 97 98 // Stop here if no selection or if the selection anchor node is null 99 if ( ! selection ) return 100 101 // Get current cursor position 102 let cursorPosition 103 104 // Element node case: we need to get the first text node from the element node 105 if ( selection?.anchorNode?.nodeType === 1 ) { 106 cursorPosition = selection.anchorNode?.firstChild?.length || 0 107 } 108 109 // Text node case 110 if ( selection?.anchorNode?.nodeType === 3 ) { 111 cursorPosition = selection.anchorOffset || 0 112 } 113 114 // If the cursorOffset is positive, newPosition equals cursorPosition + cursorOffset, else newPosition equals cursorPosition 115 const newPosition = cursorOffset >= 0 ? cursorPosition + cursorOffset : cursorPosition 116 117 // Element node 118 if ( selection?.anchorNode?.nodeType === 1 ) { 119 120 // If the anchor node is an element node, we have to get the first text node from it 121 const textNode = selection.anchorNode?.firstChild || selection.anchorNode?.childNodes[ 0 ] 122 selection.collapse( textNode, newPosition ) 123 return 124 125 } 126 127 // Text node 128 if ( selection?.anchorNode?.nodeType === 3 ) { 129 130 // If the anchor node is a text node, we have to get the parent element node 131 const textNode = selection.anchorNode 132 selection.collapse( textNode, newPosition ) 133 return 134 135 } 136 137 } -
consistency/tags/1.8.1/src/components/ConsistencyPlugin.js
r3142172 r3145550 39 39 40 40 // Render the settings sidebar 41 return (42 <SidebarSettings />43 )41 return ( 42 <SidebarSettings /> 43 ) 44 44 } 45 45 -
consistency/tags/1.8.1/src/components/GlobalSettingPanel.js
r3142172 r3145550 42 42 key={ key } 43 43 settingSlug={ rule.slug } 44 name={ rule.name }44 settingName={ rule.name } 45 45 settingDescription={ { 46 46 __html: rule.description -
consistency/tags/1.8.1/src/components/GlobalSettingToggle.js
r3142172 r3145550 63 63 } 64 64 65 return(65 return( 66 66 <PanelRow> 67 67 <ToggleControl … … 73 73 /> 74 74 </PanelRow> 75 )75 ) 76 76 } -
consistency/tags/1.8.1/src/components/LocaleLabel.js
r3142172 r3145550 27 27 : __( ' (all locales)', 'consistency' ) 28 28 29 return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> )29 return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> ) 30 30 } -
consistency/tags/1.8.1/src/components/Settings.js
r3142172 r3145550 26 26 const isAdmin = canUser( 'create', 'users' ) 27 27 28 return(29 <>28 return( 29 <> 30 30 <PluginSidebar 31 name='consistency-custom-sidebar'32 title={ __( 'Consistency', 'consistency' ) }31 name='consistency-custom-sidebar' 32 title={ __( 'Consistency', 'consistency' ) } 33 33 icon={ ConsistencyIcon } 34 >34 > 35 35 <UserSettingPanel /> 36 36 { isAdmin && <GlobalSettingPanel/> } 37 </PluginSidebar>38 <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'>37 </PluginSidebar> 38 <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'> 39 39 { __( 'Consistency Settings', 'consistency' ) } 40 40 </PluginSidebarMoreMenuItem> 41 </>42 )41 </> 42 ) 43 43 } -
consistency/tags/1.8.1/src/components/UserSettingPanel.js
r3142172 r3145550 21 21 */ 22 22 const UserSettingPanel = () => ( 23 <Panel className='UserSettingPanel'>23 <Panel className='UserSettingPanel'> 24 24 <PanelHeader><strong>{ __( 'Settings for my account', 'consistency' ) }</strong><br/></PanelHeader> 25 <div style={{ padding: 16 }}>26 <PanelRow>27 <UserSettingToggle28 settingSlug='on_the_fly'29 settingName={ __( 'On-the-fly autocorrect', 'consistency' ) }30 settingDescription={ {31 __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' )32 } }33 />34 </PanelRow>35 <PanelRow>36 <UserSettingToggle37 settingSlug='on_paste'38 settingName={ __( 'On paste autocorrect', 'consistency' ) }39 settingDescription={ {40 __html: __( 'Enable/disable autocorrect on paste', 'consistency' )41 } }42 />43 </PanelRow>44 </div>45 </Panel>25 <div style={{ padding: 16 }}> 26 <PanelRow> 27 <UserSettingToggle 28 settingSlug='on_the_fly' 29 settingName={ __( 'On-the-fly autocorrect', 'consistency' ) } 30 settingDescription={ { 31 __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' ) 32 } } 33 /> 34 </PanelRow> 35 <PanelRow> 36 <UserSettingToggle 37 settingSlug='on_paste' 38 settingName={ __( 'On paste autocorrect', 'consistency' ) } 39 settingDescription={ { 40 __html: __( 'Enable/disable autocorrect on paste', 'consistency' ) 41 } } 42 /> 43 </PanelRow> 44 </div> 45 </Panel> 46 46 ) 47 47 -
consistency/tags/1.8.1/src/components/UserSettingToggle.js
r3142172 r3145550 59 59 } 60 60 61 return(62 <ToggleControl63 label={ settingName }61 return( 62 <ToggleControl 63 label={ settingName } 64 64 help={ ( <span dangerouslySetInnerHTML={ settingDescription } /> ) } 65 checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false }66 onChange={ onSettingChanged }67 />68 )65 checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false } 66 onChange={ onSettingChanged } 67 /> 68 ) 69 69 } -
consistency/tags/1.8.1/src/contexts/GlobalContext.js
r3142172 r3145550 30 30 // This variable is used to check if custom fields are active because the editor content is within an iframe when custom fields are inactive 31 31 const [ isEditorInIframe ] = useState( document.querySelector( 'iframe[name="editor-canvas"]' ) !== null ) 32 32 33 // This variable is used to avoid new fixes when the user is undoing a fix with CTRL/CMD Z 33 34 const [ isPreviousFixCanceled, setPreviousFixCanceled ] = useState( false ) 35 34 36 // This variable is used to store the content of the block to avoid fixing it if it has not changed since we check at every state change 35 37 const [ previousFixCanceledContent, setPreviousFixCanceledContent ] = useState( '' ) 38 36 39 // This variable is used to store the blocks allowed to be processed 37 40 const [ blocksToBeProcessed, setBlocksToBeProcessed ] = useState( [] ) 41 42 // This variable is used to store the number of characters lost or gained by the correction in order to move the cursor accordingly 43 const cursorOffsetRef = useRef( 0 ) 44 38 45 // This ref is used to track if content has been past 39 46 const isContentPastedRef = useRef( false ) 40 47 41 48 // Return the global provider 42 return (43 <GlobalContext.Provider value={ {44 isEditorInIframe,45 isPreviousFixCanceled,46 setPreviousFixCanceled,49 return ( 50 <GlobalContext.Provider value={ { 51 isEditorInIframe, 52 isPreviousFixCanceled, 53 setPreviousFixCanceled, 47 54 previousFixCanceledContent, 48 setPreviousFixCanceledContent,55 setPreviousFixCanceledContent, 49 56 blocksToBeProcessed, 50 57 setBlocksToBeProcessed, 58 cursorOffsetRef, 51 59 isContentPastedRef 52 } }>53 { children }54 </GlobalContext.Provider>55 )60 } }> 61 { children } 62 </GlobalContext.Provider> 63 ) 56 64 } 57 65 -
consistency/tags/1.8.1/src/hooks/useEditorEffects.js
r3142172 r3145550 21 21 import { fixIt, fixAll } from '../app/fixes' 22 22 import { fetchCurrentUserSettings } from '../app/data' 23 import { getLocalizedRuleSettings } from '../app/helpers'23 import { moveCursorToNewPosition, getLocalizedRuleSettings } from '../app/helpers' 24 24 25 25 // Get the current selected block and its attributes … … 30 30 * Global variables in global context 31 31 */ 32 const {32 const { 33 33 isPreviousFixCanceled, 34 setPreviousFixCanceled,34 setPreviousFixCanceled, 35 35 previousFixCanceledContent, 36 setPreviousFixCanceledContent,36 setPreviousFixCanceledContent, 37 37 blocksToBeProcessed, 38 cursorOffsetRef, 38 39 isContentPastedRef 39 } = useContext( GlobalContext ) 40 } = useContext( GlobalContext ) 41 42 // Initialize the cursorOffset variable if it is undefined 43 cursorOffsetRef.current = cursorOffsetRef.current || 0 40 44 41 45 // Initialize the isContentPastedRef variable if it is undefined 42 if ( isContentPastedRef.current === undefined ) { 43 isContentPastedRef.current = false 44 } 46 isContentPastedRef.current = isContentPastedRef.current || false 45 47 46 useEffect( () => {48 useEffect( () => { 47 49 48 50 // Let’s listen for state changes 49 51 const unsubscribe = subscribe( () => { 50 52 51 // Get current user settings to check if we have to fix the content or to stop here53 // Get current user settings to check if we have to fix the content or to stop here 52 54 const { onTheFly, onPaste } = fetchCurrentUserSettings() 53 if ( ! onTheFly && ! onPaste ) return55 if ( ! onTheFly && ! onPaste ) return 54 56 55 // Get fixing rules from site entity global settings57 // Get fixing rules from site entity global settings 56 58 const localizedRuleSettings = getLocalizedRuleSettings() 57 if ( localizedRuleSettings === undefined ) return59 if ( localizedRuleSettings === undefined ) return 58 60 59 // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here61 // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here 60 62 if ( onPaste && isContentPastedRef.current === true ) { 61 63 isContentPastedRef.current = false 62 fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed} )64 fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } ) 63 65 return 64 }66 } 65 67 66 68 // Get current selected block 67 const currentBlockId = getSelectedBlockClientId()69 const currentBlockId = getSelectedBlockClientId() 68 70 69 71 // Stop here if no block is selected or if fixing on the fly is disabled 70 if ( currentBlockId === null || ! onTheFly ) return72 if ( currentBlockId === null || ! onTheFly ) return 71 73 72 74 // Don't try to fix block content if nothing has changed … … 79 81 80 82 // Store the block content to avoid fixing it twice at the next state change 81 setPreviousFixCanceledContent( blockAttributes.content )83 setPreviousFixCanceledContent( blockAttributes.content ) 82 84 83 85 // Fix the current selected block 84 isTyping() && fixIt( { currentBlockId, isPasting: false, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } ) 85 } ) 86 isTyping() && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } ) 87 88 } ) 86 89 87 90 // Unsubscribe when the component is unmounted 88 return () => unsubscribe() 91 return () => { 92 unsubscribe() 93 94 // Move cursor to the new position 95 moveCursorToNewPosition( cursorOffsetRef.current ) 89 96 90 }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, isContentPastedRef ] ) 97 // Reset cursorOffsetRef 98 cursorOffsetRef.current = 0 99 } 100 101 }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, cursorOffsetRef, isContentPastedRef ] ) 91 102 } 92 103 -
consistency/tags/1.8.1/src/hooks/usePasteEventHandler.js
r3142172 r3145550 27 27 const isPasteEventAttached = useRef( false ) 28 28 29 useEffect( () => {29 useEffect( () => { 30 30 31 31 // If the paste event has already been attached, return … … 49 49 50 50 // Get the target element depending on whether the editor is in an iframe or not 51 const targetElement = isEditorInIframe51 const targetElement = isEditorInIframe 52 52 ? document.querySelector( 'iframe[name="editor-canvas"]' ) 53 53 : document.querySelector( '#editor' ) 54 54 55 if ( ! targetElement ) return55 if ( ! targetElement ) return 56 56 57 // Attach the paste event listener and get the cleanup function58 const cleanup = attachPasteEventListener( targetElement )57 // Attach the paste event listener and get the cleanup function 58 const cleanup = attachPasteEventListener( targetElement ) 59 59 60 // If the iframe is already loaded, manually trigger the event listener attachment61 if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) {62 attachPasteEventListener( targetElement )63 }60 // If the iframe is already loaded, manually trigger the event listener attachment 61 if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) { 62 attachPasteEventListener( targetElement ) 63 } 64 64 65 65 // Update the ref to track if the paste event has been attached 66 66 isPasteEventAttached.current = true 67 67 68 // Return the cleanup function to be called when the component unmounts or before the effect re-runs69 return cleanup68 // Return the cleanup function to be called when the component unmounts or before the effect re-runs 69 return cleanup 70 70 71 }, [ isEditorInIframe ] )71 }, [ isEditorInIframe ] ) 72 72 } 73 73 -
consistency/tags/1.8.1/src/hooks/useSetAllowedBlocks.js
r3142172 r3145550 30 30 } ) 31 31 32 // Remove blocks beginning with kadence/ from the list since it doesn't work with them 33 richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! block.name.startsWith( 'kadence/' ) ) 34 35 // Remove blocks from the list cause we don't want to alter them (core/html) or they don't work properly (core/freeform) 36 const blocksToExclude = [ 'core/html', 'core/freeform' ] 32 // Remove blocks from the list cause we don't want to alter them (core/html) 33 const blocksToExclude = [ 'core/html' ] 37 34 richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! blocksToExclude.includes( block.name ) ) 38 35 39 console.log( 'Consistency - Processed blocks:', richTextAndStringContentTypes );36 console.log( 'Consistency - Blocks that can be processed:', richTextAndStringContentTypes ); 40 37 41 38 // Set the blocks to be processed in the global context -
consistency/tags/1.8.1/src/index.js
r3142172 r3145550 22 22 23 23 const PluginWrapper = () => ( 24 <GlobalProvider>25 <ConsistencyPlugin />26 </GlobalProvider>24 <GlobalProvider> 25 <ConsistencyPlugin /> 26 </GlobalProvider> 27 27 ) 28 28 29 29 domReady( () => { 30 registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } )30 registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } ) 31 31 } ) -
consistency/trunk/build/index.asset.php
r3142172 r3145550 1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => ' 525eca4ceb38a5bd7f50');1 <?php return array('dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-rich-text'), 'version' => 'ab0245b936622e6790c8'); -
consistency/trunk/build/index.js
r3142172 r3145550 1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)( !1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,isContentPastedRef:p}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),_=window.wp.richText,f=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof _.RichTextData,{getEntityRecord:v}=(0,p.select)("core"),{updateBlock:w}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=v("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=v("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},E=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],T=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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"}],P=()=>{const e=(()=>{const e=v("root","site");return e?.consistency_plugin_settings||[]})();return S()?e.filter((e=>W(e.slug))):e},F=()=>B.filter((e=>!0===P()?.find((t=>t.slug===e.slug))?.value)),{getBlockName:R,getBlockAttributes:Q}=(0,p.select)("core/block-editor"),W=e=>{const t=x();return!(void 0===localesByRules||!localesByRules.hasOwnProperty(e))&&localesByRules[e].includes(t)},M=e=>{const t=T.find((t=>t.slug===e));return!!t&&t.incompatibleWith.some((e=>P()?.find((t=>t.slug===e))?.value))},$=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{createNotice:c}=(0,p.useDispatch)(m.store);if(S()&&!W(s))return"";const[r,a]=(0,y.useEntityProp)("root","site","consistency_plugin_settings",void 0),{saveEditedEntityRecord:i}=(0,p.useDispatch)(y.store);return(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:r?.find((e=>e.slug===s))?.value||!1,disabled:M(s),onChange:e=>{let t=r.map((t=>s===t.slug?{...t,value:e}:t));a(t),i("root","site",void 0,t),c((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}}))},q=[{slug:"apostrophe",label:(0,l.__)("Apostrophes","consistency"),description:(0,l.__)("Fixes related to apostrophes.","consistency")},{slug:"quotation",label:(0,l.__)("Quotation marks","consistency"),description:(0,l.__)("Fixes related to quotation marks.","consistency")},{slug:"dash",label:(0,l.__)("Dashes","consistency"),description:(0,l.__)("Fixes related to dashes.","consistency")},{slug:"suffixe",label:(0,l.__)("Suffixes","consistency"),description:(0,l.__)("Fixes related to suffixes.","consistency")},{slug:"space",label:(0,l.__)("Spaces","consistency"),description:(0,l.__)("Fixes related to spaces.","consistency")},{slug:"case",label:(0,l.__)("Case","consistency"),description:(0,l.__)("Fixes related to case.","consistency")},{slug:"ellipsis",label:(0,l.__)("Ellipsis","consistency"),description:(0,l.__)("Fixes related to ellipsis.","consistency")},{slug:"symbol",label:(0,l.__)("Symbols","consistency"),description:(0,l.__)("Fixes related to symbols.","consistency")}],z=()=>(0,t.createElement)(d.Panel,{className:"GlobalSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Global correction rules","consistency"),(0,t.createElement)(C,null))),[...q].map(((e,s)=>(0,t.createElement)(d.PanelBody,{key:s,title:(0,l.__)(e.label,"consistency"),initialOpen:!1},[...B].filter((t=>t.category===e.slug)).map(((e,s)=>(0,t.createElement)($,{key:s,settingSlug:e.slug,name:e.name,settingDescription:{__html:e.description}}))))))),{canUser:A}=(0,p.select)("core"),I=()=>{const e=A("create","users");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(u.PluginSidebar,{name:"consistency-custom-sidebar",title:(0,l.__)("Consistency","consistency"),icon:g},(0,t.createElement)(b,null),e&&(0,t.createElement)(z,null)),(0,t.createElement)(u.PluginSidebarMoreMenuItem,{target:"consistency-custom-sidebar"},(0,l.__)("Consistency Settings","consistency")))},{getBlock:D,getBlocks:L,getBlockAttributes:N,getSelectionStart:O,isTyping:G,getBlockSelectionStart:j}=(0,p.select)("core/block-editor"),{selectionChange:U,updateBlockAttributes:H}=(0,p.dispatch)("core/block-editor"),K=e=>{const{currentBlockId:t,isPasting:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,blocksToBeProcessed:c}=e;if(!(e=>{const{currentBlockId:t,blocksToBeProcessed:s}=e,n=R(t);return!!s.includes(n)})({currentBlockId:t,blocksToBeProcessed:c})||!(e=>{const t=Q(e);return!(!t||!t.hasOwnProperty("content")||!f(t.content)&&!k(t.content))})(t))return;let r=F();const a=D(t);let i=N(t),l=!1;Object.entries(r).forEach((([e,c])=>{if(l)return;let r,u=c.replace,p="",d="",g=0,y=0,m="object"==typeof i.content?i.content.text:i.content,h=(e=>e.replace(/<\b(code|pre|kbd)\b>.*?<\/\b(code|pre|kbd)\b>/gi,"").replace(/(<([^>]+)>)/gi,""))(m),b=!1;if(G()||(b=c.mask.test(h)),G()){r=O(),g=r?.offset||document.getSelection()?.anchorOffset||0,y=(e=>{const t=document.querySelector(`#block-${e}`);if(null===t)return;const s=t.querySelector('[contenteditable="true"]')||t,n=document.getSelection(),o=n?.getRangeAt(0);if(!o||!o.collapsed)return;const c=o.cloneRange(),r=document.createTextNode("\0");c.insertNode(r);const a=s.textContent||"";let i=a.indexOf("\0");r.parentNode.removeChild(r),s.normalize();const l=(s?.innerHTML.match(/ /g)||[]).length;return l>0&&(i=a.replace(/ /g," ").indexOf("\0"),i=i-6*l+l),i})(t)||g;const e=h.match(c.mask);if(null===e||0===e.length)return;const s=e[0].length||1;p=h.substring(0,y-s),d=h.substring(y-s,h.length),b=c.mask.test(h)&&c.mask.test(d)}if(!b)return;if((e=>!!E.includes(e.slug))(c)&&(u=((e,t,s)=>{const n=e.replace.charAt(0),o=e.replace.charAt(e.replace.length-1),c=e.replace.substring(1,e.replace.indexOf("$"))||"";let r="";0!==[...e.replace.matchAll(/[0-9]/g)].length&&(r=e.replace.substring([...e.replace.matchAll(/[0-9]/g)].pop().index+1,e.replace.length-1));const a=new RegExp(`${n}`,"g"),i=new RegExp(`${o}`,"g");return(t.match(a)||[]).length===(t.match(i)||[]).length?n+c:r+o})(c,m)),0!==y&&(m=p+d.replace(c.mask,u)),0===y&&(m=m.replace(c.mask,c.replace)),n)return void o(!1);if(n||(l=(e=>{const{block:t,currentBlockId:s,blockAttributes:n,blockContent:o}=e;let c;if(k(n.content)){const e=(0,_.create)({...n.content,text:o});c=new _.RichTextData(e)}return f(n.content)&&(c=o),void 0!==c&&(w(s,{...t,attributes:{...n,content:c}}),!0)})({block:a,currentBlockId:t,blockAttributes:i,blockContent:m})),0===g||s)return;const v="function"==typeof c.nbMoved?c.nbMoved(d):c.nbMoved||0;let S=r.hasOwnProperty("attributeKey")?r.attributeKey:"content";v<0&&U(t,S,g+v,g+v),v>0&&U(t,S,g+1+v,g+v),0===v&&U(t,S,g,g)}))},{getSelectedBlockClientId:J,isTyping:V,getBlockAttributes:X}=(0,p.select)("core/block-editor"),Y=window.wp.blocks,Z=()=>((()=>{const{isEditorInIframe:e,isContentPastedRef:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{t.current=!0},o=e=>(e.addEventListener("paste",n),()=>{e.removeEventListener("paste",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[e])})(),(()=>{const{isEditorInIframe:e,setPreviousFixCanceled:t}=(0,c.useContext)(i),s=(0,c.useRef)(!1);(0,c.useEffect)((()=>{if(s.current)return;const n=e=>{90===e.keyCode&&(e.ctrlKey||e.metaKey)&&t(!0)},o=e=>(e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}),c=e?document.querySelector('iframe[name="editor-canvas"]'):document.querySelector("#editor");if(!c)return;const r=o(c);return e&&"complete"===c.contentWindow.document.readyState&&o(c),s.current=!0,r}),[t])})(),(()=>{const{setBlocksToBeProcessed:e}=(0,c.useContext)(i);(0,c.useEffect)((()=>{let t=(0,Y.getBlockTypes)().filter((e=>e.attributes&&e.attributes.content&&("string"===e.attributes.content.type||"rich-text"===e.attributes.content.type)));t=t.filter((e=>!e.name.startsWith("kadence/")));const s=["core/html","core/freeform"];t=t.filter((e=>!s.includes(e.name))),console.log("Consistency - Processed blocks:",t),e(t.map((e=>e.name)))}),[])})(),(()=>{const{isPreviousFixCanceled:e,setPreviousFixCanceled:t,previousFixCanceledContent:s,setPreviousFixCanceledContent:n,blocksToBeProcessed:o,isContentPastedRef:r}=(0,c.useContext)(i);void 0===r.current&&(r.current=!1),(0,c.useEffect)((()=>{const c=(0,p.subscribe)((()=>{const{onTheFly:c,onPaste:a}=(()=>{const e={onTheFly:!1,onPaste:!1},t=(0,p.select)(y.store).getCurrentUser(),s=v("root","user",t?.id||0,"consistency_plugin_user_settings"),n=s?.meta?.consistency_plugin_user_settings;return e.onTheFly=n?.find((e=>"on_the_fly"===e.slug))?.value||!1,e.onPaste=n?.find((e=>"on_paste"===e.slug))?.value||!1,e})();if(!c&&!a)return;const i=P();if(void 0===i)return;if(a&&!0===r.current)return r.current=!1,void(e=>{const{isPreviousFixCanceled:t,setPreviousFixCanceled:s,localizedRuleSettings:n,blocksToBeProcessed:o}=e;let c=F();const r=L(),a=r.flatMap((({innerBlocks:e,...t})=>e.map((e=>({...t,...e}))))),i=r.reduce(((e,t)=>{let s=t.attributes?.content;return o.includes(t.name)&&void 0!==s?(Object.entries(c).forEach((([e,t])=>{if(E.includes(t.slug)){const e=t.mask.toString().match(/(?<=\/).+?(?=\/)/g)[0],n=new RegExp(`(?<!=)${e}(?!>)([^${e}]*)(?<!=)${e}(?!>)`,"g");s=s.replaceAll(n,t.replace)}if(!E.includes(t.slug)){const e=t.mask.toString(),n=new RegExp(e.substring(1,e.length-1),"g");s=s.replaceAll(n,t.replace)}})),void 0!==s&&(e[t.clientId]={content:s}),e):e}),{});Object.keys(i).length>0&&H(Object.keys(i),i,!0),a.forEach((e=>{if(!o.includes(e.name))return;const n=e.clientId;e?.clientId&&K({currentBlockId:n,isPasting:!0,isPreviousFixCanceled:t,setPreviousFixCanceled:s,blocksToBeProcessed:o})}))})({isPreviousFixCanceled:e,setPreviousFixCanceled:t,localizedRuleSettings:i,blocksToBeProcessed:o});const l=J();if(null===l||!c)return;const u=X(l);u&&(u.hasOwnProperty("content")&&s===u.content||(n(u.content),V()&&K({currentBlockId:l,isPasting:!1,isPreviousFixCanceled:e,setPreviousFixCanceled:t,blocksToBeProcessed:o})))}));return()=>c()}),[e,t,s,n,o,r])})(),(0,t.createElement)(I,null)),ee=()=>(0,t.createElement)(a,null,(0,t.createElement)(Z,null));o()((()=>{(0,s.registerPlugin)("consistency-custom-sidebar",{render:ee})}))})();1 (()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,s=window.wp.plugins,n=window.wp.domReady;var o=e.n(n);const c=window.wp.element,r=(0,c.createContext)(),a=({children:e})=>{const[s]=(0,c.useState)(null!==document.querySelector('iframe[name="editor-canvas"]')),[n,o]=(0,c.useState)(!1),[a,i]=(0,c.useState)(""),[l,u]=(0,c.useState)([]),p=(0,c.useRef)(0),d=(0,c.useRef)(!1);return(0,t.createElement)(r.Provider,{value:{isEditorInIframe:s,isPreviousFixCanceled:n,setPreviousFixCanceled:o,previousFixCanceledContent:a,setPreviousFixCanceledContent:i,blocksToBeProcessed:l,setBlocksToBeProcessed:u,cursorOffsetRef:p,isContentPastedRef:d}},e)},i=r,l=window.wp.i18n,u=window.wp.editor,p=window.wp.data,d=window.wp.components,g=()=>(0,t.createElement)(d.Icon,{icon:(0,t.createElement)("svg",{version:"1.1",id:"consistency-plugin",x:"0px",y:"0px",width:"24px",height:"24px",viewBox:"0 0 24 24",enableBackground:"new 0 0 24 24"},(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"4",y1:"20",x2:"7",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"14",y1:"20",x2:"21",y2:"20"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),(0,t.createElement)("line",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),(0,t.createElement)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",points:"5,20 11,4 13,4 20,20 "}))}),y=window.wp.coreData,m=window.wp.notices,h=e=>{const{settingSlug:s,settingName:n,settingDescription:o}=e,{currentUser:c}=(0,p.useSelect)((e=>({currentUser:e(y.store).getCurrentUser()})),[]),r=c&&c.id,[a,i]=(0,y.useEntityProp)("root","user","meta",r),{saveEditedEntityRecord:u}=(0,p.useDispatch)(y.store),{createNotice:g}=(0,p.useDispatch)(m.store);return(0,t.createElement)(d.ToggleControl,{label:n,help:(0,t.createElement)("span",{dangerouslySetInnerHTML:o}),checked:a?.consistency_plugin_user_settings?.find((e=>e.slug===s))?.value||!1,onChange:e=>{let t=a?.consistency_plugin_user_settings.map((t=>s===t.slug?{...t,value:e}:t));t?.find((e=>e.slug===s))||t.push({slug:s,value:e}),i({...a,consistency_plugin_user_settings:t}),u("root","user",r,{...a,meta:t}),g((0,l.__)("info","consistency"),e?sprintf((0,l.__)('"%1$s" Correction is enabled',"consistency"),n):sprintf((0,l.__)('"%1$s" Correction is disabled',"consistency"),n),{isDismissible:!0,type:"snackbar",speak:!0})}})},b=()=>(0,t.createElement)(d.Panel,{className:"UserSettingPanel"},(0,t.createElement)(d.PanelHeader,null,(0,t.createElement)("strong",null,(0,l.__)("Settings for my account","consistency")),(0,t.createElement)("br",null)),(0,t.createElement)("div",{style:{padding:16}},(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_the_fly",settingName:(0,l.__)("On-the-fly autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable on-the-fly autocorrect","consistency")}})),(0,t.createElement)(d.PanelRow,null,(0,t.createElement)(h,{settingSlug:"on_paste",settingName:(0,l.__)("On paste autocorrect","consistency"),settingDescription:{__html:(0,l.__)("Enable/disable autocorrect on paste","consistency")}})))),f=window.wp.richText,_=e=>"string"==typeof e||e instanceof String,k=e=>"object"==typeof e&&e instanceof f.RichTextData,{getEntityRecord:w}=(0,p.select)("core"),{updateBlock:v}=(0,p.dispatch)("core/block-editor"),S=()=>{const e=w("root","site");return e?.consistency_plugin_localization_management||!0},x=()=>{const e=w("root","site");return e?.language||"en_US"},C=()=>{const e=x(),s=S()?(0,l.__)(` (${e} locale)`,"consistency"):(0,l.__)(" (all locales)","consistency");return(0,t.createElement)("span",{style:{fontWeight:"normal",fontStyle:"italic",fontSize:"smaller"}},s)},T=["regularToCurlyQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces","regularToGermanQuotes","regularToGermanBookStyleQuotes"],E=[{slug:"quote",incompatibleWith:[]},{slug:"2hyphens",incompatibleWith:[]},{slug:"3hyphens",incompatibleWith:[]},{slug:"4hyphens",incompatibleWith:[]},{slug:"ordinalNumberSuffix",incompatibleWith:[]},{slug:"regularToCurlyQuotes",incompatibleWith:["regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToGermanBookStyleQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToFrenchQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotesWithoutSpaces"]},{slug:"regularToFrenchQuotesWithoutSpaces",incompatibleWith:["regularToCurlyQuotes","regularToGermanQuotes","regularToGermanBookStyleQuotes","regularToFrenchQuotes"]},{slug:"curlyToFrenchQuotes",incompatibleWith:["regularToCurlyQuotes"]},{slug:"breakingSpace",incompatibleWith:["spaceBefore"]},{slug:"noSpaceBefore",incompatibleWith:["spaceBefore"]},{slug:"spaceBefore",incompatibleWith:["breakingSpace","noSpaceBefore"]},{slug:"noBreakingSpaceAfter",incompatibleWith:[]},{slug:"noNonBreakingSpaceAfter",incompatibleWith:[]},{slug:"capitalizeFirstSentenceLetter",incompatibleWith:[]},{slug:"etcThreeDots",incompatibleWith:[]},{slug:"etcTwoDots",incompatibleWith:[]},{slug:"etcEllipsis",incompatibleWith:[]},{slug:"ellipsis",incompatibleWith:[]},{slug:"symbolInACircle",incompatibleWith:[]},{slug:"symbolInSmallCapsAndSuperscriptStyle",incompatibleWith:[]},{slug:"fractions",incompatibleWith:[]},{slug:"percentages",incompatibleWith:[]}],B=[{slug:"quote",name:(0,l.__)("Straight Apostrophe","consistency"),description:(0,l.__)("Replace straight apostrophes with curly apostrophes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>'</code> <span style='font-size:20px'>→</span> <code>’</code></span>",mask:/\'/,replace:"’",nbMoved:0,category:"apostrophe"},{slug:"2hyphens",name:(0,l.__)("En Dash","consistency"),description:(0,l.__)("Replace two hyphens with an en dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>--</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">–</code></span>",mask:/(?:\-)\-/,replace:"–",nbMoved:-1,category:"dash"},{slug:"3hyphens",name:(0,l.__)("Em Dash","consistency"),description:(0,l.__)("Replace three hyphens with an em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>---</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">—</code></span>",mask:/(?:–|\-\-)\-/,replace:"—",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"4hyphens",name:(0,l.__)("Two-Em Dash","consistency"),description:(0,l.__)("Replace four hyphens with two-em dash:","consistency")+"<span aria-hidden='true' style='display:block;'><code>----</code> <span style='font-size:20px'>→</span> <code style=\"font-family:sans-serif;\">⸺</code></span>",mask:/(?:—|–\-|\-\-\-)\-/,replace:"⸺",nbMoved:e=>-(e.length-1),category:"dash"},{slug:"ordinalNumberSuffix",name:(0,l.__)("Ordinal Number Suffix","consistency"),description:(0,l.__)("Add the sup HTML tag to ordinal number suffixes","consistency")+"<span aria-hidden='true' style='display:block;'><code>1st</code> <span style='font-size:20px'>→</span> <code>1<sup>st</sup></code></span>",mask:/([10-9]{1,20})(th|nd|rd|e|er|res|d|ds|de|des)( | |\.|\,|\;)/,replace:"$1<sup>$2</sup>$3",nbMoved:0,category:"suffixe"},{slug:"regularToCurlyQuotes",name:(0,l.__)("Curly Quotes","consistency"),description:(0,l.__)("Replace straight quotes with curly quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>“ ”</code></span>",mask:/"/,replace:"“$1”",nbMoved:0,category:"quotation"},{slug:"regularToGermanQuotes",name:(0,l.__)("German Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>„ “</code></span>",mask:/"/,replace:"„$1“",nbMoved:0,category:"quotation"},{slug:"regularToGermanBookStyleQuotes",name:(0,l.__)("German Book-Style Quotes","consistency"),description:(0,l.__)("Replace straight quotes with german book-style quotes:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>» «</code></span>",mask:/"/,replace:"»$1«",nbMoved:0,category:"quotation"},{slug:"regularToFrenchQuotes",name:(0,l.__)("French Quotes with Spaces","consistency"),description:(0,l.__)("Replace straight quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"« $1 »",nbMoved:1,category:"quotation"},{slug:"regularToFrenchQuotesWithoutSpaces",name:(0,l.__)("French Quotes","consistency"),description:(0,l.__)("Replace straight quotes with french quotes without spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>\" \"</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/"/,replace:"«$1»",nbMoved:0,category:"quotation"},{slug:"curlyToFrenchQuotes",name:(0,l.__)("Curly Quotes to French Quotes","consistency"),description:(0,l.__)("Replace curly quotes with french quotes with non-breaking spaces:","consistency")+"<span aria-hidden='true' style='display:block;'><code>“ ”</code> <span style='font-size:20px'>→</span> <code>« »</code></span>",mask:/“.*?”/,replace:e=>`« ${e.substring(1,e.length-1)} »`,nbMoved:0,category:"quotation"},{slug:"breakingSpace",name:(0,l.__)("Breaking Spaces","consistency"),description:sprintf((0,l.__)("Replace a breaking space followed by a character from this list:%1$s with a non-breaking space","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/ ([\?|\!|\:|\;|»|€|\$|£|¥|₽|元|\%])/,replace:" $1",nbMoved:0,category:"space"},{slug:"noSpaceBefore",name:(0,l.__)("No Space Before","consistency"),description:sprintf((0,l.__)("Add a non-breaking space before a character from this list:%1$s having no space before","consistency"),"<br /><code>? ! : ; » € $ £ ¥ ₽ 元 %</code><br />"),mask:/(?<! | | )([\?|\!|\:|»|€|\$|£|¥|₽|元|\%])/,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})}))})(); -
consistency/trunk/consistency.php
r3142172 r3145550 4 4 * Plugin URI: https://www.webaxones.com 5 5 * Description: Fixes typographic and punctuation consistency 6 * Version: 1.8. 06 * Version: 1.8.1 7 7 * Requires at least: 6.1 8 8 * Requires PHP: 7.4 -
consistency/trunk/includes/Plugin.php
r3142172 r3145550 33 33 protected static function setConstants(): void 34 34 { 35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8. 0' );35 defined( __NAMESPACE__ . '\VERSION' ) || define( __NAMESPACE__ . '\VERSION', '1.8.1' ); 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/includes/Utils/Concerns/ObjectArrayTrait.php
r2857933 r3145550 23 23 $array1, 24 24 $array2, 25 function ( $a, $b ) {25 function ( $a, $b ) { 26 26 return strcmp( $a['slug'], $b['slug'] ); 27 27 } -
consistency/trunk/package.json
r3142172 r3145550 1 1 { 2 2 "name": "consistency", 3 "version": "1.8. 0",3 "version": "1.8.1", 4 4 "description": "", 5 5 "main": "index.js", -
consistency/trunk/readme.txt
r3142172 r3145550 4 4 Requires at least: 6.1 5 5 Tested up to: 6.6 6 Stable tag: 1.8. 06 Stable tag: 1.8.1 7 7 Requires PHP: 7.4 8 8 License: GPL-3.0-or-later … … 70 70 == Changelog == 71 71 72 = 1.8.1 = 73 * Fix: Resolves incompatibilities with block plugins such as Kadence, GeneratePress, etc. 74 * Fix: Fix the names of enabled or disabled rules in the notices 75 72 76 = 1.8.0 = 73 77 * Update: code refactoring (replace global variables with global context, some functions with custom hooks, and allow to process more blocks) -
consistency/trunk/src/app/checks.js
r3142172 r3145550 68 68 69 69 const blockAttributes = getBlockAttributes( currentBlockId ) 70 70 71 71 if ( ! blockAttributes || ! blockAttributes.hasOwnProperty( 'content' ) ) return false 72 72 -
consistency/trunk/src/app/fixes.js
r3142172 r3145550 20 20 import { shouldProcessBlock, canProcessBlock, regDealWithPair } from './checks' 21 21 22 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping, getBlockSelectionStart } = select( 'core/block-editor' ) 23 const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' ) 24 22 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' ) 23 const { updateBlockAttributes } = dispatch( 'core/block-editor' ) 25 24 26 25 … … 30 29 * @param {Object} props - The props object. 31 30 * @param {string} props.currentBlockId - The ID of the current block. 32 * @param {boolean} props.isPasting - Indicates if the content is being pasted.33 31 * @param {boolean} props.isPreviousFixCanceled - Indicates if the previous fix was canceled. 34 32 * @param {function} props.setPreviousFixCanceled - The function to set the previous fix canceled state. 35 33 * @param {Array} props.blocksToBeProcessed - The blocks to be processed: we pass them as props to avoid using global context since we are not in a component. 34 * @param {Ref} props.cursorOffsetRef - The reference to the cursor offset. 36 35 */ 37 36 export const fixIt = props => { 38 37 39 const { currentBlockId, isP asting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed} = props38 const { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props 40 39 41 40 // Check if the current block should be processed and can be processed … … 136 135 contentUpdated = updateBlockTextContent( { block, currentBlockId, blockAttributes, blockContent } ) 137 136 } 138 139 // Cursor repositioning:140 if ( 0 === cursorPosition || isPasting ) return141 137 142 138 // Get the number of characters moved by the replacement: needed for cursor repositioning. … … 144 140 const nbMoved = typeof reg.nbMoved === 'function' ? reg.nbMoved( lastPart ) : reg.nbMoved || 0 145 141 146 let attributeKey = selectionStart.hasOwnProperty( 'attributeKey' ) ? selectionStart.attributeKey : 'content' 147 148 // If the replaced string had more characters than the new string, the cursor has moved forward, so it must be moved back 149 // Eg: ... replaced with … removes 2 characters 150 if ( nbMoved < 0 ) { 151 selectionChange( currentBlockId, attributeKey, cursorPosition + nbMoved, cursorPosition + nbMoved ) 152 } 153 154 // If the replaced string had fewer characters than the new string, the cursor has moved backwards, so it must be moved forward 155 // Eg: "" replaced with « » adds 2 characters 156 if ( nbMoved > 0 ) { 157 selectionChange( currentBlockId, attributeKey, cursorPosition + 1 + nbMoved, cursorPosition + nbMoved ) 158 } 159 160 if ( 0 === nbMoved ) { 161 selectionChange( currentBlockId, attributeKey, cursorPosition, cursorPosition ) 142 // Set the cursor offset 143 if ( contentUpdated ) { 144 cursorOffsetRef.current = nbMoved 162 145 } 163 146 … … 167 150 168 151 /** 169 * Fixes all blocks generated by pasting. 152 * Fix all blocks generated by pasting based on the provided rules and blocks to be processed. 153 * 154 * @param {Object} props - The props object containing necessary data. 155 * @param {boolean} props.isPreviousFixCanceled - Flag indicating if the previous fix was canceled. 156 * @param {function} props.setPreviousFixCanceled - Function to set the flag indicating if the previous fix was canceled. 157 * @param {Array} props.blocksToBeProcessed - Array of block names to be processed. 158 * @param {Ref} props.cursorOffsetRef - Reference to the cursor offset. 170 159 */ 171 160 export const fixAll = props => { 172 161 173 const { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed} = props162 const { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } = props 174 163 175 164 // Get the relevant rules … … 224 213 225 214 // Select all innerBlocks to trigger their correction, then deselect all by selecting the first block 226 const isPasting = true227 215 allInners.forEach( block => { 228 216 229 217 if ( ! blocksToBeProcessed.includes( block.name ) ) return 230 218 const currentBlockId = block.clientId 231 block?.clientId && fixIt( { currentBlockId, isP asting, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed} )219 block?.clientId && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } ) 232 220 233 221 } ) -
consistency/trunk/src/app/helpers.js
r3142172 r3145550 5 5 * @author Loïc Antignac. 6 6 */ 7 8 import { select, dispatch } from '@wordpress/data' 9 const { getBlock, getBlocks, getBlockAttributes, getSelectionStart, isTyping } = select( 'core/block-editor' ) 10 const { selectionChange, updateBlockAttributes } = dispatch( 'core/block-editor' ) 7 11 8 12 /** … … 81 85 82 86 } 87 88 /** 89 * Moves the cursor to right position after fixing the content. 90 * We use window.getSelection() and not the editor's selectionChange() to avoid to trigger a new state change. 91 * 92 * @returns {void} 93 */ 94 export const moveCursorToNewPosition = cursorOffset => { 95 96 const selection = window.getSelection() 97 98 // Stop here if no selection or if the selection anchor node is null 99 if ( ! selection ) return 100 101 // Get current cursor position 102 let cursorPosition 103 104 // Element node case: we need to get the first text node from the element node 105 if ( selection?.anchorNode?.nodeType === 1 ) { 106 cursorPosition = selection.anchorNode?.firstChild?.length || 0 107 } 108 109 // Text node case 110 if ( selection?.anchorNode?.nodeType === 3 ) { 111 cursorPosition = selection.anchorOffset || 0 112 } 113 114 // If the cursorOffset is positive, newPosition equals cursorPosition + cursorOffset, else newPosition equals cursorPosition 115 const newPosition = cursorOffset >= 0 ? cursorPosition + cursorOffset : cursorPosition 116 117 // Element node 118 if ( selection?.anchorNode?.nodeType === 1 ) { 119 120 // If the anchor node is an element node, we have to get the first text node from it 121 const textNode = selection.anchorNode?.firstChild || selection.anchorNode?.childNodes[ 0 ] 122 selection.collapse( textNode, newPosition ) 123 return 124 125 } 126 127 // Text node 128 if ( selection?.anchorNode?.nodeType === 3 ) { 129 130 // If the anchor node is a text node, we have to get the parent element node 131 const textNode = selection.anchorNode 132 selection.collapse( textNode, newPosition ) 133 return 134 135 } 136 137 } -
consistency/trunk/src/components/ConsistencyPlugin.js
r3142172 r3145550 39 39 40 40 // Render the settings sidebar 41 return (42 <SidebarSettings />43 )41 return ( 42 <SidebarSettings /> 43 ) 44 44 } 45 45 -
consistency/trunk/src/components/GlobalSettingPanel.js
r3142172 r3145550 42 42 key={ key } 43 43 settingSlug={ rule.slug } 44 name={ rule.name }44 settingName={ rule.name } 45 45 settingDescription={ { 46 46 __html: rule.description -
consistency/trunk/src/components/GlobalSettingToggle.js
r3142172 r3145550 63 63 } 64 64 65 return(65 return( 66 66 <PanelRow> 67 67 <ToggleControl … … 73 73 /> 74 74 </PanelRow> 75 )75 ) 76 76 } -
consistency/trunk/src/components/LocaleLabel.js
r3142172 r3145550 27 27 : __( ' (all locales)', 'consistency' ) 28 28 29 return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> )29 return( <span style={{ fontWeight: "normal", fontStyle: "italic", fontSize: "smaller" }}>{ localizationManagementLabel }</span> ) 30 30 } -
consistency/trunk/src/components/Settings.js
r3142172 r3145550 26 26 const isAdmin = canUser( 'create', 'users' ) 27 27 28 return(29 <>28 return( 29 <> 30 30 <PluginSidebar 31 name='consistency-custom-sidebar'32 title={ __( 'Consistency', 'consistency' ) }31 name='consistency-custom-sidebar' 32 title={ __( 'Consistency', 'consistency' ) } 33 33 icon={ ConsistencyIcon } 34 >34 > 35 35 <UserSettingPanel /> 36 36 { isAdmin && <GlobalSettingPanel/> } 37 </PluginSidebar>38 <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'>37 </PluginSidebar> 38 <PluginSidebarMoreMenuItem target='consistency-custom-sidebar'> 39 39 { __( 'Consistency Settings', 'consistency' ) } 40 40 </PluginSidebarMoreMenuItem> 41 </>42 )41 </> 42 ) 43 43 } -
consistency/trunk/src/components/UserSettingPanel.js
r3142172 r3145550 21 21 */ 22 22 const UserSettingPanel = () => ( 23 <Panel className='UserSettingPanel'>23 <Panel className='UserSettingPanel'> 24 24 <PanelHeader><strong>{ __( 'Settings for my account', 'consistency' ) }</strong><br/></PanelHeader> 25 <div style={{ padding: 16 }}>26 <PanelRow>27 <UserSettingToggle28 settingSlug='on_the_fly'29 settingName={ __( 'On-the-fly autocorrect', 'consistency' ) }30 settingDescription={ {31 __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' )32 } }33 />34 </PanelRow>35 <PanelRow>36 <UserSettingToggle37 settingSlug='on_paste'38 settingName={ __( 'On paste autocorrect', 'consistency' ) }39 settingDescription={ {40 __html: __( 'Enable/disable autocorrect on paste', 'consistency' )41 } }42 />43 </PanelRow>44 </div>45 </Panel>25 <div style={{ padding: 16 }}> 26 <PanelRow> 27 <UserSettingToggle 28 settingSlug='on_the_fly' 29 settingName={ __( 'On-the-fly autocorrect', 'consistency' ) } 30 settingDescription={ { 31 __html: __( 'Enable/disable on-the-fly autocorrect', 'consistency' ) 32 } } 33 /> 34 </PanelRow> 35 <PanelRow> 36 <UserSettingToggle 37 settingSlug='on_paste' 38 settingName={ __( 'On paste autocorrect', 'consistency' ) } 39 settingDescription={ { 40 __html: __( 'Enable/disable autocorrect on paste', 'consistency' ) 41 } } 42 /> 43 </PanelRow> 44 </div> 45 </Panel> 46 46 ) 47 47 -
consistency/trunk/src/components/UserSettingToggle.js
r3142172 r3145550 59 59 } 60 60 61 return(62 <ToggleControl63 label={ settingName }61 return( 62 <ToggleControl 63 label={ settingName } 64 64 help={ ( <span dangerouslySetInnerHTML={ settingDescription } /> ) } 65 checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false }66 onChange={ onSettingChanged }67 />68 )65 checked={ settings?.consistency_plugin_user_settings?.find( x => x.slug === settingSlug )?.value || false } 66 onChange={ onSettingChanged } 67 /> 68 ) 69 69 } -
consistency/trunk/src/contexts/GlobalContext.js
r3142172 r3145550 30 30 // This variable is used to check if custom fields are active because the editor content is within an iframe when custom fields are inactive 31 31 const [ isEditorInIframe ] = useState( document.querySelector( 'iframe[name="editor-canvas"]' ) !== null ) 32 32 33 // This variable is used to avoid new fixes when the user is undoing a fix with CTRL/CMD Z 33 34 const [ isPreviousFixCanceled, setPreviousFixCanceled ] = useState( false ) 35 34 36 // This variable is used to store the content of the block to avoid fixing it if it has not changed since we check at every state change 35 37 const [ previousFixCanceledContent, setPreviousFixCanceledContent ] = useState( '' ) 38 36 39 // This variable is used to store the blocks allowed to be processed 37 40 const [ blocksToBeProcessed, setBlocksToBeProcessed ] = useState( [] ) 41 42 // This variable is used to store the number of characters lost or gained by the correction in order to move the cursor accordingly 43 const cursorOffsetRef = useRef( 0 ) 44 38 45 // This ref is used to track if content has been past 39 46 const isContentPastedRef = useRef( false ) 40 47 41 48 // Return the global provider 42 return (43 <GlobalContext.Provider value={ {44 isEditorInIframe,45 isPreviousFixCanceled,46 setPreviousFixCanceled,49 return ( 50 <GlobalContext.Provider value={ { 51 isEditorInIframe, 52 isPreviousFixCanceled, 53 setPreviousFixCanceled, 47 54 previousFixCanceledContent, 48 setPreviousFixCanceledContent,55 setPreviousFixCanceledContent, 49 56 blocksToBeProcessed, 50 57 setBlocksToBeProcessed, 58 cursorOffsetRef, 51 59 isContentPastedRef 52 } }>53 { children }54 </GlobalContext.Provider>55 )60 } }> 61 { children } 62 </GlobalContext.Provider> 63 ) 56 64 } 57 65 -
consistency/trunk/src/hooks/useEditorEffects.js
r3142172 r3145550 21 21 import { fixIt, fixAll } from '../app/fixes' 22 22 import { fetchCurrentUserSettings } from '../app/data' 23 import { getLocalizedRuleSettings } from '../app/helpers'23 import { moveCursorToNewPosition, getLocalizedRuleSettings } from '../app/helpers' 24 24 25 25 // Get the current selected block and its attributes … … 30 30 * Global variables in global context 31 31 */ 32 const {32 const { 33 33 isPreviousFixCanceled, 34 setPreviousFixCanceled,34 setPreviousFixCanceled, 35 35 previousFixCanceledContent, 36 setPreviousFixCanceledContent,36 setPreviousFixCanceledContent, 37 37 blocksToBeProcessed, 38 cursorOffsetRef, 38 39 isContentPastedRef 39 } = useContext( GlobalContext ) 40 } = useContext( GlobalContext ) 41 42 // Initialize the cursorOffset variable if it is undefined 43 cursorOffsetRef.current = cursorOffsetRef.current || 0 40 44 41 45 // Initialize the isContentPastedRef variable if it is undefined 42 if ( isContentPastedRef.current === undefined ) { 43 isContentPastedRef.current = false 44 } 46 isContentPastedRef.current = isContentPastedRef.current || false 45 47 46 useEffect( () => {48 useEffect( () => { 47 49 48 50 // Let’s listen for state changes 49 51 const unsubscribe = subscribe( () => { 50 52 51 // Get current user settings to check if we have to fix the content or to stop here53 // Get current user settings to check if we have to fix the content or to stop here 52 54 const { onTheFly, onPaste } = fetchCurrentUserSettings() 53 if ( ! onTheFly && ! onPaste ) return55 if ( ! onTheFly && ! onPaste ) return 54 56 55 // Get fixing rules from site entity global settings57 // Get fixing rules from site entity global settings 56 58 const localizedRuleSettings = getLocalizedRuleSettings() 57 if ( localizedRuleSettings === undefined ) return59 if ( localizedRuleSettings === undefined ) return 58 60 59 // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here61 // If onPaste setting is enabled and if content has been copied/pasted generating blocks, we fix all blocks then stop here 60 62 if ( onPaste && isContentPastedRef.current === true ) { 61 63 isContentPastedRef.current = false 62 fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, localizedRuleSettings, blocksToBeProcessed} )64 fixAll( { isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } ) 63 65 return 64 }66 } 65 67 66 68 // Get current selected block 67 const currentBlockId = getSelectedBlockClientId()69 const currentBlockId = getSelectedBlockClientId() 68 70 69 71 // Stop here if no block is selected or if fixing on the fly is disabled 70 if ( currentBlockId === null || ! onTheFly ) return72 if ( currentBlockId === null || ! onTheFly ) return 71 73 72 74 // Don't try to fix block content if nothing has changed … … 79 81 80 82 // Store the block content to avoid fixing it twice at the next state change 81 setPreviousFixCanceledContent( blockAttributes.content )83 setPreviousFixCanceledContent( blockAttributes.content ) 82 84 83 85 // Fix the current selected block 84 isTyping() && fixIt( { currentBlockId, isPasting: false, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed } ) 85 } ) 86 isTyping() && fixIt( { currentBlockId, isPreviousFixCanceled, setPreviousFixCanceled, blocksToBeProcessed, cursorOffsetRef } ) 87 88 } ) 86 89 87 90 // Unsubscribe when the component is unmounted 88 return () => unsubscribe() 91 return () => { 92 unsubscribe() 93 94 // Move cursor to the new position 95 moveCursorToNewPosition( cursorOffsetRef.current ) 89 96 90 }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, isContentPastedRef ] ) 97 // Reset cursorOffsetRef 98 cursorOffsetRef.current = 0 99 } 100 101 }, [ isPreviousFixCanceled, setPreviousFixCanceled, previousFixCanceledContent, setPreviousFixCanceledContent, blocksToBeProcessed, cursorOffsetRef, isContentPastedRef ] ) 91 102 } 92 103 -
consistency/trunk/src/hooks/usePasteEventHandler.js
r3142172 r3145550 27 27 const isPasteEventAttached = useRef( false ) 28 28 29 useEffect( () => {29 useEffect( () => { 30 30 31 31 // If the paste event has already been attached, return … … 49 49 50 50 // Get the target element depending on whether the editor is in an iframe or not 51 const targetElement = isEditorInIframe51 const targetElement = isEditorInIframe 52 52 ? document.querySelector( 'iframe[name="editor-canvas"]' ) 53 53 : document.querySelector( '#editor' ) 54 54 55 if ( ! targetElement ) return55 if ( ! targetElement ) return 56 56 57 // Attach the paste event listener and get the cleanup function58 const cleanup = attachPasteEventListener( targetElement )57 // Attach the paste event listener and get the cleanup function 58 const cleanup = attachPasteEventListener( targetElement ) 59 59 60 // If the iframe is already loaded, manually trigger the event listener attachment61 if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) {62 attachPasteEventListener( targetElement )63 }60 // If the iframe is already loaded, manually trigger the event listener attachment 61 if ( isEditorInIframe && targetElement.contentWindow.document.readyState === 'complete' ) { 62 attachPasteEventListener( targetElement ) 63 } 64 64 65 65 // Update the ref to track if the paste event has been attached 66 66 isPasteEventAttached.current = true 67 67 68 // Return the cleanup function to be called when the component unmounts or before the effect re-runs69 return cleanup68 // Return the cleanup function to be called when the component unmounts or before the effect re-runs 69 return cleanup 70 70 71 }, [ isEditorInIframe ] )71 }, [ isEditorInIframe ] ) 72 72 } 73 73 -
consistency/trunk/src/hooks/useSetAllowedBlocks.js
r3142172 r3145550 30 30 } ) 31 31 32 // Remove blocks beginning with kadence/ from the list since it doesn't work with them 33 richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! block.name.startsWith( 'kadence/' ) ) 34 35 // Remove blocks from the list cause we don't want to alter them (core/html) or they don't work properly (core/freeform) 36 const blocksToExclude = [ 'core/html', 'core/freeform' ] 32 // Remove blocks from the list cause we don't want to alter them (core/html) 33 const blocksToExclude = [ 'core/html' ] 37 34 richTextAndStringContentTypes = richTextAndStringContentTypes.filter( block => ! blocksToExclude.includes( block.name ) ) 38 35 39 console.log( 'Consistency - Processed blocks:', richTextAndStringContentTypes );36 console.log( 'Consistency - Blocks that can be processed:', richTextAndStringContentTypes ); 40 37 41 38 // Set the blocks to be processed in the global context -
consistency/trunk/src/index.js
r3142172 r3145550 22 22 23 23 const PluginWrapper = () => ( 24 <GlobalProvider>25 <ConsistencyPlugin />26 </GlobalProvider>24 <GlobalProvider> 25 <ConsistencyPlugin /> 26 </GlobalProvider> 27 27 ) 28 28 29 29 domReady( () => { 30 registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } )30 registerPlugin( 'consistency-custom-sidebar', { render: PluginWrapper } ) 31 31 } )
Note: See TracChangeset
for help on using the changeset viewer.