Skip to content

Commit 78d000c

Browse files
committed
feat: integrate demo editor settings and output components for enhanced editor functionality
1 parent 58a69fc commit 78d000c

File tree

1 file changed

+22
-43
lines changed

1 file changed

+22
-43
lines changed

src/routes/+page.svelte

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
import { browser } from '$app/environment';
33
import type { Content, Editor } from '@tiptap/core';
44
import type { Transaction } from '@tiptap/pm/state';
5-
import { Checkbox } from '$lib/components/ui/checkbox/index.js';
6-
import { Label } from '$lib/components/ui/label/index.js';
75
import { cn } from '$lib/utils.js';
86
import GridPattern from '$lib/components/custom/grid-pattern.svelte';
9-
import { Button, buttonVariants } from '$lib/components/ui/button/index.js';
7+
import { Button } from '$lib/components/ui/button/index.js';
108
import Document from 'lucide-svelte/icons/file-text';
119
import GitHub from 'lucide-svelte/icons/github';
12-
import * as Dialog from '$lib/components/ui/dialog/index.js';
13-
import FileJson from 'lucide-svelte/icons/file-json';
14-
import ShikiCode from '$lib/components/custom/shiki-code.svelte';
15-
import { toast } from 'svelte-sonner';
16-
import { Edra, EdraToolbar } from '$lib/edra/shadcn/index.js';
10+
import { Edra, EdraToolbar, EdraBubbleMenu } from '$lib/edra/shadcn/index.js';
1711
import { slide } from 'svelte/transition';
1812
import defaultContent from '$lib/default_content.js';
13+
import DemoEditorSettings from '$lib/components/custom/demo-editor-settings.svelte';
14+
import EditorOutput from '$lib/components/custom/editor-output.svelte';
1915
2016
let content = $state<Content>();
2117
let editor = $state<Editor>();
@@ -26,7 +22,13 @@
2622
});
2723
2824
let showToolBar = $state(true);
29-
let showMenu = $state(true);
25+
let showBubbleMenus = $state(true);
26+
let editable = $state(true);
27+
28+
$effect(() => {
29+
console.log('editable', editable);
30+
editor?.setEditable(editable);
31+
});
3032
3133
if (browser) {
3234
const rawDataString = localStorage.getItem('edra-content');
@@ -74,46 +76,23 @@
7476
</Button>
7577
</div>
7678
<div class="size-full *:my-2">
79+
<div class="text-center text-xl font-bold">Explore Demo</div>
7780
<div class="flex flex-col items-center justify-center gap-4 sm:flex-row">
78-
<div class="flex items-center gap-2">
79-
<Checkbox id="toolbar" bind:checked={showToolBar} />
80-
<Label for="toolbar" class="text-sm font-medium leading-none">Show Editor Toolbar</Label>
81-
</div>
82-
<div class="flex items-center gap-2">
83-
<Checkbox id="menus" bind:checked={showMenu} />
84-
<Label for="menus" class="text-sm font-medium leading-none">Show Editor Menus</Label>
85-
</div>
86-
<Dialog.Root>
87-
<Dialog.Trigger class={buttonVariants({ variant: 'outline' })}>
88-
<FileJson /> Show Output
89-
</Dialog.Trigger>
90-
<Dialog.Content class="h-[95%] w-[95vw] sm:h-[80%] sm:min-w-[50%]">
91-
<Dialog.Header>
92-
<Dialog.Title>JSON Output</Dialog.Title>
93-
<Dialog.Description>Observe the JSON output of the editor content</Dialog.Description>
94-
</Dialog.Header>
95-
{@const stringContent = JSON.stringify(content, null, 2)}
96-
<ShikiCode class="size-full overflow-auto" code={stringContent} lang="json" />
97-
<Button
98-
variant="outline"
99-
class="ml-auto w-fit"
100-
onclick={() => {
101-
navigator.clipboard.writeText(stringContent);
102-
toast.success(`Copied to clipboard`);
103-
}}>Copy JSON Output</Button
104-
>
105-
</Dialog.Content>
106-
</Dialog.Root>
81+
<DemoEditorSettings bind:showToolBar bind:showBubbleMenus bind:editable />
82+
<EditorOutput code={JSON.stringify(content, null, 2)} />
10783
</div>
10884
</div>
10985
</div>
11086
<div class="m-auto flex h-[35rem] w-[95%] flex-col rounded border sm:w-[85%]">
111-
{#if editor && showToolBar}
112-
<div transition:slide>
113-
<EdraToolbar {editor} />
114-
</div>
87+
{#if editor}
88+
{#if showToolBar}
89+
<div transition:slide>
90+
<EdraToolbar {editor} />
91+
</div>
92+
{/if}
93+
<EdraBubbleMenu {editor} />
11594
{/if}
116-
<Edra class="overflow-auto" bind:editor {showMenu} {content} {onUpdate} />
95+
<Edra class="overflow-auto" bind:editor {editable} {showBubbleMenus} {content} {onUpdate} />
11796
</div>
11897
</div>
11998

0 commit comments

Comments
 (0)