@wordpress/format-library 4.10.0 → 4.12.0

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 (106) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/bold/index.js +6 -8
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +6 -8
  5. package/build/code/index.js.map +1 -1
  6. package/build/default-formats.js +3 -1
  7. package/build/default-formats.js.map +1 -1
  8. package/build/image/index.js +24 -28
  9. package/build/image/index.js.map +1 -1
  10. package/build/index.js +4 -7
  11. package/build/index.js.map +1 -1
  12. package/build/italic/index.js +6 -8
  13. package/build/italic/index.js.map +1 -1
  14. package/build/keyboard/index.js +6 -8
  15. package/build/keyboard/index.js.map +1 -1
  16. package/build/language/index.js +114 -0
  17. package/build/language/index.js.map +1 -0
  18. package/build/link/index.js +12 -15
  19. package/build/link/index.js.map +1 -1
  20. package/build/link/index.native.js +4 -7
  21. package/build/link/index.native.js.map +1 -1
  22. package/build/link/inline.js +10 -11
  23. package/build/link/inline.js.map +1 -1
  24. package/build/link/modal-screens/link-picker-screen.native.js +4 -6
  25. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  26. package/build/link/modal-screens/link-settings-screen.native.js +25 -33
  27. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  28. package/build/link/modal.native.js +6 -6
  29. package/build/link/modal.native.js.map +1 -1
  30. package/build/link/utils.js +18 -44
  31. package/build/link/utils.js.map +1 -1
  32. package/build/strikethrough/index.js +6 -8
  33. package/build/strikethrough/index.js.map +1 -1
  34. package/build/subscript/index.js +6 -8
  35. package/build/subscript/index.js.map +1 -1
  36. package/build/superscript/index.js +6 -8
  37. package/build/superscript/index.js.map +1 -1
  38. package/build/text-color/index.js +11 -14
  39. package/build/text-color/index.js.map +1 -1
  40. package/build/text-color/index.native.js +16 -23
  41. package/build/text-color/index.native.js.map +1 -1
  42. package/build/text-color/inline.js +15 -21
  43. package/build/text-color/inline.js.map +1 -1
  44. package/build/text-color/inline.native.js +16 -24
  45. package/build/text-color/inline.native.js.map +1 -1
  46. package/build/underline/index.js +4 -6
  47. package/build/underline/index.js.map +1 -1
  48. package/build/unknown/index.js +6 -8
  49. package/build/unknown/index.js.map +1 -1
  50. package/build-module/bold/index.js +6 -8
  51. package/build-module/bold/index.js.map +1 -1
  52. package/build-module/code/index.js +6 -8
  53. package/build-module/code/index.js.map +1 -1
  54. package/build-module/default-formats.js +2 -1
  55. package/build-module/default-formats.js.map +1 -1
  56. package/build-module/image/index.js +24 -28
  57. package/build-module/image/index.js.map +1 -1
  58. package/build-module/index.js +4 -7
  59. package/build-module/index.js.map +1 -1
  60. package/build-module/italic/index.js +6 -8
  61. package/build-module/italic/index.js.map +1 -1
  62. package/build-module/keyboard/index.js +6 -8
  63. package/build-module/keyboard/index.js.map +1 -1
  64. package/build-module/language/index.js +104 -0
  65. package/build-module/language/index.js.map +1 -0
  66. package/build-module/link/index.js +12 -15
  67. package/build-module/link/index.js.map +1 -1
  68. package/build-module/link/index.native.js +4 -7
  69. package/build-module/link/index.native.js.map +1 -1
  70. package/build-module/link/inline.js +10 -11
  71. package/build-module/link/inline.js.map +1 -1
  72. package/build-module/link/modal-screens/link-picker-screen.native.js +4 -5
  73. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  74. package/build-module/link/modal-screens/link-settings-screen.native.js +25 -33
  75. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  76. package/build-module/link/modal.native.js +6 -6
  77. package/build-module/link/modal.native.js.map +1 -1
  78. package/build-module/link/utils.js +18 -44
  79. package/build-module/link/utils.js.map +1 -1
  80. package/build-module/strikethrough/index.js +6 -8
  81. package/build-module/strikethrough/index.js.map +1 -1
  82. package/build-module/subscript/index.js +6 -8
  83. package/build-module/subscript/index.js.map +1 -1
  84. package/build-module/superscript/index.js +6 -8
  85. package/build-module/superscript/index.js.map +1 -1
  86. package/build-module/text-color/index.js +11 -14
  87. package/build-module/text-color/index.js.map +1 -1
  88. package/build-module/text-color/index.native.js +16 -23
  89. package/build-module/text-color/index.native.js.map +1 -1
  90. package/build-module/text-color/inline.js +15 -21
  91. package/build-module/text-color/inline.js.map +1 -1
  92. package/build-module/text-color/inline.native.js +16 -24
  93. package/build-module/text-color/inline.native.js.map +1 -1
  94. package/build-module/underline/index.js +4 -6
  95. package/build-module/underline/index.js.map +1 -1
  96. package/build-module/unknown/index.js +6 -8
  97. package/build-module/unknown/index.js.map +1 -1
  98. package/build-style/style-rtl.css +6 -1
  99. package/build-style/style.css +6 -1
  100. package/package.json +13 -13
  101. package/src/default-formats.js +2 -0
  102. package/src/language/index.js +124 -0
  103. package/src/language/style.scss +6 -0
  104. package/src/link/index.native.js +1 -0
  105. package/src/link/modal.native.js +1 -0
  106. package/src/style.scss +1 -0
@@ -26,14 +26,12 @@ const subscript = {
26
26
  tagName: 'sub',
27
27
  className: null,
28
28
 
29
- edit(_ref) {
30
- let {
31
- isActive,
32
- value,
33
- onChange,
34
- onFocus
35
- } = _ref;
36
-
29
+ edit({
30
+ isActive,
31
+ value,
32
+ onChange,
33
+ onFocus
34
+ }) {
37
35
  function onToggle() {
38
36
  onChange((0, _richText.toggleFormat)(value, {
39
37
  type: name,
@@ -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,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;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"]}
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"]}
@@ -26,14 +26,12 @@ const superscript = {
26
26
  tagName: 'sup',
27
27
  className: null,
28
28
 
29
- edit(_ref) {
30
- let {
31
- isActive,
32
- value,
33
- onChange,
34
- onFocus
35
- } = _ref;
36
-
29
+ edit({
30
+ isActive,
31
+ value,
32
+ onChange,
33
+ onFocus
34
+ }) {
37
35
  function onToggle() {
38
36
  onChange((0, _richText.toggleFormat)(value, {
39
37
  type: name,
@@ -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,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;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"]}
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"]}
@@ -51,12 +51,10 @@ function getComputedStyleProperty(element, property) {
51
51
  return value;
52
52
  }
53
53
 
54
- function fillComputedColors(element, _ref) {
55
- let {
56
- color,
57
- backgroundColor
58
- } = _ref;
59
-
54
+ function fillComputedColors(element, {
55
+ color,
56
+ backgroundColor
57
+ }) {
60
58
  if (!color && !backgroundColor) {
61
59
  return;
62
60
  }
@@ -67,14 +65,13 @@ function fillComputedColors(element, _ref) {
67
65
  };
68
66
  }
69
67
 
70
- function TextColorEdit(_ref2) {
71
- let {
72
- value,
73
- onChange,
74
- isActive,
75
- activeAttributes,
76
- contentRef
77
- } = _ref2;
68
+ function TextColorEdit({
69
+ value,
70
+ onChange,
71
+ isActive,
72
+ activeAttributes,
73
+ contentRef
74
+ }) {
78
75
  const allowCustomControl = (0, _blockEditor.useSetting)('color.custom');
79
76
  const colors = (0, _blockEditor.useSetting)('color.palette') || EMPTY_ARRAY;
80
77
  const [isAddingColor, setIsAddingColor] = (0, _element.useState)(false);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","Object","keys","textColorIcon","colorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AAKA;;;;;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGO,MAAMA,gBAAgB,GAAG,kBAAzB;;AAEP,MAAMC,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,wBAAT,CAAmCC,OAAnC,EAA4CC,QAA5C,EAAuD;AACtD,QAAM;AAAEC,IAAAA;AAAF,MAAoBF,OAA1B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAkBD,aAAxB;AACA,QAAME,KAAK,GAAGD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B,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO/B,KAAP,EAAe;AAC5C,QAAK+B,GAAG,KAAK,OAAb,EAAuB,OAAO/B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAACgC,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAOhC,KAAP;AACrD,UAAMiC,QAAQ,GAAG,CAAE,kBAAF,EAAsB5C,gBAAtB,EAAyC6C,IAAzC,CAA+C,GAA/C,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAOlC,KAAK,GAAG,CAAEiC,QAAF,EAAYjC,KAAZ,EAAoBkC,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAE7B;AA3BkB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set.\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', transparentValue ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","Object","keys","textColorIcon","colorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AAKA;;;;;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGO,MAAMA,gBAAgB,GAAG,kBAAzB;;AAEP,MAAMC,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,wBAAT,CAAmCC,OAAnC,EAA4CC,QAA5C,EAAuD;AACtD,QAAM;AAAEC,IAAAA;AAAF,MAAoBF,OAA1B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAkBD,aAAxB;AACA,QAAME,KAAK,GAAGD,WAAW,CAACE,gBAAZ,CAA8BL,OAA9B,CAAd;AACA,QAAMM,KAAK,GAAGF,KAAK,CAACG,gBAAN,CAAwBN,QAAxB,CAAd;;AAEA,MACCA,QAAQ,KAAK,kBAAb,IACAK,KAAK,KAAKX,gBADV,IAEAK,OAAO,CAACQ,aAHT,EAIE;AACD,WAAOT,wBAAwB,CAAEC,OAAO,CAACQ,aAAV,EAAyBP,QAAzB,CAA/B;AACA;;AAED,SAAOK,KAAP;AACA;;AAED,SAASG,kBAAT,CAA6BT,OAA7B,EAAsC;AAAEU,EAAAA,KAAF;AAASC,EAAAA;AAAT,CAAtC,EAAmE;AAClE,MAAK,CAAED,KAAF,IAAW,CAAEC,eAAlB,EAAoC;AACnC;AACA;;AAED,SAAO;AACND,IAAAA,KAAK,EAAEA,KAAK,IAAIX,wBAAwB,CAAEC,OAAF,EAAW,OAAX,CADlC;AAENW,IAAAA,eAAe,EACdA,eAAe,KAAKhB,gBAApB,GACGI,wBAAwB,CAAEC,OAAF,EAAW,kBAAX,CAD3B,GAEGW;AALE,GAAP;AAOA;;AAED,SAASC,aAAT,CAAwB;AACvBN,EAAAA,KADuB;AAEvBO,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F,CAlBnB;AAoBC,IAAA,IAAI,EAAC;AApBN,IADD,EAuBGuB,aAAa,IACd,4BAAC,eAAD;AACC,IAAA,IAAI,EAAGvB,IADR;AAEC,IAAA,OAAO,EAAG0B,oBAFX;AAGC,IAAA,gBAAgB,EAAGP,gBAHpB;AAIC,IAAA,KAAK,EAAGT,KAJT;AAKC,IAAA,QAAQ,EAAGO,QALZ;AAMC,IAAA,UAAU,EAAGG;AANd,IAxBF,CADD;AAoCA;;AAEM,MAAMe,SAAS,GAAG;AACxBnC,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBmC,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,kBAJa;AAKxBC,EAAAA,UAAU,EAAE;AACX9B,IAAAA,KAAK,EAAE,OADI;AAEX+B,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO/B,KAAP,EAAe;AAC5C,QAAK+B,GAAG,KAAK,OAAb,EAAuB,OAAO/B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAACgC,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAOhC,KAAP;AACrD,UAAMiC,QAAQ,GAAG,CAAE,kBAAF,EAAsB5C,gBAAtB,EAAyC6C,IAAzC,CAA+C,GAA/C,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAOlC,KAAK,GAAG,CAAEiC,QAAF,EAAYjC,KAAZ,EAAoBkC,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAE7B;AA3BkB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set.\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', transparentValue ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
@@ -53,8 +53,6 @@ function getComputedStyleProperty(element, property) {
53
53
  } = element;
54
54
 
55
55
  if (property === 'background-color') {
56
- var _baseColors$color;
57
-
58
56
  const {
59
57
  backgroundColor,
60
58
  baseColors
@@ -62,22 +60,18 @@ function getComputedStyleProperty(element, property) {
62
60
 
63
61
  if (backgroundColor !== 'transparent') {
64
62
  return backgroundColor;
65
- } else if (baseColors && baseColors !== null && baseColors !== void 0 && (_baseColors$color = baseColors.color) !== null && _baseColors$color !== void 0 && _baseColors$color.background) {
66
- var _baseColors$color2;
67
-
68
- return baseColors === null || baseColors === void 0 ? void 0 : (_baseColors$color2 = baseColors.color) === null || _baseColors$color2 === void 0 ? void 0 : _baseColors$color2.background;
63
+ } else if (baseColors && baseColors?.color?.background) {
64
+ return baseColors?.color?.background;
69
65
  }
70
66
 
71
67
  return 'transparent';
72
68
  }
73
69
  }
74
70
 
75
- function fillComputedColors(element, _ref) {
76
- let {
77
- color,
78
- backgroundColor
79
- } = _ref;
80
-
71
+ function fillComputedColors(element, {
72
+ color,
73
+ backgroundColor
74
+ }) {
81
75
  if (!color && !backgroundColor) {
82
76
  return;
83
77
  }
@@ -88,14 +82,13 @@ function fillComputedColors(element, _ref) {
88
82
  };
89
83
  }
90
84
 
91
- function TextColorEdit(_ref2) {
92
- let {
93
- value,
94
- onChange,
95
- isActive,
96
- activeAttributes,
97
- contentRef
98
- } = _ref2;
85
+ function TextColorEdit({
86
+ value,
87
+ onChange,
88
+ isActive,
89
+ activeAttributes,
90
+ contentRef
91
+ }) {
99
92
  const allowCustomControl = (0, _blockEditor.useSetting)('color.custom');
100
93
  const colors = (0, _components.useMobileGlobalStylesColors)();
101
94
  const [isAddingColor, setIsAddingColor] = (0, _element.useState)(false);
@@ -117,7 +110,7 @@ function TextColorEdit(_ref2) {
117
110
  }
118
111
 
119
112
  const isActiveStyle = { ...colorIndicatorStyle,
120
- ...(!(colorIndicatorStyle !== null && colorIndicatorStyle !== void 0 && colorIndicatorStyle.backgroundColor) ? {
113
+ ...(!colorIndicatorStyle?.backgroundColor ? {
121
114
  backgroundColor: 'transparent'
122
115
  } : {}),
123
116
  ..._style.default['components-inline-color--is-active']
@@ -131,7 +124,7 @@ function TextColorEdit(_ref2) {
131
124
  isActive: isActive,
132
125
  icon: (0, _element.createElement)(_icons.Icon, {
133
126
  icon: _icons.textColor,
134
- style: (colorIndicatorStyle === null || colorIndicatorStyle === void 0 ? void 0 : colorIndicatorStyle.color) && {
127
+ style: colorIndicatorStyle?.color && {
135
128
  color: colorIndicatorStyle.color
136
129
  }
137
130
  }),
@@ -174,7 +167,7 @@ const textColor = {
174
167
  __unstableFilterAttributeValue(key, value) {
175
168
  if (key !== 'style') return value; // We need to remove the extra spaces within the styles on mobile
176
169
 
177
- const newValue = value === null || value === void 0 ? void 0 : value.replace(/ /g, ''); // We should not add a background-color if it's already set
170
+ const newValue = value?.replace(/ /g, ''); // We should not add a background-color if it's already set
178
171
 
179
172
  if (newValue && newValue.includes('background-color')) return newValue;
180
173
  const addedCSS = ['background-color', _index.transparentValue].join(':'); // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/index.native.js"],"names":["name","title","getComputedStyleProperty","element","property","props","style","backgroundColor","baseColors","color","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","hasColorsToChoose","length","onPressButton","outlineStyle","styles","isActiveStyle","customContainerStyles","textColorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","newValue","replace","includes","addedCSS","transparentValue","join","edit"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,YAAJ,CAAd;;AAEA,SAASC,wBAAT,CAAmCC,OAAnC,EAA4CC,QAA5C,EAAuD;AACtD,QAAM;AACLC,IAAAA,KAAK,EAAE;AAAEC,MAAAA,KAAK,GAAG;AAAV;AADF,MAEFH,OAFJ;;AAIA,MAAKC,QAAQ,KAAK,kBAAlB,EAAuC;AAAA;;AACtC,UAAM;AAAEG,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAkCF,KAAxC;;AAEA,QAAKC,eAAe,KAAK,aAAzB,EAAyC;AACxC,aAAOA,eAAP;AACA,KAFD,MAEO,IAAKC,UAAU,IAAIA,UAAJ,aAAIA,UAAJ,oCAAIA,UAAU,CAAEC,KAAhB,8CAAI,kBAAmBC,UAAtC,EAAmD;AAAA;;AACzD,aAAOF,UAAP,aAAOA,UAAP,6CAAOA,UAAU,CAAEC,KAAnB,uDAAO,mBAAmBC,UAA1B;AACA;;AAED,WAAO,aAAP;AACA;AACD;;AAED,SAASC,kBAAT,CAA6BR,OAA7B,QAAmE;AAAA,MAA7B;AAAEM,IAAAA,KAAF;AAASF,IAAAA;AAAT,GAA6B;;AAClE,MAAK,CAAEE,KAAF,IAAW,CAAEF,eAAlB,EAAoC;AACnC;AACA;;AAED,SAAO;AACNE,IAAAA,KAAK,EAAEA,KAAK,IAAIP,wBAAwB,CAAEC,OAAF,EAAW,OAAX,CADlC;AAENI,IAAAA,eAAe,EAAEL,wBAAwB,CACxCC,OADwC,EAExC,kBAFwC;AAFnC,GAAP;AAOA;;AAED,SAASS,aAAT,QAMI;AAAA,MANoB;AACvBC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AA,KAAK,EAAE,OADI;AAEX+B,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO1B,KAAP,EAAe;AAC5C,QAAK0B,GAAG,KAAK,OAAb,EAAuB,OAAO1B,KAAP,CADqB,CAE5C;;AACA,UAAM2B,QAAQ,GAAG3B,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAE4B,OAAP,CAAgB,IAAhB,EAAsB,EAAtB,CAAjB,CAH4C,CAI5C;;AACA,QAAKD,QAAQ,IAAIA,QAAQ,CAACE,QAAT,CAAmB,kBAAnB,CAAjB,EACC,OAAOF,QAAP;AACD,UAAMG,QAAQ,GAAG,CAAE,kBAAF,EAAsBC,uBAAtB,EAAyCC,IAAzC,CAA+C,GAA/C,CAAjB,CAP4C,CAQ5C;AACA;;AACA,WAAOL,QAAQ,GAAG,CAAEG,QAAF,EAAYH,QAAZ,EAAuBK,IAAvB,CAA6B,GAA7B,CAAH,GAAwCF,QAAvD;AACA,GA7BuB;;AA8BxBG,EAAAA,IAAI,EAAElC;AA9BkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { BlockControls, useSetting } from '@wordpress/block-editor';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport { Icon, textColor as textColorIcon } from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getActiveColors } from './inline.js';\nimport { transparentValue } from './index.js';\nimport { default as InlineColorUI } from './inline';\nimport styles from './style.scss';\n\nconst name = 'core/text-color';\nconst title = __( 'Text color' );\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst {\n\t\tprops: { style = {} },\n\t} = element;\n\n\tif ( property === 'background-color' ) {\n\t\tconst { backgroundColor, baseColors } = style;\n\n\t\tif ( backgroundColor !== 'transparent' ) {\n\t\t\treturn backgroundColor;\n\t\t} else if ( baseColors && baseColors?.color?.background ) {\n\t\t\treturn baseColors?.color?.background;\n\t\t}\n\n\t\treturn 'transparent';\n\t}\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor: getComputedStyleProperty(\n\t\t\telement,\n\t\t\t'background-color'\n\t\t),\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useMobileGlobalStylesColors();\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\n\tconst onPressButton = useCallback( () => {\n\t\tif ( hasColorsToChoose ) {\n\t\t\tenableIsAddingColor();\n\t\t} else {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t}\n\t}, [ hasColorsToChoose, value ] );\n\n\tconst outlineStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'components-inline-color__outline' ],\n\t\tstyles[ 'components-inline-color__outline--dark' ]\n\t);\n\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isActiveStyle = {\n\t\t...colorIndicatorStyle,\n\t\t...( ! colorIndicatorStyle?.backgroundColor\n\t\t\t? { backgroundColor: 'transparent' }\n\t\t\t: {} ),\n\t\t...styles[ 'components-inline-color--is-active' ],\n\t};\n\n\tconst customContainerStyles =\n\t\tstyles[ 'components-inline-color__button-container' ];\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ isActive && (\n\t\t\t\t\t\t<View style={ outlineStyle } pointerEvents=\"none\" />\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"text-color\"\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ textColorIcon }\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tcolorIndicatorStyle?.color && {\n\t\t\t\t\t\t\t\t\t\tcolor: colorIndicatorStyle.color,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\tisActiveStyle,\n\t\t\t\t\t\t\tcustomContainerStyles,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\t\t\tonClick={ onPressButton }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We need to remove the extra spaces within the styles on mobile\n\t\tconst newValue = value?.replace( / /g, '' );\n\t\t// We should not add a background-color if it's already set\n\t\tif ( newValue && newValue.includes( 'background-color' ) )\n\t\t\treturn newValue;\n\t\tconst addedCSS = [ 'background-color', transparentValue ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn newValue ? [ addedCSS, newValue ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/index.native.js"],"names":["name","title","getComputedStyleProperty","element","property","props","style","backgroundColor","baseColors","color","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","hasColorsToChoose","length","onPressButton","outlineStyle","styles","isActiveStyle","customContainerStyles","textColorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","newValue","replace","includes","addedCSS","transparentValue","join","edit"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,iBAAb;AAC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AACD,UAAMG,QAAQ,GAAG,CAAE,kBAAF,EAAsBC,uBAAtB,EAAyCC,IAAzC,CAA+C,GAA/C,CAAjB,CAP4C,CAQ5C;AACA;;AACA,WAAOL,QAAQ,GAAG,CAAEG,QAAF,EAAYH,QAAZ,EAAuBK,IAAvB,CAA6B,GAA7B,CAAH,GAAwCF,QAAvD;AACA,GA7BuB;;AA8BxBG,EAAAA,IAAI,EAAElC;AA9BkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { BlockControls, useSetting } from '@wordpress/block-editor';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport { Icon, textColor as textColorIcon } from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getActiveColors } from './inline.js';\nimport { transparentValue } from './index.js';\nimport { default as InlineColorUI } from './inline';\nimport styles from './style.scss';\n\nconst name = 'core/text-color';\nconst title = __( 'Text color' );\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst {\n\t\tprops: { style = {} },\n\t} = element;\n\n\tif ( property === 'background-color' ) {\n\t\tconst { backgroundColor, baseColors } = style;\n\n\t\tif ( backgroundColor !== 'transparent' ) {\n\t\t\treturn backgroundColor;\n\t\t} else if ( baseColors && baseColors?.color?.background ) {\n\t\t\treturn baseColors?.color?.background;\n\t\t}\n\n\t\treturn 'transparent';\n\t}\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor: getComputedStyleProperty(\n\t\t\telement,\n\t\t\t'background-color'\n\t\t),\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useMobileGlobalStylesColors();\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\n\tconst onPressButton = useCallback( () => {\n\t\tif ( hasColorsToChoose ) {\n\t\t\tenableIsAddingColor();\n\t\t} else {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t}\n\t}, [ hasColorsToChoose, value ] );\n\n\tconst outlineStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'components-inline-color__outline' ],\n\t\tstyles[ 'components-inline-color__outline--dark' ]\n\t);\n\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isActiveStyle = {\n\t\t...colorIndicatorStyle,\n\t\t...( ! colorIndicatorStyle?.backgroundColor\n\t\t\t? { backgroundColor: 'transparent' }\n\t\t\t: {} ),\n\t\t...styles[ 'components-inline-color--is-active' ],\n\t};\n\n\tconst customContainerStyles =\n\t\tstyles[ 'components-inline-color__button-container' ];\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ isActive && (\n\t\t\t\t\t\t<View style={ outlineStyle } pointerEvents=\"none\" />\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"text-color\"\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ textColorIcon }\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tcolorIndicatorStyle?.color && {\n\t\t\t\t\t\t\t\t\t\tcolor: colorIndicatorStyle.color,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\tisActiveStyle,\n\t\t\t\t\t\t\tcustomContainerStyles,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\t\t\tonClick={ onPressButton }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We need to remove the extra spaces within the styles on mobile\n\t\tconst newValue = value?.replace( / /g, '' );\n\t\t// We should not add a background-color if it's already set\n\t\tif ( newValue && newValue.includes( 'background-color' ) )\n\t\t\treturn newValue;\n\t\tconst addedCSS = [ 'background-color', transparentValue ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn newValue ? [ addedCSS, newValue ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
@@ -28,8 +28,7 @@ var _index = require("./index");
28
28
  /**
29
29
  * Internal dependencies
30
30
  */
31
- function parseCSS() {
32
- let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
31
+ function parseCSS(css = '') {
33
32
  return css.split(';').reduce((accumulator, rule) => {
34
33
  if (rule) {
35
34
  const [property, value] = rule.split(':');
@@ -41,9 +40,7 @@ function parseCSS() {
41
40
  }, {});
42
41
  }
43
42
 
44
- function parseClassName() {
45
- let className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
46
- let colorSettings = arguments.length > 1 ? arguments[1] : undefined;
43
+ function parseClassName(className = '', colorSettings) {
47
44
  return className.split(' ').reduce((accumulator, name) => {
48
45
  // `colorSlug` could contain dashes, so simply match the start and end.
49
46
  if (name.startsWith('has-') && name.endsWith('-color')) {
@@ -109,13 +106,12 @@ function setColors(value, name, colorSettings, colors) {
109
106
  });
110
107
  }
111
108
 
112
- function ColorPicker(_ref) {
113
- let {
114
- name,
115
- property,
116
- value,
117
- onChange
118
- } = _ref;
109
+ function ColorPicker({
110
+ name,
111
+ property,
112
+ value,
113
+ onChange
114
+ }) {
119
115
  const colors = (0, _data.useSelect)(select => {
120
116
  var _getSettings$colors;
121
117
 
@@ -136,15 +132,13 @@ function ColorPicker(_ref) {
136
132
  });
137
133
  }
138
134
 
139
- function InlineColorUI(_ref2) {
140
- let {
141
- name,
142
- value,
143
- onChange,
144
- onClose,
145
- contentRef
146
- } = _ref2;
147
-
135
+ function InlineColorUI({
136
+ name,
137
+ value,
138
+ onChange,
139
+ onClose,
140
+ contentRef
141
+ }) {
148
142
  /*
149
143
  As you change the text color by typing a HEX value into a field,
150
144
  the return value of document.getSelection jumps to the field you're editing,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.js"],"names":["parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","getSettings","blockEditorStore","onColorChange","activeColors","InlineColorUI","onClose","contentRef","popoverAnchor","editableContentElement","current","settings","title","tab"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAMA;;AAQA;;AACA;;AAKA;;AAzBA;AACA;AACA;;AAoBA;AACA;AACA;AAGA,SAASA,QAAT,GAA8B;AAAA,MAAXC,GAAW,uEAAL,EAAK;AAC7B,SAAOA,GAAG,CAACC,KAAJ,CAAW,GAAX,EAAiBC,MAAjB,CAAyB,CAAEC,WAAF,EAAeC,IAAf,KAAyB;AACxD,QAAKA,IAAL,EAAY;AACX,YAAM,CAAEC,QAAF,EAAYC,KAAZ,IAAsBF,IAAI,CAACH,KAAL,CAAY,GAAZ,CAA5B;AACA,UAAKI,QAAQ,KAAK,OAAlB,EAA4BF,WAAW,CAACI,KAAZ,GAAoBD,KAApB;AAC5B,UAAKD,QAAQ,KAAK,kBAAb,IAAmCC,KAAK,KAAKE,uBAAlD,EACCL,WAAW,CAACM,eAAZ,GAA8BH,KAA9B;AACD;;AACD,WAAOH,WAAP;AACA,GARM,EAQJ,EARI,CAAP;AASA;;AAEM,SAASO,cAAT,GAAyD;AAAA,MAAhCC,SAAgC,uEAApB,EAAoB;AAAA,MAAhBC,aAAgB;AAC/D,SAAOD,SAAS,CAACV,KAAV,CAAiB,GAAjB,EAAuBC,MAAvB,CAA+B,CAAEC,WAAF,EAAeU,IAAf,KAAyB;AAC9D;AACA,QAAKA,IAAI,CAACC,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A,IAAI,EAAGnC,IADR;AAEC,IAAA,QAAQ,EAAGmC,GAAG,CAACnC,IAFhB;AAGC,IAAA,KAAK,EAAGP,KAHT;AAIC,IAAA,QAAQ,EAAG4B;AAJZ,IAbF,CALD,CADD;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\t/*\n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchor uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst popoverAnchor = useCachedTruthy(\n\t\tuseAnchor( {\n\t\t\teditableContentElement: contentRef.current,\n\t\t\tsettings,\n\t\t} )\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</Popover>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.js"],"names":["parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","getSettings","blockEditorStore","onColorChange","activeColors","InlineColorUI","onClose","contentRef","popoverAnchor","editableContentElement","current","settings","title","tab"],"mappings":";;;;;;;;;AAGA;;A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CAAElC,QAAF,CADrB;AAEC,IAAA,QAAQ,EAAGiC;AAFZ,IADD;AAMA;;AAEc,SAASE,aAAT,CAAwB;AACtC3B,EAAAA,IADsC;AAEtCP,EAAAA,KAFsC;AAGtC4B,EAAAA,QAHsC;AAItCO,EAAAA,OAJsC;AAKtCC,EAAAA;AALsC,CAAxB,EAMX;AACH;AACD;AACA;AACA;AACA;AACA;AACA;AACC,QAAMC,aAAa,GAAG,kCACrB,yBAAW;AACVC,IAAAA,sBAAsB,EAAEF,UAAU,CAACG,OADzB;AAEVC,IAAAA,QAAQ,EAARA;AAFU,GAAX,CADqB,CAAtB;AAOA,SACC,4BAAC,mBAAD;AACC,IAAA,OAAO,EAAGL,OADX;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,MAAM,EAAGE;AAHV,KAKC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAG,CACN;AACC9B,MAAAA,IAAI,EAAE,OADP;AAECkC,MAAAA,KAAK,EAAE,cAAI,MAAJ;AAFR,KADM,EAKN;AACClC,MAAAA,IAAI,EAAE,iBADP;AAECkC,MAAAA,KAAK,EAAE,cAAI,YAAJ;AAFR,KALM;AADR,KAYKC,GAAF,IACD,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGnC,IADR;AAEC,IAAA,QAAQ,EAAGmC,GAAG,CAACnC,IAFhB;AAGC,IAAA,KAAK,EAAGP,KAHT;AAIC,IAAA,QAAQ,EAAG4B;AAJZ,IAbF,CALD,CADD;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\t/*\n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchor uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst popoverAnchor = useCachedTruthy(\n\t\tuseAnchor( {\n\t\t\teditableContentElement: contentRef.current,\n\t\t\tsettings,\n\t\t} )\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -24,8 +24,7 @@ var _inline = require("./inline.js");
24
24
  /**
25
25
  * Internal dependencies
26
26
  */
27
- function parseCSS() {
28
- let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
27
+ function parseCSS(css = '') {
29
28
  return css.split(';').reduce((accumulator, rule) => {
30
29
  if (rule) {
31
30
  const [property, value] = rule.replace(/ /g, '').split(':');
@@ -104,12 +103,9 @@ function setColors(value, name, colorSettings, colors) {
104
103
  const {
105
104
  activeFormats
106
105
  } = newFormat;
107
- newFormat.formats[value.start] = [...((activeFormats === null || activeFormats === void 0 ? void 0 : activeFormats.filter(_ref => {
108
- let {
109
- type
110
- } = _ref;
111
- return type !== format.type;
112
- })) || []), format];
106
+ newFormat.formats[value.start] = [...(activeFormats?.filter(({
107
+ type
108
+ }) => type !== format.type) || []), format];
113
109
  return newFormat;
114
110
  } else if (hasNoSelection) {
115
111
  return (0, _richText.removeFormat)(value, format);
@@ -118,24 +114,21 @@ function setColors(value, name, colorSettings, colors) {
118
114
  return (0, _richText.applyFormat)(value, format);
119
115
  }
120
116
 
121
- function ColorPicker(_ref2) {
122
- let {
123
- name,
124
- value,
125
- onChange
126
- } = _ref2;
117
+ function ColorPicker({
118
+ name,
119
+ value,
120
+ onChange
121
+ }) {
127
122
  const property = 'color';
128
123
  const colors = (0, _components.useMobileGlobalStylesColors)();
129
124
  const colorSettings = (0, _blockEditor.useMultipleOriginColorsAndGradients)();
130
125
  const onColorChange = (0, _element.useCallback)(color => {
131
- var _value$text;
132
-
133
126
  if (color !== '') {
134
127
  onChange(setColors(value, name, colors, {
135
128
  [property]: color
136
129
  })); // Remove formatting if the color was reset, there's no
137
130
  // current selection and the previous character is a space
138
- } else if ((value === null || value === void 0 ? void 0 : value.start) === (value === null || value === void 0 ? void 0 : value.end) && ((_value$text = value.text) === null || _value$text === void 0 ? void 0 : _value$text.charAt((value === null || value === void 0 ? void 0 : value.end) - 1)) === ' ') {
131
+ } else if (value?.start === value?.end && value.text?.charAt(value?.end - 1) === ' ') {
139
132
  onChange((0, _richText.removeFormat)(value, name, value.end - 1, value.end));
140
133
  } else {
141
134
  onChange((0, _richText.removeFormat)(value, name));
@@ -150,13 +143,12 @@ function ColorPicker(_ref2) {
150
143
  });
151
144
  }
152
145
 
153
- function InlineColorUI(_ref3) {
154
- let {
155
- name,
156
- value,
157
- onChange,
158
- onClose
159
- } = _ref3;
146
+ function InlineColorUI({
147
+ name,
148
+ value,
149
+ onChange,
150
+ onClose
151
+ }) {
160
152
  return (0, _element.createElement)(_components.BottomSheet, {
161
153
  isVisible: true,
162
154
  onClose: onClose,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.native.js"],"names":["parseCSS","css","split","reduce","accumulator","rule","property","value","replace","color","transparentValue","backgroundColor","getActiveColors","name","colorSettings","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","colorObject","slug","length","format","type","hasNoSelection","start","end","isAtTheEnd","text","previousCharacter","charAt","newFormat","activeFormats","formats","filter","ColorPicker","onChange","onColorChange","activeColors","InlineColorUI","onClose","paddingLeft","paddingRight"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AASA;;AACA;;AAxBA;AACA;AACA;;AAkBA;AACA;AACA;AAIA,SAASA,QAAT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Ac;AAJf,IADD;AAQA;;AAEc,SAAS+B,aAAT,QAA6D;AAAA,MAArC;AAAEhC,IAAAA,IAAF;AAAQN,IAAAA,KAAR;AAAemC,IAAAA,QAAf;AAAyBI,IAAAA;AAAzB,GAAqC;AAC3E,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,MADV;AAEC,IAAA,OAAO,EAAGA,OAFX;AAGC,IAAA,UAAU,MAHX;AAIC,IAAA,YAAY,EAAG;AAAEC,MAAAA,WAAW,EAAE,CAAf;AAAkBC,MAAAA,YAAY,EAAE;AAAhC,KAJhB;AAKC,IAAA,aAAa,MALd;AAMC,IAAA,UAAU,EAAG,IANd;AAOC,IAAA,MAAM,EAAC;AAPR,KASC,4BAAC,uBAAD,CAAa,mBAAb;AAAiC,IAAA,OAAO,MAAxC;AAAyC,IAAA,IAAI;AAA7C,KACC,4BAAC,uBAAD,CAAa,gBAAb;AAA8B,IAAA,IAAI,EAAC;AAAnC,KACC,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGnC,IADR;AAEC,IAAA,KAAK,EAAGN,KAFT;AAGC,IAAA,QAAQ,EAAGmC;AAHZ,IADD,CADD,CATD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n} from '@wordpress/rich-text';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tuseMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\nimport {\n\tBottomSheet,\n\tColorSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { transparentValue } from './index.js';\nimport { parseClassName } from './inline.js';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.replace( / /g, '' ).split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nfunction getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t\tstyles.push( [ 'color', colorObject.color ].join( ':' ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\tconst format = { type: name, attributes };\n\tconst hasNoSelection = value.start === value.end;\n\tconst isAtTheEnd = value.end === value.text.length;\n\tconst previousCharacter = value.text.charAt( value.end - 1 );\n\n\t// Force formatting due to limitations in the native implementation\n\tif (\n\t\thasNoSelection &&\n\t\t( value.text.length === 0 ||\n\t\t\t( previousCharacter === ' ' && isAtTheEnd ) )\n\t) {\n\t\t// For cases where there's no text selected, there's a space before\n\t\t// the current caret position and it's at the end of the text.\n\t\treturn applyFormat( value, format, value.start - 1, value.end + 1 );\n\t} else if ( hasNoSelection && isAtTheEnd ) {\n\t\t// If there's no selection and is at the end of the text\n\t\t// manually add the format within the current caret position.\n\t\tconst newFormat = applyFormat( value, format );\n\t\tconst { activeFormats } = newFormat;\n\t\tnewFormat.formats[ value.start ] = [\n\t\t\t...( activeFormats?.filter(\n\t\t\t\t( { type } ) => type !== format.type\n\t\t\t) || [] ),\n\t\t\tformat,\n\t\t];\n\t\treturn newFormat;\n\t} else if ( hasNoSelection ) {\n\t\treturn removeFormat( value, format );\n\t}\n\n\treturn applyFormat( value, format );\n}\n\nfunction ColorPicker( { name, value, onChange } ) {\n\tconst property = 'color';\n\tconst colors = useMobileGlobalStylesColors();\n\tconst colorSettings = useMultipleOriginColorsAndGradients();\n\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tif ( color !== '' ) {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t\t// Remove formatting if the color was reset, there's no\n\t\t\t\t// current selection and the previous character is a space\n\t\t\t} else if (\n\t\t\t\tvalue?.start === value?.end &&\n\t\t\t\tvalue.text?.charAt( value?.end - 1 ) === ' '\n\t\t\t) {\n\t\t\t\tonChange(\n\t\t\t\t\tremoveFormat( value, name, value.end - 1, value.end )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tonChange( removeFormat( value, name ) );\n\t\t\t}\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorSettings\n\t\t\tcolorValue={ activeColors[ property ] }\n\t\t\tonColorChange={ onColorChange }\n\t\t\tdefaultSettings={ colorSettings }\n\t\t\thideNavigation\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( { name, value, onChange, onClose } ) {\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible\n\t\t\tonClose={ onClose }\n\t\t\thideHeader\n\t\t\tcontentStyle={ { paddingLeft: 0, paddingRight: 0 } }\n\t\t\thasNavigation\n\t\t\tleftButton={ null }\n\t\t\ttestID=\"inline-text-color-modal\"\n\t\t>\n\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t<BottomSheet.NavigationScreen name=\"text-color\">\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t</BottomSheet.NavigationContainer>\n\t\t</BottomSheet>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.native.js"],"names":["parseCSS","css","split","reduce","accumulator","rule","property","value","replace","color","transparentValue","backgroundColor","getActiveColors","name","colorSettings","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","colorObject","slug","length","format","type","hasNoSelection","start","end","isAtTheEnd","text","previousCharacter","charAt","newFormat","activeFormats","formats","filter","ColorPicker","onChange","onColorChange","activeColors","InlineColorUI","onClose","paddingLeft","paddingRight"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AASA;;AACA;;AAxBA;AACA;AACA;;AAkBA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,GAAG,GAAG,EAAzB,EAA8B;AAC7B,SAAOA,GAAG,CAACC,KAAJ,CAAW,GAAX,EAAiBC,MAAjB,CAAyB,CAAEC,WAAF,EAAeC,IAAf,KAAyB;AACxD,QAAKA,IAAL,EAAY;AACX,YAAM,CAAEC,QAAF,EAAYC,KAAZ,IAAsBF,IAAI,CAACG,OAAL,CAAc,IAAd,EAAoB,EAApB,EAAyBN,KAAzB,CAAgC,GAAhC,CAA5B;AACA,UAAKI,QAAQ,KAAK,OAAlB,EAA4BF,WAAW,CAACK,KAAZ,GAAoBF,KAApB;AAC5B,UAAKD,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WAAD;AACC,IAAA,IAAI,EAAGnC,IADR;AAEC,IAAA,KAAK,EAAGN,KAFT;AAGC,IAAA,QAAQ,EAAGmC;AAHZ,IADD,CADD,CATD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n} from '@wordpress/rich-text';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tuseMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\nimport {\n\tBottomSheet,\n\tColorSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { transparentValue } from './index.js';\nimport { parseClassName } from './inline.js';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.replace( / /g, '' ).split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nfunction getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t\tstyles.push( [ 'color', colorObject.color ].join( ':' ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\tconst format = { type: name, attributes };\n\tconst hasNoSelection = value.start === value.end;\n\tconst isAtTheEnd = value.end === value.text.length;\n\tconst previousCharacter = value.text.charAt( value.end - 1 );\n\n\t// Force formatting due to limitations in the native implementation\n\tif (\n\t\thasNoSelection &&\n\t\t( value.text.length === 0 ||\n\t\t\t( previousCharacter === ' ' && isAtTheEnd ) )\n\t) {\n\t\t// For cases where there's no text selected, there's a space before\n\t\t// the current caret position and it's at the end of the text.\n\t\treturn applyFormat( value, format, value.start - 1, value.end + 1 );\n\t} else if ( hasNoSelection && isAtTheEnd ) {\n\t\t// If there's no selection and is at the end of the text\n\t\t// manually add the format within the current caret position.\n\t\tconst newFormat = applyFormat( value, format );\n\t\tconst { activeFormats } = newFormat;\n\t\tnewFormat.formats[ value.start ] = [\n\t\t\t...( activeFormats?.filter(\n\t\t\t\t( { type } ) => type !== format.type\n\t\t\t) || [] ),\n\t\t\tformat,\n\t\t];\n\t\treturn newFormat;\n\t} else if ( hasNoSelection ) {\n\t\treturn removeFormat( value, format );\n\t}\n\n\treturn applyFormat( value, format );\n}\n\nfunction ColorPicker( { name, value, onChange } ) {\n\tconst property = 'color';\n\tconst colors = useMobileGlobalStylesColors();\n\tconst colorSettings = useMultipleOriginColorsAndGradients();\n\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tif ( color !== '' ) {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t\t// Remove formatting if the color was reset, there's no\n\t\t\t\t// current selection and the previous character is a space\n\t\t\t} else if (\n\t\t\t\tvalue?.start === value?.end &&\n\t\t\t\tvalue.text?.charAt( value?.end - 1 ) === ' '\n\t\t\t) {\n\t\t\t\tonChange(\n\t\t\t\t\tremoveFormat( value, name, value.end - 1, value.end )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tonChange( removeFormat( value, name ) );\n\t\t\t}\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorSettings\n\t\t\tcolorValue={ activeColors[ property ] }\n\t\t\tonColorChange={ onColorChange }\n\t\t\tdefaultSettings={ colorSettings }\n\t\t\thideNavigation\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( { name, value, onChange, onClose } ) {\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible\n\t\t\tonClose={ onClose }\n\t\t\thideHeader\n\t\t\tcontentStyle={ { paddingLeft: 0, paddingRight: 0 } }\n\t\t\thasNavigation\n\t\t\tleftButton={ null }\n\t\t\ttestID=\"inline-text-color-modal\"\n\t\t>\n\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t<BottomSheet.NavigationScreen name=\"text-color\">\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t</BottomSheet.NavigationContainer>\n\t\t</BottomSheet>\n\t);\n}\n"]}
@@ -27,12 +27,10 @@ const underline = {
27
27
  style: 'style'
28
28
  },
29
29
 
30
- edit(_ref) {
31
- let {
32
- value,
33
- onChange
34
- } = _ref;
35
-
30
+ edit({
31
+ value,
32
+ onChange
33
+ }) {
36
34
  const onToggle = () => {
37
35
  onChange((0, _richText.toggleFormat)(value, {
38
36
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/underline/index.js"],"names":["name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAQA,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,MAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE;AADI,GALY;;AAQxBC,EAAAA,IAAI,OAAwB;AAAA,QAAtB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAsB;;AAC3B,UAAMC,QAAQ,GAAG,MAAM;AACtBD,MAAAA,QAAQ,CACP,4BAAcD,KAAd,EAAqB;AACpBG,QAAAA,IAAI,EAAEX,IADc;AAEpBK,QAAAA,UAAU,EAAE;AACXC,UAAAA,KAAK,EAAE;AADI,SAFQ;AAKpBL,QAAAA;AALoB,OAArB,CADO,CAAR;AASA,KAVD;;AAYA,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGS;AAHT,MADD,EAMC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,iBADX;AAEC,MAAA,OAAO,EAAGA;AAFX,MAND,CADD;AAaA;;AAlCuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\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=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\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/underline/index.js"],"names":["name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAQA,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,MAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE;AADI,GALY;;AAQxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAF,EAAwB;AAC3B,UAAMC,QAAQ,GAAG,MAAM;AACtBD,MAAAA,QAAQ,CACP,4BAAcD,KAAd,EAAqB;AACpBG,QAAAA,IAAI,EAAEX,IADc;AAEpBK,QAAAA,UAAU,EAAE;AACXC,UAAAA,KAAK,EAAE;AADI,SAFQ;AAKpBL,QAAAA;AALoB,OAArB,CADO,CAAR;AASA,KAVD;;AAYA,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGS;AAHT,MADD,EAMC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,iBADX;AAEC,MAAA,OAAO,EAAGA;AAFX,MAND,CADD;AAaA;;AAlCuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\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=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
@@ -26,14 +26,12 @@ const unknown = {
26
26
  tagName: '*',
27
27
  className: null,
28
28
 
29
- edit(_ref) {
30
- let {
31
- isActive,
32
- value,
33
- onChange,
34
- onFocus
35
- } = _ref;
36
-
29
+ edit({
30
+ isActive,
31
+ value,
32
+ onChange,
33
+ onFocus
34
+ }) {
37
35
  function onClick() {
38
36
  onChange((0, _richText.removeFormat)(value, name));
39
37
  onFocus();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/unknown/index.js"],"names":["name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type","help"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,cAAb;AACA,MAAMC,KAAK,GAAG,cAAI,0BAAJ,CAAd;AAEO,MAAMC,OAAO,GAAG;AACtBF,EAAAA,IADsB;AAEtBC,EAAAA,KAFsB;AAGtBE,EAAAA,OAAO,EAAE,GAHa;AAItBC,EAAAA,SAAS,EAAE,IAJW;;AAKtBC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqBP,IAArB,CAAF,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,UAAME,aAAa,GAAG,qBAAOJ,KAAP,CAAtB;AACA,UAAMK,iBAAiB,GAAGD,aAAa,CAACE,OAAd,CAAsBC,IAAtB,CAA8BD,OAAF,IAAe;AACpE,aAAOA,OAAO,CAACC,IAAR,CAAgBC,MAAF,IAAcA,MAAM,CAACC,IAAP,KAAgBhB,IAA5C,CAAP;AACA,KAFyB,CAA1B;;AAIA,QAAK,CAAEM,QAAF,IAAc,CAAEM,iBAArB,EAAyC;AACxC,aAAO,IAAP;AACA;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,IAAI,EAAGK,WAFR;AAGC,MAAA,KAAK,EAAGhB,KAHT;AAIC,MAAA,OAAO,EAAGS,OAJX;AAKC,MAAA,QAAQ,EAAG;AALZ,MADD;AASA;;AA7BqB,CAAhB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { help } from '@wordpress/icons';\n\nconst name = 'core/unknown';\nconst title = __( 'Clear Unknown Formatting' );\n\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\tconst selectedValue = slice( value );\n\t\tconst hasUnknownFormats = selectedValue.formats.some( ( formats ) => {\n\t\t\treturn formats.some( ( format ) => format.type === name );\n\t\t} );\n\n\t\tif ( ! isActive && ! hasUnknownFormats ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"unknown\"\n\t\t\t\ticon={ help }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ true }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/unknown/index.js"],"names":["name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type","help"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,cAAb;AACA,MAAMC,KAAK,GAAG,cAAI,0BAAJ,CAAd;AAEO,MAAMC,OAAO,GAAG;AACtBF,EAAAA,IADsB;AAEtBC,EAAAA,KAFsB;AAGtBE,EAAAA,OAAO,EAAE,GAHa;AAItBC,EAAAA,SAAS,EAAE,IAJW;;AAKtBC,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,EAAqBP,IAArB,CAAF,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,UAAME,aAAa,GAAG,qBAAOJ,KAAP,CAAtB;AACA,UAAMK,iBAAiB,GAAGD,aAAa,CAACE,OAAd,CAAsBC,IAAtB,CAA8BD,OAAF,IAAe;AACpE,aAAOA,OAAO,CAACC,IAAR,CAAgBC,MAAF,IAAcA,MAAM,CAACC,IAAP,KAAgBhB,IAA5C,CAAP;AACA,KAFyB,CAA1B;;AAIA,QAAK,CAAEM,QAAF,IAAc,CAAEM,iBAArB,EAAyC;AACxC,aAAO,IAAP;AACA;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,IAAI,EAAGK,WAFR;AAGC,MAAA,KAAK,EAAGhB,KAHT;AAIC,MAAA,OAAO,EAAGS,OAJX;AAKC,MAAA,QAAQ,EAAG;AALZ,MADD;AASA;;AA7BqB,CAAhB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { help } from '@wordpress/icons';\n\nconst name = 'core/unknown';\nconst title = __( 'Clear Unknown Formatting' );\n\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\tconst selectedValue = slice( value );\n\t\tconst hasUnknownFormats = selectedValue.formats.some( ( formats ) => {\n\t\t\treturn formats.some( ( format ) => format.type === name );\n\t\t} );\n\n\t\tif ( ! isActive && ! hasUnknownFormats ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"unknown\"\n\t\t\t\ticon={ help }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ true }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}