@wordpress/format-library 5.32.0 → 5.32.1-next.ff1cebbba.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 (132) hide show
  1. package/build/bold/index.js +69 -58
  2. package/build/bold/index.js.map +7 -1
  3. package/build/code/index.js +62 -54
  4. package/build/code/index.js.map +7 -1
  5. package/build/default-formats.js +52 -24
  6. package/build/default-formats.js.map +7 -1
  7. package/build/image/index.js +185 -153
  8. package/build/image/index.js.map +7 -1
  9. package/build/index.js +28 -18
  10. package/build/index.js.map +7 -1
  11. package/build/italic/index.js +69 -58
  12. package/build/italic/index.js.map +7 -1
  13. package/build/keyboard/index.js +47 -36
  14. package/build/keyboard/index.js.map +7 -1
  15. package/build/language/index.js +145 -113
  16. package/build/language/index.js.map +7 -1
  17. package/build/link/css-classes-setting.js +81 -0
  18. package/build/link/css-classes-setting.js.map +7 -0
  19. package/build/link/index.js +162 -167
  20. package/build/link/index.js.map +7 -1
  21. package/build/link/inline.js +186 -174
  22. package/build/link/inline.js.map +7 -1
  23. package/build/link/use-link-instance-key.js +25 -19
  24. package/build/link/use-link-instance-key.js.map +7 -1
  25. package/build/link/utils.js +66 -115
  26. package/build/link/utils.js.map +7 -1
  27. package/build/lock-unlock.js +31 -15
  28. package/build/lock-unlock.js.map +7 -1
  29. package/build/non-breaking-space/index.js +44 -28
  30. package/build/non-breaking-space/index.js.map +7 -1
  31. package/build/strikethrough/index.js +57 -42
  32. package/build/strikethrough/index.js.map +7 -1
  33. package/build/subscript/index.js +47 -36
  34. package/build/subscript/index.js.map +7 -1
  35. package/build/superscript/index.js +47 -36
  36. package/build/superscript/index.js.map +7 -1
  37. package/build/text-color/index.js +102 -70
  38. package/build/text-color/index.js.map +7 -1
  39. package/build/text-color/inline.js +118 -116
  40. package/build/text-color/inline.js.map +7 -1
  41. package/build/underline/index.js +62 -40
  42. package/build/underline/index.js.map +7 -1
  43. package/build/unknown/index.js +51 -37
  44. package/build/unknown/index.js.map +7 -1
  45. package/build-module/bold/index.js +52 -52
  46. package/build-module/bold/index.js.map +7 -1
  47. package/build-module/code/index.js +41 -46
  48. package/build-module/code/index.js.map +7 -1
  49. package/build-module/default-formats.js +34 -19
  50. package/build-module/default-formats.js.map +7 -1
  51. package/build-module/image/index.js +174 -144
  52. package/build-module/image/index.js.map +7 -1
  53. package/build-module/index.js +6 -14
  54. package/build-module/index.js.map +7 -1
  55. package/build-module/italic/index.js +52 -52
  56. package/build-module/italic/index.js.map +7 -1
  57. package/build-module/keyboard/index.js +25 -30
  58. package/build-module/keyboard/index.js.map +7 -1
  59. package/build-module/language/index.js +128 -105
  60. package/build-module/language/index.js.map +7 -1
  61. package/build-module/link/css-classes-setting.js +67 -0
  62. package/build-module/link/css-classes-setting.js.map +7 -0
  63. package/build-module/link/index.js +128 -146
  64. package/build-module/link/index.js.map +7 -1
  65. package/build-module/link/inline.js +158 -154
  66. package/build-module/link/inline.js.map +7 -1
  67. package/build-module/link/use-link-instance-key.js +7 -14
  68. package/build-module/link/use-link-instance-key.js.map +7 -1
  69. package/build-module/link/utils.js +46 -101
  70. package/build-module/link/utils.js.map +7 -1
  71. package/build-module/lock-unlock.js +8 -7
  72. package/build-module/lock-unlock.js.map +7 -1
  73. package/build-module/non-breaking-space/index.js +22 -22
  74. package/build-module/non-breaking-space/index.js.map +7 -1
  75. package/build-module/strikethrough/index.js +38 -36
  76. package/build-module/strikethrough/index.js.map +7 -1
  77. package/build-module/subscript/index.js +25 -30
  78. package/build-module/subscript/index.js.map +7 -1
  79. package/build-module/superscript/index.js +25 -30
  80. package/build-module/superscript/index.js.map +7 -1
  81. package/build-module/text-color/index.js +72 -61
  82. package/build-module/text-color/index.js.map +7 -1
  83. package/build-module/text-color/inline.js +107 -106
  84. package/build-module/text-color/inline.js.map +7 -1
  85. package/build-module/underline/index.js +43 -34
  86. package/build-module/underline/index.js.map +7 -1
  87. package/build-module/unknown/index.js +26 -28
  88. package/build-module/unknown/index.js.map +7 -1
  89. package/build-style/style-rtl.css +0 -194
  90. package/build-style/style.css +0 -194
  91. package/package.json +21 -15
  92. package/src/image/style.scss +3 -0
  93. package/src/link/css-classes-setting.js +89 -0
  94. package/src/link/index.js +1 -0
  95. package/src/link/inline.js +19 -0
  96. package/src/link/style.scss +3 -0
  97. package/src/link/test/css-classes-setting.js +144 -0
  98. package/src/link/utils.js +8 -0
  99. package/src/style.scss +4 -4
  100. package/src/text-color/style.scss +2 -0
  101. package/build/default-formats.native.js +0 -16
  102. package/build/default-formats.native.js.map +0 -1
  103. package/build/link/index.native.js +0 -174
  104. package/build/link/index.native.js.map +0 -1
  105. package/build/link/modal-screens/link-picker-screen.native.js +0 -67
  106. package/build/link/modal-screens/link-picker-screen.native.js.map +0 -1
  107. package/build/link/modal-screens/link-settings-screen.native.js +0 -226
  108. package/build/link/modal-screens/link-settings-screen.native.js.map +0 -1
  109. package/build/link/modal-screens/screens.native.js +0 -11
  110. package/build/link/modal-screens/screens.native.js.map +0 -1
  111. package/build/link/modal.native.js +0 -53
  112. package/build/link/modal.native.js.map +0 -1
  113. package/build/text-color/index.native.js +0 -134
  114. package/build/text-color/index.native.js.map +0 -1
  115. package/build/text-color/inline.native.js +0 -150
  116. package/build/text-color/inline.native.js.map +0 -1
  117. package/build-module/default-formats.native.js +0 -10
  118. package/build-module/default-formats.native.js.map +0 -1
  119. package/build-module/link/index.native.js +0 -166
  120. package/build-module/link/index.native.js.map +0 -1
  121. package/build-module/link/modal-screens/link-picker-screen.native.js +0 -59
  122. package/build-module/link/modal-screens/link-picker-screen.native.js.map +0 -1
  123. package/build-module/link/modal-screens/link-settings-screen.native.js +0 -218
  124. package/build-module/link/modal-screens/link-settings-screen.native.js.map +0 -1
  125. package/build-module/link/modal-screens/screens.native.js +0 -5
  126. package/build-module/link/modal-screens/screens.native.js.map +0 -1
  127. package/build-module/link/modal.native.js +0 -45
  128. package/build-module/link/modal.native.js.map +0 -1
  129. package/build-module/text-color/index.native.js +0 -126
  130. package/build-module/text-color/index.native.js.map +0 -1
  131. package/build-module/text-color/inline.native.js +0 -142
  132. package/build-module/text-color/inline.native.js.map +0 -1
@@ -1,41 +1,36 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { toggleFormat } from '@wordpress/rich-text';
6
- import { RichTextToolbarButton } from '@wordpress/block-editor';
7
- import { superscript as superscriptIcon } from '@wordpress/icons';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- const name = 'core/superscript';
10
- const title = __('Superscript');
11
- export const superscript = {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { __ } from "@wordpress/i18n";
3
+ import { toggleFormat } from "@wordpress/rich-text";
4
+ import { RichTextToolbarButton } from "@wordpress/block-editor";
5
+ import { superscript as superscriptIcon } from "@wordpress/icons";
6
+ const name = "core/superscript";
7
+ const title = __("Superscript");
8
+ const superscript = {
12
9
  name,
13
10
  title,
14
- tagName: 'sup',
11
+ tagName: "sup",
15
12
  className: null,
16
- edit({
17
- isActive,
18
- value,
19
- onChange,
20
- onFocus
21
- }) {
13
+ edit({ isActive, value, onChange, onFocus }) {
22
14
  function onToggle() {
23
- onChange(toggleFormat(value, {
24
- type: name,
25
- title
26
- }));
15
+ onChange(toggleFormat(value, { type: name, title }));
27
16
  }
28
17
  function onClick() {
29
18
  onToggle();
30
19
  onFocus();
31
20
  }
32
- return /*#__PURE__*/_jsx(RichTextToolbarButton, {
33
- icon: superscriptIcon,
34
- title: title,
35
- onClick: onClick,
36
- isActive: isActive,
37
- role: "menuitemcheckbox"
38
- });
21
+ return /* @__PURE__ */ jsx(
22
+ RichTextToolbarButton,
23
+ {
24
+ icon: superscriptIcon,
25
+ title,
26
+ onClick,
27
+ isActive,
28
+ role: "menuitemcheckbox"
29
+ }
30
+ );
39
31
  }
40
32
  };
41
- //# sourceMappingURL=index.js.map
33
+ export {
34
+ superscript
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["__","toggleFormat","RichTextToolbarButton","superscript","superscriptIcon","jsx","_jsx","name","title","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","icon","role"],"sources":["@wordpress/format-library/src/superscript/index.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,WAAW,IAAIC,eAAe,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElE,MAAMC,IAAI,GAAG,kBAAkB;AAC/B,MAAMC,KAAK,GAAGR,EAAE,CAAE,aAAc,CAAC;AAEjC,OAAO,MAAMG,WAAW,GAAG;EAC1BI,IAAI;EACJC,KAAK;EACLC,OAAO,EAAE,KAAK;EACdC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,SAASC,QAAQA,CAAA,EAAG;MACnBF,QAAQ,CAAEb,YAAY,CAAEY,KAAK,EAAE;QAAEI,IAAI,EAAEV,IAAI;QAAEC;MAAM,CAAE,CAAE,CAAC;IACzD;IAEA,SAASU,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAC,CAAC;MACVD,OAAO,CAAC,CAAC;IACV;IAEA,oBACCT,IAAA,CAACJ,qBAAqB;MACrBiB,IAAI,EAAGf,eAAiB;MACxBI,KAAK,EAAGA,KAAO;MACfU,OAAO,EAAGA,OAAS;MACnBN,QAAQ,EAAGA,QAAU;MACrBQ,IAAI,EAAC;IAAkB,CACvB,CAAC;EAEJ;AACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/superscript/index.js"],
4
+ "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"],
5
+ "mappings": "AA2BG;AAxBH,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,eAAe,uBAAuB;AAE/C,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,aAAc;AAEzB,MAAM,cAAc;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,aAAS,WAAW;AACnB,eAAU,aAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,eAAS;AACT,cAAQ;AAAA,IACT;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAK;AAAA;AAAA,IACN;AAAA,EAEF;AACD;",
6
+ "names": []
7
+ }
@@ -1,45 +1,35 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { useMemo, useState } from '@wordpress/element';
6
- import { RichTextToolbarButton, useSettings } from '@wordpress/block-editor';
7
- import { Icon, color as colorIcon, textColor as textColorIcon } from '@wordpress/icons';
8
- import { removeFormat } from '@wordpress/rich-text';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import { default as InlineColorUI, getActiveColors } from './inline';
14
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
15
- export const transparentValue = 'rgba(0, 0, 0, 0)';
16
- const name = 'core/text-color';
17
- const title = __('Highlight');
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { __ } from "@wordpress/i18n";
3
+ import { useMemo, useState } from "@wordpress/element";
4
+ import { RichTextToolbarButton, useSettings } from "@wordpress/block-editor";
5
+ import {
6
+ Icon,
7
+ color as colorIcon,
8
+ textColor as textColorIcon
9
+ } from "@wordpress/icons";
10
+ import { removeFormat } from "@wordpress/rich-text";
11
+ import { default as InlineColorUI, getActiveColors } from "./inline";
12
+ const transparentValue = "rgba(0, 0, 0, 0)";
13
+ const name = "core/text-color";
14
+ const title = __("Highlight");
18
15
  const EMPTY_ARRAY = [];
19
16
  function getComputedStyleProperty(element, property) {
20
- const {
21
- ownerDocument
22
- } = element;
23
- const {
24
- defaultView
25
- } = ownerDocument;
17
+ const { ownerDocument } = element;
18
+ const { defaultView } = ownerDocument;
26
19
  const style = defaultView.getComputedStyle(element);
27
20
  const value = style.getPropertyValue(property);
28
- if (property === 'background-color' && value === transparentValue && element.parentElement) {
21
+ if (property === "background-color" && value === transparentValue && element.parentElement) {
29
22
  return getComputedStyleProperty(element.parentElement, property);
30
23
  }
31
24
  return value;
32
25
  }
33
- function fillComputedColors(element, {
34
- color,
35
- backgroundColor
36
- }) {
26
+ function fillComputedColors(element, { color, backgroundColor }) {
37
27
  if (!color && !backgroundColor) {
38
28
  return;
39
29
  }
40
30
  return {
41
- color: color || getComputedStyleProperty(element, 'color'),
42
- backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor
31
+ color: color || getComputedStyleProperty(element, "color"),
32
+ backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, "background-color") : backgroundColor
43
33
  };
44
34
  }
45
35
  function TextColorEdit({
@@ -49,46 +39,67 @@ function TextColorEdit({
49
39
  activeAttributes,
50
40
  contentRef
51
41
  }) {
52
- const [allowCustomControl, colors = EMPTY_ARRAY] = useSettings('color.custom', 'color.palette');
42
+ const [allowCustomControl, colors = EMPTY_ARRAY] = useSettings(
43
+ "color.custom",
44
+ "color.palette"
45
+ );
53
46
  const [isAddingColor, setIsAddingColor] = useState(false);
54
- const colorIndicatorStyle = useMemo(() => fillComputedColors(contentRef.current, getActiveColors(value, name, colors)), [contentRef, value, colors]);
47
+ const colorIndicatorStyle = useMemo(
48
+ () => fillComputedColors(
49
+ contentRef.current,
50
+ getActiveColors(value, name, colors)
51
+ ),
52
+ [contentRef, value, colors]
53
+ );
55
54
  const hasColorsToChoose = !!colors.length || allowCustomControl;
56
55
  if (!hasColorsToChoose && !isActive) {
57
56
  return null;
58
57
  }
59
- return /*#__PURE__*/_jsxs(_Fragment, {
60
- children: [/*#__PURE__*/_jsx(RichTextToolbarButton, {
61
- className: "format-library-text-color-button",
62
- isActive: isActive,
63
- icon: /*#__PURE__*/_jsx(Icon, {
64
- icon: Object.keys(activeAttributes).length ? textColorIcon : colorIcon,
65
- style: colorIndicatorStyle
66
- }),
67
- title: title
68
- // If has no colors to choose but a color is active remove the color onClick.
69
- ,
70
- onClick: hasColorsToChoose ? () => setIsAddingColor(true) : () => onChange(removeFormat(value, name)),
71
- role: "menuitemcheckbox"
72
- }), isAddingColor && /*#__PURE__*/_jsx(InlineColorUI, {
73
- name: name,
74
- onClose: () => setIsAddingColor(false),
75
- activeAttributes: activeAttributes,
76
- value: value,
77
- onChange: onChange,
78
- contentRef: contentRef,
79
- isActive: isActive
80
- })]
81
- });
58
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
59
+ /* @__PURE__ */ jsx(
60
+ RichTextToolbarButton,
61
+ {
62
+ className: "format-library-text-color-button",
63
+ isActive,
64
+ icon: /* @__PURE__ */ jsx(
65
+ Icon,
66
+ {
67
+ icon: Object.keys(activeAttributes).length ? textColorIcon : colorIcon,
68
+ style: colorIndicatorStyle
69
+ }
70
+ ),
71
+ title,
72
+ onClick: hasColorsToChoose ? () => setIsAddingColor(true) : () => onChange(removeFormat(value, name)),
73
+ role: "menuitemcheckbox"
74
+ }
75
+ ),
76
+ isAddingColor && /* @__PURE__ */ jsx(
77
+ InlineColorUI,
78
+ {
79
+ name,
80
+ onClose: () => setIsAddingColor(false),
81
+ activeAttributes,
82
+ value,
83
+ onChange,
84
+ contentRef,
85
+ isActive
86
+ }
87
+ )
88
+ ] });
82
89
  }
83
- export const textColor = {
90
+ const textColor = {
84
91
  name,
85
92
  title,
86
- tagName: 'mark',
87
- className: 'has-inline-color',
93
+ tagName: "mark",
94
+ className: "has-inline-color",
88
95
  attributes: {
89
- style: 'style',
90
- class: 'class'
96
+ style: "style",
97
+ class: "class"
91
98
  },
92
99
  edit: TextColorEdit
93
100
  };
94
- //# sourceMappingURL=index.js.map
101
+ export {
102
+ textColor,
103
+ transparentValue
104
+ };
105
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["__","useMemo","useState","RichTextToolbarButton","useSettings","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColors","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","children","className","icon","Object","keys","onClick","role","onClose","tagName","attributes","class","edit"],"sources":["@wordpress/format-library/src/text-color/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSettings } 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, colors = EMPTY_ARRAY ] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette'\n\t);\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\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[ contentRef, 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? () => setIsAddingColor( true )\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={ () => setIsAddingColor( false ) }\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\tisActive={ isActive }\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\tedit: TextColorEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,yBAAyB;AAC5E,SACCC,IAAI,EACJC,KAAK,IAAIC,SAAS,EAClBC,SAAS,IAAIC,aAAa,QACpB,kBAAkB;AACzB,SAASC,YAAY,QAAQ,sBAAsB;;AAEnD;AACA;AACA;AACA,SAASC,OAAO,IAAIC,aAAa,EAAEC,eAAe,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAErE,OAAO,MAAMC,gBAAgB,GAAG,kBAAkB;AAElD,MAAMC,IAAI,GAAG,iBAAiB;AAC9B,MAAMC,KAAK,GAAGtB,EAAE,CAAE,WAAY,CAAC;AAE/B,MAAMuB,WAAW,GAAG,EAAE;AAEtB,SAASC,wBAAwBA,CAAEC,OAAO,EAAEC,QAAQ,EAAG;EACtD,MAAM;IAAEC;EAAc,CAAC,GAAGF,OAAO;EACjC,MAAM;IAAEG;EAAY,CAAC,GAAGD,aAAa;EACrC,MAAME,KAAK,GAAGD,WAAW,CAACE,gBAAgB,CAAEL,OAAQ,CAAC;EACrD,MAAMM,KAAK,GAAGF,KAAK,CAACG,gBAAgB,CAAEN,QAAS,CAAC;EAEhD,IACCA,QAAQ,KAAK,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,qBAAqB;MACrB+C,SAAS,EAAC,kCAAkC;MAC5CZ,QAAQ,EAAGA,QAAU;MACrBa,IAAI,eACHpC,IAAA,CAACV,IAAI;QACJ8C,IAAI,EACHC,MAAM,CAACC,IAAI,CAAEd,gBAAiB,CAAC,CAACS,MAAM,GACnCvC,aAAa,GACbF,SACH;QACDsB,KAAK,EAAGgB;MAAqB,CAC7B,CACD;MACDvB,KAAK,EAAGA;MACR;MAAA;MACAgC,OAAO,EACNP,iBAAiB,GACd,MAAMH,gBAAgB,CAAE,IAAK,CAAC,GAC9B,MAAMP,QAAQ,CAAE3B,YAAY,CAAEqB,KAAK,EAAEV,IAAK,CAAE,CAC/C;MACDkC,IAAI,EAAC;IAAkB,CACvB,CAAC,EACAZ,aAAa,iBACd5B,IAAA,CAACH,aAAa;MACbS,IAAI,EAAGA,IAAM;MACbmC,OAAO,EAAGA,CAAA,KAAMZ,gBAAgB,CAAE,KAAM,CAAG;MAC3CL,gBAAgB,EAAGA,gBAAkB;MACrCR,KAAK,EAAGA,KAAO;MACfM,QAAQ,EAAGA,QAAU;MACrBG,UAAU,EAAGA,UAAY;MACzBF,QAAQ,EAAGA;IAAU,CACrB,CACD;EAAA,CACA,CAAC;AAEL;AAEA,OAAO,MAAM9B,SAAS,GAAG;EACxBa,IAAI;EACJC,KAAK;EACLmC,OAAO,EAAE,MAAM;EACfP,SAAS,EAAE,kBAAkB;EAC7BQ,UAAU,EAAE;IACX7B,KAAK,EAAE,OAAO;IACd8B,KAAK,EAAE;EACR,CAAC;EACDC,IAAI,EAAExB;AACP,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/text-color/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSettings } 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, colors = EMPTY_ARRAY ] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette'\n\t);\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\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[ contentRef, 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? () => setIsAddingColor( true )\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={ () => setIsAddingColor( false ) }\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\tisActive={ isActive }\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\tedit: TextColorEdit,\n};\n"],
5
+ "mappings": "AAmFE,mBAKG,KALH;AAhFF,SAAS,UAAU;AACnB,SAAS,SAAS,gBAAgB;AAClC,SAAS,uBAAuB,mBAAmB;AACnD;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,OACP;AACP,SAAS,oBAAoB;AAK7B,SAAS,WAAW,eAAe,uBAAuB;AAEnD,MAAM,mBAAmB;AAEhC,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,WAAY;AAE9B,MAAM,cAAc,CAAC;AAErB,SAAS,yBAA0B,SAAS,UAAW;AACtD,QA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,aAAc,OAAO,IAAK,CAAE;AAAA,QAEhD,MAAK;AAAA;AAAA,IACN;AAAA,IACE,iBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,SAAU,MAAM,iBAAkB,KAAM;AAAA,QACxC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEO,MAAM,YAAY;AAAA,EACxB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,OAAO;AAAA,IACP,OAAO;AAAA,EACR;AAAA,EACA,MAAM;AACP;",
6
+ "names": []
7
+ }
@@ -1,55 +1,59 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useMemo } from '@wordpress/element';
5
- import { useSelect } from '@wordpress/data';
6
- import { applyFormat, removeFormat, getActiveFormat, useAnchor } from '@wordpress/rich-text';
7
- import { ColorPalette, getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues, store as blockEditorStore } from '@wordpress/block-editor';
8
- import { Popover, privateApis as componentsPrivateApis } from '@wordpress/components';
9
- import { __ } from '@wordpress/i18n';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { textColor as settings, transparentValue } from './index';
15
- import { unlock } from '../lock-unlock';
16
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
- const {
18
- Tabs
19
- } = unlock(componentsPrivateApis);
20
- const TABS = [{
21
- name: 'color',
22
- title: __('Text')
23
- }, {
24
- name: 'backgroundColor',
25
- title: __('Background')
26
- }];
27
- function parseCSS(css = '') {
28
- return css.split(';').reduce((accumulator, rule) => {
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "@wordpress/element";
3
+ import { useSelect } from "@wordpress/data";
4
+ import {
5
+ applyFormat,
6
+ removeFormat,
7
+ getActiveFormat,
8
+ useAnchor
9
+ } from "@wordpress/rich-text";
10
+ import {
11
+ ColorPalette,
12
+ getColorClassName,
13
+ getColorObjectByColorValue,
14
+ getColorObjectByAttributeValues,
15
+ store as blockEditorStore
16
+ } from "@wordpress/block-editor";
17
+ import {
18
+ Popover,
19
+ privateApis as componentsPrivateApis
20
+ } from "@wordpress/components";
21
+ import { __ } from "@wordpress/i18n";
22
+ import { textColor as settings, transparentValue } from "./index";
23
+ import { unlock } from "../lock-unlock";
24
+ const { Tabs } = unlock(componentsPrivateApis);
25
+ const TABS = [
26
+ { name: "color", title: __("Text") },
27
+ { name: "backgroundColor", title: __("Background") }
28
+ ];
29
+ function parseCSS(css = "") {
30
+ return css.split(";").reduce((accumulator, rule) => {
29
31
  if (rule) {
30
- const [property, value] = rule.split(':');
31
- if (property === 'color') {
32
+ const [property, value] = rule.split(":");
33
+ if (property === "color") {
32
34
  accumulator.color = value;
33
35
  }
34
- if (property === 'background-color' && value !== transparentValue) {
36
+ if (property === "background-color" && value !== transparentValue) {
35
37
  accumulator.backgroundColor = value;
36
38
  }
37
39
  }
38
40
  return accumulator;
39
41
  }, {});
40
42
  }
41
- export function parseClassName(className = '', colorSettings) {
42
- return className.split(' ').reduce((accumulator, name) => {
43
- // `colorSlug` could contain dashes, so simply match the start and end.
44
- if (name.startsWith('has-') && name.endsWith('-color')) {
45
- const colorSlug = name.replace(/^has-/, '').replace(/-color$/, '');
46
- const colorObject = getColorObjectByAttributeValues(colorSettings, colorSlug);
43
+ function parseClassName(className = "", colorSettings) {
44
+ return className.split(" ").reduce((accumulator, name) => {
45
+ if (name.startsWith("has-") && name.endsWith("-color")) {
46
+ const colorSlug = name.replace(/^has-/, "").replace(/-color$/, "");
47
+ const colorObject = getColorObjectByAttributeValues(
48
+ colorSettings,
49
+ colorSlug
50
+ );
47
51
  accumulator.color = colorObject.color;
48
52
  }
49
53
  return accumulator;
50
54
  }, {});
51
55
  }
52
- export function getActiveColors(value, name, colorSettings) {
56
+ function getActiveColors(value, name, colorSettings) {
53
57
  const activeColorFormat = getActiveFormat(value, name);
54
58
  if (!activeColorFormat) {
55
59
  return {};
@@ -60,10 +64,7 @@ export function getActiveColors(value, name, colorSettings) {
60
64
  };
61
65
  }
62
66
  function setColors(value, name, colorSettings, colors) {
63
- const {
64
- color,
65
- backgroundColor
66
- } = {
67
+ const { color, backgroundColor } = {
67
68
  ...getActiveColors(value, name, colorSettings),
68
69
  ...colors
69
70
  };
@@ -74,58 +75,50 @@ function setColors(value, name, colorSettings, colors) {
74
75
  const classNames = [];
75
76
  const attributes = {};
76
77
  if (backgroundColor) {
77
- styles.push(['background-color', backgroundColor].join(':'));
78
+ styles.push(["background-color", backgroundColor].join(":"));
78
79
  } else {
79
- // Override default browser color for mark element.
80
- styles.push(['background-color', transparentValue].join(':'));
80
+ styles.push(["background-color", transparentValue].join(":"));
81
81
  }
82
82
  if (color) {
83
83
  const colorObject = getColorObjectByColorValue(colorSettings, color);
84
84
  if (colorObject) {
85
- classNames.push(getColorClassName('color', colorObject.slug));
85
+ classNames.push(getColorClassName("color", colorObject.slug));
86
86
  } else {
87
- styles.push(['color', color].join(':'));
87
+ styles.push(["color", color].join(":"));
88
88
  }
89
89
  }
90
90
  if (styles.length) {
91
- attributes.style = styles.join(';');
91
+ attributes.style = styles.join(";");
92
92
  }
93
93
  if (classNames.length) {
94
- attributes.class = classNames.join(' ');
94
+ attributes.class = classNames.join(" ");
95
95
  }
96
- return applyFormat(value, {
97
- type: name,
98
- attributes
99
- });
96
+ return applyFormat(value, { type: name, attributes });
100
97
  }
101
- function ColorPicker({
102
- name,
103
- property,
104
- value,
105
- onChange
106
- }) {
107
- const colors = useSelect(select => {
108
- var _getSettings$colors;
109
- const {
110
- getSettings
111
- } = select(blockEditorStore);
112
- return (_getSettings$colors = getSettings().colors) !== null && _getSettings$colors !== void 0 ? _getSettings$colors : [];
98
+ function ColorPicker({ name, property, value, onChange }) {
99
+ const colors = useSelect((select) => {
100
+ const { getSettings } = select(blockEditorStore);
101
+ return getSettings().colors ?? [];
113
102
  }, []);
114
- const activeColors = useMemo(() => getActiveColors(value, name, colors), [name, value, colors]);
115
- return /*#__PURE__*/_jsx(ColorPalette, {
116
- value: activeColors[property],
117
- onChange: color => {
118
- onChange(setColors(value, name, colors, {
119
- [property]: color
120
- }));
121
- },
122
- enableAlpha: true
123
- // Prevent the text and color picker from overlapping.
124
- ,
125
- __experimentalIsRenderedInSidebar: true
126
- });
103
+ const activeColors = useMemo(
104
+ () => getActiveColors(value, name, colors),
105
+ [name, value, colors]
106
+ );
107
+ return /* @__PURE__ */ jsx(
108
+ ColorPalette,
109
+ {
110
+ value: activeColors[property],
111
+ onChange: (color) => {
112
+ onChange(
113
+ setColors(value, name, colors, { [property]: color })
114
+ );
115
+ },
116
+ enableAlpha: true,
117
+ __experimentalIsRenderedInSidebar: true
118
+ }
119
+ );
127
120
  }
128
- export default function InlineColorUI({
121
+ function InlineColorUI({
129
122
  name,
130
123
  value,
131
124
  onChange,
@@ -135,32 +128,40 @@ export default function InlineColorUI({
135
128
  }) {
136
129
  const popoverAnchor = useAnchor({
137
130
  editableContentElement: contentRef.current,
138
- settings: {
139
- ...settings,
140
- isActive
141
- }
142
- });
143
- return /*#__PURE__*/_jsx(Popover, {
144
- onClose: onClose,
145
- className: "format-library__inline-color-popover",
146
- anchor: popoverAnchor,
147
- children: /*#__PURE__*/_jsxs(Tabs, {
148
- children: [/*#__PURE__*/_jsx(Tabs.TabList, {
149
- children: TABS.map(tab => /*#__PURE__*/_jsx(Tabs.Tab, {
150
- tabId: tab.name,
151
- children: tab.title
152
- }, tab.name))
153
- }), TABS.map(tab => /*#__PURE__*/_jsx(Tabs.TabPanel, {
154
- tabId: tab.name,
155
- focusable: false,
156
- children: /*#__PURE__*/_jsx(ColorPicker, {
157
- name: name,
158
- property: tab.name,
159
- value: value,
160
- onChange: onChange
161
- })
162
- }, tab.name))]
163
- })
131
+ settings: { ...settings, isActive }
164
132
  });
133
+ return /* @__PURE__ */ jsx(
134
+ Popover,
135
+ {
136
+ onClose,
137
+ className: "format-library__inline-color-popover",
138
+ anchor: popoverAnchor,
139
+ children: /* @__PURE__ */ jsxs(Tabs, { children: [
140
+ /* @__PURE__ */ jsx(Tabs.TabList, { children: TABS.map((tab) => /* @__PURE__ */ jsx(Tabs.Tab, { tabId: tab.name, children: tab.title }, tab.name)) }),
141
+ TABS.map((tab) => /* @__PURE__ */ jsx(
142
+ Tabs.TabPanel,
143
+ {
144
+ tabId: tab.name,
145
+ focusable: false,
146
+ children: /* @__PURE__ */ jsx(
147
+ ColorPicker,
148
+ {
149
+ name,
150
+ property: tab.name,
151
+ value,
152
+ onChange
153
+ }
154
+ )
155
+ },
156
+ tab.name
157
+ ))
158
+ ] })
159
+ }
160
+ );
165
161
  }
166
- //# sourceMappingURL=inline.js.map
162
+ export {
163
+ InlineColorUI as default,
164
+ getActiveColors,
165
+ parseClassName
166
+ };
167
+ //# sourceMappingURL=inline.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","Popover","privateApis","componentsPrivateApis","__","textColor","settings","transparentValue","unlock","jsx","_jsx","jsxs","_jsxs","Tabs","TABS","name","title","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","activeColors","enableAlpha","__experimentalIsRenderedInSidebar","InlineColorUI","onClose","contentRef","isActive","popoverAnchor","editableContentElement","current","anchor","children","TabList","map","tab","Tab","tabId","TabPanel","focusable"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { 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} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\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' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\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 ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\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 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={ ( 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} }\n\t\t\tenableAlpha\n\t\t\t// Prevent the text and color picker from overlapping.\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</Popover>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAAY,EACZC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SACCC,OAAO,EACPC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,S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;QAClByD,SAAS,EAAG,KAAO;QAAAP,QAAA,eAGnBvD,IAAA,CAACuC,WAAW;UACXlC,IAAI,EAAGA,IAAM;UACbQ,QAAQ,EAAG6C,GAAG,CAACrD,IAAM;UACrBS,KAAK,EAAGA,KAAO;UACf0B,QAAQ,EAAGA;QAAU,CACrB;MAAC,GAPIkB,GAAG,CAACrD,IAQI,CACd,CAAC;IAAA,CACE;EAAC,CACC,CAAC;AAEZ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/text-color/inline.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { 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} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\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' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\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 ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\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 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={ ( 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} }\n\t\t\tenableAlpha\n\t\t\t// Prevent the text and color picker from overlapping.\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ on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