Block Editor: Second batch of fixes for 5.8 beta 2
This includes: - Fix regression emptying post content block in template mode. - Legacy Widget: Don't display "No preview" when widget has image tags. See #53397. Built from https://develop.svn.wordpress.org/trunk@51156 git-svn-id: http://core.svn.wordpress.org/trunk@50765 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aed608b98c
commit
b018c55899
File diff suppressed because one or more lines are too long
|
@ -30410,12 +30410,11 @@ const postTitle = Object(external_wp_element_["createElement"])(external_wp_prim
|
||||||
*
|
*
|
||||||
* @param {string} kind Entity kind.
|
* @param {string} kind Entity kind.
|
||||||
* @param {string} name Entity name.
|
* @param {string} name Entity name.
|
||||||
* @param {number} key Record's key.
|
|
||||||
* @param {string} recordId Record's id.
|
* @param {string} recordId Record's id.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function useCanEditEntity(kind, name, key, recordId) {
|
function useCanEditEntity(kind, name, recordId) {
|
||||||
return Object(external_wp_data_["useSelect"])(select => select(external_wp_coreData_["store"]).canUserEditEntityRecord(kind, name, key, recordId), [kind, name, key, recordId]);
|
return Object(external_wp_data_["useSelect"])(select => select(external_wp_coreData_["store"]).canUserEditEntityRecord(kind, name, recordId), [kind, name, recordId]);
|
||||||
}
|
}
|
||||||
/* harmony default export */ var utils_hooks = ({
|
/* harmony default export */ var utils_hooks = ({
|
||||||
useCanEditEntity
|
useCanEditEntity
|
||||||
|
@ -30461,7 +30460,7 @@ function PostTitleEdit({
|
||||||
}) {
|
}) {
|
||||||
const TagName = 0 === level ? 'p' : 'h' + level;
|
const TagName = 0 === level ? 'p' : 'h' + level;
|
||||||
const isDescendentOfQueryLoop = !!queryId;
|
const isDescendentOfQueryLoop = !!queryId;
|
||||||
const userCanEdit = useCanEditEntity('root', 'postType', postType, postId);
|
const userCanEdit = useCanEditEntity('postType', postType, postId);
|
||||||
const [rawTitle = '', setTitle, fullTitle] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'title', postId);
|
const [rawTitle = '', setTitle, fullTitle] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'title', postId);
|
||||||
const [link] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'link', postId);
|
const [link] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'link', postId);
|
||||||
const blockProps = Object(external_wp_blockEditor_["useBlockProps"])({
|
const blockProps = Object(external_wp_blockEditor_["useBlockProps"])({
|
||||||
|
@ -30650,9 +30649,12 @@ function ReadOnlyContent({
|
||||||
|
|
||||||
function EditableContent({
|
function EditableContent({
|
||||||
layout,
|
layout,
|
||||||
|
context = {}
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
postType,
|
postType,
|
||||||
postId
|
postId
|
||||||
}) {
|
} = context;
|
||||||
const themeSupportsLayout = Object(external_wp_data_["useSelect"])(select => {
|
const themeSupportsLayout = Object(external_wp_data_["useSelect"])(select => {
|
||||||
var _getSettings;
|
var _getSettings;
|
||||||
|
|
||||||
|
@ -30704,7 +30706,7 @@ function Content(props) {
|
||||||
} = {}
|
} = {}
|
||||||
} = props;
|
} = props;
|
||||||
const isDescendentOfQueryLoop = !!queryId;
|
const isDescendentOfQueryLoop = !!queryId;
|
||||||
const userCanEdit = useCanEditEntity('root', 'postType', postType, postId);
|
const userCanEdit = useCanEditEntity('postType', postType, postId);
|
||||||
const isEditable = userCanEdit && !isDescendentOfQueryLoop;
|
const isEditable = userCanEdit && !isDescendentOfQueryLoop;
|
||||||
return isEditable ? Object(external_wp_element_["createElement"])(EditableContent, props) : Object(external_wp_element_["createElement"])(ReadOnlyContent, {
|
return isEditable ? Object(external_wp_element_["createElement"])(EditableContent, props) : Object(external_wp_element_["createElement"])(ReadOnlyContent, {
|
||||||
userCanEdit: userCanEdit,
|
userCanEdit: userCanEdit,
|
||||||
|
@ -31027,7 +31029,7 @@ function PostExcerptEditor({
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
const isDescendentOfQueryLoop = !!queryId;
|
const isDescendentOfQueryLoop = !!queryId;
|
||||||
const userCanEdit = useCanEditEntity('root', 'postType', postType, postId);
|
const userCanEdit = useCanEditEntity('postType', postType, postId);
|
||||||
const isEditable = userCanEdit && !isDescendentOfQueryLoop;
|
const isEditable = userCanEdit && !isDescendentOfQueryLoop;
|
||||||
const [rawExcerpt, setExcerpt, {
|
const [rawExcerpt, setExcerpt, {
|
||||||
rendered: renderedExcerpt,
|
rendered: renderedExcerpt,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2044,7 +2044,8 @@ function* loadPostTypeEntities() {
|
||||||
|
|
||||||
return (record === null || record === void 0 ? void 0 : (_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) || (record === null || record === void 0 ? void 0 : record.title) || (isTemplate ? Object(external_lodash_["startCase"])(record.slug) : String(record.id));
|
return (record === null || record === void 0 ? void 0 : (_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) || (record === null || record === void 0 ? void 0 : record.title) || (isTemplate ? Object(external_lodash_["startCase"])(record.slug) : String(record.id));
|
||||||
},
|
},
|
||||||
__unstablePrePersist: isTemplate ? undefined : prePersistPostType
|
__unstablePrePersist: isTemplate ? undefined : prePersistPostType,
|
||||||
|
__unstable_rest_base: postType.rest_base
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3865,15 +3866,19 @@ function canUser(state, action, resource, id) {
|
||||||
* @param {Object} state Data state.
|
* @param {Object} state Data state.
|
||||||
* @param {string} kind Entity kind.
|
* @param {string} kind Entity kind.
|
||||||
* @param {string} name Entity name.
|
* @param {string} name Entity name.
|
||||||
* @param {number} key Record's key.
|
|
||||||
* @param {string} recordId Record's id.
|
* @param {string} recordId Record's id.
|
||||||
* @return {boolean|undefined} Whether or not the user can edit,
|
* @return {boolean|undefined} Whether or not the user can edit,
|
||||||
* or `undefined` if the OPTIONS request is still being made.
|
* or `undefined` if the OPTIONS request is still being made.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function canUserEditEntityRecord(state, kind, name, key, recordId) {
|
function canUserEditEntityRecord(state, kind, name, recordId) {
|
||||||
const entity = getEntityRecord(state, kind, name, key);
|
const entity = getEntity(state, kind, name);
|
||||||
const resource = (entity === null || entity === void 0 ? void 0 : entity.rest_base) || '';
|
|
||||||
|
if (!entity) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const resource = entity.__unstable_rest_base;
|
||||||
return canUser(state, 'update', resource, recordId);
|
return canUser(state, 'update', resource, recordId);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -4327,13 +4332,21 @@ function* resolvers_canUser(action, resource, id) {
|
||||||
*
|
*
|
||||||
* @param {string} kind Entity kind.
|
* @param {string} kind Entity kind.
|
||||||
* @param {string} name Entity name.
|
* @param {string} name Entity name.
|
||||||
* @param {number} key Record's key.
|
|
||||||
* @param {string} recordId Record's id.
|
* @param {string} recordId Record's id.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function* resolvers_canUserEditEntityRecord(kind, name, key, recordId) {
|
function* resolvers_canUserEditEntityRecord(kind, name, recordId) {
|
||||||
const entity = yield external_wp_data_["controls"].select('core', 'getEntityRecord', kind, name, key);
|
const entities = yield getKindEntities(kind);
|
||||||
const resource = (entity === null || entity === void 0 ? void 0 : entity.rest_base) || '';
|
const entity = Object(external_lodash_["find"])(entities, {
|
||||||
|
kind,
|
||||||
|
name
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!entity) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const resource = entity.__unstable_rest_base;
|
||||||
yield resolvers_canUser('update', resource, recordId);
|
yield resolvers_canUser('update', resource, recordId);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14675,6 +14675,40 @@ function EditTemplateTitle() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CONCATENATED MODULE: ./node_modules/@wordpress/edit-post/build-module/components/header/template-title/template-description.js
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WordPress dependencies
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function TemplateDescription() {
|
||||||
|
const {
|
||||||
|
description
|
||||||
|
} = Object(external_wp_data_["useSelect"])(select => {
|
||||||
|
const {
|
||||||
|
getEditedPostTemplate
|
||||||
|
} = select(store["a" /* store */]);
|
||||||
|
return {
|
||||||
|
description: getEditedPostTemplate().description
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!description) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalText"], {
|
||||||
|
size: "body"
|
||||||
|
}, description);
|
||||||
|
}
|
||||||
|
|
||||||
// CONCATENATED MODULE: ./node_modules/@wordpress/edit-post/build-module/components/header/template-title/index.js
|
// CONCATENATED MODULE: ./node_modules/@wordpress/edit-post/build-module/components/header/template-title/index.js
|
||||||
|
|
||||||
|
|
||||||
|
@ -14696,6 +14730,7 @@ function EditTemplateTitle() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TemplateTitle() {
|
function TemplateTitle() {
|
||||||
const {
|
const {
|
||||||
template,
|
template,
|
||||||
|
@ -14763,7 +14798,7 @@ function TemplateTitle() {
|
||||||
onClick: onToggle,
|
onClick: onToggle,
|
||||||
label: Object(external_wp_i18n_["__"])('Template Options')
|
label: Object(external_wp_i18n_["__"])('Template Options')
|
||||||
}), templateTitle)),
|
}), templateTitle)),
|
||||||
renderContent: () => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(EditTemplateTitle, null), Object(external_wp_element_["createElement"])(DeleteTemplate, null))
|
renderContent: () => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, template.has_theme_file ? Object(external_wp_element_["createElement"])(TemplateDescription, null) : Object(external_wp_element_["createElement"])(EditTemplateTitle, null), Object(external_wp_element_["createElement"])(DeleteTemplate, null))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -666,7 +666,33 @@ async function encodeWidget({
|
||||||
function isEmptyHTML(html) {
|
function isEmptyHTML(html) {
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
element.innerHTML = html;
|
element.innerHTML = html;
|
||||||
return element.innerText.trim() === '';
|
return isEmptyNode(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEmptyNode(node) {
|
||||||
|
switch (node.nodeType) {
|
||||||
|
case node.TEXT_NODE:
|
||||||
|
// Text nodes are empty if it's entirely whitespace.
|
||||||
|
return node.nodeValue.trim() === '';
|
||||||
|
|
||||||
|
case node.ELEMENT_NODE:
|
||||||
|
// Elements that are "embedded content" are not empty.
|
||||||
|
// https://dev.w3.org/html5/spec-LC/content-models.html#embedded-content-0
|
||||||
|
if (['AUDIO', 'CANVAS', 'EMBED', 'IFRAME', 'IMG', 'MATH', 'OBJECT', 'SVG', 'VIDEO'].includes(node.tagName)) {
|
||||||
|
return false;
|
||||||
|
} // Elements with no children are empty.
|
||||||
|
|
||||||
|
|
||||||
|
if (!node.hasChildNodes()) {
|
||||||
|
return true;
|
||||||
|
} // Elements with children are empty if all their children are empty.
|
||||||
|
|
||||||
|
|
||||||
|
return Array.from(node.childNodes).every(isEmptyNode);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeForm(form) {
|
function serializeForm(form) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.8-beta1-51155';
|
$wp_version = '5.8-beta1-51156';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue