@sierra-95/svelte-scaffold 1.1.4 → 1.1.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.
|
@@ -81,18 +81,37 @@
|
|
|
81
81
|
return false;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
$: showDropdown = $editorStore.insertImageMode?.length > 1;
|
|
86
|
+
//$: console.log("showDropdown", showDropdown);
|
|
87
|
+
|
|
88
|
+
function handleSingleMode() {
|
|
89
|
+
if ($editorStore.insertImageMode?.includes('filepicker')) {
|
|
90
|
+
handleInsertImage();
|
|
91
|
+
} else if ($editorStore.insertImageMode?.includes('url')) {
|
|
92
|
+
enterURL();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
84
95
|
</script>
|
|
96
|
+
|
|
85
97
|
{#snippet formContent()}
|
|
86
98
|
<div style="margin: 1rem 0rem;">
|
|
87
99
|
<Input label="Enter Image URL" id="image-url" underline bind:value={value}/>
|
|
88
100
|
</div>
|
|
89
101
|
{/snippet}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</
|
|
102
|
+
|
|
103
|
+
{#if showDropdown}
|
|
104
|
+
<DropdownContainer bind:open={openDropdown} width="150px">
|
|
105
|
+
{#snippet dropdownTrigger()}
|
|
106
|
+
<button type="button" aria-label="Insert Image" title="Insert File" on:click={() => openDropdown = !openDropdown}>
|
|
107
|
+
<i class="fa fa-file"></i>
|
|
108
|
+
</button>
|
|
109
|
+
{/snippet}
|
|
110
|
+
<MenuItem onclick={() => { handleInsertImage(); openDropdown = false; }}>File Picker</MenuItem>
|
|
111
|
+
<MenuItem onclick={() => { enterURL(); openDropdown = false; }}>Enter URL</MenuItem>
|
|
112
|
+
</DropdownContainer>
|
|
113
|
+
{:else}
|
|
114
|
+
<button type="button" aria-label="Insert Image" title="Insert File" on:click={() => handleSingleMode()}>
|
|
115
|
+
<i class="fa fa-file"></i>
|
|
116
|
+
</button>
|
|
117
|
+
{/if}
|
|
@@ -3,26 +3,39 @@
|
|
|
3
3
|
TextFormatting, Headings, TextColor, TextAlign, Images, History, Youtube,
|
|
4
4
|
Export, Lists, Links
|
|
5
5
|
} from './tools.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import './styles/controls.css';
|
|
8
|
-
import {Tabs} from '../../index.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
import {Tabs, editorStore} from '../../index.js';
|
|
9
|
+
|
|
10
|
+
const {editor} = $props();
|
|
11
|
+
|
|
12
|
+
let HomeItems: any[] = $state([]);
|
|
13
|
+
let InsertItems: any[] = $state([]);
|
|
14
|
+
|
|
15
|
+
const HOME_TOOLS = [
|
|
16
|
+
{ feature: 'text-formatting', component: TextFormatting },
|
|
17
|
+
{ feature: 'history', component: History },
|
|
18
|
+
{ feature: 'headings', component: Headings },
|
|
19
|
+
{ feature: 'text-color', component: TextColor },
|
|
20
|
+
{ feature: 'text-align', component: TextAlign },
|
|
21
|
+
{ feature: 'lists', component: Lists },
|
|
19
22
|
] as const;
|
|
20
23
|
|
|
21
|
-
const
|
|
22
|
-
Images,
|
|
23
|
-
Links,
|
|
24
|
-
Youtube
|
|
24
|
+
const INSERT_TOOLS = [
|
|
25
|
+
{ feature: 'images', component: Images },
|
|
26
|
+
{ feature: 'links', component: Links },
|
|
27
|
+
{ feature: 'youtube', component: Youtube }
|
|
25
28
|
] as const;
|
|
29
|
+
|
|
30
|
+
$effect(() => {
|
|
31
|
+
HomeItems = HOME_TOOLS
|
|
32
|
+
.filter(tool => $editorStore.enabledFeatures.includes(tool.feature))
|
|
33
|
+
.map(tool => tool.component);
|
|
34
|
+
|
|
35
|
+
InsertItems = INSERT_TOOLS
|
|
36
|
+
.filter(tool => $editorStore.enabledFeatures.includes(tool.feature))
|
|
37
|
+
.map(tool => tool.component);
|
|
38
|
+
});
|
|
26
39
|
</script>
|
|
27
40
|
|
|
28
41
|
{#snippet Home()}
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import type { Editor } from "@tiptap/core";
|
|
2
1
|
import './styles/controls.css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
(internal: unknown, props: Props & {
|
|
8
|
-
$$events?: Events;
|
|
9
|
-
$$slots?: Slots;
|
|
10
|
-
}): Exports & {
|
|
11
|
-
$set?: any;
|
|
12
|
-
$on?: any;
|
|
13
|
-
};
|
|
14
|
-
z_$$bindings?: Bindings;
|
|
15
|
-
}
|
|
16
|
-
declare const Controls: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
-
editor: Editor;
|
|
18
|
-
}, {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
}, {}, {}, string>;
|
|
21
|
-
type Controls = InstanceType<typeof Controls>;
|
|
2
|
+
declare const Controls: import("svelte").Component<{
|
|
3
|
+
editor: any;
|
|
4
|
+
}, {}, "">;
|
|
5
|
+
type Controls = ReturnType<typeof Controls>;
|
|
22
6
|
export default Controls;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type EditorFeature = 'text-formatting' | 'headings' | 'text-color' | 'text-align' | 'lists' | 'images' | 'links' | 'youtube' | 'history' | 'export';
|
|
2
|
+
export type ImageInsertMode = 'filepicker' | 'url';
|
|
1
3
|
export type EditorState = {
|
|
2
4
|
content: any;
|
|
3
5
|
export: boolean;
|
|
@@ -8,7 +10,8 @@ export type EditorState = {
|
|
|
8
10
|
serverDeleteUrl: string;
|
|
9
11
|
serverStorageUrl: string;
|
|
10
12
|
serverDownloadUrl: string;
|
|
11
|
-
|
|
13
|
+
enabledFeatures: EditorFeature[];
|
|
14
|
+
insertImageMode: ImageInsertMode[];
|
|
12
15
|
};
|
|
13
16
|
export declare const editorStore: import("svelte/store").Writable<EditorState>;
|
|
14
17
|
export declare function resetEditorStore(): void;
|
|
@@ -9,7 +9,8 @@ const defaultEditorState = {
|
|
|
9
9
|
serverDeleteUrl: '',
|
|
10
10
|
serverStorageUrl: '',
|
|
11
11
|
serverDownloadUrl: '',
|
|
12
|
-
|
|
12
|
+
enabledFeatures: [],
|
|
13
|
+
insertImageMode: ['filepicker', 'url']
|
|
13
14
|
};
|
|
14
15
|
export const editorStore = writable({
|
|
15
16
|
...defaultEditorState
|