mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-15 17:43:43 +08:00
fix(editor): modelValue自动更新不成功
This commit is contained in:
parent
8ab6cdb03c
commit
e813129eb8
@ -223,7 +223,7 @@ export default defineComponent({
|
||||
emits: ['props-panel-mounted', 'update:modelValue'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
editorService.on('root-change', (value) => {
|
||||
editorService.on('root-change', (value, preValue) => {
|
||||
const nodeId = editorService.get<MNode | null>('node')?.id || props.defaultSelected;
|
||||
let node;
|
||||
if (nodeId) {
|
||||
@ -240,7 +240,7 @@ export default defineComponent({
|
||||
editorService.set('page', null);
|
||||
}
|
||||
|
||||
if (toRaw(value) !== toRaw(editorService.get('root'))) {
|
||||
if (toRaw(value) !== toRaw(preValue)) {
|
||||
emit('update:modelValue', value);
|
||||
}
|
||||
});
|
||||
|
@ -95,6 +95,7 @@ class Editor extends BaseService {
|
||||
* @param value MNode
|
||||
*/
|
||||
public set<T = MNode>(name: keyof StoreState, value: T) {
|
||||
const preValue = this.state[name];
|
||||
this.state[name] = value as any;
|
||||
// set nodes时将node设置为nodes第一个元素
|
||||
if (name === 'nodes') {
|
||||
@ -102,7 +103,7 @@ class Editor extends BaseService {
|
||||
}
|
||||
if (name === 'root') {
|
||||
this.state.pageLength = (value as unknown as MApp)?.items?.length || 0;
|
||||
this.emit('root-change', value);
|
||||
this.emit('root-change', value, preValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user