@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,126 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { StyleSheet, View } from 'react-native';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { __ } from '@wordpress/i18n';
10
- import { useMemo, useState } from '@wordpress/element';
11
- import { BlockControls, useSettings, useMobileGlobalStylesColors } from '@wordpress/block-editor';
12
- import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
13
- import { Icon, color as colorIcon, textColor as textColorIcon } from '@wordpress/icons';
14
- import { removeFormat } from '@wordpress/rich-text';
15
- import { usePreferredColorSchemeStyle } from '@wordpress/compose';
16
-
17
- /**
18
- * Internal dependencies
19
- */
20
- import { getActiveColors } from './inline.native.js';
21
- import { default as InlineColorUI } from './inline';
22
- import styles from './style.scss';
23
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
24
- const name = 'core/text-color';
25
- const title = __('Text color');
26
- function getComputedStyleProperty(element, property) {
27
- var _element$props$style;
28
- const style = (_element$props$style = element?.props?.style) !== null && _element$props$style !== void 0 ? _element$props$style : {};
29
- if (property === 'background-color') {
30
- const {
31
- backgroundColor,
32
- baseColors
33
- } = style;
34
- if (backgroundColor !== 'transparent') {
35
- return backgroundColor;
36
- } else if (baseColors && baseColors?.color?.background) {
37
- return baseColors?.color?.background;
38
- }
39
- return 'transparent';
40
- }
41
- }
42
- function fillComputedColors(element, {
43
- color,
44
- backgroundColor
45
- }) {
46
- if (!color && !backgroundColor) {
47
- return;
48
- }
49
- return {
50
- color: color || getComputedStyleProperty(element, 'color'),
51
- backgroundColor: getComputedStyleProperty(element, 'background-color')
52
- };
53
- }
54
- function TextColorEdit({
55
- value,
56
- onChange,
57
- isActive,
58
- activeAttributes,
59
- contentRef
60
- }) {
61
- const [allowCustomControl] = useSettings('color.custom');
62
- const colors = useMobileGlobalStylesColors();
63
- const [isAddingColor, setIsAddingColor] = useState(false);
64
- const colorIndicatorStyle = useMemo(() => fillComputedColors(contentRef, getActiveColors(value, name, colors)), [contentRef, value, colors]);
65
- const hasColorsToChoose = colors.length || !allowCustomControl;
66
- const outlineStyle = [usePreferredColorSchemeStyle(styles['components-inline-color__outline'], styles['components-inline-color__outline--dark']), {
67
- borderWidth: StyleSheet.hairlineWidth
68
- }];
69
- if (!hasColorsToChoose && !isActive) {
70
- return null;
71
- }
72
- const isActiveStyle = {
73
- ...colorIndicatorStyle,
74
- ...(!colorIndicatorStyle?.backgroundColor ? {
75
- backgroundColor: 'transparent'
76
- } : {}),
77
- ...styles['components-inline-color--is-active']
78
- };
79
- const customContainerStyles = styles['components-inline-color__button-container'];
80
- return /*#__PURE__*/_jsxs(_Fragment, {
81
- children: [/*#__PURE__*/_jsx(BlockControls, {
82
- children: /*#__PURE__*/_jsxs(ToolbarGroup, {
83
- children: [isActive && /*#__PURE__*/_jsx(View, {
84
- style: outlineStyle,
85
- pointerEvents: "none"
86
- }), /*#__PURE__*/_jsx(ToolbarButton, {
87
- name: "text-color",
88
- isActive: isActive,
89
- icon: /*#__PURE__*/_jsx(Icon, {
90
- icon: Object.keys(activeAttributes).length ? textColorIcon : colorIcon,
91
- style: colorIndicatorStyle?.color && {
92
- color: colorIndicatorStyle.color
93
- }
94
- }),
95
- title: title,
96
- extraProps: {
97
- isActiveStyle,
98
- customContainerStyles
99
- }
100
- // If has no colors to choose but a color is active remove the color onClick
101
- ,
102
- onClick: hasColorsToChoose ? () => setIsAddingColor(true) : () => onChange(removeFormat(value, name))
103
- })]
104
- })
105
- }), isAddingColor && /*#__PURE__*/_jsx(InlineColorUI, {
106
- name: name,
107
- onClose: () => setIsAddingColor(false),
108
- activeAttributes: activeAttributes,
109
- value: value,
110
- onChange: onChange,
111
- contentRef: contentRef
112
- })]
113
- });
114
- }
115
- export const textColor = {
116
- name,
117
- title,
118
- tagName: 'mark',
119
- className: 'has-inline-color',
120
- attributes: {
121
- style: 'style',
122
- class: 'class'
123
- },
124
- edit: TextColorEdit
125
- };
126
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["StyleSheet","View","__","useMemo","useState","BlockControls","useSettings","useMobileGlobalStylesColors","ToolbarGroup","ToolbarButton","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","usePreferredColorSchemeStyle","getActiveColors","default","InlineColorUI","styles","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","name","title","getComputedStyleProperty","element","property","_element$props$style","style","props","backgroundColor","baseColors","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","colorIndicatorStyle","hasColorsToChoose","length","outlineStyle","borderWidth","hairlineWidth","isActiveStyle","customContainerStyles","children","pointerEvents","icon","Object","keys","extraProps","onClick","onClose","tagName","className","attributes","class","edit"],"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 { useMemo, useState } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } 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.native.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 style = element?.props?.style ?? {};\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 ] = useSettings( 'color.custom' );\n\tconst colors = useMobileGlobalStylesColors();\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\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[ contentRef, value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\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={\n\t\t\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t\t\t? () => setIsAddingColor( true )\n\t\t\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t\t\t}\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={ () => 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/>\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: {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fC,QAAQ,EAAGA,QAAU;MACrBG,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACA,CAAC;AAEL;AAEA,OAAO,MAAM/B,SAAS,GAAG;EACxBc,IAAI;EACJC,KAAK;EACLqC,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,kBAAkB;EAC7BC,UAAU,EAAE;IACXlC,KAAK,EAAE,OAAO;IACdmC,KAAK,EAAE;EACR,CAAC;EACDC,IAAI,EAAE9B;AACP,CAAC","ignoreList":[]}
@@ -1,142 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useCallback, useMemo } from '@wordpress/element';
5
- import { applyFormat, removeFormat, getActiveFormat } from '@wordpress/rich-text';
6
- import { getColorClassName, getColorObjectByColorValue, useMultipleOriginColorsAndGradients, useMobileGlobalStylesColors } from '@wordpress/block-editor';
7
- import { BottomSheet, ColorSettings } from '@wordpress/components';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
- import { transparentValue } from './index.js';
13
- import { parseClassName } from './inline.js';
14
- import { jsx as _jsx } from "react/jsx-runtime";
15
- function parseCSS(css = '') {
16
- return css.split(';').reduce((accumulator, rule) => {
17
- if (rule) {
18
- const [property, value] = rule.replace(/ /g, '').split(':');
19
- if (property === 'color') {
20
- accumulator.color = value;
21
- }
22
- if (property === 'background-color' && value !== transparentValue) {
23
- accumulator.backgroundColor = value;
24
- }
25
- }
26
- return accumulator;
27
- }, {});
28
- }
29
- export function getActiveColors(value, name, colorSettings) {
30
- const activeColorFormat = getActiveFormat(value, name);
31
- if (!activeColorFormat) {
32
- return {};
33
- }
34
- return {
35
- ...parseCSS(activeColorFormat.attributes.style),
36
- ...parseClassName(activeColorFormat.attributes.class, colorSettings)
37
- };
38
- }
39
- function setColors(value, name, colorSettings, colors, contentRef) {
40
- const {
41
- color,
42
- backgroundColor
43
- } = {
44
- ...getActiveColors(value, name, colorSettings),
45
- ...colors
46
- };
47
- if (!color) {
48
- contentRef?.onRemoveMarkFormatting();
49
- return removeFormat(value, name);
50
- }
51
- const styles = [];
52
- const classNames = [];
53
- const attributes = {};
54
- if (backgroundColor) {
55
- styles.push(['background-color', backgroundColor].join(':'));
56
- } else {
57
- // Override default browser color for mark element.
58
- styles.push(['background-color', transparentValue].join(':'));
59
- }
60
- if (color) {
61
- const colorObject = getColorObjectByColorValue(colorSettings, color);
62
- if (colorObject) {
63
- classNames.push(getColorClassName('color', colorObject.slug));
64
- styles.push(['color', colorObject.color].join(':'));
65
- } else {
66
- styles.push(['color', color].join(':'));
67
- }
68
- }
69
- if (styles.length) {
70
- attributes.style = styles.join(';');
71
- }
72
- if (classNames.length) {
73
- attributes.class = classNames.join(' ');
74
- }
75
- const format = {
76
- type: name,
77
- attributes
78
- };
79
- const hasNoSelection = value.start === value.end;
80
- if (hasNoSelection) {
81
- contentRef?.onMarkFormatting(color);
82
- }
83
- return applyFormat(value, format);
84
- }
85
- function ColorPicker({
86
- name,
87
- value,
88
- onChange,
89
- contentRef
90
- }) {
91
- const property = 'color';
92
- const colors = useMobileGlobalStylesColors();
93
- const colorSettings = useMultipleOriginColorsAndGradients();
94
- colorSettings.allAvailableColors = colors;
95
- const onColorChange = useCallback(color => {
96
- onChange(setColors(value, name, colors, {
97
- [property]: color
98
- }, contentRef));
99
- }, [colors, contentRef, name, onChange, value]);
100
- const activeColors = useMemo(() => getActiveColors(value, name, colors), [name, value, colors]);
101
- return /*#__PURE__*/_jsx(ColorSettings, {
102
- colorValue: activeColors[property],
103
- onColorChange: onColorChange,
104
- onColorCleared: onColorChange,
105
- defaultSettings: colorSettings,
106
- hideNavigation: true
107
- });
108
- }
109
- export default function InlineColorUI({
110
- name,
111
- value,
112
- onChange,
113
- onClose,
114
- contentRef
115
- }) {
116
- return /*#__PURE__*/_jsx(BottomSheet, {
117
- isVisible: true,
118
- onClose: onClose,
119
- hideHeader: true,
120
- contentStyle: {
121
- paddingLeft: 0,
122
- paddingRight: 0
123
- },
124
- hasNavigation: true,
125
- leftButton: null,
126
- testID: "inline-text-color-modal",
127
- children: /*#__PURE__*/_jsx(BottomSheet.NavigationContainer, {
128
- animate: true,
129
- main: true,
130
- children: /*#__PURE__*/_jsx(BottomSheet.NavigationScreen, {
131
- name: "text-color",
132
- children: /*#__PURE__*/_jsx(ColorPicker, {
133
- name: name,
134
- value: value,
135
- onChange: onChange,
136
- contentRef: contentRef
137
- })
138
- })
139
- })
140
- });
141
- }
142
- //# sourceMappingURL=inline.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useCallback","useMemo","applyFormat","removeFormat","getActiveFormat","getColorClassName","getColorObjectByColorValue","useMultipleOriginColorsAndGradients","useMobileGlobalStylesColors","BottomSheet","ColorSettings","transparentValue","parseClassName","jsx","_jsx","parseCSS","css","split","reduce","accumulator","rule","property","value","replace","color","backgroundColor","getActiveColors","name","colorSettings","activeColorFormat","attributes","style","class","setColors","colors","contentRef","onRemoveMarkFormatting","styles","classNames","push","join","colorObject","slug","length","format","type","hasNoSelection","start","end","onMarkFormatting","ColorPicker","onChange","allAvailableColors","onColorChange","activeColors","colorValue","onColorCleared","defaultSettings","hideNavigation","InlineColorUI","onClose","isVisible","hideHeader","contentStyle","paddingLeft","paddingRight","hasNavigation","leftButton","testID","children","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\tuseMobileGlobalStylesColors,\n} from '@wordpress/block-editor';\nimport { BottomSheet, ColorSettings } 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' ) {\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 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, contentRef ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color ) {\n\t\tcontentRef?.onRemoveMarkFormatting();\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 ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\tconst format = { type: name, attributes };\n\tconst hasNoSelection = value.start === value.end;\n\n\tif ( hasNoSelection ) {\n\t\tcontentRef?.onMarkFormatting( color );\n\t}\n\treturn applyFormat( value, format );\n}\n\nfunction ColorPicker( { name, value, onChange, contentRef } ) {\n\tconst property = 'color';\n\tconst colors = useMobileGlobalStylesColors();\n\tconst colorSettings = useMultipleOriginColorsAndGradients();\n\tcolorSettings.allAvailableColors = colors;\n\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors(\n\t\t\t\t\tvalue,\n\t\t\t\t\tname,\n\t\t\t\t\tcolors,\n\t\t\t\t\t{ [ property ]: color },\n\t\t\t\t\tcontentRef\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ colors, contentRef, name, onChange, value ]\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\tonColorCleared={ onColorChange }\n\t\t\tdefaultSettings={ colorSettings }\n\t\t\thideNavigation\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\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\tcontentRef={ contentRef }\n\t\t\t\t\t/>\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t</BottomSheet.NavigationContainer>\n\t\t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