0.0.1 BETA
This is not official wrapper for Toast UI Editor. Inspired from Toast UI Editor for Vue.
npm i -D tui-editor-svelte
yarn add -D tui-editor-svelte
pnpm i -D tui-editor-svelte
set output.inlineDynamicImports
to true
for work perperly.
The component is using dynamic import
for both CSR and SSR compatible.
{
// ...
"output": {
// ...
inlineDynamicImports: true
}
// ...
}
@sveltejs/kit
usersadd tui-editor-svelte
in kit.vite.optimizeDeps.include
array because @toast-ui/editor
is a browser library.
{
kit: {
// ...
vite: {
// ...
optimizeDeps: {
include: ['tui-editor-svelte']
}
// ...
}
// ...
}
}
<scrip>
import Editor from 'tui-editor-svelte/Editor.svelte';
</script>
<Editor initialValue="Markdown **rocks!**" />
<scrip>
import Viewer from 'tui-editor-svelte/Viewer.svelte';
</script>
<Viewer initialValue="Markdown **rocks!**" />
See Vue editor props.
See Vue editor props.
Same as Vue editor instance methods. but usage is not same as vue. use like this:
<scrip>
import Editor from 'tui-editor-svelte/Editor.svelte';
let editor, html;
</script>
<Editor bind:this={editor} initialValue="Markdown **rocks!**" />
<button on:click={() => html = editor.invoke('getHtml')}>Get html content</button>
<pre>{html}</pre>
editor events are load,focus,blur,change,stateChange
.
See Vue editor events and use like below:
<scrip>
import Editor from 'tui-editor-svelte/Editor.svelte';
</script>
<Editor on:load={() => console.log('TUI Editor loaded.')} initialValue="Markdown **rocks!**" />
Feel free and add an issue.
use PNPM
.
pnpm -r i
pnpm run csr:dev
pnpm run kit:dev
<Editor/>
<Viewer/>
sapper
@svelte/kit
MIT.