From 82c6e785eafcd1fca44868f3a7fed892cd9d67ce Mon Sep 17 00:00:00 2001 From: Antoine M Date: Fri, 27 Oct 2023 17:43:27 +0200 Subject: [PATCH] extending features with custom title integration --- blocks/content-page-header/build/block.json | 7 +++ .../content-page-header/build/index.asset.php | 2 +- blocks/content-page-header/build/index.js | 40 +++++++++++++-- blocks/content-page-header/build/index.js.map | 2 +- blocks/content-page-header/build/render.php | 4 +- blocks/content-page-header/src/block.json | 7 +++ blocks/content-page-header/src/edit.js | 50 +++++++++++++++++-- blocks/content-page-header/src/render.php | 4 +- 8 files changed, 103 insertions(+), 13 deletions(-) diff --git a/blocks/content-page-header/build/block.json b/blocks/content-page-header/build/block.json index 9ee5d08..0b12316 100644 --- a/blocks/content-page-header/build/block.json +++ b/blocks/content-page-header/build/block.json @@ -16,6 +16,13 @@ "style": "file:./style-index.css", "render": "file:./render.php", "attributes": { + "hasCustomTitle": { + "type": "boolean", + "default": false + }, + "blockCustomTitle": { + "type": "string" + }, "pageHeaderTitle": { "type": "string" }, diff --git a/blocks/content-page-header/build/index.asset.php b/blocks/content-page-header/build/index.asset.php index 518cb0c..e8616bb 100644 --- a/blocks/content-page-header/build/index.asset.php +++ b/blocks/content-page-header/build/index.asset.php @@ -1 +1 @@ - array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'c36bb5ed25b531e20cc1'); + array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '22ddb6977be933e11cd9'); diff --git a/blocks/content-page-header/build/index.js b/blocks/content-page-header/build/index.js index 8711671..c214cbc 100644 --- a/blocks/content-page-header/build/index.js +++ b/blocks/content-page-header/build/index.js @@ -29,11 +29,14 @@ __webpack_require__.r(__webpack_exports__); + function Edit({ attributes, setAttributes }) { const { + blockCustomTitle, + hasCustomTitle, pageHeaderTitle, pageHeaderDescription, hasCta, @@ -52,13 +55,27 @@ function Edit({ return cover; } }); + function onChangeBlockCustomTitle(blockCustomTitle) { + setAttributes({ + blockCustomTitle + }); + } function onChangeTitle(newTitle) { setAttributes({ pageHeaderTitle: newTitle }); } + function onChangeHasCustomTitle(newHasAutoTitle) { + setAttributes({ + hasCustomTitle: !hasCustomTitle + }); + if (newHasAutoTitle) { + setAttributes({ + blockCustomTitle: undefined + }); + } + } function onChangeHasCta(newHasCta) { - console.log("newHasCta", newHasCta); setAttributes({ hasCta: !hasCta }); @@ -92,9 +109,17 @@ function Edit({ } }); } + console.log(blockCustomTitle); 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_4__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, { className: "homegrade-blocks-content-page-header__panel-cta", - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Call to action", "homegrade-blocks__texte-fonctionnel") + title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Titre du bloc", "homegrade-blocks__texte-backoffice") + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToggleControl, { + label: "Titre automatique", + checked: !hasCustomTitle, + onChange: onChangeHasCustomTitle + }), !hasCustomTitle && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.Tip, null, "Le titre est automatiquement g\xE9n\xE9r\xE9 \xE0 partir du titre de la page")), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, { + className: "homegrade-blocks-content-page-header__panel-cta", + title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Call to action", "homegrade-blocks__texte-backoffice") }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToggleControl, { label: "Afficher un call to action", checked: hasCta, @@ -105,7 +130,7 @@ function Edit({ onChange: onChangeTextControl }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.__experimentalLinkControl, { label: "Lien du cta", - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Call to action", "homegrade-blocks__texte-fonctionnel"), + title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Call to action", "homegrade-blocks__texte-backoffice"), value: cta, onChange: onChangeCTA })))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("section", { @@ -114,7 +139,12 @@ function Edit({ }) }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { class: "block-content-page-header__content" - }, pageTitle && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", null, pageTitle), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.RichText, { + }, !hasCustomTitle && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", null, pageTitle), hasCustomTitle && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.RichText, { + tagName: "h1", + placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ajouter ici le Titre du Bloc Header", "homegrade"), + value: blockCustomTitle, + onChange: onChangeBlockCustomTitle + }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.RichText, { tagName: "h2", placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ajouter ici le Titre du Bloc Header", "homegrade"), value: pageHeaderTitle, @@ -267,7 +297,7 @@ module.exports = window["wp"]["i18n"]; \************************/ /***/ ((module) => { -module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/content-page-header","version":"0.1.0","title":"Content page header","category":"homegrade-blocks","icon":"smiley","description":"Bloc bannière/header de contenu de premier niveau pour les pages de contenu","supports":{"html":false},"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"pageHeaderTitle":{"type":"string"},"pageHeaderDescription":{"type":"string"},"hasCta":{"type":"boolean","default":false},"cta":{"type":"object"}}}'); +module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/content-page-header","version":"0.1.0","title":"Content page header","category":"homegrade-blocks","icon":"smiley","description":"Bloc bannière/header de contenu de premier niveau pour les pages de contenu","supports":{"html":false},"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"hasCustomTitle":{"type":"boolean","default":false},"blockCustomTitle":{"type":"string"},"pageHeaderTitle":{"type":"string"},"pageHeaderDescription":{"type":"string"},"hasCta":{"type":"boolean","default":false},"cta":{"type":"object"}}}'); /***/ }) diff --git a/blocks/content-page-header/build/index.js.map b/blocks/content-page-header/build/index.js.map index c4535fd..f670ba7 100644 --- a/blocks/content-page-header/build/index.js.map +++ b/blocks/content-page-header/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAqC;AACd;AACqB;AAOX;AAC6C;AAE/D,SAASW,IAAIA,CAAC;EAAEC,UAAU;EAAEC;AAAc,CAAC,EAAE;EAC3D,MAAM;IAAEC,eAAe;IAAEC,qBA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;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;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;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;WC7BA;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;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEnDA;UACA;UACA;UACA;UACA","sources":["webpack://multiblocks/./src/edit.js","webpack://multiblocks/./src/index.js","webpack://multiblocks/./src/editor.scss","webpack://multiblocks/./src/style.scss","webpack://multiblocks/external window [\"wp\",\"blockEditor\"]","webpack://multiblocks/external window [\"wp\",\"blocks\"]","webpack://multiblocks/external window [\"wp\",\"components\"]","webpack://multiblocks/external window [\"wp\",\"data\"]","webpack://multiblocks/external window [\"wp\",\"element\"]","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\";\nimport \"./editor.scss\";\nimport { useSelect } from \"@wordpress/data\";\nimport {\n\tuseBlockProps,\n\tRichText,\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalLinkControl as LinkControl,\n} from \"@wordpress/block-editor\";\nimport { PanelBody, TextControl, ToggleControl } from \"@wordpress/components\";\n\nexport default function Edit({ attributes, setAttributes }) {\n\tconst { pageHeaderTitle, pageHeaderDescription, hasCta, cta } = attributes;\n\n\tconst pageTitle = useSelect((select) => {\n\t\tconst { getEditedPostAttribute } = select(\"core/editor\");\n\t\treturn getEditedPostAttribute(\"title\");\n\t});\n\n\tconst pageIcon = useSelect((select) => {\n\t\tconst currentPost = select(\"core/editor\").getCurrentPost();\n\t\tif (currentPost && currentPost.acf && currentPost.acf.page_icon) {\n\t\t\tlet cover = select(\"core\").getMedia(currentPost.acf.page_icon);\n\t\t\treturn cover;\n\t\t}\n\t});\n\n\tfunction onChangeTitle(newTitle) {\n\t\tsetAttributes({ pageHeaderTitle: newTitle });\n\t}\n\tfunction onChangeHasCta(newHasCta) {\n\t\tconsole.log(\"newHasCta\", newHasCta);\n\t\tsetAttributes({ hasCta: !hasCta });\n\t\tif (!newHasCta) {\n\t\t\tsetAttributes({ cta: undefined });\n\t\t}\n\t}\n\tfunction onChangeDescription(newDescription) {\n\t\tsetAttributes({ pageHeaderDescription: newDescription });\n\t}\n\tfunction onChangeCTA(newCtaValue) {\n\t\tsetAttributes({\n\t\t\tcta: {\n\t\t\t\ttitle: !cta || !cta.title ? newCtaValue.title : cta.title,\n\t\t\t\tid: newCtaValue.id,\n\t\t\t\tkind: newCtaValue.kind,\n\t\t\t\ttype: newCtaValue.type,\n\t\t\t\turl: newCtaValue.url,\n\t\t\t},\n\t\t});\n\t}\n\tfunction onChangeTextControl(newCtaTitle) {\n\t\tsetAttributes({\n\t\t\tcta: {\n\t\t\t\t...cta,\n\t\t\t\ttitle: newCtaTitle,\n\t\t\t},\n\t\t});\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t{hasCta && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t{pageTitle &&

{pageTitle}

}\n\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{cta && cta.title && cta.url && {cta.title}}\n\t\t\t\t
\n\t\t\t\t{pageIcon && (\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\";\nimport \"./style.scss\";\n\nimport Edit from \"./edit\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ticon: {\n\t\tforeground: \"#f03\",\n\t\tsrc: (\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\n\t\t\t\n\t\t),\n\t},\n\tedit: Edit,\n});\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","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 = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\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 = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\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 = self[\"webpackChunkmultiblocks\"] = self[\"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":["__","useSelect","useBlockProps","RichText","BlockControls","InspectorControls","__experimentalLinkControl","LinkControl","PanelBody","TextControl","ToggleControl","Edit","attributes","setAttributes","pageHeaderTitle","pageHeaderDescription","hasCta","cta","pageTitle","select","getEditedPostAttribute","pageIcon","currentPost","getCurrentPost","acf","page_icon","cover","getMedia","onChangeTitle","newTitle","onChangeHasCta","newHasCta","console","log","undefined","onChangeDescription","newDescription","onChangeCTA","newCtaValue","title","id","kind","type","url","onChangeTextControl","newCtaTitle","createElement","Fragment","className","label","checked","onChange","value","class","tagName","placeholder","href","src","source_url","alt","registerBlockType","metadata","name","icon","foreground","xmlns","viewBox","d","edit"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAqC;AACd;AACqB;AAOX;AAC6C;AAClC;AAC7B,SAASY,IAAIA,CAAC;EAAEC,UAAU;EAAEC;AAAc,CAAC,EAAE;EAC3D,MAAM;IACLC,gBAAgB;IAChBC,cAAc;IACdC,eAAe;IACfC,qBAAqB;IACrBC,MAAM;IACNC;EACD,CAAC,GAAGP,UAAU;EAEd,MAAMQ,SAAS,GAAGpB,0DAAS,CAAEqB,MAAM,IAAK;IACvC,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAC,aAAa,CAAC;IACxD,OAAOC,sBAAsB,CAAC,OAAO,CAA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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;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEnDA;UACA;UACA;UACA;UACA","sources":["webpack://multiblocks/./src/edit.js","webpack://multiblocks/./src/index.js","webpack://multiblocks/./src/editor.scss","webpack://multiblocks/./src/style.scss","webpack://multiblocks/external window [\"wp\",\"blockEditor\"]","webpack://multiblocks/external window [\"wp\",\"blocks\"]","webpack://multiblocks/external window [\"wp\",\"components\"]","webpack://multiblocks/external window [\"wp\",\"data\"]","webpack://multiblocks/external window [\"wp\",\"element\"]","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\";\nimport \"./editor.scss\";\nimport { useSelect } from \"@wordpress/data\";\nimport {\n\tuseBlockProps,\n\tRichText,\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalLinkControl as LinkControl,\n} from \"@wordpress/block-editor\";\nimport { PanelBody, TextControl, ToggleControl } from \"@wordpress/components\";\nimport { Tip } from \"@wordpress/components\";\nexport default function Edit({ attributes, setAttributes }) {\n\tconst {\n\t\tblockCustomTitle,\n\t\thasCustomTitle,\n\t\tpageHeaderTitle,\n\t\tpageHeaderDescription,\n\t\thasCta,\n\t\tcta,\n\t} = attributes;\n\n\tconst pageTitle = useSelect((select) => {\n\t\tconst { getEditedPostAttribute } = select(\"core/editor\");\n\t\treturn getEditedPostAttribute(\"title\");\n\t});\n\n\tconst pageIcon = useSelect((select) => {\n\t\tconst currentPost = select(\"core/editor\").getCurrentPost();\n\t\tif (currentPost && currentPost.acf && currentPost.acf.page_icon) {\n\t\t\tlet cover = select(\"core\").getMedia(currentPost.acf.page_icon);\n\t\t\treturn cover;\n\t\t}\n\t});\n\n\tfunction onChangeBlockCustomTitle(blockCustomTitle) {\n\t\tsetAttributes({ blockCustomTitle });\n\t}\n\tfunction onChangeTitle(newTitle) {\n\t\tsetAttributes({ pageHeaderTitle: newTitle });\n\t}\n\tfunction onChangeHasCustomTitle(newHasAutoTitle) {\n\t\tsetAttributes({ hasCustomTitle: !hasCustomTitle });\n\t\tif (newHasAutoTitle) {\n\t\t\tsetAttributes({ blockCustomTitle: undefined });\n\t\t}\n\t}\n\tfunction onChangeHasCta(newHasCta) {\n\t\tsetAttributes({ hasCta: !hasCta });\n\t\tif (!newHasCta) {\n\t\t\tsetAttributes({ cta: undefined });\n\t\t}\n\t}\n\tfunction onChangeDescription(newDescription) {\n\t\tsetAttributes({ pageHeaderDescription: newDescription });\n\t}\n\tfunction onChangeCTA(newCtaValue) {\n\t\tsetAttributes({\n\t\t\tcta: {\n\t\t\t\ttitle: !cta || !cta.title ? newCtaValue.title : cta.title,\n\t\t\t\tid: newCtaValue.id,\n\t\t\t\tkind: newCtaValue.kind,\n\t\t\t\ttype: newCtaValue.type,\n\t\t\t\turl: newCtaValue.url,\n\t\t\t},\n\t\t});\n\t}\n\tfunction onChangeTextControl(newCtaTitle) {\n\t\tsetAttributes({\n\t\t\tcta: {\n\t\t\t\t...cta,\n\t\t\t\ttitle: newCtaTitle,\n\t\t\t},\n\t\t});\n\t}\n\n\tconsole.log(blockCustomTitle);\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{!hasCustomTitle && (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tLe titre est automatiquement généré à partir du titre de la page\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t{hasCta && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t{!hasCustomTitle &&

{pageTitle}

}\n\t\t\t\t\t{hasCustomTitle && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{cta && cta.title && cta.url && {cta.title}}\n\t\t\t\t
\n\t\t\t\t{pageIcon && (\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\";\nimport \"./style.scss\";\n\nimport Edit from \"./edit\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ticon: {\n\t\tforeground: \"#f03\",\n\t\tsrc: (\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\n\t\t\t\n\t\t),\n\t},\n\tedit: Edit,\n});\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","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 = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\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 = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\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 = self[\"webpackChunkmultiblocks\"] = self[\"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":["__","useSelect","useBlockProps","RichText","BlockControls","InspectorControls","__experimentalLinkControl","LinkControl","PanelBody","TextControl","ToggleControl","Tip","Edit","attributes","setAttributes","blockCustomTitle","hasCustomTitle","pageHeaderTitle","pageHeaderDescription","hasCta","cta","pageTitle","select","getEditedPostAttribute","pageIcon","currentPost","getCurrentPost","acf","page_icon","cover","getMedia","onChangeBlockCustomTitle","onChangeTitle","newTitle","onChangeHasCustomTitle","newHasAutoTitle","undefined","onChangeHasCta","newHasCta","onChangeDescription","newDescription","onChangeCTA","newCtaValue","title","id","kind","type","url","onChangeTextControl","newCtaTitle","console","log","createElement","Fragment","className","label","checked","onChange","value","class","tagName","placeholder","href","src","source_url","alt","registerBlockType","metadata","name","icon","foreground","xmlns","viewBox","d","edit"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/content-page-header/build/render.php b/blocks/content-page-header/build/render.php index 82e9f44..beff96a 100644 --- a/blocks/content-page-header/build/render.php +++ b/blocks/content-page-header/build/render.php @@ -11,7 +11,9 @@ $pageIcon = get_field('page_icon');
'block-content-page-header']) ?>>
-

+ +

+

diff --git a/blocks/content-page-header/src/block.json b/blocks/content-page-header/src/block.json index 0089737..69ece95 100644 --- a/blocks/content-page-header/src/block.json +++ b/blocks/content-page-header/src/block.json @@ -16,6 +16,13 @@ "style": "file:./style-index.css", "render": "file:./render.php", "attributes": { + "hasCustomTitle": { + "type": "boolean", + "default": false + }, + "blockCustomTitle": { + "type": "string" + }, "pageHeaderTitle": { "type": "string" }, diff --git a/blocks/content-page-header/src/edit.js b/blocks/content-page-header/src/edit.js index f60d47f..ee570e6 100644 --- a/blocks/content-page-header/src/edit.js +++ b/blocks/content-page-header/src/edit.js @@ -9,9 +9,16 @@ import { __experimentalLinkControl as LinkControl, } from "@wordpress/block-editor"; import { PanelBody, TextControl, ToggleControl } from "@wordpress/components"; - +import { Tip } from "@wordpress/components"; export default function Edit({ attributes, setAttributes }) { - const { pageHeaderTitle, pageHeaderDescription, hasCta, cta } = attributes; + const { + blockCustomTitle, + hasCustomTitle, + pageHeaderTitle, + pageHeaderDescription, + hasCta, + cta, + } = attributes; const pageTitle = useSelect((select) => { const { getEditedPostAttribute } = select("core/editor"); @@ -26,11 +33,19 @@ export default function Edit({ attributes, setAttributes }) { } }); + function onChangeBlockCustomTitle(blockCustomTitle) { + setAttributes({ blockCustomTitle }); + } function onChangeTitle(newTitle) { setAttributes({ pageHeaderTitle: newTitle }); } + function onChangeHasCustomTitle(newHasAutoTitle) { + setAttributes({ hasCustomTitle: !hasCustomTitle }); + if (newHasAutoTitle) { + setAttributes({ blockCustomTitle: undefined }); + } + } function onChangeHasCta(newHasCta) { - console.log("newHasCta", newHasCta); setAttributes({ hasCta: !hasCta }); if (!newHasCta) { setAttributes({ cta: undefined }); @@ -59,9 +74,25 @@ export default function Edit({ attributes, setAttributes }) { }); } + console.log(blockCustomTitle); return ( <> + + + {!hasCustomTitle && ( + + Le titre est automatiquement généré à partir du titre de la page + + )} +
- {pageTitle &&

{pageTitle}

} + {!hasCustomTitle &&

{pageTitle}

} + {hasCustomTitle && ( + + )} 'block-content-page-header']) ?>>
-

+ +

+