diff --git a/docs/src/docPages/installation/alpine.md b/docs/src/docPages/installation/alpine.md index bf6ed83b..352bc492 100644 --- a/docs/src/docPages/installation/alpine.md +++ b/docs/src/docPages/installation/alpine.md @@ -11,105 +11,73 @@ The following guide describes how to integrate tiptap with your [Alpine.js](http TODO -## CodeSandbox -https://codesandbox.io/s/alpine-tiptap-2ro5e?file=/index.html:0-1419 - ## index.html ```html - - - Parcel Sandbox - - - - + + + + + +
- -
- -
- - (view console for editor output) -
+ - - +
+
+ + + + + ``` -## index.js +## main.js ```js -import { Editor as TipTap } from "@tiptap/core" -import { defaultExtensions } from "@tiptap/starter-kit" +import alpinejs from 'https://cdn.skypack.dev/alpinejs' +import { Editor } from 'https://cdn.skypack.dev/@tiptap/core?min' +import { defaultExtensions } from 'https://cdn.skypack.dev/@tiptap/starter-kit?min' -window.setupEditor = function (content) { +window.setupEditor = function(content) { return { - content: content, - inFocus: false, - // updatedAt is to force Alpine to - // rerender on selection change - updatedAt: Date.now(), editor: null, - - init(el) { - let editor = new TipTap({ - element: el, + content: content, + init(element) { + this.editor = new Editor({ + element: element, extensions: defaultExtensions(), content: this.content, - editorProps: { - attributes: { - class: "prose-sm py-4 focus:outline-none" - } - } + onUpdate: ({ editor }) => { + this.content = editor.getHTML() + }, }) - - editor.on("update", () => { - this.content = this.editor.getHTML() - }) - - editor.on("focus", () => { - this.inFocus = true - }) - - editor.on("selection", () => { - this.updatedAt = Date.now() - }) - - this.editor = editor - } + }, } } ```