mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-01 23:36:46 +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 { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
||||||
|
|
||||||
import codeBlockService from '../services/codeBlock';
|
import codeBlockService from '../services/codeBlock';
|
||||||
import historyService, { StepValue } from '../services/history';
|
import historyService from '../services/history';
|
||||||
import storageService, { Protocol } from '../services/storage';
|
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 { LayerOffset, Layout } from '../type';
|
||||||
import {
|
import {
|
||||||
change2Fixed,
|
change2Fixed,
|
||||||
|
@ -18,25 +18,13 @@
|
|||||||
|
|
||||||
import { reactive } from 'vue';
|
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 { UndoRedo } from '../utils/undo-redo';
|
||||||
|
|
||||||
import BaseService from './BaseService';
|
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 {
|
class History extends BaseService {
|
||||||
public state = reactive<HistoryState>({
|
public state = reactive<HistoryState>({
|
||||||
pageSteps: {},
|
pageSteps: {},
|
||||||
@ -76,6 +64,8 @@ class History extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setCanUndoRedo();
|
this.setCanUndoRedo();
|
||||||
|
|
||||||
|
this.emit('page-change', this.state.pageSteps[this.state.pageId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public empty(): void {
|
public empty(): void {
|
||||||
|
@ -36,6 +36,7 @@ import type { HistoryService } from './services/history';
|
|||||||
import type { PropsService } from './services/props';
|
import type { PropsService } from './services/props';
|
||||||
import type { StorageService } from './services/storage';
|
import type { StorageService } from './services/storage';
|
||||||
import type { UiService } from './services/ui';
|
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 BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
|
||||||
export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
||||||
@ -395,3 +396,16 @@ export interface CodeParamStatement {
|
|||||||
/** 参数类型 */
|
/** 参数类型 */
|
||||||
type?: string;
|
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