@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
package/build/subscript/index.js
CHANGED
|
@@ -1,48 +1,59 @@
|
|
|
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 subscript_exports = {};
|
|
19
|
+
__export(subscript_exports, {
|
|
20
|
+
subscript: () => subscript
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const name = 'core/subscript';
|
|
17
|
-
const title = (0, _i18n.__)('Subscript');
|
|
18
|
-
const subscript = exports.subscript = {
|
|
22
|
+
module.exports = __toCommonJS(subscript_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/subscript";
|
|
29
|
+
const title = (0, import_i18n.__)("Subscript");
|
|
30
|
+
const subscript = {
|
|
19
31
|
name,
|
|
20
32
|
title,
|
|
21
|
-
tagName:
|
|
33
|
+
tagName: "sub",
|
|
22
34
|
className: null,
|
|
23
|
-
edit({
|
|
24
|
-
isActive,
|
|
25
|
-
value,
|
|
26
|
-
onChange,
|
|
27
|
-
onFocus
|
|
28
|
-
}) {
|
|
35
|
+
edit({ isActive, value, onChange, onFocus }) {
|
|
29
36
|
function onToggle() {
|
|
30
|
-
onChange((0,
|
|
31
|
-
type: name,
|
|
32
|
-
title
|
|
33
|
-
}));
|
|
37
|
+
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title }));
|
|
34
38
|
}
|
|
35
39
|
function onClick() {
|
|
36
40
|
onToggle();
|
|
37
41
|
onFocus();
|
|
38
42
|
}
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
import_block_editor.RichTextToolbarButton,
|
|
45
|
+
{
|
|
46
|
+
icon: import_icons.subscript,
|
|
47
|
+
title,
|
|
48
|
+
onClick,
|
|
49
|
+
isActive,
|
|
50
|
+
role: "menuitemcheckbox"
|
|
51
|
+
}
|
|
52
|
+
);
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
|
-
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
subscript
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/subscript/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BG;AAxBH,kBAAmB;AACnB,uBAA6B;AAC7B,0BAAsC;AACtC,mBAA2C;AAE3C,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,WAAY;AAEvB,MAAM,YAAY;AAAA,EACxB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,aAAS,WAAW;AACnB,mBAAU,+BAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,eAAS;AACT,cAAQ;AAAA,IACT;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAO,aAAAA;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAK;AAAA;AAAA,IACN;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": ["subscriptIcon"]
|
|
7
|
+
}
|
|
@@ -1,48 +1,59 @@
|
|
|
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 superscript_exports = {};
|
|
19
|
+
__export(superscript_exports, {
|
|
20
|
+
superscript: () => superscript
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const name = 'core/superscript';
|
|
17
|
-
const title = (0, _i18n.__)('Superscript');
|
|
18
|
-
const superscript = exports.superscript = {
|
|
22
|
+
module.exports = __toCommonJS(superscript_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/superscript";
|
|
29
|
+
const title = (0, import_i18n.__)("Superscript");
|
|
30
|
+
const superscript = {
|
|
19
31
|
name,
|
|
20
32
|
title,
|
|
21
|
-
tagName:
|
|
33
|
+
tagName: "sup",
|
|
22
34
|
className: null,
|
|
23
|
-
edit({
|
|
24
|
-
isActive,
|
|
25
|
-
value,
|
|
26
|
-
onChange,
|
|
27
|
-
onFocus
|
|
28
|
-
}) {
|
|
35
|
+
edit({ isActive, value, onChange, onFocus }) {
|
|
29
36
|
function onToggle() {
|
|
30
|
-
onChange((0,
|
|
31
|
-
type: name,
|
|
32
|
-
title
|
|
33
|
-
}));
|
|
37
|
+
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title }));
|
|
34
38
|
}
|
|
35
39
|
function onClick() {
|
|
36
40
|
onToggle();
|
|
37
41
|
onFocus();
|
|
38
42
|
}
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
import_block_editor.RichTextToolbarButton,
|
|
45
|
+
{
|
|
46
|
+
icon: import_icons.superscript,
|
|
47
|
+
title,
|
|
48
|
+
onClick,
|
|
49
|
+
isActive,
|
|
50
|
+
role: "menuitemcheckbox"
|
|
51
|
+
}
|
|
52
|
+
);
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
|
-
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
superscript
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/superscript/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BG;AAxBH,kBAAmB;AACnB,uBAA6B;AAC7B,0BAAsC;AACtC,mBAA+C;AAE/C,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,aAAc;AAEzB,MAAM,cAAc;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,aAAS,WAAW;AACnB,mBAAU,+BAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,eAAS;AACT,cAAQ;AAAA,IACT;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAO,aAAAA;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAK;AAAA;AAAA,IACN;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": ["superscriptIcon"]
|
|
7
|
+
}
|
|
@@ -1,54 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name2 in all)
|
|
9
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var text_color_exports = {};
|
|
29
|
+
__export(text_color_exports, {
|
|
30
|
+
textColor: () => textColor,
|
|
31
|
+
transparentValue: () => transparentValue
|
|
5
32
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const transparentValue = exports.transparentValue = 'rgba(0, 0, 0, 0)';
|
|
25
|
-
const name = 'core/text-color';
|
|
26
|
-
const title = (0, _i18n.__)('Highlight');
|
|
33
|
+
module.exports = __toCommonJS(text_color_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_i18n = require("@wordpress/i18n");
|
|
36
|
+
var import_element = require("@wordpress/element");
|
|
37
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
38
|
+
var import_icons = require("@wordpress/icons");
|
|
39
|
+
var import_rich_text = require("@wordpress/rich-text");
|
|
40
|
+
var import_inline = __toESM(require("./inline"));
|
|
41
|
+
const transparentValue = "rgba(0, 0, 0, 0)";
|
|
42
|
+
const name = "core/text-color";
|
|
43
|
+
const title = (0, import_i18n.__)("Highlight");
|
|
27
44
|
const EMPTY_ARRAY = [];
|
|
28
45
|
function getComputedStyleProperty(element, property) {
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
} = element;
|
|
32
|
-
const {
|
|
33
|
-
defaultView
|
|
34
|
-
} = ownerDocument;
|
|
46
|
+
const { ownerDocument } = element;
|
|
47
|
+
const { defaultView } = ownerDocument;
|
|
35
48
|
const style = defaultView.getComputedStyle(element);
|
|
36
49
|
const value = style.getPropertyValue(property);
|
|
37
|
-
if (property ===
|
|
50
|
+
if (property === "background-color" && value === transparentValue && element.parentElement) {
|
|
38
51
|
return getComputedStyleProperty(element.parentElement, property);
|
|
39
52
|
}
|
|
40
53
|
return value;
|
|
41
54
|
}
|
|
42
|
-
function fillComputedColors(element, {
|
|
43
|
-
color,
|
|
44
|
-
backgroundColor
|
|
45
|
-
}) {
|
|
55
|
+
function fillComputedColors(element, { color, backgroundColor }) {
|
|
46
56
|
if (!color && !backgroundColor) {
|
|
47
57
|
return;
|
|
48
58
|
}
|
|
49
59
|
return {
|
|
50
|
-
color: color || getComputedStyleProperty(element,
|
|
51
|
-
backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element,
|
|
60
|
+
color: color || getComputedStyleProperty(element, "color"),
|
|
61
|
+
backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, "background-color") : backgroundColor
|
|
52
62
|
};
|
|
53
63
|
}
|
|
54
64
|
function TextColorEdit({
|
|
@@ -58,46 +68,68 @@ function TextColorEdit({
|
|
|
58
68
|
activeAttributes,
|
|
59
69
|
contentRef
|
|
60
70
|
}) {
|
|
61
|
-
const [allowCustomControl, colors = EMPTY_ARRAY] = (0,
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
const [allowCustomControl, colors = EMPTY_ARRAY] = (0, import_block_editor.useSettings)(
|
|
72
|
+
"color.custom",
|
|
73
|
+
"color.palette"
|
|
74
|
+
);
|
|
75
|
+
const [isAddingColor, setIsAddingColor] = (0, import_element.useState)(false);
|
|
76
|
+
const colorIndicatorStyle = (0, import_element.useMemo)(
|
|
77
|
+
() => fillComputedColors(
|
|
78
|
+
contentRef.current,
|
|
79
|
+
(0, import_inline.getActiveColors)(value, name, colors)
|
|
80
|
+
),
|
|
81
|
+
[contentRef, value, colors]
|
|
82
|
+
);
|
|
64
83
|
const hasColorsToChoose = !!colors.length || allowCustomControl;
|
|
65
84
|
if (!hasColorsToChoose && !isActive) {
|
|
66
85
|
return null;
|
|
67
86
|
}
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
import_block_editor.RichTextToolbarButton,
|
|
90
|
+
{
|
|
91
|
+
className: "format-library-text-color-button",
|
|
92
|
+
isActive,
|
|
93
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
|
+
import_icons.Icon,
|
|
95
|
+
{
|
|
96
|
+
icon: Object.keys(activeAttributes).length ? import_icons.textColor : import_icons.color,
|
|
97
|
+
style: colorIndicatorStyle
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
title,
|
|
101
|
+
onClick: hasColorsToChoose ? () => setIsAddingColor(true) : () => onChange((0, import_rich_text.removeFormat)(value, name)),
|
|
102
|
+
role: "menuitemcheckbox"
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
isAddingColor && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
import_inline.default,
|
|
107
|
+
{
|
|
108
|
+
name,
|
|
109
|
+
onClose: () => setIsAddingColor(false),
|
|
110
|
+
activeAttributes,
|
|
111
|
+
value,
|
|
112
|
+
onChange,
|
|
113
|
+
contentRef,
|
|
114
|
+
isActive
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] });
|
|
91
118
|
}
|
|
92
|
-
const textColor =
|
|
119
|
+
const textColor = {
|
|
93
120
|
name,
|
|
94
121
|
title,
|
|
95
|
-
tagName:
|
|
96
|
-
className:
|
|
122
|
+
tagName: "mark",
|
|
123
|
+
className: "has-inline-color",
|
|
97
124
|
attributes: {
|
|
98
|
-
style:
|
|
99
|
-
class:
|
|
125
|
+
style: "style",
|
|
126
|
+
class: "class"
|
|
100
127
|
},
|
|
101
128
|
edit: TextColorEdit
|
|
102
129
|
};
|
|
103
|
-
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
textColor,
|
|
133
|
+
transparentValue
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/text-color/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { 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 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[ contentRef, 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? () => setIsAddingColor( true )\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={ () => 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\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmFE;AAhFF,kBAAmB;AACnB,qBAAkC;AAClC,0BAAmD;AACnD,mBAIO;AACP,uBAA6B;AAK7B,oBAA0D;AAEnD,MAAM,mBAAmB;AAEhC,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,WAAY;AAE9B,MAAM,cAAc,CAAC;AAErB,SAAS,yBAA0B,SAAS,UAAW;AACtD,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,IAAI;AACxB,QAAM,QAAQ,YAAY,iBAAkB,OAAQ;AACpD,QAAM,QAAQ,MAAM,iBAAkB,QAAS;AAE/C,MACC,aAAa,sBACb,UAAU,oBACV,QAAQ,eACP;AACD,WAAO,yBAA0B,QAAQ,eAAe,QAAS;AAAA,EAClE;AAEA,SAAO;AACR;AAEA,SAAS,mBAAoB,SAAS,EAAE,OAAO,gBAAgB,GAAI;AAClE,MAAK,CAAE,SAAS,CAAE,iBAAkB;AACnC;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO,SAAS,yBAA0B,SAAS,OAAQ;AAAA,IAC3D,iBACC,oBAAoB,mBACjB,yBAA0B,SAAS,kBAAmB,IACtD;AAAA,EACL;AACD;AAEA,SAAS,cAAe;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,oBAAoB,SAAS,WAAY,QAAI;AAAA,IACpD;AAAA,IACA;AAAA,EACD;AACA,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAU,KAAM;AAC5D,QAAM,0BAAsB;AAAA,IAC3B,MACC;AAAA,MACC,WAAW;AAAA,UACX,+BAAiB,OAAO,MAAM,MAAO;AAAA,IACtC;AAAA,IACD,CAAE,YAAY,OAAO,MAAO;AAAA,EAC7B;AAEA,QAAM,oBAAoB,CAAC,CAAE,OAAO,UAAU;AAC9C,MAAK,CAAE,qBAAqB,CAAE,UAAW;AACxC,WAAO;AAAA,EACR;AAEA,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV;AAAA,QACA,MACC;AAAA,UAAC;AAAA;AAAA,YACA,MACC,OAAO,KAAM,gBAAiB,EAAE,SAC7B,aAAAA,YACA,aAAAC;AAAA,YAEJ,OAAQ;AAAA;AAAA,QACT;AAAA,QAED;AAAA,QAEA,SACC,oBACG,MAAM,iBAAkB,IAAK,IAC7B,MAAM,aAAU,+BAAc,OAAO,IAAK,CAAE;AAAA,QAEhD,MAAK;AAAA;AAAA,IACN;AAAA,IACE,iBACD;AAAA,MAAC,cAAAC;AAAA,MAAA;AAAA,QACA;AAAA,QACA,SAAU,MAAM,iBAAkB,KAAM;AAAA,QACxC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEO,MAAM,YAAY;AAAA,EACxB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,OAAO;AAAA,IACP,OAAO;AAAA,EACR;AAAA,EACA,MAAM;AACP;",
|
|
6
|
+
"names": ["textColorIcon", "colorIcon", "InlineColorUI"]
|
|
7
|
+
}
|