@wordpress/block-library 7.0.1 → 7.0.2
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/README.md +16 -0
- package/build/button/edit.native.js +2 -2
- package/build/button/edit.native.js.map +1 -1
- package/build/columns/index.js +12 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/edit.js +17 -4
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comment-template/edit.js +94 -36
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +175 -0
- package/build/comment-template/hooks.js.map +1 -0
- package/build/comment-template/index.js +1 -1
- package/build/comment-template/util.js.map +1 -1
- package/build/comments-pagination-next/index.js +1 -1
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -19
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +5 -0
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/edit.js +21 -22
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +7 -5
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/overlay-color-settings.native.js +4 -3
- package/build/cover/overlay-color-settings.native.js.map +1 -1
- package/build/cover/transforms.js +4 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/image/deprecated.js +89 -5
- package/build/image/deprecated.js.map +1 -1
- package/build/image/save.js +0 -7
- package/build/image/save.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/navigation/edit/index.js +17 -15
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +44 -27
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +8 -22
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +6 -6
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-submenu/edit.js +41 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +11 -17
- package/build/page-list/edit.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/template-part/edit/index.js +36 -64
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/placeholder.js +64 -0
- package/build/template-part/edit/placeholder.js.map +1 -0
- package/build/template-part/edit/selection-modal.js +103 -0
- package/build/template-part/edit/selection-modal.js.map +1 -0
- package/build/template-part/edit/title-modal.js +54 -0
- package/build/template-part/edit/title-modal.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +156 -0
- package/build/template-part/edit/utils/hooks.js.map +1 -0
- package/build/template-part/index.js +3 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/button/edit.native.js +4 -4
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/columns/index.js +12 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +18 -6
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +95 -37
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +156 -0
- package/build-module/comment-template/hooks.js.map +1 -0
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comment-template/util.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +1 -1
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -19
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +5 -0
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/edit.js +23 -24
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +10 -8
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/overlay-color-settings.native.js +4 -4
- package/build-module/cover/overlay-color-settings.native.js.map +1 -1
- package/build-module/cover/transforms.js +4 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/image/deprecated.js +90 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/save.js +0 -7
- package/build-module/image/save.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -15
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +8 -21
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +6 -6
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +41 -10
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +12 -18
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/template-part/edit/index.js +37 -65
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +52 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -0
- package/build-module/template-part/edit/selection-modal.js +89 -0
- package/build-module/template-part/edit/selection-modal.js.map +1 -0
- package/build-module/template-part/edit/title-modal.js +46 -0
- package/build-module/template-part/edit/title-modal.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +135 -0
- package/build-module/template-part/edit/utils/hooks.js.map +1 -0
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/comment-author-avatar/editor-rtl.css +83 -0
- package/build-style/comment-author-avatar/editor.css +83 -0
- package/build-style/cover/style-rtl.css +4 -0
- package/build-style/cover/style.css +4 -0
- package/build-style/editor-rtl.css +27 -81
- package/build-style/editor.css +27 -81
- package/build-style/image/editor-rtl.css +0 -16
- package/build-style/image/editor.css +0 -16
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation/style-rtl.css +14 -3
- package/build-style/navigation/style.css +14 -3
- package/build-style/page-list/editor-rtl.css +0 -9
- package/build-style/page-list/editor.css +0 -9
- package/build-style/style-rtl.css +20 -3
- package/build-style/style.css +20 -3
- package/build-style/template-part/editor-rtl.css +19 -56
- package/build-style/template-part/editor.css +19 -56
- package/package.json +15 -15
- package/src/archives/index.php +1 -1
- package/src/button/edit.native.js +3 -3
- package/src/columns/block.json +12 -0
- package/src/comment-author-avatar/edit.js +13 -8
- package/src/comment-author-avatar/editor.scss +7 -0
- package/src/comment-template/block.json +7 -1
- package/src/comment-template/edit.js +102 -40
- package/src/comment-template/hooks.js +151 -0
- package/src/comment-template/index.php +8 -0
- package/src/comment-template/util.js +1 -0
- package/src/comments-pagination-next/block.json +8 -1
- package/src/comments-pagination-next/index.php +6 -8
- package/src/comments-pagination-numbers/block.json +7 -1
- package/src/comments-pagination-numbers/index.php +3 -10
- package/src/comments-query-loop/block.json +5 -0
- package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
- package/src/comments-query-loop/edit.js +1 -16
- package/src/cover/edit.js +15 -28
- package/src/cover/edit.native.js +15 -7
- package/src/cover/overlay-color-settings.native.js +3 -4
- package/src/cover/style.scss +4 -0
- package/src/cover/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/gallery/index.php +1 -8
- package/src/group/block.json +1 -0
- package/src/heading/edit.js +18 -5
- package/src/home-link/index.php +1 -19
- package/src/image/deprecated.js +105 -1
- package/src/image/editor.scss +0 -18
- package/src/image/save.js +0 -8
- package/src/image/style.scss +3 -0
- package/src/image/test/edit.native.js +0 -10
- package/src/latest-posts/edit.js +1 -0
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/index.js +25 -26
- package/src/navigation/edit/navigation-menu-selector.js +73 -28
- package/src/navigation/edit/placeholder/index.js +8 -32
- package/src/navigation/index.php +4 -4
- package/src/navigation/style.scss +22 -3
- package/src/navigation/use-navigation-menu.js +6 -6
- package/src/navigation-link/index.php +3 -22
- package/src/navigation-submenu/edit.js +50 -12
- package/src/navigation-submenu/index.php +3 -21
- package/src/page-list/edit.js +21 -25
- package/src/page-list/editor.scss +0 -10
- package/src/page-list/index.php +4 -4
- package/src/post-navigation-link/index.php +3 -3
- package/src/search/index.php +6 -3
- package/src/site-logo/index.php +1 -1
- package/src/social-links/deprecated.js +0 -59
- package/src/template-part/edit/index.js +61 -71
- package/src/template-part/edit/placeholder.js +78 -0
- package/src/template-part/edit/selection-modal.js +115 -0
- package/src/template-part/edit/title-modal.js +59 -0
- package/src/template-part/edit/utils/hooks.js +158 -0
- package/src/template-part/editor.scss +16 -74
- package/src/template-part/index.js +4 -1
- package/build/navigation/edit/existing-menus-options.js +0 -62
- package/build/navigation/edit/existing-menus-options.js.map +0 -1
- package/build/template-part/edit/placeholder/index.js +0 -141
- package/build/template-part/edit/placeholder/index.js.map +0 -1
- package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
- package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build/template-part/edit/selection/index.js +0 -45
- package/build/template-part/edit/selection/index.js.map +0 -1
- package/build/template-part/edit/selection/template-part-previews.js +0 -317
- package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/build-module/navigation/edit/existing-menus-options.js +0 -53
- package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
- package/build-module/template-part/edit/placeholder/index.js +0 -124
- package/build-module/template-part/edit/placeholder/index.js.map +0 -1
- package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
- package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build-module/template-part/edit/selection/index.js +0 -35
- package/build-module/template-part/edit/selection/index.js.map +0 -1
- package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
- package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/src/navigation/edit/existing-menus-options.js +0 -70
- package/src/template-part/edit/placeholder/index.js +0 -172
- package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
- package/src/template-part/edit/selection/index.js +0 -37
- package/src/template-part/edit/selection/template-part-previews.js +0 -372
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useCommentTree = exports.useCommentQueryArgs = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
15
|
+
|
|
16
|
+
var _url = require("@wordpress/url");
|
|
17
|
+
|
|
18
|
+
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Return an object with the query args needed to fetch the default page of
|
|
26
|
+
* comments.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} props Hook props.
|
|
29
|
+
* @param {number} props.postId ID of the post that contains the comments.
|
|
30
|
+
* @param {number} props.perPage The number of comments included per page.
|
|
31
|
+
* @param {string} props.defaultPage Page shown by default (newest/oldest).
|
|
32
|
+
* @param {boolean} props.inherit Overwrite props with values from WP
|
|
33
|
+
* discussion settings.
|
|
34
|
+
*
|
|
35
|
+
* @return {Object} Query args to retrieve the comments.
|
|
36
|
+
*/
|
|
37
|
+
const useCommentQueryArgs = _ref => {
|
|
38
|
+
let {
|
|
39
|
+
postId,
|
|
40
|
+
perPage,
|
|
41
|
+
defaultPage,
|
|
42
|
+
inherit
|
|
43
|
+
} = _ref;
|
|
44
|
+
// Initialize the query args that are not going to change.
|
|
45
|
+
const queryArgs = {
|
|
46
|
+
status: 'approve',
|
|
47
|
+
order: 'asc',
|
|
48
|
+
context: 'embed',
|
|
49
|
+
parent: 0,
|
|
50
|
+
_embed: 'children'
|
|
51
|
+
}; // Get the Discussion settings that may be needed to query the comments.
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
commentsPerPage,
|
|
55
|
+
defaultCommentsPage
|
|
56
|
+
} = (0, _data.useSelect)(select => {
|
|
57
|
+
const {
|
|
58
|
+
getSettings
|
|
59
|
+
} = select(_blockEditor.store);
|
|
60
|
+
const {
|
|
61
|
+
__experimentalDiscussionSettings
|
|
62
|
+
} = getSettings();
|
|
63
|
+
return __experimentalDiscussionSettings;
|
|
64
|
+
}); // Overwrite the received attributes if `inherit` is true.
|
|
65
|
+
|
|
66
|
+
if (inherit) {
|
|
67
|
+
perPage = commentsPerPage;
|
|
68
|
+
defaultPage = defaultCommentsPage;
|
|
69
|
+
} // If a block props is not set, use the settings value to generate the
|
|
70
|
+
// appropriate query arg.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
perPage = perPage || commentsPerPage;
|
|
74
|
+
defaultPage = defaultPage || defaultCommentsPage; // Get the number of the default page.
|
|
75
|
+
|
|
76
|
+
const page = useDefaultPageIndex({
|
|
77
|
+
defaultPage,
|
|
78
|
+
postId,
|
|
79
|
+
perPage,
|
|
80
|
+
queryArgs
|
|
81
|
+
}); // Merge, memoize and return all query arguments, unless the default page's
|
|
82
|
+
// number is not known yet.
|
|
83
|
+
|
|
84
|
+
return (0, _element.useMemo)(() => {
|
|
85
|
+
return page ? { ...queryArgs,
|
|
86
|
+
post: postId,
|
|
87
|
+
per_page: perPage,
|
|
88
|
+
page
|
|
89
|
+
} : null;
|
|
90
|
+
}, [postId, perPage, page]);
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Return the index of the default page, depending on whether `defaultPage` is
|
|
94
|
+
* `newest` or `oldest`. In the first case, the only way to know the page's
|
|
95
|
+
* index is by using the `X-WP-TotalPages` header, which forces to make an
|
|
96
|
+
* additional request.
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} props Hook props.
|
|
99
|
+
* @param {string} props.defaultPage Page shown by default (newest/oldest).
|
|
100
|
+
* @param {number} props.postId ID of the post that contains the comments.
|
|
101
|
+
* @param {number} props.perPage The number of comments included per page.
|
|
102
|
+
* @param {Object} props.queryArgs Other query args.
|
|
103
|
+
*
|
|
104
|
+
* @return {number} Index of the default comments page.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
exports.useCommentQueryArgs = useCommentQueryArgs;
|
|
109
|
+
|
|
110
|
+
const useDefaultPageIndex = _ref2 => {
|
|
111
|
+
let {
|
|
112
|
+
defaultPage,
|
|
113
|
+
postId,
|
|
114
|
+
perPage,
|
|
115
|
+
queryArgs
|
|
116
|
+
} = _ref2;
|
|
117
|
+
// Store the default page indices.
|
|
118
|
+
const [defaultPages, setDefaultPages] = (0, _element.useState)({});
|
|
119
|
+
const key = `${postId}_${perPage}`;
|
|
120
|
+
const page = defaultPages[key] || 0;
|
|
121
|
+
(0, _element.useEffect)(() => {
|
|
122
|
+
// Do nothing if the page is already known or not the newest page.
|
|
123
|
+
if (page || defaultPage !== 'newest') {
|
|
124
|
+
return;
|
|
125
|
+
} // We need to fetch comments to know the index. Use HEAD and limit
|
|
126
|
+
// fields just to ID, to make this call as light as possible.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
(0, _apiFetch.default)({
|
|
130
|
+
path: (0, _url.addQueryArgs)('/wp/v2/comments', { ...queryArgs,
|
|
131
|
+
post: postId,
|
|
132
|
+
per_page: perPage,
|
|
133
|
+
_fields: 'id'
|
|
134
|
+
}),
|
|
135
|
+
method: 'HEAD',
|
|
136
|
+
parse: false
|
|
137
|
+
}).then(res => {
|
|
138
|
+
setDefaultPages({ ...defaultPages,
|
|
139
|
+
[key]: parseInt(res.headers.get('X-WP-TotalPages'))
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}, [defaultPage, postId, perPage, setDefaultPages]); // The oldest one is always the first one.
|
|
143
|
+
|
|
144
|
+
return defaultPage === 'newest' ? page : 1;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Generate a tree structure of comment IDs from a list of comment entities. The
|
|
148
|
+
* children of each comment are obtained from `_embedded`.
|
|
149
|
+
*
|
|
150
|
+
* @typedef {{ commentId: number, children: CommentNode }} CommentNode
|
|
151
|
+
*
|
|
152
|
+
* @param {Object[]} topLevelComments List of comment entities.
|
|
153
|
+
* @return {{ commentTree: CommentNode[]}} Tree of comment IDs.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
const useCommentTree = topLevelComments => {
|
|
158
|
+
const commentTree = (0, _element.useMemo)(() => topLevelComments === null || topLevelComments === void 0 ? void 0 : topLevelComments.map(_ref3 => {
|
|
159
|
+
let {
|
|
160
|
+
id,
|
|
161
|
+
_embedded
|
|
162
|
+
} = _ref3;
|
|
163
|
+
const [children] = (_embedded === null || _embedded === void 0 ? void 0 : _embedded.children) || [[]];
|
|
164
|
+
return {
|
|
165
|
+
commentId: id,
|
|
166
|
+
children: children.map(child => ({
|
|
167
|
+
commentId: child.id
|
|
168
|
+
}))
|
|
169
|
+
};
|
|
170
|
+
}), [topLevelComments]);
|
|
171
|
+
return commentTree;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
exports.useCommentTree = useCommentTree;
|
|
175
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useCommentQueryArgs","postId","perPage","defaultPage","inherit","queryArgs","status","order","context","parent","_embed","commentsPerPage","defaultCommentsPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":"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","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/**\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 * @param {number} props.perPage The number of comments included per page.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {boolean} props.inherit Overwrite props with values from WP\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( {\n\tpostId,\n\tperPage,\n\tdefaultPage,\n\tinherit,\n} ) => {\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 { commentsPerPage, defaultCommentsPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// Overwrite the received attributes if `inherit` is true.\n\tif ( inherit ) {\n\t\tperPage = commentsPerPage;\n\t\tdefaultPage = defaultCommentsPage;\n\t}\n\n\t// If a block props is not set, use the settings value to generate the\n\t// appropriate query arg.\n\tperPage = perPage || commentsPerPage;\n\tdefaultPage = defaultPage || defaultCommentsPage;\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\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: parseInt( res.headers.get( 'X-WP-TotalPages' ) ),\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"]}
|
|
@@ -29,7 +29,7 @@ const metadata = {
|
|
|
29
29
|
parent: ["core/comments-query-loop"],
|
|
30
30
|
description: "Contains the block elements used to render a comment, like the title, date, author, avatar and more.",
|
|
31
31
|
textdomain: "default",
|
|
32
|
-
usesContext: ["comments/
|
|
32
|
+
usesContext: ["comments/defaultPage", "comments/inherit", "comments/order", "comments/perPage", "postId"],
|
|
33
33
|
supports: {
|
|
34
34
|
reusable: false,
|
|
35
35
|
html: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/util.js"],"names":["convertToTree","data","table","forEach","item","id","commentId","children","tree","parent","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAKC,IAAF,IAAY;AACxC,QAAMC,KAAK,GAAG,EAAd;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/util.js"],"names":["convertToTree","data","table","forEach","item","id","commentId","children","tree","parent","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAKC,IAAF,IAAY;AACxC,QAAMC,KAAK,GAAG,EAAd;AAEA,MAAK,CAAED,IAAP,EAAc,OAAO,EAAP,CAH0B,CAKxC;;AACAA,EAAAA,IAAI,CAACE,OAAL,CAAgBC,IAAF,IAAY;AACzBF,IAAAA,KAAK,CAAEE,IAAI,CAACC,EAAP,CAAL,GAAmB;AAAEC,MAAAA,SAAS,EAAEF,IAAI,CAACC,EAAlB;AAAsBE,MAAAA,QAAQ,EAAE;AAAhC,KAAnB;AACA,GAFD;AAIA,QAAMC,IAAI,GAAG,EAAb,CAVwC,CAYxC;;AACAP,EAAAA,IAAI,CAACE,OAAL,CAAgBC,IAAF,IAAY;AACzB,QAAKA,IAAI,CAACK,MAAV,EAAmB;AAAA;;AAClB;AACA;AACA;AACA,4BAAAP,KAAK,CAAEE,IAAI,CAACK,MAAP,CAAL,0EAAsBF,QAAtB,CAA+BG,IAA/B,CAAqCR,KAAK,CAAEE,IAAI,CAACC,EAAP,CAA1C;AACA,KALD,MAKO;AACN;AACA;AACA;AACAG,MAAAA,IAAI,CAACE,IAAL,CAAWR,KAAK,CAAEE,IAAI,CAACC,EAAP,CAAhB;AACA;AACD,GAZD;AAaA,SAAOG,IAAP;AACA,CA3BM","sourcesContent":["/**\n *\n * This function converts a flat list of comment objects with a `parent` property\n * to a nested list of comment objects with a `children` property. The `children`\n * property is itself a list of comment objects.\n *\n * @example\n * ```\n * const comments = [\n * \t{ id: 1, parent: 0 },\n * \t{ id: 2, parent: 1 },\n * \t{ id: 3, parent: 2 },\n * \t{ id: 4, parent: 1 },\n * ];\n * expect( convertToTree( comments ) ).toEqual( [\n * \t{\n * \t\tcommentId: 1,\n * \t\tchildren: [\n * \t\t\t{ commentId: 2, children: [ { commentId: 3, children: [] } ] },\n * \t\t\t{ commentId: 4, children: [] },\n * \t\t],\n * \t},\n * ] );\n * ```\n * @typedef {{id: number, parent: number}} Comment\n * @param {Comment[]} data - List of comment objects.\n *\n * @return {Object[]} Nested list of comment objects with a `children` property.\n */\nexport const convertToTree = ( data ) => {\n\tconst table = {};\n\n\tif ( ! data ) return [];\n\n\t// First create a hash table of { [id]: { ...comment, children: [] }}\n\tdata.forEach( ( item ) => {\n\t\ttable[ item.id ] = { commentId: item.id, children: [] };\n\t} );\n\n\tconst tree = [];\n\n\t// Iterate over the original comments again\n\tdata.forEach( ( item ) => {\n\t\tif ( item.parent ) {\n\t\t\t// If the comment has a \"parent\", then find that parent in the table that\n\t\t\t// we have created above and push the current comment to the array of its\n\t\t\t// children.\n\t\t\ttable[ item.parent ]?.children.push( table[ item.id ] );\n\t\t} else {\n\t\t\t// Otherwise, if the comment has no parent (also works if parent is 0)\n\t\t\t// that means that it's a top-level comment so we can find it in the table\n\t\t\t// and push it to the final tree.\n\t\t\ttree.push( table[ item.id ] );\n\t\t}\n\t} );\n\treturn tree;\n};\n"]}
|
|
@@ -32,7 +32,7 @@ const metadata = {
|
|
|
32
32
|
type: "string"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
usesContext: ["postId", "comments/perPage", "comments/paginationArrow"],
|
|
35
|
+
usesContext: ["postId", "comments/perPage", "comments/order", "comments/inherit", "comments/defaultPage", "comments/paginationArrow"],
|
|
36
36
|
supports: {
|
|
37
37
|
reusable: false,
|
|
38
38
|
html: false,
|
|
@@ -27,7 +27,7 @@ const metadata = {
|
|
|
27
27
|
parent: ["core/comments-pagination"],
|
|
28
28
|
description: "Displays a list of page numbers for comments pagination.",
|
|
29
29
|
textdomain: "default",
|
|
30
|
-
usesContext: ["comments/perPage", "
|
|
30
|
+
usesContext: ["postId", "comments/perPage", "comments/order", "comments/inherit", "comments/defaultPage"],
|
|
31
31
|
supports: {
|
|
32
32
|
reusable: false,
|
|
33
33
|
html: false
|
|
@@ -23,6 +23,13 @@ const orderOptions = [{
|
|
|
23
23
|
label: (0, _i18n.__)('Oldest to newest'),
|
|
24
24
|
value: 'asc'
|
|
25
25
|
}];
|
|
26
|
+
const defaultPageOptions = [{
|
|
27
|
+
label: (0, _i18n.__)('Newest'),
|
|
28
|
+
value: 'newest'
|
|
29
|
+
}, {
|
|
30
|
+
label: (0, _i18n.__)('Oldest'),
|
|
31
|
+
value: 'oldest'
|
|
32
|
+
}];
|
|
26
33
|
|
|
27
34
|
function CommentsInspectorControls(_ref) {
|
|
28
35
|
let {
|
|
@@ -30,13 +37,10 @@ function CommentsInspectorControls(_ref) {
|
|
|
30
37
|
TagName,
|
|
31
38
|
perPage,
|
|
32
39
|
order,
|
|
33
|
-
inherit
|
|
40
|
+
inherit,
|
|
41
|
+
defaultPage
|
|
34
42
|
},
|
|
35
|
-
setAttributes
|
|
36
|
-
defaultSettings: {
|
|
37
|
-
defaultPerPage,
|
|
38
|
-
defaultOrder
|
|
39
|
-
}
|
|
43
|
+
setAttributes
|
|
40
44
|
} = _ref;
|
|
41
45
|
return (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
42
46
|
title: (0, _i18n.__)('Settings')
|
|
@@ -45,9 +49,7 @@ function CommentsInspectorControls(_ref) {
|
|
|
45
49
|
checked: inherit,
|
|
46
50
|
onChange: () => {
|
|
47
51
|
setAttributes({
|
|
48
|
-
inherit: !inherit
|
|
49
|
-
order: inherit ? defaultOrder : null,
|
|
50
|
-
perPage: inherit ? defaultPerPage : null
|
|
52
|
+
inherit: !inherit
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
}), !inherit && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.SelectControl, {
|
|
@@ -59,6 +61,15 @@ function CommentsInspectorControls(_ref) {
|
|
|
59
61
|
order: value
|
|
60
62
|
});
|
|
61
63
|
}
|
|
64
|
+
}), (0, _element.createElement)(_components.SelectControl, {
|
|
65
|
+
label: (0, _i18n.__)('Default page'),
|
|
66
|
+
value: defaultPage,
|
|
67
|
+
options: defaultPageOptions,
|
|
68
|
+
onChange: value => {
|
|
69
|
+
setAttributes({
|
|
70
|
+
defaultPage: value
|
|
71
|
+
});
|
|
72
|
+
}
|
|
62
73
|
}), (0, _element.createElement)(_components.__experimentalNumberControl, {
|
|
63
74
|
__unstableInputWidth: "60px",
|
|
64
75
|
label: (0, _i18n.__)('Items per Page'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["orderOptions","label","value","CommentsInspectorControls","attributes","TagName","perPage","order","inherit","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["orderOptions","label","value","defaultPageOptions","CommentsInspectorControls","attributes","TagName","perPage","order","inherit","defaultPage","setAttributes","num","parseInt","isNaN","tagName"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nconst orderOptions = [\n\t{\n\t\tlabel: __( 'Newest to oldest' ),\n\t\tvalue: 'desc',\n\t},\n\t{\n\t\tlabel: __( 'Oldest to newest' ),\n\t\tvalue: 'asc',\n\t},\n];\n\nconst defaultPageOptions = [\n\t{\n\t\tlabel: __( 'Newest' ),\n\t\tvalue: 'newest',\n\t},\n\t{\n\t\tlabel: __( 'Oldest' ),\n\t\tvalue: 'oldest',\n\t},\n];\n\nexport default function CommentsInspectorControls( {\n\tattributes: { TagName, perPage, order, inherit, defaultPage },\n\tsetAttributes,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Inherit from Discussion Settings' ) }\n\t\t\t\t\tchecked={ inherit }\n\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tinherit: ! inherit,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\t\t\tvalue={ order }\n\t\t\t\t\t\t\toptions={ orderOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\torder: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Default page' ) }\n\t\t\t\t\t\t\tvalue={ defaultPage }\n\t\t\t\t\t\t\toptions={ defaultPageOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdefaultPage: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t\t__unstableInputWidth=\"60px\"\n\t\t\t\t\t\t\tlabel={ __( 'Items per Page' ) }\n\t\t\t\t\t\t\tlabelPosition=\"edge\"\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tconst num = parseInt( value, 10 );\n\t\t\t\t\t\t\t\tif ( isNaN( num ) || num < 1 || num > 100 ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tperPage: num,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\t\tvalue={ perPage }\n\t\t\t\t\t\t\tisDragEnabled={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -13,8 +13,6 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
13
13
|
|
|
14
14
|
var _commentsInspectorControls = _interopRequireDefault(require("./edit/comments-inspector-controls"));
|
|
15
15
|
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
16
|
/**
|
|
19
17
|
* WordPress dependencies
|
|
20
18
|
*/
|
|
@@ -36,25 +34,9 @@ function CommentsQueryLoopEdit(_ref) {
|
|
|
36
34
|
const innerBlocksProps = (0, _blockEditor.useInnerBlocksProps)(blockProps, {
|
|
37
35
|
template: TEMPLATE
|
|
38
36
|
});
|
|
39
|
-
const {
|
|
40
|
-
commentOrder,
|
|
41
|
-
commentsPerPage
|
|
42
|
-
} = (0, _data.useSelect)(select => {
|
|
43
|
-
const {
|
|
44
|
-
getSettings
|
|
45
|
-
} = select(_blockEditor.store);
|
|
46
|
-
const {
|
|
47
|
-
__experimentalDiscussionSettings
|
|
48
|
-
} = getSettings();
|
|
49
|
-
return __experimentalDiscussionSettings;
|
|
50
|
-
});
|
|
51
37
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_commentsInspectorControls.default, {
|
|
52
38
|
attributes: attributes,
|
|
53
|
-
setAttributes: setAttributes
|
|
54
|
-
defaultSettings: {
|
|
55
|
-
defaultOrder: commentOrder,
|
|
56
|
-
defaultPerPage: commentsPerPage
|
|
57
|
-
}
|
|
39
|
+
setAttributes: setAttributes
|
|
58
40
|
}), (0, _element.createElement)(TagName, innerBlocksProps));
|
|
59
41
|
}
|
|
60
42
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit.js"],"names":["TEMPLATE","CommentsQueryLoopEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit.js"],"names":["TEMPLATE","CommentsQueryLoopEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,uBAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,CAAjB;;AAKe,SAASC,qBAAT,OAAgE;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AAC9E,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAAuBH,UAA7B;AAEA,QAAMI,UAAU,GAAG,iCAAnB;AACA,QAAMC,gBAAgB,GAAG,sCAAqBD,UAArB,EAAiC;AACzDE,IAAAA,QAAQ,EAAER;AAD+C,GAAjC,CAAzB;AAIA,SACC,qDACC,4BAAC,kCAAD;AACC,IAAA,UAAU,EAAGE,UADd;AAEC,IAAA,aAAa,EAAGC;AAFjB,IADD,EAKC,4BAAC,OAAD,EAAcI,gBAAd,CALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comment-template' ],\n\t[ 'core/comments-pagination' ],\n];\n\nexport default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {\n\tconst { tagName: TagName } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<CommentsInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -44,11 +44,16 @@ const metadata = {
|
|
|
44
44
|
tagName: {
|
|
45
45
|
type: "string",
|
|
46
46
|
"default": "div"
|
|
47
|
+
},
|
|
48
|
+
defaultPage: {
|
|
49
|
+
type: "string",
|
|
50
|
+
"default": "oldest"
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
53
|
providesContext: {
|
|
50
54
|
"comments/perPage": "perPage",
|
|
51
55
|
"comments/order": "order",
|
|
56
|
+
"comments/defaultPage": "defaultPage",
|
|
52
57
|
"comments/inherit": "inherit"
|
|
53
58
|
},
|
|
54
59
|
supports: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/index.js"],"names":["name","metadata","settings","icon","edit","save"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/index.js"],"names":["name","metadata","settings","icon","edit","save"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,mBADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,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';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n"]}
|
package/build/cover/edit.js
CHANGED
|
@@ -292,8 +292,7 @@ function CoverEdit(_ref5) {
|
|
|
292
292
|
overlayColor,
|
|
293
293
|
setAttributes,
|
|
294
294
|
setOverlayColor,
|
|
295
|
-
toggleSelection
|
|
296
|
-
markNextChangeAsNotPersistent
|
|
295
|
+
toggleSelection
|
|
297
296
|
} = _ref5;
|
|
298
297
|
const {
|
|
299
298
|
contentPosition,
|
|
@@ -312,6 +311,9 @@ function CoverEdit(_ref5) {
|
|
|
312
311
|
allowedBlocks,
|
|
313
312
|
templateLock
|
|
314
313
|
} = attributes;
|
|
314
|
+
const {
|
|
315
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
316
|
+
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
315
317
|
const {
|
|
316
318
|
gradientClass,
|
|
317
319
|
gradientValue,
|
|
@@ -368,18 +370,18 @@ function CoverEdit(_ref5) {
|
|
|
368
370
|
const isCoverDark = useCoverIsDark(url, dimRatio, overlayColor.color, isDarkElement);
|
|
369
371
|
(0, _element.useEffect)(() => {
|
|
370
372
|
// This side-effect should not create an undo level.
|
|
371
|
-
|
|
373
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
374
|
+
|
|
372
375
|
setAttributes({
|
|
373
376
|
isDark: isCoverDark
|
|
374
377
|
});
|
|
375
378
|
}, [isCoverDark]);
|
|
376
379
|
const isImageBackground = _shared.IMAGE_BACKGROUND_TYPE === backgroundType;
|
|
377
380
|
const isVideoBackground = _shared.VIDEO_BACKGROUND_TYPE === backgroundType;
|
|
378
|
-
const [temporaryMinHeight, setTemporaryMinHeight] = (0, _element.useState)(null);
|
|
379
381
|
const minHeightWithUnit = minHeightUnit ? `${minHeight}${minHeightUnit}` : minHeight;
|
|
380
382
|
const isImgElement = !(hasParallax || isRepeated);
|
|
381
383
|
const style = { ...(isImageBackground && !isImgElement ? (0, _shared.backgroundImageStyles)(url) : undefined),
|
|
382
|
-
minHeight:
|
|
384
|
+
minHeight: minHeightWithUnit || undefined
|
|
383
385
|
};
|
|
384
386
|
const bgStyle = {
|
|
385
387
|
backgroundColor: overlayColor.color
|
|
@@ -496,7 +498,7 @@ function CoverEdit(_ref5) {
|
|
|
496
498
|
isShownByDefault: true,
|
|
497
499
|
panelId: clientId
|
|
498
500
|
}, (0, _element.createElement)(CoverHeightInput, {
|
|
499
|
-
value:
|
|
501
|
+
value: minHeight,
|
|
500
502
|
unit: minHeightUnit,
|
|
501
503
|
onChange: newMinHeight => setAttributes({
|
|
502
504
|
minHeight: newMinHeight
|
|
@@ -531,7 +533,7 @@ function CoverEdit(_ref5) {
|
|
|
531
533
|
onSelectMedia: onSelectMedia,
|
|
532
534
|
noticeOperations: noticeOperations,
|
|
533
535
|
style: {
|
|
534
|
-
minHeight:
|
|
536
|
+
minHeight: minHeightWithUnit || undefined
|
|
535
537
|
}
|
|
536
538
|
}, (0, _element.createElement)("div", {
|
|
537
539
|
className: "wp-block-cover__placeholder-background-options"
|
|
@@ -548,13 +550,16 @@ function CoverEdit(_ref5) {
|
|
|
548
550
|
});
|
|
549
551
|
toggleSelection(false);
|
|
550
552
|
},
|
|
551
|
-
onResize:
|
|
553
|
+
onResize: value => {
|
|
554
|
+
setAttributes({
|
|
555
|
+
minHeight: value
|
|
556
|
+
});
|
|
557
|
+
},
|
|
552
558
|
onResizeStop: newMinHeight => {
|
|
553
559
|
toggleSelection(true);
|
|
554
560
|
setAttributes({
|
|
555
561
|
minHeight: newMinHeight
|
|
556
562
|
});
|
|
557
|
-
setTemporaryMinHeight(null);
|
|
558
563
|
},
|
|
559
564
|
showHandle: isSelected
|
|
560
565
|
})));
|
|
@@ -586,13 +591,16 @@ function CoverEdit(_ref5) {
|
|
|
586
591
|
});
|
|
587
592
|
toggleSelection(false);
|
|
588
593
|
},
|
|
589
|
-
onResize:
|
|
594
|
+
onResize: value => {
|
|
595
|
+
setAttributes({
|
|
596
|
+
minHeight: value
|
|
597
|
+
});
|
|
598
|
+
},
|
|
590
599
|
onResizeStop: newMinHeight => {
|
|
591
600
|
toggleSelection(true);
|
|
592
601
|
setAttributes({
|
|
593
602
|
minHeight: newMinHeight
|
|
594
603
|
});
|
|
595
|
-
setTemporaryMinHeight(null);
|
|
596
604
|
},
|
|
597
605
|
showHandle: isSelected
|
|
598
606
|
}), (0, _element.createElement)("span", {
|
|
@@ -633,18 +641,9 @@ function CoverEdit(_ref5) {
|
|
|
633
641
|
}), (0, _element.createElement)("div", innerBlocksProps)));
|
|
634
642
|
}
|
|
635
643
|
|
|
636
|
-
var _default = (0, _compose.compose)([(0,
|
|
637
|
-
const {
|
|
638
|
-
toggleSelection,
|
|
639
|
-
__unstableMarkNextChangeAsNotPersistent
|
|
640
|
-
} = dispatch(_blockEditor.store);
|
|
641
|
-
return {
|
|
642
|
-
toggleSelection,
|
|
643
|
-
markNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent
|
|
644
|
-
};
|
|
645
|
-
}), (0, _blockEditor.withColors)({
|
|
644
|
+
var _default = (0, _compose.compose)([(0, _blockEditor.withColors)({
|
|
646
645
|
overlayColor: 'background-color'
|
|
647
|
-
}), _components.withNotices
|
|
646
|
+
}), _components.withNotices])(CoverEdit);
|
|
648
647
|
|
|
649
648
|
exports.default = _default;
|
|
650
649
|
//# sourceMappingURL=edit.js.map
|