@websline/system-components 1.3.4 → 1.3.5
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/checkbox/Checkbox.svelte +1 -1
- package/dist/components/atoms/chip/Chip.svelte +4 -3
- package/dist/components/atoms/chip/chip.variants.d.ts +15 -15
- package/dist/components/atoms/chip/chip.variants.js +48 -29
- package/dist/components/atoms/radio/Radio.svelte +1 -1
- package/dist/components/atoms/switch/Switch.svelte +1 -1
- package/dist/components/atoms/tag/Tag.svelte +47 -0
- package/dist/components/atoms/tag/Tag.svelte.d.ts +73 -0
- package/dist/components/atoms/tag/tag.variants.d.ts +58 -0
- package/dist/components/atoms/tag/tag.variants.js +32 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +50 -63
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte.d.ts +15 -135
- package/dist/components/molecules/richTextEditor/toolbar/RichTextEditorToolbar.svelte +10 -11
- package/dist/components/molecules/richTextEditor/toolbar/RichTextEditorToolbar.svelte.d.ts +0 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte +9 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte.d.ts +2 -7
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte +7 -4
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte.d.ts +0 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte +9 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte.d.ts +2 -7
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte +11 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte.d.ts +0 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte +9 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte.d.ts +2 -7
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte +9 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte.d.ts +2 -7
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte +2 -1
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte.d.ts +2 -7
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte +9 -2
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte.d.ts +2 -7
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte +2 -1
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte.d.ts +2 -7
- package/dist/components/molecules/selectorCard/SelectorCard.svelte +1 -1
- package/dist/components/molecules/tagSelector/ValueList.svelte +5 -9
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte +21 -3
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte.d.ts +16 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +5 -3
- package/dist/components/molecules/toggleGroup/toggleGroup.variants.d.ts +32 -13
- package/dist/components/molecules/toggleGroup/toggleGroup.variants.js +12 -0
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.d.ts +9 -0
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.js +8 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
<svelte:element
|
|
36
36
|
this={as}
|
|
37
37
|
class={chipVariants({
|
|
38
|
+
class: className,
|
|
39
|
+
clickable,
|
|
38
40
|
color,
|
|
39
|
-
size,
|
|
40
41
|
iconPosition,
|
|
41
|
-
variant,
|
|
42
42
|
selected: clickable && selected,
|
|
43
|
-
|
|
43
|
+
size,
|
|
44
|
+
variant,
|
|
44
45
|
})}
|
|
45
46
|
type={clickable ? "button" : undefined}
|
|
46
47
|
{...rest}>
|
|
@@ -6,17 +6,17 @@ export const chipVariants: import("tailwind-variants").TVReturnType<{
|
|
|
6
6
|
success: string;
|
|
7
7
|
warning: string;
|
|
8
8
|
};
|
|
9
|
-
size: {
|
|
10
|
-
small: string;
|
|
11
|
-
big: string;
|
|
12
|
-
};
|
|
13
9
|
iconPosition: {
|
|
14
10
|
end: string;
|
|
15
11
|
};
|
|
12
|
+
size: {
|
|
13
|
+
big: string;
|
|
14
|
+
small: string;
|
|
15
|
+
};
|
|
16
16
|
variant: {
|
|
17
|
+
dashed: string;
|
|
17
18
|
filled: string;
|
|
18
19
|
outline: string;
|
|
19
|
-
dashed: string;
|
|
20
20
|
};
|
|
21
21
|
}, undefined, string[], {
|
|
22
22
|
color: {
|
|
@@ -26,17 +26,17 @@ export const chipVariants: import("tailwind-variants").TVReturnType<{
|
|
|
26
26
|
success: string;
|
|
27
27
|
warning: string;
|
|
28
28
|
};
|
|
29
|
-
size: {
|
|
30
|
-
small: string;
|
|
31
|
-
big: string;
|
|
32
|
-
};
|
|
33
29
|
iconPosition: {
|
|
34
30
|
end: string;
|
|
35
31
|
};
|
|
32
|
+
size: {
|
|
33
|
+
big: string;
|
|
34
|
+
small: string;
|
|
35
|
+
};
|
|
36
36
|
variant: {
|
|
37
|
+
dashed: string;
|
|
37
38
|
filled: string;
|
|
38
39
|
outline: string;
|
|
39
|
-
dashed: string;
|
|
40
40
|
};
|
|
41
41
|
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
42
42
|
color: {
|
|
@@ -46,16 +46,16 @@ export const chipVariants: import("tailwind-variants").TVReturnType<{
|
|
|
46
46
|
success: string;
|
|
47
47
|
warning: string;
|
|
48
48
|
};
|
|
49
|
-
size: {
|
|
50
|
-
small: string;
|
|
51
|
-
big: string;
|
|
52
|
-
};
|
|
53
49
|
iconPosition: {
|
|
54
50
|
end: string;
|
|
55
51
|
};
|
|
52
|
+
size: {
|
|
53
|
+
big: string;
|
|
54
|
+
small: string;
|
|
55
|
+
};
|
|
56
56
|
variant: {
|
|
57
|
+
dashed: string;
|
|
57
58
|
filled: string;
|
|
58
59
|
outline: string;
|
|
59
|
-
dashed: string;
|
|
60
60
|
};
|
|
61
61
|
}, undefined, string[], unknown, unknown, undefined>>;
|
|
@@ -8,109 +8,128 @@ const chipVariants = tv({
|
|
|
8
8
|
variants: {
|
|
9
9
|
color: {
|
|
10
10
|
default:
|
|
11
|
-
"bg-neutral-
|
|
11
|
+
"bg-neutral-100 text-neutral-900 dark:bg-neutral-700 dark:text-neutral-200",
|
|
12
12
|
primary: "bg-blue-500 text-neutral-100 dark:bg-blue-400",
|
|
13
13
|
error: "bg-red-500 text-neutral-100",
|
|
14
14
|
success: "bg-green-500 text-neutral-100",
|
|
15
15
|
warning: "bg-yellow-500 text-neutral-900",
|
|
16
16
|
},
|
|
17
|
-
size: {
|
|
18
|
-
small: "min-h-[20px] px-2 py-0.5 ui-tag-badge",
|
|
19
|
-
big: "min-h-[28px] px-3 py-1.5 body-small",
|
|
20
|
-
},
|
|
21
17
|
iconPosition: {
|
|
22
18
|
end: "flex-row-reverse",
|
|
23
19
|
},
|
|
20
|
+
size: {
|
|
21
|
+
big: "min-h-[28px] px-3 py-1.5 body-small",
|
|
22
|
+
small: "min-h-[20px] px-2 py-0.5 ui-tag-badge",
|
|
23
|
+
},
|
|
24
24
|
variant: {
|
|
25
|
+
dashed: "border-dashed",
|
|
25
26
|
filled: "border-transparent",
|
|
26
|
-
outline: "
|
|
27
|
-
dashed: "border-dashed bg-transparent dark:bg-transparent",
|
|
27
|
+
outline: "",
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
compoundVariants: [
|
|
31
31
|
// Outline || Dashed
|
|
32
|
+
{
|
|
33
|
+
selected: false,
|
|
34
|
+
variant: ["dashed", "outline"],
|
|
35
|
+
class: "bg-transparent dark:bg-transparent",
|
|
36
|
+
},
|
|
32
37
|
{
|
|
33
38
|
color: "default",
|
|
39
|
+
selected: false,
|
|
34
40
|
variant: ["outline", "dashed"],
|
|
35
41
|
class: "border-gray-300 dark:border-gray-700",
|
|
36
42
|
},
|
|
37
43
|
{
|
|
38
44
|
color: "primary",
|
|
45
|
+
selected: false,
|
|
39
46
|
variant: ["outline", "dashed"],
|
|
40
47
|
class:
|
|
41
48
|
"border-blue-500 text-blue-500 dark:border-blue-400 dark:text-neutral-100",
|
|
42
49
|
},
|
|
43
50
|
{
|
|
44
51
|
color: "error",
|
|
52
|
+
selected: false,
|
|
45
53
|
variant: ["outline", "dashed"],
|
|
46
54
|
class: "text-red-500",
|
|
47
55
|
},
|
|
48
56
|
{
|
|
49
57
|
color: "success",
|
|
58
|
+
selected: false,
|
|
50
59
|
variant: ["outline", "dashed"],
|
|
51
60
|
class: "text-green-500",
|
|
52
61
|
},
|
|
53
62
|
{
|
|
54
63
|
color: "warning",
|
|
64
|
+
selected: false,
|
|
55
65
|
variant: ["outline", "dashed"],
|
|
56
66
|
class: "border-yellow-500 text-neutral-900 dark:text-yellow-600",
|
|
57
67
|
},
|
|
58
|
-
|
|
68
|
+
|
|
69
|
+
// Clickable (hover state = selected state, except for default)
|
|
59
70
|
{
|
|
60
|
-
|
|
71
|
+
clickable: true,
|
|
61
72
|
color: "default",
|
|
62
|
-
class: "bg-neutral-
|
|
73
|
+
class: "hover:bg-neutral-200 hover:dark:bg-neutral-900",
|
|
63
74
|
},
|
|
64
75
|
{
|
|
65
|
-
|
|
76
|
+
clickable: true,
|
|
66
77
|
color: "primary",
|
|
67
|
-
class: "bg-blue-600 dark:bg-blue-500",
|
|
78
|
+
class: "hover:bg-blue-600 hover:text-neutral-100 hover:dark:bg-blue-500",
|
|
68
79
|
},
|
|
69
80
|
{
|
|
70
|
-
|
|
81
|
+
clickable: true,
|
|
71
82
|
color: "error",
|
|
72
|
-
class: "bg-red-700",
|
|
83
|
+
class: "hover:bg-red-700 hover:text-neutral-100",
|
|
73
84
|
},
|
|
74
85
|
{
|
|
75
|
-
|
|
86
|
+
clickable: true,
|
|
76
87
|
color: "success",
|
|
77
|
-
class: "bg-green-700",
|
|
88
|
+
class: "hover:bg-green-700 hover:text-neutral-100",
|
|
78
89
|
},
|
|
79
90
|
{
|
|
80
|
-
|
|
91
|
+
clickable: true,
|
|
81
92
|
color: "warning",
|
|
82
|
-
class: "bg-yellow-600",
|
|
93
|
+
class: "hover:bg-yellow-600 hover:text-neutral-900",
|
|
83
94
|
},
|
|
84
|
-
//
|
|
95
|
+
// Clickable & Outline || Dashed
|
|
96
|
+
{
|
|
97
|
+
clickable: true,
|
|
98
|
+
variant: ["dashed", "outline"],
|
|
99
|
+
class: "hover:border-transparent hover:dark:border-transparent",
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Selected
|
|
85
103
|
{
|
|
86
104
|
selected: true,
|
|
87
|
-
variant: ["outline", "dashed"],
|
|
88
105
|
color: "default",
|
|
89
|
-
class: "
|
|
106
|
+
class: "bg-neutral-900 text-neutral-100 dark:bg-blue-400",
|
|
90
107
|
},
|
|
91
108
|
{
|
|
92
109
|
selected: true,
|
|
93
|
-
variant: ["outline", "dashed"],
|
|
94
110
|
color: "primary",
|
|
95
|
-
class: "
|
|
111
|
+
class: "bg-blue-600 dark:bg-blue-500",
|
|
96
112
|
},
|
|
97
113
|
{
|
|
98
114
|
selected: true,
|
|
99
|
-
variant: ["outline", "dashed"],
|
|
100
115
|
color: "error",
|
|
101
|
-
class: "
|
|
116
|
+
class: "bg-red-700",
|
|
102
117
|
},
|
|
103
118
|
{
|
|
104
119
|
selected: true,
|
|
105
|
-
variant: ["outline", "dashed"],
|
|
106
120
|
color: "success",
|
|
107
|
-
class: "
|
|
121
|
+
class: "bg-green-700",
|
|
108
122
|
},
|
|
109
123
|
{
|
|
110
124
|
selected: true,
|
|
111
|
-
variant: ["outline", "dashed"],
|
|
112
125
|
color: "warning",
|
|
113
|
-
class: "
|
|
126
|
+
class: "bg-yellow-600",
|
|
127
|
+
},
|
|
128
|
+
// Selected & Outline || Dashed
|
|
129
|
+
{
|
|
130
|
+
selected: true,
|
|
131
|
+
variant: ["dashed", "outline"],
|
|
132
|
+
class: "border-transparent dark:border-transparent",
|
|
114
133
|
},
|
|
115
134
|
],
|
|
116
135
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Icon } from "../../../index.js";
|
|
3
|
+
import { tagVariants } from "./tag.variants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {import('svelte').Snippet} [children] Content inside the tag – can be text, HTML, or Svelte components
|
|
8
|
+
* @property {string} [class=""] Additional CSS classes for the tag
|
|
9
|
+
* @property {string} [icon=""] Name of the icon to display
|
|
10
|
+
* @property {"start" | "end"} [iconPosition="start"] Position of the icon relative to the content
|
|
11
|
+
* @property {boolean} [selected=false] Whether the tag is in a visually selected state
|
|
12
|
+
* @property {"round" | "round-big"} [shape="round"] Shape of the tag
|
|
13
|
+
* @property {"small" | "big"} [size="small"] Size of the tag
|
|
14
|
+
* @property {"filled" | "outline"} [variant="filled"] Visual style of the tag
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @type {Props} */
|
|
18
|
+
let {
|
|
19
|
+
children,
|
|
20
|
+
class: className,
|
|
21
|
+
icon = "",
|
|
22
|
+
iconPosition = "start",
|
|
23
|
+
selected = false,
|
|
24
|
+
shape = "round",
|
|
25
|
+
size = "small",
|
|
26
|
+
variant = "filled",
|
|
27
|
+
...rest
|
|
28
|
+
} = $props();
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<button
|
|
32
|
+
class={tagVariants({
|
|
33
|
+
class: className,
|
|
34
|
+
iconPosition,
|
|
35
|
+
selected,
|
|
36
|
+
shape,
|
|
37
|
+
size,
|
|
38
|
+
variant,
|
|
39
|
+
})}
|
|
40
|
+
{...rest}>
|
|
41
|
+
{#if icon}
|
|
42
|
+
<Icon name={icon} size={14} />
|
|
43
|
+
{/if}
|
|
44
|
+
<span>
|
|
45
|
+
{@render children?.()}
|
|
46
|
+
</span>
|
|
47
|
+
</button>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default Tag;
|
|
2
|
+
type Tag = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Tag: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Content inside the tag – can be text, HTML, or Svelte components
|
|
9
|
+
*/
|
|
10
|
+
children?: import("svelte").Snippet;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes for the tag
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Name of the icon to display
|
|
17
|
+
*/
|
|
18
|
+
icon?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Position of the icon relative to the content
|
|
21
|
+
*/
|
|
22
|
+
iconPosition?: "start" | "end";
|
|
23
|
+
/**
|
|
24
|
+
* Whether the tag is in a visually selected state
|
|
25
|
+
*/
|
|
26
|
+
selected?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Shape of the tag
|
|
29
|
+
*/
|
|
30
|
+
shape?: "round" | "round-big";
|
|
31
|
+
/**
|
|
32
|
+
* Size of the tag
|
|
33
|
+
*/
|
|
34
|
+
size?: "small" | "big";
|
|
35
|
+
/**
|
|
36
|
+
* Visual style of the tag
|
|
37
|
+
*/
|
|
38
|
+
variant?: "filled" | "outline";
|
|
39
|
+
}, {}, "">;
|
|
40
|
+
type Props = {
|
|
41
|
+
/**
|
|
42
|
+
* Content inside the tag – can be text, HTML, or Svelte components
|
|
43
|
+
*/
|
|
44
|
+
children?: import("svelte").Snippet;
|
|
45
|
+
/**
|
|
46
|
+
* Additional CSS classes for the tag
|
|
47
|
+
*/
|
|
48
|
+
class?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Name of the icon to display
|
|
51
|
+
*/
|
|
52
|
+
icon?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Position of the icon relative to the content
|
|
55
|
+
*/
|
|
56
|
+
iconPosition?: "start" | "end";
|
|
57
|
+
/**
|
|
58
|
+
* Whether the tag is in a visually selected state
|
|
59
|
+
*/
|
|
60
|
+
selected?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Shape of the tag
|
|
63
|
+
*/
|
|
64
|
+
shape?: "round" | "round-big";
|
|
65
|
+
/**
|
|
66
|
+
* Size of the tag
|
|
67
|
+
*/
|
|
68
|
+
size?: "small" | "big";
|
|
69
|
+
/**
|
|
70
|
+
* Visual style of the tag
|
|
71
|
+
*/
|
|
72
|
+
variant?: "filled" | "outline";
|
|
73
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const tagVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
iconPosition: {
|
|
3
|
+
end: string;
|
|
4
|
+
};
|
|
5
|
+
selected: {
|
|
6
|
+
true: string;
|
|
7
|
+
};
|
|
8
|
+
shape: {
|
|
9
|
+
round: string;
|
|
10
|
+
"round-big": string;
|
|
11
|
+
};
|
|
12
|
+
size: {
|
|
13
|
+
big: string;
|
|
14
|
+
small: string;
|
|
15
|
+
};
|
|
16
|
+
variant: {
|
|
17
|
+
filled: string;
|
|
18
|
+
outline: string;
|
|
19
|
+
};
|
|
20
|
+
}, undefined, string[], {
|
|
21
|
+
iconPosition: {
|
|
22
|
+
end: string;
|
|
23
|
+
};
|
|
24
|
+
selected: {
|
|
25
|
+
true: string;
|
|
26
|
+
};
|
|
27
|
+
shape: {
|
|
28
|
+
round: string;
|
|
29
|
+
"round-big": string;
|
|
30
|
+
};
|
|
31
|
+
size: {
|
|
32
|
+
big: string;
|
|
33
|
+
small: string;
|
|
34
|
+
};
|
|
35
|
+
variant: {
|
|
36
|
+
filled: string;
|
|
37
|
+
outline: string;
|
|
38
|
+
};
|
|
39
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
40
|
+
iconPosition: {
|
|
41
|
+
end: string;
|
|
42
|
+
};
|
|
43
|
+
selected: {
|
|
44
|
+
true: string;
|
|
45
|
+
};
|
|
46
|
+
shape: {
|
|
47
|
+
round: string;
|
|
48
|
+
"round-big": string;
|
|
49
|
+
};
|
|
50
|
+
size: {
|
|
51
|
+
big: string;
|
|
52
|
+
small: string;
|
|
53
|
+
};
|
|
54
|
+
variant: {
|
|
55
|
+
filled: string;
|
|
56
|
+
outline: string;
|
|
57
|
+
};
|
|
58
|
+
}, undefined, string[], unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { tv } from "../../../utils/tailwind.js";
|
|
2
|
+
|
|
3
|
+
const tagVariants = tv({
|
|
4
|
+
base: [
|
|
5
|
+
"relative inline-flex cursor-pointer items-center gap-1 align-middle ui-tag-badge select-none",
|
|
6
|
+
"ring-blue-500 ring-offset-1 ring-offset-transparent outline-0 focus-visible:ring-1 dark:ring-blue-400",
|
|
7
|
+
"text-neutral-900 hover:bg-neutral-200 dark:text-neutral-200 hover:dark:bg-neutral-700",
|
|
8
|
+
"border border-neutral-100 hover:border-neutral-200 dark:border-neutral-700 hover:dark:border-neutral-700",
|
|
9
|
+
],
|
|
10
|
+
variants: {
|
|
11
|
+
iconPosition: {
|
|
12
|
+
end: "flex-row-reverse",
|
|
13
|
+
},
|
|
14
|
+
selected: {
|
|
15
|
+
true: "border-neutral-900 bg-neutral-900 text-neutral-100 dark:border-blue-400 dark:bg-blue-400",
|
|
16
|
+
},
|
|
17
|
+
shape: {
|
|
18
|
+
round: "rounded-sm",
|
|
19
|
+
"round-big": "rounded-lg",
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
big: "min-h-8 px-3",
|
|
23
|
+
small: "min-h-6 px-2",
|
|
24
|
+
},
|
|
25
|
+
variant: {
|
|
26
|
+
filled: "bg-neutral-100 dark:bg-neutral-700",
|
|
27
|
+
outline: "bg-transparent",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export { tagVariants };
|
|
@@ -1,61 +1,53 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { onMount,
|
|
2
|
+
import { onMount, setContext } from "svelte";
|
|
3
3
|
import RichTextEditorToolbar from "./toolbar/RichTextEditorToolbar.svelte";
|
|
4
4
|
import { richTextEditorVariants } from "./richTextEditor.variants.js";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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",
|
|
6
|
+
let {
|
|
7
|
+
classes = {},
|
|
8
|
+
content = "",
|
|
9
|
+
fieldName = "",
|
|
10
|
+
hideToolbar = false,
|
|
11
|
+
placeholder = "",
|
|
12
|
+
size = "medium",
|
|
13
|
+
toolbarConfig = {
|
|
14
|
+
bold: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
},
|
|
17
|
+
history: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
},
|
|
20
|
+
italic: {
|
|
21
|
+
enabled: true,
|
|
22
|
+
},
|
|
23
|
+
link: {
|
|
24
|
+
enabled: true,
|
|
25
|
+
},
|
|
26
|
+
list: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
},
|
|
29
|
+
listOrdered: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
},
|
|
32
|
+
underline: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
},
|
|
35
|
+
color: {
|
|
36
|
+
enabled: true,
|
|
37
|
+
colors: ["#121110", "#0000ff"],
|
|
38
|
+
defaultColor: "#121110",
|
|
39
|
+
},
|
|
53
40
|
},
|
|
54
|
-
|
|
41
|
+
...rest
|
|
42
|
+
} = $props();
|
|
55
43
|
|
|
56
|
-
let element;
|
|
57
|
-
let
|
|
58
|
-
let
|
|
44
|
+
let element = $state();
|
|
45
|
+
let htmlInputValue = $state();
|
|
46
|
+
let editor = $state.raw();
|
|
47
|
+
|
|
48
|
+
let styles = $derived(richTextEditorVariants({ hideToolbar, size }));
|
|
49
|
+
|
|
50
|
+
setContext("richt-text-editor", () => editor);
|
|
59
51
|
|
|
60
52
|
const initEditor = async () => {
|
|
61
53
|
const { Editor } = await import("@tiptap/core");
|
|
@@ -111,8 +103,7 @@
|
|
|
111
103
|
},
|
|
112
104
|
},
|
|
113
105
|
content,
|
|
114
|
-
|
|
115
|
-
editor = editor;
|
|
106
|
+
onUpdate: () => {
|
|
116
107
|
htmlInputValue = editor.getHTML();
|
|
117
108
|
},
|
|
118
109
|
});
|
|
@@ -122,12 +113,10 @@
|
|
|
122
113
|
|
|
123
114
|
onMount(() => {
|
|
124
115
|
initEditor();
|
|
125
|
-
});
|
|
126
116
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
117
|
+
return () => {
|
|
118
|
+
editor?.destroy();
|
|
119
|
+
};
|
|
131
120
|
});
|
|
132
121
|
|
|
133
122
|
const cleanHTMLWhitespace = (html) => {
|
|
@@ -152,14 +141,12 @@
|
|
|
152
141
|
|
|
153
142
|
return dom.innerHTML.trim();
|
|
154
143
|
};
|
|
155
|
-
|
|
156
|
-
let styles = richTextEditorVariants({ hideToolbar, size });
|
|
157
144
|
</script>
|
|
158
145
|
|
|
159
|
-
<div class={styles.base({ class: classes.base })}>
|
|
146
|
+
<div class={styles.base({ class: classes.base })} {...rest}>
|
|
160
147
|
{#if !hideToolbar}
|
|
161
148
|
<div class={styles.toolbar({ class: classes.toolbar })}>
|
|
162
|
-
<RichTextEditorToolbar {
|
|
149
|
+
<RichTextEditorToolbar {toolbarConfig} />
|
|
163
150
|
</div>
|
|
164
151
|
{/if}
|
|
165
152
|
{#if fieldName}
|