diff --git a/public/assets/css/stylesheet.css b/public/assets/css/stylesheet.css index ea6e1c4..f7710ce 100644 --- a/public/assets/css/stylesheet.css +++ b/public/assets/css/stylesheet.css @@ -1,3 +1,20 @@ +@page { + size: A4; + margin: 20mm 15mm 26mm 15mm; +} + +@page { + @bottom-center { content: string(title); } +} + +h2 { + break-before: page; +} + +.chapter > h2 { + string-set: title content(text); +} + #chapter-2 { font-size: 2rem; } diff --git a/src/App.vue b/src/App.vue index 99dca4e..b5d616a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,59 +1,33 @@ diff --git a/src/components/EditorPanel.vue b/src/components/EditorPanel.vue deleted file mode 100644 index 4eedd0f..0000000 --- a/src/components/EditorPanel.vue +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - diff --git a/src/components/editor/EditorPanel.vue b/src/components/editor/EditorPanel.vue new file mode 100644 index 0000000..4207ce3 --- /dev/null +++ b/src/components/editor/EditorPanel.vue @@ -0,0 +1,84 @@ + + + + + + + diff --git a/src/components/editor/PageSettings.vue b/src/components/editor/PageSettings.vue new file mode 100644 index 0000000..2bd7f21 --- /dev/null +++ b/src/components/editor/PageSettings.vue @@ -0,0 +1,360 @@ + + + Réglage des pages + + + Format d'impression + + A4 + A5 + A3 + Letter + Legal + + + + + Largeur + + + + + Hauteur + + + + + Marges + + + Haut + + + + + mm + + + px + + + + + + + Bas + + + + + mm + + + px + + + + + + + Gauche + + + + + mm + + + px + + + + + + + Droite + + + + + mm + + + px + + + + + + + + Arrière-plan + + + + + rgb + + + hex + + + + + + + Motif + + Choisissez + Points + Lignes + Grille + + + + + + Numéro de page + + + + + Titre courant + + + + + diff --git a/src/components/editor/TextSettings.vue b/src/components/editor/TextSettings.vue new file mode 100644 index 0000000..a72a39f --- /dev/null +++ b/src/components/editor/TextSettings.vue @@ -0,0 +1,604 @@ + + + Réglage du texte + + Ces réglages s'appliquent à l'ensemble des éléments du document. + Vous pouvez modifier ensuite les éléments indépendamment. + + + + Police + + + Alegreya Sans + Arial + Georgia + Helvetica + Times New Roman + + + + Italique + + + + + + Graisse + + + 200 + + + 300 + + + 400 + + + 600 + + + 800 + + + normal + + + bold + + + + + + Taille du texte + + + + + + px + + + em + + + rem + + + + + + + Alignement + + Gauche + Centre + Droite + Justifié + + + + + Couleur + + + + + + rgb + + + hex + + + × + + + + + + + Arrière-plan + + + × + + + + + rgb + + + hex + + + × + + + + + + + Marges extérieures + + + + + mm + + + px + + + + ▶ + + + + + + + Haut + + + + + mm + + + px + + + + + + + Bas + + + + + mm + + + px + + + + + + + Gauche + + + + + mm + + + px + + + + + + + Droite + + + + + mm + + + px + + + + + + + + Marges intérieures + + + + + mm + + + px + + + + ▶ + + + + + + + Haut + + + + + mm + + + px + + + + + + + Bas + + + + + mm + + + px + + + + + + + Gauche + + + + + mm + + + px + + + + + + + Droite + + + + + mm + + + px + + + + + + + + + diff --git a/src/utils/css-parsing.js b/src/utils/css-parsing.js index 2696347..08edd4c 100644 --- a/src/utils/css-parsing.js +++ b/src/utils/css-parsing.js @@ -1,33 +1,9 @@ -/** - * CSS parsing utilities for extracting and manipulating CSS rules - * @module css-parsing - */ - -/** - * Extracts a complete CSS block for a given selector - * @param {string} css - The CSS stylesheet content - * @param {string} selector - The CSS selector to find (e.g., '@page', '.my-class') - * @returns {string} The matched CSS block including selector and braces, or empty string if not found - * @example - * const css = '@page { margin: 20mm; }'; - * extractCssBlock(css, '@page'); // '@page { margin: 20mm; }' - */ const extractCssBlock = (css, selector) => { const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const match = css.match(new RegExp(`${escaped}\\s*{[^}]*}`, 'gi')); return match ? match[0] : ''; }; -/** - * Extracts a CSS property value and its unit from a stylesheet - * @param {string} css - The CSS stylesheet content - * @param {string} selector - The CSS selector to search within - * @param {string} property - The CSS property name to extract - * @returns {{value: number, unit: string}|null} Object with numeric value and unit, or null if not found - * @example - * const css = '@page { margin: 20mm; }'; - * extractCssValue(css, '@page', 'margin'); // { value: 20, unit: 'mm' } - */ const extractCssValue = (css, selector, property) => { const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const regex = new RegExp( @@ -38,26 +14,17 @@ const extractCssValue = (css, selector, property) => { return match ? { value: parseFloat(match[1]), unit: match[2] } : null; }; -/** - * Updates a CSS property value in a stylesheet - * @param {Object} options - Configuration object - * @param {string} options.css - The CSS stylesheet content to modify - * @param {string} options.selector - The CSS selector to target - * @param {string} options.property - The CSS property to update - * @param {number} options.value - The new numeric value - * @param {string} options.unit - The CSS unit (px, rem, em, mm, cm, in, etc.) - * @returns {string} The modified CSS stylesheet content - * @example - * updateCssValue({ - * css: '@page { margin: 20mm; }', - * selector: '@page', - * property: 'margin', - * value: 30, - * unit: 'mm' - * }); // '@page { margin: 30mm; }' - */ const updateCssValue = ({ css, selector, property, value, unit }) => { const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + + if (unit === '') { + const regex = new RegExp( + `(${escaped}\\s*{[^}]*${property}:\\s*)[^;]+`, + 'gi' + ); + return css.replace(regex, `$1${value}`); + } + const regex = new RegExp( `(${escaped}\\s*{[^}]*${property}:\\s*)[\\d.]+(px|rem|em|mm|cm|in)`, 'gi' @@ -65,13 +32,6 @@ const updateCssValue = ({ css, selector, property, value, unit }) => { return css.replace(regex, `$1${value}${unit}`); }; -/** - * Collection of CSS parsing utilities - * @type {Object} - * @property {Function} extractCssBlock - Extract a CSS block by selector - * @property {Function} extractCssValue - Extract a property value with unit - * @property {Function} updateCssValue - Update a property value in CSS - */ const cssParsingUtils = { extractCssBlock, extractCssValue, updateCssValue }; export default cssParsingUtils;
+ Ces réglages s'appliquent à l'ensemble des éléments du document. + Vous pouvez modifier ensuite les éléments indépendamment. +