Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support/migrate to Svelte 5 #60

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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