AI рефакторинг !
This commit is contained in:
@@ -1,21 +1,12 @@
|
||||
import { cellAddressToCoordinates, getColumnLabel } from '@/lib/cell-utils'
|
||||
import { MergedCell } from '@/type/template'
|
||||
import { MergedCellInfo } from './types'
|
||||
|
||||
// --- Helper Functions ---
|
||||
export const getColumnLabel = (index: number) => String.fromCharCode(65 + index)
|
||||
export { getColumnLabel }
|
||||
|
||||
// Функция для преобразования адреса ячейки в координаты
|
||||
export const cellAddressToCoords = (
|
||||
address: string
|
||||
): { row: number; col: number } => {
|
||||
const match = address.match(/^([A-Z]+)(\d+)$/)
|
||||
if (!match) return { row: 0, col: 0 }
|
||||
|
||||
const col = match[1].charCodeAt(0) - 65 // Простое преобразование для одной буквы
|
||||
const row = parseInt(match[2]) - 1
|
||||
|
||||
return { row, col }
|
||||
}
|
||||
// Вспомогательная функция для совместимости с существующим кодом
|
||||
export const cellAddressToCoords = cellAddressToCoordinates
|
||||
|
||||
// Функция для проверки, является ли ячейка частью объединенной группы
|
||||
export const findMergedCellInfo = (
|
||||
@@ -24,8 +15,8 @@ export const findMergedCellInfo = (
|
||||
mergedCells: MergedCell[]
|
||||
): MergedCellInfo => {
|
||||
for (const merged of mergedCells) {
|
||||
const fromCoords = cellAddressToCoords(merged.from)
|
||||
const toCoords = cellAddressToCoords(merged.to)
|
||||
const fromCoords = cellAddressToCoordinates(merged.from)
|
||||
const toCoords = cellAddressToCoordinates(merged.to)
|
||||
|
||||
// Проверяем, попадает ли текущая ячейка в диапазон объединения
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user