Tiptap: Append text to current editor's content

Created on 8 Mar 2019  路  4Comments  路  Source: ueberdosis/tiptap

Is there any ways to append a text/paragraph to the editor's current content?
For example, the current content is "This is the first sentence."
Is there any ways to append "This is the second sentence." to the end?

I found there was a setContent() method, but it replaces all the text content instead.

feature request

Most helpful comment

For adding text at the current cursor position you can do this:

const transaction = this.editor.state.tr.insertText('hey!')
this.editor.view.dispatch(transaction)

All 4 comments

Get the last position of the document, and dispatch a new transaction where you can call insertText function.

For adding text at the current cursor position you can do this:

const transaction = this.editor.state.tr.insertText('hey!')
this.editor.view.dispatch(transaction)

How to Append tag to current editor's content..?

How to Append tag to current editor's content..?

var elem = "<p>Hey!</p>"
var editorHtml = this.editor.getHTML()
editorHtml += elem
this.editor.setContent(editorHtml)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ageeye-cn picture ageeye-cn  路  3Comments

asseti6 picture asseti6  路  3Comments

pk-pressf1 picture pk-pressf1  路  3Comments

dolbex picture dolbex  路  3Comments

santicros picture santicros  路  3Comments