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

@@ -362,28 +362,6 @@ export class Editor extends EventEmitter {
return getAttributes(this.state, nameOrType) return getAttributes(this.state, nameOrType)
} }
/**
* Get attributes of the currently selected node.
*
* @param name Name of the node
*/
public getNodeAttributes(name: string): Record<string, any> {
console.warn('[tiptap warn]: editor.getNodeAttributes() is deprecated. please use editor.getAttributes() instead.')
return getNodeAttributes(this.state, name)
}
/**
* Get attributes of the currently selected mark.
*
* @param name Name of the mark
*/
public getMarkAttributes(name: string): Record<string, any> {
console.warn('[tiptap warn]: editor.getMarkAttributes() is deprecated. please use editor.getAttributes() instead.')
return getMarkAttributes(this.state, name)
}
/** /**
* Returns if the currently selected node or mark is active. * Returns if the currently selected node or mark is active.
* *

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
}

View File

@@ -22,8 +22,6 @@ import * as lift from '../commands/lift'
import * as liftEmptyBlock from '../commands/liftEmptyBlock' import * as liftEmptyBlock from '../commands/liftEmptyBlock'
import * as liftListItem from '../commands/liftListItem' import * as liftListItem from '../commands/liftListItem'
import * as newlineInCode from '../commands/newlineInCode' 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 resetAttributes from '../commands/resetAttributes'
import * as scrollIntoView from '../commands/scrollIntoView' import * as scrollIntoView from '../commands/scrollIntoView'
import * as selectAll from '../commands/selectAll' import * as selectAll from '../commands/selectAll'
@@ -73,8 +71,6 @@ export { lift }
export { liftEmptyBlock } export { liftEmptyBlock }
export { liftListItem } export { liftListItem }
export { newlineInCode } export { newlineInCode }
export { replace }
export { replaceRange }
export { resetAttributes } export { resetAttributes }
export { scrollIntoView } export { scrollIntoView }
export { selectAll } export { selectAll }
@@ -129,8 +125,6 @@ export const Commands = Extension.create({
...liftEmptyBlock, ...liftEmptyBlock,
...liftListItem, ...liftListItem,
...newlineInCode, ...newlineInCode,
...replace,
...replaceRange,
...resetAttributes, ...resetAttributes,
...scrollIntoView, ...scrollIntoView,
...selectAll, ...selectAll,