@wordpress/block-library 9.33.1-next.b8c8708f3.0 → 9.33.1

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 (158) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/build/breadcrumbs/block.json +8 -2
  4. package/build/breadcrumbs/edit.js +113 -12
  5. package/build/breadcrumbs/edit.js.map +2 -2
  6. package/build/buttons/transforms.js +7 -7
  7. package/build/buttons/transforms.js.map +2 -2
  8. package/build/code/transforms.js +19 -15
  9. package/build/code/transforms.js.map +2 -2
  10. package/build/heading/index.js +1 -3
  11. package/build/heading/index.js.map +3 -3
  12. package/build/heading/transforms.js +22 -20
  13. package/build/heading/transforms.js.map +2 -2
  14. package/build/index.js +5 -1
  15. package/build/index.js.map +2 -2
  16. package/build/math/block.json +21 -0
  17. package/build/math/edit.js +132 -0
  18. package/build/math/edit.js.map +7 -0
  19. package/build/math/index.js +63 -0
  20. package/build/math/index.js.map +7 -0
  21. package/build/math/init.js +35 -0
  22. package/build/math/init.js.map +7 -0
  23. package/build/math/save.js +40 -0
  24. package/build/math/save.js.map +7 -0
  25. package/build/navigation/edit/menu-inspector-controls.js +3 -3
  26. package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
  27. package/build/navigation-link/edit.js +6 -3
  28. package/build/navigation-link/edit.js.map +2 -2
  29. package/build/navigation-link/link-ui/index.js +1 -1
  30. package/build/navigation-link/link-ui/index.js.map +2 -2
  31. package/build/navigation-link/shared/controls.js +4 -1
  32. package/build/navigation-link/shared/controls.js.map +3 -3
  33. package/build/navigation-link/shared/index.js +2 -0
  34. package/build/navigation-link/shared/index.js.map +2 -2
  35. package/build/navigation-link/shared/update-attributes.js +3 -1
  36. package/build/navigation-link/shared/update-attributes.js.map +2 -2
  37. package/build/navigation-link/shared/use-entity-binding.js +46 -13
  38. package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
  39. package/build/navigation-submenu/edit.js +6 -3
  40. package/build/navigation-submenu/edit.js.map +2 -2
  41. package/build/page-list/use-convert-to-navigation-links.js +6 -1
  42. package/build/page-list/use-convert-to-navigation-links.js.map +2 -2
  43. package/build/paragraph/index.js +1 -3
  44. package/build/paragraph/index.js.map +3 -3
  45. package/build/post-date/deprecated.js +98 -2
  46. package/build/post-date/deprecated.js.map +2 -2
  47. package/build/post-date/edit.js +1 -1
  48. package/build/post-date/edit.js.map +1 -1
  49. package/build/post-date/variations.js +4 -4
  50. package/build/post-date/variations.js.map +2 -2
  51. package/build/term-template/edit.js +4 -1
  52. package/build/term-template/edit.js.map +2 -2
  53. package/build/utils/get-transformed-attributes.js +82 -0
  54. package/build/utils/get-transformed-attributes.js.map +7 -0
  55. package/build-module/breadcrumbs/block.json +8 -2
  56. package/build-module/breadcrumbs/edit.js +117 -14
  57. package/build-module/breadcrumbs/edit.js.map +2 -2
  58. package/build-module/buttons/transforms.js +7 -7
  59. package/build-module/buttons/transforms.js.map +2 -2
  60. package/build-module/code/transforms.js +19 -15
  61. package/build-module/code/transforms.js.map +2 -2
  62. package/build-module/heading/index.js +1 -3
  63. package/build-module/heading/index.js.map +2 -2
  64. package/build-module/heading/transforms.js +22 -20
  65. package/build-module/heading/transforms.js.map +2 -2
  66. package/build-module/index.js +5 -1
  67. package/build-module/index.js.map +2 -2
  68. package/build-module/math/block.json +21 -0
  69. package/build-module/math/edit.js +110 -0
  70. package/build-module/math/edit.js.map +7 -0
  71. package/build-module/math/index.js +26 -0
  72. package/build-module/math/index.js.map +7 -0
  73. package/build-module/math/init.js +8 -0
  74. package/build-module/math/init.js.map +7 -0
  75. package/build-module/math/save.js +20 -0
  76. package/build-module/math/save.js.map +7 -0
  77. package/build-module/navigation/edit/menu-inspector-controls.js +3 -3
  78. package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
  79. package/build-module/navigation-link/edit.js +6 -3
  80. package/build-module/navigation-link/edit.js.map +2 -2
  81. package/build-module/navigation-link/link-ui/index.js +1 -1
  82. package/build-module/navigation-link/link-ui/index.js.map +2 -2
  83. package/build-module/navigation-link/shared/controls.js +4 -1
  84. package/build-module/navigation-link/shared/controls.js.map +2 -2
  85. package/build-module/navigation-link/shared/index.js +5 -1
  86. package/build-module/navigation-link/shared/index.js.map +2 -2
  87. package/build-module/navigation-link/shared/update-attributes.js +3 -1
  88. package/build-module/navigation-link/shared/update-attributes.js.map +2 -2
  89. package/build-module/navigation-link/shared/use-entity-binding.js +45 -13
  90. package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
  91. package/build-module/navigation-submenu/edit.js +6 -3
  92. package/build-module/navigation-submenu/edit.js.map +2 -2
  93. package/build-module/page-list/use-convert-to-navigation-links.js +6 -1
  94. package/build-module/page-list/use-convert-to-navigation-links.js.map +2 -2
  95. package/build-module/paragraph/index.js +1 -3
  96. package/build-module/paragraph/index.js.map +2 -2
  97. package/build-module/post-date/deprecated.js +98 -2
  98. package/build-module/post-date/deprecated.js.map +2 -2
  99. package/build-module/post-date/edit.js +1 -1
  100. package/build-module/post-date/edit.js.map +1 -1
  101. package/build-module/post-date/variations.js +4 -4
  102. package/build-module/post-date/variations.js.map +2 -2
  103. package/build-module/term-template/edit.js +4 -1
  104. package/build-module/term-template/edit.js.map +2 -2
  105. package/build-module/utils/get-transformed-attributes.js +58 -0
  106. package/build-module/utils/get-transformed-attributes.js.map +7 -0
  107. package/package.json +61 -36
  108. package/src/breadcrumbs/block.json +8 -2
  109. package/src/breadcrumbs/edit.js +163 -18
  110. package/src/breadcrumbs/index.php +118 -16
  111. package/src/buttons/transforms.js +6 -6
  112. package/src/code/transforms.js +16 -14
  113. package/src/heading/index.js +0 -2
  114. package/src/heading/transforms.js +25 -24
  115. package/src/index.js +6 -1
  116. package/src/math/block.json +21 -0
  117. package/src/math/edit.js +123 -0
  118. package/src/math/index.js +31 -0
  119. package/src/math/init.js +4 -0
  120. package/src/math/save.js +20 -0
  121. package/src/navigation/edit/menu-inspector-controls.js +8 -7
  122. package/src/navigation-link/edit.js +6 -3
  123. package/src/navigation-link/index.php +4 -18
  124. package/src/navigation-link/link-ui/index.js +4 -2
  125. package/src/navigation-link/shared/controls.js +12 -3
  126. package/src/navigation-link/shared/index.js +4 -1
  127. package/src/navigation-link/shared/test/update-attributes.test.js +8 -0
  128. package/src/navigation-link/shared/test/use-entity-binding.js +132 -17
  129. package/src/navigation-link/shared/update-attributes.js +1 -0
  130. package/src/navigation-link/shared/use-entity-binding.js +74 -19
  131. package/src/navigation-submenu/edit.js +6 -3
  132. package/src/navigation-submenu/index.php +3 -17
  133. package/src/page-list/test/{convert-to-links-modal.js → convert-to-navigation-links.js} +67 -0
  134. package/src/page-list/use-convert-to-navigation-links.js +11 -1
  135. package/src/paragraph/index.js +0 -2
  136. package/src/post-date/deprecated.js +100 -2
  137. package/src/post-date/edit.js +1 -1
  138. package/src/post-date/index.php +3 -3
  139. package/src/post-date/variations.js +5 -4
  140. package/src/term-template/edit.js +4 -1
  141. package/src/term-template/index.php +4 -6
  142. package/src/utils/get-transformed-attributes.js +98 -0
  143. package/tsconfig.json +1 -0
  144. package/build/heading/variations.js +0 -48
  145. package/build/heading/variations.js.map +0 -7
  146. package/build/paragraph/variations.js +0 -48
  147. package/build/paragraph/variations.js.map +0 -7
  148. package/build/utils/get-transformed-metadata.js +0 -59
  149. package/build/utils/get-transformed-metadata.js.map +0 -7
  150. package/build-module/heading/variations.js +0 -28
  151. package/build-module/heading/variations.js.map +0 -7
  152. package/build-module/paragraph/variations.js +0 -28
  153. package/build-module/paragraph/variations.js.map +0 -7
  154. package/build-module/utils/get-transformed-metadata.js +0 -35
  155. package/build-module/utils/get-transformed-metadata.js.map +0 -7
  156. package/src/heading/variations.js +0 -29
  157. package/src/paragraph/variations.js +0 -29
  158. package/src/utils/get-transformed-metadata.js +0 -60
@@ -0,0 +1,82 @@
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
+ var get_transformed_attributes_exports = {};
20
+ __export(get_transformed_attributes_exports, {
21
+ getTransformedAttributes: () => getTransformedAttributes
22
+ });
23
+ module.exports = __toCommonJS(get_transformed_attributes_exports);
24
+ var import_blocks = require("@wordpress/blocks");
25
+ function getTransformedAttributes(attributes, newBlockName, bindingsCallback = null) {
26
+ if (!attributes) {
27
+ return void 0;
28
+ }
29
+ const newBlockType = (0, import_blocks.getBlockType)(newBlockName);
30
+ if (!newBlockType) {
31
+ return void 0;
32
+ }
33
+ const transformedAttributes = {};
34
+ if ((0, import_blocks.hasBlockSupport)(newBlockType, "allowedBlocks") && attributes.allowedBlocks) {
35
+ transformedAttributes.allowedBlocks = attributes.allowedBlocks;
36
+ }
37
+ if ((0, import_blocks.hasBlockSupport)(newBlockType, "anchor") && attributes.anchor) {
38
+ transformedAttributes.anchor = attributes.anchor;
39
+ }
40
+ if ((0, import_blocks.hasBlockSupport)(newBlockType, "ariaLabel") && attributes.ariaLabel) {
41
+ transformedAttributes.ariaLabel = attributes.ariaLabel;
42
+ }
43
+ if ((0, import_blocks.hasBlockSupport)(newBlockType, "className") && attributes.className) {
44
+ transformedAttributes.className = attributes.className;
45
+ }
46
+ if (attributes.metadata) {
47
+ const transformedMetadata = ["noteId"];
48
+ if (bindingsCallback) {
49
+ transformedMetadata.push("id", "bindings");
50
+ }
51
+ if ((0, import_blocks.hasBlockSupport)(newBlockType, "renaming", true)) {
52
+ transformedMetadata.push("name");
53
+ }
54
+ if ((0, import_blocks.hasBlockSupport)(newBlockType, "blockVisibility", true)) {
55
+ transformedMetadata.push("blockVisibility");
56
+ }
57
+ if (transformedMetadata.length > 0) {
58
+ const newMetadata = Object.entries(attributes.metadata).reduce(
59
+ (obj, [prop, value]) => {
60
+ if (!transformedMetadata.includes(prop)) {
61
+ return obj;
62
+ }
63
+ obj[prop] = prop === "bindings" ? bindingsCallback(value) : value;
64
+ return obj;
65
+ },
66
+ {}
67
+ );
68
+ if (Object.keys(newMetadata).length > 0) {
69
+ transformedAttributes.metadata = newMetadata;
70
+ }
71
+ }
72
+ }
73
+ if (Object.keys(transformedAttributes).length === 0) {
74
+ return void 0;
75
+ }
76
+ return transformedAttributes;
77
+ }
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ getTransformedAttributes
81
+ });
82
+ //# sourceMappingURL=get-transformed-attributes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/get-transformed-attributes.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Transform block support attributes and metadata during block transforms.\n *\n * @param {Object} attributes Original attributes from the block being transformed.\n * @param {string} newBlockName Name of the target block after transformation.\n * @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.\n * @return {Object} New attributes object with preserved block support attributes and metadata.\n */\nexport function getTransformedAttributes(\n\tattributes,\n\tnewBlockName,\n\tbindingsCallback = null\n) {\n\tif ( ! attributes ) {\n\t\treturn undefined;\n\t}\n\n\tconst newBlockType = getBlockType( newBlockName );\n\tif ( ! newBlockType ) {\n\t\treturn undefined;\n\t}\n\n\tconst transformedAttributes = {};\n\n\t// Handle attributes derived from block support.\n\tif (\n\t\thasBlockSupport( newBlockType, 'allowedBlocks' ) &&\n\t\tattributes.allowedBlocks\n\t) {\n\t\ttransformedAttributes.allowedBlocks = attributes.allowedBlocks;\n\t}\n\tif ( hasBlockSupport( newBlockType, 'anchor' ) && attributes.anchor ) {\n\t\ttransformedAttributes.anchor = attributes.anchor;\n\t}\n\tif (\n\t\thasBlockSupport( newBlockType, 'ariaLabel' ) &&\n\t\tattributes.ariaLabel\n\t) {\n\t\ttransformedAttributes.ariaLabel = attributes.ariaLabel;\n\t}\n\tif (\n\t\thasBlockSupport( newBlockType, 'className' ) &&\n\t\tattributes.className\n\t) {\n\t\ttransformedAttributes.className = attributes.className;\n\t}\n\n\t// Handle metadata transformation.\n\tif ( attributes.metadata ) {\n\t\t// The metadata properties that should be preserved after the transform.\n\t\tconst transformedMetadata = [ 'noteId' ];\n\n\t\t// If there is a transform bindings callback, add the `id` and `bindings` properties.\n\t\tif ( bindingsCallback ) {\n\t\t\ttransformedMetadata.push( 'id', 'bindings' );\n\t\t}\n\n\t\t// Handle metadata properties derived from block support.\n\t\tif ( hasBlockSupport( newBlockType, 'renaming', true ) ) {\n\t\t\ttransformedMetadata.push( 'name' );\n\t\t}\n\t\tif ( hasBlockSupport( newBlockType, 'blockVisibility', true ) ) {\n\t\t\ttransformedMetadata.push( 'blockVisibility' );\n\t\t}\n\n\t\t// Only process metadata if there are supported properties.\n\t\tif ( transformedMetadata.length > 0 ) {\n\t\t\tconst newMetadata = Object.entries( attributes.metadata ).reduce(\n\t\t\t\t( obj, [ prop, value ] ) => {\n\t\t\t\t\t// If prop is not supported, don't add it to the new metadata object.\n\t\t\t\t\tif ( ! transformedMetadata.includes( prop ) ) {\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t}\n\t\t\t\t\tobj[ prop ] =\n\t\t\t\t\t\tprop === 'bindings' ? bindingsCallback( value ) : value;\n\t\t\t\t\treturn obj;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\t// Only add metadata if object is not empty.\n\t\t\tif ( Object.keys( newMetadata ).length > 0 ) {\n\t\t\t\ttransformedAttributes.metadata = newMetadata;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( Object.keys( transformedAttributes ).length === 0 ) {\n\t\treturn undefined;\n\t}\n\n\treturn transformedAttributes;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA8C;AAUvC,SAAS,yBACf,YACA,cACA,mBAAmB,MAClB;AACD,MAAK,CAAE,YAAa;AACnB,WAAO;AAAA,EACR;AAEA,QAAM,mBAAe,4BAAc,YAAa;AAChD,MAAK,CAAE,cAAe;AACrB,WAAO;AAAA,EACR;AAEA,QAAM,wBAAwB,CAAC;AAG/B,UACC,+BAAiB,cAAc,eAAgB,KAC/C,WAAW,eACV;AACD,0BAAsB,gBAAgB,WAAW;AAAA,EAClD;AACA,UAAK,+BAAiB,cAAc,QAAS,KAAK,WAAW,QAAS;AACrE,0BAAsB,SAAS,WAAW;AAAA,EAC3C;AACA,UACC,+BAAiB,cAAc,WAAY,KAC3C,WAAW,WACV;AACD,0BAAsB,YAAY,WAAW;AAAA,EAC9C;AACA,UACC,+BAAiB,cAAc,WAAY,KAC3C,WAAW,WACV;AACD,0BAAsB,YAAY,WAAW;AAAA,EAC9C;AAGA,MAAK,WAAW,UAAW;AAE1B,UAAM,sBAAsB,CAAE,QAAS;AAGvC,QAAK,kBAAmB;AACvB,0BAAoB,KAAM,MAAM,UAAW;AAAA,IAC5C;AAGA,YAAK,+BAAiB,cAAc,YAAY,IAAK,GAAI;AACxD,0BAAoB,KAAM,MAAO;AAAA,IAClC;AACA,YAAK,+BAAiB,cAAc,mBAAmB,IAAK,GAAI;AAC/D,0BAAoB,KAAM,iBAAkB;AAAA,IAC7C;AAGA,QAAK,oBAAoB,SAAS,GAAI;AACrC,YAAM,cAAc,OAAO,QAAS,WAAW,QAAS,EAAE;AAAA,QACzD,CAAE,KAAK,CAAE,MAAM,KAAM,MAAO;AAE3B,cAAK,CAAE,oBAAoB,SAAU,IAAK,GAAI;AAC7C,mBAAO;AAAA,UACR;AACA,cAAK,IAAK,IACT,SAAS,aAAa,iBAAkB,KAAM,IAAI;AACnD,iBAAO;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACF;AAGA,UAAK,OAAO,KAAM,WAAY,EAAE,SAAS,GAAI;AAC5C,8BAAsB,WAAW;AAAA,MAClC;AAAA,IACD;AAAA,EACD;AAEA,MAAK,OAAO,KAAM,qBAAsB,EAAE,WAAW,GAAI;AACxD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -3,10 +3,16 @@
3
3
  "apiVersion": 3,
4
4
  "name": "core/breadcrumbs",
5
5
  "title": "Breadcrumbs",
6
+ "__experimental": true,
6
7
  "category": "theme",
7
- "description": "Display a breadcrumb trail only for Pages, or for hierarchical post types. The block is useful to insert in the Pages template.",
8
+ "description": "Display a breadcrumb trail for hierarchical post types or based on taxonomy terms.",
8
9
  "textdomain": "default",
9
10
  "attributes": {
11
+ "type": {
12
+ "type": "string",
13
+ "default": "auto",
14
+ "enum": [ "auto", "postWithTerms", "postWithAncestors" ]
15
+ },
10
16
  "separator": {
11
17
  "type": "string",
12
18
  "default": "/"
@@ -16,7 +22,7 @@
16
22
  "default": true
17
23
  }
18
24
  },
19
- "usesContext": [ "postId", "postType" ],
25
+ "usesContext": [ "postId", "postType", "templateSlug" ],
20
26
  "supports": {
21
27
  "html": false,
22
28
  "spacing": {
@@ -4,44 +4,110 @@ import { InspectorControls, useBlockProps } from "@wordpress/block-editor";
4
4
  import {
5
5
  ToggleControl,
6
6
  TextControl,
7
+ SelectControl,
7
8
  __experimentalToolsPanel as ToolsPanel,
8
- __experimentalToolsPanelItem as ToolsPanelItem
9
+ __experimentalToolsPanelItem as ToolsPanelItem,
10
+ Spinner
9
11
  } from "@wordpress/components";
10
12
  import { useSelect } from "@wordpress/data";
11
13
  import { store as coreStore } from "@wordpress/core-data";
12
- import { RawHTML } from "@wordpress/element";
14
+ import { useEffect, useState, RawHTML } from "@wordpress/element";
13
15
  import { useServerSideRender } from "@wordpress/server-side-render";
14
16
  import { useToolsPanelDropdownMenuProps } from "../utils/hooks";
15
17
  const separatorDefaultValue = "/";
18
+ const typeDefaultValue = "auto";
19
+ const BREADCRUMB_TYPES = {
20
+ auto: {
21
+ help: __(
22
+ "Try to automatically determine the best type of breadcrumb for the template."
23
+ )
24
+ },
25
+ postWithAncestors: {
26
+ help: __(
27
+ "Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types."
28
+ ),
29
+ placeholderItems: [__("Ancestor"), __("Parent")]
30
+ },
31
+ postWithTerms: {
32
+ help: __(
33
+ "Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical."
34
+ ),
35
+ placeholderItems: [__("Category")]
36
+ }
37
+ };
16
38
  function BreadcrumbEdit({
17
39
  attributes,
18
40
  setAttributes,
19
- context: { postId, postType }
41
+ context: { postId, postType, templateSlug }
20
42
  }) {
21
- const { separator, showHomeLink } = attributes;
22
- const isPostTypeHierarchical = useSelect(
43
+ const { separator, showHomeLink, type } = attributes;
44
+ const { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } = useSelect(
23
45
  (select) => {
24
46
  if (!postType) {
25
- return null;
47
+ return {};
48
+ }
49
+ const _post = select(coreStore).getEntityRecord(
50
+ "postType",
51
+ postType,
52
+ postId
53
+ );
54
+ const postTypeObject = select(coreStore).getPostType(postType);
55
+ const postTypeHasTaxonomies = postTypeObject && postTypeObject.taxonomies.length;
56
+ let taxonomies;
57
+ if (postTypeHasTaxonomies) {
58
+ taxonomies = select(coreStore).getTaxonomies({
59
+ type: postType,
60
+ per_page: -1
61
+ });
26
62
  }
27
- return select(coreStore).getPostType(postType)?.hierarchical;
63
+ return {
64
+ post: _post,
65
+ isPostTypeHierarchical: postTypeObject?.hierarchical,
66
+ hasTermsAssigned: _post && (taxonomies || []).filter(
67
+ ({ visibility }) => visibility?.publicly_queryable
68
+ ).some((taxonomy) => {
69
+ return !!_post[taxonomy.rest_base]?.length;
70
+ }),
71
+ isLoading: !_post || !postTypeObject || postTypeHasTaxonomies && !taxonomies
72
+ };
28
73
  },
29
- [postType]
74
+ [postType, postId]
30
75
  );
76
+ const [invalidationKey, setInvalidationKey] = useState(0);
77
+ useEffect(() => {
78
+ setInvalidationKey((c) => c + 1);
79
+ }, [post]);
31
80
  const blockProps = useBlockProps();
32
81
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
33
82
  const { content } = useServerSideRender({
34
83
  attributes,
35
84
  skipBlockSupportAttributes: true,
36
85
  block: "core/breadcrumbs",
37
- urlQueryArgs: { post_id: postId }
86
+ urlQueryArgs: { post_id: postId, invalidationKey }
38
87
  });
88
+ if (isLoading) {
89
+ return /* @__PURE__ */ jsx("div", { ...blockProps, children: /* @__PURE__ */ jsx(Spinner, {}) });
90
+ }
91
+ let breadcrumbsType;
92
+ const isSpecificSupportedTypeSet = [
93
+ "postWithAncestors",
94
+ "postWithTerms"
95
+ ].includes(type);
96
+ if (isSpecificSupportedTypeSet) {
97
+ breadcrumbsType = type;
98
+ } else {
99
+ breadcrumbsType = isPostTypeHierarchical ? "postWithAncestors" : "postWithTerms";
100
+ }
39
101
  let placeholder = null;
40
- if (!postId || !postType || !isPostTypeHierarchical) {
102
+ const showPlaceholder = !postId || !postType || // When `templateSlug` is set only show placeholder if the post type is not.
103
+ // This is needed because when we are showing the template in post editor we
104
+ // want to show the real breadcrumbs if we have the post type.
105
+ templateSlug && !postType || breadcrumbsType === "postWithAncestors" && !isPostTypeHierarchical || breadcrumbsType === "postWithTerms" && !hasTermsAssigned;
106
+ if (showPlaceholder) {
41
107
  const placeholderItems = [
42
108
  showHomeLink && __("Home"),
43
- __("Ancestor"),
44
- __("Parent")
109
+ // For now if we are adding this in a template show a generic placeholder.
110
+ ...templateSlug && !isSpecificSupportedTypeSet ? [__("Page")] : BREADCRUMB_TYPES[breadcrumbsType].placeholderItems
45
111
  ].filter(Boolean);
46
112
  placeholder = /* @__PURE__ */ jsx(
47
113
  "nav",
@@ -65,11 +131,48 @@ function BreadcrumbEdit({
65
131
  resetAll: () => {
66
132
  setAttributes({
67
133
  separator: separatorDefaultValue,
68
- showHomeLink: true
134
+ showHomeLink: true,
135
+ type: typeDefaultValue
69
136
  });
70
137
  },
71
138
  dropdownMenuProps,
72
139
  children: [
140
+ /* @__PURE__ */ jsx(
141
+ ToolsPanelItem,
142
+ {
143
+ label: __("Type"),
144
+ isShownByDefault: true,
145
+ hasValue: () => type !== typeDefaultValue,
146
+ onDeselect: () => setAttributes({
147
+ type: typeDefaultValue
148
+ }),
149
+ children: /* @__PURE__ */ jsx(
150
+ SelectControl,
151
+ {
152
+ __nextHasNoMarginBottom: true,
153
+ __next40pxDefaultSize: true,
154
+ label: __("Type"),
155
+ value: type,
156
+ onChange: (value) => setAttributes({ type: value }),
157
+ options: [
158
+ {
159
+ label: __("Auto"),
160
+ value: "auto"
161
+ },
162
+ {
163
+ label: __("Post with ancestors"),
164
+ value: "postWithAncestors"
165
+ },
166
+ {
167
+ label: __("Post with terms"),
168
+ value: "postWithTerms"
169
+ }
170
+ ],
171
+ help: BREADCRUMB_TYPES[type].help
172
+ }
173
+ )
174
+ }
175
+ ),
73
176
  /* @__PURE__ */ jsx(
74
177
  ToolsPanelItem,
75
178
  {
@@ -122,7 +225,7 @@ function BreadcrumbEdit({
122
225
  ]
123
226
  }
124
227
  ) }),
125
- /* @__PURE__ */ jsx("div", { ...blockProps, children: placeholder || /* @__PURE__ */ jsx(RawHTML, { inert: "true", children: content }) })
228
+ /* @__PURE__ */ jsx("div", { ...blockProps, children: showPlaceholder ? placeholder : /* @__PURE__ */ jsx(RawHTML, { inert: "true", children: content }) })
126
229
  ] });
127
230
  }
128
231
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/breadcrumbs/edit.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { RawHTML } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nconst separatorDefaultValue = '/';\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType },\n} ) {\n\tconst { separator, showHomeLink } = attributes;\n\tconst isPostTypeHierarchical = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn select( coreStore ).getPostType( postType )?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { content } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: 'core/breadcrumbs',\n\t\turlQueryArgs: { post_id: postId },\n\t} );\n\tlet placeholder = null;\n\t// If no post context or the post type is not hierarchical, show placeholder.\n\t// This is fragile because this block is server side rendered and we'll have to\n\t// update the placeholder html if the server side rendering output changes.\n\tif ( ! postId || ! postType || ! isPostTypeHierarchical ) {\n\t\tconst placeholderItems = [\n\t\t\tshowHomeLink && __( 'Home' ),\n\t\t\t__( 'Ancestor' ),\n\t\t\t__( 'Parent' ),\n\t\t].filter( Boolean );\n\t\tplaceholder = (\n\t\t\t<nav\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--separator': `'${ separator }'`,\n\t\t\t\t} }\n\t\t\t\tinert=\"true\"\n\t\t\t>\n\t\t\t\t<ol>\n\t\t\t\t\t{ placeholderItems.map( ( text, index ) => (\n\t\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t\t<a href={ `#breadcrumbs-pseudo-link-${ index }` }>\n\t\t\t\t\t\t\t\t{ text }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<span aria-current=\"page\">{ __( 'Current' ) }</span>\n\t\t\t\t\t</li>\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showHomeLink }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHomeLink: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showHomeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => separator !== separatorDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\t\tvalue={ separator }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { separator: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\t\tif ( ! separator ) {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ placeholder || <RawHTML inert=\"true\">{ content }</RawHTML> }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": "AA8DI,SAgBF,UAbK,KAHH;AA3DJ,SAAS,UAAU;AACnB,SAAS,mBAAmB,qBAAqB;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,eAAe;AACxB,SAAS,2BAA2B;AAKpC,SAAS,sCAAsC;AAC/C,MAAM,wBAAwB;AAEf,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA,SAAS,EAAE,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;AAAA,cACA,OAAQ,GAAI,gBAAiB;AAAA,cAC7B,kBAAgB;AAAA,cAChB,UAAW,MAAM,CAAE;AAAA,cACnB,YAAa,MACZ,cAAe;AAAA,gBACd,cAAc;AAAA,cACf,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,OAAQ,GAAI,gBAAiB;AAAA,kBAC7B,UAAW,CAAE,UACZ,cAAe,EAAE,cAAc,MAAM,CAAE;AAAA,kBAExC,SAAU;AAAA;AAAA,cACX;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,OAAQ,GAAI,WAAY;AAAA,cACxB,kBAAgB;AAAA,cAChB,UAAW,MAAM,cAAc;AAAA,cAC/B,YAAa,MACZ,cAAe;AAAA,gBACd,WAAW;AAAA,cACZ,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,uBAAqB;AAAA,kBACrB,cAAa;AAAA,kBACb,OAAQ,GAAI,WAAY;AAAA,kBACxB,OAAQ;AAAA,kBACR,UAAW,CAAE,UACZ,cAAe,EAAE,WAAW,MAAM,CAAE;AAAA,kBAErC,QAAS,MAAM;AACd,wBAAK,CAAE,WAAY;AAClB,oCAAe;AAAA,wBACd,WAAW;AAAA,sBACZ,CAAE;AAAA,oBACH;AAAA,kBACD;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,oBAAC,SAAM,GAAG,YACP,yBAAe,oBAAC,WAAQ,OAAM,QAAS,mBAAS,GACnD;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState, RawHTML } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst separatorDefaultValue = '/';\nconst typeDefaultValue = 'auto';\n\nconst BREADCRUMB_TYPES = {\n\tauto: {\n\t\thelp: __(\n\t\t\t'Try to automatically determine the best type of breadcrumb for the template.'\n\t\t),\n\t},\n\tpostWithAncestors: {\n\t\thelp: __(\n\t\t\t'Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types.'\n\t\t),\n\t\tplaceholderItems: [ __( 'Ancestor' ), __( 'Parent' ) ],\n\t},\n\tpostWithTerms: {\n\t\thelp: __(\n\t\t\t'Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical.'\n\t\t),\n\t\tplaceholderItems: [ __( 'Category' ) ],\n\t},\n};\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType, templateSlug },\n} ) {\n\tconst { separator, showHomeLink, type } = attributes;\n\tconst { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! postType ) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\t\t\t\tconst _post = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t);\n\t\t\t\tconst postTypeObject =\n\t\t\t\t\tselect( coreStore ).getPostType( postType );\n\t\t\t\tconst postTypeHasTaxonomies =\n\t\t\t\t\tpostTypeObject && postTypeObject.taxonomies.length;\n\t\t\t\tlet taxonomies;\n\t\t\t\tif ( postTypeHasTaxonomies ) {\n\t\t\t\t\ttaxonomies = select( coreStore ).getTaxonomies( {\n\t\t\t\t\t\ttype: postType,\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tpost: _post,\n\t\t\t\t\tisPostTypeHierarchical: postTypeObject?.hierarchical,\n\t\t\t\t\thasTermsAssigned:\n\t\t\t\t\t\t_post &&\n\t\t\t\t\t\t( taxonomies || [] )\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t( { visibility } ) =>\n\t\t\t\t\t\t\t\t\tvisibility?.publicly_queryable\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.some( ( taxonomy ) => {\n\t\t\t\t\t\t\t\treturn !! _post[ taxonomy.rest_base ]?.length;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\tisLoading:\n\t\t\t\t\t\t! _post ||\n\t\t\t\t\t\t! postTypeObject ||\n\t\t\t\t\t\t( postTypeHasTaxonomies && ! taxonomies ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ postType, postId ]\n\t\t);\n\n\t// Counter used to cache-bust `useServerSideRender`\n\t//\n\t// This is a catch-all signal to re-render the block when a post's title,\n\t// parent ID, or terms change.\n\t//\n\t// This is fundamentally imperfect, because there are other entities which\n\t// could change in the meantime (the titles of ancestor posts, or the\n\t// labels of taxonomy terms), hence the choice to re-render systematically\n\t// upon saving.\n\tconst [ invalidationKey, setInvalidationKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tsetInvalidationKey( ( c ) => c + 1 );\n\t}, [ post ] );\n\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { content } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: 'core/breadcrumbs',\n\t\turlQueryArgs: { post_id: postId, invalidationKey },\n\t} );\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\t// TODO: this should be handled better when we add more types.\n\tlet breadcrumbsType;\n\tconst isSpecificSupportedTypeSet = [\n\t\t'postWithAncestors',\n\t\t'postWithTerms',\n\t].includes( type );\n\tif ( isSpecificSupportedTypeSet ) {\n\t\tbreadcrumbsType = type;\n\t} else {\n\t\tbreadcrumbsType = isPostTypeHierarchical\n\t\t\t? 'postWithAncestors'\n\t\t\t: 'postWithTerms';\n\t}\n\tlet placeholder = null;\n\t// This is fragile because this block is server side rendered and we'll have to\n\t// update the placeholder html if the server side rendering output changes.\n\tconst showPlaceholder =\n\t\t! postId ||\n\t\t! postType ||\n\t\t// When `templateSlug` is set only show placeholder if the post type is not.\n\t\t// This is needed because when we are showing the template in post editor we\n\t\t// want to show the real breadcrumbs if we have the post type.\n\t\t( templateSlug && ! postType ) ||\n\t\t( breadcrumbsType === 'postWithAncestors' &&\n\t\t\t! isPostTypeHierarchical ) ||\n\t\t( breadcrumbsType === 'postWithTerms' && ! hasTermsAssigned );\n\tif ( showPlaceholder ) {\n\t\tconst placeholderItems = [\n\t\t\tshowHomeLink && __( 'Home' ),\n\t\t\t// For now if we are adding this in a template show a generic placeholder.\n\t\t\t...( templateSlug && ! isSpecificSupportedTypeSet\n\t\t\t\t? [ __( 'Page' ) ]\n\t\t\t\t: BREADCRUMB_TYPES[ breadcrumbsType ].placeholderItems ),\n\t\t].filter( Boolean );\n\t\tplaceholder = (\n\t\t\t<nav\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--separator': `'${ separator }'`,\n\t\t\t\t} }\n\t\t\t\tinert=\"true\"\n\t\t\t>\n\t\t\t\t<ol>\n\t\t\t\t\t{ placeholderItems.map( ( text, index ) => (\n\t\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t\t<a href={ `#breadcrumbs-pseudo-link-${ index }` }>\n\t\t\t\t\t\t\t\t{ text }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<span aria-current=\"page\">{ __( 'Current' ) }</span>\n\t\t\t\t\t</li>\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\ttype: typeDefaultValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Type' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => type !== typeDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\ttype: typeDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Type' ) }\n\t\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { type: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Auto' ),\n\t\t\t\t\t\t\t\t\tvalue: 'auto',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Post with ancestors' ),\n\t\t\t\t\t\t\t\t\tvalue: 'postWithAncestors',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Post with terms' ),\n\t\t\t\t\t\t\t\t\tvalue: 'postWithTerms',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thelp={ BREADCRUMB_TYPES[ type ].help }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showHomeLink }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHomeLink: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showHomeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => separator !== separatorDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\t\tvalue={ separator }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { separator: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\t\tif ( ! separator ) {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ showPlaceholder ? (\n\t\t\t\t\tplaceholder\n\t\t\t\t) : (\n\t\t\t\t\t<RawHTML inert=\"true\">{ content }</RawHTML>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": "AA0HI,SA6DF,UA7DE,KA6CA,YA7CA;AAvHJ,SAAS,UAAU;AACnB,SAAS,mBAAmB,qBAAqB;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC;AAAA,OACM;AACP,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,WAAW,UAAU,eAAe;AAC7C,SAAS,2BAA2B;AAKpC,SAAS,sCAAsC;AAE/C,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,IACL,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD;AAAA,EACA,mBAAmB;AAAA,IAClB,MAAM;AAAA,MACL;AAAA,IACD;AAAA,IACA,kBAAkB,CAAE,GAAI,UAAW,GAAG,GAAI,QAAS,CAAE;AAAA,EACtD;AAAA,EACA,eAAe;AAAA,IACd,MAAM;AAAA,MACL;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AAAA,cAChB,UAAW,MAAM,cAAc;AAAA,cAC/B,YAAa,MACZ,cAAe;AAAA,gBACd,WAAW;AAAA,cACZ,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,uBAAqB;AAAA,kBACrB,cAAa;AAAA,kBACb,OAAQ,GAAI,WAAY;AAAA,kBACxB,OAAQ;AAAA,kBACR,UAAW,CAAE,UACZ,cAAe,EAAE,WAAW,MAAM,CAAE;AAAA,kBAErC,QAAS,MAAM;AACd,wBAAK,CAAE,WAAY;AAClB,oCAAe;AAAA,wBACd,WAAW;AAAA,sBACZ,CAAE;AAAA,oBACH;AAAA,kBACD;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,oBAAC,SAAM,GAAG,YACP,4BACD,cAEA,oBAAC,WAAQ,OAAM,QAAS,mBAAS,GAEnC;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { createBlock } from "@wordpress/blocks";
2
2
  import { __unstableCreateElement as createElement } from "@wordpress/rich-text";
3
- import { getTransformedMetadata } from "../utils/get-transformed-metadata";
3
+ import { getTransformedAttributes } from "../utils/get-transformed-attributes";
4
4
  const transforms = {
5
5
  from: [
6
6
  {
@@ -33,21 +33,21 @@ const transforms = {
33
33
  {},
34
34
  // Loop the selected buttons.
35
35
  buttons.map((attributes) => {
36
- const { content, metadata } = attributes;
36
+ const { content } = attributes;
37
37
  const element = createElement(document, content);
38
38
  const text = element.innerText || "";
39
39
  const link = element.querySelector("a");
40
40
  const url = link?.getAttribute("href");
41
41
  return createBlock("core/button", {
42
- text,
43
- url,
44
- metadata: getTransformedMetadata(
45
- metadata,
42
+ ...getTransformedAttributes(
43
+ attributes,
46
44
  "core/button",
47
45
  ({ content: contentBinding }) => ({
48
46
  text: contentBinding
49
47
  })
50
- )
48
+ ),
49
+ text,
50
+ url
51
51
  });
52
52
  })
53
53
  )
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/buttons/transforms.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedMetadata } from '../utils/get-transformed-metadata';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/button' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) =>\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\tcreateBlock( 'core/button', attributes )\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) => {\n\t\t\t\t\t\tconst { content, metadata } = attributes;\n\t\t\t\t\t\tconst element = createElement( document, content );\n\t\t\t\t\t\t// Remove any HTML tags.\n\t\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\t\t// Get first url.\n\t\t\t\t\t\tconst link = element.querySelector( 'a' );\n\t\t\t\t\t\tconst url = link?.getAttribute( 'href' );\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\treturn createBlock( 'core/button', {\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tmetadata: getTransformedMetadata(\n\t\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\t\t'core/button',\n\t\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\t\ttext: contentBinding,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )\n\t\t\t\t),\n\t\t\tisMatch: ( paragraphs ) => {\n\t\t\t\treturn paragraphs.every( ( attributes ) => {\n\t\t\t\t\tconst element = createElement(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tattributes.content\n\t\t\t\t\t);\n\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\tconst links = element.querySelectorAll( 'a' );\n\t\t\t\t\treturn text.length <= 30 && links.length <= 1;\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
5
- "mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,qBAAqB;AAKzD,SAAS,8BAA8B;AAEvC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,aAAc;AAAA,MACxB,WAAW,CAAE;AAAA;AAAA,QAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ;AAAA,YAAK,CAAE;AAAA;AAAA,cAEd,YAAa,eAAe,UAAW;AAAA;AAAA,UACxC;AAAA,QACD;AAAA;AAAA,IACF;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE;AAAA;AAAA,QAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ,IAAK,CAAE,eAAgB;AAC9B,kBAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,kBAAM,UAAU,cAAe,UAAU,OAAQ;AAEjD,kBAAM,OAAO,QAAQ,aAAa;AAElC,kBAAM,OAAO,QAAQ,cAAe,GAAI;AACxC,kBAAM,MAAM,MAAM,aAAc,MAAO;AAEvC,mBAAO,YAAa,eAAe;AAAA,cAClC;AAAA,cACA;AAAA,cACA,UAAU;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA,CAAE,EAAE,SAAS,eAAe,OAAS;AAAA,kBACpC,MAAM;AAAA,gBACP;AAAA,cACD;AAAA,YACD,CAAE;AAAA,UACH,CAAE;AAAA,QACH;AAAA;AAAA,MACD,SAAS,CAAE,eAAgB;AAC1B,eAAO,WAAW,MAAO,CAAE,eAAgB;AAC1C,gBAAM,UAAU;AAAA,YACf;AAAA,YACA,WAAW;AAAA,UACZ;AACA,gBAAM,OAAO,QAAQ,aAAa;AAClC,gBAAM,QAAQ,QAAQ,iBAAkB,GAAI;AAC5C,iBAAO,KAAK,UAAU,MAAM,MAAM,UAAU;AAAA,QAC7C,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/button' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) =>\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\tcreateBlock( 'core/button', attributes )\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) => {\n\t\t\t\t\t\tconst { content } = attributes;\n\t\t\t\t\t\tconst element = createElement( document, content );\n\t\t\t\t\t\t// Remove any HTML tags.\n\t\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\t\t// Get first url.\n\t\t\t\t\t\tconst link = element.querySelector( 'a' );\n\t\t\t\t\t\tconst url = link?.getAttribute( 'href' );\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\treturn createBlock( 'core/button', {\n\t\t\t\t\t\t\t...getTransformedAttributes(\n\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\t'core/button',\n\t\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\t\ttext: contentBinding,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )\n\t\t\t\t),\n\t\t\tisMatch: ( paragraphs ) => {\n\t\t\t\treturn paragraphs.every( ( attributes ) => {\n\t\t\t\t\tconst element = createElement(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tattributes.content\n\t\t\t\t\t);\n\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\tconst links = element.querySelectorAll( 'a' );\n\t\t\t\t\treturn text.length <= 30 && links.length <= 1;\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
5
+ "mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,qBAAqB;AAKzD,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC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wordpress/blocks";
2
2
  import { create, toHTMLString } from "@wordpress/rich-text";
3
- import { getTransformedMetadata } from "../utils/get-transformed-metadata";
3
+ import { getTransformedAttributes } from "../utils/get-transformed-attributes";
4
4
  const transforms = {
5
5
  from: [
6
6
  {
@@ -11,20 +11,24 @@ const transforms = {
11
11
  {
12
12
  type: "block",
13
13
  blocks: ["core/paragraph"],
14
- transform: ({ content, metadata }) => createBlock("core/code", {
15
- content,
16
- metadata: getTransformedMetadata(metadata, "core/code")
17
- })
14
+ transform: (attributes) => {
15
+ const { content } = attributes;
16
+ return createBlock("core/code", {
17
+ ...getTransformedAttributes(attributes, "core/code"),
18
+ content
19
+ });
20
+ }
18
21
  },
19
22
  {
20
23
  type: "block",
21
24
  blocks: ["core/html"],
22
- transform: ({ content: text, metadata }) => {
25
+ transform: (attributes) => {
26
+ const { content: text } = attributes;
23
27
  return createBlock("core/code", {
28
+ ...getTransformedAttributes(attributes, "core/code"),
24
29
  // The HTML is plain text (with plain line breaks), so
25
30
  // convert it to rich text.
26
- content: toHTMLString({ value: create({ text }) }),
27
- metadata: getTransformedMetadata(metadata, "core/code")
31
+ content: toHTMLString({ value: create({ text }) })
28
32
  });
29
33
  }
30
34
  },
@@ -48,13 +52,13 @@ const transforms = {
48
52
  {
49
53
  type: "block",
50
54
  blocks: ["core/paragraph"],
51
- transform: ({ content, metadata }) => createBlock("core/paragraph", {
52
- content,
53
- metadata: getTransformedMetadata(
54
- metadata,
55
- "core/paragraph"
56
- )
57
- })
55
+ transform: (attributes) => {
56
+ const { content } = attributes;
57
+ return createBlock("core/paragraph", {
58
+ ...getTransformedAttributes(attributes, "core/paragraph"),
59
+ content
60
+ });
61
+ }
58
62
  }
59
63
  ]
60
64
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code/transforms.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedMetadata } from '../utils/get-transformed-metadata';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'enter',\n\t\t\tregExp: /^```$/,\n\t\t\ttransform: () => createBlock( 'core/code' ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { content, metadata } ) =>\n\t\t\t\tcreateBlock( 'core/code', {\n\t\t\t\t\tcontent,\n\t\t\t\t\tmetadata: getTransformedMetadata( metadata, 'core/code' ),\n\t\t\t\t} ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/html' ],\n\t\t\ttransform: ( { content: text, metadata } ) => {\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t// The HTML is plain text (with plain line breaks), so\n\t\t\t\t\t// convert it to rich text.\n\t\t\t\t\tcontent: toHTMLString( { value: create( { text } ) } ),\n\t\t\t\t\tmetadata: getTransformedMetadata( metadata, 'core/code' ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'PRE' &&\n\t\t\t\tnode.children.length === 1 &&\n\t\t\t\tnode.firstChild.nodeName === 'CODE',\n\t\t\tschema: {\n\t\t\t\tpre: {\n\t\t\t\t\tchildren: {\n\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\tchildren: {\n\t\t\t\t\t\t\t\t'#text': {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { content, metadata } ) =>\n\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\tcontent,\n\t\t\t\t\tmetadata: getTransformedMetadata(\n\t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AE,EAAE,SAAS,SAAS,MAChC,YAAa,kBAAkB;AAAA,QAC9B;AAAA,QACA,UAAU;AAAA,UACT;AAAA,UACA;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACJ;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'enter',\n\t\t\tregExp: /^```$/,\n\t\t\ttransform: () => createBlock( 'core/code' ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content } = attributes;\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/code' ),\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/html' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content: text } = attributes;\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/code' ),\n\t\t\t\t\t// The HTML is plain text (with plain line breaks), so\n\t\t\t\t\t// convert it to rich text.\n\t\t\t\t\tcontent: toHTMLString( { value: create( { text } ) } ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'PRE' &&\n\t\t\t\tnode.children.length === 1 &&\n\t\t\t\tnode.firstChild.nodeName === 'CODE',\n\t\t\tschema: {\n\t\t\t\tpre: {\n\t\t\t\t\tchildren: {\n\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\tchildren: {\n\t\t\t\t\t\t\t\t'#text': {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content } = attributes;\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/paragraph' ),\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
5
+ "mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,oBAAoB;AAKrC,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW,MAAM,YAAa,WAAY;AAAA,IAC3C;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,QAAQ,IAAI;AACpB,eAAO,YAAa,aAAa;AAAA,UAChC,GAAG,yBAA0B,YAAY,WAAY;AAAA,UACrD;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,WAAY;AAAA,MACtB,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,SAAS,KAAK,IAAI;AAC1B,eAAO,YAAa,aAAa;AAAA,UAChC,GAAG,yBAA0B,YAAY,WAAY;AAAA;AAAA;AAAA,UAGrD,SAAS,aAAc,EAAE,OAAO,OAAQ,EAAE,KAAK,CAAE,EAAE,CAAE;AAAA,QACtD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAE,SACV,KAAK,aAAa,SAClB,KAAK,SAAS,WAAW,KACzB,KAAK,WAAW,aAAa;AAAA,MAC9B,QAAQ;AAAA,QACP,KAAK;AAAA,UACJ,UAAU;AAAA,YACT,MAAM;AAAA,cACL,UAAU;AAAA,gBACT,SAAS,CAAC;AAAA,cACX;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,IAAI;AAAA,IACH;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,QAAQ,IAAI;AACpB,eAAO,YAAa,kBAAkB;AAAA,UACrC,GAAG,yBAA0B,YAAY,gBAAiB;AAAA,UAC1D;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
6
6
  "names": []
7
7
  }
@@ -6,7 +6,6 @@ import edit from "./edit";
6
6
  import metadata from "./block.json";
7
7
  import save from "./save";
8
8
  import transforms from "./transforms";
9
- import variations from "./variations";
10
9
  const { name } = metadata;
11
10
  const settings = {
12
11
  icon,
@@ -45,8 +44,7 @@ const settings = {
45
44
  };
46
45
  },
47
46
  edit,
48
- save,
49
- variations
47
+ save
50
48
  };
51
49
  const init = () => initBlock({ name, metadata, settings });
52
50
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/heading/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t\ttextAlign: 'center',\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! hasContent\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
5
- "mappings": "AAGA,SAAS,WAAW,YAAY;AAChC,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AAEvB,MAAM,EAAE,KAAK,IAAI;AAIV,MAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS,GAAI,gBAAiB;AAAA,MAC9B,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,CAAE,aACN;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,MACA,IACA;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,QACA;AAAA,MACA;AAAA,IACJ;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\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\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t\ttextAlign: 'center',\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! hasContent\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
5
+ "mappings": "AAGA,SAAS,WAAW,YAAY;AAChC,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AAEvB,MAAM,EAAE,KAAK,IAAI;AAIV,MAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS,GAAI,gBAAiB;AAAA,MAC9B,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,CAAE,aACN;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,MACA,IACA;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,QACA;AAAA,MACA;AAAA,IACJ;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
6
6
  "names": []
7
7
  }
@@ -1,26 +1,27 @@
1
1
  import { createBlock, getBlockAttributes } from "@wordpress/blocks";
2
2
  import { getLevelFromHeadingNodeName } from "./shared";
3
- import { getTransformedMetadata } from "../utils/get-transformed-metadata";
3
+ import { getTransformedAttributes } from "../utils/get-transformed-attributes";
4
4
  const transforms = {
5
5
  from: [
6
6
  {
7
7
  type: "block",
8
8
  isMultiBlock: true,
9
9
  blocks: ["core/paragraph"],
10
- transform: (attributes) => attributes.map(
11
- ({ content, anchor, align: textAlign, metadata }) => createBlock("core/heading", {
12
- content,
13
- anchor,
14
- textAlign,
15
- metadata: getTransformedMetadata(
16
- metadata,
10
+ transform: (attributes) => attributes.map((_attributes) => {
11
+ const { content, anchor, align: textAlign } = _attributes;
12
+ return createBlock("core/heading", {
13
+ ...getTransformedAttributes(
14
+ _attributes,
17
15
  "core/heading",
18
16
  ({ content: contentBinding }) => ({
19
17
  content: contentBinding
20
18
  })
21
- )
22
- })
23
- )
19
+ ),
20
+ content,
21
+ anchor,
22
+ textAlign
23
+ });
24
+ })
24
25
  },
25
26
  {
26
27
  type: "raw",
@@ -73,19 +74,20 @@ const transforms = {
73
74
  type: "block",
74
75
  isMultiBlock: true,
75
76
  blocks: ["core/paragraph"],
76
- transform: (attributes) => attributes.map(
77
- ({ content, textAlign: align, metadata }) => createBlock("core/paragraph", {
78
- content,
79
- align,
80
- metadata: getTransformedMetadata(
81
- metadata,
77
+ transform: (attributes) => attributes.map((_attributes) => {
78
+ const { content, textAlign: align } = _attributes;
79
+ return createBlock("core/paragraph", {
80
+ ...getTransformedAttributes(
81
+ _attributes,
82
82
  "core/paragraph",
83
83
  ({ content: contentBinding }) => ({
84
84
  content: contentBinding
85
85
  })
86
- )
87
- })
88
- )
86
+ ),
87
+ content,
88
+ align
89
+ });
90
+ })
89
91
  }
90
92
  ]
91
93
  };