@wordpress/block-library 7.14.4 → 7.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/build/comment-template/edit.js +40 -32
  2. package/build/comment-template/edit.js.map +1 -1
  3. package/build/comments-title/edit.js +18 -1
  4. package/build/comments-title/edit.js.map +1 -1
  5. package/build/group/edit.js +1 -1
  6. package/build/group/edit.js.map +1 -1
  7. package/build/list/transforms.js +9 -1
  8. package/build/list/transforms.js.map +1 -1
  9. package/build/list-item/edit.js +3 -2
  10. package/build/list-item/edit.js.map +1 -1
  11. package/build/list-item/hooks/use-merge.js +5 -21
  12. package/build/list-item/hooks/use-merge.js.map +1 -1
  13. package/build/navigation/index.js +0 -1
  14. package/build/navigation/index.js.map +1 -1
  15. package/build/page-list/index.js +1 -5
  16. package/build/page-list/index.js.map +1 -1
  17. package/build/search/edit.js +2 -1
  18. package/build/search/edit.js.map +1 -1
  19. package/build-module/comment-template/edit.js +38 -30
  20. package/build-module/comment-template/edit.js.map +1 -1
  21. package/build-module/comments-title/edit.js +18 -2
  22. package/build-module/comments-title/edit.js.map +1 -1
  23. package/build-module/group/edit.js +1 -1
  24. package/build-module/group/edit.js.map +1 -1
  25. package/build-module/list/transforms.js +9 -1
  26. package/build-module/list/transforms.js.map +1 -1
  27. package/build-module/list-item/edit.js +3 -2
  28. package/build-module/list-item/edit.js.map +1 -1
  29. package/build-module/list-item/hooks/use-merge.js +5 -20
  30. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  31. package/build-module/navigation/index.js +0 -1
  32. package/build-module/navigation/index.js.map +1 -1
  33. package/build-module/page-list/index.js +1 -5
  34. package/build-module/page-list/index.js.map +1 -1
  35. package/build-module/search/edit.js +3 -2
  36. package/build-module/search/edit.js.map +1 -1
  37. package/package.json +6 -6
  38. package/src/comment-author-name/index.php +1 -1
  39. package/src/comment-template/edit.js +47 -34
  40. package/src/comments-title/edit.js +24 -1
  41. package/src/group/edit.js +1 -1
  42. package/src/list/transforms.js +11 -0
  43. package/src/list-item/edit.js +2 -1
  44. package/src/list-item/hooks/use-merge.js +4 -23
  45. package/src/navigation/block.json +0 -1
  46. package/src/navigation/index.php +0 -3
  47. package/src/navigation-link/index.php +8 -1
  48. package/src/navigation-submenu/index.php +8 -1
  49. package/src/page-list/block.json +1 -5
  50. package/src/page-list/index.php +8 -6
  51. package/src/search/edit.js +6 -1
  52. package/src/search/index.php +16 -8
  53. package/src/template-part/index.php +4 -0
@@ -40,6 +40,7 @@ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-
40
40
  *
41
41
  * @param {Object} settings Discussion Settings.
42
42
  * @param {number} [settings.perPage] - Comments per page setting or block attribute.
43
+ * @param {boolean} [settings.pageComments] - Enable break comments into pages setting.
43
44
  * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
44
45
  * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.
45
46
  *
@@ -50,44 +51,49 @@ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-
50
51
  const getCommentsPlaceholder = _ref => {
51
52
  let {
52
53
  perPage,
54
+ pageComments,
53
55
  threadComments,
54
56
  threadCommentsDepth
55
57
  } = _ref;
56
- // In case that `threadCommentsDepth` is falsy, we default to a somewhat
57
- // arbitrary value of 3.
58
- // In case that the value is set but larger than 3 we truncate it to 3.
59
- const commentsDepth = Math.min(threadCommentsDepth || 3, 3); // We set a limit in order not to overload the editor of empty comments.
60
-
61
- const defaultCommentsToShow = perPage <= commentsDepth ? perPage : commentsDepth;
62
-
63
- if (!threadComments || defaultCommentsToShow === 1) {
64
- // If displaying threaded comments is disabled, we only show one comment
65
- // A commentId is negative in order to avoid conflicts with the actual comments.
66
- return [{
67
- commentId: -1,
68
- children: []
69
- }];
70
- } else if (defaultCommentsToShow === 2) {
71
- return [{
72
- commentId: -1,
73
- children: [{
74
- commentId: -2,
75
- children: []
76
- }]
77
- }];
78
- } // In case that the value is set but larger than 3 we truncate it to 3.
58
+ // Limit commentsDepth to 3
59
+ const commentsDepth = !threadComments ? 1 : Math.min(threadCommentsDepth, 3);
60
+
61
+ const buildChildrenComment = commentsLevel => {
62
+ // Render children comments until commentsDepth is reached
63
+ if (commentsLevel < commentsDepth) {
64
+ const nextLevel = commentsLevel + 1;
65
+ return [{
66
+ commentId: -(commentsLevel + 3),
67
+ children: buildChildrenComment(nextLevel)
68
+ }];
69
+ }
70
+
71
+ return [];
72
+ }; // Add the first comment and its children
79
73
 
80
74
 
81
- return [{
75
+ const placeholderComments = [{
82
76
  commentId: -1,
83
- children: [{
77
+ children: buildChildrenComment(1)
78
+ }]; // Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max
79
+
80
+ if ((!pageComments || perPage >= 2) && commentsDepth < 3) {
81
+ placeholderComments.push({
84
82
  commentId: -2,
85
- children: [{
86
- commentId: -3,
87
- children: []
88
- }]
89
- }]
90
- }];
83
+ children: []
84
+ });
85
+ } // Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments
86
+
87
+
88
+ if ((!pageComments || perPage >= 3) && commentsDepth < 2) {
89
+ placeholderComments.push({
90
+ commentId: -3,
91
+ children: []
92
+ });
93
+ } // In case that the value is set but larger than 3 we truncate it to 3.
94
+
95
+
96
+ return placeholderComments;
91
97
  };
92
98
  /**
93
99
  * Component which renders the inner blocks of the Comment Template.
@@ -232,7 +238,8 @@ function CommentTemplateEdit(_ref6) {
232
238
  commentOrder,
233
239
  threadCommentsDepth,
234
240
  threadComments,
235
- commentsPerPage
241
+ commentsPerPage,
242
+ pageComments
236
243
  } = (0, _data.useSelect)(select => {
237
244
  const {
238
245
  getSettings
@@ -269,6 +276,7 @@ function CommentTemplateEdit(_ref6) {
269
276
  if (!postId) {
270
277
  commentTree = getCommentsPlaceholder({
271
278
  perPage: commentsPerPage,
279
+ pageComments,
272
280
  threadComments,
273
281
  threadCommentsDepth
274
282
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAIxB;AAAA,MAJ0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,cAFgC;AAGhCC,IAAAA;AAHgC,GAI1B;AACN;AACA;AACA;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,GAAL,CAAUH,mBAAmB,IAAI,CAAjC,EAAoC,CAApC,CAAtB,CAJM,CAMN;;AACA,QAAMI,qBAAqB,GAC1BN,OAAO,IAAIG,aAAX,GAA2BH,OAA3B,GAAqCG,aADtC;;AAEA,MAAK,CAAEF,cAAF,IAAoBK,qBAAqB,KAAK,CAAnD,EAAuD;AACtD;AACA;AACA,WAAO,CAAE;AAAEC,MAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,MAAAA,QAAQ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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }>{ __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","pageComments","threadComments","threadCommentsDepth","commentsDepth","Math","min","buildChildrenComment","commentsLevel","nextLevel","commentId","children","placeholderComments","push","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAKxB;AAAA,MAL0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,YAFgC;AAGhCC,IAAAA,cAHgC;AAIhCC,IAAAA;AAJgC,GAK1B;AACN;AACA,QAAMC,aAAa,GAAG,CAAEF,cAAF,GACnB,CADmB,GAEnBG,IAAI,CAACC,GAAL,CAAUH,mBAAV,EAA+B,CAA/B,CAFH;;AAIA,QAAMI,oBAAoB,GAAKC,aAAF,IAAqB;AACjD;AACA,QAAKA,aAAa,GAAGJ,aAArB,EAAqC;AACpC,YAAMK,SAAS,GAAGD,aAAa,GAAG,CAAlC;AAEA,aAAO,CACN;AACCE,QAAAA,SAAS,EAAE,EAAGF,aAAa,GAAG,CAAnB,CADZ;AAECG,QAAAA,QAAQ,EAAEJ,oBAAoB,CAAEE,SAAF;AAF/B,OADM,CAAP;AAMA;;AACD,WAAO,EAAP;AACA,GAbD,CANM,CAqBN;;;AACA,QAAMG,mBAAmB,GAAG,CAC3B;AAAEF,IAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,IAAAA,QAAQ,E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,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBzC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.pageComments] - Enable break comments into pages setting.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tpageComments,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// Limit commentsDepth to 3\n\tconst commentsDepth = ! threadComments\n\t\t? 1\n\t\t: Math.min( threadCommentsDepth, 3 );\n\n\tconst buildChildrenComment = ( commentsLevel ) => {\n\t\t// Render children comments until commentsDepth is reached\n\t\tif ( commentsLevel < commentsDepth ) {\n\t\t\tconst nextLevel = commentsLevel + 1;\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -( commentsLevel + 3 ),\n\t\t\t\t\tchildren: buildChildrenComment( nextLevel ),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t};\n\n\t// Add the first comment and its children\n\tconst placeholderComments = [\n\t\t{ commentId: -1, children: buildChildrenComment( 1 ) },\n\t];\n\n\t// Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max\n\tif ( ( ! pageComments || perPage >= 2 ) && commentsDepth < 3 ) {\n\t\tplaceholderComments.push( {\n\t\t\tcommentId: -2,\n\t\t\tchildren: [],\n\t\t} );\n\t}\n\n\t// Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments\n\tif ( ( ! pageComments || perPage >= 3 ) && commentsDepth < 2 ) {\n\t\tplaceholderComments.push( {\n\t\t\tcommentId: -3,\n\t\t\tchildren: [],\n\t\t} );\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn placeholderComments;\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\t is ALWAYS rendered and the preview for the active block is hidden.\n\t\t\t This ensures that when switching the active block, the component is not\n\t\t\t mounted again but rather it only toggles the `isHidden` prop.\n\t\t\t The same strategy is used for preventing the flicker in the Post Template\n\t\t\t block. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t\tpageComments,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tpageComments,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }>{ __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
@@ -19,6 +19,8 @@ var _coreData = require("@wordpress/core-data");
19
19
 
20
20
  var _components = require("@wordpress/components");
21
21
 
22
+ var _data = require("@wordpress/data");
23
+
22
24
  var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
23
25
 
24
26
  var _url = require("@wordpress/url");
@@ -59,9 +61,24 @@ function Edit(_ref) {
59
61
  [`has-text-align-${textAlign}`]: textAlign
60
62
  })
61
63
  });
64
+ const {
65
+ threadCommentsDepth,
66
+ threadComments,
67
+ commentsPerPage,
68
+ pageComments
69
+ } = (0, _data.useSelect)(select => {
70
+ const {
71
+ getSettings
72
+ } = select(_blockEditor.store);
73
+ return getSettings().__experimentalDiscussionSettings;
74
+ });
62
75
  (0, _element.useEffect)(() => {
63
76
  if (isSiteEditor) {
64
- setCommentsCount(3);
77
+ // Match the number of comments that will be shown in the comment-template/edit.js placeholder
78
+ const nestedCommentsNumber = threadComments ? Math.min(threadCommentsDepth, 3) - 1 : 0;
79
+ const topLevelCommentsNumber = pageComments ? commentsPerPage : 3;
80
+ const commentsNumber = parseInt(nestedCommentsNumber) + parseInt(topLevelCommentsNumber);
81
+ setCommentsCount(Math.min(commentsNumber, 3));
65
82
  return;
66
83
  }
67
84
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-title/edit.js"],"names":["Edit","attributes","textAlign","showPostTitle","showCommentsCount","level","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","rawTitle","isSiteEditor","blockProps","className","currentPostId","path","post","_fields","method","parse","then","res","parseInt","headers","get","catch","blockControls","newAlign","newLevel","inspectorControls","value","postTitle","placeholder","undefined"],"mappings":";;;;;;;;;AAiBA;;AAdA;;AAKA;;AAMA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AAGe,SAASA,IAAT,OAIX;AAAA,MAJ0B;AAC7BC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;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MAGO;AACNC,QAAAA,WAAW,GAAG;AACb;AACA,sBACC,uBADD,EAEC,wBAFD,EAGCxB,aAHD,CAFa,EAObA,aAPa,EAQbuB,SARa,CAAd;AAUA;AACD,KAhBD,MAgBO,IAAKvB,aAAa,KAAK,CAAvB,EAA2B;AACjCwB,MAAAA,WAAW,GAAG,cAAI,cAAJ,CAAd;AACA,KAFM,MAEA;AACNA,MAAAA,WAAW,GAAG;AACb;AACA,oBAAI,aAAJ,EAAmB,cAAnB,EAAmCxB,aAAnC,CAFa,EAGbA,aAHa,CAAd;AAKA;AACD,GA1BD,MA0BO,IAAKR,aAAL,EAAqB;AAC3B,QAAKQ,aAAa,KAAK,CAAvB,EAA2B;AAC1B;AACAwB,MAAAA,WAAW,GAAG,mBAAS,cAAI,gBAAJ,CAAT,EAAiCD,SAAjC,CAAd;AACA,KAHD,MAGO;AACN;AACAC,MAAAA,WAAW,GAAG,mBAAS,cAAI,iBAAJ,CAAT,EAAkCD,SAAlC,CAAd;AACA;AACD,GARM,MAQA,IAAKvB,aAAa,KAAK,CAAvB,EAA2B;AACjCwB,IAAAA,WAAW,GAAG,cAAI,UAAJ,CAAd;AACA,GAFM,MAEA;AACNA,IAAAA,WAAW,GAAG,cAAI,WAAJ,CAAd;AACA;;AAED,SACC,qDACGN,aADH,EAEGG,iBAFH,EAGC,4BAAC,OAAD,EAAcjB,UAAd,EAA6BoB,WAA7B,CAHD,CADD;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport HeadingLevelDropdown from '../heading/heading-level-dropdown';\n\nexport default function Edit( {\n\tattributes: { textAlign, showPostTitle, showCommentsCount, level },\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\tsetCommentsCount( 3 );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tselectedLevel={ level }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '\"Post Title\"' ) : `\"${ rawTitle }\"`;\n\n\tlet placeholder;\n\tif ( showCommentsCount && commentsCount !== undefined ) {\n\t\tif ( showPostTitle ) {\n\t\t\tif ( commentsCount === 1 ) {\n\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\tplaceholder = sprintf( __( 'One response to %s' ), postTitle );\n\t\t\t} else {\n\t\t\t\tplaceholder = sprintf(\n\t\t\t\t\t/* translators: 1: Number of comments, 2: Post title. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%1$s response to %2$s',\n\t\t\t\t\t\t'%1$s responses to %2$s',\n\t\t\t\t\t\tcommentsCount\n\t\t\t\t\t),\n\t\t\t\t\tcommentsCount,\n\t\t\t\t\tpostTitle\n\t\t\t\t);\n\t\t\t}\n\t\t} else if ( commentsCount === 1 ) {\n\t\t\tplaceholder = __( 'One response' );\n\t\t} else {\n\t\t\tplaceholder = sprintf(\n\t\t\t\t/* translators: %s: Number of comments. */\n\t\t\t\t_n( '%s response', '%s responses', commentsCount ),\n\t\t\t\tcommentsCount\n\t\t\t);\n\t\t}\n\t} else if ( showPostTitle ) {\n\t\tif ( commentsCount === 1 ) {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Response to %s' ), postTitle );\n\t\t} else {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Responses to %s' ), postTitle );\n\t\t}\n\t} else if ( commentsCount === 1 ) {\n\t\tplaceholder = __( 'Response' );\n\t} else {\n\t\tplaceholder = __( 'Responses' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>{ placeholder }</TagName>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-title/edit.js"],"names":["Edit","attributes","textAlign","showPostTitle","showCommentsCount","level","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","rawTitle","isSiteEditor","blockProps","className","threadCommentsDepth","threadComments","commentsPerPage","pageComments","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","nestedCommentsNumber","Math","min","topLevelCommentsNumber","commentsNumber","parseInt","currentPostId","path","post","_fields","method","parse","then","res","headers","get","catch","blockControls","newAlign","newLevel","inspectorControls","value","postTitle","placeholder","undefined"],"mappings":";;;;;;;;;AAkBA;;AAfA;;AAKA;;AAOA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAGe,SAASA,IAAT,OAIX;AAAA,MAJ0B;AAC7BC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;AAAaC,MAAAA,aAAb;AAA4BC,MAAAA,iBAA5B;AAA+CC,MAAAA;AAA/C,KADiB;AAE7BC,IAAAA,aAF6B;AAG7BC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ;AAHoB,GAI1B;AACH,QAAMC,OAAO,GAAG,MAAML,KAAtB;AACA,QAAM,CAAEM,aAAF,EAAiBC,gBAAjB,IAAsC,wBAA5C;AACA,QAAM,CAAEC,Q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A2B,IAAID,QAAU,GAAvE;AAEA,MAAImC,WAAJ;;AACA,MAAK5C,iBAAiB,IAAIO,aAAa,KAAKsC,SAA5C,EAAwD;AACvD,QAAK9C,aAAL,EAAqB;AACpB,UAAKQ,aAAa,KAAK,CAAvB,EAA2B;AAC1B;AACAqC,QAAAA,WAAW,GAAG,mBAAS,cAAI,oBAAJ,CAAT,EAAqCD,SAArC,CAAd;AACA,OAHD,MAGO;AACNC,QAAAA,WAAW,GAAG;AACb;AACA,sBACC,uBADD,EAEC,wBAFD,EAGCrC,aAHD,CAFa,EAObA,aAPa,EAQboC,SARa,CAAd;AAUA;AACD,KAhBD,MAgBO,IAAKpC,aAAa,KAAK,CAAvB,EAA2B;AACjCqC,MAAAA,WAAW,GAAG,cAAI,cAAJ,CAAd;AACA,KAFM,MAEA;AACNA,MAAAA,WAAW,GAAG;AACb;AACA,oBAAI,aAAJ,EAAmB,cAAnB,EAAmCrC,aAAnC,CAFa,EAGbA,aAHa,CAAd;AAKA;AACD,GA1BD,MA0BO,IAAKR,aAAL,EAAqB;AAC3B,QAAKQ,aAAa,KAAK,CAAvB,EAA2B;AAC1B;AACAqC,MAAAA,WAAW,GAAG,mBAAS,cAAI,gBAAJ,CAAT,EAAiCD,SAAjC,CAAd;AACA,KAHD,MAGO;AACN;AACAC,MAAAA,WAAW,GAAG,mBAAS,cAAI,iBAAJ,CAAT,EAAkCD,SAAlC,CAAd;AACA;AACD,GARM,MAQA,IAAKpC,aAAa,KAAK,CAAvB,EAA2B;AACjCqC,IAAAA,WAAW,GAAG,cAAI,UAAJ,CAAd;AACA,GAFM,MAEA;AACNA,IAAAA,WAAW,GAAG,cAAI,WAAJ,CAAd;AACA;;AAED,SACC,qDACGN,aADH,EAEGG,iBAFH,EAGC,4BAAC,OAAD,EAAc9B,UAAd,EAA6BiC,WAA7B,CAHD,CADD;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport HeadingLevelDropdown from '../heading/heading-level-dropdown';\n\nexport default function Edit( {\n\tattributes: { textAlign, showPostTitle, showCommentsCount, level },\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst {\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t\tpageComments,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\t// Match the number of comments that will be shown in the comment-template/edit.js placeholder\n\n\t\t\tconst nestedCommentsNumber = threadComments\n\t\t\t\t? Math.min( threadCommentsDepth, 3 ) - 1\n\t\t\t\t: 0;\n\t\t\tconst topLevelCommentsNumber = pageComments ? commentsPerPage : 3;\n\n\t\t\tconst commentsNumber =\n\t\t\t\tparseInt( nestedCommentsNumber ) +\n\t\t\t\tparseInt( topLevelCommentsNumber );\n\n\t\t\tsetCommentsCount( Math.min( commentsNumber, 3 ) );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tselectedLevel={ level }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '\"Post Title\"' ) : `\"${ rawTitle }\"`;\n\n\tlet placeholder;\n\tif ( showCommentsCount && commentsCount !== undefined ) {\n\t\tif ( showPostTitle ) {\n\t\t\tif ( commentsCount === 1 ) {\n\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\tplaceholder = sprintf( __( 'One response to %s' ), postTitle );\n\t\t\t} else {\n\t\t\t\tplaceholder = sprintf(\n\t\t\t\t\t/* translators: 1: Number of comments, 2: Post title. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%1$s response to %2$s',\n\t\t\t\t\t\t'%1$s responses to %2$s',\n\t\t\t\t\t\tcommentsCount\n\t\t\t\t\t),\n\t\t\t\t\tcommentsCount,\n\t\t\t\t\tpostTitle\n\t\t\t\t);\n\t\t\t}\n\t\t} else if ( commentsCount === 1 ) {\n\t\t\tplaceholder = __( 'One response' );\n\t\t} else {\n\t\t\tplaceholder = sprintf(\n\t\t\t\t/* translators: %s: Number of comments. */\n\t\t\t\t_n( '%s response', '%s responses', commentsCount ),\n\t\t\t\tcommentsCount\n\t\t\t);\n\t\t}\n\t} else if ( showPostTitle ) {\n\t\tif ( commentsCount === 1 ) {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Response to %s' ), postTitle );\n\t\t} else {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Responses to %s' ), postTitle );\n\t\t}\n\t} else if ( commentsCount === 1 ) {\n\t\tplaceholder = __( 'Response' );\n\t} else {\n\t\tplaceholder = __( 'Responses' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>{ placeholder }</TagName>\n\t\t</>\n\t);\n}\n"]}
@@ -64,7 +64,7 @@ function GroupEdit(_ref) {
64
64
  const {
65
65
  type = 'default'
66
66
  } = usedLayout;
67
- const layoutSupportEnabled = themeSupportsLayout || type !== 'default';
67
+ const layoutSupportEnabled = themeSupportsLayout || type === 'flex';
68
68
  const blockProps = (0, _blockEditor.useBlockProps)();
69
69
  const innerBlocksProps = (0, _blockEditor.useInnerBlocksProps)(layoutSupportEnabled ? blockProps : {
70
70
  className: 'wp-block-group__inner-container'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/group/edit.js"],"names":["htmlElementMessages","header","main","section","article","aside","footer","GroupEdit","attributes","setAttributes","clientId","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","blockEditorStore","block","innerBlocks","length","supportsLayout","defaultLayout","tagName","TagName","templateLock","layout","usedLayout","type","layoutSupportEnabled","blockProps","innerBlocksProps","className","renderAppender","undefined","InnerBlocks","ButtonBlockAppender","__experimentalLayout","label","value"],"mappings":";;;;;;;;;AAGA;;AAEA;;AAQA;;AACA;;AAdA;AACA;AACA;AAcA,MAAMA,mBAAmB,GAAG;AAC3BC,EAAAA,MAAM,EAAE,cACP,qHADO,CADmB;AAI3BC,EAAAA,IAAI,EAAE,cACL,mFADK,CAJqB;AAO3BC,EAAAA,OAAO,EAAE,cACR,kIADQ,CAPkB;AAU3BC,EAAAA,OAAO,EAAE,cACR,gGADQ,CAVkB;AAa3BC,EAAAA,KAAK,EAAE,cACN,uIADM,CAboB;AAgB3BC,EAAAA,MAAM,EAAE,cACP,8HADO;AAhBmB,CAA5B;;AAqBA,SAASC,SAAT,OAA8D;AAAA,MAA1C;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,aAAd;AAA6BC,IAAAA;AAA7B,GAA0C;AAC7D,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAA0C,qBAC7CC,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAA4BF,MAAM,CAAEG,kBAAF,CAAxC;AACA,UAAMC,KAAK,GAAGH,QAAQ,CAAEJ,QAAF,CAAtB;AACA,WAAO;AACNC,MAAAA,cA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,CAAT;AAAkCC,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,UAAT;AAAqBC,MAAAA,KAAK,EAAE;AAA5B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,QAAT;AAAmBC,MAAAA,KAAK,EAAE;AAA1B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAJS,EAKT;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KALS,EAMT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KANS,EAOT;AAAED,MAAAA,KAAK,EAAE,UAAT;AAAqBC,MAAAA,KAAK,EAAE;AAA5B,KAPS,CAFX;AAWC,IAAA,KAAK,EAAGf,OAXT;AAYC,IAAA,QAAQ,EAAKe,KAAF,IACV7B,aAAa,CAAE;AAAEa,MAAAA,OAAO,EAAEgB;AAAX,KAAF,CAbf;AAeC,IAAA,IAAI,EAAGtC,mBAAmB,CAAEuB,OAAF;AAf3B,IADD,CADD,EAoBGK,oBAAoB,IAAI,4BAAC,OAAD,EAAcE,gBAAd,CApB3B,EAuBG,CAAEF,oBAAF,IACD,4BAAC,OAAD,EAAcC,UAAd,EACC,mCAAUC,gBAAV,CADD,CAxBF,CADD;AA+BA;;eAEcvB,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst htmlElementMessages = {\n\theader: __(\n\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t),\n\tmain: __(\n\t\t'The <main> element should be used for the primary content of your document only. '\n\t),\n\tsection: __(\n\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t),\n\tarticle: __(\n\t\t'The <article> element should represent a self contained, syndicatable portion of the document.'\n\t),\n\taside: __(\n\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t),\n\tfooter: __(\n\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t),\n};\n\nfunction GroupEdit( { attributes, setAttributes, clientId } ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst { tagName: TagName = 'div', templateLock, layout = {} } = attributes;\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst { type = 'default' } = usedLayout;\n\tconst layoutSupportEnabled = themeSupportsLayout || type !== 'default';\n\n\tconst blockProps = useBlockProps();\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\trenderAppender: hasInnerBlocks\n\t\t\t\t? undefined\n\t\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t\t\t__experimentalLayout: layoutSupportEnabled ? usedLayout : undefined,\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ layoutSupportEnabled && <TagName { ...innerBlocksProps } /> }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/group/edit.js"],"names":["htmlElementMessages","header","main","section","article","aside","footer","GroupEdit","attributes","setAttributes","clientId","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","blockEditorStore","block","innerBlocks","length","supportsLayout","defaultLayout","tagName","TagName","templateLock","layout","usedLayout","type","layoutSupportEnabled","blockProps","innerBlocksProps","className","renderAppender","undefined","InnerBlocks","ButtonBlockAppender","__experimentalLayout","label","value"],"mappings":";;;;;;;;;AAGA;;AAEA;;AAQA;;AACA;;AAdA;AACA;AACA;AAcA,MAAMA,mBAAmB,GAAG;AAC3BC,EAAAA,MAAM,EAAE,cACP,qHADO,CADmB;AAI3BC,EAAAA,IAAI,EAAE,cACL,mFADK,CAJqB;AAO3BC,EAAAA,OAAO,EAAE,cAC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AF;AAf3B,IADD,CADD,EAoBGK,oBAAoB,IAAI,4BAAC,OAAD,EAAcE,gBAAd,CApB3B,EAuBG,CAAEF,oBAAF,IACD,4BAAC,OAAD,EAAcC,UAAd,EACC,mCAAUC,gBAAV,CADD,CAxBF,CADD;AA+BA;;eAEcvB,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst htmlElementMessages = {\n\theader: __(\n\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t),\n\tmain: __(\n\t\t'The <main> element should be used for the primary content of your document only. '\n\t),\n\tsection: __(\n\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t),\n\tarticle: __(\n\t\t'The <article> element should represent a self contained, syndicatable portion of the document.'\n\t),\n\taside: __(\n\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t),\n\tfooter: __(\n\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t),\n};\n\nfunction GroupEdit( { attributes, setAttributes, clientId } ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst { tagName: TagName = 'div', templateLock, layout = {} } = attributes;\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst { type = 'default' } = usedLayout;\n\tconst layoutSupportEnabled = themeSupportsLayout || type === 'flex';\n\n\tconst blockProps = useBlockProps();\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\trenderAppender: hasInnerBlocks\n\t\t\t\t? undefined\n\t\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t\t\t__experimentalLayout: layoutSupportEnabled ? usedLayout : undefined,\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ layoutSupportEnabled && <TagName { ...innerBlocksProps } /> }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"]}
@@ -130,7 +130,15 @@ const transforms = {
130
130
  content
131
131
  }));
132
132
  }
133
- }))]
133
+ })), {
134
+ type: 'block',
135
+ blocks: ['*'],
136
+ transform: (_attributes, childBlocks) => {
137
+ return getListContentFlat(childBlocks).map(content => (0, _blocks.createBlock)('core/paragraph', {
138
+ content
139
+ }));
140
+ }
141
+ }]
134
142
  };
135
143
  var _default = transforms;
136
144
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/transforms.js"],"names":["getListContentSchema","phrasingContentSchema","listContentSchema","ul","ol","attributes","forEach","tag","children","li","getListContentFlat","blocks","flatMap","name","innerBlocks","content","transforms","from","type","isMultiBlock","transform","blockAttributes","childBlocks","length","map","value","html","result","anchor","selector","schema","args","createListBlockFromDOMElement","prefix","ordered","to","block","_attributes"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,oBAAT,OAA2D;AAAA,MAA5B;AAAEC,IAAAA;AAAF,GAA4B;AAC1D,QAAMC,iBAAiB,GAAG,EACzB,GAAGD,qBADsB;AAEzBE,IAAAA,EAAE,EAAE,EAFqB;AAGzBC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,UAAU,EAAE,CAAE,MAAF,EAAU,OAAV,EAAmB,UAAnB;AAAd;AAHqB,GAA1B,CAD0D,CAO1D;AACA;AACA;;AACA,GAAE,IAAF,EAAQ,IAAR,EAAeC,OAAf,CAA0BC,GAAF,IAAW;AAClCL,IAAAA,iBAAiB,CAAEK,GAAF,CAAjB,CAAyBC,QAAzB,GAAoC;AACnCC,MAAAA,EAAE,EAAE;AACHD,QAAAA,QAAQ,EAAEN;AADP;AAD+B,KAApC;AAKA,GAND;AAQA,SAAOA,iBAAP;AACA;;AAED,SAASQ,kBAAT,CAA6BC,MAA7B,EAAsC;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAgB,SAA8C;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A,MAAM,EAAE,CAAEyB,KAAF,CAFmD;AAG3DhB,IAAAA,SAAS,EAAE,CAAEiB,WAAF,EAAef,WAAf,KAAgC;AAC1C,aAAOZ,kBAAkB,CAAEY,WAAF,CAAlB,CAAkCE,GAAlC,CAAyCT,OAAF,IAC7C,yBAAaqB,KAAb,EAAoB;AACnBrB,QAAAA;AADmB,OAApB,CADM,CAAP;AAKA;AAT0D,GAAf,CAA1C,CADA;AA/Dc,CAAnB;eA8EeC,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, split, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { createListBlockFromDOMElement } from './utils';\n\nfunction getListContentSchema( { phrasingContentSchema } ) {\n\tconst listContentSchema = {\n\t\t...phrasingContentSchema,\n\t\tul: {},\n\t\tol: { attributes: [ 'type', 'start', 'reversed' ] },\n\t};\n\n\t// Recursion is needed.\n\t// Possible: ul > li > ul.\n\t// Impossible: ul > ul.\n\t[ 'ul', 'ol' ].forEach( ( tag ) => {\n\t\tlistContentSchema[ tag ].children = {\n\t\t\tli: {\n\t\t\t\tchildren: listContentSchema,\n\t\t\t},\n\t\t};\n\t} );\n\n\treturn listContentSchema;\n}\n\nfunction getListContentFlat( blocks ) {\n\treturn blocks.flatMap( ( { name, attributes, innerBlocks = [] } ) => {\n\t\tif ( name === 'core/list-item' ) {\n\t\t\treturn [ attributes.content, ...getListContentFlat( innerBlocks ) ];\n\t\t}\n\t\treturn getListContentFlat( innerBlocks );\n\t} );\n}\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph', 'core/heading' ],\n\t\t\ttransform: ( blockAttributes ) => {\n\t\t\t\tlet childBlocks = [];\n\t\t\t\tif ( blockAttributes.length > 1 ) {\n\t\t\t\t\tchildBlocks = blockAttributes.map( ( { content } ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', { content } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( blockAttributes.length === 1 ) {\n\t\t\t\t\tconst value = create( {\n\t\t\t\t\t\thtml: blockAttributes[ 0 ].content,\n\t\t\t\t\t} );\n\t\t\t\t\tchildBlocks = split( value, '\\n' ).map( ( result ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\t\t\tcontent: toHTMLString( { value: result } ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tanchor: blockAttributes.anchor,\n\t\t\t\t\t},\n\t\t\t\t\tchildBlocks\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tselector: 'ol,ul',\n\t\t\tschema: ( args ) => ( {\n\t\t\t\tol: getListContentSchema( args ).ol,\n\t\t\t\tul: getListContentSchema( args ).ul,\n\t\t\t} ),\n\t\t\ttransform: createListBlockFromDOMElement,\n\t\t},\n\t\t...[ '*', '-' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock( 'core/list', {}, [\n\t\t\t\t\tcreateBlock( 'core/list-item', { content } ),\n\t\t\t\t] );\n\t\t\t},\n\t\t} ) ),\n\t\t...[ '1.', '1)' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tordered: true,\n\t\t\t\t\t},\n\t\t\t\t\t[ createBlock( 'core/list-item', { content } ) ]\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t],\n\tto: [\n\t\t...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {\n\t\t\ttype: 'block',\n\t\t\tblocks: [ block ],\n\t\t\ttransform: ( _attributes, childBlocks ) => {\n\t\t\t\treturn getListContentFlat( childBlocks ).map( ( content ) =>\n\t\t\t\t\tcreateBlock( block, {\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t],\n};\n\nexport default transforms;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list/transforms.js"],"names":["getListContentSchema","phrasingContentSchema","listContentSchema","ul","ol","attributes","forEach","tag","children","li","getListContentFlat","blocks","flatMap","name","innerBlocks","content","transforms","from","type","isMultiBlock","transform","blockAttributes","childBlocks","length","map","value","html","result","anchor","selector","schema","args","createListBlockFromDOMElement","prefix","ordered","to","block","_attributes"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,oBAAT,OAA2D;AAAA,MAA5B;AAAEC,IAAAA;AAAF,GAA4B;AAC1D,QAAMC,iBAAiB,GAAG,EACzB,GAAGD,qBADsB;AAEzBE,IAAAA,EAAE,EAAE,EAFqB;AAGzBC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,UAAU,EAAE,CAAE,MAAF,EAAU,OAAV,EAAmB,UAAnB;AAAd;AAHqB,GAA1B,CAD0D,CAO1D;AACA;AACA;;AACA,GAAE,IAAF,EAAQ,IAAR,EAAeC,OAAf,CAA0BC,GAAF,IAAW;AAClCL,IAAAA,iBAAiB,CAAEK,GAAF,CAAjB,CAAyBC,QAAzB,GAAoC;AACnCC,MAAAA,EAAE,EAAE;AACHD,QAAAA,QAAQ,EAAEN;AADP;AAD+B,KAApC;AAKA,GAND;AAQA,SAAOA,iBAAP;AACA;;AAED,SAASQ,kBAAT,CAA6BC,MAA7B,EAAsC;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAgB,SAA8C;AAAA,QAA5C;AAAEC,MAAAA,IAAF;AAAQR,MAAAA,UAAR;AAAoBS,MAAAA,WAAW,GAAG;AAAlC,KAA4C;;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;AAC1C,aAAOZ,kBAAkB,CAAEY,WAAF,CAAlB,CAAkCE,GAAlC,CAAyCT,OAAF,IAC7C,yBAAaqB,KAAb,EAAoB;AACnBrB,QAAAA;AADmB,OAApB,CADM,CAAP;AAKA;AAT0D,GAAf,CAA1C,CADA,EAYH;AACCG,IAAAA,IAAI,EAAE,OADP;AAECP,IAAAA,MAAM,EAAE,CAAE,GAAF,CAFT;AAGCS,IAAAA,SAAS,EAAE,CAAEiB,WAAF,EAAef,WAAf,KAAgC;AAC1C,aAAOZ,kBAAkB,CAAEY,WAAF,CAAlB,CAAkCE,GAAlC,CAAyCT,OAAF,IAC7C,yBAAa,gBAAb,EAA+B;AAC9BA,QAAAA;AAD8B,OAA/B,CADM,CAAP;AAKA;AATF,GAZG;AA/Dc,CAAnB;eAyFeC,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, split, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { createListBlockFromDOMElement } from './utils';\n\nfunction getListContentSchema( { phrasingContentSchema } ) {\n\tconst listContentSchema = {\n\t\t...phrasingContentSchema,\n\t\tul: {},\n\t\tol: { attributes: [ 'type', 'start', 'reversed' ] },\n\t};\n\n\t// Recursion is needed.\n\t// Possible: ul > li > ul.\n\t// Impossible: ul > ul.\n\t[ 'ul', 'ol' ].forEach( ( tag ) => {\n\t\tlistContentSchema[ tag ].children = {\n\t\t\tli: {\n\t\t\t\tchildren: listContentSchema,\n\t\t\t},\n\t\t};\n\t} );\n\n\treturn listContentSchema;\n}\n\nfunction getListContentFlat( blocks ) {\n\treturn blocks.flatMap( ( { name, attributes, innerBlocks = [] } ) => {\n\t\tif ( name === 'core/list-item' ) {\n\t\t\treturn [ attributes.content, ...getListContentFlat( innerBlocks ) ];\n\t\t}\n\t\treturn getListContentFlat( innerBlocks );\n\t} );\n}\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph', 'core/heading' ],\n\t\t\ttransform: ( blockAttributes ) => {\n\t\t\t\tlet childBlocks = [];\n\t\t\t\tif ( blockAttributes.length > 1 ) {\n\t\t\t\t\tchildBlocks = blockAttributes.map( ( { content } ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', { content } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( blockAttributes.length === 1 ) {\n\t\t\t\t\tconst value = create( {\n\t\t\t\t\t\thtml: blockAttributes[ 0 ].content,\n\t\t\t\t\t} );\n\t\t\t\t\tchildBlocks = split( value, '\\n' ).map( ( result ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\t\t\tcontent: toHTMLString( { value: result } ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tanchor: blockAttributes.anchor,\n\t\t\t\t\t},\n\t\t\t\t\tchildBlocks\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tselector: 'ol,ul',\n\t\t\tschema: ( args ) => ( {\n\t\t\t\tol: getListContentSchema( args ).ol,\n\t\t\t\tul: getListContentSchema( args ).ul,\n\t\t\t} ),\n\t\t\ttransform: createListBlockFromDOMElement,\n\t\t},\n\t\t...[ '*', '-' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock( 'core/list', {}, [\n\t\t\t\t\tcreateBlock( 'core/list-item', { content } ),\n\t\t\t\t] );\n\t\t\t},\n\t\t} ) ),\n\t\t...[ '1.', '1)' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tordered: true,\n\t\t\t\t\t},\n\t\t\t\t\t[ createBlock( 'core/list-item', { content } ) ]\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t],\n\tto: [\n\t\t...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {\n\t\t\ttype: 'block',\n\t\t\tblocks: [ block ],\n\t\t\ttransform: ( _attributes, childBlocks ) => {\n\t\t\t\treturn getListContentFlat( childBlocks ).map( ( content ) =>\n\t\t\t\t\tcreateBlock( block, {\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ '*' ],\n\t\t\ttransform: ( _attributes, childBlocks ) => {\n\t\t\t\treturn getListContentFlat( childBlocks ).map( ( content ) =>\n\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"]}
@@ -55,7 +55,8 @@ function ListItemEdit(_ref2) {
55
55
  attributes,
56
56
  setAttributes,
57
57
  onReplace,
58
- clientId
58
+ clientId,
59
+ mergeBlocks
59
60
  } = _ref2;
60
61
  const {
61
62
  placeholder,
@@ -73,7 +74,7 @@ function ListItemEdit(_ref2) {
73
74
  });
74
75
  const useSpaceRef = (0, _hooks.useSpace)(clientId);
75
76
  const onSplit = (0, _hooks.useSplit)(clientId);
76
- const onMerge = (0, _hooks.useMerge)(clientId);
77
+ const onMerge = (0, _hooks.useMerge)(clientId, mergeBlocks);
77
78
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("li", innerBlocksProps, (0, _element.createElement)(_blockEditor.RichText, {
78
79
  ref: (0, _compose.useMergeRefs)([useEnterRef, useSpaceRef]),
79
80
  identifier: "content",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list-item/edit.js"],"names":["IndentUI","clientId","canIndent","indentListItem","canOutdent","outdentListItem","formatOutdentRTL","formatOutdent","formatIndentRTL","formatIndent","ListItemEdit","attributes","setAttributes","onReplace","placeholder","content","blockProps","ref","innerBlocksProps","allowedBlocks","useEnterRef","useSpaceRef","onSplit","onMerge","nextContent","blocks","args","children"],"mappings":";;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAMA;;AAKA;;AASA;;AA/BA;AACA;AACA;;AAiBA;AACA;AACA;AAYO,SAASA,QAAT,OAAkC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACxC,QAAM,CAAEC,SAAF,EAAaC,cAAb,IAAgC,8BAAmBF,QAAnB,CAAtC;AACA,QAAM,CAAEG,UAAF,EAAcC,eAAd,IAAkC,+BAAoBJ,QAApB,CAAxC;AAEA,SACC,qDACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAG,qBAAUK,uBAAV,GAA6BC,oBADrC;AAEC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAFT;AAGC,IAAA,WAAW,EAAG,cAAI,mBAAJ,CAHf;AAIC,IAAA,QAAQ,EAAG,CAAEH,UAJd;AAKC,IAAA,OAAO,EAAG,MAAMC,eAAe;AALhC,IADD,EAQC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAG,qBAAUG,sBAAV,GAA4BC,mBADpC;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,WAAW,EAAG,cAAI,kBAAJ,CAHf;AAIC,IAAA,UAAU,EAAG,CAAEP,SAJhB;AAKC,IAAA,OAAO,EAAG,MAAMC,cAAc;AAL/B,IARD,CADD;AAkBA;;AAEc,SAASO,YAAT,QAKX;AAAA,MALkC;AACrCC,IAAAA,UADqC;AAErCC,IAAAA,aAFqC;AAGrCC,IAAAA,SAHqC;AAIrCZ,IAAAA;AAJqC,GAKlC;AACH,QAAM;AAAEa,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAA2BJ,UAAjC;AACA,QAAMK,UAAU,GAAG,gCAAe;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\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport {\n\tformatOutdent,\n\tformatOutdentRTL,\n\tformatIndentRTL,\n\tformatIndent,\n} from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseEnter,\n\tuseSpace,\n\tuseIndentListItem,\n\tuseOutdentListItem,\n\tuseSplit,\n\tuseMerge,\n\tuseCopy,\n} from './hooks';\nimport { convertToListItems } from './utils';\n\nexport function IndentUI( { clientId } ) {\n\tconst [ canIndent, indentListItem ] = useIndentListItem( clientId );\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ () => outdentListItem() }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatIndentRTL : formatIndent }\n\t\t\t\ttitle={ __( 'Indent' ) }\n\t\t\t\tdescribedBy={ __( 'Indent list item' ) }\n\t\t\t\tisDisabled={ ! canIndent }\n\t\t\t\tonClick={ () => indentListItem() }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function ListItemEdit( {\n\tattributes,\n\tsetAttributes,\n\tonReplace,\n\tclientId,\n} ) {\n\tconst { placeholder, content } = attributes;\n\tconst blockProps = useBlockProps( { ref: useCopy( clientId ) } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list' ],\n\t} );\n\tconst useEnterRef = useEnter( { content, clientId } );\n\tconst useSpaceRef = useSpace( clientId );\n\tconst onSplit = useSplit( clientId );\n\tconst onMerge = useMerge( clientId );\n\treturn (\n\t\t<>\n\t\t\t<li { ...innerBlocksProps }>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ useMergeRefs( [ useEnterRef, useSpaceRef ] ) }\n\t\t\t\t\tidentifier=\"content\"\n\t\t\t\t\ttagName=\"div\"\n\t\t\t\t\tonChange={ ( nextContent ) =>\n\t\t\t\t\t\tsetAttributes( { content: nextContent } )\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\taria-label={ __( 'List text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'List' ) }\n\t\t\t\t\tonSplit={ onSplit }\n\t\t\t\t\tonMerge={ onMerge }\n\t\t\t\t\tonReplace={ ( blocks, ...args ) => {\n\t\t\t\t\t\tonReplace( convertToListItems( blocks ), ...args );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ innerBlocksProps.children }\n\t\t\t</li>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<IndentUI clientId={ clientId } />\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/edit.js"],"names":["IndentUI","clientId","canIndent","indentListItem","canOutdent","outdentListItem","formatOutdentRTL","formatOutdent","formatIndentRTL","formatIndent","ListItemEdit","attributes","setAttributes","onReplace","mergeBlocks","placeholder","content","blockProps","ref","innerBlocksProps","allowedBlocks","useEnterRef","useSpaceRef","onSplit","onMerge","nextContent","blocks","args","children"],"mappings":";;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAMA;;AAKA;;AASA;;AA/BA;AACA;AACA;;AAiBA;AACA;AACA;AAYO,SAASA,QAAT,OAAkC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACxC,QAAM,CAAEC,SAAF,EAAaC,cAAb,IAAgC,8BAAmBF,QAAnB,CAAtC;AACA,QAAM,CAAEG,UAAF,EAAcC,eAAd,IAAkC,+BAAoB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AAT,EACC,4BAAC,qBAAD;AACC,IAAA,GAAG,EAAG,2BAAc,CAAEE,WAAF,EAAeC,WAAf,CAAd,CADP;AAEC,IAAA,UAAU,EAAC,SAFZ;AAGC,IAAA,OAAO,EAAC,KAHT;AAIC,IAAA,QAAQ,EAAKG,WAAF,IACVb,aAAa,CAAE;AAAEI,MAAAA,OAAO,EAAES;AAAX,KAAF,CALf;AAOC,IAAA,KAAK,EAAGT,OAPT;AAQC,kBAAa,cAAI,WAAJ,CARd;AASC,IAAA,WAAW,EAAGD,WAAW,IAAI,cAAI,MAAJ,CAT9B;AAUC,IAAA,OAAO,EAAGQ,OAVX;AAWC,IAAA,OAAO,EAAGC,OAXX;AAYC,IAAA,SAAS,EAAG,UAAEE,MAAF,EAAuB;AAAA,wCAAVC,IAAU;AAAVA,QAAAA,IAAU;AAAA;;AAClCd,MAAAA,SAAS,CAAE,+BAAoBa,MAApB,CAAF,EAAgC,GAAGC,IAAnC,CAAT;AACA;AAdF,IADD,EAiBGR,gBAAgB,CAACS,QAjBpB,CADD,EAoBC,4BAAC,0BAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,4BAAC,QAAD;AAAU,IAAA,QAAQ,EAAG3B;AAArB,IADD,CApBD,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport {\n\tformatOutdent,\n\tformatOutdentRTL,\n\tformatIndentRTL,\n\tformatIndent,\n} from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseEnter,\n\tuseSpace,\n\tuseIndentListItem,\n\tuseOutdentListItem,\n\tuseSplit,\n\tuseMerge,\n\tuseCopy,\n} from './hooks';\nimport { convertToListItems } from './utils';\n\nexport function IndentUI( { clientId } ) {\n\tconst [ canIndent, indentListItem ] = useIndentListItem( clientId );\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ () => outdentListItem() }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatIndentRTL : formatIndent }\n\t\t\t\ttitle={ __( 'Indent' ) }\n\t\t\t\tdescribedBy={ __( 'Indent list item' ) }\n\t\t\t\tisDisabled={ ! canIndent }\n\t\t\t\tonClick={ () => indentListItem() }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function ListItemEdit( {\n\tattributes,\n\tsetAttributes,\n\tonReplace,\n\tclientId,\n\tmergeBlocks,\n} ) {\n\tconst { placeholder, content } = attributes;\n\tconst blockProps = useBlockProps( { ref: useCopy( clientId ) } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list' ],\n\t} );\n\tconst useEnterRef = useEnter( { content, clientId } );\n\tconst useSpaceRef = useSpace( clientId );\n\tconst onSplit = useSplit( clientId );\n\tconst onMerge = useMerge( clientId, mergeBlocks );\n\treturn (\n\t\t<>\n\t\t\t<li { ...innerBlocksProps }>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ useMergeRefs( [ useEnterRef, useSpaceRef ] ) }\n\t\t\t\t\tidentifier=\"content\"\n\t\t\t\t\ttagName=\"div\"\n\t\t\t\t\tonChange={ ( nextContent ) =>\n\t\t\t\t\t\tsetAttributes( { content: nextContent } )\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\taria-label={ __( 'List text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'List' ) }\n\t\t\t\t\tonSplit={ onSplit }\n\t\t\t\t\tonMerge={ onMerge }\n\t\t\t\t\tonReplace={ ( blocks, ...args ) => {\n\t\t\t\t\t\tonReplace( convertToListItems( blocks ), ...args );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ innerBlocksProps.children }\n\t\t\t</li>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<IndentUI clientId={ clientId } />\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n"]}
@@ -11,8 +11,6 @@ var _data = require("@wordpress/data");
11
11
 
12
12
  var _blockEditor = require("@wordpress/block-editor");
13
13
 
14
- var _blocks = require("@wordpress/blocks");
15
-
16
14
  var _useOutdentListItem = _interopRequireDefault(require("./use-outdent-list-item"));
17
15
 
18
16
  /**
@@ -51,21 +49,18 @@ const {
51
49
  }
52
50
  };
53
51
 
54
- function useMerge(clientId) {
52
+ function useMerge(clientId, onMerge) {
55
53
  const registry = (0, _data.useRegistry)();
56
54
  const {
57
55
  getPreviousBlockClientId,
58
56
  getNextBlockClientId,
59
57
  getBlockOrder,
60
58
  getBlockRootClientId,
61
- getBlockName,
62
- getBlock
59
+ getBlockName
63
60
  } = (0, _data.useSelect)(_blockEditor.store);
64
61
  const {
65
62
  mergeBlocks,
66
- moveBlocksToPosition,
67
- replaceBlock,
68
- selectBlock
63
+ moveBlocksToPosition
69
64
  } = (0, _data.useDispatch)(_blockEditor.store);
70
65
  const [, outdentListItem] = (0, _useOutdentListItem.default)(clientId);
71
66
 
@@ -123,23 +118,12 @@ function useMerge(clientId) {
123
118
  return getBlockOrder(order[0])[0];
124
119
  }
125
120
 
126
- function switchToDefaultBlockType(forward) {
127
- const rootClientId = getBlockRootClientId(clientId);
128
- const replacement = (0, _blocks.switchToBlockType)(getBlock(rootClientId), (0, _blocks.getDefaultBlockName)());
129
- const indexToSelect = forward ? replacement.length - 1 : 0;
130
- const initialPosition = forward ? -1 : 0;
131
- registry.batch(() => {
132
- replaceBlock(rootClientId, replacement);
133
- selectBlock(replacement[indexToSelect].clientId, initialPosition);
134
- });
135
- }
136
-
137
121
  return forward => {
138
122
  if (forward) {
139
123
  const nextBlockClientId = getNextId(clientId);
140
124
 
141
125
  if (!nextBlockClientId) {
142
- switchToDefaultBlockType(forward);
126
+ onMerge(forward);
143
127
  return;
144
128
  }
145
129
 
@@ -165,7 +149,7 @@ function useMerge(clientId) {
165
149
  mergeBlocks(trailingId, clientId);
166
150
  });
167
151
  } else {
168
- switchToDefaultBlockType(forward);
152
+ onMerge(forward);
169
153
  }
170
154
  }
171
155
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-merge.js"],"names":["useMerge","clientId","registry","getPreviousBlockClientId","getNextBlockClientId","getBlockOrder","getBlockRootClientId","getBlockName","getBlock","blockEditorStore","mergeBlocks","moveBlocksToPosition","replaceBlock","selectBlock","outdentListItem","getTrailingId","id","order","length","getParentListItemId","listId","parentListItemId","listItemName","_getNextId","next","getNextId","switchToDefaultBlockType","forward","rootClientId","replacement","indexToSelect","initialPosition","batch","nextBlockClientId","previousBlockClientId","trailingId"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKe,SAASA,QAAT,CAAmBC,QAAnB,EAA8B;AAC5C,QAAMC,QAAQ,GAAG,wBAAjB;AACA,QAAM;AACLC,IAAAA,wBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,YALK;AAMLC,IAAAA;AANK,MAOF,qBAAWC,kBAAX,CAPJ;AAQA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,oBAAf;AAAqCC,IAAAA,YAArC;AAAmDC,IAAAA;AAAnD,MACL,uBAAaJ,kBAAb,CADD;AAEA,QAAM,GAAIK,eAAJ,IAAwB,iCAAoBb,QAApB,CAA9B;;AAEA,WAASc,aAAT,CAAw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ACnC,cAAMC,UAAU,GAAGpB,aAAa,CAAEmB,qBAAF,CAAhC;AACAhC,QAAAA,QAAQ,CAAC8B,KAAT,CAAgB,MAAM;AACrBrB,UAAAA,oBAAoB,CACnBN,aAAa,CAAEJ,QAAF,CADM,EAEnBA,QAFmB,EAGnBiC,qBAHmB,CAApB;AAKAxB,UAAAA,WAAW,CAAEyB,UAAF,EAAclC,QAAd,CAAX;AACA,SAPD;AAQA,OAVM,MAUA;AACNyB,QAAAA,wBAAwB,CAAEC,OAAF,CAAxB;AACA;AACD;AACD,GAzCD;AA0CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getDefaultBlockName, switchToBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOutdentListItem from './use-outdent-list-item';\n\nimport { name as listItemName } from '../block.json';\n\nexport default function useMerge( clientId ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { mergeBlocks, moveBlocksToPosition, replaceBlock, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ , outdentListItem ] = useOutdentListItem( clientId );\n\n\tfunction getTrailingId( id ) {\n\t\tconst order = getBlockOrder( id );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn id;\n\t\t}\n\n\t\treturn getTrailingId( order[ order.length - 1 ] );\n\t}\n\n\tfunction getParentListItemId( id ) {\n\t\tconst listId = getBlockRootClientId( id );\n\t\tconst parentListItemId = getBlockRootClientId( listId );\n\t\tif ( ! parentListItemId ) return;\n\t\tif ( getBlockName( parentListItemId ) !== listItemName ) return;\n\t\treturn parentListItemId;\n\t}\n\n\t/**\n\t * Return the next list item with respect to the given list item. If none,\n\t * return the next list item of the parent list item if it exists.\n\t *\n\t * @param {string} id A list item client ID.\n\t * @return {string?} The client ID of the next list item.\n\t */\n\tfunction _getNextId( id ) {\n\t\tconst next = getNextBlockClientId( id );\n\t\tif ( next ) return next;\n\t\tconst parentListItemId = getParentListItemId( id );\n\t\tif ( ! parentListItemId ) return;\n\t\treturn _getNextId( parentListItemId );\n\t}\n\n\t/**\n\t * Given a client ID, return the client ID of the list item on the next\n\t * line, regardless of indentation level.\n\t *\n\t * @param {string} id The client ID of the current list item.\n\t * @return {string?} The client ID of the next list item.\n\t */\n\tfunction getNextId( id ) {\n\t\tconst order = getBlockOrder( id );\n\n\t\t// If the list item does not have a nested list, return the next list\n\t\t// item.\n\t\tif ( ! order.length ) {\n\t\t\treturn _getNextId( id );\n\t\t}\n\n\t\t// Get the first list item in the nested list.\n\t\treturn getBlockOrder( order[ 0 ] )[ 0 ];\n\t}\n\n\tfunction switchToDefaultBlockType( forward ) {\n\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\tconst replacement = switchToBlockType(\n\t\t\tgetBlock( rootClientId ),\n\t\t\tgetDefaultBlockName()\n\t\t);\n\t\tconst indexToSelect = forward ? replacement.length - 1 : 0;\n\t\tconst initialPosition = forward ? -1 : 0;\n\t\tregistry.batch( () => {\n\t\t\treplaceBlock( rootClientId, replacement );\n\t\t\tselectBlock(\n\t\t\t\treplacement[ indexToSelect ].clientId,\n\t\t\t\tinitialPosition\n\t\t\t);\n\t\t} );\n\t}\n\n\treturn ( forward ) => {\n\t\tif ( forward ) {\n\t\t\tconst nextBlockClientId = getNextId( clientId );\n\n\t\t\tif ( ! nextBlockClientId ) {\n\t\t\t\tswitchToDefaultBlockType( forward );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( getParentListItemId( nextBlockClientId ) ) {\n\t\t\t\toutdentListItem( nextBlockClientId );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tgetBlockOrder( nextBlockClientId ),\n\t\t\t\t\t\tnextBlockClientId,\n\t\t\t\t\t\tgetPreviousBlockClientId( nextBlockClientId )\n\t\t\t\t\t);\n\t\t\t\t\tmergeBlocks( clientId, nextBlockClientId );\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Merging is only done from the top level. For lowel levels, the\n\t\t\t// list item is outdented instead.\n\t\t\tconst previousBlockClientId = getPreviousBlockClientId( clientId );\n\t\t\tif ( getParentListItemId( clientId ) ) {\n\t\t\t\toutdentListItem( clientId );\n\t\t\t} else if ( previousBlockClientId ) {\n\t\t\t\tconst trailingId = getTrailingId( previousBlockClientId );\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tgetBlockOrder( clientId ),\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tpreviousBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\tmergeBlocks( trailingId, clientId );\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tswitchToDefaultBlockType( forward );\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-merge.js"],"names":["useMerge","clientId","onMerge","registry","getPreviousBlockClientId","getNextBlockClientId","getBlockOrder","getBlockRootClientId","getBlockName","blockEditorStore","mergeBlocks","moveBlocksToPosition","outdentListItem","getTrailingId","id","order","length","getParentListItemId","listId","parentListItemId","listItemName","_getNextId","next","getNextId","forward","nextBlockClientId","batch","previousBlockClientId","trailingId"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKe,SAASA,QAAT,CAAmBC,QAAnB,EAA6BC,OAA7B,EAAuC;AACrD,QAAMC,QAAQ,GAAG,wBAAjB;AACA,QAAM;AACLC,IAAAA,wBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,oB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CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useOutdentListItem from './use-outdent-list-item';\n\nimport { name as listItemName } from '../block.json';\n\nexport default function useMerge( clientId, onMerge ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t} = useSelect( blockEditorStore );\n\tconst { mergeBlocks, moveBlocksToPosition } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ , outdentListItem ] = useOutdentListItem( clientId );\n\n\tfunction getTrailingId( id ) {\n\t\tconst order = getBlockOrder( id );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn id;\n\t\t}\n\n\t\treturn getTrailingId( order[ order.length - 1 ] );\n\t}\n\n\tfunction getParentListItemId( id ) {\n\t\tconst listId = getBlockRootClientId( id );\n\t\tconst parentListItemId = getBlockRootClientId( listId );\n\t\tif ( ! parentListItemId ) return;\n\t\tif ( getBlockName( parentListItemId ) !== listItemName ) return;\n\t\treturn parentListItemId;\n\t}\n\n\t/**\n\t * Return the next list item with respect to the given list item. If none,\n\t * return the next list item of the parent list item if it exists.\n\t *\n\t * @param {string} id A list item client ID.\n\t * @return {string?} The client ID of the next list item.\n\t */\n\tfunction _getNextId( id ) {\n\t\tconst next = getNextBlockClientId( id );\n\t\tif ( next ) return next;\n\t\tconst parentListItemId = getParentListItemId( id );\n\t\tif ( ! parentListItemId ) return;\n\t\treturn _getNextId( parentListItemId );\n\t}\n\n\t/**\n\t * Given a client ID, return the client ID of the list item on the next\n\t * line, regardless of indentation level.\n\t *\n\t * @param {string} id The client ID of the current list item.\n\t * @return {string?} The client ID of the next list item.\n\t */\n\tfunction getNextId( id ) {\n\t\tconst order = getBlockOrder( id );\n\n\t\t// If the list item does not have a nested list, return the next list\n\t\t// item.\n\t\tif ( ! order.length ) {\n\t\t\treturn _getNextId( id );\n\t\t}\n\n\t\t// Get the first list item in the nested list.\n\t\treturn getBlockOrder( order[ 0 ] )[ 0 ];\n\t}\n\n\treturn ( forward ) => {\n\t\tif ( forward ) {\n\t\t\tconst nextBlockClientId = getNextId( clientId );\n\n\t\t\tif ( ! nextBlockClientId ) {\n\t\t\t\tonMerge( forward );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( getParentListItemId( nextBlockClientId ) ) {\n\t\t\t\toutdentListItem( nextBlockClientId );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tgetBlockOrder( nextBlockClientId ),\n\t\t\t\t\t\tnextBlockClientId,\n\t\t\t\t\t\tgetPreviousBlockClientId( nextBlockClientId )\n\t\t\t\t\t);\n\t\t\t\t\tmergeBlocks( clientId, nextBlockClientId );\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Merging is only done from the top level. For lowel levels, the\n\t\t\t// list item is outdented instead.\n\t\t\tconst previousBlockClientId = getPreviousBlockClientId( clientId );\n\t\t\tif ( getParentListItemId( clientId ) ) {\n\t\t\t\toutdentListItem( clientId );\n\t\t\t} else if ( previousBlockClientId ) {\n\t\t\t\tconst trailingId = getTrailingId( previousBlockClientId );\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tgetBlockOrder( clientId ),\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tpreviousBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\tmergeBlocks( trailingId, clientId );\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tonMerge( forward );\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
@@ -116,7 +116,6 @@ const metadata = {
116
116
  },
117
117
  supports: {
118
118
  align: ["wide", "full"],
119
- anchor: true,
120
119
  html: false,
121
120
  inserter: true,
122
121
  typography: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/index.js"],"names":["name","metadata","settings","icon","example","innerBlocks","attributes","label","url","edit","save","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,iBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,WAAW,EAAE,CACZ;AACCL,MAAAA,IAAI,EAAE,sBADP;AAECM,MAAAA,UAAU,EAAE;AACX;AACAC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CAFI;AAGXC,QAAAA,GAAG,EAAE;AAHM;AAFb,KADY,EASZ;AACCR,MAAAA,IAAI,EAAE,sBADP;AAECM,MAAAA,UAAU,EAAE;AACX;AACAC,QAAAA,KAAK,EAAE,cAAI,OAAJ,CAFI;AAGXC,QAAAA,GAAG,EAAE;AAHM;AAFb,KATY,EAiBZ;AACCR,MAAAA,IAAI,EAAE,sBADP;AAECM,MAAAA,UAAU,EAAE;AACX;AACAC,QAAAA,KAAK,EAAE,cAAI,SAAJ,CAFI;AAGXC,QAAAA,GAAG,EAAE;AAHM;AAFb,KAjBY;AADL,GAFc;AA8BvBC,EAAAA,IAAI,EAAJA,aA9BuB;AA+BvBC,EAAAA,IAAI,EAAJA,aA/BuB;AAgCvBC,EAAAA,UAAU,EAAVA;AAhCuB,CAAjB;;;AAmCA,MAAMC,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 { navigation as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/navigation-link',\n\t\t\t\tattributes: {\n\t\t\t\t\t// translators: 'Home' as in a website's home page.\n\t\t\t\t\tlabel: __( 'Home' ),\n\t\t\t\t\turl: 'https://make.wordpress.org/',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/navigation-link',\n\t\t\t\tattributes: {\n\t\t\t\t\t// translators: 'About' as in a website's about page.\n\t\t\t\t\tlabel: __( 'About' ),\n\t\t\t\t\turl: 'https://make.wordpress.org/',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/navigation-link',\n\t\t\t\tattributes: {\n\t\t\t\t\t// translators: 'Contact' as in a website's contact page.\n\t\t\t\t\tlabel: __( 'Contact' ),\n\t\t\t\t\turl: 'https://make.wordpress.org/',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/index.js"],"names":["name","metadata","settings","icon","example","innerBlocks","attributes","label","url","edit","save","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,iBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,WAAW,EAAE,CACZ;AACCL,MAAAA,IAAI,EAAE,sBADP;AAECM,MAAAA,UAAU,EAAE;AACX;AACAC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CAFI;AAGXC,QAAAA,GAAG,EAAE;AAHM;AAFb,KADY,EASZ;AACCR,MAAAA,IAAI,EAAE,sBADP;AAECM,MAAAA,UAAU,EAAE;AACX;AACAC,QAAAA,KAAK,EAAE,cAAI,OAAJ,CAFI;AAGXC,QAAAA,GAAG,EAAE;AAHM;AAFb,KATY,EAiBZ;AACCR,MAAAA,IAAI,EAAE,sBADP;AAECM,MAAAA,UAAU,EAAE;AACX;AACAC,QAAAA,KAAK,EAAE,cAAI,SAAJ,CAFI;AAGXC,QAAAA,GAAG,EAAE;AAHM;AAFb,KAjBY;AADL,GAFc;AA8BvBC,EAAAA,IAAI,EAAJA,aA9BuB;AA+BvBC,EAAAA,IAAI,EAAJA,aA/BuB;AAgCvBC,EAAAA,UAAU,EAAVA;AAhCuB,CAAjB;;;AAmCA,MAAMC,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 { navigation as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/navigation-link',\n\t\t\t\tattributes: {\n\t\t\t\t\t// translators: 'Home' as in a website's home page.\n\t\t\t\t\tlabel: __( 'Home' ),\n\t\t\t\t\turl: 'https://make.wordpress.org/',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/navigation-link',\n\t\t\t\tattributes: {\n\t\t\t\t\t// translators: 'About' as in a website's about page.\n\t\t\t\t\tlabel: __( 'About' ),\n\t\t\t\t\turl: 'https://make.wordpress.org/',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/navigation-link',\n\t\t\t\tattributes: {\n\t\t\t\t\t// translators: 'Contact' as in a website's contact page.\n\t\t\t\t\tlabel: __( 'Contact' ),\n\t\t\t\t\turl: 'https://make.wordpress.org/',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -29,11 +29,7 @@ const metadata = {
29
29
  description: "Display a list of all pages.",
30
30
  keywords: ["menu", "navigation"],
31
31
  textdomain: "default",
32
- attributes: {
33
- __unstableMaxPages: {
34
- type: "number"
35
- }
36
- },
32
+ attributes: {},
37
33
  usesContext: ["textColor", "customTextColor", "backgroundColor", "customBackgroundColor", "overlayTextColor", "customOverlayTextColor", "overlayBackgroundColor", "customOverlayBackgroundColor", "fontSize", "customFontSize", "showSubmenuIcon", "style", "openSubmenusOnClick"],
38
34
  supports: {
39
35
  reusable: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/page-list/index.js"],"names":["name","metadata","settings","icon","example","edit","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,YADuB;AAEvBC,EAAAA,OAAO,EAAE,EAFc;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB;;;AAMA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEN,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pages as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit.js';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/page-list/index.js"],"names":["name","metadata","settings","icon","example","edit","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,YADuB;AAEvBC,EAAAA,OAAO,EAAE,EAFc;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB;;;AAMA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEN,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pages as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit.js';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -100,7 +100,8 @@ function SearchEdit(_ref) {
100
100
  }
101
101
 
102
102
  const colorProps = (0, _blockEditor.__experimentalUseColorProps)(attributes);
103
- const typographyProps = (0, _blockEditor.getTypographyClassesAndStyles)(attributes);
103
+ const fluidTypographyEnabled = (0, _blockEditor.useSetting)('typography.fluid');
104
+ const typographyProps = (0, _blockEditor.getTypographyClassesAndStyles)(attributes, fluidTypographyEnabled);
104
105
  const unitControlInstanceId = (0, _compose.useInstanceId)(_components.__experimentalUnitControl);
105
106
  const unitControlInputId = `wp-block-search__width-${unitControlInstanceId}`;
106
107
  const isButtonPositionInside = 'button-inside' === buttonPosition;