add emitter

This commit is contained in:
Philipp Kühn
2020-03-05 23:59:48 +01:00
parent 8da66c9cd8
commit 27e9d2b4af
3 changed files with 9 additions and 6 deletions

View File

@@ -13,6 +13,7 @@
],
"dependencies": {
"collect.js": "^4.20.3",
"events": "^3.1.0",
"prosemirror-commands": "^1.1.3",
"prosemirror-dropcursor": "^1.3.2",
"prosemirror-gapcursor": "^1.1.3",

View File

@@ -1,6 +1,7 @@
import {EditorState, TextSelection, Plugin} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
import {Schema, DOMParser, DOMSerializer} from "prosemirror-model"
import { EventEmitter } from 'events'
import { EditorState, TextSelection } from 'prosemirror-state'
import { EditorView} from 'prosemirror-view'
import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model'
import { inputRules, undoInputRule } from 'prosemirror-inputrules'
import { keymap } from 'prosemirror-keymap'
import { baseKeymap } from 'prosemirror-commands'
@@ -11,7 +12,6 @@ import { gapCursor } from 'prosemirror-gapcursor'
import elementFromString from './utils/elementFromString'
import injectCSS from './utils/injectCSS'
import ExtensionManager from './ExtensionManager'
type EditorContent = string | JSON
@@ -23,7 +23,7 @@ interface Options {
injectCSS: Boolean
}
export class Editor {
export class Editor extends EventEmitter {
extensionManager!: ExtensionManager
schema!: Schema
@@ -39,6 +39,7 @@ export class Editor {
public selection = { from: 0, to: 0 }
constructor(options: Options) {
super()
this.options = { ...this.options, ...options }
this.createExtensionManager()
this.createSchema()
@@ -193,6 +194,7 @@ export class Editor {
}
this.view.destroy()
this.removeAllListeners()
}
}

View File

@@ -5418,7 +5418,7 @@ eventemitter3@^3.1.0:
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==
events@^3.0.0:
events@^3.0.0, events@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59"
integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg==