2025-12-03 15:20:49 +01:00
|
|
|
<template>
|
2025-12-09 17:08:40 +01:00
|
|
|
<section class="settings-section" id="settings-section_text">
|
2025-12-03 15:20:49 +01:00
|
|
|
<h2>Réglage du texte</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">
|
2025-12-05 18:21:54 +01:00
|
|
|
<label for="text-font" class="label-with-tooltip" data-css="font-family">Police</label>
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="field-with-option">
|
|
|
|
|
<select id="text-font" v-model="font">
|
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>
|
2025-12-03 15:20:49 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
<!-- Graisse -->
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="settings-subsection">
|
|
|
|
|
<div class="field">
|
2025-12-05 18:21:54 +01:00
|
|
|
<label class="label-with-tooltip" data-css="font-weight">Graisse</label>
|
2025-12-05 16:30:44 +01:00
|
|
|
<UnitToggle v-model="weight" :units="weights" />
|
2025-12-03 15:20:49 +01:00
|
|
|
</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-03 15:20:49 +01:00
|
|
|
<div class="field">
|
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"
|
|
|
|
|
:units="['px', 'em', 'rem']"
|
|
|
|
|
: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
|
|
|
<!-- Alignement -->
|
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-alignment" class="label-with-tooltip" data-css="text-align">Alignement</label>
|
2025-12-04 16:21:50 +01:00
|
|
|
<select id="text-alignment" v-model="alignment">
|
2025-12-05 16:30:44 +01:00
|
|
|
<option v-for="a in alignments" :key="a.value" :value="a.value">
|
|
|
|
|
{{ a.label }}
|
|
|
|
|
</option>
|
2025-12-04 16:21:50 +01:00
|
|
|
</select>
|
|
|
|
|
</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
|
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>
|
|
|
|
|
|
|
|
|
|
<!-- Couleurs // arrière plan -->
|
|
|
|
|
<div class="settings-subsection">
|
|
|
|
|
<div class="field field-simple">
|
2025-12-05 18:21:54 +01:00
|
|
|
<label for="text-background" class="label-with-tooltip" data-css="background">Arrière-plan</label>
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="input-with-color">
|
2025-12-03 15:20:49 +01:00
|
|
|
<input
|
2025-12-04 16:21:50 +01:00
|
|
|
id="text-background"
|
|
|
|
|
type="text"
|
2025-12-05 16:30:44 +01:00
|
|
|
v-model="background"
|
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-04 16:21:50 +01:00
|
|
|
</div>
|
2025-12-03 15:20:49 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
<!-- Marges extérieures -->
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="settings-subsection">
|
2025-12-05 16:30:44 +01:00
|
|
|
<MarginEditor
|
2025-12-05 16:35:53 +01:00
|
|
|
ref="marginOuterEditor"
|
2025-12-05 16:30:44 +01:00
|
|
|
id="margin-outer"
|
|
|
|
|
label="Marges extérieures"
|
2025-12-05 18:21:54 +01:00
|
|
|
cssProperty="margin"
|
2025-12-05 16:30:44 +01:00
|
|
|
v-model:simple="marginOuter"
|
|
|
|
|
v-model:detailed="marginOuterDetailed"
|
2025-12-05 16:38:29 +01:00
|
|
|
:units="['mm', 'px', 'rem']"
|
2025-12-05 16:30:44 +01:00
|
|
|
@change="handleMarginOuterChange"
|
|
|
|
|
/>
|
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
|
|
|
<!-- Marges intérieures -->
|
2025-12-04 16:21:50 +01:00
|
|
|
<div class="settings-subsection">
|
2025-12-05 16:30:44 +01:00
|
|
|
<MarginEditor
|
2025-12-05 16:35:53 +01:00
|
|
|
ref="marginInnerEditor"
|
2025-12-05 16:30:44 +01:00
|
|
|
id="margin-inner"
|
|
|
|
|
label="Marges intérieures"
|
2025-12-05 18:21:54 +01:00
|
|
|
cssProperty="padding"
|
2025-12-05 16:30:44 +01:00
|
|
|
v-model:simple="marginInner"
|
|
|
|
|
v-model:detailed="marginInnerDetailed"
|
2025-12-05 16:38:29 +01:00
|
|
|
:units="['mm', 'px', 'rem']"
|
2025-12-05 16:30:44 +01:00
|
|
|
@change="handleMarginInnerChange"
|
|
|
|
|
/>
|
2025-12-03 15:20:49 +01:00
|
|
|
</div>
|
2025-12-09 17:08:40 +01:00
|
|
|
|
|
|
|
|
</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';
|
|
|
|
|
import Coloris from '@melloware/coloris';
|
2025-12-05 16:30:44 +01:00
|
|
|
import UnitToggle from '../ui/UnitToggle.vue';
|
|
|
|
|
import InputWithUnit from '../ui/InputWithUnit.vue';
|
|
|
|
|
import MarginEditor from '../ui/MarginEditor.vue';
|
|
|
|
|
import { useCssUpdater } from '../../composables/useCssUpdater';
|
|
|
|
|
import { useCssSync } from '../../composables/useCssSync';
|
|
|
|
|
|
|
|
|
|
const { updateStyle, setMargin, setDetailedMargins, setPadding, setDetailedPadding } = useCssUpdater();
|
|
|
|
|
const { extractValue, extractNumericValue, extractSpacing } = useCssSync();
|
|
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
|
const fonts = ['Alegreya Sans', 'Arial', 'Georgia', 'Helvetica', 'Times New Roman'];
|
|
|
|
|
const weights = ['200', '300', '400', '600', '800', 'normal', 'bold'];
|
|
|
|
|
const alignments = [
|
|
|
|
|
{ value: 'left', label: 'Gauche' },
|
|
|
|
|
{ value: 'center', label: 'Centre' },
|
|
|
|
|
{ value: 'right', label: 'Droite' },
|
|
|
|
|
{ value: 'justify', label: 'Justifié' }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// State
|
2025-12-03 15:20:49 +01:00
|
|
|
const font = ref('Alegreya Sans');
|
|
|
|
|
const italic = ref(false);
|
|
|
|
|
const weight = ref('400');
|
2025-12-05 16:30:44 +01:00
|
|
|
const fontSize = ref({ value: 16, unit: 'px' });
|
2025-12-03 15:20:49 +01:00
|
|
|
const alignment = ref('left');
|
2025-12-05 16:30:44 +01:00
|
|
|
const color = ref('rgb(0, 0, 0)');
|
|
|
|
|
const background = ref('transparent');
|
2025-12-03 15:20:49 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
const marginOuter = ref({ value: 0, unit: 'mm' });
|
2025-12-03 15:20:49 +01:00
|
|
|
const marginOuterDetailed = ref({
|
2025-12-05 16:18:31 +01:00
|
|
|
top: { value: 0, unit: 'mm' },
|
|
|
|
|
right: { value: 0, unit: 'mm' },
|
2025-12-05 16:30:44 +01:00
|
|
|
bottom: { value: 24, unit: 'mm' },
|
|
|
|
|
left: { value: 0, unit: 'mm' }
|
2025-12-03 15:20:49 +01:00
|
|
|
});
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
const marginInner = ref({ value: 0, unit: 'mm' });
|
2025-12-03 15:20:49 +01:00
|
|
|
const marginInnerDetailed = ref({
|
2025-12-05 16:18:31 +01:00
|
|
|
top: { value: 0, unit: 'mm' },
|
|
|
|
|
right: { value: 0, unit: 'mm' },
|
2025-12-05 16:30:44 +01:00
|
|
|
bottom: { value: 0, unit: 'mm' },
|
|
|
|
|
left: { value: 0, unit: 'mm' }
|
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:35:53 +01:00
|
|
|
const marginOuterEditor = ref(null);
|
|
|
|
|
const marginInnerEditor = ref(null);
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
let isUpdatingFromStore = false;
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Watchers for body styles
|
|
|
|
|
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;
|
2025-12-05 16:30:44 +01:00
|
|
|
updateStyle('body', '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(alignment, (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', 'text-align', 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
|
|
|
});
|
|
|
|
|
|
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
|
|
|
watch(background, (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', 'background', 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
|
|
|
});
|
|
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Watchers for paragraph styles
|
|
|
|
|
watch(weight, (val) => {
|
|
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
updateStyle('p', 'font-weight', val);
|
|
|
|
|
});
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
watch(fontSize, (val) => {
|
|
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
updateStyle('p', 'font-size', `${val.value}${val.unit}`);
|
|
|
|
|
}, { deep: true });
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Margin/Padding handlers
|
|
|
|
|
const handleMarginOuterChange = ({ type, simple, detailed }) => {
|
|
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
if (type === 'simple') {
|
|
|
|
|
setMargin('p', simple.value, simple.unit);
|
|
|
|
|
} else {
|
|
|
|
|
setDetailedMargins('p', detailed.top, detailed.right, detailed.bottom, detailed.left);
|
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
|
|
|
};
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
const handleMarginInnerChange = ({ type, simple, detailed }) => {
|
|
|
|
|
if (isUpdatingFromStore) return;
|
|
|
|
|
if (type === 'simple') {
|
|
|
|
|
setPadding('p', simple.value, simple.unit);
|
|
|
|
|
} else {
|
|
|
|
|
setDetailedPadding('p', detailed.top, detailed.right, detailed.bottom, detailed.left);
|
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
|
|
|
};
|
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
|
|
|
|
|
const fontStyle = extractValue('body', 'font-style');
|
|
|
|
|
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 textAlign = extractValue('body', 'text-align');
|
|
|
|
|
if (textAlign) alignment.value = textAlign;
|
2025-12-05 16:18:31 +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
|
|
|
const bgVal = extractValue('body', 'background');
|
|
|
|
|
if (bgVal) background.value = bgVal;
|
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
|
|
|
// Paragraph styles
|
|
|
|
|
const fontWeight = extractValue('p', 'font-weight');
|
|
|
|
|
if (fontWeight) weight.value = fontWeight;
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
const fontSizeVal = extractNumericValue('p', 'font-size', ['px', 'em', 'rem']);
|
|
|
|
|
if (fontSizeVal) fontSize.value = fontSizeVal;
|
2025-12-05 16:18:31 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Margins
|
|
|
|
|
const margins = extractSpacing('p', 'margin');
|
|
|
|
|
if (margins) {
|
|
|
|
|
if (margins.simple) {
|
|
|
|
|
marginOuter.value = margins.simple;
|
2025-12-05 16:35:53 +01:00
|
|
|
// Sync detailed from simple
|
|
|
|
|
marginOuterDetailed.value = {
|
|
|
|
|
top: { ...margins.simple },
|
|
|
|
|
right: { ...margins.simple },
|
|
|
|
|
bottom: { ...margins.simple },
|
|
|
|
|
left: { ...margins.simple }
|
|
|
|
|
};
|
2025-12-05 16:30:44 +01:00
|
|
|
} else if (margins.detailed) {
|
|
|
|
|
marginOuterDetailed.value = margins.detailed;
|
2025-12-05 16:35:53 +01:00
|
|
|
// Check if all values are the same to set simple value
|
|
|
|
|
const allSame =
|
|
|
|
|
margins.detailed.top.value === margins.detailed.right.value &&
|
|
|
|
|
margins.detailed.top.value === margins.detailed.bottom.value &&
|
|
|
|
|
margins.detailed.top.value === margins.detailed.left.value &&
|
|
|
|
|
margins.detailed.top.unit === margins.detailed.right.unit &&
|
|
|
|
|
margins.detailed.top.unit === margins.detailed.bottom.unit &&
|
|
|
|
|
margins.detailed.top.unit === margins.detailed.left.unit;
|
|
|
|
|
|
|
|
|
|
if (allSame) {
|
|
|
|
|
marginOuter.value = margins.detailed.top;
|
|
|
|
|
} else {
|
|
|
|
|
// Values are different, open the detailed editor and use first value for simple
|
|
|
|
|
marginOuter.value = margins.detailed.top;
|
|
|
|
|
// Open detailed view after mount
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (marginOuterEditor.value) {
|
|
|
|
|
marginOuterEditor.value.expanded = true;
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
2025-12-05 16:30:44 +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-04 16:21:50 +01:00
|
|
|
|
2025-12-05 16:30:44 +01:00
|
|
|
// Padding
|
|
|
|
|
const padding = extractSpacing('p', 'padding');
|
|
|
|
|
if (padding) {
|
|
|
|
|
if (padding.simple) {
|
|
|
|
|
marginInner.value = padding.simple;
|
2025-12-05 16:35:53 +01:00
|
|
|
// Sync detailed from simple
|
|
|
|
|
marginInnerDetailed.value = {
|
|
|
|
|
top: { ...padding.simple },
|
|
|
|
|
right: { ...padding.simple },
|
|
|
|
|
bottom: { ...padding.simple },
|
|
|
|
|
left: { ...padding.simple }
|
|
|
|
|
};
|
2025-12-05 16:30:44 +01:00
|
|
|
} else if (padding.detailed) {
|
|
|
|
|
marginInnerDetailed.value = padding.detailed;
|
2025-12-05 16:35:53 +01:00
|
|
|
// Check if all values are the same to set simple value
|
|
|
|
|
const allSame =
|
|
|
|
|
padding.detailed.top.value === padding.detailed.right.value &&
|
|
|
|
|
padding.detailed.top.value === padding.detailed.bottom.value &&
|
|
|
|
|
padding.detailed.top.value === padding.detailed.left.value &&
|
|
|
|
|
padding.detailed.top.unit === padding.detailed.right.unit &&
|
|
|
|
|
padding.detailed.top.unit === padding.detailed.bottom.unit &&
|
|
|
|
|
padding.detailed.top.unit === padding.detailed.left.unit;
|
|
|
|
|
|
|
|
|
|
if (allSame) {
|
|
|
|
|
marginInner.value = padding.detailed.top;
|
|
|
|
|
} else {
|
|
|
|
|
// Values are different, open the detailed editor and use first value for simple
|
|
|
|
|
marginInner.value = padding.detailed.top;
|
|
|
|
|
// Open detailed view after mount
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (marginInnerEditor.value) {
|
|
|
|
|
marginInnerEditor.value.expanded = true;
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
2025-12-05 16:30:44 +01:00
|
|
|
}
|
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
|
|
|
|
2025-12-04 16:21:50 +01:00
|
|
|
onMounted(() => {
|
|
|
|
|
Coloris.init();
|
|
|
|
|
Coloris({
|
|
|
|
|
themeMode: 'dark',
|
|
|
|
|
alpha: true,
|
|
|
|
|
format: 'auto',
|
|
|
|
|
formatToggle: true,
|
2025-12-05 16:30:44 +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();
|
2025-12-04 16:21:50 +01:00
|
|
|
});
|
2025-12-03 15:20:49 +01:00
|
|
|
</script>
|