@sierra-95/svelte-scaffold 1.1.4 → 1.2.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.
- package/dist/Core/components/Menus/MenuItem/menuItem.svelte +3 -2
- package/dist/Core/components/Menus/MenuItem/menuItem.svelte.d.ts +1 -0
- package/dist/Core/components/Menus/Tabs/main.css +0 -1
- package/dist/Core/components/Menus/Tabs/main.svelte +2 -1
- package/dist/Core/components/Menus/Tabs/main.svelte.d.ts +1 -0
- package/dist/Core/components/others/Previews/Audio/audio.svelte +5 -43
- package/dist/Core/components/others/Previews/Document/documents.svelte +1 -1
- package/dist/Core/components/others/Previews/Image/image.svelte +2 -2
- package/dist/Core/components/others/Previews/Video/video.svelte +4 -6
- package/dist/Core/components/others/Previews/Video/video.svelte.d.ts +0 -2
- package/dist/Modules/Editor/Nodes/Images/images.svelte +28 -11
- package/dist/Modules/Editor/controls.svelte +29 -16
- package/dist/Modules/Editor/controls.svelte.d.ts +4 -20
- package/dist/Modules/FilePicker/{ActionsMenu → Actions}/Actions.svelte +10 -12
- package/dist/Modules/FilePicker/Actions/Actions.svelte.d.ts +3 -0
- package/dist/Modules/FilePicker/{ActionsMenu/delete_media.svelte → Actions/delete.svelte} +8 -14
- package/dist/Modules/FilePicker/Actions/delete.svelte.d.ts +5 -0
- package/dist/Modules/FilePicker/{ActionsMenu/download_media.svelte → Actions/download.svelte} +13 -13
- package/dist/Modules/FilePicker/Actions/download.svelte.d.ts +5 -0
- package/dist/Modules/FilePicker/{ActionsMenu/file_properties.svelte → Actions/properties.svelte} +3 -3
- package/dist/Modules/FilePicker/{ActionsMenu/file_properties.svelte.d.ts → Actions/properties.svelte.d.ts} +3 -3
- package/dist/Modules/FilePicker/Cloud/cloudStore.svelte +42 -104
- package/dist/Modules/FilePicker/Cloud/cloudStore.svelte.d.ts +2 -4
- package/dist/Modules/FilePicker/Cloud/content.svelte +118 -0
- package/dist/Modules/FilePicker/Cloud/content.svelte.d.ts +3 -0
- package/dist/Modules/FilePicker/Cloud/storage.svelte +40 -0
- package/dist/Modules/FilePicker/Cloud/storage.svelte.d.ts +15 -0
- package/dist/Modules/FilePicker/Upload/upload.svelte +55 -0
- package/dist/Modules/FilePicker/{Cloud/previews.svelte.d.ts → Upload/upload.svelte.d.ts} +4 -6
- package/dist/Modules/FilePicker/main.svelte +11 -62
- package/dist/stores/modules/editor.d.ts +4 -2
- package/dist/stores/modules/editor.js +2 -2
- package/dist/stores/modules/fileInput.d.ts +3 -1
- package/dist/stores/modules/fileInput.js +4 -2
- package/package.json +1 -1
- package/dist/Modules/FilePicker/ActionsMenu/Actions.svelte.d.ts +0 -5
- package/dist/Modules/FilePicker/ActionsMenu/delete_media.svelte.d.ts +0 -6
- package/dist/Modules/FilePicker/ActionsMenu/download_media.svelte.d.ts +0 -6
- package/dist/Modules/FilePicker/ActionsMenu/media_storage.svelte +0 -54
- package/dist/Modules/FilePicker/ActionsMenu/media_storage.svelte.d.ts +0 -36
- package/dist/Modules/FilePicker/Cloud/previews.svelte +0 -39
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import Storage from '../ActionsMenu/media_storage.svelte';
|
|
2
|
+
import { fileInputStore, MenuItem, isDesktop } from '../../../index.js';
|
|
3
|
+
import Content from './content.svelte';
|
|
4
|
+
import Storage from './storage.svelte';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{ name: 'Documents', icon: 'fa fa-file-o' },
|
|
6
|
+
const menuItem: { name: 'Documents'| 'Music' | 'Pictures' | 'Videos'| 'Others'; icon: string }[] = [
|
|
7
|
+
{ name: 'Documents', icon: 'fa fa-file-alt' },
|
|
10
8
|
{ name: 'Music', icon: 'fa fa-music' },
|
|
11
9
|
{ name: 'Pictures', icon: 'fa fa-file-image-o' },
|
|
12
10
|
{ name: 'Videos', icon: 'fa fa-film' },
|
|
@@ -14,120 +12,60 @@
|
|
|
14
12
|
];
|
|
15
13
|
|
|
16
14
|
$: if ($fileInputStore.disabledMenuItem?.includes($fileInputStore.activeMenu)) {
|
|
17
|
-
const firstAvailable =
|
|
15
|
+
const firstAvailable = menuItem.find(item => !$fileInputStore.disabledMenuItem?.includes(item.name));
|
|
18
16
|
if (firstAvailable) $fileInputStore.activeMenu = firstAvailable.name;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
type MediaItem = {
|
|
22
|
-
id: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type MediaResponse = {
|
|
26
|
-
Audio: MediaItem[];
|
|
27
|
-
Documents: MediaItem[];
|
|
28
|
-
Images: MediaItem[];
|
|
29
|
-
Videos: MediaItem[];
|
|
30
|
-
Others: MediaItem[];
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
let media: MediaResponse | null = null;
|
|
34
|
-
let childFunctionRef : Storage;
|
|
35
|
-
|
|
36
|
-
async function loadMedia(){
|
|
37
|
-
if (!$User.userId || !$fileInputStore.serverGetUrl) return;
|
|
38
|
-
try {
|
|
39
|
-
processing = true;
|
|
40
|
-
const params = new URLSearchParams({
|
|
41
|
-
userId: $User.userId
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const res = await fetch(`${$fileInputStore.serverGetUrl}?${params.toString()}`);
|
|
45
|
-
|
|
46
|
-
const data = await res.json();
|
|
47
|
-
|
|
48
|
-
if (!res.ok) {
|
|
49
|
-
//console.log('Error fetching media:', data);
|
|
50
|
-
addToast({
|
|
51
|
-
status: 'error',
|
|
52
|
-
message: data || "Failed to fetch media."
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
media = data;
|
|
57
|
-
} catch (e) {
|
|
58
|
-
console.error("catch error:", e);
|
|
59
|
-
addToast({
|
|
60
|
-
status: 'error',
|
|
61
|
-
message: "An error occurred while fetching media."
|
|
62
|
-
});
|
|
63
|
-
} finally {
|
|
64
|
-
processing = false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
onMount(async () => {
|
|
69
|
-
await loadMedia();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
$: if ($fileInputStore.requestReload && childFunctionRef){
|
|
73
|
-
fileInputStore.update(store => ({
|
|
74
|
-
...store,
|
|
75
|
-
requestReload: false
|
|
76
|
-
}));
|
|
77
|
-
loadMedia();
|
|
78
|
-
childFunctionRef.loadMediaStorage();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
18
|
</script>
|
|
82
|
-
|
|
83
19
|
<style>
|
|
84
|
-
#sierra-cloud-store
|
|
85
|
-
|
|
20
|
+
#sierra-cloud-store{
|
|
21
|
+
position: relative;
|
|
22
|
+
display: flex;
|
|
23
|
+
height: 400px;
|
|
86
24
|
}
|
|
87
|
-
#sierra-cloud-store
|
|
88
|
-
|
|
89
|
-
background-color: var(--menu-item-active);
|
|
90
|
-
}
|
|
91
|
-
#sierra-cloud-store i{
|
|
92
|
-
color: var(--icon-theme);
|
|
25
|
+
#sierra-cloud-store nav{
|
|
26
|
+
padding-top: 1rem;
|
|
93
27
|
}
|
|
94
|
-
#sierra-cloud-store
|
|
95
|
-
|
|
28
|
+
#sierra-cloud-store main{
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
padding: 1rem;
|
|
96
31
|
}
|
|
97
|
-
@media (max-width:
|
|
98
|
-
#sierra-cloud-store
|
|
32
|
+
@media (max-width: 1024px) {
|
|
33
|
+
#sierra-cloud-store{
|
|
99
34
|
flex-direction: column-reverse;
|
|
100
35
|
}
|
|
101
36
|
#sierra-cloud-store nav{
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
#sierra-cloud-store nav button {
|
|
37
|
+
display: flex;
|
|
105
38
|
justify-content: center;
|
|
39
|
+
padding: 0.5rem 0rem;
|
|
40
|
+
}
|
|
41
|
+
#sierra-cloud-store main{
|
|
42
|
+
flex: 1;
|
|
106
43
|
}
|
|
107
44
|
}
|
|
108
45
|
</style>
|
|
109
|
-
<main id="sierra-cloud-store"
|
|
110
|
-
<nav
|
|
111
|
-
{#each
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
on:click={() =>
|
|
46
|
+
<main id="sierra-cloud-store">
|
|
47
|
+
<nav>
|
|
48
|
+
{#each menuItem as item}
|
|
49
|
+
<MenuItem
|
|
50
|
+
onclick={() =>
|
|
115
51
|
fileInputStore.update(store =>({
|
|
116
52
|
...store,
|
|
117
|
-
activeMenu:
|
|
53
|
+
activeMenu: item.name
|
|
118
54
|
}))
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
</
|
|
55
|
+
}
|
|
56
|
+
rounded={!$isDesktop ? '8px' : '0px'}
|
|
57
|
+
title={item.name}
|
|
58
|
+
hidden={$fileInputStore.disabledMenuItem?.includes(item.name)}
|
|
59
|
+
active={$fileInputStore.activeMenu === item.name}
|
|
60
|
+
icon={item.icon}
|
|
61
|
+
iconSize='15px'
|
|
62
|
+
iconBg={ $fileInputStore.activeMenu === item.name ? 'var(--primary-bg)' : 'var(--text-secondary)'}
|
|
63
|
+
iconGap="10px">{!$isDesktop ? '' : item.name}
|
|
64
|
+
</MenuItem>
|
|
129
65
|
{/each}
|
|
130
|
-
<Storage
|
|
66
|
+
<Storage/>
|
|
131
67
|
</nav>
|
|
132
|
-
<
|
|
68
|
+
<main>
|
|
69
|
+
<Content/>
|
|
70
|
+
</main>
|
|
133
71
|
</main>
|
|
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
2
2
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
3
|
$$bindings?: Bindings;
|
|
4
4
|
} & Exports;
|
|
5
|
-
(internal: unknown, props:
|
|
5
|
+
(internal: unknown, props: {
|
|
6
6
|
$$events?: Events;
|
|
7
7
|
$$slots?: Slots;
|
|
8
8
|
}): Exports & {
|
|
@@ -11,9 +11,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
11
11
|
};
|
|
12
12
|
z_$$bindings?: Bindings;
|
|
13
13
|
}
|
|
14
|
-
declare const CloudStore: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
processing: boolean;
|
|
16
|
-
}, {
|
|
14
|
+
declare const CloudStore: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
17
15
|
[evt: string]: CustomEvent<any>;
|
|
18
16
|
}, {}, {}, string>;
|
|
19
17
|
type CloudStore = InstanceType<typeof CloudStore>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { browser } from "$app/environment";
|
|
3
|
+
import { fileInputStore, addToast, PreviewImage, PreviewVideo, PreviewAudio, PreviewDocument, PreviewGenericFile } from "../../../index.js";
|
|
4
|
+
import type {FileInputStoreMediaItem} from '../../../index.js';
|
|
5
|
+
|
|
6
|
+
let itemCount = $state(0);
|
|
7
|
+
let totalSizeMB = $state(0);
|
|
8
|
+
let currentCategory = $state('');
|
|
9
|
+
let lastSelectedCategory = $state('');
|
|
10
|
+
const categoryMap = {
|
|
11
|
+
Documents: "document",
|
|
12
|
+
Music: "audio",
|
|
13
|
+
Pictures: "image",
|
|
14
|
+
Videos: "video",
|
|
15
|
+
Others: "other"
|
|
16
|
+
};
|
|
17
|
+
const media = $state<{
|
|
18
|
+
Images: any[];
|
|
19
|
+
Videos: any[];
|
|
20
|
+
Audio: any[];
|
|
21
|
+
Documents: any[];
|
|
22
|
+
Others: any[];
|
|
23
|
+
}>({
|
|
24
|
+
Images: [],
|
|
25
|
+
Videos: [],
|
|
26
|
+
Audio: [],
|
|
27
|
+
Documents: [],
|
|
28
|
+
Others: []
|
|
29
|
+
});
|
|
30
|
+
async function loadMedia(category: string) {
|
|
31
|
+
if (!$fileInputStore.serverGetUrl) return;
|
|
32
|
+
try {
|
|
33
|
+
$fileInputStore.processing = true;
|
|
34
|
+
const res = await fetch(`${$fileInputStore.serverGetUrl}?category=${category}`);
|
|
35
|
+
const data = await res.json();
|
|
36
|
+
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
addToast({
|
|
39
|
+
status: 'error',
|
|
40
|
+
message: data || "Failed to fetch media."
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
media.Images = [];
|
|
45
|
+
media.Videos = [];
|
|
46
|
+
media.Audio = [];
|
|
47
|
+
media.Documents = [];
|
|
48
|
+
media.Others = [];
|
|
49
|
+
//console.log('Fetched media:', data);
|
|
50
|
+
for (const item of data) {
|
|
51
|
+
switch (item.category) {
|
|
52
|
+
case "image":
|
|
53
|
+
media.Images.push(item);
|
|
54
|
+
break;
|
|
55
|
+
case "video":
|
|
56
|
+
media.Videos.push(item);
|
|
57
|
+
break;
|
|
58
|
+
case "audio":
|
|
59
|
+
media.Audio.push(item);
|
|
60
|
+
break;
|
|
61
|
+
case "document":
|
|
62
|
+
media.Documents.push(item);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
media.Others.push(item);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error("catch error:", e);
|
|
70
|
+
addToast({
|
|
71
|
+
status: 'error',
|
|
72
|
+
message: "An error occurred while fetching media."
|
|
73
|
+
});
|
|
74
|
+
} finally {
|
|
75
|
+
$fileInputStore.processing = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
$effect(()=> {
|
|
80
|
+
if( !browser) return;
|
|
81
|
+
if($fileInputStore.activeMenu){
|
|
82
|
+
currentCategory = categoryMap[$fileInputStore.activeMenu];
|
|
83
|
+
if (lastSelectedCategory !== currentCategory) {
|
|
84
|
+
loadMedia(currentCategory);
|
|
85
|
+
lastSelectedCategory = currentCategory;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if($fileInputStore.submissions){
|
|
89
|
+
const submissions = $fileInputStore.submissions || [];
|
|
90
|
+
itemCount = submissions.length;
|
|
91
|
+
const totalBytes = submissions.reduce(
|
|
92
|
+
(sum: number, item: FileInputStoreMediaItem) => sum + (item.size_bytes || 0),
|
|
93
|
+
0
|
|
94
|
+
);
|
|
95
|
+
totalSizeMB = +(totalBytes / (1024 * 1024)).toFixed(2);
|
|
96
|
+
}
|
|
97
|
+
if($fileInputStore.requestReload){
|
|
98
|
+
$fileInputStore.requestReload = false;
|
|
99
|
+
loadMedia(currentCategory);
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
{#if $fileInputStore.activeMenu === 'Music'}
|
|
106
|
+
<PreviewAudio {media} />
|
|
107
|
+
{:else if $fileInputStore.activeMenu === 'Documents'}
|
|
108
|
+
<PreviewDocument {media} />
|
|
109
|
+
{:else if $fileInputStore.activeMenu === 'Pictures'}
|
|
110
|
+
<PreviewImage {media} />
|
|
111
|
+
{:else if $fileInputStore.activeMenu === 'Videos'}
|
|
112
|
+
<PreviewVideo {media} />
|
|
113
|
+
{:else if $fileInputStore.activeMenu === 'Others'}
|
|
114
|
+
<PreviewGenericFile {media} />
|
|
115
|
+
{/if}
|
|
116
|
+
<div hidden={itemCount === 0} style="position: absolute; top: 0; right: 0;padding: 2px 5px; box-shadow: var(--box-shadow); background: var(--background); z-index: 1;">
|
|
117
|
+
{itemCount} {itemCount === 1 ? 'item' : 'items'} selected ({totalSizeMB} MB)
|
|
118
|
+
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { fileInputStore,CustomProgress, isDesktop, addToast} from '../../../index.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
padding = "0.5rem",
|
|
7
|
+
width = "100%",
|
|
8
|
+
forceRender = $bindable(false),
|
|
9
|
+
} = $props()
|
|
10
|
+
|
|
11
|
+
let progress = $state(0);
|
|
12
|
+
let progressColor = $state("var(--primary-bg)");
|
|
13
|
+
|
|
14
|
+
onMount(()=>{
|
|
15
|
+
if(!$fileInputStore.usedBytes || !$fileInputStore.maxBytes){
|
|
16
|
+
addToast({
|
|
17
|
+
status: 'warning',
|
|
18
|
+
message: 'Unable to calculate storage usage. Please configure your cloud storage settings.',
|
|
19
|
+
persistent: true,
|
|
20
|
+
});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
progress = ($fileInputStore.usedBytes / $fileInputStore.maxBytes) * 100;
|
|
24
|
+
})
|
|
25
|
+
$effect(()=>{
|
|
26
|
+
if(progress){
|
|
27
|
+
progressColor = progress < 60
|
|
28
|
+
? 'var(--primary-bg)'
|
|
29
|
+
: progress < 90
|
|
30
|
+
? 'var(--warning-bg)'
|
|
31
|
+
: 'var(--error-bg)';
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<div hidden={!$isDesktop && !forceRender} style="padding: 0.5rem {padding}; width: {width};">
|
|
38
|
+
<CustomProgress value={progress} color={progressColor}/>
|
|
39
|
+
<h3 style="font-size: 0.8rem;">{progress.toFixed(2)}% of 100 MB</h3>
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default Storage;
|
|
2
|
+
type Storage = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Storage: import("svelte").Component<{
|
|
7
|
+
padding?: string;
|
|
8
|
+
width?: string;
|
|
9
|
+
forceRender?: boolean;
|
|
10
|
+
}, {}, "forceRender">;
|
|
11
|
+
type $$ComponentProps = {
|
|
12
|
+
padding?: string;
|
|
13
|
+
width?: string;
|
|
14
|
+
forceRender?: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {fileInputStore,FileInput, addToast} from '../../../index.js'
|
|
3
|
+
|
|
4
|
+
async function handleUpload() {
|
|
5
|
+
if( $fileInputStore.selectedFiles.length === 0 || !$fileInputStore.serverUploadUrl) return;
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
$fileInputStore.processing = true;
|
|
9
|
+
const formData = new FormData();
|
|
10
|
+
|
|
11
|
+
$fileInputStore.selectedFiles.forEach(file => formData.append('files', file));
|
|
12
|
+
|
|
13
|
+
const res = await fetch($fileInputStore.serverUploadUrl, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
body: formData
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const data = await res.json();
|
|
19
|
+
|
|
20
|
+
if (!res.ok) {
|
|
21
|
+
addToast({
|
|
22
|
+
status: 'error',
|
|
23
|
+
message: data || 'Upload failed',
|
|
24
|
+
persistent: true
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fileInputStore.update(store => {
|
|
30
|
+
store.selectedFiles = [];
|
|
31
|
+
store.activeTab = 'Cloud';
|
|
32
|
+
return store;
|
|
33
|
+
});
|
|
34
|
+
addToast({
|
|
35
|
+
status: 'success',
|
|
36
|
+
message: 'Files uploaded successfully!'
|
|
37
|
+
});
|
|
38
|
+
} catch (err) {
|
|
39
|
+
addToast({
|
|
40
|
+
status: 'error',
|
|
41
|
+
message: `Upload failed: ${err}`,
|
|
42
|
+
persistent: true
|
|
43
|
+
});
|
|
44
|
+
} finally {
|
|
45
|
+
$fileInputStore.processing = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<FileInput
|
|
52
|
+
minHeight="400px"
|
|
53
|
+
bind:processing={$fileInputStore.processing}
|
|
54
|
+
onclick={handleUpload}
|
|
55
|
+
/>
|
|
@@ -2,7 +2,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
2
2
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
3
|
$$bindings?: Bindings;
|
|
4
4
|
} & Exports;
|
|
5
|
-
(internal: unknown, props:
|
|
5
|
+
(internal: unknown, props: {
|
|
6
6
|
$$events?: Events;
|
|
7
7
|
$$slots?: Slots;
|
|
8
8
|
}): Exports & {
|
|
@@ -11,10 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
11
11
|
};
|
|
12
12
|
z_$$bindings?: Bindings;
|
|
13
13
|
}
|
|
14
|
-
declare const
|
|
15
|
-
media: any;
|
|
16
|
-
}, {
|
|
14
|
+
declare const Upload: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
17
15
|
[evt: string]: CustomEvent<any>;
|
|
18
16
|
}, {}, {}, string>;
|
|
19
|
-
type
|
|
20
|
-
export default
|
|
17
|
+
type Upload = InstanceType<typeof Upload>;
|
|
18
|
+
export default Upload;
|
|
@@ -1,83 +1,31 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {Backdrop,Wrapper,fileInputStore, LinearProgress,
|
|
2
|
+
import {Backdrop,Wrapper,fileInputStore, LinearProgress, Tabs, resetFileInputStore, addToast} from '../../index.js'
|
|
3
|
+
|
|
3
4
|
import CloudStore from './Cloud/cloudStore.svelte';
|
|
4
|
-
import Actions from './
|
|
5
|
-
|
|
6
|
-
let processing: boolean = false;
|
|
7
|
-
|
|
8
|
-
async function handleUpload() {
|
|
9
|
-
if(!$User.userId || !$fileInputStore.r2_key || $fileInputStore.selectedFiles.length === 0 || !$fileInputStore.serverUploadUrl) return;
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
processing = true;
|
|
13
|
-
const formData = new FormData();
|
|
14
|
-
|
|
15
|
-
$fileInputStore.selectedFiles.forEach(file => formData.append('files', file));
|
|
16
|
-
formData.append('r2_key', $fileInputStore.r2_key);
|
|
17
|
-
formData.append('userid', $User.userId);
|
|
18
|
-
|
|
19
|
-
const res = await fetch($fileInputStore.serverUploadUrl, {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
body: formData
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const data = await res.json();
|
|
25
|
-
|
|
26
|
-
if (!res.ok) {
|
|
27
|
-
addToast({
|
|
28
|
-
status: 'error',
|
|
29
|
-
message: data || 'Upload failed',
|
|
30
|
-
persistent: true
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
data.forEach((item: { original_name: string; code: number; }) => {
|
|
36
|
-
if (item.code === 500) {
|
|
37
|
-
addToast({
|
|
38
|
-
status: 'error',
|
|
39
|
-
message: `Failed to upload file: ${item.original_name}`
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
fileInputStore.update(store => {
|
|
45
|
-
store.selectedFiles = [];
|
|
46
|
-
store.activeTab = 'Cloud';
|
|
47
|
-
store.requestReload = true;
|
|
48
|
-
return store;
|
|
49
|
-
});
|
|
50
|
-
} catch (err) {
|
|
51
|
-
addToast({
|
|
52
|
-
status: 'error',
|
|
53
|
-
message: `Upload failed: ${err}`,
|
|
54
|
-
persistent: true
|
|
55
|
-
});
|
|
56
|
-
} finally {
|
|
57
|
-
processing = false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
5
|
+
import Actions from './Actions/Actions.svelte';
|
|
6
|
+
import UploadMedia from './Upload/upload.svelte';
|
|
60
7
|
|
|
61
8
|
function onEscape(){
|
|
62
9
|
resetFileInputStore();
|
|
63
10
|
}
|
|
11
|
+
|
|
64
12
|
</script>
|
|
65
13
|
|
|
66
14
|
|
|
67
15
|
{#snippet Cloud()}
|
|
68
|
-
<CloudStore
|
|
16
|
+
<CloudStore />
|
|
69
17
|
{/snippet}
|
|
70
18
|
|
|
71
19
|
{#snippet Upload()}
|
|
72
|
-
<
|
|
20
|
+
<UploadMedia />
|
|
73
21
|
{/snippet}
|
|
74
22
|
|
|
75
23
|
{#snippet actions()}
|
|
76
|
-
<Actions
|
|
24
|
+
<Actions/>
|
|
77
25
|
{/snippet}
|
|
78
26
|
|
|
79
27
|
<Backdrop onClose={onEscape} bind:open={$fileInputStore.uploadModalOpen} zIndex={15}>
|
|
80
|
-
<Wrapper maxWidth="700px"
|
|
28
|
+
<Wrapper maxWidth="700px" padding="0px">
|
|
81
29
|
<Tabs
|
|
82
30
|
bind:active={$fileInputStore.activeTab}
|
|
83
31
|
tabs={[
|
|
@@ -86,7 +34,8 @@
|
|
|
86
34
|
]}
|
|
87
35
|
snippets={{ Cloud, Upload }}
|
|
88
36
|
actions={actions}
|
|
37
|
+
padding="0px"
|
|
89
38
|
/>
|
|
90
|
-
{#if processing}<LinearProgress />{/if}
|
|
39
|
+
{#if $fileInputStore.processing}<LinearProgress />{/if}
|
|
91
40
|
</Wrapper>
|
|
92
41
|
</Backdrop>
|
|
@@ -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;
|
|
@@ -6,9 +8,9 @@ export type EditorState = {
|
|
|
6
8
|
serverGetUrl: string;
|
|
7
9
|
serverUploadUrl: string;
|
|
8
10
|
serverDeleteUrl: string;
|
|
9
|
-
serverStorageUrl: string;
|
|
10
11
|
serverDownloadUrl: string;
|
|
11
|
-
|
|
12
|
+
enabledFeatures: EditorFeature[];
|
|
13
|
+
insertImageMode: ImageInsertMode[];
|
|
12
14
|
};
|
|
13
15
|
export declare const editorStore: import("svelte/store").Writable<EditorState>;
|
|
14
16
|
export declare function resetEditorStore(): void;
|
|
@@ -7,9 +7,9 @@ const defaultEditorState = {
|
|
|
7
7
|
serverGetUrl: '',
|
|
8
8
|
serverUploadUrl: '',
|
|
9
9
|
serverDeleteUrl: '',
|
|
10
|
-
serverStorageUrl: '',
|
|
11
10
|
serverDownloadUrl: '',
|
|
12
|
-
|
|
11
|
+
enabledFeatures: [],
|
|
12
|
+
insertImageMode: ['filepicker', 'url']
|
|
13
13
|
};
|
|
14
14
|
export const editorStore = writable({
|
|
15
15
|
...defaultEditorState
|
|
@@ -23,9 +23,11 @@ export type FileInputState = {
|
|
|
23
23
|
serverGetUrl: string;
|
|
24
24
|
serverUploadUrl: string;
|
|
25
25
|
serverDeleteUrl: string;
|
|
26
|
-
serverStorageUrl: string;
|
|
27
26
|
serverDownloadUrl: string;
|
|
28
27
|
requestReload: boolean;
|
|
28
|
+
processing?: boolean;
|
|
29
|
+
usedBytes: number;
|
|
30
|
+
maxBytes: number;
|
|
29
31
|
};
|
|
30
32
|
export declare const fileInputStore: import("svelte/store").Writable<FileInputState>;
|
|
31
33
|
export declare function resetFileInputStore(): void;
|
|
@@ -15,9 +15,11 @@ const defaultFileInputState = {
|
|
|
15
15
|
serverGetUrl: '',
|
|
16
16
|
serverUploadUrl: '',
|
|
17
17
|
serverDeleteUrl: '',
|
|
18
|
-
serverStorageUrl: '',
|
|
19
18
|
serverDownloadUrl: '',
|
|
20
|
-
requestReload: false
|
|
19
|
+
requestReload: false,
|
|
20
|
+
processing: false,
|
|
21
|
+
usedBytes: 0,
|
|
22
|
+
maxBytes: 0
|
|
21
23
|
};
|
|
22
24
|
export const fileInputStore = writable({
|
|
23
25
|
...defaultFileInputState
|
package/package.json
CHANGED