diff --git a/blocks/post-card/build/block.json b/blocks/post-card/build/block.json index d1b8416..373305d 100644 --- a/blocks/post-card/build/block.json +++ b/blocks/post-card/build/block.json @@ -22,6 +22,13 @@ "postType": { "type": "string", "default": "conseils" + }, + "hasDescription": { + "type": "boolean", + "default": false + }, + "postDescription": { + "type": "string" } } } \ No newline at end of file diff --git a/blocks/post-card/build/index.asset.php b/blocks/post-card/build/index.asset.php index 7f8e17a..ba378fc 100644 --- a/blocks/post-card/build/index.asset.php +++ b/blocks/post-card/build/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '831260fc67b39b194bb9'); + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '354aaf4f576100a5c65a'); diff --git a/blocks/post-card/build/index.js b/blocks/post-card/build/index.js index aa1a8c6..fe71c5f 100644 --- a/blocks/post-card/build/index.js +++ b/blocks/post-card/build/index.js @@ -39,6 +39,8 @@ __webpack_require__.r(__webpack_exports__); function OptionsSelectControl({ setAttributes, relatedPostId, + postDescription, + hasDescription, postType }) { if (!postType || !setAttributes) return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, "Loading"); @@ -70,6 +72,11 @@ function OptionsSelectControl({ } return c_value; } + function handleHasDescriptionChange(hasDescription) { + setAttributes({ + hasDescription + }); + } function handleRelatedPostChange(postId) { setAttributes({ relatedPostId: Number(postId) @@ -133,10 +140,18 @@ function OptionsSelectControl({ value: relatedPostId, options: postOptions, onChange: e => handleRelatedPostChange(e) - }), relatedPostId && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Tip, null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.", "homegrade-blocks")), relatedPostId && editUrl && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { + }), relatedPostId && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Tip, null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Pourrrrrr modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.", "homegrade-blocks")), relatedPostId && editUrl && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { href: editUrl, className: "edit-question-button" - }, "\xC9diter le post"))); + }, "\xC9diter le post")), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.PanelBody, { + title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Texte descriptif", "homegrade-blocks"), + initialOpen: false + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.CheckboxControl, { + label: "Texte descriptif", + help: "\xC0 cocher pour afficher un texte descriptif libre", + checked: hasDescription, + onChange: handleHasDescriptionChange + }))); } /***/ }), @@ -160,13 +175,11 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _wordpress_html_entities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/html-entities */ "@wordpress/html-entities"); -/* harmony import */ var _wordpress_html_entities__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_6__); -/* harmony import */ var _OptionsSelectControl__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./OptionsSelectControl */ "./src/OptionsSelectControl.js"); -/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @wordpress/core-data */ "@wordpress/core-data"); -/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_8__); +/* harmony import */ var _wordpress_html_entities__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/html-entities */ "@wordpress/html-entities"); +/* harmony import */ var _wordpress_html_entities__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var _OptionsSelectControl__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./OptionsSelectControl */ "./src/OptionsSelectControl.js"); +/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @wordpress/core-data */ "@wordpress/core-data"); +/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_7__); @@ -176,14 +189,15 @@ __webpack_require__.r(__webpack_exports__); - function Edit({ attributes, setAttributes }) { const { relatedPostId, - postType + postType, + hasDescription, + postDescription } = attributes; const currentRelatedPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => relatedPostId && postType ? select("core").getEntityRecord("postType", postType, relatedPostId) : null, [relatedPostId, postType]); const post = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => select("core").getEntityRecord("postType", postType, relatedPostId)); @@ -204,9 +218,16 @@ function Edit({ return (_media$source_url = media?.source_url) !== null && _media$source_url !== void 0 ? _media$source_url : null; }, [postParentTaxonomy]); const postTypeDatas = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => select("core").getEntityConfig("postType", postType)); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_OptionsSelectControl__WEBPACK_IMPORTED_MODULE_7__["default"], { + function handlePostDescriptionChange(description) { + setAttributes({ + postDescription: description + }); + } + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_OptionsSelectControl__WEBPACK_IMPORTED_MODULE_6__["default"], { relatedPostId: relatedPostId, postType: postType, + hasDescription: hasDescription, + postDescription: postDescription, setAttributes: setAttributes }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { ...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.useBlockProps)({ @@ -226,7 +247,12 @@ function Edit({ class: "tag post-type-tag" }, postTypeDatas.label)), currentRelatedPost && currentRelatedPost.title && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h2", { class: "post-card__title" - }, (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_6__.decodeEntities)(currentRelatedPost.title.rendered))), !relatedPostId && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ce bloc n'est relié à aucun post. Rattachez-le à un post dans la barre latérale.", "homegrade-blocks__texte-backoffice"))))); + }, (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_5__.decodeEntities)(currentRelatedPost.title.rendered)), hasDescription && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.RichText, { + tagName: "p", + onChange: handlePostDescriptionChange // Store updated content as a block attribute + , + placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Heading...") // Insérez votre description + })), !relatedPostId && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ce bloc n'est relié à aucun post. Rattachez-le à un post dans la barre latérale.", "homegrade-blocks__texte-backoffice"))))); } /***/ }), @@ -388,7 +414,7 @@ module.exports = window["wp"]["i18n"]; \************************/ /***/ ((module) => { -module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/post-card","version":"0.1.0","title":"Post Link","category":"homegrade-blocks","description":"Pour afficher le lien vers un post (conseil, fiche-info, …) dans une carte","supports":{"anchor":true,"html":false},"textdomain":"homegrade-theme__bloks-texte-fonctionnel","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"relatedPostId":{"type":"number"},"postType":{"type":"string","default":"conseils"}}}'); +module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/post-card","version":"0.1.0","title":"Post Link","category":"homegrade-blocks","description":"Pour afficher le lien vers un post (conseil, fiche-info, …) dans une carte","supports":{"anchor":true,"html":false},"textdomain":"homegrade-theme__bloks-texte-fonctionnel","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"relatedPostId":{"type":"number"},"postType":{"type":"string","default":"conseils"},"hasDescription":{"type":"boolean","default":false},"postDescription":{"type":"string"}}}'); /***/ }) diff --git a/blocks/post-card/build/index.js.map b/blocks/post-card/build/index.js.map index a2b0aee..b5fd507 100644 --- a/blocks/post-card/build/index.js.map +++ b/blocks/post-card/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAqC;AACuB;AAK7B;AACR;AACqB;AAEA;AACa;AACC;AAE3C,SAASU,oBAAoBA,CAAC;EAC5CC,aAAa;EACbC,aAAa;EACbC;AACD,CAAC,EAAE;EACF,IAAI,CAACA,QAAQ,IAAI,CAACF,aAAa,EAAE,OAAOG,oDAAA,YAAG,SAAU,CAAC;EAEtD,IAAI,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGR,4DAAQ,CAAC,IAAI,CAAC;EAElD,MAAMS,IAAI,GAAGC,0BAA0B,CAAC,0BAA0B,CAAC;EACnE,MAAMC,WAAW,GAAGb,0DAAS,CAC3Bc,MAAM,IAAK;IACX,IAAI,CAACP,QAAQ,EAAE,OAAO,IAAI;IAC1B,IAAIQ,KAAK,GAAG;MACXC,MAAM,EAAE,SAAS;MACjBC,QAAQ,EAAE,CAAC,CAAC;MACZN,IAAI,EAAEA;IACP,CAAC;IACD,OAAOG,MAAM,CAAC,MAAM,CAAC,CAACI,gBAAgB,CAAC,UAAU,EAAEX,QAAQ,EAAEQ,KAAK,CAAC;EACpE,CAAC,EACD,CAACR,QAAQ,EAAEI,IAAI,CAChB,CAAC;EACD,MAAMQ,OAAO,GAAGb,aAAa,GACzB,GAAEc,MAAM,CAACC,QAAQ,CAACC,MAAO,2BAA0BhB,aAAc,cAAa,GAC/E,IAAI;EACP,SAASM,0BAA0BA,CAACW,MAAM,EAAE;IAC3C,IAAIC,OAAO,GAAGC,QAAQ,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ACAA;;;;;;;;;;;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://multiblocks/./src/OptionsSelectControl.js","webpack://multiblocks/./src/edit.js","webpack://multiblocks/./src/index.js","webpack://multiblocks/./src/editor.scss?d446","webpack://multiblocks/./src/style.scss?d1e4","webpack://multiblocks/external window \"React\"","webpack://multiblocks/external window [\"wp\",\"blockEditor\"]","webpack://multiblocks/external window [\"wp\",\"blocks\"]","webpack://multiblocks/external window [\"wp\",\"components\"]","webpack://multiblocks/external window [\"wp\",\"coreData\"]","webpack://multiblocks/external window [\"wp\",\"data\"]","webpack://multiblocks/external window [\"wp\",\"element\"]","webpack://multiblocks/external window [\"wp\",\"htmlEntities\"]","webpack://multiblocks/external window [\"wp\",\"i18n\"]","webpack://multiblocks/webpack/bootstrap","webpack://multiblocks/webpack/runtime/chunk loaded","webpack://multiblocks/webpack/runtime/compat get default export","webpack://multiblocks/webpack/runtime/define property getters","webpack://multiblocks/webpack/runtime/hasOwnProperty shorthand","webpack://multiblocks/webpack/runtime/make namespace object","webpack://multiblocks/webpack/runtime/jsonp chunk loading","webpack://multiblocks/webpack/before-startup","webpack://multiblocks/webpack/startup","webpack://multiblocks/webpack/after-startup"],"sourcesContent":["import { __ } from \"@wordpress/i18n\";\r\nimport { InspectorControls } from \"@wordpress/block-editor\";\r\nimport {\r\n\tPanelBody,\r\n\tSelectControl,\r\n\tComboboxControl,\r\n} from \"@wordpress/components\";\r\nimport \"./editor.scss\";\r\nimport { Tip } from \"@wordpress/components\";\r\n\r\nimport { useSelect } from \"@wordpress/data\";\r\nimport { useEffect, useState } from \"@wordpress/element\";\r\nimport { decodeEntities } from \"@wordpress/html-entities\";\r\n\r\nexport default function OptionsSelectControl({\r\n\tsetAttributes,\r\n\trelatedPostId,\r\n\tpostType,\r\n}) {\r\n\tif (!postType || !setAttributes) return

Loading

;\r\n\r\n\tlet [postOptions, setPostOptions] = useState(null);\r\n\r\n\tconst lang = getAdminLanguageFromCookie(\"wp-wpml_current_language\");\r\n\tconst optionPages = useSelect(\r\n\t\t(select) => {\r\n\t\t\tif (!postType) return null;\r\n\t\t\tlet query = {\r\n\t\t\t\tstatus: \"publish\",\r\n\t\t\t\tper_page: -1,\r\n\t\t\t\tlang: lang,\r\n\t\t\t};\r\n\t\t\treturn select(\"core\").getEntityRecords(\"postType\", postType, query);\r\n\t\t},\r\n\t\t[postType, lang],\r\n\t);\r\n\tconst editUrl = relatedPostId\r\n\t\t? `${window.location.origin}/wp-admin/post.php?post=${relatedPostId}&action=edit`\r\n\t\t: null;\r\n\tfunction getAdminLanguageFromCookie(c_name) {\r\n\t\tvar c_value = document.cookie,\r\n\t\t\tc_start = c_value.indexOf(\" \" + c_name + \"=\");\r\n\t\tif (c_start == -1) c_start = c_value.indexOf(c_name + \"=\");\r\n\t\tif (c_start == -1) {\r\n\t\t\tc_value = null;\r\n\t\t} else {\r\n\t\t\tc_start = c_value.indexOf(\"=\", c_start) + 1;\r\n\t\t\tvar c_end = c_value.indexOf(\";\", c_start);\r\n\t\t\tif (c_end == -1) {\r\n\t\t\t\tc_end = c_value.length;\r\n\t\t\t}\r\n\t\t\tc_value = unescape(c_value.substring(c_start, c_end));\r\n\t\t}\r\n\t\treturn c_value;\r\n\t}\r\n\r\n\tfunction handleRelatedPostChange(postId) {\r\n\t\tsetAttributes({ relatedPostId: Number(postId) });\r\n\t}\r\n\tfunction handlePostTypeChange(postType) {\r\n\t\tsetAttributes({ postType: postType, relatedPostId: null });\r\n\t}\r\n\r\n\tfunction buildSelectOptions(optionPages) {\r\n\t\tlet options = [];\r\n\t\tif (optionPages && optionPages.length > 0) {\r\n\t\t\toptions.push({ value: 0, label: \"Selectionnez une page\" });\r\n\t\t\toptionPages.forEach((page) => {\r\n\t\t\t\toptions.push({\r\n\t\t\t\t\tvalue: page.id,\r\n\t\t\t\t\tlabel: decodeEntities(page.title.rendered),\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\toptions.push({ value: 0, label: \"Pas encore de questions...\" });\r\n\t\t}\r\n\t\treturn options;\r\n\t}\r\n\r\n\tuseEffect(() => {\r\n\t\tif (!optionPages || !postType) return;\r\n\t\tif (optionPages && optionPages.length > 0) {\r\n\t\t\tsetPostOptions(buildSelectOptions(optionPages));\r\n\t\t}\r\n\t}, [optionPages, postType]);\r\n\r\n\tlet panelTitle = \"Post Reliée\";\r\n\r\n\treturn (\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\r\n\t\t\t\t{postOptions && (\r\n\t\t\t\t\t handleRelatedPostChange(e)}\r\n\t\t\t\t\t/>\r\n\t\t\t\t)}\r\n\t\t\t\t{relatedPostId && (\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t{__(\r\n\t\t\t\t\t\t\t\"Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.\",\r\n\t\t\t\t\t\t\t\"homegrade-blocks\",\r\n\t\t\t\t\t\t)}\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\t\t\t\t{relatedPostId && editUrl && (\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tÉditer le post\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\t\t\t\r\n\t\t\r\n\t);\r\n}\r\n","import { __ } from \"@wordpress/i18n\";\nimport { useBlockProps } from \"@wordpress/block-editor\";\n\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\nimport \"./editor.scss\";\nimport { RawHTML } from \"@wordpress/element\";\nimport { useEffect } from \"@wordpress/element\";\nimport { decodeEntities } from \"@wordpress/html-entities\";\nimport OptionsSelectControl from \"./OptionsSelectControl\";\n\nimport { useEntityProp } from \"@wordpress/core-data\";\n\nexport default function Edit({ attributes, setAttributes }) {\n\tconst { relatedPostId, postType } = attributes;\n\n\tconst currentRelatedPost = useSelect(\n\t\t(select) =>\n\t\t\trelatedPostId && postType\n\t\t\t\t? select(\"core\").getEntityRecord(\"postType\", postType, relatedPostId)\n\t\t\t\t: null,\n\t\t[relatedPostId, postType],\n\t);\n\n\tconst post = useSelect((select) =>\n\t\tselect(\"core\").getEntityRecord(\"postType\", postType, relatedPostId),\n\t);\n\n\tconst postMainTaxonomy = useSelect(\n\t\t(select) => {\n\t\t\treturn select(\"core\").getEntityRecord(\n\t\t\t\t\"taxonomy\",\n\t\t\t\t\"thematiques\",\n\t\t\t\tpost?.thematiques ?? null,\n\t\t\t);\n\t\t},\n\t\t[post],\n\t);\n\n\tconst postParentTaxonomy = useSelect(\n\t\t(select) => {\n\t\t\tif (!postMainTaxonomy) return null;\n\t\t\tif (postMainTaxonomy && !postMainTaxonomy.parent) return postMainTaxonomy;\n\t\t\treturn select(\"core\").getEntityRecord(\n\t\t\t\t\"taxonomy\",\n\t\t\t\t\"thematiques\",\n\t\t\t\tpostMainTaxonomy?.parent ?? null,\n\t\t\t);\n\t\t},\n\t\t[postMainTaxonomy],\n\t);\n\n\tconst thematiqueCoverUrl = useSelect(\n\t\t(select) => {\n\t\t\tlet thematiqueMediaId = postParentTaxonomy?.acf?.taxonomy_pictures?.icon;\n\t\t\tconst media = select(\"core\").getMedia(thematiqueMediaId);\n\t\t\treturn media?.source_url ?? null;\n\t\t},\n\t\t[postParentTaxonomy],\n\t);\n\n\tconst postTypeDatas = useSelect((select) =>\n\t\tselect(\"core\").getEntityConfig(\"postType\", postType),\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t\n\n\t\t\t\n\t\t\t\t{/* postParentTaxonomy */}\n\t\t\t\t\"\"\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{postParentTaxonomy && (\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t{postParentTaxonomy.name}\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{postTypeDatas && (\n\t\t\t\t\t\t\t
{postTypeDatas.label}
\n\t\t\t\t\t\t)}\n\t\t\t\t\t
\n\t\t\t\t\t{currentRelatedPost && currentRelatedPost.title && (\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{decodeEntities(currentRelatedPost.title.rendered)}\n\t\t\t\t\t\t

\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\t{!relatedPostId && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{__(\n\t\t\t\t\t\t\t\t\"Ce bloc n'est relié à aucun post. Rattachez-le à un post dans la barre latérale.\",\n\t\t\t\t\t\t\t\t\"homegrade-blocks__texte-backoffice\",\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t)}\n\t\t\t\n\t\t\n\t);\n}\n","import { registerBlockType } from \"@wordpress/blocks\";\n\nimport \"./style.scss\";\n\nimport Edit from \"./edit\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ticon: {\n\t\tsrc: (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t\tforeground: \"#DF1E1E\",\n\t},\n\n\tedit: Edit,\n});\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"coreData\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"htmlEntities\"];","module.exports = window[\"wp\"][\"i18n\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkmultiblocks\"] = globalThis[\"webpackChunkmultiblocks\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","InspectorControls","PanelBody","SelectControl","ComboboxControl","Tip","useSelect","useEffect","useState","decodeEntities","OptionsSelectControl","setAttributes","relatedPostId","postType","createElement","postOptions","setPostOptions","lang","getAdminLanguageFromCookie","optionPages","select","query","status","per_page","getEntityRecords","editUrl","window","location","origin","c_name","c_value","document","cookie","c_start","indexOf","c_end","length","unescape","substring","handleRelatedPostChange","postId","Number","handlePostTypeChange","buildSelectOptions","options","push","value","label","forEach","page","id","title","rendered","panelTitle","onChange","e","href","className","useBlockProps","RawHTML","useEntityProp","Edit","attributes","currentRelatedPost","getEntityRecord","post","postMainTaxonomy","_post$thematiques","thematiques","postParentTaxonomy","_postMainTaxonomy$par","parent","thematiqueCoverUrl","_media$source_url","thematiqueMediaId","acf","taxonomy_pictures","icon","media","getMedia","source_url","postTypeDatas","getEntityConfig","Fragment","class","alt","src","slug","name","registerBlockType","metadata","xmlns","width","height","viewBox","d","foreground","edit"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAqC;AACuB;AAK7B;AACR;AACsC;AAEjB;AACa;AACC;AAE3C,SAASW,oBAAoBA,CAAC;EAC5CC,aAAa;EACbC,aAAa;EACbC,eAAe;EACfC,cAAc;EACdC;AACD,CAAC,EAAE;EACF,IAAI,CAACA,QAAQ,IAAI,CAACJ,aAAa,EAAE,OAAOK,oDAAA,YAAG,SAAU,CAAC;EAEtD,IAAI,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGV,4DAAQ,CAAC,IAAI,CAAC;EAElD,MAAMW,IAAI,GAAGC,0BAA0B,CAAC,0BAA0B,CAAC;EACnE,MAAMC,WAAW,GAAGf,0DAAS,CAC3BgB,MAAM,IAAK;IACX,IAAI,CAACP,QAAQ,EAAE,OAAO,IAAI;IAC1B,IAAIQ,KAAK,GAAG;MACXC,MAAM,EAAE,SAAS;MACjBC,QAAQ,EAAE,CAAC,CAAC;MACZN,IAAI,EAAEA;IACP,CAAC;IACD,OAAOG,MAAM,CAAC,MAAM,CAAC,CAACI,gBAAgB,CAAC,UAAU,EAAEX,QAAQ,EAAEQ,KAAK,CAAC;EACpE,CAAC,EACD,CAACR,QAAQ,EAAEI,IAAI,CAChB,CAAC;EACD,MAAMQ,OAAO,GAAGf,aAAa,GACzB,GAAEgB,MAAM,CAACC,QAAQ,CAACC,MAAO,2BAA0BlB,aAAc,cAAa,GAC/E,IAAI;EACP,SAASQ,0BAA0BA,CAACW,MAAM,EAAE;IAC3C,IAAIC,OAAO,GAAGC,QAAQ,CAACC,MAAM;MAC5BC,OAAO,GAAGH,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BAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://multiblocks/./src/OptionsSelectControl.js","webpack://multiblocks/./src/edit.js","webpack://multiblocks/./src/index.js","webpack://multiblocks/./src/editor.scss","webpack://multiblocks/./src/style.scss","webpack://multiblocks/external window \"React\"","webpack://multiblocks/external window [\"wp\",\"blockEditor\"]","webpack://multiblocks/external window [\"wp\",\"blocks\"]","webpack://multiblocks/external window [\"wp\",\"components\"]","webpack://multiblocks/external window [\"wp\",\"coreData\"]","webpack://multiblocks/external window [\"wp\",\"data\"]","webpack://multiblocks/external window [\"wp\",\"element\"]","webpack://multiblocks/external window [\"wp\",\"htmlEntities\"]","webpack://multiblocks/external window [\"wp\",\"i18n\"]","webpack://multiblocks/webpack/bootstrap","webpack://multiblocks/webpack/runtime/chunk loaded","webpack://multiblocks/webpack/runtime/compat get default export","webpack://multiblocks/webpack/runtime/define property getters","webpack://multiblocks/webpack/runtime/hasOwnProperty shorthand","webpack://multiblocks/webpack/runtime/make namespace object","webpack://multiblocks/webpack/runtime/jsonp chunk loading","webpack://multiblocks/webpack/before-startup","webpack://multiblocks/webpack/startup","webpack://multiblocks/webpack/after-startup"],"sourcesContent":["import { __ } from \"@wordpress/i18n\";\r\nimport { InspectorControls } from \"@wordpress/block-editor\";\r\nimport {\r\n\tPanelBody,\r\n\tSelectControl,\r\n\tComboboxControl,\r\n} from \"@wordpress/components\";\r\nimport \"./editor.scss\";\r\nimport { Tip, CheckboxControl } from \"@wordpress/components\";\r\n\r\nimport { useSelect } from \"@wordpress/data\";\r\nimport { useEffect, useState } from \"@wordpress/element\";\r\nimport { decodeEntities } from \"@wordpress/html-entities\";\r\n\r\nexport default function OptionsSelectControl({\r\n\tsetAttributes,\r\n\trelatedPostId,\r\n\tpostDescription,\r\n\thasDescription,\r\n\tpostType,\r\n}) {\r\n\tif (!postType || !setAttributes) return

Loading

;\r\n\r\n\tlet [postOptions, setPostOptions] = useState(null);\r\n\r\n\tconst lang = getAdminLanguageFromCookie(\"wp-wpml_current_language\");\r\n\tconst optionPages = useSelect(\r\n\t\t(select) => {\r\n\t\t\tif (!postType) return null;\r\n\t\t\tlet query = {\r\n\t\t\t\tstatus: \"publish\",\r\n\t\t\t\tper_page: -1,\r\n\t\t\t\tlang: lang,\r\n\t\t\t};\r\n\t\t\treturn select(\"core\").getEntityRecords(\"postType\", postType, query);\r\n\t\t},\r\n\t\t[postType, lang],\r\n\t);\r\n\tconst editUrl = relatedPostId\r\n\t\t? `${window.location.origin}/wp-admin/post.php?post=${relatedPostId}&action=edit`\r\n\t\t: null;\r\n\tfunction getAdminLanguageFromCookie(c_name) {\r\n\t\tvar c_value = document.cookie,\r\n\t\t\tc_start = c_value.indexOf(\" \" + c_name + \"=\");\r\n\t\tif (c_start == -1) c_start = c_value.indexOf(c_name + \"=\");\r\n\t\tif (c_start == -1) {\r\n\t\t\tc_value = null;\r\n\t\t} else {\r\n\t\t\tc_start = c_value.indexOf(\"=\", c_start) + 1;\r\n\t\t\tvar c_end = c_value.indexOf(\";\", c_start);\r\n\t\t\tif (c_end == -1) {\r\n\t\t\t\tc_end = c_value.length;\r\n\t\t\t}\r\n\t\t\tc_value = unescape(c_value.substring(c_start, c_end));\r\n\t\t}\r\n\t\treturn c_value;\r\n\t}\r\n\r\n\tfunction handleHasDescriptionChange(hasDescription) {\r\n\t\tsetAttributes({ hasDescription });\r\n\t}\r\n\r\n\tfunction handleRelatedPostChange(postId) {\r\n\t\tsetAttributes({ relatedPostId: Number(postId) });\r\n\t}\r\n\tfunction handlePostTypeChange(postType) {\r\n\t\tsetAttributes({ postType: postType, relatedPostId: null });\r\n\t}\r\n\r\n\tfunction buildSelectOptions(optionPages) {\r\n\t\tlet options = [];\r\n\t\tif (optionPages && optionPages.length > 0) {\r\n\t\t\toptions.push({ value: 0, label: \"Selectionnez une page\" });\r\n\t\t\toptionPages.forEach((page) => {\r\n\t\t\t\toptions.push({\r\n\t\t\t\t\tvalue: page.id,\r\n\t\t\t\t\tlabel: decodeEntities(page.title.rendered),\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\toptions.push({ value: 0, label: \"Pas encore de questions...\" });\r\n\t\t}\r\n\t\treturn options;\r\n\t}\r\n\r\n\tuseEffect(() => {\r\n\t\tif (!optionPages || !postType) return;\r\n\t\tif (optionPages && optionPages.length > 0) {\r\n\t\t\tsetPostOptions(buildSelectOptions(optionPages));\r\n\t\t}\r\n\t}, [optionPages, postType]);\r\n\r\n\tlet panelTitle = \"Post Reliée\";\r\n\r\n\treturn (\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\r\n\t\t\t\t{postOptions && (\r\n\t\t\t\t\t handleRelatedPostChange(e)}\r\n\t\t\t\t\t/>\r\n\t\t\t\t)}\r\n\t\t\t\t{relatedPostId && (\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t{__(\r\n\t\t\t\t\t\t\t\"Pourrrrrr modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.\",\r\n\t\t\t\t\t\t\t\"homegrade-blocks\",\r\n\t\t\t\t\t\t)}\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\t\t\t\t{relatedPostId && editUrl && (\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tÉditer le post\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t);\r\n}\r\n","import { __ } from \"@wordpress/i18n\";\nimport { useBlockProps } from \"@wordpress/block-editor\";\n\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\nimport \"./editor.scss\";\nimport { decodeEntities } from \"@wordpress/html-entities\";\nimport OptionsSelectControl from \"./OptionsSelectControl\";\nimport { RichText } from \"@wordpress/block-editor\";\n\nimport { useEntityProp } from \"@wordpress/core-data\";\n\nexport default function Edit({ attributes, setAttributes }) {\n\tconst { relatedPostId, postType, hasDescription, postDescription } =\n\t\tattributes;\n\n\tconst currentRelatedPost = useSelect(\n\t\t(select) =>\n\t\t\trelatedPostId && postType\n\t\t\t\t? select(\"core\").getEntityRecord(\"postType\", postType, relatedPostId)\n\t\t\t\t: null,\n\t\t[relatedPostId, postType],\n\t);\n\n\tconst post = useSelect((select) =>\n\t\tselect(\"core\").getEntityRecord(\"postType\", postType, relatedPostId),\n\t);\n\n\tconst postMainTaxonomy = useSelect(\n\t\t(select) => {\n\t\t\treturn select(\"core\").getEntityRecord(\n\t\t\t\t\"taxonomy\",\n\t\t\t\t\"thematiques\",\n\t\t\t\tpost?.thematiques ?? null,\n\t\t\t);\n\t\t},\n\t\t[post],\n\t);\n\n\tconst postParentTaxonomy = useSelect(\n\t\t(select) => {\n\t\t\tif (!postMainTaxonomy) return null;\n\t\t\tif (postMainTaxonomy && !postMainTaxonomy.parent) return postMainTaxonomy;\n\t\t\treturn select(\"core\").getEntityRecord(\n\t\t\t\t\"taxonomy\",\n\t\t\t\t\"thematiques\",\n\t\t\t\tpostMainTaxonomy?.parent ?? null,\n\t\t\t);\n\t\t},\n\t\t[postMainTaxonomy],\n\t);\n\n\tconst thematiqueCoverUrl = useSelect(\n\t\t(select) => {\n\t\t\tlet thematiqueMediaId = postParentTaxonomy?.acf?.taxonomy_pictures?.icon;\n\t\t\tconst media = select(\"core\").getMedia(thematiqueMediaId);\n\t\t\treturn media?.source_url ?? null;\n\t\t},\n\t\t[postParentTaxonomy],\n\t);\n\n\tconst postTypeDatas = useSelect((select) =>\n\t\tselect(\"core\").getEntityConfig(\"postType\", postType),\n\t);\n\tfunction handlePostDescriptionChange(description) {\n\t\tsetAttributes({ postDescription: description });\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t\n\n\t\t\t\n\t\t\t\t\"\"\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{postParentTaxonomy && (\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t{postParentTaxonomy.name}\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{postTypeDatas && (\n\t\t\t\t\t\t\t
{postTypeDatas.label}
\n\t\t\t\t\t\t)}\n\t\t\t\t\t
\n\t\t\t\t\t{currentRelatedPost && currentRelatedPost.title && (\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{decodeEntities(currentRelatedPost.title.rendered)}\n\t\t\t\t\t\t

\n\t\t\t\t\t)}\n\t\t\t\t\t{hasDescription && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\t{!relatedPostId && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{__(\n\t\t\t\t\t\t\t\t\"Ce bloc n'est relié à aucun post. Rattachez-le à un post dans la barre latérale.\",\n\t\t\t\t\t\t\t\t\"homegrade-blocks__texte-backoffice\",\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t)}\n\t\t\t\n\t\t\n\t);\n}\n","import { registerBlockType } from \"@wordpress/blocks\";\n\nimport \"./style.scss\";\n\nimport Edit from \"./edit\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ticon: {\n\t\tsrc: (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t\tforeground: \"#DF1E1E\",\n\t},\n\n\tedit: Edit,\n});\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"coreData\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"htmlEntities\"];","module.exports = window[\"wp\"][\"i18n\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkmultiblocks\"] = globalThis[\"webpackChunkmultiblocks\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","InspectorControls","PanelBody","SelectControl","ComboboxControl","Tip","CheckboxControl","useSelect","useEffect","useState","decodeEntities","OptionsSelectControl","setAttributes","relatedPostId","postDescription","hasDescription","postType","createElement","postOptions","setPostOptions","lang","getAdminLanguageFromCookie","optionPages","select","query","status","per_page","getEntityRecords","editUrl","window","location","origin","c_name","c_value","document","cookie","c_start","indexOf","c_end","length","unescape","substring","handleHasDescriptionChange","handleRelatedPostChange","postId","Number","handlePostTypeChange","buildSelectOptions","options","push","value","label","forEach","page","id","title","rendered","panelTitle","onChange","e","href","className","initialOpen","help","checked","useBlockProps","RichText","useEntityProp","Edit","attributes","currentRelatedPost","getEntityRecord","post","postMainTaxonomy","_post$thematiques","thematiques","postParentTaxonomy","_postMainTaxonomy$par","parent","thematiqueCoverUrl","_media$source_url","thematiqueMediaId","acf","taxonomy_pictures","icon","media","getMedia","source_url","postTypeDatas","getEntityConfig","handlePostDescriptionChange","description","Fragment","class","alt","src","slug","name","tagName","placeholder","registerBlockType","metadata","xmlns","width","height","viewBox","d","foreground","edit"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/post-card/build/render.php b/blocks/post-card/build/render.php index f7fca52..cd7dd4f 100644 --- a/blocks/post-card/build/render.php +++ b/blocks/post-card/build/render.php @@ -1,6 +1,4 @@ slug; $thematique_icon = get_field('taxonomy_pictures', 'thematiques' . '_' . $mainThematique->term_id)['icon']; +$postDescription = $attributes['postDescription']; $coverUrl = $postType->name === 'videos-webinaires' && $postThumbnail ? $postThumbnail : ($thematique_icon ? $thematique_icon['url'] : null); ?> - + @@ -30,5 +29,9 @@ $coverUrl = $postType->name === 'videos-webinaires' && $postThumbnail ? $postTh
label ?>

post_title ?>

+ +

+ +

\ No newline at end of file diff --git a/blocks/post-card/src/OptionsSelectControl.js b/blocks/post-card/src/OptionsSelectControl.js index dc156da..c8aaff2 100644 --- a/blocks/post-card/src/OptionsSelectControl.js +++ b/blocks/post-card/src/OptionsSelectControl.js @@ -6,7 +6,7 @@ import { ComboboxControl, } from "@wordpress/components"; import "./editor.scss"; -import { Tip } from "@wordpress/components"; +import { Tip, CheckboxControl } from "@wordpress/components"; import { useSelect } from "@wordpress/data"; import { useEffect, useState } from "@wordpress/element"; @@ -15,6 +15,8 @@ import { decodeEntities } from "@wordpress/html-entities"; export default function OptionsSelectControl({ setAttributes, relatedPostId, + postDescription, + hasDescription, postType, }) { if (!postType || !setAttributes) return

Loading

; @@ -54,6 +56,10 @@ export default function OptionsSelectControl({ return c_value; } + function handleHasDescriptionChange(hasDescription) { + setAttributes({ hasDescription }); + } + function handleRelatedPostChange(postId) { setAttributes({ relatedPostId: Number(postId) }); } @@ -112,7 +118,7 @@ export default function OptionsSelectControl({ {relatedPostId && ( {__( - "Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.", + "Pourrrrrr modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.", "homegrade-blocks", )} @@ -123,6 +129,17 @@ export default function OptionsSelectControl({ )} + + + ); } diff --git a/blocks/post-card/src/block.json b/blocks/post-card/src/block.json index de850de..8d9ae6e 100644 --- a/blocks/post-card/src/block.json +++ b/blocks/post-card/src/block.json @@ -22,6 +22,13 @@ "postType": { "type": "string", "default": "conseils" + }, + "hasDescription": { + "type": "boolean", + "default": false + }, + "postDescription": { + "type": "string" } } } \ No newline at end of file diff --git a/blocks/post-card/src/edit.js b/blocks/post-card/src/edit.js index 9b9697d..cb4d2e9 100644 --- a/blocks/post-card/src/edit.js +++ b/blocks/post-card/src/edit.js @@ -3,15 +3,15 @@ import { useBlockProps } from "@wordpress/block-editor"; import { useSelect } from "@wordpress/data"; // pour les querry import "./editor.scss"; -import { RawHTML } from "@wordpress/element"; -import { useEffect } from "@wordpress/element"; import { decodeEntities } from "@wordpress/html-entities"; import OptionsSelectControl from "./OptionsSelectControl"; +import { RichText } from "@wordpress/block-editor"; import { useEntityProp } from "@wordpress/core-data"; export default function Edit({ attributes, setAttributes }) { - const { relatedPostId, postType } = attributes; + const { relatedPostId, postType, hasDescription, postDescription } = + attributes; const currentRelatedPost = useSelect( (select) => @@ -61,12 +61,17 @@ export default function Edit({ attributes, setAttributes }) { const postTypeDatas = useSelect((select) => select("core").getEntityConfig("postType", postType), ); + function handlePostDescriptionChange(description) { + setAttributes({ postDescription: description }); + } return ( <> @@ -75,7 +80,6 @@ export default function Edit({ attributes, setAttributes }) { className: `post-card`, })} > - {/* postParentTaxonomy */}
@@ -98,6 +102,13 @@ export default function Edit({ attributes, setAttributes }) { {decodeEntities(currentRelatedPost.title.rendered)} )} + {hasDescription && ( + + )}
{!relatedPostId && ( <> diff --git a/blocks/post-card/src/render.php b/blocks/post-card/src/render.php index b618cf9..cd7dd4f 100644 --- a/blocks/post-card/src/render.php +++ b/blocks/post-card/src/render.php @@ -12,6 +12,7 @@ $mainThematique = getMainThematique($thematique); $thematiqueColorSlug = $mainThematique->slug; $thematique_icon = get_field('taxonomy_pictures', 'thematiques' . '_' . $mainThematique->term_id)['icon']; +$postDescription = $attributes['postDescription']; $coverUrl = $postType->name === 'videos-webinaires' && $postThumbnail ? $postThumbnail : ($thematique_icon ? $thematique_icon['url'] : null); @@ -28,5 +29,9 @@ $coverUrl = $postType->name === 'videos-webinaires' && $postThumbnail ? $postTh
label ?>

post_title ?>

+ +

+ +

\ No newline at end of file