tiptap/packages/core/src/commands/insertText.ts

23 lines
507 B
TypeScript
Raw Normal View History

2021-02-17 01:36:37 +08:00
import { Command, RawCommands } from '../types'
2020-11-05 05:38:52 +08:00
2021-02-11 01:05:02 +08:00
declare module '@tiptap/core' {
2021-02-17 01:39:37 +08:00
interface Commands {
2021-02-16 18:27:58 +08:00
insertText: {
/**
* Insert a string of text at the current position.
*/
insertText: (value: string) => Command,
}
2021-02-11 01:05:02 +08:00
}
}
2021-02-17 01:36:37 +08:00
export const insertText: RawCommands['insertText'] = value => ({ tr, dispatch }) => {
console.warn('[tiptap warn]: insertText() is deprecated. please use insertContent() instead.')
2020-11-05 05:38:52 +08:00
if (dispatch) {
tr.insertText(value)
}
return true
}