chore: remove unnecessary comments
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
});
|
||||
|
||||
function initializeCropper() {
|
||||
// Remove verbose debug logging
|
||||
if (!imageElement || !CropperJS) {
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +51,6 @@
|
||||
throw new Error("Не удалось получить обрезанное изображение");
|
||||
}
|
||||
|
||||
// Используем метод $toCanvas для получения HTMLCanvasElement
|
||||
const canvas = await cropperCanvasElement.$toCanvas({
|
||||
width: 320,
|
||||
});
|
||||
@@ -61,10 +59,8 @@
|
||||
throw new Error("Не удалось получить canvas");
|
||||
}
|
||||
|
||||
// Теперь canvas - это обычный HTMLCanvasElement
|
||||
const croppedImage = canvas.toDataURL("image/png");
|
||||
|
||||
// Validate cropped image
|
||||
const cropResult: ImageCropResult = {
|
||||
success: true,
|
||||
croppedImage,
|
||||
@@ -171,7 +167,6 @@
|
||||
background-color: #007bff;
|
||||
}
|
||||
|
||||
/* Базовые стили для cropperjs */
|
||||
:global(.cropper-container) {
|
||||
direction: ltr;
|
||||
font-size: 0;
|
||||
|
||||
@@ -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 || "Ошибка удаления панели";
|
||||
|
||||
@@ -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)}
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
let newText = $state("");
|
||||
let errorMessage = $state<string | undefined>(undefined);
|
||||
|
||||
// Use reactive store for text settings
|
||||
let commonTextSettings = $derived($textSettingsStore);
|
||||
|
||||
// Список доступных шрифтов
|
||||
const availableFonts = [
|
||||
"Arial",
|
||||
"Verdana",
|
||||
@@ -89,7 +87,6 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Список текстов -->
|
||||
{#if texts.length > 0}
|
||||
<div class="texts-list">
|
||||
<h3>Созданные тексты ({texts.length})</h3>
|
||||
@@ -112,7 +109,6 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Общие настройки текста -->
|
||||
<div class="common-settings-section">
|
||||
<h3>Общие настройки текста</h3>
|
||||
<p class="settings-note">Настройки применятся ко всем создаваемым панелям</p>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
img.src = src;
|
||||
}
|
||||
|
||||
// Вычисляем позицию текста на основе выравнивания и отступов
|
||||
function getTextPosition() {
|
||||
const panelWidth = 320;
|
||||
const paddingX = textItem.paddingX || 0;
|
||||
|
||||
Reference in New Issue
Block a user