diff --git a/packages/designer/src/document/history.ts b/packages/designer/src/document/history.ts index a27e180b9..2bd127aac 100644 --- a/packages/designer/src/document/history.ts +++ b/packages/designer/src/document/history.ts @@ -1,6 +1,7 @@ import { EventEmitter } from 'events'; import { autorun, reaction, mobx, untracked, globalContext, Editor } from '@ali/lowcode-editor-core'; import { NodeSchema } from '@ali/lowcode-types'; +import { History as ShellHistory } from '@ali/lowcode-shell'; // TODO: cache to localStorage @@ -100,7 +101,7 @@ export class History { this.redoer(currentSerialization.unserialize(hotData)); this.emitter.emit('cursor', hotData); } catch (e) { - // + console.error(e); } this.wakeup(); @@ -194,6 +195,10 @@ export class History { isModified() { return this.isSavePoint(); } + + internalToShellHistory() { + return new ShellHistory(this); + } } class Session { diff --git a/packages/engine/src/modules/editor-cabin.ts b/packages/engine/src/modules/editor-cabin.ts index ac88f832e..8aa3059f5 100644 --- a/packages/engine/src/modules/editor-cabin.ts +++ b/packages/engine/src/modules/editor-cabin.ts @@ -1,5 +1,6 @@ export { Title, + Tip, shallowIntl, createIntl, createSetterContent, diff --git a/packages/shell/src/document-model.ts b/packages/shell/src/document-model.ts index fba2f3e81..ce2487103 100644 --- a/packages/shell/src/document-model.ts +++ b/packages/shell/src/document-model.ts @@ -42,7 +42,7 @@ export default class DocumentModel { this[editorSymbol] = document.designer.editor as Editor; this.selection = new Selection(document); this.detecting = new Detecting(document); - this.history = new History(document); + this.history = new History(document.getHistory()); this.canvas = new Canvas(document.designer); } diff --git a/packages/shell/src/event.ts b/packages/shell/src/event.ts index 1956b5768..65bc58a88 100644 --- a/packages/shell/src/event.ts +++ b/packages/shell/src/event.ts @@ -26,6 +26,10 @@ export default class Event { } on(event: string, listener: (...args: unknown[]) => void) { + if (event.startsWith('designer')) { + logger.warn('designer events are disabled'); + return; + } this[editorSymbol].on(event, listener); } diff --git a/packages/shell/src/history.ts b/packages/shell/src/history.ts index cbf51d419..65b5ba25c 100644 --- a/packages/shell/src/history.ts +++ b/packages/shell/src/history.ts @@ -1,13 +1,11 @@ import { History as InnerHistory, DocumentModel as InnerDocumentModel } from '@ali/lowcode-designer'; -import { documentSymbol, historySymbol } from './symbols'; +import { historySymbol } from './symbols'; export default class History { - private readonly [documentSymbol]: InnerDocumentModel; private readonly [historySymbol]: InnerHistory; - constructor(document: InnerDocumentModel) { - this[documentSymbol] = document; - this[historySymbol] = this[documentSymbol].getHistory(); + constructor(history: InnerHistory) { + this[historySymbol] = history; } go(cursor: number) { diff --git a/packages/shell/src/project.ts b/packages/shell/src/project.ts index dd72bfb6d..97b740b87 100644 --- a/packages/shell/src/project.ts +++ b/packages/shell/src/project.ts @@ -117,7 +117,10 @@ export default class Project { * 当前 project 内的 document 变更事件 */ onChangeDocument(fn: (doc: DocumentModel) => void) { - // TODO: 思考一下是否要实现补偿触发能力 + if (this[projectSymbol].currentDocument) { + fn(DocumentModel.create(this[projectSymbol].currentDocument)!); + return () => {}; + } return this[projectSymbol].onCurrentDocumentChange((originalDoc) => { fn(DocumentModel.create(originalDoc)!); }); diff --git a/xima.config.js b/xima.config.js deleted file mode 100644 index 17adca113..000000000 --- a/xima.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - eslintType: 'typescript/react', - enableStylelint: false, -};