@wordpress/editor 14.30.0 → 14.30.1-next.6f42e1382.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bindings/api.js +2 -0
- package/build/bindings/api.js.map +1 -1
- package/build/bindings/term-data.js +171 -0
- package/build/bindings/term-data.js.map +1 -0
- package/build/components/collab-sidebar/add-comment.js +6 -3
- package/build/components/collab-sidebar/add-comment.js.map +1 -1
- package/build/components/collab-sidebar/comment-form.js +17 -6
- package/build/components/collab-sidebar/comment-form.js.map +1 -1
- package/build/components/collab-sidebar/index.js +8 -11
- package/build/components/collab-sidebar/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +21 -9
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/bindings/api.js +2 -0
- package/build-module/bindings/api.js.map +1 -1
- package/build-module/bindings/term-data.js +165 -0
- package/build-module/bindings/term-data.js.map +1 -0
- package/build-module/components/collab-sidebar/add-comment.js +6 -3
- package/build-module/components/collab-sidebar/add-comment.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-form.js +17 -7
- package/build-module/components/collab-sidebar/comment-form.js.map +1 -1
- package/build-module/components/collab-sidebar/index.js +8 -11
- package/build-module/components/collab-sidebar/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +21 -11
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-types/bindings/api.d.ts.map +1 -1
- package/build-types/bindings/term-data.d.ts +25 -0
- package/build-types/bindings/term-data.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +10 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/bindings/api.js +2 -0
- package/src/bindings/term-data.js +159 -0
- package/src/components/collab-sidebar/add-comment.js +20 -9
- package/src/components/collab-sidebar/comment-form.js +20 -8
- package/src/components/collab-sidebar/index.js +15 -14
- package/src/components/post-taxonomies/hierarchical-term-selector.js +25 -8
- package/tsconfig.tsbuildinfo +1 -1
package/build/bindings/api.js
CHANGED
|
@@ -9,6 +9,7 @@ var _blocks = require("@wordpress/blocks");
|
|
|
9
9
|
var _patternOverrides = _interopRequireDefault(require("./pattern-overrides"));
|
|
10
10
|
var _postData = _interopRequireDefault(require("./post-data"));
|
|
11
11
|
var _postMeta = _interopRequireDefault(require("./post-meta"));
|
|
12
|
+
var _termData = _interopRequireDefault(require("./term-data"));
|
|
12
13
|
/**
|
|
13
14
|
* WordPress dependencies
|
|
14
15
|
*/
|
|
@@ -31,5 +32,6 @@ function registerCoreBlockBindingsSources() {
|
|
|
31
32
|
(0, _blocks.registerBlockBindingsSource)(_patternOverrides.default);
|
|
32
33
|
(0, _blocks.registerBlockBindingsSource)(_postData.default);
|
|
33
34
|
(0, _blocks.registerBlockBindingsSource)(_postMeta.default);
|
|
35
|
+
(0, _blocks.registerBlockBindingsSource)(_termData.default);
|
|
34
36
|
}
|
|
35
37
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_patternOverrides","_interopRequireDefault","_postData","_postMeta","registerCoreBlockBindingsSources","registerBlockBindingsSource","patternOverrides","postData","postMeta"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerBlockBindingsSource } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport patternOverrides from './pattern-overrides';\nimport postData from './post-data';\nimport postMeta from './post-meta';\n\n/**\n * Function to register core block bindings sources provided by the editor.\n *\n * @example\n * ```js\n * import { registerCoreBlockBindingsSources } from '@wordpress/editor';\n *\n * registerCoreBlockBindingsSources();\n * ```\n */\nexport function registerCoreBlockBindingsSources() {\n\tregisterBlockBindingsSource( patternOverrides );\n\tregisterBlockBindingsSource( postData );\n\tregisterBlockBindingsSource( postMeta );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,SAAA,GAAAF,sBAAA,CAAAF,OAAA;
|
|
1
|
+
{"version":3,"names":["_blocks","require","_patternOverrides","_interopRequireDefault","_postData","_postMeta","_termData","registerCoreBlockBindingsSources","registerBlockBindingsSource","patternOverrides","postData","postMeta","termData"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerBlockBindingsSource } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport patternOverrides from './pattern-overrides';\nimport postData from './post-data';\nimport postMeta from './post-meta';\nimport termData from './term-data';\n\n/**\n * Function to register core block bindings sources provided by the editor.\n *\n * @example\n * ```js\n * import { registerCoreBlockBindingsSources } from '@wordpress/editor';\n *\n * registerCoreBlockBindingsSources();\n * ```\n */\nexport function registerCoreBlockBindingsSources() {\n\tregisterBlockBindingsSource( patternOverrides );\n\tregisterBlockBindingsSource( postData );\n\tregisterBlockBindingsSource( postMeta );\n\tregisterBlockBindingsSource( termData );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,SAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,gCAAgCA,CAAA,EAAG;EAClD,IAAAC,mCAA2B,EAAEC,yBAAiB,CAAC;EAC/C,IAAAD,mCAA2B,EAAEE,iBAAS,CAAC;EACvC,IAAAF,mCAA2B,EAAEG,iBAAS,CAAC;EACvC,IAAAH,mCAA2B,EAAEI,iBAAS,CAAC;AACxC","ignoreList":[]}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
var _coreData = require("@wordpress/core-data");
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates the data fields object with the given term data values and ID value.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} termDataValues The term data values.
|
|
17
|
+
* @param {string|number} idValue The ID value to use.
|
|
18
|
+
* @return {Object} The data fields object.
|
|
19
|
+
*/
|
|
20
|
+
function createDataFields(termDataValues, idValue) {
|
|
21
|
+
var _termDataValues$count;
|
|
22
|
+
return {
|
|
23
|
+
id: {
|
|
24
|
+
label: (0, _i18n.__)('Term ID'),
|
|
25
|
+
value: idValue,
|
|
26
|
+
type: 'string'
|
|
27
|
+
},
|
|
28
|
+
name: {
|
|
29
|
+
label: (0, _i18n.__)('Name'),
|
|
30
|
+
value: termDataValues?.name,
|
|
31
|
+
type: 'string'
|
|
32
|
+
},
|
|
33
|
+
slug: {
|
|
34
|
+
label: (0, _i18n.__)('Slug'),
|
|
35
|
+
value: termDataValues?.slug,
|
|
36
|
+
type: 'string'
|
|
37
|
+
},
|
|
38
|
+
link: {
|
|
39
|
+
label: (0, _i18n.__)('Link'),
|
|
40
|
+
value: termDataValues?.link,
|
|
41
|
+
type: 'string'
|
|
42
|
+
},
|
|
43
|
+
description: {
|
|
44
|
+
label: (0, _i18n.__)('Description'),
|
|
45
|
+
value: termDataValues?.description,
|
|
46
|
+
type: 'string'
|
|
47
|
+
},
|
|
48
|
+
parent: {
|
|
49
|
+
label: (0, _i18n.__)('Parent ID'),
|
|
50
|
+
value: termDataValues?.parent,
|
|
51
|
+
type: 'string'
|
|
52
|
+
},
|
|
53
|
+
count: {
|
|
54
|
+
label: (0, _i18n.__)('Count'),
|
|
55
|
+
value: `(${(_termDataValues$count = termDataValues?.count) !== null && _termDataValues$count !== void 0 ? _termDataValues$count : 0})`,
|
|
56
|
+
type: 'string'
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Gets a list of term data fields with their values and labels
|
|
63
|
+
* to be consumed in the needed callbacks.
|
|
64
|
+
* If the value is not available based on context, like in templates,
|
|
65
|
+
* it falls back to the default value, label, or key.
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} select The select function from the data store.
|
|
68
|
+
* @param {Object} context The context provided.
|
|
69
|
+
* @return {Object} List of term data fields with their value and label.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```js
|
|
73
|
+
* {
|
|
74
|
+
* name: {
|
|
75
|
+
* label: 'Term Name',
|
|
76
|
+
* value: 'Category Name',
|
|
77
|
+
* },
|
|
78
|
+
* count: {
|
|
79
|
+
* label: 'Term Count',
|
|
80
|
+
* value: 5,
|
|
81
|
+
* },
|
|
82
|
+
* ...
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function getTermDataFields(select, context) {
|
|
87
|
+
const {
|
|
88
|
+
getEntityRecord
|
|
89
|
+
} = select(_coreData.store);
|
|
90
|
+
let termDataValues, dataFields;
|
|
91
|
+
if (context?.taxonomy && context?.termId) {
|
|
92
|
+
termDataValues = getEntityRecord('taxonomy', context?.taxonomy, context?.termId);
|
|
93
|
+
if (!termDataValues && context?.termData) {
|
|
94
|
+
termDataValues = context.termData;
|
|
95
|
+
}
|
|
96
|
+
if (termDataValues) {
|
|
97
|
+
dataFields = createDataFields(termDataValues, context?.termId);
|
|
98
|
+
}
|
|
99
|
+
} else if (context?.termData) {
|
|
100
|
+
termDataValues = context.termData;
|
|
101
|
+
dataFields = createDataFields(termDataValues, termDataValues?.term_id);
|
|
102
|
+
}
|
|
103
|
+
if (!dataFields || !Object.keys(dataFields).length) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return dataFields;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @type {WPBlockBindingsSource}
|
|
111
|
+
*/
|
|
112
|
+
var _default = exports.default = {
|
|
113
|
+
name: 'core/term-data',
|
|
114
|
+
usesContext: ['taxonomy', 'termId', 'termData'],
|
|
115
|
+
getValues({
|
|
116
|
+
select,
|
|
117
|
+
context,
|
|
118
|
+
bindings
|
|
119
|
+
}) {
|
|
120
|
+
const dataFields = getTermDataFields(select, context);
|
|
121
|
+
const newValues = {};
|
|
122
|
+
for (const [attributeName, source] of Object.entries(bindings)) {
|
|
123
|
+
var _ref;
|
|
124
|
+
// Use the value, the field label, or the field key.
|
|
125
|
+
const fieldKey = source.args.key;
|
|
126
|
+
const {
|
|
127
|
+
value: fieldValue,
|
|
128
|
+
label: fieldLabel
|
|
129
|
+
} = dataFields?.[fieldKey] || {};
|
|
130
|
+
newValues[attributeName] = (_ref = fieldValue !== null && fieldValue !== void 0 ? fieldValue : fieldLabel) !== null && _ref !== void 0 ? _ref : fieldKey;
|
|
131
|
+
}
|
|
132
|
+
return newValues;
|
|
133
|
+
},
|
|
134
|
+
// eslint-disable-next-line no-unused-vars
|
|
135
|
+
setValues({
|
|
136
|
+
dispatch,
|
|
137
|
+
context,
|
|
138
|
+
bindings
|
|
139
|
+
}) {
|
|
140
|
+
// Terms are typically not editable through block bindings in most contexts.
|
|
141
|
+
return false;
|
|
142
|
+
},
|
|
143
|
+
canUserEditValue({
|
|
144
|
+
select,
|
|
145
|
+
context,
|
|
146
|
+
args
|
|
147
|
+
}) {
|
|
148
|
+
// Terms are typically read-only when displayed.
|
|
149
|
+
if (context?.termQuery || context?.termQueryId) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Lock editing when `taxonomy` or `termId` is not defined.
|
|
154
|
+
if (!context?.taxonomy || !context?.termId) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const fieldValue = getTermDataFields(select, context)?.[args.key]?.value;
|
|
158
|
+
// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
|
|
159
|
+
if (fieldValue === undefined) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
},
|
|
164
|
+
getFieldsList({
|
|
165
|
+
select,
|
|
166
|
+
context
|
|
167
|
+
}) {
|
|
168
|
+
return getTermDataFields(select, context);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=term-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_coreData","createDataFields","termDataValues","idValue","_termDataValues$count","id","label","__","value","type","name","slug","link","description","parent","count","getTermDataFields","select","context","getEntityRecord","coreDataStore","dataFields","taxonomy","termId","termData","term_id","Object","keys","length","_default","exports","default","usesContext","getValues","bindings","newValues","attributeName","source","entries","_ref","fieldKey","args","key","fieldValue","fieldLabel","setValues","dispatch","canUserEditValue","termQuery","termQueryId","undefined","getFieldsList"],"sources":["@wordpress/editor/src/bindings/term-data.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Creates the data fields object with the given term data values and ID value.\n *\n * @param {Object} termDataValues The term data values.\n * @param {string|number} idValue The ID value to use.\n * @return {Object} The data fields object.\n */\nfunction createDataFields( termDataValues, idValue ) {\n\treturn {\n\t\tid: {\n\t\t\tlabel: __( 'Term ID' ),\n\t\t\tvalue: idValue,\n\t\t\ttype: 'string',\n\t\t},\n\t\tname: {\n\t\t\tlabel: __( 'Name' ),\n\t\t\tvalue: termDataValues?.name,\n\t\t\ttype: 'string',\n\t\t},\n\t\tslug: {\n\t\t\tlabel: __( 'Slug' ),\n\t\t\tvalue: termDataValues?.slug,\n\t\t\ttype: 'string',\n\t\t},\n\t\tlink: {\n\t\t\tlabel: __( 'Link' ),\n\t\t\tvalue: termDataValues?.link,\n\t\t\ttype: 'string',\n\t\t},\n\t\tdescription: {\n\t\t\tlabel: __( 'Description' ),\n\t\t\tvalue: termDataValues?.description,\n\t\t\ttype: 'string',\n\t\t},\n\t\tparent: {\n\t\t\tlabel: __( 'Parent ID' ),\n\t\t\tvalue: termDataValues?.parent,\n\t\t\ttype: 'string',\n\t\t},\n\t\tcount: {\n\t\t\tlabel: __( 'Count' ),\n\t\t\tvalue: `(${ termDataValues?.count ?? 0 })`,\n\t\t\ttype: 'string',\n\t\t},\n\t};\n}\n\n/**\n * Gets a list of term data fields with their values and labels\n * to be consumed in the needed callbacks.\n * If the value is not available based on context, like in templates,\n * it falls back to the default value, label, or key.\n *\n * @param {Object} select The select function from the data store.\n * @param {Object} context The context provided.\n * @return {Object} List of term data fields with their value and label.\n *\n * @example\n * ```js\n * {\n * name: {\n * label: 'Term Name',\n * value: 'Category Name',\n * },\n * count: {\n * label: 'Term Count',\n * value: 5,\n * },\n * ...\n * }\n * ```\n */\nfunction getTermDataFields( select, context ) {\n\tconst { getEntityRecord } = select( coreDataStore );\n\n\tlet termDataValues, dataFields;\n\tif ( context?.taxonomy && context?.termId ) {\n\t\ttermDataValues = getEntityRecord(\n\t\t\t'taxonomy',\n\t\t\tcontext?.taxonomy,\n\t\t\tcontext?.termId\n\t\t);\n\n\t\tif ( ! termDataValues && context?.termData ) {\n\t\t\ttermDataValues = context.termData;\n\t\t}\n\n\t\tif ( termDataValues ) {\n\t\t\tdataFields = createDataFields( termDataValues, context?.termId );\n\t\t}\n\t} else if ( context?.termData ) {\n\t\ttermDataValues = context.termData;\n\t\tdataFields = createDataFields(\n\t\t\ttermDataValues,\n\t\t\ttermDataValues?.term_id\n\t\t);\n\t}\n\n\tif ( ! dataFields || ! Object.keys( dataFields ).length ) {\n\t\treturn null;\n\t}\n\n\treturn dataFields;\n}\n\n/**\n * @type {WPBlockBindingsSource}\n */\nexport default {\n\tname: 'core/term-data',\n\tusesContext: [ 'taxonomy', 'termId', 'termData' ],\n\tgetValues( { select, context, bindings } ) {\n\t\tconst dataFields = getTermDataFields( select, context );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst fieldKey = source.args.key;\n\t\t\tconst { value: fieldValue, label: fieldLabel } =\n\t\t\t\tdataFields?.[ fieldKey ] || {};\n\t\t\tnewValues[ attributeName ] = fieldValue ?? fieldLabel ?? fieldKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\t// eslint-disable-next-line no-unused-vars\n\tsetValues( { dispatch, context, bindings } ) {\n\t\t// Terms are typically not editable through block bindings in most contexts.\n\t\treturn false;\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Terms are typically read-only when displayed.\n\t\tif ( context?.termQuery || context?.termQueryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Lock editing when `taxonomy` or `termId` is not defined.\n\t\tif ( ! context?.taxonomy || ! context?.termId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fieldValue = getTermDataFields( select, context )?.[ args.key ]\n\t\t\t?.value;\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn false;\n\t},\n\tgetFieldsList( { select, context } ) {\n\t\treturn getTermDataFields( select, context );\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;A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CAAC","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
11
|
var _blockEditor = require("@wordpress/block-editor");
|
|
12
|
+
var _blocks = require("@wordpress/blocks");
|
|
12
13
|
var _commentAuthorInfo = _interopRequireDefault(require("./comment-author-info"));
|
|
13
14
|
var _commentForm = _interopRequireDefault(require("./comment-form"));
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -36,7 +37,8 @@ function AddComment({
|
|
|
36
37
|
}) {
|
|
37
38
|
const {
|
|
38
39
|
clientId,
|
|
39
|
-
blockCommentId
|
|
40
|
+
blockCommentId,
|
|
41
|
+
isEmptyDefaultBlock
|
|
40
42
|
} = (0, _data.useSelect)(select => {
|
|
41
43
|
const {
|
|
42
44
|
getSelectedBlock
|
|
@@ -44,10 +46,11 @@ function AddComment({
|
|
|
44
46
|
const selectedBlock = getSelectedBlock();
|
|
45
47
|
return {
|
|
46
48
|
clientId: selectedBlock?.clientId,
|
|
47
|
-
blockCommentId: selectedBlock?.attributes?.blockCommentId
|
|
49
|
+
blockCommentId: selectedBlock?.attributes?.blockCommentId,
|
|
50
|
+
isEmptyDefaultBlock: selectedBlock ? (0, _blocks.isUnmodifiedDefaultBlock)(selectedBlock) : false
|
|
48
51
|
};
|
|
49
52
|
});
|
|
50
|
-
if (!showCommentBoard || !clientId || undefined !== blockCommentId) {
|
|
53
|
+
if (!showCommentBoard || !clientId || undefined !== blockCommentId || isEmptyDefaultBlock) {
|
|
51
54
|
return null;
|
|
52
55
|
}
|
|
53
56
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_components","_blockEditor","_commentAuthorInfo","_interopRequireDefault","_commentForm","_jsxRuntime","AddComment","onSubmit","showCommentBoard","setShowCommentBoard","clientId","blockCommentId","useSelect","select","getSelectedBlock","blockEditorStore","selectedBlock","attributes","undefined","jsxs","__experimentalVStack","spacing","className","children","jsx","__experimentalHStack","alignment","default","inputComment","onCancel","submitButtonText","_x"],"sources":["@wordpress/editor/src/components/collab-sidebar/add-comment.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\n\n/**\n * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.\n * @param {boolean} props.showCommentBoard - The function to edit the comment.\n * @param {Function} props.setShowCommentBoard - The function to delete the comment.\n * @return {React.ReactNode} The rendered comment input UI.\n */\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\tconst { clientId, blockCommentId } = useSelect(
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_components","_blockEditor","_blocks","_commentAuthorInfo","_interopRequireDefault","_commentForm","_jsxRuntime","AddComment","onSubmit","showCommentBoard","setShowCommentBoard","clientId","blockCommentId","isEmptyDefaultBlock","useSelect","select","getSelectedBlock","blockEditorStore","selectedBlock","attributes","isUnmodifiedDefaultBlock","undefined","jsxs","__experimentalVStack","spacing","className","children","jsx","__experimentalHStack","alignment","default","inputComment","onCancel","submitButtonText","_x"],"sources":["@wordpress/editor/src/components/collab-sidebar/add-comment.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\n\n/**\n * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.\n * @param {boolean} props.showCommentBoard - The function to edit the comment.\n * @param {Function} props.setShowCommentBoard - The function to delete the comment.\n * @return {React.ReactNode} The rendered comment input UI.\n */\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\tconst { clientId, blockCommentId, isEmptyDefaultBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSelectedBlock } = select( blockEditorStore );\n\t\t\tconst selectedBlock = getSelectedBlock();\n\t\t\treturn {\n\t\t\t\tclientId: selectedBlock?.clientId,\n\t\t\t\tblockCommentId: selectedBlock?.attributes?.blockCommentId,\n\t\t\t\tisEmptyDefaultBlock: selectedBlock\n\t\t\t\t\t? isUnmodifiedDefaultBlock( selectedBlock )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t}\n\t);\n\n\tif (\n\t\t! showCommentBoard ||\n\t\t! clientId ||\n\t\tundefined !== blockCommentId ||\n\t\tisEmptyDefaultBlock\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing=\"3\"\n\t\t\tclassName=\"editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread editor-collab-sidebar-panel__focus-thread\"\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={ ( inputComment ) => {\n\t\t\t\t\tonSubmit( inputComment );\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => {\n\t\t\t\t\tsetShowCommentBoard( false );\n\t\t\t\t} }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B,WAAA,CAAAqB,GAAA,EAAC3B,WAAA,CAAA4B,oBAAM;MAACC,SAAS,EAAC,MAAM;MAACL,OAAO,EAAC,GAAG;MAAAE,QAAA,eACnC,IAAApB,WAAA,CAAAqB,GAAA,EAACxB,kBAAA,CAAA2B,OAAiB,IAAE;IAAC,CACd,CAAC,eACT,IAAAxB,WAAA,CAAAqB,GAAA,EAACtB,YAAA,CAAAyB,OAAW;MACXtB,QAAQ,EAAKuB,YAAY,IAAM;QAC9BvB,QAAQ,CAAEuB,YAAa,CAAC;MACzB,CAAG;MACHC,QAAQ,EAAGA,CAAA,KAAM;QAChBtB,mBAAmB,CAAE,KAAM,CAAC;MAC7B,CAAG;MACHuB,gBAAgB,EAAG,IAAAC,QAAE,EAAE,SAAS,EAAE,oBAAqB;IAAG,CAC1D,CAAC;EAAA,CACK,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
var _reactAutosizeTextarea = _interopRequireDefault(require("react-autosize-textarea"));
|
|
7
9
|
var _element = require("@wordpress/element");
|
|
8
10
|
var _components = require("@wordpress/components");
|
|
9
11
|
var _i18n = require("@wordpress/i18n");
|
|
12
|
+
var _compose = require("@wordpress/compose");
|
|
10
13
|
var _utils = require("./utils");
|
|
11
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
/**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
20
|
* WordPress dependencies
|
|
14
21
|
*/
|
|
@@ -34,14 +41,18 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
34
41
|
}) {
|
|
35
42
|
var _thread$content$raw;
|
|
36
43
|
const [inputComment, setInputComment] = (0, _element.useState)((_thread$content$raw = thread?.content?.raw) !== null && _thread$content$raw !== void 0 ? _thread$content$raw : '');
|
|
44
|
+
const inputId = (0, _compose.useInstanceId)(CommentForm, 'comment-input');
|
|
37
45
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
38
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
|
|
47
|
+
as: "label",
|
|
48
|
+
htmlFor: inputId,
|
|
49
|
+
children: (0, _i18n.__)('Comment')
|
|
50
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactAutosizeTextarea.default, {
|
|
51
|
+
id: inputId,
|
|
41
52
|
value: inputComment !== null && inputComment !== void 0 ? inputComment : '',
|
|
42
|
-
onChange: setInputComment,
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
onChange: comment => setInputComment(comment.target.value),
|
|
54
|
+
rows: 4,
|
|
55
|
+
maxRows: 20
|
|
45
56
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
46
57
|
alignment: "left",
|
|
47
58
|
spacing: "3",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactAutosizeTextarea","_interopRequireDefault","require","_element","_components","_i18n","_compose","_utils","_jsxRuntime","CommentForm","onSubmit","onCancel","thread","submitButtonText","_thread$content$raw","inputComment","setInputComment","useState","content","raw","inputId","useInstanceId","jsxs","Fragment","children","jsx","VisuallyHidden","as","htmlFor","__","default","id","value","onChange","comment","target","rows","maxRows","__experimentalHStack","alignment","spacing","justify","Button","__next40pxDefaultSize","accessibleWhenDisabled","variant","onClick","disabled","sanitizeCommentString","length","text","_x","_default","exports"],"sources":["@wordpress/editor/src/components/collab-sidebar/comment-form.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\tButton,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { _x, __ } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { sanitizeCommentString } from './utils';\n\n/**\n * EditComment component.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - The function to call when updating the comment.\n * @param {Function} props.onCancel - The function to call when canceling the comment update.\n * @param {Object} props.thread - The comment thread object.\n * @param {string} props.submitButtonText - The text to display on the submit button.\n * @return {React.ReactNode} The CommentForm component.\n */\nfunction CommentForm( { onSubmit, onCancel, thread, submitButtonText } ) {\n\tconst [ inputComment, setInputComment ] = useState(\n\t\tthread?.content?.raw ?? ''\n\t);\n\n\tconst inputId = useInstanceId( CommentForm, 'comment-input' );\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden as=\"label\" htmlFor={ inputId }>\n\t\t\t\t{ __( 'Comment' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<TextareaAutosize\n\t\t\t\tid={ inputId }\n\t\t\t\tvalue={ inputComment ?? '' }\n\t\t\t\tonChange={ ( comment ) =>\n\t\t\t\t\tsetInputComment( comment.target.value )\n\t\t\t\t}\n\t\t\t\trows={ 4 }\n\t\t\t\tmaxRows={ 20 }\n\t\t\t></TextareaAutosize>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSubmit( inputComment );\n\t\t\t\t\t\tsetInputComment( '' );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={\n\t\t\t\t\t\t0 === sanitizeCommentString( inputComment ).length\n\t\t\t\t\t}\n\t\t\t\t\ttext={ submitButtonText }\n\t\t\t\t/>\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t\ttext={ _x( 'Cancel', 'Cancel comment button' ) }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</>\n\t);\n}\n\nexport default CommentForm;\n"],"mappings":";;;;;;;AAGA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAgD,IAAAM,WAAA,GAAAN,OAAA;AApBhD;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,SAASO,WAAWA,CAAE;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC,MAAM;EAAEC;AAAiB,CAAC,EAAG;EAAA,IAAAC,mBAAA;EACxE,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC,iBAAQ,GAAAH,mBAAA,GACjDF,MAAM,EAAEM,OAAO,EAAEC,GAAG,cAAAL,mBAAA,cAAAA,mBAAA,GAAI,EACzB,CAAC;EAED,MAAMM,OAAO,GAAG,IAAAC,sBAAa,EAAEZ,WAAW,EAAE,eAAgB,CAAC;EAE7D,oBACC,IAAAD,WAAA,CAAAc,IAAA,EAAAd,WAAA,CAAAe,QAAA;IAAAC,QAAA,gBACC,IAAAhB,WAAA,CAAAiB,GAAA,EAACrB,WAAA,CAAAsB,cAAc;MAACC,EAAE,EAAC,OAAO;MAACC,OAAO,EAAGR,OAAS;MAAAI,QAAA,EAC3C,IAAAK,QAAE,EAAE,SAAU;IAAC,CACF,CAAC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|
|
206
205
|
threads
|
|
207
206
|
} = (0, _data.useSelect)(select => {
|
|
208
207
|
const {
|
|
@@ -219,7 +218,6 @@ function CollabSidebar() {
|
|
|
219
218
|
return {
|
|
220
219
|
postId: _postId,
|
|
221
220
|
postType: getCurrentPostType(),
|
|
222
|
-
postStatus: select(_store.store).getEditedPostAttribute('status'),
|
|
223
221
|
threads: data
|
|
224
222
|
};
|
|
225
223
|
}, []);
|
|
@@ -237,7 +235,7 @@ function CollabSidebar() {
|
|
|
237
235
|
}, []);
|
|
238
236
|
const openCollabBoard = () => {
|
|
239
237
|
setShowCommentBoard(true);
|
|
240
|
-
enableComplementaryArea('core',
|
|
238
|
+
enableComplementaryArea('core', _constants.collabHistorySidebarName);
|
|
241
239
|
};
|
|
242
240
|
const [blocks] = (0, _coreData.useEntityBlockEditor)('postType', postType, {
|
|
243
241
|
id: postId
|
|
@@ -246,7 +244,7 @@ function CollabSidebar() {
|
|
|
246
244
|
// Process comments to build the tree structure
|
|
247
245
|
const {
|
|
248
246
|
resultComments,
|
|
249
|
-
|
|
247
|
+
unresolvedSortedThreads
|
|
250
248
|
} = (0, _element.useMemo)(() => {
|
|
251
249
|
// Create a compare to store the references to all objects by id
|
|
252
250
|
const compare = {};
|
|
@@ -274,7 +272,7 @@ function CollabSidebar() {
|
|
|
274
272
|
if (0 === result?.length) {
|
|
275
273
|
return {
|
|
276
274
|
resultComments: [],
|
|
277
|
-
|
|
275
|
+
unresolvedSortedThreads: []
|
|
278
276
|
};
|
|
279
277
|
}
|
|
280
278
|
const updatedResult = result.map(item => ({
|
|
@@ -283,10 +281,12 @@ function CollabSidebar() {
|
|
|
283
281
|
}));
|
|
284
282
|
const blockCommentIds = (0, _utils.getCommentIdsFromBlocks)(blocks);
|
|
285
283
|
const threadIdMap = new Map(updatedResult.map(thread => [thread.id, thread]));
|
|
286
|
-
|
|
284
|
+
|
|
285
|
+
// Get comments by block order, filter out undefined threads, and exclude resolved comments.
|
|
286
|
+
const unresolvedSortedComments = blockCommentIds.map(id => threadIdMap.get(id)).filter(thread => thread !== undefined && thread.status !== 'approved');
|
|
287
287
|
return {
|
|
288
288
|
resultComments: updatedResult,
|
|
289
|
-
|
|
289
|
+
unresolvedSortedThreads: unresolvedSortedComments
|
|
290
290
|
};
|
|
291
291
|
}, [threads, blocks]);
|
|
292
292
|
|
|
@@ -304,9 +304,6 @@ function CollabSidebar() {
|
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
if (postStatus === 'publish') {
|
|
308
|
-
return null; // or maybe return some message indicating no threads are available.
|
|
309
|
-
}
|
|
310
307
|
const AddCommentComponent = blockCommentId ? _commentButtonToolbar.default : _commentButton.default;
|
|
311
308
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
312
309
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AddCommentComponent, {
|
|
@@ -329,7 +326,7 @@ function CollabSidebar() {
|
|
|
329
326
|
className: "editor-collab-sidebar",
|
|
330
327
|
headerClassName: "editor-collab-sidebar__header",
|
|
331
328
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CollabSidebarContent, {
|
|
332
|
-
comments:
|
|
329
|
+
comments: unresolvedSortedThreads,
|
|
333
330
|
showCommentBoard: showCommentBoard,
|
|
334
331
|
setShowCommentBoard: setShowCommentBoard,
|
|
335
332
|
styles: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentButtonToolbar","_globalStylesProvider","_utils","_jsxRuntime","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","useSelect","select","getCurrentPostId","editorStore","_postId","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","addNewComment","comment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","__","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","useEntityBlockEditor","resultComments","sortedThreads","useMemo","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","thread","sortedComments","get","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","collabHistorySidebarName","title","icon","commentIcon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], sortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: updatedResult, sortedThreads: sortedComments };\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tif ( postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ sortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAKA,IAAAS,cAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAL,sBAAA,CAAAV,OAAA;AACA,IAAAgB,qBAAA,GAAAN,sBAAA,CAAAV,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA;AACA,IAAAkB,MAAA,GAAAlB,OAAA;AAAkD,IAAAmB,WAAA,GAAAnB,OAAA;AA7BlD;AACA;AACA;;AAgBA;AACA;AACA;;AAWA,MAAMoB,4BAA4B,GAA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ChCzD,SAAS,EAAC,uBAAuB;MACjCuE,eAAe,EAAC,+BAA+B;MAAArE,QAAA,eAE/C,IAAAtD,WAAA,CAAAuD,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGoE,aAAe;QAC1BvE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR6F;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentButtonToolbar","_globalStylesProvider","_utils","_jsxRuntime","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","useSelect","select","getCurrentPostId","editorStore","_postId","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","addNewComment","comment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","__","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","getCurrentPostType","data","getEntityRecords","per_page","getBlockAttributes","_clientId","openCollabBoard","collabHistorySidebarName","blocks","useEntityBlockEditor","resultComments","unresolvedSortedThreads","useMemo","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","thread","unresolvedSortedComments","get","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","title","icon","commentIcon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', collabHistorySidebarName );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\t// Get comments by block order, filter out undefined threads, and exclude resolved comments.\n\t\tconst unresolvedSortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) =>\n\t\t\t\t\tthread !== undefined && thread.status !== 'approved'\n\t\t\t);\n\n\t\treturn {\n\t\t\tresultComments: updatedResult,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ unresolvedSortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAA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,GAAA,EAACsD,mBAAmB;MAACI,OAAO,EAAGxC;IAAiB,CAAE,CAAC,eACnD,IAAAzE,WAAA,CAAAuD,GAAA,EAACjE,cAAA,CAAA4H,OAAa;MACbC,UAAU,EAAGzC;MACb;MAAA;MACA0C,KAAK,EAAG,IAAA3E,QAAE,EAAE,UAAW,CAAG;MAC1B4E,IAAI,EAAGC,cAAa;MAAAhE,QAAA,eAEpB,IAAAtD,WAAA,CAAAuD,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGkE,cAAgB;QAC3BrE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChB,IAAAT,WAAA,CAAAuD,GAAA,EAACjE,cAAA,CAAA4H,OAAa;MACbK,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBL,UAAU,EAAGP,4BAAmB;MAChCxD,SAAS,EAAC,uBAAuB;MACjCqE,eAAe,EAAC,+BAA+B;MAAAnE,QAAA,eAE/C,IAAAtD,WAAA,CAAAuD,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGmE,uBAAyB;QACpCtE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR4F;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
|
|
@@ -29,20 +29,26 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
29
29
|
* Internal dependencies
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
+
const {
|
|
33
|
+
normalizeTextString
|
|
34
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
35
|
+
const {
|
|
36
|
+
RECEIVE_INTERMEDIATE_RESULTS
|
|
37
|
+
} = (0, _lockUnlock.unlock)(_coreData.privateApis);
|
|
38
|
+
|
|
32
39
|
/**
|
|
33
40
|
* Module Constants
|
|
34
|
-
*/
|
|
41
|
+
*/
|
|
42
|
+
const DEFAULT_QUERY = {
|
|
35
43
|
per_page: -1,
|
|
36
44
|
orderby: 'name',
|
|
37
45
|
order: 'asc',
|
|
38
46
|
_fields: 'id,name,parent',
|
|
39
|
-
context: 'view'
|
|
47
|
+
context: 'view',
|
|
48
|
+
[RECEIVE_INTERMEDIATE_RESULTS]: true
|
|
40
49
|
};
|
|
41
50
|
const MIN_TERMS_COUNT_FOR_FILTER = 8;
|
|
42
51
|
const EMPTY_ARRAY = [];
|
|
43
|
-
const {
|
|
44
|
-
normalizeTextString
|
|
45
|
-
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* Sort Terms by Selected.
|
|
@@ -161,7 +167,6 @@ function HierarchicalTermSelector({
|
|
|
161
167
|
availableTerms,
|
|
162
168
|
taxonomy
|
|
163
169
|
} = (0, _data.useSelect)(select => {
|
|
164
|
-
var _post$_links, _post$_links2;
|
|
165
170
|
const {
|
|
166
171
|
getCurrentPost,
|
|
167
172
|
getEditedPostAttribute
|
|
@@ -174,8 +179,8 @@ function HierarchicalTermSelector({
|
|
|
174
179
|
const _taxonomy = getEntityRecord('root', 'taxonomy', slug);
|
|
175
180
|
const post = getCurrentPost();
|
|
176
181
|
return {
|
|
177
|
-
hasCreateAction: _taxonomy ?
|
|
178
|
-
hasAssignAction: _taxonomy ?
|
|
182
|
+
hasCreateAction: _taxonomy ? !!post._links?.['wp:action-create-' + _taxonomy.rest_base] : false,
|
|
183
|
+
hasAssignAction: _taxonomy ? !!post._links?.['wp:action-assign-' + _taxonomy.rest_base] : false,
|
|
179
184
|
terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : EMPTY_ARRAY,
|
|
180
185
|
loading: isResolving('getEntityRecords', ['taxonomy', slug, DEFAULT_QUERY]),
|
|
181
186
|
availableTerms: getEntityRecords('taxonomy', slug, DEFAULT_QUERY) || EMPTY_ARRAY,
|
|
@@ -340,13 +345,20 @@ function HierarchicalTermSelector({
|
|
|
340
345
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Flex, {
|
|
341
346
|
direction: "column",
|
|
342
347
|
gap: "4",
|
|
343
|
-
children: [showFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SearchControl, {
|
|
348
|
+
children: [showFilter && !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SearchControl, {
|
|
344
349
|
__next40pxDefaultSize: true,
|
|
345
350
|
__nextHasNoMarginBottom: true,
|
|
346
351
|
label: filterLabel,
|
|
347
352
|
placeholder: filterLabel,
|
|
348
353
|
value: filterValue,
|
|
349
354
|
onChange: setFilter
|
|
355
|
+
}), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Flex, {
|
|
356
|
+
justify: "center",
|
|
357
|
+
style: {
|
|
358
|
+
// Match SearchControl height to prevent layout shift.
|
|
359
|
+
height: '40px'
|
|
360
|
+
},
|
|
361
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
350
362
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
351
363
|
className: "editor-post-taxonomies__hierarchical-terms-list",
|
|
352
364
|
tabIndex: "0",
|