@wordpress/block-editor 15.18.1-next.v.202604201441.0 → 15.19.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 +7 -1
- package/build/components/autocomplete/index.cjs.map +3 -3
- package/build/components/background-image-control/index.cjs +2 -1
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-allowed-blocks/modal.cjs.map +2 -2
- package/build/components/block-bindings/attribute-control.cjs.map +3 -3
- package/build/components/block-card/index.cjs +2 -2
- package/build/components/block-card/index.cjs.map +3 -3
- package/build/components/block-controls/fill.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +7 -1
- package/build/components/block-inspector/edit-contents.cjs.map +2 -2
- package/build/components/block-mover/button.cjs +9 -3
- package/build/components/block-mover/button.cjs.map +2 -2
- package/build/components/block-pattern-setup/index.cjs +3 -2
- package/build/components/block-pattern-setup/index.cjs.map +2 -2
- package/build/components/block-patterns-list/index.cjs +2 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-patterns-paging/index.cjs.map +3 -3
- package/build/components/block-settings-menu/block-settings-dropdown.cjs +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +3 -3
- package/build/components/block-settings-menu/index.cjs +2 -2
- package/build/components/block-settings-menu/index.cjs.map +3 -3
- package/build/components/block-styles/menu-items.cjs.map +3 -3
- package/build/components/block-switcher/index.cjs.map +3 -3
- package/build/components/block-switcher/pattern-transformations-menu.cjs +2 -1
- package/build/components/block-switcher/pattern-transformations-menu.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs +7 -1
- package/build/components/block-toolbar/edit-section-button.cjs.map +2 -2
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
- package/build/components/block-variation-transforms/index.cjs +4 -3
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +0 -10
- package/build/components/block-visibility/modal.cjs.map +3 -3
- package/build/components/block-visibility/viewport-visibility-info.cjs +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
- package/build/components/collab/{block-comment-icon-slot.cjs → note-icon-slot.cjs} +8 -8
- package/build/components/collab/note-icon-slot.cjs.map +7 -0
- package/build/components/collab/{block-comment-icon-toolbar-slot.cjs → note-icon-toolbar-slot.cjs} +9 -9
- package/build/components/collab/note-icon-toolbar-slot.cjs.map +7 -0
- package/build/components/date-format-picker/index.cjs +2 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +111 -37
- package/build/components/global-styles/state-control.cjs.map +3 -3
- package/build/components/gradients/use-gradient.cjs +2 -2
- package/build/components/gradients/use-gradient.cjs.map +2 -2
- package/build/components/grid/grid-item-movers.cjs +2 -1
- package/build/components/grid/grid-item-movers.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.cjs.map +2 -2
- package/build/components/inserter/index.cjs +41 -43
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +32 -3
- package/build/components/inserter/menu.cjs.map +3 -3
- package/build/components/inserter/search-results.cjs +3 -3
- package/build/components/inserter/search-results.cjs.map +2 -2
- package/build/components/inserter/tips.cjs +1 -1
- package/build/components/inserter/tips.cjs.map +2 -2
- package/build/components/inspector-popover-header/index.cjs.map +3 -3
- package/build/components/link-control/link-preview.cjs +2 -2
- package/build/components/link-control/link-preview.cjs.map +2 -2
- package/build/components/link-control/settings.cjs +2 -1
- package/build/components/link-control/settings.cjs.map +2 -2
- package/build/components/link-picker/link-picker.cjs +3 -2
- package/build/components/link-picker/link-picker.cjs.map +2 -2
- package/build/components/link-picker/link-preview.cjs +2 -2
- package/build/components/link-picker/link-preview.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +2 -2
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/index.cjs +2 -1
- package/build/components/list-view/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +80 -7
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/responsive-block-control/label.cjs +9 -2
- package/build/components/responsive-block-control/label.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/paste-handler.cjs +12 -5
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/hooks/block-bindings.cjs.map +3 -3
- package/build/hooks/custom-css.cjs +1 -1
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/layouts/flex.cjs +5 -8
- package/build/layouts/flex.cjs.map +3 -3
- package/build/layouts/grid.cjs +5 -5
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +5 -4
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -0
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/reducer.cjs +8 -30
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/dom.cjs +3 -1
- package/build/utils/dom.cjs.map +2 -2
- package/build-module/components/autocomplete/index.mjs +2 -2
- package/build-module/components/autocomplete/index.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +2 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
- package/build-module/components/block-bindings/attribute-control.mjs +3 -3
- package/build-module/components/block-bindings/attribute-control.mjs.map +2 -2
- package/build-module/components/block-card/index.mjs +4 -4
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-controls/fill.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +7 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-mover/button.mjs +11 -5
- package/build-module/components/block-mover/button.mjs.map +2 -2
- package/build-module/components/block-pattern-setup/index.mjs +2 -1
- package/build-module/components/block-pattern-setup/index.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-patterns-paging/index.mjs +3 -3
- package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-settings-menu/index.mjs +2 -2
- package/build-module/components/block-settings-menu/index.mjs.map +2 -2
- package/build-module/components/block-styles/menu-items.mjs +2 -2
- package/build-module/components/block-styles/menu-items.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +2 -2
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-switcher/pattern-transformations-menu.mjs +2 -7
- package/build-module/components/block-switcher/pattern-transformations-menu.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs +7 -1
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +2 -2
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +2 -2
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +4 -4
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +0 -10
- package/build-module/components/block-visibility/modal.mjs.map +3 -3
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +4 -4
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/collab/note-icon-slot.mjs +8 -0
- package/build-module/components/collab/note-icon-slot.mjs.map +7 -0
- package/build-module/components/collab/note-icon-toolbar-slot.mjs +10 -0
- package/build-module/components/collab/note-icon-toolbar-slot.mjs.map +7 -0
- package/build-module/components/date-format-picker/index.mjs +2 -2
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +119 -40
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/gradients/use-gradient.mjs +2 -2
- package/build-module/components/gradients/use-gradient.mjs.map +2 -2
- package/build-module/components/grid/grid-item-movers.mjs +2 -5
- package/build-module/components/grid/grid-item-movers.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.mjs +3 -3
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.mjs.map +1 -1
- package/build-module/components/inserter/index.mjs +41 -43
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +34 -4
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/search-results.mjs +1 -1
- package/build-module/components/inserter/search-results.mjs.map +1 -1
- package/build-module/components/inserter/tips.mjs +1 -1
- package/build-module/components/inserter/tips.mjs.map +2 -2
- package/build-module/components/inspector-popover-header/index.mjs +2 -2
- package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
- package/build-module/components/link-control/link-preview.mjs +2 -2
- package/build-module/components/link-control/link-preview.mjs.map +2 -2
- package/build-module/components/link-control/settings.mjs +3 -2
- package/build-module/components/link-control/settings.mjs.map +2 -2
- package/build-module/components/link-picker/link-picker.mjs +1 -1
- package/build-module/components/link-picker/link-picker.mjs.map +2 -2
- package/build-module/components/link-picker/link-preview.mjs +2 -2
- package/build-module/components/link-picker/link-preview.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +2 -2
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs +2 -4
- package/build-module/components/list-view/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +82 -8
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/responsive-block-control/label.mjs +9 -2
- package/build-module/components/responsive-block-control/label.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +12 -5
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/hooks/block-bindings.mjs +2 -2
- package/build-module/hooks/block-bindings.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +1 -1
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +4 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +4 -4
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +7 -5
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -0
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/reducer.mjs +8 -30
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/dom.mjs +2 -1
- package/build-module/utils/dom.mjs.map +2 -2
- package/build-style/content-rtl.css +0 -3
- package/build-style/content.css +0 -3
- package/build-style/style-rtl.css +29 -3
- package/build-style/style.css +29 -3
- package/build-types/components/block-context/index.d.ts +9 -16
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts +13 -6
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +39 -38
- package/src/components/autocomplete/index.js +4 -2
- package/src/components/background-image-control/index.js +2 -2
- package/src/components/block-allowed-blocks/modal.js +3 -3
- package/src/components/block-bindings/attribute-control.js +4 -4
- package/src/components/block-card/index.js +5 -5
- package/src/components/block-controls/fill.js +1 -0
- package/src/components/block-inspector/edit-contents.js +4 -2
- package/src/components/block-list/content.scss +0 -4
- package/src/components/block-manager/style.scss +3 -2
- package/src/components/block-mover/button.js +17 -7
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-patterns-paging/index.js +5 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-styles/menu-items.js +3 -3
- package/src/components/block-switcher/index.js +3 -3
- package/src/components/block-switcher/pattern-transformations-menu.js +2 -7
- package/src/components/block-toolbar/edit-section-button.js +5 -1
- package/src/components/block-toolbar/pattern-overrides-dropdown.js +2 -2
- package/src/components/block-variation-transforms/index.js +4 -4
- package/src/components/block-visibility/modal.js +0 -1
- package/src/components/block-visibility/viewport-visibility-info.js +5 -5
- package/src/components/collab/note-icon-slot.js +8 -0
- package/src/components/collab/note-icon-toolbar-slot.js +10 -0
- package/src/components/date-format-picker/index.js +4 -2
- package/src/components/dimensions-tool/scale-tool.js +2 -2
- package/src/components/global-styles/state-control.js +152 -49
- package/src/components/global-styles/style.scss +9 -0
- package/src/components/gradients/use-gradient.js +3 -1
- package/src/components/grid/grid-item-movers.js +2 -5
- package/src/components/iframe/use-scale-canvas.js +0 -4
- package/src/components/inner-blocks/README.md +5 -1
- package/src/components/inner-blocks/index.native.js +1 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +5 -5
- package/src/components/inserter/index.js +58 -69
- package/src/components/inserter/menu.js +35 -3
- package/src/components/inserter/search-results.js +1 -1
- package/src/components/inserter/style.scss +18 -3
- package/src/components/inserter/tips.js +1 -1
- package/src/components/inspector-popover-header/index.js +2 -2
- package/src/components/link-control/link-preview.js +3 -3
- package/src/components/link-control/settings.js +3 -2
- package/src/components/link-picker/link-picker.js +1 -1
- package/src/components/link-picker/link-preview.js +3 -3
- package/src/components/list-view/block-select-button.js +3 -3
- package/src/components/list-view/index.js +2 -4
- package/src/components/provider/index.js +149 -8
- package/src/components/responsive-block-control/label.js +5 -2
- package/src/components/rich-text/event-listeners/index.js +0 -1
- package/src/components/rich-text/event-listeners/paste-handler.js +18 -4
- package/src/hooks/block-bindings.js +3 -3
- package/src/hooks/custom-css.js +1 -8
- package/src/layouts/flex.js +7 -9
- package/src/layouts/grid.js +7 -4
- package/src/private-apis.js +6 -4
- package/src/store/actions.js +12 -6
- package/src/store/private-keys.js +1 -0
- package/src/store/reducer.js +11 -39
- package/src/store/selectors.js +6 -0
- package/src/store/test/reducer.js +39 -0
- package/src/utils/dom.js +3 -3
- package/src/utils/test/dom.js +47 -4
- package/build/components/collab/block-comment-icon-slot.cjs.map +0 -7
- package/build/components/collab/block-comment-icon-toolbar-slot.cjs.map +0 -7
- package/build-module/components/collab/block-comment-icon-slot.mjs +0 -8
- package/build-module/components/collab/block-comment-icon-slot.mjs.map +0 -7
- package/build-module/components/collab/block-comment-icon-toolbar-slot.mjs +0 -10
- package/build-module/components/collab/block-comment-icon-toolbar-slot.mjs.map +0 -7
- package/src/components/collab/block-comment-icon-slot.js +0 -8
- package/src/components/collab/block-comment-icon-toolbar-slot.js +0 -10
|
@@ -164,12 +164,12 @@ var Inserter = class extends Component {
|
|
|
164
164
|
const {
|
|
165
165
|
position,
|
|
166
166
|
hasSingleBlockType,
|
|
167
|
-
|
|
167
|
+
blockToInsert,
|
|
168
168
|
insertOnlyAllowedBlock,
|
|
169
169
|
__experimentalIsQuick: isQuick,
|
|
170
170
|
onSelectOrClose
|
|
171
171
|
} = this.props;
|
|
172
|
-
if (hasSingleBlockType ||
|
|
172
|
+
if (hasSingleBlockType || blockToInsert) {
|
|
173
173
|
return this.renderToggle({ onToggle: insertOnlyAllowedBlock });
|
|
174
174
|
}
|
|
175
175
|
return /* @__PURE__ */ jsx(
|
|
@@ -197,16 +197,19 @@ var inserter_default = compose([
|
|
|
197
197
|
getBlockRootClientId,
|
|
198
198
|
hasInserterItems,
|
|
199
199
|
getAllowedBlocks,
|
|
200
|
-
getDirectInsertBlock
|
|
200
|
+
getDirectInsertBlock,
|
|
201
|
+
getBlockListSettings
|
|
201
202
|
} = select(blockEditorStore);
|
|
202
203
|
const { getBlockVariations, getBlockType } = select(blocksStore);
|
|
203
204
|
rootClientId = rootClientId || getBlockRootClientId(clientId) || void 0;
|
|
204
205
|
const allowedBlocks = getAllowedBlocks(rootClientId);
|
|
205
206
|
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(rootClientId);
|
|
207
|
+
const { defaultBlock } = getBlockListSettings(rootClientId) ?? {};
|
|
206
208
|
const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, "inserter")?.length === 0;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
const allowedBlockType = hasSingleBlockType ? allowedBlocks[0] : null;
|
|
210
|
+
let blockToInsert = directInsertBlock || null;
|
|
211
|
+
if (!blockToInsert && hasSingleBlockType && defaultBlock?.name === allowedBlockType.name) {
|
|
212
|
+
blockToInsert = defaultBlock;
|
|
210
213
|
}
|
|
211
214
|
const defaultBlockType = directInsertBlock ? getBlockType(directInsertBlock.name) : null;
|
|
212
215
|
const appenderLabel = getAppenderLabel(
|
|
@@ -218,7 +221,7 @@ var inserter_default = compose([
|
|
|
218
221
|
hasSingleBlockType,
|
|
219
222
|
blockTitle: allowedBlockType ? allowedBlockType.title : "",
|
|
220
223
|
allowedBlockType,
|
|
221
|
-
|
|
224
|
+
blockToInsert,
|
|
222
225
|
appenderLabel,
|
|
223
226
|
rootClientId
|
|
224
227
|
};
|
|
@@ -233,43 +236,43 @@ var inserter_default = compose([
|
|
|
233
236
|
isAppender,
|
|
234
237
|
hasSingleBlockType,
|
|
235
238
|
allowedBlockType,
|
|
236
|
-
|
|
239
|
+
blockToInsert,
|
|
237
240
|
onSelectOrClose,
|
|
238
241
|
selectBlockOnInsert
|
|
239
242
|
} = ownProps;
|
|
240
|
-
if (!hasSingleBlockType && !
|
|
243
|
+
if (!hasSingleBlockType && !blockToInsert) {
|
|
241
244
|
return;
|
|
242
245
|
}
|
|
246
|
+
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
243
247
|
function getAdjacentBlockAttributes(attributesToCopy) {
|
|
244
|
-
|
|
245
|
-
if (!attributesToCopy || !clientId && !rootClientId) {
|
|
248
|
+
if (!attributesToCopy?.length) {
|
|
246
249
|
return {};
|
|
247
250
|
}
|
|
248
|
-
const
|
|
249
|
-
let adjacentAttributes
|
|
250
|
-
if (
|
|
251
|
-
const parentBlock = getBlock(rootClientId);
|
|
252
|
-
if (parentBlock?.innerBlocks?.length) {
|
|
253
|
-
const lastInnerBlock = parentBlock.innerBlocks[parentBlock.innerBlocks.length - 1];
|
|
254
|
-
if (directInsertBlock && directInsertBlock?.name === lastInnerBlock.name) {
|
|
255
|
-
adjacentAttributes = lastInnerBlock.attributes;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
251
|
+
const { getBlock, getPreviousBlockClientId } = select(blockEditorStore);
|
|
252
|
+
let adjacentAttributes;
|
|
253
|
+
if (clientId) {
|
|
259
254
|
const currentBlock = getBlock(clientId);
|
|
260
255
|
const previousBlock = getBlock(
|
|
261
256
|
getPreviousBlockClientId(clientId)
|
|
262
257
|
);
|
|
263
258
|
if (currentBlock?.name === previousBlock?.name) {
|
|
264
|
-
adjacentAttributes = previousBlock?.attributes
|
|
259
|
+
adjacentAttributes = previousBlock?.attributes;
|
|
265
260
|
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
|
|
261
|
+
} else if (rootClientId) {
|
|
262
|
+
const lastInnerBlock = getBlock(rootClientId)?.innerBlocks?.at(-1);
|
|
263
|
+
if (lastInnerBlock?.name === blockName) {
|
|
264
|
+
adjacentAttributes = lastInnerBlock.attributes;
|
|
270
265
|
}
|
|
271
|
-
}
|
|
272
|
-
|
|
266
|
+
}
|
|
267
|
+
if (!adjacentAttributes) {
|
|
268
|
+
return {};
|
|
269
|
+
}
|
|
270
|
+
return Object.fromEntries(
|
|
271
|
+
attributesToCopy.filter((attr) => attr in adjacentAttributes).map((attr) => [
|
|
272
|
+
attr,
|
|
273
|
+
adjacentAttributes[attr]
|
|
274
|
+
])
|
|
275
|
+
);
|
|
273
276
|
}
|
|
274
277
|
function getInsertionIndex() {
|
|
275
278
|
const {
|
|
@@ -288,26 +291,21 @@ var inserter_default = compose([
|
|
|
288
291
|
return getBlockOrder(rootClientId).length;
|
|
289
292
|
}
|
|
290
293
|
const { insertBlock } = dispatch(blockEditorStore);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
...newAttributes
|
|
299
|
-
});
|
|
300
|
-
} else {
|
|
301
|
-
blockToInsert = createBlock(allowedBlockType.name);
|
|
302
|
-
}
|
|
294
|
+
const newAttributes = getAdjacentBlockAttributes(
|
|
295
|
+
blockToInsert?.attributesToCopy
|
|
296
|
+
);
|
|
297
|
+
const newBlock = createBlock(blockName, {
|
|
298
|
+
...blockToInsert?.attributes || {},
|
|
299
|
+
...newAttributes
|
|
300
|
+
});
|
|
303
301
|
insertBlock(
|
|
304
|
-
|
|
302
|
+
newBlock,
|
|
305
303
|
getInsertionIndex(),
|
|
306
304
|
rootClientId,
|
|
307
305
|
selectBlockOnInsert
|
|
308
306
|
);
|
|
309
307
|
if (onSelectOrClose) {
|
|
310
|
-
onSelectOrClose(
|
|
308
|
+
onSelectOrClose(newBlock);
|
|
311
309
|
}
|
|
312
310
|
const message = sprintf(
|
|
313
311
|
// translators: %s: the name of the block that has been added
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\tappenderLabel,\n\ttoggleProps = {},\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle.toLowerCase()\n\t\t);\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {Element} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {Element} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonClose={ onClose }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t\t'is-quick': isQuick,\n\t\t\t\t} ) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\tconst appenderLabel = getAppenderLabel(\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tdefaultBlockType\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tappenderLabel,\n\t\t\t\trootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( blockToInsert );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AACt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ACb,UAAO,GAAG,SAAU;AAEpB,SAAK,WAAW,KAAK,SAAS,KAAM,IAAK;AACzC,SAAK,eAAe,KAAK,aAAa,KAAM,IAAK;AACjD,SAAK,gBAAgB,KAAK,cAAc,KAAM,IAAK;AAAA,EACpD;AAAA,EAEA,SAAU,QAAS;AAClB,UAAM,EAAE,SAAS,IAAI,KAAK;AAG1B,QAAK,UAAW;AACf,eAAU,MAAO;AAAA,IAClB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,aAAc,EAAE,UAAU,OAAO,GAAI;AACpC,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,IAChB,IAAI,KAAK;AAET,WAAO,aAAc;AAAA,MACpB;AAAA,MACA;AAAA,MACA,UAAU,YAAY,CAAE;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,cAAe,EAAE,QAAQ,GAAI;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\tappenderLabel,\n\ttoggleProps = {},\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle.toLowerCase()\n\t\t);\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {Element} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {Element} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonClose={ onClose }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tblockToInsert,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || blockToInsert ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t\t'is-quick': isQuick,\n\t\t\t\t} ) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t\tgetBlockListSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\t\t\tconst { defaultBlock } = getBlockListSettings( rootClientId ) ?? {};\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\t\t\tconst allowedBlockType = hasSingleBlockType\n\t\t\t\t? allowedBlocks[ 0 ]\n\t\t\t\t: null;\n\n\t\t\t// Single-block-type parents get adjacent-attribute copying\n\t\t\t// without needing to set `directInsert: true`.\n\t\t\tlet blockToInsert = directInsertBlock || null;\n\t\t\tif (\n\t\t\t\t! blockToInsert &&\n\t\t\t\thasSingleBlockType &&\n\t\t\t\tdefaultBlock?.name === allowedBlockType.name\n\t\t\t) {\n\t\t\t\tblockToInsert = defaultBlock;\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\tconst appenderLabel = getAppenderLabel(\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tdefaultBlockType\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tblockToInsert,\n\t\t\t\tappenderLabel,\n\t\t\t\trootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! blockToInsert ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blockName = blockToInsert?.name ?? allowedBlockType.name;\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tif ( ! attributesToCopy?.length ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\t// Find the adjacent block of the same type whose attributes\n\t\t\t\t\t// should be copied: previous sibling when inserting next to\n\t\t\t\t\t// an existing block, otherwise the last child of the root.\n\t\t\t\t\tlet adjacentAttributes;\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes = previousBlock?.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ( rootClientId ) {\n\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\tgetBlock( rootClientId )?.innerBlocks?.at( -1 );\n\t\t\t\t\t\tif ( lastInnerBlock?.name === blockName ) {\n\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! adjacentAttributes ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tattributesToCopy\n\t\t\t\t\t\t\t.filter( ( attr ) => attr in adjacentAttributes )\n\t\t\t\t\t\t\t.map( ( attr ) => [\n\t\t\t\t\t\t\t\tattr,\n\t\t\t\t\t\t\t\tadjacentAttributes[ attr ],\n\t\t\t\t\t\t\t] )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\t// Attempt to augment the inserted block with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\tblockToInsert?.attributesToCopy\n\t\t\t\t);\n\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\t...( blockToInsert?.attributes || {} ),\n\t\t\t\t\t...newAttributes,\n\t\t\t\t} );\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tnewBlock,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( newBlock );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AACtB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,UAAU,cAAc;AACjC,SAAS,iBAAiB;AAC1B,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,mBAAmB;AACrC,SAAS,aAAa,SAAS,mBAAmB;AAClD,SAAS,YAAY;AAKrB,OAAO,kBAAkB;AACzB,OAAO,mBAAmB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AA2C/B;AAzCF,IAAM,sBAAsB,CAAE;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAChB,MAAO;AACN,QAAM;A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cAC/B;AACD,mBAAO,cAAe,GAAI,IAAI;AAAA,UAC/B;AAGA,iBAAO,cAAe,YAAa,EAAE;AAAA,QACtC;AAEA,cAAM,EAAE,YAAY,IAAI,SAAU,gBAAiB;AAKnD,cAAM,gBAAgB;AAAA,UACrB,eAAe;AAAA,QAChB;AAEA,cAAM,WAAW,YAAa,WAAW;AAAA,UACxC,GAAK,eAAe,cAAc,CAAC;AAAA,UACnC,GAAG;AAAA,QACJ,CAAE;AAEF;AAAA,UACC;AAAA,UACA,kBAAkB;AAAA,UAClB;AAAA,UACA;AAAA,QACD;AAEA,YAAK,iBAAkB;AACtB,0BAAiB,QAAS;AAAA,QAC3B;AAEA,cAAM,UAAU;AAAA;AAAA,UAEf,GAAI,gBAAiB;AAAA,UACrB,iBAAiB;AAAA,QAClB;AACA,cAAO,OAAQ;AAAA,MAChB;AAAA,IACD;AAAA,EACD,CAAE;AAAA;AAAA;AAAA,EAGF;AAAA,IACC,CAAE,EAAE,UAAU,YAAY,cAAc,SAAS,MAChD,YAAc,CAAE,cAAc,CAAE,gBAAgB,CAAE;AAAA,EACpD;AACD,CAAE,EAAG,QAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,11 +4,13 @@ import {
|
|
|
4
4
|
forwardRef,
|
|
5
5
|
useState,
|
|
6
6
|
useCallback,
|
|
7
|
+
useEffect,
|
|
7
8
|
useMemo,
|
|
8
9
|
useRef,
|
|
9
10
|
useLayoutEffect
|
|
10
11
|
} from "@wordpress/element";
|
|
11
|
-
import {
|
|
12
|
+
import { SearchControl, Popover } from "@wordpress/components";
|
|
13
|
+
import { VisuallyHidden } from "@wordpress/ui";
|
|
12
14
|
import { __ } from "@wordpress/i18n";
|
|
13
15
|
import { useDebouncedInput, useViewportMatch } from "@wordpress/compose";
|
|
14
16
|
import { useSelect } from "@wordpress/data";
|
|
@@ -127,6 +129,28 @@ function InserterMenu({
|
|
|
127
129
|
);
|
|
128
130
|
const showPatternPanel = selectedTab === "patterns" && !delayedFilterValue && !!selectedPatternCategory;
|
|
129
131
|
const showMediaPanel = selectedTab === "media" && !!selectedMediaCategory;
|
|
132
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
133
|
+
const blocksPanelRef = useRef(null);
|
|
134
|
+
const patternsPanelRef = useRef(null);
|
|
135
|
+
const mediaPanelRef = useRef(null);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
const handleScroll = (event) => {
|
|
138
|
+
setIsScrolled(event.currentTarget.scrollTop > 0);
|
|
139
|
+
};
|
|
140
|
+
const panels = [
|
|
141
|
+
blocksPanelRef.current,
|
|
142
|
+
patternsPanelRef.current,
|
|
143
|
+
mediaPanelRef.current
|
|
144
|
+
].filter(Boolean);
|
|
145
|
+
panels.forEach(
|
|
146
|
+
(panel) => panel.addEventListener("scroll", handleScroll)
|
|
147
|
+
);
|
|
148
|
+
return () => {
|
|
149
|
+
panels.forEach(
|
|
150
|
+
(panel) => panel.removeEventListener("scroll", handleScroll)
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
}, []);
|
|
130
154
|
const inserterSearch = useMemo(() => {
|
|
131
155
|
if (selectedTab === "media") {
|
|
132
156
|
return null;
|
|
@@ -135,7 +159,9 @@ function InserterMenu({
|
|
|
135
159
|
/* @__PURE__ */ jsx(
|
|
136
160
|
SearchControl,
|
|
137
161
|
{
|
|
138
|
-
className: "block-editor-inserter__search",
|
|
162
|
+
className: clsx("block-editor-inserter__search", {
|
|
163
|
+
"is-scrolled": isScrolled
|
|
164
|
+
}),
|
|
139
165
|
onChange: (value) => {
|
|
140
166
|
if (hoveredItem) {
|
|
141
167
|
setHoveredItem(null);
|
|
@@ -176,7 +202,8 @@ function InserterMenu({
|
|
|
176
202
|
clientId,
|
|
177
203
|
rootClientId,
|
|
178
204
|
__experimentalInsertionIndex,
|
|
179
|
-
isAppender
|
|
205
|
+
isAppender,
|
|
206
|
+
isScrolled
|
|
180
207
|
]);
|
|
181
208
|
const blocksTab = useMemo(() => {
|
|
182
209
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -191,7 +218,7 @@ function InserterMenu({
|
|
|
191
218
|
}
|
|
192
219
|
) }),
|
|
193
220
|
showInserterHelpPanel && /* @__PURE__ */ jsxs("div", { className: "block-editor-inserter__tips", children: [
|
|
194
|
-
/* @__PURE__ */ jsx(VisuallyHidden, {
|
|
221
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { render: /* @__PURE__ */ jsx("h2", {}), children: __("A tip for using the block editor") }),
|
|
195
222
|
/* @__PURE__ */ jsx(Tips, {})
|
|
196
223
|
] })
|
|
197
224
|
] });
|
|
@@ -290,6 +317,7 @@ function InserterMenu({
|
|
|
290
317
|
{
|
|
291
318
|
name: "blocks",
|
|
292
319
|
title: __("Blocks"),
|
|
320
|
+
panelRef: blocksPanelRef,
|
|
293
321
|
panel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
294
322
|
inserterSearch,
|
|
295
323
|
selectedTab === "blocks" && !delayedFilterValue && blocksTab
|
|
@@ -298,6 +326,7 @@ function InserterMenu({
|
|
|
298
326
|
{
|
|
299
327
|
name: "patterns",
|
|
300
328
|
title: __("Patterns"),
|
|
329
|
+
panelRef: patternsPanelRef,
|
|
301
330
|
panel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
302
331
|
inserterSearch,
|
|
303
332
|
selectedTab === "patterns" && !delayedFilterValue && patternsTab
|
|
@@ -306,6 +335,7 @@ function InserterMenu({
|
|
|
306
335
|
{
|
|
307
336
|
name: "media",
|
|
308
337
|
title: __("Media"),
|
|
338
|
+
panelRef: mediaPanelRef,
|
|
309
339
|
panel: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
310
340
|
inserterSearch,
|
|
311
341
|
mediaTab
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/menu.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { VisuallyHidden, SearchControl, Popover } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDebouncedInput, useViewportMatch } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport Tips from './tips';\nimport InserterPreviewPanel from './preview-panel';\nimport BlockTypesTab from './block-types-tab';\nimport BlockPatternsTab from './block-patterns-tab';\nimport { PatternCategoryPreviews } from './block-patterns-tab/pattern-category-previews';\nimport { MediaTab, MediaCategoryPanel } from './media-tab';\nimport InserterSearchResults from './search-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport { store as blockEditorStore } from '../../store';\nimport TabbedSidebar from '../tabbed-sidebar';\nimport { useZoomOut } from '../../hooks/use-zoom-out';\nimport { unlock } from '../../lock-unlock';\n\nconst NOOP = () => {};\nfunction InserterMenu(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\t__experimentalInsertionIndex,\n\t\tonSelect,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks,\n\t\t__experimentalFilterValue = '',\n\t\tshouldFocusBlock = true,\n\t\tonPatternCategorySelection,\n\t\tonClose,\n\t\t__experimentalInitialTab,\n\t\t__experimentalInitialCategory,\n\t},\n\tref\n) {\n\tconst { isZoomOutMode, hasSectionRootClientId } = useSelect( ( select ) => {\n\t\tconst { isZoomOut, getSectionRootClientId } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\treturn {\n\t\t\tisZoomOutMode: isZoomOut(),\n\t\t\thasSectionRootClientId: !! getSectionRootClientId(),\n\t\t};\n\t}, [] );\n\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( __experimentalFilterValue );\n\tconst [ hoveredItem, setHoveredItem ] = useState( null );\n\tconst [ selectedPatternCategory, setSelectedPatternCategory ] = useState(\n\t\t__experimentalInitialCategory\n\t);\n\tconst [ patternFilter, setPatternFilter ] = useState( 'all' );\n\tconst [ selectedMediaCategory, setSelectedMediaCategory ] =\n\t\tuseState( null );\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst maybeCloseInserter = isMobileViewport ? onClose : NOOP;\n\n\tfunction getInitialTab() {\n\t\tif ( __experimentalInitialTab ) {\n\t\t\treturn __experimentalInitialTab;\n\t\t}\n\n\t\tif ( isZoomOutMode ) {\n\t\t\treturn 'patterns';\n\t\t}\n\n\t\treturn 'blocks';\n\t}\n\tconst [ selectedTab, setSelectedTab ] = useState( getInitialTab() );\n\n\tconst shouldUseZoomOut =\n\t\thasSectionRootClientId &&\n\t\t( selectedTab === 'patterns' || selectedTab === 'media' );\n\n\tuseZoomOut( shouldUseZoomOut && isLargeViewport );\n\n\tconst [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ] =\n\t\tuseInsertionPoint( {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\t\tshouldFocusBlock,\n\t\t} );\n\tconst blockTypesTabRef = useRef();\n\n\tconst onInsert = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock, _rootClientId ) => {\n\t\t\tonInsertBlocks(\n\t\t\t\tblocks,\n\t\t\t\tmeta,\n\t\t\t\tshouldForceFocusBlock,\n\t\t\t\t_rootClientId\n\t\t\t);\n\t\t\tonSelect( blocks );\n\t\t\tmaybeCloseInserter();\n\n\t\t\t// Check for focus loss due to filtering blocks by selected block type\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\tif (\n\t\t\t\t\t! shouldFocusBlock &&\n\t\t\t\t\t! blockTypesTabRef.current?.contains(\n\t\t\t\t\t\tref.current.ownerDocument.activeElement\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\t// There has been a focus loss, so focus the first button in the block types tab\n\t\t\t\t\tblockTypesTabRef.current?.querySelector( 'button' ).focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, ref, shouldFocusBlock ]\n\t);\n\n\tconst onInsertPattern = useCallback(\n\t\t( blocks, patternName, ...args ) => {\n\t\t\tonToggleInsertionPoint( false );\n\t\t\tonInsertBlocks( blocks, { patternName }, ...args );\n\t\t\tonSelect();\n\t\t\tmaybeCloseInserter();\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, onToggleInsertionPoint ]\n\t);\n\n\tconst onHover = useCallback(\n\t\t( item ) => {\n\t\t\tonToggleInsertionPoint( item );\n\t\t\tsetHoveredItem( item );\n\t\t},\n\t\t[ onToggleInsertionPoint, setHoveredItem ]\n\t);\n\n\tconst onClickPatternCategory = useCallback(\n\t\t( patternCategory, filter ) => {\n\t\t\tsetSelectedPatternCategory( patternCategory );\n\t\t\tsetPatternFilter( filter );\n\t\t\tonPatternCategorySelection?.();\n\t\t},\n\t\t[ setSelectedPatternCategory, onPatternCategorySelection ]\n\t);\n\n\tconst showPatternPanel =\n\t\tselectedTab === 'patterns' &&\n\t\t! delayedFilterValue &&\n\t\t!! selectedPatternCategory;\n\n\tconst showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;\n\n\tconst inserterSearch = useMemo( () => {\n\t\tif ( selectedTab === 'media' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SearchControl\n\t\t\t\t\tclassName=\"block-editor-inserter__search\"\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tif ( hoveredItem ) {\n\t\t\t\t\t\t\tsetHoveredItem( null );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetFilterValue( value );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t/>\n\t\t\t\t{ !! delayedFilterValue && (\n\t\t\t\t\t<InserterSearchResults\n\t\t\t\t\t\tfilterValue={ delayedFilterValue }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\t\t__experimentalInsertionIndex\n\t\t\t\t\t\t}\n\t\t\t\t\t\tshowBlockDirectory\n\t\t\t\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\t\t\t\tprioritizePatterns={ selectedTab === 'patterns' }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tselectedTab,\n\t\thoveredItem,\n\t\tsetHoveredItem,\n\t\tsetFilterValue,\n\t\tfilterValue,\n\t\tdelayedFilterValue,\n\t\tonSelect,\n\t\tonHover,\n\t\tshouldFocusBlock,\n\t\tclientId,\n\t\trootClientId,\n\t\t__experimentalInsertionIndex,\n\t\tisAppender,\n\t] );\n\n\tconst blocksTab = useMemo( () => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-inserter__block-list\">\n\t\t\t\t\t<BlockTypesTab\n\t\t\t\t\t\tref={ blockTypesTabRef }\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ showInserterHelpPanel && (\n\t\t\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t\t\t<VisuallyHidden as=\"h2\">\n\t\t\t\t\t\t\t{ __( 'A tip for using the block editor' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t<Tips />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tonHover,\n\t\tshowMostUsedBlocks,\n\t\tshowInserterHelpPanel,\n\t] );\n\n\tconst patternsTab = useMemo( () => {\n\t\treturn (\n\t\t\t<BlockPatternsTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\tonSelectCategory={ onClickPatternCategory }\n\t\t\t\tselectedCategory={ selectedPatternCategory }\n\t\t\t>\n\t\t\t\t{ showPatternPanel && (\n\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\t\t\tcategory={ selectedPatternCategory }\n\t\t\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPatternsTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsertPattern,\n\t\tonClickPatternCategory,\n\t\tpatternFilter,\n\t\tselectedPatternCategory,\n\t\tshowPatternPanel,\n\t] );\n\n\tconst mediaTab = useMemo( () => {\n\t\treturn (\n\t\t\t<MediaTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tselectedCategory={ selectedMediaCategory }\n\t\t\t\tonSelectCategory={ setSelectedMediaCategory }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t>\n\t\t\t\t{ showMediaPanel && (\n\t\t\t\t\t<MediaCategoryPanel\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tcategory={ selectedMediaCategory }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</MediaTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tselectedMediaCategory,\n\t\tsetSelectedMediaCategory,\n\t\tshowMediaPanel,\n\t] );\n\n\tconst handleSetSelectedTab = ( value ) => {\n\t\t// If no longer on patterns tab remove the category setting.\n\t\tif ( value !== 'patterns' ) {\n\t\t\tsetSelectedPatternCategory( null );\n\t\t}\n\t\tsetSelectedTab( value );\n\t};\n\n\t// Focus first active tab, if any\n\tconst tabsRef = useRef();\n\tuseLayoutEffect( () => {\n\t\tif ( tabsRef.current ) {\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\ttabsRef.current\n\t\t\t\t\t.querySelector( '[role=\"tab\"][aria-selected=\"true\"]' )\n\t\t\t\t\t?.focus();\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'block-editor-inserter__menu', {\n\t\t\t\t'show-panel': showPatternPanel || showMediaPanel,\n\t\t\t\t'is-zoom-out': isZoomOutMode,\n\t\t\t} ) }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__main-area\">\n\t\t\t\t<TabbedSidebar\n\t\t\t\t\tref={ tabsRef }\n\t\t\t\t\tonSelect={ handleSetSelectedTab }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tselectedTab={ selectedTab }\n\t\t\t\t\tcloseButtonLabel={ __( 'Close Block Inserter' ) }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'blocks',\n\t\t\t\t\t\t\ttitle: __( 'Blocks' ),\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'blocks' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tblocksTab }\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\t{\n\t\t\t\t\t\t\tname: 'patterns',\n\t\t\t\t\t\t\ttitle: __( 'Patterns' ),\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'patterns' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tpatternsTab }\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\t{\n\t\t\t\t\t\t\tname: 'media',\n\t\t\t\t\t\t\ttitle: __( 'Media' ),\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ mediaTab }\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/>\n\t\t\t</div>\n\t\t\t{ showInserterHelpPanel && hoveredItem && (\n\t\t\t\t<Popover\n\t\t\t\t\tclassName=\"block-editor-inserter__preview-container__popover\"\n\t\t\t\t\tplacement=\"right-start\"\n\t\t\t\t\toffset={ 16 }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tanimate={ false }\n\t\t\t\t>\n\t\t\t\t\t<InserterPreviewPanel item={ hoveredItem } />\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport const PrivateInserterMenu = forwardRef( InserterMenu );\n\nfunction PublicInserterMenu( props, ref ) {\n\treturn (\n\t\t<PrivateInserterMenu\n\t\t\t{ ...props }\n\t\t\tonPatternCategorySelection={ NOOP }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( PublicInserterMenu );\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseState,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { SearchControl, Popover } from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { useDebouncedInput, useViewportMatch } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport Tips from './tips';\nimport InserterPreviewPanel from './preview-panel';\nimport BlockTypesTab from './block-types-tab';\nimport BlockPatternsTab from './block-patterns-tab';\nimport { PatternCategoryPreviews } from './block-patterns-tab/pattern-category-previews';\nimport { MediaTab, MediaCategoryPanel } from './media-tab';\nimport InserterSearchResults from './search-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport { store as blockEditorStore } from '../../store';\nimport TabbedSidebar from '../tabbed-sidebar';\nimport { useZoomOut } from '../../hooks/use-zoom-out';\nimport { unlock } from '../../lock-unlock';\n\nconst NOOP = () => {};\nfunction InserterMenu(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\t__experimentalInsertionIndex,\n\t\tonSelect,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks,\n\t\t__experimentalFilterValue = '',\n\t\tshouldFocusBlock = true,\n\t\tonPatternCategorySelection,\n\t\tonClose,\n\t\t__experimentalInitialTab,\n\t\t__experimentalInitialCategory,\n\t},\n\tref\n) {\n\tconst { isZoomOutMode, hasSectionRootClientId } = useSelect( ( select ) => {\n\t\tconst { isZoomOut, getSectionRootClientId } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\treturn {\n\t\t\tisZoomOutMode: isZoomOut(),\n\t\t\thasSectionRootClientId: !! getSectionRootClientId(),\n\t\t};\n\t}, [] );\n\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( __experimentalFilterValue );\n\tconst [ hoveredItem, setHoveredItem ] = useState( null );\n\tconst [ selectedPatternCategory, setSelectedPatternCategory ] = useState(\n\t\t__experimentalInitialCategory\n\t);\n\tconst [ patternFilter, setPatternFilter ] = useState( 'all' );\n\tconst [ selectedMediaCategory, setSelectedMediaCategory ] =\n\t\tuseState( null );\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst maybeCloseInserter = isMobileViewport ? onClose : NOOP;\n\n\tfunction getInitialTab() {\n\t\tif ( __experimentalInitialTab ) {\n\t\t\treturn __experimentalInitialTab;\n\t\t}\n\n\t\tif ( isZoomOutMode ) {\n\t\t\treturn 'patterns';\n\t\t}\n\n\t\treturn 'blocks';\n\t}\n\tconst [ selectedTab, setSelectedTab ] = useState( getInitialTab() );\n\n\tconst shouldUseZoomOut =\n\t\thasSectionRootClientId &&\n\t\t( selectedTab === 'patterns' || selectedTab === 'media' );\n\n\tuseZoomOut( shouldUseZoomOut && isLargeViewport );\n\n\tconst [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ] =\n\t\tuseInsertionPoint( {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\t\tshouldFocusBlock,\n\t\t} );\n\tconst blockTypesTabRef = useRef();\n\n\tconst onInsert = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock, _rootClientId ) => {\n\t\t\tonInsertBlocks(\n\t\t\t\tblocks,\n\t\t\t\tmeta,\n\t\t\t\tshouldForceFocusBlock,\n\t\t\t\t_rootClientId\n\t\t\t);\n\t\t\tonSelect( blocks );\n\t\t\tmaybeCloseInserter();\n\n\t\t\t// Check for focus loss due to filtering blocks by selected block type\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\tif (\n\t\t\t\t\t! shouldFocusBlock &&\n\t\t\t\t\t! blockTypesTabRef.current?.contains(\n\t\t\t\t\t\tref.current.ownerDocument.activeElement\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\t// There has been a focus loss, so focus the first button in the block types tab\n\t\t\t\t\tblockTypesTabRef.current?.querySelector( 'button' ).focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, ref, shouldFocusBlock ]\n\t);\n\n\tconst onInsertPattern = useCallback(\n\t\t( blocks, patternName, ...args ) => {\n\t\t\tonToggleInsertionPoint( false );\n\t\t\tonInsertBlocks( blocks, { patternName }, ...args );\n\t\t\tonSelect();\n\t\t\tmaybeCloseInserter();\n\t\t},\n\t\t[ onInsertBlocks, maybeCloseInserter, onSelect, onToggleInsertionPoint ]\n\t);\n\n\tconst onHover = useCallback(\n\t\t( item ) => {\n\t\t\tonToggleInsertionPoint( item );\n\t\t\tsetHoveredItem( item );\n\t\t},\n\t\t[ onToggleInsertionPoint, setHoveredItem ]\n\t);\n\n\tconst onClickPatternCategory = useCallback(\n\t\t( patternCategory, filter ) => {\n\t\t\tsetSelectedPatternCategory( patternCategory );\n\t\t\tsetPatternFilter( filter );\n\t\t\tonPatternCategorySelection?.();\n\t\t},\n\t\t[ setSelectedPatternCategory, onPatternCategorySelection ]\n\t);\n\n\tconst showPatternPanel =\n\t\tselectedTab === 'patterns' &&\n\t\t! delayedFilterValue &&\n\t\t!! selectedPatternCategory;\n\n\tconst showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;\n\n\tconst [ isScrolled, setIsScrolled ] = useState( false );\n\tconst blocksPanelRef = useRef( null );\n\tconst patternsPanelRef = useRef( null );\n\tconst mediaPanelRef = useRef( null );\n\tuseEffect( () => {\n\t\tconst handleScroll = ( event ) => {\n\t\t\tsetIsScrolled( event.currentTarget.scrollTop > 0 );\n\t\t};\n\t\tconst panels = [\n\t\t\tblocksPanelRef.current,\n\t\t\tpatternsPanelRef.current,\n\t\t\tmediaPanelRef.current,\n\t\t].filter( Boolean );\n\t\tpanels.forEach( ( panel ) =>\n\t\t\tpanel.addEventListener( 'scroll', handleScroll )\n\t\t);\n\n\t\treturn () => {\n\t\t\tpanels.forEach( ( panel ) =>\n\t\t\t\tpanel.removeEventListener( 'scroll', handleScroll )\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst inserterSearch = useMemo( () => {\n\t\tif ( selectedTab === 'media' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SearchControl\n\t\t\t\t\tclassName={ clsx( 'block-editor-inserter__search', {\n\t\t\t\t\t\t'is-scrolled': isScrolled,\n\t\t\t\t\t} ) }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tif ( hoveredItem ) {\n\t\t\t\t\t\t\tsetHoveredItem( null );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetFilterValue( value );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t/>\n\t\t\t\t{ !! delayedFilterValue && (\n\t\t\t\t\t<InserterSearchResults\n\t\t\t\t\t\tfilterValue={ delayedFilterValue }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\t\t__experimentalInsertionIndex\n\t\t\t\t\t\t}\n\t\t\t\t\t\tshowBlockDirectory\n\t\t\t\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\t\t\t\tprioritizePatterns={ selectedTab === 'patterns' }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tselectedTab,\n\t\thoveredItem,\n\t\tsetHoveredItem,\n\t\tsetFilterValue,\n\t\tfilterValue,\n\t\tdelayedFilterValue,\n\t\tonSelect,\n\t\tonHover,\n\t\tshouldFocusBlock,\n\t\tclientId,\n\t\trootClientId,\n\t\t__experimentalInsertionIndex,\n\t\tisAppender,\n\t\tisScrolled,\n\t] );\n\n\tconst blocksTab = useMemo( () => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-inserter__block-list\">\n\t\t\t\t\t<BlockTypesTab\n\t\t\t\t\t\tref={ blockTypesTabRef }\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ showInserterHelpPanel && (\n\t\t\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t\t\t\t{ __( 'A tip for using the block editor' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t<Tips />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tonHover,\n\t\tshowMostUsedBlocks,\n\t\tshowInserterHelpPanel,\n\t] );\n\n\tconst patternsTab = useMemo( () => {\n\t\treturn (\n\t\t\t<BlockPatternsTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\tonSelectCategory={ onClickPatternCategory }\n\t\t\t\tselectedCategory={ selectedPatternCategory }\n\t\t\t>\n\t\t\t\t{ showPatternPanel && (\n\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsertPattern }\n\t\t\t\t\t\tcategory={ selectedPatternCategory }\n\t\t\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPatternsTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsertPattern,\n\t\tonClickPatternCategory,\n\t\tpatternFilter,\n\t\tselectedPatternCategory,\n\t\tshowPatternPanel,\n\t] );\n\n\tconst mediaTab = useMemo( () => {\n\t\treturn (\n\t\t\t<MediaTab\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tselectedCategory={ selectedMediaCategory }\n\t\t\t\tonSelectCategory={ setSelectedMediaCategory }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t>\n\t\t\t\t{ showMediaPanel && (\n\t\t\t\t\t<MediaCategoryPanel\n\t\t\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tcategory={ selectedMediaCategory }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</MediaTab>\n\t\t);\n\t}, [\n\t\tdestinationRootClientId,\n\t\tonInsert,\n\t\tselectedMediaCategory,\n\t\tsetSelectedMediaCategory,\n\t\tshowMediaPanel,\n\t] );\n\n\tconst handleSetSelectedTab = ( value ) => {\n\t\t// If no longer on patterns tab remove the category setting.\n\t\tif ( value !== 'patterns' ) {\n\t\t\tsetSelectedPatternCategory( null );\n\t\t}\n\t\tsetSelectedTab( value );\n\t};\n\n\t// Focus first active tab, if any\n\tconst tabsRef = useRef();\n\tuseLayoutEffect( () => {\n\t\tif ( tabsRef.current ) {\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\ttabsRef.current\n\t\t\t\t\t.querySelector( '[role=\"tab\"][aria-selected=\"true\"]' )\n\t\t\t\t\t?.focus();\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'block-editor-inserter__menu', {\n\t\t\t\t'show-panel': showPatternPanel || showMediaPanel,\n\t\t\t\t'is-zoom-out': isZoomOutMode,\n\t\t\t} ) }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__main-area\">\n\t\t\t\t<TabbedSidebar\n\t\t\t\t\tref={ tabsRef }\n\t\t\t\t\tonSelect={ handleSetSelectedTab }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tselectedTab={ selectedTab }\n\t\t\t\t\tcloseButtonLabel={ __( 'Close Block Inserter' ) }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'blocks',\n\t\t\t\t\t\t\ttitle: __( 'Blocks' ),\n\t\t\t\t\t\t\tpanelRef: blocksPanelRef,\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'blocks' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tblocksTab }\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\t{\n\t\t\t\t\t\t\tname: 'patterns',\n\t\t\t\t\t\t\ttitle: __( 'Patterns' ),\n\t\t\t\t\t\t\tpanelRef: patternsPanelRef,\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ selectedTab === 'patterns' &&\n\t\t\t\t\t\t\t\t\t\t! delayedFilterValue &&\n\t\t\t\t\t\t\t\t\t\tpatternsTab }\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\t{\n\t\t\t\t\t\t\tname: 'media',\n\t\t\t\t\t\t\ttitle: __( 'Media' ),\n\t\t\t\t\t\t\tpanelRef: mediaPanelRef,\n\t\t\t\t\t\t\tpanel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ inserterSearch }\n\t\t\t\t\t\t\t\t\t{ mediaTab }\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/>\n\t\t\t</div>\n\t\t\t{ showInserterHelpPanel && hoveredItem && (\n\t\t\t\t<Popover\n\t\t\t\t\tclassName=\"block-editor-inserter__preview-container__popover\"\n\t\t\t\t\tplacement=\"right-start\"\n\t\t\t\t\toffset={ 16 }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tanimate={ false }\n\t\t\t\t>\n\t\t\t\t\t<InserterPreviewPanel item={ hoveredItem } />\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport const PrivateInserterMenu = forwardRef( InserterMenu );\n\nfunction PublicInserterMenu( props, ref ) {\n\treturn (\n\t\t<PrivateInserterMenu\n\t\t\t{ ...props }\n\t\t\tonPatternCategorySelection={ NOOP }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( PublicInserterMenu );\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,eAAe;AACvC,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB,wBAAwB;AACpD,SAAS,iBAAiB;AAK1B,OAAO,UAAU;AACjB,OAAO,0BAA0B;AACjC,OAAO,mBAAmB;AAC1B,OAAO,sBAAsB;AAC7B,SAAS,+BAA+B;AACxC,SAAS,UAAU,0BAA0B;AAC7C,OAAO,2BAA2B;AAClC,OAAO,uBAAuB;AAC9B,SAAS,SAAS,wBAAwB;AAC1C,OAAO,mBAAmB;AAC1B,SAAS,kBAAkB;AAC3B,S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YACT,cAAe;AAAA,YACf,SAAU;AAAA,YAEV,8BAAC,wBAAqB,MAAO,aAAc;AAAA;AAAA,QAC5C;AAAA;AAAA;AAAA,EAEF;AAEF;AAEO,IAAM,sBAAsB,WAAY,YAAa;AAE5D,SAAS,mBAAoB,OAAO,KAAM;AACzC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,4BAA6B;AAAA,MAC7B;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,eAAQ,WAAY,kBAAmB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/block-editor/src/components/inserter/search-results.js
|
|
2
2
|
import { useMemo, useEffect } from "@wordpress/element";
|
|
3
3
|
import { __, _n, sprintf } from "@wordpress/i18n";
|
|
4
|
-
import { VisuallyHidden } from "@wordpress/
|
|
4
|
+
import { VisuallyHidden } from "@wordpress/ui";
|
|
5
5
|
import { useDebounce, useAsyncList } from "@wordpress/compose";
|
|
6
6
|
import { speak } from "@wordpress/a11y";
|
|
7
7
|
import { useSelect } from "@wordpress/data";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/search-results.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\nimport { orderInserterBlockItems } from '../../utils/order-inserter-block-items';\nimport { store as blockEditorStore } from '../../store';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\tonHoverPattern,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n\tprioritizePatterns,\n\tselectBlockOnInsert,\n\tisQuick,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst { prioritizedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst blockListSettings =\n\t\t\t\tselect( blockEditorStore ).getBlockListSettings( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tprioritizedBlocks:\n\t\t\t\t\tblockListSettings?.prioritizedInserterBlocks || EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t\tselectBlockOnInsert,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks, isQuick );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tundefined,\n\t\tisQuick\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( maxBlockPatterns === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\tlet maxBlockTypesToShow = maxBlockTypes;\n\tif ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {\n\t\tmaxBlockTypesToShow = 0;\n\t}\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( maxBlockTypesToShow === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst nonPatternBlockTypes = blockTypes.filter(\n\t\t\t( blockType ) => blockType.name !== 'core/block'\n\t\t);\n\t\tlet orderedItems = orderBy( nonPatternBlockTypes, 'frecency', 'desc' );\n\n\t\tif ( ! filterValue && prioritizedBlocks.length ) {\n\t\t\torderedItems = orderInserterBlockItems(\n\t\t\t\torderedItems,\n\t\t\t\tprioritizedBlocks\n\t\t\t);\n\t\t}\n\n\t\tconst results = searchBlockItems(\n\t\t\torderedItems,\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypesToShow !== undefined\n\t\t\t? results.slice( 0, maxBlockTypesToShow )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypesToShow,\n\t\tprioritizedBlocks,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [\n\t\tfilterValue,\n\t\tdebouncedSpeak,\n\t\tfilteredBlockTypes,\n\t\tfilteredBlockPatterns,\n\t] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\n\tconst hasItems =\n\t\tfilteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0;\n\n\tconst blocksUI = !! filteredBlockTypes.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\tisDraggable={ isDraggable }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n\n\tconst patternsUI = !! filteredBlockPatterns.length && (\n\t\t<InserterPanel\n\t\t\ttitle={\n\t\t\t\t<VisuallyHidden>{ __( 'Block patterns' ) }</VisuallyHidden>\n\t\t\t}\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-patterns\">\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHoverPattern }\n\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</InserterPanel>\n\t);\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }\n\n\t\t\t{ prioritizePatterns ? patternsUI : blocksUI }\n\n\t\t\t{ !! filteredBlockTypes.length &&\n\t\t\t\t!! filteredBlockPatterns.length && (\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t) }\n\n\t\t\t{ prioritizePatterns ? blocksUI : patternsUI }\n\n\t\t\t{ showBlockDirectory && (\n\t\t\t\t<__unstableInserterMenuExtension.Slot\n\t\t\t\t\tfillProps={ {\n\t\t\t\t\t\tonSelect: onSelectBlockType,\n\t\t\t\t\t\tonHover,\n\t\t\t\t\t\tfilterValue,\n\t\t\t\t\t\thasItems,\n\t\t\t\t\t\trootClientId: destinationRootClientId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( fills ) => {\n\t\t\t\t\t\tif ( fills.length ) {\n\t\t\t\t\t\t\treturn fills;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! hasItems ) {\n\t\t\t\t\t\t\treturn <InserterNoResults />;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} }\n\t\t\t\t</__unstableInserterMenuExtension.Slot>\n\t\t\t) }\n\t\t</InserterListbox>\n\t);\n}\n\nexport default InserterSearchResults;\n"],
|
|
5
5
|
"mappings": ";AAGA,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,sBAAsB;AAC/B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAK1B,OAAO,oBAAoB;AAC3B,OAAO,uBAAuB;AAC9B,OAAO,qCAAqC;AAC5C,OAAO,mBAAmB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,uBAAuB;AAC9B,OAAO,sBAAsB;AAC7B,OAAO,wBAAwB;AAC/B,SAAS,kBAAkB,mBAAmB;AAC9C,OAAO,qBAAqB;AAC5B,SAAS,eAAe;AACxB,SAAS,+BAA+B;AACxC,SAAS,SAAS,wBAAwB;AAgJ/B,cA8BT,YA9BS;AA9IX,IAAM,2BAA2B;AAOjC,IAAM,cAAc,CAAC;AAErB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AiB,aAAI,gBAAiB,GAAG;AAAA,MAG3C,8BAAC,SAAI,WAAU,kDACd;AAAA,QAAC;AAAA;AAAA,UACA,eAAgB;AAAA,UAChB;AAAA,UACA,SAAU;AAAA,UACV;AAAA;AAAA,MACD,GACD;AAAA;AAAA,EACD;AAGD,SACC,qBAAC,mBACE;AAAA,KAAE,sBAAsB,CAAE,YAAY,oBAAC,qBAAkB;AAAA,IAEzD,qBAAqB,aAAa;AAAA,IAElC,CAAC,CAAE,mBAAmB,UACvB,CAAC,CAAE,sBAAsB,UACxB,oBAAC,SAAI,WAAU,mDAAkD;AAAA,IAGjE,qBAAqB,WAAW;AAAA,IAEhC,sBACD;AAAA,MAAC,gCAAgC;AAAA,MAAhC;AAAA,QACA,WAAY;AAAA,UACX,UAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QACf;AAAA,QAEE,WAAE,UAAW;AACd,cAAK,MAAM,QAAS;AACnB,mBAAO;AAAA,UACR;AACA,cAAK,CAAE,UAAW;AACjB,mBAAO,oBAAC,qBAAkB;AAAA,UAC3B;AACA,iBAAO;AAAA,QACR;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var globalTips = [
|
|
|
27
27
|
];
|
|
28
28
|
function Tips() {
|
|
29
29
|
const [randomIndex] = useState(
|
|
30
|
-
Math.floor(Math.random() * globalTips.length)
|
|
30
|
+
() => Math.floor(Math.random() * globalTips.length)
|
|
31
31
|
);
|
|
32
32
|
return /* @__PURE__ */ jsx(Tip, { children: globalTips[randomIndex] });
|
|
33
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/tips.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement, useState } from '@wordpress/element';\nimport { Tip } from '@wordpress/components';\n\nconst globalTips = [\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\t__( 'Drag files into the editor to automatically insert media blocks.' ),\n\t__( \"Change a block's type by pressing the block icon on the toolbar.\" ),\n];\n\nfunction Tips() {\n\tconst [ randomIndex ] = useState(
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,0BAA0B,gBAAgB;AACnD,SAAS,WAAW;AAOX;AALT,IAAM,aAAa;AAAA,EAClB;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA,GAAI,kEAAmE;AAAA,EACvE,GAAI,kEAAmE;AACxE;AAEA,SAAS,OAAO;AACf,QAAM,CAAE,WAAY,IAAI;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement, useState } from '@wordpress/element';\nimport { Tip } from '@wordpress/components';\n\nconst globalTips = [\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\tcreateInterpolateElement(\n\t\t__(\n\t\t\t'Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'\n\t\t),\n\t\t{ kbd: <kbd /> }\n\t),\n\t__( 'Drag files into the editor to automatically insert media blocks.' ),\n\t__( \"Change a block's type by pressing the block icon on the toolbar.\" ),\n];\n\nfunction Tips() {\n\tconst [ randomIndex ] = useState( () =>\n\t\tMath.floor( Math.random() * globalTips.length )\n\t);\n\n\treturn <Tip>{ globalTips[ randomIndex ] }</Tip>;\n}\n\nexport default Tips;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,0BAA0B,gBAAgB;AACnD,SAAS,WAAW;AAOX;AALT,IAAM,aAAa;AAAA,EAClB;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA;AAAA,IACC;AAAA,MACC;AAAA,IACD;AAAA,IACA,EAAE,KAAK,oBAAC,SAAI,EAAG;AAAA,EAChB;AAAA,EACA,GAAI,kEAAmE;AAAA,EACvE,GAAI,kEAAmE;AACxE;AAEA,SAAS,OAAO;AACf,QAAM,CAAE,WAAY,IAAI;AAAA,IAAU,MACjC,KAAK,MAAO,KAAK,OAAO,IAAI,WAAW,MAAO;AAAA,EAC/C;AAEA,SAAO,oBAAC,OAAM,qBAAY,WAAY,GAAG;AAC1C;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__experimentalHeading as Heading,
|
|
6
6
|
__experimentalSpacer as Spacer,
|
|
7
7
|
Button,
|
|
8
|
-
__experimentalText as
|
|
8
|
+
__experimentalText as WCText
|
|
9
9
|
} from "@wordpress/components";
|
|
10
10
|
import { closeSmall } from "@wordpress/icons";
|
|
11
11
|
import { __ } from "@wordpress/i18n";
|
|
@@ -52,7 +52,7 @@ function InspectorPopoverHeader({
|
|
|
52
52
|
}
|
|
53
53
|
)
|
|
54
54
|
] }),
|
|
55
|
-
help && /* @__PURE__ */ jsx(
|
|
55
|
+
help && /* @__PURE__ */ jsx(WCText, { children: help })
|
|
56
56
|
] });
|
|
57
57
|
}
|
|
58
58
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inspector-popover-header/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tButton,\n\t__experimentalText as
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,wBAAwB;AAAA,EACxB;AAAA,EACA,sBAAsB;AAAA,OAChB;AACP,SAAS,kBAAkB;AAC3B,SAAS,UAAU;AAUhB,SACC,KADD;AARY,SAAR,uBAAyC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AACD,GAAI;AACH,SACC,qBAAC,UAAO,WAAU,yCAAwC,SAAU,GACnE;AAAA,yBAAC,UAAO,WAAU,UACjB;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,OAAQ;AAAA,UACR,MAAO;AAAA,UAEL;AAAA;AAAA,MACH;AAAA,MACA,oBAAC,UAAO;AAAA,MACN,QAAQ,IAAK,CAAE,EAAE,OAAO,MAAM,QAAQ,MACvC;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UAEL,WAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,SAAU,CAAE,QAAQ;AAAA,UACpB;AAAA,UAEE,WAAE,QAAQ;AAAA;AAAA,QAPN;AAAA,MAQP,CACC;AAAA,MACA,WACD;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ,GAAI,OAAQ;AAAA,UACpB,MAAO;AAAA,UACP,SAAU;AAAA;AAAA,MACX;AAAA,OAEF;AAAA,IACE,QAAQ,oBAAC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tButton,\n\t__experimentalText as WCText,\n} from '@wordpress/components';\nimport { closeSmall } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function InspectorPopoverHeader( {\n\ttitle,\n\thelp,\n\tactions = [],\n\tonClose,\n} ) {\n\treturn (\n\t\t<VStack className=\"block-editor-inspector-popover-header\" spacing={ 4 }>\n\t\t\t<HStack alignment=\"center\">\n\t\t\t\t<Heading\n\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__heading\"\n\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\tsize={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</Heading>\n\t\t\t\t<Spacer />\n\t\t\t\t{ actions.map( ( { label, icon, onClick } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__action\"\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tvariant={ ! icon && 'tertiary' }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! icon && label }\n\t\t\t\t\t</Button>\n\t\t\t\t) ) }\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__action\"\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ help && <WCText>{ help }</WCText> }\n\t\t</VStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,wBAAwB;AAAA,EACxB;AAAA,EACA,sBAAsB;AAAA,OAChB;AACP,SAAS,kBAAkB;AAC3B,SAAS,UAAU;AAUhB,SACC,KADD;AARY,SAAR,uBAAyC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AACD,GAAI;AACH,SACC,qBAAC,UAAO,WAAU,yCAAwC,SAAU,GACnE;AAAA,yBAAC,UAAO,WAAU,UACjB;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,OAAQ;AAAA,UACR,MAAO;AAAA,UAEL;AAAA;AAAA,MACH;AAAA,MACA,oBAAC,UAAO;AAAA,MACN,QAAQ,IAAK,CAAE,EAAE,OAAO,MAAM,QAAQ,MACvC;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UAEL,WAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,SAAU,CAAE,QAAQ;AAAA,UACpB;AAAA,UAEE,WAAE,QAAQ;AAAA;AAAA,QAPN;AAAA,MAQP,CACC;AAAA,MACA,WACD;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ,GAAI,OAAQ;AAAA,UACpB,MAAO;AAAA,UACP,SAAU;AAAA;AAAA,MACX;AAAA,OAEF;AAAA,IACE,QAAQ,oBAAC,UAAS,gBAAM;AAAA,KAC3B;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ import { unlock } from "../../lock-unlock.mjs";
|
|
|
27
27
|
import { ViewerSlot } from "./viewer-slot.mjs";
|
|
28
28
|
import useRichUrlData from "./use-rich-url-data.mjs";
|
|
29
29
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
-
var { Badge } = unlock(componentsPrivateApis);
|
|
30
|
+
var { Badge: WCBadge } = unlock(componentsPrivateApis);
|
|
31
31
|
function LinkPreview({
|
|
32
32
|
value,
|
|
33
33
|
onEditClick,
|
|
@@ -132,7 +132,7 @@ function LinkPreview({
|
|
|
132
132
|
gap: 1,
|
|
133
133
|
children: value.badges.map(
|
|
134
134
|
(badge, index) => /* @__PURE__ */ jsx(
|
|
135
|
-
|
|
135
|
+
WCBadge,
|
|
136
136
|
{
|
|
137
137
|
intent: badge.intent,
|
|
138
138
|
children: badge.label
|