@foxui/text 0.4.0

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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -0
  3. package/dist/components/advanced-text-area/AdvancedTextArea.svelte +58 -0
  4. package/dist/components/advanced-text-area/AdvancedTextArea.svelte.d.ts +12 -0
  5. package/dist/components/advanced-text-area/index.d.ts +1 -0
  6. package/dist/components/advanced-text-area/index.js +1 -0
  7. package/dist/components/index.d.ts +3 -0
  8. package/dist/components/index.js +3 -0
  9. package/dist/components/plain-text-editor/PlainTextEditor.svelte +133 -0
  10. package/dist/components/plain-text-editor/PlainTextEditor.svelte.d.ts +14 -0
  11. package/dist/components/plain-text-editor/index.d.ts +1 -0
  12. package/dist/components/plain-text-editor/index.js +1 -0
  13. package/dist/components/rich-text-editor/Icon.svelte +120 -0
  14. package/dist/components/rich-text-editor/Icon.svelte.d.ts +7 -0
  15. package/dist/components/rich-text-editor/RichTextEditor.svelte +427 -0
  16. package/dist/components/rich-text-editor/RichTextEditor.svelte.d.ts +18 -0
  17. package/dist/components/rich-text-editor/RichTextEditorLinkMenu.svelte +95 -0
  18. package/dist/components/rich-text-editor/RichTextEditorLinkMenu.svelte.d.ts +10 -0
  19. package/dist/components/rich-text-editor/RichTextEditorMenu.svelte +184 -0
  20. package/dist/components/rich-text-editor/RichTextEditorMenu.svelte.d.ts +19 -0
  21. package/dist/components/rich-text-editor/RichTextLink.d.ts +13 -0
  22. package/dist/components/rich-text-editor/RichTextLink.js +105 -0
  23. package/dist/components/rich-text-editor/Select.svelte +72 -0
  24. package/dist/components/rich-text-editor/Select.svelte.d.ts +13 -0
  25. package/dist/components/rich-text-editor/code.css +142 -0
  26. package/dist/components/rich-text-editor/image-upload/ImageUploadComponent.svelte +47 -0
  27. package/dist/components/rich-text-editor/image-upload/ImageUploadComponent.svelte.d.ts +4 -0
  28. package/dist/components/rich-text-editor/image-upload/ImageUploadNode.d.ts +45 -0
  29. package/dist/components/rich-text-editor/image-upload/ImageUploadNode.js +56 -0
  30. package/dist/components/rich-text-editor/index.d.ts +2 -0
  31. package/dist/components/rich-text-editor/index.js +1 -0
  32. package/dist/components/rich-text-editor/slash-menu/SuggestionSelect.svelte +88 -0
  33. package/dist/components/rich-text-editor/slash-menu/SuggestionSelect.svelte.d.ts +22 -0
  34. package/dist/components/rich-text-editor/slash-menu/index.d.ts +32 -0
  35. package/dist/components/rich-text-editor/slash-menu/index.js +168 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/types.d.ts +1 -0
  39. package/package.json +93 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License Copyright (c) 2025 flo-bit
2
+
3
+ Permission is hereby granted, free of
4
+ charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use, copy, modify, merge,
7
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ (including the next paragraph) shall be included in all copies or substantial
13
+ portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
18
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # 🦊 fox ui
2
+
3
+ svelte 5 + tailwind 4 ui kit, text components
4
+
5
+ - [Plain Text Editor](https://flo-bit.dev/ui-kit/components/text/plain-text-editor)
6
+ - [Rich Text Editor](https://flo-bit.dev/ui-kit/components/text/rich-text-editor)
7
+
8
+ > **This is a public alpha release. Expect bugs and breaking changes.**
9
+
10
+ [See all components here](https://flo-bit.dev/ui-kit)
11
+
12
+ For a guide on how to use this ui kit, see the [Quickstart Guide](https://flo-bit.dev/ui-kit/docs/quick-start).
13
+
14
+ Read more about [the philosophy/aim of this project here](https://flo-bit.dev/ui-kit/docs/philosophy).
15
+
16
+ For more information about development, contributing and the like, see the main [README](https://github.com/flo-bit/ui-kit/blob/main/README.md).
@@ -0,0 +1,58 @@
1
+ <script lang="ts">
2
+ import { Button, ScrollArea } from '@foxui/core';
3
+ import type { Snippet } from 'svelte';
4
+
5
+ let {
6
+ value = $bindable(),
7
+ placeholder = 'Write something here...',
8
+ rows = 3,
9
+ additionalContent = null,
10
+ actionButtons = null,
11
+ submitButton = 'Post',
12
+ ...restProps
13
+ }: {
14
+ value?: string;
15
+ placeholder?: string;
16
+ rows?: number;
17
+ additionalContent?: Snippet | null;
18
+ actionButtons?: Snippet | null;
19
+ submitButton?: Snippet | string | null;
20
+ } = $props();
21
+ </script>
22
+
23
+ <div class="relative min-w-0 flex-1">
24
+ <div
25
+ class="outline-base-300 focus-within:outline-accent-600 dark:focus-within:outline-accent-500 dark:bg-base-900/50 rounded-2xl bg-white outline-1 -outline-offset-1 focus-within:outline-2 focus-within:-outline-offset-2 dark:outline-white/10"
26
+ >
27
+ <ScrollArea>
28
+ <textarea
29
+ {rows}
30
+ {placeholder}
31
+ bind:value
32
+ class="text-base-900 placeholder:text-base-500 dark:placeholder:text-base-400 block w-full resize-none border-none bg-transparent p-3 text-base outline-none focus:border-0 focus:outline-none focus:ring-0 sm:text-sm dark:text-white"
33
+ {...restProps}
34
+ ></textarea>
35
+ </ScrollArea>
36
+
37
+ {#if additionalContent}
38
+ {@render additionalContent()}
39
+ {/if}
40
+
41
+ <div class="h-[50px]"></div>
42
+ </div>
43
+
44
+ <div class="absolute inset-x-0 bottom-0 flex justify-between p-2">
45
+ <div class="flex items-center space-x-2">
46
+ {#if actionButtons}
47
+ {@render actionButtons()}
48
+ {/if}
49
+ </div>
50
+ <div class="shrink-0">
51
+ {#if typeof submitButton === 'string'}
52
+ <Button type="submit" class="rounded-xl">{submitButton}</Button>
53
+ {:else if submitButton}
54
+ {@render submitButton()}
55
+ {/if}
56
+ </div>
57
+ </div>
58
+ </div>
@@ -0,0 +1,12 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ value?: string;
4
+ placeholder?: string;
5
+ rows?: number;
6
+ additionalContent?: Snippet | null;
7
+ actionButtons?: Snippet | null;
8
+ submitButton?: Snippet | string | null;
9
+ };
10
+ declare const AdvancedTextArea: import("svelte").Component<$$ComponentProps, {}, "value">;
11
+ type AdvancedTextArea = ReturnType<typeof AdvancedTextArea>;
12
+ export default AdvancedTextArea;
@@ -0,0 +1 @@
1
+ export { default as AdvancedTextArea } from './AdvancedTextArea.svelte';
@@ -0,0 +1 @@
1
+ export { default as AdvancedTextArea } from './AdvancedTextArea.svelte';
@@ -0,0 +1,3 @@
1
+ export * from './plain-text-editor/';
2
+ export * from './rich-text-editor/';
3
+ export * from './advanced-text-area/';
@@ -0,0 +1,3 @@
1
+ export * from './plain-text-editor/';
2
+ export * from './rich-text-editor/';
3
+ export * from './advanced-text-area/';
@@ -0,0 +1,133 @@
1
+ <script lang="ts">
2
+ import { onDestroy, onMount } from 'svelte';
3
+ import { Editor, type Extensions, mergeAttributes, Node } from '@tiptap/core';
4
+ import Placeholder from '@tiptap/extension-placeholder';
5
+ import { type ParagraphOptions } from '@tiptap/extension-paragraph';
6
+ import Text from '@tiptap/extension-text';
7
+ import History from '@tiptap/extension-history';
8
+ import { cn } from '@foxui/core';
9
+
10
+ let {
11
+ class: className,
12
+ placeholder = '',
13
+ value = $bindable(''),
14
+ ref = $bindable(null),
15
+ editor = $bindable(null),
16
+ allowMultiline = false,
17
+ onupdate,
18
+ ontransaction,
19
+ ...props
20
+ }: {
21
+ class?: string;
22
+ placeholder?: string;
23
+ value?: string;
24
+ ref?: HTMLElement | null;
25
+ editor?: Editor | null;
26
+ allowMultiline?: boolean;
27
+ onupdate?: (value: string) => void;
28
+ ontransaction?: () => void;
29
+ } = $props();
30
+
31
+ onMount(async () => {
32
+ if (!ref || editor) return;
33
+
34
+ const Document = Node.create({
35
+ name: 'doc',
36
+ topNode: true,
37
+ content: allowMultiline ? 'block+' : 'block'
38
+ });
39
+
40
+ const Paragraph = Node.create<ParagraphOptions>({
41
+ name: 'paragraph',
42
+
43
+ priority: 1000,
44
+
45
+ addOptions() {
46
+ return {
47
+ HTMLAttributes: {}
48
+ };
49
+ },
50
+
51
+ group: 'block',
52
+
53
+ content: 'text*',
54
+
55
+ parseHTML() {
56
+ return [{ tag: 'p' }];
57
+ },
58
+
59
+ renderHTML({ HTMLAttributes }) {
60
+ return ['p', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
61
+ },
62
+
63
+ addCommands() {
64
+ return {
65
+ setParagraph:
66
+ () =>
67
+ ({ commands }) => {
68
+ return commands.setNode(this.name);
69
+ }
70
+ };
71
+ },
72
+
73
+ addKeyboardShortcuts() {
74
+ return {
75
+ 'Mod-Alt-0': () => this.editor.commands.setParagraph()
76
+ };
77
+ }
78
+ });
79
+
80
+ let extensions: Extensions = [Document.configure(), Paragraph.configure(), Text.configure(), History.configure()];
81
+
82
+ if (placeholder) {
83
+ extensions.push(
84
+ Placeholder.configure({
85
+ placeholder: placeholder
86
+ })
87
+ );
88
+ }
89
+
90
+ editor = new Editor({
91
+ element: ref,
92
+ extensions: extensions,
93
+ onUpdate: () => {
94
+ onupdate?.(editor?.getText() ?? '');
95
+
96
+ value = editor?.getText() ?? '';
97
+ },
98
+ onTransaction: () => {
99
+ ontransaction?.();
100
+ },
101
+
102
+ content: value,
103
+
104
+ editorProps: {
105
+ attributes: {
106
+ class: 'outline-none pointer-events-auto'
107
+ }
108
+ }
109
+ });
110
+ });
111
+
112
+ $effect(() => {
113
+ if (!editor || editor.getText() === value) return;
114
+
115
+ editor.commands.setContent(value);
116
+ });
117
+
118
+ onDestroy(() => {
119
+ editor?.destroy();
120
+ });
121
+ </script>
122
+
123
+ <div class={cn('min-h-[1em]', className)} bind:this={ref} {...props}></div>
124
+
125
+ <style>
126
+ :global(.tiptap p.is-editor-empty:first-child::before) {
127
+ color: var(--color-base-500);
128
+ content: attr(data-placeholder);
129
+ float: left;
130
+ height: 0;
131
+ pointer-events: none;
132
+ }
133
+ </style>
@@ -0,0 +1,14 @@
1
+ import { Editor } from '@tiptap/core';
2
+ type $$ComponentProps = {
3
+ class?: string;
4
+ placeholder?: string;
5
+ value?: string;
6
+ ref?: HTMLElement | null;
7
+ editor?: Editor | null;
8
+ allowMultiline?: boolean;
9
+ onupdate?: (value: string) => void;
10
+ ontransaction?: () => void;
11
+ };
12
+ declare const PlainTextEditor: import("svelte").Component<$$ComponentProps, {}, "value" | "ref" | "editor">;
13
+ type PlainTextEditor = ReturnType<typeof PlainTextEditor>;
14
+ export default PlainTextEditor;
@@ -0,0 +1 @@
1
+ export { default as PlainTextEditor } from './PlainTextEditor.svelte';
@@ -0,0 +1 @@
1
+ export { default as PlainTextEditor } from './PlainTextEditor.svelte';
@@ -0,0 +1,120 @@
1
+ <script lang="ts">
2
+ import type { RichTextTypes } from '.';
3
+
4
+ let {
5
+ name
6
+ }: {
7
+ name: RichTextTypes;
8
+ } = $props();
9
+ </script>
10
+
11
+ {#if name === 'paragraph'}
12
+ <svg
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ viewBox="0 0 24 24"
15
+ fill="none"
16
+ stroke="currentColor"
17
+ stroke-width="2"
18
+ stroke-linecap="round"
19
+ stroke-linejoin="round"
20
+ ><path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" /></svg
21
+ >
22
+ {:else if name === 'heading-1'}
23
+ <svg
24
+ xmlns="http://www.w3.org/2000/svg"
25
+ viewBox="0 0 24 24"
26
+ fill="none"
27
+ stroke="currentColor"
28
+ stroke-width="2"
29
+ stroke-linecap="round"
30
+ stroke-linejoin="round"
31
+ ><path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" /></svg
32
+ >
33
+ {:else if name === 'heading-2'}
34
+ <svg
35
+ xmlns="http://www.w3.org/2000/svg"
36
+ viewBox="0 0 24 24"
37
+ fill="none"
38
+ stroke="currentColor"
39
+ stroke-width="2"
40
+ stroke-linecap="round"
41
+ stroke-linejoin="round"
42
+ ><path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path
43
+ d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"
44
+ /></svg
45
+ >
46
+ {:else if name === 'heading-3'}
47
+ <svg
48
+ xmlns="http://www.w3.org/2000/svg"
49
+ viewBox="0 0 24 24"
50
+ fill="none"
51
+ stroke="currentColor"
52
+ stroke-width="2"
53
+ stroke-linecap="round"
54
+ stroke-linejoin="round"
55
+ ><path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path
56
+ d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"
57
+ /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" /></svg
58
+ >
59
+ {:else if name === 'blockquote'}
60
+ <svg
61
+ xmlns="http://www.w3.org/2000/svg"
62
+ viewBox="0 0 24 24"
63
+ fill="none"
64
+ stroke="currentColor"
65
+ stroke-width="2"
66
+ stroke-linecap="round"
67
+ stroke-linejoin="round"
68
+ ><path d="M17 6H3" /><path d="M21 12H8" /><path d="M21 18H8" /><path d="M3 12v6" /></svg
69
+ >
70
+ {:else if name === 'code'}
71
+ <svg
72
+ xmlns="http://www.w3.org/2000/svg"
73
+ viewBox="0 0 24 24"
74
+ fill="none"
75
+ stroke="currentColor"
76
+ stroke-width="2"
77
+ stroke-linecap="round"
78
+ stroke-linejoin="round"
79
+ ><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg
80
+ >
81
+ {:else if name === 'bullet-list'}
82
+ <svg
83
+ xmlns="http://www.w3.org/2000/svg"
84
+ viewBox="0 0 24 24"
85
+ fill="none"
86
+ stroke="currentColor"
87
+ stroke-width="2"
88
+ stroke-linecap="round"
89
+ stroke-linejoin="round"
90
+ ><path d="M3 12h.01" /><path d="M3 18h.01" /><path d="M3 6h.01" /><path d="M8 12h13" /><path
91
+ d="M8 18h13"
92
+ /><path d="M8 6h13" /></svg
93
+ >
94
+ {:else if name === 'ordered-list'}
95
+ <svg
96
+ xmlns="http://www.w3.org/2000/svg"
97
+ viewBox="0 0 24 24"
98
+ fill="none"
99
+ stroke="currentColor"
100
+ stroke-width="2"
101
+ stroke-linecap="round"
102
+ stroke-linejoin="round"
103
+ ><path d="M10 12h11" /><path d="M10 18h11" /><path d="M10 6h11" /><path d="M4 10h2" /><path
104
+ d="M4 6h1v4"
105
+ /><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" /></svg
106
+ >
107
+ {:else if name === 'image'}
108
+ <svg
109
+ xmlns="http://www.w3.org/2000/svg"
110
+ viewBox="0 0 24 24"
111
+ fill="none"
112
+ stroke="currentColor"
113
+ stroke-width="2"
114
+ stroke-linecap="round"
115
+ stroke-linejoin="round"
116
+ ><rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path
117
+ d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"
118
+ /></svg
119
+ >
120
+ {/if}
@@ -0,0 +1,7 @@
1
+ import type { RichTextTypes } from '.';
2
+ type $$ComponentProps = {
3
+ name: RichTextTypes;
4
+ };
5
+ declare const Icon: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type Icon = ReturnType<typeof Icon>;
7
+ export default Icon;