From dea39d7219cfa0a697d5cbc89a0426c1c296b7ff Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 3 Jul 2024 15:27:37 +0200 Subject: [PATCH] handling tooltip words used --- .../post-content-container/build/block.json | 4 ++ .../build/index.asset.php | 2 +- blocks/post-content-container/build/index.js | 71 +++++++++++++++++-- .../post-content-container/build/index.js.map | 2 +- .../post-content-container/build/render.php | 23 +++--- blocks/post-content-container/src/block.json | 4 ++ blocks/post-content-container/src/edit.js | 39 ++++++++++ blocks/post-content-container/src/index.js | 2 + blocks/post-content-container/src/render.php | 23 +++--- blocks/post-content-container/src/save.js | 15 ++++ 10 files changed, 156 insertions(+), 29 deletions(-) create mode 100644 blocks/post-content-container/src/save.js diff --git a/blocks/post-content-container/build/block.json b/blocks/post-content-container/build/block.json index d6a66aa..c7d9f68 100644 --- a/blocks/post-content-container/build/block.json +++ b/blocks/post-content-container/build/block.json @@ -30,6 +30,10 @@ }, "anchor": { "type": "string" + }, + "tooltipsWordsUsed": { + "type": "array", + "default": [] } } } \ No newline at end of file diff --git a/blocks/post-content-container/build/index.asset.php b/blocks/post-content-container/build/index.asset.php index a784b83..b110632 100644 --- a/blocks/post-content-container/build/index.asset.php +++ b/blocks/post-content-container/build/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '3034e2cd7814cf68cba4'); + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '548c237f02dcdec27f46'); diff --git a/blocks/post-content-container/build/index.js b/blocks/post-content-container/build/index.js index 84fc914..78f69ee 100644 --- a/blocks/post-content-container/build/index.js +++ b/blocks/post-content-container/build/index.js @@ -176,7 +176,37 @@ function Edit({ relatedPostId, postType } = attributes; + function parseBlockContentForTooltips(editorContent) { + const parser = new DOMParser(); + const doc = parser.parseFromString(editorContent, "text/html"); + const domTooltipWords = doc.querySelectorAll(".tooltip-word"); + const filteredTooltipWords = []; + + // Looping over tooltip words and filtering duplicates + Array.from(domTooltipWords).forEach(tooltipWord => { + const tooltipID = tooltipWord.getAttribute("data-definition-id"); + const tooltipText = tooltipWord.getAttribute("data-tooltip-word"); + const tooltipDefinition = tooltipWord.getAttribute("data-tooltip-definition"); + const existingTooltip = filteredTooltipWords.find(item => item.tooltipID === tooltipID); + if (!existingTooltip) { + filteredTooltipWords.push({ + tooltipID, + tooltipText, + tooltipDefinition + }); + } + }); + return filteredTooltipWords; + } let currentRelatedPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => relatedPostId && postType ? select("core").getEntityRecord("postType", postType, relatedPostId) : null, [relatedPostId, postType]); + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.useEffect)(() => { + if (currentRelatedPost) { + const currentBlockTooltips = parseBlockContentForTooltips(currentRelatedPost.content.rendered); + setAttributes({ + tooltipsWordsUsed: currentBlockTooltips + }); + } + }, [currentRelatedPost]); 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"], { relatedPostId: relatedPostId, postType: postType, @@ -203,15 +233,17 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss"); /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edit */ "./src/edit.js"); -/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./block.json */ "./src/block.json"); -/* harmony import */ var _transforms__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transforms */ "./src/transforms.js"); +/* harmony import */ var _save__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./save */ "./src/save.js"); +/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./block.json */ "./src/block.json"); +/* harmony import */ var _transforms__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./transforms */ "./src/transforms.js"); -(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_4__.name, { + +(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_5__.name, { icon: { src: (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", { xmlns: "http://www.w3.org/2000/svg", @@ -228,11 +260,40 @@ __webpack_require__.r(__webpack_exports__); foreground: "#DF1E1E" }, edit: _edit__WEBPACK_IMPORTED_MODULE_3__["default"], - transforms: _transforms__WEBPACK_IMPORTED_MODULE_5__["default"] + save: _save__WEBPACK_IMPORTED_MODULE_4__["default"], + transforms: _transforms__WEBPACK_IMPORTED_MODULE_6__["default"] }); /***/ }), +/***/ "./src/save.js": +/*!*********************!*\ + !*** ./src/save.js ***! + \*********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ save) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); +/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); + + + +function save({ + attributes, + setAttributes +}) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dignissimos reiciendis officiis molestias nostrum necessitatibus, explicabo culpa assumenda quod sit facere. Ullam vitae dignissimos quasi ea amet nisi rerum omnis saepe!")); +} + +/***/ }), + /***/ "./src/transforms.js": /*!***************************!*\ !*** ./src/transforms.js ***! @@ -383,7 +444,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-content-container","version":"0.1.0","title":"Post Container","category":"homegrade-blocks","icon":{"background":"#fff","foreground":"#DF1E1E","src":"feedback"},"description":"Pour intégrer le contenu d\'une page ou d\'un post type","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":"questions"},"anchor":{"type":"string"}}}'); +module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/post-content-container","version":"0.1.0","title":"Post Container","category":"homegrade-blocks","icon":{"background":"#fff","foreground":"#DF1E1E","src":"feedback"},"description":"Pour intégrer le contenu d\'une page ou d\'un post type","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":"questions"},"anchor":{"type":"string"},"tooltipsWordsUsed":{"type":"array","default":[]}}}'); /***/ }) diff --git a/blocks/post-content-container/build/index.js.map b/blocks/post-content-container/build/index.js.map index cc2f822..b93e7c6 100644 --- a/blocks/post-content-container/build/index.js.map +++ b/blocks/post-content-container/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,GACz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AeZ,UAAU;;;;;;;;;;;AC3BzB;;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;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,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/transforms.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\",\"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\nexport default function Edit({ attributes, setAttributes }) {\n\tconst { relatedPostId, postType } = attributes;\n\n\tlet 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\treturn (\n\t\t<>\n\t\t\t\n\n\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é à aucune question. Rattachez-le à une fiche question 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\n\t\t\t\t{currentRelatedPost &&\n\t\t\t\t\tcurrentRelatedPost.content &&\n\t\t\t\t\tcurrentRelatedPost.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\t{currentRelatedPost.content.rendered}\n\t\t\t\t\t\t\n\t\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\";\nimport transforms from \"./transforms\";\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\ttransforms: transforms,\n});\n","import { createBlock } from \"@wordpress/blocks\";\r\n\r\nconst transforms = {\r\n\tto: [\r\n\t\t/* supported to transforms */\r\n\t],\r\n\tfrom: [\r\n\t\t{\r\n\t\t\ttype: \"block\",\r\n\t\t\tblocks: [\"homegrade-content-blocks/questions-container\"],\r\n\t\t\ttransform: ({ relatedPostId }) => {\r\n\t\t\t\treturn createBlock(\"homegrade-content-blocks/post-content-container\", {\r\n\t\t\t\t\trelatedPostId,\r\n\t\t\t\t\tpostType: \"questions\",\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t},\r\n\t\t{\r\n\t\t\ttype: \"block\",\r\n\t\t\tblocks: [\"core/paragraph\"],\r\n\t\t\ttransform: () => {\r\n\t\t\t\treturn createBlock(\"homegrade-content-blocks/post-content-container\");\r\n\t\t\t},\r\n\t\t},\r\n\t],\r\n};\r\n\r\nexport default transforms;\r\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\"][\"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","Edit","attributes","currentRelatedPost","getEntityRecord","Fragment","content","registerBlockType","metadata","transforms","name","icon","src","xmlns","width","height","viewBox","class","d","foreground","edit","createBlock","to","from","type","blocks","transform"],"sourceRoot":""} \ No newline at end of file +{"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,SAA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C;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/save.js","webpack://multiblocks/./src/transforms.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\",\"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\nexport default function Edit({ attributes, setAttributes }) {\n\tconst { relatedPostId, postType } = attributes;\n\n\tfunction parseBlockContentForTooltips(editorContent) {\n\t\tconst parser = new DOMParser();\n\t\tconst doc = parser.parseFromString(editorContent, \"text/html\");\n\t\tconst domTooltipWords = doc.querySelectorAll(\".tooltip-word\");\n\n\t\tconst filteredTooltipWords = [];\n\n\t\t// Looping over tooltip words and filtering duplicates\n\t\tArray.from(domTooltipWords).forEach((tooltipWord) => {\n\t\t\tconst tooltipID = tooltipWord.getAttribute(\"data-definition-id\");\n\t\t\tconst tooltipText = tooltipWord.getAttribute(\"data-tooltip-word\");\n\t\t\tconst tooltipDefinition = tooltipWord.getAttribute(\n\t\t\t\t\"data-tooltip-definition\",\n\t\t\t);\n\n\t\t\tconst existingTooltip = filteredTooltipWords.find(\n\t\t\t\t(item) => item.tooltipID === tooltipID,\n\t\t\t);\n\n\t\t\tif (!existingTooltip) {\n\t\t\t\tfilteredTooltipWords.push({\n\t\t\t\t\ttooltipID,\n\t\t\t\t\ttooltipText,\n\t\t\t\t\ttooltipDefinition,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\treturn filteredTooltipWords;\n\t}\n\n\tlet 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\tuseEffect(() => {\n\t\tif (currentRelatedPost) {\n\t\t\tconst currentBlockTooltips = parseBlockContentForTooltips(\n\t\t\t\tcurrentRelatedPost.content.rendered,\n\t\t\t);\n\t\t\tsetAttributes({ tooltipsWordsUsed: currentBlockTooltips });\n\t\t}\n\t}, [currentRelatedPost]);\n\n\treturn (\n\t\t<>\n\t\t\t\n\n\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é à aucune question. Rattachez-le à une fiche question 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\n\t\t\t\t{currentRelatedPost &&\n\t\t\t\t\tcurrentRelatedPost.content &&\n\t\t\t\t\tcurrentRelatedPost.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\t{currentRelatedPost.content.rendered}\n\t\t\t\t\t\t\n\t\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 save from \"./save\";\nimport metadata from \"./block.json\";\nimport transforms from \"./transforms\";\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\tsave,\n\ttransforms: transforms,\n});\n","import { useBlockProps, RichText, InnerBlocks } from \"@wordpress/block-editor\";\r\nimport { __ } from \"@wordpress/i18n\";\r\n\r\nexport default function save({ attributes, setAttributes }) {\r\n\treturn (\r\n\t\t<>\r\n\t\t\t

\r\n\t\t\t\tLorem, ipsum dolor sit amet consectetur adipisicing elit. Dignissimos\r\n\t\t\t\treiciendis officiis molestias nostrum necessitatibus, explicabo culpa\r\n\t\t\t\tassumenda quod sit facere. Ullam vitae dignissimos quasi ea amet nisi\r\n\t\t\t\trerum omnis saepe!\r\n\t\t\t

\r\n\t\t\r\n\t);\r\n}\r\n","import { createBlock } from \"@wordpress/blocks\";\r\n\r\nconst transforms = {\r\n\tto: [\r\n\t\t/* supported to transforms */\r\n\t],\r\n\tfrom: [\r\n\t\t{\r\n\t\t\ttype: \"block\",\r\n\t\t\tblocks: [\"homegrade-content-blocks/questions-container\"],\r\n\t\t\ttransform: ({ relatedPostId }) => {\r\n\t\t\t\treturn createBlock(\"homegrade-content-blocks/post-content-container\", {\r\n\t\t\t\t\trelatedPostId,\r\n\t\t\t\t\tpostType: \"questions\",\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t},\r\n\t\t{\r\n\t\t\ttype: \"block\",\r\n\t\t\tblocks: [\"core/paragraph\"],\r\n\t\t\ttransform: () => {\r\n\t\t\t\treturn createBlock(\"homegrade-content-blocks/post-content-container\");\r\n\t\t\t},\r\n\t\t},\r\n\t],\r\n};\r\n\r\nexport default transforms;\r\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\"][\"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","Edit","attributes","parseBlockContentForTooltips","editorContent","parser","DOMParser","doc","parseFromString","domTooltipWords","querySelectorAll","filteredTooltipWords","Array","from","tooltipWord","tooltipID","getAttribute","tooltipText","tooltipDefinition","existingTooltip","find","item","currentRelatedPost","getEntityRecord","currentBlockTooltips","content","tooltipsWordsUsed","Fragment","registerBlockType","save","metadata","transforms","name","icon","src","xmlns","width","height","viewBox","class","d","foreground","edit","RichText","InnerBlocks","createBlock","to","type","blocks","transform"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/post-content-container/build/render.php b/blocks/post-content-container/build/render.php index 82583a2..9a30cf5 100644 --- a/blocks/post-content-container/build/render.php +++ b/blocks/post-content-container/build/render.php @@ -9,21 +9,22 @@ $anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_ht $anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : ''); $content = get_the_content(null, null, $relatedPost); -if ($relatedPost) { - // Temporarily set up the global post variable so the_content works as expected - global $post; - $post = $relatedPost; - setup_postdata($post); +// if ($relatedPost) { +// // Temporarily set up the global post variable so the_content works as expected +// global $post; +// $post = $relatedPost; +// setup_postdata($post); - ob_start(); - the_content(); - $content = ob_get_clean(); - wp_reset_postdata(); -} +// ob_start(); +// the_content(); +// $content = ob_get_clean(); +// wp_reset_postdata(); +// } ?>
">

post_title ?>

- + + post_content ?>
\ No newline at end of file diff --git a/blocks/post-content-container/src/block.json b/blocks/post-content-container/src/block.json index 6abfa0b..f671cbf 100644 --- a/blocks/post-content-container/src/block.json +++ b/blocks/post-content-container/src/block.json @@ -30,6 +30,10 @@ }, "anchor": { "type": "string" + }, + "tooltipsWordsUsed": { + "type": "array", + "default": [] } } } \ No newline at end of file diff --git a/blocks/post-content-container/src/edit.js b/blocks/post-content-container/src/edit.js index 8365701..4ca17eb 100644 --- a/blocks/post-content-container/src/edit.js +++ b/blocks/post-content-container/src/edit.js @@ -11,6 +11,36 @@ import OptionsSelectControl from "./OptionsSelectControl"; export default function Edit({ attributes, setAttributes }) { const { relatedPostId, postType } = attributes; + function parseBlockContentForTooltips(editorContent) { + const parser = new DOMParser(); + const doc = parser.parseFromString(editorContent, "text/html"); + const domTooltipWords = doc.querySelectorAll(".tooltip-word"); + + const filteredTooltipWords = []; + + // Looping over tooltip words and filtering duplicates + Array.from(domTooltipWords).forEach((tooltipWord) => { + const tooltipID = tooltipWord.getAttribute("data-definition-id"); + const tooltipText = tooltipWord.getAttribute("data-tooltip-word"); + const tooltipDefinition = tooltipWord.getAttribute( + "data-tooltip-definition", + ); + + const existingTooltip = filteredTooltipWords.find( + (item) => item.tooltipID === tooltipID, + ); + + if (!existingTooltip) { + filteredTooltipWords.push({ + tooltipID, + tooltipText, + tooltipDefinition, + }); + } + }); + return filteredTooltipWords; + } + let currentRelatedPost = useSelect( (select) => relatedPostId && postType @@ -19,6 +49,15 @@ export default function Edit({ attributes, setAttributes }) { [relatedPostId, postType], ); + useEffect(() => { + if (currentRelatedPost) { + const currentBlockTooltips = parseBlockContentForTooltips( + currentRelatedPost.content.rendered, + ); + setAttributes({ tooltipsWordsUsed: currentBlockTooltips }); + } + }, [currentRelatedPost]); + return ( <>
">

post_title ?>

- + + post_content ?>
\ No newline at end of file diff --git a/blocks/post-content-container/src/save.js b/blocks/post-content-container/src/save.js new file mode 100644 index 0000000..749a979 --- /dev/null +++ b/blocks/post-content-container/src/save.js @@ -0,0 +1,15 @@ +import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor"; +import { __ } from "@wordpress/i18n"; + +export default function save({ attributes, setAttributes }) { + return ( + <> +

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dignissimos + reiciendis officiis molestias nostrum necessitatibus, explicabo culpa + assumenda quod sit facere. Ullam vitae dignissimos quasi ea amet nisi + rerum omnis saepe! +

+ + ); +}