0)
+ area.children.forEach((child) => {
+ const [startRow, startCol, endRow, endCol] = child.gridArea.split(' / ')
+ if (colIndex < Number(startCol))
+ child.gridArea = `${startRow} / ${Number(startCol) + 1} / ${endRow} / ${Number(endCol) + 1}`
+ else if (colIndex < Number(endCol))
+ child.gridArea = `${startRow} / ${startCol} / ${endRow} / ${Number(endCol) + 1}`
+ })
}
-export function addRow(grid, rowStr) {
- addToDimension(grid.row, rowStr)
+export function addRow(area, rowStr) {
+ const rowIndex = area.grid.hover?.row || -1
+ addToDimension(area.grid.row, rowIndex, rowStr)
+ if (rowIndex > 0)
+ area.children.forEach((child) => {
+ const [startRow, startCol, endRow, endCol] = child.gridArea.split(' / ')
+ if (rowIndex < Number(startRow))
+ child.gridArea = `${Number(startRow) + 1} / ${startCol} / ${Number(endRow) + 1} / ${endCol}`
+ else if (rowIndex < Number(endRow))
+ child.gridArea = `${startRow} / ${startCol} / ${Number(endRow) + 1} / ${endCol}`
+ })
}
function reduceLimit(l) {
diff --git a/src/utils/keyMonitor.js b/src/utils/keyMonitor.js
index 6b70083..9df5e89 100644
--- a/src/utils/keyMonitor.js
+++ b/src/utils/keyMonitor.js
@@ -4,6 +4,7 @@ import {
canRedo,
canUndo,
currentArea,
+ overArea,
deselectCurrentArea,
mainArea,
redo,
@@ -37,6 +38,7 @@ function ctrlMetaKeyHandler(event) {
}
function keyHandler(event) {
+ const targetArea = overArea?.value || currentArea.value
switch (event.key.toLowerCase()) {
case 'backspace':
case 'delete':
@@ -50,14 +52,10 @@ function keyHandler(event) {
}
break
case 'r':
- if (currentArea?.value?.grid) {
- addRow(currentArea.value.grid, '1fr')
- }
+ if (targetArea.display === 'grid') addRow(targetArea, '1fr')
break
case 'c':
- if (currentArea?.value?.grid) {
- addCol(currentArea.value.grid, '1fr')
- }
+ if (targetArea.display === 'grid') addCol(targetArea, '1fr')
break
case 'escape':
if (currentArea.value !== mainArea.value) {