@diramazioni/tui-editor-svelte v0.0.1
tui-editor-svelte for Svelte 5!
This libraray is a wrapper for tui-editor for Svelte 5.
Installation
npm install @diramazioni/tui-editor-svelte
Usage
Example +page.svelte:
<script lang="ts" setup>
import Editor from "$lib/Editor.svelte";
import Viewer from "$lib/Viewer.svelte";
import { content } from "./dummy.js";
let viewerMode = $state(false);
let editorRef = $state(); // Reference to store the component instance
</script>
<main>
<h1>Welcome to tui-editor-svelte for Svelte 5!</h1>
<p>
<button onclick={() => (viewerMode = !viewerMode)}>
{viewerMode ? "Editor mode" : "Viewer mode"}
</button>
</p>
{#if viewerMode}
<Viewer initialValue={content} onload={() => console.log("Viewer loaded")} />
{:else}
<Editor
bind:this={editorRef}
initialValue={content}
onload={() => console.log("Editor loaded")}
/>
{/if}
</main>Developing this library
Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --openEverything inside src/lib is part of your library, everything inside src/routes can be used as a showcase or preview app.
Building
To build your library:
npm run packageTo create a production version of your showcase app:
npm run buildYou can preview the production build with npm run preview.
To deploy your app, you may need to install an adapter for your target environment.
Publishing
Go into the package.json and give your package the desired name through the "name" option. Also consider adding a "license" field and point it to a LICENSE file which you can create from a template (one popular option is the MIT license).
To publish your library to npm:
npm publish1 year ago