fix chain again

This commit is contained in:
Philipp Kühn
2020-12-01 23:32:39 +01:00
parent 30d5ab5f39
commit 532eaa4e86

View File

@@ -68,7 +68,6 @@ export default class CommandManager {
const callbacks: boolean[] = [] const callbacks: boolean[] = []
const hasStartTransaction = !!startTr const hasStartTransaction = !!startTr
const tr = startTr || state.tr const tr = startTr || state.tr
const props = this.buildProps(tr, shouldDispatch)
return new Proxy({}, { return new Proxy({}, {
get: (_, name: string, proxy) => { get: (_, name: string, proxy) => {
@@ -87,7 +86,9 @@ export default class CommandManager {
} }
return (...args: any) => { return (...args: any) => {
const props = this.buildProps(tr, shouldDispatch)
const callback = command(...args)(props) const callback = command(...args)(props)
callbacks.push(callback) callbacks.push(callback)
return proxy return proxy
@@ -118,6 +119,10 @@ export default class CommandManager {
const { editor, commands } = this const { editor, commands } = this
const { state, view } = editor const { state, view } = editor
if (state.storedMarks) {
tr.setStoredMarks(state.storedMarks)
}
const props = { const props = {
tr, tr,
editor, editor,
@@ -141,6 +146,10 @@ export default class CommandManager {
} }
public chainableState(tr: Transaction, state: EditorState): EditorState { public chainableState(tr: Transaction, state: EditorState): EditorState {
let { selection } = tr
let { doc } = tr
let { storedMarks } = tr
return { return {
...state, ...state,
schema: state.schema, schema: state.schema,
@@ -150,15 +159,19 @@ export default class CommandManager {
reconfigure: state.reconfigure.bind(state), reconfigure: state.reconfigure.bind(state),
toJSON: state.toJSON.bind(state), toJSON: state.toJSON.bind(state),
get storedMarks() { get storedMarks() {
return tr.storedMarks return storedMarks
}, },
get selection() { get selection() {
return tr.selection return selection
}, },
get doc() { get doc() {
return tr.doc return doc
}, },
get tr() { get tr() {
selection = tr.selection
doc = tr.doc
storedMarks = tr.storedMarks
return tr return tr
}, },
} }