From 9bd887dde8c99b787159e2229cade9f9ceba2cd5 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 23 Oct 2023 16:30:22 +0200 Subject: [PATCH] extending the features --- blocks/monoblock/build/block.json | 19 +++- blocks/monoblock/build/index.asset.php | 2 +- blocks/monoblock/build/index.css | 28 +++-- blocks/monoblock/build/index.css.map | 2 +- blocks/monoblock/build/index.js | 147 +++++++++++++++++++++++-- blocks/monoblock/build/index.js.map | 2 +- blocks/monoblock/src/block.json | 19 +++- blocks/monoblock/src/edit.js | 97 +++++++++++++++- blocks/monoblock/src/editor.scss | 30 +++-- blocks/monoblock/src/save.js | 18 ++- 10 files changed, 330 insertions(+), 34 deletions(-) diff --git a/blocks/monoblock/build/block.json b/blocks/monoblock/build/block.json index 51965fd..539fd5d 100644 --- a/blocks/monoblock/build/block.json +++ b/blocks/monoblock/build/block.json @@ -10,10 +10,25 @@ "html": false }, "parent": [ - "homegrade-content-blocks/grey-box" + "homegrade-content-blocks/content-box" ], "textdomain": "homegrade-blocks", "editorScript": "file:./index.js", "editorStyle": "file:./index.css", - "style": "file:./style-index.css" + "style": "file:./style-index.css", + "attributes": { + "hasIllustration": { + "type": "boolean", + "default": false + }, + "illustrationUrl": { + "type": "string" + }, + "illustrationId": { + "type": "string" + }, + "illustrationAlt": { + "type": "string" + } + } } \ No newline at end of file diff --git a/blocks/monoblock/build/index.asset.php b/blocks/monoblock/build/index.asset.php index 3135610..df3385b 100644 --- a/blocks/monoblock/build/index.asset.php +++ b/blocks/monoblock/build/index.asset.php @@ -1 +1 @@ - array('wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n'), 'version' => 'e5f461877af67f8ad376'); + array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c0251f51b5196af21e3e'); diff --git a/blocks/monoblock/build/index.css b/blocks/monoblock/build/index.css index efb8ea8..b68bd23 100644 --- a/blocks/monoblock/build/index.css +++ b/blocks/monoblock/build/index.css @@ -1,13 +1,27 @@ /*!****************************************************************************************************************************************************************************************************************************************!*\ !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/editor.scss ***! \****************************************************************************************************************************************************************************************************************************************/ -/** - * The following styles get applied inside the editor only. - * - * Replace them with your own styles or remove the file completely. - */ -.wp-block-create-block-multiblocks { - border: 1px dotted #f00; +.homegrade-blocks-box-monoblock__superior-illustration { + max-width: 200px !important; +} + +.homegrade-blocks-box-monoblock__panel-body .components-dropdown .components-toolbar__control { + background-color: #e04d42; + color: white; +} +.homegrade-blocks-box-monoblock__panel-body img { + display: block; +} +.homegrade-blocks-box-monoblock__panel-body .components-dropdown { + display: block; + width: -moz-fit-content; + width: fit-content; +} +.homegrade-blocks-box-monoblock__panel-body .media-replace-container { + padding: 10px 0; + display: flex; + gap: 10px; + align-items: center; } /*# sourceMappingURL=index.css.map*/ \ No newline at end of file diff --git a/blocks/monoblock/build/index.css.map b/blocks/monoblock/build/index.css.map index 8e53675..6ad9132 100644 --- a/blocks/monoblock/build/index.css.map +++ b/blocks/monoblock/build/index.css.map @@ -1 +1 @@ -{"version":3,"file":"index.css","mappings":";;;AAAA;;;;EAAA;AAMA;EACC;AAAD,C","sources":["webpack://multiblocks/./src/editor.scss"],"sourcesContent":["/**\n * The following styles get applied inside the editor only.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.wp-block-create-block-multiblocks {\n\tborder: 1px dotted #f00;\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.css","mappings":";;;AAAA;EACC;AACD;;AAEC;EACC;EACA;AACF;AACC;EACC;AACF;AACC;EACC;EACA;EAAA;AACF;AACC;EACC;EACA;EACA;EACA;AACF,C","sources":["webpack://multiblocks/./src/editor.scss"],"sourcesContent":[".homegrade-blocks-box-monoblock__superior-illustration {\n\tmax-width: 200px !important;\n}\n.homegrade-blocks-box-monoblock__panel-body {\n\t.components-dropdown .components-toolbar__control {\n\t\tbackground-color: #e04d42;\n\t\tcolor: white;\n\t}\n\timg {\n\t\tdisplay: block;\n\t}\n\t.components-dropdown {\n\t\tdisplay: block;\n\t\twidth: fit-content;\n\t}\n\t.media-replace-container {\n\t\tpadding: 10px 0;\n\t\tdisplay: flex;\n\t\tgap: 10px;\n\t\talign-items: center;\n\t\t// margin-top: 10px;\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/monoblock/build/index.js b/blocks/monoblock/build/index.js index bb71c5b..a130189 100644 --- a/blocks/monoblock/build/index.js +++ b/blocks/monoblock/build/index.js @@ -19,6 +19,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); /* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); /* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var _wordpress_icons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/icons */ "../../node_modules/@wordpress/icons/build-module/library/trash.js"); + + + + @@ -29,12 +36,74 @@ function Edit({ setAttributes, ...props }) { - 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)("div", { + let { + hasIllustration, + illustrationId, + illustrationUrl, + illustrationAlt + } = attributes; + function onHasIllustrationChange() { + setAttributes({ + hasIllustration: !hasIllustration + }); + if (!hasIllustration) { + setAttributes({ + illustrationUrl: null, + illustrationId: null, + illustrationAlt: null + }); + } + } + function setIllustrationAttributes(media) { + setAttributes({ + illustrationUrl: media.url, + illustrationId: media.id, + illustrationAlt: media?.alt + }); + } + function removeIllustrationAttributes() { + setAttributes({ + illustrationUrl: null, + illustrationId: null, + illustrationAlt: null + }); + } + return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.PanelBody, { + title: "Illustration", + className: "homegrade-blocks-box-monoblock__panel-body" + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.ToggleControl, { + help: hasIllustration ? "Afficher une illustration" : "Pas d'illustration", + label: "Illustration sup\xE9rieure", + checked: hasIllustration, + onChange: onHasIllustrationChange + }), illustrationUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", { + src: illustrationUrl, + alt: illustrationAlt + }), hasIllustration && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { + className: "media-replace-container " + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.MediaReplaceFlow, { + mediaId: illustrationId, + mediaUrl: illustrationUrl, + allowedTypes: ["image"], + accept: "image/*", + onSelect: setIllustrationAttributes, + name: !illustrationUrl ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ajouter", "homegrade-blocks__texte-backoffice") : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Remplacer", "homegrade-blocks__texte-backoffice") + }), illustrationUrl && (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_components__WEBPACK_IMPORTED_MODULE_4__.Button, { + className: "custom-flow-button", + variant: "primary", + icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_5__["default"], + label: "Supprimer", + onClick: removeIllustrationAttributes + }))))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { ...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.useBlockProps)({ - className: `box-monoblock card-large-content` + className: `box-monoblock card-large-content homegrade-blocks-box-monoblock ${hasIllustration ? "homegrade-blocks-box-monoblock--has-illustration " : ""}` }) - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InnerBlocks, { - allowedBlocks: ["core/paragraph"] + }, hasIllustration && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", { + className: " homegrade-blocks-box-monoblock__superior-illustration", + src: illustrationUrl, + alt: illustrationAlt + }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InnerBlocks, { + allowedBlocks: ["core/paragraph", "homegrade-content-blocks/section-titling"] }))); } @@ -99,12 +168,23 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__); -function save() { +function save({ + attributes +}) { + const { + hasIllustration, + illustrationUrl, + illustrationAlt + } = attributes; return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { ..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps.save({ - className: `box-monoblock card-large-content` + className: `box-monoblock card-large-content homegrade-blocks-box-monoblock ${hasIllustration ? "homegrade-blocks-box-monoblock--has-illustration" : ""}` }) - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks.Content, null)); + }, hasIllustration && illustrationUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", { + className: " homegrade-blocks-box-monoblock__superior-illustration", + src: illustrationUrl, + alt: illustrationAlt + }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks.Content, null)); } /***/ }), @@ -131,6 +211,37 @@ __webpack_require__.r(__webpack_exports__); // extracted by mini-css-extract-plugin +/***/ }), + +/***/ "../../node_modules/@wordpress/icons/build-module/library/trash.js": +/*!*************************************************************************!*\ + !*** ../../node_modules/@wordpress/icons/build-module/library/trash.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/primitives */ "@wordpress/primitives"); +/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); + + +/** + * WordPress dependencies + */ + +const trash = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__.Path, { + d: "M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z" +})); +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (trash); +//# sourceMappingURL=trash.js.map + /***/ }), /***/ "@wordpress/block-editor": @@ -153,6 +264,16 @@ module.exports = window["wp"]["blocks"]; /***/ }), +/***/ "@wordpress/components": +/*!************************************!*\ + !*** external ["wp","components"] ***! + \************************************/ +/***/ ((module) => { + +module.exports = window["wp"]["components"]; + +/***/ }), + /***/ "@wordpress/element": /*!*********************************!*\ !*** external ["wp","element"] ***! @@ -173,13 +294,23 @@ module.exports = window["wp"]["i18n"]; /***/ }), +/***/ "@wordpress/primitives": +/*!************************************!*\ + !*** external ["wp","primitives"] ***! + \************************************/ +/***/ ((module) => { + +module.exports = window["wp"]["primitives"]; + +/***/ }), + /***/ "./src/block.json": /*!************************!*\ !*** ./src/block.json ***! \************************/ /***/ ((module) => { -module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/box-monoblock","version":"0.1.0","title":"Monobloc","category":"homegrade-blocks","description":"Bloc conteneur d\'une seule colonne","supports":{"html":false},"parent":["homegrade-content-blocks/grey-box"],"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css"}'); +module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/box-monoblock","version":"0.1.0","title":"Monobloc","category":"homegrade-blocks","description":"Bloc conteneur d\'une seule colonne","supports":{"html":false},"parent":["homegrade-content-blocks/content-box"],"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","attributes":{"hasIllustration":{"type":"boolean","default":false},"illustrationUrl":{"type":"string"},"illustrationId":{"type":"string"},"illustrationAlt":{"type":"string"}}}'); /***/ }) diff --git a/blocks/monoblock/build/index.js.map b/blocks/monoblock/build/index.js.map index 6c4ab19..52ae4ed 100644 --- a/blocks/monoblock/build/index.js.map +++ b/blocks/monoblock/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;AAAqC;AACd;AAE2C;AACZ;AAEvC,SAASI,IAAIA,CAAC;EAAEC,UAAU;EAAEC,aAAa;EAAE,GAAGC;AAAM,CAAC,EAAE;EACrE,OACCC,iEAAA,CAAAC,wDAAA,QACCD,iEAAA;IAAA,GACKP,sEAAa,CAAC;MACjBS,SAAS,EAAG;IACb,CAAC;EAAC,GAEFF,iEAAA,CAACL,gEAAW;IAACQ,aAAa,EAAE,CAAC,gBAAgB;EAAE,CAAE,CAC7C,CACJ,CAAC;AAEL;;;;;;;;;;;;;;;;;;;;AClBsD;AAChC;AAEI;AACA;AACU;AAEpCC,oEAAiB,CAACE,6CAAa,EAAE;EAChCE,KAAK,EAAEF,8CAAc;EACrBG,IAAI,EAAE;IACLC,UAAU,EAAE,SAAS;IACrBC,GAAG,EACFX,iEAAA;MACCY,OAAO,EAAC,KAAK;MACbC,CAAC,EAAC,KAAK;MACPC,CAAC,EAAC,KAAK;M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A;;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/save.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\",\"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\";\n\nimport { useBlockProps, RichText } from \"@wordpress/block-editor\";\nimport { InnerBlocks } from \"@wordpress/block-editor\";\n\nexport default function Edit({ attributes, setAttributes, ...props }) {\n\treturn (\n\t\t<>\n\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 save from \"./save\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ttitle: metadata.title,\n\ticon: {\n\t\tforeground: \"#DF1E1E\",\n\t\tsrc: (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t},\n\n\tsupports: metadata.supports,\n\tattributes: metadata.attributes,\n\tedit: Edit,\n\tsave,\n});\n","import { useBlockProps, InnerBlocks } from \"@wordpress/block-editor\";\n\nexport default function save() {\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\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\"][\"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":["__","useBlockProps","RichText","InnerBlocks","Edit","attributes","setAttributes","props","createElement","Fragment","className","allowedBlocks","registerBlockType","save","metadata","name","title","icon","foreground","src","version","x","y","viewBox","d","supports","edit","Content"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAqC;AACd;AAE2C;AACZ;AACmB;AACb;AAEnB;AAEkB;AAE5C,SAASU,IAAIA,CAAC;EAAEC,UAAU;EAAEC,aAAa;EAAE,GAAGC;AAAM,CAAC,EAAE;EACrE,IAAI;IAAEC,eAAe;IAAEC,cAAc;IAAEC,eAAe;IAAEC;EAAgB,CAAC,GACxE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;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/save.js","webpack://multiblocks/./src/editor.scss?0339","webpack://multiblocks/./src/style.scss","webpack://multiblocks/../../node_modules/@wordpress/icons/build-module/library/trash.js","webpack://multiblocks/external window [\"wp\",\"blockEditor\"]","webpack://multiblocks/external window [\"wp\",\"blocks\"]","webpack://multiblocks/external window [\"wp\",\"components\"]","webpack://multiblocks/external window [\"wp\",\"element\"]","webpack://multiblocks/external window [\"wp\",\"i18n\"]","webpack://multiblocks/external window [\"wp\",\"primitives\"]","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\";\n\nimport { useBlockProps, RichText } from \"@wordpress/block-editor\";\nimport { InnerBlocks } from \"@wordpress/block-editor\";\nimport { PanelBody, ToggleControl, Button } from \"@wordpress/components\";\nimport { InspectorControls } from \"@wordpress/block-editor\";\n\nimport { trash } from \"@wordpress/icons\";\n\nimport { MediaReplaceFlow } from \"@wordpress/block-editor\";\n\nexport default function Edit({ attributes, setAttributes, ...props }) {\n\tlet { hasIllustration, illustrationId, illustrationUrl, illustrationAlt } =\n\t\tattributes;\n\tfunction onHasIllustrationChange() {\n\t\tsetAttributes({ hasIllustration: !hasIllustration });\n\t\tif (!hasIllustration) {\n\t\t\tsetAttributes({\n\t\t\t\tillustrationUrl: null,\n\t\t\t\tillustrationId: null,\n\t\t\t\tillustrationAlt: null,\n\t\t\t});\n\t\t}\n\t}\n\n\tfunction setIllustrationAttributes(media) {\n\t\tsetAttributes({\n\t\t\tillustrationUrl: media.url,\n\t\t\tillustrationId: media.id,\n\t\t\tillustrationAlt: media?.alt,\n\t\t});\n\t}\n\tfunction removeIllustrationAttributes() {\n\t\tsetAttributes({\n\t\t\tillustrationUrl: null,\n\t\t\tillustrationId: null,\n\t\t\tillustrationAlt: null,\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\t\t\t\t\t{illustrationUrl && (\n\t\t\t\t\t\t{illustrationAlt}\n\t\t\t\t\t)}\n\t\t\t\t\t{hasIllustration && (\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t{illustrationUrl && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\n\t\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{hasIllustration && (\n\t\t\t\t\t\n\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 save from \"./save\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ttitle: metadata.title,\n\ticon: {\n\t\tforeground: \"#DF1E1E\",\n\t\tsrc: (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t},\n\n\tsupports: metadata.supports,\n\tattributes: metadata.attributes,\n\tedit: Edit,\n\tsave,\n});\n","import { useBlockProps, InnerBlocks } from \"@wordpress/block-editor\";\n\nexport default function save({ attributes }) {\n\tconst { hasIllustration, illustrationUrl, illustrationAlt } = attributes;\n\n\treturn (\n\t\t\n\t\t\t{hasIllustration && illustrationUrl && (\n\t\t\t\t\n\t\t\t)}\n\n\t\t\t\n\t\t\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","import { createElement } from \"@wordpress/element\";\n\n/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nconst trash = createElement(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\"\n}, createElement(Path, {\n d: \"M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z\"\n}));\nexport default trash;\n//# sourceMappingURL=trash.js.map","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","// 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":["__","useBlockProps","RichText","InnerBlocks","PanelBody","ToggleControl","Button","InspectorControls","trash","MediaReplaceFlow","Edit","attributes","setAttributes","props","hasIllustration","illustrationId","illustrationUrl","illustrationAlt","onHasIllustrationChange","setIllustrationAttributes","media","url","id","alt","removeIllustrationAttributes","createElement","Fragment","title","className","help","label","checked","onChange","src","mediaId","mediaUrl","allowedTypes","accept","onSelect","name","variant","icon","onClick","allowedBlocks","registerBlockType","save","metadata","foreground","version","x","y","viewBox","d","supports","edit","Content"],"sourceRoot":""} \ No newline at end of file diff --git a/blocks/monoblock/src/block.json b/blocks/monoblock/src/block.json index 87bbb0a..f24db3e 100644 --- a/blocks/monoblock/src/block.json +++ b/blocks/monoblock/src/block.json @@ -10,10 +10,25 @@ "html": false }, "parent": [ - "homegrade-content-blocks/grey-box" + "homegrade-content-blocks/content-box" ], "textdomain": "homegrade-blocks", "editorScript": "file:./index.js", "editorStyle": "file:./index.css", - "style": "file:./style-index.css" + "style": "file:./style-index.css", + "attributes": { + "hasIllustration": { + "type": "boolean", + "default": false + }, + "illustrationUrl": { + "type": "string" + }, + "illustrationId": { + "type": "string" + }, + "illustrationAlt": { + "type": "string" + } + } } \ No newline at end of file diff --git a/blocks/monoblock/src/edit.js b/blocks/monoblock/src/edit.js index 4f7f6d5..58d34ab 100644 --- a/blocks/monoblock/src/edit.js +++ b/blocks/monoblock/src/edit.js @@ -3,16 +3,109 @@ import "./editor.scss"; import { useBlockProps, RichText } from "@wordpress/block-editor"; import { InnerBlocks } from "@wordpress/block-editor"; +import { PanelBody, ToggleControl, Button } from "@wordpress/components"; +import { InspectorControls } from "@wordpress/block-editor"; + +import { trash } from "@wordpress/icons"; + +import { MediaReplaceFlow } from "@wordpress/block-editor"; export default function Edit({ attributes, setAttributes, ...props }) { + let { hasIllustration, illustrationId, illustrationUrl, illustrationAlt } = + attributes; + function onHasIllustrationChange() { + setAttributes({ hasIllustration: !hasIllustration }); + if (!hasIllustration) { + removeIllustrationAttributes(); + } + } + + function setIllustrationAttributes(media) { + setAttributes({ + illustrationUrl: media.url, + illustrationId: media.id, + illustrationAlt: media?.alt, + }); + } + function removeIllustrationAttributes() { + setAttributes({ + illustrationUrl: null, + illustrationId: null, + illustrationAlt: null, + }); + } + return ( <> + + + + {illustrationUrl && ( + {illustrationAlt} + )} + {hasIllustration && ( +
+ + {illustrationUrl && ( + <> +
+ )} +
+
- + {hasIllustration && ( + {illustrationAlt} + )} +
); diff --git a/blocks/monoblock/src/editor.scss b/blocks/monoblock/src/editor.scss index 0ba9f21..7444021 100644 --- a/blocks/monoblock/src/editor.scss +++ b/blocks/monoblock/src/editor.scss @@ -1,9 +1,23 @@ -/** - * The following styles get applied inside the editor only. - * - * Replace them with your own styles or remove the file completely. - */ - -.wp-block-create-block-multiblocks { - border: 1px dotted #f00; +.homegrade-blocks-box-monoblock__superior-illustration { + max-width: 200px !important; +} +.homegrade-blocks-box-monoblock__panel-body { + .components-dropdown .components-toolbar__control { + background-color: #e04d42; + color: white; + } + img { + display: block; + } + .components-dropdown { + display: block; + width: fit-content; + } + .media-replace-container { + padding: 10px 0; + display: flex; + gap: 10px; + align-items: center; + // margin-top: 10px; + } } diff --git a/blocks/monoblock/src/save.js b/blocks/monoblock/src/save.js index 75d5a91..377c1e2 100644 --- a/blocks/monoblock/src/save.js +++ b/blocks/monoblock/src/save.js @@ -1,12 +1,26 @@ import { useBlockProps, InnerBlocks } from "@wordpress/block-editor"; -export default function save() { +export default function save({ attributes }) { + const { hasIllustration, illustrationUrl, illustrationAlt } = attributes; + return (
+ {hasIllustration && illustrationUrl && ( + {illustrationAlt} + )} +
);