@wordpress/format-library 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/build/bold/index.js +5 -2
  2. package/build/bold/index.js.map +1 -1
  3. package/build/code/index.js +4 -2
  4. package/build/code/index.js.map +1 -1
  5. package/build/italic/index.js +5 -2
  6. package/build/italic/index.js.map +1 -1
  7. package/build/keyboard/index.js +4 -2
  8. package/build/keyboard/index.js.map +1 -1
  9. package/build/link/inline.js +56 -5
  10. package/build/link/inline.js.map +1 -1
  11. package/build/link/utils.js +112 -0
  12. package/build/link/utils.js.map +1 -1
  13. package/build/strikethrough/index.js +4 -2
  14. package/build/strikethrough/index.js.map +1 -1
  15. package/build/subscript/index.js +4 -2
  16. package/build/subscript/index.js.map +1 -1
  17. package/build/superscript/index.js +4 -2
  18. package/build/superscript/index.js.map +1 -1
  19. package/build/text-color/index.js +2 -1
  20. package/build/text-color/index.js.map +1 -1
  21. package/build/text-color/inline.js +9 -2
  22. package/build/text-color/inline.js.map +1 -1
  23. package/build/underline/index.js +4 -2
  24. package/build/underline/index.js.map +1 -1
  25. package/build-module/bold/index.js +5 -2
  26. package/build-module/bold/index.js.map +1 -1
  27. package/build-module/code/index.js +4 -2
  28. package/build-module/code/index.js.map +1 -1
  29. package/build-module/italic/index.js +5 -2
  30. package/build-module/italic/index.js.map +1 -1
  31. package/build-module/keyboard/index.js +4 -2
  32. package/build-module/keyboard/index.js.map +1 -1
  33. package/build-module/link/inline.js +58 -7
  34. package/build-module/link/inline.js.map +1 -1
  35. package/build-module/link/utils.js +110 -1
  36. package/build-module/link/utils.js.map +1 -1
  37. package/build-module/strikethrough/index.js +4 -2
  38. package/build-module/strikethrough/index.js.map +1 -1
  39. package/build-module/subscript/index.js +4 -2
  40. package/build-module/subscript/index.js.map +1 -1
  41. package/build-module/superscript/index.js +4 -2
  42. package/build-module/superscript/index.js.map +1 -1
  43. package/build-module/text-color/index.js +2 -1
  44. package/build-module/text-color/index.js.map +1 -1
  45. package/build-module/text-color/inline.js +10 -3
  46. package/build-module/text-color/inline.js.map +1 -1
  47. package/build-module/underline/index.js +6 -2
  48. package/build-module/underline/index.js.map +1 -1
  49. package/package.json +10 -10
  50. package/src/bold/index.js +2 -2
  51. package/src/code/index.js +2 -1
  52. package/src/italic/index.js +2 -2
  53. package/src/keyboard/index.js +2 -1
  54. package/src/link/inline.js +67 -5
  55. package/src/link/test/utils.js +362 -1
  56. package/src/link/utils.js +132 -1
  57. package/src/strikethrough/index.js +2 -1
  58. package/src/subscript/index.js +2 -1
  59. package/src/superscript/index.js +2 -1
  60. package/src/text-color/index.js +1 -0
  61. package/src/text-color/inline.js +12 -1
  62. package/src/underline/index.js +3 -1
@@ -34,12 +34,15 @@ const bold = {
34
34
  }) {
35
35
  function onToggle() {
36
36
  onChange((0, _richText.toggleFormat)(value, {
37
- type: name
37
+ type: name,
38
+ title
38
39
  }));
39
40
  }
40
41
 
41
42
  function onClick() {
42
- onToggle();
43
+ onChange((0, _richText.toggleFormat)(value, {
44
+ type: name
45
+ }));
43
46
  onFocus();
44
47
  }
45
48
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/bold/index.js"],"names":["name","title","bold","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","formatBold"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;AAUA,MAAMA,IAAI,GAAG,WAAb;AACA,MAAMC,KAAK,GAAG,cAAI,MAAJ,CAAd;AAEO,MAAMC,IAAI,GAAG;AACnBF,EAAAA,IADmB;AAEnBC,EAAAA,KAFmB;AAGnBE,EAAAA,OAAO,EAAE,QAHU;AAInBC,EAAAA,SAAS,EAAE,IAJQ;;AAKnBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACA;;AAED,aAASY,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,MADN;AAEC,MAAA,IAAI,EAAGG,iBAFR;AAGC,MAAA,KAAK,EAAGZ,KAHT;AAIC,MAAA,OAAO,EAAGW,OAJX;AAKC,MAAA,QAAQ,EAAGN,QALZ;AAMC,MAAA,YAAY,EAAC,SANd;AAOC,MAAA,iBAAiB,EAAC;AAPnB,MAND,EAeC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,YADX;AAEC,MAAA,OAAO,EAAGI;AAFX,MAfD,CADD;AAsBA;;AArCkB,CAAb","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"b\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"bold\"\n\t\t\t\t\ticon={ formatBold }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"b\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatBold\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/bold/index.js"],"names":["name","title","bold","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","formatBold"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;AAUA,MAAMA,IAAI,GAAG,WAAb;AACA,MAAMC,KAAK,GAAG,cAAI,MAAJ,CAAd;AAEO,MAAMC,IAAI,GAAG;AACnBF,EAAAA,IADmB;AAEnBC,EAAAA,KAFmB;AAGnBE,EAAAA,OAAO,EAAE,QAHU;AAInBC,EAAAA,SAAS,EAAE,IAJQ;;AAKnBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBJ,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,MADN;AAEC,MAAA,IAAI,EAAGG,iBAFR;AAGC,MAAA,KAAK,EAAGZ,KAHT;AAIC,MAAA,OAAO,EAAGW,OAJX;AAKC,MAAA,QAAQ,EAAGN,QALZ;AAMC,MAAA,YAAY,EAAC,SANd;AAOC,MAAA,iBAAiB,EAAC;AAPnB,MAND,EAeC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,YADX;AAEC,MAAA,OAAO,EAAGI;AAFX,MAfD,CADD;AAsBA;;AArCkB,CAAb","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"b\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"bold\"\n\t\t\t\t\ticon={ formatBold }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"b\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatBold\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
@@ -68,7 +68,8 @@ const code = {
68
68
  }) {
69
69
  function onClick() {
70
70
  onChange((0, _richText.toggleFormat)(value, {
71
- type: name
71
+ type: name,
72
+ title
72
73
  }));
73
74
  onFocus();
74
75
  }
@@ -77,7 +78,8 @@ const code = {
77
78
  icon: _icons.code,
78
79
  title: title,
79
80
  onClick: onClick,
80
- isActive: isActive
81
+ isActive: isActive,
82
+ role: "menuitemcheckbox"
81
83
  });
82
84
  }
83
85
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/code/index.js"],"names":["name","title","code","tagName","className","__unstableInputRule","value","BACKTICK","start","text","characterBefore","slice","textBefore","indexBefore","lastIndexOf","startIndex","endIndex","type","edit","onChange","onFocus","isActive","onClick","codeIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,WAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,IAAI,GAAG;AACnBF,EAAAA,IADmB;AAEnBC,EAAAA,KAFmB;AAGnBE,EAAAA,OAAO,EAAE,MAHU;AAInBC,EAAAA,SAAS,EAAE,IAJQ;;AAKnBC,EAAAA,mBAAmB,CAAEC,KAAF,EAAU;AAC5B,UAAMC,QAAQ,GAAG,GAAjB;AACA,UAAM;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAkBH,KAAxB;AACA,UAAMI,eAAe,GAAGD,IAAI,CAACE,KAAL,CAAYH,KAAK,GAAG,CAApB,EAAuBA,KAAvB,CAAxB,CAH4B,CAK5B;;AACA,QAAKE,eAAe,KAAKH,QAAzB,EAAoC;AACnC,aAAOD,KAAP;AACA;;AAED,UAAM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ormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { code as codeIcon } from '@wordpress/icons';\n\nconst name = 'core/code';\nconst title = __( 'Inline code' );\n\nexport const code = {\n\tname,\n\ttitle,\n\ttagName: 'code',\n\tclassName: null,\n\t__unstableInputRule( value ) {\n\t\tconst BACKTICK = '`';\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// Quick check the text for the necessary character.\n\t\tif ( characterBefore !== BACKTICK ) {\n\t\t\treturn value;\n\t\t}\n\n\t\tconst textBefore = text.slice( 0, start - 1 );\n\t\tconst indexBefore = textBefore.lastIndexOf( BACKTICK );\n\n\t\tif ( indexBefore === -1 ) {\n\t\t\treturn value;\n\t\t}\n\n\t\tconst startIndex = indexBefore;\n\t\tconst endIndex = start - 2;\n\n\t\tif ( startIndex === endIndex ) {\n\t\t\treturn value;\n\t\t}\n\n\t\tvalue = remove( value, startIndex, startIndex + 1 );\n\t\tvalue = remove( value, endIndex, endIndex + 1 );\n\t\tvalue = applyFormat( value, { type: name }, startIndex, endIndex );\n\n\t\treturn value;\n\t},\n\tedit( { value, onChange, onFocus, isActive } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ codeIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/code/index.js"],"names":["name","title","code","tagName","className","__unstableInputRule","value","BACKTICK","start","text","characterBefore","slice","textBefore","indexBefore","lastIndexOf","startIndex","endIndex","type","edit","onChange","onFocus","isActive","onClick","codeIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,WAAb;AAC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EZ,IAAAA,KAAF;AAASa,IAAAA,QAAT;AAAmBC,IAAAA,OAAnB;AAA4BC,IAAAA;AAA5B,GAAF,EAA2C;AAC9C,aAASC,OAAT,GAAmB;AAClBH,MAAAA,QAAQ,CAAE,4BAAcb,KAAd,EAAqB;AAAEW,QAAAA,IAAI,EAAEjB,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACAmB,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGG,WADR;AAEC,MAAA,KAAK,EAAGtB,KAFT;AAGC,MAAA,OAAO,EAAGqB,OAHX;AAIC,MAAA,QAAQ,EAAGD,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAlDkB,CAAb","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat, remove, applyFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { code as codeIcon } from '@wordpress/icons';\n\nconst name = 'core/code';\nconst title = __( 'Inline code' );\n\nexport const code = {\n\tname,\n\ttitle,\n\ttagName: 'code',\n\tclassName: null,\n\t__unstableInputRule( value ) {\n\t\tconst BACKTICK = '`';\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// Quick check the text for the necessary character.\n\t\tif ( characterBefore !== BACKTICK ) {\n\t\t\treturn value;\n\t\t}\n\n\t\tconst textBefore = text.slice( 0, start - 1 );\n\t\tconst indexBefore = textBefore.lastIndexOf( BACKTICK );\n\n\t\tif ( indexBefore === -1 ) {\n\t\t\treturn value;\n\t\t}\n\n\t\tconst startIndex = indexBefore;\n\t\tconst endIndex = start - 2;\n\n\t\tif ( startIndex === endIndex ) {\n\t\t\treturn value;\n\t\t}\n\n\t\tvalue = remove( value, startIndex, startIndex + 1 );\n\t\tvalue = remove( value, endIndex, endIndex + 1 );\n\t\tvalue = applyFormat( value, { type: name }, startIndex, endIndex );\n\n\t\treturn value;\n\t},\n\tedit( { value, onChange, onFocus, isActive } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ codeIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -34,12 +34,15 @@ const italic = {
34
34
  }) {
35
35
  function onToggle() {
36
36
  onChange((0, _richText.toggleFormat)(value, {
37
- type: name
37
+ type: name,
38
+ title
38
39
  }));
39
40
  }
40
41
 
41
42
  function onClick() {
42
- onToggle();
43
+ onChange((0, _richText.toggleFormat)(value, {
44
+ type: name
45
+ }));
43
46
  onFocus();
44
47
  }
45
48
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/italic/index.js"],"names":["name","title","italic","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","formatItalic"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;AAUA,MAAMA,IAAI,GAAG,aAAb;AACA,MAAMC,KAAK,GAAG,cAAI,QAAJ,CAAd;AAEO,MAAMC,MAAM,GAAG;AACrBF,EAAAA,IADqB;AAErBC,EAAAA,KAFqB;AAGrBE,EAAAA,OAAO,EAAE,IAHY;AAIrBC,EAAAA,SAAS,EAAE,IAJU;;AAKrBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACA;;AAED,aAASY,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,QADN;AAEC,MAAA,IAAI,EAAGG,mBAFR;AAGC,MAAA,KAAK,EAAGZ,KAHT;AAIC,MAAA,OAAO,EAAGW,OAJX;AAKC,MAAA,QAAQ,EAAGN,QALZ;AAMC,MAAA,YAAY,EAAC,SANd;AAOC,MAAA,iBAAiB,EAAC;AAPnB,MAND,EAeC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,cADX;AAEC,MAAA,OAAO,EAAGI;AAFX,MAfD,CADD;AAsBA;;AArCoB,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"i\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"italic\"\n\t\t\t\t\ticon={ formatItalic }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"i\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatItalic\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/italic/index.js"],"names":["name","title","italic","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","formatItalic"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;AAUA,MAAMA,IAAI,GAAG,aAAb;AACA,MAAMC,KAAK,GAAG,cAAI,QAAJ,CAAd;AAEO,MAAMC,MAAM,GAAG;AACrBF,EAAAA,IADqB;AAErBC,EAAAA,KAFqB;AAGrBE,EAAAA,OAAO,EAAE,IAHY;AAIrBC,EAAAA,SAAS,EAAE,IAJU;;AAKrBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBJ,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,QADN;AAEC,MAAA,IAAI,EAAGG,mBAFR;AAGC,MAAA,KAAK,EAAGZ,KAHT;AAIC,MAAA,OAAO,EAAGW,OAJX;AAKC,MAAA,QAAQ,EAAGN,QALZ;AAMC,MAAA,YAAY,EAAC,SANd;AAOC,MAAA,iBAAiB,EAAC;AAPnB,MAND,EAeC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,cADX;AAEC,MAAA,OAAO,EAAGI;AAFX,MAfD,CADD;AAsBA;;AArCoB,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"i\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"italic\"\n\t\t\t\t\ticon={ formatItalic }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"i\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatItalic\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
@@ -34,7 +34,8 @@ const keyboard = {
34
34
  }) {
35
35
  function onToggle() {
36
36
  onChange((0, _richText.toggleFormat)(value, {
37
- type: name
37
+ type: name,
38
+ title
38
39
  }));
39
40
  }
40
41
 
@@ -47,7 +48,8 @@ const keyboard = {
47
48
  icon: _icons.button,
48
49
  title: title,
49
50
  onClick: onClick,
50
- isActive: isActive
51
+ isActive: isActive,
52
+ role: "menuitemcheckbox"
51
53
  });
52
54
  }
53
55
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/keyboard/index.js"],"names":["name","title","keyboard","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","button"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,eAAb;AACA,MAAMC,KAAK,GAAG,cAAI,gBAAJ,CAAd;AAEO,MAAMC,QAAQ,GAAG;AACvBF,EAAAA,IADuB;AAEvBC,EAAAA,KAFuB;AAGvBE,EAAAA,OAAO,EAAE,KAHc;AAIvBC,EAAAA,SAAS,EAAE,IAJY;;AAKvBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACA;;AAED,aAASY,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,aADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN;AAJZ,MADD;AAQA;;AAvBsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { button } from '@wordpress/icons';\n\nconst name = 'core/keyboard';\nconst title = __( 'Keyboard input' );\n\nexport const keyboard = {\n\tname,\n\ttitle,\n\ttagName: 'kbd',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ button }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/keyboard/index.js"],"names":["name","title","keyboard","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","button"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,eAAb;AACA,MAAMC,KAAK,GAAG,cAAI,gBAAJ,CAAd;AAEO,MAAMC,QAAQ,GAAG;AACvBF,EAAAA,IADuB;AAEvBC,EAAAA,KAFuB;AAGvBE,EAAAA,OAAO,EAAE,KAHc;AAIvBC,EAAAA,SAAS,EAAE,IAJY;;AAKvBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,aADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxBsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { button } from '@wordpress/icons';\n\nconst name = 'core/keyboard';\nconst title = __( 'Keyboard input' );\n\nexport const keyboard = {\n\tname,\n\ttitle,\n\ttagName: 'kbd',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ button }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -40,6 +40,9 @@ function InlineLinkUI({
40
40
  stopAddingLink,
41
41
  contentRef
42
42
  }) {
43
+ const richLinkTextValue = getRichTextValueFromSelection(value, isActive); // Get the text content minus any HTML tags.
44
+
45
+ const richTextText = richLinkTextValue.text;
43
46
  /**
44
47
  * Pending settings to be applied to the next link. When inserting a new
45
48
  * link, toggle values cannot be applied immediately, because there is not
@@ -48,6 +51,7 @@ function InlineLinkUI({
48
51
  *
49
52
  * @type {[Object|undefined,Function]}
50
53
  */
54
+
51
55
  const [nextLinkValue, setNextLinkValue] = (0, _element.useState)();
52
56
  const {
53
57
  createPageEntity,
@@ -69,6 +73,7 @@ function InlineLinkUI({
69
73
  type: activeAttributes.type,
70
74
  id: activeAttributes.id,
71
75
  opensInNewTab: activeAttributes.target === '_blank',
76
+ title: richTextText,
72
77
  ...nextLinkValue
73
78
  };
74
79
 
@@ -101,21 +106,45 @@ function InlineLinkUI({
101
106
  }
102
107
 
103
108
  const newUrl = (0, _url.prependHTTP)(nextValue.url);
104
- const format = (0, _utils.createLinkFormat)({
109
+ const linkFormat = (0, _utils.createLinkFormat)({
105
110
  url: newUrl,
106
111
  type: nextValue.type,
107
112
  id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined,
108
113
  opensInNewWindow: nextValue.opensInNewTab
109
114
  });
115
+ const newText = nextValue.title || newUrl;
110
116
 
111
117
  if ((0, _richText.isCollapsed)(value) && !isActive) {
112
- const newText = nextValue.title || newUrl;
118
+ // Scenario: we don't have any actively selected text or formats.
113
119
  const toInsert = (0, _richText.applyFormat)((0, _richText.create)({
114
120
  text: newText
115
- }), format, 0, newText.length);
121
+ }), linkFormat, 0, newText.length);
116
122
  onChange((0, _richText.insert)(value, toInsert));
117
123
  } else {
118
- const newValue = (0, _richText.applyFormat)(value, format);
124
+ // Scenario: we have any active text selection or an active format
125
+ let newValue;
126
+
127
+ if (newText === richTextText) {
128
+ // If we're not updating the text then ignore
129
+ newValue = (0, _richText.applyFormat)(value, linkFormat);
130
+ } else {
131
+ // Create new RichText value for the new text in order that we
132
+ // can apply formats to it.
133
+ newValue = (0, _richText.create)({
134
+ text: newText
135
+ }); // Apply the new Link format to this new text value.
136
+
137
+ newValue = (0, _richText.applyFormat)(newValue, linkFormat, 0, newText.length); // Update the original (full) RichTextValue replacing the
138
+ // target text with the *new* RichTextValue containing:
139
+ // 1. The new text content.
140
+ // 2. The new link format.
141
+ // Note original formats will be lost when applying this change.
142
+ // That is expected behaviour.
143
+ // See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179.
144
+
145
+ newValue = (0, _richText.replace)(value, richTextText, newValue);
146
+ }
147
+
119
148
  newValue.start = newValue.end;
120
149
  newValue.activeFormats = [];
121
150
  onChange(newValue);
@@ -180,10 +209,32 @@ function InlineLinkUI({
180
209
  hasRichPreviews: true,
181
210
  createSuggestion: createPageEntity && handleCreate,
182
211
  withCreateSuggestion: userCanCreatePages,
183
- createSuggestionButtonText: createButtonText
212
+ createSuggestionButtonText: createButtonText,
213
+ hasTextControl: true
184
214
  }));
185
215
  }
186
216
 
217
+ function getRichTextValueFromSelection(value, isActive) {
218
+ // Default to the selection ranges on the RichTextValue object.
219
+ let textStart = value.start;
220
+ let textEnd = value.end; // If the format is currently active then the rich text value
221
+ // should always be taken from the bounds of the active format
222
+ // and not the selected text.
223
+
224
+ if (isActive) {
225
+ const boundary = (0, _utils.getFormatBoundary)(value, {
226
+ type: 'core/link'
227
+ });
228
+ textStart = boundary.start; // Text *selection* always extends +1 beyond the edge of the format.
229
+ // We account for that here.
230
+
231
+ textEnd = boundary.end + 1;
232
+ } // Get a RichTextValue containing the selected text content.
233
+
234
+
235
+ return (0, _richText.slice)(value, textStart, textEnd);
236
+ }
237
+
187
238
  var _default = (0, _components.withSpokenMessages)(InlineLinkUI);
188
239
 
189
240
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/inline.js"],"names":["InlineLinkUI","isActive","activeAttributes","addingLink","value","onChange","speak","stopAddingLink","contentRef","nextLinkValue","setNextLinkValue","createPageEntity","userCanCreatePages","select","getSettings","blockEditorStore","_settings","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","linkValue","url","type","id","opensInNewTab","target","removeLink","newValue","onChangeLink","nextValue","didToggleSetting","didToggleSettingForNewLink","undefined","newUrl","format","String","opensInNewWindow","newText","title","toInsert","text","length","start","end","activeFormats","anchorRef","ref","settings","focusOnMount","handleCreate","pageTitle","page","status","rendered","link","kind","createButtonText","searchTerm","mark","current"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AAIA;;AAKA;;AACA;;AAzB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AE;AALA,KAAP;AAOA;;AAED,WAASC,gBAAT,CAA2BC,UAA3B,EAAwC;AACvC,WAAO,uCACN;AACC;AACA,kBAAI,8BAAJ,CAFD,EAGCA,UAHD,CADM,EAMN;AAAEC,MAAAA,IAAI,EAAE;AAAR,KANM,CAAP;AAQA;;AAED,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAGb,SADb;AAEC,IAAA,YAAY,EAAGG,YAAY,CAACW,OAF7B;AAGC,IAAA,OAAO,EAAGnD,cAHX;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMC,4BAAC,sCAAD;AACC,IAAA,KAAK,EAAGY,SADT;AAEC,IAAA,QAAQ,EAAGQ,YAFZ;AAGC,IAAA,QAAQ,EAAGF,UAHZ;AAIC,IAAA,kBAAkB,EAAGtB,UAJtB;AAKC,IAAA,eAAe,MALhB;AAMC,IAAA,gBAAgB,EAAGQ,gBAAgB,IAAIqC,YANxC;AAOC,IAAA,oBAAoB,EAAGpC,kBAPxB;AAQC,IAAA,0BAA0B,EAAG2C;AAR9B,IAND,CADD;AAmBA;;eAEc,oCAAoBvD,YAApB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef, createInterpolateElement } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { withSpokenMessages, Popover } from '@wordpress/components';\nimport { prependHTTP } from '@wordpress/url';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tuseAnchorRef,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport {\n\t__experimentalLinkControl as LinkControl,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from './utils';\nimport { link as settings } from './index';\n\nfunction InlineLinkUI( {\n\tisActive,\n\tactiveAttributes,\n\taddingLink,\n\tvalue,\n\tonChange,\n\tspeak,\n\tstopAddingLink,\n\tcontentRef,\n} ) {\n\t/**\n\t * Pending settings to be applied to the next link. When inserting a new\n\t * link, toggle values cannot be applied immediately, because there is not\n\t * yet a link for them to apply to. Thus, they are maintained in a state\n\t * value until the time that the link can be inserted or edited.\n\t *\n\t * @type {[Object|undefined,Function]}\n\t */\n\tconst [ nextLinkValue, setNextLinkValue ] = useState();\n\n\tconst { createPageEntity, userCanCreatePages } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst _settings = getSettings();\n\n\t\treturn {\n\t\t\tcreatePageEntity: _settings.__experimentalCreatePageEntity,\n\t\t\tuserCanCreatePages: _settings.__experimentalUserCanCreatePages,\n\t\t};\n\t}, [] );\n\n\tconst linkValue = {\n\t\turl: activeAttributes.url,\n\t\ttype: activeAttributes.type,\n\t\tid: activeAttributes.id,\n\t\topensInNewTab: activeAttributes.target === '_blank',\n\t\t...nextLinkValue,\n\t};\n\n\tfunction removeLink() {\n\t\tconst newValue = removeFormat( value, 'core/link' );\n\t\tonChange( newValue );\n\t\tstopAddingLink();\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\tfunction onChangeLink( nextValue ) {\n\t\t// Merge with values from state, both for the purpose of assigning the\n\t\t// next state value, and for use in constructing the new link format if\n\t\t// the link is ready to be applied.\n\t\tnextValue = {\n\t\t\t...nextLinkValue,\n\t\t\t...nextValue,\n\t\t};\n\n\t\t// LinkControl calls `onChange` immediately upon the toggling a setting.\n\t\tconst didToggleSetting =\n\t\t\tlinkValue.opensInNewTab !== nextValue.opensInNewTab &&\n\t\t\tlinkValue.url === nextValue.url;\n\n\t\t// If change handler was called as a result of a settings change during\n\t\t// link insertion, it must be held in state until the link is ready to\n\t\t// be applied.\n\t\tconst didToggleSettingForNewLink =\n\t\t\tdidToggleSetting && nextValue.url === undefined;\n\n\t\t// If link will be assigned, the state value can be considered flushed.\n\t\t// Otherwise, persist the pending changes.\n\t\tsetNextLinkValue( didToggleSettingForNewLink ? nextValue : undefined );\n\n\t\tif ( didToggleSettingForNewLink ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newUrl = prependHTTP( nextValue.url );\n\t\tconst format = createLinkFormat( {\n\t\t\turl: newUrl,\n\t\t\ttype: nextValue.type,\n\t\t\tid:\n\t\t\t\tnextValue.id !== undefined && nextValue.id !== null\n\t\t\t\t\t? String( nextValue.id )\n\t\t\t\t\t: undefined,\n\t\t\topensInNewWindow: nextValue.opensInNewTab,\n\t\t} );\n\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\tconst newText = nextValue.title || newUrl;\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: newText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tnewText.length\n\t\t\t);\n\t\t\tonChange( insert( value, toInsert ) );\n\t\t} else {\n\t\t\tconst newValue = applyFormat( value, format );\n\t\t\tnewValue.start = newValue.end;\n\t\t\tnewValue.activeFormats = [];\n\t\t\tonChange( newValue );\n\t\t}\n\n\t\t// Focus should only be shifted back to the formatted segment when the\n\t\t// URL is submitted.\n\t\tif ( ! didToggleSetting ) {\n\t\t\tstopAddingLink();\n\t\t}\n\n\t\tif ( ! isValidHref( newUrl ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted.' ), 'assertive' );\n\t\t}\n\t}\n\n\tconst anchorRef = useAnchorRef( { ref: contentRef, value, settings } );\n\n\t// The focusOnMount prop shouldn't evolve during render of a Popover\n\t// otherwise it causes a render of the content.\n\tconst focusOnMount = useRef( addingLink ? 'firstElement' : false );\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst page = await createPageEntity( {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: page.type,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tfunction createButtonText( searchTerm ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create Page: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanchorRef={ anchorRef }\n\t\t\tfocusOnMount={ focusOnMount.current }\n\t\t\tonClose={ stopAddingLink }\n\t\t\tposition=\"bottom center\"\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\tvalue={ linkValue }\n\t\t\t\tonChange={ onChangeLink }\n\t\t\t\tonRemove={ removeLink }\n\t\t\t\tforceIsEditingLink={ addingLink }\n\t\t\t\thasRichPreviews\n\t\t\t\tcreateSuggestion={ createPageEntity && handleCreate }\n\t\t\t\twithCreateSuggestion={ userCanCreatePages }\n\t\t\t\tcreateSuggestionButtonText={ createButtonText }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n\nexport default withSpokenMessages( InlineLinkUI );\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/inline.js"],"names":["InlineLinkUI","isActive","activeAttributes","addingLink","value","onChange","speak","stopAddingLink","contentRef","richLinkTextValue","getRichTextValueFromSelection","richTextText","text","nextLinkValue","setNextLinkValue","createPageEntity","userCanCreatePages","select","getSettings","blockEditorStore","_settings","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","linkValue","url","type","id","opensInNewTab","target","title","removeLink","newValue","onChangeLink","nextValue","didToggleSetting","didToggleSettingForNewLink","undefined","newUrl","linkFormat","String","opensInNewWindow","newText","toInsert","length","start","end","activeFormats","anchorRef","ref","settings","focusOnMount","handleCreate","pageTitle","page","status","rendered","link","kind","createButtonText","searchTerm","mark","current","textStart","textEnd","boundary"],"mappings":";;;;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gB,IAAIoC,YANxC;AAOC,IAAA,oBAAoB,EAAGnC,kBAPxB;AAQC,IAAA,0BAA0B,EAAG0C,gBAR9B;AASC,IAAA,cAAc;AATf,IAND,CADD;AAoBA;;AAED,SAAShD,6BAAT,CAAwCN,KAAxC,EAA+CH,QAA/C,EAA0D;AACzD;AACA,MAAI6D,SAAS,GAAG1D,KAAK,CAACwC,KAAtB;AACA,MAAImB,OAAO,GAAG3D,KAAK,CAACyC,GAApB,CAHyD,CAKzD;AACA;AACA;;AACA,MAAK5C,QAAL,EAAgB;AACf,UAAM+D,QAAQ,GAAG,8BAAmB5D,KAAnB,EAA0B;AAC1CqB,MAAAA,IAAI,EAAE;AADoC,KAA1B,CAAjB;AAIAqC,IAAAA,SAAS,GAAGE,QAAQ,CAACpB,KAArB,CALe,CAOf;AACA;;AACAmB,IAAAA,OAAO,GAAGC,QAAQ,CAACnB,GAAT,GAAe,CAAzB;AACA,GAlBwD,CAoBzD;;;AACA,SAAO,qBAAOzC,KAAP,EAAc0D,SAAd,EAAyBC,OAAzB,CAAP;AACA;;eAEc,oCAAoB/D,YAApB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef, createInterpolateElement } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { withSpokenMessages, Popover } from '@wordpress/components';\nimport { prependHTTP } from '@wordpress/url';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tuseAnchorRef,\n\tremoveFormat,\n\tslice,\n\treplace,\n} from '@wordpress/rich-text';\nimport {\n\t__experimentalLinkControl as LinkControl,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref, getFormatBoundary } from './utils';\nimport { link as settings } from './index';\n\nfunction InlineLinkUI( {\n\tisActive,\n\tactiveAttributes,\n\taddingLink,\n\tvalue,\n\tonChange,\n\tspeak,\n\tstopAddingLink,\n\tcontentRef,\n} ) {\n\tconst richLinkTextValue = getRichTextValueFromSelection( value, isActive );\n\n\t// Get the text content minus any HTML tags.\n\tconst richTextText = richLinkTextValue.text;\n\n\t/**\n\t * Pending settings to be applied to the next link. When inserting a new\n\t * link, toggle values cannot be applied immediately, because there is not\n\t * yet a link for them to apply to. Thus, they are maintained in a state\n\t * value until the time that the link can be inserted or edited.\n\t *\n\t * @type {[Object|undefined,Function]}\n\t */\n\tconst [ nextLinkValue, setNextLinkValue ] = useState();\n\n\tconst { createPageEntity, userCanCreatePages } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst _settings = getSettings();\n\n\t\treturn {\n\t\t\tcreatePageEntity: _settings.__experimentalCreatePageEntity,\n\t\t\tuserCanCreatePages: _settings.__experimentalUserCanCreatePages,\n\t\t};\n\t}, [] );\n\n\tconst linkValue = {\n\t\turl: activeAttributes.url,\n\t\ttype: activeAttributes.type,\n\t\tid: activeAttributes.id,\n\t\topensInNewTab: activeAttributes.target === '_blank',\n\t\ttitle: richTextText,\n\t\t...nextLinkValue,\n\t};\n\n\tfunction removeLink() {\n\t\tconst newValue = removeFormat( value, 'core/link' );\n\t\tonChange( newValue );\n\t\tstopAddingLink();\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\tfunction onChangeLink( nextValue ) {\n\t\t// Merge with values from state, both for the purpose of assigning the\n\t\t// next state value, and for use in constructing the new link format if\n\t\t// the link is ready to be applied.\n\t\tnextValue = {\n\t\t\t...nextLinkValue,\n\t\t\t...nextValue,\n\t\t};\n\n\t\t// LinkControl calls `onChange` immediately upon the toggling a setting.\n\t\tconst didToggleSetting =\n\t\t\tlinkValue.opensInNewTab !== nextValue.opensInNewTab &&\n\t\t\tlinkValue.url === nextValue.url;\n\n\t\t// If change handler was called as a result of a settings change during\n\t\t// link insertion, it must be held in state until the link is ready to\n\t\t// be applied.\n\t\tconst didToggleSettingForNewLink =\n\t\t\tdidToggleSetting && nextValue.url === undefined;\n\n\t\t// If link will be assigned, the state value can be considered flushed.\n\t\t// Otherwise, persist the pending changes.\n\t\tsetNextLinkValue( didToggleSettingForNewLink ? nextValue : undefined );\n\n\t\tif ( didToggleSettingForNewLink ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newUrl = prependHTTP( nextValue.url );\n\t\tconst linkFormat = createLinkFormat( {\n\t\t\turl: newUrl,\n\t\t\ttype: nextValue.type,\n\t\t\tid:\n\t\t\t\tnextValue.id !== undefined && nextValue.id !== null\n\t\t\t\t\t? String( nextValue.id )\n\t\t\t\t\t: undefined,\n\t\t\topensInNewWindow: nextValue.opensInNewTab,\n\t\t} );\n\n\t\tconst newText = nextValue.title || newUrl;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Scenario: we don't have any actively selected text or formats.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: newText } ),\n\t\t\t\tlinkFormat,\n\t\t\t\t0,\n\t\t\t\tnewText.length\n\t\t\t);\n\t\t\tonChange( insert( value, toInsert ) );\n\t\t} else {\n\t\t\t// Scenario: we have any active text selection or an active format\n\t\t\tlet newValue;\n\n\t\t\tif ( newText === richTextText ) {\n\t\t\t\t// If we're not updating the text then ignore\n\t\t\t\tnewValue = applyFormat( value, linkFormat );\n\t\t\t} else {\n\t\t\t\t// Create new RichText value for the new text in order that we\n\t\t\t\t// can apply formats to it.\n\t\t\t\tnewValue = create( { text: newText } );\n\n\t\t\t\t// Apply the new Link format to this new text value.\n\t\t\t\tnewValue = applyFormat(\n\t\t\t\t\tnewValue,\n\t\t\t\t\tlinkFormat,\n\t\t\t\t\t0,\n\t\t\t\t\tnewText.length\n\t\t\t\t);\n\n\t\t\t\t// Update the original (full) RichTextValue replacing the\n\t\t\t\t// target text with the *new* RichTextValue containing:\n\t\t\t\t// 1. The new text content.\n\t\t\t\t// 2. The new link format.\n\t\t\t\t// Note original formats will be lost when applying this change.\n\t\t\t\t// That is expected behaviour.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179.\n\t\t\t\tnewValue = replace( value, richTextText, newValue );\n\t\t\t}\n\n\t\t\tnewValue.start = newValue.end;\n\t\t\tnewValue.activeFormats = [];\n\t\t\tonChange( newValue );\n\t\t}\n\n\t\t// Focus should only be shifted back to the formatted segment when the\n\t\t// URL is submitted.\n\t\tif ( ! didToggleSetting ) {\n\t\t\tstopAddingLink();\n\t\t}\n\n\t\tif ( ! isValidHref( newUrl ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted.' ), 'assertive' );\n\t\t}\n\t}\n\n\tconst anchorRef = useAnchorRef( { ref: contentRef, value, settings } );\n\n\t// The focusOnMount prop shouldn't evolve during render of a Popover\n\t// otherwise it causes a render of the content.\n\tconst focusOnMount = useRef( addingLink ? 'firstElement' : false );\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst page = await createPageEntity( {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: page.type,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tfunction createButtonText( searchTerm ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create Page: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanchorRef={ anchorRef }\n\t\t\tfocusOnMount={ focusOnMount.current }\n\t\t\tonClose={ stopAddingLink }\n\t\t\tposition=\"bottom center\"\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\tvalue={ linkValue }\n\t\t\t\tonChange={ onChangeLink }\n\t\t\t\tonRemove={ removeLink }\n\t\t\t\tforceIsEditingLink={ addingLink }\n\t\t\t\thasRichPreviews\n\t\t\t\tcreateSuggestion={ createPageEntity && handleCreate }\n\t\t\t\twithCreateSuggestion={ userCanCreatePages }\n\t\t\t\tcreateSuggestionButtonText={ createButtonText }\n\t\t\t\thasTextControl\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n\nfunction getRichTextValueFromSelection( value, isActive ) {\n\t// Default to the selection ranges on the RichTextValue object.\n\tlet textStart = value.start;\n\tlet textEnd = value.end;\n\n\t// If the format is currently active then the rich text value\n\t// should always be taken from the bounds of the active format\n\t// and not the selected text.\n\tif ( isActive ) {\n\t\tconst boundary = getFormatBoundary( value, {\n\t\t\ttype: 'core/link',\n\t\t} );\n\n\t\ttextStart = boundary.start;\n\n\t\t// Text *selection* always extends +1 beyond the edge of the format.\n\t\t// We account for that here.\n\t\ttextEnd = boundary.end + 1;\n\t}\n\n\t// Get a RichTextValue containing the selected text content.\n\treturn slice( value, textStart, textEnd );\n}\n\nexport default withSpokenMessages( InlineLinkUI );\n"]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isValidHref = isValidHref;
7
7
  exports.createLinkFormat = createLinkFormat;
8
+ exports.getFormatBoundary = getFormatBoundary;
8
9
 
9
10
  var _lodash = require("lodash");
10
11
 
@@ -117,4 +118,115 @@ function createLinkFormat({
117
118
 
118
119
  return format;
119
120
  }
121
+ /* eslint-disable jsdoc/no-undefined-types */
122
+
123
+ /**
124
+ * Get the start and end boundaries of a given format from a rich text value.
125
+ *
126
+ *
127
+ * @param {RichTextValue} value the rich text value to interrogate.
128
+ * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).
129
+ * @param {number?} startIndex optional startIndex to seek from.
130
+ * @param {number?} endIndex optional endIndex to seek from.
131
+ * @return {Object} object containing start and end values for the given format.
132
+ */
133
+
134
+ /* eslint-enable jsdoc/no-undefined-types */
135
+
136
+
137
+ function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
138
+ const EMPTY_BOUNDARIES = {
139
+ start: null,
140
+ end: null
141
+ };
142
+ const {
143
+ formats
144
+ } = value;
145
+ let targetFormat;
146
+ let initialIndex;
147
+
148
+ if (!(formats !== null && formats !== void 0 && formats.length)) {
149
+ return EMPTY_BOUNDARIES;
150
+ } // Clone formats to avoid modifying source formats.
151
+
152
+
153
+ const newFormats = formats.slice();
154
+ const formatAtStart = (0, _lodash.find)(newFormats[startIndex], {
155
+ type: format.type
156
+ });
157
+ const formatAtEnd = (0, _lodash.find)(newFormats[endIndex], {
158
+ type: format.type
159
+ });
160
+ const formatAtEndMinusOne = (0, _lodash.find)(newFormats[endIndex - 1], {
161
+ type: format.type
162
+ });
163
+
164
+ if (!!formatAtStart) {
165
+ // Set values to conform to "start"
166
+ targetFormat = formatAtStart;
167
+ initialIndex = startIndex;
168
+ } else if (!!formatAtEnd) {
169
+ // Set values to conform to "end"
170
+ targetFormat = formatAtEnd;
171
+ initialIndex = endIndex;
172
+ } else if (!!formatAtEndMinusOne) {
173
+ // This is an edge case which will occur if you create a format, then place
174
+ // the caret just before the format and hit the back ARROW key. The resulting
175
+ // value object will have start and end +1 beyond the edge of the format boundary.
176
+ targetFormat = formatAtEndMinusOne;
177
+ initialIndex = endIndex - 1;
178
+ } else {
179
+ return EMPTY_BOUNDARIES;
180
+ }
181
+
182
+ const index = newFormats[initialIndex].indexOf(targetFormat);
183
+ const walkingArgs = [newFormats, initialIndex, targetFormat, index]; // Walk the startIndex "backwards" to the leading "edge" of the matching format.
184
+
185
+ startIndex = walkToStart(...walkingArgs); // Walk the endIndex "forwards" until the trailing "edge" of the matching format.
186
+
187
+ endIndex = walkToEnd(...walkingArgs); // Safe guard: start index cannot be less than 0
188
+
189
+ startIndex = startIndex < 0 ? 0 : startIndex; // // Return the indicies of the "edges" as the boundaries.
190
+
191
+ return {
192
+ start: startIndex,
193
+ end: endIndex
194
+ };
195
+ }
196
+ /**
197
+ * Walks forwards/backwards towards the boundary of a given format within an
198
+ * array of format objects. Returns the index of the boundary.
199
+ *
200
+ * @param {Array} formats the formats to search for the given format type.
201
+ * @param {number} initialIndex the starting index from which to walk.
202
+ * @param {Object} targetFormatRef a reference to the format type object being sought.
203
+ * @param {number} formatIndex the index at which we expect the target format object to be.
204
+ * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.
205
+ * @return {number} the index of the boundary of the given format.
206
+ */
207
+
208
+
209
+ function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) {
210
+ let index = initialIndex;
211
+ const directions = {
212
+ forwards: 1,
213
+ backwards: -1
214
+ };
215
+ const directionIncrement = directions[direction] || 1; // invalid direction arg default to forwards
216
+
217
+ const inverseDirectionIncrement = directionIncrement * -1;
218
+
219
+ while (formats[index] && formats[index][formatIndex] === targetFormatRef) {
220
+ // Increment/decrement in the direction of operation.
221
+ index = index + directionIncrement;
222
+ } // Restore by one in inverse direction of operation
223
+ // to avoid out of bounds.
224
+
225
+
226
+ index = index + inverseDirectionIncrement;
227
+ return index;
228
+ }
229
+
230
+ const walkToStart = (0, _lodash.partialRight)(walkToBoundary, 'backwards');
231
+ const walkToEnd = (0, _lodash.partialRight)(walkToBoundary, 'forwards');
120
232
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["isValidHref","href","trimmedHref","trim","test","protocol","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","format","attributes","target","rel"],"mappings":";;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,IAAtB,EAA6B;AACnC,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,KAAP;AACA;;AAED,QAAMC,WAAW,GA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A;AAAjB,CAA3B,EAAiE;AACvE,QAAMC,MAAM,GAAG;AACdH,IAAAA,IAAI,EAAE,WADQ;AAEdI,IAAAA,UAAU,EAAE;AACXL,MAAAA;AADW;AAFE,GAAf;AAOA,MAAKC,IAAL,EAAYG,MAAM,CAACC,UAAP,CAAkBJ,IAAlB,GAAyBA,IAAzB;AACZ,MAAKC,EAAL,EAAUE,MAAM,CAACC,UAAP,CAAkBH,EAAlB,GAAuBA,EAAvB;;AAEV,MAAKC,gBAAL,EAAwB;AACvBC,IAAAA,MAAM,CAACC,UAAP,CAAkBC,MAAlB,GAA2B,QAA3B;AACAF,IAAAA,MAAM,CAACC,UAAP,CAAkBE,GAAlB,GAAwB,qBAAxB;AACA;;AAED,SAAOH,MAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { startsWith } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tstartsWith( protocol, 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( startsWith( trimmedHref, '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n *\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( { url, type, id, opensInNewWindow } ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) format.attributes.type = type;\n\tif ( id ) format.attributes.id = id;\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = 'noreferrer noopener';\n\t}\n\n\treturn format;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["isValidHref","href","trimmedHref","trim","test","protocol","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","format","attributes","target","rel","getFormatBoundary","value","startIndex","start","endIndex","end","EMPTY_BOUNDARIES","formats","targetFormat","initialIndex","length","newFormats","slice","formatAtStart","formatAtEnd","formatAtEndMinusOne","index","indexOf","walkingArgs","walkToStart","walkToEnd","walkToBoundary","targetFormatRef","formatIndex","direction","directions","forwards","backwards","directionI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AiB,CAAjB,GAAqBA,UAAlC,CA1DC,CA4DD;;AACA,SAAO;AACNC,IAAAA,KAAK,EAAED,UADD;AAENG,IAAAA,GAAG,EAAED;AAFC,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASiB,cAAT,CACCd,OADD,EAECE,YAFD,EAGCa,eAHD,EAICC,WAJD,EAKCC,SALD,EAME;AACD,MAAIR,KAAK,GAAGP,YAAZ;AAEA,QAAMgB,UAAU,GAAG;AAClBC,IAAAA,QAAQ,EAAE,CADQ;AAElBC,IAAAA,SAAS,EAAE,CAAC;AAFM,GAAnB;AAKA,QAAMC,kBAAkB,GAAGH,UAAU,CAAED,SAAF,CAAV,IAA2B,CAAtD,CARC,CAQwD;;AACzD,QAAMK,yBAAyB,GAAGD,kBAAkB,GAAG,CAAC,CAAxD;;AAEA,SACCrB,OAAO,CAAES,KAAF,CAAP,IACAT,OAAO,CAAES,KAAF,CAAP,CAAkBO,WAAlB,MAAoCD,eAFrC,EAGE;AACD;AACAN,IAAAA,KAAK,GAAGA,KAAK,GAAGY,kBAAhB;AACA,GAjBA,CAmBD;AACA;;;AACAZ,EAAAA,KAAK,GAAGA,KAAK,GAAGa,yBAAhB;AAEA,SAAOb,KAAP;AACA;;AAED,MAAMG,WAAW,GAAG,0BAAcE,cAAd,EAA8B,WAA9B,CAApB;AAEA,MAAMD,SAAS,GAAG,0BAAcC,cAAd,EAA8B,UAA9B,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { startsWith, find, partialRight } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tstartsWith( protocol, 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( startsWith( trimmedHref, '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n *\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( { url, type, id, opensInNewWindow } ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) format.attributes.type = type;\n\tif ( id ) format.attributes.id = id;\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = 'noreferrer noopener';\n\t}\n\n\treturn format;\n}\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = find( newFormats[ startIndex ], {\n\t\ttype: format.type,\n\t} );\n\n\tconst formatAtEnd = find( newFormats[ endIndex ], {\n\t\ttype: format.type,\n\t} );\n\n\tconst formatAtEndMinusOne = find( newFormats[ endIndex - 1 ], {\n\t\ttype: format.type,\n\t} );\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// // Return the indicies of the \"edges\" as the boundaries.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"]}
@@ -34,7 +34,8 @@ const strikethrough = {
34
34
  }) {
35
35
  function onClick() {
36
36
  onChange((0, _richText.toggleFormat)(value, {
37
- type: name
37
+ type: name,
38
+ title
38
39
  }));
39
40
  onFocus();
40
41
  }
@@ -43,7 +44,8 @@ const strikethrough = {
43
44
  icon: _icons.formatStrikethrough,
44
45
  title: title,
45
46
  onClick: onClick,
46
- isActive: isActive
47
+ isActive: isActive,
48
+ role: "menuitemcheckbox"
47
49
  });
48
50
  }
49
51
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","formatStrikethrough"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,oBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,eAAJ,CAAd;AAEO,MAAMC,aAAa,GAAG;AAC5BF,EAAAA,IAD4B;AAE5BC,EAAAA,KAF4B;AAG5BE,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,SAAS,EAAE,IAJiB;;AAK5BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGG,0BADR;AAEC,MAAA,KAAK,EAAGX,KAFT;AAGC,MAAA,OAAO,EAAGS,OAHX;AAIC,MAAA,QAAQ,EAAGJ;AAJZ,MADD;AAQA;;AAnB2B,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","formatStrikethrough"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,oBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,eAAJ,CAAd;AAEO,MAAMC,aAAa,GAAG;AAC5BF,EAAAA,IAD4B;AAE5BC,EAAAA,KAF4B;AAG5BE,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,SAAS,EAAE,IAJiB;;AAK5BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACAQ,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGG,0BADR;AAEC,MAAA,KAAK,EAAGX,KAFT;AAGC,MAAA,OAAO,EAAGS,OAHX;AAIC,MAAA,QAAQ,EAAGJ,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AApB2B,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -34,7 +34,8 @@ const subscript = {
34
34
  }) {
35
35
  function onToggle() {
36
36
  onChange((0, _richText.toggleFormat)(value, {
37
- type: name
37
+ type: name,
38
+ title
38
39
  }));
39
40
  }
40
41
 
@@ -47,7 +48,8 @@ const subscript = {
47
48
  icon: _icons.subscript,
48
49
  title: title,
49
50
  onClick: onClick,
50
- isActive: isActive
51
+ isActive: isActive,
52
+ role: "menuitemcheckbox"
51
53
  });
52
54
  }
53
55
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["name","title","subscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","subscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,KAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;;AAKxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACA;;AAED,aAASY,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,gBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN;AAJZ,MADD;AAQA;;AAvBuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["name","title","subscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","subscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,KAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;;AAKxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,gBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxBuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -34,7 +34,8 @@ const superscript = {
34
34
  }) {
35
35
  function onToggle() {
36
36
  onChange((0, _richText.toggleFormat)(value, {
37
- type: name
37
+ type: name,
38
+ title
38
39
  }));
39
40
  }
40
41
 
@@ -47,7 +48,8 @@ const superscript = {
47
48
  icon: _icons.superscript,
48
49
  title: title,
49
50
  onClick: onClick,
50
- isActive: isActive
51
+ isActive: isActive,
52
+ role: "menuitemcheckbox"
51
53
  });
52
54
  }
53
55
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["name","title","superscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","superscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,kBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,WAAW,GAAG;AAC1BF,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BE,EAAAA,OAAO,EAAE,KAHiB;AAI1BC,EAAAA,SAAS,EAAE,IAJe;;AAK1BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX;AAAR,OAArB,CAAF,CAAR;AACA;;AAED,aAASY,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,kBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN;AAJZ,MADD;AAQA;;AAvByB,CAApB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["name","title","superscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","superscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,kBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,WAAW,GAAG;AAC1BF,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BE,EAAAA,OAAO,EAAE,KAHiB;AAI1BC,EAAAA,SAAS,EAAE,IAJe;;AAK1BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,kBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxByB,CAApB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -95,7 +95,8 @@ function TextColorEdit({
95
95
  }),
96
96
  title: title // If has no colors to choose but a color is active remove the color onClick
97
97
  ,
98
- onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0, _richText.removeFormat)(value, name))
98
+ onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0, _richText.removeFormat)(value, name)),
99
+ role: "menuitemcheckbox"
99
100
  }), isAddingColor && (0, _element.createElement)(_inline.default, {
100
101
  name: name,
101
102
  onClose: disableIsAddingColor,