adding feature to handle vocabulary form inner nested question container
|
|
@ -16,7 +16,6 @@ import { ToolbarButton, ToggleControl, PanelBody } from "@wordpress/components";
|
|||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const { title, iconName, hasTitle } = attributes;
|
||||
|
||||
const handleIconChange = (newIconName) => {
|
||||
setAttributes({ iconName: newIconName });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import save from "./save";
|
|||
import metadata from "./block.json";
|
||||
|
||||
registerBlockType(metadata.name, {
|
||||
|
||||
icon: {
|
||||
src: (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
|
|
|
|||
18
blocks/plus-loin/.editorconfig
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
# WordPress Coding Standards
|
||||
# https://make.wordpress.org/core/handbook/coding-standards/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = tab
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
30
blocks/plus-loin/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Output of `npm pack`
|
||||
*.tgz
|
||||
|
||||
# Output of `wp-scripts plugin-zip`
|
||||
*.zip
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
31
blocks/plus-loin/build/block.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 2,
|
||||
"name": "homegrade-content-blocks/highlight",
|
||||
"version": "0.1.0",
|
||||
"title": "Mise en avant",
|
||||
"category": "homegrade-blocks",
|
||||
"description": "Bloc pour mettre en avant des informations importantes",
|
||||
"supports": {
|
||||
"html": false
|
||||
},
|
||||
"textdomain": "homegrade-blocks__texte-fonctionnel",
|
||||
"editorScript": "file:./index.js",
|
||||
"editorStyle": "file:./index.css",
|
||||
"style": "file:./style-index.css",
|
||||
"attributes": {
|
||||
"title": {
|
||||
"type": "string",
|
||||
"source": "html",
|
||||
"selector": "h3"
|
||||
},
|
||||
"iconName": {
|
||||
"type": "string",
|
||||
"default": "key"
|
||||
},
|
||||
"hasTitle": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
}
|
||||
1
blocks/plus-loin/build/index.asset.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'd1752e8f3a4f050f9e8a');
|
||||
24
blocks/plus-loin/build/index.css
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*!****************************************************************************************************************************************************************************************************************************************!*\
|
||||
!*** 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.
|
||||
*/
|
||||
.homegrade-blocks-highlight ul li {
|
||||
display: flex;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.homegrade-blocks-highlight ul li:before {
|
||||
transform: translateY(6px);
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
content: "";
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=index.css.map*/
|
||||
1
blocks/plus-loin/build/index.css.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.css","mappings":";;;AAAA;;;;EAAA;AAQE;EAEC;EACA;AAHH;AAKE;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAHH,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.homegrade-blocks-highlight {\n\tul {\n\t\tli {\n\t\t\t// list-style: none !important;\n\t\t\tdisplay: flex;\n\t\t\tpadding: 10px 0;\n\t\t}\n\t\tli:before {\n\t\t\ttransform: translateY(6px);\n\t\t\tflex-shrink: 0;\n\t\t\tborder-radius: 50%;\n\t\t\tcontent: \"\";\n\t\t\twidth: 10px;\n\t\t\theight: 10px;\n\t\t\tdisplay: inline-block;\n\t\t\tmargin-right: 10px;\n\t\t}\n\t}\n}\n"],"names":[],"sourceRoot":""}
|
||||
683
blocks/plus-loin/build/index.js
Normal file
|
|
@ -0,0 +1,683 @@
|
|||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./src/img/icon_block_chain.svg":
|
||||
/*!**************************************!*\
|
||||
!*** ./src/img/icon_block_chain.svg ***!
|
||||
\**************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ ReactComponent: () => (/* binding */ SvgIconBlockChain),
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* 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__);
|
||||
var _g;
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
var SvgIconBlockChain = function SvgIconBlockChain(props) {
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
width: 16.012,
|
||||
height: 15.999
|
||||
}, props), _g || (_g = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", {
|
||||
"data-name": "Icon feather-link",
|
||||
fill: "none",
|
||||
stroke: "#fff",
|
||||
strokeLinecap: "round",
|
||||
strokeLinejoin: "round",
|
||||
strokeWidth: 2
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
"data-name": "Trac\\xE9 18559",
|
||||
d: "M6.605 8.7a3.5 3.5 0 0 0 5.28.378l2.1-2.1a3.5 3.5 0 1 0-4.95-4.952l-1.2 1.2"
|
||||
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
"data-name": "Trac\\xE9 18560",
|
||||
d: "M9.407 7.303a3.5 3.5 0 0 0-5.28-.378l-2.1 2.1a3.5 3.5 0 1 0 4.95 4.948l1.2-1.2"
|
||||
}))));
|
||||
};
|
||||
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNi4wMTIiIGhlaWdodD0iMTUuOTk5IiB2aWV3Qm94PSIwIDAgMTYuMDEyIDE1Ljk5OSI+CiAgPGcgaWQ9Ikljb25fZmVhdGhlci1saW5rIiBkYXRhLW5hbWU9Ikljb24gZmVhdGhlci1saW5rIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMS45OTMgLTIuMDA3KSI+CiAgICA8cGF0aCBpZD0iVHJhY8OpXzE4NTU5IiBkYXRhLW5hbWU9IlRyYWPDqSAxODU1OSIgZD0iTTE1LDEwLjcwN2EzLjUsMy41LDAsMCwwLDUuMjguMzc4bDIuMS0yLjFBMy41LDMuNSwwLDEsMCwxNy40Myw0LjAzM2wtMS4yLDEuMiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTYuNDAyIDApIiBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIi8+CiAgICA8cGF0aCBpZD0iVHJhY8OpXzE4NTYwIiBkYXRhLW5hbWU9IlRyYWPDqSAxODU2MCIgZD0iTTExLjQsMTQuOWEzLjUsMy41LDAsMCwwLTUuMjgtLjM3OGwtMi4xLDIuMUEzLjUsMy41LDAsMSwwLDguOTcsMjEuNTdsMS4yLTEuMiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCAtNS41OSkiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjIiLz4KICA8L2c+Cjwvc3ZnPgo=");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/img/icon_bulb.svg":
|
||||
/*!*******************************!*\
|
||||
!*** ./src/img/icon_bulb.svg ***!
|
||||
\*******************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ ReactComponent: () => (/* binding */ SvgIconBulb),
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* 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__);
|
||||
var _g;
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
var SvgIconBulb = function SvgIconBulb(props) {
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
width: 13.098,
|
||||
height: 18.409
|
||||
}, props), _g || (_g = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", {
|
||||
"data-name": "Groupe 3209",
|
||||
fill: "none",
|
||||
strokeLinecap: "round"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", {
|
||||
"data-name": "Union 18",
|
||||
strokeLinejoin: "round"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
d: "M4.447 14.845a1 1 0 0 1-1-1v-1.787A6.392 6.392 0 0 1 0 6.411 6.481 6.481 0 0 1 6.549 0 6.481 6.481 0 0 1 13.1 6.411a6.393 6.393 0 0 1-3.447 5.647v1.787a1 1 0 0 1-1 1Z"
|
||||
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
d: "M7.65 12.845v-.787a2 2 0 0 1 1.068-1.769c1.468-.774 2.38-2.26 2.38-3.878C11.098 3.979 9.058 2 6.549 2 4.041 2 2 3.979 2 6.41c0 1.619.912 3.105 2.38 3.879a2 2 0 0 1 1.067 1.769v.787h2.204m1 2H4.447a1 1 0 0 1-1-1v-1.787C1.395 10.976 0 8.853 0 6.411 0 2.87 2.932 0 6.55 0c3.615 0 6.548 2.87 6.548 6.41 0 2.443-1.395 4.566-3.447 5.648v1.788a1 1 0 0 1-1 1Z",
|
||||
fill: "#fff"
|
||||
})), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
"data-name": "Ligne 3197",
|
||||
stroke: "#fff",
|
||||
strokeWidth: 2,
|
||||
d: "M4.096 17.409h4.779"
|
||||
}))));
|
||||
};
|
||||
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMy4wOTgiIGhlaWdodD0iMTguNDA5IiB2aWV3Qm94PSIwIDAgMTMuMDk4IDE4LjQwOSI+CiAgPGcgaWQ9Ikdyb3VwZV8zMjA5IiBkYXRhLW5hbWU9Ikdyb3VwZSAzMjA5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTkzIC00ODEwKSI+CiAgICA8ZyBpZD0iVW5pb25fMTgiIGRhdGEtbmFtZT0iVW5pb24gMTgiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDE5MyA0ODEwKSIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj4KICAgICAgPHBhdGggZD0iTTQuNDQ3LDE0Ljg0NWExLDEsMCwwLDEtMS0xVjEyLjA1OEE2LjM5Miw2LjM5MiwwLDAsMSwwLDYuNDExLDYuNDgxLDYuNDgxLDAsMCwxLDYuNTQ5LDAsNi40ODEsNi40ODEsMCwwLDEsMTMuMSw2LjQxMWE2LjM5Myw2LjM5MywwLDAsMS0zLjQ0Nyw1LjY0N3YxLjc4N2ExLDEsMCwwLDEtMSwxWiIgc3Ryb2tlPSJub25lIi8+CiAgICAgIDxwYXRoIGQ9Ik0gNy42NTA3MDAwOTIzMTU2NzQgMTIuODQ1NDk5OTkyMzcwNjEgTCA3LjY1MDcwMDA5MjMxNTY3NCAxMi4wNTgxMTk3NzM4NjQ3NSBDIDcuNjUwNzAwMDkyMzE1Njc0IDExLjMxNjIyMDI4MzUwODMgOC4wNjEzODAzODYzNTI1MzkgMTAuNjM1Mjc5NjU1NDU2NTQgOC43MTc1Nzk4NDE2MTM3NyAxMC4yODkxMzk3NDc2MTk2MyBDIDEwLjE4NTY4OTkyNjE0NzQ2IDkuNTE0NzE5OTYzMDczNzMgMTEuMDk3NzAwMTE5MDE4NTUgOC4wMjg1OTAyMDIzMzE1NDMgMTEuMDk3NzAwMTE5MDE4NTUgNi40MTA2OTk4NDQzNjAzNTIgQyAxMS4wOTc3MDAxMTkwMTg1NSAzLjk3ODYzMDA2NTkxNzk2OSA5LjA1NzI5OTYxMzk1MjYzNyAyIDYuNTQ5MzAwMTkzNzg2NjIxIDIgQyA0LjA0MDgxMDEwODE4NDgxNCAyIDIgMy45Nzg2MzAwNjU5MTc5NjkgMiA2LjQxMDY5OTg0NDM2MDM1MiBDIDIgOC4wMjg2MTAyMjk0OTIxODggMi45MTE5NzAxMzg1NDk4MDUgOS41MTQ2NTk4ODE1OTE3OTcgNC4zODAwMjAxNDE2MDE1NjIgMTAuMjg4OTQwNDI5Njg3NSBDIDUuMDM2MjgwMTU1MTgxODg1IDEwLjYzNTA2MDMxMDM2Mzc3IDUuNDQ3MDAwMDI2NzAyODgxIDExLjMxNjAyOTU0ODY0NTAyIDUuNDQ3MDAwMDI2NzAyODgxIDEyLjA1Nzk3MDA0Njk5NzA3IEwgNS40NDcwMDAwMjY3MDI4ODEgMTIuODQ1NDk5OTkyMzcwNjEgTCA3LjY1MDcwMDA5MjMxNTY3NCAxMi44NDU0OTk5OTIzNzA2MSBNIDguNjUwNzk5NzUxMjgxNzM4IDE0Ljg0NTQ5OTk5MjM3MDYxIEwgNC40NDY4OTk4OTA4OTk2NTggMTQuODQ1NDk5OTkyMzcwNjEgQyAzLjg5NDI5OTk4Mzk3ODI3MSAxNC44NDU0OTk5OTIzNzA2MSAzLjQ0NzAwMDAyNjcwMjg4MSAxNC4zOTcyOTk3NjY1NDA1MyAzLjQ0NzAwMDAyNjcwMjg4MSAxMy44NDU2MDAxMjgxNzM4MyBMIDMuNDQ3MDAwMDI2NzAyODgxIDEyLjA1Nzk3MDA0Njk5NzA3IEMgMS4zOTQ3MDAwNTAzNTQwMDQgMTAuOTc1NTQ5Njk3ODc1OTggNS45NTA5Mjc1NzI5Mzk2OWUtMDggOC44NTI2NDAxNTE5Nzc1MzkgNS45NTA5Mjc1NzI5Mzk2OWUtMDggNi40MTA2OTk4NDQzNjAzNTIgQyA1Ljk1MDkyNzU3MjkzOTY5ZS0wOCAyLjg3MDEwMDAyMTM2MjMwNSAyLjkzMjE5OTk1NDk4NjU3MiAtMy44MTQ2OTc4OTA5MDI2MDdlLTA5IDYuNTQ5MzAwMTkzNzg2NjIxIC0zLjgxNDY5Nzg5MDkwMjYwN2UtMDkgQyAxMC4xNjU0OTk2ODcxOTQ4MiAtMy44MTQ2OTc4OTA5MDI2MDdlLTA5IDEzLjA5NzcwMDExOTAxODU1IDIuODcwMTAwMDIxMzYyMzA1IDEzLjA5NzcwMDExOTAxODU1IDYuNDEwNjk5ODQ0MzYwMzUyIEMgMTMuMDk3NzAwMTE5MDE4NTUgOC44NTI2NDAxNTE5Nzc1MzkgMTEuNzAyNzEwMTUxNjcyMzYgMTAuOTc1NzAwMzc4NDE3OTcgOS42NTA2OTk2MTU0Nzg1MTYgMTIuMDU4MTE5NzczODY0NzUgTCA5LjY1MDY5OTYxNTQ3ODUxNiAxMy44NDU2MDAxMjgxNzM4MyBDIDkuNjUwNjk5NjE1NDc4NTE2IDE0LjM5NzI5OTc2NjU0MDUzIDkuMjAzMzk5NjU4MjAzMTI1IDE0Ljg0NTQ5OTk5MjM3MDYxIDguNjUwNzk5NzUxMjgxNzM4IDE0Ljg0NTQ5OTk5MjM3MDYxIFoiIHN0cm9rZT0ibm9uZSIgZmlsbD0iI2ZmZiIvPgogICAgPC9nPgogICAgPGxpbmUgaWQ9IkxpZ25lXzMxOTciIGRhdGEtbmFtZT0iTGlnbmUgMzE5NyIgeDI9IjQuNzc5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxOTcuMDk2IDQ4MjcuNDA5KSIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS13aWR0aD0iMiIvPgogIDwvZz4KPC9zdmc+Cg==");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/img/icon_feather_key.svg":
|
||||
/*!**************************************!*\
|
||||
!*** ./src/img/icon_feather_key.svg ***!
|
||||
\**************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ ReactComponent: () => (/* binding */ SvgIconFeatherKey),
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* 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__);
|
||||
var _path;
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
var SvgIconFeatherKey = function SvgIconFeatherKey(props) {
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
width: 17.803,
|
||||
height: 17.426
|
||||
}, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
"data-name": "Icon feather-key",
|
||||
d: "m16.012 1.414-1.58 1.58M8.419 9.007a4.346 4.346 0 1 1-6.146 0 4.346 4.346 0 0 1 6.146 0Zm0 0 3.248-3.248m0 0 2.37 2.37 2.762-2.764-2.37-2.37M11.667 5.76l2.765-2.766",
|
||||
fill: "none",
|
||||
stroke: "#fff",
|
||||
strokeLinecap: "round",
|
||||
strokeLinejoin: "round",
|
||||
strokeWidth: 2
|
||||
})));
|
||||
};
|
||||
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNy44MDMiIGhlaWdodD0iMTcuNDI2IiB2aWV3Qm94PSIwIDAgMTcuODAzIDE3LjQyNiI+CiAgPHBhdGggaWQ9Ikljb25fZmVhdGhlci1rZXkiIGRhdGEtbmFtZT0iSWNvbiBmZWF0aGVyLWtleSIgZD0iTTE4LjAxMywzbC0xLjU4LDEuNThNMTAuNDIsMTAuNTkzYTQuMzQ2LDQuMzQ2LDAsMSwxLTYuMTQ2LDAsNC4zNDYsNC4zNDYsMCwwLDEsNi4xNDYsMFptMCwwLDMuMjQ4LTMuMjQ4bTAsMCwyLjM3LDIuMzdMMTguOCw2Ljk1MWwtMi4zNy0yLjM3TTEzLjY2OCw3LjM0NiwxNi40MzMsNC41OCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIuMDAxIC0xLjU4NikiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjIiLz4KPC9zdmc+Cg==");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/img/icon_house.svg":
|
||||
/*!********************************!*\
|
||||
!*** ./src/img/icon_house.svg ***!
|
||||
\********************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ ReactComponent: () => (/* binding */ SvgIconHouse),
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* 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__);
|
||||
var _path;
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
var SvgIconHouse = function SvgIconHouse(props) {
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
width: 12.388,
|
||||
height: 14.186
|
||||
}, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||
"data-name": "Trac\\xE9 18534",
|
||||
d: "M6.194 1 1 5.782v7.4h10.388v-7.4Z",
|
||||
fill: "none",
|
||||
stroke: "#fff",
|
||||
strokeLinecap: "round",
|
||||
strokeLinejoin: "round",
|
||||
strokeWidth: 2
|
||||
})));
|
||||
};
|
||||
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi4zODgiIGhlaWdodD0iMTQuMTg2IiB2aWV3Qm94PSIwIDAgMTIuMzg4IDE0LjE4NiI+CiAgPHBhdGggaWQ9IlRyYWPDqV8xODUzNCIgZGF0YS1uYW1lPSJUcmFjw6kgMTg1MzQiIGQ9Ik05NjAuMjE0LDkyOS40NDJsLTUuMTk0LDQuNzgydjcuNGgxMC4zODh2LTcuNFoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC05NTQuMDIgLTkyOC40NDIpIiBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/edit.js":
|
||||
/*!*********************!*\
|
||||
!*** ./src/edit.js ***!
|
||||
\*********************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* binding */ Edit)
|
||||
/* 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_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
|
||||
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss");
|
||||
/* harmony import */ var _img_icon_feather_key_svg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./img/icon_feather_key.svg */ "./src/img/icon_feather_key.svg");
|
||||
/* harmony import */ var _img_icon_block_chain_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./img/icon_block_chain.svg */ "./src/img/icon_block_chain.svg");
|
||||
/* harmony import */ var _img_icon_house_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./img/icon_house.svg */ "./src/img/icon_house.svg");
|
||||
/* harmony import */ var _img_icon_bulb_svg__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./img/icon_bulb.svg */ "./src/img/icon_bulb.svg");
|
||||
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
|
||||
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7__);
|
||||
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
|
||||
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Edit({
|
||||
attributes,
|
||||
setAttributes
|
||||
}) {
|
||||
const {
|
||||
title,
|
||||
iconName,
|
||||
hasTitle
|
||||
} = attributes;
|
||||
const handleIconChange = newIconName => {
|
||||
setAttributes({
|
||||
iconName: newIconName
|
||||
});
|
||||
};
|
||||
function getIconPicture() {
|
||||
switch (iconName) {
|
||||
case "key":
|
||||
return _img_icon_feather_key_svg__WEBPACK_IMPORTED_MODULE_3__["default"];
|
||||
case "chain":
|
||||
return _img_icon_block_chain_svg__WEBPACK_IMPORTED_MODULE_4__["default"];
|
||||
case "house":
|
||||
return _img_icon_house_svg__WEBPACK_IMPORTED_MODULE_5__["default"];
|
||||
case "bulb":
|
||||
return _img_icon_bulb_svg__WEBPACK_IMPORTED_MODULE_6__["default"];
|
||||
}
|
||||
}
|
||||
function getDashiconSymbol() {
|
||||
switch (iconName) {
|
||||
case "key":
|
||||
return "admin-network";
|
||||
case "chain":
|
||||
return "admin-links";
|
||||
case "house":
|
||||
return "admin-home";
|
||||
case "bulb":
|
||||
return "lightbulb";
|
||||
}
|
||||
}
|
||||
function onHasTitleChange() {
|
||||
setAttributes({
|
||||
hasTitle: !hasTitle,
|
||||
title: undefined
|
||||
});
|
||||
}
|
||||
let iconPicture = getIconPicture();
|
||||
let iconDashiconSymbol = getDashiconSymbol();
|
||||
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_7__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__.PanelBody, {
|
||||
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Titre", "homegrade-blocks__texte-fonctionnel"),
|
||||
initialOpen: true
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__.ToggleControl, {
|
||||
label: "Afficher le titre",
|
||||
checked: hasTitle,
|
||||
onChange: onHasTitleChange
|
||||
}))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7__.BlockControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__.ToolbarButton, {
|
||||
title: "Clé",
|
||||
icon: "admin-network",
|
||||
isActive: iconName === "key",
|
||||
onClick: () => handleIconChange("key")
|
||||
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__.ToolbarButton, {
|
||||
title: "Lien",
|
||||
icon: "admin-links",
|
||||
isActive: iconName === "chain",
|
||||
onClick: () => handleIconChange("chain")
|
||||
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__.ToolbarButton, {
|
||||
title: "Homegrade",
|
||||
icon: "admin-home",
|
||||
isActive: iconName === "house",
|
||||
onClick: () => handleIconChange("house")
|
||||
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_8__.ToolbarButton, {
|
||||
title: "Inspiration",
|
||||
icon: "lightbulb",
|
||||
isActive: iconName === "bulb",
|
||||
onClick: () => handleIconChange("bulb")
|
||||
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("section", {
|
||||
...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7__.useBlockProps)({
|
||||
className: `homegrade-blocks-highlight`
|
||||
})
|
||||
}, hasTitle && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
className: "homegrade-blocks-highlight__titling"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
className: "icon"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||
src: iconPicture,
|
||||
alt: ""
|
||||
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7__.RichText, {
|
||||
className: "homegrade-blocks-highlight__block-title",
|
||||
onChange: value => setAttributes({
|
||||
title: value
|
||||
}),
|
||||
value: title,
|
||||
placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Insérez un titre", "homegrade-blocks__texte-fonctionnel"),
|
||||
tagName: "h3",
|
||||
allowedFormats: []
|
||||
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_7__.InnerBlocks, {
|
||||
allowedBlocks: ["core/paragraph", "core/list", "core/buttons", "core/button", "core/colums", "core/colum", "homegrade-content-blocks/content-heading"],
|
||||
template: [["core/paragraph"]]
|
||||
})));
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/index.js":
|
||||
/*!**********************!*\
|
||||
!*** ./src/index.js ***!
|
||||
\**********************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* 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_blocks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks");
|
||||
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__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__);
|
||||
/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss");
|
||||
/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./edit */ "./src/edit.js");
|
||||
/* harmony import */ var _save__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./save */ "./src/save.js");
|
||||
/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./block.json */ "./src/block.json");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_6__.name, {
|
||||
icon: {
|
||||
src: (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
|
||||
d: "M8,7h8a1,1,0,0,1,1,1v8a1,1,0,0,1-1,1H8a1,1,0,0,1-1-1V8A1,1,0,0,1,8,7Zm3-5V4h2V2Zm7,0H16V4h2ZM6,4H8V2H6ZM2,2V4L4,2ZM22,4V2H20ZM13,22V20H11v2Zm3,0h2V20H16ZM6,22H8V20H6Zm14-9h2V11H20Zm0,5h2V16H20ZM20,8h2V6H20ZM4,11H2v2H4Zm0,5H2v2H4ZM4,6H2V8H4ZM2,20v2H4Zm20,2V20l-2,2Z"
|
||||
})),
|
||||
foreground: "#DF1E1E"
|
||||
},
|
||||
edit: _edit__WEBPACK_IMPORTED_MODULE_4__["default"],
|
||||
save: _save__WEBPACK_IMPORTED_MODULE_5__["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 _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_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__);
|
||||
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
|
||||
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _img_icon_feather_key_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./img/icon_feather_key.svg */ "./src/img/icon_feather_key.svg");
|
||||
/* harmony import */ var _img_icon_block_chain_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./img/icon_block_chain.svg */ "./src/img/icon_block_chain.svg");
|
||||
/* harmony import */ var _img_icon_house_svg__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./img/icon_house.svg */ "./src/img/icon_house.svg");
|
||||
/* harmony import */ var _img_icon_bulb_svg__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./img/icon_bulb.svg */ "./src/img/icon_bulb.svg");
|
||||
|
||||
|
||||
|
||||
// pour les querry
|
||||
|
||||
|
||||
|
||||
|
||||
function save({
|
||||
attributes,
|
||||
setAttributes
|
||||
}) {
|
||||
const {
|
||||
title,
|
||||
iconName,
|
||||
hasTitle
|
||||
} = attributes;
|
||||
function getIconPicture() {
|
||||
switch (iconName) {
|
||||
case "key":
|
||||
return _img_icon_feather_key_svg__WEBPACK_IMPORTED_MODULE_4__["default"];
|
||||
case "chain":
|
||||
return _img_icon_block_chain_svg__WEBPACK_IMPORTED_MODULE_5__["default"];
|
||||
case "house":
|
||||
return _img_icon_house_svg__WEBPACK_IMPORTED_MODULE_6__["default"];
|
||||
case "bulb":
|
||||
return _img_icon_bulb_svg__WEBPACK_IMPORTED_MODULE_7__["default"];
|
||||
}
|
||||
}
|
||||
let iconPicture = getIconPicture();
|
||||
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("section", {
|
||||
..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps.save({
|
||||
className: `homegrade-blocks-highlight`
|
||||
})
|
||||
}, hasTitle && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
className: "homegrade-blocks-highlight__titling"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
className: "icon"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||
clas: true,
|
||||
src: iconPicture,
|
||||
alt: ""
|
||||
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText.Content, {
|
||||
tagName: "h3",
|
||||
value: title,
|
||||
className: "homegrade-blocks-highlight__block-title"
|
||||
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks.Content, null));
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/editor.scss":
|
||||
/*!*************************!*\
|
||||
!*** ./src/editor.scss ***!
|
||||
\*************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
// extracted by mini-css-extract-plugin
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/style.scss":
|
||||
/*!************************!*\
|
||||
!*** ./src/style.scss ***!
|
||||
\************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
// extracted by mini-css-extract-plugin
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "react":
|
||||
/*!************************!*\
|
||||
!*** external "React" ***!
|
||||
\************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["React"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/block-editor":
|
||||
/*!*************************************!*\
|
||||
!*** external ["wp","blockEditor"] ***!
|
||||
\*************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["blockEditor"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/blocks":
|
||||
/*!********************************!*\
|
||||
!*** external ["wp","blocks"] ***!
|
||||
\********************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["blocks"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/components":
|
||||
/*!************************************!*\
|
||||
!*** external ["wp","components"] ***!
|
||||
\************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["components"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/data":
|
||||
/*!******************************!*\
|
||||
!*** external ["wp","data"] ***!
|
||||
\******************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["data"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/element":
|
||||
/*!*********************************!*\
|
||||
!*** external ["wp","element"] ***!
|
||||
\*********************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["element"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/i18n":
|
||||
/*!******************************!*\
|
||||
!*** external ["wp","i18n"] ***!
|
||||
\******************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["i18n"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./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/highlight","version":"0.1.0","title":"Mise en avant","category":"homegrade-blocks","description":"Bloc pour mettre en avant des informations importantes","supports":{"html":false},"textdomain":"homegrade-blocks__texte-fonctionnel","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","attributes":{"title":{"type":"string","source":"html","selector":"h3"},"iconName":{"type":"string","default":"key"},"hasTitle":{"type":"boolean","default":true}}}');
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = __webpack_modules__;
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/chunk loaded */
|
||||
/******/ (() => {
|
||||
/******/ var deferred = [];
|
||||
/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
|
||||
/******/ if(chunkIds) {
|
||||
/******/ priority = priority || 0;
|
||||
/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
|
||||
/******/ deferred[i] = [chunkIds, fn, priority];
|
||||
/******/ return;
|
||||
/******/ }
|
||||
/******/ var notFulfilled = Infinity;
|
||||
/******/ for (var i = 0; i < deferred.length; i++) {
|
||||
/******/ var chunkIds = deferred[i][0];
|
||||
/******/ var fn = deferred[i][1];
|
||||
/******/ var priority = deferred[i][2];
|
||||
/******/ var fulfilled = true;
|
||||
/******/ for (var j = 0; j < chunkIds.length; j++) {
|
||||
/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
|
||||
/******/ chunkIds.splice(j--, 1);
|
||||
/******/ } else {
|
||||
/******/ fulfilled = false;
|
||||
/******/ if(priority < notFulfilled) notFulfilled = priority;
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ if(fulfilled) {
|
||||
/******/ deferred.splice(i--, 1)
|
||||
/******/ var r = fn();
|
||||
/******/ if (r !== undefined) result = r;
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ return result;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (exports, definition) => {
|
||||
/******/ for(var key in definition) {
|
||||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (exports) => {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/jsonp chunk loading */
|
||||
/******/ (() => {
|
||||
/******/ // no baseURI
|
||||
/******/
|
||||
/******/ // object to store loaded and loading chunks
|
||||
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
||||
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
||||
/******/ var installedChunks = {
|
||||
/******/ "index": 0,
|
||||
/******/ "./style-index": 0
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // no chunk on demand loading
|
||||
/******/
|
||||
/******/ // no prefetching
|
||||
/******/
|
||||
/******/ // no preloaded
|
||||
/******/
|
||||
/******/ // no HMR
|
||||
/******/
|
||||
/******/ // no HMR manifest
|
||||
/******/
|
||||
/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
|
||||
/******/
|
||||
/******/ // install a JSONP callback for chunk loading
|
||||
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
||||
/******/ var chunkIds = data[0];
|
||||
/******/ var moreModules = data[1];
|
||||
/******/ var runtime = data[2];
|
||||
/******/ // add "moreModules" to the modules object,
|
||||
/******/ // then flag all "chunkIds" as loaded and fire callback
|
||||
/******/ var moduleId, chunkId, i = 0;
|
||||
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
||||
/******/ for(moduleId in moreModules) {
|
||||
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
||||
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ if(runtime) var result = runtime(__webpack_require__);
|
||||
/******/ }
|
||||
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
||||
/******/ for(;i < chunkIds.length; i++) {
|
||||
/******/ chunkId = chunkIds[i];
|
||||
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
||||
/******/ installedChunks[chunkId][0]();
|
||||
/******/ }
|
||||
/******/ installedChunks[chunkId] = 0;
|
||||
/******/ }
|
||||
/******/ return __webpack_require__.O(result);
|
||||
/******/ }
|
||||
/******/
|
||||
/******/ var chunkLoadingGlobal = self["webpackChunkmultiblocks"] = self["webpackChunkmultiblocks"] || [];
|
||||
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
||||
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/
|
||||
/******/ // startup
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
|
||||
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["./style-index"], () => (__webpack_require__("./src/index.js")))
|
||||
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
|
||||
/******/
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
blocks/plus-loin/build/index.js.map
Normal file
45
blocks/plus-loin/build/style-index.css
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*!***************************************************************************************************************************************************************************************************************************************!*\
|
||||
!*** 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/style.scss ***!
|
||||
\***************************************************************************************************************************************************************************************************************************************/
|
||||
/**
|
||||
* The following styles get applied both on the front of your site
|
||||
* and in the editor.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
.homegrade-blocks-highlight__block-title {
|
||||
margin: 0 !important;
|
||||
}
|
||||
.homegrade-blocks-highlight__titling {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.homegrade-blocks-highlight__titling .icon {
|
||||
background-color: black;
|
||||
border-radius: 50%;
|
||||
aspect-ratio: 1/1;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.homegrade-blocks-highlight__titling .icon img {
|
||||
width: 30px;
|
||||
max-width: 80%;
|
||||
max-height: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.homegrade-blocks-highlight__titling h3 {
|
||||
padding-left: 10px;
|
||||
}
|
||||
.homegrade-blocks-highlight p + ul {
|
||||
padding-top: 16px;
|
||||
}
|
||||
.homegrade-blocks-highlight ul + p {
|
||||
padding-top: 16px;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=style-index.css.map*/
|
||||
1
blocks/plus-loin/build/style-index.css.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"./style-index.css","mappings":";;;AAAA;;;;;EAAA;AAQC;EACC;AADF;AAGC;EACC;EACA;EACA;AADF;AAEE;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAAH;AAEG;EACC;EACA;EACA;EACA;AAAJ;AAGE;EACC;AADH;AAWC;EACC;AATF;AAWC;EACC;AATF,C","sources":["webpack://multiblocks/./src/style.scss"],"sourcesContent":["/**\n * The following styles get applied both on the front of your site\n * and in the editor.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.homegrade-blocks-highlight {\n\t&__block-title {\n\t\tmargin: 0 !important;\n\t}\n\t&__titling {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tmargin-bottom: 20px;\n\t\t.icon {\n\t\t\tbackground-color: black;\n\t\t\tborder-radius: 50%;\n\t\t\taspect-ratio: 1/1;\n\t\t\twidth: 40px;\n\t\t\theight: 40px;\n\t\t\tpadding: 10px;\n\t\t\tdisplay: flex;\n\t\t\tjustify-content: center;\n\t\t\talign-items: center;\n\n\t\t\timg {\n\t\t\t\twidth: 30px;\n\t\t\t\tmax-width: 80%;\n\t\t\t\tmax-height: 100%;\n\t\t\t\theight: auto;\n\t\t\t}\n\t\t}\n\t\th3 {\n\t\t\tpadding-left: 10px;\n\t\t}\n\t}\n\n\t// ul li {\n\t// \tlist-style-type: disc;\n\t// \tlist-style-position: inside;\n\t// \tmargin-left: 1.5em;\n\t// }\n\n\tp + ul {\n\t\tpadding-top: 16px;\n\t}\n\tul + p {\n\t\tpadding-top: 16px;\n\t}\n}\n"],"names":[],"sourceRoot":""}
|
||||
28142
blocks/plus-loin/package-lock.json
generated
Normal file
20
blocks/plus-loin/package.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "multiblocks",
|
||||
"version": "0.1.0",
|
||||
"description": "Example block scaffolded with Create Block tool.",
|
||||
"author": "The WordPress Contributors",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
"build": "wp-scripts build",
|
||||
"format": "wp-scripts format",
|
||||
"lint:css": "wp-scripts lint-style",
|
||||
"lint:js": "wp-scripts lint-js",
|
||||
"packages-update": "wp-scripts packages-update",
|
||||
"plugin-zip": "wp-scripts plugin-zip",
|
||||
"start": "wp-scripts start"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@wordpress/scripts": "^26.9.0"
|
||||
}
|
||||
}
|
||||
BIN
blocks/plus-loin/src/.DS_Store
vendored
Normal file
31
blocks/plus-loin/src/block.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 2,
|
||||
"name": "homegrade-content-blocks/plus-loin",
|
||||
"version": "0.1.0",
|
||||
"title": "Plus loin",
|
||||
"category": "homegrade-blocks",
|
||||
"description": "Bloc pour de liens pour aller plus loin",
|
||||
"supports": {
|
||||
"html": false
|
||||
},
|
||||
"textdomain": "homegrade-blocks__texte-fonctionnel",
|
||||
"editorScript": "file:./index.js",
|
||||
"editorStyle": "file:./index.css",
|
||||
"style": "file:./style-index.css",
|
||||
"attributes": {
|
||||
"title": {
|
||||
"type": "string",
|
||||
"source": "html",
|
||||
"selector": "h3"
|
||||
},
|
||||
"iconName": {
|
||||
"type": "string",
|
||||
"default": "key"
|
||||
},
|
||||
"hasTitle": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
}
|
||||
141
blocks/plus-loin/src/edit.js
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import { __ } from "@wordpress/i18n";
|
||||
import "./editor.scss";
|
||||
import keyIcon from "./img/icon_feather_key.svg";
|
||||
import chainIcon from "./img/icon_block_chain.svg";
|
||||
import houseIcon from "./img/icon_house.svg";
|
||||
import bulbIcon from "./img/icon_bulb.svg";
|
||||
import {
|
||||
RichText,
|
||||
useBlockProps,
|
||||
BlockControls,
|
||||
InnerBlocks,
|
||||
InspectorControls,
|
||||
} from "@wordpress/block-editor";
|
||||
|
||||
import { ToolbarButton, ToggleControl, PanelBody } from "@wordpress/components";
|
||||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const { title, iconName, hasTitle } = attributes;
|
||||
const handleIconChange = (newIconName) => {
|
||||
setAttributes({ iconName: newIconName });
|
||||
};
|
||||
function getIconPicture() {
|
||||
switch (iconName) {
|
||||
case "key":
|
||||
return keyIcon;
|
||||
|
||||
case "chain":
|
||||
return chainIcon;
|
||||
|
||||
case "house":
|
||||
return houseIcon;
|
||||
|
||||
case "bulb":
|
||||
return bulbIcon;
|
||||
}
|
||||
}
|
||||
function getDashiconSymbol() {
|
||||
switch (iconName) {
|
||||
case "key":
|
||||
return "admin-network";
|
||||
|
||||
case "chain":
|
||||
return "admin-links";
|
||||
|
||||
case "house":
|
||||
return "admin-home";
|
||||
|
||||
case "bulb":
|
||||
return "lightbulb";
|
||||
}
|
||||
}
|
||||
function onHasTitleChange() {
|
||||
setAttributes({
|
||||
hasTitle: !hasTitle,
|
||||
title: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
let iconPicture = getIconPicture();
|
||||
let iconDashiconSymbol = getDashiconSymbol();
|
||||
|
||||
return (
|
||||
<>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={__("Titre", "homegrade-blocks__texte-fonctionnel")}
|
||||
initialOpen={true}
|
||||
>
|
||||
<ToggleControl
|
||||
label="Afficher le titre"
|
||||
checked={hasTitle}
|
||||
onChange={onHasTitleChange}
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<BlockControls>
|
||||
<ToolbarButton
|
||||
title={"Clé"}
|
||||
icon={"admin-network"}
|
||||
isActive={iconName === "key"}
|
||||
onClick={() => handleIconChange("key")}
|
||||
/>
|
||||
<ToolbarButton
|
||||
title={"Lien"}
|
||||
icon={"admin-links"}
|
||||
isActive={iconName === "chain"}
|
||||
onClick={() => handleIconChange("chain")}
|
||||
/>
|
||||
<ToolbarButton
|
||||
title={"Homegrade"}
|
||||
icon={"admin-home"}
|
||||
isActive={iconName === "house"}
|
||||
onClick={() => handleIconChange("house")}
|
||||
/>
|
||||
<ToolbarButton
|
||||
title={"Inspiration"}
|
||||
icon={"lightbulb"}
|
||||
isActive={iconName === "bulb"}
|
||||
onClick={() => handleIconChange("bulb")}
|
||||
/>
|
||||
</BlockControls>
|
||||
<section
|
||||
{...useBlockProps({
|
||||
className: `homegrade-blocks-highlight`,
|
||||
})}
|
||||
>
|
||||
{hasTitle && (
|
||||
<div className="homegrade-blocks-highlight__titling">
|
||||
<div className="icon">
|
||||
<img src={iconPicture} alt="" />
|
||||
</div>
|
||||
<RichText
|
||||
className="homegrade-blocks-highlight__block-title"
|
||||
onChange={(value) => setAttributes({ title: value })}
|
||||
value={title}
|
||||
placeholder={__(
|
||||
"Insérez un titre",
|
||||
"homegrade-blocks__texte-fonctionnel"
|
||||
)}
|
||||
tagName="h3"
|
||||
allowedFormats={[]}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<InnerBlocks
|
||||
allowedBlocks={[
|
||||
"core/paragraph",
|
||||
"core/list",
|
||||
"core/buttons",
|
||||
"core/button",
|
||||
"core/colums",
|
||||
"core/colum",
|
||||
"homegrade-content-blocks/content-heading",
|
||||
]}
|
||||
template={[["core/paragraph"]]}
|
||||
/>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
25
blocks/plus-loin/src/editor.scss
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* The following styles get applied inside the editor only.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
|
||||
.homegrade-blocks-highlight {
|
||||
ul {
|
||||
li {
|
||||
// list-style: none !important;
|
||||
display: flex;
|
||||
padding: 10px 0;
|
||||
}
|
||||
li:before {
|
||||
transform: translateY(6px);
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
content: "";
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
blocks/plus-loin/src/img/icon_block_chain.png
Normal file
|
After Width: | Height: | Size: 382 B |
6
blocks/plus-loin/src/img/icon_block_chain.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16.012" height="15.999" viewBox="0 0 16.012 15.999">
|
||||
<g id="Icon_feather-link" data-name="Icon feather-link" transform="translate(-1.993 -2.007)">
|
||||
<path id="Tracé_18559" data-name="Tracé 18559" d="M15,10.707a3.5,3.5,0,0,0,5.28.378l2.1-2.1A3.5,3.5,0,1,0,17.43,4.033l-1.2,1.2" transform="translate(-6.402 0)" fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
|
||||
<path id="Tracé_18560" data-name="Tracé 18560" d="M11.4,14.9a3.5,3.5,0,0,0-5.28-.378l-2.1,2.1A3.5,3.5,0,1,0,8.97,21.57l1.2-1.2" transform="translate(0 -5.59)" fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 725 B |
BIN
blocks/plus-loin/src/img/icon_bulb.png
Normal file
|
After Width: | Height: | Size: 378 B |
9
blocks/plus-loin/src/img/icon_bulb.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="13.098" height="18.409" viewBox="0 0 13.098 18.409">
|
||||
<g id="Groupe_3209" data-name="Groupe 3209" transform="translate(-193 -4810)">
|
||||
<g id="Union_18" data-name="Union 18" transform="translate(193 4810)" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4.447,14.845a1,1,0,0,1-1-1V12.058A6.392,6.392,0,0,1,0,6.411,6.481,6.481,0,0,1,6.549,0,6.481,6.481,0,0,1,13.1,6.411a6.393,6.393,0,0,1-3.447,5.647v1.787a1,1,0,0,1-1,1Z" stroke="none"/>
|
||||
<path d="M 7.650700092315674 12.84549999237061 L 7.650700092315674 12.05811977386475 C 7.650700092315674 11.3162202835083 8.061380386352539 10.63527965545654 8.71757984161377 10.28913974761963 C 10.18568992614746 9.51471996307373 11.09770011901855 8.028590202331543 11.09770011901855 6.410699844360352 C 11.09770011901855 3.978630065917969 9.057299613952637 2 6.549300193786621 2 C 4.040810108184814 2 2 3.978630065917969 2 6.410699844360352 C 2 8.028610229492188 2.911970138549805 9.514659881591797 4.380020141601562 10.2889404296875 C 5.036280155181885 10.63506031036377 5.447000026702881 11.31602954864502 5.447000026702881 12.05797004699707 L 5.447000026702881 12.84549999237061 L 7.650700092315674 12.84549999237061 M 8.650799751281738 14.84549999237061 L 4.446899890899658 14.84549999237061 C 3.894299983978271 14.84549999237061 3.447000026702881 14.39729976654053 3.447000026702881 13.84560012817383 L 3.447000026702881 12.05797004699707 C 1.394700050354004 10.97554969787598 5.95092757293969e-08 8.852640151977539 5.95092757293969e-08 6.410699844360352 C 5.95092757293969e-08 2.870100021362305 2.932199954986572 -3.814697890902607e-09 6.549300193786621 -3.814697890902607e-09 C 10.16549968719482 -3.814697890902607e-09 13.09770011901855 2.870100021362305 13.09770011901855 6.410699844360352 C 13.09770011901855 8.852640151977539 11.70271015167236 10.97570037841797 9.650699615478516 12.05811977386475 L 9.650699615478516 13.84560012817383 C 9.650699615478516 14.39729976654053 9.203399658203125 14.84549999237061 8.650799751281738 14.84549999237061 Z" stroke="none" fill="#fff"/>
|
||||
</g>
|
||||
<line id="Ligne_3197" data-name="Ligne 3197" x2="4.779" transform="translate(197.096 4827.409)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
BIN
blocks/plus-loin/src/img/icon_feather_key.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
3
blocks/plus-loin/src/img/icon_feather_key.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="17.803" height="17.426" viewBox="0 0 17.803 17.426">
|
||||
<path id="Icon_feather-key" data-name="Icon feather-key" d="M18.013,3l-1.58,1.58M10.42,10.593a4.346,4.346,0,1,1-6.146,0,4.346,4.346,0,0,1,6.146,0Zm0,0,3.248-3.248m0,0,2.37,2.37L18.8,6.951l-2.37-2.37M13.668,7.346,16.433,4.58" transform="translate(-2.001 -1.586)" fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 463 B |
BIN
blocks/plus-loin/src/img/icon_house.png
Normal file
|
After Width: | Height: | Size: 268 B |
3
blocks/plus-loin/src/img/icon_house.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="12.388" height="14.186" viewBox="0 0 12.388 14.186">
|
||||
<path id="Tracé_18534" data-name="Tracé 18534" d="M960.214,929.442l-5.194,4.782v7.4h10.388v-7.4Z" transform="translate(-954.02 -928.442)" fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 341 B |
21
blocks/plus-loin/src/index.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { registerBlockType } from "@wordpress/blocks";
|
||||
import { __ } from "@wordpress/i18n";
|
||||
import "./style.scss";
|
||||
|
||||
import Edit from "./edit";
|
||||
import save from "./save";
|
||||
import metadata from "./block.json";
|
||||
|
||||
registerBlockType(metadata.name, {
|
||||
|
||||
icon: {
|
||||
src: (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<path d="M8,7h8a1,1,0,0,1,1,1v8a1,1,0,0,1-1,1H8a1,1,0,0,1-1-1V8A1,1,0,0,1,8,7Zm3-5V4h2V2Zm7,0H16V4h2ZM6,4H8V2H6ZM2,2V4L4,2ZM22,4V2H20ZM13,22V20H11v2Zm3,0h2V20H16ZM6,22H8V20H6Zm14-9h2V11H20Zm0,5h2V16H20ZM20,8h2V6H20ZM4,11H2v2H4Zm0,5H2v2H4ZM4,6H2V8H4ZM2,20v2H4Zm20,2V20l-2,2Z" />
|
||||
</svg>
|
||||
),
|
||||
foreground: "#DF1E1E",
|
||||
},
|
||||
edit: Edit,
|
||||
save,
|
||||
});
|
||||
22
blocks/plus-loin/src/render.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
// $attributes = get_block_attributes();
|
||||
// echo '<pre>';
|
||||
// print_r($block);
|
||||
// echo '</pre>';
|
||||
|
||||
$inner_blocks_html = '';
|
||||
foreach ($block->inner_blocks as $inner_block) {
|
||||
$inner_blocks_html .= $inner_block->render();
|
||||
}
|
||||
?>
|
||||
<section class="homegrade-blocks-highlight">
|
||||
<div class="homegrade-blocks-highlight__titling">
|
||||
<div class="icon">
|
||||
<img src="<?php echo plugin_dir_url(dirname(__DIR__)) ?>src/points-cles/img/icon_feather_key.png" alt="" />
|
||||
</div>
|
||||
<h3 class=""><?php echo __("Les points clés", "homegrade-theme__blocks-texte-fonctionnel") ?></h3>
|
||||
</div>
|
||||
<?php echo $inner_blocks_html ?>
|
||||
|
||||
|
||||
</section>
|
||||
51
blocks/plus-loin/src/save.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor";
|
||||
import { __ } from "@wordpress/i18n";
|
||||
import { useSelect, useDispatch } from "@wordpress/data"; // pour les querry
|
||||
import keyIcon from "./img/icon_feather_key.svg";
|
||||
import chainIcon from "./img/icon_block_chain.svg";
|
||||
import houseIcon from "./img/icon_house.svg";
|
||||
import bulbIcon from "./img/icon_bulb.svg";
|
||||
|
||||
export default function save({ attributes, setAttributes }) {
|
||||
const { title, iconName, hasTitle } = attributes;
|
||||
function getIconPicture() {
|
||||
switch (iconName) {
|
||||
case "key":
|
||||
return keyIcon;
|
||||
|
||||
case "chain":
|
||||
return chainIcon;
|
||||
|
||||
case "house":
|
||||
return houseIcon;
|
||||
|
||||
case "bulb":
|
||||
return bulbIcon;
|
||||
}
|
||||
}
|
||||
let iconPicture = getIconPicture();
|
||||
|
||||
return (
|
||||
<section
|
||||
{...useBlockProps.save({
|
||||
className: `homegrade-blocks-highlight`,
|
||||
})}
|
||||
>
|
||||
{hasTitle && (
|
||||
<div className="homegrade-blocks-highlight__titling">
|
||||
<div className="icon">
|
||||
<img clas src={iconPicture} alt="" />
|
||||
</div>
|
||||
|
||||
<RichText.Content
|
||||
tagName="h3"
|
||||
value={title}
|
||||
className="homegrade-blocks-highlight__block-title"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<InnerBlocks.Content />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
51
blocks/plus-loin/src/style.scss
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* The following styles get applied both on the front of your site
|
||||
* and in the editor.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
|
||||
.homegrade-blocks-highlight {
|
||||
&__block-title {
|
||||
margin: 0 !important;
|
||||
}
|
||||
&__titling {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
.icon {
|
||||
background-color: black;
|
||||
border-radius: 50%;
|
||||
aspect-ratio: 1/1;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
width: 30px;
|
||||
max-width: 80%;
|
||||
max-height: 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
h3 {
|
||||
padding-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
// ul li {
|
||||
// list-style-type: disc;
|
||||
// list-style-position: inside;
|
||||
// margin-left: 1.5em;
|
||||
// }
|
||||
|
||||
p + ul {
|
||||
padding-top: 16px;
|
||||
}
|
||||
ul + p {
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,10 @@
|
|||
"attributes": {
|
||||
"relatedPostId": {
|
||||
"type": "number"
|
||||
},
|
||||
"tooltipsWordsUsed": {
|
||||
"type": "array",
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'd119409565df9cba01b5');
|
||||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '53ba63544a9275dbaa4d');
|
||||
|
|
|
|||
|
|
@ -155,6 +155,29 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
function Edit({
|
||||
attributes,
|
||||
setAttributes
|
||||
|
|
@ -163,6 +186,14 @@ function Edit({
|
|||
relatedPostId
|
||||
} = attributes;
|
||||
let currentRelatedPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => select("core").getEntityRecord("postType", "questions", relatedPostId));
|
||||
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
if (currentRelatedPost) {
|
||||
const currentBlockTooltips = parseBlockContentForTooltips(currentRelatedPost.content.rendered);
|
||||
setAttributes({
|
||||
tooltipsWordsUsed: currentBlockTooltips
|
||||
});
|
||||
}
|
||||
}, [currentRelatedPost]);
|
||||
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)(_OptionsSelectControl__WEBPACK_IMPORTED_MODULE_6__["default"], {
|
||||
relatedPostId: relatedPostId,
|
||||
setAttributes: setAttributes
|
||||
|
|
@ -297,7 +328,7 @@ module.exports = window["wp"]["i18n"];
|
|||
\************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/questions-container","version":"0.1.0","title":"Bloc Questions","category":"homegrade-blocks","icon":{"background":"#fff","foreground":"#DF1E1E","src":"feedback"},"description":"Pour intégrer le contenu d\'une fiche de questions dans une page conseils","supports":{"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"}}}');
|
||||
module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/questions-container","version":"0.1.0","title":"Bloc Questions","category":"homegrade-blocks","icon":{"background":"#fff","foreground":"#DF1E1E","src":"feedback"},"description":"Pour intégrer le contenu d\'une fiche de questions dans une page conseils","supports":{"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"},"tooltipsWordsUsed":{"type":"array","default":[]}}}');
|
||||
|
||||
/***/ })
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
"attributes": {
|
||||
"relatedPostId": {
|
||||
"type": "number"
|
||||
},
|
||||
"tooltipsWordsUsed": {
|
||||
"type": "array",
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,40 @@ import { useBlockProps } from "@wordpress/block-editor";
|
|||
import { useSelect } from "@wordpress/data"; // pour les querry
|
||||
import "./editor.scss";
|
||||
import { RawHTML } from "@wordpress/element";
|
||||
import { useEffect } from "@wordpress/element";
|
||||
import { decodeEntities } from "@wordpress/html-entities";
|
||||
import OptionsSelectControl from "./OptionsSelectControl";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const { relatedPostId } = attributes;
|
||||
|
||||
|
|
@ -14,6 +45,15 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
select("core").getEntityRecord("postType", "questions", relatedPostId)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentRelatedPost) {
|
||||
const currentBlockTooltips = parseBlockContentForTooltips(
|
||||
currentRelatedPost.content.rendered
|
||||
);
|
||||
setAttributes({ tooltipsWordsUsed: currentBlockTooltips });
|
||||
}
|
||||
}, [currentRelatedPost]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<OptionsSelectControl
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'b40a3d19c7b63765015f');
|
||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'e49486412a0cfc6ccbf9');
|
||||
|
|
|
|||
|
|
@ -106,46 +106,71 @@ function Edit({
|
|||
}
|
||||
return record;
|
||||
}
|
||||
function buildTooltipWords(editorContent) {
|
||||
// Parsing Content
|
||||
function filterToolTipsArray(tooltipWords) {
|
||||
const filteredTooltipWords = [];
|
||||
tooltipWords.forEach(tooltipWord => {
|
||||
const existingTooltip = filteredTooltipWords.find(item => item.tooltipID === tooltipWord.tooltipID);
|
||||
if (!existingTooltip) {
|
||||
filteredTooltipWords.push(tooltipWord);
|
||||
}
|
||||
});
|
||||
return filteredTooltipWords;
|
||||
}
|
||||
function parseContentTooltips(editorContent) {
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(editorContent, "text/html");
|
||||
const domTooltipWords = doc.querySelectorAll(".tooltip-word");
|
||||
const filteredTooltipWords = [];
|
||||
const tooltipWords = [];
|
||||
|
||||
// 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
|
||||
tooltipWords.push({
|
||||
tooltipID,
|
||||
tooltipText,
|
||||
tooltipDefinition
|
||||
});
|
||||
});
|
||||
return tooltipWords;
|
||||
}
|
||||
function parseBlocksTooltips(currentBlocks) {
|
||||
const blocksTooltipWords = [];
|
||||
currentBlocks.forEach(block => {
|
||||
if (block.name === "homegrade-content-blocks/questions-container" && block.attributes && block.attributes.tooltipsWordsUsed && block.attributes.tooltipsWordsUsed.length > 0) {
|
||||
block.attributes.tooltipsWordsUsed.forEach(tooltipWord => {
|
||||
blocksTooltipWords.push(tooltipWord);
|
||||
});
|
||||
}
|
||||
});
|
||||
return blocksTooltipWords;
|
||||
}
|
||||
function buildTooltipWords() {
|
||||
let newParsedTooltipWords = parseContentTooltips(currentPost.content);
|
||||
let newBlocksTooltipWords = parseBlocksTooltips(currentBlocks);
|
||||
let allTooltipWords = [...newParsedTooltipWords, ...newBlocksTooltipWords];
|
||||
const filteredTooltipWords = filterToolTipsArray(allTooltipWords);
|
||||
return filteredTooltipWords;
|
||||
}
|
||||
function compareHasNewVocabularyWord(previousWords, newWords) {
|
||||
return !(JSON.stringify(previousWords) === JSON.stringify(newWords));
|
||||
}
|
||||
const currentPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select("core/editor").getCurrentPost());
|
||||
const currentBlocks = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select("core/block-editor").getBlocks());
|
||||
const currentTaxonomies = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select("core/editor").getCurrentPostAttribute("thematiques"));
|
||||
let currentThematique = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select("core").getEntityRecord("taxonomy", "thematiques", currentTaxonomies[0] // or currentPost.thematiques[0] works as well
|
||||
), [currentTaxonomies]);
|
||||
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
if (currentPost.content) {
|
||||
let newTooltipWords = buildTooltipWords(currentPost.content);
|
||||
if (currentPost.content && currentBlocks) {
|
||||
const newTooltipWords = buildTooltipWords();
|
||||
if (compareHasNewVocabularyWord(tooltipWords, newTooltipWords)) {
|
||||
setAttributes({
|
||||
tooltipWords: newTooltipWords
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [currentPost]);
|
||||
}, [currentPost, currentBlocks]);
|
||||
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("section", {
|
||||
...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.useBlockProps)({
|
||||
className: `homegrade-blocks-vocabulaire-summary`
|
||||
|
|
|
|||
|
|
@ -42,13 +42,28 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
}
|
||||
return record;
|
||||
}
|
||||
function buildTooltipWords(editorContent) {
|
||||
// Parsing Content
|
||||
|
||||
function filterToolTipsArray(tooltipWords) {
|
||||
const filteredTooltipWords = [];
|
||||
|
||||
tooltipWords.forEach((tooltipWord) => {
|
||||
const existingTooltip = filteredTooltipWords.find(
|
||||
(item) => item.tooltipID === tooltipWord.tooltipID
|
||||
);
|
||||
|
||||
if (!existingTooltip) {
|
||||
filteredTooltipWords.push(tooltipWord);
|
||||
}
|
||||
});
|
||||
|
||||
return filteredTooltipWords;
|
||||
}
|
||||
function parseContentTooltips(editorContent) {
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(editorContent, "text/html");
|
||||
const domTooltipWords = doc.querySelectorAll(".tooltip-word");
|
||||
|
||||
const filteredTooltipWords = [];
|
||||
const tooltipWords = [];
|
||||
|
||||
// Looping over tooltip words and filtering duplicates
|
||||
Array.from(domTooltipWords).forEach((tooltipWord) => {
|
||||
|
|
@ -58,20 +73,40 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
"data-tooltip-definition"
|
||||
);
|
||||
|
||||
const existingTooltip = filteredTooltipWords.find(
|
||||
(item) => item.tooltipID === tooltipID
|
||||
);
|
||||
|
||||
if (!existingTooltip) {
|
||||
filteredTooltipWords.push({
|
||||
tooltipID,
|
||||
tooltipText,
|
||||
tooltipDefinition,
|
||||
tooltipWords.push({
|
||||
tooltipID,
|
||||
tooltipText,
|
||||
tooltipDefinition,
|
||||
});
|
||||
});
|
||||
return tooltipWords;
|
||||
}
|
||||
function parseBlocksTooltips(currentBlocks) {
|
||||
const blocksTooltipWords = [];
|
||||
currentBlocks.forEach((block) => {
|
||||
if (
|
||||
block.name === "homegrade-content-blocks/questions-container" &&
|
||||
block.attributes &&
|
||||
block.attributes.tooltipsWordsUsed &&
|
||||
block.attributes.tooltipsWordsUsed.length > 0
|
||||
) {
|
||||
block.attributes.tooltipsWordsUsed.forEach((tooltipWord) => {
|
||||
blocksTooltipWords.push(tooltipWord);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return blocksTooltipWords;
|
||||
}
|
||||
function buildTooltipWords() {
|
||||
let newParsedTooltipWords = parseContentTooltips(currentPost.content);
|
||||
let newBlocksTooltipWords = parseBlocksTooltips(currentBlocks);
|
||||
let allTooltipWords = [...newParsedTooltipWords, ...newBlocksTooltipWords];
|
||||
const filteredTooltipWords = filterToolTipsArray(allTooltipWords);
|
||||
|
||||
return filteredTooltipWords;
|
||||
}
|
||||
|
||||
function compareHasNewVocabularyWord(previousWords, newWords) {
|
||||
return !(JSON.stringify(previousWords) === JSON.stringify(newWords));
|
||||
}
|
||||
|
|
@ -80,6 +115,10 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
select("core/editor").getCurrentPost()
|
||||
);
|
||||
|
||||
const currentBlocks = useSelect((select) =>
|
||||
select("core/block-editor").getBlocks()
|
||||
);
|
||||
|
||||
const currentTaxonomies = useSelect((select) =>
|
||||
select("core/editor").getCurrentPostAttribute("thematiques")
|
||||
);
|
||||
|
|
@ -95,13 +134,14 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentPost.content) {
|
||||
let newTooltipWords = buildTooltipWords(currentPost.content);
|
||||
if (currentPost.content && currentBlocks) {
|
||||
const newTooltipWords = buildTooltipWords();
|
||||
|
||||
if (compareHasNewVocabularyWord(tooltipWords, newTooltipWords)) {
|
||||
setAttributes({ tooltipWords: newTooltipWords });
|
||||
}
|
||||
}
|
||||
}, [currentPost]);
|
||||
}, [currentPost, currentBlocks]);
|
||||
|
||||
return (
|
||||
<section
|
||||
|
|
|
|||