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
@@ -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 {