remove some deprecated commands

This commit is contained in:
Philipp Kühn
2021-05-05 23:45:17 +02:00
parent b69cf4106e
commit 9399e3061f
3 changed files with 0 additions and 74 deletions

View File

@@ -1,33 +0,0 @@
import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import deleteProps from '../utilities/deleteProps'
import { Command, RawCommands } from '../types'
declare module '@tiptap/core' {
interface Commands {
resetNodeAttributes: {
/**
* Resets node attributes to the default value.
*/
resetNodeAttributes: (typeOrName: string | NodeType, attributes: string | string[]) => Command,
}
}
}
export const resetNodeAttributes: RawCommands['resetNodeAttributes'] = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
console.warn('[tiptap warn]: resetNodeAttributes() is deprecated. please use resetAttributes() instead.')
const type = getNodeType(typeOrName, state.schema)
const { selection } = tr
const { ranges } = selection
ranges.forEach(range => {
state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
if (node.type === type && dispatch) {
tr.setNodeMarkup(pos, undefined, deleteProps(node.attrs, attributes))
}
})
})
return true
}

View File

@@ -1,35 +0,0 @@
import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import { Command, RawCommands } from '../types'
declare module '@tiptap/core' {
interface Commands {
updateNodeAttributes: {
/**
* Update attributes of a node.
*/
updateNodeAttributes: (typeOrName: string | NodeType, attributes: Record<string, any>) => Command,
}
}
}
export const updateNodeAttributes: RawCommands['updateNodeAttributes'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
console.warn('[tiptap warn]: updateNodeAttributes() is deprecated. please use updateAttributes() instead.')
const type = getNodeType(typeOrName, state.schema)
const { selection } = tr
const { ranges } = selection
ranges.forEach(range => {
state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
if (node.type === type && dispatch) {
tr.setNodeMarkup(pos, undefined, {
...node.attrs,
...attributes,
})
}
})
})
return true
}