@wordpress/format-library 3.0.5 → 3.0.9
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 +8 -6
- package/build/bold/index.js.map +1 -1
- package/build/code/index.js +8 -6
- package/build/code/index.js.map +1 -1
- package/build/image/index.js +27 -23
- package/build/image/index.js.map +1 -1
- package/build/index.js +7 -4
- package/build/index.js.map +1 -1
- package/build/italic/index.js +8 -6
- package/build/italic/index.js.map +1 -1
- package/build/keyboard/index.js +8 -6
- package/build/keyboard/index.js.map +1 -1
- package/build/link/index.js +15 -12
- package/build/link/index.js.map +1 -1
- package/build/link/inline.js +22 -11
- package/build/link/inline.js.map +1 -1
- package/build/link/modal-screens/link-picker-screen.native.js +6 -4
- package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build/link/modal-screens/link-settings-screen.native.js +15 -12
- package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build/link/modal.native.js +5 -4
- package/build/link/modal.native.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 +11 -8
- package/build/link/utils.js.map +1 -1
- package/build/strikethrough/index.js +8 -6
- package/build/strikethrough/index.js.map +1 -1
- package/build/subscript/index.js +8 -6
- package/build/subscript/index.js.map +1 -1
- package/build/superscript/index.js +8 -6
- package/build/superscript/index.js.map +1 -1
- package/build/text-color/index.js +18 -13
- package/build/text-color/index.js.map +1 -1
- package/build/text-color/inline.js +22 -16
- package/build/text-color/inline.js.map +1 -1
- package/build/underline/index.js +6 -4
- package/build/underline/index.js.map +1 -1
- package/build-module/bold/index.js +8 -6
- package/build-module/bold/index.js.map +1 -1
- package/build-module/code/index.js +8 -6
- package/build-module/code/index.js.map +1 -1
- package/build-module/image/index.js +27 -23
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +7 -4
- package/build-module/index.js.map +1 -1
- package/build-module/italic/index.js +8 -6
- package/build-module/italic/index.js.map +1 -1
- package/build-module/keyboard/index.js +8 -6
- package/build-module/keyboard/index.js.map +1 -1
- package/build-module/link/index.js +15 -12
- package/build-module/link/index.js.map +1 -1
- package/build-module/link/inline.js +19 -11
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +6 -4
- package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build-module/link/modal-screens/link-settings-screen.native.js +15 -12
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build-module/link/modal.native.js +5 -4
- package/build-module/link/modal.native.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 +10 -7
- package/build-module/link/utils.js.map +1 -1
- package/build-module/strikethrough/index.js +8 -6
- package/build-module/strikethrough/index.js.map +1 -1
- package/build-module/subscript/index.js +8 -6
- package/build-module/subscript/index.js.map +1 -1
- package/build-module/superscript/index.js +8 -6
- package/build-module/superscript/index.js.map +1 -1
- package/build-module/text-color/index.js +14 -11
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/inline.js +21 -15
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/underline/index.js +6 -4
- package/build-module/underline/index.js.map +1 -1
- package/package.json +16 -16
- package/src/link/inline.js +8 -0
- package/src/link/use-link-instance-key.js +34 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,24 +25,24 @@
|
|
|
25
25
|
"module": "build-module/index.js",
|
|
26
26
|
"react-native": "src/index",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@babel/runtime": "^7.
|
|
29
|
-
"@wordpress/a11y": "^3.2.
|
|
30
|
-
"@wordpress/block-editor": "^8.0.
|
|
31
|
-
"@wordpress/components": "^19.0.
|
|
32
|
-
"@wordpress/compose": "^5.0.
|
|
33
|
-
"@wordpress/data": "^6.1.
|
|
34
|
-
"@wordpress/dom": "^3.2.
|
|
35
|
-
"@wordpress/element": "^4.0.
|
|
36
|
-
"@wordpress/html-entities": "^3.2.
|
|
37
|
-
"@wordpress/i18n": "^4.2.
|
|
38
|
-
"@wordpress/icons": "^6.1.
|
|
39
|
-
"@wordpress/keycodes": "^3.2.
|
|
40
|
-
"@wordpress/rich-text": "^5.0.
|
|
41
|
-
"@wordpress/url": "^3.3.
|
|
28
|
+
"@babel/runtime": "^7.16.0",
|
|
29
|
+
"@wordpress/a11y": "^3.2.4",
|
|
30
|
+
"@wordpress/block-editor": "^8.0.3",
|
|
31
|
+
"@wordpress/components": "^19.0.3",
|
|
32
|
+
"@wordpress/compose": "^5.0.6",
|
|
33
|
+
"@wordpress/data": "^6.1.4",
|
|
34
|
+
"@wordpress/dom": "^3.2.7",
|
|
35
|
+
"@wordpress/element": "^4.0.4",
|
|
36
|
+
"@wordpress/html-entities": "^3.2.3",
|
|
37
|
+
"@wordpress/i18n": "^4.2.4",
|
|
38
|
+
"@wordpress/icons": "^6.1.1",
|
|
39
|
+
"@wordpress/keycodes": "^3.2.4",
|
|
40
|
+
"@wordpress/rich-text": "^5.0.6",
|
|
41
|
+
"@wordpress/url": "^3.3.1",
|
|
42
42
|
"lodash": "^4.17.21"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c6594e767659bd3289e633a17c44fdf6a4933194"
|
|
48
48
|
}
|
package/src/link/inline.js
CHANGED
|
@@ -26,6 +26,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
26
26
|
*/
|
|
27
27
|
import { createLinkFormat, isValidHref, getFormatBoundary } from './utils';
|
|
28
28
|
import { link as settings } from './index';
|
|
29
|
+
import useLinkInstanceKey from './use-link-instance-key';
|
|
29
30
|
|
|
30
31
|
function InlineLinkUI( {
|
|
31
32
|
isActive,
|
|
@@ -184,6 +185,12 @@ function InlineLinkUI( {
|
|
|
184
185
|
|
|
185
186
|
const anchorRef = useAnchorRef( { ref: contentRef, value, settings } );
|
|
186
187
|
|
|
188
|
+
// Generate a string based key that is unique to this anchor reference.
|
|
189
|
+
// This is used to force re-mount the LinkControl component to avoid
|
|
190
|
+
// potential stale state bugs caused by the component not being remounted
|
|
191
|
+
// See https://github.com/WordPress/gutenberg/pull/34742.
|
|
192
|
+
const forceRemountKey = useLinkInstanceKey( anchorRef );
|
|
193
|
+
|
|
187
194
|
// The focusOnMount prop shouldn't evolve during render of a Popover
|
|
188
195
|
// otherwise it causes a render of the content.
|
|
189
196
|
const focusOnMount = useRef( addingLink ? 'firstElement' : false );
|
|
@@ -222,6 +229,7 @@ function InlineLinkUI( {
|
|
|
222
229
|
position="bottom center"
|
|
223
230
|
>
|
|
224
231
|
<LinkControl
|
|
232
|
+
key={ forceRemountKey }
|
|
225
233
|
value={ linkValue }
|
|
226
234
|
onChange={ onChangeLink }
|
|
227
235
|
onRemove={ removeLink }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Weakly referenced map allows unused ids to be garbage collected.
|
|
2
|
+
const weakMap = new WeakMap();
|
|
3
|
+
|
|
4
|
+
// Incrementing zero-based ID value
|
|
5
|
+
let id = -1;
|
|
6
|
+
|
|
7
|
+
const prefix = 'link-control-instance';
|
|
8
|
+
|
|
9
|
+
function getKey( _id ) {
|
|
10
|
+
return `${ prefix }-${ _id }`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Builds a unique link control key for the given object reference.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} instance an unique object reference specific to this link control instance.
|
|
17
|
+
* @return {string} the unique key to use for this link control.
|
|
18
|
+
*/
|
|
19
|
+
function useLinkInstanceKey( instance ) {
|
|
20
|
+
if ( ! instance ) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if ( weakMap.has( instance ) ) {
|
|
24
|
+
return getKey( weakMap.get( instance ) );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
id += 1;
|
|
28
|
+
|
|
29
|
+
weakMap.set( instance, id );
|
|
30
|
+
|
|
31
|
+
return getKey( id );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default useLinkInstanceKey;
|