@wordpress/block-library 8.15.0 → 8.16.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 (156) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/avatar/index.js +3 -0
  3. package/build/avatar/index.js.map +1 -1
  4. package/build/block/edit.js +2 -30
  5. package/build/block/edit.js.map +1 -1
  6. package/build/cover/index.js +2 -1
  7. package/build/cover/index.js.map +1 -1
  8. package/build/footnotes/edit.js +11 -0
  9. package/build/footnotes/edit.js.map +1 -1
  10. package/build/footnotes/format.js +101 -8
  11. package/build/footnotes/format.js.map +1 -1
  12. package/build/footnotes/index.js +45 -3
  13. package/build/footnotes/index.js.map +1 -1
  14. package/build/gallery/edit.js +7 -5
  15. package/build/gallery/edit.js.map +1 -1
  16. package/build/image/deprecated.js +106 -2
  17. package/build/image/deprecated.js.map +1 -1
  18. package/build/image/image.js +2 -2
  19. package/build/image/image.js.map +1 -1
  20. package/build/image/index.js +2 -1
  21. package/build/image/index.js.map +1 -1
  22. package/build/index.js +3 -1
  23. package/build/index.js.map +1 -1
  24. package/build/list-item/hooks/use-merge.js +10 -1
  25. package/build/list-item/hooks/use-merge.js.map +1 -1
  26. package/build/navigation/edit/menu-inspector-controls.js +1 -1
  27. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  28. package/build/navigation/edit/navigation-menu-selector.js +4 -4
  29. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  30. package/build/navigation/view-modal.js +93 -32
  31. package/build/navigation/view-modal.js.map +1 -1
  32. package/build/navigation/view.js +63 -31
  33. package/build/navigation/view.js.map +1 -1
  34. package/build/pattern/edit.js +28 -4
  35. package/build/pattern/edit.js.map +1 -1
  36. package/build/preformatted/index.js +4 -0
  37. package/build/preformatted/index.js.map +1 -1
  38. package/build/search/view.js +166 -62
  39. package/build/search/view.js.map +1 -1
  40. package/build/social-link/icons/index.js +13 -0
  41. package/build/social-link/icons/index.js.map +1 -1
  42. package/build/social-link/icons/threads.js +25 -0
  43. package/build/social-link/icons/threads.js.map +1 -0
  44. package/build/social-link/variations.js +7 -0
  45. package/build/social-link/variations.js.map +1 -1
  46. package/build/template-part/edit/import-controls.js +1 -1
  47. package/build/template-part/edit/import-controls.js.map +1 -1
  48. package/build-module/avatar/index.js +3 -0
  49. package/build-module/avatar/index.js.map +1 -1
  50. package/build-module/block/edit.js +4 -29
  51. package/build-module/block/edit.js.map +1 -1
  52. package/build-module/cover/index.js +2 -1
  53. package/build-module/cover/index.js.map +1 -1
  54. package/build-module/footnotes/edit.js +11 -0
  55. package/build-module/footnotes/edit.js.map +1 -1
  56. package/build-module/footnotes/format.js +102 -10
  57. package/build-module/footnotes/format.js.map +1 -1
  58. package/build-module/footnotes/index.js +45 -3
  59. package/build-module/footnotes/index.js.map +1 -1
  60. package/build-module/gallery/edit.js +7 -5
  61. package/build-module/gallery/edit.js.map +1 -1
  62. package/build-module/image/deprecated.js +107 -3
  63. package/build-module/image/deprecated.js.map +1 -1
  64. package/build-module/image/image.js +2 -2
  65. package/build-module/image/image.js.map +1 -1
  66. package/build-module/image/index.js +2 -1
  67. package/build-module/image/index.js.map +1 -1
  68. package/build-module/index.js +3 -1
  69. package/build-module/index.js.map +1 -1
  70. package/build-module/list-item/hooks/use-merge.js +10 -1
  71. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  72. package/build-module/navigation/edit/menu-inspector-controls.js +1 -1
  73. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  74. package/build-module/navigation/edit/navigation-menu-selector.js +4 -4
  75. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  76. package/build-module/navigation/view-modal.js +93 -31
  77. package/build-module/navigation/view-modal.js.map +1 -1
  78. package/build-module/navigation/view.js +63 -31
  79. package/build-module/navigation/view.js.map +1 -1
  80. package/build-module/pattern/edit.js +27 -4
  81. package/build-module/pattern/edit.js.map +1 -1
  82. package/build-module/preformatted/index.js +4 -0
  83. package/build-module/preformatted/index.js.map +1 -1
  84. package/build-module/search/view.js +166 -62
  85. package/build-module/search/view.js.map +1 -1
  86. package/build-module/social-link/icons/index.js +1 -0
  87. package/build-module/social-link/icons/index.js.map +1 -1
  88. package/build-module/social-link/icons/threads.js +15 -0
  89. package/build-module/social-link/icons/threads.js.map +1 -0
  90. package/build-module/social-link/variations.js +8 -1
  91. package/build-module/social-link/variations.js.map +1 -1
  92. package/build-module/template-part/edit/import-controls.js +2 -2
  93. package/build-module/template-part/edit/import-controls.js.map +1 -1
  94. package/build-style/preformatted/style-rtl.css +2 -1
  95. package/build-style/preformatted/style.css +2 -1
  96. package/build-style/social-links/style-rtl.css +7 -0
  97. package/build-style/social-links/style.css +7 -0
  98. package/build-style/style-rtl.css +10 -1
  99. package/build-style/style.css +10 -1
  100. package/build-style/video/style-rtl.css +1 -0
  101. package/build-style/video/style.css +1 -0
  102. package/package.json +32 -32
  103. package/src/audio/test/__snapshots__/edit.native.js.snap +60 -0
  104. package/src/avatar/block.json +3 -0
  105. package/src/block/edit.js +1 -39
  106. package/src/buttons/test/edit.native.js +4 -0
  107. package/src/columns/test/edit.native.js +5 -0
  108. package/src/comment-template/index.php +2 -0
  109. package/src/cover/block.json +2 -1
  110. package/src/cover/test/edit.native.js +8 -0
  111. package/src/embed/test/index.native.js +8 -0
  112. package/src/file/index.php +1 -1
  113. package/src/file/test/__snapshots__/edit.native.js.snap +61 -0
  114. package/src/footnotes/block.json +44 -1
  115. package/src/footnotes/edit.js +12 -0
  116. package/src/footnotes/format.js +70 -7
  117. package/src/footnotes/index.js +0 -1
  118. package/src/footnotes/index.php +207 -0
  119. package/src/gallery/edit.js +41 -37
  120. package/src/gallery/test/index.native.js +15 -3
  121. package/src/heading/test/index.native.js +4 -0
  122. package/src/image/block.json +2 -1
  123. package/src/image/deprecated.js +109 -3
  124. package/src/image/image.js +2 -2
  125. package/src/image/index.php +1 -3
  126. package/src/image/test/edit.native.js +0 -1
  127. package/src/index.js +5 -1
  128. package/src/list/test/edit.native.js +5 -0
  129. package/src/list-item/hooks/use-merge.js +12 -5
  130. package/src/missing/test/__snapshots__/edit.native.js.snap +21 -0
  131. package/src/navigation/edit/menu-inspector-controls.js +1 -1
  132. package/src/navigation/edit/navigation-menu-selector.js +8 -4
  133. package/src/navigation/index.php +27 -13
  134. package/src/navigation/view-modal.js +88 -39
  135. package/src/navigation/view.js +69 -36
  136. package/src/paragraph/test/edit.native.js +55 -35
  137. package/src/pattern/edit.js +21 -0
  138. package/src/pattern/index.php +13 -1
  139. package/src/post-template/index.php +2 -0
  140. package/src/post-title/index.php +2 -0
  141. package/src/preformatted/block.json +4 -0
  142. package/src/preformatted/style.scss +4 -1
  143. package/src/pullquote/test/edit.native.js +12 -4
  144. package/src/quote/test/edit.native.js +12 -4
  145. package/src/search/index.php +4 -0
  146. package/src/search/test/__snapshots__/edit.native.js.snap +63 -0
  147. package/src/search/view.js +171 -67
  148. package/src/social-link/icons/index.js +1 -0
  149. package/src/social-link/icons/threads.js +10 -0
  150. package/src/social-link/index.php +4 -0
  151. package/src/social-link/socials-with-bg.scss +5 -0
  152. package/src/social-link/socials-without-bg.scss +4 -0
  153. package/src/social-link/variations.js +7 -0
  154. package/src/template-part/edit/import-controls.js +2 -2
  155. package/src/template-part/index.php +6 -9
  156. package/src/video/style.scss +1 -0
@@ -4,13 +4,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
 
5
5
  var _micromodal = _interopRequireDefault(require("micromodal"));
6
6
 
7
+ /*eslint-env browser*/
8
+
7
9
  /**
8
10
  * External dependencies
9
11
  */
10
12
  // Responsive navigation toggle.
11
- function navigationToggleModal(modal) {
13
+
14
+ /**
15
+ * Toggles responsive navigation.
16
+ *
17
+ * @param {HTMLDivElement} modal
18
+ * @param {boolean} isHidden
19
+ */
20
+ function navigationToggleModal(modal, isHidden) {
12
21
  const dialogContainer = modal.querySelector(`.wp-block-navigation__responsive-dialog`);
13
- const isHidden = 'true' === modal.getAttribute('aria-hidden');
14
22
  modal.classList.toggle('has-modal-open', !isHidden);
15
23
  dialogContainer.toggleAttribute('aria-modal', !isHidden);
16
24
 
@@ -23,42 +31,95 @@ function navigationToggleModal(modal) {
23
31
  } // Add a class to indicate the modal is open.
24
32
 
25
33
 
26
- const htmlElement = document.documentElement;
27
- htmlElement.classList.toggle('has-modal-open');
34
+ document.documentElement.classList.toggle('has-modal-open');
28
35
  }
36
+ /**
37
+ * Checks whether the provided link is an anchor on the current page.
38
+ *
39
+ * @param {HTMLAnchorElement} node
40
+ * @return {boolean} Is anchor.
41
+ */
42
+
29
43
 
30
44
  function isLinkToAnchorOnCurrentPage(node) {
31
45
  return node.hash && node.protocol === window.location.protocol && node.host === window.location.host && node.pathname === window.location.pathname && node.search === window.location.search;
32
46
  }
47
+ /**
48
+ * Handles effects after opening the modal.
49
+ *
50
+ * @param {HTMLDivElement} modal
51
+ */
33
52
 
34
- window.addEventListener('load', () => {
35
- _micromodal.default.init({
36
- onShow: navigationToggleModal,
37
- onClose: navigationToggleModal,
38
- openClass: 'is-menu-open'
39
- }); // Close modal automatically on clicking anchor links inside modal.
40
-
41
-
42
- const navigationLinks = document.querySelectorAll('.wp-block-navigation-item__content');
43
- navigationLinks.forEach(function (link) {
44
- // Ignore non-anchor links and anchor links which open on a new tab.
45
- if (!isLinkToAnchorOnCurrentPage(link) || link.attributes?.target === '_blank') {
46
- return;
47
- } // Find the specific parent modal for this link
48
- // since .close() won't work without an ID if there are
49
- // multiple navigation menus in a post/page.
50
-
51
-
52
- const modal = link.closest('.wp-block-navigation__responsive-container');
53
- const modalId = modal?.getAttribute('id');
54
- link.addEventListener('click', () => {
55
- // check if modal exists and is open before trying to close it
56
- // otherwise Micromodal will toggle the `has-modal-open` class
57
- // on the html tag which prevents scrolling
58
- if (modalId && modal.classList.contains('has-modal-open')) {
59
- _micromodal.default.close(modalId);
60
- }
61
- });
53
+
54
+ function onShow(modal) {
55
+ navigationToggleModal(modal, false);
56
+ modal.addEventListener('click', handleAnchorLinkClicksInsideModal, {
57
+ passive: true
58
+ });
59
+ }
60
+ /**
61
+ * Handles effects after closing the modal.
62
+ *
63
+ * @param {HTMLDivElement} modal
64
+ */
65
+
66
+
67
+ function onClose(modal) {
68
+ navigationToggleModal(modal, true);
69
+ modal.removeEventListener('click', handleAnchorLinkClicksInsideModal, {
70
+ passive: true
62
71
  });
72
+ }
73
+ /**
74
+ * Handle clicks to anchor links in modal using event delegation by closing modal automatically
75
+ *
76
+ * @param {UIEvent} event
77
+ */
78
+
79
+
80
+ function handleAnchorLinkClicksInsideModal(event) {
81
+ const link = event.target.closest('.wp-block-navigation-item__content');
82
+
83
+ if (!(link instanceof HTMLAnchorElement)) {
84
+ return;
85
+ } // Ignore non-anchor links and anchor links which open on a new tab.
86
+
87
+
88
+ if (!isLinkToAnchorOnCurrentPage(link) || link.attributes?.target === '_blank') {
89
+ return;
90
+ } // Find the specific parent modal for this link
91
+ // since .close() won't work without an ID if there are
92
+ // multiple navigation menus in a post/page.
93
+
94
+
95
+ const modal = link.closest('.wp-block-navigation__responsive-container');
96
+ const modalId = modal?.getAttribute('id');
97
+
98
+ if (!modalId) {
99
+ return;
100
+ } // check if modal exists and is open before trying to close it
101
+ // otherwise Micromodal will toggle the `has-modal-open` class
102
+ // on the html tag which prevents scrolling
103
+
104
+
105
+ if (modalId && modal.classList.contains('has-modal-open')) {
106
+ _micromodal.default.close(modalId);
107
+ }
108
+ } // MicroModal.init() does not support event delegation for the open trigger, so here MicroModal.show() is called manually.
109
+
110
+
111
+ document.addEventListener('click', event => {
112
+ /** @type {HTMLElement} */
113
+ const target = event.target;
114
+
115
+ if (target.dataset.micromodalTrigger) {
116
+ _micromodal.default.show(target.dataset.micromodalTrigger, {
117
+ onShow,
118
+ onClose,
119
+ openClass: 'is-menu-open'
120
+ });
121
+ }
122
+ }, {
123
+ passive: true
63
124
  });
64
125
  //# sourceMappingURL=view-modal.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/view-modal.js"],"names":["navigationToggleModal","modal","dialogContainer","querySelector","isHidden","getAttribute","classList","toggle","toggleAttribute","removeAttribute","setAttribute","htmlElement","document","documentElement","isLinkToAnchorOnCurrentPage","node","hash","protocol","window","location","host","pathname","search","addEventListener","MicroModal","init","onShow","onClose","openClass","navigationLinks","querySelectorAll","forEach","link","attributes","target","closest","modalId","contains","close"],"mappings":";;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA,SAASA,qBAAT,CAAgCC,KAAhC,EAAwC;AACvC,QAAMC,eAAe,GAAGD,KAAK,CAACE,aAAN,CACtB,yCADsB,CAAxB;AAIA,QAAMC,QAAQ,GAAG,WAAWH,KAAK,CAACI,YAAN,CAAoB,aAApB,CAA5B;AAEAJ,EAAAA,KAAK,CAACK,SAAN,CAAgBC,MAAhB,CAAwB,gBAAxB,EAA0C,CAAEH,QAA5C;AACAF,EAAAA,eAAe,CAACM,eAAhB,CAAiC,YAAjC,EAA+C,CAAEJ,QAAjD;;AAEA,MAAKA,QAAL,EAAgB;AACfF,IAAAA,eAAe,CAACO,eAAhB,CAAiC,MAAjC;AACAP,IAAAA,eAAe,CAACO,eAAhB,CAAiC,YAAjC;AACA,GAHD,MAGO;AACNP,IAAAA,eAAe,CAACQ,YAAhB,CAA8B,MAA9B,EAAsC,QAAtC;AACAR,IAAAA,eAAe,CAACQ,YAAhB,CAA8B,YAA9B,EAA4C,MAA5C;AACA,GAhBsC,CAkBvC;;;AACA,QAAMC,WAAW,GAAGC,QAAQ,CAACC,eAA7B;AACAF,EAAAA,WAAW,CAACL,SAAZ,CAAsBC,MAAtB,CAA8B,gBAA9B;AACA;;AAED,SAASO,2BAAT,CAAsCC,IAAtC,EAA6C;AAC5C,SACCA,IAAI,CAACC,IAAL,IACAD,IAAI,CAACE,QAAL,KAAkBC,MAAM,CAACC,QAAP,CAAgBF,QADlC,IAEAF,IAAI,CAACK,IAAL,KAAcF,MAAM,CAACC,QAAP,CAAgBC,IAF9B,IAGAL,IAAI,CAACM,QAAL,KAAkBH,MAAM,CAACC,QAAP,CAAgBE,QAHlC,IAIAN,IAAI,CAACO,MAAL,KAAgBJ,MAAM,CAACC,QAAP,CAAgBG,MALjC;AAOA;;AAEDJ,MAAM,CAACK,gBAAP,CAAyB,MAAzB,EAAiC,MAAM;AACtCC,sBAAWC,IAAX,CAAiB;AAChBC,IAAAA,MAAM,EAAE1B,qBADQ;AAEhB2B,IAAAA,OAAO,EAAE3B,qBAFO;AAGhB4B,IAAAA,SAAS,EAAE;AAHK,GAAjB,EADsC,CAOtC;;;AACA,QAAMC,eAAe,GAAGjB,QAAQ,CAACkB,gBAAT,CACvB,oCADuB,CAAxB;AAIAD,EAAAA,eAAe,CAACE,OAAhB,CAAyB,UAAWC,IAAX,EAAkB;AAC1C;AACA,QACC,CAAElB,2BAA2B,CAAEkB,IAAF,CAA7B,IACAA,IAAI,CAACC,UAAL,EAAiBC,MAAjB,KAA4B,QAF7B,EAGE;AACD;AACA,KAPyC,CAS1C;AACA;AACA;;;AACA,UAAMjC,KAAK,GAAG+B,IAAI,CAACG,OAAL,CACb,4CADa,CAAd;AAGA,UAAMC,OAAO,GAAGnC,KAAK,EAAEI,YAAP,CAAqB,IAArB,CAAhB;AAEA2B,IAAAA,IAAI,CAACT,gBAAL,CAAuB,OAAvB,EAAgC,MAAM;AACrC;AACA;AACA;AACA,UAAKa,OAAO,IAAInC,KAAK,CAACK,SAAN,CAAgB+B,QAAhB,CAA0B,gBAA1B,CAAhB,EAA+D;AAC9Db,4BAAWc,KAAX,CAAkBF,OAAlB;AACA;AACD,KAPD;AAQA,GAzBD;AA0BA,CAtCD","sourcesContent":["/**\n * External dependencies\n */\nimport MicroModal from 'micromodal';\n\n// Responsive navigation toggle.\nfunction navigationToggleModal( modal ) {\n\tconst dialogContainer = modal.querySelector(\n\t\t`.wp-block-navigation__responsive-dialog`\n\t);\n\n\tconst isHidden = 'true' === modal.getAttribute( 'aria-hidden' );\n\n\tmodal.classList.toggle( 'has-modal-open', ! isHidden );\n\tdialogContainer.toggleAttribute( 'aria-modal', ! isHidden );\n\n\tif ( isHidden ) {\n\t\tdialogContainer.removeAttribute( 'role' );\n\t\tdialogContainer.removeAttribute( 'aria-modal' );\n\t} else {\n\t\tdialogContainer.setAttribute( 'role', 'dialog' );\n\t\tdialogContainer.setAttribute( 'aria-modal', 'true' );\n\t}\n\n\t// Add a class to indicate the modal is open.\n\tconst htmlElement = document.documentElement;\n\thtmlElement.classList.toggle( 'has-modal-open' );\n}\n\nfunction isLinkToAnchorOnCurrentPage( node ) {\n\treturn (\n\t\tnode.hash &&\n\t\tnode.protocol === window.location.protocol &&\n\t\tnode.host === window.location.host &&\n\t\tnode.pathname === window.location.pathname &&\n\t\tnode.search === window.location.search\n\t);\n}\n\nwindow.addEventListener( 'load', () => {\n\tMicroModal.init( {\n\t\tonShow: navigationToggleModal,\n\t\tonClose: navigationToggleModal,\n\t\topenClass: 'is-menu-open',\n\t} );\n\n\t// Close modal automatically on clicking anchor links inside modal.\n\tconst navigationLinks = document.querySelectorAll(\n\t\t'.wp-block-navigation-item__content'\n\t);\n\n\tnavigationLinks.forEach( function ( link ) {\n\t\t// Ignore non-anchor links and anchor links which open on a new tab.\n\t\tif (\n\t\t\t! isLinkToAnchorOnCurrentPage( link ) ||\n\t\t\tlink.attributes?.target === '_blank'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Find the specific parent modal for this link\n\t\t// since .close() won't work without an ID if there are\n\t\t// multiple navigation menus in a post/page.\n\t\tconst modal = link.closest(\n\t\t\t'.wp-block-navigation__responsive-container'\n\t\t);\n\t\tconst modalId = modal?.getAttribute( 'id' );\n\n\t\tlink.addEventListener( 'click', () => {\n\t\t\t// check if modal exists and is open before trying to close it\n\t\t\t// otherwise Micromodal will toggle the `has-modal-open` class\n\t\t\t// on the html tag which prevents scrolling\n\t\t\tif ( modalId && modal.classList.contains( 'has-modal-open' ) ) {\n\t\t\t\tMicroModal.close( modalId );\n\t\t\t}\n\t\t} );\n\t} );\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/view-modal.js"],"names":["navigationToggleModal","modal","isHidden","dialogContainer","querySelector","classList","toggle","toggleAttribute","removeAttribute","setAttribute","document","documentElement","isLinkToAnchorOnCurrentPage","node","hash","protocol","window","location","host","pathname","search","onShow","addEventListener","handleAnchorLinkClicksInsideModal","passive","onClose","removeEventListener","event","link","target","closest","HTMLAnchorElement","attributes","modalId","getAttribute","contains","MicroModal","close","dataset","micromodalTrigger","show","openClass"],"mappings":"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","sourcesContent":["/*eslint-env browser*/\n/**\n * External dependencies\n */\nimport MicroModal from 'micromodal';\n\n// Responsive navigation toggle.\n\n/**\n * Toggles responsive navigation.\n *\n * @param {HTMLDivElement} modal\n * @param {boolean} isHidden\n */\nfunction navigationToggleModal( modal, isHidden ) {\n\tconst dialogContainer = modal.querySelector(\n\t\t`.wp-block-navigation__responsive-dialog`\n\t);\n\n\tmodal.classList.toggle( 'has-modal-open', ! isHidden );\n\tdialogContainer.toggleAttribute( 'aria-modal', ! isHidden );\n\n\tif ( isHidden ) {\n\t\tdialogContainer.removeAttribute( 'role' );\n\t\tdialogContainer.removeAttribute( 'aria-modal' );\n\t} else {\n\t\tdialogContainer.setAttribute( 'role', 'dialog' );\n\t\tdialogContainer.setAttribute( 'aria-modal', 'true' );\n\t}\n\n\t// Add a class to indicate the modal is open.\n\tdocument.documentElement.classList.toggle( 'has-modal-open' );\n}\n\n/**\n * Checks whether the provided link is an anchor on the current page.\n *\n * @param {HTMLAnchorElement} node\n * @return {boolean} Is anchor.\n */\nfunction isLinkToAnchorOnCurrentPage( node ) {\n\treturn (\n\t\tnode.hash &&\n\t\tnode.protocol === window.location.protocol &&\n\t\tnode.host === window.location.host &&\n\t\tnode.pathname === window.location.pathname &&\n\t\tnode.search === window.location.search\n\t);\n}\n\n/**\n * Handles effects after opening the modal.\n *\n * @param {HTMLDivElement} modal\n */\nfunction onShow( modal ) {\n\tnavigationToggleModal( modal, false );\n\tmodal.addEventListener( 'click', handleAnchorLinkClicksInsideModal, {\n\t\tpassive: true,\n\t} );\n}\n\n/**\n * Handles effects after closing the modal.\n *\n * @param {HTMLDivElement} modal\n */\nfunction onClose( modal ) {\n\tnavigationToggleModal( modal, true );\n\tmodal.removeEventListener( 'click', handleAnchorLinkClicksInsideModal, {\n\t\tpassive: true,\n\t} );\n}\n\n/**\n * Handle clicks to anchor links in modal using event delegation by closing modal automatically\n *\n * @param {UIEvent} event\n */\nfunction handleAnchorLinkClicksInsideModal( event ) {\n\tconst link = event.target.closest( '.wp-block-navigation-item__content' );\n\tif ( ! ( link instanceof HTMLAnchorElement ) ) {\n\t\treturn;\n\t}\n\n\t// Ignore non-anchor links and anchor links which open on a new tab.\n\tif (\n\t\t! isLinkToAnchorOnCurrentPage( link ) ||\n\t\tlink.attributes?.target === '_blank'\n\t) {\n\t\treturn;\n\t}\n\n\t// Find the specific parent modal for this link\n\t// since .close() won't work without an ID if there are\n\t// multiple navigation menus in a post/page.\n\tconst modal = link.closest( '.wp-block-navigation__responsive-container' );\n\tconst modalId = modal?.getAttribute( 'id' );\n\tif ( ! modalId ) {\n\t\treturn;\n\t}\n\n\t// check if modal exists and is open before trying to close it\n\t// otherwise Micromodal will toggle the `has-modal-open` class\n\t// on the html tag which prevents scrolling\n\tif ( modalId && modal.classList.contains( 'has-modal-open' ) ) {\n\t\tMicroModal.close( modalId );\n\t}\n}\n\n// MicroModal.init() does not support event delegation for the open trigger, so here MicroModal.show() is called manually.\ndocument.addEventListener(\n\t'click',\n\t( event ) => {\n\t\t/** @type {HTMLElement} */\n\t\tconst target = event.target;\n\n\t\tif ( target.dataset.micromodalTrigger ) {\n\t\t\tMicroModal.show( target.dataset.micromodalTrigger, {\n\t\t\t\tonShow,\n\t\t\t\tonClose,\n\t\t\t\topenClass: 'is-menu-open',\n\t\t\t} );\n\t\t}\n\t},\n\t{ passive: true }\n);\n"]}
@@ -1,61 +1,93 @@
1
1
  "use strict";
2
2
 
3
+ /*eslint-env browser*/
3
4
  // Open on click functionality.
4
- function closeSubmenus(element) {
5
- element.querySelectorAll('[aria-expanded="true"]').forEach(function (toggle) {
5
+
6
+ /**
7
+ * Keep track of whether a submenu is open to short-circuit delegated event listeners.
8
+ *
9
+ * @type {boolean}
10
+ */
11
+ let hasOpenSubmenu = false;
12
+ /**
13
+ * Close submenu items for a navigation item.
14
+ *
15
+ * @param {HTMLElement} navigationItem - Either a NAV or LI element.
16
+ */
17
+
18
+ function closeSubmenus(navigationItem) {
19
+ navigationItem.querySelectorAll('[aria-expanded="true"]').forEach(function (toggle) {
6
20
  toggle.setAttribute('aria-expanded', 'false');
7
21
  });
22
+ hasOpenSubmenu = false;
8
23
  }
24
+ /**
25
+ * Toggle submenu on click.
26
+ *
27
+ * @param {HTMLButtonElement} buttonToggle
28
+ */
29
+
9
30
 
10
- function toggleSubmenuOnClick(event) {
11
- const buttonToggle = event.target.closest('[aria-expanded]');
12
- const isSubmenuOpen = buttonToggle.getAttribute('aria-expanded');
31
+ function toggleSubmenuOnClick(buttonToggle) {
32
+ const isSubmenuOpen = buttonToggle.getAttribute('aria-expanded') === 'true';
33
+ const navigationItem = buttonToggle.closest('.wp-block-navigation-item');
13
34
 
14
- if (isSubmenuOpen === 'true') {
15
- closeSubmenus(buttonToggle.closest('.wp-block-navigation-item'));
35
+ if (isSubmenuOpen) {
36
+ closeSubmenus(navigationItem);
16
37
  } else {
17
38
  // Close all sibling submenus.
18
- const parentElement = buttonToggle.closest('.wp-block-navigation-item');
19
39
  const navigationParent = buttonToggle.closest('.wp-block-navigation__submenu-container, .wp-block-navigation__container, .wp-block-page-list');
20
- navigationParent.querySelectorAll('.wp-block-navigation-item').forEach(function (child) {
21
- if (child !== parentElement) {
40
+ navigationParent.querySelectorAll('.wp-block-navigation-item').forEach(child => {
41
+ if (child !== navigationItem) {
22
42
  closeSubmenus(child);
23
43
  }
24
44
  }); // Open submenu.
25
45
 
26
46
  buttonToggle.setAttribute('aria-expanded', 'true');
47
+ hasOpenSubmenu = true;
27
48
  }
28
- } // Necessary for some themes such as TT1 Blocks, where
29
- // scripts could be loaded before the body.
49
+ } // Open on button click or close on click outside.
30
50
 
31
51
 
32
- window.addEventListener('load', () => {
33
- const submenuButtons = document.querySelectorAll('.wp-block-navigation-submenu__toggle');
34
- submenuButtons.forEach(function (button) {
35
- button.addEventListener('click', toggleSubmenuOnClick);
36
- }); // Close on click outside.
52
+ document.addEventListener('click', function (event) {
53
+ const target = event.target;
54
+ const button = target.closest('.wp-block-navigation-submenu__toggle'); // Close any other open submenus.
37
55
 
38
- document.addEventListener('click', function (event) {
56
+ if (hasOpenSubmenu) {
39
57
  const navigationBlocks = document.querySelectorAll('.wp-block-navigation');
40
58
  navigationBlocks.forEach(function (block) {
41
- if (!block.contains(event.target)) {
59
+ if (!block.contains(target)) {
42
60
  closeSubmenus(block);
43
61
  }
44
62
  });
45
- }); // Close on focus outside or escape key.
63
+ } // Now open the submenu if one was clicked.
46
64
 
47
- document.addEventListener('keyup', function (event) {
48
- const submenuBlocks = document.querySelectorAll('.wp-block-navigation-item.has-child');
49
- submenuBlocks.forEach(function (block) {
50
- if (!block.contains(event.target)) {
51
- closeSubmenus(block);
52
- } else if (event.key === 'Escape') {
53
- const toggle = block.querySelector('[aria-expanded="true"]');
54
- closeSubmenus(block); // Focus the submenu trigger so focus does not get trapped in the closed submenu.
55
65
 
56
- toggle?.focus();
57
- }
58
- });
66
+ if (button instanceof HTMLButtonElement) {
67
+ toggleSubmenuOnClick(button);
68
+ }
69
+ }, {
70
+ passive: true
71
+ }); // Close on focus outside or escape key.
72
+
73
+ document.addEventListener('keyup', function (event) {
74
+ // Abort if there aren't any submenus open anyway.
75
+ if (!hasOpenSubmenu) {
76
+ return;
77
+ }
78
+
79
+ const submenuBlocks = document.querySelectorAll('.wp-block-navigation-item.has-child');
80
+ submenuBlocks.forEach(function (block) {
81
+ if (!block.contains(event.target)) {
82
+ closeSubmenus(block);
83
+ } else if (event.key === 'Escape') {
84
+ const toggle = block.querySelector('[aria-expanded="true"]');
85
+ closeSubmenus(block); // Focus the submenu trigger so focus does not get trapped in the closed submenu.
86
+
87
+ toggle?.focus();
88
+ }
59
89
  });
90
+ }, {
91
+ passive: true
60
92
  });
61
93
  //# sourceMappingURL=view.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/view.js"],"names":["closeSubmenus","element","querySelectorAll","forEach","toggle","setAttribute","toggleSubmenuOnClick","event","buttonToggle","target","closest","isSubmenuOpen","getAttribute","parentElement","navigationParent","child","window","addEventListener","submenuButtons","document","button","navigationBlocks","block","contains","submenuBlocks","key","querySelector","focus"],"mappings":";;AAAA;AACA,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACjCA,EAAAA,OAAO,CACLC,gBADF,CACoB,wBADpB,EAEEC,OAFF,CAEW,UAAWC,MAAX,EAAoB;AAC7BA,IAAAA,MAAM,CAACC,YAAP,CAAqB,eAArB,EAAsC,OAAtC;AACA,GAJF;AAKA;;AAED,SAASC,oBAAT,CAA+BC,KAA/B,EAAuC;AACtC,QAAMC,YAAY,GAAGD,KAAK,CAACE,MAAN,CAAaC,OAAb,CAAsB,iBAAtB,CAArB;AACA,QAAMC,aAAa,GAAGH,YAAY,CAACI,YAAb,CAA2B,eAA3B,CAAtB;;AAEA,MAAKD,aAAa,KAAK,MAAvB,EAAgC;AAC/BX,IAAAA,aAAa,CAAEQ,YAAY,CAACE,OAAb,CAAsB,2BAAtB,CAAF,CAAb;AACA,GAFD,MAEO;AACN;AACA,UAAMG,aAAa,GAAGL,YAAY,CAACE,OAAb,CACrB,2BADqB,CAAtB;AAGA,UAAMI,gBAAgB,GAAGN,YAAY,CAACE,OAAb,CACxB,+FADwB,CAAzB;AAGAI,IAAAA,gBAAgB,CACdZ,gBADF,CACoB,2BADpB,EAEEC,OAFF,CAEW,UAAWY,KAAX,EAAmB;AAC5B,UAAKA,KAAK,KAAKF,aAAf,EAA+B;AAC9Bb,QAAAA,aAAa,CAAEe,KAAF,CAAb;AACA;AACD,KANF,EARM,CAeN;;AACAP,IAAAA,YAAY,CAACH,YAAb,CAA2B,eAA3B,EAA4C,MAA5C;AACA;AACD,C,CAED;AACA;;;AACAW,MAAM,CAACC,gBAAP,CAAyB,MAAzB,EAAiC,MAAM;AACtC,QAAMC,cAAc,GAAGC,QAAQ,CAACjB,gBAAT,CACtB,sCADsB,CAAvB;AAIAgB,EAAAA,cAAc,CAACf,OAAf,CAAwB,UAAWiB,MAAX,EAAoB;AAC3CA,IAAAA,MAAM,CAACH,gBAAP,CAAyB,OAAzB,EAAkCX,oBAAlC;AACA,GAFD,EALsC,CAStC;;AACAa,EAAAA,QAAQ,CAACF,gBAAT,CAA2B,OAA3B,EAAoC,UAAWV,KAAX,EAAmB;AACtD,UAAMc,gBAAgB,GAAGF,QAAQ,CAACjB,gBAAT,CACxB,sBADwB,CAAzB;AAGAmB,IAAAA,gBAAgB,CAAClB,OAAjB,CAA0B,UAAWmB,KAAX,EAAmB;AAC5C,UAAK,CAAEA,KAAK,CAACC,QAAN,CAAgBhB,KAAK,CAACE,MAAtB,CAAP,EAAwC;AACvCT,QAAAA,aAAa,CAAEsB,KAAF,CAAb;AACA;AACD,KAJD;AAKA,GATD,EAVsC,CAoBtC;;AACAH,EAAAA,QAAQ,CAACF,gBAAT,CAA2B,OAA3B,EAAoC,UAAWV,KAAX,EAAmB;AACtD,UAAMiB,aAAa,GAAGL,QAAQ,CAACjB,gBAAT,CACrB,qCADqB,CAAtB;AAGAsB,IAAAA,aAAa,CAACrB,OAAd,CAAuB,UAAWmB,KAAX,EAAmB;AACzC,UAAK,CAAEA,KAAK,CAACC,QAAN,CAAgBhB,KAAK,CAACE,MAAtB,CAAP,EAAwC;AACvCT,QAAAA,aAAa,CAAEsB,KAAF,CAAb;AACA,OAFD,MAEO,IAAKf,KAAK,CAACkB,GAAN,KAAc,QAAnB,EAA8B;AACpC,cAAMrB,MAAM,GAAGkB,KAAK,CAACI,aAAN,CAAqB,wBAArB,CAAf;AACA1B,QAAAA,aAAa,CAAEsB,KAAF,CAAb,CAFoC,CAGpC;;AACAlB,QAAAA,MAAM,EAAEuB,KAAR;AACA;AACD,KATD;AAUA,GAdD;AAeA,CApCD","sourcesContent":["// Open on click functionality.\nfunction closeSubmenus( element ) {\n\telement\n\t\t.querySelectorAll( '[aria-expanded=\"true\"]' )\n\t\t.forEach( function ( toggle ) {\n\t\t\ttoggle.setAttribute( 'aria-expanded', 'false' );\n\t\t} );\n}\n\nfunction toggleSubmenuOnClick( event ) {\n\tconst buttonToggle = event.target.closest( '[aria-expanded]' );\n\tconst isSubmenuOpen = buttonToggle.getAttribute( 'aria-expanded' );\n\n\tif ( isSubmenuOpen === 'true' ) {\n\t\tcloseSubmenus( buttonToggle.closest( '.wp-block-navigation-item' ) );\n\t} else {\n\t\t// Close all sibling submenus.\n\t\tconst parentElement = buttonToggle.closest(\n\t\t\t'.wp-block-navigation-item'\n\t\t);\n\t\tconst navigationParent = buttonToggle.closest(\n\t\t\t'.wp-block-navigation__submenu-container, .wp-block-navigation__container, .wp-block-page-list'\n\t\t);\n\t\tnavigationParent\n\t\t\t.querySelectorAll( '.wp-block-navigation-item' )\n\t\t\t.forEach( function ( child ) {\n\t\t\t\tif ( child !== parentElement ) {\n\t\t\t\t\tcloseSubmenus( child );\n\t\t\t\t}\n\t\t\t} );\n\t\t// Open submenu.\n\t\tbuttonToggle.setAttribute( 'aria-expanded', 'true' );\n\t}\n}\n\n// Necessary for some themes such as TT1 Blocks, where\n// scripts could be loaded before the body.\nwindow.addEventListener( 'load', () => {\n\tconst submenuButtons = document.querySelectorAll(\n\t\t'.wp-block-navigation-submenu__toggle'\n\t);\n\n\tsubmenuButtons.forEach( function ( button ) {\n\t\tbutton.addEventListener( 'click', toggleSubmenuOnClick );\n\t} );\n\n\t// Close on click outside.\n\tdocument.addEventListener( 'click', function ( event ) {\n\t\tconst navigationBlocks = document.querySelectorAll(\n\t\t\t'.wp-block-navigation'\n\t\t);\n\t\tnavigationBlocks.forEach( function ( block ) {\n\t\t\tif ( ! block.contains( event.target ) ) {\n\t\t\t\tcloseSubmenus( block );\n\t\t\t}\n\t\t} );\n\t} );\n\t// Close on focus outside or escape key.\n\tdocument.addEventListener( 'keyup', function ( event ) {\n\t\tconst submenuBlocks = document.querySelectorAll(\n\t\t\t'.wp-block-navigation-item.has-child'\n\t\t);\n\t\tsubmenuBlocks.forEach( function ( block ) {\n\t\t\tif ( ! block.contains( event.target ) ) {\n\t\t\t\tcloseSubmenus( block );\n\t\t\t} else if ( event.key === 'Escape' ) {\n\t\t\t\tconst toggle = block.querySelector( '[aria-expanded=\"true\"]' );\n\t\t\t\tcloseSubmenus( block );\n\t\t\t\t// Focus the submenu trigger so focus does not get trapped in the closed submenu.\n\t\t\t\ttoggle?.focus();\n\t\t\t}\n\t\t} );\n\t} );\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/view.js"],"names":["hasOpenSubmenu","closeSubmenus","navigationItem","querySelectorAll","forEach","toggle","setAttribute","toggleSubmenuOnClick","buttonToggle","isSubmenuOpen","getAttribute","closest","navigationParent","child","document","addEventListener","event","target","button","navigationBlocks","block","contains","HTMLButtonElement","passive","submenuBlocks","key","querySelector","focus"],"mappings":"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","sourcesContent":["/*eslint-env browser*/\n// Open on click functionality.\n\n/**\n * Keep track of whether a submenu is open to short-circuit delegated event listeners.\n *\n * @type {boolean}\n */\nlet hasOpenSubmenu = false;\n\n/**\n * Close submenu items for a navigation item.\n *\n * @param {HTMLElement} navigationItem - Either a NAV or LI element.\n */\nfunction closeSubmenus( navigationItem ) {\n\tnavigationItem\n\t\t.querySelectorAll( '[aria-expanded=\"true\"]' )\n\t\t.forEach( function ( toggle ) {\n\t\t\ttoggle.setAttribute( 'aria-expanded', 'false' );\n\t\t} );\n\thasOpenSubmenu = false;\n}\n\n/**\n * Toggle submenu on click.\n *\n * @param {HTMLButtonElement} buttonToggle\n */\nfunction toggleSubmenuOnClick( buttonToggle ) {\n\tconst isSubmenuOpen =\n\t\tbuttonToggle.getAttribute( 'aria-expanded' ) === 'true';\n\tconst navigationItem = buttonToggle.closest( '.wp-block-navigation-item' );\n\n\tif ( isSubmenuOpen ) {\n\t\tcloseSubmenus( navigationItem );\n\t} else {\n\t\t// Close all sibling submenus.\n\t\tconst navigationParent = buttonToggle.closest(\n\t\t\t'.wp-block-navigation__submenu-container, .wp-block-navigation__container, .wp-block-page-list'\n\t\t);\n\t\tnavigationParent\n\t\t\t.querySelectorAll( '.wp-block-navigation-item' )\n\t\t\t.forEach( ( child ) => {\n\t\t\t\tif ( child !== navigationItem ) {\n\t\t\t\t\tcloseSubmenus( child );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t// Open submenu.\n\t\tbuttonToggle.setAttribute( 'aria-expanded', 'true' );\n\t\thasOpenSubmenu = true;\n\t}\n}\n\n// Open on button click or close on click outside.\ndocument.addEventListener(\n\t'click',\n\tfunction ( event ) {\n\t\tconst target = event.target;\n\t\tconst button = target.closest( '.wp-block-navigation-submenu__toggle' );\n\n\t\t// Close any other open submenus.\n\t\tif ( hasOpenSubmenu ) {\n\t\t\tconst navigationBlocks = document.querySelectorAll(\n\t\t\t\t'.wp-block-navigation'\n\t\t\t);\n\t\t\tnavigationBlocks.forEach( function ( block ) {\n\t\t\t\tif ( ! block.contains( target ) ) {\n\t\t\t\t\tcloseSubmenus( block );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Now open the submenu if one was clicked.\n\t\tif ( button instanceof HTMLButtonElement ) {\n\t\t\ttoggleSubmenuOnClick( button );\n\t\t}\n\t},\n\t{ passive: true }\n);\n\n// Close on focus outside or escape key.\ndocument.addEventListener(\n\t'keyup',\n\tfunction ( event ) {\n\t\t// Abort if there aren't any submenus open anyway.\n\t\tif ( ! hasOpenSubmenu ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst submenuBlocks = document.querySelectorAll(\n\t\t\t'.wp-block-navigation-item.has-child'\n\t\t);\n\t\tsubmenuBlocks.forEach( function ( block ) {\n\t\t\tif ( ! block.contains( event.target ) ) {\n\t\t\t\tcloseSubmenus( block );\n\t\t\t} else if ( event.key === 'Escape' ) {\n\t\t\t\tconst toggle = block.querySelector( '[aria-expanded=\"true\"]' );\n\t\t\t\tcloseSubmenus( block );\n\t\t\t\t// Focus the submenu trigger so focus does not get trapped in the closed submenu.\n\t\t\t\ttoggle?.focus();\n\t\t\t}\n\t\t} );\n\t},\n\t{ passive: true }\n);\n"]}
@@ -13,9 +13,15 @@ var _data = require("@wordpress/data");
13
13
 
14
14
  var _blockEditor = require("@wordpress/block-editor");
15
15
 
16
+ var _lockUnlock = require("../lock-unlock");
17
+
16
18
  /**
17
19
  * WordPress dependencies
18
20
  */
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
19
25
  const PatternEdit = ({
20
26
  attributes,
21
27
  clientId
@@ -24,7 +30,14 @@ const PatternEdit = ({
24
30
  const {
25
31
  replaceBlocks,
26
32
  __unstableMarkNextChangeAsNotPersistent
27
- } = (0, _data.useDispatch)(_blockEditor.store); // Run this effect when the component loads.
33
+ } = (0, _data.useDispatch)(_blockEditor.store);
34
+ const {
35
+ setBlockEditingMode
36
+ } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_blockEditor.store));
37
+ const {
38
+ getBlockRootClientId,
39
+ getBlockEditingMode
40
+ } = (0, _lockUnlock.unlock)((0, _data.useSelect)(_blockEditor.store)); // Run this effect when the component loads.
28
41
  // This adds the Pattern's contents to the post.
29
42
  // This change won't be saved.
30
43
  // It will continue to pull from the pattern file unless changes are made to its respective template part.
@@ -37,16 +50,27 @@ const PatternEdit = ({
37
50
  // because nested pattern blocks cannot be inserted if the parent block supports
38
51
  // inner blocks but doesn't have blockSettings in the state.
39
52
  window.queueMicrotask(() => {
40
- // Clone blocks from the pattern before insertion to ensure they receive
53
+ const rootClientId = getBlockRootClientId(clientId); // Clone blocks from the pattern before insertion to ensure they receive
41
54
  // distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.
55
+
42
56
  const clonedBlocks = selectedPattern.blocks.map(block => (0, _blocks.cloneBlock)(block));
57
+ const rootEditingMode = getBlockEditingMode(rootClientId); // Temporarily set the root block to default mode to allow replacing the pattern.
58
+ // This could happen when the page is disabling edits of non-content blocks.
59
+
60
+ __unstableMarkNextChangeAsNotPersistent();
61
+
62
+ setBlockEditingMode(rootClientId, 'default');
63
+
64
+ __unstableMarkNextChangeAsNotPersistent();
65
+
66
+ replaceBlocks(clientId, clonedBlocks); // Restore the root block's original mode.
43
67
 
44
68
  __unstableMarkNextChangeAsNotPersistent();
45
69
 
46
- replaceBlocks(clientId, clonedBlocks);
70
+ setBlockEditingMode(rootClientId, rootEditingMode);
47
71
  });
48
72
  }
49
- }, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks]);
73
+ }, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks, getBlockEditingMode, setBlockEditingMode, getBlockRootClientId]);
50
74
  const props = (0, _blockEditor.useBlockProps)();
51
75
  return (0, _element.createElement)("div", { ...props
52
76
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/pattern/edit.js"],"names":["PatternEdit","attributes","clientId","selectedPattern","select","blockEditorStore","__experimentalGetParsedPattern","slug","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","blocks","window","queueMicrotask","clonedBlocks","map","block","props"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AANA;AACA;AACA;AASA,MAAMA,WAAW,GAAG,CAAE;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,CAAF,KAAgC;AACnD,QAAMC,eAAe,GAAG,qBACrBC,MAAF,IACCA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,8BAA3B,CACCL,UAAU,CAACM,IADZ,CAFsB,EAKvB,CAAEN,UAAU,CAACM,IAAb,CALuB,CAAxB;AAQA,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MACL,uBAAaJ,kBAAb,CADD,CATmD,CAYnD;AACA;AACA;AACA;;AACA,0BAAW,MAAM;AAChB,QAAKF,eAAe,EAAEO,MAAtB,EAA+B;AAC9B;AACA;AACA;AACA;AACA;AACAC,MAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5B;AACA;AACA,cAAMC,YAAY,GAAGV,eAAe,CAACO,MAAhB,CAAuBI,GAAvB,CAA8BC,KAAF,IAChD,wBAAYA,KAAZ,CADoB,CAArB;;AAGAN,QAAAA,uCAAuC;;AACvCD,QAAAA,aAAa,CAAEN,QAAF,EAAYW,YAAZ,CAAb;AACA,OARD;AASA;AACD,GAjBD,EAiBG,CACFX,QADE,EAEFC,eAAe,EAAEO,MAFf,EAGFD,uCAHE,EAIFD,aAJE,CAjBH;AAwBA,QAAMQ,KAAK,GAAG,iCAAd;AAEA,SAAO,wCAAUA;AAAV,IAAP;AACA,CA3CD;;eA6CehB,W","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/pattern/edit.js"],"names":["PatternEdit","attributes","clientId","selectedPattern","select","blockEditorStore","__experimentalGetParsedPattern","slug","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","blocks","window","queueMicrotask","rootClientId","clonedBlocks","map","block","rootEditingMode","props"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAQA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,CAAE;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,CAAF,KAAgC;AACnD,QAAMC,eAAe,GAAG,qBACrBC,MAAF,IACCA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,8BAA3B,CACCL,UAAU,CAACM,IADZ,CAFsB,EAKvB,CAAEN,UAAU,CAACM,IAAb,CALuB,CAAxB;AAQA,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MACL,uBAAaJ,kBAAb,CADD;AAEA,QAAM;AAAEK,IAAAA;AAAF,MAA0B,wBAAQ,uBAAaL,kBAAb,CAAR,CAAhC;AACA,QAAM;AAAEM,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MAAgD,wBACrD,qBAAWP,kBAAX,CADqD,CAAtD,CAZmD,CAgBnD;AACA;AACA;AACA;;AACA,0BAAW,MAAM;AAChB,QAAKF,eAAe,EAAEU,MAAtB,EAA+B;AAC9B;AACA;AACA;AACA;AACA;AACAC,MAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5B,cAAMC,YAAY,GAAGL,oBAAoB,CAAET,QAAF,CAAzC,CAD4B,CAE5B;AACA;;AACA,cAAMe,YAAY,GAAGd,eAAe,CAACU,MAAhB,CAAuBK,GAAvB,CAA8BC,KAAF,IAChD,wBAAYA,KAAZ,CADoB,CAArB;AAGA,cAAMC,eAAe,GAAGR,mBAAmB,CAAEI,YAAF,CAA3C,CAP4B,CAQ5B;AACA;;AACAP,QAAAA,uCAAuC;;AACvCC,QAAAA,mBAAmB,CAAEM,YAAF,EAAgB,SAAhB,CAAnB;;AACAP,QAAAA,uCAAuC;;AACvCD,QAAAA,aAAa,CAAEN,QAAF,EAAYe,YAAZ,CAAb,CAb4B,CAc5B;;AACAR,QAAAA,uCAAuC;;AACvCC,QAAAA,mBAAmB,CAAEM,YAAF,EAAgBI,eAAhB,CAAnB;AACA,OAjBD;AAkBA;AACD,GA1BD,EA0BG,CACFlB,QADE,EAEFC,eAAe,EAAEU,MAFf,EAGFJ,uCAHE,EAIFD,aAJE,EAKFI,mBALE,EAMFF,mBANE,EAOFC,oBAPE,CA1BH;AAoCA,QAAMU,KAAK,GAAG,iCAAd;AAEA,SAAO,wCAAUA;AAAV,IAAP;AACA,CA3DD;;eA6DerB,W","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = unlock( useDispatch( blockEditorStore ) );\n\tconst { getBlockRootClientId, getBlockEditingMode } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"]}
@@ -53,6 +53,10 @@ const metadata = {
53
53
  text: true
54
54
  }
55
55
  },
56
+ spacing: {
57
+ padding: true,
58
+ margin: true
59
+ },
56
60
  typography: {
57
61
  fontSize: true,
58
62
  lineHeight: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/preformatted/index.js"],"names":["name","metadata","settings","icon","example","attributes","content","transforms","edit","save","merge","attributesToMerge","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,mBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACX;AACA;AACAC,MAAAA,OAAO,EAAE,cACR,wQADQ;AAGT;;AANW;AADJ,GAFc;AAYvBC,EAAAA,UAAU,EAAVA,mBAZuB;AAavBC,EAAAA,IAAI,EAAJA,aAbuB;AAcvBC,EAAAA,IAAI,EAAJA,aAduB;;AAevBC,EAAAA,KAAK,CAAEL,UAAF,EAAcM,iBAAd,EAAkC;AACtC,WAAO;AACNL,MAAAA,OAAO,EAAED,UAAU,CAACC,OAAX,GAAqBK,iBAAiB,CAACL;AAD1C,KAAP;AAGA;;AAnBsB,CAAjB;;;AAsBA,MAAMM,IAAI,GAAG,MAAM,wBAAW;AAAEZ,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { preformatted as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Preformatted block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'EXT. XANADU - FAINT DAWN - 1940 (MINIATURE)\\nWindow, very small in the distance, illuminated.\\nAll around this is an almost totally black screen. Now, as the camera moves slowly towards the window which is almost a postage stamp in the frame, other forms appear;'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/preformatted/index.js"],"names":["name","metadata","settings","icon","example","attributes","content","transforms","edit","save","merge","attributesToMerge","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,mBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACX;AACA;AACAC,MAAAA,OAAO,EAAE,cACR,wQADQ;AAGT;;AANW;AADJ,GAFc;AAYvBC,EAAAA,UAAU,EAAVA,mBAZuB;AAavBC,EAAAA,IAAI,EAAJA,aAbuB;AAcvBC,EAAAA,IAAI,EAAJA,aAduB;;AAevBC,EAAAA,KAAK,CAAEL,UAAF,EAAcM,iBAAd,EAAkC;AACtC,WAAO;AACNL,MAAAA,OAAO,EAAED,UAAU,CAACC,OAAX,GAAqBK,iBAAiB,CAACL;AAD1C,KAAP;AAGA;;AAnBsB,CAAjB;;;AAsBA,MAAMM,IAAI,GAAG,MAAM,wBAAW;AAAEZ,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { preformatted as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Preformatted block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'EXT. XANADU - FAINT DAWN - 1940 (MINIATURE)\\nWindow, very small in the distance, illuminated.\\nAll around this is an almost totally black screen. Now, as the camera moves slowly towards the window which is almost a postage stamp in the frame, other forms appear;'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}