@wordpress/format-library 3.14.1-next.957ca95e4c.0 → 3.15.1
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 +2 -0
- package/build/image/index.js +3 -3
- package/build/image/index.js.map +1 -1
- package/build/link/index.native.js +6 -4
- package/build/link/index.native.js.map +1 -1
- package/build/link/inline.js +5 -5
- package/build/link/inline.js.map +1 -1
- package/build/text-color/index.js +1 -7
- package/build/text-color/index.js.map +1 -1
- package/build/text-color/index.native.js +1 -3
- package/build/text-color/index.native.js.map +1 -1
- package/build/text-color/inline.js +8 -12
- package/build/text-color/inline.js.map +1 -1
- package/build-module/image/index.js +4 -4
- package/build-module/image/index.js.map +1 -1
- package/build-module/link/index.native.js +6 -3
- package/build-module/link/index.native.js.map +1 -1
- package/build-module/link/inline.js +6 -6
- package/build-module/link/inline.js.map +1 -1
- package/build-module/text-color/index.js +1 -6
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/index.native.js +1 -2
- package/build-module/text-color/index.native.js.map +1 -1
- package/build-module/text-color/inline.js +9 -12
- package/build-module/text-color/inline.js.map +1 -1
- package/package.json +13 -14
- package/src/image/index.js +4 -4
- package/src/link/index.native.js +10 -3
- package/src/link/inline.js +9 -5
- package/src/text-color/index.js +1 -6
- package/src/text-color/index.native.js +1 -2
- package/src/text-color/inline.js +11 -12
- package/src/text-color/test/index.native.js +3 -3
- package/src/link/test/inline.js +0 -15
package/src/link/index.native.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find } from 'lodash';
|
|
5
4
|
import Clipboard from '@react-native-clipboard/clipboard';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -86,13 +85,21 @@ export const link = {
|
|
|
86
85
|
let startIndex = value.start;
|
|
87
86
|
let endIndex = value.end;
|
|
88
87
|
|
|
89
|
-
while (
|
|
88
|
+
while (
|
|
89
|
+
value.formats[ startIndex ]?.find(
|
|
90
|
+
( format ) => format?.type === startFormat.type
|
|
91
|
+
)
|
|
92
|
+
) {
|
|
90
93
|
startIndex--;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
endIndex++;
|
|
94
97
|
|
|
95
|
-
while (
|
|
98
|
+
while (
|
|
99
|
+
value.formats[ endIndex ]?.find(
|
|
100
|
+
( format ) => format?.type === startFormat.type
|
|
101
|
+
)
|
|
102
|
+
) {
|
|
96
103
|
endIndex++;
|
|
97
104
|
}
|
|
98
105
|
|
package/src/link/inline.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
insert,
|
|
11
11
|
isCollapsed,
|
|
12
12
|
applyFormat,
|
|
13
|
-
|
|
13
|
+
useAnchor,
|
|
14
14
|
removeFormat,
|
|
15
15
|
slice,
|
|
16
16
|
replace,
|
|
@@ -183,13 +183,17 @@ function InlineLinkUI( {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
const
|
|
186
|
+
const popoverAnchor = useAnchor( {
|
|
187
|
+
editableContentElement: contentRef.current,
|
|
188
|
+
value,
|
|
189
|
+
settings,
|
|
190
|
+
} );
|
|
187
191
|
|
|
188
192
|
// Generate a string based key that is unique to this anchor reference.
|
|
189
193
|
// This is used to force re-mount the LinkControl component to avoid
|
|
190
194
|
// potential stale state bugs caused by the component not being remounted
|
|
191
195
|
// See https://github.com/WordPress/gutenberg/pull/34742.
|
|
192
|
-
const forceRemountKey = useLinkInstanceKey(
|
|
196
|
+
const forceRemountKey = useLinkInstanceKey( popoverAnchor );
|
|
193
197
|
|
|
194
198
|
// The focusOnMount prop shouldn't evolve during render of a Popover
|
|
195
199
|
// otherwise it causes a render of the content.
|
|
@@ -223,11 +227,11 @@ function InlineLinkUI( {
|
|
|
223
227
|
|
|
224
228
|
return (
|
|
225
229
|
<Popover
|
|
226
|
-
|
|
230
|
+
anchor={ popoverAnchor }
|
|
227
231
|
focusOnMount={ focusOnMount.current }
|
|
228
232
|
onClose={ stopAddingLink }
|
|
229
233
|
position="bottom center"
|
|
230
|
-
|
|
234
|
+
shift
|
|
231
235
|
>
|
|
232
236
|
<LinkControl
|
|
233
237
|
key={ forceRemountKey }
|
package/src/text-color/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isEmpty } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -82,7 +77,7 @@ function TextColorEdit( {
|
|
|
82
77
|
[ value, colors ]
|
|
83
78
|
);
|
|
84
79
|
|
|
85
|
-
const hasColorsToChoose =
|
|
80
|
+
const hasColorsToChoose = colors.length || ! allowCustomControl;
|
|
86
81
|
if ( ! hasColorsToChoose && ! isActive ) {
|
|
87
82
|
return null;
|
|
88
83
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { isEmpty } from 'lodash';
|
|
5
4
|
import { View } from 'react-native';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -89,7 +88,7 @@ function TextColorEdit( {
|
|
|
89
88
|
[ value, colors ]
|
|
90
89
|
);
|
|
91
90
|
|
|
92
|
-
const hasColorsToChoose =
|
|
91
|
+
const hasColorsToChoose = colors.length || ! allowCustomControl;
|
|
93
92
|
|
|
94
93
|
const onPressButton = useCallback( () => {
|
|
95
94
|
if ( hasColorsToChoose ) {
|
package/src/text-color/inline.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -12,7 +7,7 @@ import {
|
|
|
12
7
|
applyFormat,
|
|
13
8
|
removeFormat,
|
|
14
9
|
getActiveFormat,
|
|
15
|
-
|
|
10
|
+
useAnchor,
|
|
16
11
|
} from '@wordpress/rich-text';
|
|
17
12
|
import {
|
|
18
13
|
ColorPalette,
|
|
@@ -112,7 +107,7 @@ function setColors( value, name, colorSettings, colors ) {
|
|
|
112
107
|
function ColorPicker( { name, property, value, onChange } ) {
|
|
113
108
|
const colors = useSelect( ( select ) => {
|
|
114
109
|
const { getSettings } = select( blockEditorStore );
|
|
115
|
-
return
|
|
110
|
+
return getSettings().colors ?? [];
|
|
116
111
|
}, [] );
|
|
117
112
|
const onColorChange = useCallback(
|
|
118
113
|
( color ) => {
|
|
@@ -142,22 +137,26 @@ export default function InlineColorUI( {
|
|
|
142
137
|
onClose,
|
|
143
138
|
contentRef,
|
|
144
139
|
} ) {
|
|
145
|
-
/*
|
|
140
|
+
/*
|
|
146
141
|
As you change the text color by typing a HEX value into a field,
|
|
147
142
|
the return value of document.getSelection jumps to the field you're editing,
|
|
148
|
-
not the highlighted text. Given that
|
|
143
|
+
not the highlighted text. Given that useAnchor uses document.getSelection,
|
|
149
144
|
it will return null, since it can't find the <mark> element within the HEX input.
|
|
150
145
|
This caches the last truthy value of the selection anchor reference.
|
|
151
146
|
*/
|
|
152
|
-
const
|
|
153
|
-
|
|
147
|
+
const popoverAnchor = useCachedTruthy(
|
|
148
|
+
useAnchor( {
|
|
149
|
+
editableContentElement: contentRef.current,
|
|
150
|
+
value,
|
|
151
|
+
settings,
|
|
152
|
+
} )
|
|
154
153
|
);
|
|
155
154
|
|
|
156
155
|
return (
|
|
157
156
|
<Popover
|
|
158
157
|
onClose={ onClose }
|
|
159
158
|
className="components-inline-color-popover"
|
|
160
|
-
|
|
159
|
+
anchor={ popoverAnchor }
|
|
161
160
|
>
|
|
162
161
|
<TabPanel
|
|
163
162
|
tabs={ [
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
* WordPress dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { setDefaultBlockName, unregisterBlockType } from '@wordpress/blocks';
|
|
15
|
-
import {
|
|
15
|
+
import { coreBlocks } from '@wordpress/block-library';
|
|
16
16
|
|
|
17
17
|
const COLOR_PINK = '#f78da7';
|
|
18
18
|
const paragraph = coreBlocks[ 'core/paragraph' ];
|
|
@@ -22,7 +22,7 @@ const TEXT_WITH_COLOR = `<!-- wp:paragraph -->
|
|
|
22
22
|
<!-- /wp:paragraph -->`;
|
|
23
23
|
|
|
24
24
|
beforeAll( () => {
|
|
25
|
-
|
|
25
|
+
paragraph.init();
|
|
26
26
|
setDefaultBlockName( paragraph.name );
|
|
27
27
|
} );
|
|
28
28
|
|
|
@@ -164,7 +164,7 @@ describe( 'Text color', () => {
|
|
|
164
164
|
initialHtml: `<!-- wp:paragraph -->
|
|
165
165
|
<p>this <span class="has-inline-color has-green-color">is</span> <span class="has-inline-color has-red-color">test</span></p>
|
|
166
166
|
<!-- /wp:paragraph -->
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
<!-- wp:paragraph -->
|
|
169
169
|
<p><span style="color:#08a5e9" class="has-inline-color">this is a test</span></p>
|
|
170
170
|
<!-- /wp:paragraph -->`,
|
package/src/link/test/inline.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import InlineLinkUI from '../inline';
|
|
5
|
-
/**
|
|
6
|
-
* External dependencies
|
|
7
|
-
*/
|
|
8
|
-
import { shallow } from 'enzyme';
|
|
9
|
-
|
|
10
|
-
describe( 'InlineLinkUI', () => {
|
|
11
|
-
it( 'InlineLinkUI renders', () => {
|
|
12
|
-
const wrapper = shallow( <InlineLinkUI /> );
|
|
13
|
-
expect( wrapper ).toBeTruthy();
|
|
14
|
-
} );
|
|
15
|
-
} );
|