chore: remove unnecessary comments

This commit is contained in:
2026-02-04 23:52:00 +05:00
parent 49f427f3a0
commit dafc1bbfd2
13 changed files with 28 additions and 139 deletions
-3
View File
@@ -24,7 +24,6 @@
errorMessage = undefined;
panels = panelStorage.getAllPanels();
// Если есть текущая панель в store, отмечаем её как выбранную
const currentPanel = $panelStore;
if (currentPanel) {
selectedPanelId = currentPanel.id;
@@ -47,12 +46,10 @@
if (result.success) {
panels = panels.filter((p) => p.id !== panelId);
// Если удалили выбранную панель, сбрасываем выбор
if (selectedPanelId === panelId) {
selectedPanelId = undefined;
}
// Уведомляем родительский компонент
onPanelDelete(panelId);
} else {
errorMessage = result.error || "Ошибка удаления панели";
+2 -30
View File
@@ -16,10 +16,8 @@
let konvaStage: KonvaStage | null = $state(null);
let stageComponent: any = $state(null);
// Get the Konva stage after component mounts
$effect(() => {
if (stageComponent) {
// According to svelte-konva docs, access the node property to get the underlying Konva Stage
konvaStage = stageComponent.node;
}
});
@@ -35,7 +33,6 @@
});
function loadImage(src: string) {
// Remove verbose logging - image data is too large for console
const img = document.createElement("img");
img.onload = () => {
backgroundImage = img;
@@ -47,50 +44,30 @@
}
function handleDownload() {
console.log("[PanelPreview] handleDownload called");
console.log("[PanelPreview] onDownload exists:", onDownload ? true : false);
console.log("[PanelPreview] konvaStage exists:", konvaStage ? true : false);
console.log("[PanelPreview] konvaStage value:", konvaStage);
console.log("[PanelPreview] stageComponent exists:", stageComponent ? true : false);
// Try different approaches to get the Konva stage for download
let stageToUse = konvaStage;
if (!stageToUse && stageComponent) {
console.log("[PanelPreview] konvaStage is null, trying to get stage from stageComponent");
// Try different properties that might contain the Konva stage
stageToUse = stageComponent.node || stageComponent.stage || stageComponent._stage || stageComponent;
// Check if this is actually a valid Konva stage
if (stageToUse && typeof stageToUse.toBlob === "function") {
console.log("[PanelPreview] Found valid Konva stage in stageComponent");
} else {
console.log("[PanelPreview] stageComponent itself might be the Konva stage");
// Maybe stageComponent IS the Konva stage - check if it has toBlob
if (typeof stageComponent.toBlob === "function") {
stageToUse = stageComponent;
console.log("[PanelPreview] ✅ stageComponent IS the Konva stage");
} else {
console.log("[PanelPreview] ❌ Could not find valid Konva stage");
}
}
}
if (onDownload && stageToUse) {
console.log("[PanelPreview] Calling onDownload with panel and stage");
onDownload(panel, stageToUse);
} else {
console.error("[PanelPreview] Cannot download - onDownload or valid stage is missing");
}
}
function getTextPosition(textItem: TextItem) {
const panelWidth = 320;
const paddingX = textItem.paddingX || 20; // Default padding
const paddingX = textItem.paddingX || 20;
const verticalOffset = textItem.verticalOffset || 0;
const centerY = panel.height / 2 + verticalOffset;
const textWidth = 300; // Width of the text area
const textWidth = 300;
let position;
switch (textItem.textAlign) {
@@ -98,12 +75,10 @@
position = { x: paddingX, y: centerY };
break;
case "right":
// For right alignment, position the right edge of text at panel edge minus padding
position = { x: panelWidth - textWidth - paddingX, y: centerY };
break;
case "center":
default:
// For center alignment, center the text area within the panel
position = { x: (panelWidth - textWidth) / 2, y: centerY };
break;
}
@@ -118,18 +93,15 @@
<Button variant="primary" size="sm" onclick={handleDownload}>Скачать</Button>
</div>
<div class="preview-sections">
<!-- Превью с текстом -->
<div class="preview-section">
<div class="canvas-container">
<Stage width={320} height={panel.height} bind:this={stageComponent}>
<!-- Background layer -->
<Layer>
{#if backgroundImage}
<Image image={backgroundImage} width={320} height={panel.height} />
{/if}
</Layer>
<!-- Text layer (renders above background) -->
<Layer>
{#if panel.text}
{@const textPosition = getTextPosition(panel.text)}