at path:
ROOT
/
wp-includes
/
js
/
dist
/
reusable-blocks.js
run:
R
W
Run
development
DIR
2023-02-13 12:53:07
R
W
Run
script-modules
DIR
2026-05-21 18:07:37
R
W
Run
vendor
DIR
2026-05-21 18:07:38
R
W
Run
a11y.js
5.45 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
a11y.min.js
2.44 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
annotations.js
15.13 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
annotations.min.js
5.62 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
api-fetch.js
17.46 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
api-fetch.min.js
6.32 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
autop.js
9.73 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
autop.min.js
5.5 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
base-styles.js
48 By
2026-05-21 18:07:37
R
W
Run
Delete
Rename
base-styles.min.js
75 By
2026-07-10 17:22:33
R
W
Run
Delete
Rename
blob.js
2.3 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
blob.min.js
1.16 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-directory.js
55.67 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
block-directory.min.js
21.96 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-editor.js
2.7 MB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-editor.min.js
1.01 MB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-library.js
2.57 MB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-library.min.js
1.09 MB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-serialization-default-parser.js
6.54 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
block-serialization-default-parser.min.js
2.39 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
block-serialization-spec-parser.js
50.48 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
block-serialization-spec-parser.min.js
10.38 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
blocks.js
381.06 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
blocks.min.js
180.62 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
commands.js
151.71 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
commands.min.js
63.14 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
components.js
3.83 MB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
components.min.js
786.28 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
compose.js
80.75 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
compose.min.js
28.18 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
core-commands.js
28.68 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
core-commands.min.js
11.87 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
core-data.js
612.03 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
core-data.min.js
210.46 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
customize-widgets.js
91.57 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
customize-widgets.min.js
36.62 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
data-controls.js
4.13 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
data-controls.min.js
1.77 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
data.js
82.78 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
data.min.js
25.92 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
date.js
176.34 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
date.min.js
141.22 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
deprecated.js
3.04 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
deprecated.min.js
1.28 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
dom-ready.js
1.47 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
dom-ready.min.js
818 By
2026-07-10 17:22:33
R
W
Run
Delete
Rename
dom.js
34.61 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
dom.min.js
12.65 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
edit-post.js
117.4 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
edit-post.min.js
49.11 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
edit-site.js
1.69 MB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
edit-site.min.js
684.45 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
edit-widgets.js
160.25 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
edit-widgets.min.js
61.86 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
editor.js
2.5 MB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
editor.min.js
1021.63 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
element.js
27.93 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
element.min.js
12.17 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
escape-html.js
2.29 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
escape-html.min.js
1.07 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
format-library.js
73.34 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
format-library.min.js
28.88 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
hooks.js
11.96 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
hooks.min.js
4.93 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
html-entities.js
1.65 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
html-entities.min.js
879 By
2026-07-10 17:22:33
R
W
Run
Delete
Rename
i18n.js
15.3 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
i18n.min.js
5.6 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
is-shallow-equal.js
2.69 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
is-shallow-equal.min.js
1.1 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
keyboard-shortcuts.js
9.68 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
keyboard-shortcuts.min.js
3.44 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
keycodes.js
8.3 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
keycodes.min.js
2.91 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
list-reusable-blocks.js
13.06 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
list-reusable-blocks.min.js
5.24 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
media-utils.js
637.15 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
media-utils.min.js
237.64 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
notices.js
10.11 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
notices.min.js
4.38 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
nux.js
10.32 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
nux.min.js
3.95 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
patterns.js
58.25 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
patterns.min.js
21.63 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
plugins.js
11.67 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
plugins.min.js
4.76 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
preferences-persistence.js
17.22 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
preferences-persistence.min.js
5.49 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
preferences.js
21.07 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
preferences.min.js
7.71 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
primitives.js
5.08 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
primitives.min.js
1.98 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
priority-queue.js
10.02 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
priority-queue.min.js
3.35 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
private-apis.js
4.09 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
private-apis.min.js
2.66 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
react-i18n.js
3.91 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
react-i18n.min.js
1.53 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
redux-routine.js
24.68 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
redux-routine.min.js
9.65 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
reusable-blocks.js
20.51 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
reusable-blocks.min.js
7.22 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
rich-text.js
97.04 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
rich-text.min.js
39.89 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
router.js
36.12 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
router.min.js
14.13 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
server-side-render.js
10.97 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
server-side-render.min.js
3.94 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
shortcode.js
7.96 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
shortcode.min.js
3.28 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
style-engine.js
17.62 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
style-engine.min.js
6.42 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
sync.js
359.4 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
sync.min.js
118.11 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
theme.js
127.65 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
theme.min.js
56.12 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
token-list.js
6.12 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
token-list.min.js
1.62 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
undo-manager.js
5.29 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
undo-manager.min.js
1.7 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
upload-media.js
55.67 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
upload-media.min.js
23.05 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
url.js
23.39 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
url.min.js
10.13 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
viewport.js
6.61 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
viewport.min.js
2.24 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
warning.js
1.52 KB
2026-05-21 18:07:36
R
W
Run
Delete
Rename
warning.min.js
755 By
2026-07-10 17:22:33
R
W
Run
Delete
Rename
widgets.js
50.08 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
widgets.min.js
20.83 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
wordcount.js
6.93 KB
2026-05-21 18:07:37
R
W
Run
Delete
Rename
wordcount.min.js
2.45 KB
2026-07-10 17:22:33
R
W
Run
Delete
Rename
error_log
up
📄
reusable-blocks.js
Save
var wp; (wp ||= {}).reusableBlocks = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // package-external:@wordpress/data var require_data = __commonJS({ "package-external:@wordpress/data"(exports, module) { module.exports = window.wp.data; } }); // package-external:@wordpress/block-editor var require_block_editor = __commonJS({ "package-external:@wordpress/block-editor"(exports, module) { module.exports = window.wp.blockEditor; } }); // package-external:@wordpress/blocks var require_blocks = __commonJS({ "package-external:@wordpress/blocks"(exports, module) { module.exports = window.wp.blocks; } }); // package-external:@wordpress/i18n var require_i18n = __commonJS({ "package-external:@wordpress/i18n"(exports, module) { module.exports = window.wp.i18n; } }); // package-external:@wordpress/element var require_element = __commonJS({ "package-external:@wordpress/element"(exports, module) { module.exports = window.wp.element; } }); // package-external:@wordpress/components var require_components = __commonJS({ "package-external:@wordpress/components"(exports, module) { module.exports = window.wp.components; } }); // package-external:@wordpress/primitives var require_primitives = __commonJS({ "package-external:@wordpress/primitives"(exports, module) { module.exports = window.wp.primitives; } }); // vendor-external:react/jsx-runtime var require_jsx_runtime = __commonJS({ "vendor-external:react/jsx-runtime"(exports, module) { module.exports = window.ReactJSXRuntime; } }); // package-external:@wordpress/notices var require_notices = __commonJS({ "package-external:@wordpress/notices"(exports, module) { module.exports = window.wp.notices; } }); // package-external:@wordpress/core-data var require_core_data = __commonJS({ "package-external:@wordpress/core-data"(exports, module) { module.exports = window.wp.coreData; } }); // package-external:@wordpress/url var require_url = __commonJS({ "package-external:@wordpress/url"(exports, module) { module.exports = window.wp.url; } }); // packages/reusable-blocks/build-module/index.mjs var index_exports = {}; __export(index_exports, { ReusableBlocksMenuItems: () => ReusableBlocksMenuItems, store: () => store }); // packages/reusable-blocks/build-module/store/index.mjs var import_data2 = __toESM(require_data(), 1); // packages/reusable-blocks/build-module/store/actions.mjs var actions_exports = {}; __export(actions_exports, { __experimentalConvertBlockToStatic: () => __experimentalConvertBlockToStatic, __experimentalConvertBlocksToReusable: () => __experimentalConvertBlocksToReusable, __experimentalDeleteReusableBlock: () => __experimentalDeleteReusableBlock, __experimentalSetEditingReusableBlock: () => __experimentalSetEditingReusableBlock }); var import_block_editor = __toESM(require_block_editor(), 1); var import_blocks = __toESM(require_blocks(), 1); var import_i18n = __toESM(require_i18n(), 1); var __experimentalConvertBlockToStatic = (clientId) => ({ registry }) => { const oldBlock = registry.select(import_block_editor.store).getBlock(clientId); const reusableBlock = registry.select("core").getEditedEntityRecord( "postType", "wp_block", oldBlock.attributes.ref ); const newBlocks = (0, import_blocks.parse)( typeof reusableBlock.content === "function" ? reusableBlock.content(reusableBlock) : reusableBlock.content ); registry.dispatch(import_block_editor.store).replaceBlocks(oldBlock.clientId, newBlocks); }; var __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({ registry, dispatch }) => { const meta = syncType === "unsynced" ? { wp_pattern_sync_status: syncType } : void 0; const reusableBlock = { title: title || (0, import_i18n.__)("Untitled pattern block"), content: (0, import_blocks.serialize)( registry.select(import_block_editor.store).getBlocksByClientId(clientIds) ), status: "publish", meta }; const updatedRecord = await registry.dispatch("core").saveEntityRecord("postType", "wp_block", reusableBlock); if (syncType === "unsynced") { return; } const newBlock = (0, import_blocks.createBlock)("core/block", { ref: updatedRecord.id }); registry.dispatch(import_block_editor.store).replaceBlocks(clientIds, newBlock); dispatch.__experimentalSetEditingReusableBlock( newBlock.clientId, true ); }; var __experimentalDeleteReusableBlock = (id) => async ({ registry }) => { const reusableBlock = registry.select("core").getEditedEntityRecord("postType", "wp_block", id); if (!reusableBlock) { return; } const allBlocks = registry.select(import_block_editor.store).getBlocks(); const associatedBlocks = allBlocks.filter( (block) => (0, import_blocks.isReusableBlock)(block) && block.attributes.ref === id ); const associatedBlockClientIds = associatedBlocks.map( (block) => block.clientId ); if (associatedBlockClientIds.length) { registry.dispatch(import_block_editor.store).removeBlocks(associatedBlockClientIds); } await registry.dispatch("core").deleteEntityRecord("postType", "wp_block", id); }; function __experimentalSetEditingReusableBlock(clientId, isEditing) { return { type: "SET_EDITING_REUSABLE_BLOCK", clientId, isEditing }; } // packages/reusable-blocks/build-module/store/reducer.mjs var import_data = __toESM(require_data(), 1); function isEditingReusableBlock(state = {}, action) { if (action?.type === "SET_EDITING_REUSABLE_BLOCK") { return { ...state, [action.clientId]: action.isEditing }; } return state; } var reducer_default = (0, import_data.combineReducers)({ isEditingReusableBlock }); // packages/reusable-blocks/build-module/store/selectors.mjs var selectors_exports = {}; __export(selectors_exports, { __experimentalIsEditingReusableBlock: () => __experimentalIsEditingReusableBlock }); function __experimentalIsEditingReusableBlock(state, clientId) { return state.isEditingReusableBlock[clientId]; } // packages/reusable-blocks/build-module/store/index.mjs var STORE_NAME = "core/reusable-blocks"; var store = (0, import_data2.createReduxStore)(STORE_NAME, { actions: actions_exports, reducer: reducer_default, selectors: selectors_exports }); (0, import_data2.register)(store); // packages/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.mjs var import_block_editor4 = __toESM(require_block_editor(), 1); // packages/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.mjs var import_blocks2 = __toESM(require_blocks(), 1); var import_block_editor2 = __toESM(require_block_editor(), 1); var import_element = __toESM(require_element(), 1); var import_components = __toESM(require_components(), 1); // packages/icons/build-module/library/symbol.mjs var import_primitives = __toESM(require_primitives(), 1); var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) }); // packages/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.mjs var import_data3 = __toESM(require_data(), 1); var import_i18n2 = __toESM(require_i18n(), 1); var import_notices = __toESM(require_notices(), 1); var import_core_data = __toESM(require_core_data(), 1); var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); function ReusableBlockConvertButton({ clientIds, rootClientId, onClose }) { const [syncType, setSyncType] = (0, import_element.useState)(void 0); const [isModalOpen, setIsModalOpen] = (0, import_element.useState)(false); const [title, setTitle] = (0, import_element.useState)(""); const canConvert = (0, import_data3.useSelect)( (select) => { const { canUser } = select(import_core_data.store); const { getBlocksByClientId, canInsertBlockType, getBlockRootClientId } = select(import_block_editor2.store); const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : void 0); const blocks = getBlocksByClientId(clientIds) ?? []; const isReusable = blocks.length === 1 && blocks[0] && (0, import_blocks2.isReusableBlock)(blocks[0]) && !!select(import_core_data.store).getEntityRecord( "postType", "wp_block", blocks[0].attributes.ref ); const _canConvert = ( // Hide when this is already a reusable block. !isReusable && // Hide when reusable blocks are disabled. canInsertBlockType("core/block", rootId) && blocks.every( (block) => ( // Guard against the case where a regular block has *just* been converted. !!block && // Hide on invalid blocks. block.isValid && // Hide when block doesn't support being made reusable. (0, import_blocks2.hasBlockSupport)(block.name, "reusable", true) ) ) && // Hide when current doesn't have permission to do that. // Blocks refers to the wp_block post type, this checks the ability to create a post of that type. !!canUser("create", { kind: "postType", name: "wp_block" }) ); return _canConvert; }, [clientIds, rootClientId] ); const { __experimentalConvertBlocksToReusable: convertBlocksToReusable } = (0, import_data3.useDispatch)(store); const { createSuccessNotice, createErrorNotice } = (0, import_data3.useDispatch)(import_notices.store); const onConvert = (0, import_element.useCallback)( async function(reusableBlockTitle) { try { await convertBlocksToReusable( clientIds, reusableBlockTitle, syncType ); createSuccessNotice( !syncType ? (0, import_i18n2.sprintf)( // translators: %s: the name the user has given to the pattern. (0, import_i18n2.__)("Synced pattern created: %s"), reusableBlockTitle ) : (0, import_i18n2.sprintf)( // translators: %s: the name the user has given to the pattern. (0, import_i18n2.__)("Unsynced pattern created: %s"), reusableBlockTitle ), { type: "snackbar", id: "convert-to-reusable-block-success" } ); } catch (error) { createErrorNotice(error.message, { type: "snackbar", id: "convert-to-reusable-block-error" }); } }, [ convertBlocksToReusable, clientIds, syncType, createSuccessNotice, createErrorNotice ] ); if (!canConvert) { return null; } return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_components.MenuItem, { icon: symbol_default, onClick: () => setIsModalOpen(true), children: (0, import_i18n2.__)("Create pattern") }), isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_components.Modal, { title: (0, import_i18n2.__)("Create pattern"), onRequestClose: () => { setIsModalOpen(false); setTitle(""); }, overlayClassName: "reusable-blocks-menu-items__convert-modal", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "form", { onSubmit: (event) => { event.preventDefault(); onConvert(title); setIsModalOpen(false); setTitle(""); onClose(); }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components.__experimentalVStack, { spacing: "5", children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_components.TextControl, { __next40pxDefaultSize: true, label: (0, import_i18n2.__)("Name"), value: title, onChange: setTitle, placeholder: (0, import_i18n2.__)("My pattern") } ), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_components.ToggleControl, { label: (0, import_i18n2._x)("Synced", "pattern (singular)"), help: (0, import_i18n2.__)( "Sync this pattern across multiple locations." ), checked: !syncType, onChange: () => { setSyncType( !syncType ? "unsynced" : void 0 ); } } ), /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components.__experimentalHStack, { justify: "right", children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_components.Button, { __next40pxDefaultSize: true, variant: "tertiary", onClick: () => { setIsModalOpen(false); setTitle(""); }, children: (0, import_i18n2.__)("Cancel") } ), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_components.Button, { __next40pxDefaultSize: true, variant: "primary", type: "submit", children: (0, import_i18n2.__)("Create") } ) ] }) ] }) } ) } ) ] }); } // packages/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.mjs var import_components2 = __toESM(require_components(), 1); var import_i18n3 = __toESM(require_i18n(), 1); var import_blocks3 = __toESM(require_blocks(), 1); var import_data4 = __toESM(require_data(), 1); var import_element2 = __toESM(require_element(), 1); var import_block_editor3 = __toESM(require_block_editor(), 1); var import_url = __toESM(require_url(), 1); var import_core_data2 = __toESM(require_core_data(), 1); var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); function ReusableBlocksManageButton({ clientId }) { const [showConfirmDialog, setShowConfirmDialog] = (0, import_element2.useState)(false); const { canRemove, isVisible, managePatternsUrl } = (0, import_data4.useSelect)( (select) => { const { getBlock, canRemoveBlock } = select(import_block_editor3.store); const { canUser } = select(import_core_data2.store); const reusableBlock = getBlock(clientId); return { canRemove: canRemoveBlock(clientId), isVisible: !!reusableBlock && (0, import_blocks3.isReusableBlock)(reusableBlock) && !!canUser("update", { kind: "postType", name: "wp_block", id: reusableBlock.attributes.ref }), // The site editor and templates both check whether the user // has edit_theme_options capabilities. We can leverage that here // and omit the manage patterns link if the user can't access it. managePatternsUrl: canUser("create", { kind: "postType", name: "wp_template" }) ? (0, import_url.addQueryArgs)("site-editor.php", { p: "/pattern" }) : (0, import_url.addQueryArgs)("edit.php", { post_type: "wp_block" }) }; }, [clientId] ); const { __experimentalConvertBlockToStatic: convertBlockToStatic } = (0, import_data4.useDispatch)(store); if (!isVisible) { return null; } const handleDetach = () => { convertBlockToStatic(clientId); setShowConfirmDialog(false); }; return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_components2.MenuItem, { href: managePatternsUrl, children: (0, import_i18n3.__)("Manage patterns") }), canRemove && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_components2.MenuItem, { onClick: () => setShowConfirmDialog(true), children: (0, import_i18n3.__)("Disconnect pattern") }), /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( import_components2.__experimentalConfirmDialog, { isOpen: showConfirmDialog, onConfirm: handleDetach, onCancel: () => setShowConfirmDialog(false), confirmButtonText: (0, import_i18n3.__)("Disconnect"), size: "medium", title: (0, import_i18n3.__)("Disconnect pattern?"), __experimentalHideHeader: false, children: (0, import_i18n3.__)( "Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here." ) } ) ] }) ] }); } var reusable_blocks_manage_button_default = ReusableBlocksManageButton; // packages/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.mjs var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); function ReusableBlocksMenuItems({ rootClientId }) { return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_block_editor4.BlockSettingsMenuControls, { children: ({ onClose, selectedClientIds }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( ReusableBlockConvertButton, { clientIds: selectedClientIds, rootClientId, onClose } ), selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( reusable_blocks_manage_button_default, { clientId: selectedClientIds[0] } ) ] }) }); } return __toCommonJS(index_exports); })();