refactor: remove isEditable from node views, remove viewUpdate event

This commit is contained in:
Philipp Kühn
2021-04-07 22:07:36 +02:00
parent 7b1d8d103c
commit a0e2a830d7
14 changed files with 3 additions and 92 deletions

View File

@@ -60,7 +60,6 @@ export class Editor extends EventEmitter {
onCreate: () => null,
onUpdate: () => null,
onSelectionUpdate: () => null,
onViewUpdate: () => null,
onTransaction: () => null,
onFocus: () => null,
onBlur: () => null,
@@ -79,7 +78,6 @@ export class Editor extends EventEmitter {
this.on('create', this.options.onCreate)
this.on('update', this.options.onUpdate)
this.on('selectionUpdate', this.options.onSelectionUpdate)
this.on('viewUpdate', this.options.onViewUpdate)
this.on('transaction', this.options.onTransaction)
this.on('focus', this.options.onFocus)
this.on('blur', this.options.onBlur)
@@ -243,16 +241,7 @@ export class Editor extends EventEmitter {
// `editor.view` is not yet available at this time.
// Therefore we will add all plugins and node views directly afterwards.
const newState = this.state.reconfigure({
plugins: [
new Plugin({
view: () => ({
update: () => this.emit('viewUpdate', {
editor: this,
}),
}),
}),
...this.extensionManager.plugins,
],
plugins: this.extensionManager.plugins,
})
this.view.updateState(newState)

View File

@@ -123,14 +123,6 @@ declare module '@tiptap/core' {
editor: Editor,
}) => void) | null,
/**
* The view has changed.
*/
onViewUpdate?: ((this: {
options: Options,
editor: Editor,
}) => void) | null,
/**
* The editor state has changed.
*/

View File

@@ -55,10 +55,6 @@ export default class ExtensionManager {
this.editor.on('selectionUpdate', extension.config.onSelectionUpdate.bind(context))
}
if (typeof extension.config.onViewUpdate === 'function') {
this.editor.on('viewUpdate', extension.config.onViewUpdate.bind(context))
}
if (typeof extension.config.onTransaction === 'function') {
this.editor.on('transaction', extension.config.onTransaction.bind(context))
}

View File

@@ -136,15 +136,6 @@ declare module '@tiptap/core' {
type: MarkType,
}) => void) | null,
/**
* The view has changed.
*/
onViewUpdate?: ((this: {
options: Options,
editor: Editor,
type: MarkType,
}) => void) | null,
/**
* The editor state has changed.
*/

View File

@@ -135,16 +135,7 @@ declare module '@tiptap/core' {
/**
* The selection has changed.
*/
onSelectionUpdate?: ((this: {
options: Options,
editor: Editor,
type: NodeType,
}) => void) | null,
/**
* The view has changed.
*/
onViewUpdate?: ((this: {
onSelectionUpdate?: ((this: {
options: Options,
editor: Editor,
type: NodeType,

View File

@@ -31,7 +31,6 @@ export interface EditorOptions {
enablePasteRules: boolean,
onCreate: (props: { editor: Editor }) => void,
onUpdate: (props: { editor: Editor }) => void,
onViewUpdate: (props: { editor: Editor }) => void,
onSelectionUpdate: (props: { editor: Editor }) => void,
onTransaction: (props: { editor: Editor, transaction: Transaction }) => void,
onFocus: (props: { editor: Editor, event: FocusEvent }) => void,