refactor: remove deprecated packages

This commit is contained in:
Philipp Kühn
2021-08-13 15:47:53 +02:00
parent 731c1640d7
commit 9cf99fedc0
4 changed files with 0 additions and 83 deletions

View File

@@ -1,22 +0,0 @@
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
replace: {
/**
* Replaces text with a node.
*/
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
}
}
}
export const replace: RawCommands['replace'] = (typeOrName, attributes = {}) => ({ state, commands }) => {
console.warn('[tiptap warn]: replace() is deprecated. please use insertContent() instead.')
const { from, to } = state.selection
const range = { from, to }
return commands.replaceRange(range, typeOrName, attributes)
}

View File

@@ -1,33 +0,0 @@
import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import { RawCommands, Range } from '../types'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
replaceRange: {
/**
* Replaces text with a node within a range.
*/
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
}
}
}
export const replaceRange: RawCommands['replaceRange'] = (range, typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
console.warn('[tiptap warn]: replaceRange() is deprecated. please use insertContent() instead.')
const type = getNodeType(typeOrName, state.schema)
const { from, to } = range
// const $from = tr.doc.resolve(from)
// const index = $from.index()
// if (!$from.parent.canReplaceWith(index, index, type)) {
// return false
// }
if (dispatch) {
tr.replaceRangeWith(from, to, type.create(attributes))
}
return true
}