@wordpress/block-editor 15.11.1-next.v.0 → 15.12.1-next.v.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 (201) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-breadcrumb/index.cjs +10 -2
  3. package/build/components/block-breadcrumb/index.cjs.map +2 -2
  4. package/build/components/block-inspector/index.cjs +11 -11
  5. package/build/components/block-inspector/index.cjs.map +3 -3
  6. package/build/components/block-list/block.cjs +6 -3
  7. package/build/components/block-list/block.cjs.map +3 -3
  8. package/build/components/block-list/index.cjs +26 -18
  9. package/build/components/block-list/index.cjs.map +2 -2
  10. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +2 -6
  11. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
  12. package/build/components/block-list/use-in-between-inserter.cjs +4 -4
  13. package/build/components/block-list/use-in-between-inserter.cjs.map +2 -2
  14. package/build/components/block-settings-menu/block-settings-dropdown.cjs +10 -7
  15. package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
  16. package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs +1 -1
  17. package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs.map +2 -2
  18. package/build/components/block-settings-menu-controls/index.cjs +10 -15
  19. package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
  20. package/build/components/block-toolbar/block-toolbar-icon.cjs +6 -4
  21. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  22. package/build/components/block-toolbar/index.cjs +1 -1
  23. package/build/components/block-toolbar/index.cjs.map +2 -2
  24. package/build/components/block-variation-transforms/index.cjs +1 -2
  25. package/build/components/block-variation-transforms/index.cjs.map +2 -2
  26. package/build/components/block-visibility/modal.cjs +5 -92
  27. package/build/components/block-visibility/modal.cjs.map +2 -2
  28. package/build/components/inserter/index.cjs +1 -0
  29. package/build/components/inserter/index.cjs.map +2 -2
  30. package/build/components/inspector-controls/last-item.cjs +41 -0
  31. package/build/components/inspector-controls/last-item.cjs.map +7 -0
  32. package/build/components/inspector-controls-tabs/index.cjs +2 -2
  33. package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
  34. package/build/components/inspector-controls-tabs/styles-tab.cjs +4 -4
  35. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  36. package/build/components/media-replace-flow/index.cjs +2 -2
  37. package/build/components/media-replace-flow/index.cjs.map +2 -2
  38. package/build/components/rich-text/index.cjs +1 -1
  39. package/build/components/rich-text/index.cjs.map +2 -2
  40. package/build/components/use-block-display-information/index.cjs +1 -1
  41. package/build/components/use-block-display-information/index.cjs.map +2 -2
  42. package/build/components/writing-flow/index.cjs +2 -0
  43. package/build/components/writing-flow/index.cjs.map +2 -2
  44. package/build/components/writing-flow/use-arrow-nav.cjs +3 -0
  45. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  46. package/build/components/writing-flow/use-drag-selection.cjs +2 -1
  47. package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
  48. package/build/components/writing-flow/use-preview-mode-nav.cjs +92 -0
  49. package/build/components/writing-flow/use-preview-mode-nav.cjs.map +7 -0
  50. package/build/hooks/anchor.cjs +1 -1
  51. package/build/hooks/anchor.cjs.map +1 -1
  52. package/build/hooks/block-renaming.cjs +1 -1
  53. package/build/hooks/block-renaming.cjs.map +2 -2
  54. package/build/hooks/custom-css.cjs +1 -1
  55. package/build/hooks/custom-css.cjs.map +2 -2
  56. package/build/hooks/grid-visualizer.cjs +42 -5
  57. package/build/hooks/grid-visualizer.cjs.map +3 -3
  58. package/build/hooks/index.cjs +0 -2
  59. package/build/hooks/index.cjs.map +3 -3
  60. package/build/hooks/layout-child.cjs +41 -5
  61. package/build/hooks/layout-child.cjs.map +3 -3
  62. package/build/private-apis.cjs +2 -0
  63. package/build/private-apis.cjs.map +3 -3
  64. package/build/store/actions.cjs +5 -0
  65. package/build/store/actions.cjs.map +2 -2
  66. package/build/store/private-selectors.cjs +1 -1
  67. package/build/store/private-selectors.cjs.map +2 -2
  68. package/build/store/reducer.cjs +5 -7
  69. package/build/store/reducer.cjs.map +2 -2
  70. package/build/store/selectors.cjs +15 -0
  71. package/build/store/selectors.cjs.map +2 -2
  72. package/build/utils/fit-text-utils.cjs +17 -7
  73. package/build/utils/fit-text-utils.cjs.map +2 -2
  74. package/build-module/components/block-breadcrumb/index.mjs +10 -2
  75. package/build-module/components/block-breadcrumb/index.mjs.map +2 -2
  76. package/build-module/components/block-inspector/index.mjs +12 -11
  77. package/build-module/components/block-inspector/index.mjs.map +2 -2
  78. package/build-module/components/block-list/block.mjs +6 -3
  79. package/build-module/components/block-list/block.mjs.map +3 -3
  80. package/build-module/components/block-list/index.mjs +26 -18
  81. package/build-module/components/block-list/index.mjs.map +2 -2
  82. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +2 -6
  83. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
  84. package/build-module/components/block-list/use-in-between-inserter.mjs +4 -4
  85. package/build-module/components/block-list/use-in-between-inserter.mjs.map +2 -2
  86. package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +10 -7
  87. package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
  88. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs +1 -1
  89. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs.map +2 -2
  90. package/build-module/components/block-settings-menu-controls/index.mjs +10 -15
  91. package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
  92. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +6 -4
  93. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  94. package/build-module/components/block-toolbar/index.mjs +1 -1
  95. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  96. package/build-module/components/block-variation-transforms/index.mjs +1 -2
  97. package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
  98. package/build-module/components/block-visibility/modal.mjs +5 -92
  99. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  100. package/build-module/components/inserter/index.mjs +1 -0
  101. package/build-module/components/inserter/index.mjs.map +2 -2
  102. package/build-module/components/inspector-controls/last-item.mjs +23 -0
  103. package/build-module/components/inspector-controls/last-item.mjs.map +7 -0
  104. package/build-module/components/inspector-controls-tabs/index.mjs +2 -2
  105. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  106. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +4 -4
  107. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  108. package/build-module/components/media-replace-flow/index.mjs +2 -2
  109. package/build-module/components/media-replace-flow/index.mjs.map +2 -2
  110. package/build-module/components/rich-text/index.mjs +1 -1
  111. package/build-module/components/rich-text/index.mjs.map +2 -2
  112. package/build-module/components/use-block-display-information/index.mjs +1 -1
  113. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  114. package/build-module/components/writing-flow/index.mjs +2 -0
  115. package/build-module/components/writing-flow/index.mjs.map +2 -2
  116. package/build-module/components/writing-flow/use-arrow-nav.mjs +3 -0
  117. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  118. package/build-module/components/writing-flow/use-drag-selection.mjs +2 -1
  119. package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
  120. package/build-module/components/writing-flow/use-preview-mode-nav.mjs +67 -0
  121. package/build-module/components/writing-flow/use-preview-mode-nav.mjs.map +7 -0
  122. package/build-module/hooks/anchor.mjs +1 -1
  123. package/build-module/hooks/anchor.mjs.map +1 -1
  124. package/build-module/hooks/block-renaming.mjs +1 -1
  125. package/build-module/hooks/block-renaming.mjs.map +2 -2
  126. package/build-module/hooks/custom-css.mjs +1 -1
  127. package/build-module/hooks/custom-css.mjs.map +2 -2
  128. package/build-module/hooks/grid-visualizer.mjs +20 -5
  129. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  130. package/build-module/hooks/index.mjs +0 -2
  131. package/build-module/hooks/index.mjs.map +2 -2
  132. package/build-module/hooks/layout-child.mjs +31 -5
  133. package/build-module/hooks/layout-child.mjs.map +2 -2
  134. package/build-module/private-apis.mjs +2 -0
  135. package/build-module/private-apis.mjs.map +2 -2
  136. package/build-module/store/actions.mjs +5 -0
  137. package/build-module/store/actions.mjs.map +2 -2
  138. package/build-module/store/private-selectors.mjs +1 -1
  139. package/build-module/store/private-selectors.mjs.map +2 -2
  140. package/build-module/store/reducer.mjs +5 -7
  141. package/build-module/store/reducer.mjs.map +2 -2
  142. package/build-module/store/selectors.mjs +15 -0
  143. package/build-module/store/selectors.mjs.map +2 -2
  144. package/build-module/utils/fit-text-utils.mjs +17 -7
  145. package/build-module/utils/fit-text-utils.mjs.map +2 -2
  146. package/build-style/content-rtl.css +10 -0
  147. package/build-style/content.css +10 -0
  148. package/package.json +39 -39
  149. package/src/components/block-breadcrumb/index.js +6 -1
  150. package/src/components/block-inspector/index.js +20 -21
  151. package/src/components/block-list/block.js +5 -2
  152. package/src/components/block-list/content.scss +11 -0
  153. package/src/components/block-list/index.js +25 -17
  154. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -7
  155. package/src/components/block-list/use-in-between-inserter.js +8 -6
  156. package/src/components/block-settings-menu/block-settings-dropdown.js +11 -6
  157. package/src/components/block-settings-menu-controls/edit-section-menu-item.js +1 -7
  158. package/src/components/block-settings-menu-controls/index.js +14 -16
  159. package/src/components/block-toolbar/block-toolbar-icon.js +6 -10
  160. package/src/components/block-toolbar/index.js +1 -7
  161. package/src/components/block-variation-transforms/index.js +1 -4
  162. package/src/components/inserter/index.js +1 -0
  163. package/src/components/inserter/stories/index.story.jsx +31 -24
  164. package/src/components/inspector-controls/last-item.js +29 -0
  165. package/src/components/inspector-controls-tabs/index.js +1 -1
  166. package/src/components/inspector-controls-tabs/styles-tab.js +10 -11
  167. package/src/components/media-replace-flow/index.js +3 -3
  168. package/src/components/rich-text/index.js +1 -1
  169. package/src/components/use-block-display-information/index.js +1 -5
  170. package/src/components/writing-flow/index.js +2 -0
  171. package/src/components/writing-flow/use-arrow-nav.js +5 -0
  172. package/src/components/writing-flow/use-drag-selection.js +7 -1
  173. package/src/components/writing-flow/use-preview-mode-nav.js +102 -0
  174. package/src/hooks/anchor.js +1 -1
  175. package/src/hooks/block-renaming.js +5 -2
  176. package/src/hooks/custom-css.js +1 -1
  177. package/src/hooks/grid-visualizer.js +23 -4
  178. package/src/hooks/index.js +0 -2
  179. package/src/hooks/layout-child.js +39 -3
  180. package/src/private-apis.js +2 -0
  181. package/src/store/actions.js +7 -0
  182. package/src/store/private-selectors.js +0 -1
  183. package/src/store/reducer.js +11 -18
  184. package/src/store/selectors.js +25 -0
  185. package/src/store/test/reducer.js +258 -266
  186. package/src/utils/fit-text-utils.js +24 -8
  187. package/build/components/content-lock/index.cjs +0 -31
  188. package/build/components/content-lock/index.cjs.map +0 -7
  189. package/build/components/content-lock/modify-content-lock-menu-item.cjs +0 -70
  190. package/build/components/content-lock/modify-content-lock-menu-item.cjs.map +0 -7
  191. package/build/hooks/content-lock-ui.cjs +0 -68
  192. package/build/hooks/content-lock-ui.cjs.map +0 -7
  193. package/build-module/components/content-lock/index.mjs +0 -6
  194. package/build-module/components/content-lock/index.mjs.map +0 -7
  195. package/build-module/components/content-lock/modify-content-lock-menu-item.mjs +0 -45
  196. package/build-module/components/content-lock/modify-content-lock-menu-item.mjs.map +0 -7
  197. package/build-module/hooks/content-lock-ui.mjs +0 -47
  198. package/build-module/hooks/content-lock-ui.mjs.map +0 -7
  199. package/src/components/content-lock/index.js +0 -1
  200. package/src/components/content-lock/modify-content-lock-menu-item.js +0 -67
  201. package/src/hooks/content-lock-ui.js +0 -76
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/components/content-lock/modify-content-lock-menu-item.js
21
- var modify_content_lock_menu_item_exports = {};
22
- __export(modify_content_lock_menu_item_exports, {
23
- ModifyContentOnlySectionMenuItem: () => ModifyContentOnlySectionMenuItem
24
- });
25
- module.exports = __toCommonJS(modify_content_lock_menu_item_exports);
26
- var import_components = require("@wordpress/components");
27
- var import_data = require("@wordpress/data");
28
- var import_i18n = require("@wordpress/i18n");
29
- var import_store = require("../../store/index.cjs");
30
- var import_lock_unlock = require("../../lock-unlock.cjs");
31
- var import_jsx_runtime = require("react/jsx-runtime");
32
- function ModifyContentOnlySectionMenuItem({ clientId, onClose }) {
33
- const { templateLock, isLockedByParent, isEditingContentOnlySection } = (0, import_data.useSelect)(
34
- (select) => {
35
- const {
36
- getContentLockingParent,
37
- getTemplateLock,
38
- getEditedContentOnlySection
39
- } = (0, import_lock_unlock.unlock)(select(import_store.store));
40
- return {
41
- templateLock: getTemplateLock(clientId),
42
- isLockedByParent: !!getContentLockingParent(clientId),
43
- isEditingContentOnlySection: getEditedContentOnlySection() === clientId
44
- };
45
- },
46
- [clientId]
47
- );
48
- const blockEditorActions = (0, import_data.useDispatch)(import_store.store);
49
- const isContentLocked = !isLockedByParent && templateLock === "contentOnly";
50
- if (window?.__experimentalContentOnlyPatternInsertion || !isContentLocked && !isEditingContentOnlySection) {
51
- return null;
52
- }
53
- const { editContentOnlySection } = (0, import_lock_unlock.unlock)(blockEditorActions);
54
- const showContentOnlyModifyButton = !isEditingContentOnlySection && isContentLocked;
55
- return showContentOnlyModifyButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
- import_components.MenuItem,
57
- {
58
- onClick: () => {
59
- editContentOnlySection(clientId);
60
- onClose();
61
- },
62
- children: (0, import_i18n._x)("Modify", "Unlock content locked blocks")
63
- }
64
- );
65
- }
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- ModifyContentOnlySectionMenuItem
69
- });
70
- //# sourceMappingURL=modify-content-lock-menu-item.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/content-lock/modify-content-lock-menu-item.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n// The implementation of content locking is mainly in this file, although the mechanism\n// to stop editing a content only section when an outside block is selected is in the component\n// `StopEditingContentOnlySectionOnOutsideSelect` at block-editor/src/components/block-list/index.js.\n// Besides the components on this file and the file referenced above the implementation\n// also includes artifacts on the store (actions, reducers, and selector).\n\nexport function ModifyContentOnlySectionMenuItem( { clientId, onClose } ) {\n\tconst { templateLock, isLockedByParent, isEditingContentOnlySection } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\tgetEditedContentOnlySection,\n\t\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( clientId ),\n\t\t\t\t\tisLockedByParent: !! getContentLockingParent( clientId ),\n\t\t\t\t\tisEditingContentOnlySection:\n\t\t\t\t\t\tgetEditedContentOnlySection() === clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tconst isContentLocked =\n\t\t! isLockedByParent && templateLock === 'contentOnly';\n\n\t// Hide the Modify button when the content only pattern insertion experiment is active.\n\t// This is replaced by an alternative UI in the experiment.\n\tif (\n\t\twindow?.__experimentalContentOnlyPatternInsertion ||\n\t\t( ! isContentLocked && ! isEditingContentOnlySection )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { editContentOnlySection } = unlock( blockEditorActions );\n\tconst showContentOnlyModifyButton =\n\t\t! isEditingContentOnlySection && isContentLocked;\n\n\treturn (\n\t\tshowContentOnlyModifyButton && (\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\teditContentOnlySection( clientId );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ _x( 'Modify', 'Unlock content locked blocks' ) }\n\t\t\t</MenuItem>\n\t\t)\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAyB;AACzB,kBAAuC;AACvC,kBAAmB;AAKnB,mBAA0C;AAC1C,yBAAuB;AA6CpB;AArCI,SAAS,iCAAkC,EAAE,UAAU,QAAQ,GAAI;AACzE,QAAM,EAAE,cAAc,kBAAkB,4BAA4B,QACnE;AAAA,IACC,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AACvC,aAAO;AAAA,QACN,cAAc,gBAAiB,QAAS;AAAA,QACxC,kBAAkB,CAAC,CAAE,wBAAyB,QAAS;AAAA,QACvD,6BACC,4BAA4B,MAAM;AAAA,MACpC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD,QAAM,yBAAqB,yBAAa,aAAAA,KAAiB;AACzD,QAAM,kBACL,CAAE,oBAAoB,iBAAiB;AAIxC,MACC,QAAQ,6CACN,CAAE,mBAAmB,CAAE,6BACxB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,uBAAuB,QAAI,2BAAQ,kBAAmB;AAC9D,QAAM,8BACL,CAAE,+BAA+B;AAElC,SACC,+BACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM;AACf,+BAAwB,QAAS;AACjC,gBAAQ;AAAA,MACT;AAAA,MAEE,8BAAI,UAAU,8BAA+B;AAAA;AAAA,EAChD;AAGH;",
6
- "names": ["blockEditorStore"]
7
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/hooks/content-lock-ui.js
21
- var content_lock_ui_exports = {};
22
- __export(content_lock_ui_exports, {
23
- default: () => content_lock_ui_default
24
- });
25
- module.exports = __toCommonJS(content_lock_ui_exports);
26
- var import_components = require("@wordpress/components");
27
- var import_data = require("@wordpress/data");
28
- var import_i18n = require("@wordpress/i18n");
29
- var import_element = require("@wordpress/element");
30
- var import_store = require("../store/index.cjs");
31
- var import_components2 = require("../components/index.cjs");
32
- var import_lock_unlock = require("../lock-unlock.cjs");
33
- var import_jsx_runtime = require("react/jsx-runtime");
34
- function ContentLockControlsPure({ clientId }) {
35
- const { templateLock, isLockedByParent, isEditingContentOnlySection } = (0, import_data.useSelect)(
36
- (select) => {
37
- const {
38
- getContentLockingParent,
39
- getTemplateLock,
40
- getEditedContentOnlySection
41
- } = (0, import_lock_unlock.unlock)(select(import_store.store));
42
- return {
43
- templateLock: getTemplateLock(clientId),
44
- isLockedByParent: !!getContentLockingParent(clientId),
45
- isEditingContentOnlySection: getEditedContentOnlySection() === clientId
46
- };
47
- },
48
- [clientId]
49
- );
50
- const { stopEditingContentOnlySection } = (0, import_lock_unlock.unlock)(
51
- (0, import_data.useDispatch)(import_store.store)
52
- );
53
- const isContentLocked = !isLockedByParent && templateLock === "contentOnly";
54
- const stopEditingAsBlockCallback = (0, import_element.useCallback)(() => {
55
- stopEditingContentOnlySection();
56
- }, [stopEditingContentOnlySection]);
57
- if (window?.__experimentalContentOnlyPatternInsertion || !isContentLocked && !isEditingContentOnlySection) {
58
- return null;
59
- }
60
- return isEditingContentOnlySection && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components2.BlockControls, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarButton, { onClick: stopEditingAsBlockCallback, children: (0, import_i18n.__)("Done") }) });
61
- }
62
- var content_lock_ui_default = {
63
- edit: ContentLockControlsPure,
64
- hasSupport() {
65
- return true;
66
- }
67
- };
68
- //# sourceMappingURL=content-lock-ui.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/content-lock-ui.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { BlockControls } from '../components';\nimport { unlock } from '../lock-unlock';\n\n// The implementation of content locking is mainly in this file, although the mechanism\n// to stop editing a content only section when an outside block is selected is in the component\n// `StopEditingContentOnlySectionOnOutsideSelect` at block-editor/src/components/block-list/index.js.\n// Besides the components on this file and the file referenced above the implementation\n// also includes artifacts on the store (actions, reducers, and selector).\n\nfunction ContentLockControlsPure( { clientId } ) {\n\tconst { templateLock, isLockedByParent, isEditingContentOnlySection } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\tgetEditedContentOnlySection,\n\t\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( clientId ),\n\t\t\t\t\tisLockedByParent: !! getContentLockingParent( clientId ),\n\t\t\t\t\tisEditingContentOnlySection:\n\t\t\t\t\t\tgetEditedContentOnlySection() === clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\tconst { stopEditingContentOnlySection } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isContentLocked =\n\t\t! isLockedByParent && templateLock === 'contentOnly';\n\n\tconst stopEditingAsBlockCallback = useCallback( () => {\n\t\tstopEditingContentOnlySection();\n\t}, [ stopEditingContentOnlySection ] );\n\n\t// Hide the Done button when the content only pattern insertion experiment is active.\n\t// This is replaced by an alternative UI in the experiment.\n\tif (\n\t\twindow?.__experimentalContentOnlyPatternInsertion ||\n\t\t( ! isContentLocked && ! isEditingContentOnlySection )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\tisEditingContentOnlySection && (\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarButton onClick={ stopEditingAsBlockCallback }>\n\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</BlockControls>\n\t\t)\n\t);\n}\n\nexport default {\n\tedit: ContentLockControlsPure,\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA8B;AAC9B,kBAAuC;AACvC,kBAAmB;AACnB,qBAA4B;AAK5B,mBAA0C;AAC1C,IAAAA,qBAA8B;AAC9B,yBAAuB;AAiDnB;AAzCJ,SAAS,wBAAyB,EAAE,SAAS,GAAI;AAChD,QAAM,EAAE,cAAc,kBAAkB,4BAA4B,QACnE;AAAA,IACC,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,QAAI,2BAAQ,OAAQ,aAAAC,KAAiB,CAAE;AACvC,aAAO;AAAA,QACN,cAAc,gBAAiB,QAAS;AAAA,QACxC,kBAAkB,CAAC,CAAE,wBAAyB,QAAS;AAAA,QACvD,6BACC,4BAA4B,MAAM;AAAA,MACpC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAED,QAAM,EAAE,8BAA8B,QAAI;AAAA,QACzC,yBAAa,aAAAA,KAAiB;AAAA,EAC/B;AACA,QAAM,kBACL,CAAE,oBAAoB,iBAAiB;AAExC,QAAM,iCAA6B,4BAAa,MAAM;AACrD,kCAA8B;AAAA,EAC/B,GAAG,CAAE,6BAA8B,CAAE;AAIrC,MACC,QAAQ,6CACN,CAAE,mBAAmB,CAAE,6BACxB;AACD,WAAO;AAAA,EACR;AAEA,SACC,+BACC,4CAAC,oCAAc,OAAM,SACpB,sDAAC,mCAAc,SAAU,4BACtB,8BAAI,MAAO,GACd,GACD;AAGH;AAEA,IAAO,0BAAQ;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AACZ,WAAO;AAAA,EACR;AACD;",
6
- "names": ["import_components", "blockEditorStore"]
7
- }
@@ -1,6 +0,0 @@
1
- // packages/block-editor/src/components/content-lock/index.js
2
- import { ModifyContentOnlySectionMenuItem } from "./modify-content-lock-menu-item.mjs";
3
- export {
4
- ModifyContentOnlySectionMenuItem
5
- };
6
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/content-lock/index.js"],
4
- "sourcesContent": ["export { ModifyContentOnlySectionMenuItem } from './modify-content-lock-menu-item';\n"],
5
- "mappings": ";AAAA,SAAS,wCAAwC;",
6
- "names": []
7
- }
@@ -1,45 +0,0 @@
1
- // packages/block-editor/src/components/content-lock/modify-content-lock-menu-item.js
2
- import { MenuItem } from "@wordpress/components";
3
- import { useDispatch, useSelect } from "@wordpress/data";
4
- import { _x } from "@wordpress/i18n";
5
- import { store as blockEditorStore } from "../../store/index.mjs";
6
- import { unlock } from "../../lock-unlock.mjs";
7
- import { jsx } from "react/jsx-runtime";
8
- function ModifyContentOnlySectionMenuItem({ clientId, onClose }) {
9
- const { templateLock, isLockedByParent, isEditingContentOnlySection } = useSelect(
10
- (select) => {
11
- const {
12
- getContentLockingParent,
13
- getTemplateLock,
14
- getEditedContentOnlySection
15
- } = unlock(select(blockEditorStore));
16
- return {
17
- templateLock: getTemplateLock(clientId),
18
- isLockedByParent: !!getContentLockingParent(clientId),
19
- isEditingContentOnlySection: getEditedContentOnlySection() === clientId
20
- };
21
- },
22
- [clientId]
23
- );
24
- const blockEditorActions = useDispatch(blockEditorStore);
25
- const isContentLocked = !isLockedByParent && templateLock === "contentOnly";
26
- if (window?.__experimentalContentOnlyPatternInsertion || !isContentLocked && !isEditingContentOnlySection) {
27
- return null;
28
- }
29
- const { editContentOnlySection } = unlock(blockEditorActions);
30
- const showContentOnlyModifyButton = !isEditingContentOnlySection && isContentLocked;
31
- return showContentOnlyModifyButton && /* @__PURE__ */ jsx(
32
- MenuItem,
33
- {
34
- onClick: () => {
35
- editContentOnlySection(clientId);
36
- onClose();
37
- },
38
- children: _x("Modify", "Unlock content locked blocks")
39
- }
40
- );
41
- }
42
- export {
43
- ModifyContentOnlySectionMenuItem
44
- };
45
- //# sourceMappingURL=modify-content-lock-menu-item.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/content-lock/modify-content-lock-menu-item.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n// The implementation of content locking is mainly in this file, although the mechanism\n// to stop editing a content only section when an outside block is selected is in the component\n// `StopEditingContentOnlySectionOnOutsideSelect` at block-editor/src/components/block-list/index.js.\n// Besides the components on this file and the file referenced above the implementation\n// also includes artifacts on the store (actions, reducers, and selector).\n\nexport function ModifyContentOnlySectionMenuItem( { clientId, onClose } ) {\n\tconst { templateLock, isLockedByParent, isEditingContentOnlySection } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\tgetEditedContentOnlySection,\n\t\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( clientId ),\n\t\t\t\t\tisLockedByParent: !! getContentLockingParent( clientId ),\n\t\t\t\t\tisEditingContentOnlySection:\n\t\t\t\t\t\tgetEditedContentOnlySection() === clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tconst isContentLocked =\n\t\t! isLockedByParent && templateLock === 'contentOnly';\n\n\t// Hide the Modify button when the content only pattern insertion experiment is active.\n\t// This is replaced by an alternative UI in the experiment.\n\tif (\n\t\twindow?.__experimentalContentOnlyPatternInsertion ||\n\t\t( ! isContentLocked && ! isEditingContentOnlySection )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { editContentOnlySection } = unlock( blockEditorActions );\n\tconst showContentOnlyModifyButton =\n\t\t! isEditingContentOnlySection && isContentLocked;\n\n\treturn (\n\t\tshowContentOnlyModifyButton && (\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\teditContentOnlySection( clientId );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ _x( 'Modify', 'Unlock content locked blocks' ) }\n\t\t\t</MenuItem>\n\t\t)\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AAKnB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AA6CpB;AArCI,SAAS,iCAAkC,EAAE,UAAU,QAAQ,GAAI;AACzE,QAAM,EAAE,cAAc,kBAAkB,4BAA4B,IACnE;AAAA,IACC,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,OAAQ,gBAAiB,CAAE;AACvC,aAAO;AAAA,QACN,cAAc,gBAAiB,QAAS;AAAA,QACxC,kBAAkB,CAAC,CAAE,wBAAyB,QAAS;AAAA,QACvD,6BACC,4BAA4B,MAAM;AAAA,MACpC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD,QAAM,qBAAqB,YAAa,gBAAiB;AACzD,QAAM,kBACL,CAAE,oBAAoB,iBAAiB;AAIxC,MACC,QAAQ,6CACN,CAAE,mBAAmB,CAAE,6BACxB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,uBAAuB,IAAI,OAAQ,kBAAmB;AAC9D,QAAM,8BACL,CAAE,+BAA+B;AAElC,SACC,+BACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM;AACf,+BAAwB,QAAS;AACjC,gBAAQ;AAAA,MACT;AAAA,MAEE,aAAI,UAAU,8BAA+B;AAAA;AAAA,EAChD;AAGH;",
6
- "names": []
7
- }
@@ -1,47 +0,0 @@
1
- // packages/block-editor/src/hooks/content-lock-ui.js
2
- import { ToolbarButton } from "@wordpress/components";
3
- import { useDispatch, useSelect } from "@wordpress/data";
4
- import { __ } from "@wordpress/i18n";
5
- import { useCallback } from "@wordpress/element";
6
- import { store as blockEditorStore } from "../store/index.mjs";
7
- import { BlockControls } from "../components/index.mjs";
8
- import { unlock } from "../lock-unlock.mjs";
9
- import { jsx } from "react/jsx-runtime";
10
- function ContentLockControlsPure({ clientId }) {
11
- const { templateLock, isLockedByParent, isEditingContentOnlySection } = useSelect(
12
- (select) => {
13
- const {
14
- getContentLockingParent,
15
- getTemplateLock,
16
- getEditedContentOnlySection
17
- } = unlock(select(blockEditorStore));
18
- return {
19
- templateLock: getTemplateLock(clientId),
20
- isLockedByParent: !!getContentLockingParent(clientId),
21
- isEditingContentOnlySection: getEditedContentOnlySection() === clientId
22
- };
23
- },
24
- [clientId]
25
- );
26
- const { stopEditingContentOnlySection } = unlock(
27
- useDispatch(blockEditorStore)
28
- );
29
- const isContentLocked = !isLockedByParent && templateLock === "contentOnly";
30
- const stopEditingAsBlockCallback = useCallback(() => {
31
- stopEditingContentOnlySection();
32
- }, [stopEditingContentOnlySection]);
33
- if (window?.__experimentalContentOnlyPatternInsertion || !isContentLocked && !isEditingContentOnlySection) {
34
- return null;
35
- }
36
- return isEditingContentOnlySection && /* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsx(ToolbarButton, { onClick: stopEditingAsBlockCallback, children: __("Done") }) });
37
- }
38
- var content_lock_ui_default = {
39
- edit: ContentLockControlsPure,
40
- hasSupport() {
41
- return true;
42
- }
43
- };
44
- export {
45
- content_lock_ui_default as default
46
- };
47
- //# sourceMappingURL=content-lock-ui.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/content-lock-ui.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { BlockControls } from '../components';\nimport { unlock } from '../lock-unlock';\n\n// The implementation of content locking is mainly in this file, although the mechanism\n// to stop editing a content only section when an outside block is selected is in the component\n// `StopEditingContentOnlySectionOnOutsideSelect` at block-editor/src/components/block-list/index.js.\n// Besides the components on this file and the file referenced above the implementation\n// also includes artifacts on the store (actions, reducers, and selector).\n\nfunction ContentLockControlsPure( { clientId } ) {\n\tconst { templateLock, isLockedByParent, isEditingContentOnlySection } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\tgetEditedContentOnlySection,\n\t\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( clientId ),\n\t\t\t\t\tisLockedByParent: !! getContentLockingParent( clientId ),\n\t\t\t\t\tisEditingContentOnlySection:\n\t\t\t\t\t\tgetEditedContentOnlySection() === clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\tconst { stopEditingContentOnlySection } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst isContentLocked =\n\t\t! isLockedByParent && templateLock === 'contentOnly';\n\n\tconst stopEditingAsBlockCallback = useCallback( () => {\n\t\tstopEditingContentOnlySection();\n\t}, [ stopEditingContentOnlySection ] );\n\n\t// Hide the Done button when the content only pattern insertion experiment is active.\n\t// This is replaced by an alternative UI in the experiment.\n\tif (\n\t\twindow?.__experimentalContentOnlyPatternInsertion ||\n\t\t( ! isContentLocked && ! isEditingContentOnlySection )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\tisEditingContentOnlySection && (\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarButton onClick={ stopEditingAsBlockCallback }>\n\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</BlockControls>\n\t\t)\n\t);\n}\n\nexport default {\n\tedit: ContentLockControlsPure,\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAK5B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AAiDnB;AAzCJ,SAAS,wBAAyB,EAAE,SAAS,GAAI;AAChD,QAAM,EAAE,cAAc,kBAAkB,4BAA4B,IACnE;AAAA,IACC,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,OAAQ,gBAAiB,CAAE;AACvC,aAAO;AAAA,QACN,cAAc,gBAAiB,QAAS;AAAA,QACxC,kBAAkB,CAAC,CAAE,wBAAyB,QAAS;AAAA,QACvD,6BACC,4BAA4B,MAAM;AAAA,MACpC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAED,QAAM,EAAE,8BAA8B,IAAI;AAAA,IACzC,YAAa,gBAAiB;AAAA,EAC/B;AACA,QAAM,kBACL,CAAE,oBAAoB,iBAAiB;AAExC,QAAM,6BAA6B,YAAa,MAAM;AACrD,kCAA8B;AAAA,EAC/B,GAAG,CAAE,6BAA8B,CAAE;AAIrC,MACC,QAAQ,6CACN,CAAE,mBAAmB,CAAE,6BACxB;AACD,WAAO;AAAA,EACR;AAEA,SACC,+BACC,oBAAC,iBAAc,OAAM,SACpB,8BAAC,iBAAc,SAAU,4BACtB,aAAI,MAAO,GACd,GACD;AAGH;AAEA,IAAO,0BAAQ;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AACZ,WAAO;AAAA,EACR;AACD;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- export { ModifyContentOnlySectionMenuItem } from './modify-content-lock-menu-item';
@@ -1,67 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MenuItem } from '@wordpress/components';
5
- import { useDispatch, useSelect } from '@wordpress/data';
6
- import { _x } from '@wordpress/i18n';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { store as blockEditorStore } from '../../store';
12
- import { unlock } from '../../lock-unlock';
13
-
14
- // The implementation of content locking is mainly in this file, although the mechanism
15
- // to stop editing a content only section when an outside block is selected is in the component
16
- // `StopEditingContentOnlySectionOnOutsideSelect` at block-editor/src/components/block-list/index.js.
17
- // Besides the components on this file and the file referenced above the implementation
18
- // also includes artifacts on the store (actions, reducers, and selector).
19
-
20
- export function ModifyContentOnlySectionMenuItem( { clientId, onClose } ) {
21
- const { templateLock, isLockedByParent, isEditingContentOnlySection } =
22
- useSelect(
23
- ( select ) => {
24
- const {
25
- getContentLockingParent,
26
- getTemplateLock,
27
- getEditedContentOnlySection,
28
- } = unlock( select( blockEditorStore ) );
29
- return {
30
- templateLock: getTemplateLock( clientId ),
31
- isLockedByParent: !! getContentLockingParent( clientId ),
32
- isEditingContentOnlySection:
33
- getEditedContentOnlySection() === clientId,
34
- };
35
- },
36
- [ clientId ]
37
- );
38
- const blockEditorActions = useDispatch( blockEditorStore );
39
- const isContentLocked =
40
- ! isLockedByParent && templateLock === 'contentOnly';
41
-
42
- // Hide the Modify button when the content only pattern insertion experiment is active.
43
- // This is replaced by an alternative UI in the experiment.
44
- if (
45
- window?.__experimentalContentOnlyPatternInsertion ||
46
- ( ! isContentLocked && ! isEditingContentOnlySection )
47
- ) {
48
- return null;
49
- }
50
-
51
- const { editContentOnlySection } = unlock( blockEditorActions );
52
- const showContentOnlyModifyButton =
53
- ! isEditingContentOnlySection && isContentLocked;
54
-
55
- return (
56
- showContentOnlyModifyButton && (
57
- <MenuItem
58
- onClick={ () => {
59
- editContentOnlySection( clientId );
60
- onClose();
61
- } }
62
- >
63
- { _x( 'Modify', 'Unlock content locked blocks' ) }
64
- </MenuItem>
65
- )
66
- );
67
- }
@@ -1,76 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { ToolbarButton } from '@wordpress/components';
5
- import { useDispatch, useSelect } from '@wordpress/data';
6
- import { __ } from '@wordpress/i18n';
7
- import { useCallback } from '@wordpress/element';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
- import { store as blockEditorStore } from '../store';
13
- import { BlockControls } from '../components';
14
- import { unlock } from '../lock-unlock';
15
-
16
- // The implementation of content locking is mainly in this file, although the mechanism
17
- // to stop editing a content only section when an outside block is selected is in the component
18
- // `StopEditingContentOnlySectionOnOutsideSelect` at block-editor/src/components/block-list/index.js.
19
- // Besides the components on this file and the file referenced above the implementation
20
- // also includes artifacts on the store (actions, reducers, and selector).
21
-
22
- function ContentLockControlsPure( { clientId } ) {
23
- const { templateLock, isLockedByParent, isEditingContentOnlySection } =
24
- useSelect(
25
- ( select ) => {
26
- const {
27
- getContentLockingParent,
28
- getTemplateLock,
29
- getEditedContentOnlySection,
30
- } = unlock( select( blockEditorStore ) );
31
- return {
32
- templateLock: getTemplateLock( clientId ),
33
- isLockedByParent: !! getContentLockingParent( clientId ),
34
- isEditingContentOnlySection:
35
- getEditedContentOnlySection() === clientId,
36
- };
37
- },
38
- [ clientId ]
39
- );
40
-
41
- const { stopEditingContentOnlySection } = unlock(
42
- useDispatch( blockEditorStore )
43
- );
44
- const isContentLocked =
45
- ! isLockedByParent && templateLock === 'contentOnly';
46
-
47
- const stopEditingAsBlockCallback = useCallback( () => {
48
- stopEditingContentOnlySection();
49
- }, [ stopEditingContentOnlySection ] );
50
-
51
- // Hide the Done button when the content only pattern insertion experiment is active.
52
- // This is replaced by an alternative UI in the experiment.
53
- if (
54
- window?.__experimentalContentOnlyPatternInsertion ||
55
- ( ! isContentLocked && ! isEditingContentOnlySection )
56
- ) {
57
- return null;
58
- }
59
-
60
- return (
61
- isEditingContentOnlySection && (
62
- <BlockControls group="other">
63
- <ToolbarButton onClick={ stopEditingAsBlockCallback }>
64
- { __( 'Done' ) }
65
- </ToolbarButton>
66
- </BlockControls>
67
- )
68
- );
69
- }
70
-
71
- export default {
72
- edit: ContentLockControlsPure,
73
- hasSupport() {
74
- return true;
75
- },
76
- };