changes
This commit is contained in:
@@ -403,6 +403,9 @@ export default {
|
||||
document.removeEventListener('mouseup', stopDrag);
|
||||
}
|
||||
|
||||
// Track if we've initialized from server data
|
||||
let initialized = false;
|
||||
|
||||
// Initialize from modelValue
|
||||
onMounted(() => {
|
||||
if (props.modelValue && props.modelValue.length > 0) {
|
||||
@@ -410,6 +413,7 @@ export default {
|
||||
_uid: generateUid(),
|
||||
...block
|
||||
}));
|
||||
initialized = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -417,12 +421,13 @@ export default {
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newValue) => {
|
||||
if (newValue && newValue.length > 0 && blocks.value.length === 0) {
|
||||
// Only initialize if blocks are empty (initial load from server)
|
||||
if (newValue && newValue.length > 0 && !initialized) {
|
||||
// Only initialize once (initial load from server)
|
||||
blocks.value = newValue.map(block => ({
|
||||
_uid: generateUid(),
|
||||
...block
|
||||
}));
|
||||
initialized = true;
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
|
||||
@@ -41,7 +41,7 @@ export default {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
emits: ['update:modelValue', 'update'],
|
||||
data() {
|
||||
return {
|
||||
editorId: `paragraph-editor-${++editorCounter}`,
|
||||
@@ -61,6 +61,7 @@ export default {
|
||||
...this.modelValue,
|
||||
[field]: value
|
||||
});
|
||||
this.$emit('update');
|
||||
},
|
||||
waitForTinyMCE() {
|
||||
if (typeof tinymce !== 'undefined') {
|
||||
@@ -111,6 +112,8 @@ export default {
|
||||
editor.on('init', () => {
|
||||
editor.setContent(this.modelValue.content || '');
|
||||
this.loading = false;
|
||||
// Emit initial content to ensure parent has correct value
|
||||
this.update('content', editor.getContent());
|
||||
});
|
||||
editor.on('change', () => {
|
||||
this.update('content', editor.getContent());
|
||||
|
||||
Reference in New Issue
Block a user