Adds style panel, styles
This commit is contained in:
parent
def8f665d3
commit
6c8499309e
26 changed files with 819 additions and 141 deletions
36
state/commands/style.ts
Normal file
36
state/commands/style.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import Command from "./command"
|
||||
import history from "../history"
|
||||
import { Data, ShapeStyles } from "types"
|
||||
import { getPage, getSelectedShapes } from "utils/utils"
|
||||
import { getShapeUtils } from "lib/shape-utils"
|
||||
import { current } from "immer"
|
||||
|
||||
export default function styleCommand(data: Data, styles: ShapeStyles) {
|
||||
const { currentPageId } = data
|
||||
const initialShapes = getSelectedShapes(current(data))
|
||||
|
||||
history.execute(
|
||||
data,
|
||||
new Command({
|
||||
name: "changed_style",
|
||||
category: "canvas",
|
||||
manualSelection: true,
|
||||
do(data) {
|
||||
const { shapes } = getPage(data, currentPageId)
|
||||
|
||||
for (const { id } of initialShapes) {
|
||||
const shape = shapes[id]
|
||||
getShapeUtils(shape).applyStyles(shape, styles)
|
||||
}
|
||||
},
|
||||
undo(data) {
|
||||
const { shapes } = getPage(data, currentPageId)
|
||||
|
||||
for (const { id, style } of initialShapes) {
|
||||
const shape = shapes[id]
|
||||
getShapeUtils(shape).applyStyles(shape, style)
|
||||
}
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue