Browse Source

Add more events to EditorEvents

pull/6360/head
Artur Arseniev 2 years ago
parent
commit
047016afed
  1. 14
      packages/core/src/editor/types.ts
  2. 5
      packages/core/src/editor/view/EditorView.ts

14
packages/core/src/editor/types.ts

@ -21,6 +21,13 @@ export enum EditorEvents {
*/ */
redo = 'redo', redo = 'redo',
/**
* @event `load` Editor is loaded. At this stage, the project is loaded in the editor and elements in the canvas are rendered.
* @example
* editor.on('load', () => { ... });
*/
load = 'load',
/** /**
* @event `project:load` Project JSON loaded in the editor. The event is triggered on the initial load and on the `editor.loadProjectData` method. * @event `project:load` Project JSON loaded in the editor. The event is triggered on the initial load and on the `editor.loadProjectData` method.
* @example * @example
@ -35,6 +42,13 @@ export enum EditorEvents {
*/ */
log = 'log', log = 'log',
/**
* @event `telemetry:init` Initial telemetry data are sent.
* @example
* editor.on('telemetry:init', () => { ... });
*/
telemetryInit = 'telemetry:init',
/** /**
* @event `destroy` Editor started destroy (on `editor.destroy()`). * @event `destroy` Editor started destroy (on `editor.destroy()`).
* @example * @example

5
packages/core/src/editor/view/EditorView.ts

@ -2,6 +2,7 @@ import { View, $ } from '../../common';
import { getHostName } from '../../utils/host-name'; import { getHostName } from '../../utils/host-name';
import { appendStyles } from '../../utils/mixins'; import { appendStyles } from '../../utils/mixins';
import EditorModel from '../model/Editor'; import EditorModel from '../model/Editor';
import { EditorEvents } from '../types';
export default class EditorView extends View<EditorModel> { export default class EditorView extends View<EditorModel> {
constructor(model: EditorModel) { constructor(model: EditorModel) {
@ -20,7 +21,7 @@ export default class EditorView extends View<EditorModel> {
} }
setTimeout(() => { setTimeout(() => {
model.trigger('load', model.Editor); model.trigger(EditorEvents.load, model.Editor);
model.clearDirtyCount(); model.clearDirtyCount();
}); });
}); });
@ -91,6 +92,6 @@ export default class EditorView extends View<EditorModel> {
} }
}); });
this.trigger('telemetry:sent'); this.trigger(EditorEvents.telemetryInit);
} }
} }

Loading…
Cancel
Save