diff --git a/blocks/post-content-container/build/block.json b/blocks/post-content-container/build/block.json index c7d9f68..43d2c2b 100644 --- a/blocks/post-content-container/build/block.json +++ b/blocks/post-content-container/build/block.json @@ -24,6 +24,10 @@ "relatedPostId": { "type": "number" }, + "relatedPostPreviewGhostContent": { + "type": "string", + "default": "" + }, "postType": { "type": "string", "default": "questions" diff --git a/blocks/post-content-container/build/index.asset.php b/blocks/post-content-container/build/index.asset.php index b110632..40484f5 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' => '548c237f02dcdec27f46'); + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'f8adefcd282fd42751be'); diff --git a/blocks/post-content-container/build/index.js b/blocks/post-content-container/build/index.js index 78f69ee..3c78e5c 100644 --- a/blocks/post-content-container/build/index.js +++ b/blocks/post-content-container/build/index.js @@ -174,8 +174,25 @@ function Edit({ }) { const { relatedPostId, - postType + postType, + relatedPostPreviewGhostContent } = attributes; + let currentRelatedPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => relatedPostId && postType ? select("core").getEntityRecord("postType", postType, relatedPostId) : null, [relatedPostId, postType]); + + // console.log("relatedPostPreviewGhostContent", relatedPostPreviewGhostContent); + + // useEffect(() => { + // if (currentRelatedPost?.content?.rendered) { + // setAttributes({ + // relatedPostPreviewGhostContent: currentRelatedPost.content.rendered, + // }); + // } else { + // setAttributes({ + // relatedPostPreviewGhostContent: null, + // }); + // } + // }, [currentRelatedPost]); + function parseBlockContentForTooltips(editorContent) { const parser = new DOMParser(); const doc = parser.parseFromString(editorContent, "text/html"); @@ -198,7 +215,6 @@ function Edit({ }); 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); @@ -260,7 +276,7 @@ __webpack_require__.r(__webpack_exports__); foreground: "#DF1E1E" }, edit: _edit__WEBPACK_IMPORTED_MODULE_3__["default"], - save: _save__WEBPACK_IMPORTED_MODULE_4__["default"], + // save, transforms: _transforms__WEBPACK_IMPORTED_MODULE_6__["default"] }); @@ -289,7 +305,11 @@ 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!")); + const { + relatedPostPreviewGhostContent + } = attributes; + if (!relatedPostPreviewGhostContent) return null; + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, relatedPostPreviewGhostContent); } /***/ }), @@ -444,7 +464,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"},"tooltipsWordsUsed":{"type":"array","default":[]}}}'); +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"},"relatedPostPreviewGhostContent":{"type":"string","default":""},"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 b93e7c6..67d61c1 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,CAA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ACA;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 +{"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,CAACC,MAAM;MAC5BC,OAAO,GAAGH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E;EACD,CAAC;AAEH,CAAC;AAED,iEAAed,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/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, relatedPostPreviewGhostContent } =\n\t\tattributes;\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\t// console.log(\"relatedPostPreviewGhostContent\", relatedPostPreviewGhostContent);\n\n\t// useEffect(() => {\n\t// \tif (currentRelatedPost?.content?.rendered) {\n\t// \t\tsetAttributes({\n\t// \t\t\trelatedPostPreviewGhostContent: currentRelatedPost.content.rendered,\n\t// \t\t});\n\t// \t} else {\n\t// \t\tsetAttributes({\n\t// \t\t\trelatedPostPreviewGhostContent: null,\n\t// \t\t});\n\t// \t}\n\t// }, [currentRelatedPost]);\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\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\t// save,\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\tconst { relatedPostPreviewGhostContent } = attributes;\r\n\tif (!relatedPostPreviewGhostContent) return null;\r\n\r\n\treturn <>{relatedPostPreviewGhostContent};\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","relatedPostPreviewGhostContent","currentRelatedPost","getEntityRecord","parseBlockContentForTooltips","editorContent","parser","DOMParser","doc","parseFromString","domTooltipWords","querySelectorAll","filteredTooltipWords","Array","from","tooltipWord","tooltipID","getAttribute","tooltipText","tooltipDefinition","existingTooltip","find","item","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 9a30cf5..82583a2 100644 --- a/blocks/post-content-container/build/render.php +++ b/blocks/post-content-container/build/render.php @@ -9,22 +9,21 @@ $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 f671cbf..ae54f86 100644 --- a/blocks/post-content-container/src/block.json +++ b/blocks/post-content-container/src/block.json @@ -24,6 +24,10 @@ "relatedPostId": { "type": "number" }, + "relatedPostPreviewGhostContent": { + "type": "string", + "default": "" + }, "postType": { "type": "string", "default": "questions" diff --git a/blocks/post-content-container/src/edit.js b/blocks/post-content-container/src/edit.js index 4ca17eb..81e0a7b 100644 --- a/blocks/post-content-container/src/edit.js +++ b/blocks/post-content-container/src/edit.js @@ -9,7 +9,29 @@ import { decodeEntities } from "@wordpress/html-entities"; import OptionsSelectControl from "./OptionsSelectControl"; export default function Edit({ attributes, setAttributes }) { - const { relatedPostId, postType } = attributes; + const { relatedPostId, postType, relatedPostPreviewGhostContent } = + attributes; + let currentRelatedPost = useSelect( + (select) => + relatedPostId && postType + ? select("core").getEntityRecord("postType", postType, relatedPostId) + : null, + [relatedPostId, postType], + ); + + // console.log("relatedPostPreviewGhostContent", relatedPostPreviewGhostContent); + + // useEffect(() => { + // if (currentRelatedPost?.content?.rendered) { + // setAttributes({ + // relatedPostPreviewGhostContent: currentRelatedPost.content.rendered, + // }); + // } else { + // setAttributes({ + // relatedPostPreviewGhostContent: null, + // }); + // } + // }, [currentRelatedPost]); function parseBlockContentForTooltips(editorContent) { const parser = new DOMParser(); @@ -41,14 +63,6 @@ export default function Edit({ attributes, setAttributes }) { return filteredTooltipWords; } - let currentRelatedPost = useSelect( - (select) => - relatedPostId && postType - ? select("core").getEntityRecord("postType", postType, relatedPostId) - : null, - [relatedPostId, postType], - ); - useEffect(() => { if (currentRelatedPost) { const currentBlockTooltips = parseBlockContentForTooltips( diff --git a/blocks/post-content-container/src/index.js b/blocks/post-content-container/src/index.js index 5270698..e654980 100644 --- a/blocks/post-content-container/src/index.js +++ b/blocks/post-content-container/src/index.js @@ -28,6 +28,6 @@ registerBlockType(metadata.name, { }, edit: Edit, - save, + // save, transforms: transforms, }); diff --git a/blocks/post-content-container/src/render.php b/blocks/post-content-container/src/render.php index 9a30cf5..82583a2 100644 --- a/blocks/post-content-container/src/render.php +++ b/blocks/post-content-container/src/render.php @@ -9,22 +9,21 @@ $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/save.js b/blocks/post-content-container/src/save.js index 749a979..51b9e19 100644 --- a/blocks/post-content-container/src/save.js +++ b/blocks/post-content-container/src/save.js @@ -2,14 +2,8 @@ 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! -

- - ); + const { relatedPostPreviewGhostContent } = attributes; + if (!relatedPostPreviewGhostContent) return null; + + return <>{relatedPostPreviewGhostContent}; }