@vizel/svelte 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/dist/components/Vizel.svelte +158 -0
- package/dist/components/Vizel.svelte.d.ts +82 -0
- package/dist/components/Vizel.svelte.d.ts.map +1 -0
- package/dist/components/VizelBubbleMenu.svelte +96 -0
- package/dist/components/VizelBubbleMenu.svelte.d.ts +28 -0
- package/dist/components/VizelBubbleMenu.svelte.d.ts.map +1 -0
- package/dist/components/VizelBubbleMenuButton.svelte +45 -0
- package/dist/components/VizelBubbleMenuButton.svelte.d.ts +21 -0
- package/dist/components/VizelBubbleMenuButton.svelte.d.ts.map +1 -0
- package/dist/components/VizelBubbleMenuColorPicker.svelte +135 -0
- package/dist/components/VizelBubbleMenuColorPicker.svelte.d.ts +19 -0
- package/dist/components/VizelBubbleMenuColorPicker.svelte.d.ts.map +1 -0
- package/dist/components/VizelBubbleMenuDefault.svelte +111 -0
- package/dist/components/VizelBubbleMenuDefault.svelte.d.ts +13 -0
- package/dist/components/VizelBubbleMenuDefault.svelte.d.ts.map +1 -0
- package/dist/components/VizelBubbleMenuDivider.svelte +12 -0
- package/dist/components/VizelBubbleMenuDivider.svelte.d.ts +8 -0
- package/dist/components/VizelBubbleMenuDivider.svelte.d.ts.map +1 -0
- package/dist/components/VizelColorPicker.svelte +269 -0
- package/dist/components/VizelColorPicker.svelte.d.ts +25 -0
- package/dist/components/VizelColorPicker.svelte.d.ts.map +1 -0
- package/dist/components/VizelContext.d.ts +27 -0
- package/dist/components/VizelContext.d.ts.map +1 -0
- package/dist/components/VizelContext.js +34 -0
- package/dist/components/VizelEditor.svelte +61 -0
- package/dist/components/VizelEditor.svelte.d.ts +17 -0
- package/dist/components/VizelEditor.svelte.d.ts.map +1 -0
- package/dist/components/VizelEmbedView.svelte +162 -0
- package/dist/components/VizelEmbedView.svelte.d.ts +13 -0
- package/dist/components/VizelEmbedView.svelte.d.ts.map +1 -0
- package/dist/components/VizelIcon.svelte +54 -0
- package/dist/components/VizelIcon.svelte.d.ts +32 -0
- package/dist/components/VizelIcon.svelte.d.ts.map +1 -0
- package/dist/components/VizelIconContext.d.ts +27 -0
- package/dist/components/VizelIconContext.d.ts.map +1 -0
- package/dist/components/VizelIconContext.js +31 -0
- package/dist/components/VizelIconProvider.svelte +43 -0
- package/dist/components/VizelIconProvider.svelte.d.ts +31 -0
- package/dist/components/VizelIconProvider.svelte.d.ts.map +1 -0
- package/dist/components/VizelLinkEditor.svelte +143 -0
- package/dist/components/VizelLinkEditor.svelte.d.ts +15 -0
- package/dist/components/VizelLinkEditor.svelte.d.ts.map +1 -0
- package/dist/components/VizelNodeSelector.svelte +172 -0
- package/dist/components/VizelNodeSelector.svelte.d.ts +13 -0
- package/dist/components/VizelNodeSelector.svelte.d.ts.map +1 -0
- package/dist/components/VizelPortal.svelte +70 -0
- package/dist/components/VizelPortal.svelte.d.ts +19 -0
- package/dist/components/VizelPortal.svelte.d.ts.map +1 -0
- package/dist/components/VizelProvider.svelte +26 -0
- package/dist/components/VizelProvider.svelte.d.ts +14 -0
- package/dist/components/VizelProvider.svelte.d.ts.map +1 -0
- package/dist/components/VizelSaveIndicator.svelte +94 -0
- package/dist/components/VizelSaveIndicator.svelte.d.ts +15 -0
- package/dist/components/VizelSaveIndicator.svelte.d.ts.map +1 -0
- package/dist/components/VizelSlashMenu.svelte +211 -0
- package/dist/components/VizelSlashMenu.svelte.d.ts +31 -0
- package/dist/components/VizelSlashMenu.svelte.d.ts.map +1 -0
- package/dist/components/VizelSlashMenuEmpty.svelte +22 -0
- package/dist/components/VizelSlashMenuEmpty.svelte.d.ts +11 -0
- package/dist/components/VizelSlashMenuEmpty.svelte.d.ts.map +1 -0
- package/dist/components/VizelSlashMenuItem.svelte +57 -0
- package/dist/components/VizelSlashMenuItem.svelte.d.ts +17 -0
- package/dist/components/VizelSlashMenuItem.svelte.d.ts.map +1 -0
- package/dist/components/VizelThemeProvider.svelte +79 -0
- package/dist/components/VizelThemeProvider.svelte.d.ts +11 -0
- package/dist/components/VizelThemeProvider.svelte.d.ts.map +1 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +64 -0
- package/dist/iconRenderer.d.ts +6 -0
- package/dist/iconRenderer.d.ts.map +1 -0
- package/dist/iconRenderer.js +7 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/runes/createVizelAutoSave.svelte.d.ts +44 -0
- package/dist/runes/createVizelAutoSave.svelte.d.ts.map +1 -0
- package/dist/runes/createVizelAutoSave.svelte.js +91 -0
- package/dist/runes/createVizelEditor.svelte.d.ts +43 -0
- package/dist/runes/createVizelEditor.svelte.d.ts.map +1 -0
- package/dist/runes/createVizelEditor.svelte.js +65 -0
- package/dist/runes/createVizelEditorState.svelte.d.ts +27 -0
- package/dist/runes/createVizelEditorState.svelte.d.ts.map +1 -0
- package/dist/runes/createVizelEditorState.svelte.js +35 -0
- package/dist/runes/createVizelMarkdown.svelte.d.ts +68 -0
- package/dist/runes/createVizelMarkdown.svelte.d.ts.map +1 -0
- package/dist/runes/createVizelMarkdown.svelte.js +123 -0
- package/dist/runes/createVizelSlashMenuRenderer.d.ts +22 -0
- package/dist/runes/createVizelSlashMenuRenderer.d.ts.map +1 -0
- package/dist/runes/createVizelSlashMenuRenderer.js +84 -0
- package/dist/runes/createVizelState.svelte.d.ts +22 -0
- package/dist/runes/createVizelState.svelte.d.ts.map +1 -0
- package/dist/runes/createVizelState.svelte.js +50 -0
- package/dist/runes/getVizelTheme.svelte.d.ts +23 -0
- package/dist/runes/getVizelTheme.svelte.d.ts.map +1 -0
- package/dist/runes/getVizelTheme.svelte.js +31 -0
- package/dist/runes/index.d.ts +8 -0
- package/dist/runes/index.d.ts.map +1 -0
- package/dist/runes/index.js +7 -0
- package/package.json +64 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
export interface VizelSlashMenuEmptyProps {
|
|
5
|
+
/** Custom class name */
|
|
6
|
+
class?: string;
|
|
7
|
+
/** Custom content */
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
let { class: className, children }: VizelSlashMenuEmptyProps = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div class="vizel-slash-menu-empty {className ?? ''}" data-vizel-slash-menu-empty="">
|
|
17
|
+
{#if children}
|
|
18
|
+
{@render children()}
|
|
19
|
+
{:else}
|
|
20
|
+
No results
|
|
21
|
+
{/if}
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
export interface VizelSlashMenuEmptyProps {
|
|
3
|
+
/** Custom class name */
|
|
4
|
+
class?: string;
|
|
5
|
+
/** Custom content */
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
}
|
|
8
|
+
declare const VizelSlashMenuEmpty: import("svelte").Component<VizelSlashMenuEmptyProps, {}, "">;
|
|
9
|
+
type VizelSlashMenuEmpty = ReturnType<typeof VizelSlashMenuEmpty>;
|
|
10
|
+
export default VizelSlashMenuEmpty;
|
|
11
|
+
//# sourceMappingURL=VizelSlashMenuEmpty.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VizelSlashMenuEmpty.svelte.d.ts","sourceRoot":"","sources":["../../src/components/VizelSlashMenuEmpty.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,wBAAwB;IACvC,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAgBD,QAAA,MAAM,mBAAmB,8DAAwC,CAAC;AAClE,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { VizelSlashCommandItem } from "@vizel/core";
|
|
3
|
+
|
|
4
|
+
export interface VizelSlashMenuItemProps {
|
|
5
|
+
/** The slash command item to display */
|
|
6
|
+
item: VizelSlashCommandItem;
|
|
7
|
+
/** Whether the item is selected */
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
/** Custom class name */
|
|
10
|
+
class?: string;
|
|
11
|
+
/** Click handler */
|
|
12
|
+
onclick?: () => void;
|
|
13
|
+
/** Match indices for highlighting (from fuzzy search) */
|
|
14
|
+
titleMatches?: [number, number][];
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
import { splitVizelTextByMatches } from "@vizel/core";
|
|
20
|
+
import VizelIcon from "./VizelIcon.svelte";
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
item,
|
|
24
|
+
isSelected = false,
|
|
25
|
+
class: className,
|
|
26
|
+
onclick,
|
|
27
|
+
titleMatches,
|
|
28
|
+
}: VizelSlashMenuItemProps = $props();
|
|
29
|
+
|
|
30
|
+
const parts = $derived(splitVizelTextByMatches(item.title, titleMatches));
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
class="vizel-slash-menu-item {isSelected ? 'is-selected' : ''} {className ?? ''}"
|
|
36
|
+
data-selected={isSelected || undefined}
|
|
37
|
+
{onclick}
|
|
38
|
+
>
|
|
39
|
+
<span class="vizel-slash-menu-icon">
|
|
40
|
+
<VizelIcon name={item.icon} />
|
|
41
|
+
</span>
|
|
42
|
+
<div class="vizel-slash-menu-text">
|
|
43
|
+
<span class="vizel-slash-menu-title">
|
|
44
|
+
{#each parts as part}
|
|
45
|
+
{#if part.highlight}
|
|
46
|
+
<mark class="vizel-slash-menu-highlight">{part.text}</mark>
|
|
47
|
+
{:else}
|
|
48
|
+
{part.text}
|
|
49
|
+
{/if}
|
|
50
|
+
{/each}
|
|
51
|
+
</span>
|
|
52
|
+
<span class="vizel-slash-menu-description">{item.description}</span>
|
|
53
|
+
</div>
|
|
54
|
+
{#if item.shortcut}
|
|
55
|
+
<span class="vizel-slash-menu-shortcut">{item.shortcut}</span>
|
|
56
|
+
{/if}
|
|
57
|
+
</button>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VizelSlashCommandItem } from "@vizel/core";
|
|
2
|
+
export interface VizelSlashMenuItemProps {
|
|
3
|
+
/** The slash command item to display */
|
|
4
|
+
item: VizelSlashCommandItem;
|
|
5
|
+
/** Whether the item is selected */
|
|
6
|
+
isSelected?: boolean;
|
|
7
|
+
/** Custom class name */
|
|
8
|
+
class?: string;
|
|
9
|
+
/** Click handler */
|
|
10
|
+
onclick?: () => void;
|
|
11
|
+
/** Match indices for highlighting (from fuzzy search) */
|
|
12
|
+
titleMatches?: [number, number][];
|
|
13
|
+
}
|
|
14
|
+
declare const VizelSlashMenuItem: import("svelte").Component<VizelSlashMenuItemProps, {}, "">;
|
|
15
|
+
type VizelSlashMenuItem = ReturnType<typeof VizelSlashMenuItem>;
|
|
16
|
+
export default VizelSlashMenuItem;
|
|
17
|
+
//# sourceMappingURL=VizelSlashMenuItem.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VizelSlashMenuItem.svelte.d.ts","sourceRoot":"","sources":["../../src/components/VizelSlashMenuItem.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,yDAAyD;IACzD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACnC;AA8CD,QAAA,MAAM,kBAAkB,6DAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { VizelThemeProviderOptions, VizelThemeState } from "@vizel/core";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
|
|
5
|
+
export const VIZEL_THEME_CONTEXT_KEY = Symbol("VizelThemeContext");
|
|
6
|
+
|
|
7
|
+
export interface VizelThemeProviderProps extends VizelThemeProviderOptions {
|
|
8
|
+
/** Children to render */
|
|
9
|
+
children: Snippet;
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import {
|
|
15
|
+
applyVizelTheme,
|
|
16
|
+
createVizelSystemThemeListener,
|
|
17
|
+
VIZEL_DEFAULT_THEME,
|
|
18
|
+
VIZEL_DEFAULT_THEME_STORAGE_KEY,
|
|
19
|
+
getStoredVizelTheme,
|
|
20
|
+
getVizelSystemTheme,
|
|
21
|
+
resolveVizelTheme,
|
|
22
|
+
storeVizelTheme,
|
|
23
|
+
type VizelResolvedTheme,
|
|
24
|
+
type VizelTheme,
|
|
25
|
+
} from "@vizel/core";
|
|
26
|
+
import { setContext } from "svelte";
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
children,
|
|
30
|
+
defaultTheme = VIZEL_DEFAULT_THEME,
|
|
31
|
+
storageKey = VIZEL_DEFAULT_THEME_STORAGE_KEY,
|
|
32
|
+
targetSelector,
|
|
33
|
+
disableTransitionOnChange = false,
|
|
34
|
+
}: VizelThemeProviderProps = $props();
|
|
35
|
+
|
|
36
|
+
// Intentionally capture initial values only - theme state should persist
|
|
37
|
+
// regardless of prop changes after mount
|
|
38
|
+
// svelte-ignore state_referenced_locally
|
|
39
|
+
let theme = $state<VizelTheme>(getStoredVizelTheme(storageKey) ?? defaultTheme);
|
|
40
|
+
let systemTheme = $state<VizelResolvedTheme>(getVizelSystemTheme());
|
|
41
|
+
|
|
42
|
+
const resolvedTheme = $derived(resolveVizelTheme(theme, systemTheme));
|
|
43
|
+
|
|
44
|
+
function setTheme(newTheme: VizelTheme) {
|
|
45
|
+
theme = newTheme;
|
|
46
|
+
storeVizelTheme(storageKey, newTheme);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const themeState: VizelThemeState = {
|
|
50
|
+
get theme() {
|
|
51
|
+
return theme;
|
|
52
|
+
},
|
|
53
|
+
get resolvedTheme() {
|
|
54
|
+
return resolvedTheme;
|
|
55
|
+
},
|
|
56
|
+
get systemTheme() {
|
|
57
|
+
return systemTheme;
|
|
58
|
+
},
|
|
59
|
+
setTheme,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
setContext(VIZEL_THEME_CONTEXT_KEY, themeState);
|
|
63
|
+
|
|
64
|
+
// Apply theme when resolved theme changes
|
|
65
|
+
$effect(() => {
|
|
66
|
+
applyVizelTheme(resolvedTheme, targetSelector, disableTransitionOnChange);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
$effect(() => {
|
|
70
|
+
// Listen for system theme changes
|
|
71
|
+
const cleanup = createVizelSystemThemeListener((newSystemTheme: VizelResolvedTheme) => {
|
|
72
|
+
systemTheme = newSystemTheme;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return cleanup;
|
|
76
|
+
});
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
{@render children()}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VizelThemeProviderOptions } from "@vizel/core";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
export declare const VIZEL_THEME_CONTEXT_KEY: unique symbol;
|
|
4
|
+
export interface VizelThemeProviderProps extends VizelThemeProviderOptions {
|
|
5
|
+
/** Children to render */
|
|
6
|
+
children: Snippet;
|
|
7
|
+
}
|
|
8
|
+
declare const VizelThemeProvider: import("svelte").Component<VizelThemeProviderProps, {}, "">;
|
|
9
|
+
type VizelThemeProvider = ReturnType<typeof VizelThemeProvider>;
|
|
10
|
+
export default VizelThemeProvider;
|
|
11
|
+
//# sourceMappingURL=VizelThemeProvider.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VizelThemeProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/components/VizelThemeProvider.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAmB,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,eAAO,MAAM,uBAAuB,eAA8B,CAAC;AAEnE,MAAM,WAAW,uBAAwB,SAAQ,yBAAyB;IACxE,yBAAyB;IACzB,QAAQ,EAAE,OAAO,CAAC;CACnB;AA8ED,QAAA,MAAM,kBAAkB,6DAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { default as Vizel, type VizelProps, type VizelRef } from "./Vizel.svelte";
|
|
2
|
+
export { default as VizelBubbleMenu, type VizelBubbleMenuProps, } from "./VizelBubbleMenu.svelte";
|
|
3
|
+
export { default as VizelBubbleMenuButton, type VizelBubbleMenuButtonProps, } from "./VizelBubbleMenuButton.svelte";
|
|
4
|
+
export { default as VizelBubbleMenuColorPicker, type VizelBubbleMenuColorPickerProps, } from "./VizelBubbleMenuColorPicker.svelte";
|
|
5
|
+
export { default as VizelBubbleMenuDefault, type VizelBubbleMenuDefaultProps, } from "./VizelBubbleMenuDefault.svelte";
|
|
6
|
+
export { default as VizelBubbleMenuDivider, type VizelBubbleMenuDividerProps, } from "./VizelBubbleMenuDivider.svelte";
|
|
7
|
+
export { default as VizelColorPicker, type VizelColorPickerProps, } from "./VizelColorPicker.svelte";
|
|
8
|
+
export { getVizelContext, getVizelContextSafe } from "./VizelContext.ts";
|
|
9
|
+
export { default as VizelEditor, type VizelEditorProps, type VizelExposed, } from "./VizelEditor.svelte";
|
|
10
|
+
export { default as VizelEmbedView, type VizelEmbedViewProps, } from "./VizelEmbedView.svelte";
|
|
11
|
+
export { default as VizelIcon, type VizelIconProps } from "./VizelIcon.svelte";
|
|
12
|
+
export { getVizelIconContext, setVizelIcons } from "./VizelIconContext.ts";
|
|
13
|
+
export { default as VizelIconProvider, type VizelIconProviderProps, } from "./VizelIconProvider.svelte";
|
|
14
|
+
export { default as VizelLinkEditor, type VizelLinkEditorProps, } from "./VizelLinkEditor.svelte";
|
|
15
|
+
export { default as VizelNodeSelector, type VizelNodeSelectorProps, } from "./VizelNodeSelector.svelte";
|
|
16
|
+
export { default as VizelPortal, type VizelPortalProps, } from "./VizelPortal.svelte";
|
|
17
|
+
export { default as VizelProvider, type VizelProviderProps, } from "./VizelProvider.svelte";
|
|
18
|
+
export { default as VizelSaveIndicator, type VizelSaveIndicatorProps, } from "./VizelSaveIndicator.svelte";
|
|
19
|
+
export { default as VizelSlashMenu, type VizelSlashMenuProps, type VizelSlashMenuRef, } from "./VizelSlashMenu.svelte";
|
|
20
|
+
export { default as VizelSlashMenuEmpty, type VizelSlashMenuEmptyProps, } from "./VizelSlashMenuEmpty.svelte";
|
|
21
|
+
export { default as VizelSlashMenuItem, type VizelSlashMenuItemProps, } from "./VizelSlashMenuItem.svelte";
|
|
22
|
+
export { default as VizelThemeProvider, type VizelThemeProviderProps, } from "./VizelThemeProvider.svelte";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAIlF,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,IAAI,qBAAqB,EAChC,KAAK,0BAA0B,GAChC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,0BAA0B,EACrC,KAAK,+BAA+B,GACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,OAAO,IAAI,sBAAsB,EACjC,KAAK,2BAA2B,GACjC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,OAAO,IAAI,sBAAsB,EACjC,KAAK,2BAA2B,GACjC,MAAM,iCAAiC,CAAC;AAIzC,OAAO,EACL,OAAO,IAAI,gBAAgB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIzE,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,KAAK,mBAAmB,GACzB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EACL,OAAO,IAAI,iBAAiB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,OAAO,IAAI,iBAAiB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,KAAK,kBAAkB,GACxB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,OAAO,IAAI,kBAAkB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,OAAO,IAAI,mBAAmB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,OAAO,IAAI,kBAAkB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,OAAO,IAAI,kBAAkB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Vizel all-in-one component
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export { default as Vizel } from "./Vizel.svelte";
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Vizel BubbleMenu components
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export { default as VizelBubbleMenu, } from "./VizelBubbleMenu.svelte";
|
|
9
|
+
export { default as VizelBubbleMenuButton, } from "./VizelBubbleMenuButton.svelte";
|
|
10
|
+
export { default as VizelBubbleMenuColorPicker, } from "./VizelBubbleMenuColorPicker.svelte";
|
|
11
|
+
export { default as VizelBubbleMenuDefault, } from "./VizelBubbleMenuDefault.svelte";
|
|
12
|
+
export { default as VizelBubbleMenuDivider, } from "./VizelBubbleMenuDivider.svelte";
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Vizel ColorPicker component
|
|
15
|
+
// ============================================================================
|
|
16
|
+
export { default as VizelColorPicker, } from "./VizelColorPicker.svelte";
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Vizel Context
|
|
19
|
+
// ============================================================================
|
|
20
|
+
export { getVizelContext, getVizelContextSafe } from "./VizelContext.ts";
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Vizel Editor components
|
|
23
|
+
// ============================================================================
|
|
24
|
+
export { default as VizelEditor, } from "./VizelEditor.svelte";
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Vizel EmbedView component
|
|
27
|
+
// ============================================================================
|
|
28
|
+
export { default as VizelEmbedView, } from "./VizelEmbedView.svelte";
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Vizel Icon component
|
|
31
|
+
// ============================================================================
|
|
32
|
+
export { default as VizelIcon } from "./VizelIcon.svelte";
|
|
33
|
+
export { getVizelIconContext, setVizelIcons } from "./VizelIconContext.ts";
|
|
34
|
+
export { default as VizelIconProvider, } from "./VizelIconProvider.svelte";
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Vizel LinkEditor component
|
|
37
|
+
// ============================================================================
|
|
38
|
+
export { default as VizelLinkEditor, } from "./VizelLinkEditor.svelte";
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Vizel NodeSelector component
|
|
41
|
+
// ============================================================================
|
|
42
|
+
export { default as VizelNodeSelector, } from "./VizelNodeSelector.svelte";
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// Vizel Portal component
|
|
45
|
+
// ============================================================================
|
|
46
|
+
export { default as VizelPortal, } from "./VizelPortal.svelte";
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Vizel Provider component
|
|
49
|
+
// ============================================================================
|
|
50
|
+
export { default as VizelProvider, } from "./VizelProvider.svelte";
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Vizel SaveIndicator component
|
|
53
|
+
// ============================================================================
|
|
54
|
+
export { default as VizelSaveIndicator, } from "./VizelSaveIndicator.svelte";
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Vizel SlashMenu components
|
|
57
|
+
// ============================================================================
|
|
58
|
+
export { default as VizelSlashMenu, } from "./VizelSlashMenu.svelte";
|
|
59
|
+
export { default as VizelSlashMenuEmpty, } from "./VizelSlashMenuEmpty.svelte";
|
|
60
|
+
export { default as VizelSlashMenuItem, } from "./VizelSlashMenuItem.svelte";
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Vizel ThemeProvider component
|
|
63
|
+
// ============================================================================
|
|
64
|
+
export { default as VizelThemeProvider, } from "./VizelThemeProvider.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconRenderer.d.ts","sourceRoot":"","sources":["../src/iconRenderer.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vizel/svelte
|
|
3
|
+
*
|
|
4
|
+
* Svelte 5 components and runes for the Vizel visual editor.
|
|
5
|
+
*/
|
|
6
|
+
import "./iconRenderer.ts";
|
|
7
|
+
export { getVizelContext, getVizelContextSafe, getVizelIconContext, setVizelIcons, Vizel, VizelBubbleMenu, VizelBubbleMenuButton, type VizelBubbleMenuButtonProps, VizelBubbleMenuColorPicker, type VizelBubbleMenuColorPickerProps, VizelBubbleMenuDefault, type VizelBubbleMenuDefaultProps, VizelBubbleMenuDivider, type VizelBubbleMenuDividerProps, type VizelBubbleMenuProps, VizelColorPicker, type VizelColorPickerProps, VizelEditor, type VizelEditorProps, VizelEmbedView, type VizelEmbedViewProps, type VizelExposed, VizelIcon, type VizelIconProps, VizelIconProvider, type VizelIconProviderProps, VizelLinkEditor, type VizelLinkEditorProps, VizelNodeSelector, type VizelNodeSelectorProps, VizelPortal, type VizelPortalProps, type VizelProps, VizelProvider, type VizelProviderProps, type VizelRef, VizelSaveIndicator, type VizelSaveIndicatorProps, VizelSlashMenu, VizelSlashMenuEmpty, type VizelSlashMenuEmptyProps, VizelSlashMenuItem, type VizelSlashMenuItemProps, type VizelSlashMenuProps, type VizelSlashMenuRef, VizelThemeProvider, type VizelThemeProviderProps, } from "./components/index.ts";
|
|
8
|
+
export { type CreateVizelAutoSaveResult, type CreateVizelEditorOptions, type CreateVizelMarkdownOptions, type CreateVizelMarkdownResult, createVizelAutoSave, createVizelEditor, createVizelEditorState, createVizelMarkdown, createVizelSlashMenuRenderer, createVizelState, getVizelTheme, getVizelThemeSafe, type VizelSlashMenuRendererOptions, } from "./runes/index.ts";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,mBAAmB,CAAC;AAG3B,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EAEb,KAAK,EAEL,eAAe,EACf,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,0BAA0B,EAC1B,KAAK,+BAA+B,EACpC,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EAEzB,gBAAgB,EAChB,KAAK,qBAAqB,EAE1B,WAAW,EACX,KAAK,gBAAgB,EAErB,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,SAAS,EACT,KAAK,cAAc,EACnB,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,oBAAoB,EAEzB,iBAAiB,EACjB,KAAK,sBAAsB,EAE3B,WAAW,EACX,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EAEb,kBAAkB,EAClB,KAAK,uBAAuB,EAE5B,cAAc,EACd,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,KAAK,6BAA6B,GACnC,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vizel/svelte
|
|
3
|
+
*
|
|
4
|
+
* Svelte 5 components and runes for the Vizel visual editor.
|
|
5
|
+
*/
|
|
6
|
+
// Initialize icon renderer (auto-registers with core)
|
|
7
|
+
import "./iconRenderer.ts";
|
|
8
|
+
// Components
|
|
9
|
+
export { getVizelContext, getVizelContextSafe, getVizelIconContext, setVizelIcons,
|
|
10
|
+
// Vizel all-in-one
|
|
11
|
+
Vizel,
|
|
12
|
+
// BubbleMenu
|
|
13
|
+
VizelBubbleMenu, VizelBubbleMenuButton, VizelBubbleMenuColorPicker, VizelBubbleMenuDefault, VizelBubbleMenuDivider,
|
|
14
|
+
// ColorPicker
|
|
15
|
+
VizelColorPicker,
|
|
16
|
+
// Editor components
|
|
17
|
+
VizelEditor,
|
|
18
|
+
// EmbedView
|
|
19
|
+
VizelEmbedView,
|
|
20
|
+
// Icon
|
|
21
|
+
VizelIcon, VizelIconProvider, VizelLinkEditor,
|
|
22
|
+
// NodeSelector
|
|
23
|
+
VizelNodeSelector,
|
|
24
|
+
// Portal
|
|
25
|
+
VizelPortal, VizelProvider,
|
|
26
|
+
// SaveIndicator
|
|
27
|
+
VizelSaveIndicator,
|
|
28
|
+
// SlashMenu
|
|
29
|
+
VizelSlashMenu, VizelSlashMenuEmpty, VizelSlashMenuItem, VizelThemeProvider, } from "./components/index.ts";
|
|
30
|
+
// Runes (Svelte 5 reactive state)
|
|
31
|
+
export { createVizelAutoSave, createVizelEditor, createVizelEditorState, createVizelMarkdown, createVizelSlashMenuRenderer, createVizelState, getVizelTheme, getVizelThemeSafe, } from "./runes/index.ts";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Editor, type JSONContent, type VizelAutoSaveOptions, type VizelSaveStatus } from "@vizel/core";
|
|
2
|
+
/**
|
|
3
|
+
* Auto-save rune result
|
|
4
|
+
*/
|
|
5
|
+
export interface CreateVizelAutoSaveResult {
|
|
6
|
+
/** Current save status */
|
|
7
|
+
readonly status: VizelSaveStatus;
|
|
8
|
+
/** Whether there are unsaved changes */
|
|
9
|
+
readonly hasUnsavedChanges: boolean;
|
|
10
|
+
/** Timestamp of last successful save */
|
|
11
|
+
readonly lastSaved: Date | null;
|
|
12
|
+
/** Last error that occurred */
|
|
13
|
+
readonly error: Error | null;
|
|
14
|
+
/** Manually trigger save */
|
|
15
|
+
save: () => Promise<void>;
|
|
16
|
+
/** Restore content from storage */
|
|
17
|
+
restore: () => Promise<JSONContent | null>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Svelte 5 rune for auto-saving editor content with debouncing.
|
|
21
|
+
*
|
|
22
|
+
* @param getEditor - Function that returns the editor instance
|
|
23
|
+
* @param options - Auto-save configuration options
|
|
24
|
+
* @returns Auto-save state and controls
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```svelte
|
|
28
|
+
* <script lang="ts">
|
|
29
|
+
* import { createVizelEditor, createVizelAutoSave, VizelEditor, VizelSaveIndicator } from '@vizel/svelte';
|
|
30
|
+
*
|
|
31
|
+
* const editor = createVizelEditor({ ... });
|
|
32
|
+
* const autoSave = createVizelAutoSave(() => editor.current, {
|
|
33
|
+
* debounceMs: 2000,
|
|
34
|
+
* storage: 'localStorage',
|
|
35
|
+
* key: 'my-document',
|
|
36
|
+
* });
|
|
37
|
+
* </script>
|
|
38
|
+
*
|
|
39
|
+
* <VizelEditor editor={editor.current} />
|
|
40
|
+
* <VizelSaveIndicator status={autoSave.status} lastSaved={autoSave.lastSaved} />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function createVizelAutoSave(getEditor: () => Editor | null | undefined, options?: VizelAutoSaveOptions): CreateVizelAutoSaveResult;
|
|
44
|
+
//# sourceMappingURL=createVizelAutoSave.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVizelAutoSave.svelte.d.ts","sourceRoot":"","sources":["../../src/runes/createVizelAutoSave.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,WAAW,EAEhB,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,wCAAwC;IACxC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,wCAAwC;IACxC,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAChC,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,4BAA4B;IAC5B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,mCAAmC;IACnC,OAAO,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,EAC1C,OAAO,GAAE,oBAAyB,GACjC,yBAAyB,CA0E3B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createVizelAutoSaveHandlers, VIZEL_DEFAULT_AUTO_SAVE_OPTIONS, } from "@vizel/core";
|
|
2
|
+
/**
|
|
3
|
+
* Svelte 5 rune for auto-saving editor content with debouncing.
|
|
4
|
+
*
|
|
5
|
+
* @param getEditor - Function that returns the editor instance
|
|
6
|
+
* @param options - Auto-save configuration options
|
|
7
|
+
* @returns Auto-save state and controls
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```svelte
|
|
11
|
+
* <script lang="ts">
|
|
12
|
+
* import { createVizelEditor, createVizelAutoSave, VizelEditor, VizelSaveIndicator } from '@vizel/svelte';
|
|
13
|
+
*
|
|
14
|
+
* const editor = createVizelEditor({ ... });
|
|
15
|
+
* const autoSave = createVizelAutoSave(() => editor.current, {
|
|
16
|
+
* debounceMs: 2000,
|
|
17
|
+
* storage: 'localStorage',
|
|
18
|
+
* key: 'my-document',
|
|
19
|
+
* });
|
|
20
|
+
* </script>
|
|
21
|
+
*
|
|
22
|
+
* <VizelEditor editor={editor.current} />
|
|
23
|
+
* <VizelSaveIndicator status={autoSave.status} lastSaved={autoSave.lastSaved} />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function createVizelAutoSave(getEditor, options = {}) {
|
|
27
|
+
const opts = { ...VIZEL_DEFAULT_AUTO_SAVE_OPTIONS, ...options };
|
|
28
|
+
let status = $state("saved");
|
|
29
|
+
let hasUnsavedChanges = $state(false);
|
|
30
|
+
let lastSaved = $state(null);
|
|
31
|
+
let error = $state(null);
|
|
32
|
+
let currentEditor = null;
|
|
33
|
+
let handlers = null;
|
|
34
|
+
function handleStateChange(partial) {
|
|
35
|
+
if (partial.status !== undefined)
|
|
36
|
+
status = partial.status;
|
|
37
|
+
if (partial.hasUnsavedChanges !== undefined)
|
|
38
|
+
hasUnsavedChanges = partial.hasUnsavedChanges;
|
|
39
|
+
if (partial.lastSaved !== undefined)
|
|
40
|
+
lastSaved = partial.lastSaved;
|
|
41
|
+
if (partial.error !== undefined)
|
|
42
|
+
error = partial.error;
|
|
43
|
+
}
|
|
44
|
+
function subscribe(editor) {
|
|
45
|
+
// Unsubscribe from previous editor
|
|
46
|
+
if (currentEditor && handlers) {
|
|
47
|
+
currentEditor.off("update", handlers.handleUpdate);
|
|
48
|
+
handlers.cancel();
|
|
49
|
+
}
|
|
50
|
+
currentEditor = editor ?? null;
|
|
51
|
+
if (!(currentEditor && opts.enabled)) {
|
|
52
|
+
handlers = null;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
handlers = createVizelAutoSaveHandlers(() => currentEditor, opts, handleStateChange);
|
|
56
|
+
currentEditor.on("update", handlers.handleUpdate);
|
|
57
|
+
}
|
|
58
|
+
// Watch for editor changes - $effect cleanup handles unmount
|
|
59
|
+
$effect(() => {
|
|
60
|
+
const editor = getEditor();
|
|
61
|
+
subscribe(editor);
|
|
62
|
+
return () => {
|
|
63
|
+
if (currentEditor && handlers) {
|
|
64
|
+
currentEditor.off("update", handlers.handleUpdate);
|
|
65
|
+
handlers.cancel();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
async function save() {
|
|
70
|
+
await handlers?.saveNow();
|
|
71
|
+
}
|
|
72
|
+
async function restore() {
|
|
73
|
+
return (await handlers?.restore()) ?? null;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
get status() {
|
|
77
|
+
return status;
|
|
78
|
+
},
|
|
79
|
+
get hasUnsavedChanges() {
|
|
80
|
+
return hasUnsavedChanges;
|
|
81
|
+
},
|
|
82
|
+
get lastSaved() {
|
|
83
|
+
return lastSaved;
|
|
84
|
+
},
|
|
85
|
+
get error() {
|
|
86
|
+
return error;
|
|
87
|
+
},
|
|
88
|
+
save,
|
|
89
|
+
restore,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Editor, type VizelCreateEditorOptions } from "@vizel/core";
|
|
2
|
+
/**
|
|
3
|
+
* Options for createVizelEditor rune.
|
|
4
|
+
* @see VizelCreateEditorOptions for available options.
|
|
5
|
+
*/
|
|
6
|
+
export type CreateVizelEditorOptions = VizelCreateEditorOptions;
|
|
7
|
+
/**
|
|
8
|
+
* Svelte 5 rune to create and manage a Vizel editor instance.
|
|
9
|
+
* Returns a reactive editor state that works with EditorContent component.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```svelte
|
|
13
|
+
* <script lang="ts">
|
|
14
|
+
* import { createVizelEditor, EditorContent, BubbleMenu } from '@vizel/svelte';
|
|
15
|
+
*
|
|
16
|
+
* const editor = createVizelEditor({
|
|
17
|
+
* placeholder: "Start typing...",
|
|
18
|
+
* onUpdate: ({ editor }) => {
|
|
19
|
+
* console.log(editor.getJSON());
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
* </script>
|
|
23
|
+
*
|
|
24
|
+
* <EditorContent editor={editor.current} />
|
|
25
|
+
* {#if editor.current}
|
|
26
|
+
* <BubbleMenu editor={editor.current} />
|
|
27
|
+
* {/if}
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```svelte
|
|
32
|
+
* <script lang="ts">
|
|
33
|
+
* // With initial markdown content
|
|
34
|
+
* const editor = createVizelEditor({
|
|
35
|
+
* initialMarkdown: "# Hello World\n\nThis is **bold** text.",
|
|
36
|
+
* });
|
|
37
|
+
* </script>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createVizelEditor(options?: CreateVizelEditorOptions): {
|
|
41
|
+
readonly current: Editor | null;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=createVizelEditor.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVizelEditor.svelte.d.ts","sourceRoot":"","sources":["../../src/runes/createVizelEditor.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAEX,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AAGrB;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B;;EAoCvE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createVizelEditorInstance, registerVizelUploadEventHandler, } from "@vizel/core";
|
|
2
|
+
import { createVizelSlashMenuRenderer } from "./createVizelSlashMenuRenderer.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Svelte 5 rune to create and manage a Vizel editor instance.
|
|
5
|
+
* Returns a reactive editor state that works with EditorContent component.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```svelte
|
|
9
|
+
* <script lang="ts">
|
|
10
|
+
* import { createVizelEditor, EditorContent, BubbleMenu } from '@vizel/svelte';
|
|
11
|
+
*
|
|
12
|
+
* const editor = createVizelEditor({
|
|
13
|
+
* placeholder: "Start typing...",
|
|
14
|
+
* onUpdate: ({ editor }) => {
|
|
15
|
+
* console.log(editor.getJSON());
|
|
16
|
+
* },
|
|
17
|
+
* });
|
|
18
|
+
* </script>
|
|
19
|
+
*
|
|
20
|
+
* <EditorContent editor={editor.current} />
|
|
21
|
+
* {#if editor.current}
|
|
22
|
+
* <BubbleMenu editor={editor.current} />
|
|
23
|
+
* {/if}
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```svelte
|
|
28
|
+
* <script lang="ts">
|
|
29
|
+
* // With initial markdown content
|
|
30
|
+
* const editor = createVizelEditor({
|
|
31
|
+
* initialMarkdown: "# Hello World\n\nThis is **bold** text.",
|
|
32
|
+
* });
|
|
33
|
+
* </script>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function createVizelEditor(options = {}) {
|
|
37
|
+
const { features, extensions: additionalExtensions = [], ...editorOptions } = options;
|
|
38
|
+
// Store image upload options for event handler
|
|
39
|
+
const imageOptions = typeof features?.image === "object" ? features.image : {};
|
|
40
|
+
let editor = $state(null);
|
|
41
|
+
// Create editor on mount and cleanup on destroy
|
|
42
|
+
$effect(() => {
|
|
43
|
+
const { editor: instance } = createVizelEditorInstance({
|
|
44
|
+
...editorOptions,
|
|
45
|
+
...(features !== undefined && { features }),
|
|
46
|
+
extensions: additionalExtensions,
|
|
47
|
+
createSlashMenuRenderer: createVizelSlashMenuRenderer,
|
|
48
|
+
});
|
|
49
|
+
editor = instance;
|
|
50
|
+
// Handle vizel:upload-image custom event from slash command
|
|
51
|
+
const cleanupHandler = registerVizelUploadEventHandler({
|
|
52
|
+
getEditor: () => editor,
|
|
53
|
+
getImageOptions: () => imageOptions,
|
|
54
|
+
});
|
|
55
|
+
return () => {
|
|
56
|
+
cleanupHandler();
|
|
57
|
+
editor?.destroy();
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
get current() {
|
|
62
|
+
return editor;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|