Skip to content

Commit 4b8ec09

Browse files
LeoYuanJackLian
authored andcommitted
feat: add importSchema event for documentModel
1 parent 6eefb4e commit 4b8ec09

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/shell/src/document-model.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ type PropChangeOptions = {
3636
oldValue: any;
3737
};
3838

39+
const Events = {
40+
IMPORT_SCHEMA: 'shell.document.importSchema',
41+
};
42+
3943
export default class DocumentModel {
4044
private readonly [documentSymbol]: InnerDocumentModel;
4145
private readonly [editorSymbol]: Editor;
@@ -135,6 +139,7 @@ export default class DocumentModel {
135139
*/
136140
importSchema(schema: RootSchema) {
137141
this[documentSymbol].import(schema);
142+
this[editorSymbol].emit(Events.IMPORT_SCHEMA, schema);
138143
}
139144

140145
/**
@@ -290,4 +295,12 @@ export default class DocumentModel {
290295
},
291296
);
292297
}
298+
299+
/**
300+
* import schema event
301+
* @param fn
302+
*/
303+
onImportSchema(fn: (schema: RootSchema) => void) {
304+
this[editorSymbol].on(Events.IMPORT_SCHEMA, fn as any);
305+
}
293306
}

0 commit comments

Comments
 (0)