Tiptap: Append text/info to the end of the document

Created on 12 May 2020  路  3Comments  路  Source: ueberdosis/tiptap

Hello! I've checked the Issue https://github.com/scrumpy/tiptap/issues/230 where they explained how to append text to current position with

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

I want to append text dynamically to the end of the document, and without moving the user cursor. Should it be a transaction also? How should I target the end of the document and add the transaction there?
Thanks!

feature request

Most helpful comment

const { size } = this.editor.view.state.doc.content
const transaction = this.editor.state.tr.insertText('hey!', size )
this.editor.view.dispatch(transaction)

All 3 comments

const { size } = this.editor.view.state.doc.content
const transaction = this.editor.state.tr.insertText('hey!', size )
this.editor.view.dispatch(transaction)

That was just perfect! Thanks so much @apg-dev !!

Np. #679 held the answer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

afwn90cj93201nixr2e1re picture afwn90cj93201nixr2e1re  路  3Comments

pk-pressf1 picture pk-pressf1  路  3Comments

git-mischa picture git-mischa  路  3Comments

connecteev picture connecteev  路  3Comments

dolbex picture dolbex  路  3Comments