diff --git a/packages/core/src/commands/resetNodeAttributes.ts b/packages/core/src/commands/resetNodeAttributes.ts deleted file mode 100644 index d8bb68f3..00000000 --- a/packages/core/src/commands/resetNodeAttributes.ts +++ /dev/null @@ -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 -} diff --git a/packages/core/src/commands/updateNodeAttributes.ts b/packages/core/src/commands/updateNodeAttributes.ts deleted file mode 100644 index ff910dbd..00000000 --- a/packages/core/src/commands/updateNodeAttributes.ts +++ /dev/null @@ -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) => 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 -} diff --git a/packages/core/src/extensions/commands.ts b/packages/core/src/extensions/commands.ts index e1c1d129..26d5bfb7 100644 --- a/packages/core/src/extensions/commands.ts +++ b/packages/core/src/extensions/commands.ts @@ -23,7 +23,6 @@ import * as newlineInCode from '../commands/newlineInCode' import * as replace from '../commands/replace' import * as replaceRange from '../commands/replaceRange' import * as resetAttributes from '../commands/resetAttributes' -import * as resetNodeAttributes from '../commands/resetNodeAttributes' import * as scrollIntoView from '../commands/scrollIntoView' import * as selectAll from '../commands/selectAll' import * as selectNodeBackward from '../commands/selectNodeBackward' @@ -45,7 +44,6 @@ import * as undoInputRule from '../commands/undoInputRule' import * as unsetAllMarks from '../commands/unsetAllMarks' import * as unsetMark from '../commands/unsetMark' import * as updateAttributes from '../commands/updateAttributes' -import * as updateNodeAttributes from '../commands/updateNodeAttributes' import * as wrapIn from '../commands/wrapIn' import * as wrapInList from '../commands/wrapInList' @@ -73,7 +71,6 @@ export { newlineInCode } export { replace } export { replaceRange } export { resetAttributes } -export { resetNodeAttributes } export { scrollIntoView } export { selectAll } export { selectNodeBackward } @@ -95,7 +92,6 @@ export { undoInputRule } export { unsetAllMarks } export { unsetMark } export { updateAttributes } -export { updateNodeAttributes } export { wrapIn } export { wrapInList } @@ -128,7 +124,6 @@ export const Commands = Extension.create({ ...replace, ...replaceRange, ...resetAttributes, - ...resetNodeAttributes, ...scrollIntoView, ...selectAll, ...selectNodeBackward, @@ -150,7 +145,6 @@ export const Commands = Extension.create({ ...unsetAllMarks, ...unsetMark, ...updateAttributes, - ...updateNodeAttributes, ...wrapIn, ...wrapInList, }