Skip to content

Commit

Permalink
Update php.md (ueberdosis#3618)
Browse files Browse the repository at this point in the history
Changes are based on reading this thread ueberdosis#1515 (comment)

This example relies on AlpineJS still and doing causes the editor to be wrapped in an observable/reactive layer. Moving the editor out of the returned object means it doesn't become a proxy object; otherwise, `editor.commands.setContent(content, false)` will already trigger an error `Range Error: Applying a mismatched transaction` and not work.
  • Loading branch information
peterfox authored and aliasliao committed May 24, 2023
1 parent b8c8000 commit 02b94e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/installation/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'

window.setupEditor = function (content) {
let editor

return {
editor: null,
content: content,

init(element) {
this.editor = new Editor({
editor = new Editor({
element: element,
extensions: [
StarterKit,
Expand All @@ -63,7 +64,7 @@ window.setupEditor = function (content) {

this.$watch('content', (content) => {
// If the new content matches TipTap's then we just skip.
if (content === this.editor.getHTML()) return
if (content === editor.getHTML()) return

/*
Otherwise, it means that a force external to TipTap
Expand All @@ -74,7 +75,7 @@ window.setupEditor = function (content) {
For more information on the `setContent()` method, see:
https://www.tiptap.dev/api/commands/set-content
*/
this.editor.commands.setContent(content, false)
editor.commands.setContent(content, false)
})
}
}
Expand Down

0 comments on commit 02b94e5

Please sign in to comment.