Skip to content

Commit

Permalink
Support/migrate to Svelte 5 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
rChaoz authored Oct 30, 2024
1 parent d777523 commit 6490536
Show file tree
Hide file tree
Showing 20 changed files with 588 additions and 677 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Monthly Downloads](https://badgen.net/npm/dm/svelte-tiptap)](https://www.npmjs.com/package/svelte-tiptap)
[![License](https://badgen.net/npm/license/svelte-tiptap)](https://github.com/sibiraj-s/svelte-tiptap/blob/master/LICENSE)

> [!IMPORTANT]
> [!NOTE]
> This is the documentation for **svelte-tiptap v1**, which is compatible with Svelte 4.
> If you're using Svelte 5, check out the latest version [here](https://github.com/sibiraj-s/svelte-tiptap/?tab=readme-ov-file#svelte-tiptap).
Expand Down Expand Up @@ -38,7 +38,7 @@ A Simple editor.
import { createEditor, Editor, EditorContent } from 'svelte-tiptap';
import StarterKit from '@tiptap/starter-kit';
let editor: Readable<Editor>;
let editor = $state() as Readable<Editor>;
onMount(() => {
editor = createEditor({
Expand Down Expand Up @@ -144,8 +144,7 @@ export const SvelteCounterExtension = Node.create({
import cx from 'clsx';
import { NodeViewWrapper } from 'svelte-tiptap';
export let node: NodeViewProps['node'];
export let updateAttributes: NodeViewProps['updateAttributes'];
let { node, updateAttributes }: NodeViewProps = $props();
const handleClick = () => {
updateAttributes({ count: node.attrs.count + 1 });
Expand All @@ -156,7 +155,7 @@ export const SvelteCounterExtension = Node.create({
<span>Svelte Component</span>
<div>
<button on:click={handleClick} type="button">
<button onclick={handleClick} type="button">
This button has been clicked {node.attrs.count} times.
</button>
</div>
Expand All @@ -173,7 +172,7 @@ import StarterKit from '@tiptap/starter-kit';

import { SvelteCounterExtension } from './SvelteExtension';

let editor: Readable<Editor>;
let editor = $state() as Readable<Editor>;

onMount(() => {
editor = createEditor({
Expand All @@ -194,9 +193,7 @@ Refer https://www.tiptap.dev/guide/node-views/react/#all-available-props for the
```ts
import type { NodeViewProps } from '@tiptap/core';

export let node: NodeViewProps['node'];
export let updateAttributes: NodeViewProps['updateAttributes'];
// ...define other props as needed.
let { node, updateAttributes }: NodeViewProps = $props();

// update attributes
const handleClick = () => {
Expand Down
Loading

0 comments on commit 6490536

Please sign in to comment.