mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-18 11:23:39 +08:00
feat(editor,stage): runtime-api中的add/update/remove中的参数加上parentId
This commit is contained in:
parent
9d2e2210d1
commit
59e6aff70a
@ -302,11 +302,11 @@ class Editor extends BaseService {
|
|||||||
const layout = await this.getLayout(toRaw(parent), node as MNode);
|
const layout = await this.getLayout(toRaw(parent), node as MNode);
|
||||||
node.style = getInitPositionStyle(node.style, layout);
|
node.style = getInitPositionStyle(node.style, layout);
|
||||||
|
|
||||||
await stage?.add({ config: cloneDeep(node), parent: cloneDeep(parent), root: cloneDeep(root) });
|
await stage?.add({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
|
||||||
|
|
||||||
node.style = fixNodePosition(node, parent, stage);
|
node.style = fixNodePosition(node, parent, stage);
|
||||||
|
|
||||||
await stage?.update({ config: cloneDeep(node), root: cloneDeep(root) });
|
await stage?.update({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
|
||||||
|
|
||||||
this.addModifiedNodeId(node.id);
|
this.addModifiedNodeId(node.id);
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ class Editor extends BaseService {
|
|||||||
|
|
||||||
parent.items?.splice(index, 1);
|
parent.items?.splice(index, 1);
|
||||||
const stage = this.get<StageCore | null>('stage');
|
const stage = this.get<StageCore | null>('stage');
|
||||||
stage?.remove({ id: node.id, root: this.get('root') });
|
stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
||||||
|
|
||||||
if (node.type === NodeType.PAGE) {
|
if (node.type === NodeType.PAGE) {
|
||||||
this.state.pageLength -= 1;
|
this.state.pageLength -= 1;
|
||||||
@ -466,7 +466,11 @@ class Editor extends BaseService {
|
|||||||
nodes.splice(targetIndex, 1, newConfig);
|
nodes.splice(targetIndex, 1, newConfig);
|
||||||
this.set('nodes', nodes);
|
this.set('nodes', nodes);
|
||||||
|
|
||||||
this.get<StageCore | null>('stage')?.update({ config: cloneDeep(newConfig), root: cloneDeep(this.get('root')) });
|
this.get<StageCore | null>('stage')?.update({
|
||||||
|
config: cloneDeep(newConfig),
|
||||||
|
parentId: parent.id,
|
||||||
|
root: cloneDeep(this.get('root')),
|
||||||
|
});
|
||||||
|
|
||||||
if (newConfig.type === NodeType.PAGE) {
|
if (newConfig.type === NodeType.PAGE) {
|
||||||
this.set('page', newConfig);
|
this.set('page', newConfig);
|
||||||
@ -513,7 +517,11 @@ class Editor extends BaseService {
|
|||||||
await this.update(parent);
|
await this.update(parent);
|
||||||
await this.select(node);
|
await this.select(node);
|
||||||
|
|
||||||
this.get<StageCore | null>('stage')?.update({ config: cloneDeep(node), root: cloneDeep(this.get('root')) });
|
this.get<StageCore | null>('stage')?.update({
|
||||||
|
config: cloneDeep(node),
|
||||||
|
parentId: parent.id,
|
||||||
|
root: cloneDeep(this.get('root')),
|
||||||
|
});
|
||||||
|
|
||||||
this.addModifiedNodeId(parent.id);
|
this.addModifiedNodeId(parent.id);
|
||||||
this.pushHistoryState();
|
this.pushHistoryState();
|
||||||
@ -612,6 +620,7 @@ class Editor extends BaseService {
|
|||||||
|
|
||||||
this.get<StageCore | null>('stage')?.update({
|
this.get<StageCore | null>('stage')?.update({
|
||||||
config: cloneDeep(toRaw(parent)),
|
config: cloneDeep(toRaw(parent)),
|
||||||
|
parentId: parent.id,
|
||||||
root: cloneDeep(this.get<MApp>('root')),
|
root: cloneDeep(this.get<MApp>('root')),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -632,7 +641,7 @@ class Editor extends BaseService {
|
|||||||
const index = getNodeIndex(node, parent);
|
const index = getNodeIndex(node, parent);
|
||||||
parent.items?.splice(index, 1);
|
parent.items?.splice(index, 1);
|
||||||
|
|
||||||
await stage.remove({ id: node.id, root });
|
await stage.remove({ id: node.id, parentId: parent.id, root });
|
||||||
|
|
||||||
const layout = await this.getLayout(target);
|
const layout = await this.getLayout(target);
|
||||||
|
|
||||||
@ -647,7 +656,7 @@ class Editor extends BaseService {
|
|||||||
|
|
||||||
await stage.select(targetId);
|
await stage.select(targetId);
|
||||||
|
|
||||||
await stage.update({ config: cloneDeep(target), root });
|
await stage.update({ config: cloneDeep(target), parentId: parent.id, root });
|
||||||
|
|
||||||
await this.select(newConfig);
|
await this.select(newConfig);
|
||||||
stage.select(newConfig.id);
|
stage.select(newConfig.id);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import { MoveableOptions } from 'moveable';
|
import { MoveableOptions } from 'moveable';
|
||||||
|
|
||||||
import Core from '@tmagic/core';
|
import Core from '@tmagic/core';
|
||||||
import type { Id, MApp, MContainer, MNode } from '@tmagic/schema';
|
import type { Id, MApp, MNode } from '@tmagic/schema';
|
||||||
|
|
||||||
import { GuidesType } from './const';
|
import { GuidesType } from './const';
|
||||||
import StageCore from './StageCore';
|
import StageCore from './StageCore';
|
||||||
@ -118,12 +118,13 @@ export interface SortEventData {
|
|||||||
|
|
||||||
export interface UpdateData {
|
export interface UpdateData {
|
||||||
config: MNode;
|
config: MNode;
|
||||||
parent?: MContainer;
|
parentId: Id;
|
||||||
root: MApp;
|
root: MApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RemoveData {
|
export interface RemoveData {
|
||||||
id: Id;
|
id: Id;
|
||||||
|
parentId: Id;
|
||||||
root: MApp;
|
root: MApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user