@wordpress/format-library 3.20.0 → 4.1.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/CHANGELOG.md +8 -0
- package/build/default-formats.js +3 -1
- package/build/default-formats.js.map +1 -1
- package/build/unknown/index.js +62 -0
- package/build/unknown/index.js.map +1 -0
- package/build-module/default-formats.js +2 -1
- package/build-module/default-formats.js.map +1 -1
- package/build-module/unknown/index.js +52 -0
- package/build-module/unknown/index.js.map +1 -0
- package/build-style/style-rtl.css +17 -3
- package/build-style/style.css +17 -3
- package/package.json +15 -15
- package/src/default-formats.js +2 -0
- package/src/text-color/test/index.native.js +30 -42
- package/src/unknown/index.js +42 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 4.1.0 (2023-01-02)
|
|
6
|
+
|
|
7
|
+
## 4.0.0 (2022-12-14)
|
|
8
|
+
|
|
9
|
+
### Breaking Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies to require React 18 ([45235](https://github.com/WordPress/gutenberg/pull/45235))
|
|
12
|
+
|
|
5
13
|
## 3.20.0 (2022-11-16)
|
|
6
14
|
|
|
7
15
|
## 3.19.0 (2022-11-02)
|
package/build/default-formats.js
CHANGED
|
@@ -27,9 +27,11 @@ var _superscript = require("./superscript");
|
|
|
27
27
|
|
|
28
28
|
var _keyboard = require("./keyboard");
|
|
29
29
|
|
|
30
|
+
var _unknown = require("./unknown");
|
|
31
|
+
|
|
30
32
|
/**
|
|
31
33
|
* Internal dependencies
|
|
32
34
|
*/
|
|
33
|
-
var _default = [_bold.bold, _code.code, _image.image, _italic.italic, _link.link, _strikethrough.strikethrough, _underline.underline, _textColor.textColor, _subscript.subscript, _superscript.superscript, _keyboard.keyboard];
|
|
35
|
+
var _default = [_bold.bold, _code.code, _image.image, _italic.italic, _link.link, _strikethrough.strikethrough, _underline.underline, _textColor.textColor, _subscript.subscript, _superscript.superscript, _keyboard.keyboard, _unknown.unknown];
|
|
34
36
|
exports.default = _default;
|
|
35
37
|
//# sourceMappingURL=default-formats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/format-library/src/default-formats.js"],"names":["bold","code","image","italic","link","strikethrough","underline","textColor","subscript","superscript","keyboard"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/format-library/src/default-formats.js"],"names":["bold","code","image","italic","link","strikethrough","underline","textColor","subscript","superscript","keyboard","unknown"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;eAce,CACdA,UADc,EAEdC,UAFc,EAGdC,YAHc,EAIdC,cAJc,EAKdC,UALc,EAMdC,4BANc,EAOdC,oBAPc,EAQdC,oBARc,EASdC,oBATc,EAUdC,wBAVc,EAWdC,kBAXc,EAYdC,gBAZc,C","sourcesContent":["/**\n * Internal dependencies\n */\nimport { bold } from './bold';\nimport { code } from './code';\nimport { image } from './image';\nimport { italic } from './italic';\nimport { link } from './link';\nimport { strikethrough } from './strikethrough';\nimport { underline } from './underline';\nimport { textColor } from './text-color';\nimport { subscript } from './subscript';\nimport { superscript } from './superscript';\nimport { keyboard } from './keyboard';\nimport { unknown } from './unknown';\n\nexport default [\n\tbold,\n\tcode,\n\timage,\n\titalic,\n\tlink,\n\tstrikethrough,\n\tunderline,\n\ttextColor,\n\tsubscript,\n\tsuperscript,\n\tkeyboard,\n\tunknown,\n];\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unknown = void 0;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _richText = require("@wordpress/rich-text");
|
|
13
|
+
|
|
14
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
15
|
+
|
|
16
|
+
var _icons = require("@wordpress/icons");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
const name = 'core/unknown';
|
|
22
|
+
const title = (0, _i18n.__)('Clear Unknown Formatting');
|
|
23
|
+
const unknown = {
|
|
24
|
+
name,
|
|
25
|
+
title,
|
|
26
|
+
tagName: '*',
|
|
27
|
+
className: null,
|
|
28
|
+
|
|
29
|
+
edit(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
isActive,
|
|
32
|
+
value,
|
|
33
|
+
onChange,
|
|
34
|
+
onFocus
|
|
35
|
+
} = _ref;
|
|
36
|
+
|
|
37
|
+
function onClick() {
|
|
38
|
+
onChange((0, _richText.removeFormat)(value, name));
|
|
39
|
+
onFocus();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const selectedValue = (0, _richText.slice)(value);
|
|
43
|
+
const hasUnknownFormats = selectedValue.formats.some(formats => {
|
|
44
|
+
return formats.some(format => format.type === name);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!isActive && !hasUnknownFormats) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (0, _element.createElement)(_blockEditor.RichTextToolbarButton, {
|
|
52
|
+
name: "unknown",
|
|
53
|
+
icon: _icons.help,
|
|
54
|
+
title: title,
|
|
55
|
+
onClick: onClick,
|
|
56
|
+
isActive: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
};
|
|
61
|
+
exports.unknown = unknown;
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/format-library/src/unknown/index.js"],"names":["name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type","help"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,cAAb;AACA,MAAMC,KAAK,GAAG,cAAI,0BAAJ,CAAd;AAEO,MAAMC,OAAO,GAAG;AACtBF,EAAAA,IADsB;AAEtBC,EAAAA,KAFsB;AAGtBE,EAAAA,OAAO,EAAE,GAHa;AAItBC,EAAAA,SAAS,EAAE,IAJW;;AAKtBC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqBP,IAArB,CAAF,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,UAAME,aAAa,GAAG,qBAAOJ,KAAP,CAAtB;AACA,UAAMK,iBAAiB,GAAGD,aAAa,CAACE,OAAd,CAAsBC,IAAtB,CAA8BD,OAAF,IAAe;AACpE,aAAOA,OAAO,CAACC,IAAR,CAAgBC,MAAF,IAAcA,MAAM,CAACC,IAAP,KAAgBhB,IAA5C,CAAP;AACA,KAFyB,CAA1B;;AAIA,QAAK,CAAEM,QAAF,IAAc,CAAEM,iBAArB,EAAyC;AACxC,aAAO,IAAP;AACA;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,IAAI,EAAGK,WAFR;AAGC,MAAA,KAAK,EAAGhB,KAHT;AAIC,MAAA,OAAO,EAAGS,OAJX;AAKC,MAAA,QAAQ,EAAG;AALZ,MADD;AASA;;AA7BqB,CAAhB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice } 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\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\tconst selectedValue = slice( value );\n\t\tconst hasUnknownFormats = selectedValue.formats.some( ( formats ) => {\n\t\t\treturn formats.some( ( format ) => format.type === name );\n\t\t} );\n\n\t\tif ( ! isActive && ! hasUnknownFormats ) {\n\t\t\treturn null;\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={ true }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
|
|
@@ -12,5 +12,6 @@ import { textColor } from './text-color';
|
|
|
12
12
|
import { subscript } from './subscript';
|
|
13
13
|
import { superscript } from './superscript';
|
|
14
14
|
import { keyboard } from './keyboard';
|
|
15
|
-
|
|
15
|
+
import { unknown } from './unknown';
|
|
16
|
+
export default [bold, code, image, italic, link, strikethrough, underline, textColor, subscript, superscript, keyboard, unknown];
|
|
16
17
|
//# sourceMappingURL=default-formats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/format-library/src/default-formats.js"],"names":["bold","code","image","italic","link","strikethrough","underline","textColor","subscript","superscript","keyboard"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,QAAT,QAAyB,YAAzB;AAEA,eAAe,
|
|
1
|
+
{"version":3,"sources":["@wordpress/format-library/src/default-formats.js"],"names":["bold","code","image","italic","link","strikethrough","underline","textColor","subscript","superscript","keyboard","unknown"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,QAAT,QAAyB,YAAzB;AACA,SAASC,OAAT,QAAwB,WAAxB;AAEA,eAAe,CACdX,IADc,EAEdC,IAFc,EAGdC,KAHc,EAIdC,MAJc,EAKdC,IALc,EAMdC,aANc,EAOdC,SAPc,EAQdC,SARc,EASdC,SATc,EAUdC,WAVc,EAWdC,QAXc,EAYdC,OAZc,CAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { bold } from './bold';\nimport { code } from './code';\nimport { image } from './image';\nimport { italic } from './italic';\nimport { link } from './link';\nimport { strikethrough } from './strikethrough';\nimport { underline } from './underline';\nimport { textColor } from './text-color';\nimport { subscript } from './subscript';\nimport { superscript } from './superscript';\nimport { keyboard } from './keyboard';\nimport { unknown } from './unknown';\n\nexport default [\n\tbold,\n\tcode,\n\timage,\n\titalic,\n\tlink,\n\tstrikethrough,\n\tunderline,\n\ttextColor,\n\tsubscript,\n\tsuperscript,\n\tkeyboard,\n\tunknown,\n];\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { removeFormat, slice } from '@wordpress/rich-text';
|
|
8
|
+
import { RichTextToolbarButton } from '@wordpress/block-editor';
|
|
9
|
+
import { help } from '@wordpress/icons';
|
|
10
|
+
const name = 'core/unknown';
|
|
11
|
+
|
|
12
|
+
const title = __('Clear Unknown Formatting');
|
|
13
|
+
|
|
14
|
+
export const unknown = {
|
|
15
|
+
name,
|
|
16
|
+
title,
|
|
17
|
+
tagName: '*',
|
|
18
|
+
className: null,
|
|
19
|
+
|
|
20
|
+
edit(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
isActive,
|
|
23
|
+
value,
|
|
24
|
+
onChange,
|
|
25
|
+
onFocus
|
|
26
|
+
} = _ref;
|
|
27
|
+
|
|
28
|
+
function onClick() {
|
|
29
|
+
onChange(removeFormat(value, name));
|
|
30
|
+
onFocus();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const selectedValue = slice(value);
|
|
34
|
+
const hasUnknownFormats = selectedValue.formats.some(formats => {
|
|
35
|
+
return formats.some(format => format.type === name);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!isActive && !hasUnknownFormats) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return createElement(RichTextToolbarButton, {
|
|
43
|
+
name: "unknown",
|
|
44
|
+
icon: help,
|
|
45
|
+
title: title,
|
|
46
|
+
onClick: onClick,
|
|
47
|
+
isActive: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/format-library/src/unknown/index.js"],"names":["__","removeFormat","slice","RichTextToolbarButton","help","name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,EAAuBC,KAAvB,QAAoC,sBAApC;AACA,SAASC,qBAAT,QAAsC,yBAAtC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA,MAAMC,IAAI,GAAG,cAAb;;AACA,MAAMC,KAAK,GAAGN,EAAE,CAAE,0BAAF,CAAhB;;AAEA,OAAO,MAAMO,OAAO,GAAG;AACtBF,EAAAA,IADsB;AAEtBC,EAAAA,KAFsB;AAGtBE,EAAAA,OAAO,EAAE,GAHa;AAItBC,EAAAA,SAAS,EAAE,IAJW;;AAKtBC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAEZ,YAAY,CAAEW,KAAF,EAASP,IAAT,CAAd,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,UAAME,aAAa,GAAGd,KAAK,CAAEU,KAAF,CAA3B;AACA,UAAMK,iBAAiB,GAAGD,aAAa,CAACE,OAAd,CAAsBC,IAAtB,CAA8BD,OAAF,IAAe;AACpE,aAAOA,OAAO,CAACC,IAAR,CAAgBC,MAAF,IAAcA,MAAM,CAACC,IAAP,KAAgBhB,IAA5C,CAAP;AACA,KAFyB,CAA1B;;AAIA,QAAK,CAAEM,QAAF,IAAc,CAAEM,iBAArB,EAAyC;AACxC,aAAO,IAAP;AACA;;AAED,WACC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,IAAI,EAAGb,IAFR;AAGC,MAAA,KAAK,EAAGE,KAHT;AAIC,MAAA,OAAO,EAAGS,OAJX;AAKC,MAAA,QAAQ,EAAG;AALZ,MADD;AASA;;AA7BqB,CAAhB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice } 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\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\tconst selectedValue = slice( value );\n\t\tconst hasUnknownFormats = selectedValue.formats.some( ( formats ) => {\n\t\t\treturn formats.some( ( format ) => format.type === name );\n\t\t} );\n\n\t\tif ( ! isActive && ! hasUnknownFormats ) {\n\t\t\treturn null;\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={ true }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex value into the rgb equivalent.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
5
|
+
* @return {string} comma separated rgb values
|
|
6
|
+
*/
|
|
1
7
|
/**
|
|
2
8
|
* Colors
|
|
3
9
|
*/
|
|
@@ -11,6 +17,12 @@
|
|
|
11
17
|
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
|
|
12
18
|
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
|
|
13
19
|
*/
|
|
20
|
+
/**
|
|
21
|
+
* Converts a hex value into the rgb equivalent.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
24
|
+
* @return {string} comma separated rgb values
|
|
25
|
+
*/
|
|
14
26
|
/**
|
|
15
27
|
* Colors
|
|
16
28
|
*/
|
|
@@ -46,15 +58,15 @@
|
|
|
46
58
|
* @param {string} hex - the hexadecimal value to convert
|
|
47
59
|
* @return {string} comma separated rgb values
|
|
48
60
|
*/
|
|
49
|
-
/**
|
|
50
|
-
* Breakpoint mixins
|
|
51
|
-
*/
|
|
52
61
|
/**
|
|
53
62
|
* Long content fade mixin
|
|
54
63
|
*
|
|
55
64
|
* Creates a fading overlay to signify that the content is longer
|
|
56
65
|
* than the space allows.
|
|
57
66
|
*/
|
|
67
|
+
/**
|
|
68
|
+
* Breakpoint mixins
|
|
69
|
+
*/
|
|
58
70
|
/**
|
|
59
71
|
* Focus styles.
|
|
60
72
|
*/
|
|
@@ -82,6 +94,8 @@
|
|
|
82
94
|
--wp-admin-theme-color-darker-20: #005a87;
|
|
83
95
|
--wp-admin-theme-color-darker-20--rgb: 0, 90, 135;
|
|
84
96
|
--wp-admin-border-width-focus: 2px;
|
|
97
|
+
--wp-block-synced-color: #7a00df;
|
|
98
|
+
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
85
99
|
}
|
|
86
100
|
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
|
|
87
101
|
:root {
|
package/build-style/style.css
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex value into the rgb equivalent.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
5
|
+
* @return {string} comma separated rgb values
|
|
6
|
+
*/
|
|
1
7
|
/**
|
|
2
8
|
* Colors
|
|
3
9
|
*/
|
|
@@ -11,6 +17,12 @@
|
|
|
11
17
|
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
|
|
12
18
|
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
|
|
13
19
|
*/
|
|
20
|
+
/**
|
|
21
|
+
* Converts a hex value into the rgb equivalent.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
24
|
+
* @return {string} comma separated rgb values
|
|
25
|
+
*/
|
|
14
26
|
/**
|
|
15
27
|
* Colors
|
|
16
28
|
*/
|
|
@@ -46,15 +58,15 @@
|
|
|
46
58
|
* @param {string} hex - the hexadecimal value to convert
|
|
47
59
|
* @return {string} comma separated rgb values
|
|
48
60
|
*/
|
|
49
|
-
/**
|
|
50
|
-
* Breakpoint mixins
|
|
51
|
-
*/
|
|
52
61
|
/**
|
|
53
62
|
* Long content fade mixin
|
|
54
63
|
*
|
|
55
64
|
* Creates a fading overlay to signify that the content is longer
|
|
56
65
|
* than the space allows.
|
|
57
66
|
*/
|
|
67
|
+
/**
|
|
68
|
+
* Breakpoint mixins
|
|
69
|
+
*/
|
|
58
70
|
/**
|
|
59
71
|
* Focus styles.
|
|
60
72
|
*/
|
|
@@ -82,6 +94,8 @@
|
|
|
82
94
|
--wp-admin-theme-color-darker-20: #005a87;
|
|
83
95
|
--wp-admin-theme-color-darker-20--rgb: 0, 90, 135;
|
|
84
96
|
--wp-admin-border-width-focus: 2px;
|
|
97
|
+
--wp-block-synced-color: #7a00df;
|
|
98
|
+
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
85
99
|
}
|
|
86
100
|
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
|
|
87
101
|
:root {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -26,24 +26,24 @@
|
|
|
26
26
|
"react-native": "src/index",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/a11y": "^3.
|
|
30
|
-
"@wordpress/block-editor": "^
|
|
31
|
-
"@wordpress/components": "^
|
|
32
|
-
"@wordpress/compose": "^
|
|
33
|
-
"@wordpress/data": "^
|
|
34
|
-
"@wordpress/element": "^
|
|
35
|
-
"@wordpress/html-entities": "^3.
|
|
36
|
-
"@wordpress/i18n": "^4.
|
|
37
|
-
"@wordpress/icons": "^9.
|
|
38
|
-
"@wordpress/rich-text": "^
|
|
39
|
-
"@wordpress/url": "^3.
|
|
29
|
+
"@wordpress/a11y": "^3.24.0",
|
|
30
|
+
"@wordpress/block-editor": "^11.1.0",
|
|
31
|
+
"@wordpress/components": "^23.1.0",
|
|
32
|
+
"@wordpress/compose": "^6.1.0",
|
|
33
|
+
"@wordpress/data": "^8.1.0",
|
|
34
|
+
"@wordpress/element": "^5.1.0",
|
|
35
|
+
"@wordpress/html-entities": "^3.24.0",
|
|
36
|
+
"@wordpress/i18n": "^4.24.0",
|
|
37
|
+
"@wordpress/icons": "^9.15.0",
|
|
38
|
+
"@wordpress/rich-text": "^6.1.0",
|
|
39
|
+
"@wordpress/url": "^3.25.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"react": "^
|
|
43
|
-
"react-dom": "^
|
|
42
|
+
"react": "^18.0.0",
|
|
43
|
+
"react-dom": "^18.0.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "200bee7b06b15f6fa655e25b6ab69cbd6b49a357"
|
|
49
49
|
}
|
package/src/default-formats.js
CHANGED
|
@@ -12,6 +12,7 @@ import { textColor } from './text-color';
|
|
|
12
12
|
import { subscript } from './subscript';
|
|
13
13
|
import { superscript } from './superscript';
|
|
14
14
|
import { keyboard } from './keyboard';
|
|
15
|
+
import { unknown } from './unknown';
|
|
15
16
|
|
|
16
17
|
export default [
|
|
17
18
|
bold,
|
|
@@ -25,4 +26,5 @@ export default [
|
|
|
25
26
|
subscript,
|
|
26
27
|
superscript,
|
|
27
28
|
keyboard,
|
|
29
|
+
unknown,
|
|
28
30
|
];
|
|
@@ -32,60 +32,55 @@ afterAll( () => {
|
|
|
32
32
|
|
|
33
33
|
describe( 'Text color', () => {
|
|
34
34
|
it( 'shows the text color formatting button in the toolbar', async () => {
|
|
35
|
-
const
|
|
35
|
+
const screen = await initializeEditor();
|
|
36
36
|
|
|
37
37
|
// Wait for the editor placeholder
|
|
38
|
-
const paragraphPlaceholder = await
|
|
39
|
-
|
|
38
|
+
const paragraphPlaceholder = await screen.findByLabelText(
|
|
39
|
+
'Add paragraph block'
|
|
40
40
|
);
|
|
41
41
|
expect( paragraphPlaceholder ).toBeDefined();
|
|
42
42
|
fireEvent.press( paragraphPlaceholder );
|
|
43
43
|
|
|
44
44
|
// Wait for the block to be created
|
|
45
|
-
const paragraphBlock = await
|
|
46
|
-
|
|
45
|
+
const [ paragraphBlock ] = await screen.findAllByLabelText(
|
|
46
|
+
/Paragraph Block\. Row 1/
|
|
47
47
|
);
|
|
48
48
|
expect( paragraphBlock ).toBeDefined();
|
|
49
49
|
|
|
50
50
|
// Look for the highlight text color button
|
|
51
|
-
const textColorButton = await
|
|
52
|
-
getByLabelText( 'Text color' )
|
|
53
|
-
);
|
|
51
|
+
const textColorButton = await screen.findByLabelText( 'Text color' );
|
|
54
52
|
expect( textColorButton ).toBeDefined();
|
|
55
53
|
} );
|
|
56
54
|
|
|
57
55
|
it( 'allows toggling the highlight color feature to type new text', async () => {
|
|
58
|
-
const
|
|
59
|
-
await initializeEditor();
|
|
56
|
+
const screen = await initializeEditor();
|
|
60
57
|
|
|
61
58
|
// Wait for the editor placeholder
|
|
62
|
-
const paragraphPlaceholder = await
|
|
63
|
-
|
|
59
|
+
const paragraphPlaceholder = await screen.findByLabelText(
|
|
60
|
+
'Add paragraph block'
|
|
64
61
|
);
|
|
65
62
|
expect( paragraphPlaceholder ).toBeDefined();
|
|
66
63
|
fireEvent.press( paragraphPlaceholder );
|
|
67
64
|
|
|
68
65
|
// Wait for the block to be created
|
|
69
|
-
const paragraphBlock = await
|
|
70
|
-
|
|
66
|
+
const [ paragraphBlock ] = await screen.findAllByLabelText(
|
|
67
|
+
/Paragraph Block\. Row 1/
|
|
71
68
|
);
|
|
72
69
|
expect( paragraphBlock ).toBeDefined();
|
|
73
70
|
|
|
74
71
|
// Look for the highlight text color button
|
|
75
|
-
const textColorButton = await
|
|
76
|
-
getByLabelText( 'Text color' )
|
|
77
|
-
);
|
|
72
|
+
const textColorButton = await screen.findByLabelText( 'Text color' );
|
|
78
73
|
expect( textColorButton ).toBeDefined();
|
|
79
74
|
fireEvent.press( textColorButton );
|
|
80
75
|
|
|
81
76
|
// Wait for Inline color modal to be visible
|
|
82
|
-
const inlineTextColorModal = getByTestId(
|
|
77
|
+
const inlineTextColorModal = screen.getByTestId(
|
|
78
|
+
'inline-text-color-modal'
|
|
79
|
+
);
|
|
83
80
|
await waitFor( () => inlineTextColorModal.props.isVisible );
|
|
84
81
|
|
|
85
82
|
// Look for the pink color button
|
|
86
|
-
const pinkColorButton = await
|
|
87
|
-
getByA11yHint( COLOR_PINK )
|
|
88
|
-
);
|
|
83
|
+
const pinkColorButton = await screen.findByA11yHint( COLOR_PINK );
|
|
89
84
|
expect( pinkColorButton ).toBeDefined();
|
|
90
85
|
fireEvent.press( pinkColorButton );
|
|
91
86
|
|
|
@@ -93,29 +88,24 @@ describe( 'Text color', () => {
|
|
|
93
88
|
} );
|
|
94
89
|
|
|
95
90
|
it( 'allows toggling the highlight color feature to selected text', async () => {
|
|
96
|
-
const
|
|
97
|
-
getByLabelText,
|
|
98
|
-
getByTestId,
|
|
99
|
-
getByPlaceholderText,
|
|
100
|
-
getByA11yHint,
|
|
101
|
-
} = await initializeEditor();
|
|
91
|
+
const screen = await initializeEditor();
|
|
102
92
|
const text = 'Hello this is a test';
|
|
103
93
|
|
|
104
94
|
// Wait for the editor placeholder
|
|
105
|
-
const paragraphPlaceholder = await
|
|
106
|
-
|
|
95
|
+
const paragraphPlaceholder = await screen.findByLabelText(
|
|
96
|
+
'Add paragraph block'
|
|
107
97
|
);
|
|
108
98
|
expect( paragraphPlaceholder ).toBeDefined();
|
|
109
99
|
fireEvent.press( paragraphPlaceholder );
|
|
110
100
|
|
|
111
101
|
// Wait for the block to be created
|
|
112
|
-
const paragraphBlock = await
|
|
113
|
-
|
|
102
|
+
const [ paragraphBlock ] = await screen.findAllByLabelText(
|
|
103
|
+
/Paragraph Block\. Row 1/
|
|
114
104
|
);
|
|
115
105
|
expect( paragraphBlock ).toBeDefined();
|
|
116
106
|
|
|
117
107
|
// Update TextInput value
|
|
118
|
-
const paragraphText = getByPlaceholderText( 'Start writing…' );
|
|
108
|
+
const paragraphText = screen.getByPlaceholderText( 'Start writing…' );
|
|
119
109
|
fireEvent( paragraphText, 'onSelectionChange', 0, text.length, text, {
|
|
120
110
|
nativeEvent: {
|
|
121
111
|
eventCount: 1,
|
|
@@ -125,20 +115,18 @@ describe( 'Text color', () => {
|
|
|
125
115
|
} );
|
|
126
116
|
|
|
127
117
|
// Look for the highlight text color button
|
|
128
|
-
const textColorButton = await
|
|
129
|
-
getByLabelText( 'Text color' )
|
|
130
|
-
);
|
|
118
|
+
const textColorButton = await screen.findByLabelText( 'Text color' );
|
|
131
119
|
expect( textColorButton ).toBeDefined();
|
|
132
120
|
fireEvent.press( textColorButton );
|
|
133
121
|
|
|
134
122
|
// Wait for Inline color modal to be visible
|
|
135
|
-
const inlineTextColorModal = getByTestId(
|
|
123
|
+
const inlineTextColorModal = screen.getByTestId(
|
|
124
|
+
'inline-text-color-modal'
|
|
125
|
+
);
|
|
136
126
|
await waitFor( () => inlineTextColorModal.props.isVisible );
|
|
137
127
|
|
|
138
128
|
// Look for the pink color button
|
|
139
|
-
const pinkColorButton = await
|
|
140
|
-
getByA11yHint( COLOR_PINK )
|
|
141
|
-
);
|
|
129
|
+
const pinkColorButton = await screen.findByA11yHint( COLOR_PINK );
|
|
142
130
|
expect( pinkColorButton ).toBeDefined();
|
|
143
131
|
fireEvent.press( pinkColorButton );
|
|
144
132
|
|
|
@@ -146,13 +134,13 @@ describe( 'Text color', () => {
|
|
|
146
134
|
} );
|
|
147
135
|
|
|
148
136
|
it( 'creates a paragraph block with the text color format', async () => {
|
|
149
|
-
const
|
|
137
|
+
const screen = await initializeEditor( {
|
|
150
138
|
initialHtml: TEXT_WITH_COLOR,
|
|
151
139
|
} );
|
|
152
140
|
|
|
153
141
|
// Wait for the block to be created
|
|
154
|
-
const paragraphBlock = await
|
|
155
|
-
|
|
142
|
+
const [ paragraphBlock ] = await screen.findAllByLabelText(
|
|
143
|
+
/Paragraph Block\. Row 1/
|
|
156
144
|
);
|
|
157
145
|
expect( paragraphBlock ).toBeDefined();
|
|
158
146
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { removeFormat, slice } from '@wordpress/rich-text';
|
|
6
|
+
import { RichTextToolbarButton } from '@wordpress/block-editor';
|
|
7
|
+
import { help } from '@wordpress/icons';
|
|
8
|
+
|
|
9
|
+
const name = 'core/unknown';
|
|
10
|
+
const title = __( 'Clear Unknown Formatting' );
|
|
11
|
+
|
|
12
|
+
export const unknown = {
|
|
13
|
+
name,
|
|
14
|
+
title,
|
|
15
|
+
tagName: '*',
|
|
16
|
+
className: null,
|
|
17
|
+
edit( { isActive, value, onChange, onFocus } ) {
|
|
18
|
+
function onClick() {
|
|
19
|
+
onChange( removeFormat( value, name ) );
|
|
20
|
+
onFocus();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const selectedValue = slice( value );
|
|
24
|
+
const hasUnknownFormats = selectedValue.formats.some( ( formats ) => {
|
|
25
|
+
return formats.some( ( format ) => format.type === name );
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
if ( ! isActive && ! hasUnknownFormats ) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<RichTextToolbarButton
|
|
34
|
+
name="unknown"
|
|
35
|
+
icon={ help }
|
|
36
|
+
title={ title }
|
|
37
|
+
onClick={ onClick }
|
|
38
|
+
isActive={ true }
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
};
|