Package Exports
- @flowbite-svelte-plugins/texteditor
- @flowbite-svelte-plugins/texteditor/AlignmentButtons.svelte
- @flowbite-svelte-plugins/texteditor/ContentWrapper.svelte
- @flowbite-svelte-plugins/texteditor/Divider.svelte
- @flowbite-svelte-plugins/texteditor/EditorWrapper.svelte
- @flowbite-svelte-plugins/texteditor/FontButtons.svelte
- @flowbite-svelte-plugins/texteditor/FormatButtons.svelte
- @flowbite-svelte-plugins/texteditor/GroupAlignments.svelte
- @flowbite-svelte-plugins/texteditor/GroupCustom.svelte
- @flowbite-svelte-plugins/texteditor/GroupFonts.svelte
- @flowbite-svelte-plugins/texteditor/GroupFormats.svelte
- @flowbite-svelte-plugins/texteditor/GroupImages.svelte
- @flowbite-svelte-plugins/texteditor/GroupLayouts.svelte
- @flowbite-svelte-plugins/texteditor/GroupLists.svelte
- @flowbite-svelte-plugins/texteditor/GroupTables1.svelte
- @flowbite-svelte-plugins/texteditor/GroupTables2.svelte
- @flowbite-svelte-plugins/texteditor/GroupTask.svelte
- @flowbite-svelte-plugins/texteditor/GroupUndoRedo.svelte
- @flowbite-svelte-plugins/texteditor/GroupVideos.svelte
- @flowbite-svelte-plugins/texteditor/ImageButtons.svelte
- @flowbite-svelte-plugins/texteditor/LayoutButtons.svelte
- @flowbite-svelte-plugins/texteditor/ListButtons.svelte
- @flowbite-svelte-plugins/texteditor/TableButtons.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/VideoButtons.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>