add emitter
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"collect.js": "^4.20.3",
|
"collect.js": "^4.20.3",
|
||||||
|
"events": "^3.1.0",
|
||||||
"prosemirror-commands": "^1.1.3",
|
"prosemirror-commands": "^1.1.3",
|
||||||
"prosemirror-dropcursor": "^1.3.2",
|
"prosemirror-dropcursor": "^1.3.2",
|
||||||
"prosemirror-gapcursor": "^1.1.3",
|
"prosemirror-gapcursor": "^1.1.3",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {EditorState, TextSelection, Plugin} from "prosemirror-state"
|
import { EventEmitter } from 'events'
|
||||||
import {EditorView} from "prosemirror-view"
|
import { EditorState, TextSelection } from 'prosemirror-state'
|
||||||
import {Schema, DOMParser, DOMSerializer} from "prosemirror-model"
|
import { EditorView} from 'prosemirror-view'
|
||||||
|
import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model'
|
||||||
import { inputRules, undoInputRule } from 'prosemirror-inputrules'
|
import { inputRules, undoInputRule } from 'prosemirror-inputrules'
|
||||||
import { keymap } from 'prosemirror-keymap'
|
import { keymap } from 'prosemirror-keymap'
|
||||||
import { baseKeymap } from 'prosemirror-commands'
|
import { baseKeymap } from 'prosemirror-commands'
|
||||||
@@ -11,7 +12,6 @@ import { gapCursor } from 'prosemirror-gapcursor'
|
|||||||
|
|
||||||
import elementFromString from './utils/elementFromString'
|
import elementFromString from './utils/elementFromString'
|
||||||
import injectCSS from './utils/injectCSS'
|
import injectCSS from './utils/injectCSS'
|
||||||
|
|
||||||
import ExtensionManager from './ExtensionManager'
|
import ExtensionManager from './ExtensionManager'
|
||||||
|
|
||||||
type EditorContent = string | JSON
|
type EditorContent = string | JSON
|
||||||
@@ -23,7 +23,7 @@ interface Options {
|
|||||||
injectCSS: Boolean
|
injectCSS: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Editor {
|
export class Editor extends EventEmitter {
|
||||||
|
|
||||||
extensionManager!: ExtensionManager
|
extensionManager!: ExtensionManager
|
||||||
schema!: Schema
|
schema!: Schema
|
||||||
@@ -39,6 +39,7 @@ export class Editor {
|
|||||||
public selection = { from: 0, to: 0 }
|
public selection = { from: 0, to: 0 }
|
||||||
|
|
||||||
constructor(options: Options) {
|
constructor(options: Options) {
|
||||||
|
super()
|
||||||
this.options = { ...this.options, ...options }
|
this.options = { ...this.options, ...options }
|
||||||
this.createExtensionManager()
|
this.createExtensionManager()
|
||||||
this.createSchema()
|
this.createSchema()
|
||||||
@@ -193,6 +194,7 @@ export class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.view.destroy()
|
this.view.destroy()
|
||||||
|
this.removeAllListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5418,7 +5418,7 @@ eventemitter3@^3.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
|
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
|
||||||
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==
|
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==
|
||||||
|
|
||||||
events@^3.0.0:
|
events@^3.0.0, events@^3.1.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59"
|
resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59"
|
||||||
integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg==
|
integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg==
|
||||||
|
|||||||
Reference in New Issue
Block a user