@wordpress/format-library 4.16.0 → 4.17.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 (107) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bold/index.js +1 -10
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +3 -17
  5. package/build/code/index.js.map +1 -1
  6. package/build/default-formats.js +0 -14
  7. package/build/default-formats.js.map +1 -1
  8. package/build/default-formats.native.js +0 -6
  9. package/build/default-formats.native.js.map +1 -1
  10. package/build/image/index.js +5 -14
  11. package/build/image/index.js.map +1 -1
  12. package/build/index.js +1 -3
  13. package/build/index.js.map +1 -1
  14. package/build/italic/index.js +1 -10
  15. package/build/italic/index.js.map +1 -1
  16. package/build/keyboard/index.js +1 -10
  17. package/build/keyboard/index.js.map +1 -1
  18. package/build/language/index.js +1 -11
  19. package/build/language/index.js.map +1 -1
  20. package/build/link/index.js +5 -26
  21. package/build/link/index.js.map +1 -1
  22. package/build/link/index.native.js +14 -39
  23. package/build/link/index.native.js.map +1 -1
  24. package/build/link/inline.js +41 -78
  25. package/build/link/inline.js.map +1 -1
  26. package/build/link/modal-screens/link-picker-screen.native.js +1 -13
  27. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  28. package/build/link/modal-screens/link-settings-screen.native.js +9 -36
  29. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  30. package/build/link/modal-screens/screens.native.js.map +1 -1
  31. package/build/link/modal.native.js +1 -9
  32. package/build/link/modal.native.js.map +1 -1
  33. package/build/link/use-link-instance-key.js +3 -7
  34. package/build/link/use-link-instance-key.js.map +1 -1
  35. package/build/link/utils.js +23 -47
  36. package/build/link/utils.js.map +1 -1
  37. package/build/strikethrough/index.js +1 -9
  38. package/build/strikethrough/index.js.map +1 -1
  39. package/build/subscript/index.js +1 -10
  40. package/build/subscript/index.js.map +1 -1
  41. package/build/superscript/index.js +1 -10
  42. package/build/superscript/index.js.map +1 -1
  43. package/build/text-color/index.js +7 -25
  44. package/build/text-color/index.js.map +1 -1
  45. package/build/text-color/index.native.js +11 -34
  46. package/build/text-color/index.native.js.map +1 -1
  47. package/build/text-color/inline.js +5 -26
  48. package/build/text-color/inline.js.map +1 -1
  49. package/build/text-color/inline.native.js +9 -25
  50. package/build/text-color/inline.native.js.map +1 -1
  51. package/build/underline/index.js +1 -8
  52. package/build/underline/index.js.map +1 -1
  53. package/build/unknown/index.js +1 -11
  54. package/build/unknown/index.js.map +1 -1
  55. package/build-module/bold/index.js +0 -7
  56. package/build-module/bold/index.js.map +1 -1
  57. package/build-module/code/index.js +2 -14
  58. package/build-module/code/index.js.map +1 -1
  59. package/build-module/default-formats.js.map +1 -1
  60. package/build-module/default-formats.native.js.map +1 -1
  61. package/build-module/image/index.js +4 -10
  62. package/build-module/image/index.js.map +1 -1
  63. package/build-module/index.js +1 -1
  64. package/build-module/index.js.map +1 -1
  65. package/build-module/italic/index.js +0 -7
  66. package/build-module/italic/index.js.map +1 -1
  67. package/build-module/keyboard/index.js +0 -7
  68. package/build-module/keyboard/index.js.map +1 -1
  69. package/build-module/language/index.js +1 -8
  70. package/build-module/language/index.js.map +1 -1
  71. package/build-module/link/index.js +5 -17
  72. package/build-module/link/index.js.map +1 -1
  73. package/build-module/link/index.native.js +15 -30
  74. package/build-module/link/index.native.js.map +1 -1
  75. package/build-module/link/inline.js +42 -69
  76. package/build-module/link/inline.js.map +1 -1
  77. package/build-module/link/modal-screens/link-picker-screen.native.js +2 -8
  78. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  79. package/build-module/link/modal-screens/link-settings-screen.native.js +10 -28
  80. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  81. package/build-module/link/modal-screens/screens.native.js.map +1 -1
  82. package/build-module/link/modal.native.js +1 -4
  83. package/build-module/link/modal.native.js.map +1 -1
  84. package/build-module/link/use-link-instance-key.js +3 -7
  85. package/build-module/link/use-link-instance-key.js.map +1 -1
  86. package/build-module/link/utils.js +24 -43
  87. package/build-module/link/utils.js.map +1 -1
  88. package/build-module/strikethrough/index.js +0 -6
  89. package/build-module/strikethrough/index.js.map +1 -1
  90. package/build-module/subscript/index.js +0 -7
  91. package/build-module/subscript/index.js.map +1 -1
  92. package/build-module/superscript/index.js +0 -7
  93. package/build-module/superscript/index.js.map +1 -1
  94. package/build-module/text-color/index.js +7 -20
  95. package/build-module/text-color/index.js.map +1 -1
  96. package/build-module/text-color/index.native.js +12 -24
  97. package/build-module/text-color/index.native.js.map +1 -1
  98. package/build-module/text-color/inline.js +5 -20
  99. package/build-module/text-color/inline.js.map +1 -1
  100. package/build-module/text-color/inline.native.js +9 -21
  101. package/build-module/text-color/inline.native.js.map +1 -1
  102. package/build-module/underline/index.js +0 -6
  103. package/build-module/underline/index.js.map +1 -1
  104. package/build-module/unknown/index.js +0 -8
  105. package/build-module/unknown/index.js.map +1 -1
  106. package/package.json +13 -13
  107. package/src/link/inline.js +11 -34
@@ -1,36 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.textColor = void 0;
9
-
10
8
  var _element = require("@wordpress/element");
11
-
12
9
  var _reactNative = require("react-native");
13
-
14
10
  var _i18n = require("@wordpress/i18n");
15
-
16
11
  var _blockEditor = require("@wordpress/block-editor");
17
-
18
12
  var _components = require("@wordpress/components");
19
-
20
13
  var _icons = require("@wordpress/icons");
21
-
22
14
  var _richText = require("@wordpress/rich-text");
23
-
24
15
  var _compose = require("@wordpress/compose");
25
-
26
16
  var _inline = require("./inline.js");
27
-
28
17
  var _index = require("./index.js");
29
-
30
18
  var _inline2 = _interopRequireDefault(require("./inline"));
31
-
32
19
  var _style = _interopRequireDefault(require("./style.scss"));
33
-
34
20
  /**
35
21
  * External dependencies
36
22
  */
@@ -42,32 +28,28 @@ var _style = _interopRequireDefault(require("./style.scss"));
42
28
  /**
43
29
  * Internal dependencies
44
30
  */
31
+
45
32
  const name = 'core/text-color';
46
33
  const title = (0, _i18n.__)('Text color');
47
-
48
34
  function getComputedStyleProperty(element, property) {
49
35
  const {
50
36
  props: {
51
37
  style = {}
52
38
  }
53
39
  } = element;
54
-
55
40
  if (property === 'background-color') {
56
41
  const {
57
42
  backgroundColor,
58
43
  baseColors
59
44
  } = style;
60
-
61
45
  if (backgroundColor !== 'transparent') {
62
46
  return backgroundColor;
63
47
  } else if (baseColors && baseColors?.color?.background) {
64
48
  return baseColors?.color?.background;
65
49
  }
66
-
67
50
  return 'transparent';
68
51
  }
69
52
  }
70
-
71
53
  function fillComputedColors(element, {
72
54
  color,
73
55
  backgroundColor
@@ -75,13 +57,11 @@ function fillComputedColors(element, {
75
57
  if (!color && !backgroundColor) {
76
58
  return;
77
59
  }
78
-
79
60
  return {
80
61
  color: color || getComputedStyleProperty(element, 'color'),
81
62
  backgroundColor: getComputedStyleProperty(element, 'background-color')
82
63
  };
83
64
  }
84
-
85
65
  function TextColorEdit({
86
66
  value,
87
67
  onChange,
@@ -106,12 +86,11 @@ function TextColorEdit({
106
86
  const outlineStyle = [(0, _compose.usePreferredColorSchemeStyle)(_style.default['components-inline-color__outline'], _style.default['components-inline-color__outline--dark']), {
107
87
  borderWidth: _reactNative.StyleSheet.hairlineWidth
108
88
  }];
109
-
110
89
  if (!hasColorsToChoose && !isActive) {
111
90
  return null;
112
91
  }
113
-
114
- const isActiveStyle = { ...colorIndicatorStyle,
92
+ const isActiveStyle = {
93
+ ...colorIndicatorStyle,
115
94
  ...(!colorIndicatorStyle?.backgroundColor ? {
116
95
  backgroundColor: 'transparent'
117
96
  } : {}),
@@ -134,7 +113,8 @@ function TextColorEdit({
134
113
  extraProps: {
135
114
  isActiveStyle,
136
115
  customContainerStyles
137
- } // If has no colors to choose but a color is active remove the color onClick
116
+ }
117
+ // If has no colors to choose but a color is active remove the color onClick
138
118
  ,
139
119
  onClick: onPressButton
140
120
  }))), isAddingColor && (0, _element.createElement)(_inline2.default, {
@@ -146,7 +126,6 @@ function TextColorEdit({
146
126
  contentRef: contentRef
147
127
  }));
148
128
  }
149
-
150
129
  const textColor = {
151
130
  name,
152
131
  title,
@@ -156,7 +135,6 @@ const textColor = {
156
135
  style: 'style',
157
136
  class: 'class'
158
137
  },
159
-
160
138
  /*
161
139
  * Since this format relies on the <mark> tag, it's important to
162
140
  * prevent the default yellow background color applied by most
@@ -167,17 +145,16 @@ const textColor = {
167
145
  * @see https://github.com/WordPress/gutenberg/pull/35516
168
146
  */
169
147
  __unstableFilterAttributeValue(key, value) {
170
- if (key !== 'style') return value; // We need to remove the extra spaces within the styles on mobile
171
-
172
- const newValue = value?.replace(/ /g, ''); // We should not add a background-color if it's already set
173
-
148
+ if (key !== 'style') return value;
149
+ // We need to remove the extra spaces within the styles on mobile
150
+ const newValue = value?.replace(/ /g, '');
151
+ // We should not add a background-color if it's already set
174
152
  if (newValue && newValue.includes('background-color')) return newValue;
175
- const addedCSS = ['background-color', _index.transparentValue].join(':'); // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
153
+ const addedCSS = ['background-color', _index.transparentValue].join(':');
154
+ // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
176
155
  // rules will already include a `;`.
177
-
178
156
  return newValue ? [addedCSS, newValue].join(';') : addedCSS;
179
157
  },
180
-
181
158
  edit: TextColorEdit
182
159
  };
183
160
  exports.textColor = textColor;
@@ -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","borderWidth","StyleSheet","hairlineWidth","isActiveStyle","customContainerStyles","Object","keys","textColorIcon","colorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","newValue","replace","includes","addedCSS","transparentValue","join","edit"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;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;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,UAAU,EAAEC,KAAZ,EAAmBC,UAAtC,EAAmD;AACzD,aAAOF,UAAU,EAAEC,KAAZ,EAAmBC,UAA1B;AACA;;AAED,WAAO,aAAP;AACA;AACD;;AAED,SAASC,kBAAT,CAA6BR,OAA7B,EAAsC;AAAEM,EAAAA,KAAF;AAASF,EAAAA;AAAT,CAAtC,EAAmE;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,CAAwB;AACvBC,EAAAA,KADuB;AAEvBC,EAAAA,QAFuB;AAGvBC,EAAAA,QAHuB;AAIvBC,EAAAA,gBAJuB;AAKvBC,EAA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K,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAOhC,KAAP,EAAe;AAC5C,QAAKgC,GAAG,KAAK,OAAb,EAAuB,OAAOhC,KAAP,CADqB,CAE5C;;AACA,UAAMiC,QAAQ,GAAGjC,KAAK,EAAEkC,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,EAAExC;AA9BkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { StyleSheet, 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 {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} 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 = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-inline-color__outline' ],\n\t\t\tstyles[ 'components-inline-color__outline--dark' ]\n\t\t),\n\t\t{ borderWidth: StyleSheet.hairlineWidth },\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={\n\t\t\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t\t\t}\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,"names":["_element","require","_reactNative","_i18n","_blockEditor","_components","_icons","_richText","_compose","_inline","_index","_inline2","_interopRequireDefault","_style","name","title","__","getComputedStyleProperty","element","property","props","style","backgroundColor","baseColors","color","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","useSetting","colors","useMobileGlobalStylesColors","isAddingColor","setIsAddingColor","useState","enableIsAddingColor","useCallback","disableIsAddingColor","colorIndicatorStyle","useMemo","getActiveColors","hasColorsToChoose","length","onPressButton","removeFormat","outlineStyle","usePreferredColorSchemeStyle","styles","borderWidth","StyleSheet","hairlineWidth","isActiveStyle","customContainerStyles","createElement","Fragment","BlockControls","ToolbarGroup","View","pointerEvents","ToolbarButton","icon","Icon","Object","keys","textColorIcon","colorIcon","extraProps","onClick","default","onClose","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","newValue","replace","includes","addedCSS","transparentValue","join","edit","exports"],"sources":["@wordpress/format-library/src/text-color/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { StyleSheet, 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 {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} 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 = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-inline-color__outline' ],\n\t\t\tstyles[ 'components-inline-color__outline--dark' ]\n\t\t),\n\t\t{ borderWidth: StyleSheet.hairlineWidth },\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={\n\t\t\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t\t\t}\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"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,MAAA,GAAAD,sBAAA,CAAAX,OAAA;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAMA,MAAMa,IAAI,GAAG,iBAAiB;AAC9B,MAAMC,KAAK,GAAG,IAAAC,QAAE,EAAE,YAAa,CAAC;AAEhC,SAASC,wBAAwBA,CAAEC,OAAO,EAAEC,QAAQ,EAAG;EACtD,MAAM;IACLC,KAAK,EAAE;MAAEC,KAAK,GAAG,CAAC;IAAE;EACrB,CAAC,GAAGH,OAAO;EAEX,IAAKC,QAAQ,KAAK,kBAAkB,EAAG;IACtC,MAAM;MAAEG,eAAe;MAAEC;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kBAAmB,CAAC,EACvD,OAAOF,QAAQ;IAChB,MAAMG,QAAQ,GAAG,CAAE,kBAAkB,EAAEC,uBAAgB,CAAE,CAACC,IAAI,CAAE,GAAI,CAAC;IACrE;IACA;IACA,OAAOL,QAAQ,GAAG,CAAEG,QAAQ,EAAEH,QAAQ,CAAE,CAACK,IAAI,CAAE,GAAI,CAAC,GAAGF,QAAQ;EAChE,CAAC;EACDG,IAAI,EAAE7D;AACP,CAAC;AAAC8D,OAAA,CAAAd,SAAA,GAAAA,SAAA"}
@@ -6,21 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = InlineColorUI;
7
7
  exports.getActiveColors = getActiveColors;
8
8
  exports.parseClassName = parseClassName;
9
-
10
9
  var _element = require("@wordpress/element");
11
-
12
10
  var _data = require("@wordpress/data");
13
-
14
11
  var _richText = require("@wordpress/rich-text");
15
-
16
12
  var _blockEditor = require("@wordpress/block-editor");
17
-
18
13
  var _components = require("@wordpress/components");
19
-
20
14
  var _i18n = require("@wordpress/i18n");
21
-
22
15
  var _index = require("./index");
23
-
24
16
  /**
25
17
  * WordPress dependencies
26
18
  */
@@ -28,6 +20,7 @@ var _index = require("./index");
28
20
  /**
29
21
  * Internal dependencies
30
22
  */
23
+
31
24
  function parseCSS(css = '') {
32
25
  return css.split(';').reduce((accumulator, rule) => {
33
26
  if (rule) {
@@ -35,11 +28,9 @@ function parseCSS(css = '') {
35
28
  if (property === 'color') accumulator.color = value;
36
29
  if (property === 'background-color' && value !== _index.transparentValue) accumulator.backgroundColor = value;
37
30
  }
38
-
39
31
  return accumulator;
40
32
  }, {});
41
33
  }
42
-
43
34
  function parseClassName(className = '', colorSettings) {
44
35
  return className.split(' ').reduce((accumulator, name) => {
45
36
  // `colorSlug` could contain dashes, so simply match the start and end.
@@ -48,56 +39,47 @@ function parseClassName(className = '', colorSettings) {
48
39
  const colorObject = (0, _blockEditor.getColorObjectByAttributeValues)(colorSettings, colorSlug);
49
40
  accumulator.color = colorObject.color;
50
41
  }
51
-
52
42
  return accumulator;
53
43
  }, {});
54
44
  }
55
-
56
45
  function getActiveColors(value, name, colorSettings) {
57
46
  const activeColorFormat = (0, _richText.getActiveFormat)(value, name);
58
-
59
47
  if (!activeColorFormat) {
60
48
  return {};
61
49
  }
62
-
63
- return { ...parseCSS(activeColorFormat.attributes.style),
50
+ return {
51
+ ...parseCSS(activeColorFormat.attributes.style),
64
52
  ...parseClassName(activeColorFormat.attributes.class, colorSettings)
65
53
  };
66
54
  }
67
-
68
55
  function setColors(value, name, colorSettings, colors) {
69
56
  const {
70
57
  color,
71
58
  backgroundColor
72
- } = { ...getActiveColors(value, name, colorSettings),
59
+ } = {
60
+ ...getActiveColors(value, name, colorSettings),
73
61
  ...colors
74
62
  };
75
-
76
63
  if (!color && !backgroundColor) {
77
64
  return (0, _richText.removeFormat)(value, name);
78
65
  }
79
-
80
66
  const styles = [];
81
67
  const classNames = [];
82
68
  const attributes = {};
83
-
84
69
  if (backgroundColor) {
85
70
  styles.push(['background-color', backgroundColor].join(':'));
86
71
  } else {
87
72
  // Override default browser color for mark element.
88
73
  styles.push(['background-color', _index.transparentValue].join(':'));
89
74
  }
90
-
91
75
  if (color) {
92
76
  const colorObject = (0, _blockEditor.getColorObjectByColorValue)(colorSettings, color);
93
-
94
77
  if (colorObject) {
95
78
  classNames.push((0, _blockEditor.getColorClassName)('color', colorObject.slug));
96
79
  } else {
97
80
  styles.push(['color', color].join(':'));
98
81
  }
99
82
  }
100
-
101
83
  if (styles.length) attributes.style = styles.join(';');
102
84
  if (classNames.length) attributes.class = classNames.join(' ');
103
85
  return (0, _richText.applyFormat)(value, {
@@ -105,7 +87,6 @@ function setColors(value, name, colorSettings, colors) {
105
87
  attributes
106
88
  });
107
89
  }
108
-
109
90
  function ColorPicker({
110
91
  name,
111
92
  property,
@@ -114,7 +95,6 @@ function ColorPicker({
114
95
  }) {
115
96
  const colors = (0, _data.useSelect)(select => {
116
97
  var _getSettings$colors;
117
-
118
98
  const {
119
99
  getSettings
120
100
  } = select(_blockEditor.store);
@@ -131,7 +111,6 @@ function ColorPicker({
131
111
  onChange: onColorChange
132
112
  });
133
113
  }
134
-
135
114
  function InlineColorUI({
136
115
  name,
137
116
  value,
@@ -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,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,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,CAAyBC,SAAS,GAAG,EAArC,EAAyCC,aAAzC,EAAyD;AAC/D,SAAOD,SAAS,CAACV,KAAV,CAAiB,GAAjB,EAAuBC,MAAvB,CAA+B,CAAEC,WAAF,EAAeU,IAAf,KAAyB;AAC9D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AAD;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"]}
1
+ {"version":3,"names":["_element","require","_data","_richText","_blockEditor","_components","_i18n","_index","parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getColorObjectByAttributeValues","getActiveColors","activeColorFormat","getActiveFormat","attributes","style","class","setColors","colors","removeFormat","styles","classNames","push","join","getColorObjectByColorValue","getColorClassName","slug","length","applyFormat","type","ColorPicker","onChange","useSelect","select","_getSettings$colors","getSettings","blockEditorStore","onColorChange","useCallback","activeColors","useMemo","createElement","ColorPalette","InlineColorUI","onClose","contentRef","popoverAnchor","useCachedTruthy","useAnchor","editableContentElement","current","settings","Popover","anchor","TabPanel","tabs","title","__","tab"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"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"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAzBA;AACA;AACA;;AAoBA;AACA;AACA;;AAGA,SAASO,QAAQA,CAAEC,GAAG,GAAG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IAClCmC,QAAQ,EAAGM;EAAe,CAC1B,CAAC;AAEJ;AAEe,SAASM,aAAaA,CAAE;EACtCvC,IAAI;EACJP,KAAK;EACLkC,QAAQ;EACRa,OAAO;EACPC;AACD,CAAC,EAAG;EACH;AACD;AACA;AACA;AACA;AACA;AACA;EACC,MAAMC,aAAa,GAAG,IAAAC,4BAAe,EACpC,IAAAC,mBAAS,EAAE;IACVC,sBAAsB,EAAEJ,UAAU,CAACK,OAAO;IAC1CC,QAAQ,EAARA;EACD,CAAE,CACH,CAAC;EAED,OACC,IAAArE,QAAA,CAAA2D,aAAA,EAACtD,WAAA,CAAAiE,OAAO;IACPR,OAAO,EAAGA,OAAS;IACnB1C,SAAS,EAAC,iCAAiC;IAC3CmD,MAAM,EAAGP;EAAe,GAExB,IAAAhE,QAAA,CAAA2D,aAAA,EAACtD,WAAA,CAAAmE,QAAQ;IACRC,IAAI,EAAG,CACN;MACCnD,IAAI,EAAE,OAAO;MACboD,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO;IACnB,CAAC,EACD;MACCrD,IAAI,EAAE,iBAAiB;MACvBoD,KAAK,EAAE,IAAAC,QAAE,EAAE,YAAa;IACzB,CAAC;EACC,GAECC,GAAG,IACN,IAAA5E,QAAA,CAAA2D,aAAA,EAACX,WAAW;IACX1B,IAAI,EAAGA,IAAM;IACbR,QAAQ,EAAG8D,GAAG,CAACtD,IAAM;IACrBP,KAAK,EAAGA,KAAO;IACfkC,QAAQ,EAAGA;EAAU,CACrB,CAEO,CACF,CAAC;AAEZ"}
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = InlineColorUI;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _richText = require("@wordpress/rich-text");
11
-
12
9
  var _blockEditor = require("@wordpress/block-editor");
13
-
14
10
  var _components = require("@wordpress/components");
15
-
16
11
  var _index = require("./index.js");
17
-
18
12
  var _inline = require("./inline.js");
19
-
20
13
  /**
21
14
  * WordPress dependencies
22
15
  */
@@ -24,6 +17,7 @@ var _inline = require("./inline.js");
24
17
  /**
25
18
  * Internal dependencies
26
19
  */
20
+
27
21
  function parseCSS(css = '') {
28
22
  return css.split(';').reduce((accumulator, rule) => {
29
23
  if (rule) {
@@ -31,49 +25,41 @@ function parseCSS(css = '') {
31
25
  if (property === 'color') accumulator.color = value;
32
26
  if (property === 'background-color' && value !== _index.transparentValue) accumulator.backgroundColor = value;
33
27
  }
34
-
35
28
  return accumulator;
36
29
  }, {});
37
30
  }
38
-
39
31
  function getActiveColors(value, name, colorSettings) {
40
32
  const activeColorFormat = (0, _richText.getActiveFormat)(value, name);
41
-
42
33
  if (!activeColorFormat) {
43
34
  return {};
44
35
  }
45
-
46
- return { ...parseCSS(activeColorFormat.attributes.style),
36
+ return {
37
+ ...parseCSS(activeColorFormat.attributes.style),
47
38
  ...(0, _inline.parseClassName)(activeColorFormat.attributes.class, colorSettings)
48
39
  };
49
40
  }
50
-
51
41
  function setColors(value, name, colorSettings, colors) {
52
42
  const {
53
43
  color,
54
44
  backgroundColor
55
- } = { ...getActiveColors(value, name, colorSettings),
45
+ } = {
46
+ ...getActiveColors(value, name, colorSettings),
56
47
  ...colors
57
48
  };
58
-
59
49
  if (!color && !backgroundColor) {
60
50
  return (0, _richText.removeFormat)(value, name);
61
51
  }
62
-
63
52
  const styles = [];
64
53
  const classNames = [];
65
54
  const attributes = {};
66
-
67
55
  if (backgroundColor) {
68
56
  styles.push(['background-color', backgroundColor].join(':'));
69
57
  } else {
70
58
  // Override default browser color for mark element.
71
59
  styles.push(['background-color', _index.transparentValue].join(':'));
72
60
  }
73
-
74
61
  if (color) {
75
62
  const colorObject = (0, _blockEditor.getColorObjectByColorValue)(colorSettings, color);
76
-
77
63
  if (colorObject) {
78
64
  classNames.push((0, _blockEditor.getColorClassName)('color', colorObject.slug));
79
65
  styles.push(['color', colorObject.color].join(':'));
@@ -81,7 +67,6 @@ function setColors(value, name, colorSettings, colors) {
81
67
  styles.push(['color', color].join(':'));
82
68
  }
83
69
  }
84
-
85
70
  if (styles.length) attributes.style = styles.join(';');
86
71
  if (classNames.length) attributes.class = classNames.join(' ');
87
72
  const format = {
@@ -90,8 +75,9 @@ function setColors(value, name, colorSettings, colors) {
90
75
  };
91
76
  const hasNoSelection = value.start === value.end;
92
77
  const isAtTheEnd = value.end === value.text.length;
93
- const previousCharacter = value.text.charAt(value.end - 1); // Force formatting due to limitations in the native implementation
78
+ const previousCharacter = value.text.charAt(value.end - 1);
94
79
 
80
+ // Force formatting due to limitations in the native implementation
95
81
  if (hasNoSelection && (value.text.length === 0 || previousCharacter === ' ' && isAtTheEnd)) {
96
82
  // For cases where there's no text selected, there's a space before
97
83
  // the current caret position and it's at the end of the text.
@@ -110,10 +96,8 @@ function setColors(value, name, colorSettings, colors) {
110
96
  } else if (hasNoSelection) {
111
97
  return (0, _richText.removeFormat)(value, format);
112
98
  }
113
-
114
99
  return (0, _richText.applyFormat)(value, format);
115
100
  }
116
-
117
101
  function ColorPicker({
118
102
  name,
119
103
  value,
@@ -126,7 +110,8 @@ function ColorPicker({
126
110
  if (color !== '') {
127
111
  onChange(setColors(value, name, colors, {
128
112
  [property]: color
129
- })); // Remove formatting if the color was reset, there's no
113
+ }));
114
+ // Remove formatting if the color was reset, there's no
130
115
  // current selection and the previous character is a space
131
116
  } else if (value?.start === value?.end && value.text?.charAt(value?.end - 1) === ' ') {
132
117
  onChange((0, _richText.removeFormat)(value, name, value.end - 1, value.end));
@@ -142,7 +127,6 @@ function ColorPicker({
142
127
  hideNavigation: true
143
128
  });
144
129
  }
145
-
146
130
  function InlineColorUI({
147
131
  name,
148
132
  value,
@@ -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,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,QAAQ,KAAK,kBAAb,IAAmCC,KAAK,KAAKG,uBAAlD,EACCN,WAAW,CAACO,eAAZ,GAA8BJ,KAA9B;AACD;;AACD,WAAOH,WAAP;AACA,GARM,EAQJ,EARI,CAAP;AASA;;AAED,SAASQ,eAAT,CAA0BL,KAA1B,EAAiCM,IAAjC,EAAuCC,aAAvC,EAAuD;AACtD,QAAMC,iBAAiB,GAAG,+BAAiBR,KAAjB,EAAwBM,IAAxB,CAA1B;;AAEA,MAAK,CAAEE,iBAAP,EAA2B;AAC1B,WAAO,EAAP;AACA;;AAED,SAAO,EACN,GAAGf,QAAQ,CAAEe,iBAAiB,CAACC,UAAlB,CAA6BC,KAA/B,CADL;AAEN,OAAG,4BAAgBF,iBAAiB,CAACC,UAAlB,CAA6BE,KAA7C,EAAoDJ,aAApD;AAFG,GAAP;AAIA;;AAED,SAASK,SAAT,CAAoBZ,KAApB,EAA2BM,IAA3B,EAAiCC,aAAjC,EAAgDM,MAAhD,EAAyD;AACxD,QAAM;AAAEX,IA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A,cAAc;AAJf,IADD;AAQA;;AAEc,SAAS+B,aAAT,CAAwB;AAAEhC,EAAAA,IAAF;AAAQN,EAAAA,KAAR;AAAemC,EAAAA,QAAf;AAAyBI,EAAAA;AAAzB,CAAxB,EAA6D;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,"names":["_element","require","_richText","_blockEditor","_components","_index","_inline","parseCSS","css","split","reduce","accumulator","rule","property","value","replace","color","transparentValue","backgroundColor","getActiveColors","name","colorSettings","activeColorFormat","getActiveFormat","attributes","style","parseClassName","class","setColors","colors","removeFormat","styles","classNames","push","join","colorObject","getColorObjectByColorValue","getColorClassName","slug","length","format","type","hasNoSelection","start","end","isAtTheEnd","text","previousCharacter","charAt","applyFormat","newFormat","activeFormats","formats","filter","ColorPicker","onChange","useMobileGlobalStylesColors","useMultipleOriginColorsAndGradients","onColorChange","useCallback","activeColors","useMemo","createElement","ColorSettings","colorValue","defaultSettings","hideNavigation","InlineColorUI","onClose","BottomSheet","isVisible","hideHeader","contentStyle","paddingLeft","paddingRight","hasNavigation","leftButton","testID","NavigationContainer","animate","main","NavigationScreen"],"sources":["@wordpress/format-library/src/text-color/inline.native.js"],"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"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AASA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAxBA;AACA;AACA;;AAkBA;AACA;AACA;;AAIA,SAASM,QAAQA,CAAEC,GAAG,GAAG,EAAE,EAAG;EAC7B,OAAOA,GAAG,CAACC,KAAK,CAAE,GAAI,CAAC,CAACC,MAAM,CAAE,CAAEC,WAAW,EAAEC,IAAI,KAAM;IACxD,IAAKA,IAAI,EAAG;MACX,MAAM,CAAEC,QAAQ,EAAEC,KAAK,CAAE,GAAGF,IAAI,CAACG,OAAO,CAAE,IAAI,EAAE,EAAG,CAAC,CAACN,KA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D,aAAA,EAAC1D,WAAA,CAAAiE,WAAW,CAACS,mBAAmB;IAACC,OAAO;IAACC,IAAI;EAAA,GAC5C,IAAAhF,QAAA,CAAA8D,aAAA,EAAC1D,WAAA,CAAAiE,WAAW,CAACY,gBAAgB;IAAC7D,IAAI,EAAC;EAAY,GAC9C,IAAApB,QAAA,CAAA8D,aAAA,EAACR,WAAW;IACXlC,IAAI,EAAGA,IAAM;IACbN,KAAK,EAAGA,KAAO;IACfyC,QAAQ,EAAGA;EAAU,CACrB,CAC4B,CACE,CACrB,CAAC;AAEhB"}
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.underline = void 0;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _i18n = require("@wordpress/i18n");
11
-
12
9
  var _richText = require("@wordpress/rich-text");
13
-
14
10
  var _blockEditor = require("@wordpress/block-editor");
15
-
16
11
  /**
17
12
  * WordPress dependencies
18
13
  */
14
+
19
15
  const name = 'core/underline';
20
16
  const title = (0, _i18n.__)('Underline');
21
17
  const underline = {
@@ -26,7 +22,6 @@ const underline = {
26
22
  attributes: {
27
23
  style: 'style'
28
24
  },
29
-
30
25
  edit({
31
26
  value,
32
27
  onChange
@@ -40,7 +35,6 @@ const underline = {
40
35
  title
41
36
  }));
42
37
  };
43
-
44
38
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.RichTextShortcut, {
45
39
  type: "primary",
46
40
  character: "u",
@@ -50,7 +44,6 @@ const underline = {
50
44
  onInput: onToggle
51
45
  }));
52
46
  }
53
-
54
47
  };
55
48
  exports.underline = underline;
56
49
  //# sourceMappingURL=index.js.map
@@ -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,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"]}
1
+ {"version":3,"names":["_i18n","require","_richText","_blockEditor","name","title","__","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","toggleFormat","type","_element","createElement","Fragment","RichTextShortcut","character","onUse","__unstableRichTextInputEvent","inputType","onInput","exports"],"sources":["@wordpress/format-library/src/underline/index.js"],"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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