-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
229 additions
and
127 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
51 changes: 51 additions & 0 deletions
51
...ts/page/editor/project/preferences/keyboard/EditorProjectPreferencesKeyboardInsertAdd.vue
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,51 @@ | ||
<template> | ||
<div class="flex items-center w-full gap-5 wb-text my-6 wb-text"> | ||
<InputText | ||
v-model="state.key" | ||
class="p-2 shadow-lg bg-theme-background-2 rounded-xl tracking-wider placeholder-theme-text-1 w-full" | ||
:placeholder="t('editor.preferences.shortcuts.inserts.key')" | ||
@keydown="onInputKey" | ||
/> | ||
<InputText | ||
v-model="state.value" | ||
class="p-2 shadow-lg bg-theme-background-2 rounded-xl tracking-wider placeholder-theme-text-1 w-full" | ||
:placeholder="t('editor.preferences.shortcuts.inserts.value')" | ||
@keyup.enter="add" | ||
/> | ||
<IconAdd class="w-18 h-18 wb-icon" @click.prevent.stop="add" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { reactive } from 'vue' | ||
import { useProjectStore } from '@/store/project' | ||
import { useI18n } from 'vue-i18n' | ||
const PROJECT = useProjectStore() | ||
const { t } = useI18n() | ||
const state = reactive({ | ||
key: '', | ||
value: '', | ||
}) | ||
const add = () => { | ||
if (!state.key || !state.value) return | ||
PROJECT.shortcuts.inserts.unshift({ | ||
key: state.key, | ||
value: state.value, | ||
}) | ||
state.key = '' | ||
state.value = '' | ||
} | ||
const onInputKey = (e: KeyboardEvent) => { | ||
e.preventDefault() | ||
e.stopPropagation() | ||
if (e.key) state.key = e.key | ||
} | ||
</script> |
59 changes: 59 additions & 0 deletions
59
...s/page/editor/project/preferences/keyboard/EditorProjectPreferencesKeyboardInsertItem.vue
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,59 @@ | ||
<template> | ||
<div class="flex items-center w-full gap-5 wb-text wb-text my-2"> | ||
<p | ||
class="px-3 py-1 rounded-full font-bold bg-theme-background-2 text-theme-text-2 shadow-lg w-24" | ||
> | ||
Alt | ||
</p> | ||
<p class="text-2xl">+</p> | ||
<InputText | ||
v-model="props.insert.key" | ||
class="p-2 shadow-lg bg-theme-background-2 rounded-xl tracking-wider placeholder-theme-text-1 w-full" | ||
:placeholder="t('editor.preferences.shortcuts.inserts.key')" | ||
@keydown="onInputKey" | ||
/> | ||
<p class="text-2xl">=</p> | ||
<InputText | ||
v-model="props.insert.value" | ||
class="p-2 shadow-lg bg-theme-background-2 rounded-xl tracking-wider placeholder-theme-text-1 w-full" | ||
:placeholder="t('editor.preferences.shortcuts.inserts.value')" | ||
/> | ||
<div class="flex items-center gap-0 md:gap-2"> | ||
<IconDelete | ||
v-motion | ||
:initial="{ opacity: 0, y: 30 }" | ||
:enter="{ opacity: 1, y: 0 }" | ||
:delay="50" | ||
class="w-7 h-7 wb-icon" | ||
@click.prevent.stop="remove" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useProjectStore } from '@/store/project' | ||
import { ProjectStateShortcutsInserts } from 'better-write-types' | ||
import { useI18n } from 'vue-i18n' | ||
const props = defineProps<{ | ||
insert: ProjectStateShortcutsInserts | ||
}>() | ||
const PROJECT = useProjectStore() | ||
const { t } = useI18n() | ||
const remove = () => { | ||
PROJECT.shortcuts.inserts = PROJECT.shortcuts.inserts.filter( | ||
(t) => t !== props.insert | ||
) | ||
} | ||
const onInputKey = (e: KeyboardEvent) => { | ||
e.preventDefault() | ||
e.stopPropagation() | ||
if (e.key) props.insert.key = e.key | ||
} | ||
</script> |
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
Oops, something went wrong.