@wordpress/format-library 3.0.3 → 3.0.7
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 +5 -2
- package/build/bold/index.js.map +1 -1
- package/build/code/index.js +4 -2
- package/build/code/index.js.map +1 -1
- package/build/italic/index.js +5 -2
- package/build/italic/index.js.map +1 -1
- package/build/keyboard/index.js +4 -2
- package/build/keyboard/index.js.map +1 -1
- package/build/link/inline.js +67 -6
- package/build/link/inline.js.map +1 -1
- package/build/link/use-link-instance-key.js +40 -0
- package/build/link/use-link-instance-key.js.map +1 -0
- package/build/link/utils.js +112 -0
- package/build/link/utils.js.map +1 -1
- package/build/strikethrough/index.js +4 -2
- package/build/strikethrough/index.js.map +1 -1
- package/build/subscript/index.js +4 -2
- package/build/subscript/index.js.map +1 -1
- package/build/superscript/index.js +4 -2
- package/build/superscript/index.js.map +1 -1
- package/build/text-color/index.js +22 -1
- package/build/text-color/index.js.map +1 -1
- package/build/text-color/inline.js +9 -2
- package/build/text-color/inline.js.map +1 -1
- package/build/underline/index.js +4 -2
- package/build/underline/index.js.map +1 -1
- package/build-module/bold/index.js +5 -2
- package/build-module/bold/index.js.map +1 -1
- package/build-module/code/index.js +4 -2
- package/build-module/code/index.js.map +1 -1
- package/build-module/italic/index.js +5 -2
- package/build-module/italic/index.js.map +1 -1
- package/build-module/keyboard/index.js +4 -2
- package/build-module/keyboard/index.js.map +1 -1
- package/build-module/link/inline.js +66 -8
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/use-link-instance-key.js +33 -0
- package/build-module/link/use-link-instance-key.js.map +1 -0
- package/build-module/link/utils.js +110 -1
- package/build-module/link/utils.js.map +1 -1
- package/build-module/strikethrough/index.js +4 -2
- package/build-module/strikethrough/index.js.map +1 -1
- package/build-module/subscript/index.js +4 -2
- package/build-module/subscript/index.js.map +1 -1
- package/build-module/superscript/index.js +4 -2
- package/build-module/superscript/index.js.map +1 -1
- package/build-module/text-color/index.js +22 -1
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/inline.js +10 -3
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/underline/index.js +6 -2
- package/build-module/underline/index.js.map +1 -1
- package/package.json +11 -11
- package/src/bold/index.js +2 -2
- package/src/code/index.js +2 -1
- package/src/italic/index.js +2 -2
- package/src/keyboard/index.js +2 -1
- package/src/link/inline.js +75 -5
- package/src/link/test/utils.js +362 -1
- package/src/link/use-link-instance-key.js +34 -0
- package/src/link/utils.js +132 -1
- package/src/strikethrough/index.js +2 -1
- package/src/subscript/index.js +2 -1
- package/src/superscript/index.js +2 -1
- package/src/text-color/index.js +19 -0
- package/src/text-color/inline.js +12 -1
- package/src/underline/index.js +3 -1
package/src/subscript/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export const subscript = {
|
|
|
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 subscript = {
|
|
|
30
30
|
title={ title }
|
|
31
31
|
onClick={ onClick }
|
|
32
32
|
isActive={ isActive }
|
|
33
|
+
role="menuitemcheckbox"
|
|
33
34
|
/>
|
|
34
35
|
);
|
|
35
36
|
},
|
package/src/superscript/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export const superscript = {
|
|
|
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 superscript = {
|
|
|
30
30
|
title={ title }
|
|
31
31
|
onClick={ onClick }
|
|
32
32
|
isActive={ isActive }
|
|
33
|
+
role="menuitemcheckbox"
|
|
33
34
|
/>
|
|
34
35
|
);
|
|
35
36
|
},
|
package/src/text-color/index.js
CHANGED
|
@@ -101,6 +101,7 @@ function TextColorEdit( {
|
|
|
101
101
|
? enableIsAddingColor
|
|
102
102
|
: () => onChange( removeFormat( value, name ) )
|
|
103
103
|
}
|
|
104
|
+
role="menuitemcheckbox"
|
|
104
105
|
/>
|
|
105
106
|
{ isAddingColor && (
|
|
106
107
|
<InlineColorUI
|
|
@@ -125,5 +126,23 @@ export const textColor = {
|
|
|
125
126
|
style: 'style',
|
|
126
127
|
class: 'class',
|
|
127
128
|
},
|
|
129
|
+
/*
|
|
130
|
+
* Since this format relies on the <mark> tag, it's important to
|
|
131
|
+
* prevent the default yellow background color applied by most
|
|
132
|
+
* browsers. The solution is to detect when this format is used with a
|
|
133
|
+
* text color but no background color, and in such cases to override
|
|
134
|
+
* the default styling with a transparent background.
|
|
135
|
+
*
|
|
136
|
+
* @see https://github.com/WordPress/gutenberg/pull/35516
|
|
137
|
+
*/
|
|
138
|
+
__unstableFilterAttributeValue( key, value ) {
|
|
139
|
+
if ( key !== 'style' ) return value;
|
|
140
|
+
// We should not add a background-color if it's already set
|
|
141
|
+
if ( value && value.includes( 'background-color' ) ) return value;
|
|
142
|
+
const addedCSS = [ 'background-color', 'rgba(0, 0, 0, 0)' ].join( ':' );
|
|
143
|
+
// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
|
|
144
|
+
// rules will already include a `;`.
|
|
145
|
+
return value ? [ addedCSS, value ].join( ';' ) : addedCSS;
|
|
146
|
+
},
|
|
128
147
|
edit: TextColorEdit,
|
|
129
148
|
};
|
package/src/text-color/inline.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getColorObjectByColorValue,
|
|
21
21
|
getColorObjectByAttributeValues,
|
|
22
22
|
store as blockEditorStore,
|
|
23
|
+
useCachedTruthy,
|
|
23
24
|
} from '@wordpress/block-editor';
|
|
24
25
|
import { Popover, TabPanel } from '@wordpress/components';
|
|
25
26
|
import { __ } from '@wordpress/i18n';
|
|
@@ -139,7 +140,17 @@ export default function InlineColorUI( {
|
|
|
139
140
|
onClose,
|
|
140
141
|
contentRef,
|
|
141
142
|
} ) {
|
|
142
|
-
|
|
143
|
+
/*
|
|
144
|
+
As you change the text color by typing a HEX value into a field,
|
|
145
|
+
the return value of document.getSelection jumps to the field you're editing,
|
|
146
|
+
not the highlighted text. Given that useAnchorRef uses document.getSelection,
|
|
147
|
+
it will return null, since it can't find the <mark> element within the HEX input.
|
|
148
|
+
This caches the last truthy value of the selection anchor reference.
|
|
149
|
+
*/
|
|
150
|
+
const anchorRef = useCachedTruthy(
|
|
151
|
+
useAnchorRef( { ref: contentRef, value, settings } )
|
|
152
|
+
);
|
|
153
|
+
|
|
143
154
|
return (
|
|
144
155
|
<Popover
|
|
145
156
|
onClose={ onClose }
|
package/src/underline/index.js
CHANGED
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
} from '@wordpress/block-editor';
|
|
10
10
|
|
|
11
11
|
const name = 'core/underline';
|
|
12
|
+
const title = __( 'Underline' );
|
|
12
13
|
|
|
13
14
|
export const underline = {
|
|
14
15
|
name,
|
|
15
|
-
title
|
|
16
|
+
title,
|
|
16
17
|
tagName: 'span',
|
|
17
18
|
className: null,
|
|
18
19
|
attributes: {
|
|
@@ -26,6 +27,7 @@ export const underline = {
|
|
|
26
27
|
attributes: {
|
|
27
28
|
style: 'text-decoration: underline;',
|
|
28
29
|
},
|
|
30
|
+
title,
|
|
29
31
|
} )
|
|
30
32
|
);
|
|
31
33
|
};
|