From 7f6ed0b1c078985a1acee736bc605fb9f93b5af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 13 Aug 2021 14:00:50 +0200 Subject: [PATCH] feat: add transaction to all events if possible, see #1461 --- packages/core/src/Editor.ts | 3 +++ packages/core/src/types.ts | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index aee6a066c..1bebe18bb 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -322,6 +322,7 @@ export class Editor extends EventEmitter { if (selectionHasChanged) { this.emit('selectionUpdate', { editor: this, + transaction, }) } @@ -332,6 +333,7 @@ export class Editor extends EventEmitter { this.emit('focus', { editor: this, event: focus.event, + transaction, }) } @@ -339,6 +341,7 @@ export class Editor extends EventEmitter { this.emit('blur', { editor: this, event: blur.event, + transaction, }) } diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index fb9692dd9..7656c215b 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -52,11 +52,11 @@ export interface EditorOptions { enablePasteRules: boolean, onBeforeCreate: (props: { editor: Editor }) => void, onCreate: (props: { editor: Editor }) => void, - onUpdate: (props: { editor: Editor }) => void, - onSelectionUpdate: (props: { editor: Editor }) => void, + onUpdate: (props: { editor: Editor, transaction: Transaction }) => void, + onSelectionUpdate: (props: { editor: Editor, transaction: Transaction }) => void, onTransaction: (props: { editor: Editor, transaction: Transaction }) => void, - onFocus: (props: { editor: Editor, event: FocusEvent }) => void, - onBlur: (props: { editor: Editor, event: FocusEvent }) => void, + onFocus: (props: { editor: Editor, event: FocusEvent, transaction: Transaction }) => void, + onBlur: (props: { editor: Editor, event: FocusEvent, transaction: Transaction }) => void, onDestroy: () => void, }