@wordpress/block-editor 12.3.4 → 12.5.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/README.md +4 -0
- package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
- package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +8 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +18 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +7 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +34 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/index.js +19 -1
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +2 -21
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +62 -0
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build/components/inserter/reusable-blocks-tab.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/tabs.native.js +1 -1
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +9 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/list-view/appender.js +2 -6
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/provider/index.js +5 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +10 -27
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-mode-control/index.js +70 -0
- package/build/components/writing-mode-control/index.js.map +1 -0
- package/build/hooks/behaviors.js +25 -20
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +4 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +3 -0
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +195 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +10 -1
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +46 -40
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -5
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +19 -23
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +33 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/index.js +6 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +2 -21
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build-module/components/inserter/reusable-blocks-tab.js +4 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +1 -1
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +9 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/list-view/appender.js +2 -6
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/provider/index.js +5 -2
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +8 -26
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +57 -0
- package/build-module/components/writing-mode-control/index.js.map +1 -0
- package/build-module/hooks/behaviors.js +26 -20
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +4 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +2 -0
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +191 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +10 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +45 -36
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +22 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -81
- package/build-style/style.css +88 -81
- package/package.json +31 -31
- package/src/components/block-draggable/style.scss +1 -0
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
- package/src/components/block-heading-level-dropdown/index.native.js +8 -4
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-parent-selector/index.js +13 -8
- package/src/components/block-removal-warning-modal/index.js +16 -27
- package/src/components/block-tools/block-contextual-toolbar.js +5 -11
- package/src/components/block-tools/style.scss +69 -26
- package/src/components/font-family/README.md +71 -0
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +40 -0
- package/src/components/index.js +6 -0
- package/src/components/inserter/media-tab/hooks.js +2 -22
- package/src/components/inserter/reusable-block-rename-hint.js +52 -0
- package/src/components/inserter/reusable-blocks-tab.js +4 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/src/components/inserter/style.scss +28 -0
- package/src/components/inserter/tabs.native.js +5 -1
- package/src/components/inserter-draggable-blocks/index.js +13 -2
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/style.scss +18 -68
- package/src/components/link-control/test/index.js +6 -7
- package/src/components/list-view/appender.js +5 -6
- package/src/components/panel-color-settings/README.md +98 -0
- package/src/components/provider/index.js +9 -2
- package/src/components/recursion-provider/README.md +101 -0
- package/src/components/writing-flow/use-tab-nav.js +10 -33
- package/src/components/writing-mode-control/index.js +68 -0
- package/src/components/writing-mode-control/style.scss +18 -0
- package/src/hooks/behaviors.js +25 -16
- package/src/hooks/supports.js +7 -0
- package/src/hooks/typography.js +2 -0
- package/src/hooks/utils.js +3 -0
- package/src/private-apis.js +2 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +194 -1
- package/src/store/index.js +10 -0
- package/src/store/private-actions.js +39 -39
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +22 -8
- package/src/store/selectors.js +9 -6
- package/src/store/test/actions.js +111 -0
- package/src/store/test/private-actions.js +56 -0
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Platform } from '@wordpress/element';
|
|
5
|
-
/**
|
|
6
|
-
* Internal dependencies
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { blockTypePromptMessages } from '../components/block-removal-warning-modal';
|
|
10
5
|
|
|
11
6
|
const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
12
7
|
/**
|
|
@@ -24,12 +19,17 @@ const privateSettings = ['inserterMediaCategories', 'blockInspectorAnimation'];
|
|
|
24
19
|
* Action that updates the block editor settings and
|
|
25
20
|
* conditionally preserves the experimental ones.
|
|
26
21
|
*
|
|
27
|
-
* @param {Object} settings
|
|
28
|
-
* @param {
|
|
22
|
+
* @param {Object} settings Updated settings
|
|
23
|
+
* @param {Object} options Options object.
|
|
24
|
+
* @param {boolean} options.stripExperimentalSettings Whether to strip experimental settings.
|
|
25
|
+
* @param {boolean} options.reset Whether to reset the settings.
|
|
29
26
|
* @return {Object} Action object
|
|
30
27
|
*/
|
|
31
28
|
|
|
32
|
-
export function __experimentalUpdateSettings(settings,
|
|
29
|
+
export function __experimentalUpdateSettings(settings, {
|
|
30
|
+
stripExperimentalSettings = false,
|
|
31
|
+
reset = false
|
|
32
|
+
} = {}) {
|
|
33
33
|
let cleanSettings = settings; // There are no plugins in the mobile apps, so there is no
|
|
34
34
|
// need to strip the experimental settings:
|
|
35
35
|
|
|
@@ -45,7 +45,8 @@ export function __experimentalUpdateSettings(settings, stripExperimentalSettings
|
|
|
45
45
|
|
|
46
46
|
return {
|
|
47
47
|
type: 'UPDATE_SETTINGS',
|
|
48
|
-
settings: cleanSettings
|
|
48
|
+
settings: cleanSettings,
|
|
49
|
+
reset
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
@@ -147,26 +148,18 @@ export const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemov
|
|
|
147
148
|
// confirmation that they intended to remove such block(s). However,
|
|
148
149
|
// the editor instance is responsible for presenting those confirmation
|
|
149
150
|
// prompts to the user. Any instance opting into removal prompts must
|
|
150
|
-
// register using `
|
|
151
|
+
// register using `setBlockRemovalRules()`.
|
|
151
152
|
//
|
|
152
153
|
// @see https://github.com/WordPress/gutenberg/pull/51145
|
|
153
154
|
|
|
154
155
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// the fact that the `registry` object passed to the thunk actions
|
|
159
|
-
// doesn't include this private action. This needs to be
|
|
160
|
-
// investigated to understand whether it's a real smell or if it's
|
|
161
|
-
// because not all store code has been updated to accommodate
|
|
162
|
-
// private selectors.
|
|
163
|
-
select.isRemovalPromptSupported && select.isRemovalPromptSupported()) {
|
|
156
|
+
const rules = !forceRemove && select.getBlockRemovalRules();
|
|
157
|
+
|
|
158
|
+
if (rules) {
|
|
164
159
|
const blockNamesForPrompt = new Set(); // Given a list of client IDs of blocks that the user intended to
|
|
165
160
|
// remove, perform a tree search (BFS) to find all block names
|
|
166
161
|
// corresponding to "important" blocks, i.e. blocks that require a
|
|
167
162
|
// removal prompt.
|
|
168
|
-
//
|
|
169
|
-
// @see blockTypePromptMessages
|
|
170
163
|
|
|
171
164
|
const queue = [...clientIds];
|
|
172
165
|
|
|
@@ -174,7 +167,7 @@ export const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemov
|
|
|
174
167
|
const clientId = queue.shift();
|
|
175
168
|
const blockName = select.getBlockName(clientId);
|
|
176
169
|
|
|
177
|
-
if (
|
|
170
|
+
if (rules[blockName]) {
|
|
178
171
|
blockNamesForPrompt.add(blockName);
|
|
179
172
|
}
|
|
180
173
|
|
|
@@ -185,7 +178,7 @@ export const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemov
|
|
|
185
178
|
|
|
186
179
|
|
|
187
180
|
if (blockNamesForPrompt.size) {
|
|
188
|
-
dispatch(
|
|
181
|
+
dispatch(displayBlockRemovalPrompt(clientIds, selectPrevious, Array.from(blockNamesForPrompt)));
|
|
189
182
|
return;
|
|
190
183
|
}
|
|
191
184
|
}
|
|
@@ -238,7 +231,7 @@ export const ensureDefaultBlock = () => ({
|
|
|
238
231
|
* Returns an action object used in signalling that a block removal prompt must
|
|
239
232
|
* be displayed.
|
|
240
233
|
*
|
|
241
|
-
* Contrast with `
|
|
234
|
+
* Contrast with `setBlockRemovalRules`.
|
|
242
235
|
*
|
|
243
236
|
* @param {string|string[]} clientIds Client IDs of blocks to remove.
|
|
244
237
|
* @param {boolean} selectPrevious True if the previous block
|
|
@@ -246,13 +239,16 @@ export const ensureDefaultBlock = () => ({
|
|
|
246
239
|
* (if no previous block exists)
|
|
247
240
|
* should be selected
|
|
248
241
|
* when a block is removed.
|
|
249
|
-
* @param {string[]} blockNamesForPrompt Names of blocks
|
|
242
|
+
* @param {string[]} blockNamesForPrompt Names of the blocks that
|
|
243
|
+
* triggered the need for
|
|
244
|
+
* confirmation before removal.
|
|
245
|
+
*
|
|
250
246
|
* @return {Object} Action object.
|
|
251
247
|
*/
|
|
252
248
|
|
|
253
|
-
|
|
249
|
+
function displayBlockRemovalPrompt(clientIds, selectPrevious, blockNamesForPrompt) {
|
|
254
250
|
return {
|
|
255
|
-
type: '
|
|
251
|
+
type: 'DISPLAY_BLOCK_REMOVAL_PROMPT',
|
|
256
252
|
clientIds,
|
|
257
253
|
selectPrevious,
|
|
258
254
|
blockNamesForPrompt
|
|
@@ -266,25 +262,38 @@ export function displayRemovalPrompt(clientIds, selectPrevious, blockNamesForPro
|
|
|
266
262
|
* @return {Object} Action object.
|
|
267
263
|
*/
|
|
268
264
|
|
|
269
|
-
|
|
265
|
+
|
|
266
|
+
export function clearBlockRemovalPrompt() {
|
|
270
267
|
return {
|
|
271
|
-
type: '
|
|
268
|
+
type: 'CLEAR_BLOCK_REMOVAL_PROMPT'
|
|
272
269
|
};
|
|
273
270
|
}
|
|
274
271
|
/**
|
|
275
|
-
* Returns an action object used
|
|
276
|
-
*
|
|
272
|
+
* Returns an action object used to set up any rules that a block editor may
|
|
273
|
+
* provide in order to prevent a user from accidentally removing certain
|
|
274
|
+
* blocks. These rules are then used to display a confirmation prompt to the
|
|
275
|
+
* user. For instance, in the Site Editor, the Query Loop block is important
|
|
276
|
+
* enough to warrant such confirmation.
|
|
277
|
+
*
|
|
278
|
+
* IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`
|
|
279
|
+
* action that the editor will be responsible for displaying block removal
|
|
280
|
+
* prompts and confirming deletions. This action is meant to be used by
|
|
281
|
+
* component `BlockRemovalWarningModal` only.
|
|
282
|
+
*
|
|
283
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
284
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
285
|
+
* displays a list of posts or pages.').
|
|
277
286
|
*
|
|
278
|
-
* Contrast with `
|
|
287
|
+
* Contrast with `displayBlockRemovalPrompt`.
|
|
279
288
|
*
|
|
280
|
-
* @param {
|
|
289
|
+
* @param {Record<string,string>|false} rules Block removal rules.
|
|
281
290
|
* @return {Object} Action object.
|
|
282
291
|
*/
|
|
283
292
|
|
|
284
|
-
export function
|
|
293
|
+
export function setBlockRemovalRules(rules = false) {
|
|
285
294
|
return {
|
|
286
|
-
type: '
|
|
287
|
-
|
|
295
|
+
type: 'SET_BLOCK_REMOVAL_RULES',
|
|
296
|
+
rules
|
|
288
297
|
};
|
|
289
298
|
}
|
|
290
299
|
//# sourceMappingURL=private-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/store/private-actions.js"],"names":["Platform","blockTypePromptMessages","castArray","maybeArray","Array","isArray","privateSettings","__experimentalUpdateSettings","settings","stripExperimentalSettings","cleanSettings","OS","key","includes","type","hideBlockInterface","showBlockInterface","setBlockEditingMode","clientId","mode","unsetBlockEditingMode","privateRemoveBlocks","clientIds","selectPrevious","forceRemove","select","dispatch","length","rootClientId","getBlockRootClientId","canRemoveBlocks","isRemovalPromptSupported","blockNamesForPrompt","Set","queue","shift","blockName","getBlockName","add","innerBlocks","getBlockOrder","push","size","displayRemovalPrompt","from","selectPreviousBlock","ensureDefaultBlock","count","getBlockCount","__unstableHasCustomAppender","getSettings","insertDefaultBlock","clearRemovalPrompt","toggleRemovalPromptSupport","status"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,QAAwC,2CAAxC;;AAEA,MAAMC,SAAS,GAAKC,UAAF,IACjBC,KAAK,CAACC,OAAN,CAAeF,UAAf,IAA8BA,UAA9B,GAA2C,CAAEA,UAAF,CAD5C;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,eAAe,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SAFM;AAGNC,IAAAA,cAHM;AAINS,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASoB,kBAAT,GAA8B;AACpC,SAAO;AACNtC,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASuC,0BAAT,CAAqCC,MAAM,GAAG,IAA9C,EAAqD;AAC3D,SAAO;AACNxC,IAAAA,IAAI,EAAE,+BADA;AAENwC,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { blockTypePromptMessages } from '../components/block-removal-warning-modal';\n\nconst castArray = ( maybeArray ) =>\n\tArray.isArray( maybeArray ) ? maybeArray : [ maybeArray ];\n\n/**\n * A list of private/experimental block editor settings that\n * should not become a part of the WordPress public API.\n * BlockEditorProvider will remove these settings from the\n * settings object it receives.\n *\n * @see https://github.com/WordPress/gutenberg/pull/46131\n */\nconst privateSettings = [\n\t'inserterMediaCategories',\n\t'blockInspectorAnimation',\n];\n\n/**\n * Action that updates the block editor settings and\n * conditionally preserves the experimental ones.\n *\n * @param {Object} settings Updated settings\n * @param {boolean} stripExperimentalSettings Whether to strip experimental settings.\n * @return {Object} Action object\n */\nexport function __experimentalUpdateSettings(\n\tsettings,\n\tstripExperimentalSettings = false\n) {\n\tlet cleanSettings = settings;\n\t// There are no plugins in the mobile apps, so there is no\n\t// need to strip the experimental settings:\n\tif ( stripExperimentalSettings && Platform.OS === 'web' ) {\n\t\tcleanSettings = {};\n\t\tfor ( const key in settings ) {\n\t\t\tif ( ! privateSettings.includes( key ) ) {\n\t\t\t\tcleanSettings[ key ] = settings[ key ];\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings: cleanSettings,\n\t};\n}\n\n/**\n * Hides the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function hideBlockInterface() {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * Shows the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function showBlockInterface() {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode\n */\n\n/**\n * Sets the block editing mode for a given block.\n *\n * @see useBlockEditingMode\n *\n * @param {string} clientId The block client ID, or `''` for the root container.\n * @param {BlockEditingMode} mode The block editing mode. One of `'disabled'`,\n * `'contentOnly'`, or `'default'`.\n *\n * @return {Object} Action object.\n */\nexport function setBlockEditingMode( clientId = '', mode ) {\n\treturn {\n\t\ttype: 'SET_BLOCK_EDITING_MODE',\n\t\tclientId,\n\t\tmode,\n\t};\n}\n\n/**\n * Clears the block editing mode for a given block.\n *\n * @see useBlockEditingMode\n *\n * @param {string} clientId The block client ID, or `''` for the root container.\n *\n * @return {Object} Action object.\n */\nexport function unsetBlockEditingMode( clientId = '' ) {\n\treturn {\n\t\ttype: 'UNSET_BLOCK_EDITING_MODE',\n\t\tclientId,\n\t};\n}\n\n/**\n * Yields action objects used in signalling that the blocks corresponding to\n * the set of specified client IDs are to be removed.\n *\n * Compared to `removeBlocks`, this private interface exposes an additional\n * parameter; see `forceRemove`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {boolean} forceRemove Whether to force the operation,\n * bypassing any checks for certain\n * block types.\n */\nexport const privateRemoveBlocks =\n\t( clientIds, selectPrevious = true, forceRemove = false ) =>\n\t( { select, dispatch } ) => {\n\t\tif ( ! clientIds || ! clientIds.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tclientIds = castArray( clientIds );\n\t\tconst rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canRemoveBlocks = select.canRemoveBlocks(\n\t\t\tclientIds,\n\t\t\trootClientId\n\t\t);\n\n\t\tif ( ! canRemoveBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In certain editing contexts, we'd like to prevent accidental removal\n\t\t// of important blocks. For example, in the site editor, the Query Loop\n\t\t// block is deemed important. In such cases, we'll ask the user for\n\t\t// confirmation that they intended to remove such block(s). However,\n\t\t// the editor instance is responsible for presenting those confirmation\n\t\t// prompts to the user. Any instance opting into removal prompts must\n\t\t// register using `toggleRemovalPromptSupport()`.\n\t\t//\n\t\t// @see https://github.com/WordPress/gutenberg/pull/51145\n\t\tif (\n\t\t\t! forceRemove &&\n\t\t\t// FIXME: Without this existence check, the unit tests for\n\t\t\t// `__experimentalDeleteReusableBlock` in\n\t\t\t// `packages/reusable-blocks/src/store/test/actions.js` fail due to\n\t\t\t// the fact that the `registry` object passed to the thunk actions\n\t\t\t// doesn't include this private action. This needs to be\n\t\t\t// investigated to understand whether it's a real smell or if it's\n\t\t\t// because not all store code has been updated to accommodate\n\t\t\t// private selectors.\n\t\t\tselect.isRemovalPromptSupported &&\n\t\t\tselect.isRemovalPromptSupported()\n\t\t) {\n\t\t\tconst blockNamesForPrompt = new Set();\n\n\t\t\t// Given a list of client IDs of blocks that the user intended to\n\t\t\t// remove, perform a tree search (BFS) to find all block names\n\t\t\t// corresponding to \"important\" blocks, i.e. blocks that require a\n\t\t\t// removal prompt.\n\t\t\t//\n\t\t\t// @see blockTypePromptMessages\n\t\t\tconst queue = [ ...clientIds ];\n\t\t\twhile ( queue.length ) {\n\t\t\t\tconst clientId = queue.shift();\n\t\t\t\tconst blockName = select.getBlockName( clientId );\n\t\t\t\tif ( blockTypePromptMessages[ blockName ] ) {\n\t\t\t\t\tblockNamesForPrompt.add( blockName );\n\t\t\t\t}\n\t\t\t\tconst innerBlocks = select.getBlockOrder( clientId );\n\t\t\t\tqueue.push( ...innerBlocks );\n\t\t\t}\n\n\t\t\t// If any such blocks were found, trigger the removal prompt and\n\t\t\t// skip any other steps (thus postponing actual removal).\n\t\t\tif ( blockNamesForPrompt.size ) {\n\t\t\t\tdispatch(\n\t\t\t\t\tdisplayRemovalPrompt(\n\t\t\t\t\t\tclientIds,\n\t\t\t\t\t\tselectPrevious,\n\t\t\t\t\t\tArray.from( blockNamesForPrompt )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( selectPrevious ) {\n\t\t\tdispatch.selectPreviousBlock( clientIds[ 0 ], selectPrevious );\n\t\t}\n\n\t\tdispatch( { type: 'REMOVE_BLOCKS', clientIds } );\n\n\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t// always a default block if the last of the blocks have been removed.\n\t\tdispatch( ensureDefaultBlock() );\n\t};\n\n/**\n * Action which will insert a default block insert action if there\n * are no other blocks at the root of the editor. This action should be used\n * in actions which may result in no blocks remaining in the editor (removal,\n * replacement, etc).\n */\nexport const ensureDefaultBlock =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t// always a default block if the last of the blocks have been removed.\n\t\tconst count = select.getBlockCount();\n\t\tif ( count > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there's an custom appender, don't insert default block.\n\t\t// We have to remember to manually move the focus elsewhere to\n\t\t// prevent it from being lost though.\n\t\tconst { __unstableHasCustomAppender } = select.getSettings();\n\t\tif ( __unstableHasCustomAppender ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdispatch.insertDefaultBlock();\n\t};\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be displayed.\n *\n * Contrast with `toggleRemovalPromptSupport`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {string[]} blockNamesForPrompt Names of blocks requiring user\n * @return {Object} Action object.\n */\nexport function displayRemovalPrompt(\n\tclientIds,\n\tselectPrevious,\n\tblockNamesForPrompt\n) {\n\treturn {\n\t\ttype: 'DISPLAY_REMOVAL_PROMPT',\n\t\tclientIds,\n\t\tselectPrevious,\n\t\tblockNamesForPrompt,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be cleared, either be cause the user has confirmed or canceled the request\n * for removal.\n *\n * @return {Object} Action object.\n */\nexport function clearRemovalPrompt() {\n\treturn {\n\t\ttype: 'CLEAR_REMOVAL_PROMPT',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a removal prompt display\n * mechanism is available or unavailable in the current editor.\n *\n * Contrast with `displayRemovalPrompt`.\n *\n * @param {boolean} status Whether a prompt display mechanism exists.\n * @return {Object} Action object.\n */\nexport function toggleRemovalPromptSupport( status = true ) {\n\treturn {\n\t\ttype: 'TOGGLE_REMOVAL_PROMPT_SUPPORT',\n\t\tstatus,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/store/private-actions.js"],"names":["Platform","castArray","maybeArray","Array","isArray","privateSettings","__experimentalUpdateSettings","settings","stripExperimentalSettings","reset","cleanSettings","OS","key","includes","type","hideBlockInterface","showBlockInterface","setBlockEditingMode","clientId","mode","unsetBlockEditingMode","privateRemoveBlocks","clientIds","selectPrevious","forceRemove","select","dispatch","length","rootClientId","getBlockRootClientId","canRemoveBlocks","rules","getBlockRemovalRules","blockNamesForPrompt","Set","queue","shift","blockName","getBlockName","add","innerBlocks","getBlockOrder","push","size","displayBlockRemovalPrompt","from","selectPreviousBlock","ensureDefaultBlock","count","getBlockCount","__unstableHasCustomAppender","getSettings","insertDefaultBlock","clearBlockRemovalPrompt","setBlockRemovalRules"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,oBAAzB;;AAEA,MAAMC,SAAS,GAAKC,UAAF,IACjBC,KAAK,CAACC,OAAN,CAAeF,UAAf,IAA8BA,UAA9B,G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A;AACA;AACA;AACA;AACA;;AACA,SAASR,yBAAT,CACCtB,SADD,EAECC,cAFD,EAGCU,mBAHD,EAIE;AACD,SAAO;AACNnB,IAAAA,IAAI,EAAE,8BADA;AAENQ,IAAAA,SAFM;AAGNC,IAAAA,cAHM;AAINU,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASoB,uBAAT,GAAmC;AACzC,SAAO;AACNvC,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASwC,oBAAT,CAA+BvB,KAAK,GAAG,KAAvC,EAA+C;AACrD,SAAO;AACNjB,IAAAA,IAAI,EAAE,yBADA;AAENiB,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform } from '@wordpress/element';\n\nconst castArray = ( maybeArray ) =>\n\tArray.isArray( maybeArray ) ? maybeArray : [ maybeArray ];\n\n/**\n * A list of private/experimental block editor settings that\n * should not become a part of the WordPress public API.\n * BlockEditorProvider will remove these settings from the\n * settings object it receives.\n *\n * @see https://github.com/WordPress/gutenberg/pull/46131\n */\nconst privateSettings = [\n\t'inserterMediaCategories',\n\t'blockInspectorAnimation',\n];\n\n/**\n * Action that updates the block editor settings and\n * conditionally preserves the experimental ones.\n *\n * @param {Object} settings Updated settings\n * @param {Object} options Options object.\n * @param {boolean} options.stripExperimentalSettings Whether to strip experimental settings.\n * @param {boolean} options.reset Whether to reset the settings.\n * @return {Object} Action object\n */\nexport function __experimentalUpdateSettings(\n\tsettings,\n\t{ stripExperimentalSettings = false, reset = false } = {}\n) {\n\tlet cleanSettings = settings;\n\t// There are no plugins in the mobile apps, so there is no\n\t// need to strip the experimental settings:\n\tif ( stripExperimentalSettings && Platform.OS === 'web' ) {\n\t\tcleanSettings = {};\n\t\tfor ( const key in settings ) {\n\t\t\tif ( ! privateSettings.includes( key ) ) {\n\t\t\t\tcleanSettings[ key ] = settings[ key ];\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings: cleanSettings,\n\t\treset,\n\t};\n}\n\n/**\n * Hides the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function hideBlockInterface() {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * Shows the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function showBlockInterface() {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode\n */\n\n/**\n * Sets the block editing mode for a given block.\n *\n * @see useBlockEditingMode\n *\n * @param {string} clientId The block client ID, or `''` for the root container.\n * @param {BlockEditingMode} mode The block editing mode. One of `'disabled'`,\n * `'contentOnly'`, or `'default'`.\n *\n * @return {Object} Action object.\n */\nexport function setBlockEditingMode( clientId = '', mode ) {\n\treturn {\n\t\ttype: 'SET_BLOCK_EDITING_MODE',\n\t\tclientId,\n\t\tmode,\n\t};\n}\n\n/**\n * Clears the block editing mode for a given block.\n *\n * @see useBlockEditingMode\n *\n * @param {string} clientId The block client ID, or `''` for the root container.\n *\n * @return {Object} Action object.\n */\nexport function unsetBlockEditingMode( clientId = '' ) {\n\treturn {\n\t\ttype: 'UNSET_BLOCK_EDITING_MODE',\n\t\tclientId,\n\t};\n}\n\n/**\n * Yields action objects used in signalling that the blocks corresponding to\n * the set of specified client IDs are to be removed.\n *\n * Compared to `removeBlocks`, this private interface exposes an additional\n * parameter; see `forceRemove`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {boolean} forceRemove Whether to force the operation,\n * bypassing any checks for certain\n * block types.\n */\nexport const privateRemoveBlocks =\n\t( clientIds, selectPrevious = true, forceRemove = false ) =>\n\t( { select, dispatch } ) => {\n\t\tif ( ! clientIds || ! clientIds.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tclientIds = castArray( clientIds );\n\t\tconst rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canRemoveBlocks = select.canRemoveBlocks(\n\t\t\tclientIds,\n\t\t\trootClientId\n\t\t);\n\n\t\tif ( ! canRemoveBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In certain editing contexts, we'd like to prevent accidental removal\n\t\t// of important blocks. For example, in the site editor, the Query Loop\n\t\t// block is deemed important. In such cases, we'll ask the user for\n\t\t// confirmation that they intended to remove such block(s). However,\n\t\t// the editor instance is responsible for presenting those confirmation\n\t\t// prompts to the user. Any instance opting into removal prompts must\n\t\t// register using `setBlockRemovalRules()`.\n\t\t//\n\t\t// @see https://github.com/WordPress/gutenberg/pull/51145\n\t\tconst rules = ! forceRemove && select.getBlockRemovalRules();\n\t\tif ( rules ) {\n\t\t\tconst blockNamesForPrompt = new Set();\n\n\t\t\t// Given a list of client IDs of blocks that the user intended to\n\t\t\t// remove, perform a tree search (BFS) to find all block names\n\t\t\t// corresponding to \"important\" blocks, i.e. blocks that require a\n\t\t\t// removal prompt.\n\t\t\tconst queue = [ ...clientIds ];\n\t\t\twhile ( queue.length ) {\n\t\t\t\tconst clientId = queue.shift();\n\t\t\t\tconst blockName = select.getBlockName( clientId );\n\t\t\t\tif ( rules[ blockName ] ) {\n\t\t\t\t\tblockNamesForPrompt.add( blockName );\n\t\t\t\t}\n\t\t\t\tconst innerBlocks = select.getBlockOrder( clientId );\n\t\t\t\tqueue.push( ...innerBlocks );\n\t\t\t}\n\n\t\t\t// If any such blocks were found, trigger the removal prompt and\n\t\t\t// skip any other steps (thus postponing actual removal).\n\t\t\tif ( blockNamesForPrompt.size ) {\n\t\t\t\tdispatch(\n\t\t\t\t\tdisplayBlockRemovalPrompt(\n\t\t\t\t\t\tclientIds,\n\t\t\t\t\t\tselectPrevious,\n\t\t\t\t\t\tArray.from( blockNamesForPrompt )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( selectPrevious ) {\n\t\t\tdispatch.selectPreviousBlock( clientIds[ 0 ], selectPrevious );\n\t\t}\n\n\t\tdispatch( { type: 'REMOVE_BLOCKS', clientIds } );\n\n\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t// always a default block if the last of the blocks have been removed.\n\t\tdispatch( ensureDefaultBlock() );\n\t};\n\n/**\n * Action which will insert a default block insert action if there\n * are no other blocks at the root of the editor. This action should be used\n * in actions which may result in no blocks remaining in the editor (removal,\n * replacement, etc).\n */\nexport const ensureDefaultBlock =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t// always a default block if the last of the blocks have been removed.\n\t\tconst count = select.getBlockCount();\n\t\tif ( count > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there's an custom appender, don't insert default block.\n\t\t// We have to remember to manually move the focus elsewhere to\n\t\t// prevent it from being lost though.\n\t\tconst { __unstableHasCustomAppender } = select.getSettings();\n\t\tif ( __unstableHasCustomAppender ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdispatch.insertDefaultBlock();\n\t};\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be displayed.\n *\n * Contrast with `setBlockRemovalRules`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {string[]} blockNamesForPrompt Names of the blocks that\n * triggered the need for\n * confirmation before removal.\n *\n * @return {Object} Action object.\n */\nfunction displayBlockRemovalPrompt(\n\tclientIds,\n\tselectPrevious,\n\tblockNamesForPrompt\n) {\n\treturn {\n\t\ttype: 'DISPLAY_BLOCK_REMOVAL_PROMPT',\n\t\tclientIds,\n\t\tselectPrevious,\n\t\tblockNamesForPrompt,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be cleared, either be cause the user has confirmed or canceled the request\n * for removal.\n *\n * @return {Object} Action object.\n */\nexport function clearBlockRemovalPrompt() {\n\treturn {\n\t\ttype: 'CLEAR_BLOCK_REMOVAL_PROMPT',\n\t};\n}\n\n/**\n * Returns an action object used to set up any rules that a block editor may\n * provide in order to prevent a user from accidentally removing certain\n * blocks. These rules are then used to display a confirmation prompt to the\n * user. For instance, in the Site Editor, the Query Loop block is important\n * enough to warrant such confirmation.\n *\n * IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`\n * action that the editor will be responsible for displaying block removal\n * prompts and confirming deletions. This action is meant to be used by\n * component `BlockRemovalWarningModal` only.\n *\n * The data is a record whose keys are block types (e.g. 'core/query') and\n * whose values are the explanation to be shown to users (e.g. 'Query Loop\n * displays a list of posts or pages.').\n *\n * Contrast with `displayBlockRemovalPrompt`.\n *\n * @param {Record<string,string>|false} rules Block removal rules.\n * @return {Object} Action object.\n */\nexport function setBlockRemovalRules( rules = false ) {\n\treturn {\n\t\ttype: 'SET_BLOCK_REMOVAL_RULES',\n\t\trules,\n\t};\n}\n"]}
|
|
@@ -171,7 +171,7 @@ export function getRemovalPromptData(state) {
|
|
|
171
171
|
* @return {boolean} Whether removal prompt exists.
|
|
172
172
|
*/
|
|
173
173
|
|
|
174
|
-
export function
|
|
175
|
-
return state.
|
|
174
|
+
export function getBlockRemovalRules(state) {
|
|
175
|
+
return state.blockRemovalRules;
|
|
176
176
|
}
|
|
177
177
|
//# sourceMappingURL=private-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/store/private-selectors.js"],"names":["createSelector","select","store","blocksStore","getBlockRootClientId","getTemplateLock","getBlockName","getBlockOrder","getBlockParents","isBlockInterfaceHidden","state","getLastInsertedBlocksClientIds","lastBlockInserted","clientIds","getBlockEditingMode","clientId","blockEditingModes","has","get","rootClientId","templateLock","name","isContent","__experimentalHasContentRoleAttribute","parentMode","isBlockSubtreeDisabled","isChildSubtreeDisabled","childClientId","mode","undefined","every","blocks","parents","getListViewClientIdsTree","flatMap","innerBlocks","order","settings","blockListSettings","getEnabledBlockParents","ascending","filter","parent","getRemovalPromptData","removalPromptData","isRemovalPromptSupported"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SACCC,oBADD,EAECC,eAFD,EAGCC,YAHD,EAICC,aAJD,EAKCC,eALD,QAMO,aANP;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,KAAjC,EAAyC;AAC/C,SAAOA,KAAK,CAACD,sBAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,8BAAT,CAAyCD,KAAzC,EAAiD;AACvD,SAAOA,KAAK,EAAEE,iBAAP,EAA0BC,SAAjC;AACA;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BJ,KAA9B,EAAqCK,QAAQ,GAAG,EAAhD,EAAqD;AAC3D,MAAKL,KAAK,CAACM,iBAAN,CAAwBC,GAAxB,CAA6BF,QAA7B,CAAL,EAA+C;AAC9C,WAAOL,KAAK,CAACM,iBAAN,CAAwBE,GAAxB,CAA6BH,QAA7B,CAAP;AACA;;AACD,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,SAAP;AACA;;AACD,QAAMI,YAAY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,SAASK,oBAAT,CAA+BjC,KAA/B,EAAuC;AAC7C,SAAOA,KAAK,CAACkC,iBAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,wBAAT,CAAmCnC,KAAnC,EAA2C;AACjD,SAAOA,KAAK,CAACmC,wBAAb;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockRootClientId,\n\tgetTemplateLock,\n\tgetBlockName,\n\tgetBlockOrder,\n\tgetBlockParents,\n} from './selectors';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\n/**\n * @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode\n */\n\n/**\n * Returns the block editing mode for a given block.\n *\n * The mode can be one of three options:\n *\n * - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be\n * selected.\n * - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the\n * toolbar, the block movers, block settings.\n * - `'default'`: Allows editing the block as normal.\n *\n * Blocks can set a mode using the `useBlockEditingMode` hook.\n *\n * The mode is inherited by all of the block's inner blocks, unless they have\n * their own mode.\n *\n * A template lock can also set a mode. If the template lock is `'contentOnly'`,\n * the block's mode is overridden to `'contentOnly'` if the block has a content\n * role attribute, or `'disabled'` otherwise.\n *\n * @see useBlockEditingMode\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID, or `''` for the root container.\n *\n * @return {BlockEditingMode} The block editing mode. One of `'disabled'`,\n * `'contentOnly'`, or `'default'`.\n */\nexport function getBlockEditingMode( state, clientId = '' ) {\n\tif ( state.blockEditingModes.has( clientId ) ) {\n\t\treturn state.blockEditingModes.get( clientId );\n\t}\n\tif ( ! clientId ) {\n\t\treturn 'default';\n\t}\n\tconst rootClientId = getBlockRootClientId( state, clientId );\n\tconst templateLock = getTemplateLock( state, rootClientId );\n\tif ( templateLock === 'contentOnly' ) {\n\t\tconst name = getBlockName( state, clientId );\n\t\t// TODO: Terrible hack! We're calling the global select() function\n\t\t// here instead of using createRegistrySelector(). The problem with\n\t\t// using createRegistrySelector() is that then the public\n\t\t// block-editor selectors (e.g. canInsertBlockTypeUnmemoized) can't\n\t\t// call this private block-editor selector due to a bug in\n\t\t// @wordpress/data. See\n\t\t// https://github.com/WordPress/gutenberg/pull/50985.\n\t\tconst isContent =\n\t\t\tselect( blocksStore ).__experimentalHasContentRoleAttribute( name );\n\t\treturn isContent ? 'contentOnly' : 'disabled';\n\t}\n\tconst parentMode = getBlockEditingMode( state, rootClientId );\n\treturn parentMode === 'contentOnly' ? 'default' : parentMode;\n}\n\n/**\n * Returns true if the block with the given client ID and all of its descendants\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block and its descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = createSelector(\n\t( state, clientId ) => {\n\t\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\t\tconst mode = state.blockEditingModes.get( childClientId );\n\t\t\treturn (\n\t\t\t\t( mode === undefined || mode === 'disabled' ) &&\n\t\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\t\tisChildSubtreeDisabled\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, clientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, clientId ).every( isChildSubtreeDisabled )\n\t\t);\n\t},\n\t( state ) => [ state.blockEditingModes, state.blocks.parents ]\n);\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getListViewClientIdsTree = createSelector(\n\t( state, rootClientId = '' ) => {\n\t\treturn getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {\n\t\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tinnerBlocks: getListViewClientIdsTree(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn getListViewClientIdsTree( state, clientId );\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function isRemovalPromptSupported( state ) {\n\treturn state.isRemovalPromptSupported;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/store/private-selectors.js"],"names":["createSelector","select","store","blocksStore","getBlockRootClientId","getTemplateLock","getBlockName","getBlockOrder","getBlockParents","isBlockInterfaceHidden","state","getLastInsertedBlocksClientIds","lastBlockInserted","clientIds","getBlockEditingMode","clientId","blockEditingModes","has","get","rootClientId","templateLock","name","isContent","__experimentalHasContentRoleAttribute","parentMode","isBlockSubtreeDisabled","isChildSubtreeDisabled","childClientId","mode","undefined","every","blocks","parents","getListViewClientIdsTree","flatMap","innerBlocks","order","settings","blockListSettings","getEnabledBlockParents","ascending","filter","parent","getRemovalPromptData","removalPromptData","getBlockRemovalRules","blockRemovalRules"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SACCC,oBADD,EAECC,eAFD,EAGCC,YAHD,EAICC,aAJD,EAKCC,eALD,QAMO,aANP;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,KAAjC,EAAyC;AAC/C,SAAOA,KAAK,CAACD,sBAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,8BAAT,CAAyCD,KAAzC,EAAiD;AACvD,SAAOA,KAAK,EAAEE,iBAAP,EAA0BC,SAAjC;AACA;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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QAAT,EAAmByB,SAAnB,CAAf,CAA8CC,MAA9C,CACJC,MAAF,IAAc5B,mBAAmB,CAAEJ,KAAF,EAASgC,MAAT,CAAnB,KAAyC,UADjD,CAAP;AAGA,CALkD,EAMjDhC,KAAF,IAAa,CACZA,KAAK,CAACqB,MAAN,CAAaC,OADD,EAEZtB,KAAK,CAACM,iBAFM,EAGZN,KAAK,CAAC2B,QAAN,CAAejB,YAHH,EAIZV,KAAK,CAAC4B,iBAJM,CANsC,CAA7C;AAcP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,oBAAT,CAA+BjC,KAA/B,EAAuC;AAC7C,SAAOA,KAAK,CAACkC,iBAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,oBAAT,CAA+BnC,KAA/B,EAAuC;AAC7C,SAAOA,KAAK,CAACoC,iBAAb;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockRootClientId,\n\tgetTemplateLock,\n\tgetBlockName,\n\tgetBlockOrder,\n\tgetBlockParents,\n} from './selectors';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\n/**\n * @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode\n */\n\n/**\n * Returns the block editing mode for a given block.\n *\n * The mode can be one of three options:\n *\n * - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be\n * selected.\n * - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the\n * toolbar, the block movers, block settings.\n * - `'default'`: Allows editing the block as normal.\n *\n * Blocks can set a mode using the `useBlockEditingMode` hook.\n *\n * The mode is inherited by all of the block's inner blocks, unless they have\n * their own mode.\n *\n * A template lock can also set a mode. If the template lock is `'contentOnly'`,\n * the block's mode is overridden to `'contentOnly'` if the block has a content\n * role attribute, or `'disabled'` otherwise.\n *\n * @see useBlockEditingMode\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID, or `''` for the root container.\n *\n * @return {BlockEditingMode} The block editing mode. One of `'disabled'`,\n * `'contentOnly'`, or `'default'`.\n */\nexport function getBlockEditingMode( state, clientId = '' ) {\n\tif ( state.blockEditingModes.has( clientId ) ) {\n\t\treturn state.blockEditingModes.get( clientId );\n\t}\n\tif ( ! clientId ) {\n\t\treturn 'default';\n\t}\n\tconst rootClientId = getBlockRootClientId( state, clientId );\n\tconst templateLock = getTemplateLock( state, rootClientId );\n\tif ( templateLock === 'contentOnly' ) {\n\t\tconst name = getBlockName( state, clientId );\n\t\t// TODO: Terrible hack! We're calling the global select() function\n\t\t// here instead of using createRegistrySelector(). The problem with\n\t\t// using createRegistrySelector() is that then the public\n\t\t// block-editor selectors (e.g. canInsertBlockTypeUnmemoized) can't\n\t\t// call this private block-editor selector due to a bug in\n\t\t// @wordpress/data. See\n\t\t// https://github.com/WordPress/gutenberg/pull/50985.\n\t\tconst isContent =\n\t\t\tselect( blocksStore ).__experimentalHasContentRoleAttribute( name );\n\t\treturn isContent ? 'contentOnly' : 'disabled';\n\t}\n\tconst parentMode = getBlockEditingMode( state, rootClientId );\n\treturn parentMode === 'contentOnly' ? 'default' : parentMode;\n}\n\n/**\n * Returns true if the block with the given client ID and all of its descendants\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block and its descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = createSelector(\n\t( state, clientId ) => {\n\t\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\t\tconst mode = state.blockEditingModes.get( childClientId );\n\t\t\treturn (\n\t\t\t\t( mode === undefined || mode === 'disabled' ) &&\n\t\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\t\tisChildSubtreeDisabled\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, clientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, clientId ).every( isChildSubtreeDisabled )\n\t\t);\n\t},\n\t( state ) => [ state.blockEditingModes, state.blocks.parents ]\n);\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getListViewClientIdsTree = createSelector(\n\t( state, rootClientId = '' ) => {\n\t\treturn getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {\n\t\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tinnerBlocks: getListViewClientIdsTree(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn getListViewClientIdsTree( state, clientId );\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function getBlockRemovalRules( state ) {\n\treturn state.blockRemovalRules;\n}\n"]}
|
|
@@ -1407,7 +1407,7 @@ export function isSelectionEnabled(state = true, action) {
|
|
|
1407
1407
|
|
|
1408
1408
|
function removalPromptData(state = false, action) {
|
|
1409
1409
|
switch (action.type) {
|
|
1410
|
-
case '
|
|
1410
|
+
case 'DISPLAY_BLOCK_REMOVAL_PROMPT':
|
|
1411
1411
|
const {
|
|
1412
1412
|
clientIds,
|
|
1413
1413
|
selectPrevious,
|
|
@@ -1419,26 +1419,34 @@ function removalPromptData(state = false, action) {
|
|
|
1419
1419
|
blockNamesForPrompt
|
|
1420
1420
|
};
|
|
1421
1421
|
|
|
1422
|
-
case '
|
|
1422
|
+
case 'CLEAR_BLOCK_REMOVAL_PROMPT':
|
|
1423
1423
|
return false;
|
|
1424
1424
|
}
|
|
1425
1425
|
|
|
1426
1426
|
return state;
|
|
1427
1427
|
}
|
|
1428
1428
|
/**
|
|
1429
|
-
* Reducer
|
|
1429
|
+
* Reducer returning any rules that a block editor may provide in order to
|
|
1430
|
+
* prevent a user from accidentally removing certain blocks. These rules are
|
|
1431
|
+
* then used to display a confirmation prompt to the user. For instance, in the
|
|
1432
|
+
* Site Editor, the Query Loop block is important enough to warrant such
|
|
1433
|
+
* confirmation.
|
|
1434
|
+
*
|
|
1435
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
1436
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
1437
|
+
* displays a list of posts or pages.').
|
|
1430
1438
|
*
|
|
1431
1439
|
* @param {boolean} state Current state.
|
|
1432
1440
|
* @param {Object} action Dispatched action.
|
|
1433
1441
|
*
|
|
1434
|
-
* @return {
|
|
1442
|
+
* @return {Record<string,string>} Updated state.
|
|
1435
1443
|
*/
|
|
1436
1444
|
|
|
1437
1445
|
|
|
1438
|
-
function
|
|
1446
|
+
function blockRemovalRules(state = false, action) {
|
|
1439
1447
|
switch (action.type) {
|
|
1440
|
-
case '
|
|
1441
|
-
return action.
|
|
1448
|
+
case 'SET_BLOCK_REMOVAL_RULES':
|
|
1449
|
+
return action.rules;
|
|
1442
1450
|
}
|
|
1443
1451
|
|
|
1444
1452
|
return state;
|
|
@@ -1548,6 +1556,12 @@ export function template(state = {
|
|
|
1548
1556
|
export function settings(state = SETTINGS_DEFAULTS, action) {
|
|
1549
1557
|
switch (action.type) {
|
|
1550
1558
|
case 'UPDATE_SETTINGS':
|
|
1559
|
+
if (action.reset) {
|
|
1560
|
+
return { ...SETTINGS_DEFAULTS,
|
|
1561
|
+
...action.settings
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1551
1565
|
return { ...state,
|
|
1552
1566
|
...action.settings
|
|
1553
1567
|
};
|
|
@@ -1858,7 +1872,7 @@ const combinedReducers = combineReducers({
|
|
|
1858
1872
|
blockVisibility,
|
|
1859
1873
|
blockEditingModes,
|
|
1860
1874
|
removalPromptData,
|
|
1861
|
-
|
|
1875
|
+
blockRemovalRules
|
|
1862
1876
|
});
|
|
1863
1877
|
|
|
1864
1878
|
function withAutomaticChangeReset(reducer) {
|