fix: change command behavior for monacos

This commit is contained in:
Ruben Fiszel
2022-10-03 03:54:18 +02:00
parent ad0ffb5eb6
commit 0a67d3fb87
5 changed files with 32 additions and 46 deletions
+11 -14
View File
@@ -364,20 +364,6 @@
editorConfig(model, code, lang, automaticLayout)
)
if (shouldBindKey) {
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
code = getCode()
format()
})
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
if (cmdEnterAction) {
code = getCode()
cmdEnterAction()
}
})
}
let timeoutModel: NodeJS.Timeout | undefined = undefined
editor.onDidChangeModelContent((event) => {
timeoutModel && clearTimeout(timeoutModel)
@@ -389,6 +375,17 @@
editor.onDidFocusEditorText(() => {
dispatch('focus')
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
code = getCode()
shouldBindKey && format && format()
})
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
code = getCode()
shouldBindKey && cmdEnterAction && cmdEnterAction()
})
if (
!websocketAlive.black &&
!websocketAlive.deno &&
@@ -158,6 +158,16 @@
<div class="flex flex-col flex-1 h-full">
<!-- Nav between steps-->
<div class="justify-between flex flex-row w-full my-2 px-4 space-x-4 h-10">
<div id="flow_title" class="flex justify-between items-center">
<button class="flex flex-row items-center w-full h-full" on:click={() => select('settings')}>
<span class="font-mono text-sm"> {$flowStore.path}</span>
<Icon
data={faPen}
scale={0.8}
class="text-gray-500 ml-2 flex justify-center items-center mb-0.5"
/>
</button>
</div>
<div class="shrink h-full">
<button
class="flex flex-row items-center w-full h-full"
+10 -14
View File
@@ -38,7 +38,7 @@
export let automaticLayout = true
export let extraLib: string = ''
export let extraLibPath: string = ''
export let shouldBindKey: boolean = false
export let shouldBindKey: boolean = true
const dispatch = createEventDispatcher()
@@ -105,19 +105,6 @@
editorConfig(model, code, lang, automaticLayout)
)
if (shouldBindKey) {
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
format()
})
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
if (cmdEnterAction) {
code = getCode()
cmdEnterAction()
}
})
}
let timeoutModel: NodeJS.Timeout | undefined = undefined
editor.onDidChangeModelContent((event) => {
timeoutModel && clearTimeout(timeoutModel)
@@ -128,6 +115,15 @@
})
editor.onDidFocusEditorText(() => {
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
code = getCode()
shouldBindKey && format && format()
})
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
code = getCode()
shouldBindKey && cmdEnterAction && cmdEnterAction()
})
dispatch('focus')
})
@@ -48,6 +48,7 @@
lang="javascript"
bind:code={$flowStore.value.modules[index].value.iterator.expr}
class="small-editor"
shouldBindKey={false}
/>
</PropPickerWrapper>
</div>
@@ -1,27 +1,9 @@
<script lang="ts">
import { flowStore } from '$lib/components/flows/flowStore'
import { faPen } from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
import FlowPreviewButtons from './FlowPreviewButtons.svelte'
import FlowStatus from './FlowStatus.svelte'
import { getContext } from 'svelte'
import type { FlowEditorContext } from '../types'
const { select } = getContext<FlowEditorContext>('FlowEditorContext')
</script>
<div class="flex justify-between items-center border-y p-2 px-4 space-x-2">
<div id="flow_title" class="flex justify-between items-center">
<button on:click={() => select('settings')}>
<span class="font-mono text-sm"> {$flowStore.path}</span>
<Icon
data={faPen}
scale={0.8}
class="text-gray-500 ml-2 flex justify-center items-center mb-0.5"
/>
</button>
</div>
<FlowStatus />
<FlowPreviewButtons />
</div>