Skip to content

Commit

Permalink
add tiptap example
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBacon committed Aug 17, 2024
1 parent f08f178 commit 2194c2e
Show file tree
Hide file tree
Showing 4 changed files with 489 additions and 9 deletions.
43 changes: 43 additions & 0 deletions app/tiptap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "react";

import TipTapWrap from "@/components/tiptap-wrap";

export default function RTE() {
return (
<TipTapWrap
content={`
<h2>
Hi there! 👋,
</h2>
<p>
this is a <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles you’d probably expect from a text editor. But wait until you see the lists:
</p>
<ul>
<li>
That’s a bullet list with one …
</li>
<li>
… or two list items.
</li>
</ul>
<p>
Isn’t that great? And all of that is editable. But wait, there’s more. Let’s try a code block:
</p>
<pre><code class="language-css">body {
display: none;
}</code></pre>
<p>
I know, I know, this is impressive. It’s only the tip of the iceberg though. Give it a try and click a little bit around. Don’t forget to check the other examples too.
</p>
<blockquote>
Wow, that’s amazing. Good work, boy! 👏
<br />
— Mom
</blockquote>
`}
dom={{
scrollEnabled: false,
}}
/>
);
}
23 changes: 23 additions & 0 deletions components/tiptap-wrap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use dom";

import React from "react";
import { useEditor, EditorContent } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";

export default function TipTapWrap({
content,
}: {
content: string;
dom?: import("expo/dom").DOMProps;
}) {
const editor = useEditor({
extensions: [StarterKit],
content,
});

return (
<>
<EditorContent editor={editor} />
</>
);
}
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
"@radix-ui/react-tabs": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@react-navigation/native": "^6.0.2",
"@react-three/drei": "9.105.6",
"@react-three/fiber": "8.16.6",
"@tiptap/core": "^2.6.4",
"@tiptap/react": "^2.6.4",
"@tiptap/starter-kit": "^2.6.4",
"@types/three": "0.164.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"emoji-mart": "^5.6.0",
Expand All @@ -56,15 +62,11 @@
"react-native-web": "~0.19.10",
"react-native-webview": "13.8.6",
"recharts": "alpha",
"tailwindcss": "^3.4.10",
"sass": "^1.77.8",
"tailwind-merge": "^2.4.0",
"tailwindcss": "^3.4.10",
"tailwindcss-animate": "^1.0.7",

"@react-three/drei": "9.105.6",
"@react-three/fiber": "8.16.6",
"@types/three": "0.164.0",
"three": "0.164.1"

},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
Loading

0 comments on commit 2194c2e

Please sign in to comment.