enhancing brochures formt system
This commit is contained in:
parent
5731177580
commit
b06e0632be
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => '617b3841d9e762364fd5');
|
||||
<?php return array('dependencies' => array('wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => '251b40e555a82eb6d434');
|
||||
|
|
|
|||
|
|
@ -119,12 +119,13 @@ const BrochureLinkFormatButton = props => {
|
|||
}
|
||||
});
|
||||
function setFormat(postDatas) {
|
||||
console.log("postdata", postDatas);
|
||||
setIsPopoverOpen(!isPopoverOpen);
|
||||
setPendingBrochure(true);
|
||||
onChange((0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.applyFormat)(value, {
|
||||
type: formatName,
|
||||
attributes: {
|
||||
href: "",
|
||||
href: postDatas.url,
|
||||
brochurePostID: postDatas.id.toString(),
|
||||
target: "_blank",
|
||||
style: "text-decoration: underline;"
|
||||
|
|
@ -137,28 +138,30 @@ const BrochureLinkFormatButton = props => {
|
|||
type: formatName
|
||||
}));
|
||||
}
|
||||
console.log(brochurePost);
|
||||
console.log(brochureAttachedMedia);
|
||||
if (brochurePost && brochureAttachedMedia && pendingBrochure) {
|
||||
onChange((0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.applyFormat)(value, {
|
||||
type: formatName,
|
||||
attributes: {
|
||||
target: "_blank",
|
||||
brochurePostID: brochurePost.id.toString(),
|
||||
brochureID: brochureAttachedMedia.id.toString(),
|
||||
href: brochureAttachedMedia.source_url,
|
||||
style: "text-decoration: underline;"
|
||||
}
|
||||
}));
|
||||
setPendingBrochure(false);
|
||||
}
|
||||
|
||||
// if (brochurePost && brochureAttachedMedia && pendingBrochure) {
|
||||
// onChange(
|
||||
// applyFormat(value, {
|
||||
// type: formatName,
|
||||
// attributes: {
|
||||
// target: "_blank",
|
||||
// brochurePostID: brochurePost.id.toString(),
|
||||
// brochureID: brochureAttachedMedia.id.toString(),
|
||||
// href: brochurePost.link,
|
||||
// style: "text-decoration: underline;",
|
||||
// },
|
||||
// })
|
||||
// );
|
||||
// setPendingBrochure(false);
|
||||
// }
|
||||
|
||||
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.BlockControls, null, isPopoverOpen && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.Popover, {
|
||||
onClose: () => setIsPopoverOpen(false),
|
||||
className: "popover_tooltip_field"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.__experimentalLinkControl, {
|
||||
suggestionsQuery: {
|
||||
type: "post",
|
||||
subtype: "brochures"
|
||||
subtype: ["brochures", "fiches-infos"]
|
||||
// subtype: "application/pdf", // Not working
|
||||
// mime_type: "application/pdf", // Not working
|
||||
},
|
||||
|
|
@ -170,12 +173,12 @@ const BrochureLinkFormatButton = props => {
|
|||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.ToolbarButton, {
|
||||
isActive: isActive,
|
||||
icon: !isActive ? "book" : _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__["default"],
|
||||
label: !isActive ? "Ajouter un lien brochure" : "Supprimer le lien brochure",
|
||||
label: !isActive ? "Ajouter un lien Brochure / Fiche-info" : "Supprimer le lien Brochure / Fiche-info",
|
||||
onClick: () => !isActive ? setIsPopoverOpen(!isPopoverOpen) : removeFormat()
|
||||
}))));
|
||||
};
|
||||
(0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.registerFormatType)("homegrade-format/brochure-format", {
|
||||
title: "Lien Brochure",
|
||||
title: "Lien Brochure/Fiche-info",
|
||||
tagName: "a",
|
||||
attributes: {
|
||||
brochureID: "brochure-id",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -43,5 +43,5 @@ async function hydrateBrochuresLinks() {
|
|||
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
buildDownloadIcons();
|
||||
hydrateBrochuresLinks();
|
||||
// hydrateBrochuresLinks(); // Plus besoin depuis le que single-post-type Brochure redirige automatiquement vers le PDF correspondant
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,13 +36,14 @@ const BrochureLinkFormatButton = (props) => {
|
|||
});
|
||||
|
||||
function setFormat(postDatas) {
|
||||
console.log("postdata", postDatas);
|
||||
setIsPopoverOpen(!isPopoverOpen);
|
||||
setPendingBrochure(true);
|
||||
onChange(
|
||||
applyFormat(value, {
|
||||
type: formatName,
|
||||
attributes: {
|
||||
href: "",
|
||||
href: postDatas.url,
|
||||
brochurePostID: postDatas.id.toString(),
|
||||
target: "_blank",
|
||||
style: "text-decoration: underline;",
|
||||
|
|
@ -59,23 +60,22 @@ const BrochureLinkFormatButton = (props) => {
|
|||
})
|
||||
);
|
||||
}
|
||||
console.log(brochurePost);
|
||||
console.log(brochureAttachedMedia);
|
||||
if (brochurePost && brochureAttachedMedia && pendingBrochure) {
|
||||
onChange(
|
||||
applyFormat(value, {
|
||||
type: formatName,
|
||||
attributes: {
|
||||
target: "_blank",
|
||||
brochurePostID: brochurePost.id.toString(),
|
||||
brochureID: brochureAttachedMedia.id.toString(),
|
||||
href: brochureAttachedMedia.source_url,
|
||||
style: "text-decoration: underline;",
|
||||
},
|
||||
})
|
||||
);
|
||||
setPendingBrochure(false);
|
||||
}
|
||||
|
||||
// if (brochurePost && brochureAttachedMedia && pendingBrochure) {
|
||||
// onChange(
|
||||
// applyFormat(value, {
|
||||
// type: formatName,
|
||||
// attributes: {
|
||||
// target: "_blank",
|
||||
// brochurePostID: brochurePost.id.toString(),
|
||||
// brochureID: brochureAttachedMedia.id.toString(),
|
||||
// href: brochurePost.link,
|
||||
// style: "text-decoration: underline;",
|
||||
// },
|
||||
// })
|
||||
// );
|
||||
// setPendingBrochure(false);
|
||||
// }
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -87,7 +87,7 @@ const BrochureLinkFormatButton = (props) => {
|
|||
<LinkControl
|
||||
suggestionsQuery={{
|
||||
type: "post",
|
||||
subtype: "brochures",
|
||||
subtype: ["brochures", "fiches-infos"],
|
||||
// subtype: "application/pdf", // Not working
|
||||
// mime_type: "application/pdf", // Not working
|
||||
}}
|
||||
|
|
@ -103,8 +103,8 @@ const BrochureLinkFormatButton = (props) => {
|
|||
icon={!isActive ? "book" : trash}
|
||||
label={
|
||||
!isActive
|
||||
? "Ajouter un lien brochure"
|
||||
: "Supprimer le lien brochure"
|
||||
? "Ajouter un lien Brochure / Fiche-info"
|
||||
: "Supprimer le lien Brochure / Fiche-info"
|
||||
}
|
||||
onClick={() =>
|
||||
!isActive ? setIsPopoverOpen(!isPopoverOpen) : removeFormat()
|
||||
|
|
@ -117,7 +117,7 @@ const BrochureLinkFormatButton = (props) => {
|
|||
};
|
||||
|
||||
registerFormatType("homegrade-format/brochure-format", {
|
||||
title: "Lien Brochure",
|
||||
title: "Lien Brochure/Fiche-info",
|
||||
tagName: "a",
|
||||
attributes: {
|
||||
brochureID: "brochure-id",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user