2025-12-03 15:20:49 +01:00
|
|
|
<template>
|
2025-12-10 11:10:14 +01:00
|
|
|
<section class="settings-section" id="settings-section_elem" data-color-type="elem">
|
2026-03-05 11:42:18 +01:00
|
|
|
<h2>Réglage du texte par défaut</h2>
|
2025-12-09 17:08:40 +01:00
|
|
|
<div class="container">
|
|
|
|
|
|
2025-12-03 15:20:49 +01:00
|
|
|
<p class="infos">
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
Ces réglages s'appliquent à l'ensemble des éléments du document. Vous
|
|
|
|
|
pouvez modifier ensuite les éléments indépendamment.
|
2025-12-03 15:20:49 +01:00
|
|
|
</p>
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
<!-- Police -->
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="settings-subsection">
|
2025-12-09 17:08:40 +01:00
|
|
|
<div class="field field-font">
|
2026-02-24 15:08:08 +01:00
|
|
|
<label for="text-font" class="label-with-tooltip field--view-only" data-css="font-family" title="Fonctionnalité à venir">Police</label>
|
2026-03-05 11:08:44 +01:00
|
|
|
<div class="field-font__options">
|
2026-02-24 15:08:08 +01:00
|
|
|
<select id="text-font" v-model="font" disabled class="field--view-only" title="Fonctionnalité à venir">
|
2025-12-05 16:30:44 +01:00
|
|
|
<option v-for="f in fonts" :key="f" :value="f">{{ f }}</option>
|
2025-12-04 16:21:50 +01:00
|
|
|
</select>
|
|
|
|
|
<div class="field-checkbox">
|
|
|
|
|
<input id="text-italic" type="checkbox" v-model="italic" />
|
2025-12-05 18:21:54 +01:00
|
|
|
<label for="text-italic" class="label-with-tooltip" data-css="font-style">Italique</label>
|
2025-12-04 16:21:50 +01:00
|
|
|
</div>
|
2026-03-05 11:42:18 +01:00
|
|
|
<div class="field-checkbox">
|
|
|
|
|
<input id="text-bold" type="checkbox" v-model="bold" />
|
|
|
|
|
<label for="text-bold" class="label-with-tooltip" data-css="font-weight">Gras</label>
|
|
|
|
|
</div>
|
2025-12-03 15:20:49 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
<!-- Taille du texte -->
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="settings-subsection">
|
2025-12-11 13:38:27 +01:00
|
|
|
<div class="field field-text-size">
|
2025-12-05 18:21:54 +01:00
|
|
|
<label for="text-size-range" class="label-with-tooltip" data-css="font-size">Taille du texte</label>
|
2025-12-05 16:30:44 +01:00
|
|
|
<InputWithUnit
|
|
|
|
|
v-model="fontSize"
|
2026-02-24 14:16:54 +01:00
|
|
|
:units="['px']"
|
2025-12-05 16:30:44 +01:00
|
|
|
:min="8"
|
|
|
|
|
:max="72"
|
|
|
|
|
showRange
|
|
|
|
|
/>
|
2025-12-03 15:20:49 +01:00
|
|
|
</div>
|
2025-12-04 16:21:50 +01:00
|
|
|
</div>
|
2025-12-03 15:20:49 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
<!-- Couleurs -->
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="settings-subsection">
|
2025-12-09 17:08:40 +01:00
|
|
|
<div class="field field-simple">
|
2025-12-05 18:21:54 +01:00
|
|
|
<label for="text-color" class="label-with-tooltip" data-css="color">Couleur</label>
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="input-with-color">
|
2025-12-03 15:20:49 +01:00
|
|
|
<input
|
2026-02-24 14:02:33 +01:00
|
|
|
ref="colorInput"
|
2025-12-04 16:21:50 +01:00
|
|
|
id="text-color"
|
|
|
|
|
type="text"
|
2025-12-05 16:30:44 +01:00
|
|
|
v-model="color"
|
2025-12-04 16:21:50 +01:00
|
|
|
class="color-input"
|
|
|
|
|
data-coloris
|
2025-12-03 15:20:49 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-09 17:08:40 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2025-12-03 15:20:49 +01:00
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-12-04 16:21:50 +01:00
|
|
|
import { ref, watch, onMounted } from 'vue';
|
2026-02-26 15:35:45 +01:00
|
|
|
import { initColoris } from '../../composables/useColoris';
|
2025-12-05 16:30:44 +01:00
|
|
|
import InputWithUnit from '../ui/InputWithUnit.vue';
|
|
|
|
|
import { useCssUpdater } from '../../composables/useCssUpdater';
|
|
|
|
|
import { useCssSync } from '../../composables/useCssSync';
|
2025-12-10 11:51:53 +01:00
|
|
|
import { useDebounce } from '../../composables/useDebounce';
|
2026-03-05 14:49:58 +01:00
|
|
|
import { useTextDefaults } from '../../composables/useTextDefaults';
|
2025-12-05 16:30:44 +01:00
|
|
|
|
2026-03-05 11:42:18 +01:00
|
|
|
const { updateStyle } = useCssUpdater();
|
|
|
|
|
const { extractValue, extractNumericValue } = useCssSync();
|
2025-12-10 11:51:53 +01:00
|
|
|
const { debouncedUpdate } = useDebounce(500);
|
2026-03-05 14:49:58 +01:00
|
|
|
const textDefaults = useTextDefaults();
|
2025-12-05 16:30:44 +01:00
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
|
const fonts = ['Alegreya Sans', 'Arial', 'Georgia', 'Helvetica', 'Times New Roman'];
|
|
|
|
|
|
|
|
|
|
// State
|
2025-12-03 15:20:49 +01:00
|
|
|
const font = ref('Alegreya Sans');
|
|
|
|
|
const italic = ref(false);
|
2026-03-05 11:42:18 +01:00
|
|
|
const bold = ref(false);
|
2025-12-05 16:30:44 +01:00
|
|
|
const fontSize = ref({ value: 16, unit: 'px' });
|
|
|
|
|
const color = ref('rgb(0, 0, 0)');
|
2026-02-24 14:02:33 +01:00
|
|
|
const colorInput = ref(null);
|
2025-12-03 15:20:49 +01:00
|
|
|
|
2026-02-26 15:35:45 +01:00
|
|
|
let isUpdatingFromStore = false;
|
2025-12-05 16:35:53 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Watchers for body styles
|
2026-01-09 16:42:34 +01:00
|
|
|
watch(font, (val) => {
|
|
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
updateStyle('body', 'font-family', `"${val}"`);
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
watch(italic, (val) => {
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
if (isUpdatingFromStore) return;
|
2026-02-24 15:03:50 +01:00
|
|
|
updateStyle('p', 'font-style', val ? 'italic' : 'normal');
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
watch(color, (val) => {
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
if (isUpdatingFromStore) return;
|
2025-12-05 16:30:44 +01:00
|
|
|
updateStyle('body', 'color', val);
|
2025-12-03 15:20:49 +01:00
|
|
|
});
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Watchers for paragraph styles
|
2026-03-05 11:42:18 +01:00
|
|
|
watch(bold, (val) => {
|
2025-12-05 16:30:44 +01:00
|
|
|
if (isUpdatingFromStore) return;
|
2026-03-05 11:42:18 +01:00
|
|
|
updateStyle('p', 'font-weight', val ? 'bold' : 'normal');
|
2025-12-05 16:30:44 +01:00
|
|
|
});
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
watch(fontSize, (val) => {
|
2026-03-05 14:49:58 +01:00
|
|
|
textDefaults.fontSize = { value: val.value, unit: val.unit };
|
2025-12-05 16:30:44 +01:00
|
|
|
if (isUpdatingFromStore) return;
|
2025-12-10 11:51:53 +01:00
|
|
|
debouncedUpdate(() => {
|
|
|
|
|
updateStyle('p', 'font-size', `${val.value}${val.unit}`);
|
|
|
|
|
});
|
2026-03-05 14:49:58 +01:00
|
|
|
}, { deep: true, immediate: true });
|
2025-12-05 16:18:31 +01:00
|
|
|
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Sync from store
|
|
|
|
|
const syncFromStore = () => {
|
|
|
|
|
isUpdatingFromStore = true;
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Body styles
|
2026-02-24 15:03:50 +01:00
|
|
|
const fontStyle = extractValue('p', 'font-style');
|
2025-12-05 16:30:44 +01:00
|
|
|
if (fontStyle) italic.value = fontStyle === 'italic';
|
refactor: optimize EditorPanel updates with selective debouncing
Implement immediate vs debounced updates based on input type to improve
UX responsiveness while preventing excessive re-renders.
Update strategy:
- Immediate (0ms): select, buttons, checkboxes, color picker
- Debounced (1s): text inputs, number inputs, range sliders
Changes:
- PageSettings.vue: Split watchers for margin values/units and background
value/format. Extract update logic into reusable functions.
- TextSettings.vue: Add comprehensive watcher system with selective
debouncing for all settings (font, size, color, margins, etc.)
This ensures button clicks (unit toggles, format switches) apply instantly
while typed values (numbers, text) batch updates to reduce CSS re-parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:03:40 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
const colorVal = extractValue('body', 'color');
|
|
|
|
|
if (colorVal) color.value = colorVal;
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Paragraph styles
|
|
|
|
|
const fontWeight = extractValue('p', 'font-weight');
|
2026-03-05 11:42:18 +01:00
|
|
|
if (fontWeight) bold.value = fontWeight === 'bold' || parseInt(fontWeight) >= 700;
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2026-02-24 14:16:54 +01:00
|
|
|
const fontSizeVal = extractNumericValue('p', 'font-size', ['px']); // ['px', 'em', 'rem']
|
2025-12-05 16:30:44 +01:00
|
|
|
if (fontSizeVal) fontSize.value = fontSizeVal;
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
isUpdatingFromStore = false;
|
|
|
|
|
};
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2026-02-24 14:02:33 +01:00
|
|
|
const updateColorisButtons = () => {
|
2026-03-05 11:42:18 +01:00
|
|
|
if (colorInput.value) {
|
|
|
|
|
colorInput.value.dispatchEvent(new Event('input', { bubbles: true }));
|
|
|
|
|
}
|
2026-02-24 14:02:33 +01:00
|
|
|
};
|
|
|
|
|
|
2025-12-04 16:21:50 +01:00
|
|
|
onMounted(() => {
|
2026-02-26 15:35:45 +01:00
|
|
|
initColoris({
|
2025-12-04 16:21:50 +01:00
|
|
|
format: 'auto',
|
2026-02-26 15:35:45 +01:00
|
|
|
swatches: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', 'transparent'],
|
2025-12-04 16:21:50 +01:00
|
|
|
});
|
2025-12-05 16:18:31 +01:00
|
|
|
syncFromStore();
|
2026-02-24 14:02:33 +01:00
|
|
|
setTimeout(updateColorisButtons, 100);
|
2025-12-04 16:21:50 +01:00
|
|
|
});
|
2025-12-03 15:20:49 +01:00
|
|
|
</script>
|
2025-12-10 13:47:49 +01:00
|
|
|
|