Skip to content

Commit

Permalink
Add tiptap placeholder extension
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Nov 5, 2024
1 parent a3c35ea commit 4f06d7c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
53 changes: 17 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@
"typescript-transform-extensions": "^1.0.1",
"vite": "^5.4.10",
"vitest": "^2.1.4"
},
"dependencies": {
"@tiptap/extension-placeholder": "^2.9.1"
}
}
8 changes: 8 additions & 0 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@
@apply text-2xl;
}
}

.tiptap p.is-editor-empty:first-child::before {
color: #adb5bd;
content: attr(data-placeholder);
float: left;
height: 0;
pointer-events: none;
}
10 changes: 9 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
import StarterKit from '@tiptap/starter-kit';
import cx from 'clsx';
import { Editor, EditorContent, createEditor } from '$lib';
import Placeholder from '@tiptap/extension-placeholder';
import { SvelteCounterExtension, SvelteEditableExtension } from './_components/SvelteExtension';
const extensions = [
StarterKit,
SvelteCounterExtension,
SvelteEditableExtension,
Placeholder.configure({ placeholder: 'Writwe something...' }),
];
let editor = $state() as Readable<Editor>;
onMount(() => {
editor = createEditor({
extensions: [StarterKit, SvelteCounterExtension, SvelteEditableExtension],
extensions,
content: `
<p>This is still the text editor you're used to, but enriched with node views.</p>
<svelte-counter-component count="0"></svelte-counter-component>
Expand Down

0 comments on commit 4f06d7c

Please sign in to comment.