whitespace

This commit is contained in:
Hans Pagel
2020-08-11 16:57:11 +02:00
parent 1a3f36c864
commit 5d4e63a26a

View File

@@ -53,16 +53,16 @@ export class Editor extends EventEmitter {
extensions: [], extensions: [],
renderer: null, renderer: null,
} }
private lastCommand = Promise.resolve() private lastCommand = Promise.resolve()
public selection = { from: 0, to: 0 } public selection = { from: 0, to: 0 }
constructor(options: Partial<EditorOptions> = {}) { constructor(options: Partial<EditorOptions> = {}) {
super() super()
this.options = { ...this.options, ...options } this.options = { ...this.options, ...options }
} }
private init() { private init() {
this.createExtensionManager() this.createExtensionManager()
this.createSchema() this.createSchema()
@@ -81,7 +81,7 @@ export class Editor extends EventEmitter {
this.registerCommand('toggleMark', require('./commands/toggleMark').default) this.registerCommand('toggleMark', require('./commands/toggleMark').default)
this.registerCommand('toggleNode', require('./commands/toggleNode').default) this.registerCommand('toggleNode', require('./commands/toggleNode').default)
this.registerCommand('updateMark', require('./commands/updateMark').default) this.registerCommand('updateMark', require('./commands/updateMark').default)
if (this.options.injectCSS) { if (this.options.injectCSS) {
require('./style.css') require('./style.css')
} }
@@ -95,7 +95,7 @@ export class Editor extends EventEmitter {
// throw new Error(`tiptap: command '${name}' not found.`) // throw new Error(`tiptap: command '${name}' not found.`)
return return
} }
return (...args: any) => command(...args) return (...args: any) => command(...args)
} }
@@ -107,11 +107,11 @@ export class Editor extends EventEmitter {
if (this.commands[name]) { if (this.commands[name]) {
throw new Error(`tiptap: command '${name}' is already defined.`) throw new Error(`tiptap: command '${name}' is already defined.`)
} }
if (getAllMethodNames(this).includes(name)) { if (getAllMethodNames(this).includes(name)) {
throw new Error(`tiptap: '${name}' is a protected name.`) throw new Error(`tiptap: '${name}' is a protected name.`)
} }
this.commands[name] = this.chainCommand((...args: any) => { this.commands[name] = this.chainCommand((...args: any) => {
return new Promise(resolve => callback(resolve, this.proxy)(...args)) return new Promise(resolve => callback(resolve, this.proxy)(...args))
}) })
@@ -214,7 +214,7 @@ export class Editor extends EventEmitter {
this.view.updateState(state) this.view.updateState(state)
this.storeSelection() this.storeSelection()
this.emit('transaction', { transaction }) this.emit('transaction', { transaction })
if (!transaction.docChanged || transaction.getMeta('preventUpdate')) { if (!transaction.docChanged || transaction.getMeta('preventUpdate')) {
return return
} }
@@ -281,5 +281,5 @@ export class Editor extends EventEmitter {
this.removeAllListeners() this.removeAllListeners()
removeElement(this.css) removeElement(this.css)
} }
} }