mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-02 21:59:54 +08:00
fix(editor): 没有页面时,添加页面出错
This commit is contained in:
parent
13ef262bc2
commit
e67cbceb7d
@ -193,9 +193,15 @@ export default defineComponent({
|
|||||||
emits: ['props-panel-mounted', 'update:modelValue'],
|
emits: ['props-panel-mounted', 'update:modelValue'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
editorService.on('root-change', () => {
|
editorService.on('root-change', (value) => {
|
||||||
const node = editorService.get<MNode | null>('node') || props.defaultSelected;
|
const node = editorService.get<MNode | null>('node');
|
||||||
node && editorService.select(node);
|
const nodeId = node?.id || props.defaultSelected;
|
||||||
|
if (nodeId && node !== value) {
|
||||||
|
editorService.select(nodeId);
|
||||||
|
} else {
|
||||||
|
editorService.set('nodes', [value]);
|
||||||
|
}
|
||||||
|
|
||||||
emit('update:modelValue', toRaw(editorService.get('root')));
|
emit('update:modelValue', toRaw(editorService.get('root')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ class Editor extends BaseService {
|
|||||||
await this.select(root.items[0]);
|
await this.select(root.items[0]);
|
||||||
stage?.select(root.items[0].id);
|
stage?.select(root.items[0].id);
|
||||||
} else {
|
} else {
|
||||||
this.set('node', null);
|
this.set('nodes', [root]);
|
||||||
this.set('parent', null);
|
this.set('parent', null);
|
||||||
this.set('page', null);
|
this.set('page', null);
|
||||||
this.set('stage', null);
|
this.set('stage', null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user