refactor: replace MarginEditor with linked margin fields in TextSettings
- Replace MarginEditor component with individual fields (top/bottom/left/right) - Add link/unlink button with SVG icons to sync margin values - When linked, all fields share the same value - Auto-detect linked state when loading from stylesheet - Match PageSettings UI pattern for consistency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c6873ff7e0
commit
06aef5beb3
1 changed files with 400 additions and 77 deletions
|
|
@ -91,31 +91,269 @@
|
|||
</div>
|
||||
|
||||
<!-- Marges extérieures -->
|
||||
<div class="settings-subsection">
|
||||
<MarginEditor
|
||||
ref="marginOuterEditor"
|
||||
id="margin-outer"
|
||||
label="Marges extérieures"
|
||||
cssProperty="margin"
|
||||
v-model:simple="marginOuter"
|
||||
v-model:detailed="marginOuterDetailed"
|
||||
:units="['mm', 'px', 'rem']"
|
||||
@change="handleMarginOuterChange"
|
||||
<div class="settings-subsection margins">
|
||||
<div class="subsection-header">
|
||||
<h3>Marges extérieures</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="link-button"
|
||||
:class="{ active: marginOuterLinked }"
|
||||
@click="marginOuterLinked = !marginOuterLinked"
|
||||
:title="marginOuterLinked ? 'Dissocier les marges' : 'Lier les marges'"
|
||||
>
|
||||
<svg v-if="marginOuterLinked" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z"></path></svg>
|
||||
<svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z"></path></svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-outer-top" class="label-with-tooltip" data-css="margin-top">Haut</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-outer-top"
|
||||
v-model="marginOuterDetailed.top.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.top.unit === 'mm' }"
|
||||
@click="updateMarginOuterUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.top.unit === 'px' }"
|
||||
@click="updateMarginOuterUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.top.unit === 'rem' }"
|
||||
@click="updateMarginOuterUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-outer-bottom" class="label-with-tooltip" data-css="margin-bottom">Bas</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-outer-bottom"
|
||||
v-model="marginOuterDetailed.bottom.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.bottom.unit === 'mm' }"
|
||||
@click="updateMarginOuterUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.bottom.unit === 'px' }"
|
||||
@click="updateMarginOuterUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.bottom.unit === 'rem' }"
|
||||
@click="updateMarginOuterUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-outer-left" class="label-with-tooltip" data-css="margin-left">Gauche</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-outer-left"
|
||||
v-model="marginOuterDetailed.left.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.left.unit === 'mm' }"
|
||||
@click="updateMarginOuterUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.left.unit === 'px' }"
|
||||
@click="updateMarginOuterUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.left.unit === 'rem' }"
|
||||
@click="updateMarginOuterUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-outer-right" class="label-with-tooltip" data-css="margin-right">Droite</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-outer-right"
|
||||
v-model="marginOuterDetailed.right.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.right.unit === 'mm' }"
|
||||
@click="updateMarginOuterUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.right.unit === 'px' }"
|
||||
@click="updateMarginOuterUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginOuterDetailed.right.unit === 'rem' }"
|
||||
@click="updateMarginOuterUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Marges intérieures -->
|
||||
<div class="settings-subsection">
|
||||
<MarginEditor
|
||||
ref="marginInnerEditor"
|
||||
id="margin-inner"
|
||||
label="Marges intérieures"
|
||||
cssProperty="padding"
|
||||
v-model:simple="marginInner"
|
||||
v-model:detailed="marginInnerDetailed"
|
||||
:units="['mm', 'px', 'rem']"
|
||||
@change="handleMarginInnerChange"
|
||||
<div class="settings-subsection margins">
|
||||
<div class="subsection-header">
|
||||
<h3>Marges intérieures</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="link-button"
|
||||
:class="{ active: marginInnerLinked }"
|
||||
@click="marginInnerLinked = !marginInnerLinked"
|
||||
:title="marginInnerLinked ? 'Dissocier les marges' : 'Lier les marges'"
|
||||
>
|
||||
<svg v-if="marginInnerLinked" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z"></path></svg>
|
||||
<svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z"></path></svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-inner-top" class="label-with-tooltip" data-css="padding-top">Haut</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-inner-top"
|
||||
v-model="marginInnerDetailed.top.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.top.unit === 'mm' }"
|
||||
@click="updateMarginInnerUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.top.unit === 'px' }"
|
||||
@click="updateMarginInnerUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.top.unit === 'rem' }"
|
||||
@click="updateMarginInnerUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-inner-bottom" class="label-with-tooltip" data-css="padding-bottom">Bas</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-inner-bottom"
|
||||
v-model="marginInnerDetailed.bottom.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.bottom.unit === 'mm' }"
|
||||
@click="updateMarginInnerUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.bottom.unit === 'px' }"
|
||||
@click="updateMarginInnerUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.bottom.unit === 'rem' }"
|
||||
@click="updateMarginInnerUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-inner-left" class="label-with-tooltip" data-css="padding-left">Gauche</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-inner-left"
|
||||
v-model="marginInnerDetailed.left.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.left.unit === 'mm' }"
|
||||
@click="updateMarginInnerUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.left.unit === 'px' }"
|
||||
@click="updateMarginInnerUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.left.unit === 'rem' }"
|
||||
@click="updateMarginInnerUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field field-margin">
|
||||
<label for="margin-inner-right" class="label-with-tooltip" data-css="padding-right">Droite</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput
|
||||
id="margin-inner-right"
|
||||
v-model="marginInnerDetailed.right.value"
|
||||
:min="0"
|
||||
:step="1"
|
||||
/>
|
||||
<div class="unit-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.right.unit === 'mm' }"
|
||||
@click="updateMarginInnerUnit('mm')"
|
||||
>mm</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.right.unit === 'px' }"
|
||||
@click="updateMarginInnerUnit('px')"
|
||||
>px</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: marginInnerDetailed.right.unit === 'rem' }"
|
||||
@click="updateMarginInnerUnit('rem')"
|
||||
>rem</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -127,7 +365,7 @@ import { ref, watch, onMounted } from 'vue';
|
|||
import Coloris from '@melloware/coloris';
|
||||
import UnitToggle from '../ui/UnitToggle.vue';
|
||||
import InputWithUnit from '../ui/InputWithUnit.vue';
|
||||
import MarginEditor from '../ui/MarginEditor.vue';
|
||||
import NumberInput from '../ui/NumberInput.vue';
|
||||
import { useCssUpdater } from '../../composables/useCssUpdater';
|
||||
import { useCssSync } from '../../composables/useCssSync';
|
||||
import { useDebounce } from '../../composables/useDebounce';
|
||||
|
|
@ -155,7 +393,6 @@ const alignment = ref('left');
|
|||
const color = ref('rgb(0, 0, 0)');
|
||||
const background = ref('transparent');
|
||||
|
||||
const marginOuter = ref({ value: 0, unit: 'mm' });
|
||||
const marginOuterDetailed = ref({
|
||||
top: { value: 0, unit: 'mm' },
|
||||
right: { value: 0, unit: 'mm' },
|
||||
|
|
@ -163,7 +400,6 @@ const marginOuterDetailed = ref({
|
|||
left: { value: 0, unit: 'mm' }
|
||||
});
|
||||
|
||||
const marginInner = ref({ value: 0, unit: 'mm' });
|
||||
const marginInnerDetailed = ref({
|
||||
top: { value: 0, unit: 'mm' },
|
||||
right: { value: 0, unit: 'mm' },
|
||||
|
|
@ -171,11 +407,27 @@ const marginInnerDetailed = ref({
|
|||
left: { value: 0, unit: 'mm' }
|
||||
});
|
||||
|
||||
const marginOuterEditor = ref(null);
|
||||
const marginInnerEditor = ref(null);
|
||||
const marginOuterLinked = ref(false);
|
||||
const marginInnerLinked = ref(false);
|
||||
|
||||
let isUpdatingFromStore = false;
|
||||
|
||||
// Update margin outer unit for all sides
|
||||
const updateMarginOuterUnit = (unit) => {
|
||||
marginOuterDetailed.value.top.unit = unit;
|
||||
marginOuterDetailed.value.right.unit = unit;
|
||||
marginOuterDetailed.value.bottom.unit = unit;
|
||||
marginOuterDetailed.value.left.unit = unit;
|
||||
};
|
||||
|
||||
// Update margin inner unit for all sides
|
||||
const updateMarginInnerUnit = (unit) => {
|
||||
marginInnerDetailed.value.top.unit = unit;
|
||||
marginInnerDetailed.value.right.unit = unit;
|
||||
marginInnerDetailed.value.bottom.unit = unit;
|
||||
marginInnerDetailed.value.left.unit = unit;
|
||||
};
|
||||
|
||||
// Watchers for body styles
|
||||
watch(italic, (val) => {
|
||||
if (isUpdatingFromStore) return;
|
||||
|
|
@ -210,28 +462,77 @@ watch(fontSize, (val) => {
|
|||
});
|
||||
}, { deep: true });
|
||||
|
||||
// Margin/Padding handlers
|
||||
const handleMarginOuterChange = ({ type, simple, detailed }) => {
|
||||
// Watch margin outer values
|
||||
watch(() => [
|
||||
marginOuterDetailed.value.top.value,
|
||||
marginOuterDetailed.value.bottom.value,
|
||||
marginOuterDetailed.value.left.value,
|
||||
marginOuterDetailed.value.right.value,
|
||||
], () => {
|
||||
if (isUpdatingFromStore) return;
|
||||
debouncedUpdate(() => {
|
||||
if (type === 'simple') {
|
||||
setMargin('p', simple.value, simple.unit);
|
||||
} else {
|
||||
setDetailedMargins('p', detailed.top, detailed.right, detailed.bottom, detailed.left);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleMarginInnerChange = ({ type, simple, detailed }) => {
|
||||
if (isUpdatingFromStore) return;
|
||||
debouncedUpdate(() => {
|
||||
if (type === 'simple') {
|
||||
setPadding('p', simple.value, simple.unit);
|
||||
} else {
|
||||
setDetailedPadding('p', detailed.top, detailed.right, detailed.bottom, detailed.left);
|
||||
// If linked, sync all values to the one that changed
|
||||
if (marginOuterLinked.value) {
|
||||
// Find which value changed and sync others to it
|
||||
const top = marginOuterDetailed.value.top.value;
|
||||
const bottom = marginOuterDetailed.value.bottom.value;
|
||||
const left = marginOuterDetailed.value.left.value;
|
||||
const right = marginOuterDetailed.value.right.value;
|
||||
|
||||
// Use the max value to determine which one changed (simple heuristic)
|
||||
const maxValue = Math.max(top, bottom, left, right);
|
||||
isUpdatingFromStore = true;
|
||||
marginOuterDetailed.value.top.value = maxValue;
|
||||
marginOuterDetailed.value.bottom.value = maxValue;
|
||||
marginOuterDetailed.value.left.value = maxValue;
|
||||
marginOuterDetailed.value.right.value = maxValue;
|
||||
isUpdatingFromStore = false;
|
||||
}
|
||||
|
||||
debouncedUpdate(() => {
|
||||
setDetailedMargins('p',
|
||||
marginOuterDetailed.value.top,
|
||||
marginOuterDetailed.value.right,
|
||||
marginOuterDetailed.value.bottom,
|
||||
marginOuterDetailed.value.left
|
||||
);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// Watch margin inner values
|
||||
watch(() => [
|
||||
marginInnerDetailed.value.top.value,
|
||||
marginInnerDetailed.value.bottom.value,
|
||||
marginInnerDetailed.value.left.value,
|
||||
marginInnerDetailed.value.right.value,
|
||||
], () => {
|
||||
if (isUpdatingFromStore) return;
|
||||
|
||||
// If linked, sync all values to the one that changed
|
||||
if (marginInnerLinked.value) {
|
||||
const top = marginInnerDetailed.value.top.value;
|
||||
const bottom = marginInnerDetailed.value.bottom.value;
|
||||
const left = marginInnerDetailed.value.left.value;
|
||||
const right = marginInnerDetailed.value.right.value;
|
||||
|
||||
const maxValue = Math.max(top, bottom, left, right);
|
||||
isUpdatingFromStore = true;
|
||||
marginInnerDetailed.value.top.value = maxValue;
|
||||
marginInnerDetailed.value.bottom.value = maxValue;
|
||||
marginInnerDetailed.value.left.value = maxValue;
|
||||
marginInnerDetailed.value.right.value = maxValue;
|
||||
isUpdatingFromStore = false;
|
||||
}
|
||||
|
||||
debouncedUpdate(() => {
|
||||
setDetailedPadding('p',
|
||||
marginInnerDetailed.value.top,
|
||||
marginInnerDetailed.value.right,
|
||||
marginInnerDetailed.value.bottom,
|
||||
marginInnerDetailed.value.left
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Sync from store
|
||||
const syncFromStore = () => {
|
||||
|
|
@ -261,17 +562,17 @@ const syncFromStore = () => {
|
|||
const margins = extractSpacing('p', 'margin');
|
||||
if (margins) {
|
||||
if (margins.simple) {
|
||||
marginOuter.value = margins.simple;
|
||||
// Sync detailed from simple
|
||||
// All margins are the same
|
||||
marginOuterDetailed.value = {
|
||||
top: { ...margins.simple },
|
||||
right: { ...margins.simple },
|
||||
bottom: { ...margins.simple },
|
||||
left: { ...margins.simple }
|
||||
};
|
||||
marginOuterLinked.value = true;
|
||||
} else if (margins.detailed) {
|
||||
marginOuterDetailed.value = margins.detailed;
|
||||
// Check if all values are the same to set simple value
|
||||
// Check if all values are the same
|
||||
const allSame =
|
||||
margins.detailed.top.value === margins.detailed.right.value &&
|
||||
margins.detailed.top.value === margins.detailed.bottom.value &&
|
||||
|
|
@ -279,19 +580,7 @@ const syncFromStore = () => {
|
|||
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);
|
||||
}
|
||||
marginOuterLinked.value = allSame;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -299,17 +588,17 @@ const syncFromStore = () => {
|
|||
const padding = extractSpacing('p', 'padding');
|
||||
if (padding) {
|
||||
if (padding.simple) {
|
||||
marginInner.value = padding.simple;
|
||||
// Sync detailed from simple
|
||||
// All paddings are the same
|
||||
marginInnerDetailed.value = {
|
||||
top: { ...padding.simple },
|
||||
right: { ...padding.simple },
|
||||
bottom: { ...padding.simple },
|
||||
left: { ...padding.simple }
|
||||
};
|
||||
marginInnerLinked.value = true;
|
||||
} else if (padding.detailed) {
|
||||
marginInnerDetailed.value = padding.detailed;
|
||||
// Check if all values are the same to set simple value
|
||||
// Check if all values are the same
|
||||
const allSame =
|
||||
padding.detailed.top.value === padding.detailed.right.value &&
|
||||
padding.detailed.top.value === padding.detailed.bottom.value &&
|
||||
|
|
@ -317,19 +606,7 @@ const syncFromStore = () => {
|
|||
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);
|
||||
}
|
||||
marginInnerLinked.value = allSame;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,3 +625,49 @@ onMounted(() => {
|
|||
syncFromStore();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.subsection-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.subsection-header h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.link-button {
|
||||
background: none;
|
||||
border: 1px solid var(--color-border, #ddd);
|
||||
border-radius: 4px;
|
||||
padding: 0.25rem;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.link-button svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: var(--color-text-secondary, #666);
|
||||
}
|
||||
|
||||
.link-button:hover {
|
||||
background: var(--color-hover, #f0f0f0);
|
||||
}
|
||||
|
||||
.link-button.active {
|
||||
background: var(--color-primary, #007bff);
|
||||
border-color: var(--color-primary, #007bff);
|
||||
}
|
||||
|
||||
.link-button.active svg {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue