adding selected object resizing with ctrl+arrows

This commit is contained in:
Jeff Emmett 2024-12-12 23:22:35 -05:00
parent 7987c3a8e4
commit ce3063e9ba
1 changed files with 87 additions and 0 deletions

View File

@ -196,6 +196,93 @@ export const overrides: TLUiOverrides = {
}
},
},
// TODO: FIX THIS
resizeSelectedUp: {
id: "resize-selected-up",
label: "Resize Up",
kbd: "ctrl+ArrowUp",
onSelect: () => {
const selectedShapes = editor.getSelectedShapes()
if (selectedShapes.length > 0) {
selectedShapes.forEach((shape) => {
const bounds = editor.getShapeGeometry(shape).bounds
editor.updateShape({
id: shape.id,
type: shape.type,
//y: shape.y - 50,
props: {
...shape.props,
h: bounds.height + 50,
},
})
})
}
},
},
resizeSelectedDown: {
id: "resize-selected-down",
label: "Resize Down",
kbd: "ctrl+ArrowDown",
onSelect: () => {
const selectedShapes = editor.getSelectedShapes()
if (selectedShapes.length > 0) {
selectedShapes.forEach((shape) => {
const bounds = editor.getShapeGeometry(shape).bounds
editor.updateShape({
id: shape.id,
type: shape.type,
props: {
...shape.props,
h: bounds.height + 50,
},
})
})
}
},
},
resizeSelectedLeft: {
id: "resize-selected-left",
label: "Resize Left",
kbd: "ctrl+ArrowLeft",
onSelect: () => {
const selectedShapes = editor.getSelectedShapes()
if (selectedShapes.length > 0) {
selectedShapes.forEach((shape) => {
const bounds = editor.getShapeGeometry(shape).bounds
editor.updateShape({
id: shape.id,
type: shape.type,
props: {
...shape.props,
w: bounds.width + 50,
},
})
})
}
},
},
resizeSelectedRight: {
id: "resize-selected-right",
label: "Resize Right",
kbd: "ctrl+ArrowRight",
onSelect: () => {
const selectedShapes = editor.getSelectedShapes()
if (selectedShapes.length > 0) {
selectedShapes.forEach((shape) => {
const bounds = editor.getShapeGeometry(shape).bounds
editor.updateShape({
id: shape.id,
type: shape.type,
props: {
...shape.props,
w: bounds.width + 50,
},
})
})
}
},
},
}
},
}