fix: resolve typescript types errors
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
let uploadedImage = $state<string | undefined>(undefined);
|
let uploadedImage = $state<string | undefined>(undefined);
|
||||||
let errorMessage = $state<string | undefined>(undefined);
|
let errorMessage = $state<string | undefined>(undefined);
|
||||||
|
|
||||||
const uiError = $derived($uiStore.error?.error);
|
const uiError = $derived($uiStore.error);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
setupPasteHandler();
|
setupPasteHandler();
|
||||||
@@ -40,14 +40,14 @@
|
|||||||
function setupDragAndDrop() {
|
function setupDragAndDrop() {
|
||||||
if (!dropZone) return;
|
if (!dropZone) return;
|
||||||
|
|
||||||
dropZone.addEventListener("dragover", handleDragOver);
|
dropZone!.addEventListener("dragover", handleDragOver);
|
||||||
dropZone.addEventListener("dragleave", handleDragLeave);
|
dropZone!.addEventListener("dragleave", handleDragLeave);
|
||||||
dropZone.addEventListener("drop", handleDrop);
|
dropZone!.addEventListener("drop", handleDrop);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
dropZone.removeEventListener("dragover", handleDragOver);
|
dropZone!.removeEventListener("dragover", handleDragOver);
|
||||||
dropZone.removeEventListener("dragleave", handleDragLeave);
|
dropZone!.removeEventListener("dragleave", handleDragLeave);
|
||||||
dropZone.removeEventListener("drop", handleDrop);
|
dropZone!.removeEventListener("drop", handleDrop);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
async function handleUrlSubmit(e: Event) {
|
async function handleUrlSubmit(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!urlInput.value.trim()) return;
|
if (!urlInput?.value.trim()) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -230,12 +230,11 @@
|
|||||||
accept="image/jpeg,image/jpg,image/png,image/webp,image/gif"
|
accept="image/jpeg,image/jpg,image/png,image/webp,image/gif"
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
onchange={(e) => {
|
onchange={(e) => {
|
||||||
const file = e.target.files?.[0];
|
const file = (e.target as HTMLInputElement).files?.[0];
|
||||||
if (file) handleFileUpload(file);
|
if (file) handleFileUpload(file);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if errorMessage}
|
{#if errorMessage}
|
||||||
<div class="error-message">
|
<div class="error-message">
|
||||||
<strong>Ошибка:</strong>
|
<strong>Ошибка:</strong>
|
||||||
|
|||||||
@@ -92,10 +92,9 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<div class="panels-grid">
|
<div class="panels-grid">
|
||||||
{#each panels as panel (panel.id)}
|
{#each panels as panel (panel.id)}
|
||||||
<div
|
<button
|
||||||
class="panel-card {selectedPanelId === panel.id ? 'selected' : ''}"
|
class="panel-card {selectedPanelId === panel.id ? 'selected' : ''}"
|
||||||
onclick={() => handlePanelSelect(panel)}
|
onclick={() => handlePanelSelect(panel)}
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<div class="panel-preview">
|
<div class="panel-preview">
|
||||||
@@ -125,7 +124,7 @@
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<div class="panel-preview">
|
<div class="panel-preview">
|
||||||
<div class="preview-header">
|
<div class="preview-header">
|
||||||
<div class="panel-title">{panel.texts[0]?.text || "Без названия"}</div>
|
<div class="panel-title">{panel.texts[0]?.text || "Без названия"}</div>
|
||||||
<Button variant="primary" size="sm" onclick={onDownload}>Скачать</Button>
|
<Button variant="primary" size="sm" onclick={handleDownload}>Скачать</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="preview-sections">
|
<div class="preview-sections">
|
||||||
<!-- Превью с текстом -->
|
<!-- Превью с текстом -->
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontFamily: "Arial",
|
fontFamily: "Arial",
|
||||||
color: "#ffffff",
|
color: "#ffffff",
|
||||||
textAlign: "left" | "center" | "right",
|
textAlign: "left",
|
||||||
paddingX: 10,
|
paddingX: 10,
|
||||||
verticalOffset: 0,
|
verticalOffset: 0,
|
||||||
});
|
});
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={textItem.text}
|
value={textItem.text}
|
||||||
oninput={(e) => handleUpdateText(textItem.id, e.target.value)}
|
oninput={(e) => handleUpdateText(textItem.id, e.currentTarget.value)}
|
||||||
class="text-edit-input"
|
class="text-edit-input"
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
/>
|
/>
|
||||||
@@ -132,8 +132,8 @@
|
|||||||
max="72"
|
max="72"
|
||||||
step="1"
|
step="1"
|
||||||
value={commonTextSettings.fontSize}
|
value={commonTextSettings.fontSize}
|
||||||
oninput={(e) => {
|
oninput={(e: Event) => {
|
||||||
commonTextSettings.fontSize = parseInt(e.target.value);
|
commonTextSettings.fontSize = parseInt((e.target as HTMLInputElement).value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span class="value-display">{commonTextSettings.fontSize}px</span>
|
<span class="value-display">{commonTextSettings.fontSize}px</span>
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
<select
|
<select
|
||||||
value={commonTextSettings.fontFamily}
|
value={commonTextSettings.fontFamily}
|
||||||
onchange={(e) => {
|
onchange={(e) => {
|
||||||
commonTextSettings.fontFamily = e.target.value;
|
commonTextSettings.fontFamily = (e.target as HTMLSelectElement).value;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#each availableFonts as font}
|
{#each availableFonts as font}
|
||||||
@@ -163,7 +163,7 @@
|
|||||||
type="color"
|
type="color"
|
||||||
value={commonTextSettings.color}
|
value={commonTextSettings.color}
|
||||||
oninput={(e) => {
|
oninput={(e) => {
|
||||||
commonTextSettings.color = e.target.value;
|
commonTextSettings.color = (e.target as HTMLInputElement).value;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
step="1"
|
step="1"
|
||||||
value={commonTextSettings.paddingX}
|
value={commonTextSettings.paddingX}
|
||||||
oninput={(e) => {
|
oninput={(e) => {
|
||||||
commonTextSettings.paddingX = parseInt(e.target.value);
|
commonTextSettings.paddingX = parseInt((e.target as HTMLInputElement).value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span class="value-display">{commonTextSettings.paddingX}px</span>
|
<span class="value-display">{commonTextSettings.paddingX}px</span>
|
||||||
@@ -231,7 +231,7 @@
|
|||||||
step="1"
|
step="1"
|
||||||
value={commonTextSettings.verticalOffset}
|
value={commonTextSettings.verticalOffset}
|
||||||
oninput={(e) => {
|
oninput={(e) => {
|
||||||
commonTextSettings.verticalOffset = parseInt(e.target.value);
|
commonTextSettings.verticalOffset = parseInt((e.target as HTMLInputElement).value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span class="value-display"
|
<span class="value-display"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
class?: string;
|
class?: string;
|
||||||
children?: any;
|
children?: any;
|
||||||
|
onclick?: (event: MouseEvent) => void;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
class?: string;
|
class?: string;
|
||||||
children?: any;
|
children?: any;
|
||||||
|
onclick?: (event: MouseEvent) => void;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
|
export type TextAlign = "left" | "center" | "right";
|
||||||
|
|
||||||
export interface TextItem {
|
export interface TextItem {
|
||||||
id: string;
|
id: string;
|
||||||
text: string;
|
text: string;
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
color: string;
|
color: string;
|
||||||
// Выравнивание текста: left, center, right
|
textAlign: TextAlign;
|
||||||
textAlign: "left" | "center" | "right";
|
|
||||||
// Боковые отступы (лево/право)
|
|
||||||
paddingX: number;
|
paddingX: number;
|
||||||
// Смещение от центра по вертикали (для компенсации визуального центра разных шрифтов)
|
|
||||||
verticalOffset: number;
|
verticalOffset: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,14 @@ import { ImageError } from "../types/errors";
|
|||||||
export const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
|
export const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
|
||||||
export const SUPPORTED_FORMATS = ["image/jpeg", "image/jpg", "image/png", "image/webp", "image/gif"];
|
export const SUPPORTED_FORMATS = ["image/jpeg", "image/jpg", "image/png", "image/webp", "image/gif"];
|
||||||
|
|
||||||
export interface ValidationResult {
|
export type ValidationResult =
|
||||||
isValid: boolean;
|
| {
|
||||||
error?: string;
|
isValid: true;
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
isValid: false;
|
||||||
|
error: string;
|
||||||
|
};
|
||||||
|
|
||||||
export function validateFileSize(file: File): ValidationResult {
|
export function validateFileSize(file: File): ValidationResult {
|
||||||
if (file.size > MAX_FILE_SIZE) {
|
if (file.size > MAX_FILE_SIZE) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from "svelte/store";
|
||||||
import { type Panel } from "../lib/types/panel";
|
import { type Panel, type TextAlign, type TextItem } from "../lib/types/panel";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
export const panelStore: Writable<Panel | undefined> = writable(undefined);
|
export const panelStore: Writable<Panel | undefined> = writable(undefined);
|
||||||
@@ -24,7 +24,7 @@ export const updatePanel = (panel: Panel, updates: Partial<Panel>): Panel => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const addTextToPanel = (panel: Panel, text: string): Panel => {
|
export const addTextToPanel = (panel: Panel, text: string): Panel => {
|
||||||
const newText = {
|
const newText: TextItem = {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
text,
|
text,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -52,7 +52,7 @@ export const removeTextFromPanel = (panel: Panel, textId: string): Panel => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const createPanelFromText = (backgroundImage: string, text: string, height: number = 100): Panel => {
|
export const createPanelFromText = (backgroundImage: string, text: string, height: number = 100): Panel => {
|
||||||
const newText = {
|
const newText: TextItem = {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
text,
|
text,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
|
|||||||
Reference in New Issue
Block a user