mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-22 16:17:50 +08:00
e07a5b625d
* use named exports instead of default exports * fix tests Co-authored-by: Philipp Kühn <philippkuehn@MacBook-Pro-von-Philipp.local>
38 lines
889 B
TypeScript
38 lines
889 B
TypeScript
import { EditorState, Transaction } from 'prosemirror-state'
|
|
|
|
export function createChainableState(config: {
|
|
transaction: Transaction,
|
|
state: EditorState,
|
|
}): EditorState {
|
|
const { state, transaction } = config
|
|
let { selection } = transaction
|
|
let { doc } = transaction
|
|
let { storedMarks } = transaction
|
|
|
|
return {
|
|
...state,
|
|
schema: state.schema,
|
|
plugins: state.plugins,
|
|
apply: state.apply.bind(state),
|
|
applyTransaction: state.applyTransaction.bind(state),
|
|
reconfigure: state.reconfigure.bind(state),
|
|
toJSON: state.toJSON.bind(state),
|
|
get storedMarks() {
|
|
return storedMarks
|
|
},
|
|
get selection() {
|
|
return selection
|
|
},
|
|
get doc() {
|
|
return doc
|
|
},
|
|
get tr() {
|
|
selection = transaction.selection
|
|
doc = transaction.doc
|
|
storedMarks = transaction.storedMarks
|
|
|
|
return transaction
|
|
},
|
|
}
|
|
}
|