@wordpress/editor 14.33.3-next.36001005c.0 → 14.33.4
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.
- package/build/bindings/post-data.js +49 -72
- package/build/bindings/post-data.js.map +3 -3
- package/build/bindings/post-meta.js +46 -47
- package/build/bindings/post-meta.js.map +2 -2
- package/build/bindings/term-data.js +6 -16
- package/build/bindings/term-data.js.map +2 -2
- package/build/components/block-settings-menu/content-only-settings-menu.js +186 -0
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +7 -0
- package/build/components/collab-sidebar/add-comment.js +34 -7
- package/build/components/collab-sidebar/add-comment.js.map +3 -3
- package/build/components/collab-sidebar/comment-author-info.js +27 -15
- package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +15 -45
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
- package/build/components/collab-sidebar/comments.js +137 -35
- package/build/components/collab-sidebar/comments.js.map +3 -3
- package/build/components/collab-sidebar/hooks.js +8 -7
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/collab-sidebar/index.js +56 -60
- package/build/components/collab-sidebar/index.js.map +3 -3
- package/build/components/editor/index.js +2 -0
- package/build/components/editor/index.js.map +3 -3
- package/build/components/header/index.js +0 -3
- package/build/components/header/index.js.map +3 -3
- package/build/components/more-menu/index.js +1 -1
- package/build/components/more-menu/index.js.map +2 -2
- package/build/components/post-template/hooks.js +7 -38
- package/build/components/post-template/hooks.js.map +2 -2
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +3 -3
- package/build/components/visual-editor/index.js +20 -9
- package/build/components/visual-editor/index.js.map +2 -2
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +2 -2
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +2 -2
- package/build/store/private-selectors.js +5 -0
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +10 -0
- package/build/store/reducer.js.map +2 -2
- package/build-module/bindings/post-data.js +49 -72
- package/build-module/bindings/post-data.js.map +2 -2
- package/build-module/bindings/post-meta.js +46 -47
- package/build-module/bindings/post-meta.js.map +2 -2
- package/build-module/bindings/term-data.js +6 -16
- package/build-module/bindings/term-data.js.map +2 -2
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +161 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +7 -0
- package/build-module/components/collab-sidebar/add-comment.js +36 -9
- package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-author-info.js +27 -15
- package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +21 -37
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
- package/build-module/components/collab-sidebar/comments.js +147 -38
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +8 -7
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/collab-sidebar/index.js +56 -60
- package/build-module/components/collab-sidebar/index.js.map +2 -2
- package/build-module/components/editor/index.js +2 -0
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/header/index.js +0 -3
- package/build-module/components/header/index.js.map +2 -2
- package/build-module/components/more-menu/index.js +1 -1
- package/build-module/components/more-menu/index.js.map +2 -2
- package/build-module/components/post-template/hooks.js +7 -38
- package/build-module/components/post-template/hooks.js.map +2 -2
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +2 -2
- package/build-module/components/visual-editor/index.js +20 -9
- package/build-module/components/visual-editor/index.js.map +2 -2
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +2 -2
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +2 -2
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +9 -0
- package/build-module/store/reducer.js.map +2 -2
- package/build-style/style-rtl.css +18 -66
- package/build-style/style.css +18 -66
- package/build-types/bindings/post-data.d.ts +20 -20
- package/build-types/bindings/post-meta.d.ts +1 -14
- package/build-types/bindings/term-data.d.ts +6 -16
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts +2 -0
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/add-comment.d.ts +6 -1
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +1 -2
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts +12 -26
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts +1 -4
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/editor/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +7 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +10 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/package.json +38 -38
- package/src/bindings/post-data.js +65 -124
- package/src/bindings/post-meta.js +56 -58
- package/src/bindings/term-data.js +6 -21
- package/src/bindings/test/post-meta.js +211 -0
- package/src/components/block-settings-menu/content-only-settings-menu.js +185 -0
- package/src/components/block-settings-menu/content-only-settings-menu.native.js +4 -0
- package/src/components/block-settings-menu/style.scss +6 -0
- package/src/components/collab-sidebar/add-comment.js +41 -8
- package/src/components/collab-sidebar/comment-author-info.js +33 -26
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +25 -51
- package/src/components/collab-sidebar/comments.js +147 -43
- package/src/components/collab-sidebar/hooks.js +9 -8
- package/src/components/collab-sidebar/index.js +58 -48
- package/src/components/collab-sidebar/style.scss +8 -69
- package/src/components/editor/index.js +2 -0
- package/src/components/editor-help/style.scss +1 -1
- package/src/components/header/index.js +0 -7
- package/src/components/more-menu/index.js +1 -1
- package/src/components/post-last-revision/style.scss +1 -1
- package/src/components/post-panel-row/style.scss +0 -1
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-template/hooks.js +10 -51
- package/src/components/provider/index.js +3 -4
- package/src/components/visual-editor/index.js +27 -6
- package/src/store/actions.js +4 -1
- package/src/store/private-actions.js +13 -0
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +16 -0
- package/src/style.scss +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
BlockSettingsMenuControls,
|
|
4
|
+
__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,
|
|
5
|
+
store as blockEditorStore,
|
|
6
|
+
useBlockDisplayInformation
|
|
7
|
+
} from "@wordpress/block-editor";
|
|
8
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
9
|
+
import { __experimentalText as Text, MenuItem } from "@wordpress/components";
|
|
10
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
11
|
+
import { __, _x } from "@wordpress/i18n";
|
|
12
|
+
import { store as editorStore } from "../../store";
|
|
13
|
+
import { unlock } from "../../lock-unlock";
|
|
14
|
+
import usePostContentBlocks from "../provider/use-post-content-blocks";
|
|
15
|
+
function ContentOnlySettingsMenuItems({ clientId, onClose }) {
|
|
16
|
+
const postContentBlocks = usePostContentBlocks();
|
|
17
|
+
const { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(
|
|
18
|
+
(select) => {
|
|
19
|
+
const {
|
|
20
|
+
getBlockParentsByBlockName,
|
|
21
|
+
getSettings,
|
|
22
|
+
getBlockAttributes,
|
|
23
|
+
getBlockParents
|
|
24
|
+
} = select(blockEditorStore);
|
|
25
|
+
const { getCurrentTemplateId, getRenderingMode } = select(editorStore);
|
|
26
|
+
const patternParent = getBlockParentsByBlockName(
|
|
27
|
+
clientId,
|
|
28
|
+
"core/block",
|
|
29
|
+
true
|
|
30
|
+
)[0];
|
|
31
|
+
let record;
|
|
32
|
+
if (patternParent) {
|
|
33
|
+
record = select(coreStore).getEntityRecord(
|
|
34
|
+
"postType",
|
|
35
|
+
"wp_block",
|
|
36
|
+
getBlockAttributes(patternParent).ref
|
|
37
|
+
);
|
|
38
|
+
} else if (getRenderingMode() === "template-locked" && !getBlockParents(clientId).some(
|
|
39
|
+
(parent) => postContentBlocks.includes(parent)
|
|
40
|
+
)) {
|
|
41
|
+
record = select(coreStore).getEntityRecord(
|
|
42
|
+
"postType",
|
|
43
|
+
"wp_template",
|
|
44
|
+
getCurrentTemplateId()
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (!record) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
const _canEditTemplates = select(coreStore).canUser("create", {
|
|
51
|
+
kind: "postType",
|
|
52
|
+
name: "wp_template"
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
canEditTemplates: _canEditTemplates,
|
|
56
|
+
entity: record,
|
|
57
|
+
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
[clientId, postContentBlocks]
|
|
61
|
+
);
|
|
62
|
+
if (!entity) {
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
TemplateLockContentOnlyMenuItems,
|
|
65
|
+
{
|
|
66
|
+
clientId,
|
|
67
|
+
onClose
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const isPattern = entity.type === "wp_block";
|
|
72
|
+
let helpText = isPattern ? __(
|
|
73
|
+
"Edit the pattern to move, delete, or make further changes to this block."
|
|
74
|
+
) : __(
|
|
75
|
+
"Edit the template to move, delete, or make further changes to this block."
|
|
76
|
+
);
|
|
77
|
+
if (!canEditTemplates) {
|
|
78
|
+
helpText = __(
|
|
79
|
+
"Only users with permissions to edit the template can move or delete this block"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx(BlockSettingsMenuFirstItem, { children: /* @__PURE__ */ jsx(
|
|
84
|
+
MenuItem,
|
|
85
|
+
{
|
|
86
|
+
onClick: () => {
|
|
87
|
+
onNavigateToEntityRecord({
|
|
88
|
+
postId: entity.id,
|
|
89
|
+
postType: entity.type
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
disabled: !canEditTemplates,
|
|
93
|
+
children: isPattern ? __("Edit pattern") : __("Edit template")
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
Text,
|
|
98
|
+
{
|
|
99
|
+
variant: "muted",
|
|
100
|
+
as: "p",
|
|
101
|
+
className: "editor-content-only-settings-menu__description",
|
|
102
|
+
children: helpText
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] });
|
|
106
|
+
}
|
|
107
|
+
function TemplateLockContentOnlyMenuItems({ clientId, onClose }) {
|
|
108
|
+
const { contentLockingParent } = useSelect(
|
|
109
|
+
(select) => {
|
|
110
|
+
const { getContentLockingParent } = unlock(
|
|
111
|
+
select(blockEditorStore)
|
|
112
|
+
);
|
|
113
|
+
return {
|
|
114
|
+
contentLockingParent: getContentLockingParent(clientId)
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
[clientId]
|
|
118
|
+
);
|
|
119
|
+
const blockDisplayInformation = useBlockDisplayInformation(contentLockingParent);
|
|
120
|
+
const blockEditorActions = useDispatch(blockEditorStore);
|
|
121
|
+
if (!blockDisplayInformation?.title) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const { modifyContentLockBlock } = unlock(blockEditorActions);
|
|
125
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
126
|
+
/* @__PURE__ */ jsx(BlockSettingsMenuFirstItem, { children: /* @__PURE__ */ jsx(
|
|
127
|
+
MenuItem,
|
|
128
|
+
{
|
|
129
|
+
onClick: () => {
|
|
130
|
+
modifyContentLockBlock(contentLockingParent);
|
|
131
|
+
onClose();
|
|
132
|
+
},
|
|
133
|
+
children: _x("Unlock", "Unlock content locked blocks")
|
|
134
|
+
}
|
|
135
|
+
) }),
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
Text,
|
|
138
|
+
{
|
|
139
|
+
variant: "muted",
|
|
140
|
+
as: "p",
|
|
141
|
+
className: "editor-content-only-settings-menu__description",
|
|
142
|
+
children: __(
|
|
143
|
+
"Temporarily unlock the parent block to edit, delete or make further changes to this block."
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
function ContentOnlySettingsMenu() {
|
|
150
|
+
return /* @__PURE__ */ jsx(BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => selectedClientIds.length === 1 && /* @__PURE__ */ jsx(
|
|
151
|
+
ContentOnlySettingsMenuItems,
|
|
152
|
+
{
|
|
153
|
+
clientId: selectedClientIds[0],
|
|
154
|
+
onClose
|
|
155
|
+
}
|
|
156
|
+
) });
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
ContentOnlySettingsMenu as default
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=content-only-settings-menu.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/block-settings-menu/content-only-settings-menu.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport usePostContentBlocks from '../provider/use-post-content-blocks';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst postContentBlocks = usePostContentBlocks();\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockParents,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getCurrentTemplateId, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tgetRenderingMode() === 'template-locked' &&\n\t\t\t\t! getBlockParents( clientId ).some( ( parent ) =>\n\t\t\t\t\tpostContentBlocks.includes( parent )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tgetCurrentTemplateId()\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( ! record ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId, postContentBlocks ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
2
3
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { useSelect } from "@wordpress/data";
|
|
4
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
4
5
|
import {
|
|
5
6
|
__experimentalHStack as HStack,
|
|
6
7
|
__experimentalVStack as VStack
|
|
@@ -12,13 +13,17 @@ import {
|
|
|
12
13
|
import { unlock } from "../../lock-unlock";
|
|
13
14
|
import CommentAuthorInfo from "./comment-author-info";
|
|
14
15
|
import CommentForm from "./comment-form";
|
|
15
|
-
import { focusCommentThread } from "./utils";
|
|
16
|
+
import { focusCommentThread, noop } from "./utils";
|
|
16
17
|
const { useBlockElement } = unlock(blockEditorPrivateApis);
|
|
17
18
|
function AddComment({
|
|
18
19
|
onSubmit,
|
|
19
20
|
showCommentBoard,
|
|
20
21
|
setShowCommentBoard,
|
|
21
|
-
commentSidebarRef
|
|
22
|
+
commentSidebarRef,
|
|
23
|
+
reflowComments = noop,
|
|
24
|
+
isFloating = false,
|
|
25
|
+
y,
|
|
26
|
+
refs
|
|
22
27
|
}) {
|
|
23
28
|
const { clientId, blockCommentId } = useSelect((select) => {
|
|
24
29
|
const { getSelectedBlock } = select(blockEditorStore);
|
|
@@ -29,16 +34,40 @@ function AddComment({
|
|
|
29
34
|
};
|
|
30
35
|
}, []);
|
|
31
36
|
const blockElement = useBlockElement(clientId);
|
|
37
|
+
const { toggleBlockSpotlight } = unlock(useDispatch(blockEditorStore));
|
|
38
|
+
const unselectThread = () => {
|
|
39
|
+
setShowCommentBoard(false);
|
|
40
|
+
blockElement?.focus();
|
|
41
|
+
toggleBlockSpotlight(clientId, false);
|
|
42
|
+
};
|
|
32
43
|
if (!showCommentBoard || !clientId || void 0 !== blockCommentId) {
|
|
33
44
|
return null;
|
|
34
45
|
}
|
|
35
46
|
return /* @__PURE__ */ jsxs(
|
|
36
47
|
VStack,
|
|
37
48
|
{
|
|
38
|
-
className:
|
|
49
|
+
className: clsx(
|
|
50
|
+
"editor-collab-sidebar-panel__thread is-selected",
|
|
51
|
+
{
|
|
52
|
+
"is-floating": isFloating
|
|
53
|
+
}
|
|
54
|
+
),
|
|
39
55
|
spacing: "3",
|
|
40
56
|
tabIndex: 0,
|
|
57
|
+
"aria-label": __("New note"),
|
|
41
58
|
role: "listitem",
|
|
59
|
+
ref: isFloating ? refs.setFloating : void 0,
|
|
60
|
+
style: isFloating ? (
|
|
61
|
+
// Delay showing the floating note box until a Y position is known to prevent blink.
|
|
62
|
+
{ top: y, opacity: !y ? 0 : void 0 }
|
|
63
|
+
) : void 0,
|
|
64
|
+
onBlur: (event) => {
|
|
65
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
toggleBlockSpotlight(clientId, false);
|
|
69
|
+
setShowCommentBoard(false);
|
|
70
|
+
},
|
|
42
71
|
children: [
|
|
43
72
|
/* @__PURE__ */ jsx(HStack, { alignment: "left", spacing: "3", children: /* @__PURE__ */ jsx(CommentAuthorInfo, {}) }),
|
|
44
73
|
/* @__PURE__ */ jsx(
|
|
@@ -49,12 +78,10 @@ function AddComment({
|
|
|
49
78
|
focusCommentThread(id, commentSidebarRef.current);
|
|
50
79
|
setShowCommentBoard(false);
|
|
51
80
|
},
|
|
52
|
-
onCancel:
|
|
53
|
-
|
|
54
|
-
blockElement?.focus();
|
|
55
|
-
},
|
|
81
|
+
onCancel: unselectThread,
|
|
82
|
+
reflowComments,
|
|
56
83
|
submitButtonText: __("Add note"),
|
|
57
|
-
labelText: __("New
|
|
84
|
+
labelText: __("New note")
|
|
58
85
|
}
|
|
59
86
|
)
|
|
60
87
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/add-comment.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } 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 } from './utils';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\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\n\tif ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName
|
|
5
|
-
"mappings": "
|
|
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": "AA4DE,SA2BE,KA3BF;AAzDF,OAAO,UAAU;AAIjB,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AACxB,SAAS,oBAAoB,YAAY;AAEzC,MAAM,EAAE,gBAAgB,IAAI,OAAQ,sBAAuB;AAEpD,SAAS,WAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,UAAU,eAAe,IAAI,UAAW,CAAE,WAAY;AAC7D,UAAM,EAAE,iBAAiB,IAAI,OAAQ,gBAAiB;AACtD,UAAM,gBAAgB,iBAAiB;AACvC,WAAO;AAAA,MACN,UAAU,eAAe;AAAA,MACzB,gBAAgB,eAAe,YAAY,UAAU;AAAA,IACtD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,eAAe,gBAAiB,QAAS;AAC/C,QAAM,EAAE,qBAAqB,IAAI,OAAQ,YAAa,gBAAiB,CAAE;AAEzE,QAAM,iBAAiB,MAAM;AAC5B,wBAAqB,KAAM;AAC3B,kBAAc,MAAM;AACpB,yBAAsB,UAAU,KAAM;AAAA,EACvC;AAEA,MAAK,CAAE,oBAAoB,CAAE,YAAY,WAAc,gBAAiB;AACvE,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY;AAAA,QACX;AAAA,QACA;AAAA,UACC,eAAe;AAAA,QAChB;AAAA,MACD;AAAA,MACA,SAAQ;AAAA,MACR,UAAW;AAAA,MACX,cAAa,GAAI,UAAW;AAAA,MAC5B,MAAK;AAAA,MACL,KAAM,aAAa,KAAK,cAAc;AAAA,MACtC,OACC;AAAA;AAAA,QAEG,EAAE,KAAK,GAAG,SAAS,CAAE,IAAI,IAAI,OAAU;AAAA,UACvC;AAAA,MAEJ,QAAS,CAAE,UAAW;AACrB,YAAK,MAAM,cAAc,SAAU,MAAM,aAAc,GAAI;AAC1D;AAAA,QACD;AACA,6BAAsB,UAAU,KAAM;AACtC,4BAAqB,KAAM;AAAA,MAC5B;AAAA,MAEA;AAAA,4BAAC,UAAO,WAAU,QAAO,SAAQ,KAChC,8BAAC,qBAAkB,GACpB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,UAAW,OAAQ,iBAAkB;AACpC,oBAAM,EAAE,GAAG,IAAI,MAAM,SAAU,EAAE,SAAS,aAAa,CAAE;AACzD,iCAAoB,IAAI,kBAAkB,OAAQ;AAClD,kCAAqB,KAAM;AAAA,YAC5B;AAAA,YACA,UAAW;AAAA,YACX;AAAA,YACA,kBAAmB,GAAI,UAAW;AAAA,YAClC,WAAY,GAAI,UAAW;AAAA;AAAA,QAC5B;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,26 +12,38 @@ import { useSelect } from "@wordpress/data";
|
|
|
12
12
|
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
13
13
|
import { getAvatarBorderColor } from "./utils";
|
|
14
14
|
function CommentAuthorInfo({ avatar, name, date, userId }) {
|
|
15
|
+
const hasAvatar = !!avatar;
|
|
15
16
|
const dateSettings = getDateSettings();
|
|
16
17
|
const {
|
|
17
18
|
currentUserAvatar,
|
|
18
19
|
currentUserName,
|
|
19
20
|
currentUserId,
|
|
20
21
|
dateFormat = dateSettings.formats.date
|
|
21
|
-
} = useSelect(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
} = useSelect(
|
|
23
|
+
(select) => {
|
|
24
|
+
const { canUser, getCurrentUser, getEntityRecord } = select(coreStore);
|
|
25
|
+
const siteSettings = canUser("read", {
|
|
26
|
+
kind: "root",
|
|
27
|
+
name: "site"
|
|
28
|
+
}) ? getEntityRecord("root", "site") : void 0;
|
|
29
|
+
if (hasAvatar) {
|
|
30
|
+
return {
|
|
31
|
+
dateFormat: siteSettings?.date_format
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const { getSettings } = select(blockEditorStore);
|
|
35
|
+
const { __experimentalDiscussionSettings } = getSettings();
|
|
36
|
+
const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
|
|
37
|
+
const userData = getCurrentUser();
|
|
38
|
+
return {
|
|
39
|
+
currentUserAvatar: userData?.avatar_urls?.[48] ?? defaultAvatar,
|
|
40
|
+
currentUserName: userData?.name,
|
|
41
|
+
currentUserId: userData?.id,
|
|
42
|
+
dateFormat: siteSettings?.date_format
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
[hasAvatar]
|
|
46
|
+
);
|
|
35
47
|
const commentDate = getDate(date);
|
|
36
48
|
const commentDateTime = dateI18n("c", commentDate);
|
|
37
49
|
const shouldShowHumanTimeDiff = Math.floor((/* @__PURE__ */ new Date() - commentDate) / (1e3 * 60 * 60 * 24)) < 30;
|
|
@@ -59,7 +71,7 @@ function CommentAuthorInfo({ avatar, name, date, userId }) {
|
|
|
59
71
|
),
|
|
60
72
|
/* @__PURE__ */ jsxs(VStack, { spacing: "0", children: [
|
|
61
73
|
/* @__PURE__ */ jsx("span", { className: "editor-collab-sidebar-panel__user-name", children: name ?? currentUserName }),
|
|
62
|
-
date && /* @__PURE__ */ jsx(Tooltip, {
|
|
74
|
+
date && /* @__PURE__ */ jsx(Tooltip, { text: tooltipText, children: /* @__PURE__ */ jsx(
|
|
63
75
|
"time",
|
|
64
76
|
{
|
|
65
77
|
dateTime: commentDateTime,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/comment-author-info.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Tooltip, __experimentalVStack as VStack } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Tooltip, __experimentalVStack as VStack } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\nfunction CommentAuthorInfo( { avatar, name, date, userId } ) {\n\tconst hasAvatar = !! avatar;\n\tconst dateSettings = getDateSettings();\n\tconst {\n\t\tcurrentUserAvatar,\n\t\tcurrentUserName,\n\t\tcurrentUserId,\n\t\tdateFormat = dateSettings.formats.date,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getCurrentUser, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tif ( hasAvatar ) {\n\t\t\t\treturn {\n\t\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\t\tconst userData = getCurrentUser();\n\t\t\treturn {\n\t\t\t\tcurrentUserAvatar:\n\t\t\t\t\tuserData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\t\tcurrentUserName: userData?.name,\n\t\t\t\tcurrentUserId: userData?.id,\n\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t};\n\t\t},\n\t\t[ hasAvatar ]\n\t);\n\n\tconst commentDate = getDate( date );\n\tconst commentDateTime = dateI18n( 'c', commentDate );\n\tconst shouldShowHumanTimeDiff =\n\t\tMath.floor( ( new Date() - commentDate ) / ( 1000 * 60 * 60 * 24 ) ) <\n\t\t30;\n\n\tconst commentDateText = shouldShowHumanTimeDiff\n\t\t? humanTimeDiff( commentDate )\n\t\t: dateI18n( dateFormat, commentDate );\n\n\tconst tooltipText = dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'Note date full date format' ),\n\t\tdate\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ avatar || currentUserAvatar }\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\talt={ __( 'User avatar' ) }\n\t\t\t\twidth={ 32 }\n\t\t\t\theight={ 32 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\tuserId ?? currentUserId\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<VStack spacing=\"0\">\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ name ?? currentUserName }\n\t\t\t\t</span>\n\t\t\t\t{ date && (\n\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t<time\n\t\t\t\t\t\t\tdateTime={ commentDateTime }\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ commentDateText }\n\t\t\t\t\t\t</time>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default CommentAuthorInfo;\n"],
|
|
5
|
+
"mappings": "AA6EE,mBACC,KAaA,YAdD;AA1EF,SAAS,SAAS,wBAAwB,cAAc;AACxD,SAAS,IAAI,UAAU;AACvB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAK1C,SAAS,4BAA4B;AAErC,SAAS,kBAAmB,EAAE,QAAQ,MAAM,MAAM,OAAO,GAAI;AAC5D,QAAM,YAAY,CAAC,CAAE;AACrB,QAAM,eAAe,gBAAgB;AACrC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,aAAa,QAAQ;AAAA,EACnC,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM,EAAE,SAAS,gBAAgB,gBAAgB,IAChD,OAAQ,SAAU;AACnB,YAAM,eAAe,QAAS,QAAQ;AAAA,QACrC,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC;AAEH,UAAK,WAAY;AAChB,eAAO;AAAA,UACN,YAAY,cAAc;AAAA,QAC3B;AAAA,MACD;AAEA,YAAM,EAAE,YAAY,IAAI,OAAQ,gBAAiB;AACjD,YAAM,EAAE,iCAAiC,IAAI,YAAY;AACzD,YAAM,gBAAgB,kCAAkC;AACxD,YAAM,WAAW,eAAe;AAChC,aAAO;AAAA,QACN,mBACC,UAAU,cAAe,EAAG,KAAK;AAAA,QAClC,iBAAiB,UAAU;AAAA,QAC3B,eAAe,UAAU;AAAA,QACzB,YAAY,cAAc;AAAA,MAC3B;AAAA,IACD;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AAEA,QAAM,cAAc,QAAS,IAAK;AAClC,QAAM,kBAAkB,SAAU,KAAK,WAAY;AACnD,QAAM,0BACL,KAAK,OAAS,oBAAI,KAAK,IAAI,gBAAkB,MAAO,KAAK,KAAK,GAAK,IACnE;AAED,QAAM,kBAAkB,0BACrB,cAAe,WAAY,IAC3B,SAAU,YAAY,WAAY;AAErC,QAAM,cAAc;AAAA;AAAA,IAEnB,GAAI,mBAAmB,4BAA6B;AAAA,IACpD;AAAA,EACD;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,KAAM,UAAU;AAAA,QAChB,WAAU;AAAA,QAEV,KAAM,GAAI,aAAc;AAAA,QACxB,OAAQ;AAAA,QACR,QAAS;AAAA,QACT,OAAQ;AAAA,UACP,aAAa;AAAA,YACZ,UAAU;AAAA,UACX;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IACA,qBAAC,UAAO,SAAQ,KACf;AAAA,0BAAC,UAAK,WAAU,0CACb,kBAAQ,iBACX;AAAA,MACE,QACD,oBAAC,WAAQ,MAAO,aACf;AAAA,QAAC;AAAA;AAAA,UACA,UAAW;AAAA,UACX,WAAU;AAAA,UAER;AAAA;AAAA,MACH,GACD;AAAA,OAEF;AAAA,KACD;AAEF;AAEA,IAAO,8BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ToolbarButton,
|
|
4
|
+
__experimentalText as Text,
|
|
5
|
+
__experimentalHStack as HStack
|
|
6
|
+
} from "@wordpress/components";
|
|
7
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
4
8
|
import { useMemo } from "@wordpress/element";
|
|
5
9
|
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
|
|
6
|
-
import clsx from "clsx";
|
|
7
10
|
import { unlock } from "../../lock-unlock";
|
|
8
11
|
import { getAvatarBorderColor } from "./utils";
|
|
9
12
|
const { CommentIconToolbarSlotFill } = unlock(blockEditorPrivateApis);
|
|
10
|
-
const CommentAvatarIndicator = ({ onClick, thread
|
|
13
|
+
const CommentAvatarIndicator = ({ onClick, thread }) => {
|
|
11
14
|
const threadParticipants = useMemo(() => {
|
|
12
15
|
if (!thread) {
|
|
13
16
|
return [];
|
|
@@ -17,13 +20,11 @@ const CommentAvatarIndicator = ({ onClick, thread, hasMoreComments }) => {
|
|
|
17
20
|
allComments.sort((a, b) => new Date(a.date) - new Date(b.date));
|
|
18
21
|
allComments.forEach((comment) => {
|
|
19
22
|
if (comment.author_name && comment.author_avatar_urls) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
participantsMap.set(authorKey, {
|
|
23
|
+
if (!participantsMap.has(comment.author)) {
|
|
24
|
+
participantsMap.set(comment.author, {
|
|
23
25
|
name: comment.author_name,
|
|
24
26
|
avatar: comment.author_avatar_urls?.["48"] || comment.author_avatar_urls?.["96"],
|
|
25
27
|
id: comment.author,
|
|
26
|
-
isOriginalCommenter: comment.id === thread.id,
|
|
27
28
|
date: comment.date
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -31,62 +32,45 @@ const CommentAvatarIndicator = ({ onClick, thread, hasMoreComments }) => {
|
|
|
31
32
|
});
|
|
32
33
|
return Array.from(participantsMap.values());
|
|
33
34
|
}, [thread]);
|
|
34
|
-
const hasUnresolved = thread?.status !== "approved";
|
|
35
|
-
const threadHasMoreParticipants = hasMoreComments && thread?.reply && 1 + thread.reply.length >= 100;
|
|
36
35
|
if (!threadParticipants.length) {
|
|
37
36
|
return null;
|
|
38
37
|
}
|
|
39
38
|
const maxAvatars = 3;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
39
|
+
const isOverflow = threadParticipants.length > maxAvatars;
|
|
40
|
+
const visibleParticipants = isOverflow ? threadParticipants.slice(0, maxAvatars - 1) : threadParticipants;
|
|
41
|
+
const overflowCount = Math.max(
|
|
42
|
+
0,
|
|
43
|
+
threadParticipants.length - visibleParticipants.length
|
|
44
|
+
);
|
|
45
|
+
const threadHasMoreParticipants = threadParticipants.length > 100;
|
|
42
46
|
const overflowText = threadHasMoreParticipants && overflowCount > 0 ? __("100+") : sprintf(
|
|
43
47
|
// translators: %s: Number of participants.
|
|
44
48
|
__("+%s"),
|
|
45
49
|
overflowCount
|
|
46
50
|
);
|
|
47
|
-
const overflowTitle = threadHasMoreParticipants && overflowCount > 0 ? __("100+ participants") : sprintf(
|
|
48
|
-
// translators: %s: Number of participants.
|
|
49
|
-
_n(
|
|
50
|
-
"+%s more participant",
|
|
51
|
-
"+%s more participants",
|
|
52
|
-
overflowCount
|
|
53
|
-
),
|
|
54
|
-
overflowCount
|
|
55
|
-
);
|
|
56
51
|
return /* @__PURE__ */ jsx(CommentIconToolbarSlotFill.Fill, { children: /* @__PURE__ */ jsx(
|
|
57
52
|
ToolbarButton,
|
|
58
53
|
{
|
|
59
|
-
className:
|
|
60
|
-
"has-unresolved": hasUnresolved
|
|
61
|
-
}),
|
|
54
|
+
className: "comment-avatar-indicator",
|
|
62
55
|
label: __("View notes"),
|
|
63
56
|
onClick,
|
|
64
57
|
showTooltip: true,
|
|
65
|
-
children: /* @__PURE__ */ jsxs(
|
|
66
|
-
visibleParticipants.map((participant
|
|
58
|
+
children: /* @__PURE__ */ jsxs(HStack, { spacing: "1", children: [
|
|
59
|
+
visibleParticipants.map((participant) => /* @__PURE__ */ jsx(
|
|
67
60
|
"img",
|
|
68
61
|
{
|
|
69
62
|
src: participant.avatar,
|
|
70
63
|
alt: participant.name,
|
|
71
64
|
className: "comment-avatar",
|
|
72
65
|
style: {
|
|
73
|
-
zIndex: maxAvatars - index,
|
|
74
66
|
borderColor: getAvatarBorderColor(
|
|
75
67
|
participant.id
|
|
76
68
|
)
|
|
77
69
|
}
|
|
78
70
|
},
|
|
79
|
-
participant.
|
|
71
|
+
participant.id
|
|
80
72
|
)),
|
|
81
|
-
overflowCount > 0 && /* @__PURE__ */ jsx(
|
|
82
|
-
"div",
|
|
83
|
-
{
|
|
84
|
-
className: "comment-avatar-overflow",
|
|
85
|
-
style: { zIndex: 0 },
|
|
86
|
-
title: overflowTitle,
|
|
87
|
-
children: overflowText
|
|
88
|
-
}
|
|
89
|
-
)
|
|
73
|
+
overflowCount > 0 && /* @__PURE__ */ jsx(Text, { weight: 500, children: overflowText })
|
|
90
74
|
] })
|
|
91
75
|
}
|
|
92
76
|
) });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/comment-indicator-toolbar.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarBorderColor } from './utils';\n\nconst { CommentIconToolbarSlotFill } = unlock( blockEditorPrivateApis );\n\nconst CommentAvatarIndicator = ( { onClick, thread } ) => {\n\tconst threadParticipants = useMemo( () => {\n\t\tif ( ! thread ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst participantsMap = new Map();\n\t\tconst allComments = [ thread, ...thread.reply ];\n\n\t\t// Sort by date to show participants in chronological order.\n\t\tallComments.sort( ( a, b ) => new Date( a.date ) - new Date( b.date ) );\n\n\t\tallComments.forEach( ( comment ) => {\n\t\t\t// Track thread participants (original commenter + repliers).\n\t\t\tif ( comment.author_name && comment.author_avatar_urls ) {\n\t\t\t\tif ( ! participantsMap.has( comment.author ) ) {\n\t\t\t\t\tparticipantsMap.set( comment.author, {\n\t\t\t\t\t\tname: comment.author_name,\n\t\t\t\t\t\tavatar:\n\t\t\t\t\t\t\tcomment.author_avatar_urls?.[ '48' ] ||\n\t\t\t\t\t\t\tcomment.author_avatar_urls?.[ '96' ],\n\t\t\t\t\t\tid: comment.author,\n\t\t\t\t\t\tdate: comment.date,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t\treturn Array.from( participantsMap.values() );\n\t}, [ thread ] );\n\n\tif ( ! threadParticipants.length ) {\n\t\treturn null;\n\t}\n\n\t// If there are more than 3 participants, show 2 avatars and a \"+n\" number.\n\tconst maxAvatars = 3;\n\tconst isOverflow = threadParticipants.length > maxAvatars;\n\tconst visibleParticipants = isOverflow\n\t\t? threadParticipants.slice( 0, maxAvatars - 1 )\n\t\t: threadParticipants;\n\tconst overflowCount = Math.max(\n\t\t0,\n\t\tthreadParticipants.length - visibleParticipants.length\n\t);\n\tconst threadHasMoreParticipants = threadParticipants.length > 100;\n\n\t// If we hit the comment limit, show \"100+\" instead of exact overflow count.\n\tconst overflowText =\n\t\tthreadHasMoreParticipants && overflowCount > 0\n\t\t\t? __( '100+' )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: Number of participants.\n\t\t\t\t\t__( '+%s' ),\n\t\t\t\t\toverflowCount\n\t\t\t );\n\n\treturn (\n\t\t<CommentIconToolbarSlotFill.Fill>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"comment-avatar-indicator\"\n\t\t\t\tlabel={ __( 'View notes' ) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tshowTooltip\n\t\t\t>\n\t\t\t\t<HStack spacing=\"1\">\n\t\t\t\t\t{ visibleParticipants.map( ( participant ) => (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tkey={ participant.id }\n\t\t\t\t\t\t\tsrc={ participant.avatar }\n\t\t\t\t\t\t\talt={ participant.name }\n\t\t\t\t\t\t\tclassName=\"comment-avatar\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\tparticipant.id\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t\t{ overflowCount > 0 && (\n\t\t\t\t\t\t<Text weight={ 500 }>{ overflowText }</Text>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</ToolbarButton>\n\t\t</CommentIconToolbarSlotFill.Fill>\n\t);\n};\n\nexport default CommentAvatarIndicator;\n"],
|
|
5
|
+
"mappings": "AAqFI,SAEE,KAFF;AAlFJ;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,OAClB;AACP,SAAS,IAAI,eAAe;AAC5B,SAAS,eAAe;AACxB,SAAS,eAAe,8BAA8B;AAKtD,SAAS,cAAc;AACvB,SAAS,4BAA4B;AAErC,MAAM,EAAE,2BAA2B,IAAI,OAAQ,sBAAuB;AAEtE,MAAM,yBAAyB,CAAE,EAAE,SAAS,OAAO,MAAO;AACzD,QAAM,qBAAqB,QAAS,MAAM;AACzC,QAAK,CAAE,QAAS;AACf,aAAO,CAAC;AAAA,IACT;AAEA,UAAM,kBAAkB,oBAAI,IAAI;AAChC,UAAM,cAAc,CAAE,QAAQ,GAAG,OAAO,KAAM;AAG9C,gBAAY,KAAM,CAAE,GAAG,MAAO,IAAI,KAAM,EAAE,IAAK,IAAI,IAAI,KAAM,EAAE,IAAK,CAAE;AAEtE,gBAAY,QAAS,CAAE,YAAa;AAEnC,UAAK,QAAQ,eAAe,QAAQ,oBAAqB;AACxD,YAAK,CAAE,gBAAgB,IAAK,QAAQ,MAAO,GAAI;AAC9C,0BAAgB,IAAK,QAAQ,QAAQ;AAAA,YACpC,MAAM,QAAQ;AAAA,YACd,QACC,QAAQ,qBAAsB,IAAK,KACnC,QAAQ,qBAAsB,IAAK;AAAA,YACpC,IAAI,QAAQ;AAAA,YACZ,MAAM,QAAQ;AAAA,UACf,CAAE;AAAA,QACH;AAAA,MACD;AAAA,IACD,CAAE;AAEF,WAAO,MAAM,KAAM,gBAAgB,OAAO,CAAE;AAAA,EAC7C,GAAG,CAAE,MAAO,CAAE;AAEd,MAAK,CAAE,mBAAmB,QAAS;AAClC,WAAO;AAAA,EACR;AAGA,QAAM,aAAa;AACnB,QAAM,aAAa,mBAAmB,SAAS;AAC/C,QAAM,sBAAsB,aACzB,mBAAmB,MAAO,GAAG,aAAa,CAAE,IAC5C;AACH,QAAM,gBAAgB,KAAK;AAAA,IAC1B;AAAA,IACA,mBAAmB,SAAS,oBAAoB;AAAA,EACjD;AACA,QAAM,4BAA4B,mBAAmB,SAAS;AAG9D,QAAM,eACL,6BAA6B,gBAAgB,IAC1C,GAAI,MAAO,IACX;AAAA;AAAA,IAEA,GAAI,KAAM;AAAA,IACV;AAAA,EACA;AAEJ,SACC,oBAAC,2BAA2B,MAA3B,EACA;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,GAAI,YAAa;AAAA,MACzB;AAAA,MACA,aAAW;AAAA,MAEX,+BAAC,UAAO,SAAQ,KACb;AAAA,4BAAoB,IAAK,CAAE,gBAC5B;AAAA,UAAC;AAAA;AAAA,YAEA,KAAM,YAAY;AAAA,YAClB,KAAM,YAAY;AAAA,YAClB,WAAU;AAAA,YACV,OAAQ;AAAA,cACP,aAAa;AAAA,gBACZ,YAAY;AAAA,cACb;AAAA,YACD;AAAA;AAAA,UARM,YAAY;AAAA,QASnB,CACC;AAAA,QACA,gBAAgB,KACjB,oBAAC,QAAK,QAAS,KAAQ,wBAAc;AAAA,SAEvC;AAAA;AAAA,EACD,GACD;AAEF;AAEA,IAAO,oCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|