mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-25 18:32:09 +08:00
parent
5529bbc6e1
commit
9b9c9db683
@ -620,7 +620,7 @@ class Editor extends BaseService {
|
|||||||
*/
|
*/
|
||||||
public async moveLayer(offset: number | LayerOffset): Promise<void> {
|
public async moveLayer(offset: number | LayerOffset): Promise<void> {
|
||||||
const parent = this.get<MContainer>('parent');
|
const parent = this.get<MContainer>('parent');
|
||||||
const node = this.get('node');
|
const node = this.get<MNode>('node');
|
||||||
const brothers: MNode[] = parent?.items || [];
|
const brothers: MNode[] = parent?.items || [];
|
||||||
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
||||||
|
|
||||||
@ -632,11 +632,15 @@ class Editor extends BaseService {
|
|||||||
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const grandparent = this.getParentById(parent.id);
|
||||||
this.get<StageCore | null>('stage')?.update({
|
this.get<StageCore | null>('stage')?.update({
|
||||||
config: cloneDeep(toRaw(parent)),
|
config: cloneDeep(toRaw(parent)),
|
||||||
parentId: parent.id,
|
parentId: grandparent?.id,
|
||||||
root: cloneDeep(this.get<MApp>('root')),
|
root: cloneDeep(this.get<MApp>('root')),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addModifiedNodeId(parent.id);
|
||||||
|
this.pushHistoryState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,7 @@ import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|||||||
import { NodeType } from '@tmagic/schema';
|
import { NodeType } from '@tmagic/schema';
|
||||||
|
|
||||||
import editorService from '@editor/services/editor';
|
import editorService from '@editor/services/editor';
|
||||||
|
import historyService from '@editor/services/history';
|
||||||
import storageService from '@editor/services/storage';
|
import storageService from '@editor/services/storage';
|
||||||
import { COPY_STORAGE_KEY } from '@editor/utils';
|
import { COPY_STORAGE_KEY } from '@editor/utils';
|
||||||
|
|
||||||
@ -414,6 +415,7 @@ describe('undo redo', () => {
|
|||||||
beforeAll(() => editorService.set('root', cloneDeep(root)));
|
beforeAll(() => editorService.set('root', cloneDeep(root)));
|
||||||
|
|
||||||
test('正常', async () => {
|
test('正常', async () => {
|
||||||
|
historyService.reset();
|
||||||
// 设置当前编辑的组件
|
// 设置当前编辑的组件
|
||||||
await editorService.select(NodeId.NODE_ID);
|
await editorService.select(NodeId.NODE_ID);
|
||||||
const node = editorService.get('node');
|
const node = editorService.get('node');
|
||||||
|
@ -79,7 +79,7 @@ describe('isFixed', () => {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
id: 1,
|
id: 1,
|
||||||
style: {
|
style: {
|
||||||
absulote: 'absulote',
|
position: 'absolute',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
).toBeFalsy();
|
).toBeFalsy();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user