@wordpress/reusable-blocks 5.32.0 → 5.32.1-next.47f435fc9.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.
Files changed (53) hide show
  1. package/build/components/index.js +36 -12
  2. package/build/components/index.js.map +7 -1
  3. package/build/components/reusable-blocks-menu-items/index.js +51 -34
  4. package/build/components/reusable-blocks-menu-items/index.js.map +7 -1
  5. package/build/components/reusable-blocks-menu-items/reusable-block-convert-button.js +189 -150
  6. package/build/components/reusable-blocks-menu-items/reusable-block-convert-button.js.map +7 -1
  7. package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +65 -72
  8. package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map +7 -1
  9. package/build/index.js +27 -24
  10. package/build/index.js.map +7 -1
  11. package/build/lock-unlock.js +30 -14
  12. package/build/lock-unlock.js.map +7 -1
  13. package/build/store/actions.js +74 -81
  14. package/build/store/actions.js.map +7 -1
  15. package/build/store/index.js +44 -33
  16. package/build/store/index.js.map +7 -1
  17. package/build/store/reducer.js +30 -14
  18. package/build/store/reducer.js.map +7 -1
  19. package/build/store/selectors.js +26 -13
  20. package/build/store/selectors.js.map +7 -1
  21. package/build-module/components/index.js +5 -2
  22. package/build-module/components/index.js.map +7 -1
  23. package/build-module/components/reusable-blocks-menu-items/index.js +23 -27
  24. package/build-module/components/reusable-blocks-menu-items/index.js.map +7 -1
  25. package/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js +178 -145
  26. package/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js.map +7 -1
  27. package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +47 -66
  28. package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map +7 -1
  29. package/build-module/index.js +6 -3
  30. package/build-module/index.js.map +7 -1
  31. package/build-module/lock-unlock.js +8 -7
  32. package/build-module/lock-unlock.js.map +7 -1
  33. package/build-module/store/actions.js +50 -68
  34. package/build-module/store/actions.js.map +7 -1
  35. package/build-module/store/index.js +10 -22
  36. package/build-module/store/index.js.map +7 -1
  37. package/build-module/store/reducer.js +9 -8
  38. package/build-module/store/reducer.js.map +7 -1
  39. package/build-module/store/selectors.js +5 -9
  40. package/build-module/store/selectors.js.map +7 -1
  41. package/build-style/style-rtl.css +3 -138
  42. package/build-style/style.css +3 -138
  43. package/package.json +21 -14
  44. package/src/components/reusable-blocks-menu-items/style.scss +2 -0
  45. package/src/style.scss +2 -1
  46. package/build/components/reusable-blocks-menu-items/index.native.js +0 -9
  47. package/build/components/reusable-blocks-menu-items/index.native.js.map +0 -1
  48. package/build/index.native.js +0 -29
  49. package/build/index.native.js.map +0 -1
  50. package/build-module/components/reusable-blocks-menu-items/index.native.js +0 -2
  51. package/build-module/components/reusable-blocks-menu-items/index.native.js.map +0 -1
  52. package/build-module/index.native.js +0 -7
  53. package/build-module/index.native.js.map +0 -1
@@ -1,77 +1,70 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var reusable_blocks_manage_button_exports = {};
19
+ __export(reusable_blocks_manage_button_exports, {
20
+ default: () => reusable_blocks_manage_button_default
5
21
  });
6
- exports.default = void 0;
7
- var _components = require("@wordpress/components");
8
- var _i18n = require("@wordpress/i18n");
9
- var _blocks = require("@wordpress/blocks");
10
- var _data = require("@wordpress/data");
11
- var _blockEditor = require("@wordpress/block-editor");
12
- var _url = require("@wordpress/url");
13
- var _coreData = require("@wordpress/core-data");
14
- var _store = require("../../store");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- /**
17
- * WordPress dependencies
18
- */
19
-
20
- /**
21
- * Internal dependencies
22
- */
23
-
24
- function ReusableBlocksManageButton({
25
- clientId
26
- }) {
27
- const {
28
- canRemove,
29
- isVisible,
30
- managePatternsUrl
31
- } = (0, _data.useSelect)(select => {
32
- const {
33
- getBlock,
34
- canRemoveBlock
35
- } = select(_blockEditor.store);
36
- const {
37
- canUser
38
- } = select(_coreData.store);
39
- const reusableBlock = getBlock(clientId);
40
- return {
41
- canRemove: canRemoveBlock(clientId),
42
- isVisible: !!reusableBlock && (0, _blocks.isReusableBlock)(reusableBlock) && !!canUser('update', {
43
- kind: 'postType',
44
- name: 'wp_block',
45
- id: reusableBlock.attributes.ref
46
- }),
47
- // The site editor and templates both check whether the user
48
- // has edit_theme_options capabilities. We can leverage that here
49
- // and omit the manage patterns link if the user can't access it.
50
- managePatternsUrl: canUser('create', {
51
- kind: 'postType',
52
- name: 'wp_template'
53
- }) ? (0, _url.addQueryArgs)('site-editor.php', {
54
- p: '/pattern'
55
- }) : (0, _url.addQueryArgs)('edit.php', {
56
- post_type: 'wp_block'
57
- })
58
- };
59
- }, [clientId]);
60
- const {
61
- __experimentalConvertBlockToStatic: convertBlockToStatic
62
- } = (0, _data.useDispatch)(_store.store);
22
+ module.exports = __toCommonJS(reusable_blocks_manage_button_exports);
23
+ var import_jsx_runtime = require("react/jsx-runtime");
24
+ var import_components = require("@wordpress/components");
25
+ var import_i18n = require("@wordpress/i18n");
26
+ var import_blocks = require("@wordpress/blocks");
27
+ var import_data = require("@wordpress/data");
28
+ var import_block_editor = require("@wordpress/block-editor");
29
+ var import_url = require("@wordpress/url");
30
+ var import_core_data = require("@wordpress/core-data");
31
+ var import_store = require("../../store");
32
+ function ReusableBlocksManageButton({ clientId }) {
33
+ const { canRemove, isVisible, managePatternsUrl } = (0, import_data.useSelect)(
34
+ (select) => {
35
+ const { getBlock, canRemoveBlock } = select(import_block_editor.store);
36
+ const { canUser } = select(import_core_data.store);
37
+ const reusableBlock = getBlock(clientId);
38
+ return {
39
+ canRemove: canRemoveBlock(clientId),
40
+ isVisible: !!reusableBlock && (0, import_blocks.isReusableBlock)(reusableBlock) && !!canUser("update", {
41
+ kind: "postType",
42
+ name: "wp_block",
43
+ id: reusableBlock.attributes.ref
44
+ }),
45
+ // The site editor and templates both check whether the user
46
+ // has edit_theme_options capabilities. We can leverage that here
47
+ // and omit the manage patterns link if the user can't access it.
48
+ managePatternsUrl: canUser("create", {
49
+ kind: "postType",
50
+ name: "wp_template"
51
+ }) ? (0, import_url.addQueryArgs)("site-editor.php", {
52
+ p: "/pattern"
53
+ }) : (0, import_url.addQueryArgs)("edit.php", {
54
+ post_type: "wp_block"
55
+ })
56
+ };
57
+ },
58
+ [clientId]
59
+ );
60
+ const { __experimentalConvertBlockToStatic: convertBlockToStatic } = (0, import_data.useDispatch)(import_store.store);
63
61
  if (!isVisible) {
64
62
  return null;
65
63
  }
66
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
67
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
68
- href: managePatternsUrl,
69
- children: (0, _i18n.__)('Manage patterns')
70
- }), canRemove && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
71
- onClick: () => convertBlockToStatic(clientId),
72
- children: (0, _i18n.__)('Detach')
73
- })]
74
- });
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuItem, { href: managePatternsUrl, children: (0, import_i18n.__)("Manage patterns") }),
66
+ canRemove && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuItem, { onClick: () => convertBlockToStatic(clientId), children: (0, import_i18n.__)("Detach") })
67
+ ] });
75
68
  }
76
- var _default = exports.default = ReusableBlocksManageButton;
77
- //# sourceMappingURL=reusable-blocks-manage-button.js.map
69
+ var reusable_blocks_manage_button_default = ReusableBlocksManageButton;
70
+ //# sourceMappingURL=reusable-blocks-manage-button.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_components","require","_i18n","_blocks","_data","_blockEditor","_url","_coreData","_store","_jsxRuntime","ReusableBlocksManageButton","clientId","canRemove","isVisible","managePatternsUrl","useSelect","select","getBlock","canRemoveBlock","blockEditorStore","canUser","coreStore","reusableBlock","isReusableBlock","kind","name","id","attributes","ref","addQueryArgs","p","post_type","__experimentalConvertBlockToStatic","convertBlockToStatic","useDispatch","reusableBlocksStore","jsxs","Fragment","children","jsx","MenuItem","href","__","onClick","_default","exports","default"],"sources":["@wordpress/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as reusableBlocksStore } from '../../store';\n\nfunction ReusableBlocksManageButton( { clientId } ) {\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock } = select( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t\tid: reusableBlock.attributes.ref,\n\t\t\t\t\t} ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t\t{ canRemove && (\n\t\t\t\t<MenuItem onClick={ () => convertBlockToStatic( clientId ) }>\n\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksManageButton;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MA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IAAA,EAAA3B,WAAA,CAAA4B,QAAA;IAAAC,QAAA,gBACC,IAAA7B,WAAA,CAAA8B,GAAA,EAACvC,WAAA,CAAAwC,QAAQ;MAACC,IAAI,EAAG3B,iBAAmB;MAAAwB,QAAA,EACjC,IAAAI,QAAE,EAAE,iBAAkB;IAAC,CAChB,CAAC,EACT9B,SAAS,iBACV,IAAAH,WAAA,CAAA8B,GAAA,EAACvC,WAAA,CAAAwC,QAAQ;MAACG,OAAO,EAAGA,CAAA,KAAMV,oBAAoB,CAAEtB,QAAS,CAAG;MAAA2B,QAAA,EACzD,IAAAI,QAAE,EAAE,QAAS;IAAC,CACP,CACV;EAAA,CACA,CAAC;AAEL;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcpC,0BAA0B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as reusableBlocksStore } from '../../store';\n\nfunction ReusableBlocksManageButton( { clientId } ) {\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock } = select( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t\tid: reusableBlock.attributes.ref,\n\t\t\t\t\t} ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t\t{ canRemove && (\n\t\t\t\t<MenuItem onClick={ () => convertBlockToStatic( clientId ) }>\n\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksManageButton;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2DE;AAxDF,wBAAyB;AACzB,kBAAmB;AACnB,oBAAgC;AAChC,kBAAuC;AACvC,0BAA0C;AAC1C,iBAA6B;AAC7B,uBAAmC;AAKnC,mBAA6C;AAE7C,SAAS,2BAA4B,EAAE,SAAS,GAAI;AACnD,QAAM,EAAE,WAAW,WAAW,kBAAkB,QAAI;AAAA,IACnD,CAAE,WAAY;AACb,YAAM,EAAE,UAAU,eAAe,IAAI,OAAQ,oBAAAA,KAAiB;AAC9D,YAAM,EAAE,QAAQ,IAAI,OAAQ,iBAAAC,KAAU;AACtC,YAAM,gBAAgB,SAAU,QAAS;AAEzC,aAAO;AAAA,QACN,WAAW,eAAgB,QAAS;AAAA,QACpC,WACC,CAAC,CAAE,qBACH,+BAAiB,aAAc,KAC/B,CAAC,CAAE,QAAS,UAAU;AAAA,UACrB,MAAM;AAAA,UACN,MAAM;AAAA,UACN,IAAI,cAAc,WAAW;AAAA,QAC9B,CAAE;AAAA;AAAA;AAAA;AAAA,QAIH,mBAAmB,QAAS,UAAU;AAAA,UACrC,MAAM;AAAA,UACN,MAAM;AAAA,QACP,CAAE,QACC,yBAAc,mBAAmB;AAAA,UACjC,GAAG;AAAA,QACH,CAAE,QACF,yBAAc,YAAY;AAAA,UAC1B,WAAW;AAAA,QACX,CAAE;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,EAAE,oCAAoC,qBAAqB,QAChE,yBAAa,aAAAC,KAAoB;AAElC,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SACC,4EACC;AAAA,gDAAC,8BAAS,MAAO,mBACd,8BAAI,iBAAkB,GACzB;AAAA,IACE,aACD,4CAAC,8BAAS,SAAU,MAAM,qBAAsB,QAAS,GACtD,8BAAI,QAAS,GAChB;AAAA,KAEF;AAEF;AAEA,IAAO,wCAAQ;",
6
+ "names": ["blockEditorStore", "coreStore", "reusableBlocksStore"]
7
+ }
package/build/index.js CHANGED
@@ -1,28 +1,31 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- store: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
8
  };
9
- Object.defineProperty(exports, "store", {
10
- enumerable: true,
11
- get: function () {
12
- return _store.store;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
14
  }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ store: () => import_store.store
14
22
  });
15
- var _store = require("./store");
16
- var _components = require("./components");
17
- Object.keys(_components).forEach(function (key) {
18
- if (key === "default" || key === "__esModule") return;
19
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
- if (key in exports && exports[key] === _components[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _components[key];
25
- }
26
- });
23
+ module.exports = __toCommonJS(index_exports);
24
+ var import_store = require("./store");
25
+ __reExport(index_exports, require("./components"), module.exports);
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ store,
29
+ ...require("./components")
27
30
  });
28
- //# sourceMappingURL=index.js.map
31
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_store","require","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["@wordpress/reusable-blocks/src/index.js"],"sourcesContent":["export { store } from './store';\nexport * from './components';\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["export { store } from './store';\nexport * from './components';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,0BAAc,yBADd;",
6
+ "names": []
7
+ }
@@ -1,16 +1,32 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var lock_unlock_exports = {};
19
+ __export(lock_unlock_exports, {
20
+ unlock: () => unlock
5
21
  });
6
- exports.unlock = void 0;
7
- var _privateApis = require("@wordpress/private-apis");
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- const {
22
+ module.exports = __toCommonJS(lock_unlock_exports);
23
+ var import_private_apis = require("@wordpress/private-apis");
24
+ const { unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
25
+ "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26
+ "@wordpress/reusable-blocks"
27
+ );
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
13
30
  unlock
14
- } = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/reusable-blocks');
15
- exports.unlock = unlock;
16
- //# sourceMappingURL=lock-unlock.js.map
31
+ });
32
+ //# sourceMappingURL=lock-unlock.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_privateApis","require","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/reusable-blocks/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t'@wordpress/reusable-blocks'\n);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC;AAAO,CAAC,GAAG,IAAAC,6DAAgD,EACzE,+HAA+H,EAC/H,4BACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lock-unlock.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t'@wordpress/reusable-blocks'\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,MAAM,EAAE,OAAO,QAAI;AAAA,EACzB;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -1,104 +1,97 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var actions_exports = {};
19
+ __export(actions_exports, {
20
+ __experimentalConvertBlockToStatic: () => __experimentalConvertBlockToStatic,
21
+ __experimentalConvertBlocksToReusable: () => __experimentalConvertBlocksToReusable,
22
+ __experimentalDeleteReusableBlock: () => __experimentalDeleteReusableBlock,
23
+ __experimentalSetEditingReusableBlock: () => __experimentalSetEditingReusableBlock
5
24
  });
6
- exports.__experimentalDeleteReusableBlock = exports.__experimentalConvertBlocksToReusable = exports.__experimentalConvertBlockToStatic = void 0;
7
- exports.__experimentalSetEditingReusableBlock = __experimentalSetEditingReusableBlock;
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _blocks = require("@wordpress/blocks");
10
- var _i18n = require("@wordpress/i18n");
11
- /**
12
- * WordPress dependencies
13
- */
14
-
15
- /**
16
- * Returns a generator converting a reusable block into a static block.
17
- *
18
- * @param {string} clientId The client ID of the block to attach.
19
- */
20
- const __experimentalConvertBlockToStatic = clientId => ({
21
- registry
22
- }) => {
23
- const oldBlock = registry.select(_blockEditor.store).getBlock(clientId);
24
- const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
25
- const newBlocks = (0, _blocks.parse)(typeof reusableBlock.content === 'function' ? reusableBlock.content(reusableBlock) : reusableBlock.content);
26
- registry.dispatch(_blockEditor.store).replaceBlocks(oldBlock.clientId, newBlocks);
25
+ module.exports = __toCommonJS(actions_exports);
26
+ var import_block_editor = require("@wordpress/block-editor");
27
+ var import_blocks = require("@wordpress/blocks");
28
+ var import_i18n = require("@wordpress/i18n");
29
+ const __experimentalConvertBlockToStatic = (clientId) => ({ registry }) => {
30
+ const oldBlock = registry.select(import_block_editor.store).getBlock(clientId);
31
+ const reusableBlock = registry.select("core").getEditedEntityRecord(
32
+ "postType",
33
+ "wp_block",
34
+ oldBlock.attributes.ref
35
+ );
36
+ const newBlocks = (0, import_blocks.parse)(
37
+ typeof reusableBlock.content === "function" ? reusableBlock.content(reusableBlock) : reusableBlock.content
38
+ );
39
+ registry.dispatch(import_block_editor.store).replaceBlocks(oldBlock.clientId, newBlocks);
27
40
  };
28
-
29
- /**
30
- * Returns a generator converting one or more static blocks into a pattern.
31
- *
32
- * @param {string[]} clientIds The client IDs of the block to detach.
33
- * @param {string} title Pattern title.
34
- * @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'.
35
- */
36
- exports.__experimentalConvertBlockToStatic = __experimentalConvertBlockToStatic;
37
- const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({
38
- registry,
39
- dispatch
40
- }) => {
41
- const meta = syncType === 'unsynced' ? {
41
+ const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({ registry, dispatch }) => {
42
+ const meta = syncType === "unsynced" ? {
42
43
  wp_pattern_sync_status: syncType
43
- } : undefined;
44
+ } : void 0;
44
45
  const reusableBlock = {
45
- title: title || (0, _i18n.__)('Untitled pattern block'),
46
- content: (0, _blocks.serialize)(registry.select(_blockEditor.store).getBlocksByClientId(clientIds)),
47
- status: 'publish',
46
+ title: title || (0, import_i18n.__)("Untitled pattern block"),
47
+ content: (0, import_blocks.serialize)(
48
+ registry.select(import_block_editor.store).getBlocksByClientId(clientIds)
49
+ ),
50
+ status: "publish",
48
51
  meta
49
52
  };
50
- const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
51
- if (syncType === 'unsynced') {
53
+ const updatedRecord = await registry.dispatch("core").saveEntityRecord("postType", "wp_block", reusableBlock);
54
+ if (syncType === "unsynced") {
52
55
  return;
53
56
  }
54
- const newBlock = (0, _blocks.createBlock)('core/block', {
57
+ const newBlock = (0, import_blocks.createBlock)("core/block", {
55
58
  ref: updatedRecord.id
56
59
  });
57
- registry.dispatch(_blockEditor.store).replaceBlocks(clientIds, newBlock);
58
- dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true);
60
+ registry.dispatch(import_block_editor.store).replaceBlocks(clientIds, newBlock);
61
+ dispatch.__experimentalSetEditingReusableBlock(
62
+ newBlock.clientId,
63
+ true
64
+ );
59
65
  };
60
-
61
- /**
62
- * Returns a generator deleting a reusable block.
63
- *
64
- * @param {string} id The ID of the reusable block to delete.
65
- */
66
- exports.__experimentalConvertBlocksToReusable = __experimentalConvertBlocksToReusable;
67
- const __experimentalDeleteReusableBlock = id => async ({
68
- registry
69
- }) => {
70
- const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id);
71
-
72
- // Don't allow a reusable block with a temporary ID to be deleted.
66
+ const __experimentalDeleteReusableBlock = (id) => async ({ registry }) => {
67
+ const reusableBlock = registry.select("core").getEditedEntityRecord("postType", "wp_block", id);
73
68
  if (!reusableBlock) {
74
69
  return;
75
70
  }
76
-
77
- // Remove any other blocks that reference this reusable block.
78
- const allBlocks = registry.select(_blockEditor.store).getBlocks();
79
- const associatedBlocks = allBlocks.filter(block => (0, _blocks.isReusableBlock)(block) && block.attributes.ref === id);
80
- const associatedBlockClientIds = associatedBlocks.map(block => block.clientId);
81
-
82
- // Remove the parsed block.
71
+ const allBlocks = registry.select(import_block_editor.store).getBlocks();
72
+ const associatedBlocks = allBlocks.filter(
73
+ (block) => (0, import_blocks.isReusableBlock)(block) && block.attributes.ref === id
74
+ );
75
+ const associatedBlockClientIds = associatedBlocks.map(
76
+ (block) => block.clientId
77
+ );
83
78
  if (associatedBlockClientIds.length) {
84
- registry.dispatch(_blockEditor.store).removeBlocks(associatedBlockClientIds);
79
+ registry.dispatch(import_block_editor.store).removeBlocks(associatedBlockClientIds);
85
80
  }
86
- await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
81
+ await registry.dispatch("core").deleteEntityRecord("postType", "wp_block", id);
87
82
  };
88
-
89
- /**
90
- * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
91
- *
92
- * @param {string} clientId The clientID of the reusable block to target.
93
- * @param {boolean} isEditing Whether the block should be in editing state.
94
- * @return {Object} Action descriptor.
95
- */
96
- exports.__experimentalDeleteReusableBlock = __experimentalDeleteReusableBlock;
97
83
  function __experimentalSetEditingReusableBlock(clientId, isEditing) {
98
84
  return {
99
- type: 'SET_EDITING_REUSABLE_BLOCK',
85
+ type: "SET_EDITING_REUSABLE_BLOCK",
100
86
  clientId,
101
87
  isEditing
102
88
  };
103
89
  }
104
- //# sourceMappingURL=actions.js.map
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ __experimentalConvertBlockToStatic,
93
+ __experimentalConvertBlocksToReusable,
94
+ __experimentalDeleteReusableBlock,
95
+ __experimentalSetEditingReusableBlock
96
+ });
97
+ //# sourceMappingURL=actions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_blockEditor","require","_blocks","_i18n","__experimentalConvertBlockToStatic","clientId","registry","oldBlock","select","blockEditorStore","getBlock","reusableBlock","getEditedEntityRecord","attributes","ref","newBlocks","parse","content","dispatch","replaceBlocks","exports","__experimentalConvertBlocksToReusable","clientIds","title","syncType","meta","wp_pattern_sync_status","undefined","__","serialize","getBlocksByClientId","status","updatedRecord","saveEntityRecord","newBlock","createBlock","id","__experimentalSetEditingReusableBlock","__experimentalDeleteReusableBlock","allBlocks","getBlocks","associatedBlocks","filter","block","isReusableBlock","associatedBlockClientIds","map","length","removeBlocks","deleteEntityRecord","isEditing","type"],"sources":["@wordpress/reusable-blocks/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tcreateBlock,\n\tisReusableBlock,\n\tparse,\n\tserialize,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Returns a generator converting a reusable block into a static block.\n *\n * @param {string} clientId The client ID of the block to attach.\n */\nexport const __experimentalConvertBlockToStatic =\n\t( clientId ) =>\n\t( { registry } ) => {\n\t\tconst oldBlock = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlock( clientId );\n\t\tconst reusableBlock = registry\n\t\t\t.select( 'core' )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\toldBlock.attributes.ref\n\t\t\t);\n\n\t\tconst newBlocks = parse(\n\t\t\ttypeof reusableBlock.content === 'function'\n\t\t\t\t? reusableBlock.content( reusableBlock )\n\t\t\t\t: reusableBlock.content\n\t\t);\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.replaceBlocks( oldBlock.clientId, newBlocks );\n\t};\n\n/**\n * Returns a generator converting one or more static blocks into a pattern.\n *\n * @param {string[]} clientIds The client IDs of the block to detach.\n * @param {string} title Pattern title.\n * @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'.\n */\nexport const __experimentalConvertBlocksToReusable =\n\t( clientIds, title, syncType ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst meta =\n\t\t\tsyncType === 'unsynced'\n\t\t\t\t? {\n\t\t\t\t\t\twp_pattern_sync_status: syncType,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\n\t\tconst reusableBlock = {\n\t\t\ttitle: title || __( 'Untitled pattern block' ),\n\t\t\tcontent: serialize(\n\t\t\t\tregistry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlocksByClientId( clientIds )\n\t\t\t),\n\t\t\tstatus: 'publish',\n\t\t\tmeta,\n\t\t};\n\n\t\tconst updatedRecord = await registry\n\t\t\t.dispatch( 'core' )\n\t\t\t.saveEntityRecord( 'postType', 'wp_block', reusableBlock );\n\n\t\tif ( syncType === 'unsynced' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\tref: updatedRecord.id,\n\t\t} );\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.replaceBlocks( clientIds, newBlock );\n\t\tdispatch.__experimentalSetEditingReusableBlock(\n\t\t\tnewBlock.clientId,\n\t\t\ttrue\n\t\t);\n\t};\n\n/**\n * Returns a generator deleting a reusable block.\n *\n * @param {string} id The ID of the reusable block to delete.\n */\nexport const __experimentalDeleteReusableBlock =\n\t( id ) =>\n\tasync ( { registry } ) => {\n\t\tconst reusableBlock = registry\n\t\t\t.select( 'core' )\n\t\t\t.getEditedEntityRecord( 'postType', 'wp_block', id );\n\n\t\t// Don't allow a reusable block with a temporary ID to be deleted.\n\t\tif ( ! reusableBlock ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Remove any other blocks that reference this reusable block.\n\t\tconst allBlocks = registry.select( blockEditorStore ).getBlocks();\n\t\tconst associatedBlocks = allBlocks.filter(\n\t\t\t( block ) => isReusableBlock( block ) && block.attributes.ref === id\n\t\t);\n\t\tconst associatedBlockClientIds = associatedBlocks.map(\n\t\t\t( block ) => block.clientId\n\t\t);\n\n\t\t// Remove the parsed block.\n\t\tif ( associatedBlockClientIds.length ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.removeBlocks( associatedBlockClientIds );\n\t\t}\n\n\t\tawait registry\n\t\t\t.dispatch( 'core' )\n\t\t\t.deleteEntityRecord( 'postType', 'wp_block', id );\n\t};\n\n/**\n * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.\n *\n * @param {string} clientId The clientID of the reusable block to target.\n * @param {boolean} isEditing Whether the block should be in editing state.\n * @return {Object} Action descriptor.\n */\nexport function __experimentalSetEditingReusableBlock( clientId, isEditing ) {\n\treturn {\n\t\ttype: 'SET_EDITING_REUSABLE_BLOCK',\n\t\tclientId,\n\t\tisEditing,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AAVA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACO,MAAMG,kCAAkC,GAC5CC,QAAQ,IACV,CAAE;EAAEC;AAAS,CAAC,KAAM;EACnB,MAAMC,QAAQ,GAAGD,QAAQ,CACvBE,MAAM,CAAEC,kBAAiB,CAAC,CAC1BC,QAAQ,CAAEL,QAAS,CAAC;EACtB,MAAMM,aAAa,GAAGL,QAAQ,CAC5BE,MAAM,CAAE,MAAO,CAAC,CAChBI,qBAAqB,CACrB,UAAU,EACV,UAAU,EACVL,QAAQ,CAACM,UAAU,CAACC,GACrB,CAAC;EAEF,MAAMC,SAAS,GAAG,IAAAC,aAAK,EACtB,OAAOL,aAAa,CAACM,OAAO,KAAK,UAAU,GACxCN,aAAa,CAACM,OAAO,CAAEN,aAAc,CAAC,GACtCA,aAAa,CAACM,OAClB,CAAC;EACDX,QAAQ,CACNY,QAAQ,CAAET,kBAAiB,CAAC,CAC5BU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E9B;AAAS,CAAC,KAAM;EACzB,MAAMK,aAAa,GAAGL,QAAQ,CAC5BE,MAAM,CAAE,MAAO,CAAC,CAChBI,qBAAqB,CAAE,UAAU,EAAE,UAAU,EAAEwB,EAAG,CAAC;;EAErD;EACA,IAAK,CAAEzB,aAAa,EAAG;IACtB;EACD;;EAEA;EACA,MAAM4B,SAAS,GAAGjC,QAAQ,CAACE,MAAM,CAAEC,kBAAiB,CAAC,CAAC+B,SAAS,CAAC,CAAC;EACjE,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,MAAM,CACtCC,KAAK,IAAM,IAAAC,uBAAe,EAAED,KAAM,CAAC,IAAIA,KAAK,CAAC9B,UAAU,CAACC,GAAG,KAAKsB,EACnE,CAAC;EACD,MAAMS,wBAAwB,GAAGJ,gBAAgB,CAACK,GAAG,CAClDH,KAAK,IAAMA,KAAK,CAACtC,QACpB,CAAC;;EAED;EACA,IAAKwC,wBAAwB,CAACE,MAAM,EAAG;IACtCzC,QAAQ,CACNY,QAAQ,CAAET,kBAAiB,CAAC,CAC5BuC,YAAY,CAAEH,wBAAyB,CAAC;EAC3C;EAEA,MAAMvC,QAAQ,CACZY,QAAQ,CAAE,MAAO,CAAC,CAClB+B,kBAAkB,CAAE,UAAU,EAAE,UAAU,EAAEb,EAAG,CAAC;AACnD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AANAhB,OAAA,CAAAkB,iCAAA,GAAAA,iCAAA;AAOO,SAASD,qCAAqCA,CAAEhC,QAAQ,EAAE6C,SAAS,EAAG;EAC5E,OAAO;IACNC,IAAI,EAAE,4BAA4B;IAClC9C,QAAQ;IACR6C;EACD,CAAC;AACF","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/actions.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tcreateBlock,\n\tisReusableBlock,\n\tparse,\n\tserialize,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Returns a generator converting a reusable block into a static block.\n *\n * @param {string} clientId The client ID of the block to attach.\n */\nexport const __experimentalConvertBlockToStatic =\n\t( clientId ) =>\n\t( { registry } ) => {\n\t\tconst oldBlock = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlock( clientId );\n\t\tconst reusableBlock = registry\n\t\t\t.select( 'core' )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\toldBlock.attributes.ref\n\t\t\t);\n\n\t\tconst newBlocks = parse(\n\t\t\ttypeof reusableBlock.content === 'function'\n\t\t\t\t? reusableBlock.content( reusableBlock )\n\t\t\t\t: reusableBlock.content\n\t\t);\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.replaceBlocks( oldBlock.clientId, newBlocks );\n\t};\n\n/**\n * Returns a generator converting one or more static blocks into a pattern.\n *\n * @param {string[]} clientIds The client IDs of the block to detach.\n * @param {string} title Pattern title.\n * @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'.\n */\nexport const __experimentalConvertBlocksToReusable =\n\t( clientIds, title, syncType ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst meta =\n\t\t\tsyncType === 'unsynced'\n\t\t\t\t? {\n\t\t\t\t\t\twp_pattern_sync_status: syncType,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\n\t\tconst reusableBlock = {\n\t\t\ttitle: title || __( 'Untitled pattern block' ),\n\t\t\tcontent: serialize(\n\t\t\t\tregistry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlocksByClientId( clientIds )\n\t\t\t),\n\t\t\tstatus: 'publish',\n\t\t\tmeta,\n\t\t};\n\n\t\tconst updatedRecord = await registry\n\t\t\t.dispatch( 'core' )\n\t\t\t.saveEntityRecord( 'postType', 'wp_block', reusableBlock );\n\n\t\tif ( syncType === 'unsynced' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\tref: updatedRecord.id,\n\t\t} );\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.replaceBlocks( clientIds, newBlock );\n\t\tdispatch.__experimentalSetEditingReusableBlock(\n\t\t\tnewBlock.clientId,\n\t\t\ttrue\n\t\t);\n\t};\n\n/**\n * Returns a generator deleting a reusable block.\n *\n * @param {string} id The ID of the reusable block to delete.\n */\nexport const __experimentalDeleteReusableBlock =\n\t( id ) =>\n\tasync ( { registry } ) => {\n\t\tconst reusableBlock = registry\n\t\t\t.select( 'core' )\n\t\t\t.getEditedEntityRecord( 'postType', 'wp_block', id );\n\n\t\t// Don't allow a reusable block with a temporary ID to be deleted.\n\t\tif ( ! reusableBlock ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Remove any other blocks that reference this reusable block.\n\t\tconst allBlocks = registry.select( blockEditorStore ).getBlocks();\n\t\tconst associatedBlocks = allBlocks.filter(\n\t\t\t( block ) => isReusableBlock( block ) && block.attributes.ref === id\n\t\t);\n\t\tconst associatedBlockClientIds = associatedBlocks.map(\n\t\t\t( block ) => block.clientId\n\t\t);\n\n\t\t// Remove the parsed block.\n\t\tif ( associatedBlockClientIds.length ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.removeBlocks( associatedBlockClientIds );\n\t\t}\n\n\t\tawait registry\n\t\t\t.dispatch( 'core' )\n\t\t\t.deleteEntityRecord( 'postType', 'wp_block', id );\n\t};\n\n/**\n * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.\n *\n * @param {string} clientId The clientID of the reusable block to target.\n * @param {boolean} isEditing Whether the block should be in editing state.\n * @return {Object} Action descriptor.\n */\nexport function __experimentalSetEditingReusableBlock( clientId, isEditing ) {\n\treturn {\n\t\ttype: 'SET_EDITING_REUSABLE_BLOCK',\n\t\tclientId,\n\t\tisEditing,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;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Y,YAAY,EAAG;AAGpD,MAAK,CAAE,eAAgB;AACtB;AAAA,EACD;AAGA,QAAM,YAAY,SAAS,OAAQ,oBAAAA,KAAiB,EAAE,UAAU;AAChE,QAAM,mBAAmB,UAAU;AAAA,IAClC,CAAE,cAAW,+BAAiB,KAAM,KAAK,MAAM,WAAW,QAAQ;AAAA,EACnE;AACA,QAAM,2BAA2B,iBAAiB;AAAA,IACjD,CAAE,UAAW,MAAM;AAAA,EACpB;AAGA,MAAK,yBAAyB,QAAS;AACtC,aACE,SAAU,oBAAAA,KAAiB,EAC3B,aAAc,wBAAyB;AAAA,EAC1C;AAEA,QAAM,SACJ,SAAU,MAAO,EACjB,mBAAoB,YAAY,YAAY,EAAG;AAClD;AASM,SAAS,sCAAuC,UAAU,WAAY;AAC5E,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
6
+ "names": ["blockEditorStore"]
7
+ }
@@ -1,37 +1,48 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var store_exports = {};
29
+ __export(store_exports, {
30
+ store: () => store
6
31
  });
7
- exports.store = void 0;
8
- var _data = require("@wordpress/data");
9
- var actions = _interopRequireWildcard(require("./actions"));
10
- var _reducer = _interopRequireDefault(require("./reducer"));
11
- var selectors = _interopRequireWildcard(require("./selectors"));
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- /**
15
- * WordPress dependencies
16
- */
17
-
18
- /**
19
- * Internal dependencies
20
- */
21
-
22
- const STORE_NAME = 'core/reusable-blocks';
23
-
24
- /**
25
- * Store definition for the reusable blocks namespace.
26
- *
27
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
28
- *
29
- * @type {Object}
30
- */
31
- const store = exports.store = (0, _data.createReduxStore)(STORE_NAME, {
32
+ module.exports = __toCommonJS(store_exports);
33
+ var import_data = require("@wordpress/data");
34
+ var actions = __toESM(require("./actions"));
35
+ var import_reducer = __toESM(require("./reducer"));
36
+ var selectors = __toESM(require("./selectors"));
37
+ const STORE_NAME = "core/reusable-blocks";
38
+ const store = (0, import_data.createReduxStore)(STORE_NAME, {
32
39
  actions,
33
- reducer: _reducer.default,
40
+ reducer: import_reducer.default,
34
41
  selectors
35
42
  });
36
- (0, _data.register)(store);
37
- //# sourceMappingURL=index.js.map
43
+ (0, import_data.register)(store);
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ store
47
+ });
48
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_data","require","actions","_interopRequireWildcard","_reducer","_interopRequireDefault","selectors","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","STORE_NAME","store","exports","createReduxStore","reducer","register"],"sources":["@wordpress/reusable-blocks/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/reusable-blocks';\n\n/**\n * Store definition for the reusable blocks namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\tactions,\n\treducer,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAH,uBAAA,CAAAF,OAAA;AAAyC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,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AE,CAAC;AAEH,IAAA0B,cAAQ,EAAEJ,KAAM,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/reusable-blocks';\n\n/**\n * Store definition for the reusable blocks namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\tactions,\n\treducer,\n\tselectors,\n} );\n\nregister( store );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2C;AAK3C,cAAyB;AACzB,qBAAoB;AACpB,gBAA2B;AAE3B,MAAM,aAAa;AASZ,MAAM,YAAQ,8BAAkB,YAAY;AAAA,EAClD;AAAA,EACA,wBAAAA;AAAA,EACA;AACD,CAAE;AAAA,IAEF,sBAAU,KAAM;",
6
+ "names": ["reducer"]
7
+ }