@wordpress/format-library 4.15.0 → 4.17.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 +4 -0
- package/build/bold/index.js +1 -10
- package/build/bold/index.js.map +1 -1
- package/build/code/index.js +3 -17
- package/build/code/index.js.map +1 -1
- package/build/default-formats.js +0 -14
- package/build/default-formats.js.map +1 -1
- package/build/default-formats.native.js +0 -6
- package/build/default-formats.native.js.map +1 -1
- package/build/image/index.js +5 -14
- package/build/image/index.js.map +1 -1
- package/build/index.js +1 -3
- package/build/index.js.map +1 -1
- package/build/italic/index.js +1 -10
- package/build/italic/index.js.map +1 -1
- package/build/keyboard/index.js +1 -10
- package/build/keyboard/index.js.map +1 -1
- package/build/language/index.js +1 -11
- package/build/language/index.js.map +1 -1
- package/build/link/index.js +5 -26
- package/build/link/index.js.map +1 -1
- package/build/link/index.native.js +14 -39
- package/build/link/index.native.js.map +1 -1
- package/build/link/inline.js +47 -84
- package/build/link/inline.js.map +1 -1
- package/build/link/modal-screens/link-picker-screen.native.js +1 -13
- package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
- package/build/link/modal-screens/link-settings-screen.native.js +9 -36
- package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build/link/modal-screens/screens.native.js.map +1 -1
- package/build/link/modal.native.js +1 -9
- package/build/link/modal.native.js.map +1 -1
- package/build/link/use-link-instance-key.js +3 -7
- package/build/link/use-link-instance-key.js.map +1 -1
- package/build/link/utils.js +23 -47
- package/build/link/utils.js.map +1 -1
- package/build/strikethrough/index.js +1 -9
- package/build/strikethrough/index.js.map +1 -1
- package/build/subscript/index.js +1 -10
- package/build/subscript/index.js.map +1 -1
- package/build/superscript/index.js +1 -10
- package/build/superscript/index.js.map +1 -1
- package/build/text-color/index.js +7 -25
- package/build/text-color/index.js.map +1 -1
- package/build/text-color/index.native.js +11 -34
- package/build/text-color/index.native.js.map +1 -1
- package/build/text-color/inline.js +5 -26
- package/build/text-color/inline.js.map +1 -1
- package/build/text-color/inline.native.js +9 -25
- package/build/text-color/inline.native.js.map +1 -1
- package/build/underline/index.js +1 -8
- package/build/underline/index.js.map +1 -1
- package/build/unknown/index.js +1 -11
- package/build/unknown/index.js.map +1 -1
- package/build-module/bold/index.js +0 -7
- package/build-module/bold/index.js.map +1 -1
- package/build-module/code/index.js +2 -14
- package/build-module/code/index.js.map +1 -1
- package/build-module/default-formats.js.map +1 -1
- package/build-module/default-formats.native.js.map +1 -1
- package/build-module/image/index.js +4 -10
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/italic/index.js +0 -7
- package/build-module/italic/index.js.map +1 -1
- package/build-module/keyboard/index.js +0 -7
- package/build-module/keyboard/index.js.map +1 -1
- package/build-module/language/index.js +1 -8
- package/build-module/language/index.js.map +1 -1
- package/build-module/link/index.js +5 -17
- package/build-module/link/index.js.map +1 -1
- package/build-module/link/index.native.js +15 -30
- package/build-module/link/index.native.js.map +1 -1
- package/build-module/link/inline.js +45 -72
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +2 -8
- 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 +10 -28
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build-module/link/modal-screens/screens.native.js.map +1 -1
- package/build-module/link/modal.native.js +1 -4
- package/build-module/link/modal.native.js.map +1 -1
- package/build-module/link/use-link-instance-key.js +3 -7
- package/build-module/link/use-link-instance-key.js.map +1 -1
- package/build-module/link/utils.js +24 -43
- package/build-module/link/utils.js.map +1 -1
- package/build-module/strikethrough/index.js +0 -6
- package/build-module/strikethrough/index.js.map +1 -1
- package/build-module/subscript/index.js +0 -7
- package/build-module/subscript/index.js.map +1 -1
- package/build-module/superscript/index.js +0 -7
- package/build-module/superscript/index.js.map +1 -1
- package/build-module/text-color/index.js +7 -20
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/index.native.js +12 -24
- package/build-module/text-color/index.native.js.map +1 -1
- package/build-module/text-color/inline.js +5 -20
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/text-color/inline.native.js +9 -21
- package/build-module/text-color/inline.native.js.map +1 -1
- package/build-module/underline/index.js +0 -6
- package/build-module/underline/index.js.map +1 -1
- package/build-module/unknown/index.js +0 -8
- package/build-module/unknown/index.js.map +1 -1
- package/package.json +13 -13
- package/src/link/inline.js +14 -37
- package/src/link/test/__snapshots__/modal.native.js.snap +372 -295
- package/src/text-color/test/index.native.js +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["__","removeFormat","slice","RichTextToolbarButton","help","name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type","createElement","icon"],"sources":["@wordpress/format-library/src/unknown/index.js"],"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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
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.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,17 +26,17 @@
|
|
|
26
26
|
"react-native": "src/index",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/a11y": "^3.
|
|
30
|
-
"@wordpress/block-editor": "^12.
|
|
31
|
-
"@wordpress/components": "^25.
|
|
32
|
-
"@wordpress/compose": "^6.
|
|
33
|
-
"@wordpress/data": "^9.
|
|
34
|
-
"@wordpress/element": "^5.
|
|
35
|
-
"@wordpress/html-entities": "^3.
|
|
36
|
-
"@wordpress/i18n": "^4.
|
|
37
|
-
"@wordpress/icons": "^9.
|
|
38
|
-
"@wordpress/rich-text": "^6.
|
|
39
|
-
"@wordpress/url": "^3.
|
|
29
|
+
"@wordpress/a11y": "^3.40.0",
|
|
30
|
+
"@wordpress/block-editor": "^12.8.0",
|
|
31
|
+
"@wordpress/components": "^25.6.0",
|
|
32
|
+
"@wordpress/compose": "^6.17.0",
|
|
33
|
+
"@wordpress/data": "^9.10.0",
|
|
34
|
+
"@wordpress/element": "^5.17.0",
|
|
35
|
+
"@wordpress/html-entities": "^3.40.0",
|
|
36
|
+
"@wordpress/i18n": "^4.40.0",
|
|
37
|
+
"@wordpress/icons": "^9.31.0",
|
|
38
|
+
"@wordpress/rich-text": "^6.17.0",
|
|
39
|
+
"@wordpress/url": "^3.41.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^18.0.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
|
|
49
49
|
}
|
package/src/link/inline.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useRef, createInterpolateElement } from '@wordpress/element';
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
6
|
+
import { speak } from '@wordpress/a11y';
|
|
7
|
+
import { Popover } from '@wordpress/components';
|
|
7
8
|
import { prependHTTP } from '@wordpress/url';
|
|
8
9
|
import {
|
|
9
10
|
create,
|
|
@@ -36,7 +37,6 @@ function InlineLinkUI( {
|
|
|
36
37
|
addingLink,
|
|
37
38
|
value,
|
|
38
39
|
onChange,
|
|
39
|
-
speak,
|
|
40
40
|
stopAddingLink,
|
|
41
41
|
contentRef,
|
|
42
42
|
} ) {
|
|
@@ -45,16 +45,6 @@ function InlineLinkUI( {
|
|
|
45
45
|
// Get the text content minus any HTML tags.
|
|
46
46
|
const richTextText = richLinkTextValue.text;
|
|
47
47
|
|
|
48
|
-
/**
|
|
49
|
-
* Pending settings to be applied to the next link. When inserting a new
|
|
50
|
-
* link, toggle values cannot be applied immediately, because there is not
|
|
51
|
-
* yet a link for them to apply to. Thus, they are maintained in a state
|
|
52
|
-
* value until the time that the link can be inserted or edited.
|
|
53
|
-
*
|
|
54
|
-
* @type {[Object|undefined,Function]}
|
|
55
|
-
*/
|
|
56
|
-
const [ nextLinkValue, setNextLinkValue ] = useState();
|
|
57
|
-
|
|
58
48
|
const { createPageEntity, userCanCreatePages } = useSelect( ( select ) => {
|
|
59
49
|
const { getSettings } = select( blockEditorStore );
|
|
60
50
|
const _settings = getSettings();
|
|
@@ -71,7 +61,6 @@ function InlineLinkUI( {
|
|
|
71
61
|
id: activeAttributes.id,
|
|
72
62
|
opensInNewTab: activeAttributes.target === '_blank',
|
|
73
63
|
title: richTextText,
|
|
74
|
-
...nextLinkValue,
|
|
75
64
|
};
|
|
76
65
|
|
|
77
66
|
function removeLink() {
|
|
@@ -82,32 +71,18 @@ function InlineLinkUI( {
|
|
|
82
71
|
}
|
|
83
72
|
|
|
84
73
|
function onChangeLink( nextValue ) {
|
|
85
|
-
// Merge with values from state, both for the purpose of assigning the
|
|
86
|
-
// next state value, and for use in constructing the new link format if
|
|
87
|
-
// the link is ready to be applied.
|
|
88
|
-
nextValue = {
|
|
89
|
-
...nextLinkValue,
|
|
90
|
-
...nextValue,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
74
|
// LinkControl calls `onChange` immediately upon the toggling a setting.
|
|
75
|
+
// Before merging the next value with the current link value, check if
|
|
76
|
+
// the setting was toggled.
|
|
94
77
|
const didToggleSetting =
|
|
95
78
|
linkValue.opensInNewTab !== nextValue.opensInNewTab &&
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// If change handler was called as a result of a settings change during
|
|
99
|
-
// link insertion, it must be held in state until the link is ready to
|
|
100
|
-
// be applied.
|
|
101
|
-
const didToggleSettingForNewLink =
|
|
102
|
-
didToggleSetting && nextValue.url === undefined;
|
|
79
|
+
nextValue.url === undefined;
|
|
103
80
|
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
81
|
+
// Merge the next value with the current link value.
|
|
82
|
+
nextValue = {
|
|
83
|
+
...linkValue,
|
|
84
|
+
...nextValue,
|
|
85
|
+
};
|
|
111
86
|
|
|
112
87
|
const newUrl = prependHTTP( nextValue.url );
|
|
113
88
|
const linkFormat = createLinkFormat( {
|
|
@@ -185,6 +160,8 @@ function InlineLinkUI( {
|
|
|
185
160
|
}
|
|
186
161
|
|
|
187
162
|
newValue.start = newValue.end;
|
|
163
|
+
|
|
164
|
+
// Hides the Link UI.
|
|
188
165
|
newValue.activeFormats = [];
|
|
189
166
|
onChange( newValue );
|
|
190
167
|
}
|
|
@@ -299,4 +276,4 @@ function getRichTextValueFromSelection( value, isActive ) {
|
|
|
299
276
|
return slice( value, textStart, textEnd );
|
|
300
277
|
}
|
|
301
278
|
|
|
302
|
-
export default
|
|
279
|
+
export default InlineLinkUI;
|