Subir ajustes de acordeon y SEO
This commit is contained in:
Vendored
+1300
-1280
File diff suppressed because it is too large
Load Diff
+32
-32
File diff suppressed because one or more lines are too long
Vendored
+121
-46
@@ -29319,6 +29319,13 @@ ${url}
|
||||
function defaultColumnsNumber(imageCount) {
|
||||
return imageCount ? Math.min(3, imageCount) : 3;
|
||||
}
|
||||
function isObject(value) {
|
||||
return !!value && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
function isGalleryFlexLayout(layout) {
|
||||
const layoutType = isObject(layout) ? layout.type : void 0;
|
||||
return typeof layoutType !== "string" || layoutType === "" || layoutType === "flex";
|
||||
}
|
||||
var pickRelevantMediaFiles = (image, sizeSlug = "large") => {
|
||||
const imageProps = Object.fromEntries(
|
||||
Object.entries(image ?? {}).filter(
|
||||
@@ -30529,9 +30536,10 @@ ${url}
|
||||
)
|
||||
] });
|
||||
}
|
||||
function GalleryImagesPreview({ imageBlocks }) {
|
||||
function GalleryImagesPreview({ imageBlocks, layout }) {
|
||||
const { children, ref, className } = (0, import_block_editor97.__experimentalUseBlockPreview)({
|
||||
blocks: imageBlocks
|
||||
blocks: imageBlocks,
|
||||
layout
|
||||
});
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
|
||||
"div",
|
||||
@@ -30563,6 +30571,10 @@ ${url}
|
||||
} = dynamic;
|
||||
const blockEditingMode = (0, import_block_editor97.useBlockEditingMode)();
|
||||
const [isConfirmingDetach, setIsConfirmingDetach] = (0, import_element44.useState)(false);
|
||||
const previewLayout = (0, import_element44.useMemo)(
|
||||
() => isGalleryFlexLayout(attributes.layout) ? { ...attributes.layout, type: "flex" } : attributes.layout,
|
||||
[attributes.layout]
|
||||
);
|
||||
const emptyInstructions = isResolvingDynamic ? (0, import_i18n79.__)("Loading images\u2026") : sourceDescriptor?.emptyMessage ?? (0, import_i18n79.__)("Dynamic images will appear here.");
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)(import_jsx_runtime274.Fragment, { children: [
|
||||
blockEditingMode === "default" && /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)(import_jsx_runtime274.Fragment, { children: [
|
||||
@@ -30589,7 +30601,8 @@ ${url}
|
||||
dynamicImageBlocks.length ? /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(import_block_editor97.BlockContextProvider, { value: galleryContext, children: /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
|
||||
GalleryImagesPreview,
|
||||
{
|
||||
imageBlocks: dynamicImageBlocks
|
||||
imageBlocks: dynamicImageBlocks,
|
||||
layout: previewLayout
|
||||
}
|
||||
) }) : /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
|
||||
import_components45.Placeholder,
|
||||
@@ -36185,6 +36198,42 @@ ${text}
|
||||
}
|
||||
return syncedAttributes;
|
||||
}
|
||||
function getNewAttachmentSizeAttributes(sizeSlug, attachment) {
|
||||
const sizes = attachment.media_details?.sizes;
|
||||
if (!sizeSlug || sizeSlug === DEFAULT_MEDIA_SIZE_SLUG3 || !sizes) {
|
||||
return void 0;
|
||||
}
|
||||
const sizeUrl = sizes[sizeSlug]?.source_url;
|
||||
if (sizeUrl) {
|
||||
return { url: sizeUrl };
|
||||
}
|
||||
const fullUrl = attachment.source_url ?? sizes.full?.source_url;
|
||||
return fullUrl ? { url: fullUrl, sizeSlug: DEFAULT_MEDIA_SIZE_SLUG3 } : void 0;
|
||||
}
|
||||
function getNewAttachmentLinkAttributes(linkDestination, attachment) {
|
||||
if (linkDestination === LINK_DESTINATION_MEDIA2) {
|
||||
return attachment.source_url ? { href: attachment.source_url } : void 0;
|
||||
}
|
||||
if (linkDestination === LINK_DESTINATION_ATTACHMENT2) {
|
||||
return attachment.link ? { href: attachment.link } : void 0;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
function getNewAttachmentImageBlockAttributes(blockAttributes8, attachment) {
|
||||
if (!attachment) {
|
||||
return void 0;
|
||||
}
|
||||
return {
|
||||
...getNewAttachmentSizeAttributes(
|
||||
blockAttributes8.sizeSlug,
|
||||
attachment
|
||||
),
|
||||
...getNewAttachmentLinkAttributes(
|
||||
blockAttributes8.linkDestination,
|
||||
attachment
|
||||
)
|
||||
};
|
||||
}
|
||||
var { openMediaEditorModalKey: openMediaEditorModalKey2 } = unlock(import_block_editor115.privateApis);
|
||||
function getAttachmentFallbackForEmptyBlockMetadata({ alt, caption }) {
|
||||
const attachment = {};
|
||||
@@ -36210,7 +36259,7 @@ ${text}
|
||||
onClose,
|
||||
onUrlChange
|
||||
}) {
|
||||
const { id, url, alt, caption } = attributes;
|
||||
const { id, url, alt, caption, sizeSlug, linkDestination } = attributes;
|
||||
const registry = (0, import_data50.useRegistry)();
|
||||
const openMediaEditorModal = (0, import_data50.useSelect)(
|
||||
(select10) => select10(import_block_editor115.store).getSettings()[openMediaEditorModalKey2],
|
||||
@@ -36220,7 +36269,9 @@ ${text}
|
||||
id,
|
||||
url,
|
||||
alt,
|
||||
caption: caption?.toString()
|
||||
caption: caption?.toString(),
|
||||
sizeSlug,
|
||||
linkDestination
|
||||
});
|
||||
const mediaEditorMetadataBaselineRef = (0, import_element56.useRef)();
|
||||
const mediaEditorMetadataSyncRequestRef = (0, import_element56.useRef)(0);
|
||||
@@ -36229,9 +36280,11 @@ ${text}
|
||||
id,
|
||||
url,
|
||||
alt,
|
||||
caption: caption?.toString()
|
||||
caption: caption?.toString(),
|
||||
sizeSlug,
|
||||
linkDestination
|
||||
};
|
||||
}, [alt, caption, id, url]);
|
||||
}, [alt, caption, id, linkDestination, sizeSlug, url]);
|
||||
const getCachedAttachmentRecord = (0, import_element56.useCallback)(
|
||||
(attachmentId) => registry.select(import_core_data25.store).getEditedEntityRecord(
|
||||
"postType",
|
||||
@@ -36277,7 +36330,8 @@ ${text}
|
||||
const syncRequest = ++mediaEditorMetadataSyncRequestRef.current;
|
||||
const nextAttributes = {};
|
||||
const currentBlockAttributes = blockAttributesRef.current;
|
||||
if (newId !== currentBlockAttributes.id) {
|
||||
const isNewAttachment = newId !== currentBlockAttributes.id;
|
||||
if (isNewAttachment) {
|
||||
nextAttributes.id = newId;
|
||||
nextAttributes.url = newUrl ?? currentBlockAttributes.url;
|
||||
if (nextAttributes.url !== currentBlockAttributes.url) {
|
||||
@@ -36289,19 +36343,37 @@ ${text}
|
||||
url: nextAttributes.url
|
||||
};
|
||||
}
|
||||
if (originalAttachment) {
|
||||
if (originalAttachment || isNewAttachment) {
|
||||
const resolvedAttachment = await resolveFreshAttachmentRecord(newId);
|
||||
if (syncRequest !== mediaEditorMetadataSyncRequestRef.current) {
|
||||
return;
|
||||
}
|
||||
const attachmentRecord = resolvedAttachment ?? getCachedAttachmentRecord(newId);
|
||||
const latestBlockAttributes = blockAttributesRef.current;
|
||||
const resolvedMetadataAttributes = getSyncedImageBlockAttributes(
|
||||
latestBlockAttributes,
|
||||
originalAttachment,
|
||||
resolvedAttachment
|
||||
);
|
||||
if (Object.keys(resolvedMetadataAttributes).length) {
|
||||
Object.assign(nextAttributes, resolvedMetadataAttributes);
|
||||
if (originalAttachment) {
|
||||
const resolvedMetadataAttributes = getSyncedImageBlockAttributes(
|
||||
latestBlockAttributes,
|
||||
originalAttachment,
|
||||
attachmentRecord
|
||||
);
|
||||
if (Object.keys(resolvedMetadataAttributes).length) {
|
||||
Object.assign(
|
||||
nextAttributes,
|
||||
resolvedMetadataAttributes
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isNewAttachment) {
|
||||
const derivedAttributes = getNewAttachmentImageBlockAttributes(
|
||||
latestBlockAttributes,
|
||||
attachmentRecord
|
||||
);
|
||||
if (derivedAttributes) {
|
||||
Object.assign(nextAttributes, derivedAttributes);
|
||||
if (derivedAttributes.url && derivedAttributes.url !== latestBlockAttributes.url) {
|
||||
onUrlChange?.(derivedAttributes.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Object.keys(nextAttributes).length) {
|
||||
@@ -36312,7 +36384,12 @@ ${text}
|
||||
setAttributes(nextAttributes);
|
||||
}
|
||||
},
|
||||
[onUrlChange, resolveFreshAttachmentRecord, setAttributes]
|
||||
[
|
||||
getCachedAttachmentRecord,
|
||||
onUrlChange,
|
||||
resolveFreshAttachmentRecord,
|
||||
setAttributes
|
||||
]
|
||||
);
|
||||
const openImageMediaEditorModal = (0, import_element56.useCallback)(async () => {
|
||||
if (!id || !openMediaEditorModal) {
|
||||
@@ -36563,7 +36640,8 @@ ${text}
|
||||
setOffsetTop(imageElement?.offsetTop ?? 0);
|
||||
}, [imageElement]);
|
||||
const setRefs = (0, import_compose24.useMergeRefs)([setImageElement, setResizeObserved]);
|
||||
const { allowResize = true } = context;
|
||||
const { allowResize = true, imageCrop = false } = context;
|
||||
const isCroppedGalleryImage = imageCrop && parentLayoutType === "flex";
|
||||
const { image, attachmentResolutionError } = (0, import_data51.useSelect)(
|
||||
(select10) => {
|
||||
const imageRecord = id && isSingleSelected ? select10(import_core_data26.store).getEntityRecord(
|
||||
@@ -37287,10 +37365,12 @@ ${text}
|
||||
} else if (width !== void 0 && width !== null) {
|
||||
style2.width = typeof width === "number" ? `${width}px` : width;
|
||||
}
|
||||
if (height === "auto" || height === void 0 || height === null) {
|
||||
if (height === "auto") {
|
||||
style2.height = "auto";
|
||||
} else {
|
||||
} else if (height !== void 0 && height !== null) {
|
||||
style2.height = typeof height === "number" ? `${height}px` : height;
|
||||
} else if (!isCroppedGalleryImage) {
|
||||
style2.height = "auto";
|
||||
}
|
||||
return style2;
|
||||
})(),
|
||||
@@ -40887,20 +40967,14 @@ ${text}
|
||||
var import_blocks45 = __toESM(require_blocks(), 1);
|
||||
function useOutdentListItem() {
|
||||
const registry = (0, import_data57.useRegistry)();
|
||||
const {
|
||||
moveBlocksToPosition,
|
||||
removeBlock,
|
||||
insertBlock,
|
||||
updateBlockListSettings
|
||||
} = (0, import_data57.useDispatch)(import_block_editor128.store);
|
||||
const { moveBlocksToPosition, removeBlock, removeBlocks, insertBlock } = (0, import_data57.useDispatch)(import_block_editor128.store);
|
||||
const {
|
||||
getBlockRootClientId,
|
||||
getBlockName,
|
||||
getBlockOrder,
|
||||
getBlockIndex,
|
||||
getSelectedBlockClientIds,
|
||||
getBlock,
|
||||
getBlockListSettings
|
||||
getBlock
|
||||
} = (0, import_data57.useSelect)(import_block_editor128.store);
|
||||
function getParentListItemId(id) {
|
||||
const listId = getBlockRootClientId(id);
|
||||
@@ -40936,25 +41010,22 @@ ${text}
|
||||
);
|
||||
registry.batch(() => {
|
||||
if (followingListItems.length) {
|
||||
let nestedListId = getBlockOrder(firstClientId)[0];
|
||||
if (!nestedListId) {
|
||||
const nestedListId = getBlockOrder(firstClientId)[0];
|
||||
if (nestedListId) {
|
||||
moveBlocksToPosition(
|
||||
followingListItems,
|
||||
parentListId,
|
||||
nestedListId
|
||||
);
|
||||
} else {
|
||||
const nestedListBlock = (0, import_blocks45.cloneBlock)(
|
||||
getBlock(parentListId),
|
||||
{},
|
||||
[]
|
||||
followingListItems.map((id) => getBlock(id))
|
||||
);
|
||||
nestedListId = nestedListBlock.clientId;
|
||||
removeBlocks(followingListItems, false);
|
||||
insertBlock(nestedListBlock, 0, firstClientId, false);
|
||||
updateBlockListSettings(
|
||||
nestedListId,
|
||||
getBlockListSettings(parentListId)
|
||||
);
|
||||
}
|
||||
moveBlocksToPosition(
|
||||
followingListItems,
|
||||
parentListId,
|
||||
nestedListId
|
||||
);
|
||||
}
|
||||
moveBlocksToPosition(
|
||||
clientIds,
|
||||
@@ -60530,7 +60601,9 @@ ${text}
|
||||
query: {
|
||||
perPage,
|
||||
offset = 0,
|
||||
postType,
|
||||
// Match `build_query_vars_from_query_block()`, which queries posts when
|
||||
// `query` has no post type.
|
||||
postType = "post",
|
||||
order,
|
||||
orderBy,
|
||||
author,
|
||||
@@ -64047,7 +64120,9 @@ ${text}
|
||||
orderBy,
|
||||
author: authorIds,
|
||||
pages,
|
||||
postType,
|
||||
// Match `build_query_vars_from_query_block()`, which queries posts when
|
||||
// `query` has no post type.
|
||||
postType = "post",
|
||||
perPage,
|
||||
offset,
|
||||
sticky,
|
||||
@@ -64135,7 +64210,7 @@ ${text}
|
||||
);
|
||||
const showExcludeCurrentControl = shouldExcludeCurrentPost && isControlAllowed(allowedControls, "excludeCurrent");
|
||||
const postTypeSingularName = (0, import_data125.useSelect)(
|
||||
(select10) => select10(import_core_data77.store).getPostType(postType)?.labels.singular_name,
|
||||
(select10) => select10(import_core_data77.store).getPostType(postType)?.labels?.singular_name,
|
||||
[postType]
|
||||
);
|
||||
const showFiltersPanel = showTaxControl || showAuthorControl || showSearchControl || showParentControl || showFormatControl || showExcludeCurrentControl;
|
||||
@@ -68050,7 +68125,7 @@ ${text}
|
||||
}
|
||||
|
||||
// packages/block-library/build-module/block/deprecated.mjs
|
||||
var isObject = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj !== null;
|
||||
var isObject2 = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj !== null;
|
||||
var v219 = {
|
||||
attributes: {
|
||||
ref: {
|
||||
@@ -68073,7 +68148,7 @@ ${text}
|
||||
// the likelihood, it doesn't solve it completely.
|
||||
isEligible({ content }) {
|
||||
return !!content && Object.keys(content).every(
|
||||
(contentKey) => content[contentKey].values && isObject(content[contentKey].values)
|
||||
(contentKey) => content[contentKey].values && isObject2(content[contentKey].values)
|
||||
);
|
||||
},
|
||||
/*
|
||||
|
||||
+29
-29
File diff suppressed because one or more lines are too long
Vendored
+24
-3
@@ -11932,7 +11932,6 @@ var wp;
|
||||
core.__experimentalGetCurrentThemeBaseGlobalStyles(),
|
||||
core.__experimentalGetCurrentThemeGlobalStylesVariations(),
|
||||
core.getEntityRecord("root", "__unstableBase"),
|
||||
core.getEntityRecord("root", "site"),
|
||||
core.canUser("read", { kind: "root", name: "site" }),
|
||||
core.canUser("create", { kind: "postType", name: "attachment" }),
|
||||
core.canUser("create", { kind: "postType", name: "page" }),
|
||||
@@ -11970,11 +11969,13 @@ var wp;
|
||||
] : []
|
||||
]);
|
||||
const tasks = [];
|
||||
if (coreSelect.canUser("read", { kind: "root", name: "site" })) {
|
||||
tasks.push(core.getEntityRecord("root", "site"));
|
||||
}
|
||||
const globalStylesId = coreSelect.__experimentalGetCurrentGlobalStylesId();
|
||||
if (globalStylesId) {
|
||||
tasks.push(
|
||||
core.getEntityRecord("root", "globalStyles", globalStylesId),
|
||||
core.canUser("read", {
|
||||
core.canUser("update", {
|
||||
kind: "root",
|
||||
name: "globalStyles",
|
||||
id: globalStylesId
|
||||
@@ -12006,6 +12007,26 @@ var wp;
|
||||
if (tasks.length) {
|
||||
await Promise.all(tasks);
|
||||
}
|
||||
if (globalStylesId) {
|
||||
if (coreSelect.canUser("update", {
|
||||
kind: "root",
|
||||
name: "globalStyles",
|
||||
id: globalStylesId
|
||||
})) {
|
||||
await core.getEntityRecord(
|
||||
"root",
|
||||
"globalStyles",
|
||||
globalStylesId
|
||||
);
|
||||
} else {
|
||||
await core.getEntityRecord(
|
||||
"root",
|
||||
"globalStyles",
|
||||
globalStylesId,
|
||||
{ context: "view" }
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+7
-3
@@ -54928,9 +54928,13 @@ If there's a particular need for this, please submit a feature request at https:
|
||||
const fieldsKey = fieldList ? [...fieldList].sort().join(",") : void 0;
|
||||
return (0, import_data65.useSelect)(
|
||||
(select4) => {
|
||||
return unlock7(select4(import_core_data41.store)).getViewConfig(kind, name2, {
|
||||
fields: fieldsKey
|
||||
});
|
||||
return unlock7(select4(import_core_data41.store)).getViewConfig(
|
||||
kind,
|
||||
name2,
|
||||
fieldsKey ? {
|
||||
fields: fieldsKey
|
||||
} : void 0
|
||||
);
|
||||
},
|
||||
[kind, name2, fieldsKey]
|
||||
);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+3526
-3449
File diff suppressed because it is too large
Load Diff
Vendored
+36
-36
File diff suppressed because one or more lines are too long
Vendored
+3
-11
@@ -1334,7 +1334,7 @@ var wp;
|
||||
return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
|
||||
}
|
||||
function flattenFormData(formData, key, data) {
|
||||
if (isPlainObject(data)) {
|
||||
if (Array.isArray(data) || isPlainObject(data)) {
|
||||
for (const [name, value] of Object.entries(data)) {
|
||||
flattenFormData(formData, `${key}[${name}]`, value);
|
||||
}
|
||||
@@ -1361,11 +1361,7 @@ var wp;
|
||||
const data = new FormData();
|
||||
data.append("file", file, file.name || file.type.replace("/", "."));
|
||||
for (const [key, value] of Object.entries(additionalData)) {
|
||||
flattenFormData(
|
||||
data,
|
||||
key,
|
||||
value
|
||||
);
|
||||
flattenFormData(data, key, value);
|
||||
}
|
||||
return transformAttachment(
|
||||
await (0, import_api_fetch.default)({
|
||||
@@ -1587,11 +1583,7 @@ var wp;
|
||||
const data = new FormData();
|
||||
data.append("file", file, file.name || file.type.replace("/", "."));
|
||||
for (const [key, value] of Object.entries(additionalData)) {
|
||||
flattenFormData(
|
||||
data,
|
||||
key,
|
||||
value
|
||||
);
|
||||
flattenFormData(data, key, value);
|
||||
}
|
||||
return (0, import_api_fetch2.default)({
|
||||
path: `/wp/v2/media/${attachmentId}/sideload`,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '685442d334b2d3e70832');
|
||||
<?php return array('dependencies' => array(), 'version' => '7e33cd8c4128731126e8');
|
||||
+26
-8
@@ -52894,9 +52894,7 @@ var vips_heif_default = bytes2;
|
||||
|
||||
// packages/vips/src/utils.ts
|
||||
function supportsQuality(type) {
|
||||
return ["image/jpeg", "image/png", "image/webp", "image/avif"].includes(
|
||||
type
|
||||
);
|
||||
return ["image/jpeg", "image/webp", "image/avif"].includes(type);
|
||||
}
|
||||
function supportsAnimation(type) {
|
||||
return ["image/webp", "image/gif"].includes(type);
|
||||
@@ -52999,6 +52997,9 @@ async function convertImageFormat(id, buffer, inputType, outputType, options = {
|
||||
if (interlaced && supportsInterlace(outputType)) {
|
||||
saveOptions.interlace = interlaced;
|
||||
}
|
||||
if ("image/png" === outputType && isPaletteImage(image)) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
if ("image/avif" === outputType) {
|
||||
saveOptions.effort = 2;
|
||||
const sourceBitdepth = getSourceBitdepth(image);
|
||||
@@ -53090,6 +53091,9 @@ function applyResizeAndCrop(resize, originalWidth, originalHeight, smartCrop, cr
|
||||
setImage.call(result, "gainmap", newGainmap);
|
||||
return result;
|
||||
}
|
||||
function isPaletteImage(image) {
|
||||
return image.getTypeof("palette") !== 0;
|
||||
}
|
||||
function getSourceBitdepth(image) {
|
||||
try {
|
||||
const bitdepth = image.getInt("heif-bitdepth");
|
||||
@@ -53110,7 +53114,13 @@ function resolveSaveBitdepth(sourceBitdepth, maxBitdepth) {
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
function buildSaveOptions(type, quality, bitdepth = 8, stripMeta = true) {
|
||||
function buildSaveOptions({
|
||||
type,
|
||||
quality,
|
||||
bitdepth = 8,
|
||||
stripMeta = true,
|
||||
isPalette = false
|
||||
}) {
|
||||
const saveOptions = {
|
||||
// Strip metadata except ICC color profiles or gainmaps,
|
||||
// matching WordPress core's behavior. The \`image_strip_meta\`
|
||||
@@ -53120,6 +53130,9 @@ function buildSaveOptions(type, quality, bitdepth = 8, stripMeta = true) {
|
||||
if (supportsQuality(type)) {
|
||||
saveOptions.Q = quality * 100;
|
||||
}
|
||||
if ("image/png" === type && isPalette) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
if ("image/avif" === type) {
|
||||
saveOptions.effort = 2;
|
||||
if (bitdepth > 8) {
|
||||
@@ -53208,12 +53221,13 @@ async function resizeImage(id, buffer, type, resize, options = {}) {
|
||||
return thumb;
|
||||
}
|
||||
);
|
||||
const saveOptions = buildSaveOptions(
|
||||
const saveOptions = buildSaveOptions({
|
||||
type,
|
||||
quality,
|
||||
saveBitdepth,
|
||||
stripMeta
|
||||
);
|
||||
bitdepth: saveBitdepth,
|
||||
stripMeta,
|
||||
isPalette: isPaletteImage(sourceImage)
|
||||
});
|
||||
const outBuffer = image.writeToBuffer(\`.\${ext}\`, saveOptions);
|
||||
const result = {
|
||||
buffer: outBuffer.buffer,
|
||||
@@ -53271,6 +53285,7 @@ async function rotateImage(id, buffer, type, orientation) {
|
||||
image.kill = true;
|
||||
}
|
||||
};
|
||||
const isPalette = isPaletteImage(image);
|
||||
switch (orientation) {
|
||||
case 2:
|
||||
image = image.flipHor();
|
||||
@@ -53296,6 +53311,9 @@ async function rotateImage(id, buffer, type, orientation) {
|
||||
}
|
||||
image.remove("orientation");
|
||||
const saveOptions = {};
|
||||
if ("image/png" === type && isPalette) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
const outBuffer = image.writeToBuffer(\`.\${ext}\`, saveOptions);
|
||||
const result = {
|
||||
buffer: outBuffer.buffer,
|
||||
|
||||
Vendored
+72
-43
@@ -194,7 +194,8 @@ var wp;
|
||||
maxConcurrentUploads: DEFAULT_MAX_CONCURRENT_UPLOADS,
|
||||
maxConcurrentImageProcessing: DEFAULT_MAX_CONCURRENT_IMAGE_PROCESSING,
|
||||
retry: { ...DEFAULT_RETRY_SETTINGS }
|
||||
}
|
||||
},
|
||||
failureCount: 0
|
||||
};
|
||||
function reducer(state = DEFAULT_STATE, action = { type: Type.Unknown }) {
|
||||
switch (action.type) {
|
||||
@@ -235,9 +236,13 @@ var wp;
|
||||
...state,
|
||||
queue: [...state.queue, action.item]
|
||||
};
|
||||
case Type.Cancel:
|
||||
case Type.Cancel: {
|
||||
const cancelled = state.queue.find(
|
||||
(item) => item.id === action.id
|
||||
);
|
||||
return {
|
||||
...state,
|
||||
failureCount: cancelled && !cancelled.parentId ? state.failureCount + 1 : state.failureCount,
|
||||
queue: state.queue.map(
|
||||
(item) => item.id === action.id ? {
|
||||
...item,
|
||||
@@ -245,6 +250,7 @@ var wp;
|
||||
} : item
|
||||
)
|
||||
};
|
||||
}
|
||||
case Type.RetryItem:
|
||||
return {
|
||||
...state,
|
||||
@@ -421,6 +427,7 @@ var wp;
|
||||
getAllItems: () => getAllItems,
|
||||
getBlobUrls: () => getBlobUrls,
|
||||
getFailedItems: () => getFailedItems,
|
||||
getFailureCount: () => getFailureCount,
|
||||
getItem: () => getItem,
|
||||
getItemProgress: () => getItemProgress,
|
||||
getPendingImageProcessing: () => getPendingImageProcessing,
|
||||
@@ -433,6 +440,9 @@ var wp;
|
||||
function getAllItems(state) {
|
||||
return state.queue;
|
||||
}
|
||||
function getFailureCount(state) {
|
||||
return state.failureCount;
|
||||
}
|
||||
function getItem(state, id) {
|
||||
return state.queue.find((item) => item.id === id);
|
||||
}
|
||||
@@ -1569,6 +1579,13 @@ var wp;
|
||||
}
|
||||
function readItemData(buffer, loc, idatOffset) {
|
||||
const baseOffset = loc.constructionMethod === 1 ? idatOffset : 0;
|
||||
for (const ext of loc.extents) {
|
||||
if (baseOffset + ext.offset + ext.length > buffer.byteLength) {
|
||||
throw new Error(
|
||||
"HEIC item data extends past the end of the file"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (loc.extents.length === 1) {
|
||||
const ext = loc.extents[0];
|
||||
const start = baseOffset + ext.offset;
|
||||
@@ -2057,6 +2074,8 @@ var wp;
|
||||
}
|
||||
|
||||
// packages/upload-media/build-module/canvas-utils.mjs
|
||||
var HeicUnsupportedError = class extends Error {
|
||||
};
|
||||
async function canvasConvertToJpeg(file, quality = 0.82) {
|
||||
const baseName = getFileBasename(file.name);
|
||||
try {
|
||||
@@ -2114,51 +2133,57 @@ var wp;
|
||||
}
|
||||
}
|
||||
}
|
||||
let heicData;
|
||||
try {
|
||||
heicData = parseHeic(await file.arrayBuffer());
|
||||
} catch (error) {
|
||||
throw new Error("The HEIC file could not be parsed", {
|
||||
cause: error
|
||||
});
|
||||
}
|
||||
if (typeof VideoDecoder !== "undefined") {
|
||||
let supported = false;
|
||||
try {
|
||||
const heicData = parseHeic(await file.arrayBuffer());
|
||||
const support = await VideoDecoder.isConfigSupported({
|
||||
codec: heicData.codecString
|
||||
});
|
||||
if (support.supported) {
|
||||
const canvas = new OffscreenCanvas(
|
||||
heicData.outputWidth,
|
||||
heicData.outputHeight
|
||||
);
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) {
|
||||
throw new Error("Could not get canvas 2d context");
|
||||
}
|
||||
for (const tile of heicData.tiles) {
|
||||
const frame = await decodeHevcFrame(
|
||||
heicData.codecString,
|
||||
heicData.description,
|
||||
heicData.tileWidth,
|
||||
heicData.tileHeight,
|
||||
tile.data
|
||||
);
|
||||
try {
|
||||
ctx.drawImage(frame, tile.x, tile.y);
|
||||
} finally {
|
||||
frame.close();
|
||||
}
|
||||
}
|
||||
const outputCanvas = heicData.rotation !== 0 ? applyRotation(canvas, heicData.rotation) : applyExifOrientation(
|
||||
canvas,
|
||||
heicData.exifOrientation
|
||||
);
|
||||
const jpegBlob = await outputCanvas.convertToBlob({
|
||||
type: "image/jpeg",
|
||||
quality
|
||||
});
|
||||
return new File([jpegBlob], `${baseName}.jpg`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
}
|
||||
supported = support.supported === true;
|
||||
} catch {
|
||||
}
|
||||
if (supported) {
|
||||
const canvas = new OffscreenCanvas(
|
||||
heicData.outputWidth,
|
||||
heicData.outputHeight
|
||||
);
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) {
|
||||
throw new Error("Could not get canvas 2d context");
|
||||
}
|
||||
for (const tile of heicData.tiles) {
|
||||
const frame = await decodeHevcFrame(
|
||||
heicData.codecString,
|
||||
heicData.description,
|
||||
heicData.tileWidth,
|
||||
heicData.tileHeight,
|
||||
tile.data
|
||||
);
|
||||
try {
|
||||
ctx.drawImage(frame, tile.x, tile.y);
|
||||
} finally {
|
||||
frame.close();
|
||||
}
|
||||
}
|
||||
const outputCanvas = heicData.rotation !== 0 ? applyRotation(canvas, heicData.rotation) : applyExifOrientation(canvas, heicData.exifOrientation);
|
||||
const jpegBlob = await outputCanvas.convertToBlob({
|
||||
type: "image/jpeg",
|
||||
quality
|
||||
});
|
||||
return new File([jpegBlob], `${baseName}.jpg`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
}
|
||||
}
|
||||
throw new Error(getHeicUnsupportedMessage());
|
||||
throw new HeicUnsupportedError(getHeicUnsupportedMessage());
|
||||
}
|
||||
function applyRotation(source, rotation) {
|
||||
if (rotation === 0) {
|
||||
@@ -2836,13 +2861,17 @@ var wp;
|
||||
file,
|
||||
settings.imageQuality ?? DEFAULT_OUTPUT_QUALITY
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
const unsupported = error instanceof HeicUnsupportedError;
|
||||
dispatch.cancelItem(
|
||||
id,
|
||||
new UploadError({
|
||||
code: ErrorCode.HEIC_DECODE_ERROR,
|
||||
message: getHeicUnsupportedMessage(),
|
||||
file
|
||||
code: unsupported ? ErrorCode.HEIC_DECODE_ERROR : ErrorCode.IMAGE_TRANSCODING_ERROR,
|
||||
message: unsupported ? getHeicUnsupportedMessage() : (0, import_i18n7.__)(
|
||||
"This HEIC image could not be converted. Try converting it to JPEG before uploading."
|
||||
),
|
||||
file,
|
||||
cause: error instanceof Error ? error : void 0
|
||||
})
|
||||
);
|
||||
return;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -8,19 +8,29 @@
|
||||
*/
|
||||
(() => {
|
||||
|
||||
const popovers = /** @type {NodeListOf<HTMLSpanElement>} */ ( document.querySelectorAll( '.wp-is-tooltip' ) );
|
||||
const supportsPopover = /** @type {boolean} */ ( Object.prototype.hasOwnProperty.call( HTMLElement.prototype, 'popover' ) );
|
||||
let hidePopover = false;
|
||||
if ( ! supportsPopover ) {
|
||||
hidePopover = true;
|
||||
}
|
||||
|
||||
/** @type {ReturnType<typeof setTimeout>} */
|
||||
let openTimeout;
|
||||
const popovers = /** @type {NodeListOf<HTMLSpanElement>} */ ( document.querySelectorAll( '.wp-is-tooltip' ) );
|
||||
|
||||
popovers.forEach( function( popover ) {
|
||||
const trigger = /** @type {HTMLButtonElement|HTMLAnchorElement|null} */ ( popover.querySelector( '.wp-tooltip__toggle' ) );
|
||||
const panel = /** @type {HTMLSpanElement|null} */ ( popover.querySelector( 'span.wp-tooltip__bubble' ) );
|
||||
if ( hidePopover && panel ) {
|
||||
panel.classList.add( 'hidden' );
|
||||
|
||||
return;
|
||||
}
|
||||
if ( ! trigger || ! panel ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {ReturnType<typeof setTimeout>} */
|
||||
let openTimeout;
|
||||
|
||||
// Show Tooltip Function (with delay to prevent flickering).
|
||||
const showTooltip = () => {
|
||||
clearTimeout( openTimeout );
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{var e=document.querySelectorAll(".wp-is-tooltip");let n;e.forEach(function(e){const o=e.querySelector(".wp-tooltip__toggle"),t=e.querySelector("span.wp-tooltip__bubble");var r;o&&t&&(e=()=>{clearTimeout(n),n=setTimeout(()=>{t.matches(":popover-open")||t.showPopover({source:o})},300)},r=()=>{clearTimeout(n),t.matches(":popover-open")&&t.hidePopover()},o.addEventListener("mouseenter",e),o.addEventListener("focus",e),o.addEventListener("mouseleave",r),o.addEventListener("blur",r))})})();
|
||||
(()=>{let e=Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover")?!1:!0;document.querySelectorAll(".wp-is-tooltip").forEach(function(o){const t=o.querySelector(".wp-tooltip__toggle"),r=o.querySelector("span.wp-tooltip__bubble");if(e&&r)r.classList.add("hidden");else if(t&&r){let e;var o=()=>{clearTimeout(e),e=setTimeout(()=>{r.matches(":popover-open")||r.showPopover({source:t})},300)},p=()=>{clearTimeout(e),r.matches(":popover-open")&&r.hidePopover()};t.addEventListener("mouseenter",o),t.addEventListener("focus",o),t.addEventListener("mouseleave",p),t.addEventListener("blur",p)}})})();
|
||||
Reference in New Issue
Block a user