Update index.html
Browse files- index.html +37 -17
index.html
CHANGED
|
@@ -184,7 +184,7 @@
|
|
| 184 |
class="w-full py-3 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-bold rounded-lg shadow-md hover:shadow-lg active:scale-95 transition-all flex items-center justify-center gap-2"
|
| 185 |
>
|
| 186 |
<span class="text-xl leading-none">🍀</span>
|
| 187 |
-
<span class="text-sm"
|
| 188 |
</button>
|
| 189 |
<p class="text-xs text-slate-400 mt-2">提示:套用後會自動切換為 6x8 網格並填入內容。</p>
|
| 190 |
</div>
|
|
@@ -314,14 +314,14 @@
|
|
| 314 |
ref="batchInputRef"
|
| 315 |
type="text"
|
| 316 |
v-model="batchInputBuffer"
|
| 317 |
-
placeholder="
|
| 318 |
class="flex-1 min-w-0 border-2 border-indigo-200 rounded-lg p-2 text-sm focus:border-indigo-500 focus:outline-none"
|
| 319 |
>
|
| 320 |
<button
|
| 321 |
@click="applyBatchText"
|
| 322 |
class="px-3 py-2 bg-indigo-600 text-white font-bold rounded-lg text-sm hover:bg-indigo-700 transition-all whitespace-nowrap"
|
| 323 |
>
|
| 324 |
-
|
| 325 |
</button>
|
| 326 |
</div>
|
| 327 |
<input
|
|
@@ -338,7 +338,7 @@
|
|
| 338 |
:style="{ color: selectedCellIndices.size > 0 ? selectedColor : '' }"
|
| 339 |
>
|
| 340 |
<p class="text-xs text-slate-400 mt-1" v-if="selectedCellIndices.size <= 1">提示:輸入 2~3 個字或數字時,字體會自動縮小。</p>
|
| 341 |
-
<p class="text-xs text-indigo-500 mt-1 font-bold" v-else
|
| 342 |
</div>
|
| 343 |
|
| 344 |
<!-- Icon Picker -->
|
|
@@ -581,6 +581,12 @@
|
|
| 581 |
:class="{ 'ring-4 ring-indigo-500 ring-inset z-20': selectedCellIndices.has(index) }"
|
| 582 |
:style="{ backgroundColor: cell.bgColor }"
|
| 583 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
<div class="rotation-wrapper pointer-events-none" :style="{ transform: `rotate(${cell.rotation}deg)` }">
|
| 585 |
<span v-if="cell.type === 'text'" class="font-bold cell-text block" :class="getFontSizeClass(cell.content)" :style="{ color: cell.color }">
|
| 586 |
{{ cell.content }}
|
|
@@ -661,7 +667,13 @@
|
|
| 661 |
'飛機': '✈️',
|
| 662 |
'花朵': '🌸',
|
| 663 |
'樹木': '🌳',
|
| 664 |
-
'禮物': '🎁'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
};
|
| 666 |
|
| 667 |
// --- State Initialization ---
|
|
@@ -724,6 +736,9 @@
|
|
| 724 |
return !gridOptions.some(opt => opt.label === currentGrid.value.label);
|
| 725 |
});
|
| 726 |
|
|
|
|
|
|
|
|
|
|
| 727 |
// --- Helper: Dynamic Font Size ---
|
| 728 |
const getFontSizeClass = (content) => {
|
| 729 |
const len = content ? content.length : 0;
|
|
@@ -746,6 +761,12 @@
|
|
| 746 |
return "60";
|
| 747 |
};
|
| 748 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 749 |
// --- Actions ---
|
| 750 |
|
| 751 |
const changeGridSize = (conf) => {
|
|
@@ -1127,7 +1148,7 @@
|
|
| 1127 |
});
|
| 1128 |
};
|
| 1129 |
|
| 1130 |
-
// Batch Text Update (Sequential)
|
| 1131 |
const applyBatchText = () => {
|
| 1132 |
const text = batchInputBuffer.value;
|
| 1133 |
if (!text || selectedCellIndices.value.size === 0) return;
|
|
@@ -1136,18 +1157,15 @@
|
|
| 1136 |
// However, Set iteration order is insertion order in JS.
|
| 1137 |
// So [...Set] preserves click order.
|
| 1138 |
const indices = [...selectedCellIndices.value];
|
| 1139 |
-
const
|
| 1140 |
-
// Note: Complex emojis or surrogate pairs might need better splitting if advanced usage,
|
| 1141 |
-
// but for general text split('') is okay-ish, or use [...text] for better unicode support.
|
| 1142 |
-
const charArray = [...text];
|
| 1143 |
|
| 1144 |
indices.forEach((cellIndex, i) => {
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
|
| 1151 |
});
|
| 1152 |
|
| 1153 |
// Clear buffers after apply
|
|
@@ -1438,7 +1456,9 @@
|
|
| 1438 |
// Multi-select
|
| 1439 |
isMultiSelectMode,
|
| 1440 |
toggleMultiSelectMode,
|
| 1441 |
-
clearSelection
|
|
|
|
|
|
|
| 1442 |
};
|
| 1443 |
}
|
| 1444 |
}).mount('#app');
|
|
|
|
| 184 |
class="w-full py-3 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-bold rounded-lg shadow-md hover:shadow-lg active:scale-95 transition-all flex items-center justify-center gap-2"
|
| 185 |
>
|
| 186 |
<span class="text-xl leading-none">🍀</span>
|
| 187 |
+
<span class="text-sm">套用:[幸運草與一句話]</span>
|
| 188 |
</button>
|
| 189 |
<p class="text-xs text-slate-400 mt-2">提示:套用後會自動切換為 6x8 網格並填入內容。</p>
|
| 190 |
</div>
|
|
|
|
| 314 |
ref="batchInputRef"
|
| 315 |
type="text"
|
| 316 |
v-model="batchInputBuffer"
|
| 317 |
+
placeholder="輸入文字將循環填入選取格子..."
|
| 318 |
class="flex-1 min-w-0 border-2 border-indigo-200 rounded-lg p-2 text-sm focus:border-indigo-500 focus:outline-none"
|
| 319 |
>
|
| 320 |
<button
|
| 321 |
@click="applyBatchText"
|
| 322 |
class="px-3 py-2 bg-indigo-600 text-white font-bold rounded-lg text-sm hover:bg-indigo-700 transition-all whitespace-nowrap"
|
| 323 |
>
|
| 324 |
+
填入
|
| 325 |
</button>
|
| 326 |
</div>
|
| 327 |
<input
|
|
|
|
| 338 |
:style="{ color: selectedCellIndices.size > 0 ? selectedColor : '' }"
|
| 339 |
>
|
| 340 |
<p class="text-xs text-slate-400 mt-1" v-if="selectedCellIndices.size <= 1">提示:輸入 2~3 個字或數字時,字體會自動縮小。</p>
|
| 341 |
+
<p class="text-xs text-indigo-500 mt-1 font-bold" v-else>批次模式:文字將依序循環填入選取格子。</p>
|
| 342 |
</div>
|
| 343 |
|
| 344 |
<!-- Icon Picker -->
|
|
|
|
| 581 |
:class="{ 'ring-4 ring-indigo-500 ring-inset z-20': selectedCellIndices.has(index) }"
|
| 582 |
:style="{ backgroundColor: cell.bgColor }"
|
| 583 |
>
|
| 584 |
+
<!-- Selection Order Badge (Only visible in Multi-Select Mode when selected) -->
|
| 585 |
+
<div v-if="isMultiSelectMode && selectedCellIndices.has(index)"
|
| 586 |
+
class="absolute top-1 right-1 w-6 h-6 bg-indigo-600 text-white rounded-full flex items-center justify-center text-xs font-bold z-30 shadow-sm border-2 border-white">
|
| 587 |
+
{{ getSelectionOrder(index) }}
|
| 588 |
+
</div>
|
| 589 |
+
|
| 590 |
<div class="rotation-wrapper pointer-events-none" :style="{ transform: `rotate(${cell.rotation}deg)` }">
|
| 591 |
<span v-if="cell.type === 'text'" class="font-bold cell-text block" :class="getFontSizeClass(cell.content)" :style="{ color: cell.color }">
|
| 592 |
{{ cell.content }}
|
|
|
|
| 667 |
'飛機': '✈️',
|
| 668 |
'花朵': '🌸',
|
| 669 |
'樹木': '🌳',
|
| 670 |
+
'禮物': '🎁',
|
| 671 |
+
'猴子臉': '🐵',
|
| 672 |
+
'猴子': '🐒',
|
| 673 |
+
'馬臉': '🐴',
|
| 674 |
+
'馬': '🐎',
|
| 675 |
+
'白圓': '⚪',
|
| 676 |
+
'白方': '⬜'
|
| 677 |
};
|
| 678 |
|
| 679 |
// --- State Initialization ---
|
|
|
|
| 736 |
return !gridOptions.some(opt => opt.label === currentGrid.value.label);
|
| 737 |
});
|
| 738 |
|
| 739 |
+
// NEW: Computed array to track selection order
|
| 740 |
+
const selectedIndicesArray = computed(() => Array.from(selectedCellIndices.value));
|
| 741 |
+
|
| 742 |
// --- Helper: Dynamic Font Size ---
|
| 743 |
const getFontSizeClass = (content) => {
|
| 744 |
const len = content ? content.length : 0;
|
|
|
|
| 761 |
return "60";
|
| 762 |
};
|
| 763 |
|
| 764 |
+
// NEW: Helper to get order for UI Badge
|
| 765 |
+
const getSelectionOrder = (index) => {
|
| 766 |
+
const order = selectedIndicesArray.value.indexOf(index);
|
| 767 |
+
return order !== -1 ? order + 1 : '';
|
| 768 |
+
};
|
| 769 |
+
|
| 770 |
// --- Actions ---
|
| 771 |
|
| 772 |
const changeGridSize = (conf) => {
|
|
|
|
| 1148 |
});
|
| 1149 |
};
|
| 1150 |
|
| 1151 |
+
// Batch Text Update (Sequential with Modulo)
|
| 1152 |
const applyBatchText = () => {
|
| 1153 |
const text = batchInputBuffer.value;
|
| 1154 |
if (!text || selectedCellIndices.value.size === 0) return;
|
|
|
|
| 1157 |
// However, Set iteration order is insertion order in JS.
|
| 1158 |
// So [...Set] preserves click order.
|
| 1159 |
const indices = [...selectedCellIndices.value];
|
| 1160 |
+
const charArray = [...text]; // Use spread for unicode safety
|
|
|
|
|
|
|
|
|
|
| 1161 |
|
| 1162 |
indices.forEach((cellIndex, i) => {
|
| 1163 |
+
// Use modulo to cycle through input text
|
| 1164 |
+
const char = charArray[i % charArray.length];
|
| 1165 |
+
const cell = activePageCells.value[cellIndex];
|
| 1166 |
+
cell.type = 'text';
|
| 1167 |
+
cell.content = char;
|
| 1168 |
+
cell.color = selectedColor.value;
|
| 1169 |
});
|
| 1170 |
|
| 1171 |
// Clear buffers after apply
|
|
|
|
| 1456 |
// Multi-select
|
| 1457 |
isMultiSelectMode,
|
| 1458 |
toggleMultiSelectMode,
|
| 1459 |
+
clearSelection,
|
| 1460 |
+
getSelectionOrder,
|
| 1461 |
+
selectedIndicesArray
|
| 1462 |
};
|
| 1463 |
}
|
| 1464 |
}).mount('#app');
|