-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
undo redo, trying to debug something catching and going wrong but now…
… dont feel like it
- Loading branch information
1 parent
e6f6cee
commit d079be8
Showing
7 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import store from "../stores/store"; | ||
function onKeyDown(e: any) { | ||
const tagName = e.target.tagName.toLowerCase(); | ||
const tagType = e.target.type; | ||
const classes = e.target.getAttribute("class") || ""; | ||
if (tagName === "input" && !classes.includes("color-slider")) { | ||
const isUIElement = | ||
tagType === "number" || tagType === "range" || tagType === "text"; | ||
if (isUIElement) { | ||
return; | ||
} | ||
} | ||
// block code mirror editing | ||
if (classes.includes("cm-content")) { | ||
return; | ||
} | ||
if (tagName === "textarea") { | ||
return; | ||
} | ||
const key = e.key.toLowerCase(); | ||
const metaKey = e.metaKey || e.ctrlKey; | ||
// UNDO REDO | ||
if (key === "z" && metaKey) { | ||
e.preventDefault(); | ||
store.undo(); | ||
} | ||
if ((key === "y" && metaKey) || (key === "z" && metaKey && e.shiftKey)) { | ||
e.preventDefault(); | ||
store.redo(); | ||
} | ||
} | ||
</script> | ||
|
||
<svelte:window on:keydown={onKeyDown} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters