@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.
- package/build/bold/index.js +69 -58
- package/build/bold/index.js.map +7 -1
- package/build/code/index.js +62 -54
- package/build/code/index.js.map +7 -1
- package/build/default-formats.js +52 -24
- package/build/default-formats.js.map +7 -1
- package/build/image/index.js +185 -153
- package/build/image/index.js.map +7 -1
- package/build/index.js +28 -18
- package/build/index.js.map +7 -1
- package/build/italic/index.js +69 -58
- package/build/italic/index.js.map +7 -1
- package/build/keyboard/index.js +47 -36
- package/build/keyboard/index.js.map +7 -1
- package/build/language/index.js +145 -113
- package/build/language/index.js.map +7 -1
- package/build/link/css-classes-setting.js +81 -0
- package/build/link/css-classes-setting.js.map +7 -0
- package/build/link/index.js +162 -167
- package/build/link/index.js.map +7 -1
- package/build/link/inline.js +186 -174
- package/build/link/inline.js.map +7 -1
- package/build/link/use-link-instance-key.js +25 -19
- package/build/link/use-link-instance-key.js.map +7 -1
- package/build/link/utils.js +66 -115
- package/build/link/utils.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/non-breaking-space/index.js +44 -28
- package/build/non-breaking-space/index.js.map +7 -1
- package/build/strikethrough/index.js +57 -42
- package/build/strikethrough/index.js.map +7 -1
- package/build/subscript/index.js +47 -36
- package/build/subscript/index.js.map +7 -1
- package/build/superscript/index.js +47 -36
- package/build/superscript/index.js.map +7 -1
- package/build/text-color/index.js +102 -70
- package/build/text-color/index.js.map +7 -1
- package/build/text-color/inline.js +118 -116
- package/build/text-color/inline.js.map +7 -1
- package/build/underline/index.js +62 -40
- package/build/underline/index.js.map +7 -1
- package/build/unknown/index.js +51 -37
- package/build/unknown/index.js.map +7 -1
- package/build-module/bold/index.js +52 -52
- package/build-module/bold/index.js.map +7 -1
- package/build-module/code/index.js +41 -46
- package/build-module/code/index.js.map +7 -1
- package/build-module/default-formats.js +34 -19
- package/build-module/default-formats.js.map +7 -1
- package/build-module/image/index.js +174 -144
- package/build-module/image/index.js.map +7 -1
- package/build-module/index.js +6 -14
- package/build-module/index.js.map +7 -1
- package/build-module/italic/index.js +52 -52
- package/build-module/italic/index.js.map +7 -1
- package/build-module/keyboard/index.js +25 -30
- package/build-module/keyboard/index.js.map +7 -1
- package/build-module/language/index.js +128 -105
- package/build-module/language/index.js.map +7 -1
- package/build-module/link/css-classes-setting.js +67 -0
- package/build-module/link/css-classes-setting.js.map +7 -0
- package/build-module/link/index.js +128 -146
- package/build-module/link/index.js.map +7 -1
- package/build-module/link/inline.js +158 -154
- package/build-module/link/inline.js.map +7 -1
- package/build-module/link/use-link-instance-key.js +7 -14
- package/build-module/link/use-link-instance-key.js.map +7 -1
- package/build-module/link/utils.js +46 -101
- package/build-module/link/utils.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/non-breaking-space/index.js +22 -22
- package/build-module/non-breaking-space/index.js.map +7 -1
- package/build-module/strikethrough/index.js +38 -36
- package/build-module/strikethrough/index.js.map +7 -1
- package/build-module/subscript/index.js +25 -30
- package/build-module/subscript/index.js.map +7 -1
- package/build-module/superscript/index.js +25 -30
- package/build-module/superscript/index.js.map +7 -1
- package/build-module/text-color/index.js +72 -61
- package/build-module/text-color/index.js.map +7 -1
- package/build-module/text-color/inline.js +107 -106
- package/build-module/text-color/inline.js.map +7 -1
- package/build-module/underline/index.js +43 -34
- package/build-module/underline/index.js.map +7 -1
- package/build-module/unknown/index.js +26 -28
- package/build-module/unknown/index.js.map +7 -1
- package/build-style/style-rtl.css +0 -194
- package/build-style/style.css +0 -194
- package/package.json +21 -15
- package/src/image/style.scss +3 -0
- package/src/link/css-classes-setting.js +89 -0
- package/src/link/index.js +1 -0
- package/src/link/inline.js +19 -0
- package/src/link/style.scss +3 -0
- package/src/link/test/css-classes-setting.js +144 -0
- package/src/link/utils.js +8 -0
- package/src/style.scss +4 -4
- package/src/text-color/style.scss +2 -0
- package/build/default-formats.native.js +0 -16
- package/build/default-formats.native.js.map +0 -1
- package/build/link/index.native.js +0 -174
- package/build/link/index.native.js.map +0 -1
- package/build/link/modal-screens/link-picker-screen.native.js +0 -67
- package/build/link/modal-screens/link-picker-screen.native.js.map +0 -1
- package/build/link/modal-screens/link-settings-screen.native.js +0 -226
- package/build/link/modal-screens/link-settings-screen.native.js.map +0 -1
- package/build/link/modal-screens/screens.native.js +0 -11
- package/build/link/modal-screens/screens.native.js.map +0 -1
- package/build/link/modal.native.js +0 -53
- package/build/link/modal.native.js.map +0 -1
- package/build/text-color/index.native.js +0 -134
- package/build/text-color/index.native.js.map +0 -1
- package/build/text-color/inline.native.js +0 -150
- package/build/text-color/inline.native.js.map +0 -1
- package/build-module/default-formats.native.js +0 -10
- package/build-module/default-formats.native.js.map +0 -1
- package/build-module/link/index.native.js +0 -166
- package/build-module/link/index.native.js.map +0 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +0 -59
- package/build-module/link/modal-screens/link-picker-screen.native.js.map +0 -1
- package/build-module/link/modal-screens/link-settings-screen.native.js +0 -218
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +0 -1
- package/build-module/link/modal-screens/screens.native.js +0 -5
- package/build-module/link/modal-screens/screens.native.js.map +0 -1
- package/build-module/link/modal.native.js +0 -45
- package/build-module/link/modal.native.js.map +0 -1
- package/build-module/text-color/index.native.js +0 -126
- package/build-module/text-color/index.native.js.map +0 -1
- package/build-module/text-color/inline.native.js +0 -142
- package/build-module/text-color/inline.native.js.map +0 -1
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _native = require("@react-navigation/native");
|
|
9
|
-
var _i18n = require("@wordpress/i18n");
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
var _url = require("@wordpress/url");
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
var _richText = require("@wordpress/rich-text");
|
|
14
|
-
var _icons = require("@wordpress/icons");
|
|
15
|
-
var _utils = require("../utils");
|
|
16
|
-
var _screens = _interopRequireDefault(require("./screens"));
|
|
17
|
-
var _modal = _interopRequireDefault(require("../modal.scss"));
|
|
18
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
/**
|
|
20
|
-
* External dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* WordPress dependencies
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal dependencies
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
const LinkSettingsScreen = ({
|
|
32
|
-
onRemove,
|
|
33
|
-
onClose,
|
|
34
|
-
onChange,
|
|
35
|
-
speak,
|
|
36
|
-
value,
|
|
37
|
-
isActive,
|
|
38
|
-
activeAttributes,
|
|
39
|
-
isVisible
|
|
40
|
-
}) => {
|
|
41
|
-
const [text, setText] = (0, _element.useState)((0, _richText.getTextContent)((0, _richText.slice)(value)));
|
|
42
|
-
const [opensInNewWindow, setOpensInNewWindows] = (0, _element.useState)(activeAttributes.target === '_blank');
|
|
43
|
-
const [linkValues, setLinkValues] = (0, _element.useState)({
|
|
44
|
-
isActiveLink: isActive,
|
|
45
|
-
isRemovingLink: false
|
|
46
|
-
});
|
|
47
|
-
const {
|
|
48
|
-
shouldEnableBottomSheetMaxHeight,
|
|
49
|
-
onHandleClosingBottomSheet,
|
|
50
|
-
listProps
|
|
51
|
-
} = (0, _element.useContext)(_components.BottomSheetContext);
|
|
52
|
-
const navigation = (0, _native.useNavigation)();
|
|
53
|
-
const route = (0, _native.useRoute)();
|
|
54
|
-
const {
|
|
55
|
-
inputValue = activeAttributes.url || ''
|
|
56
|
-
} = route.params || {};
|
|
57
|
-
const onLinkCellPressed = () => {
|
|
58
|
-
shouldEnableBottomSheetMaxHeight(false);
|
|
59
|
-
navigation.navigate(_screens.default.picker, {
|
|
60
|
-
inputValue
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
(0, _element.useEffect)(() => {
|
|
64
|
-
onHandleClosingBottomSheet(() => {
|
|
65
|
-
submit(inputValue, {
|
|
66
|
-
skipStateUpdates: true
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}, [inputValue, opensInNewWindow, text]);
|
|
70
|
-
(0, _element.useEffect)(() => {
|
|
71
|
-
const {
|
|
72
|
-
isActiveLink,
|
|
73
|
-
isRemovingLink
|
|
74
|
-
} = linkValues;
|
|
75
|
-
if (!!inputValue && !isActiveLink && isVisible) {
|
|
76
|
-
submitLink({
|
|
77
|
-
shouldCloseBottomSheet: false
|
|
78
|
-
});
|
|
79
|
-
} else if ((inputValue === '' && isActiveLink || isRemovingLink) && isVisible) {
|
|
80
|
-
removeLink({
|
|
81
|
-
shouldCloseBottomSheet: false
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}, [inputValue, isVisible, linkValues.isActiveLink, linkValues.isRemovingLink]);
|
|
85
|
-
const clearFormat = ({
|
|
86
|
-
skipStateUpdates = false
|
|
87
|
-
} = {}) => {
|
|
88
|
-
onChange({
|
|
89
|
-
...value,
|
|
90
|
-
activeFormats: []
|
|
91
|
-
});
|
|
92
|
-
if (!skipStateUpdates) {
|
|
93
|
-
setLinkValues({
|
|
94
|
-
isActiveLink: false,
|
|
95
|
-
isRemovingLink: true
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const submitLink = ({
|
|
100
|
-
shouldCloseBottomSheet = true,
|
|
101
|
-
skipStateUpdates = false
|
|
102
|
-
} = {}) => {
|
|
103
|
-
const url = (0, _url.prependHTTP)(inputValue);
|
|
104
|
-
const linkText = text || inputValue;
|
|
105
|
-
const format = (0, _utils.createLinkFormat)({
|
|
106
|
-
url,
|
|
107
|
-
opensInNewWindow,
|
|
108
|
-
text: linkText
|
|
109
|
-
});
|
|
110
|
-
let newAttributes;
|
|
111
|
-
if ((0, _richText.isCollapsed)(value) && !isActive) {
|
|
112
|
-
// Insert link.
|
|
113
|
-
const toInsert = (0, _richText.applyFormat)((0, _richText.create)({
|
|
114
|
-
text: linkText
|
|
115
|
-
}), format, 0, linkText.length);
|
|
116
|
-
newAttributes = (0, _richText.insert)(value, toInsert);
|
|
117
|
-
} else if (text !== (0, _richText.getTextContent)((0, _richText.slice)(value))) {
|
|
118
|
-
// Edit text in selected link.
|
|
119
|
-
const toInsert = (0, _richText.applyFormat)((0, _richText.create)({
|
|
120
|
-
text
|
|
121
|
-
}), format, 0, text.length);
|
|
122
|
-
newAttributes = (0, _richText.insert)(value, toInsert, value.start, value.end);
|
|
123
|
-
} else {
|
|
124
|
-
// Transform selected text into link.
|
|
125
|
-
newAttributes = (0, _richText.applyFormat)(value, format);
|
|
126
|
-
}
|
|
127
|
-
// Move selection to end of link.
|
|
128
|
-
const textLength = newAttributes.text.length;
|
|
129
|
-
// check for zero width spaces
|
|
130
|
-
if (newAttributes.end > textLength) {
|
|
131
|
-
newAttributes.start = textLength;
|
|
132
|
-
newAttributes.end = textLength;
|
|
133
|
-
} else {
|
|
134
|
-
newAttributes.start = newAttributes.end;
|
|
135
|
-
}
|
|
136
|
-
newAttributes.activeFormats = [];
|
|
137
|
-
onChange({
|
|
138
|
-
...newAttributes,
|
|
139
|
-
needsSelectionUpdate: true
|
|
140
|
-
});
|
|
141
|
-
if (!skipStateUpdates) {
|
|
142
|
-
setLinkValues({
|
|
143
|
-
isActiveLink: true,
|
|
144
|
-
isRemovingLink: false
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (!(0, _utils.isValidHref)(url)) {
|
|
148
|
-
speak((0, _i18n.__)('Warning: the link has been inserted but may have errors. Please test it.'), 'assertive');
|
|
149
|
-
} else if (isActive) {
|
|
150
|
-
speak((0, _i18n.__)('Link edited.'), 'assertive');
|
|
151
|
-
} else {
|
|
152
|
-
speak((0, _i18n.__)('Link inserted'), 'assertive');
|
|
153
|
-
}
|
|
154
|
-
if (shouldCloseBottomSheet) {
|
|
155
|
-
onClose();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const removeLink = ({
|
|
159
|
-
shouldCloseBottomSheet = true,
|
|
160
|
-
skipStateUpdates = false
|
|
161
|
-
} = {}) => {
|
|
162
|
-
clearFormat({
|
|
163
|
-
skipStateUpdates
|
|
164
|
-
});
|
|
165
|
-
onRemove();
|
|
166
|
-
if (shouldCloseBottomSheet) {
|
|
167
|
-
onClose();
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const submit = (submitValue, {
|
|
171
|
-
skipStateUpdates = false
|
|
172
|
-
} = {}) => {
|
|
173
|
-
if (submitValue === '') {
|
|
174
|
-
removeLink({
|
|
175
|
-
skipStateUpdates
|
|
176
|
-
});
|
|
177
|
-
} else {
|
|
178
|
-
submitLink({
|
|
179
|
-
skipStateUpdates
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
(0, _element.useEffect)(() => {
|
|
184
|
-
const unsubscribe = navigation.addListener('focus', () => {
|
|
185
|
-
const {
|
|
186
|
-
params = {}
|
|
187
|
-
} = route;
|
|
188
|
-
if (!text && params.text) {
|
|
189
|
-
setText(params.text);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
return unsubscribe;
|
|
193
|
-
}, [navigation, route.params?.text, text]);
|
|
194
|
-
return (0, _element.useMemo)(() => {
|
|
195
|
-
const shouldShowLinkOptions = !!inputValue;
|
|
196
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
197
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.LinkCell, {
|
|
198
|
-
value: inputValue,
|
|
199
|
-
onPress: onLinkCellPressed
|
|
200
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.Cell, {
|
|
201
|
-
icon: _icons.textColor,
|
|
202
|
-
label: (0, _i18n.__)('Link text'),
|
|
203
|
-
value: text,
|
|
204
|
-
placeholder: (0, _i18n.__)('Add link text'),
|
|
205
|
-
onChangeValue: setText,
|
|
206
|
-
onSubmit: submit,
|
|
207
|
-
separatorType: shouldShowLinkOptions ? undefined : 'none'
|
|
208
|
-
}), shouldShowLinkOptions && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
209
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.SwitchCell, {
|
|
210
|
-
icon: _icons.external,
|
|
211
|
-
label: (0, _i18n.__)('Open in new tab'),
|
|
212
|
-
value: opensInNewWindow,
|
|
213
|
-
onValueChange: setOpensInNewWindows,
|
|
214
|
-
separatorType: "fullWidth"
|
|
215
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.Cell, {
|
|
216
|
-
label: (0, _i18n.__)('Remove link'),
|
|
217
|
-
labelStyle: _modal.default.clearLinkButton,
|
|
218
|
-
separatorType: "none",
|
|
219
|
-
onPress: removeLink
|
|
220
|
-
})]
|
|
221
|
-
})]
|
|
222
|
-
});
|
|
223
|
-
}, [inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset]);
|
|
224
|
-
};
|
|
225
|
-
var _default = exports.default = LinkSettingsScreen;
|
|
226
|
-
//# sourceMappingURL=link-settings-screen.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_native","require","_i18n","_element","_url","_components","_richText","_icons","_utils","_screens","_interopRequireDefault","_modal","_jsxRuntime","LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","useState","getTextContent","slice","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","useContext","BottomSheetContext","navigation","useNavigation","route","useRoute","inputValue","url","params","onLinkCellPressed","navigate","linkSettingsScreens","picker","useEffect","submit","skipStateUpdates","submitLink","shouldCloseBottomSheet","removeLink","clearFormat","activeFormats","prependHTTP","linkText","format","createLinkFormat","newAttributes","isCollapsed","toInsert","applyFormat","create","length","insert","start","end","textLength","needsSelectionUpdate","isValidHref","__","submitValue","unsubscribe","addListener","useMemo","shouldShowLinkOptions","jsxs","Fragment","children","jsx","BottomSheet","LinkCell","onPress","Cell","icon","textColor","label","placeholder","onChangeValue","onSubmit","separatorType","undefined","SwitchCell","external","onValueChange","labelStyle","styles","clearLinkButton","safeAreaBottomInset","_default","exports","default"],"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue, { skipStateUpdates: true } );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( { shouldCloseBottomSheet: false } );\n\t\t} else if (\n\t\t\t( ( inputValue === '' && isActiveLink ) || isRemovingLink ) &&\n\t\t\tisVisible\n\t\t) {\n\t\t\tremoveLink( { shouldCloseBottomSheet: false } );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = ( { skipStateUpdates = false } = {} ) => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t\t}\n\t};\n\n\tconst submitLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Insert link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// Edit text in selected link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// Transform selected text into link.\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// Move selection to end of link.\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\t\t}\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tclearFormat( { skipStateUpdates } );\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue, { skipStateUpdates = false } = {} ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink( { skipStateUpdates } );\n\t\t} else {\n\t\t\tsubmitLink( { skipStateUpdates } );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType=\"fullWidth\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType=\"none\"\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\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IAAM;QACdqE,WAAW,EAAG,IAAAjB,QAAE,EAAE,eAAgB,CAAG;QACrCkB,aAAa,EAAGrE,OAAS;QACzBsE,QAAQ,EAAG1C,MAAQ;QACnB2C,aAAa,EAAGf,qBAAqB,GAAGgB,SAAS,GAAG;MAAQ,CAC5D,CAAC,EACAhB,qBAAqB,iBACtB,IAAAnE,WAAA,CAAAoE,IAAA,EAAApE,WAAA,CAAAqE,QAAA;QAAAC,QAAA,gBACC,IAAAtE,WAAA,CAAAuE,GAAA,EAAC9E,WAAA,CAAA+E,WAAW,CAACY,UAAU;UACtBR,IAAI,EAAGS,eAAU;UACjBP,KAAK,EAAG,IAAAhB,QAAE,EAAE,iBAAkB,CAAG;UACjCxD,KAAK,EAAGS,gBAAkB;UAC1BuE,aAAa,EAAGtE,oBAAsB;UACtCkE,aAAa,EAAC;QAAW,CACzB,CAAC,eACF,IAAAlF,WAAA,CAAAuE,GAAA,EAAC9E,WAAA,CAAA+E,WAAW,CAACG,IAAI;UAChBG,KAAK,EAAG,IAAAhB,QAAE,EAAE,aAAc,CAAG;UAC7ByB,UAAU,EAAGC,cAAM,CAACC,eAAiB;UACrCP,aAAa,EAAC,MAAM;UACpBR,OAAO,EAAG/B;QAAY,CACtB,CAAC;MAAA,CACD,CACF;IAAA,CACA,CAAC;EAEL,CAAC,EAAE,CAAEZ,UAAU,EAAErB,IAAI,EAAEK,gBAAgB,EAAES,SAAS,CAACkE,mBAAmB,CAAG,CAAC;AAC3E,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa5F,kBAAkB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["settings","picker"],"sources":["@wordpress/format-library/src/link/modal-screens/screens.native.js"],"sourcesContent":["export default {\n\tsettings: 'linkSettings',\n\tpicker: 'linkPicker',\n};\n"],"mappings":";;;;;;iCAAe;EACdA,QAAQ,EAAE,cAAc;EACxBC,MAAM,EAAE;AACT,CAAC","ignoreList":[]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
|
-
var _screens = _interopRequireDefault(require("./modal-screens/screens"));
|
|
11
|
-
var _linkSettingsScreen = _interopRequireDefault(require("./modal-screens/link-settings-screen"));
|
|
12
|
-
var _linkPickerScreen = _interopRequireDefault(require("./modal-screens/link-picker-screen"));
|
|
13
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const ModalLinkUI = ({
|
|
23
|
-
isVisible,
|
|
24
|
-
...restProps
|
|
25
|
-
}) => {
|
|
26
|
-
return (0, _element.useMemo)(() => {
|
|
27
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet, {
|
|
28
|
-
isVisible: isVisible,
|
|
29
|
-
hideHeader: true,
|
|
30
|
-
onClose: restProps.onClose,
|
|
31
|
-
hasNavigation: true,
|
|
32
|
-
testID: "link-settings-modal",
|
|
33
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.BottomSheet.NavigationContainer, {
|
|
34
|
-
animate: true,
|
|
35
|
-
main: true,
|
|
36
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.NavigationScreen, {
|
|
37
|
-
name: _screens.default.settings,
|
|
38
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_linkSettingsScreen.default, {
|
|
39
|
-
isVisible: isVisible,
|
|
40
|
-
...restProps
|
|
41
|
-
})
|
|
42
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet.NavigationScreen, {
|
|
43
|
-
name: _screens.default.picker,
|
|
44
|
-
isScrollable: true,
|
|
45
|
-
fullScreen: true,
|
|
46
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_linkPickerScreen.default, {})
|
|
47
|
-
})]
|
|
48
|
-
})
|
|
49
|
-
});
|
|
50
|
-
}, [isVisible]);
|
|
51
|
-
};
|
|
52
|
-
var _default = exports.default = (0, _components.withSpokenMessages)(ModalLinkUI);
|
|
53
|
-
//# sourceMappingURL=modal.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_components","_screens","_interopRequireDefault","_linkSettingsScreen","_linkPickerScreen","_jsxRuntime","ModalLinkUI","isVisible","restProps","useMemo","jsx","BottomSheet","hideHeader","onClose","hasNavigation","testID","children","jsxs","NavigationContainer","animate","main","NavigationScreen","name","screens","settings","default","picker","isScrollable","fullScreen","_default","exports","withSpokenMessages"],"sources":["@wordpress/format-library/src/link/modal.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t\ttestID=\"link-settings-modal\"\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,iBAAA,GAAAF,sBAAA,CAAAH,OAAA;AAAkE,IAAAM,WAAA,GAAAN,OAAA;AAXlE;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMO,WAAW,GAAGA,CAAE;EAAEC,SAAS;EAAE,GAAGC;AAAU,CAAC,KAAM;EACtD,OAAO,IAAAC,gBAAO,EAAE,MAAM;IACrB,oBACC,IAAAJ,WAAA,CAAAK,GAAA,EAACV,WAAA,CAAAW,WAAW;MACXJ,SAAS,EAAGA,SAAW;MACvBK,UAAU;MACVC,OAAO,EAAGL,SAAS,CAACK,OAAS;MAC7BC,aAAa;MACbC,MAAM,EAAC,qBAAqB;MAAAC,QAAA,eAE5B,IAAAX,WAAA,CAAAY,IAAA,EAACjB,WAAA,CAAAW,WAAW,CAACO,mBAAmB;QAACC,OAAO;QAACC,IAAI;QAAAJ,QAAA,gBAC5C,IAAAX,WAAA,CAAAK,GAAA,EAACV,WAAA,CAAAW,WAAW,CAACU,gBAAgB;UAACC,IAAI,EAAGC,gBAAO,CAACC,QAAU;UAAAR,QAAA,eACtD,IAAAX,WAAA,CAAAK,GAAA,EAACP,mBAAA,CAAAsB,OAAkB;YAClBlB,SAAS,EAAGA,SAAW;YAAA,GAClBC;UAAS,CACd;QAAC,CAC2B,CAAC,eAC/B,IAAAH,WAAA,CAAAK,GAAA,EAACV,WAAA,CAAAW,WAAW,CAACU,gBAAgB;UAC5BC,IAAI,EAAGC,gBAAO,CAACG,MAAQ;UACvBC,YAAY;UACZC,UAAU;UAAAZ,QAAA,eAEV,IAAAX,WAAA,CAAAK,GAAA,EAACN,iBAAA,CAAAqB,OAAgB,IAAE;QAAC,CACS,CAAC;MAAA,CACC;IAAC,CACtB,CAAC;EAEhB,CAAC,EAAE,CAAElB,SAAS,CAAG,CAAC;AACnB,CAAC;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEa,IAAAM,8BAAkB,EAAEzB,WAAY,CAAC","ignoreList":[]}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.textColor = void 0;
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _i18n = require("@wordpress/i18n");
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
var _icons = require("@wordpress/icons");
|
|
14
|
-
var _richText = require("@wordpress/rich-text");
|
|
15
|
-
var _compose = require("@wordpress/compose");
|
|
16
|
-
var _inlineNative = require("./inline.native.js");
|
|
17
|
-
var _inline = _interopRequireDefault(require("./inline"));
|
|
18
|
-
var _style = _interopRequireDefault(require("./style.scss"));
|
|
19
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
const name = 'core/text-color';
|
|
33
|
-
const title = (0, _i18n.__)('Text color');
|
|
34
|
-
function getComputedStyleProperty(element, property) {
|
|
35
|
-
var _element$props$style;
|
|
36
|
-
const style = (_element$props$style = element?.props?.style) !== null && _element$props$style !== void 0 ? _element$props$style : {};
|
|
37
|
-
if (property === 'background-color') {
|
|
38
|
-
const {
|
|
39
|
-
backgroundColor,
|
|
40
|
-
baseColors
|
|
41
|
-
} = style;
|
|
42
|
-
if (backgroundColor !== 'transparent') {
|
|
43
|
-
return backgroundColor;
|
|
44
|
-
} else if (baseColors && baseColors?.color?.background) {
|
|
45
|
-
return baseColors?.color?.background;
|
|
46
|
-
}
|
|
47
|
-
return 'transparent';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function fillComputedColors(element, {
|
|
51
|
-
color,
|
|
52
|
-
backgroundColor
|
|
53
|
-
}) {
|
|
54
|
-
if (!color && !backgroundColor) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
color: color || getComputedStyleProperty(element, 'color'),
|
|
59
|
-
backgroundColor: getComputedStyleProperty(element, 'background-color')
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function TextColorEdit({
|
|
63
|
-
value,
|
|
64
|
-
onChange,
|
|
65
|
-
isActive,
|
|
66
|
-
activeAttributes,
|
|
67
|
-
contentRef
|
|
68
|
-
}) {
|
|
69
|
-
const [allowCustomControl] = (0, _blockEditor.useSettings)('color.custom');
|
|
70
|
-
const colors = (0, _blockEditor.useMobileGlobalStylesColors)();
|
|
71
|
-
const [isAddingColor, setIsAddingColor] = (0, _element.useState)(false);
|
|
72
|
-
const colorIndicatorStyle = (0, _element.useMemo)(() => fillComputedColors(contentRef, (0, _inlineNative.getActiveColors)(value, name, colors)), [contentRef, value, colors]);
|
|
73
|
-
const hasColorsToChoose = colors.length || !allowCustomControl;
|
|
74
|
-
const outlineStyle = [(0, _compose.usePreferredColorSchemeStyle)(_style.default['components-inline-color__outline'], _style.default['components-inline-color__outline--dark']), {
|
|
75
|
-
borderWidth: _reactNative.StyleSheet.hairlineWidth
|
|
76
|
-
}];
|
|
77
|
-
if (!hasColorsToChoose && !isActive) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const isActiveStyle = {
|
|
81
|
-
...colorIndicatorStyle,
|
|
82
|
-
...(!colorIndicatorStyle?.backgroundColor ? {
|
|
83
|
-
backgroundColor: 'transparent'
|
|
84
|
-
} : {}),
|
|
85
|
-
..._style.default['components-inline-color--is-active']
|
|
86
|
-
};
|
|
87
|
-
const customContainerStyles = _style.default['components-inline-color__button-container'];
|
|
88
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
89
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockControls, {
|
|
90
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.ToolbarGroup, {
|
|
91
|
-
children: [isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
92
|
-
style: outlineStyle,
|
|
93
|
-
pointerEvents: "none"
|
|
94
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
|
|
95
|
-
name: "text-color",
|
|
96
|
-
isActive: isActive,
|
|
97
|
-
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
98
|
-
icon: Object.keys(activeAttributes).length ? _icons.textColor : _icons.color,
|
|
99
|
-
style: colorIndicatorStyle?.color && {
|
|
100
|
-
color: colorIndicatorStyle.color
|
|
101
|
-
}
|
|
102
|
-
}),
|
|
103
|
-
title: title,
|
|
104
|
-
extraProps: {
|
|
105
|
-
isActiveStyle,
|
|
106
|
-
customContainerStyles
|
|
107
|
-
}
|
|
108
|
-
// If has no colors to choose but a color is active remove the color onClick
|
|
109
|
-
,
|
|
110
|
-
onClick: hasColorsToChoose ? () => setIsAddingColor(true) : () => onChange((0, _richText.removeFormat)(value, name))
|
|
111
|
-
})]
|
|
112
|
-
})
|
|
113
|
-
}), isAddingColor && /*#__PURE__*/(0, _jsxRuntime.jsx)(_inline.default, {
|
|
114
|
-
name: name,
|
|
115
|
-
onClose: () => setIsAddingColor(false),
|
|
116
|
-
activeAttributes: activeAttributes,
|
|
117
|
-
value: value,
|
|
118
|
-
onChange: onChange,
|
|
119
|
-
contentRef: contentRef
|
|
120
|
-
})]
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
const textColor = exports.textColor = {
|
|
124
|
-
name,
|
|
125
|
-
title,
|
|
126
|
-
tagName: 'mark',
|
|
127
|
-
className: 'has-inline-color',
|
|
128
|
-
attributes: {
|
|
129
|
-
style: 'style',
|
|
130
|
-
class: 'class'
|
|
131
|
-
},
|
|
132
|
-
edit: TextColorEdit
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","colorIndicatorStyle","useMemo","getActiveColors","hasColorsToChoose","length","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","removeFormat","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 { 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: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,MAAA,GAAAD,sBAAA,CAAAV,OAAA;AAAkC,IAAAY,WAAA,GAAAZ,OAAA;AA7BlC;AACA;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|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = InlineColorUI;
|
|
7
|
-
exports.getActiveColors = getActiveColors;
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
var _richText = require("@wordpress/rich-text");
|
|
10
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
var _components = require("@wordpress/components");
|
|
12
|
-
var _index = require("./index.js");
|
|
13
|
-
var _inline = require("./inline.js");
|
|
14
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
/**
|
|
16
|
-
* WordPress dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
function parseCSS(css = '') {
|
|
24
|
-
return css.split(';').reduce((accumulator, rule) => {
|
|
25
|
-
if (rule) {
|
|
26
|
-
const [property, value] = rule.replace(/ /g, '').split(':');
|
|
27
|
-
if (property === 'color') {
|
|
28
|
-
accumulator.color = value;
|
|
29
|
-
}
|
|
30
|
-
if (property === 'background-color' && value !== _index.transparentValue) {
|
|
31
|
-
accumulator.backgroundColor = value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return accumulator;
|
|
35
|
-
}, {});
|
|
36
|
-
}
|
|
37
|
-
function getActiveColors(value, name, colorSettings) {
|
|
38
|
-
const activeColorFormat = (0, _richText.getActiveFormat)(value, name);
|
|
39
|
-
if (!activeColorFormat) {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
...parseCSS(activeColorFormat.attributes.style),
|
|
44
|
-
...(0, _inline.parseClassName)(activeColorFormat.attributes.class, colorSettings)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function setColors(value, name, colorSettings, colors, contentRef) {
|
|
48
|
-
const {
|
|
49
|
-
color,
|
|
50
|
-
backgroundColor
|
|
51
|
-
} = {
|
|
52
|
-
...getActiveColors(value, name, colorSettings),
|
|
53
|
-
...colors
|
|
54
|
-
};
|
|
55
|
-
if (!color) {
|
|
56
|
-
contentRef?.onRemoveMarkFormatting();
|
|
57
|
-
return (0, _richText.removeFormat)(value, name);
|
|
58
|
-
}
|
|
59
|
-
const styles = [];
|
|
60
|
-
const classNames = [];
|
|
61
|
-
const attributes = {};
|
|
62
|
-
if (backgroundColor) {
|
|
63
|
-
styles.push(['background-color', backgroundColor].join(':'));
|
|
64
|
-
} else {
|
|
65
|
-
// Override default browser color for mark element.
|
|
66
|
-
styles.push(['background-color', _index.transparentValue].join(':'));
|
|
67
|
-
}
|
|
68
|
-
if (color) {
|
|
69
|
-
const colorObject = (0, _blockEditor.getColorObjectByColorValue)(colorSettings, color);
|
|
70
|
-
if (colorObject) {
|
|
71
|
-
classNames.push((0, _blockEditor.getColorClassName)('color', colorObject.slug));
|
|
72
|
-
styles.push(['color', colorObject.color].join(':'));
|
|
73
|
-
} else {
|
|
74
|
-
styles.push(['color', color].join(':'));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (styles.length) {
|
|
78
|
-
attributes.style = styles.join(';');
|
|
79
|
-
}
|
|
80
|
-
if (classNames.length) {
|
|
81
|
-
attributes.class = classNames.join(' ');
|
|
82
|
-
}
|
|
83
|
-
const format = {
|
|
84
|
-
type: name,
|
|
85
|
-
attributes
|
|
86
|
-
};
|
|
87
|
-
const hasNoSelection = value.start === value.end;
|
|
88
|
-
if (hasNoSelection) {
|
|
89
|
-
contentRef?.onMarkFormatting(color);
|
|
90
|
-
}
|
|
91
|
-
return (0, _richText.applyFormat)(value, format);
|
|
92
|
-
}
|
|
93
|
-
function ColorPicker({
|
|
94
|
-
name,
|
|
95
|
-
value,
|
|
96
|
-
onChange,
|
|
97
|
-
contentRef
|
|
98
|
-
}) {
|
|
99
|
-
const property = 'color';
|
|
100
|
-
const colors = (0, _blockEditor.useMobileGlobalStylesColors)();
|
|
101
|
-
const colorSettings = (0, _blockEditor.useMultipleOriginColorsAndGradients)();
|
|
102
|
-
colorSettings.allAvailableColors = colors;
|
|
103
|
-
const onColorChange = (0, _element.useCallback)(color => {
|
|
104
|
-
onChange(setColors(value, name, colors, {
|
|
105
|
-
[property]: color
|
|
106
|
-
}, contentRef));
|
|
107
|
-
}, [colors, contentRef, name, onChange, value]);
|
|
108
|
-
const activeColors = (0, _element.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]);
|
|
109
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ColorSettings, {
|
|
110
|
-
colorValue: activeColors[property],
|
|
111
|
-
onColorChange: onColorChange,
|
|
112
|
-
onColorCleared: onColorChange,
|
|
113
|
-
defaultSettings: colorSettings,
|
|
114
|
-
hideNavigation: true
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function InlineColorUI({
|
|
118
|
-
name,
|
|
119
|
-
value,
|
|
120
|
-
onChange,
|
|
121
|
-
onClose,
|
|
122
|
-
contentRef
|
|
123
|
-
}) {
|
|
124
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BottomSheet, {
|
|
125
|
-
isVisible: true,
|
|
126
|
-
onClose: onClose,
|
|
127
|
-
hideHeader: true,
|
|
128
|
-
contentStyle: {
|
|
129
|
-
paddingLeft: 0,
|
|
130
|
-
paddingRight: 0
|
|
131
|
-
},
|
|
132
|
-
hasNavigation: true,
|
|
133
|
-
leftButton: null,
|
|
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
|
-
});
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=inline.native.js.map
|