@wordpress/block-library 9.26.1-next.719a03cbe.0 → 9.27.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 +2 -0
- package/build/cover/edit/block-controls.js +4 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js +6 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +11 -4
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit/poster-image.js +81 -0
- package/build/cover/edit/poster-image.js.map +1 -0
- package/build/cover/index.js +6 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +3 -1
- package/build/cover/save.js.map +1 -1
- package/build/media-text/edit.js +2 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/navigation-link/edit.js +32 -15
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/update-attributes.js +112 -14
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/edit.js +19 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/post-content/edit.js +78 -16
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +6 -0
- package/build/post-content/index.js.map +1 -1
- package/build/separator/edit.js +5 -30
- package/build/separator/edit.js.map +1 -1
- package/build/site-tagline/index.js +1 -1
- package/build/video/edit.js +2 -5
- package/build/video/edit.js.map +1 -1
- package/build/video/poster-image.js +25 -25
- package/build/video/poster-image.js.map +1 -1
- package/build/video/tracks-editor.js +95 -104
- package/build/video/tracks-editor.js.map +1 -1
- package/build/video/tracks.js +6 -2
- package/build/video/tracks.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +4 -2
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +6 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +10 -4
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit/poster-image.js +74 -0
- package/build-module/cover/edit/poster-image.js.map +1 -0
- package/build-module/cover/index.js +6 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +3 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/media-text/edit.js +2 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/navigation-link/edit.js +32 -15
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +113 -15
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +20 -3
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/post-content/edit.js +80 -18
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +6 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/separator/edit.js +6 -31
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -1
- package/build-module/video/edit.js +2 -5
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/poster-image.js +26 -26
- package/build-module/video/poster-image.js.map +1 -1
- package/build-module/video/tracks-editor.js +96 -105
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-module/video/tracks.js +6 -2
- package/build-module/video/tracks.js.map +1 -1
- package/build-style/archives/editor-rtl.css +0 -4
- package/build-style/archives/editor.css +0 -4
- package/build-style/editor-rtl.css +0 -8
- package/build-style/editor.css +0 -8
- package/build-style/file/style-rtl.css +1 -1
- package/build-style/file/style.css +1 -1
- package/build-style/navigation/style-rtl.css +1 -0
- package/build-style/navigation/style.css +1 -0
- package/build-style/style-rtl.css +2 -1
- package/build-style/style.css +2 -1
- package/build-style/video/editor-rtl.css +0 -4
- package/build-style/video/editor.css +0 -4
- package/package.json +35 -35
- package/src/archives/editor.scss +0 -4
- package/src/comments-pagination/index.php +7 -2
- package/src/cover/block.json +6 -0
- package/src/cover/edit/block-controls.js +22 -17
- package/src/cover/edit/index.js +4 -1
- package/src/cover/edit/inspector-controls.js +11 -2
- package/src/cover/edit/poster-image.js +91 -0
- package/src/cover/save.js +2 -0
- package/src/file/style.scss +1 -1
- package/src/media-text/edit.js +1 -1
- package/src/navigation/style.scss +1 -0
- package/src/navigation-link/edit.js +28 -16
- package/src/navigation-link/test/edit.js +738 -6
- package/src/navigation-link/update-attributes.js +125 -12
- package/src/navigation-submenu/edit.js +21 -1
- package/src/post-content/block.json +6 -0
- package/src/post-content/edit.js +71 -19
- package/src/post-content/index.php +11 -4
- package/src/post-featured-image/index.php +3 -2
- package/src/separator/edit.js +8 -43
- package/src/site-tagline/block.json +1 -1
- package/src/video/edit.js +1 -4
- package/src/video/editor.scss +0 -6
- package/src/video/poster-image.js +29 -24
- package/src/video/tracks-editor.js +93 -103
- package/src/video/tracks.js +2 -1
|
@@ -1,8 +1,82 @@
|
|
|
1
|
+
/* wp:polyfill */
|
|
1
2
|
/**
|
|
2
3
|
* WordPress dependencies
|
|
3
4
|
*/
|
|
4
5
|
import { escapeHTML } from '@wordpress/escape-html';
|
|
5
|
-
import { safeDecodeURI } from '@wordpress/url';
|
|
6
|
+
import { safeDecodeURI, getPath } from '@wordpress/url';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Determines if an entity link should be severed based on URL changes.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} originalUrl - The original URL
|
|
12
|
+
* @param {string} newUrl - The new URL
|
|
13
|
+
* @return {boolean} True if the entity link should be severed
|
|
14
|
+
*/
|
|
15
|
+
const shouldSeverEntityLink = (originalUrl, newUrl) => {
|
|
16
|
+
if (!originalUrl || !newUrl) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const normalizePath = path => {
|
|
20
|
+
if (!path) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
return path.replace(/\/+$/, ''); // Remove trailing slashes
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Helper function to create URL objects with proper base handling
|
|
27
|
+
const createUrlObject = (url, baseUrl = null) => {
|
|
28
|
+
try {
|
|
29
|
+
// Always provide a base URL - it will be ignored for absolute URLs
|
|
30
|
+
// Use window.location.origin in browser, fallback for Node/tests
|
|
31
|
+
const base = baseUrl || (typeof window !== 'undefined' ? window.location.origin : 'https://wordpress.org');
|
|
32
|
+
return new URL(url, base);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// If URL construction still fails, it's likely an invalid URL
|
|
35
|
+
// and we should sever the entity link
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const originalUrlObj = createUrlObject(originalUrl);
|
|
40
|
+
if (!originalUrlObj) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const newUrlObj = createUrlObject(newUrl, originalUrl);
|
|
44
|
+
if (!newUrlObj) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Move these declarations here, after the null checks
|
|
49
|
+
const originalHostname = originalUrlObj.hostname;
|
|
50
|
+
const newHostname = newUrlObj.hostname;
|
|
51
|
+
const originalPath = normalizePath(getPath(originalUrlObj.toString()));
|
|
52
|
+
const newPath = normalizePath(getPath(newUrlObj.toString()));
|
|
53
|
+
|
|
54
|
+
// If hostname or path changed, sever the entity link
|
|
55
|
+
if (originalHostname !== newHostname || originalPath !== newPath) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Special handling for plain permalinks (query string post IDs)
|
|
60
|
+
const originalP = originalUrlObj.searchParams.get('p');
|
|
61
|
+
const newP = newUrlObj.searchParams.get('p');
|
|
62
|
+
|
|
63
|
+
// If both are plain permalinks (with ?p= or ?page_id=), compare the IDs
|
|
64
|
+
if (originalP && newP && originalP !== newP) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
const originalPageId = originalUrlObj.searchParams.get('page_id');
|
|
68
|
+
const newPageId = newUrlObj.searchParams.get('page_id');
|
|
69
|
+
if (originalPageId && newPageId && originalPageId !== newPageId) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
// If switching between ?p= and ?page_id=, or one is missing, sever
|
|
73
|
+
if (originalP && newPageId || originalPageId && newP) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If only query string or fragment changed, preserve the entity link
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
6
80
|
|
|
7
81
|
/**
|
|
8
82
|
* @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
|
|
@@ -30,6 +104,7 @@ import { safeDecodeURI } from '@wordpress/url';
|
|
|
30
104
|
*/
|
|
31
105
|
|
|
32
106
|
export const updateAttributes = (updatedValue = {}, setAttributes, blockAttributes = {}) => {
|
|
107
|
+
var _newUrl$replace;
|
|
33
108
|
const {
|
|
34
109
|
label: originalLabel = '',
|
|
35
110
|
kind: originalKind = '',
|
|
@@ -38,15 +113,20 @@ export const updateAttributes = (updatedValue = {}, setAttributes, blockAttribut
|
|
|
38
113
|
const {
|
|
39
114
|
title: newLabel = '',
|
|
40
115
|
// the title of any provided Post.
|
|
41
|
-
|
|
116
|
+
label: newLabelFromLabel = '',
|
|
117
|
+
// alternative to title
|
|
118
|
+
url: newUrl,
|
|
42
119
|
opensInNewTab,
|
|
43
|
-
id,
|
|
120
|
+
id: newID,
|
|
44
121
|
kind: newKind = originalKind,
|
|
45
122
|
type: newType = originalType
|
|
46
123
|
} = updatedValue;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
124
|
+
|
|
125
|
+
// Use title if provided, otherwise fall back to label
|
|
126
|
+
const finalNewLabel = newLabel || newLabelFromLabel;
|
|
127
|
+
const newLabelWithoutHttp = finalNewLabel.replace(/http(s?):\/\//gi, '');
|
|
128
|
+
const newUrlWithoutHttp = (_newUrl$replace = newUrl?.replace(/http(s?):\/\//gi, '')) !== null && _newUrl$replace !== void 0 ? _newUrl$replace : '';
|
|
129
|
+
const useNewLabel = finalNewLabel && finalNewLabel !== originalLabel &&
|
|
50
130
|
// LinkControl without the title field relies
|
|
51
131
|
// on the check below. Specifically, it assumes that
|
|
52
132
|
// the URL is the same as a title.
|
|
@@ -64,33 +144,51 @@ export const updateAttributes = (updatedValue = {}, setAttributes, blockAttribut
|
|
|
64
144
|
// See also:
|
|
65
145
|
// - https://github.com/WordPress/gutenberg/pull/41063
|
|
66
146
|
// - https://github.com/WordPress/gutenberg/pull/18617.
|
|
67
|
-
const label = useNewLabel ? escapeHTML(
|
|
147
|
+
const label = useNewLabel ? escapeHTML(finalNewLabel) : originalLabel || escapeHTML(newUrlWithoutHttp);
|
|
68
148
|
|
|
69
149
|
// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
|
|
70
150
|
const type = newType === 'post_tag' ? 'tag' : newType.replace('-', '_');
|
|
71
151
|
const isBuiltInType = ['post', 'page', 'tag', 'category'].indexOf(type) > -1;
|
|
72
152
|
const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
|
|
73
153
|
const kind = isCustomLink ? 'custom' : newKind;
|
|
74
|
-
|
|
154
|
+
const attributes = {
|
|
75
155
|
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
|
|
76
|
-
...(newUrl
|
|
77
|
-
url: encodeURI(safeDecodeURI(newUrl))
|
|
78
|
-
}),
|
|
156
|
+
...(newUrl !== undefined ? {
|
|
157
|
+
url: newUrl ? encodeURI(safeDecodeURI(newUrl)) : newUrl
|
|
158
|
+
} : {}),
|
|
79
159
|
...(label && {
|
|
80
160
|
label
|
|
81
161
|
}),
|
|
82
162
|
...(undefined !== opensInNewTab && {
|
|
83
163
|
opensInNewTab
|
|
84
164
|
}),
|
|
85
|
-
...(id && Number.isInteger(id) && {
|
|
86
|
-
id
|
|
87
|
-
}),
|
|
88
165
|
...(kind && {
|
|
89
166
|
kind
|
|
90
167
|
}),
|
|
91
168
|
...(type && type !== 'URL' && {
|
|
92
169
|
type
|
|
93
170
|
})
|
|
94
|
-
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// If the block's id is set then the menu item is linking to an entity.
|
|
174
|
+
// Therefore, if the URL is set but a new ID is not provided, check if
|
|
175
|
+
// the entity link should be severed based on URL changes.
|
|
176
|
+
if (newUrl && !newID && blockAttributes.id) {
|
|
177
|
+
const shouldSever = shouldSeverEntityLink(blockAttributes.url, newUrl);
|
|
178
|
+
if (shouldSever) {
|
|
179
|
+
attributes.id = undefined; // explicitly "unset" the ID.
|
|
180
|
+
// When URL is manually changed in a way that severs the entity link,
|
|
181
|
+
// update kind and type to "custom" to indicate this is now a custom link.
|
|
182
|
+
attributes.kind = 'custom';
|
|
183
|
+
attributes.type = 'custom';
|
|
184
|
+
}
|
|
185
|
+
} else if (newID && Number.isInteger(newID)) {
|
|
186
|
+
attributes.id = newID;
|
|
187
|
+
} else if (blockAttributes.id) {
|
|
188
|
+
// If we have an existing ID and no URL change, ensure kind and type are preserved
|
|
189
|
+
attributes.kind = kind;
|
|
190
|
+
attributes.type = type;
|
|
191
|
+
}
|
|
192
|
+
setAttributes(attributes);
|
|
95
193
|
};
|
|
96
194
|
//# sourceMappingURL=update-attributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["escapeHTML","safeDecodeURI","updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger"],"sources":["@wordpress/block-library/src/navigation-link/update-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,wBAAwB;AACnD,SAASC,aAAa,QAAQ,gBAAgB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,gBAAgB,GAAGA,CAC/BC,YAAY,GAAG,CAAC,CAAC,EACjBC,aAAa,EACbC,eAAe,GAAG,CAAC,CAAC,KAChB;EACJ,MAAM;IACLC,KAAK,EAAEC,aAAa,GAAG,EAAE;IACzBC,IAAI,EAAEC,YAAY,GAAG,EAAE;IACvBC,IAAI,EAAEC,YAAY,GAAG;EACtB,CAAC,GAAGN,eAAe;EAEnB,MAAM;IACLO,KAAK,EAAEC,QAAQ,GAAG,EAAE;IAAE;IACtBC,GAAG,EAAE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IACvD,IAAKC,EAAE,IAAIY,MAAM,CAACC,SAAS,CAAEb,EAAG,CAAC,IAAI;MAAEA;IAAG,CAAC,CAAE;IAC7C,IAAKT,IAAI,IAAI;MAAEA;IAAK,CAAC,CAAE;IACvB,IAAKE,IAAI,IAAIA,IAAI,KAAK,KAAK,IAAI;MAAEA;IAAK,CAAC;EACxC,CAAE,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["escapeHTML","safeDecodeURI","getPath","shouldSeverEntityLink","originalUrl","newUrl","normalizePath","path","replace","createUrlObject","url","baseUrl","base","window","location","origin","URL","error","originalUrlObj","newUrlObj","originalHostname","hostname","newHostname","originalPath","toString","newPath","originalP","searchParams","get","newP","originalPageId","newPageId","updateAttributes","updatedValue","setAttributes","blockAttributes","_newUrl$replace","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","newLabelFromLabel","opensInNewTab","id","newID","newKind","newType","finalNewLabel","newLabelWithoutHttp","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","attributes","undefined","encodeURI","shouldSever","Number","isInteger"],"sources":["@wordpress/block-library/src/navigation-link/update-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI, getPath } from '@wordpress/url';\n\n/**\n * Determines if an entity link should be severed based on URL changes.\n *\n * @param {string} originalUrl - The original URL\n * @param {string} newUrl - The new URL\n * @return {boolean} True if the entity link should be severed\n */\nconst shouldSeverEntityLink = ( originalUrl, newUrl ) => {\n\tif ( ! originalUrl || ! newUrl ) {\n\t\treturn false;\n\t}\n\n\tconst normalizePath = ( path ) => {\n\t\tif ( ! path ) {\n\t\t\treturn '';\n\t\t}\n\t\treturn path.replace( /\\/+$/, '' ); // Remove trailing slashes\n\t};\n\n\t// Helper function to create URL objects with proper base handling\n\tconst createUrlObject = ( url, baseUrl = null ) => {\n\t\ttry {\n\t\t\t// Always provide a base URL - it will be ignored for absolute URLs\n\t\t\t// Use window.location.origin in browser, fallback for Node/tests\n\t\t\tconst base =\n\t\t\t\tbaseUrl ||\n\t\t\t\t( typeof window !== 'undefined'\n\t\t\t\t\t? window.location.origin\n\t\t\t\t\t: 'https://wordpress.org' );\n\t\t\treturn new URL( url, base );\n\t\t} catch ( error ) {\n\t\t\t// If URL construction still fails, it's likely an invalid URL\n\t\t\t// and we should sever the entity link\n\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst originalUrlObj = createUrlObject( originalUrl );\n\tif ( ! originalUrlObj ) {\n\t\treturn true;\n\t}\n\n\tconst newUrlObj = createUrlObject( newUrl, originalUrl );\n\tif ( ! newUrlObj ) {\n\t\treturn true;\n\t}\n\n\t// Move these declarations here, after the null checks\n\tconst originalHostname = originalUrlObj.hostname;\n\tconst newHostname = newUrlObj.hostname;\n\tconst originalPath = normalizePath( getPath( originalUrlObj.toString() ) );\n\tconst newPath = normalizePath( getPath( newUrlObj.toString() ) );\n\n\t// If hostname or path changed, sever the entity link\n\tif ( originalHostname !== newHostname || originalPath !== newPath ) {\n\t\treturn true;\n\t}\n\n\t// Special handling for plain permalinks (query string post IDs)\n\tconst originalP = originalUrlObj.searchParams.get( 'p' );\n\tconst newP = newUrlObj.searchParams.get( 'p' );\n\n\t// If both are plain permalinks (with ?p= or ?page_id=), compare the IDs\n\tif ( originalP && newP && originalP !== newP ) {\n\t\treturn true;\n\t}\n\n\tconst originalPageId = originalUrlObj.searchParams.get( 'page_id' );\n\tconst newPageId = newUrlObj.searchParams.get( 'page_id' );\n\n\tif ( originalPageId && newPageId && originalPageId !== newPageId ) {\n\t\treturn true;\n\t}\n\t// If switching between ?p= and ?page_id=, or one is missing, sever\n\tif ( ( originalP && newPageId ) || ( originalPageId && newP ) ) {\n\t\treturn true;\n\t}\n\n\t// If only query string or fragment changed, preserve the entity link\n\treturn false;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\tlabel: newLabelFromLabel = '', // alternative to title\n\t\turl: newUrl,\n\t\topensInNewTab,\n\t\tid: newID,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\t// Use title if provided, otherwise fall back to label\n\tconst finalNewLabel = newLabel || newLabelFromLabel;\n\n\tconst newLabelWithoutHttp = finalNewLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl?.replace( /http(s?):\\/\\//gi, '' ) ?? '';\n\n\tconst useNewLabel =\n\t\tfinalNewLabel &&\n\t\tfinalNewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( finalNewLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tconst attributes = {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl !== undefined\n\t\t\t? { url: newUrl ? encodeURI( safeDecodeURI( newUrl ) ) : newUrl }\n\t\t\t: {} ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t};\n\n\t// If the block's id is set then the menu item is linking to an entity.\n\t// Therefore, if the URL is set but a new ID is not provided, check if\n\t// the entity link should be severed based on URL changes.\n\tif ( newUrl && ! newID && blockAttributes.id ) {\n\t\tconst shouldSever = shouldSeverEntityLink(\n\t\t\tblockAttributes.url,\n\t\t\tnewUrl\n\t\t);\n\n\t\tif ( shouldSever ) {\n\t\t\tattributes.id = undefined; // explicitly \"unset\" the ID.\n\t\t\t// When URL is manually changed in a way that severs the entity link,\n\t\t\t// update kind and type to \"custom\" to indicate this is now a custom link.\n\t\t\tattributes.kind = 'custom';\n\t\t\tattributes.type = 'custom';\n\t\t}\n\t} else if ( newID && Number.isInteger( newID ) ) {\n\t\tattributes.id = newID;\n\t} else if ( blockAttributes.id ) {\n\t\t// If we have an existing ID and no URL change, ensure kind and type are preserved\n\t\tattributes.kind = kind;\n\t\tattributes.type = type;\n\t}\n\n\tsetAttributes( attributes );\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,wBAAwB;AACnD,SAASC,aAAa,EAAEC,OAAO,QAAQ,gBAAgB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAGA,CAAEC,WAAW,EAAEC,MAAM,KAAM;EACxD,IAAK,CAAED,WAAW,IAAI,CAAEC,MAAM,EAAG;IAChC,OAAO,KAAK;EACb;EAEA,MAAMC,aAAa,GAAKC,IAAI,IAAM;IACjC,IAAK,CAAEA,IAAI,EAAG;MACb,OAAO,EAAE;IACV;IACA,OAAOA,IAAI,CAACC,OAAO,CAAE,MAAM,EAAE,EAAG,CAAC,CAAC,CAAC;EACpC,CAAC;;EAED;EACA,MAAMC,eAAe,GAAGA,CAAEC,GAAG,EAAEC,OAAO,GAAG,IAAI,KAAM;IAClD,IAAI;MACH;MACA;MACA,MAAMC,IAAI,GACTD,OAAO,KACL,OAAOE,MAAM,KAAK,WAAW,GAC5BA,MAAM,CAACC,QAAQ,CAACC,MAAM,GACtB,uBAAuB,CAAE;MAC7B,OAAO,IAAIC,GAAG,CAAEN,GAAG,EAAEE,IAAK,CAAC;IAC5B,CAAC,CAAC,OAAQK,KAAK,EAAG;MACjB;MACA;MACA,OAAO,IAAI;IACZ;EACD,CAAC;EAED,MAAMC,cAAc,GAAGT,eAAe,CAAEL,WAAY,CAAC;EACrD,IAAK,CAAEc,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;EAEA,MAAMC,SAAS,GAAGV,eAAe,CAAEJ,MAAM,EAAED,WAAY,CAAC;EACxD,IAAK,CAAEe,SAAS,EAAG;IAClB,O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AACjB,IAAI,GAAGA,IAAI;EACvB;EAEAP,aAAa,CAAEwB,UAAW,CAAC;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ import clsx from 'clsx';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
-
import { TextControl, TextareaControl, ToolbarButton, ToolbarGroup, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
10
|
+
import { CheckboxControl, TextControl, TextareaControl, ToolbarButton, ToolbarGroup, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
11
11
|
import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
13
|
import { BlockControls, InnerBlocks, useInnerBlocksProps, InspectorControls, RichText, useBlockProps, store as blockEditorStore, getColorClassName } from '@wordpress/block-editor';
|
|
@@ -111,7 +111,8 @@ export default function NavigationSubmenuEdit({
|
|
|
111
111
|
label,
|
|
112
112
|
url,
|
|
113
113
|
description,
|
|
114
|
-
rel
|
|
114
|
+
rel,
|
|
115
|
+
opensInNewTab
|
|
115
116
|
} = attributes;
|
|
116
117
|
const {
|
|
117
118
|
showSubmenuIcon,
|
|
@@ -319,7 +320,8 @@ export default function NavigationSubmenuEdit({
|
|
|
319
320
|
label: '',
|
|
320
321
|
url: '',
|
|
321
322
|
description: '',
|
|
322
|
-
rel: ''
|
|
323
|
+
rel: '',
|
|
324
|
+
opensInNewTab: false
|
|
323
325
|
});
|
|
324
326
|
},
|
|
325
327
|
dropdownMenuProps: dropdownMenuProps,
|
|
@@ -362,6 +364,21 @@ export default function NavigationSubmenuEdit({
|
|
|
362
364
|
autoComplete: "off",
|
|
363
365
|
type: "url"
|
|
364
366
|
})
|
|
367
|
+
}), /*#__PURE__*/_jsx(ToolsPanelItem, {
|
|
368
|
+
hasValue: () => !!opensInNewTab,
|
|
369
|
+
label: __('Open in new tab'),
|
|
370
|
+
onDeselect: () => setAttributes({
|
|
371
|
+
opensInNewTab: false
|
|
372
|
+
}),
|
|
373
|
+
isShownByDefault: true,
|
|
374
|
+
children: /*#__PURE__*/_jsx(CheckboxControl, {
|
|
375
|
+
__nextHasNoMarginBottom: true,
|
|
376
|
+
label: __('Open in new tab'),
|
|
377
|
+
checked: opensInNewTab,
|
|
378
|
+
onChange: value => setAttributes({
|
|
379
|
+
opensInNewTab: value
|
|
380
|
+
})
|
|
381
|
+
})
|
|
365
382
|
}), /*#__PURE__*/_jsx(ToolsPanelItem, {
|
|
366
383
|
label: __('Description'),
|
|
367
384
|
isShownByDefault: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useSelect","useDispatch","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","link","linkIcon","removeSubmenu","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","getColors","getNavigationChildBlockProps","useToolsPanelDropdownMenuProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","url","description","rel","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","selectBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","dropdownMenuProps","parentCount","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","defaultBlock","directInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","children","icon","title","shortcut","onClick","currentTarget","disabled","resetAll","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","urlValue","type","descriptionValue","help","relValue","identifier","onMerge","placeholder","withoutInteractiveFormatting","onClose","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, rel } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tlabel: '',\n\t\t\t\t\t\t\turl: '',\n\t\t\t\t\t\t\tdescription: '',\n\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! label }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! url }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\ttype=\"url\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! description }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { description: '' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! rel }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( ref.current );\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\t{ description && (\n\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\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</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,S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AgB,CAAC,EAAE,WAAY,CAAC;UAC5C,CAAG;UACHsJ,QAAQ,EAAKe,YAAY,IAAM;YAC9B7I,gBAAgB,CACf6I,YAAY,EACZ/G,aAAa,EACbF,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACa,CAAC,EACd,CAAEW,eAAe,IAAIE,mBAAmB,kBACzCpC,IAAA;QAAMyF,SAAS,EAAC,mCAAmC;QAAAkB,QAAA,eAClD3G,IAAA,CAACP,eAAe,IAAE;MAAC,CACd,CACN,eACDO,IAAA;QAAA,GAAUiG;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useSelect","useDispatch","CheckboxControl","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","link","linkIcon","removeSubmenu","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","getColors","getNavigationChildBlockProps","useToolsPanelDropdownMenuProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","url","description","rel","opensInNewTab","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","selectBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","dropdownMenuProps","parentCount","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","defaultBlock","directInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","children","icon","title","shortcut","onClick","currentTarget","disabled","resetAll","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","urlValue","type","checked","descriptionValue","help","relValue","identifier","onMerge","placeholder","withoutInteractiveFormatting","onClose","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tCheckboxControl,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, rel, opensInNewTab } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tlabel: '',\n\t\t\t\t\t\t\turl: '',\n\t\t\t\t\t\t\tdescription: '',\n\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t\topensInNewTab: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! label }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! url }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\ttype=\"url\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! opensInNewTab }\n\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { opensInNewTab: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { opensInNewTab: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! description }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { description: '' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! rel }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( ref.current );\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\t{ description && (\n\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\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</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,eAAe,EACfC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,eAAe,EAAEC,eAAe,QAAQ,qBAAqB;AACtE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iBAAiB,QACX,yBAAyB;AAChC,SAASC,KAAK,EAAEC,WAAW,QAAQ,gBAAgB;AACnD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AAChE,SAASC,IAAI,IAAIC,QAAQ,EAAEC,aAAa,QAAQ,kBAAkB;AAClE,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,MA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,CAAC,EACd,CAAEY,eAAe,IAAIE,mBAAmB,kBACzCrC,IAAA;QAAM0F,SAAS,EAAC,mCAAmC;QAAAkB,QAAA,eAClD5G,IAAA,CAACP,eAAe,IAAE;MAAC,CACd,CACN,eACDO,IAAA;QAAA,GAAUkG;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useBlockProps, useInnerBlocksProps, RecursionProvider, useHasRecursion, Warning, __experimentalUseBlockPreview as useBlockPreview } from '@wordpress/block-editor';
|
|
5
|
+
import { InspectorControls, useBlockProps, useInnerBlocksProps, RecursionProvider, useHasRecursion, Warning, privateApis as blockEditorPrivateApis, __experimentalUseBlockPreview as useBlockPreview } from '@wordpress/block-editor';
|
|
6
6
|
import { parse } from '@wordpress/blocks';
|
|
7
7
|
import { useEntityProp, useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
@@ -12,13 +12,18 @@ import { useMemo } from '@wordpress/element';
|
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { useCanEditEntity } from '../utils/hooks';
|
|
15
|
-
import {
|
|
15
|
+
import { unlock } from '../lock-unlock';
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
const {
|
|
18
|
+
HTMLElementControl
|
|
19
|
+
} = unlock(blockEditorPrivateApis);
|
|
16
20
|
function ReadOnlyContent({
|
|
17
21
|
parentLayout,
|
|
18
22
|
layoutClassNames,
|
|
19
23
|
userCanEdit,
|
|
20
24
|
postType,
|
|
21
|
-
postId
|
|
25
|
+
postId,
|
|
26
|
+
tagName: TagName = 'div'
|
|
22
27
|
}) {
|
|
23
28
|
const [,, content] = useEntityProp('postType', postType, 'content', postId);
|
|
24
29
|
const blockProps = useBlockProps({
|
|
@@ -45,12 +50,12 @@ function ReadOnlyContent({
|
|
|
45
50
|
...blockPreviewProps
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
|
-
return content?.protected ? /*#__PURE__*/_jsx(
|
|
53
|
+
return content?.protected ? /*#__PURE__*/_jsx(TagName, {
|
|
49
54
|
...blockProps,
|
|
50
55
|
children: /*#__PURE__*/_jsx(Warning, {
|
|
51
56
|
children: __('This content is password protected.')
|
|
52
57
|
})
|
|
53
|
-
}) : /*#__PURE__*/_jsx(
|
|
58
|
+
}) : /*#__PURE__*/_jsx(TagName, {
|
|
54
59
|
...blockProps,
|
|
55
60
|
dangerouslySetInnerHTML: {
|
|
56
61
|
__html: content?.rendered
|
|
@@ -58,7 +63,8 @@ function ReadOnlyContent({
|
|
|
58
63
|
});
|
|
59
64
|
}
|
|
60
65
|
function EditableContent({
|
|
61
|
-
context = {}
|
|
66
|
+
context = {},
|
|
67
|
+
tagName: TagName = 'div'
|
|
62
68
|
}) {
|
|
63
69
|
const {
|
|
64
70
|
postType,
|
|
@@ -80,7 +86,7 @@ function EditableContent({
|
|
|
80
86
|
onChange,
|
|
81
87
|
template: !hasInnerBlocks ? initialInnerBlocks : undefined
|
|
82
88
|
});
|
|
83
|
-
return /*#__PURE__*/_jsx(
|
|
89
|
+
return /*#__PURE__*/_jsx(TagName, {
|
|
84
90
|
...props
|
|
85
91
|
});
|
|
86
92
|
}
|
|
@@ -91,7 +97,8 @@ function Content(props) {
|
|
|
91
97
|
postType,
|
|
92
98
|
postId
|
|
93
99
|
} = {},
|
|
94
|
-
layoutClassNames
|
|
100
|
+
layoutClassNames,
|
|
101
|
+
tagName
|
|
95
102
|
} = props;
|
|
96
103
|
const userCanEdit = useCanEditEntity('postType', postType, postId);
|
|
97
104
|
if (userCanEdit === undefined) {
|
|
@@ -106,7 +113,8 @@ function Content(props) {
|
|
|
106
113
|
layoutClassNames: layoutClassNames,
|
|
107
114
|
userCanEdit: userCanEdit,
|
|
108
115
|
postType: postType,
|
|
109
|
-
postId: postId
|
|
116
|
+
postId: postId,
|
|
117
|
+
tagName: tagName
|
|
110
118
|
});
|
|
111
119
|
}
|
|
112
120
|
function Placeholder({
|
|
@@ -135,8 +143,51 @@ function RecursionError() {
|
|
|
135
143
|
})
|
|
136
144
|
});
|
|
137
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Render inspector controls for the PostContent block.
|
|
149
|
+
*
|
|
150
|
+
* @param {Object} props Component props.
|
|
151
|
+
* @param {string} props.tagName The HTML tag name.
|
|
152
|
+
* @param {Function} props.onSelectTagName onChange function for the SelectControl.
|
|
153
|
+
* @param {string} props.clientId The client ID of the current block.
|
|
154
|
+
*
|
|
155
|
+
* @return {JSX.Element} The control group.
|
|
156
|
+
*/
|
|
157
|
+
function PostContentEditControls({
|
|
158
|
+
tagName,
|
|
159
|
+
onSelectTagName,
|
|
160
|
+
clientId
|
|
161
|
+
}) {
|
|
162
|
+
return /*#__PURE__*/_jsx(InspectorControls, {
|
|
163
|
+
group: "advanced",
|
|
164
|
+
children: /*#__PURE__*/_jsx(HTMLElementControl, {
|
|
165
|
+
tagName: tagName,
|
|
166
|
+
onChange: onSelectTagName,
|
|
167
|
+
clientId: clientId,
|
|
168
|
+
options: [{
|
|
169
|
+
label: __('Default (<div>)'),
|
|
170
|
+
value: 'div'
|
|
171
|
+
}, {
|
|
172
|
+
label: '<main>',
|
|
173
|
+
value: 'main'
|
|
174
|
+
}, {
|
|
175
|
+
label: '<section>',
|
|
176
|
+
value: 'section'
|
|
177
|
+
}, {
|
|
178
|
+
label: '<article>',
|
|
179
|
+
value: 'article'
|
|
180
|
+
}]
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
}
|
|
138
184
|
export default function PostContentEdit({
|
|
139
185
|
context,
|
|
186
|
+
attributes: {
|
|
187
|
+
tagName = 'div'
|
|
188
|
+
},
|
|
189
|
+
setAttributes,
|
|
190
|
+
clientId,
|
|
140
191
|
__unstableLayoutClassNames: layoutClassNames,
|
|
141
192
|
__unstableParentLayout: parentLayout
|
|
142
193
|
}) {
|
|
@@ -148,15 +199,26 @@ export default function PostContentEdit({
|
|
|
148
199
|
if (contextPostId && contextPostType && hasAlreadyRendered) {
|
|
149
200
|
return /*#__PURE__*/_jsx(RecursionError, {});
|
|
150
201
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
202
|
+
const handleSelectTagName = value => {
|
|
203
|
+
setAttributes({
|
|
204
|
+
tagName: value
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
208
|
+
children: [/*#__PURE__*/_jsx(PostContentEditControls, {
|
|
209
|
+
tagName: tagName,
|
|
210
|
+
onSelectTagName: handleSelectTagName,
|
|
211
|
+
clientId: clientId
|
|
212
|
+
}), /*#__PURE__*/_jsx(RecursionProvider, {
|
|
213
|
+
uniqueId: contextPostId,
|
|
214
|
+
children: contextPostId && contextPostType ? /*#__PURE__*/_jsx(Content, {
|
|
215
|
+
context: context,
|
|
216
|
+
parentLayout: parentLayout,
|
|
217
|
+
layoutClassNames: layoutClassNames
|
|
218
|
+
}) : /*#__PURE__*/_jsx(Placeholder, {
|
|
219
|
+
layoutClassNames: layoutClassNames
|
|
220
|
+
})
|
|
221
|
+
})]
|
|
160
222
|
});
|
|
161
223
|
}
|
|
162
224
|
//# sourceMappingURL=edit.js.map
|