mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(editor): history增加page-change事件
This commit is contained in:
parent
64d71bef42
commit
830c8d8747
@ -25,9 +25,9 @@ import StageCore from '@tmagic/stage';
|
||||
import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
||||
|
||||
import codeBlockService from '../services/codeBlock';
|
||||
import historyService, { StepValue } from '../services/history';
|
||||
import historyService from '../services/history';
|
||||
import storageService, { Protocol } from '../services/storage';
|
||||
import type { AddMNode, EditorNodeInfo, PastePosition, StoreState } from '../type';
|
||||
import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState } from '../type';
|
||||
import { LayerOffset, Layout } from '../type';
|
||||
import {
|
||||
change2Fixed,
|
||||
|
@ -18,25 +18,13 @@
|
||||
|
||||
import { reactive } from 'vue';
|
||||
|
||||
import type { Id, MPage } from '@tmagic/schema';
|
||||
import type { MPage } from '@tmagic/schema';
|
||||
|
||||
import { HistoryState, StepValue } from '../type';
|
||||
import { UndoRedo } from '../utils/undo-redo';
|
||||
|
||||
import BaseService from './BaseService';
|
||||
|
||||
export interface StepValue {
|
||||
data: MPage;
|
||||
modifiedNodeIds: Map<Id, Id>;
|
||||
nodeId: Id;
|
||||
}
|
||||
|
||||
export interface HistoryState {
|
||||
pageId?: Id;
|
||||
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
||||
canRedo: boolean;
|
||||
canUndo: boolean;
|
||||
}
|
||||
|
||||
class History extends BaseService {
|
||||
public state = reactive<HistoryState>({
|
||||
pageSteps: {},
|
||||
@ -76,6 +64,8 @@ class History extends BaseService {
|
||||
}
|
||||
|
||||
this.setCanUndoRedo();
|
||||
|
||||
this.emit('page-change', this.state.pageSteps[this.state.pageId]);
|
||||
}
|
||||
|
||||
public empty(): void {
|
||||
|
@ -36,6 +36,7 @@ import type { HistoryService } from './services/history';
|
||||
import type { PropsService } from './services/props';
|
||||
import type { StorageService } from './services/storage';
|
||||
import type { UiService } from './services/ui';
|
||||
import type { UndoRedo } from './utils/undo-redo';
|
||||
|
||||
export type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
|
||||
export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
||||
@ -395,3 +396,16 @@ export interface CodeParamStatement {
|
||||
/** 参数类型 */
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface StepValue {
|
||||
data: MPage;
|
||||
modifiedNodeIds: Map<Id, Id>;
|
||||
nodeId: Id;
|
||||
}
|
||||
|
||||
export interface HistoryState {
|
||||
pageId?: Id;
|
||||
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
||||
canRedo: boolean;
|
||||
canUndo: boolean;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user