@wordpress/format-library 3.0.1 → 3.0.5

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.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/build/bold/index.js +5 -2
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +4 -2
  5. package/build/code/index.js.map +1 -1
  6. package/build/italic/index.js +5 -2
  7. package/build/italic/index.js.map +1 -1
  8. package/build/keyboard/index.js +4 -2
  9. package/build/keyboard/index.js.map +1 -1
  10. package/build/link/inline.js +99 -5
  11. package/build/link/inline.js.map +1 -1
  12. package/build/link/utils.js +112 -0
  13. package/build/link/utils.js.map +1 -1
  14. package/build/strikethrough/index.js +4 -2
  15. package/build/strikethrough/index.js.map +1 -1
  16. package/build/subscript/index.js +4 -2
  17. package/build/subscript/index.js.map +1 -1
  18. package/build/superscript/index.js +4 -2
  19. package/build/superscript/index.js.map +1 -1
  20. package/build/text-color/index.js +60 -21
  21. package/build/text-color/index.js.map +1 -1
  22. package/build/text-color/inline.js +105 -37
  23. package/build/text-color/inline.js.map +1 -1
  24. package/build/underline/index.js +4 -2
  25. package/build/underline/index.js.map +1 -1
  26. package/build-module/bold/index.js +5 -2
  27. package/build-module/bold/index.js.map +1 -1
  28. package/build-module/code/index.js +4 -2
  29. package/build-module/code/index.js.map +1 -1
  30. package/build-module/italic/index.js +5 -2
  31. package/build-module/italic/index.js.map +1 -1
  32. package/build-module/keyboard/index.js +4 -2
  33. package/build-module/keyboard/index.js.map +1 -1
  34. package/build-module/link/inline.js +103 -10
  35. package/build-module/link/inline.js.map +1 -1
  36. package/build-module/link/utils.js +110 -1
  37. package/build-module/link/utils.js.map +1 -1
  38. package/build-module/strikethrough/index.js +4 -2
  39. package/build-module/strikethrough/index.js.map +1 -1
  40. package/build-module/subscript/index.js +4 -2
  41. package/build-module/subscript/index.js.map +1 -1
  42. package/build-module/superscript/index.js +4 -2
  43. package/build-module/superscript/index.js.map +1 -1
  44. package/build-module/text-color/index.js +61 -22
  45. package/build-module/text-color/index.js.map +1 -1
  46. package/build-module/text-color/inline.js +104 -37
  47. package/build-module/text-color/inline.js.map +1 -1
  48. package/build-module/underline/index.js +6 -2
  49. package/build-module/underline/index.js.map +1 -1
  50. package/build-style/style-rtl.css +2 -25
  51. package/build-style/style.css +2 -25
  52. package/package.json +15 -15
  53. package/src/bold/index.js +2 -2
  54. package/src/code/index.js +2 -1
  55. package/src/italic/index.js +2 -2
  56. package/src/keyboard/index.js +2 -1
  57. package/src/link/inline.js +113 -8
  58. package/src/link/test/utils.js +362 -1
  59. package/src/link/utils.js +132 -1
  60. package/src/strikethrough/index.js +2 -1
  61. package/src/subscript/index.js +2 -1
  62. package/src/superscript/index.js +2 -1
  63. package/src/text-color/index.js +66 -23
  64. package/src/text-color/inline.js +125 -49
  65. package/src/text-color/style.scss +2 -24
  66. package/src/underline/index.js +3 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["isEmpty","__","useCallback","useMemo","useState","RichTextToolbarButton","useSetting","Icon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColor","name","title","EMPTY_ARRAY","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","activeColor","undefined","backgroundColor","hasColorsToChoose","tagName","className","attributes","style","class","edit"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,QAA/B,QAA+C,oBAA/C;AACA,SAASC,qBAAT,EAAgCC,UAAhC,QAAkD,yBAAlD;AACA,SAASC,IAAT,EAAeC,SAAS,IAAIC,aAA5B,QAAiD,kBAAjD;AACA,SAASC,YAAT,QAA6B,sBAA7B;AAEA;AACA;AACA;;AACA,SAAS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;AACC,IAAA,GAAG,EAAGA,QAAQ,GAAG,YAAH,GAAkB,uBADjC;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,IAAI,EAAGA,QAAQ,GAAG,YAAH,GAAkBW,SAHlC;AAIC,IAAA,IAAI,EACH,8BACC,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGtB;AAAb,MADD,EAEGW,QAAQ,IACT;AACC,MAAA,SAAS,EAAC,6CADX;AAEC,MAAA,KAAK,EAAGS;AAFT,MAHF,CALF;AAeC,IAAA,KAAK,EAAGd,KAfT,CAgBC;AAhBD;AAiBC,IAAA,OAAO,EACNkB,iBAAiB,GACdN,mBADc,GAEd,MAAMR,QAAQ,CAAET,YAAY,CAAEQ,KAAF,EAASJ,IAAT,CAAd;AApBnB,IADD,EAwBGW,aAAa,IACd,cAAC,aAAD;AACC,IAAA,IAAI,EAAGX,IADR;AAEC,IAAA,OAAO,EAAGc,oBAFX;AAGC,IAAA,gBAAgB,EAAGP,gBAHpB;AAIC,IAAA,KAAK,EAAGH,KAJT;AAKC,IAAA,QAAQ,EAAGC,QALZ;AAMC,IAAA,UAAU,EAAGG;AANd,IAzBF,CADD;AAqCA;;AAED,OAAO,MAAMd,SAAS,GAAG;AACxBM,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBmB,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,kBAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE,OADI;AAEXC,IAAAA,KAAK,EAAE;AAFI,GALY;AASxBC,EAAAA,IAAI,EAAEtB;AATkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport { Icon, textColor as textColorIcon } from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColor } from './inline';\n\nconst name = 'core/text-color';\nconst title = __( 'Text color' );\n\nconst EMPTY_ARRAY = [];\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback( () => setIsAddingColor( true ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst disableIsAddingColor = useCallback( () => setIsAddingColor( false ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst colorIndicatorStyle = useMemo( () => {\n\t\tconst activeColor = getActiveColor( name, value, colors );\n\t\tif ( ! activeColor ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tbackgroundColor: activeColor,\n\t\t};\n\t}, [ value, colors ] );\n\n\tconst hasColorsToChoose = ! isEmpty( colors ) || ! 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\tkey={ isActive ? 'text-color' : 'text-color-not-active' }\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tname={ isActive ? 'text-color' : undefined }\n\t\t\t\ticon={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Icon icon={ textColorIcon } />\n\t\t\t\t\t\t{ isActive && (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"format-library-text-color-button__indicator\"\n\t\t\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["isEmpty","__","useCallback","useMemo","useState","RichTextToolbarButton","useSetting","Icon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColors","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,QAA/B,QAA+C,oBAA/C;AACA,SAASC,qBAAT,EAAgCC,UAAhC,QAAkD,yBAAlD;AACA,SAASC,IAAT,EAAeC,SAAS,IAAIC,aAA5B,QAAiD,kBAAjD;AACA,SAASC,YAAT,Q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G0B,oBAFX;AAGC,IAAA,gBAAgB,EAAGP,gBAHpB;AAIC,IAAA,KAAK,EAAGT,KAJT;AAKC,IAAA,QAAQ,EAAGO,QALZ;AAMC,IAAA,UAAU,EAAGG;AANd,IApBF,CADD;AAgCA;;AAED,OAAO,MAAM1B,SAAS,GAAG;AACxBM,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxB6B,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,kBAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXxB,IAAAA,KAAK,EAAE,OADI;AAEXyB,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAOzB,KAAP,EAAe;AAC5C,QAAKyB,GAAG,KAAK,OAAb,EAAuB,OAAOzB,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAAC0B,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAO1B,KAAP;AACrD,UAAM2B,QAAQ,GAAG,CAAE,kBAAF,EAAsB,kBAAtB,EAA2CC,IAA3C,CAAiD,GAAjD,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAO5B,KAAK,GAAG,CAAE2B,QAAF,EAAY3B,KAAZ,EAAoB4B,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAEvB;AA3BkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport { Icon, textColor as textColorIcon } from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\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 === 'rgba(0, 0, 0, 0)' &&\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 === 'rgba(0, 0, 0, 0)'\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 = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback( () => setIsAddingColor( true ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst disableIsAddingColor = useCallback( () => setIsAddingColor( false ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = ! isEmpty( colors ) || ! 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={ textColorIcon }\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\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\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', 'rgba(0, 0, 0, 0)' ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
@@ -11,65 +11,117 @@ import { get } from 'lodash';
11
11
  import { useCallback, useMemo } from '@wordpress/element';
12
12
  import { useSelect } from '@wordpress/data';
13
13
  import { applyFormat, removeFormat, getActiveFormat, useAnchorRef } from '@wordpress/rich-text';
14
- import { ColorPalette, URLPopover, getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues, store as blockEditorStore } from '@wordpress/block-editor';
14
+ import { ColorPalette, getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues, store as blockEditorStore, useCachedTruthy } from '@wordpress/block-editor';
15
+ import { Popover, TabPanel } from '@wordpress/components';
16
+ import { __ } from '@wordpress/i18n';
15
17
  /**
16
18
  * Internal dependencies
17
19
  */
18
20
 
19
21
  import { textColor as settings } from './index';
20
- export function getActiveColor(formatName, formatValue, colors) {
21
- const activeColorFormat = getActiveFormat(formatValue, formatName);
22
+
23
+ function parseCSS(css = '') {
24
+ return css.split(';').reduce((accumulator, rule) => {
25
+ if (rule) {
26
+ const [property, value] = rule.split(':');
27
+ if (property === 'color') accumulator.color = value;
28
+ if (property === 'background-color') accumulator.backgroundColor = value;
29
+ }
30
+
31
+ return accumulator;
32
+ }, {});
33
+ }
34
+
35
+ function parseClassName(className = '', colorSettings) {
36
+ return className.split(' ').reduce((accumulator, name) => {
37
+ const match = name.match(/^has-([^-]+)-color$/);
38
+
39
+ if (match) {
40
+ const [, colorSlug] = name.match(/^has-([^-]+)-color$/);
41
+ const colorObject = getColorObjectByAttributeValues(colorSettings, colorSlug);
42
+ accumulator.color = colorObject.color;
43
+ }
44
+
45
+ return accumulator;
46
+ }, {});
47
+ }
48
+
49
+ export function getActiveColors(value, name, colorSettings) {
50
+ const activeColorFormat = getActiveFormat(value, name);
22
51
 
23
52
  if (!activeColorFormat) {
24
- return;
53
+ return {};
54
+ }
55
+
56
+ return { ...parseCSS(activeColorFormat.attributes.style),
57
+ ...parseClassName(activeColorFormat.attributes.class, colorSettings)
58
+ };
59
+ }
60
+
61
+ function setColors(value, name, colorSettings, colors) {
62
+ const {
63
+ color,
64
+ backgroundColor
65
+ } = { ...getActiveColors(value, name, colorSettings),
66
+ ...colors
67
+ };
68
+
69
+ if (!color && !backgroundColor) {
70
+ return removeFormat(value, name);
25
71
  }
26
72
 
27
- const styleColor = activeColorFormat.attributes.style;
73
+ const styles = [];
74
+ const classNames = [];
75
+ const attributes = {};
28
76
 
29
- if (styleColor) {
30
- return styleColor.replace(new RegExp(`^color:\\s*`), '');
77
+ if (backgroundColor) {
78
+ styles.push(['background-color', backgroundColor].join(':'));
79
+ } else {
80
+ // Override default browser color for mark element.
81
+ styles.push(['background-color', 'rgba(0, 0, 0, 0)'].join(':'));
31
82
  }
32
83
 
33
- const currentClass = activeColorFormat.attributes.class;
84
+ if (color) {
85
+ const colorObject = getColorObjectByColorValue(colorSettings, color);
34
86
 
35
- if (currentClass) {
36
- const colorSlug = currentClass.replace(/.*has-([^\s]*)-color.*/, '$1');
37
- return getColorObjectByAttributeValues(colors, colorSlug).color;
87
+ if (colorObject) {
88
+ classNames.push(getColorClassName('color', colorObject.slug));
89
+ } else {
90
+ styles.push(['color', color].join(':'));
91
+ }
38
92
  }
93
+
94
+ if (styles.length) attributes.style = styles.join(';');
95
+ if (classNames.length) attributes.class = classNames.join(' ');
96
+ return applyFormat(value, {
97
+ type: name,
98
+ attributes
99
+ });
39
100
  }
40
101
 
41
- const ColorPicker = ({
102
+ function ColorPicker({
42
103
  name,
104
+ property,
43
105
  value,
44
106
  onChange
45
- }) => {
107
+ }) {
46
108
  const colors = useSelect(select => {
47
109
  const {
48
110
  getSettings
49
111
  } = select(blockEditorStore);
50
112
  return get(getSettings(), ['colors'], []);
51
- });
113
+ }, []);
52
114
  const onColorChange = useCallback(color => {
53
- if (color) {
54
- const colorObject = getColorObjectByColorValue(colors, color);
55
- onChange(applyFormat(value, {
56
- type: name,
57
- attributes: colorObject ? {
58
- class: getColorClassName('color', colorObject.slug)
59
- } : {
60
- style: `color:${color}`
61
- }
62
- }));
63
- } else {
64
- onChange(removeFormat(value, name));
65
- }
66
- }, [colors, onChange]);
67
- const activeColor = useMemo(() => getActiveColor(name, value, colors), [name, value, colors]);
115
+ onChange(setColors(value, name, colors, {
116
+ [property]: color
117
+ }));
118
+ }, [colors, onChange, property]);
119
+ const activeColors = useMemo(() => getActiveColors(value, name, colors), [name, value, colors]);
68
120
  return createElement(ColorPalette, {
69
- value: activeColor,
121
+ value: activeColors[property],
70
122
  onChange: onColorChange
71
123
  });
72
- };
124
+ }
73
125
 
74
126
  export default function InlineColorUI({
75
127
  name,
@@ -78,20 +130,35 @@ export default function InlineColorUI({
78
130
  onClose,
79
131
  contentRef
80
132
  }) {
81
- const anchorRef = useAnchorRef({
133
+ /*
134
+ As you change the text color by typing a HEX value into a field,
135
+ the return value of document.getSelection jumps to the field you're editing,
136
+ not the highlighted text. Given that useAnchorRef uses document.getSelection,
137
+ it will return null, since it can't find the <mark> element within the HEX input.
138
+ This caches the last truthy value of the selection anchor reference.
139
+ */
140
+ const anchorRef = useCachedTruthy(useAnchorRef({
82
141
  ref: contentRef,
83
142
  value,
84
143
  settings
85
- });
86
- return createElement(URLPopover, {
87
- value: value,
144
+ }));
145
+ return createElement(Popover, {
88
146
  onClose: onClose,
89
147
  className: "components-inline-color-popover",
90
148
  anchorRef: anchorRef
91
- }, createElement(ColorPicker, {
149
+ }, createElement(TabPanel, {
150
+ tabs: [{
151
+ name: 'color',
152
+ title: __('Text')
153
+ }, {
154
+ name: 'backgroundColor',
155
+ title: __('Background')
156
+ }]
157
+ }, tab => createElement(ColorPicker, {
92
158
  name: name,
159
+ property: tab.name,
93
160
  value: value,
94
161
  onChange: onChange
95
- }));
162
+ })));
96
163
  }
97
164
  //# sourceMappingURL=inline.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.js"],"names":["get","useCallback","useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchorRef","ColorPalette","URLPopover","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","textColor","settings","getActiveColor","formatName","formatValue","colors","activeColorFormat","styleColor","attributes","style","replace","RegExp","currentClass","class","colorSlug","color","ColorPicker","name","value","onChange","select","getSettings","onColorChange","colorObject","type","slug","activeColor","InlineColorUI","onClose","contentRef","anchorRef","ref"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,WADD,EAECC,YAFD,EAGCC,eAHD,EAICC,YAJD,QAKO,sBALP;AAMA,SACCC,YADD,EAECC,UAFD,EAGCC,iBAHD,EAICC,0BAJD,EAKCC,+BALD,EAMCC,KAAK,IAAIC,gBANV,QAOO,yBAPP;AASA;AACA;AACA;;AACA,SAASC,SAAS,IAAIC,QAAtB,QAAsC,SAAtC;AAEA,OAAO,SAASC,cAAT,CAAyBC,UAAzB,EAAqCC,WAArC,EAAkDC,MAAlD,EAA2D;AACjE,QAAMC,iBAAiB,GAAGf,eAAe,CAAEa,WAAF,EAAeD,UAAf,CAAzC;;AACA,MAAK,CAAEG,iBAAP,EAA2B;AAC1B;AACA;;AACD,QAAMC,UAAU,GAAGD,iBAAiB,CAACE,UAAlB,CAA6BC,KAAhD;;AACA,MAAKF,UAAL,EAAkB;AACjB,WAAOA,UAAU,CAACG,OAAX,CAAoB,IAAIC,MAAJ,CAAa,aAAb,CAApB,EAAiD,EAAjD,CAAP;AACA;;AACD,QAAMC,YAAY,GAAGN,iBAAiB,CAACE,UAAlB,CAA6BK,KAAlD;;AACA,MAAKD,YAAL,EAAoB;AACnB,UAAME,SAAS,GAAGF,YAAY,CAACF,OAAb,CACjB,wBADiB,EAEjB,IAFiB,CAAlB;AAIA,WAAOb,+BAA+B,CAAEQ,MAAF,EAAUS,SAAV,CAA/B,CAAqDC,KAA5D;AACA;AACD;;AAED,MAAMC,WAAW,GAA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,EAAAA,IADsC;AAEtCC,EAAAA,KAFsC;AAGtCC,EAAAA,QAHsC;AAItCS,EAAAA,OAJsC;AAKtCC,EAAAA;AALsC,CAAxB,EAMX;AACH,QAAMC,SAAS,GAAGtC,YAAY,CAAE;AAAEuC,IAAAA,GAAG,EAAEF,UAAP;AAAmBX,IAAAA,KAAnB;AAA0BjB,IAAAA;AAA1B,GAAF,CAA9B;AACA,SACC,cAAC,UAAD;AACC,IAAA,KAAK,EAAGiB,KADT;AAEC,IAAA,OAAO,EAAGU,OAFX;AAGC,IAAA,SAAS,EAAC,iCAHX;AAIC,IAAA,SAAS,EAAGE;AAJb,KAMC,cAAC,WAAD;AAAa,IAAA,IAAI,EAAGb,IAApB;AAA2B,IAAA,KAAK,EAAGC,KAAnC;AAA2C,IAAA,QAAQ,EAAGC;AAAtD,IAND,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchorRef,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tURLPopover,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings } from './index';\n\nexport function getActiveColor( formatName, formatValue, colors ) {\n\tconst activeColorFormat = getActiveFormat( formatValue, formatName );\n\tif ( ! activeColorFormat ) {\n\t\treturn;\n\t}\n\tconst styleColor = activeColorFormat.attributes.style;\n\tif ( styleColor ) {\n\t\treturn styleColor.replace( new RegExp( `^color:\\\\s*` ), '' );\n\t}\n\tconst currentClass = activeColorFormat.attributes.class;\n\tif ( currentClass ) {\n\t\tconst colorSlug = currentClass.replace(\n\t\t\t/.*has-([^\\s]*)-color.*/,\n\t\t\t'$1'\n\t\t);\n\t\treturn getColorObjectByAttributeValues( colors, colorSlug ).color;\n\t}\n}\n\nconst ColorPicker = ( { name, value, onChange } ) => {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn get( getSettings(), [ 'colors' ], [] );\n\t} );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tif ( color ) {\n\t\t\t\tconst colorObject = getColorObjectByColorValue( colors, color );\n\t\t\t\tonChange(\n\t\t\t\t\tapplyFormat( value, {\n\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\tattributes: colorObject\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\t'color',\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tstyle: `color:${ color }`,\n\t\t\t\t\t\t\t },\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tonChange( removeFormat( value, name ) );\n\t\t\t}\n\t\t},\n\t\t[ colors, onChange ]\n\t);\n\tconst activeColor = useMemo( () => getActiveColor( name, value, colors ), [\n\t\tname,\n\t\tvalue,\n\t\tcolors,\n\t] );\n\n\treturn <ColorPalette value={ activeColor } onChange={ onColorChange } />;\n};\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\tconst anchorRef = useAnchorRef( { ref: contentRef, value, settings } );\n\treturn (\n\t\t<URLPopover\n\t\t\tvalue={ value }\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchorRef={ anchorRef }\n\t\t>\n\t\t\t<ColorPicker name={ name } value={ value } onChange={ onChange } />\n\t\t</URLPopover>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.js"],"names":["get","useCallback","useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchorRef","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","useCachedTruthy","Popover","TabPanel","__","textColor","settings","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","name","match","colorSlug","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","getSettings","onColorChange","activeColors","InlineColorUI","onClose","contentRef","anchorRef","ref","title","tab"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,WADD,EAECC,YAFD,EAGCC,eAHD,EAICC,YAJD,QAKO,sBALP;AAMA,SACCC,YADD,EAECC,iBAFD,EAGCC,0BAHD,EAICC,+BAJD,EAKCC,KAAK,IAAIC,gBALV,EAMCC,eAND,QAOO,yBAPP;AAQA,SAASC,OAAT,EAAkBC,QAAlB,QAAkC,uBAAlC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,SAAS,IAAIC,QAAtB,QAAsC,SAAtC;;AAEA,SAASC,QAAT,CAAmBC,GAAG,GAAG,EAAzB,EAA8B;AAC7B,SAAOA,GAAG,CAACC,KAAJ,CAAW,GAAX,EAAiBC,MAAjB,CAAyB,CAAEC,WAAF,EAAeC,IAAf,KAAyB;AACxD,QAAKA,IAAL,EAAY;AACX,YAAM,CAAEC,QAAF,EAAYC,KAAZ,IAAsBF,IAAI,CAACH,KAAL,CAAY,GAAZ,CAA5B;AACA,UAAKI,QAAQ,KAAK,OAAlB,EAA4BF,WAAW,CAACI,KAAZ,GAAoBD,KAApB;AAC5B,UAAKD,QAAQ,KAAK,kBAAlB,EACCF,WAAW,CAACK,eAA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;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,SAAS,EAAGE;AAHb,KAKC,cAAC,QAAD;AACC,IAAA,IAAI,EAAG,CACN;AACC3B,MAAAA,IAAI,EAAE,OADP;AAEC6B,MAAAA,KAAK,EAAE7C,EAAE,CAAE,MAAF;AAFV,KADM,EAKN;AACCgB,MAAAA,IAAI,EAAE,iBADP;AAEC6B,MAAAA,KAAK,EAAE7C,EAAE,CAAE,YAAF;AAFV,KALM;AADR,KAYK8C,GAAF,IACD,cAAC,WAAD;AACC,IAAA,IAAI,EAAG9B,IADR;AAEC,IAAA,QAAQ,EAAG8B,GAAG,CAAC9B,IAFhB;AAGC,IAAA,KAAK,EAAGN,KAHT;AAIC,IAAA,QAAQ,EAAGyB;AAJZ,IAbF,CALD,CADD;AA6BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchorRef,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings } from './index';\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' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nfunction parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\tconst match = name.match( /^has-([^-]+)-color$/ );\n\t\tif ( match ) {\n\t\t\tconst [ , colorSlug ] = name.match( /^has-([^-]+)-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', 'rgba(0, 0, 0, 0)' ].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 ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\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 get( getSettings(), [ 'colors' ], [] );\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\t/* \n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchorRef uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst anchorRef = useCachedTruthy(\n\t\tuseAnchorRef( { ref: contentRef, value, settings } )\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchorRef={ anchorRef }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -7,9 +7,12 @@ import { __ } from '@wordpress/i18n';
7
7
  import { toggleFormat } from '@wordpress/rich-text';
8
8
  import { RichTextShortcut, __unstableRichTextInputEvent } from '@wordpress/block-editor';
9
9
  const name = 'core/underline';
10
+
11
+ const title = __('Underline');
12
+
10
13
  export const underline = {
11
14
  name,
12
- title: __('Underline'),
15
+ title,
13
16
  tagName: 'span',
14
17
  className: null,
15
18
  attributes: {
@@ -25,7 +28,8 @@ export const underline = {
25
28
  type: name,
26
29
  attributes: {
27
30
  style: 'text-decoration: underline;'
28
- }
31
+ },
32
+ title
29
33
  }));
30
34
  };
31
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/underline/index.js"],"names":["__","toggleFormat","RichTextShortcut","__unstableRichTextInputEvent","name","underline","title","tagName","className","attributes","style","edit","value","onChange","onToggle","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SACCC,gBADD,EAECC,4BAFD,QAGO,yBAHP;AAKA,MAAMC,IAAI,GAAG,gBAAb;AAEA,OAAO,MAAMC,SAAS,GAAG;AACxBD,EAAAA,IADwB;AAExBE,EAAAA,KAAK,EAAEN,EAAE,CAAE,WAAF,CAFe;AAGxBO,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE;AADI,GALY;;AAQxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAF,EAAwB;AAC3B,UAAMC,QAAQ,GAAG,MAAM;AACtBD,MAAAA,QAAQ,CACPZ,YAAY,CAAEW,KAAF,EAAS;AACpBG,QAAAA,IAAI,EAAEX,IADc;AAEpBK,QAAAA,UAAU,EAAE;AACXC,UAAAA,KAAK,EAAE;AADI;AAFQ,OAAT,CADL,CAAR;AAQA,KATD;;AAWA,WACC,8BACC,cAAC,gBAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGI;AAHT,MADD,EAMC,cAAC,4BAAD;AACC,MAAA,SAAS,EAAC,iBADX;AAEC,MAAA,OAAO,EAAGA;AAFX,MAND,CADD;AAaA;;AAjCuB,CAAlB","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';\n\nexport const underline = {\n\tname,\n\ttitle: __( 'Underline' ),\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} )\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"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/underline/index.js"],"names":["__","toggleFormat","RichTextShortcut","__unstableRichTextInputEvent","name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SACCC,gBADD,EAECC,4BAFD,QAGO,yBAHP;AAKA,MAAMC,IAAI,GAAG,gBAAb;;AACA,MAAMC,KAAK,GAAGL,EAAE,CAAE,WAAF,CAAhB;;AAEA,OAAO,MAAMM,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE;AADI,GALY;;AAQxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAF,EAAwB;AAC3B,UAAMC,QAAQ,GAAG,MAAM;AACtBD,MAAAA,QAAQ,CACPZ,YAAY,CAAEW,KAAF,EAAS;AACpBG,QAAAA,IAAI,EAAEX,IADc;AAEpBK,QAAAA,UAAU,EAAE;AACXC,UAAAA,KAAK,EAAE;AADI,SAFQ;AAKpBL,QAAAA;AALoB,OAAT,CADL,CAAR;AASA,KAVD;;AAYA,WACC,8BACC,cAAC,gBAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGS;AAHT,MADD,EAMC,cAAC,4BAAD;AACC,MAAA,SAAS,EAAC,iBADX;AAEC,MAAA,OAAO,EAAGA;AAFX,MAND,CADD;AAaA;;AAlCuB,CAAlB","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"]}
@@ -137,19 +137,8 @@
137
137
  color: #cc1818;
138
138
  }
139
139
 
140
- .components-inline-color__indicator {
141
- position: absolute;
142
- background: #000;
143
- height: 3px;
144
- width: 20px;
145
- bottom: 6px;
146
- right: auto;
147
- left: auto;
148
- margin: 0 5px;
149
- }
150
-
151
- .components-inline-color-popover .components-popover__content > div {
152
- padding: 20px 18px;
140
+ .components-inline-color-popover .components-popover__content .components-tab-panel__tab-content {
141
+ padding: 16px;
153
142
  }
154
143
  .components-inline-color-popover .components-popover__content .components-color-palette {
155
144
  margin-top: 0.6rem;
@@ -162,16 +151,4 @@
162
151
  }
163
152
  .components-inline-color-popover .components-popover__content .component-color-indicator {
164
153
  vertical-align: text-bottom;
165
- }
166
-
167
- .format-library-text-color-button {
168
- position: relative;
169
- }
170
-
171
- .format-library-text-color-button__indicator {
172
- height: 4px;
173
- width: 20px;
174
- position: absolute;
175
- bottom: 10px;
176
- right: 8px;
177
154
  }
@@ -137,19 +137,8 @@
137
137
  color: #cc1818;
138
138
  }
139
139
 
140
- .components-inline-color__indicator {
141
- position: absolute;
142
- background: #000;
143
- height: 3px;
144
- width: 20px;
145
- bottom: 6px;
146
- left: auto;
147
- right: auto;
148
- margin: 0 5px;
149
- }
150
-
151
- .components-inline-color-popover .components-popover__content > div {
152
- padding: 20px 18px;
140
+ .components-inline-color-popover .components-popover__content .components-tab-panel__tab-content {
141
+ padding: 16px;
153
142
  }
154
143
  .components-inline-color-popover .components-popover__content .components-color-palette {
155
144
  margin-top: 0.6rem;
@@ -162,16 +151,4 @@
162
151
  }
163
152
  .components-inline-color-popover .components-popover__content .component-color-indicator {
164
153
  vertical-align: text-bottom;
165
- }
166
-
167
- .format-library-text-color-button {
168
- position: relative;
169
- }
170
-
171
- .format-library-text-color-button__indicator {
172
- height: 4px;
173
- width: 20px;
174
- position: absolute;
175
- bottom: 10px;
176
- left: 8px;
177
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/format-library",
3
- "version": "3.0.1",
3
+ "version": "3.0.5",
4
4
  "description": "Format library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,23 +26,23 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.13.10",
29
- "@wordpress/a11y": "^3.2.1",
30
- "@wordpress/block-editor": "^7.0.1",
31
- "@wordpress/components": "^16.0.0",
32
- "@wordpress/compose": "^5.0.1",
33
- "@wordpress/data": "^6.0.1",
34
- "@wordpress/dom": "^3.2.2",
35
- "@wordpress/element": "^4.0.0",
36
- "@wordpress/html-entities": "^3.2.1",
37
- "@wordpress/i18n": "^4.2.1",
38
- "@wordpress/icons": "^5.0.1",
39
- "@wordpress/keycodes": "^3.2.1",
40
- "@wordpress/rich-text": "^5.0.1",
41
- "@wordpress/url": "^3.2.1",
29
+ "@wordpress/a11y": "^3.2.3",
30
+ "@wordpress/block-editor": "^8.0.0",
31
+ "@wordpress/components": "^19.0.1",
32
+ "@wordpress/compose": "^5.0.5",
33
+ "@wordpress/data": "^6.1.3",
34
+ "@wordpress/dom": "^3.2.6",
35
+ "@wordpress/element": "^4.0.3",
36
+ "@wordpress/html-entities": "^3.2.2",
37
+ "@wordpress/i18n": "^4.2.3",
38
+ "@wordpress/icons": "^6.1.0",
39
+ "@wordpress/keycodes": "^3.2.3",
40
+ "@wordpress/rich-text": "^5.0.5",
41
+ "@wordpress/url": "^3.3.0",
42
42
  "lodash": "^4.17.21"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "8b67fbd424bc67f81c2d825877f0fae726d6363a"
47
+ "gitHead": "393c2b5533837fd637e998d23f0124c081a10df0"
48
48
  }
package/src/bold/index.js CHANGED
@@ -20,11 +20,11 @@ export const bold = {
20
20
  className: null,
21
21
  edit( { isActive, value, onChange, onFocus } ) {
22
22
  function onToggle() {
23
- onChange( toggleFormat( value, { type: name } ) );
23
+ onChange( toggleFormat( value, { type: name, title } ) );
24
24
  }
25
25
 
26
26
  function onClick() {
27
- onToggle();
27
+ onChange( toggleFormat( value, { type: name } ) );
28
28
  onFocus();
29
29
  }
30
30
 
package/src/code/index.js CHANGED
@@ -46,7 +46,7 @@ export const code = {
46
46
  },
47
47
  edit( { value, onChange, onFocus, isActive } ) {
48
48
  function onClick() {
49
- onChange( toggleFormat( value, { type: name } ) );
49
+ onChange( toggleFormat( value, { type: name, title } ) );
50
50
  onFocus();
51
51
  }
52
52
 
@@ -56,6 +56,7 @@ export const code = {
56
56
  title={ title }
57
57
  onClick={ onClick }
58
58
  isActive={ isActive }
59
+ role="menuitemcheckbox"
59
60
  />
60
61
  );
61
62
  },
@@ -20,11 +20,11 @@ export const italic = {
20
20
  className: null,
21
21
  edit( { isActive, value, onChange, onFocus } ) {
22
22
  function onToggle() {
23
- onChange( toggleFormat( value, { type: name } ) );
23
+ onChange( toggleFormat( value, { type: name, title } ) );
24
24
  }
25
25
 
26
26
  function onClick() {
27
- onToggle();
27
+ onChange( toggleFormat( value, { type: name } ) );
28
28
  onFocus();
29
29
  }
30
30
 
@@ -16,7 +16,7 @@ export const keyboard = {
16
16
  className: null,
17
17
  edit( { isActive, value, onChange, onFocus } ) {
18
18
  function onToggle() {
19
- onChange( toggleFormat( value, { type: name } ) );
19
+ onChange( toggleFormat( value, { type: name, title } ) );
20
20
  }
21
21
 
22
22
  function onClick() {
@@ -30,6 +30,7 @@ export const keyboard = {
30
30
  title={ title }
31
31
  onClick={ onClick }
32
32
  isActive={ isActive }
33
+ role="menuitemcheckbox"
33
34
  />
34
35
  );
35
36
  },