mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 23:15:15 +08:00
refactor: remove deprecated packages
This commit is contained in:
parent
731c1640d7
commit
9cf99fedc0
@ -362,28 +362,6 @@ export class Editor extends EventEmitter {
|
||||
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.
|
||||
*
|
||||
|
@ -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)
|
||||
}
|
@ -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
|
||||
}
|
@ -22,8 +22,6 @@ import * as lift from '../commands/lift'
|
||||
import * as liftEmptyBlock from '../commands/liftEmptyBlock'
|
||||
import * as liftListItem from '../commands/liftListItem'
|
||||
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 scrollIntoView from '../commands/scrollIntoView'
|
||||
import * as selectAll from '../commands/selectAll'
|
||||
@ -73,8 +71,6 @@ export { lift }
|
||||
export { liftEmptyBlock }
|
||||
export { liftListItem }
|
||||
export { newlineInCode }
|
||||
export { replace }
|
||||
export { replaceRange }
|
||||
export { resetAttributes }
|
||||
export { scrollIntoView }
|
||||
export { selectAll }
|
||||
@ -129,8 +125,6 @@ export const Commands = Extension.create({
|
||||
...liftEmptyBlock,
|
||||
...liftListItem,
|
||||
...newlineInCode,
|
||||
...replace,
|
||||
...replaceRange,
|
||||
...resetAttributes,
|
||||
...scrollIntoView,
|
||||
...selectAll,
|
||||
|
Loading…
Reference in New Issue
Block a user