@swdotcom/editor-flow
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

editor-flow

Handles document change events

Install

yarn add editor-flow

Usage

import { EditorFlow, EditorType, FlowEventType, ProjectChangeInfo, VSCodeInterface } from 'editor-flow';

const iface: VSCodeInterface = {
  disposable: Disposable,  // vscode disposable
  window: window,          // vscode window namespace
  workspace: workspace     // vscode workspace namespace
};

const editorFlow:EditorFlow = EditorFlow.getInstance(EditorType.VSCODE, iface);
const emitter: any = editorFlow.getEmitter();

emitter.on('editor_flow_data', (data: any) => {
  switch(data.flow_event_type) {
    case FlowEventType.CLOSE:
      this.fileCloseHandler(data.event);
      break;
    case FlowEventType.OPEN:
      this.fileOpenHandler(data.event);
      break;
    case FlowEventType.SAVE:
      this.fileSaveHandler(data.event);
      break;
    case FlowEventType.UNFOCUS:
      this.windowStateChangeHandler(data.event);
      break;
    case FlowEventType.FOCUS:
      this.windowStateChangeHandler(data.event);
      break;
    case FlowEventType.THEME:
      this.themeKindChangeHandler(data.event);
      break;
    case FlowEventType.KPM:
      // get the project_change_info attribute and post it
      this.kpmHandler(data.project_change_info);
      break;
  }
});

...

private kpmHandler(
  projectChangeInfo: ProjectChangeInfo) {
  this.tracker.trackCodeTimeEvent(projectChangeInfo);
}

Dependents (0)

Package Sidebar

Install

npm i @swdotcom/editor-flow

Weekly Downloads

2

Version

1.1.2

License

SEE LICENSE IN LICENSE

Unpacked Size

148 kB

Total Files

69

Last publish

Collaborators

  • software_ryan
  • daniel.alfaro
  • bo_j
  • brettmstevens7
  • xavierluiz
  • thegeoffstevens
  • masonmc