diff --git a/plugins/carhop-format-types/build/index-rtl.css b/plugins/carhop-format-types/build/index-rtl.css new file mode 100644 index 0000000..4c7e45b --- /dev/null +++ b/plugins/carhop-format-types/build/index-rtl.css @@ -0,0 +1,61 @@ +/*!**********************************************************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[2].use[2]!./src/footnote.css ***! + \**********************************************************************************************************************************************************************/ +body { + counter-reset: footnote-index; +} +.footnote-reference { + counter-increment: footnote-index; + position: relative; + + &::after { + background-color: var(--wp--preset--color--primary); + color: #fff; + width: 30px; + height: 30px; + border-radius: 50%; + content: counter(footnote-index); + display: inline-flex; + justify-content: center; + align-items: center; + font-size: 0.8em; + font-weight: 600; + margin-right: 3px; + margin-left: 3px; + } +} + +// Editor +.footnote-reference { + .wp-block-post-content & { + text-decoration: underline; + text-decoration-style: dotted; + text-decoration-color: var(--wp--preset--color--primary); + text-decoration-thickness: 2px; + text-underline-offset: 2px; + } +} + +.popover_footnote_field { + .components-popover__content { + padding: 10px !important; + min-width: 300px; + } + .popover_footnote_field_buttons { + display: flex; + justify-content: flex-end; + gap: 10px; + margin-top: 10px; + + button.is-destructive { + background-color: #cc1818 !important; + color: #fff !important; + } + + button.is-primary { + background-color: var(--wp--preset--color--primary) !important; + color: #fff !important; + } + } +} + diff --git a/plugins/carhop-format-types/build/index.asset.php b/plugins/carhop-format-types/build/index.asset.php index 816f28b..4655886 100644 --- a/plugins/carhop-format-types/build/index.asset.php +++ b/plugins/carhop-format-types/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => 'd91f9a9d13264a009654'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => '71f06791f6231465e42e'); diff --git a/plugins/carhop-format-types/build/index.css b/plugins/carhop-format-types/build/index.css new file mode 100644 index 0000000..3b9dcdb --- /dev/null +++ b/plugins/carhop-format-types/build/index.css @@ -0,0 +1,63 @@ +/*!**********************************************************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[2].use[2]!./src/footnote.css ***! + \**********************************************************************************************************************************************************************/ +body { + counter-reset: footnote-index; +} +.footnote-reference { + counter-increment: footnote-index; + position: relative; + + &::after { + background-color: var(--wp--preset--color--primary); + color: #fff; + width: 30px; + height: 30px; + border-radius: 50%; + content: counter(footnote-index); + display: inline-flex; + justify-content: center; + align-items: center; + font-size: 0.8em; + font-weight: 600; + margin-left: 3px; + margin-right: 3px; + } +} + +// Editor +.footnote-reference { + .wp-block-post-content & { + text-decoration: underline; + text-decoration-style: dotted; + text-decoration-color: var(--wp--preset--color--primary); + text-decoration-thickness: 2px; + text-underline-offset: 2px; + } +} + +.popover_footnote_field { + .components-popover__content { + padding: 10px !important; + min-width: 300px; + } + .popover_footnote_field_buttons { + display: flex; + justify-content: flex-end; + gap: 10px; + margin-top: 10px; + + button.is-destructive { + background-color: #cc1818 !important; + color: #fff !important; + } + + button.is-primary { + background-color: var(--wp--preset--color--primary) !important; + color: #fff !important; + } + } +} + + +/*# sourceMappingURL=index.css.map*/ \ No newline at end of file diff --git a/plugins/carhop-format-types/build/index.css.map b/plugins/carhop-format-types/build/index.css.map new file mode 100644 index 0000000..696dc5f --- /dev/null +++ b/plugins/carhop-format-types/build/index.css.map @@ -0,0 +1 @@ +{"version":3,"file":"index.css","mappings":";;;AAAA;CACC,6BAA6B;AAC9B;AACA;CACC,iCAAiC;CACjC,kBAAkB;;CAElB;EACC,mDAAmD;EACnD,WAAW;EACX,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB,gCAAgC;EAChC,oBAAoB;EACpB,uBAAuB;EACvB,mBAAmB;EACnB,gBAAgB;EAChB,gBAAgB;EAChB,gBAAgB;EAChB,iBAAiB;CAClB;AACD;;AAEA;;CAEC;EACC,0BAA0B;EAC1B,6BAA6B;EAC7B,wDAAwD;EACxD,8BAA8B;EAC9B,0BAA0B;CAC3B;AACD;;AAEA;CACC;EACC,wBAAwB;EACxB,gBAAgB;CACjB;CACA;EACC,aAAa;EACb,yBAAyB;EACzB,SAAS;EACT,gBAAgB;;EAEhB;GACC,oCAAoC;GACpC,sBAAsB;EACvB;;EAEA;GACC,8DAA8D;GAC9D,sBAAsB;EACvB;CACD;AACD","sources":["webpack:///./src/footnote.css"],"sourcesContent":["body {\r\n\tcounter-reset: footnote-index;\r\n}\r\n.footnote-reference {\r\n\tcounter-increment: footnote-index;\r\n\tposition: relative;\r\n\r\n\t&::after {\r\n\t\tbackground-color: var(--wp--preset--color--primary);\r\n\t\tcolor: #fff;\r\n\t\twidth: 30px;\r\n\t\theight: 30px;\r\n\t\tborder-radius: 50%;\r\n\t\tcontent: counter(footnote-index);\r\n\t\tdisplay: inline-flex;\r\n\t\tjustify-content: center;\r\n\t\talign-items: center;\r\n\t\tfont-size: 0.8em;\r\n\t\tfont-weight: 600;\r\n\t\tmargin-left: 3px;\r\n\t\tmargin-right: 3px;\r\n\t}\r\n}\r\n\r\n// Editor\r\n.footnote-reference {\r\n\t.wp-block-post-content & {\r\n\t\ttext-decoration: underline;\r\n\t\ttext-decoration-style: dotted;\r\n\t\ttext-decoration-color: var(--wp--preset--color--primary);\r\n\t\ttext-decoration-thickness: 2px;\r\n\t\ttext-underline-offset: 2px;\r\n\t}\r\n}\r\n\r\n.popover_footnote_field {\r\n\t.components-popover__content {\r\n\t\tpadding: 10px !important;\r\n\t\tmin-width: 300px;\r\n\t}\r\n\t.popover_footnote_field_buttons {\r\n\t\tdisplay: flex;\r\n\t\tjustify-content: flex-end;\r\n\t\tgap: 10px;\r\n\t\tmargin-top: 10px;\r\n\r\n\t\tbutton.is-destructive {\r\n\t\t\tbackground-color: #cc1818 !important;\r\n\t\t\tcolor: #fff !important;\r\n\t\t}\r\n\r\n\t\tbutton.is-primary {\r\n\t\t\tbackground-color: var(--wp--preset--color--primary) !important;\r\n\t\t\tcolor: #fff !important;\r\n\t\t}\r\n\t}\r\n}\r\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/plugins/carhop-format-types/build/index.js b/plugins/carhop-format-types/build/index.js index 8cc23b2..2eb6744 100644 --- a/plugins/carhop-format-types/build/index.js +++ b/plugins/carhop-format-types/build/index.js @@ -33,37 +33,16 @@ const customPostType = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODUL /***/ }), -/***/ "./node_modules/@wordpress/icons/build-module/library/trash.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@wordpress/icons/build-module/library/trash.js ***! - \*********************************************************************/ +/***/ "./src/footnote.css": +/*!**************************!*\ + !*** ./src/footnote.css ***! + \**************************/ /***/ ((__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_primitives__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/primitives */ "@wordpress/primitives"); -/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__); -/** - * WordPress dependencies - */ +// extracted by mini-css-extract-plugin -const trash = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24", - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__.Path, { - fillRule: "evenodd", - clipRule: "evenodd", - d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" - }) -}); -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (trash); -//# sourceMappingURL=trash.js.map - /***/ }), /***/ "@wordpress/block-editor": @@ -86,16 +65,6 @@ module.exports = window["wp"]["components"]; /***/ }), -/***/ "@wordpress/data": -/*!******************************!*\ - !*** external ["wp","data"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["data"]; - -/***/ }), - /***/ "@wordpress/element": /*!*********************************!*\ !*** external ["wp","element"] ***! @@ -230,11 +199,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _wordpress_icons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @wordpress/icons */ "./node_modules/@wordpress/icons/build-module/library/custom-post-type.js"); -/* harmony import */ var _wordpress_icons__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @wordpress/icons */ "./node_modules/@wordpress/icons/build-module/library/trash.js"); /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var _footnote_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./footnote.css */ "./src/footnote.css"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__); @@ -243,72 +210,78 @@ __webpack_require__.r(__webpack_exports__); - // pour les querry + const formatName = "carhop-format/footnote"; -const EditFormatButton = props => { +const FootnoteFormatButton = props => { const { isActive, value, onChange } = props; const [isPopoverOpen, setIsPopoverOpen] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(false); - // const [pendingDefinition, setPendingDefinition] = useState(false); - const activeFormat = (0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.getActiveFormats)(value).filter(format => format.type === formatName)[0]; + console.log(activeFormat); + function handleFootnoteContentChange(value) { + setFormat(value); + } function removeFormat() { setIsPopoverOpen(false); onChange((0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.toggleFormat)(value, { type: formatName })); } - function setFormat(postDatas) { - setIsPopoverOpen(false); + function setFormat(footnoteContent) { onChange((0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.applyFormat)(value, { type: formatName, attributes: { - // definitionId: postDatas.id.toString(), - // dataTooltipWord: postDatas.title, + footnoteContent: footnoteContent } })); } return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.Fragment, { children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.BlockControls, { - children: [isPopoverOpen && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Popover, { + children: [isPopoverOpen && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Popover, { onClose: () => setIsPopoverOpen(false), - className: "popover_tooltip_field", - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.TextControl, { + className: "popover_footnote_field", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.TextControl, { __nextHasNoMarginBottom: true, __next40pxDefaultSize: true, label: "Note de bas de page", - value: value, - onChange: value => setFormat(value) - }) - }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarGroup, { - children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton, { - isActive: isActive, - icon: !isActive ? _wordpress_icons__WEBPACK_IMPORTED_MODULE_7__["default"] : "edit", - label: !isActive ? "Ajouter une note de bas de page" : "Éditer la note de bas de page", - onClick: () => { - setFormat(); - setIsPopoverOpen(true); - } - }), isActive && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton, { - icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_8__["default"], - label: "Supprimer la note de bas de page", - onClick: () => { - removeFormat(); - } + value: activeFormat?.attributes?.footnoteContent || "", + onChange: handleFootnoteContentChange + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", { + className: "popover_footnote_field_buttons", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Button, { + variant: "primary", + onClick: () => setIsPopoverOpen(false), + children: "Ok" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Button, { + isDestructive: true, + onClick: () => removeFormat(), + children: "Supprimer" + })] })] + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarGroup, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.ToolbarButton, { + isActive: isActive, + icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_7__["default"], + isPressed: isActive, + label: !isActive ? "Ajouter une note de bas de page" : "Éditer la note de bas de page", + onClick: () => setIsPopoverOpen(true) + }) })] }) }); }; (0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.registerFormatType)(formatName, { title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Notes de bas de page", "carhop-format-types"), - tagName: "span", + tagName: "button", + attributes: { + footnoteContent: "footnote-content" + }, className: "footnote-reference", - edit: EditFormatButton + edit: FootnoteFormatButton }); })(); diff --git a/plugins/carhop-format-types/build/index.js.map b/plugins/carhop-format-types/build/index.js.map index 0383fae..4b611e9 100644 --- a/plugins/carhop-format-types/build/index.js.map +++ b/plugins/carhop-format-types/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":"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","sources":["webpack:///./node_modules/@wordpress/icons/build-module/library/custom-post-type.js","webpack:///./node_modules/@wordpress/icons/build-module/library/trash.js","webpack:///external window [\"wp\",\"blockEditor\"]","webpack:///external window [\"wp\",\"components\"]","webpack:///external window [\"wp\",\"data\"]","webpack:///external window [\"wp\",\"element\"]","webpack:///external window [\"wp\",\"i18n\"]","webpack:///external window [\"wp\",\"primitives\"]","webpack:///external window [\"wp\",\"richText\"]","webpack:///external window \"ReactJSXRuntime\"","webpack:///webpack/bootstrap","webpack:///webpack/runtime/compat get default export","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst customPostType = /*#__PURE__*/_jsx(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\",\n children: /*#__PURE__*/_jsx(Path, {\n d: \"M4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4zm.8-4l.7.7 2-2V12h1V9.2l2 2 .7-.7-2-2H12v-1H9.2l2-2-.7-.7-2 2V4h-1v2.8l-2-2-.7.7 2 2H4v1h2.8l-2 2z\"\n })\n});\nexport default customPostType;\n//# sourceMappingURL=custom-post-type.js.map","/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst trash = /*#__PURE__*/_jsx(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\",\n children: /*#__PURE__*/_jsx(Path, {\n fillRule: \"evenodd\",\n clipRule: \"evenodd\",\n d: \"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z\"\n })\n});\nexport default trash;\n//# sourceMappingURL=trash.js.map","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"wp\"][\"richText\"];","module.exports = window[\"ReactJSXRuntime\"];","// 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","// 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};","import { __ } from \"@wordpress/i18n\";\r\nimport { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from \"@wordpress/rich-text\";\r\n\r\nimport { BlockControls, __experimentalLinkControl as LinkControl } from \"@wordpress/block-editor\";\r\nimport { Popover, ToolbarGroup, ToolbarButton, TextControl } from \"@wordpress/components\";\r\nimport { trash, customPostType } from \"@wordpress/icons\";\r\nimport { useState } from \"@wordpress/element\";\r\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\r\n\r\nconst formatName = \"carhop-format/footnote\";\r\n\r\nconst EditFormatButton = (props) => {\r\n\tconst { isActive, value, onChange } = props;\r\n\tconst [isPopoverOpen, setIsPopoverOpen] = useState(false);\r\n\t// const [pendingDefinition, setPendingDefinition] = useState(false);\r\n\r\n\tconst activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];\r\n\r\n\tfunction removeFormat() {\r\n\t\tsetIsPopoverOpen(false);\r\n\t\tonChange(\r\n\t\t\ttoggleFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\tfunction setFormat(postDatas) {\r\n\t\tsetIsPopoverOpen(false);\r\n\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\t// definitionId: postDatas.id.toString(),\r\n\t\t\t\t\t// dataTooltipWord: postDatas.title,\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t\r\n\t\t\t\t{isPopoverOpen && (\r\n\t\t\t\t\t setIsPopoverOpen(false)}\r\n\t\t\t\t\t\tclassName='popover_tooltip_field'>\r\n\t\t\t\t\t\t setFormat(value)}\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\t\tsetFormat();\r\n\t\t\t\t\t\t\tsetIsPopoverOpen(true);\r\n\t\t\t\t\t\t}}\r\n\t\t\t\t\t/>\r\n\t\t\t\t\t{isActive && (\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t\tremoveFormat();\r\n\t\t\t\t\t\t\t}}\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t)}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t);\r\n};\r\n\r\nregisterFormatType(formatName, {\r\n\ttitle: __(\"Notes de bas de page\", \"carhop-format-types\"),\r\n\ttagName: \"span\",\r\n\tclassName: \"footnote-reference\",\r\n\tedit: EditFormatButton,\r\n});\r\n"],"names":["__","registerFormatType","toggleFormat","applyFormat","getActiveFormats","BlockControls","__experimentalLinkControl","LinkControl","Popover","ToolbarGroup","ToolbarButton","TextControl","trash","customPostType","useState","useSelect","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","formatName","EditFormatButton","props","isActive","value","onChange","isPopoverOpen","setIsPopoverOpen","activeFormat","filter","format","type","removeFormat","setFormat","postDatas","attributes","children","onClose","className","__nextHasNoMarginBottom","__next40pxDefaultSize","label","icon","onClick","title","tagName","edit"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":"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","sources":["webpack:///./node_modules/@wordpress/icons/build-module/library/custom-post-type.js","webpack:///./src/footnote.css?0d32","webpack:///external window [\"wp\",\"blockEditor\"]","webpack:///external window [\"wp\",\"components\"]","webpack:///external window [\"wp\",\"element\"]","webpack:///external window [\"wp\",\"i18n\"]","webpack:///external window [\"wp\",\"primitives\"]","webpack:///external window [\"wp\",\"richText\"]","webpack:///external window \"ReactJSXRuntime\"","webpack:///webpack/bootstrap","webpack:///webpack/runtime/compat get default export","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst customPostType = /*#__PURE__*/_jsx(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\",\n children: /*#__PURE__*/_jsx(Path, {\n d: \"M4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4zm.8-4l.7.7 2-2V12h1V9.2l2 2 .7-.7-2-2H12v-1H9.2l2-2-.7-.7-2 2V4h-1v2.8l-2-2-.7.7 2 2H4v1h2.8l-2 2z\"\n })\n});\nexport default customPostType;\n//# sourceMappingURL=custom-post-type.js.map","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"wp\"][\"richText\"];","module.exports = window[\"ReactJSXRuntime\"];","// 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","// 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};","import { __ } from \"@wordpress/i18n\";\r\nimport { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from \"@wordpress/rich-text\";\r\n\r\nimport { BlockControls, __experimentalLinkControl as LinkControl } from \"@wordpress/block-editor\";\r\nimport { Popover, ToolbarGroup, ToolbarButton, TextControl, Button } from \"@wordpress/components\";\r\nimport { trash, customPostType } from \"@wordpress/icons\";\r\nimport { useState } from \"@wordpress/element\";\r\n\r\nimport \"./footnote.css\";\r\n\r\nconst formatName = \"carhop-format/footnote\";\r\n\r\nconst FootnoteFormatButton = (props) => {\r\n\tconst { isActive, value, onChange } = props;\r\n\tconst [isPopoverOpen, setIsPopoverOpen] = useState(false);\r\n\r\n\tconst activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];\r\n\tconsole.log(activeFormat);\r\n\r\n\tfunction handleFootnoteContentChange(value) {\r\n\t\tsetFormat(value);\r\n\t}\r\n\r\n\tfunction removeFormat() {\r\n\t\tsetIsPopoverOpen(false);\r\n\t\tonChange(\r\n\t\t\ttoggleFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\tfunction setFormat(footnoteContent) {\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\tfootnoteContent: footnoteContent,\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t\r\n\t\t\t\t{isPopoverOpen && (\r\n\t\t\t\t\t setIsPopoverOpen(false)}\r\n\t\t\t\t\t\tclassName='popover_footnote_field'>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t setIsPopoverOpen(false)}>\r\n\t\t\t\t\t\t\t\tOk\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t setIsPopoverOpen(true)}\r\n\t\t\t\t\t/>\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t\r\n\t);\r\n};\r\n\r\nregisterFormatType(formatName, {\r\n\ttitle: __(\"Notes de bas de page\", \"carhop-format-types\"),\r\n\ttagName: \"button\",\r\n\tattributes: {\r\n\t\tfootnoteContent: \"footnote-content\",\r\n\t},\r\n\tclassName: \"footnote-reference\",\r\n\tedit: FootnoteFormatButton,\r\n});\r\n"],"names":["__","registerFormatType","toggleFormat","applyFormat","getActiveFormats","BlockControls","__experimentalLinkControl","LinkControl","Popover","ToolbarGroup","ToolbarButton","TextControl","Button","trash","customPostType","useState","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","formatName","FootnoteFormatButton","props","isActive","value","onChange","isPopoverOpen","setIsPopoverOpen","activeFormat","filter","format","type","console","log","handleFootnoteContentChange","setFormat","removeFormat","footnoteContent","attributes","children","onClose","className","__nextHasNoMarginBottom","__next40pxDefaultSize","label","variant","onClick","isDestructive","icon","isPressed","title","tagName","edit"],"sourceRoot":""} \ No newline at end of file diff --git a/plugins/carhop-format-types/carhop-format-types.php b/plugins/carhop-format-types/carhop-format-types.php index 771ab8b..18df0da 100644 --- a/plugins/carhop-format-types/carhop-format-types.php +++ b/plugins/carhop-format-types/carhop-format-types.php @@ -12,12 +12,19 @@ if (! defined('ABSPATH')) { } -function carhop_format_types_enqueue_editor_assets() +function carhop_format_types_enqueue_assets() { - $asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php'); wp_enqueue_script('carhop-format-types-script', plugins_url('build/index.js', __FILE__), $asset_file['dependencies'], $asset_file['version']); - wp_enqueue_style('carhop-format-types-style', plugins_url('build/index.css', __FILE__)); + wp_enqueue_style('carhop-format-types-style', plugins_url('build/index.css', __FILE__), array(), $asset_file['version']); } -add_action('enqueue_block_editor_assets', 'carhop_format_types_enqueue_editor_assets'); +add_action('enqueue_block_editor_assets', 'carhop_format_types_enqueue_assets'); + + + +function carhop_format_types_enqueue_front_assets() +{ + wp_enqueue_style('carhop-format-types-style', plugins_url('src/footnote.css', __FILE__)); +} +add_action('wp_enqueue_scripts', 'carhop_format_types_enqueue_front_assets'); diff --git a/plugins/carhop-format-types/src/footnote.css b/plugins/carhop-format-types/src/footnote.css new file mode 100644 index 0000000..ba2f58d --- /dev/null +++ b/plugins/carhop-format-types/src/footnote.css @@ -0,0 +1,57 @@ +body { + counter-reset: footnote-index; +} +.footnote-reference { + counter-increment: footnote-index; + position: relative; + + &::after { + background-color: var(--wp--preset--color--primary); + color: #fff; + width: 30px; + height: 30px; + border-radius: 50%; + content: counter(footnote-index); + display: inline-flex; + justify-content: center; + align-items: center; + font-size: 0.8em; + font-weight: 600; + margin-left: 3px; + margin-right: 3px; + } +} + +// Editor +.footnote-reference { + .wp-block-post-content & { + text-decoration: underline; + text-decoration-style: dotted; + text-decoration-color: var(--wp--preset--color--primary); + text-decoration-thickness: 2px; + text-underline-offset: 2px; + } +} + +.popover_footnote_field { + .components-popover__content { + padding: 10px !important; + min-width: 300px; + } + .popover_footnote_field_buttons { + display: flex; + justify-content: flex-end; + gap: 10px; + margin-top: 10px; + + button.is-destructive { + background-color: #cc1818 !important; + color: #fff !important; + } + + button.is-primary { + background-color: var(--wp--preset--color--primary) !important; + color: #fff !important; + } + } +} diff --git a/plugins/carhop-format-types/src/index.js b/plugins/carhop-format-types/src/index.js index bda19be..0adb616 100644 --- a/plugins/carhop-format-types/src/index.js +++ b/plugins/carhop-format-types/src/index.js @@ -2,19 +2,24 @@ import { __ } from "@wordpress/i18n"; import { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from "@wordpress/rich-text"; import { BlockControls, __experimentalLinkControl as LinkControl } from "@wordpress/block-editor"; -import { Popover, ToolbarGroup, ToolbarButton, TextControl } from "@wordpress/components"; +import { Popover, ToolbarGroup, ToolbarButton, TextControl, Button } from "@wordpress/components"; import { trash, customPostType } from "@wordpress/icons"; import { useState } from "@wordpress/element"; -import { useSelect } from "@wordpress/data"; // pour les querry + +import "./footnote.css"; const formatName = "carhop-format/footnote"; -const EditFormatButton = (props) => { +const FootnoteFormatButton = (props) => { const { isActive, value, onChange } = props; const [isPopoverOpen, setIsPopoverOpen] = useState(false); - // const [pendingDefinition, setPendingDefinition] = useState(false); const activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0]; + console.log(activeFormat); + + function handleFootnoteContentChange(value) { + setFormat(value); + } function removeFormat() { setIsPopoverOpen(false); @@ -24,15 +29,12 @@ const EditFormatButton = (props) => { }) ); } - function setFormat(postDatas) { - setIsPopoverOpen(false); - + function setFormat(footnoteContent) { onChange( applyFormat(value, { type: formatName, attributes: { - // definitionId: postDatas.id.toString(), - // dataTooltipWord: postDatas.title, + footnoteContent: footnoteContent, }, }) ); @@ -44,40 +46,39 @@ const EditFormatButton = (props) => { {isPopoverOpen && ( setIsPopoverOpen(false)} - className='popover_tooltip_field'> + className='popover_footnote_field'> setFormat(value)} + value={activeFormat?.attributes?.footnoteContent || ""} + onChange={handleFootnoteContentChange} /> +
+ + +
)} { - setFormat(); - setIsPopoverOpen(true); - }} + onClick={() => setIsPopoverOpen(true)} /> - {isActive && ( - { - removeFormat(); - }} - /> - )} @@ -86,7 +87,10 @@ const EditFormatButton = (props) => { registerFormatType(formatName, { title: __("Notes de bas de page", "carhop-format-types"), - tagName: "span", + tagName: "button", + attributes: { + footnoteContent: "footnote-content", + }, className: "footnote-reference", - edit: EditFormatButton, + edit: FootnoteFormatButton, });