Compare commits
6 Commits
9f7cdb7fe2
...
9221cb9616
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9221cb9616 | ||
|
|
a0b8972a8b | ||
|
|
4b1baf1bb3 | ||
|
|
838653f522 | ||
|
|
f494836760 | ||
|
|
f705d748ef |
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -7,6 +7,8 @@
|
|||
!plugins/dynamiques-blocks/**
|
||||
!plugins/carhop-blocks/
|
||||
!plugins/carhop-blocks/**
|
||||
!plugins/carhop-format-types/
|
||||
!plugins/carhop-format-types/**
|
||||
plugins/advanced-custom-fields-pro/
|
||||
plugins/advanced-custom-fields-pro/**
|
||||
!.drone.yml
|
||||
|
|
|
|||
61
plugins/carhop-format-types/build/index-rtl.css
Normal file
61
plugins/carhop-format-types/build/index-rtl.css
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
plugins/carhop-format-types/build/index.asset.php
Normal file
1
plugins/carhop-format-types/build/index.asset.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => '71f06791f6231465e42e');
|
||||
63
plugins/carhop-format-types/build/index.css
Normal file
63
plugins/carhop-format-types/build/index.css
Normal file
|
|
@ -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*/
|
||||
1
plugins/carhop-format-types/build/index.css.map
Normal file
1
plugins/carhop-format-types/build/index.css.map
Normal file
|
|
@ -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":""}
|
||||
290
plugins/carhop-format-types/build/index.js
Normal file
290
plugins/carhop-format-types/build/index.js
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./node_modules/@wordpress/icons/build-module/library/custom-post-type.js":
|
||||
/*!********************************************************************************!*\
|
||||
!*** ./node_modules/@wordpress/icons/build-module/library/custom-post-type.js ***!
|
||||
\********************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _wordpress_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
|
||||
*/
|
||||
|
||||
|
||||
const customPostType = /*#__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, {
|
||||
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"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (customPostType);
|
||||
//# sourceMappingURL=custom-post-type.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/footnote.css":
|
||||
/*!**************************!*\
|
||||
!*** ./src/footnote.css ***!
|
||||
\**************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
// extracted by mini-css-extract-plugin
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/block-editor":
|
||||
/*!*************************************!*\
|
||||
!*** external ["wp","blockEditor"] ***!
|
||||
\*************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["blockEditor"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/components":
|
||||
/*!************************************!*\
|
||||
!*** external ["wp","components"] ***!
|
||||
\************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["components"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/element":
|
||||
/*!*********************************!*\
|
||||
!*** external ["wp","element"] ***!
|
||||
\*********************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["element"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/i18n":
|
||||
/*!******************************!*\
|
||||
!*** external ["wp","i18n"] ***!
|
||||
\******************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["i18n"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/primitives":
|
||||
/*!************************************!*\
|
||||
!*** external ["wp","primitives"] ***!
|
||||
\************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["primitives"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/rich-text":
|
||||
/*!**********************************!*\
|
||||
!*** external ["wp","richText"] ***!
|
||||
\**********************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["richText"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "react/jsx-runtime":
|
||||
/*!**********************************!*\
|
||||
!*** external "ReactJSXRuntime" ***!
|
||||
\**********************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["ReactJSXRuntime"];
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // 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;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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 });
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
||||
(() => {
|
||||
/*!**********************!*\
|
||||
!*** ./src/index.js ***!
|
||||
\**********************/
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
|
||||
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var _wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/rich-text */ "@wordpress/rich-text");
|
||||
/* harmony import */ var _wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
|
||||
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* 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_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 _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__);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const formatName = "carhop-format/footnote";
|
||||
const FootnoteFormatButton = props => {
|
||||
const {
|
||||
isActive,
|
||||
value,
|
||||
onChange
|
||||
} = props;
|
||||
const [isPopoverOpen, setIsPopoverOpen] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.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(footnoteContent) {
|
||||
onChange((0,_wordpress_rich_text__WEBPACK_IMPORTED_MODULE_1__.applyFormat)(value, {
|
||||
type: formatName,
|
||||
attributes: {
|
||||
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__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Popover, {
|
||||
onClose: () => setIsPopoverOpen(false),
|
||||
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: 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: "button",
|
||||
attributes: {
|
||||
footnoteContent: "footnote-content"
|
||||
},
|
||||
className: "footnote-reference",
|
||||
edit: FootnoteFormatButton
|
||||
});
|
||||
})();
|
||||
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
plugins/carhop-format-types/build/index.js.map
Normal file
1
plugins/carhop-format-types/build/index.js.map
Normal file
File diff suppressed because one or more lines are too long
30
plugins/carhop-format-types/carhop-format-types.php
Normal file
30
plugins/carhop-format-types/carhop-format-types.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Plugin Name: Carhop Format Types
|
||||
* Description: Un série de formats sur mesure pour l'écriture du contenu de Carhop
|
||||
* Author: Deligraph
|
||||
* Text Domain: carhop-format-types
|
||||
*/
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
|
||||
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__), array(), $asset_file['version']);
|
||||
}
|
||||
|
||||
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');
|
||||
20437
plugins/carhop-format-types/package-lock.json
generated
Normal file
20437
plugins/carhop-format-types/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
plugins/carhop-format-types/package.json
Normal file
12
plugins/carhop-format-types/package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"scripts": {
|
||||
"start": "wp-scripts start",
|
||||
"build": "wp-scripts build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@wordpress/scripts": "^30.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wordpress/icons": "^10.25.0"
|
||||
}
|
||||
}
|
||||
57
plugins/carhop-format-types/src/footnote.css
Normal file
57
plugins/carhop-format-types/src/footnote.css
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
96
plugins/carhop-format-types/src/index.js
Normal file
96
plugins/carhop-format-types/src/index.js
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
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, Button } from "@wordpress/components";
|
||||
import { trash, customPostType } from "@wordpress/icons";
|
||||
import { useState } from "@wordpress/element";
|
||||
|
||||
import "./footnote.css";
|
||||
|
||||
const formatName = "carhop-format/footnote";
|
||||
|
||||
const FootnoteFormatButton = (props) => {
|
||||
const { isActive, value, onChange } = props;
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
|
||||
const activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];
|
||||
console.log(activeFormat);
|
||||
|
||||
function handleFootnoteContentChange(value) {
|
||||
setFormat(value);
|
||||
}
|
||||
|
||||
function removeFormat() {
|
||||
setIsPopoverOpen(false);
|
||||
onChange(
|
||||
toggleFormat(value, {
|
||||
type: formatName,
|
||||
})
|
||||
);
|
||||
}
|
||||
function setFormat(footnoteContent) {
|
||||
onChange(
|
||||
applyFormat(value, {
|
||||
type: formatName,
|
||||
attributes: {
|
||||
footnoteContent: footnoteContent,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<BlockControls>
|
||||
{isPopoverOpen && (
|
||||
<Popover
|
||||
onClose={() => setIsPopoverOpen(false)}
|
||||
className='popover_footnote_field'>
|
||||
<TextControl
|
||||
__nextHasNoMarginBottom
|
||||
__next40pxDefaultSize
|
||||
label='Note de bas de page'
|
||||
value={activeFormat?.attributes?.footnoteContent || ""}
|
||||
onChange={handleFootnoteContentChange}
|
||||
/>
|
||||
<div className='popover_footnote_field_buttons'>
|
||||
<Button
|
||||
variant='primary'
|
||||
onClick={() => setIsPopoverOpen(false)}>
|
||||
Ok
|
||||
</Button>
|
||||
<Button isDestructive onClick={() => removeFormat()}>
|
||||
Supprimer
|
||||
</Button>
|
||||
</div>
|
||||
</Popover>
|
||||
)}
|
||||
|
||||
<ToolbarGroup>
|
||||
<ToolbarButton
|
||||
isActive={isActive}
|
||||
icon={customPostType}
|
||||
isPressed={isActive}
|
||||
label={
|
||||
!isActive
|
||||
? "Ajouter une note de bas de page"
|
||||
: "Éditer la note de bas de page"
|
||||
}
|
||||
onClick={() => setIsPopoverOpen(true)}
|
||||
/>
|
||||
</ToolbarGroup>
|
||||
</BlockControls>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
registerFormatType(formatName, {
|
||||
title: __("Notes de bas de page", "carhop-format-types"),
|
||||
tagName: "button",
|
||||
attributes: {
|
||||
footnoteContent: "footnote-content",
|
||||
},
|
||||
className: "footnote-reference",
|
||||
edit: FootnoteFormatButton,
|
||||
});
|
||||
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array(), 'version' => '33a16438385e48e55cbd');
|
||||
<?php return array('dependencies' => array(), 'version' => '20f3a357ca2dd81394e5');
|
||||
|
|
|
|||
|
|
@ -2,31 +2,6 @@
|
|||
/*!**********************************!*\
|
||||
!*** ./src/explore-tags/view.js ***!
|
||||
\**********************************/
|
||||
/**
|
||||
* Use this file for JavaScript code that you want to run in the front-end
|
||||
* on posts/pages that contain this block.
|
||||
*
|
||||
* When this file is defined as the value of the `viewScript` property
|
||||
* in `block.json` it will be enqueued on the front end of the site.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* "viewScript": "file:./view.js"
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If you're not making any changes to this file because your project doesn't need any
|
||||
* JavaScript running in the front-end, then you should delete this file and remove
|
||||
* the `viewScript` property from `block.json`.
|
||||
*
|
||||
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script
|
||||
*/
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('Hello World! (from create-block-explore-tags block)');
|
||||
/* eslint-enable no-console */
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=view.js.map
|
||||
;
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"explore-tags/view.js","mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACAA,OAAO,CAACC,GAAG,CAAE,qDAAsD,CAAC;AACpE,8B","sources":["webpack://explore-tags/./src/explore-tags/view.js"],"sourcesContent":["/**\n * Use this file for JavaScript code that you want to run in the front-end\n * on posts/pages that contain this block.\n *\n * When this file is defined as the value of the `viewScript` property\n * in `block.json` it will be enqueued on the front end of the site.\n *\n * Example:\n *\n * ```js\n * {\n * \"viewScript\": \"file:./view.js\"\n * }\n * ```\n *\n * If you're not making any changes to this file because your project doesn't need any\n * JavaScript running in the front-end, then you should delete this file and remove\n * the `viewScript` property from `block.json`.\n *\n * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script\n */\n\n/* eslint-disable no-console */\nconsole.log( 'Hello World! (from create-block-explore-tags block)' );\n/* eslint-enable no-console */\n"],"names":["console","log"],"sourceRoot":""}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
/**
|
||||
* Use this file for JavaScript code that you want to run in the front-end
|
||||
* on posts/pages that contain this block.
|
||||
*
|
||||
* When this file is defined as the value of the `viewScript` property
|
||||
* in `block.json` it will be enqueued on the front end of the site.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* "viewScript": "file:./view.js"
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If you're not making any changes to this file because your project doesn't need any
|
||||
* JavaScript running in the front-end, then you should delete this file and remove
|
||||
* the `viewScript` property from `block.json`.
|
||||
*
|
||||
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script
|
||||
*/
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log( 'Hello World! (from create-block-explore-tags block)' );
|
||||
/* eslint-enable no-console */
|
||||
Loading…
Reference in New Issue
Block a user