@wordpress/editor 14.33.4 → 14.33.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 (97) hide show
  1. package/build/components/collab-sidebar/add-comment.js +10 -12
  2. package/build/components/collab-sidebar/add-comment.js.map +2 -2
  3. package/build/components/collab-sidebar/comment-menu-item.js +36 -6
  4. package/build/components/collab-sidebar/comment-menu-item.js.map +3 -3
  5. package/build/components/collab-sidebar/comments.js +316 -318
  6. package/build/components/collab-sidebar/comments.js.map +3 -3
  7. package/build/components/collab-sidebar/index.js +38 -25
  8. package/build/components/collab-sidebar/index.js.map +3 -3
  9. package/build/components/collab-sidebar/utils.js +1 -1
  10. package/build/components/collab-sidebar/utils.js.map +2 -2
  11. package/build/components/editor/index.js +2 -2
  12. package/build/components/editor/index.js.map +3 -3
  13. package/build/components/post-excerpt/panel.js +1 -6
  14. package/build/components/post-excerpt/panel.js.map +2 -2
  15. package/build/components/post-template/block-theme.js +4 -32
  16. package/build/components/post-template/block-theme.js.map +3 -3
  17. package/build/components/post-template/create-new-template-modal.js +1 -2
  18. package/build/components/post-template/create-new-template-modal.js.map +2 -2
  19. package/build/components/post-template/hooks.js +1 -3
  20. package/build/components/post-template/hooks.js.map +2 -2
  21. package/build/components/preferences-modal/index.js +1 -1
  22. package/build/components/preferences-modal/index.js.map +1 -1
  23. package/build/components/provider/index.js +2 -3
  24. package/build/components/provider/index.js.map +2 -2
  25. package/build/components/start-page-options/index.js +4 -5
  26. package/build/components/start-page-options/index.js.map +2 -2
  27. package/build/dataviews/store/private-actions.js +3 -9
  28. package/build/dataviews/store/private-actions.js.map +2 -2
  29. package/build/store/actions.js +2 -67
  30. package/build/store/actions.js.map +2 -2
  31. package/build-module/components/collab-sidebar/add-comment.js +10 -12
  32. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  33. package/build-module/components/collab-sidebar/comment-menu-item.js +40 -7
  34. package/build-module/components/collab-sidebar/comment-menu-item.js.map +2 -2
  35. package/build-module/components/collab-sidebar/comments.js +316 -318
  36. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  37. package/build-module/components/collab-sidebar/index.js +38 -25
  38. package/build-module/components/collab-sidebar/index.js.map +2 -2
  39. package/build-module/components/collab-sidebar/utils.js +1 -1
  40. package/build-module/components/collab-sidebar/utils.js.map +2 -2
  41. package/build-module/components/editor/index.js +2 -2
  42. package/build-module/components/editor/index.js.map +2 -2
  43. package/build-module/components/post-excerpt/panel.js +1 -6
  44. package/build-module/components/post-excerpt/panel.js.map +2 -2
  45. package/build-module/components/post-template/block-theme.js +4 -32
  46. package/build-module/components/post-template/block-theme.js.map +2 -2
  47. package/build-module/components/post-template/create-new-template-modal.js +1 -2
  48. package/build-module/components/post-template/create-new-template-modal.js.map +2 -2
  49. package/build-module/components/post-template/hooks.js +1 -3
  50. package/build-module/components/post-template/hooks.js.map +2 -2
  51. package/build-module/components/preferences-modal/index.js +1 -1
  52. package/build-module/components/preferences-modal/index.js.map +1 -1
  53. package/build-module/components/provider/index.js +2 -3
  54. package/build-module/components/provider/index.js.map +2 -2
  55. package/build-module/components/start-page-options/index.js +5 -6
  56. package/build-module/components/start-page-options/index.js.map +2 -2
  57. package/build-module/dataviews/store/private-actions.js +3 -9
  58. package/build-module/dataviews/store/private-actions.js.map +2 -2
  59. package/build-module/store/actions.js +3 -68
  60. package/build-module/store/actions.js.map +2 -2
  61. package/build-style/style-rtl.css +14 -2
  62. package/build-style/style.css +14 -2
  63. package/build-types/components/collab-sidebar/add-comment.d.ts +3 -3
  64. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  65. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +3 -2
  66. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -1
  67. package/build-types/components/collab-sidebar/comments.d.ts +4 -4
  68. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  69. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  70. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  71. package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
  72. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  73. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  74. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  75. package/build-types/components/provider/index.d.ts.map +1 -1
  76. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  77. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  78. package/build-types/store/actions.d.ts.map +1 -1
  79. package/package.json +14 -14
  80. package/src/components/collab-sidebar/add-comment.js +10 -12
  81. package/src/components/collab-sidebar/comment-menu-item.js +51 -11
  82. package/src/components/collab-sidebar/comments.js +53 -56
  83. package/src/components/collab-sidebar/index.js +66 -46
  84. package/src/components/collab-sidebar/style.scss +16 -0
  85. package/src/components/collab-sidebar/utils.js +3 -2
  86. package/src/components/editor/index.js +1 -1
  87. package/src/components/post-excerpt/panel.js +1 -11
  88. package/src/components/post-template/block-theme.js +3 -45
  89. package/src/components/post-template/create-new-template-modal.js +0 -1
  90. package/src/components/post-template/hooks.js +1 -3
  91. package/src/components/preferences-modal/index.js +1 -1
  92. package/src/components/provider/index.js +2 -5
  93. package/src/components/start-page-options/index.js +5 -6
  94. package/src/components/start-page-options/style.scss +1 -1
  95. package/src/dataviews/store/private-actions.ts +7 -16
  96. package/src/store/actions.js +3 -100
  97. package/tsconfig.tsbuildinfo +1 -1
@@ -44,30 +44,28 @@ var import_utils = require("./utils");
44
44
  const { useBlockElement } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
45
45
  function AddComment({
46
46
  onSubmit,
47
- showCommentBoard,
48
- setShowCommentBoard,
47
+ newNoteFormState,
48
+ setNewNoteFormState,
49
49
  commentSidebarRef,
50
50
  reflowComments = import_utils.noop,
51
51
  isFloating = false,
52
52
  y,
53
53
  refs
54
54
  }) {
55
- const { clientId, blockCommentId } = (0, import_data.useSelect)((select) => {
56
- const { getSelectedBlock } = select(import_block_editor.store);
57
- const selectedBlock = getSelectedBlock();
55
+ const { clientId } = (0, import_data.useSelect)((select) => {
56
+ const { getSelectedBlockClientId } = select(import_block_editor.store);
58
57
  return {
59
- clientId: selectedBlock?.clientId,
60
- blockCommentId: selectedBlock?.attributes?.metadata?.noteId
58
+ clientId: getSelectedBlockClientId()
61
59
  };
62
60
  }, []);
63
61
  const blockElement = useBlockElement(clientId);
64
62
  const { toggleBlockSpotlight } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_block_editor.store));
65
63
  const unselectThread = () => {
66
- setShowCommentBoard(false);
64
+ setNewNoteFormState("closed");
67
65
  blockElement?.focus();
68
66
  toggleBlockSpotlight(clientId, false);
69
67
  };
70
- if (!showCommentBoard || !clientId || void 0 !== blockCommentId) {
68
+ if (newNoteFormState !== "open" || !clientId) {
71
69
  return null;
72
70
  }
73
71
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -82,7 +80,7 @@ function AddComment({
82
80
  spacing: "3",
83
81
  tabIndex: 0,
84
82
  "aria-label": (0, import_i18n.__)("New note"),
85
- role: "listitem",
83
+ role: "treeitem",
86
84
  ref: isFloating ? refs.setFloating : void 0,
87
85
  style: isFloating ? (
88
86
  // Delay showing the floating note box until a Y position is known to prevent blink.
@@ -93,7 +91,7 @@ function AddComment({
93
91
  return;
94
92
  }
95
93
  toggleBlockSpotlight(clientId, false);
96
- setShowCommentBoard(false);
94
+ setNewNoteFormState("closed");
97
95
  },
98
96
  children: [
99
97
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_comment_author_info.default, {}) }),
@@ -103,7 +101,7 @@ function AddComment({
103
101
  onSubmit: async (inputComment) => {
104
102
  const { id } = await onSubmit({ content: inputComment });
105
103
  (0, import_utils.focusCommentThread)(id, commentSidebarRef.current);
106
- setShowCommentBoard(false);
104
+ setNewNoteFormState("creating");
107
105
  },
108
106
  onCancel: unselectThread,
109
107
  reflowComments,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/add-comment.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\nimport { focusCommentThread, noop } from './utils';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n\treflowComments = noop,\n\tisFloating = false,\n\ty,\n\trefs,\n} ) {\n\tconst { clientId, blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock } = select( blockEditorStore );\n\t\tconst selectedBlock = getSelectedBlock();\n\t\treturn {\n\t\t\tclientId: selectedBlock?.clientId,\n\t\t\tblockCommentId: selectedBlock?.attributes?.metadata?.noteId,\n\t\t};\n\t}, [] );\n\tconst blockElement = useBlockElement( clientId );\n\tconst { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );\n\n\tconst unselectThread = () => {\n\t\tsetShowCommentBoard( false );\n\t\tblockElement?.focus();\n\t\ttoggleBlockSpotlight( clientId, false );\n\t};\n\n\tif ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-collab-sidebar-panel__thread is-selected',\n\t\t\t\t{\n\t\t\t\t\t'is-floating': isFloating,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tspacing=\"3\"\n\t\t\ttabIndex={ 0 }\n\t\t\taria-label={ __( 'New note' ) }\n\t\t\trole=\"listitem\"\n\t\t\tref={ isFloating ? refs.setFloating : undefined }\n\t\t\tstyle={\n\t\t\t\tisFloating\n\t\t\t\t\t? // Delay showing the floating note box until a Y position is known to prevent blink.\n\t\t\t\t\t { top: y, opacity: ! y ? 0 : undefined }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonBlur={ ( event ) => {\n\t\t\t\tif ( event.currentTarget.contains( event.relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttoggleBlockSpotlight( clientId, false );\n\t\t\t\tsetShowCommentBoard( false );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\">\n\t\t\t\t<CommentAuthorInfo />\n\t\t\t</HStack>\n\t\t\t<CommentForm\n\t\t\t\tonSubmit={ async ( inputComment ) => {\n\t\t\t\t\tconst { id } = await onSubmit( { content: inputComment } );\n\t\t\t\t\tfocusCommentThread( id, commentSidebarRef.current );\n\t\t\t\t\tsetShowCommentBoard( false );\n\t\t\t\t} }\n\t\t\t\tonCancel={ unselectThread }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tsubmitButtonText={ __( 'Add note' ) }\n\t\t\t\tlabelText={ __( 'New note' ) }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DE;AAzDF,kBAAiB;AAIjB,kBAAmB;AACnB,kBAAuC;AACvC,wBAGO;AACP,0BAGO;AAKP,yBAAuB;AACvB,iCAA8B;AAC9B,0BAAwB;AACxB,mBAAyC;AAEzC,MAAM,EAAE,gBAAgB,QAAI,2BAAQ,oBAAAA,WAAuB;AAEpD,SAAS,WAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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,oBAAAC;AAAA,UAAA;AAAA,YACA,UAAW,OAAQ,iBAAkB;AACpC,oBAAM,EAAE,GAAG,IAAI,MAAM,SAAU,EAAE,SAAS,aAAa,CAAE;AACzD,mDAAoB,IAAI,kBAAkB,OAAQ;AAClD,kCAAqB,KAAM;AAAA,YAC5B;AAAA,YACA,UAAW;AAAA,YACX;AAAA,YACA,sBAAmB,gBAAI,UAAW;AAAA,YAClC,eAAY,gBAAI,UAAW;AAAA;AAAA,QAC5B;AAAA;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\nimport { focusCommentThread, noop } from './utils';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function AddComment( {\n\tonSubmit,\n\tnewNoteFormState,\n\tsetNewNoteFormState,\n\tcommentSidebarRef,\n\treflowComments = noop,\n\tisFloating = false,\n\ty,\n\trefs,\n} ) {\n\tconst { clientId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId } = select( blockEditorStore );\n\t\treturn {\n\t\t\tclientId: getSelectedBlockClientId(),\n\t\t};\n\t}, [] );\n\tconst blockElement = useBlockElement( clientId );\n\tconst { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );\n\n\tconst unselectThread = () => {\n\t\tsetNewNoteFormState( 'closed' );\n\t\tblockElement?.focus();\n\t\ttoggleBlockSpotlight( clientId, false );\n\t};\n\n\tif ( newNoteFormState !== 'open' || ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-collab-sidebar-panel__thread is-selected',\n\t\t\t\t{\n\t\t\t\t\t'is-floating': isFloating,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tspacing=\"3\"\n\t\t\ttabIndex={ 0 }\n\t\t\taria-label={ __( 'New note' ) }\n\t\t\trole=\"treeitem\"\n\t\t\tref={ isFloating ? refs.setFloating : undefined }\n\t\t\tstyle={\n\t\t\t\tisFloating\n\t\t\t\t\t? // Delay showing the floating note box until a Y position is known to prevent blink.\n\t\t\t\t\t { top: y, opacity: ! y ? 0 : undefined }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonBlur={ ( event ) => {\n\t\t\t\tif ( event.currentTarget.contains( event.relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttoggleBlockSpotlight( clientId, false );\n\t\t\t\tsetNewNoteFormState( 'closed' );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\">\n\t\t\t\t<CommentAuthorInfo />\n\t\t\t</HStack>\n\t\t\t<CommentForm\n\t\t\t\tonSubmit={ async ( inputComment ) => {\n\t\t\t\t\tconst { id } = await onSubmit( { content: inputComment } );\n\t\t\t\t\tfocusCommentThread( id, commentSidebarRef.current );\n\t\t\t\t\tsetNewNoteFormState( 'creating' );\n\t\t\t\t} }\n\t\t\t\tonCancel={ unselectThread }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tsubmitButtonText={ __( 'Add note' ) }\n\t\t\t\tlabelText={ __( 'New note' ) }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DE;AAvDF,kBAAiB;AAIjB,kBAAmB;AACnB,kBAAuC;AACvC,wBAGO;AACP,0BAGO;AAKP,yBAAuB;AACvB,iCAA8B;AAC9B,0B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Q,KAChC,sDAAC,2BAAAC,SAAA,EAAkB,GACpB;AAAA,QACA;AAAA,UAAC,oBAAAC;AAAA,UAAA;AAAA,YACA,UAAW,OAAQ,iBAAkB;AACpC,oBAAM,EAAE,GAAG,IAAI,MAAM,SAAU,EAAE,SAAS,aAAa,CAAE;AACzD,mDAAoB,IAAI,kBAAkB,OAAQ;AAClD,kCAAqB,UAAW;AAAA,YACjC;AAAA,YACA,UAAW;AAAA,YACX;AAAA,YACA,sBAAmB,gBAAI,UAAW;AAAA,YAClC,eAAY,gBAAI,UAAW;AAAA;AAAA,QAC5B;AAAA;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": ["blockEditorPrivateApis", "blockEditorStore", "VStack", "clsx", "HStack", "CommentAuthorInfo", "CommentForm"]
7
7
  }
@@ -26,21 +26,51 @@ var import_components = require("@wordpress/components");
26
26
  var import_i18n = require("@wordpress/i18n");
27
27
  var import_icons = require("@wordpress/icons");
28
28
  var import_block_editor = require("@wordpress/block-editor");
29
+ var import_data = require("@wordpress/data");
30
+ var import_blocks = require("@wordpress/blocks");
29
31
  var import_lock_unlock = require("../../lock-unlock");
30
32
  const { CommentIconSlotFill } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
31
- const AddCommentMenuItem = ({ onClick }) => {
32
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommentIconSlotFill.Fill, { children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
33
+ const AddCommentMenuItem = ({ clientId, onClick, isDistractionFree }) => {
34
+ const block = (0, import_data.useSelect)(
35
+ (select) => {
36
+ return select(import_block_editor.store).getBlock(clientId);
37
+ },
38
+ [clientId]
39
+ );
40
+ if (!block?.isValid || block?.name === (0, import_blocks.getUnregisteredTypeHandlerName)()) {
41
+ return null;
42
+ }
43
+ const isDisabled = isDistractionFree || block?.name === "core/freeform";
44
+ let infoText;
45
+ if (isDistractionFree) {
46
+ infoText = (0, import_i18n.__)("Notes are disabled in distraction free mode.");
47
+ } else if (block?.name === "core/freeform") {
48
+ infoText = (0, import_i18n.__)("Convert to blocks to add notes.");
49
+ }
50
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
33
51
  import_components.MenuItem,
34
52
  {
35
53
  icon: import_icons.comment,
54
+ onClick,
55
+ "aria-haspopup": "dialog",
56
+ disabled: isDisabled,
57
+ info: infoText,
58
+ children: (0, import_i18n.__)("Add note")
59
+ }
60
+ );
61
+ };
62
+ const AddCommentMenuItemFill = ({ onClick, isDistractionFree }) => {
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommentIconSlotFill.Fill, { children: ({ clientId, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
+ AddCommentMenuItem,
65
+ {
66
+ clientId,
67
+ isDistractionFree,
36
68
  onClick: () => {
37
69
  onClick();
38
70
  onClose();
39
- },
40
- "aria-haspopup": "dialog",
41
- children: (0, import_i18n.__)("Add note")
71
+ }
42
72
  }
43
73
  ) });
44
74
  };
45
- var comment_menu_item_default = AddCommentMenuItem;
75
+ var comment_menu_item_default = AddCommentMenuItemFill;
46
76
  //# sourceMappingURL=comment-menu-item.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/comment-menu-item.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { comment as commentIcon } from '@wordpress/icons';\n\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { CommentIconSlotFill } = unlock( blockEditorPrivateApis );\n\nconst AddCommentMenuItem = ( { onClick } ) => {\n\treturn (\n\t\t<CommentIconSlotFill.Fill>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\ticon={ commentIcon }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add note' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</CommentIconSlotFill.Fill>\n\t);\n};\n\nexport default AddCommentMenuItem;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBI;AAjBJ,wBAAyB;AACzB,kBAAmB;AACnB,mBAAuC;AAEvC,0BAAsD;AAKtD,yBAAuB;AAEvB,MAAM,EAAE,oBAAoB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE/D,MAAM,qBAAqB,CAAE,EAAE,QAAQ,MAAO;AAC7C,SACC,4CAAC,oBAAoB,MAApB,EACE,WAAE,EAAE,QAAQ,MACb;AAAA,IAAC;AAAA;AAAA,MACA,MAAO,aAAAC;AAAA,MACP,SAAU,MAAM;AACf,gBAAQ;AACR,gBAAQ;AAAA,MACT;AAAA,MACA,iBAAc;AAAA,MAEZ,8BAAI,UAAW;AAAA;AAAA,EAClB,GAEF;AAEF;AAEA,IAAO,4BAAQ;",
6
- "names": ["blockEditorPrivateApis", "commentIcon"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getUnregisteredTypeHandlerName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { CommentIconSlotFill } = unlock( blockEditorPrivateApis );\n\nconst AddCommentMenuItem = ( { clientId, onClick, isDistractionFree } ) => {\n\tconst block = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( blockEditorStore ).getBlock( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif (\n\t\t! block?.isValid ||\n\t\tblock?.name === getUnregisteredTypeHandlerName()\n\t) {\n\t\treturn null;\n\t}\n\n\tconst isDisabled = isDistractionFree || block?.name === 'core/freeform';\n\n\tlet infoText;\n\n\tif ( isDistractionFree ) {\n\t\tinfoText = __( 'Notes are disabled in distraction free mode.' );\n\t} else if ( block?.name === 'core/freeform' ) {\n\t\tinfoText = __( 'Convert to blocks to add notes.' );\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ commentIcon }\n\t\t\tonClick={ onClick }\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdisabled={ isDisabled }\n\t\t\tinfo={ infoText }\n\t\t>\n\t\t\t{ __( 'Add note' ) }\n\t\t</MenuItem>\n\t);\n};\n\nconst AddCommentMenuItemFill = ( { onClick, isDistractionFree } ) => {\n\treturn (\n\t\t<CommentIconSlotFill.Fill>\n\t\t\t{ ( { clientId, onClose } ) => (\n\t\t\t\t<AddCommentMenuItem\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisDistractionFree={ isDistractionFree }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</CommentIconSlotFill.Fill>\n\t);\n};\n\nexport default AddCommentMenuItemFill;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CE;AA3CF,wBAAyB;AACzB,kBAAmB;AACnB,mBAAuC;AACvC,0BAGO;AACP,kBAA0B;AAC1B,oBAA+C;AAK/C,yBAAuB;AAEvB,MAAM,EAAE,oBAAoB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE/D,MAAM,qBAAqB,CAAE,EAAE,UAAU,SAAS,kBAAkB,MAAO;AAC1E,QAAM,YAAQ;AAAA,IACb,CAAE,WAAY;AACb,aAAO,OAAQ,oBAAAC,KAAiB,EA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