@wordpress/format-library 4.35.0 → 5.0.1
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.
- package/CHANGELOG.md +6 -0
- package/build/bold/index.js +19 -17
- package/build/bold/index.js.map +1 -1
- package/build/code/index.js +14 -12
- package/build/code/index.js.map +1 -1
- package/build/image/index.js +79 -85
- package/build/image/index.js.map +1 -1
- package/build/italic/index.js +19 -17
- package/build/italic/index.js.map +1 -1
- package/build/keyboard/index.js +2 -2
- package/build/keyboard/index.js.map +1 -1
- package/build/language/index.js +63 -58
- package/build/language/index.js.map +1 -1
- package/build/link/index.js +33 -31
- package/build/link/index.js.map +1 -1
- package/build/link/index.native.js +20 -18
- package/build/link/index.native.js.map +1 -1
- package/build/link/inline.js +24 -23
- package/build/link/inline.js.map +1 -1
- package/build/link/modal-screens/link-picker-screen.native.js +2 -2
- package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build/link/modal-screens/link-settings-screen.native.js +28 -24
- package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build/link/modal.native.js +20 -16
- package/build/link/modal.native.js.map +1 -1
- package/build/non-breaking-space/index.js +2 -2
- package/build/non-breaking-space/index.js.map +1 -1
- package/build/strikethrough/index.js +14 -12
- package/build/strikethrough/index.js.map +1 -1
- package/build/subscript/index.js +2 -2
- package/build/subscript/index.js.map +1 -1
- package/build/superscript/index.js +2 -2
- package/build/superscript/index.js.map +1 -1
- package/build/text-color/index.js +24 -22
- package/build/text-color/index.js.map +1 -1
- package/build/text-color/index.native.js +36 -30
- package/build/text-color/index.native.js.map +1 -1
- package/build/text-color/inline.js +22 -17
- package/build/text-color/inline.js.map +1 -1
- package/build/text-color/inline.native.js +20 -16
- package/build/text-color/inline.native.js.map +1 -1
- package/build/underline/index.js +11 -9
- package/build/underline/index.js.map +1 -1
- package/build/unknown/index.js +2 -2
- package/build/unknown/index.js.map +1 -1
- package/build-module/bold/index.js +21 -17
- package/build-module/bold/index.js.map +1 -1
- package/build-module/code/index.js +16 -12
- package/build-module/code/index.js.map +1 -1
- package/build-module/image/index.js +80 -85
- package/build-module/image/index.js.map +1 -1
- package/build-module/italic/index.js +21 -17
- package/build-module/italic/index.js.map +1 -1
- package/build-module/keyboard/index.js +2 -2
- package/build-module/keyboard/index.js.map +1 -1
- package/build-module/language/index.js +65 -58
- package/build-module/language/index.js.map +1 -1
- package/build-module/link/index.js +35 -31
- package/build-module/link/index.js.map +1 -1
- package/build-module/link/index.native.js +22 -18
- package/build-module/link/index.native.js.map +1 -1
- package/build-module/link/inline.js +24 -23
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +2 -2
- package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build-module/link/modal-screens/link-settings-screen.native.js +30 -24
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build-module/link/modal.native.js +21 -16
- package/build-module/link/modal.native.js.map +1 -1
- package/build-module/non-breaking-space/index.js +2 -2
- package/build-module/non-breaking-space/index.js.map +1 -1
- package/build-module/strikethrough/index.js +16 -12
- package/build-module/strikethrough/index.js.map +1 -1
- package/build-module/subscript/index.js +2 -2
- package/build-module/subscript/index.js.map +1 -1
- package/build-module/superscript/index.js +2 -2
- package/build-module/superscript/index.js.map +1 -1
- package/build-module/text-color/index.js +26 -22
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/index.native.js +39 -31
- package/build-module/text-color/index.native.js.map +1 -1
- package/build-module/text-color/inline.js +23 -17
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/text-color/inline.native.js +21 -17
- package/build-module/text-color/inline.native.js.map +1 -1
- package/build-module/underline/index.js +13 -9
- package/build-module/underline/index.js.map +1 -1
- package/build-module/unknown/index.js +2 -2
- package/build-module/unknown/index.js.map +1 -1
- package/package.json +16 -15
- package/src/image/index.js +34 -47
- package/src/link/modal-screens/link-settings-screen.native.js +2 -2
- package/src/text-color/index.native.js +4 -4
- package/src/text-color/inline.native.js +3 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_blockEditor","_icons","_richText","_inline","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","transparentValue","exports","name","title","__","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","useSettings","isAddingColor","setIsAddingColor","useState","enableIsAddingColor","useCallback","disableIsAddingColor","colorIndicatorStyle","useMemo","current","getActiveColors","hasColorsToChoose","length","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_blockEditor","_icons","_richText","_inline","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","transparentValue","exports","name","title","__","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","useSettings","isAddingColor","setIsAddingColor","useState","enableIsAddingColor","useCallback","disableIsAddingColor","colorIndicatorStyle","useMemo","current","getActiveColors","hasColorsToChoose","length","jsxs","Fragment","children","jsx","RichTextToolbarButton","className","icon","Icon","keys","textColorIcon","colorIcon","onClick","removeFormat","role","onClose","textColor","tagName","attributes","class","edit"],"sources":["@wordpress/format-library/src/text-color/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSettings } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst [ allowCustomControl, colors = EMPTY_ARRAY ] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette'\n\t);\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IA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AAa,iBACd,IAAAhD,WAAA,CAAA+D,GAAA,EAACjE,OAAA,CAAAS,OAAa;MACbgB,IAAI,EAAGA,IAAM;MACbmD,OAAO,EAAGrB,oBAAsB;MAChCV,gBAAgB,EAAGA,gBAAkB;MACrCT,KAAK,EAAGA,KAAO;MACfO,QAAQ,EAAGA,QAAU;MACrBG,UAAU,EAAGA,UAAY;MACzBF,QAAQ,EAAGA;IAAU,CACrB,CACD;EAAA,CACA,CAAC;AAEL;AAEO,MAAMiC,SAAS,GAAArD,OAAA,CAAAqD,SAAA,GAAG;EACxBpD,IAAI;EACJC,KAAK;EACLoD,OAAO,EAAE,MAAM;EACfX,SAAS,EAAE,kBAAkB;EAC7BY,UAAU,EAAE;IACX7C,KAAK,EAAE,OAAO;IACd8C,KAAK,EAAE;EACR,CAAC;EACDC,IAAI,EAAEvC;AACP,CAAC","ignoreList":[]}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.textColor = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
8
|
var _reactNative = require("react-native");
|
|
10
9
|
var _i18n = require("@wordpress/i18n");
|
|
11
10
|
var _element = require("@wordpress/element");
|
|
@@ -17,6 +16,7 @@ var _compose = require("@wordpress/compose");
|
|
|
17
16
|
var _inlineNative = require("./inline.native.js");
|
|
18
17
|
var _inline = _interopRequireDefault(require("./inline"));
|
|
19
18
|
var _style = _interopRequireDefault(require("./style.scss"));
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
/**
|
|
21
21
|
* External dependencies
|
|
22
22
|
*/
|
|
@@ -67,7 +67,7 @@ function TextColorEdit({
|
|
|
67
67
|
contentRef
|
|
68
68
|
}) {
|
|
69
69
|
const [allowCustomControl] = (0, _blockEditor.useSettings)('color.custom');
|
|
70
|
-
const colors = (0,
|
|
70
|
+
const colors = (0, _blockEditor.useMobileGlobalStylesColors)();
|
|
71
71
|
const [isAddingColor, setIsAddingColor] = (0, _element.useState)(false);
|
|
72
72
|
const enableIsAddingColor = (0, _element.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]);
|
|
73
73
|
const disableIsAddingColor = (0, _element.useCallback)(() => setIsAddingColor(false), [setIsAddingColor]);
|
|
@@ -94,34 +94,40 @@ function TextColorEdit({
|
|
|
94
94
|
..._style.default['components-inline-color--is-active']
|
|
95
95
|
};
|
|
96
96
|
const customContainerStyles = _style.default['components-inline-color__button-container'];
|
|
97
|
-
return (0,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
98
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockControls, {
|
|
99
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.ToolbarGroup, {
|
|
100
|
+
children: [isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
101
|
+
style: outlineStyle,
|
|
102
|
+
pointerEvents: "none"
|
|
103
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
|
|
104
|
+
name: "text-color",
|
|
105
|
+
isActive: isActive,
|
|
106
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
107
|
+
icon: Object.keys(activeAttributes).length ? _icons.textColor : _icons.color,
|
|
108
|
+
style: colorIndicatorStyle?.color && {
|
|
109
|
+
color: colorIndicatorStyle.color
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
title: title,
|
|
113
|
+
extraProps: {
|
|
114
|
+
isActiveStyle,
|
|
115
|
+
customContainerStyles
|
|
116
|
+
}
|
|
117
|
+
// If has no colors to choose but a color is active remove the color onClick
|
|
118
|
+
,
|
|
119
|
+
onClick: onPressButton
|
|
120
|
+
})]
|
|
121
|
+
})
|
|
122
|
+
}), isAddingColor && /*#__PURE__*/(0, _jsxRuntime.jsx)(_inline.default, {
|
|
123
|
+
name: name,
|
|
124
|
+
onClose: disableIsAddingColor,
|
|
125
|
+
activeAttributes: activeAttributes,
|
|
126
|
+
value: value,
|
|
127
|
+
onChange: onChange,
|
|
128
|
+
contentRef: contentRef
|
|
129
|
+
})]
|
|
130
|
+
});
|
|
125
131
|
}
|
|
126
132
|
const textColor = exports.textColor = {
|
|
127
133
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_i18n","_element","_blockEditor","_components","_icons","_richText","_compose","_inlineNative","_inline","_interopRequireDefault","_style","name","title","__","getComputedStyleProperty","element","property","_element$props$style","style","props","backgroundColor","baseColors","color","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","useSettings","colors","useMobileGlobalStylesColors","isAddingColor","setIsAddingColor","useState","enableIsAddingColor","useCallback","disableIsAddingColor","colorIndicatorStyle","useMemo","getActiveColors","hasColorsToChoose","length","onPressButton","removeFormat","outlineStyle","usePreferredColorSchemeStyle","styles","borderWidth","StyleSheet","hairlineWidth","isActiveStyle","customContainerStyles","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_i18n","_element","_blockEditor","_components","_icons","_richText","_compose","_inlineNative","_inline","_interopRequireDefault","_style","_jsxRuntime","name","title","__","getComputedStyleProperty","element","property","_element$props$style","style","props","backgroundColor","baseColors","color","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","useSettings","colors","useMobileGlobalStylesColors","isAddingColor","setIsAddingColor","useState","enableIsAddingColor","useCallback","disableIsAddingColor","colorIndicatorStyle","useMemo","getActiveColors","hasColorsToChoose","length","onPressButton","removeFormat","outlineStyle","usePreferredColorSchemeStyle","styles","borderWidth","StyleSheet","hairlineWidth","isActiveStyle","customContainerStyles","jsxs","Fragment","children","jsx","BlockControls","ToolbarGroup","View","pointerEvents","ToolbarButton","icon","Icon","Object","keys","textColorIcon","colorIcon","extraProps","onClick","default","onClose","textColor","exports","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 { useCallback, 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 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\tedit: TextCol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I;cAC7BA,KAAK,EAAEmB,mBAAmB,CAACnB;YAC5B;UACA,CACD,CACD;UACDV,KAAK,EAAGA,KAAO;UACf2D,UAAU,EAAG;YACZjB,aAAa;YACbC;UACD;UACA;UAAA;UACAiB,OAAO,EAAG1B;QAAe,CACzB,CAAC;MAAA,CACW;IAAC,CACD,CAAC,EACdX,aAAa,iBACd,IAAAzB,WAAA,CAAAiD,GAAA,EAACpD,OAAA,CAAAkE,OAAa;MACb9D,IAAI,EAAGA,IAAM;MACb+D,OAAO,EAAGlC,oBAAsB;MAChCX,gBAAgB,EAAGA,gBAAkB;MACrCH,KAAK,EAAGA,KAAO;MACfC,QAAQ,EAAGA,QAAU;MACrBG,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACA,CAAC;AAEL;AAEO,MAAM6C,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACxBhE,IAAI;EACJC,KAAK;EACLiE,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,kBAAkB;EAC7BC,UAAU,EAAE;IACX7D,KAAK,EAAE,OAAO;IACd8D,KAAK,EAAE;EACR,CAAC;EACDC,IAAI,EAAExD;AACP,CAAC","ignoreList":[]}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = InlineColorUI;
|
|
7
7
|
exports.getActiveColors = getActiveColors;
|
|
8
8
|
exports.parseClassName = parseClassName;
|
|
9
|
-
var _react = require("react");
|
|
10
9
|
var _element = require("@wordpress/element");
|
|
11
10
|
var _data = require("@wordpress/data");
|
|
12
11
|
var _richText = require("@wordpress/rich-text");
|
|
@@ -15,6 +14,7 @@ var _components = require("@wordpress/components");
|
|
|
15
14
|
var _i18n = require("@wordpress/i18n");
|
|
16
15
|
var _index = require("./index");
|
|
17
16
|
var _lockUnlock = require("../lock-unlock");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
/**
|
|
19
19
|
* WordPress dependencies
|
|
20
20
|
*/
|
|
@@ -126,7 +126,7 @@ function ColorPicker({
|
|
|
126
126
|
}));
|
|
127
127
|
}, [colors, onChange, property]);
|
|
128
128
|
const activeColors = (0, _element.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]);
|
|
129
|
-
return (0,
|
|
129
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.ColorPalette, {
|
|
130
130
|
value: activeColors[property],
|
|
131
131
|
onChange: onColorChange
|
|
132
132
|
});
|
|
@@ -146,22 +146,27 @@ function InlineColorUI({
|
|
|
146
146
|
isActive
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
|
-
return (0,
|
|
149
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Popover, {
|
|
150
150
|
onClose: onClose,
|
|
151
151
|
className: "format-library__inline-color-popover",
|
|
152
|
-
anchor: popoverAnchor
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
152
|
+
anchor: popoverAnchor,
|
|
153
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Tabs, {
|
|
154
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabList, {
|
|
155
|
+
children: TABS.map(tab => /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.Tab, {
|
|
156
|
+
tabId: tab.name,
|
|
157
|
+
children: tab.title
|
|
158
|
+
}, tab.name))
|
|
159
|
+
}), TABS.map(tab => /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabPanel, {
|
|
160
|
+
tabId: tab.name,
|
|
161
|
+
focusable: false,
|
|
162
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorPicker, {
|
|
163
|
+
name: name,
|
|
164
|
+
property: tab.name,
|
|
165
|
+
value: value,
|
|
166
|
+
onChange: onChange
|
|
167
|
+
})
|
|
168
|
+
}, tab.name))]
|
|
169
|
+
})
|
|
170
|
+
});
|
|
166
171
|
}
|
|
167
172
|
//# sourceMappingURL=inline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_richText","_blockEditor","_components","_i18n","_index","_lockUnlock","Tabs","unlock","componentsPrivateApis","TABS","name","title","__","parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","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","_react","createElement","ColorPalette","InlineColorUI","onClose","contentRef","isActive","popoverAnchor","useAnchor","editableContentElement","current","settings","Popover","anchor","TabList","map","tab","Tab","tabId","key","TabPanel","focusable"],"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} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst 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\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAOA,IAAAI,WAAA,GAAAJ,OAAA;AAIA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AA5BA;AACA;AACA;;AAsBA;AACA;AACA;;AAIA,MAAM;EAAEQ;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEhD,MAAMC,IAAI,GAAG,CACZ;EAAEC,IAAI,EAAE,OAAO;EAAEC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO;AAAE,CAAC,EACtC;EAAEF,IAAI,EAAE,iBAAiB;EAAEC,KAAK,EAAE,IAAAC,QAAE,EAAE,YAAa;AAAE,CAAC,CACtD;AAED,SAASC,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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AQ;EACRc,OAAO;EACPC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,MAAMC,aAAa,GAAG,IAAAC,mBAAS,EAAE;IAChCC,sBAAsB,EAAEJ,UAAU,CAACK,OAAO;IAC1CC,QAAQ,EAAE;MAAE,GAAGA,gBAAQ;MAAEL;IAAS;EACnC,CAAE,CAAC;EAEH,OACC,IAAAN,MAAA,CAAAC,aAAA,EAAC9D,WAAA,CAAAyE,OAAO;IACPR,OAAO,EAAGA,OAAS;IACnB1C,SAAS,EAAC,sCAAsC;IAChDmD,MAAM,EAAGN;EAAe,GAExB,IAAAP,MAAA,CAAAC,aAAA,EAAC1D,IAAI,QACJ,IAAAyD,MAAA,CAAAC,aAAA,EAAC1D,IAAI,CAACuE,OAAO,QACVpE,IAAI,CAACqE,GAAG,CAAIC,GAAG,IAChB,IAAAhB,MAAA,CAAAC,aAAA,EAAC1D,IAAI,CAAC0E,GAAG;IAACC,KAAK,EAAGF,GAAG,CAACrE,IAAM;IAACwE,GAAG,EAAGH,GAAG,CAACrE;EAAM,GAC1CqE,GAAG,CAACpE,KACG,CACT,CACW,CAAC,EACbF,IAAI,CAACqE,GAAG,CAAIC,GAAG,IAChB,IAAAhB,MAAA,CAAAC,aAAA,EAAC1D,IAAI,CAAC6E,QAAQ;IACbF,KAAK,EAAGF,GAAG,CAACrE,IAAM;IAClB0E,SAAS,EAAG,KAAO;IACnBF,GAAG,EAAGH,GAAG,CAACrE;EAAM,GAEhB,IAAAqD,MAAA,CAAAC,aAAA,EAACZ,WAAW;IACX1C,IAAI,EAAGA,IAAM;IACbS,QAAQ,EAAG4D,GAAG,CAACrE,IAAM;IACrBU,KAAK,EAAGA,KAAO;IACfiC,QAAQ,EAAGA;EAAU,CACrB,CACa,CACd,CACG,CACE,CAAC;AAEZ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_richText","_blockEditor","_components","_i18n","_index","_lockUnlock","_jsxRuntime","Tabs","unlock","componentsPrivateApis","TABS","name","title","__","parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","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","jsx","ColorPalette","InlineColorUI","onClose","contentRef","isActive","popoverAnchor","useAnchor","editableContentElement","current","settings","Popover","anchor","children","jsxs","TabList","map","tab","Tab","tabId","TabPanel","focusable"],"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} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst 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\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n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S;EACnC,CAAE,CAAC;EAEH,oBACC,IAAA/D,WAAA,CAAA0D,GAAA,EAAC9D,WAAA,CAAAyE,OAAO;IACPR,OAAO,EAAGA,OAAS;IACnBzC,SAAS,EAAC,sCAAsC;IAChDkD,MAAM,EAAGN,aAAe;IAAAO,QAAA,eAExB,IAAAvE,WAAA,CAAAwE,IAAA,EAACvE,IAAI;MAAAsE,QAAA,gBACJ,IAAAvE,WAAA,CAAA0D,GAAA,EAACzD,IAAI,CAACwE,OAAO;QAAAF,QAAA,EACVnE,IAAI,CAACsE,GAAG,CAAIC,GAAG,iBAChB,IAAA3E,WAAA,CAAA0D,GAAA,EAACzD,IAAI,CAAC2E,GAAG;UAACC,KAAK,EAAGF,GAAG,CAACtE,IAAM;UAAAkE,QAAA,EACzBI,GAAG,CAACrE;QAAK,GADuBqE,GAAG,CAACtE,IAE7B,CACT;MAAC,CACU,CAAC,EACbD,IAAI,CAACsE,GAAG,CAAIC,GAAG,iBAChB,IAAA3E,WAAA,CAAA0D,GAAA,EAACzD,IAAI,CAAC6E,QAAQ;QACbD,KAAK,EAAGF,GAAG,CAACtE,IAAM;QAClB0E,SAAS,EAAG,KAAO;QAAAR,QAAA,eAGnB,IAAAvE,WAAA,CAAA0D,GAAA,EAACX,WAAW;UACX1C,IAAI,EAAGA,IAAM;UACbS,QAAQ,EAAG6D,GAAG,CAACtE,IAAM;UACrBU,KAAK,EAAGA,KAAO;UACfiC,QAAQ,EAAGA;QAAU,CACrB;MAAC,GAPI2B,GAAG,CAACtE,IAQI,CACd,CAAC;IAAA,CACE;EAAC,CACC,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = InlineColorUI;
|
|
7
7
|
exports.getActiveColors = getActiveColors;
|
|
8
|
-
var _react = require("react");
|
|
9
8
|
var _element = require("@wordpress/element");
|
|
10
9
|
var _richText = require("@wordpress/rich-text");
|
|
11
10
|
var _blockEditor = require("@wordpress/block-editor");
|
|
12
11
|
var _components = require("@wordpress/components");
|
|
13
12
|
var _index = require("./index.js");
|
|
14
13
|
var _inline = require("./inline.js");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
/**
|
|
16
16
|
* WordPress dependencies
|
|
17
17
|
*/
|
|
@@ -97,15 +97,16 @@ function ColorPicker({
|
|
|
97
97
|
contentRef
|
|
98
98
|
}) {
|
|
99
99
|
const property = 'color';
|
|
100
|
-
const colors = (0,
|
|
100
|
+
const colors = (0, _blockEditor.useMobileGlobalStylesColors)();
|
|
101
101
|
const colorSettings = (0, _blockEditor.useMultipleOriginColorsAndGradients)();
|
|
102
|
+
colorSettings.allAvailableColors = colors;
|
|
102
103
|
const onColorChange = (0, _element.useCallback)(color => {
|
|
103
104
|
onChange(setColors(value, name, colors, {
|
|
104
105
|
[property]: color
|
|
105
106
|
}, contentRef));
|
|
106
107
|
}, [colors, contentRef, name, onChange, value]);
|
|
107
108
|
const activeColors = (0, _element.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]);
|
|
108
|
-
return (0,
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ColorSettings, {
|
|
109
110
|
colorValue: activeColors[property],
|
|
110
111
|
onColorChange: onColorChange,
|
|
111
112
|
onColorCleared: onColorChange,
|
|
@@ -120,7 +121,7 @@ function InlineColorUI({
|
|
|
120
121
|
onClose,
|
|
121
122
|
contentRef
|
|
122
123
|
}) {
|
|
123
|
-
return (0,
|
|
124
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet, {
|
|
124
125
|
isVisible: true,
|
|
125
126
|
onClose: onClose,
|
|
126
127
|
hideHeader: true,
|
|
@@ -130,17 +131,20 @@ function InlineColorUI({
|
|
|
130
131
|
},
|
|
131
132
|
hasNavigation: true,
|
|
132
133
|
leftButton: null,
|
|
133
|
-
testID: "inline-text-color-modal"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
134
|
+
testID: "inline-text-color-modal",
|
|
135
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.NavigationContainer, {
|
|
136
|
+
animate: true,
|
|
137
|
+
main: true,
|
|
138
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.NavigationScreen, {
|
|
139
|
+
name: "text-color",
|
|
140
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorPicker, {
|
|
141
|
+
name: name,
|
|
142
|
+
value: value,
|
|
143
|
+
onChange: onChange,
|
|
144
|
+
contentRef: contentRef
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
});
|
|
145
149
|
}
|
|
146
150
|
//# sourceMappingURL=inline.native.js.map
|
|
@@ -1 +1 @@
|
|
|
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","contentRef","onRemoveMarkFormatting","removeFormat","styles","classNames","push","join","colorObject","getColorObjectByColorValue","getColorClassName","slug","length","format","type","hasNoSelection","start","end","onMarkFormatting","applyFormat","ColorPicker","onChange","useMobileGlobalStylesColors","useMultipleOriginColorsAndGradients","onColorChange","useCallback","activeColors","useMemo","
|
|
1
|
+
{"version":3,"names":["_element","require","_richText","_blockEditor","_components","_index","_inline","_jsxRuntime","parseCSS","css","split","reduce","accumulator","rule","property","value","replace","color","transparentValue","backgroundColor","getActiveColors","name","colorSettings","activeColorFormat","getActiveFormat","attributes","style","parseClassName","class","setColors","colors","contentRef","onRemoveMarkFormatting","removeFormat","styles","classNames","push","join","colorObject","getColorObjectByColorValue","getColorClassName","slug","length","format","type","hasNoSelection","start","end","onMarkFormatting","applyFormat","ColorPicker","onChange","useMobileGlobalStylesColors","useMultipleOriginColorsAndGradients","allAvailableColors","onColorChange","useCallback","activeColors","useMemo","jsx","ColorSettings","colorValue","onColorCleared","defaultSettings","hideNavigation","InlineColorUI","onClose","BottomSheet","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</BottomSheet>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAA6C,IAAAM,WAAA,GAAAN,OAAA;AArB7C;AACA;AACA;;AAeA;AACA;AACA;;AAIA,SAASO,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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WAAW,EAAE,CAAC;MAAEC,YAAY,EAAE;IAAE,CAAG;IACpDC,aAAa;IACbC,UAAU,EAAG,IAAM;IACnBC,MAAM,EAAC,yBAAyB;IAAAC,QAAA,eAEhC,IAAArE,WAAA,CAAAoD,GAAA,EAACvD,WAAA,CAAA+D,WAAW,CAACU,mBAAmB;MAACC,OAAO;MAACC,IAAI;MAAAH,QAAA,eAC5C,IAAArE,WAAA,CAAAoD,GAAA,EAACvD,WAAA,CAAA+D,WAAW,CAACa,gBAAgB;QAAC3D,IAAI,EAAC,YAAY;QAAAuD,QAAA,eAC9C,IAAArE,WAAA,CAAAoD,GAAA,EAACT,WAAW;UACX7B,IAAI,EAAGA,IAAM;UACbN,KAAK,EAAGA,KAAO;UACfoC,QAAQ,EAAGA,QAAU;UACrBpB,UAAU,EAAGA;QAAY,CACzB;MAAC,CAC2B;IAAC,CACC;EAAC,CACtB,CAAC;AAEhB","ignoreList":[]}
|
package/build/underline/index.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.underline = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _i18n = require("@wordpress/i18n");
|
|
9
8
|
var _richText = require("@wordpress/rich-text");
|
|
10
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
/**
|
|
12
12
|
* WordPress dependencies
|
|
13
13
|
*/
|
|
@@ -35,14 +35,16 @@ const underline = exports.underline = {
|
|
|
35
35
|
title
|
|
36
36
|
}));
|
|
37
37
|
};
|
|
38
|
-
return (0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
39
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.RichTextShortcut, {
|
|
40
|
+
type: "primary",
|
|
41
|
+
character: "u",
|
|
42
|
+
onUse: onToggle
|
|
43
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.__unstableRichTextInputEvent, {
|
|
44
|
+
inputType: "formatUnderline",
|
|
45
|
+
onInput: onToggle
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_richText","_blockEditor","name","title","__","underline","exports","tagName","className","attributes","style","edit","value","onChange","onToggle","toggleFormat","type","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_richText","_blockEditor","_jsxRuntime","name","title","__","underline","exports","tagName","className","attributes","style","edit","value","onChange","onToggle","toggleFormat","type","jsxs","Fragment","children","jsx","RichTextShortcut","character","onUse","__unstableRichTextInputEvent","inputType","onInput"],"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=\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IAAA,CACD,CAAC;EAEL;AACD,CAAC","ignoreList":[]}
|
package/build/unknown/index.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.unknown = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _i18n = require("@wordpress/i18n");
|
|
9
8
|
var _richText = require("@wordpress/rich-text");
|
|
10
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
11
10
|
var _icons = require("@wordpress/icons");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
/**
|
|
13
13
|
* WordPress dependencies
|
|
14
14
|
*/
|
|
@@ -42,7 +42,7 @@ const unknown = exports.unknown = {
|
|
|
42
42
|
onChange((0, _richText.removeFormat)(value, name));
|
|
43
43
|
onFocus();
|
|
44
44
|
}
|
|
45
|
-
return (0,
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.RichTextToolbarButton, {
|
|
46
46
|
name: "unknown",
|
|
47
47
|
icon: _icons.help,
|
|
48
48
|
title: title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_richText","_blockEditor","_icons","name","title","__","selectionContainsUnknownFormats","value","isCollapsed","selectedValue","slice","formats","some","format","type","unknown","exports","tagName","className","edit","isActive","onChange","onFocus","onClick","removeFormat","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_richText","_blockEditor","_icons","_jsxRuntime","name","title","__","selectionContainsUnknownFormats","value","isCollapsed","selectedValue","slice","formats","some","format","type","unknown","exports","tagName","className","edit","isActive","onChange","onFocus","onClick","removeFormat","jsx","RichTextToolbarButton","icon","help"],"sources":["@wordpress/format-library/src/unknown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice, isCollapsed } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { help } from '@wordpress/icons';\n\nconst name = 'core/unknown';\nconst title = __( 'Clear Unknown Formatting' );\n\nfunction selectionContainsUnknownFormats( value ) {\n\tif ( isCollapsed( value ) ) {\n\t\treturn false;\n\t}\n\n\tconst selectedValue = slice( value );\n\treturn selectedValue.formats.some( ( formats ) => {\n\t\treturn formats.some( ( format ) => format.type === name );\n\t} );\n}\n\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tif ( ! isActive && ! selectionContainsUnknownFormats( value ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"unknown\"\n\t\t\t\ticon={ help }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive\n\t\t\t/>\n\t\t);\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AANxC;AACA;AACA;;AAMA,MAAMK,IAAI,GAAG,cAAc;AAC3B,MAAMC,KAAK,GAAG,IAAAC,QAAE,EAAE,0BAA2B,CAAC;AAE9C,SAASC,+BAA+BA,CAAEC,KAAK,EAAG;EACjD,IAAK,IAAAC,qBAAW,EAAED,KAAM,CAAC,EAAG;IAC3B,OAAO,KAAK;EACb;EAEA,MAAME,aAAa,GAAG,IAAAC,eAAK,EAAEH,KAAM,CAAC;EACpC,OAAOE,aAAa,CAACE,OAAO,CAACC,IAAI,CAAID,OAAO,IAAM;IACjD,OAAOA,OAAO,CAACC,IAAI,CAAIC,MAAM,IAAMA,MAAM,CAACC,IAAI,KAAKX,IAAK,CAAC;EAC1D,CAAE,CAAC;AACJ;AAEO,MAAMY,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG;EACtBZ,IAAI;EACJC,KAAK;EACLa,OAAO,EAAE,GAAG;EACZC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEb,KAAK;IAAEc,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,IAAK,CAAEF,QAAQ,IAAI,CAAEd,+BAA+B,CAAEC,KAAM,CAAC,EAAG;MAC/D,OAAO,IAAI;IACZ;IAEA,SAASgB,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAE,IAAAG,sBAAY,EAAEjB,KAAK,EAAEJ,IAAK,CAAE,CAAC;MACvCmB,OAAO,CAAC,CAAC;IACV;IAEA,oBACC,IAAApB,WAAA,CAAAuB,GAAA,EAACzB,YAAA,CAAA0B,qBAAqB;MACrBvB,IAAI,EAAC,SAAS;MACdwB,IAAI,EAAGC,WAAM;MACbxB,KAAK,EAAGA,KAAO;MACfmB,OAAO,EAAGA,OAAS;MACnBH,QAAQ;IAAA,CACR,CAAC;EAEJ;AACD,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
@@ -6,6 +5,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
5
|
import { toggleFormat } from '@wordpress/rich-text';
|
|
7
6
|
import { RichTextToolbarButton, RichTextShortcut, __unstableRichTextInputEvent } from '@wordpress/block-editor';
|
|
8
7
|
import { formatBold } from '@wordpress/icons';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
11
|
const name = 'core/bold';
|
|
10
12
|
const title = __('Bold');
|
|
11
13
|
export const bold = {
|
|
@@ -31,22 +33,24 @@ export const bold = {
|
|
|
31
33
|
}));
|
|
32
34
|
onFocus();
|
|
33
35
|
}
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
37
|
+
children: [/*#__PURE__*/_jsx(RichTextShortcut, {
|
|
38
|
+
type: "primary",
|
|
39
|
+
character: "b",
|
|
40
|
+
onUse: onToggle
|
|
41
|
+
}), /*#__PURE__*/_jsx(RichTextToolbarButton, {
|
|
42
|
+
name: "bold",
|
|
43
|
+
icon: formatBold,
|
|
44
|
+
title: title,
|
|
45
|
+
onClick: onClick,
|
|
46
|
+
isActive: isActive,
|
|
47
|
+
shortcutType: "primary",
|
|
48
|
+
shortcutCharacter: "b"
|
|
49
|
+
}), /*#__PURE__*/_jsx(__unstableRichTextInputEvent, {
|
|
50
|
+
inputType: "formatBold",
|
|
51
|
+
onInput: onToggle
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
50
54
|
}
|
|
51
55
|
};
|
|
52
56
|
//# sourceMappingURL=index.js.map
|