refactoring

This commit is contained in:
Philipp Kühn
2021-02-10 18:05:02 +01:00
parent f70974678b
commit 55ff908423
69 changed files with 519 additions and 527 deletions

View File

@@ -2,9 +2,15 @@ import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import { AnyObject, Command, Commands } from '../types'
/**
* Update attributes of a node.
*/
declare module '@tiptap/core' {
interface Commands {
/**
* Update attributes of a node.
*/
updateNodeAttributes: (typeOrName: string | NodeType, attributes: AnyObject) => Command,
}
}
export const updateNodeAttributes: Commands['updateNodeAttributes'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
const type = getNodeType(typeOrName, state.schema)
const { selection } = tr
@@ -21,9 +27,3 @@ export const updateNodeAttributes: Commands['updateNodeAttributes'] = (typeOrNam
return true
}
declare module '@tiptap/core' {
interface Commands {
updateNodeAttributes: (typeOrName: string | NodeType, attributes: AnyObject) => Command,
}
}