From 1495573d6ba99da9fd87134d58e5e19ab7f17e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 1 Dec 2020 13:08:11 +0100 Subject: [PATCH 1/2] fix bug --- packages/core/src/CommandManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/CommandManager.ts b/packages/core/src/CommandManager.ts index ce1804861..a2c9e2170 100644 --- a/packages/core/src/CommandManager.ts +++ b/packages/core/src/CommandManager.ts @@ -68,6 +68,7 @@ export default class CommandManager { const callbacks: boolean[] = [] const hasStartTransaction = !!startTr const tr = startTr || state.tr + const props = this.buildProps(tr, shouldDispatch) return new Proxy({}, { get: (_, name: string, proxy) => { @@ -86,7 +87,6 @@ export default class CommandManager { } return (...args: any) => { - const props = this.buildProps(tr, shouldDispatch) const callback = command(...args)(props) callbacks.push(callback) From d8322d2e2e5c26ee3fba1ebe90918598ef87c7e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 1 Dec 2020 14:44:53 +0100 Subject: [PATCH 2/2] fix chained commands --- packages/core/src/CommandManager.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/core/src/CommandManager.ts b/packages/core/src/CommandManager.ts index a2c9e2170..b5ea87cd8 100644 --- a/packages/core/src/CommandManager.ts +++ b/packages/core/src/CommandManager.ts @@ -141,10 +141,6 @@ export default class CommandManager { } public chainableState(tr: Transaction, state: EditorState): EditorState { - let { selection } = tr - let { doc } = tr - let { storedMarks } = tr - return { ...state, schema: state.schema, @@ -154,19 +150,15 @@ export default class CommandManager { reconfigure: state.reconfigure.bind(state), toJSON: state.toJSON.bind(state), get storedMarks() { - return storedMarks + return tr.storedMarks }, get selection() { - return selection + return tr.selection }, get doc() { - return doc + return tr.doc }, get tr() { - selection = tr.selection - doc = tr.doc - storedMarks = tr.storedMarks - return tr }, }