mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-22 16:23:28 +01:00
Merge pull request #1387 from JeLuF/picker
Keyboard shortcuts for the image editor
This commit is contained in:
commit
99ab2d2a81
@ -1611,6 +1611,14 @@ body.wait-pause {
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image-editor-button-label {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-editor-button-label::first-letter {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes slideInRight {
|
@keyframes slideInRight {
|
||||||
from {
|
from {
|
||||||
right: -300px;
|
right: -300px;
|
||||||
@ -1641,3 +1649,4 @@ body.wait-pause {
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ const IMAGE_EDITOR_TOOLS = [
|
|||||||
begin: defaultToolBegin,
|
begin: defaultToolBegin,
|
||||||
move: defaultToolMove,
|
move: defaultToolMove,
|
||||||
end: defaultToolEnd,
|
end: defaultToolEnd,
|
||||||
|
hotkey: "d",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "erase",
|
id: "erase",
|
||||||
@ -77,6 +78,7 @@ const IMAGE_EDITOR_TOOLS = [
|
|||||||
setBrush: (editor, layer) => {
|
setBrush: (editor, layer) => {
|
||||||
layer.ctx.globalCompositeOperation = "destination-out"
|
layer.ctx.globalCompositeOperation = "destination-out"
|
||||||
},
|
},
|
||||||
|
hotkey: "e",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "fill",
|
id: "fill",
|
||||||
@ -92,6 +94,7 @@ const IMAGE_EDITOR_TOOLS = [
|
|||||||
},
|
},
|
||||||
move: toolDoNothing,
|
move: toolDoNothing,
|
||||||
end: toolDoNothing,
|
end: toolDoNothing,
|
||||||
|
hotkey: "f",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "colorpicker",
|
id: "colorpicker",
|
||||||
@ -113,6 +116,7 @@ const IMAGE_EDITOR_TOOLS = [
|
|||||||
},
|
},
|
||||||
move: toolDoNothing,
|
move: toolDoNothing,
|
||||||
end: toolDoNothing,
|
end: toolDoNothing,
|
||||||
|
hotkey: "p",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -208,7 +212,10 @@ var IMAGE_EDITOR_SECTIONS = [
|
|||||||
var icon = document.createElement("i")
|
var icon = document.createElement("i")
|
||||||
tool_info.icon.split(" ").forEach((c) => icon.classList.add(c))
|
tool_info.icon.split(" ").forEach((c) => icon.classList.add(c))
|
||||||
sub_element.appendChild(icon)
|
sub_element.appendChild(icon)
|
||||||
sub_element.append(tool_info.name)
|
var label_element = document.createElement("div")
|
||||||
|
label_element.classList.add("image-editor-button-label")
|
||||||
|
label_element.textContent=tool_info.name
|
||||||
|
sub_element.appendChild(label_element)
|
||||||
element.appendChild(sub_element)
|
element.appendChild(sub_element)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -702,15 +709,22 @@ class ImageEditor {
|
|||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
if (event.key == "y" && event.ctrlKey) {
|
else if (event.key == "y" && event.ctrlKey) {
|
||||||
this.history.redo()
|
this.history.redo()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
if (event.key === "Escape") {
|
else if (event.key === "Escape") {
|
||||||
this.hide()
|
this.hide()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
} else {
|
||||||
|
let toolIndex = IMAGE_EDITOR_TOOLS.findIndex( t => t.hotkey ==event.key )
|
||||||
|
if (toolIndex != -1) {
|
||||||
|
this.selectOption("tool", toolIndex)
|
||||||
|
event.stopPropagation()
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user