Package Exports
- @flowbite-svelte-plugins/texteditor
- @flowbite-svelte-plugins/texteditor/AlignmentButton.svelte
- @flowbite-svelte-plugins/texteditor/AlignmentButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/ContentWrapper.svelte
- @flowbite-svelte-plugins/texteditor/Divider.svelte
- @flowbite-svelte-plugins/texteditor/EditorWrapper.svelte
- @flowbite-svelte-plugins/texteditor/ExportButton.svelte
- @flowbite-svelte-plugins/texteditor/ExportButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/FontButton.svelte
- @flowbite-svelte-plugins/texteditor/FontButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/FormatButton.svelte
- @flowbite-svelte-plugins/texteditor/FormatButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/GroupCustom.svelte
- @flowbite-svelte-plugins/texteditor/HtmlCodeButton.svelte
- @flowbite-svelte-plugins/texteditor/ImageButton.svelte
- @flowbite-svelte-plugins/texteditor/ImageButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/LayoutButton.svelte
- @flowbite-svelte-plugins/texteditor/LayoutButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/ListButton.svelte
- @flowbite-svelte-plugins/texteditor/ListButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/SourceButton.svelte
- @flowbite-svelte-plugins/texteditor/TableButton.svelte
- @flowbite-svelte-plugins/texteditor/TableButtonGroup1.svelte
- @flowbite-svelte-plugins/texteditor/TableButtonGroup2.svelte
- @flowbite-svelte-plugins/texteditor/TaskButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/TextEditor.svelte
- @flowbite-svelte-plugins/texteditor/ToolbarRowWrapper.svelte
- @flowbite-svelte-plugins/texteditor/ToolbarWrapper.svelte
- @flowbite-svelte-plugins/texteditor/UndoRedo.svelte
- @flowbite-svelte-plugins/texteditor/UndoRedoButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/VideoButton.svelte
- @flowbite-svelte-plugins/texteditor/VideoButtonGroup.svelte
- @flowbite-svelte-plugins/texteditor/package.json
Readme
@flowbite-svelte-plugins/texteditor
Use the wysiwyg text editor component to create and modify content by manipulating paragraphs, headings, images and styling them using all available options.
Installation
pnpm i -D @flowbite-svelte-plugins/texteditor
Text editor example
<script lang="ts">
import { GroupAlignment, GroupUndoRedo, GroupFormat, GroupLayout, GroupMedia, TextEditor, ToolbarRowWrapper, Divider } from '@flowbite-svelte-plugins/texteditor';
import type { Editor } from '@tiptap/core';
import { Button } from 'flowbite-svelte';
let editorElement = $state<HTMLDivElement | null>(null);
let editorInstance = $state<Editor | null>(null);
function getEditorContent() {
return editorInstance?.getHTML() ?? '';
}
function setEditorContent(content: string) {
editorInstance?.commands.setContent(content);
}
const content =
'<p>Flowbite is an <strong>open-source library of UI components</strong> based on the utility-first Tailwind CSS framework featuring dark mode support, a Figma design system, and more.</p><p>It includes all of the commonly used components that a website requires, such as buttons, dropdowns, navigation bars, modals, datepickers, advanced charts and the list goes on.</p><p>Here is an example of a button component:</p><code><button type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">Default</button></code><p>Learn more about all components from the <a href="https://flowbite.com/docs/getting-started/introduction/">Flowbite Docs</a>.</p>';
</script>
<TextEditor bind:element={editorElement} bind:editor={editorInstance} {content}>
<ToolbarRowWrapper>
<GroupFormat editor={editorInstance} />
<Divider />
<GroupAlignment editor={editorInstance} />
</ToolbarRowWrapper>
<ToolbarRowWrapper top={false}>
<GroupUndoRedo editor={editorInstance} />
<GroupLayout editor={editorInstance} />
<Divider />
<GroupMedia editor={editorInstance} />
</ToolbarRowWrapper>
</TextEditor>
<div class="mt-4">
<Button onclick={() => console.log(getEditorContent())}>Get Content</Button>
<Button onclick={() => setEditorContent('<p>New content!</p>')}>Set Content</Button>
</div>