@wordpress/block-library 7.3.2 → 7.3.5
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/comment-template/hooks.js +11 -3
- package/build/comment-template/hooks.js.map +1 -1
- package/build/comments-pagination/edit.js +18 -1
- package/build/comments-pagination/edit.js.map +1 -1
- package/build/comments-query-loop/edit.js +2 -2
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-title/edit.js +151 -0
- package/build/comments-title/edit.js.map +1 -0
- package/build/comments-title/index.js +101 -0
- package/build/comments-title/index.js.map +1 -0
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/navigation/edit/index.js +17 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +5 -7
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +7 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation-link/edit.js +29 -30
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +14 -14
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/post-comments/edit.js +141 -35
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments/index.js +2 -1
- package/build/post-comments/index.js.map +1 -1
- package/build/post-comments-form/edit.js +22 -1
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +11 -3
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/comments-pagination/edit.js +19 -2
- package/build-module/comments-pagination/edit.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -2
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-title/edit.js +135 -0
- package/build-module/comments-title/edit.js.map +1 -0
- package/build-module/comments-title/index.js +88 -0
- package/build-module/comments-title/index.js.map +1 -0
- package/build-module/index.js +3 -2
- package/build-module/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +5 -7
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation-link/edit.js +29 -30
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +14 -14
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/post-comments/edit.js +143 -38
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments/index.js +2 -1
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-comments-form/edit.js +21 -1
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-style/comment-content/style-rtl.css +81 -0
- package/build-style/comment-content/style.css +81 -0
- package/build-style/comments-title/editor-rtl.css +79 -0
- package/build-style/comments-title/editor.css +79 -0
- package/build-style/cover/style-rtl.css +1 -1
- package/build-style/cover/style.css +1 -1
- package/build-style/editor-rtl.css +12 -0
- package/build-style/editor.css +12 -0
- package/build-style/latest-posts/style-rtl.css +2 -0
- package/build-style/latest-posts/style.css +4 -0
- package/build-style/post-comments/editor-rtl.css +79 -0
- package/build-style/post-comments/editor.css +79 -0
- package/build-style/post-comments/style-rtl.css +6 -4
- package/build-style/post-comments/style.css +6 -4
- package/build-style/post-comments-form/editor-rtl.css +79 -0
- package/build-style/post-comments-form/editor.css +79 -0
- package/build-style/post-comments-form/style-rtl.css +9 -0
- package/build-style/post-comments-form/style.css +9 -0
- package/build-style/style-rtl.css +18 -5
- package/build-style/style.css +20 -5
- package/package.json +10 -10
- package/src/comment-author-name/index.php +7 -5
- package/src/comment-content/index.php +25 -3
- package/src/comment-content/style.scss +5 -0
- package/src/comment-edit-link/index.php +1 -4
- package/src/comment-reply-link/index.php +1 -4
- package/src/comment-template/hooks.js +13 -1
- package/src/comment-template/index.php +13 -4
- package/src/comments-pagination/edit.js +23 -0
- package/src/comments-query-loop/edit.js +2 -0
- package/src/comments-title/block.json +70 -0
- package/src/comments-title/edit.js +213 -0
- package/src/comments-title/editor.scss +4 -0
- package/src/comments-title/index.js +18 -0
- package/src/comments-title/index.php +75 -0
- package/src/cover/index.php +1 -1
- package/src/cover/style.scss +1 -1
- package/src/editor.scss +3 -0
- package/src/index.js +4 -1
- package/src/latest-posts/style.scss +4 -0
- package/src/navigation/edit/index.js +24 -0
- package/src/navigation/edit/inner-blocks.js +5 -7
- package/src/navigation/edit/navigation-menu-selector.js +15 -9
- package/src/navigation-link/edit.js +40 -43
- package/src/navigation-submenu/edit.js +13 -17
- package/src/post-comments/block.json +2 -1
- package/src/post-comments/edit.js +204 -44
- package/src/post-comments/editor.scss +3 -0
- package/src/post-comments/style.scss +6 -7
- package/src/post-comments-form/block.json +1 -0
- package/src/post-comments-form/edit.js +39 -2
- package/src/post-comments-form/editor.scss +3 -0
- package/src/post-comments-form/index.php +4 -1
- package/src/post-comments-form/style.scss +11 -0
- package/src/post-content/edit.js +15 -1
- package/src/post-excerpt/edit.js +14 -1
- package/src/query-no-results/edit.js +1 -1
|
@@ -11,14 +11,16 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
|
|
14
|
-
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
14
|
var _blockEditor = require("@wordpress/block-editor");
|
|
17
15
|
|
|
18
16
|
var _i18n = require("@wordpress/i18n");
|
|
19
17
|
|
|
18
|
+
var _data = require("@wordpress/data");
|
|
19
|
+
|
|
20
20
|
var _coreData = require("@wordpress/core-data");
|
|
21
21
|
|
|
22
|
+
var _compose = require("@wordpress/compose");
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
* External dependencies
|
|
24
26
|
*/
|
|
@@ -26,45 +28,57 @@ var _coreData = require("@wordpress/core-data");
|
|
|
26
28
|
/**
|
|
27
29
|
* WordPress dependencies
|
|
28
30
|
*/
|
|
29
|
-
function
|
|
31
|
+
function PostCommentsEdit(_ref) {
|
|
30
32
|
let {
|
|
31
|
-
|
|
33
|
+
attributes: {
|
|
34
|
+
textAlign
|
|
35
|
+
},
|
|
36
|
+
setAttributes,
|
|
37
|
+
context: {
|
|
38
|
+
postType,
|
|
39
|
+
postId
|
|
40
|
+
}
|
|
32
41
|
} = _ref;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
let [postTitle] = (0, _coreData.useEntityProp)('postType', postType, 'title', postId);
|
|
43
|
+
postTitle = postTitle || (0, _i18n.__)('Post Title');
|
|
44
|
+
const [commentStatus] = (0, _coreData.useEntityProp)('postType', postType, 'comment_status', postId);
|
|
45
|
+
const {
|
|
46
|
+
avatarURL,
|
|
47
|
+
defaultCommentStatus
|
|
48
|
+
} = (0, _data.useSelect)(select => select(_blockEditor.store).getSettings().__experimentalDiscussionSettings);
|
|
49
|
+
const isSiteEditor = postType === undefined || postId === undefined;
|
|
50
|
+
const postTypeSupportsComments = (0, _data.useSelect)(select => {
|
|
51
|
+
var _select$getPostType;
|
|
37
52
|
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
return postType ? !!((_select$getPostType = select(_coreData.store).getPostType(postType)) !== null && _select$getPostType !== void 0 && _select$getPostType.supports.comments) : false;
|
|
54
|
+
});
|
|
55
|
+
let warning = (0, _i18n.__)('Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the "Comments Query Loop" block.');
|
|
56
|
+
let showPlacholder = true;
|
|
57
|
+
|
|
58
|
+
if (!isSiteEditor && 'open' !== commentStatus) {
|
|
59
|
+
if ('closed' === commentStatus) {
|
|
60
|
+
warning = (0, _i18n.sprintf)(
|
|
61
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
62
|
+
(0, _i18n.__)('Post Comments block: Comments to this %s are not allowed.'), postType);
|
|
63
|
+
showPlacholder = false;
|
|
64
|
+
} else if (!postTypeSupportsComments) {
|
|
65
|
+
warning = (0, _i18n.sprintf)(
|
|
66
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
67
|
+
(0, _i18n.__)('Post Comments block: Comments for this post type (%s) are not enabled.'), postType);
|
|
68
|
+
showPlacholder = false;
|
|
69
|
+
} else if ('open' !== defaultCommentStatus) {
|
|
70
|
+
warning = (0, _i18n.__)('Post Comments block: Comments are not enabled.');
|
|
71
|
+
showPlacholder = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
44
74
|
|
|
45
|
-
function PostCommentsEdit(_ref2) {
|
|
46
|
-
let {
|
|
47
|
-
attributes,
|
|
48
|
-
setAttributes,
|
|
49
|
-
context
|
|
50
|
-
} = _ref2;
|
|
51
|
-
const {
|
|
52
|
-
postType,
|
|
53
|
-
postId
|
|
54
|
-
} = context;
|
|
55
|
-
const {
|
|
56
|
-
textAlign
|
|
57
|
-
} = attributes;
|
|
58
75
|
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
59
76
|
className: (0, _classnames.default)({
|
|
60
77
|
[`has-text-align-${textAlign}`]: textAlign
|
|
61
78
|
})
|
|
62
79
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Post comments block: no post found.')));
|
|
66
|
-
}
|
|
67
|
-
|
|
80
|
+
const disabledRef = (0, _compose.__experimentalUseDisabled)();
|
|
81
|
+
const textareaId = (0, _compose.useInstanceId)(PostCommentsEdit);
|
|
68
82
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
|
|
69
83
|
group: "block"
|
|
70
84
|
}, (0, _element.createElement)(_blockEditor.AlignmentControl, {
|
|
@@ -74,8 +88,100 @@ function PostCommentsEdit(_ref2) {
|
|
|
74
88
|
textAlign: nextAlign
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
|
-
})), (0, _element.createElement)("div", blockProps, (0, _element.createElement)(
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
})), (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_blockEditor.Warning, null, warning), showPlacholder && (0, _element.createElement)("div", {
|
|
92
|
+
className: "wp-block-post-comments__placeholder",
|
|
93
|
+
ref: disabledRef
|
|
94
|
+
}, (0, _element.createElement)("h3", null, (0, _i18n.__)('One response to'), " \u201C", postTitle, "\u201D"), (0, _element.createElement)("div", {
|
|
95
|
+
className: "navigation"
|
|
96
|
+
}, (0, _element.createElement)("div", {
|
|
97
|
+
className: "alignleft"
|
|
98
|
+
}, (0, _element.createElement)("a", {
|
|
99
|
+
href: "#top"
|
|
100
|
+
}, "\xAB ", (0, _i18n.__)('Older Comments'))), (0, _element.createElement)("div", {
|
|
101
|
+
className: "alignright"
|
|
102
|
+
}, (0, _element.createElement)("a", {
|
|
103
|
+
href: "#top"
|
|
104
|
+
}, (0, _i18n.__)('Newer Comments'), " \xBB"))), (0, _element.createElement)("ol", {
|
|
105
|
+
className: "commentlist"
|
|
106
|
+
}, (0, _element.createElement)("li", {
|
|
107
|
+
className: "comment even thread-even depth-1"
|
|
108
|
+
}, (0, _element.createElement)("article", {
|
|
109
|
+
className: "comment-body"
|
|
110
|
+
}, (0, _element.createElement)("footer", {
|
|
111
|
+
className: "comment-meta"
|
|
112
|
+
}, (0, _element.createElement)("div", {
|
|
113
|
+
className: "comment-author vcard"
|
|
114
|
+
}, (0, _element.createElement)("img", {
|
|
115
|
+
alt: "Commenter Avatar",
|
|
116
|
+
src: avatarURL,
|
|
117
|
+
className: "avatar avatar-32 photo",
|
|
118
|
+
height: "32",
|
|
119
|
+
width: "32",
|
|
120
|
+
loading: "lazy"
|
|
121
|
+
}), (0, _element.createElement)("b", {
|
|
122
|
+
className: "fn"
|
|
123
|
+
}, (0, _element.createElement)("a", {
|
|
124
|
+
href: "#top",
|
|
125
|
+
className: "url"
|
|
126
|
+
}, (0, _i18n.__)('A WordPress Commenter'))), ' ', (0, _element.createElement)("span", {
|
|
127
|
+
className: "says"
|
|
128
|
+
}, (0, _i18n.__)('says'), ":")), (0, _element.createElement)("div", {
|
|
129
|
+
className: "comment-metadata"
|
|
130
|
+
}, (0, _element.createElement)("a", {
|
|
131
|
+
href: "#top"
|
|
132
|
+
}, (0, _element.createElement)("time", {
|
|
133
|
+
dateTime: "2000-01-01T00:00:00+00:00"
|
|
134
|
+
}, (0, _i18n.__)('January 1, 2000 at 00:00 am'))), ' ', (0, _element.createElement)("span", {
|
|
135
|
+
className: "edit-link"
|
|
136
|
+
}, (0, _element.createElement)("a", {
|
|
137
|
+
className: "comment-edit-link",
|
|
138
|
+
href: "#top"
|
|
139
|
+
}, (0, _i18n.__)('Edit'))))), (0, _element.createElement)("div", {
|
|
140
|
+
className: "comment-content"
|
|
141
|
+
}, (0, _element.createElement)("p", null, (0, _i18n.__)('Hi, this is a comment.'), (0, _element.createElement)("br", null), (0, _i18n.__)('To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'), (0, _element.createElement)("br", null), (0, _i18n.__)('Commenter avatars come from'), ' ', (0, _element.createElement)("a", {
|
|
142
|
+
href: "https://gravatar.com/"
|
|
143
|
+
}, "Gravatar"), ".")), (0, _element.createElement)("div", {
|
|
144
|
+
className: "reply"
|
|
145
|
+
}, (0, _element.createElement)("a", {
|
|
146
|
+
className: "comment-reply-link",
|
|
147
|
+
href: "#top",
|
|
148
|
+
"aria-label": "Reply to A WordPress Commenter"
|
|
149
|
+
}, (0, _i18n.__)('Reply')))))), (0, _element.createElement)("div", {
|
|
150
|
+
className: "navigation"
|
|
151
|
+
}, (0, _element.createElement)("div", {
|
|
152
|
+
className: "alignleft"
|
|
153
|
+
}, (0, _element.createElement)("a", {
|
|
154
|
+
href: "#top"
|
|
155
|
+
}, "\xAB ", (0, _i18n.__)('Older Comments'))), (0, _element.createElement)("div", {
|
|
156
|
+
className: "alignright"
|
|
157
|
+
}, (0, _element.createElement)("a", {
|
|
158
|
+
href: "#top"
|
|
159
|
+
}, (0, _i18n.__)('Newer Comments'), " \xBB"))), (0, _element.createElement)("div", {
|
|
160
|
+
className: "comment-respond"
|
|
161
|
+
}, (0, _element.createElement)("h3", {
|
|
162
|
+
className: "comment-reply-title"
|
|
163
|
+
}, (0, _i18n.__)('Leave a Reply')), (0, _element.createElement)("form", {
|
|
164
|
+
className: "comment-form",
|
|
165
|
+
noValidate: true
|
|
166
|
+
}, (0, _element.createElement)("p", {
|
|
167
|
+
className: "comment-form-comment"
|
|
168
|
+
}, (0, _element.createElement)("label", {
|
|
169
|
+
htmlFor: `comment-${textareaId}`
|
|
170
|
+
}, (0, _i18n.__)('Comment'), ' ', (0, _element.createElement)("span", {
|
|
171
|
+
className: "required"
|
|
172
|
+
}, "*")), (0, _element.createElement)("textarea", {
|
|
173
|
+
id: `comment-${textareaId}`,
|
|
174
|
+
name: "comment",
|
|
175
|
+
cols: "45",
|
|
176
|
+
rows: "8",
|
|
177
|
+
required: true
|
|
178
|
+
})), (0, _element.createElement)("p", {
|
|
179
|
+
className: "form-submit wp-block-button"
|
|
180
|
+
}, (0, _element.createElement)("input", {
|
|
181
|
+
name: "submit",
|
|
182
|
+
type: "submit",
|
|
183
|
+
className: "submit wp-block-button__link",
|
|
184
|
+
value: (0, _i18n.__)('Post Comment')
|
|
185
|
+
})))))));
|
|
80
186
|
}
|
|
81
187
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments/edit.js"],"names":["PostCommentsDisplay","postId","select","comments","coreStore","getEntityRecords","post","length","map","comment","id","content","rendered","PostCommentsEdit","attributes","setAttributes","context","postType","textAlign","blockProps","className","nextAlign"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AACA;;AAMA;;AAEA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;AAYA,SAASA,mBAAT,OAA2C;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC1C,SAAO,qBACJC,MAAF,IAAc;AACb,UAAMC,QAAQ,GAAGD,MAAM,CAAEE,eAAF,CAAN,CAAoBC,gBAApB,CAChB,MADgB,EAEhB,SAFgB,EAGhB;AACCC,MAAAA,IAAI,EAAEL;AADP,KAHgB,CAAjB,CADa,CAQb;;AACA,WAAOE,QAAQ,IAAIA,QAAQ,CAACI,MAArB,GACJJ,QAAQ,CAACK,GAAT,CAAgBC,OAAF,IACd,4BAAC,gBAAD;AACC,MAAA,SAAS,EAAC,iCADX;AAEC,MAAA,GAAG,EAAGA,OAAO,CAACC;AAFf,OAIGD,OAAO,CAACE,OAAR,CAAgBC,QAJnB,CADA,CADI,GASJ,cAAI,cAAJ,CATH;AAUA,GApBK,EAqBN,CAAEX,MAAF,CArBM,CAAP;AAuBA;;AAEc,SAASY,gBAAT,QAIX;AAAA,MAJsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,aAFyC;AAGzCC,IAAAA;AAHyC,GAItC;AACH,QAAM;AAAEC,IAAAA,QAAF;AAAYhB,IAAAA;AAAZ,MAAuBe,OAA7B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAgBJ,UAAtB;AACA,QAAMK,UAAU,GAAG,gCAAe;AACjCC,IAAAA,SAAS,EAAE,yBAAY;AACtB,OAAG,kBAAkBF,SAAW,EAAhC,GAAqCA;AADf,KAAZ;AADsB,GAAf,CAAnB;;AAMA,MAAK,CAAED,QAAF,IAAc,CAAEhB,MAArB,EAA8B;AAC7B,WACC,mCAAUkB,UAAV,EACC,4BAAC,oBAAD,QACG,cAAI,qCAAJ,CADH,CADD,CADD;AAOA;;AAED,SACC,qDACC,4BAAC,0BAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,4BAAC,6BAAD;AACC,IAAA,KAAK,EAAGD,SADT;AAEC,IAAA,QAAQ,EAAKG,SAAF,IAAiB;AAC3BN,MAAAA,aAAa,CAAE;AAAEG,QAAAA,SAAS,EAAEG;AAAb,OAAF,CAAb;AACA;AAJF,IADD,CADD,EAUC,mCAAUF,UAAV,EACC,4BAAC,mBAAD;AAAqB,IAAA,MAAM,EAAGlB;AAA9B,IADD,CAVD,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tWarning,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { RawHTML } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\nfunction PostCommentsDisplay( { postId } ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst comments = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tpost: postId,\n\t\t\t\t}\n\t\t\t);\n\t\t\t// TODO: \"No Comments\" placeholder should be editable.\n\t\t\treturn comments && comments.length\n\t\t\t\t? comments.map( ( comment ) => (\n\t\t\t\t\t\t<RawHTML\n\t\t\t\t\t\t\tclassName=\"wp-block-post-comments__comment\"\n\t\t\t\t\t\t\tkey={ comment.id }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ comment.content.rendered }\n\t\t\t\t\t\t</RawHTML>\n\t\t\t\t ) )\n\t\t\t\t: __( 'No comments.' );\n\t\t},\n\t\t[ postId ]\n\t);\n}\n\nexport default function PostCommentsEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext,\n} ) {\n\tconst { postType, postId } = context;\n\tconst { textAlign } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tif ( ! postType || ! postId ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Post comments block: no post found.' ) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<PostCommentsDisplay postId={ postId } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments/edit.js"],"names":["PostCommentsEdit","attributes","textAlign","setAttributes","context","postType","postId","postTitle","commentStatus","avatarURL","defaultCommentStatus","select","blockEditorStore","getSettings","__experimentalDiscussionSettings","isSiteEditor","undefined","postTypeSupportsComments","coreStore","getPostType","supports","comments","warning","showPlacholder","blockProps","className","disabledRef","textareaId","nextAlign"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAOA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;AAgBe,SAASA,gBAAT,OAIX;AAAA,MAJsC;AACzCC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KAD6B;AAEzCC,IAAAA,a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,EAAC;AAAf,KACC;AAAG,IAAA,IAAI,EAAC;AAAR,KAAiB,cAAI,gBAAJ,CAAjB,UADD,CAJD,CA5FD,EAqGC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACG,cAAI,eAAJ,CADH,CADD,EAKC;AAAM,IAAA,SAAS,EAAC,cAAhB;AAA+B,IAAA,UAAU;AAAzC,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KACC;AACC,IAAA,OAAO,EAAI,WAAWkB,UAAY;AADnC,KAGG,cAAI,SAAJ,CAHH,EAGsB,GAHtB,EAIC;AAAM,IAAA,SAAS,EAAC;AAAhB,SAJD,CADD,EAOC;AACC,IAAA,EAAE,EAAI,WAAWA,UAAY,EAD9B;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,IAAI,EAAC,IAHN;AAIC,IAAA,IAAI,EAAC,GAJN;AAKC,IAAA,QAAQ;AALT,IAPD,CADD,EAgBC;AAAG,IAAA,SAAS,EAAC;AAAb,KACC;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,SAAS,EAAC,8BAHX;AAIC,IAAA,KAAK,EAAG,cAAI,cAAJ;AAJT,IADD,CAhBD,CALD,CArGD,CAJF,CAVD,CADD;AAwJA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalUseDisabled as useDisabled,\n\tuseInstanceId,\n} from '@wordpress/compose';\n\nexport default function PostCommentsEdit( {\n\tattributes: { textAlign },\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tlet [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tpostTitle = postTitle || __( 'Post Title' );\n\n\tconst [ commentStatus ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'comment_status',\n\t\tpostId\n\t);\n\n\tconst { avatarURL, defaultCommentStatus } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalDiscussionSettings\n\t);\n\n\tconst isSiteEditor = postType === undefined || postId === undefined;\n\n\tconst postTypeSupportsComments = useSelect( ( select ) =>\n\t\tpostType\n\t\t\t? !! select( coreStore ).getPostType( postType )?.supports.comments\n\t\t\t: false\n\t);\n\n\tlet warning = __(\n\t\t'Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the \"Comments Query Loop\" block.'\n\t);\n\tlet showPlacholder = true;\n\n\tif ( ! isSiteEditor && 'open' !== commentStatus ) {\n\t\tif ( 'closed' === commentStatus ) {\n\t\t\twarning = sprintf(\n\t\t\t\t/* translators: 1: Post type (i.e. \"post\", \"page\") */\n\t\t\t\t__(\n\t\t\t\t\t'Post Comments block: Comments to this %s are not allowed.'\n\t\t\t\t),\n\t\t\t\tpostType\n\t\t\t);\n\t\t\tshowPlacholder = false;\n\t\t} else if ( ! postTypeSupportsComments ) {\n\t\t\twarning = sprintf(\n\t\t\t\t/* translators: 1: Post type (i.e. \"post\", \"page\") */\n\t\t\t\t__(\n\t\t\t\t\t'Post Comments block: Comments for this post type (%s) are not enabled.'\n\t\t\t\t),\n\t\t\t\tpostType\n\t\t\t);\n\t\t\tshowPlacholder = false;\n\t\t} else if ( 'open' !== defaultCommentStatus ) {\n\t\t\twarning = __( 'Post Comments block: Comments are not enabled.' );\n\t\t\tshowPlacholder = false;\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst disabledRef = useDisabled();\n\n\tconst textareaId = useInstanceId( PostCommentsEdit );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>{ warning }</Warning>\n\n\t\t\t\t{ showPlacholder && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"wp-block-post-comments__placeholder\"\n\t\t\t\t\t\tref={ disabledRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<h3>\n\t\t\t\t\t\t\t{ __( 'One response to' ) } “{ postTitle }”\n\t\t\t\t\t\t</h3>\n\n\t\t\t\t\t\t<div className=\"navigation\">\n\t\t\t\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">« { __( 'Older Comments' ) }</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } »</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<ol className=\"commentlist\">\n\t\t\t\t\t\t\t<li className=\"comment even thread-even depth-1\">\n\t\t\t\t\t\t\t\t<article className=\"comment-body\">\n\t\t\t\t\t\t\t\t\t<footer className=\"comment-meta\">\n\t\t\t\t\t\t\t\t\t\t<div className=\"comment-author vcard\">\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"Commenter Avatar\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"avatar avatar-32 photo\"\n\t\t\t\t\t\t\t\t\t\t\t\theight=\"32\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth=\"32\"\n\t\t\t\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<b className=\"fn\">\n\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"#top\" className=\"url\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'A WordPress Commenter'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</b>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"says\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'says' ) }:\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t\t<div className=\"comment-metadata\">\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"#top\">\n\t\t\t\t\t\t\t\t\t\t\t\t<time dateTime=\"2000-01-01T00:00:00+00:00\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'January 1, 2000 at 00:00 am'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"edit-link\">\n\t\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"comment-edit-link\"\n\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</footer>\n\n\t\t\t\t\t\t\t\t\t<div className=\"comment-content\">\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Hi, this is a comment.' ) }\n\t\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Commenter avatars come from'\n\t\t\t\t\t\t\t\t\t\t\t) }{ ' ' }\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"https://gravatar.com/\">\n\t\t\t\t\t\t\t\t\t\t\t\tGravatar\n\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t.\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t<div className=\"reply\">\n\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"comment-reply-link\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Reply to A WordPress Commenter\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Reply' ) }\n\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</article>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ol>\n\n\t\t\t\t\t\t<div className=\"navigation\">\n\t\t\t\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">« { __( 'Older Comments' ) }</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } »</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div className=\"comment-respond\">\n\t\t\t\t\t\t\t<h3 className=\"comment-reply-title\">\n\t\t\t\t\t\t\t\t{ __( 'Leave a Reply' ) }\n\t\t\t\t\t\t\t</h3>\n\n\t\t\t\t\t\t\t<form className=\"comment-form\" noValidate>\n\t\t\t\t\t\t\t\t<p className=\"comment-form-comment\">\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\thtmlFor={ `comment-${ textareaId }` }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Comment' ) }{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<span className=\"required\">*</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\t\t\t\tid={ `comment-${ textareaId }` }\n\t\t\t\t\t\t\t\t\t\tname=\"comment\"\n\t\t\t\t\t\t\t\t\t\tcols=\"45\"\n\t\t\t\t\t\t\t\t\t\trows=\"8\"\n\t\t\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t<p className=\"form-submit wp-block-button\">\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\tname=\"submit\"\n\t\t\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"submit wp-block-button__link\"\n\t\t\t\t\t\t\t\t\t\tvalue={ __( 'Post Comment' ) }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -56,7 +56,8 @@ const metadata = {
|
|
|
56
56
|
},
|
|
57
57
|
inserter: false
|
|
58
58
|
},
|
|
59
|
-
style: ["wp-block-post-comments", "wp-block-buttons", "wp-block-button"]
|
|
59
|
+
style: ["wp-block-post-comments", "wp-block-buttons", "wp-block-button"],
|
|
60
|
+
editorStyle: "wp-block-post-comments-editor"
|
|
60
61
|
};
|
|
61
62
|
exports.metadata = metadata;
|
|
62
63
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,mBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
|
|
@@ -17,6 +17,8 @@ var _coreData = require("@wordpress/core-data");
|
|
|
17
17
|
|
|
18
18
|
var _i18n = require("@wordpress/i18n");
|
|
19
19
|
|
|
20
|
+
var _compose = require("@wordpress/compose");
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* External dependencies
|
|
22
24
|
*/
|
|
@@ -44,6 +46,8 @@ function PostCommentsFormEdit(_ref) {
|
|
|
44
46
|
})
|
|
45
47
|
});
|
|
46
48
|
const isInSiteEditor = postType === undefined || postId === undefined;
|
|
49
|
+
const disabledFormRef = (0, _compose.__experimentalUseDisabled)();
|
|
50
|
+
const instanceId = (0, _compose.useInstanceId)(PostCommentsFormEdit);
|
|
47
51
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
|
|
48
52
|
group: "block"
|
|
49
53
|
}, (0, _element.createElement)(_blockEditor.AlignmentControl, {
|
|
@@ -55,6 +59,23 @@ function PostCommentsFormEdit(_ref) {
|
|
|
55
59
|
}
|
|
56
60
|
})), (0, _element.createElement)("div", blockProps, !commentStatus && !isInSiteEditor && (0, _element.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Post Comments Form block: comments are not enabled for this post type.')), 'open' !== commentStatus && !isInSiteEditor && (0, _element.createElement)(_blockEditor.Warning, null, (0, _i18n.sprintf)(
|
|
57
61
|
/* translators: 1: Post type (i.e. "post", "page") */
|
|
58
|
-
(0, _i18n.__)('Post Comments Form block: comments to this %s are not allowed.'), postType)), ('open' === commentStatus || isInSiteEditor) && (0, _i18n.__)('
|
|
62
|
+
(0, _i18n.__)('Post Comments Form block: comments to this %s are not allowed.'), postType)), ('open' === commentStatus || isInSiteEditor) && (0, _element.createElement)("div", null, (0, _element.createElement)("h3", null, (0, _i18n.__)('Leave a Reply')), (0, _element.createElement)("form", {
|
|
63
|
+
noValidate: true,
|
|
64
|
+
className: "comment-form",
|
|
65
|
+
ref: disabledFormRef
|
|
66
|
+
}, (0, _element.createElement)("p", null, (0, _element.createElement)("label", {
|
|
67
|
+
htmlFor: `comment-${instanceId}`
|
|
68
|
+
}, (0, _i18n.__)('Comment')), (0, _element.createElement)("textarea", {
|
|
69
|
+
id: `comment-${instanceId}`,
|
|
70
|
+
name: "comment",
|
|
71
|
+
cols: "45",
|
|
72
|
+
rows: "8"
|
|
73
|
+
})), (0, _element.createElement)("p", null, (0, _element.createElement)("input", {
|
|
74
|
+
name: "submit",
|
|
75
|
+
className: "submit wp-block-button__link",
|
|
76
|
+
label: (0, _i18n.__)('Post Comment'),
|
|
77
|
+
value: (0, _i18n.__)('Post Comment'),
|
|
78
|
+
readOnly: true
|
|
79
|
+
}))))));
|
|
59
80
|
}
|
|
60
81
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments-form/edit.js"],"names":["PostCommentsFormEdit","attributes","context","setAttributes","textAlign","postId","postType","commentStatus","blockProps","className","isInSiteEditor","undefined","nextAlign"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments-form/edit.js"],"names":["PostCommentsFormEdit","attributes","context","setAttributes","textAlign","postId","postType","commentStatus","blockProps","className","isInSiteEditor","undefined","disabledFormRef","instanceId","nextAlign"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;AAce,SAASA,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,UAD6C;AAE7CC,IAAAA,OAF6C;AAG7CC,IAAAA;AAH6C,GAI1C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAgBH,UAAtB;AACA,QAAM;AAAEI,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAuBJ,OAA7B;AACA,QAAM,CAAEK,aAAF,IAAoB,6BACzB,UADyB,EAEzBD,QAFyB,EAGzB,gBAHyB,EAIzBD,MAJyB,CAA1B;AAMA,QAAMG,UAAU,GAAG,gCAAe;AACjCC,IAAAA,SAAS,EAAE,yBAAY;AACtB,OAAG,kBAAkBL,SAAW,EAAhC,GAAqCA;AADf,KAAZ;AADsB,GAAf,CAAnB;AAMA,QAAMM,cAAc,GAAGJ,QAAQ,KAAKK,SAAb,IAA0BN,MAAM,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\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tWarning,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__experimentalUseDisabled as useDisabled,\n\tuseInstanceId,\n} from '@wordpress/compose';\n\nexport default function PostCommentsFormEdit( {\n\tattributes,\n\tcontext,\n\tsetAttributes,\n} ) {\n\tconst { textAlign } = attributes;\n\tconst { postId, postType } = context;\n\tconst [ commentStatus ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'comment_status',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst isInSiteEditor = postType === undefined || postId === undefined;\n\n\tconst disabledFormRef = useDisabled();\n\n\tconst instanceId = useInstanceId( PostCommentsFormEdit );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ ! commentStatus && ! isInSiteEditor && (\n\t\t\t\t\t<Warning>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Post Comments Form block: comments are not enabled for this post type.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Warning>\n\t\t\t\t) }\n\n\t\t\t\t{ 'open' !== commentStatus && ! isInSiteEditor && (\n\t\t\t\t\t<Warning>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Post type (i.e. \"post\", \"page\") */\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Post Comments Form block: comments to this %s are not allowed.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Warning>\n\t\t\t\t) }\n\n\t\t\t\t{ ( 'open' === commentStatus || isInSiteEditor ) && (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3>{ __( 'Leave a Reply' ) }</h3>\n\t\t\t\t\t\t<form\n\t\t\t\t\t\t\tnoValidate\n\t\t\t\t\t\t\tclassName=\"comment-form\"\n\t\t\t\t\t\t\tref={ disabledFormRef }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t<label htmlFor={ `comment-${ instanceId }` }>\n\t\t\t\t\t\t\t\t\t{ __( 'Comment' ) }\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\t\t\tid={ `comment-${ instanceId }` }\n\t\t\t\t\t\t\t\t\tname=\"comment\"\n\t\t\t\t\t\t\t\t\tcols=\"45\"\n\t\t\t\t\t\t\t\t\trows=\"8\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tname=\"submit\"\n\t\t\t\t\t\t\t\t\tclassName=\"submit wp-block-button__link\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Post Comment' ) }\n\t\t\t\t\t\t\t\t\tvalue={ __( 'Post Comment' ) }\n\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments-form/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments-form/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,uBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postCommentsForm as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
|
|
@@ -96,7 +96,7 @@ function Content(props) {
|
|
|
96
96
|
|
|
97
97
|
function Placeholder() {
|
|
98
98
|
const blockProps = (0, _blockEditor.useBlockProps)();
|
|
99
|
-
return (0, _element.createElement)("div", blockProps, (0, _element.createElement)("p", null, (0, _i18n.__)('Post Content')));
|
|
99
|
+
return (0, _element.createElement)("div", blockProps, (0, _element.createElement)("p", null, (0, _i18n.__)('This is the Post Content block, it will display all the blocks in any single post or page.')), (0, _element.createElement)("p", null, (0, _i18n.__)('That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.')), (0, _element.createElement)("p", null, (0, _i18n.__)('If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.')));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
function RecursionError() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","inherit","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered","RecursionProvider"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AAQA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uBAAuB,EAAG;AAAEE,MAAAA,MAAM,EAAEH,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI;AAAnB;AAF3B,KALD;AAUA;;AAED,SAASC,eAAT,QAAqD;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAO,GAAG;AAApB,GAA2B;AACpD,QAAM;AAAET,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuBQ,OAA7B;AACA,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,2BAAOD,WAAW,EAAlB,iDAAO,aAAeE,cAAtB;AACA,GAH2B,EAGzB,EAHyB,CAA5B;AAIA,QAAMC,aAAa,GAAG,6BAAY,QAAZ,KAA0B,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.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","inherit","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered","RecursionProvider"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AAQA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uBAAuB,EAAG;AAAEE,MAAAA,MAAM,EAAEH,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI;AAAnB;AAF3B,KALD;AAUA;;AAED,SAASC,eAAT,QAAqD;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAO,GAAG;AAApB,GAA2B;AACpD,QAAM;AAAET,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuBQ,OAA7B;AACA,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,2BAAOD,WAAW,EAAlB,iD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B,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,uCACG,cACD,4FADC,CADH,CADD,EAMC,uCACG,cACD,mMADC,CADH,CAND,EAWC,uCACG,cACD,uIADC,CADH,CAXD,CADD;AAmBA;;AAED,SAAS+B,cAAT,GAA0B;AACzB,QAAM/B,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,oBAAD,QACG,cAAI,yCAAJ,CADH,CADD,CADD;AAOA;;AAEc,SAASgC,eAAT,QAAoD;AAAA,MAA1B;AAAE1B,IAAAA,OAAF;AAAW2B,IAAAA;AAAX,GAA0B;AAClE,QAAM;AAAEnC,IAAAA,MAAM,EAAEoC,aAAV;AAAyBrC,IAAAA,QAAQ,EAAEsC;AAAnC,MAAuD7B,OAA7D;AACA,QAAM;AAAED,IAAAA,MAAM,GAAG;AAAX,MAAkB4B,UAAxB;AACA,QAAM,CAAEG,kBAAF,EAAsBC,iBAAtB,IAA4C,sDACjDH,aADiD,CAAlD;;AAIA,MAAKA,aAAa,IAAIC,eAAjB,IAAoCC,kBAAzC,EAA8D;AAC7D,WAAO,4BAAC,cAAD,OAAP;AACA;;AAED,SACC,4BAAC,iBAAD,QACGF,aAAa,IAAIC,eAAjB,GACD,4BAAC,OAAD;AAAS,IAAA,OAAO,EAAG7B,OAAnB;AAA6B,IAAA,MAAM,EAAGD;AAAtC,IADC,GAGD,4BAAC,WAAD,OAJF,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\t__experimentalUseNoRecursiveRenders as useNoRecursiveRenders,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { layout, context = {} } ) {\n\tconst { postType, postId } = context;\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Post Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( { context, attributes } ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders(\n\t\tcontextPostId\n\t);\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
|
|
@@ -72,7 +72,7 @@ function PostExcerptEditor(_ref) {
|
|
|
72
72
|
}, [renderedExcerpt]);
|
|
73
73
|
|
|
74
74
|
if (!postType || !postId) {
|
|
75
|
-
return (0, _element.createElement)("div", blockProps, (0, _i18n.__)('Post Excerpt'));
|
|
75
|
+
return (0, _element.createElement)("div", blockProps, (0, _element.createElement)("p", null, (0, _i18n.__)('This is the Post Excerpt block, it will display the excerpt from single posts.')), (0, _element.createElement)("p", null, (0, _i18n.__)('If there are any Custom Post Types with support for excerpts, the Post Excerpt block can display the excerpts of those entries as well.')));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
if (isProtected && !userCanEdit) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-excerpt/edit.js"],"names":["PostExcerptEditor","attributes","textAlign","moreText","showMoreOnNewLine","setAttributes","isSelected","context","postId","postType","queryId","isDescendentOfQueryLoop","Number","isFinite","userCanEdit","isEditable","rawExcerpt","setExcerpt","rendered","renderedExcerpt","protected","isProtected","blockProps","className","strippedRenderedExcerpt","document","window","DOMParser","parseFromString","body","textContent","innerText","readMoreLink","newMoreText","excerptClassName","excerptContent","newAlign","newShowMoreOnNewLine"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAQA;;AACA;;AAKA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AAGe,SAASA,iBAAT,OAKX;AAAA,MALuC;AAC1CC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;AAAaC,MAAAA,QAAb;AAAuBC,MAAAA;AAAvB,KAD8B;AAE1CC,IAAAA,aAF0C;AAG1CC,IAAAA,UAH0C;AAI1CC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,QAAV;AAAoBC,MAAAA;AAApB;AAJiC,GAKvC;AACH,QAAMC,uBAAuB,GAAGC,MAAM,CAACC,QAAP,CAAiBH,OAAjB,CAAhC;AACA,QAAMI,WAAW,GAAG,6BAAkB,UAAlB,EAA8BL,QAA9B,EAAwCD,MAAxC,CAApB;AACA,QAAMO,UAAU,GAAGD,WAAW,IAAI,CAAEH,uBAApC;AACA,QAAM,CACLK,UADK,EAELC,UAFK,EAGL;AAAEC,IAAAA,QAAQ,EAAEC,eAAZ;AAA6BC,IAAAA,SAAS,EAAEC;AAAxC,MAAwD,EAHnD,IAIF,6BAAe,UAAf,EAA2BZ,QAA3B,EAAqC,SAArC,EAAgDD,MAAhD,CAJJ;AAKA,QAAMc,UAAU,GAAG,gCAAe;AACjCC,IAAAA,SAAS,EAAE,yBAAY;AACtB,OAAG,kBAAkBrB,SAAW,EAAhC,GAAqCA;AADf,KAAZ;AADsB,GAAf,CAAnB;AAKA;AACD;AACA;AACA;AACA;;AACC,QAAMsB,uBAAuB,GAAG,sBAAS,MAAM;AAC9C,QAAK,CAAEL,eAAP,EAAyB,OAAO,EAAP;AACzB,UAAMM,QAAQ,GAAG,IAAIC,MAAM,CAACC,SAAX,GAAuBC,eAAvB,CAChBT,eADgB,EAEhB,WAFgB,CAAjB;AAIA,WAAOM,QAAQ,CAACI,IAAT,CAAcC,WAAd,IAA6BL,QAAQ,CAACI,IAAT,CAAcE,SAA3C,IAAwD,EAA/D;AACA,GAP+B,EAO7B,CAAEZ,eAAF,CAP6B,CAAhC;;AAQA,MAAK,CAAEV,QAAF,IAAc,CAAED,MAArB,EAA8B;AAC7B,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-excerpt/edit.js"],"names":["PostExcerptEditor","attributes","textAlign","moreText","showMoreOnNewLine","setAttributes","isSelected","context","postId","postType","queryId","isDescendentOfQueryLoop","Number","isFinite","userCanEdit","isEditable","rawExcerpt","setExcerpt","rendered","renderedExcerpt","protected","isProtected","blockProps","className","strippedRenderedExcerpt","document","window","DOMParser","parseFromString","body","textContent","innerText","readMoreLink","newMoreText","excerptClassName","excerptContent","newAlign","newShowMoreOnNewLine"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAQA;;AACA;;AAKA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AAGe,SAASA,iBAAT,OAKX;AAAA,MALuC;AAC1CC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;AAAaC,MAAAA,QAAb;AAAuBC,MAAAA;AAAvB,KAD8B;AAE1CC,IAAAA,aAF0C;AAG1CC,IAAAA,UAH0C;AAI1CC,IAAAA,OAAO,EAAE;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Q,EAAKiC,oBAAF,IACVhC,aAAa,CAAE;AACdD,MAAAA,iBAAiB,EAAEiC;AADL,KAAF;AAJf,IADD,CADD,CATD,EAsBC,mCAAUf,UAAV,EACGa,cADH,EAEG,CAAE/B,iBAAF,IAAuB,GAF1B,EAGGA,iBAAiB,GAClB;AAAG,IAAA,SAAS,EAAC;AAAb,KACG4B,YADH,CADkB,GAKlBA,YARF,CAtBD,CADD;AAoCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tAlignmentToolbar,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tWarning,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nexport default function PostExcerptEditor( {\n\tattributes: { textAlign, moreText, showMoreOnNewLine },\n\tsetAttributes,\n\tisSelected,\n\tcontext: { postId, postType, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\tconst [\n\t\trawExcerpt,\n\t\tsetExcerpt,\n\t\t{ rendered: renderedExcerpt, protected: isProtected } = {},\n\t] = useEntityProp( 'postType', postType, 'excerpt', postId );\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\t/**\n\t * When excerpt is editable, strip the html tags from\n\t * rendered excerpt. This will be used if the entity's\n\t * excerpt has been produced from the content.\n\t */\n\tconst strippedRenderedExcerpt = useMemo( () => {\n\t\tif ( ! renderedExcerpt ) return '';\n\t\tconst document = new window.DOMParser().parseFromString(\n\t\t\trenderedExcerpt,\n\t\t\t'text/html'\n\t\t);\n\t\treturn document.body.textContent || document.body.innerText || '';\n\t}, [ renderedExcerpt ] );\n\tif ( ! postType || ! postId ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'This is the Post Excerpt block, it will display the excerpt from single posts.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'If there are any Custom Post Types with support for excerpts, the Post Excerpt block can display the excerpts of those entries as well.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\tif ( isProtected && ! userCanEdit ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'There is no excerpt because this is a protected post.'\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\tconst readMoreLink = (\n\t\t<RichText\n\t\t\tclassName=\"wp-block-post-excerpt__more-link\"\n\t\t\ttagName=\"a\"\n\t\t\taria-label={ __( '\"Read more\" link text' ) }\n\t\t\tplaceholder={ __( 'Add \"read more\" link text' ) }\n\t\t\tvalue={ moreText }\n\t\t\tonChange={ ( newMoreText ) =>\n\t\t\t\tsetAttributes( { moreText: newMoreText } )\n\t\t\t}\n\t\t\twithoutInteractiveFormatting={ true }\n\t\t/>\n\t);\n\tconst excerptClassName = classnames( 'wp-block-post-excerpt__excerpt', {\n\t\t'is-inline': ! showMoreOnNewLine,\n\t} );\n\tconst excerptContent = isEditable ? (\n\t\t<RichText\n\t\t\tclassName={ excerptClassName }\n\t\t\taria-label={ __( 'Post excerpt text' ) }\n\t\t\tvalue={\n\t\t\t\trawExcerpt ||\n\t\t\t\tstrippedRenderedExcerpt ||\n\t\t\t\t( isSelected ? '' : __( 'No post excerpt found' ) )\n\t\t\t}\n\t\t\tonChange={ setExcerpt }\n\t\t\ttagName=\"p\"\n\t\t/>\n\t) : (\n\t\t<p className={ excerptClassName }>\n\t\t\t{ strippedRenderedExcerpt || __( 'No post excerpt found' ) }\n\t\t</p>\n\t);\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<AlignmentToolbar\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Post Excerpt Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show link on new line' ) }\n\t\t\t\t\t\tchecked={ showMoreOnNewLine }\n\t\t\t\t\t\tonChange={ ( newShowMoreOnNewLine ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowMoreOnNewLine: newShowMoreOnNewLine,\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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ excerptContent }\n\t\t\t\t{ ! showMoreOnNewLine && ' ' }\n\t\t\t\t{ showMoreOnNewLine ? (\n\t\t\t\t\t<p className=\"wp-block-post-excerpt__more-text\">\n\t\t\t\t\t\t{ readMoreLink }\n\t\t\t\t\t</p>\n\t\t\t\t) : (\n\t\t\t\t\treadMoreLink\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -15,7 +15,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
15
15
|
* WordPress dependencies
|
|
16
16
|
*/
|
|
17
17
|
const TEMPLATE = [['core/paragraph', {
|
|
18
|
-
placeholder: (0, _i18n.__)('Add
|
|
18
|
+
placeholder: (0, _i18n.__)('Add text or blocks that will display when the query returns no results.')
|
|
19
19
|
}]];
|
|
20
20
|
|
|
21
21
|
function QueryNoResultsEdit() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query-no-results/edit.js"],"names":["TEMPLATE","placeholder","QueryNoResultsEdit","blockProps","innerBlocksProps","template"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG,CAChB,CACC,gBADD,EAEC;AACCC,EAAAA,WAAW,EAAE,cACZ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query-no-results/edit.js"],"names":["TEMPLATE","placeholder","QueryNoResultsEdit","blockProps","innerBlocksProps","template"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG,CAChB,CACC,gBADD,EAEC;AACCC,EAAAA,WAAW,EAAE,cACZ,yEADY;AADd,CAFD,CADgB,CAAjB;;AAWe,SAASC,kBAAT,GAA8B;AAC5C,QAAMC,UAAU,GAAG,iCAAnB;AACA,QAAMC,gBAAgB,GAAG,sCAAqBD,UAArB,EAAiC;AACzDE,IAAAA,QAAQ,EAAEL;AAD+C,GAAjC,CAAzB;AAGA,SACC,qDACC,mCAAUI,gBAAV,CADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\tplaceholder: __(\n\t\t\t\t'Add text or blocks that will display when the query returns no results.'\n\t\t\t),\n\t\t},\n\t],\n];\n\nexport default function QueryNoResultsEdit() {\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\treturn (\n\t\t<>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -5,7 +5,9 @@ import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
7
|
import { addQueryArgs } from '@wordpress/url';
|
|
8
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
8
|
+
import apiFetch from '@wordpress/api-fetch'; // This is limited by WP REST API
|
|
9
|
+
|
|
10
|
+
const MAX_COMMENTS_PER_PAGE = 100;
|
|
9
11
|
/**
|
|
10
12
|
* Return an object with the query args needed to fetch the default page of
|
|
11
13
|
* comments.
|
|
@@ -31,7 +33,8 @@ export const useCommentQueryArgs = _ref => {
|
|
|
31
33
|
}; // Get the Discussion settings that may be needed to query the comments.
|
|
32
34
|
|
|
33
35
|
const {
|
|
34
|
-
|
|
36
|
+
pageComments,
|
|
37
|
+
commentsPerPage,
|
|
35
38
|
defaultCommentsPage: defaultPage
|
|
36
39
|
} = useSelect(select => {
|
|
37
40
|
const {
|
|
@@ -41,7 +44,12 @@ export const useCommentQueryArgs = _ref => {
|
|
|
41
44
|
__experimentalDiscussionSettings
|
|
42
45
|
} = getSettings();
|
|
43
46
|
return __experimentalDiscussionSettings;
|
|
44
|
-
}); //
|
|
47
|
+
}); // WP REST API doesn't allow fetching more than max items limit set per single page of data.
|
|
48
|
+
// As for the editor performance is more important than completeness of data and fetching only the
|
|
49
|
+
// max allowed for single page should be enough for the purpose of design and laying out the page.
|
|
50
|
+
// Fetching over the limit would return an error here but would work with backend query.
|
|
51
|
+
|
|
52
|
+
const perPage = pageComments ? Math.min(commentsPerPage, MAX_COMMENTS_PER_PAGE) : MAX_COMMENTS_PER_PAGE; // Get the number of the default page.
|
|
45
53
|
|
|
46
54
|
const page = useDefaultPageIndex({
|
|
47
55
|
defaultPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useState","useEffect","useMemo","useSelect","store","blockEditorStore","addQueryArgs","apiFetch","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useState","useEffect","useMemo","useSelect","store","blockEditorStore","addQueryArgs","apiFetch","MAX_COMMENTS_PER_PAGE","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","pageComments","commentsPerPage","defaultCommentsPage","defaultPage","select","getSettings","__experimentalDiscussionSettings","perPage","Math","min","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","pages","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAAOC,QAAP,MAAqB,sBAArB,C,CAEA;;AACA,MAAMC,qBAAqB,GAAG,GAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAG,QAAkB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACpD;AACA,QAAMC,SAAS,GAAG;AACjBC,IAAAA,MAAM,EAAE,SADS;AAEjBC,IAAAA,KAAK,EAAE,KAFU;AAGjBC,IAAAA,OAAO,EAAE,OAHQ;AAIjBC,IAAAA,MAAM,EAAE,CAJS;AAKjBC,IAAAA,MAAM,EAAE;AALS,GAAlB,CAFoD,CAUpD;;AACA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA,mBAAmB,EAAEC;AAHhB,MAIFjB,SAAS,CAAIkB,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEhB,gBAAF,CAA9B;AACA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CAACH,GAAT,CAAgBK,KAAF,KAAe;AACtCD,QAAAA,SAAS,EAAEC,KAAK,CAACJ;AADqB,OAAf,CAAd;AAFJ,KAAP;AAMA,GARD,CAFyB,EAW1B,CAAEH,gBAAF,CAX0B,CAA3B;AAcA,SAAOC,WAAP;AACA,CAhBM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n// This is limited by WP REST API\nconst MAX_COMMENTS_PER_PAGE = 100;\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( { postId } ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst {\n\t\tpageComments,\n\t\tcommentsPerPage,\n\t\tdefaultCommentsPage: defaultPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// WP REST API doesn't allow fetching more than max items limit set per single page of data.\n\t// As for the editor performance is more important than completeness of data and fetching only the\n\t// max allowed for single page should be enough for the purpose of design and laying out the page.\n\t// Fetching over the limit would return an error here but would work with backend query.\n\tconst perPage = pageComments\n\t\t? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )\n\t\t: MAX_COMMENTS_PER_PAGE;\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tconst pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { InspectorControls, useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { InspectorControls, useBlockProps, useInnerBlocksProps, store as blockEditorStore, Warning } from '@wordpress/block-editor';
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
9
9
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
10
10
|
import { PanelBody } from '@wordpress/components';
|
|
@@ -51,7 +51,24 @@ export default function QueryPaginationEdit(_ref) {
|
|
|
51
51
|
template: TEMPLATE,
|
|
52
52
|
allowedBlocks: ['core/comments-pagination-previous', 'core/comments-pagination-numbers', 'core/comments-pagination-next'],
|
|
53
53
|
__experimentalLayout: usedLayout
|
|
54
|
-
});
|
|
54
|
+
}); // Get the Discussion settings
|
|
55
|
+
|
|
56
|
+
const pageComments = useSelect(select => {
|
|
57
|
+
const {
|
|
58
|
+
getSettings
|
|
59
|
+
} = select(blockEditorStore);
|
|
60
|
+
const {
|
|
61
|
+
__experimentalDiscussionSettings
|
|
62
|
+
} = getSettings();
|
|
63
|
+
return __experimentalDiscussionSettings === null || __experimentalDiscussionSettings === void 0 ? void 0 : __experimentalDiscussionSettings.pageComments;
|
|
64
|
+
}, []); // If paging comments is not enabled in the Discussion Settings then hide the pagination
|
|
65
|
+
// controls. We don't want to remove them from the template so that when the user enables
|
|
66
|
+
// paging comments, the controls will be visible.
|
|
67
|
+
|
|
68
|
+
if (!pageComments) {
|
|
69
|
+
return createElement(Warning, null, __('Comments Pagination block: paging comments is disabled in the Discussion Settings'));
|
|
70
|
+
}
|
|
71
|
+
|
|
55
72
|
return createElement(Fragment, null, hasNextPreviousBlocks && createElement(InspectorControls, null, createElement(PanelBody, {
|
|
56
73
|
title: __('Settings')
|
|
57
74
|
}, createElement(CommentsPaginationArrowControls, {
|