@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,65 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var inline_exports = {};
|
|
19
|
+
__export(inline_exports, {
|
|
20
|
+
default: () => InlineColorUI,
|
|
21
|
+
getActiveColors: () => getActiveColors,
|
|
22
|
+
parseClassName: () => parseClassName
|
|
5
23
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
Tabs
|
|
28
|
-
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
29
|
-
const TABS = [{
|
|
30
|
-
name: 'color',
|
|
31
|
-
title: (0, _i18n.__)('Text')
|
|
32
|
-
}, {
|
|
33
|
-
name: 'backgroundColor',
|
|
34
|
-
title: (0, _i18n.__)('Background')
|
|
35
|
-
}];
|
|
36
|
-
function parseCSS(css = '') {
|
|
37
|
-
return css.split(';').reduce((accumulator, rule) => {
|
|
24
|
+
module.exports = __toCommonJS(inline_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_element = require("@wordpress/element");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
29
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
30
|
+
var import_components = require("@wordpress/components");
|
|
31
|
+
var import_i18n = require("@wordpress/i18n");
|
|
32
|
+
var import_index = require("./index");
|
|
33
|
+
var import_lock_unlock = require("../lock-unlock");
|
|
34
|
+
const { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
35
|
+
const TABS = [
|
|
36
|
+
{ name: "color", title: (0, import_i18n.__)("Text") },
|
|
37
|
+
{ name: "backgroundColor", title: (0, import_i18n.__)("Background") }
|
|
38
|
+
];
|
|
39
|
+
function parseCSS(css = "") {
|
|
40
|
+
return css.split(";").reduce((accumulator, rule) => {
|
|
38
41
|
if (rule) {
|
|
39
|
-
const [property, value] = rule.split(
|
|
40
|
-
if (property ===
|
|
42
|
+
const [property, value] = rule.split(":");
|
|
43
|
+
if (property === "color") {
|
|
41
44
|
accumulator.color = value;
|
|
42
45
|
}
|
|
43
|
-
if (property ===
|
|
46
|
+
if (property === "background-color" && value !== import_index.transparentValue) {
|
|
44
47
|
accumulator.backgroundColor = value;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
return accumulator;
|
|
48
51
|
}, {});
|
|
49
52
|
}
|
|
50
|
-
function parseClassName(className =
|
|
51
|
-
return className.split(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
53
|
+
function parseClassName(className = "", colorSettings) {
|
|
54
|
+
return className.split(" ").reduce((accumulator, name) => {
|
|
55
|
+
if (name.startsWith("has-") && name.endsWith("-color")) {
|
|
56
|
+
const colorSlug = name.replace(/^has-/, "").replace(/-color$/, "");
|
|
57
|
+
const colorObject = (0, import_block_editor.getColorObjectByAttributeValues)(
|
|
58
|
+
colorSettings,
|
|
59
|
+
colorSlug
|
|
60
|
+
);
|
|
56
61
|
accumulator.color = colorObject.color;
|
|
57
62
|
}
|
|
58
63
|
return accumulator;
|
|
59
64
|
}, {});
|
|
60
65
|
}
|
|
61
66
|
function getActiveColors(value, name, colorSettings) {
|
|
62
|
-
const activeColorFormat = (0,
|
|
67
|
+
const activeColorFormat = (0, import_rich_text.getActiveFormat)(value, name);
|
|
63
68
|
if (!activeColorFormat) {
|
|
64
69
|
return {};
|
|
65
70
|
}
|
|
@@ -69,70 +74,59 @@ function getActiveColors(value, name, colorSettings) {
|
|
|
69
74
|
};
|
|
70
75
|
}
|
|
71
76
|
function setColors(value, name, colorSettings, colors) {
|
|
72
|
-
const {
|
|
73
|
-
color,
|
|
74
|
-
backgroundColor
|
|
75
|
-
} = {
|
|
77
|
+
const { color, backgroundColor } = {
|
|
76
78
|
...getActiveColors(value, name, colorSettings),
|
|
77
79
|
...colors
|
|
78
80
|
};
|
|
79
81
|
if (!color && !backgroundColor) {
|
|
80
|
-
return (0,
|
|
82
|
+
return (0, import_rich_text.removeFormat)(value, name);
|
|
81
83
|
}
|
|
82
84
|
const styles = [];
|
|
83
85
|
const classNames = [];
|
|
84
86
|
const attributes = {};
|
|
85
87
|
if (backgroundColor) {
|
|
86
|
-
styles.push([
|
|
88
|
+
styles.push(["background-color", backgroundColor].join(":"));
|
|
87
89
|
} else {
|
|
88
|
-
|
|
89
|
-
styles.push(['background-color', _index.transparentValue].join(':'));
|
|
90
|
+
styles.push(["background-color", import_index.transparentValue].join(":"));
|
|
90
91
|
}
|
|
91
92
|
if (color) {
|
|
92
|
-
const colorObject = (0,
|
|
93
|
+
const colorObject = (0, import_block_editor.getColorObjectByColorValue)(colorSettings, color);
|
|
93
94
|
if (colorObject) {
|
|
94
|
-
classNames.push((0,
|
|
95
|
+
classNames.push((0, import_block_editor.getColorClassName)("color", colorObject.slug));
|
|
95
96
|
} else {
|
|
96
|
-
styles.push([
|
|
97
|
+
styles.push(["color", color].join(":"));
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
if (styles.length) {
|
|
100
|
-
attributes.style = styles.join(
|
|
101
|
+
attributes.style = styles.join(";");
|
|
101
102
|
}
|
|
102
103
|
if (classNames.length) {
|
|
103
|
-
attributes.class = classNames.join(
|
|
104
|
+
attributes.class = classNames.join(" ");
|
|
104
105
|
}
|
|
105
|
-
return (0,
|
|
106
|
-
type: name,
|
|
107
|
-
attributes
|
|
108
|
-
});
|
|
106
|
+
return (0, import_rich_text.applyFormat)(value, { type: name, attributes });
|
|
109
107
|
}
|
|
110
|
-
function ColorPicker({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
onChange
|
|
115
|
-
}) {
|
|
116
|
-
const colors = (0, _data.useSelect)(select => {
|
|
117
|
-
var _getSettings$colors;
|
|
118
|
-
const {
|
|
119
|
-
getSettings
|
|
120
|
-
} = select(_blockEditor.store);
|
|
121
|
-
return (_getSettings$colors = getSettings().colors) !== null && _getSettings$colors !== void 0 ? _getSettings$colors : [];
|
|
108
|
+
function ColorPicker({ name, property, value, onChange }) {
|
|
109
|
+
const colors = (0, import_data.useSelect)((select) => {
|
|
110
|
+
const { getSettings } = select(import_block_editor.store);
|
|
111
|
+
return getSettings().colors ?? [];
|
|
122
112
|
}, []);
|
|
123
|
-
const activeColors = (0,
|
|
124
|
-
|
|
125
|
-
value
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
113
|
+
const activeColors = (0, import_element.useMemo)(
|
|
114
|
+
() => getActiveColors(value, name, colors),
|
|
115
|
+
[name, value, colors]
|
|
116
|
+
);
|
|
117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_block_editor.ColorPalette,
|
|
119
|
+
{
|
|
120
|
+
value: activeColors[property],
|
|
121
|
+
onChange: (color) => {
|
|
122
|
+
onChange(
|
|
123
|
+
setColors(value, name, colors, { [property]: color })
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
enableAlpha: true,
|
|
127
|
+
__experimentalIsRenderedInSidebar: true
|
|
128
|
+
}
|
|
129
|
+
);
|
|
136
130
|
}
|
|
137
131
|
function InlineColorUI({
|
|
138
132
|
name,
|
|
@@ -142,34 +136,42 @@ function InlineColorUI({
|
|
|
142
136
|
contentRef,
|
|
143
137
|
isActive
|
|
144
138
|
}) {
|
|
145
|
-
const popoverAnchor = (0,
|
|
139
|
+
const popoverAnchor = (0, import_rich_text.useAnchor)({
|
|
146
140
|
editableContentElement: contentRef.current,
|
|
147
|
-
settings: {
|
|
148
|
-
..._index.textColor,
|
|
149
|
-
isActive
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Popover, {
|
|
153
|
-
onClose: onClose,
|
|
154
|
-
className: "format-library__inline-color-popover",
|
|
155
|
-
anchor: popoverAnchor,
|
|
156
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Tabs, {
|
|
157
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabList, {
|
|
158
|
-
children: TABS.map(tab => /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.Tab, {
|
|
159
|
-
tabId: tab.name,
|
|
160
|
-
children: tab.title
|
|
161
|
-
}, tab.name))
|
|
162
|
-
}), TABS.map(tab => /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabPanel, {
|
|
163
|
-
tabId: tab.name,
|
|
164
|
-
focusable: false,
|
|
165
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorPicker, {
|
|
166
|
-
name: name,
|
|
167
|
-
property: tab.name,
|
|
168
|
-
value: value,
|
|
169
|
-
onChange: onChange
|
|
170
|
-
})
|
|
171
|
-
}, tab.name))]
|
|
172
|
-
})
|
|
141
|
+
settings: { ...import_index.textColor, isActive }
|
|
173
142
|
});
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_components.Popover,
|
|
145
|
+
{
|
|
146
|
+
onClose,
|
|
147
|
+
className: "format-library__inline-color-popover",
|
|
148
|
+
anchor: popoverAnchor,
|
|
149
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs, { children: [
|
|
150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabList, { children: TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: tab.name, children: tab.title }, tab.name)) }),
|
|
151
|
+
TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
+
Tabs.TabPanel,
|
|
153
|
+
{
|
|
154
|
+
tabId: tab.name,
|
|
155
|
+
focusable: false,
|
|
156
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
157
|
+
ColorPicker,
|
|
158
|
+
{
|
|
159
|
+
name,
|
|
160
|
+
property: tab.name,
|
|
161
|
+
value,
|
|
162
|
+
onChange
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
tab.name
|
|
167
|
+
))
|
|
168
|
+
] })
|
|
169
|
+
}
|
|
170
|
+
);
|
|
174
171
|
}
|
|
175
|
-
|
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
173
|
+
0 && (module.exports = {
|
|
174
|
+
getActiveColors,
|
|
175
|
+
parseClassName
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=inline.js.map
|
|
@@ -1 +1,7 @@
|
|
|
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","activeColors","useMemo","jsx","ColorPalette","enableAlpha","__experimentalIsRenderedInSidebar","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 { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ ( color ) => {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t} }\n\t\t\tenableAlpha\n\t\t\t// Prevent the text and color picker from overlapping.\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t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AAAO,QAAA,eAExB,IAAAvE,WAAA,CAAAwE,IAAA,EAACvE,IAAI;MAAAsE,QAAA,gBACJ,IAAAvE,WAAA,CAAAwD,GAAA,EAACvD,IAAI,CAACwE,OAAO;QAAAF,QAAA,EACVnE,IAAI,CAACsE,GAAG,CAAIC,GAAG,iBAChB,IAAA3E,WAAA,CAAAwD,GAAA,EAACvD,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,CAAAwD,GAAA,EAACvD,IAAI,CAAC6E,QAAQ;QACbD,KAAK,EAAGF,GAAG,CAACtE,IAAM;QAClB0E,SAAS,EAAG,KAAO;QAAAR,QAAA,eAGnB,IAAAvE,WAAA,CAAAwD,GAAA,EAACT,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":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/text-color/inline.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ ( color ) => {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t} }\n\t\t\tenableAlpha\n\t\t\t// Prevent the text and color picker from overlapping.\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyIE;AAtIF,qBAAwB;AACxB,kBAA0B;AAC1B,uBAKO;AACP,0BAMO;AACP,wBAGO;AACP,kBAAmB;AAKnB,mBAAwD;AACxD,yBAAuB;AAEvB,MAAM,EAAE,KAAK,QAAI,2BAAQ,kBAAAA,WAAsB;AAE/C,MAAM,OAAO;AAAA,EACZ,EAAE,MAAM,SAAS,WAAO,gBAAI,MAAO,EAAE;AAAA,EACrC,EAAE,MAAM,mBAAmB,WAAO,gBAAI,YAAa,EAAE;AACtD;AAEA,SAAS,SAAU,MAAM,IAAK;AAC7B,SAAO,IAAI,MAAO,GAAI,EAAE,OAAQ,CAAE,aAAa,SAAU;AACxD,QAAK,MAAO;AACX,YAAM,CAAE,UAAU,KAAM,IAAI,KAAK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AAwB,WAAW;AAAA,IACnC,UAAU,EAAE,GAAG,aAAAC,WAAU,SAAS;AAAA,EACnC,CAAE;AAEF,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,WAAU;AAAA,MACV,QAAS;AAAA,MAET,uDAAC,QACA;AAAA,oDAAC,KAAK,SAAL,EACE,eAAK,IAAK,CAAE,QACb,4CAAC,KAAK,KAAL,EAAS,OAAQ,IAAI,MACnB,cAAI,SAD4B,IAAI,IAEvC,CACC,GACH;AAAA,QACE,KAAK,IAAK,CAAE,QACb;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACA,OAAQ,IAAI;AAAA,YACZ,WAAY;AAAA,YAGZ;AAAA,cAAC;AAAA;AAAA,gBACA;AAAA,gBACA,UAAW,IAAI;AAAA,gBACf;AAAA,gBACA;AAAA;AAAA,YACD;AAAA;AAAA,UAPM,IAAI;AAAA,QAQX,CACC;AAAA,SACH;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["componentsPrivateApis", "blockEditorStore", "settings"]
|
|
7
|
+
}
|
package/build/underline/index.js
CHANGED
|
@@ -1,50 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name2 in all)
|
|
7
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var underline_exports = {};
|
|
19
|
+
__export(underline_exports, {
|
|
20
|
+
underline: () => underline
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const name = 'core/underline';
|
|
16
|
-
const title = (0, _i18n.__)('Underline');
|
|
17
|
-
const underline = exports.underline = {
|
|
22
|
+
module.exports = __toCommonJS(underline_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_i18n = require("@wordpress/i18n");
|
|
25
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
26
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
27
|
+
const name = "core/underline";
|
|
28
|
+
const title = (0, import_i18n.__)("Underline");
|
|
29
|
+
const underline = {
|
|
18
30
|
name,
|
|
19
31
|
title,
|
|
20
|
-
tagName:
|
|
32
|
+
tagName: "span",
|
|
21
33
|
className: null,
|
|
22
34
|
attributes: {
|
|
23
|
-
style:
|
|
35
|
+
style: "style"
|
|
24
36
|
},
|
|
25
|
-
edit({
|
|
26
|
-
value,
|
|
27
|
-
onChange
|
|
28
|
-
}) {
|
|
37
|
+
edit({ value, onChange }) {
|
|
29
38
|
const onToggle = () => {
|
|
30
|
-
onChange(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
onChange(
|
|
40
|
+
(0, import_rich_text.toggleFormat)(value, {
|
|
41
|
+
type: name,
|
|
42
|
+
attributes: {
|
|
43
|
+
style: "text-decoration: underline;"
|
|
44
|
+
},
|
|
45
|
+
title
|
|
46
|
+
})
|
|
47
|
+
);
|
|
37
48
|
};
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
50
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_block_editor.RichTextShortcut,
|
|
52
|
+
{
|
|
53
|
+
type: "primary",
|
|
54
|
+
character: "u",
|
|
55
|
+
onUse: onToggle
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
import_block_editor.__unstableRichTextInputEvent,
|
|
60
|
+
{
|
|
61
|
+
inputType: "formatUnderline",
|
|
62
|
+
onInput: onToggle
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] });
|
|
48
66
|
}
|
|
49
67
|
};
|
|
50
|
-
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
underline
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/underline/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCG;AAhCH,kBAAmB;AACnB,uBAA6B;AAC7B,0BAGO;AAEP,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,WAAY;AAEvB,MAAM,YAAY;AAAA,EACxB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,OAAO;AAAA,EACR;AAAA,EACA,KAAM,EAAE,OAAO,SAAS,GAAI;AAC3B,UAAM,WAAW,MAAM;AACtB;AAAA,YACC,+BAAc,OAAO;AAAA,UACpB,MAAM;AAAA,UACN,YAAY;AAAA,YACX,OAAO;AAAA,UACR;AAAA,UACA;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAEA,WACC,4EACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ;AAAA;AAAA,MACT;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/unknown/index.js
CHANGED
|
@@ -1,54 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name2 in all)
|
|
7
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var unknown_exports = {};
|
|
19
|
+
__export(unknown_exports, {
|
|
20
|
+
unknown: () => unknown
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const name = 'core/unknown';
|
|
17
|
-
const title = (0, _i18n.__)('Clear Unknown Formatting');
|
|
22
|
+
module.exports = __toCommonJS(unknown_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_i18n = require("@wordpress/i18n");
|
|
25
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
26
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
27
|
+
var import_icons = require("@wordpress/icons");
|
|
28
|
+
const name = "core/unknown";
|
|
29
|
+
const title = (0, import_i18n.__)("Clear Unknown Formatting");
|
|
18
30
|
function selectionContainsUnknownFormats(value) {
|
|
19
|
-
if ((0,
|
|
31
|
+
if ((0, import_rich_text.isCollapsed)(value)) {
|
|
20
32
|
return false;
|
|
21
33
|
}
|
|
22
|
-
const selectedValue = (0,
|
|
23
|
-
return selectedValue.formats.some(formats => {
|
|
24
|
-
return formats.some(format => format.type === name);
|
|
34
|
+
const selectedValue = (0, import_rich_text.slice)(value);
|
|
35
|
+
return selectedValue.formats.some((formats) => {
|
|
36
|
+
return formats.some((format) => format.type === name);
|
|
25
37
|
});
|
|
26
38
|
}
|
|
27
|
-
const unknown =
|
|
39
|
+
const unknown = {
|
|
28
40
|
name,
|
|
29
41
|
title,
|
|
30
|
-
tagName:
|
|
42
|
+
tagName: "*",
|
|
31
43
|
className: null,
|
|
32
|
-
edit({
|
|
33
|
-
isActive,
|
|
34
|
-
value,
|
|
35
|
-
onChange,
|
|
36
|
-
onFocus
|
|
37
|
-
}) {
|
|
44
|
+
edit({ isActive, value, onChange, onFocus }) {
|
|
38
45
|
if (!isActive && !selectionContainsUnknownFormats(value)) {
|
|
39
46
|
return null;
|
|
40
47
|
}
|
|
41
48
|
function onClick() {
|
|
42
|
-
onChange((0,
|
|
49
|
+
onChange((0, import_rich_text.removeFormat)(value, name));
|
|
43
50
|
onFocus();
|
|
44
51
|
}
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
import_block_editor.RichTextToolbarButton,
|
|
54
|
+
{
|
|
55
|
+
name: "unknown",
|
|
56
|
+
icon: import_icons.help,
|
|
57
|
+
title,
|
|
58
|
+
onClick,
|
|
59
|
+
isActive: true
|
|
60
|
+
}
|
|
61
|
+
);
|
|
52
62
|
}
|
|
53
63
|
};
|
|
54
|
-
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
unknown
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/unknown/index.js"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCG;AAnCH,kBAAmB;AACnB,uBAAiD;AACjD,0BAAsC;AACtC,mBAAqB;AAErB,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,0BAA2B;AAE7C,SAAS,gCAAiC,OAAQ;AACjD,UAAK,8BAAa,KAAM,GAAI;AAC3B,WAAO;AAAA,EACR;AAEA,QAAM,oBAAgB,wBAAO,KAAM;AACnC,SAAO,cAAc,QAAQ,KAAM,CAAE,YAAa;AACjD,WAAO,QAAQ,KAAM,CAAE,WAAY,OAAO,SAAS,IAAK;AAAA,EACzD,CAAE;AACH;AAEO,MAAM,UAAU;AAAA,EACtB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,QAAK,CAAE,YAAY,CAAE,gCAAiC,KAAM,GAAI;AAC/D,aAAO;AAAA,IACR;AAEA,aAAS,UAAU;AAClB,mBAAU,+BAAc,OAAO,IAAK,CAAE;AACtC,cAAQ;AAAA,IACT;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA,UAAQ;AAAA;AAAA,IACT;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|