Skip to content

Commit

Permalink
feat: use escape to exit from markdown, code & screenshot previews (#235
Browse files Browse the repository at this point in the history
)
  • Loading branch information
antonreshetov authored Aug 15, 2022
1 parent 3fb66e4 commit 12c6906
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/renderer/components/editor/EditorPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ import { computed, ref, onMounted, watch } from 'vue'
import interact from 'interactjs'
import { useAppStore } from '@/store/app'
import { i18n, ipc, track } from '@/electron'
import { useMagicKeys } from '@vueuse/core'
const snippetStore = useSnippetStore()
const appStore = useAppStore()
const { escape } = useMagicKeys()
const srcDoc = ref()
const height = computed(() => appStore.sizes.codePreviewHeight + 'px')
Expand Down Expand Up @@ -112,6 +115,10 @@ const onClickSnippetShowcase = () => {
track('app/open-url', 'https://masscode.io/snippets')
}
watch(escape, () => {
snippetStore.isCodePreview = false
})
onMounted(() => {
interact(previewRef.value).resizable({
edges: { top: true },
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/components/markdown/TheMarkdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import mermaid from 'mermaid'
import { useHljsTheme, goToSnippet } from '@/composable'
import { useCodemirror } from '@/composable/codemirror'
import { nanoid } from 'nanoid'
import { useMagicKeys } from '@vueuse/core'
const isDev = import.meta.env.DEV
Expand All @@ -38,6 +39,7 @@ const props = withDefaults(defineProps<Props>(), {
const appStore = useAppStore()
const snippetStore = useSnippetStore()
const { escape } = useMagicKeys()
const renderedHtml = ref()
Expand Down Expand Up @@ -269,6 +271,10 @@ watch(
}
)
watch(escape, () => {
snippetStore.isMarkdownPreview = false
})
init()
onMounted(() => {
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/components/screenshot/TheScreenshot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<div class="right">
<AppActionButton
v-tooltip="i18n.t('saveScreenshot')"
@click="onSaveScreenshot">
@click="onSaveScreenshot"
>
<UniconsFileDownload />
</AppActionButton>
</div>
Expand Down Expand Up @@ -109,6 +110,7 @@ import { computed, onMounted, ref, watch } from 'vue'
import { useHljsTheme } from '@/composable'
import { store, track, i18n } from '@/electron'
import { useSnippetStore } from '@/store/snippets'
import { useMagicKeys } from '@vueuse/core'
const GUTTER_RIGHT_OFFSET = 10
const GUTTER_WIDTH = 8
Expand All @@ -125,6 +127,7 @@ const props = defineProps<Props>()
const appStore = useAppStore()
const snippetStore = useSnippetStore()
const { escape } = useMagicKeys()
const frameRef = ref<HTMLElement>()
const snippetRef = ref<HTMLElement>()
Expand Down Expand Up @@ -211,6 +214,10 @@ watch(
{ deep: true }
)
watch(escape, () => {
snippetStore.isScreenshotPreview = false
})
onMounted(() => {
interact(frameRef.value!).resizable({
allowFrom: gutterRef.value!,
Expand Down

0 comments on commit 12c6906

Please sign in to comment.