This commit is contained in:
F4ilji
2026-04-10 09:01:47 +05:00
parent 1c6f09ed80
commit 9e35cf848d
25 changed files with 195 additions and 155 deletions
@@ -291,7 +291,7 @@ export default {
const blockDefaults = {
heading: () => ({ id: `anchor-${Date.now()}`, content: '' }),
paragraph: () => ({ seo_active: true, content: '' }),
paragraph: () => ({ content: '' }),
image: () => ({ url: '', alt: '' }),
images: () => ({ url: [], alt: '' }),
files: () => ({ file: [] }),
@@ -288,7 +288,7 @@ export default {
const blockDefaults = {
heading: () => ({ id: `anchor-${Date.now()}`, content: '' }),
paragraph: () => ({ seo_active: true, content: '' }),
paragraph: () => ({ content: '' }),
image: () => ({ url: '', alt: '' }),
images: () => ({ url: [], alt: '' }),
files: () => ({ file: [] }),
@@ -402,24 +402,26 @@ export default {
onMounted(() => {
if (props.modelValue && props.modelValue.length > 0) {
blocks.value = props.modelValue.map(block => ({
_uid: generateUid(),
_uid: block._uid || generateUid(),
...block
}));
}
});
// Watch for modelValue changes (e.g., when loading existing content)
// Watch for modelValue changes — only for initial load or when parent reloads
// DO NOT sync on every change to avoid infinite loops with emitChange
watch(
() => props.modelValue,
(newValue) => {
// Only update if blocks are empty (page reload or tab switch)
if (newValue && newValue.length > 0 && blocks.value.length === 0) {
// Only initialize if blocks are empty (initial load from server)
blocks.value = newValue.map(block => ({
_uid: generateUid(),
_uid: block._uid || generateUid(),
...block
}));
}
}
},
{ deep: true }
);
return {
@@ -1,17 +1,5 @@
<template>
<div class="space-y-3" style="overflow: visible;">
<div class="flex items-center gap-2 mb-2">
<input
type="checkbox"
:checked="modelValue.seo_active"
@change="update('seo_active', $event.target.checked)"
class="h-4 w-4 text-primary focus:ring-primary border-layer-line rounded"
/>
<label class="text-sm text-foreground">
Активировать SEO для этого блока
</label>
</div>
<div style="overflow: visible;">
<label class="block text-sm font-medium text-foreground mb-1">
Текст <span class="text-danger">*</span>
@@ -81,7 +81,7 @@ export default {
props: {
modelValue: { type: Object, required: true }
},
emits: ['update:modelValue'],
emits: ['update:modelValue', 'update'],
computed: {
tabs() {
const rawTabs = this.modelValue?.tab || [];
@@ -95,6 +95,7 @@ export default {
methods: {
update(field, value) {
this.$emit('update:modelValue', { ...this.modelValue, [field]: value });
this.$emit('update');
},
updateSettings(field, value) {
this.update('settings', { ...(this.modelValue.settings || {}), [field]: value });