@websline/system-components 0.0.2 → 0.0.4
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/dist/components/atoms/{form → actions}/button/Button.svelte +33 -11
- package/dist/components/atoms/{form → actions}/button/Button.svelte.d.ts +28 -4
- package/dist/components/atoms/actions/button/button.variants.d.ts +151 -0
- package/dist/components/atoms/actions/button/button.variants.js +143 -0
- package/dist/components/atoms/{closeButton → actions/closeButton}/CloseButton.svelte +8 -7
- package/dist/components/atoms/actions/closeButton/CloseButton.svelte.d.ts +49 -0
- package/dist/components/atoms/avatar/Avatar.svelte +4 -4
- package/dist/components/atoms/badge/Badge.svelte +44 -0
- package/dist/components/atoms/badge/Badge.svelte.d.ts +65 -0
- package/dist/components/atoms/badge/badge.variants.d.ts +85 -0
- package/dist/components/atoms/badge/badge.variants.js +59 -0
- package/dist/components/atoms/chip/Chip.svelte +52 -0
- package/dist/components/atoms/chip/Chip.svelte.d.ts +81 -0
- package/dist/components/atoms/chip/chip.variants.d.ts +61 -0
- package/dist/components/atoms/chip/chip.variants.js +118 -0
- package/dist/components/atoms/colorChip/ColorChip.svelte +33 -0
- package/dist/components/atoms/colorChip/ColorChip.svelte.d.ts +57 -0
- package/dist/components/atoms/colorChip/colorChip.variants.d.ts +40 -0
- package/dist/components/atoms/colorChip/colorChip.variants.js +27 -0
- package/dist/components/atoms/{loading → feedback}/spinner/Spinner.svelte +2 -16
- package/dist/components/atoms/feedback/spinner/spinner.variants.d.ts +19 -0
- package/dist/components/atoms/feedback/spinner/spinner.variants.js +17 -0
- package/dist/components/atoms/form/formField/FormField.svelte +2 -10
- package/dist/components/atoms/form/formField/FormField.svelte.d.ts +8 -0
- package/dist/components/atoms/form/formField/formField.variants.d.ts +13 -0
- package/dist/components/atoms/form/formField/formField.variants.js +12 -0
- package/dist/components/atoms/form/helperText/HelperText.svelte +9 -10
- package/dist/components/atoms/form/helperText/HelperText.svelte.d.ts +22 -4
- package/dist/components/atoms/form/helperText/helperText.variants.d.ts +13 -0
- package/dist/components/atoms/form/helperText/helperText.variants.js +12 -0
- package/dist/components/atoms/form/label/Label.svelte +6 -14
- package/dist/components/atoms/form/label/Label.svelte.d.ts +8 -0
- package/dist/components/atoms/form/label/label.variants.d.ts +22 -0
- package/dist/components/atoms/form/label/label.variants.js +15 -0
- package/dist/components/atoms/form/radio/Radio.svelte +58 -0
- package/dist/components/atoms/form/radio/Radio.svelte.d.ts +65 -0
- package/dist/components/atoms/form/radio/radio.variants.d.ts +22 -0
- package/dist/components/atoms/form/radio/radio.variants.js +15 -0
- package/dist/components/atoms/form/select/Select.svelte +91 -0
- package/dist/components/atoms/form/select/Select.svelte.d.ts +81 -0
- package/dist/components/atoms/form/select/select.variants.d.ts +58 -0
- package/dist/components/atoms/form/select/select.variants.js +66 -0
- package/dist/components/atoms/form/switch/Switch.svelte +57 -0
- package/dist/components/atoms/form/switch/Switch.svelte.d.ts +65 -0
- package/dist/components/atoms/form/switch/switch.variants.d.ts +22 -0
- package/dist/components/atoms/form/switch/switch.variants.js +15 -0
- package/dist/components/atoms/icon/Icon.svelte +8 -1
- package/dist/components/atoms/icon/components/Add.svelte +27 -0
- package/dist/components/atoms/icon/components/Add.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Check.svelte +27 -0
- package/dist/components/atoms/icon/components/Check.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/ChevronDown.svelte +27 -0
- package/dist/components/atoms/icon/components/ChevronDown.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/CloseSmall.svelte +27 -0
- package/dist/components/atoms/icon/components/CloseSmall.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Page.svelte +27 -0
- package/dist/components/atoms/icon/components/Page.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Redo.svelte +27 -0
- package/dist/components/atoms/icon/components/Redo.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Undo.svelte +27 -0
- package/dist/components/atoms/icon/components/Undo.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/index.d.ts +14 -0
- package/dist/components/atoms/icon/index.js +14 -0
- package/dist/components/molecules/navigationItem/NavigationItem.svelte +80 -0
- package/dist/components/molecules/navigationItem/NavigationItem.svelte.d.ts +81 -0
- package/dist/components/molecules/navigationItem/navigationItem.variants.d.ts +61 -0
- package/dist/components/molecules/navigationItem/navigationItem.variants.js +29 -0
- package/dist/components/molecules/notification/Notification.svelte +1 -1
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatch.svelte +99 -0
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatch.svelte.d.ts +57 -0
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatchColor.svelte +13 -0
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatchColor.svelte.d.ts +11 -0
- package/dist/components/molecules/pickers/colorSwatch/colorSwatch.variants.d.ts +49 -0
- package/dist/components/molecules/pickers/colorSwatch/colorSwatch.variants.js +46 -0
- package/dist/components/molecules/pickers/colorSwatch/index.d.ts +3 -0
- package/dist/components/molecules/pickers/colorSwatch/index.js +4 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +50 -21
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte.d.ts +56 -0
- package/dist/components/molecules/richTextEditor/richTextEditor.variants.js +25 -3
- package/dist/components/molecules/richTextEditor/toolbar/RichTextEditorToolbar.svelte +49 -0
- package/dist/components/molecules/richTextEditor/{RichTextEditorToolbar.svelte.d.ts → toolbar/RichTextEditorToolbar.svelte.d.ts} +2 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte +27 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte.d.ts +15 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte +34 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte.d.ts +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte.d.ts +11 -0
- package/dist/components/molecules/selectorCard/SelectorCard.svelte +78 -0
- package/dist/components/molecules/selectorCard/SelectorCard.svelte.d.ts +105 -0
- package/dist/components/molecules/selectorCard/selectorCard.variants.d.ts +61 -0
- package/dist/components/molecules/selectorCard/selectorCard.variants.js +32 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte +1 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte.d.ts +8 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +1 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte.d.ts +8 -0
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte +1 -1
- package/dist/components/organisms/popover/Popover.svelte +15 -0
- package/dist/components/organisms/popover/Popover.svelte.d.ts +18 -0
- package/dist/components/organisms/popover/PopoverContent.svelte +84 -0
- package/dist/components/organisms/popover/PopoverContent.svelte.d.ts +89 -0
- package/dist/components/organisms/popover/PopoverTrigger.svelte +14 -0
- package/dist/components/{atoms/closeButton/CloseButton.svelte.d.ts → organisms/popover/PopoverTrigger.svelte.d.ts} +3 -11
- package/dist/components/organisms/popover/index.d.ts +4 -0
- package/dist/components/organisms/popover/index.js +5 -0
- package/dist/components/organisms/popover/popover.variants.d.ts +39 -0
- package/dist/components/organisms/popover/popover.variants.js +15 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +14 -4
- package/dist/utils/colors.d.ts +9 -0
- package/dist/utils/colors.js +119 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/theme.svelte.d.ts +10 -0
- package/dist/utils/theme.svelte.js +31 -0
- package/package.json +38 -39
- package/dist/components/atoms/form/button/button.variants.d.ts +0 -58
- package/dist/components/atoms/form/button/button.variants.js +0 -82
- package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte +0 -5
- package/dist/components/atoms/{closeButton → actions/closeButton}/closeButton.variants.d.ts +0 -0
- package/dist/components/atoms/{closeButton → actions/closeButton}/closeButton.variants.js +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/IconButton.svelte +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/IconButton.svelte.d.ts +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/iconButton.variants.d.ts +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/iconButton.variants.js +0 -0
- package/dist/components/atoms/{loading → feedback}/spinner/Spinner.svelte.d.ts +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { onMount, onDestroy } from "svelte";
|
|
3
|
-
import RichTextEditorToolbar from "./RichTextEditorToolbar.svelte";
|
|
3
|
+
import RichTextEditorToolbar from "./toolbar/RichTextEditorToolbar.svelte";
|
|
4
4
|
import { richTextEditorVariants } from "./richTextEditor.variants.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -18,13 +18,40 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
/** @type {Props} */
|
|
21
|
-
|
|
22
21
|
export let classes = {};
|
|
23
22
|
export let content = "";
|
|
24
23
|
export let fieldName = "";
|
|
25
24
|
export let hideToolbar = false;
|
|
26
|
-
export let placeholder = "Beginne mit dem Schreiben...";
|
|
25
|
+
export let placeholder = "Beginne mit dem Schreiben...";
|
|
27
26
|
export let size = "medium";
|
|
27
|
+
export let toolbarConfig = {
|
|
28
|
+
bold: {
|
|
29
|
+
enabled: true,
|
|
30
|
+
},
|
|
31
|
+
history: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
},
|
|
34
|
+
italic: {
|
|
35
|
+
enabled: true,
|
|
36
|
+
},
|
|
37
|
+
link: {
|
|
38
|
+
enabled: true,
|
|
39
|
+
},
|
|
40
|
+
list: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
},
|
|
43
|
+
listOrdered: {
|
|
44
|
+
enabled: true,
|
|
45
|
+
},
|
|
46
|
+
underline: {
|
|
47
|
+
enabled: true,
|
|
48
|
+
},
|
|
49
|
+
color: {
|
|
50
|
+
enabled: true,
|
|
51
|
+
colors: ["#121110", "#0000ff"],
|
|
52
|
+
defaultColor: "#121110",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
28
55
|
|
|
29
56
|
let element;
|
|
30
57
|
let editor;
|
|
@@ -33,36 +60,35 @@
|
|
|
33
60
|
const initEditor = async () => {
|
|
34
61
|
const { Editor } = await import("@tiptap/core");
|
|
35
62
|
const StarterKit = (await import("@tiptap/starter-kit")).default;
|
|
36
|
-
const Link = (await import("@tiptap/extension-link")).default;
|
|
37
63
|
const TextAlign = (await import("@tiptap/extension-text-align")).default;
|
|
38
64
|
const Color = (await import("@tiptap/extension-color")).default;
|
|
39
|
-
const TextStyle =
|
|
65
|
+
const { TextStyle } = await import("@tiptap/extension-text-style");
|
|
40
66
|
const Highlight = (await import("@tiptap/extension-highlight")).default;
|
|
41
|
-
const Underline = (await import("@tiptap/extension-underline")).default;
|
|
42
67
|
const Placeholder = (await import("@tiptap/extension-placeholder")).default;
|
|
43
68
|
const DOMPurify = (await import("dompurify")).default;
|
|
44
69
|
|
|
45
70
|
editor = new Editor({
|
|
46
71
|
element: element,
|
|
47
72
|
extensions: [
|
|
48
|
-
StarterKit
|
|
49
|
-
|
|
73
|
+
StarterKit.configure({
|
|
74
|
+
link: {
|
|
75
|
+
openOnClick: false,
|
|
76
|
+
HTMLAttributes: {
|
|
77
|
+
rel: "noopener noreferrer",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
50
81
|
Color,
|
|
51
82
|
Highlight.configure({
|
|
52
83
|
multicolor: true,
|
|
53
84
|
}),
|
|
54
|
-
|
|
55
|
-
|
|
85
|
+
Placeholder.configure({
|
|
86
|
+
placeholder,
|
|
56
87
|
}),
|
|
57
88
|
TextAlign.configure({
|
|
58
89
|
types: ["paragraph", "heading"],
|
|
59
90
|
}),
|
|
60
|
-
|
|
61
|
-
Placeholder.configure({
|
|
62
|
-
placeholder,
|
|
63
|
-
showOnlyWhenEditable: true,
|
|
64
|
-
showOnlyCurrent: true,
|
|
65
|
-
}),
|
|
91
|
+
TextStyle,
|
|
66
92
|
],
|
|
67
93
|
editorProps: {
|
|
68
94
|
handlePaste(view, event) {
|
|
@@ -127,18 +153,21 @@
|
|
|
127
153
|
return dom.innerHTML.trim();
|
|
128
154
|
};
|
|
129
155
|
|
|
130
|
-
let {
|
|
156
|
+
let styles = richTextEditorVariants({ hideToolbar, size });
|
|
131
157
|
</script>
|
|
132
158
|
|
|
133
|
-
<div class={base({ class: classes.base })}>
|
|
159
|
+
<div class={styles.base({ class: classes.base })}>
|
|
134
160
|
{#if !hideToolbar}
|
|
135
|
-
<div class={toolbar({ class: classes.toolbar })}>
|
|
136
|
-
<RichTextEditorToolbar {editor} />
|
|
161
|
+
<div class={styles.toolbar({ class: classes.toolbar })}>
|
|
162
|
+
<RichTextEditorToolbar {editor} {toolbarConfig} />
|
|
137
163
|
</div>
|
|
138
164
|
{/if}
|
|
139
165
|
{#if fieldName}
|
|
140
166
|
<input type="hidden" name={fieldName} bind:value={htmlInputValue} />
|
|
141
167
|
{/if}
|
|
142
|
-
<div
|
|
168
|
+
<div
|
|
169
|
+
class={styles.field({ class: classes.field })}
|
|
170
|
+
bind:this={element}
|
|
171
|
+
style={`color: ${toolbarConfig.color?.defaultColor || "#121110"};`}>
|
|
143
172
|
</div>
|
|
144
173
|
</div>
|
|
@@ -3,6 +3,34 @@ type RichTextEditor = SvelteComponent<{
|
|
|
3
3
|
size?: string;
|
|
4
4
|
placeholder?: string;
|
|
5
5
|
content?: string;
|
|
6
|
+
toolbarConfig?: {
|
|
7
|
+
bold: {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
history: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
};
|
|
13
|
+
italic: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
};
|
|
16
|
+
link: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
};
|
|
19
|
+
list: {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
};
|
|
22
|
+
listOrdered: {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
};
|
|
25
|
+
underline: {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
};
|
|
28
|
+
color: {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
colors: string[];
|
|
31
|
+
defaultColor: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
6
34
|
hideToolbar?: boolean;
|
|
7
35
|
classes?: Props;
|
|
8
36
|
fieldName?: string;
|
|
@@ -15,6 +43,34 @@ declare const RichTextEditor: $$__sveltets_2_IsomorphicComponent<{
|
|
|
15
43
|
size?: string;
|
|
16
44
|
placeholder?: string;
|
|
17
45
|
content?: string;
|
|
46
|
+
toolbarConfig?: {
|
|
47
|
+
bold: {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
};
|
|
50
|
+
history: {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
};
|
|
53
|
+
italic: {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
};
|
|
56
|
+
link: {
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
};
|
|
59
|
+
list: {
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
};
|
|
62
|
+
listOrdered: {
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
};
|
|
65
|
+
underline: {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
};
|
|
68
|
+
color: {
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
colors: string[];
|
|
71
|
+
defaultColor: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
18
74
|
hideToolbar?: boolean;
|
|
19
75
|
classes?: {
|
|
20
76
|
/**
|
|
@@ -3,9 +3,31 @@ import { tv } from "tailwind-variants";
|
|
|
3
3
|
const richTextEditorVariants = tv({
|
|
4
4
|
slots: {
|
|
5
5
|
base: "body-default text-neutral-800 dark:text-white",
|
|
6
|
-
toolbar:
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
toolbar:
|
|
7
|
+
"flex gap-0.5 px-5 py-2 border-neutral-300 dark:border-neutral-700 border border-b-0 rounded-t-sm pointer",
|
|
8
|
+
field: `
|
|
9
|
+
[&>div]:transition-[border]
|
|
10
|
+
[&>div]:duration-300
|
|
11
|
+
[&>div]:border
|
|
12
|
+
[&>div]:border-neutral-300
|
|
13
|
+
[&>div]:overflow-auto
|
|
14
|
+
dark:[&>div]:border-neutral-700
|
|
15
|
+
[&>div]:rounded-b-sm
|
|
16
|
+
[&>div]:outline-none
|
|
17
|
+
[&>div]:p-5
|
|
18
|
+
[&>div]:h-full
|
|
19
|
+
[&>div>p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]
|
|
20
|
+
[&>div>p.is-editor-empty:first-child::before]:float-left
|
|
21
|
+
[&>div>p.is-editor-empty:first-child::before]:h-0
|
|
22
|
+
[&>div>p.is-editor-empty:first-child::before]:text-neutral-500
|
|
23
|
+
[&>div>p.is-editor-empty:first-child::before]:pointer-events-none
|
|
24
|
+
[&>div_a]:underline
|
|
25
|
+
[&>div_a]:text-blue-500
|
|
26
|
+
[&>div_ol]:list-decimal
|
|
27
|
+
[&>div_ol]:pl-4
|
|
28
|
+
[&>div_ul]:list-disc
|
|
29
|
+
[&>div_ul]:pl-4
|
|
30
|
+
`,
|
|
9
31
|
},
|
|
10
32
|
variants: {
|
|
11
33
|
hideToolbar: {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import ToolbarBold from "./ToolbarBold.svelte";
|
|
3
|
+
import ToolbarItalic from "./ToolbarItalic.svelte";
|
|
4
|
+
import ToolbarUnderline from "./ToolbarUnderline.svelte";
|
|
5
|
+
import ToolbarLink from "./ToolbarLink.svelte";
|
|
6
|
+
import ToolbarListOrdered from "./ToolbarListOrdered.svelte";
|
|
7
|
+
import ToolbarList from "./ToolbarList.svelte";
|
|
8
|
+
import ToolbarUndo from "./ToolbarUndo.svelte";
|
|
9
|
+
import ToolbarRedo from "./ToolbarRedo.svelte";
|
|
10
|
+
import ToolbarColor from "./ToolbarColor.svelte";
|
|
11
|
+
|
|
12
|
+
let { editor, toolbarConfig } = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if toolbarConfig && toolbarConfig.bold && toolbarConfig.bold.enabled}
|
|
16
|
+
<ToolbarBold {editor} />
|
|
17
|
+
{/if}
|
|
18
|
+
|
|
19
|
+
{#if toolbarConfig && toolbarConfig.italic && toolbarConfig.italic.enabled}
|
|
20
|
+
<ToolbarItalic {editor} />
|
|
21
|
+
{/if}
|
|
22
|
+
|
|
23
|
+
{#if toolbarConfig && toolbarConfig.underline && toolbarConfig.underline.enabled}
|
|
24
|
+
<ToolbarUnderline {editor} />
|
|
25
|
+
{/if}
|
|
26
|
+
|
|
27
|
+
{#if toolbarConfig && toolbarConfig.link && toolbarConfig.link.enabled}
|
|
28
|
+
<ToolbarLink {editor} onOpenLink={toolbarConfig.link.onOpenLink} />
|
|
29
|
+
{/if}
|
|
30
|
+
|
|
31
|
+
{#if toolbarConfig && toolbarConfig.color && toolbarConfig.color.enabled && toolbarConfig.color.colors.length > 0}
|
|
32
|
+
<ToolbarColor
|
|
33
|
+
colors={toolbarConfig.color.colors}
|
|
34
|
+
defaultColor={toolbarConfig.color.defaultColor}
|
|
35
|
+
{editor} />
|
|
36
|
+
{/if}
|
|
37
|
+
|
|
38
|
+
{#if toolbarConfig && toolbarConfig.list && toolbarConfig.list.enabled}
|
|
39
|
+
<ToolbarList {editor} />
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
{#if toolbarConfig && toolbarConfig.listOrdered && toolbarConfig.listOrdered.enabled}
|
|
43
|
+
<ToolbarListOrdered {editor} />
|
|
44
|
+
{/if}
|
|
45
|
+
|
|
46
|
+
{#if toolbarConfig && toolbarConfig.history && toolbarConfig.history.enabled}
|
|
47
|
+
<ToolbarUndo {editor} />
|
|
48
|
+
<ToolbarRedo {editor} />
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="bold"
|
|
10
|
+
onclick={() => editor.chain().focus().toggleBold().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant={editor.isActive("bold") ? "filled" : "transparent"} />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarBold;
|
|
2
|
+
type ToolbarBold = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarBold: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { ColorSwatch } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { colors = [], defaultColor = "#121110", editor } = $props();
|
|
5
|
+
|
|
6
|
+
let isOpen = $state(false);
|
|
7
|
+
let selectedColor = $state(defaultColor);
|
|
8
|
+
|
|
9
|
+
const handleColorSelect = (color) => {
|
|
10
|
+
selectedColor = color;
|
|
11
|
+
isOpen = false;
|
|
12
|
+
|
|
13
|
+
editor.chain().focus().setColor(selectedColor).run();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
$effect(() => {
|
|
17
|
+
if (!editor) return;
|
|
18
|
+
const attrs = editor.getAttributes("textStyle");
|
|
19
|
+
selectedColor = attrs.color || defaultColor;
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<ColorSwatch.Root bind:isOpen bind:selectedColor>
|
|
24
|
+
{#each colors as color (color)}
|
|
25
|
+
<ColorSwatch.Color clickable {color} onclick={() => handleColorSelect(color)} />
|
|
26
|
+
{/each}
|
|
27
|
+
</ColorSwatch.Root>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default ToolbarColor;
|
|
2
|
+
type ToolbarColor = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarColor: import("svelte").Component<{
|
|
7
|
+
colors?: any[];
|
|
8
|
+
defaultColor?: string;
|
|
9
|
+
editor: any;
|
|
10
|
+
}, {}, "">;
|
|
11
|
+
type $$ComponentProps = {
|
|
12
|
+
colors?: any[];
|
|
13
|
+
defaultColor?: string;
|
|
14
|
+
editor: any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="italic"
|
|
10
|
+
onclick={() => editor.chain().focus().toggleItalic().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant={editor.isActive("italic") ? "filled" : "transparent"} />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarItalic;
|
|
2
|
+
type ToolbarItalic = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarItalic: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor, onOpenLink } = $props();
|
|
5
|
+
|
|
6
|
+
const setLink = () => {
|
|
7
|
+
const focus = () => editor.chain().focus();
|
|
8
|
+
|
|
9
|
+
const previousUrl = editor.getAttributes("link").href;
|
|
10
|
+
const url = prompt("Link eingeben:", previousUrl || "https://");
|
|
11
|
+
|
|
12
|
+
if (url === null) return;
|
|
13
|
+
url === "" ? focus().unsetLink().run() : focus().setLink({ href: url }).run();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const handleOpenLinkModal = () => {
|
|
17
|
+
if (onOpenLink) {
|
|
18
|
+
onOpenLink({ setLink, editor });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
alert(
|
|
23
|
+
"[Editor] No link modal configured. Please provide an `onOpenLink` callback",
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
{#if editor}
|
|
29
|
+
<IconButton
|
|
30
|
+
icon="link"
|
|
31
|
+
onclick={handleOpenLinkModal}
|
|
32
|
+
shape="square"
|
|
33
|
+
variant={editor.isActive("link") ? "filled" : "transparent"} />
|
|
34
|
+
{/if}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default ToolbarLink;
|
|
2
|
+
type ToolbarLink = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarLink: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
onOpenLink: any;
|
|
9
|
+
}, {}, "">;
|
|
10
|
+
type $$ComponentProps = {
|
|
11
|
+
editor: any;
|
|
12
|
+
onOpenLink: any;
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="listUnordered"
|
|
10
|
+
onclick={() => editor.chain().focus().toggleBulletList().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant={editor.isActive("bulletList") ? "filled" : "transparent"} />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarList;
|
|
2
|
+
type ToolbarList = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarList: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="listOrdered"
|
|
10
|
+
onclick={() => editor.chain().focus().toggleOrderedList().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant={editor.isActive("orderedList") ? "filled" : "transparent"} />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarListOrdered;
|
|
2
|
+
type ToolbarListOrdered = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarListOrdered: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="redo"
|
|
10
|
+
onclick={() => editor.chain().focus().redo().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant="transparent" />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarRedo;
|
|
2
|
+
type ToolbarRedo = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarRedo: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="underline"
|
|
10
|
+
onclick={() => editor.chain().focus().toggleUnderline().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant={editor.isActive("underline") ? "filled" : "transparent"} />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarUnderline;
|
|
2
|
+
type ToolbarUnderline = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarUnderline: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { IconButton } from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
let { editor } = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if editor}
|
|
8
|
+
<IconButton
|
|
9
|
+
icon="undo"
|
|
10
|
+
onclick={() => editor.chain().focus().undo().run()}
|
|
11
|
+
shape="square"
|
|
12
|
+
variant="transparent" />
|
|
13
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ToolbarUndo;
|
|
2
|
+
type ToolbarUndo = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ToolbarUndo: import("svelte").Component<{
|
|
7
|
+
editor: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
editor: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { selectorCardVariants } from "./selectorCard.variants.js";
|
|
3
|
+
import { Switch, Radio, Label } from "../../../index.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {boolean} [checked=false] Wether this card is checked or not, bound to the component
|
|
8
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
9
|
+
* @property {boolean} [disabled=false] Whether the card is disabled
|
|
10
|
+
* @property {boolean} [error=false] Whether the form field has an error
|
|
11
|
+
* @property {string} [errorText=""] The error text for the form field
|
|
12
|
+
* @property {string} [helperText=""] The helper text for the card
|
|
13
|
+
* @property {string} [id=""] The ID of the card element
|
|
14
|
+
* @property {string} [label=""] Label to display in the card
|
|
15
|
+
* @property {string} [name] The name of the card, used for form submission
|
|
16
|
+
* @property {boolean} [required=false] Whether the card is required
|
|
17
|
+
* @property {"radio" | "switch"} [type="radio"] The type of card
|
|
18
|
+
* @property {string} [value=""] The value of the card
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @type {Props} */
|
|
22
|
+
let {
|
|
23
|
+
checked = $bindable(),
|
|
24
|
+
class: className = "",
|
|
25
|
+
disabled = false,
|
|
26
|
+
error = false,
|
|
27
|
+
errorText = "",
|
|
28
|
+
helperText = "",
|
|
29
|
+
id = "",
|
|
30
|
+
label = "",
|
|
31
|
+
name,
|
|
32
|
+
required = false,
|
|
33
|
+
type = "radio",
|
|
34
|
+
value = "",
|
|
35
|
+
...rest
|
|
36
|
+
} = $props();
|
|
37
|
+
|
|
38
|
+
let inputProps = $derived({ disabled, id, name, required, value });
|
|
39
|
+
let styles = $derived(selectorCardVariants({ checked, disabled, error, type }));
|
|
40
|
+
|
|
41
|
+
let localHelperText = $derived.by(() => {
|
|
42
|
+
if (error && errorText) {
|
|
43
|
+
return errorText;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return helperText;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let handleClick = () => {
|
|
50
|
+
if (disabled) return;
|
|
51
|
+
if (type === "radio" && checked) return;
|
|
52
|
+
|
|
53
|
+
checked = !checked;
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
aria-disabled={disabled}
|
|
59
|
+
class={styles.base({
|
|
60
|
+
class: className,
|
|
61
|
+
})}
|
|
62
|
+
onclick={handleClick}
|
|
63
|
+
{...rest}>
|
|
64
|
+
{#if type === "radio"}
|
|
65
|
+
<Radio bind:checked class={styles.input()} {...inputProps} />
|
|
66
|
+
{/if}
|
|
67
|
+
<div class={styles.content()}>
|
|
68
|
+
{#if label}
|
|
69
|
+
<Label class={styles.label()} {error} for={id} {required}>{label}</Label>
|
|
70
|
+
{/if}
|
|
71
|
+
{#if localHelperText}
|
|
72
|
+
<p class={styles.helperText()}>{localHelperText}</p>
|
|
73
|
+
{/if}
|
|
74
|
+
</div>
|
|
75
|
+
{#if type === "switch"}
|
|
76
|
+
<Switch bind:checked class={styles.input()} {...inputProps} />
|
|
77
|
+
{/if}
|
|
78
|
+
</div>
|