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>
|
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
|
|
|
|
2026-03-05 15:59:38 +01:00
|
|
|
<!-- Interlignage -->
|
|
|
|
|
<div class="settings-subsection">
|
|
|
|
|
<div class="field field-text-size">
|
|
|
|
|
<label for="text-lineheight-range" class="label-with-tooltip" data-css="line-height">Interlignage</label>
|
|
|
|
|
<InputWithUnit
|
|
|
|
|
v-model="lineHeight"
|
|
|
|
|
:units="['px']"
|
|
|
|
|
:min="0"
|
|
|
|
|
:max="72"
|
|
|
|
|
showRange
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
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');
|
2025-12-05 16:30:44 +01:00
|
|
|
const fontSize = ref({ value: 16, unit: 'px' });
|
2026-03-05 15:59:38 +01:00
|
|
|
const lineHeight = ref({ value: 20, unit: 'px' });
|
2025-12-05 16:30:44 +01:00
|
|
|
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) => {
|
2026-03-05 15:59:38 +01:00
|
|
|
textDefaults.fontFamily = val;
|
2026-01-09 16:42:34 +01:00
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
updateStyle('body', 'font-family', `"${val}"`);
|
2026-03-05 15:59:38 +01:00
|
|
|
}, { immediate: 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
|
|
|
watch(color, (val) => {
|
2026-03-05 15:59:38 +01:00
|
|
|
textDefaults.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);
|
2026-03-05 15:59:38 +01:00
|
|
|
}, { immediate: true });
|
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
|
|
|
|
2026-03-05 15:59:38 +01:00
|
|
|
watch(lineHeight, (val) => {
|
|
|
|
|
textDefaults.lineHeight = { value: val.value, unit: val.unit };
|
|
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
debouncedUpdate(() => {
|
|
|
|
|
updateStyle('p', 'line-height', `${val.value}${val.unit}`);
|
|
|
|
|
});
|
|
|
|
|
}, { deep: true, immediate: 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
|
|
|
// 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
|
|
|
const colorVal = extractValue('body', 'color');
|
|
|
|
|
if (colorVal) color.value = colorVal;
|
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
|
|
|
|
2026-03-05 15:59:38 +01:00
|
|
|
const lineHeightVal = extractNumericValue('p', 'line-height', ['px']);
|
|
|
|
|
if (lineHeightVal) lineHeight.value = lineHeightVal;
|
|
|
|
|
|
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
|
|
|
|