Save drawer shortcut

This commit is contained in:
Mel O'Hagan 2023-12-19 17:48:03 +00:00
parent 986eba7a50
commit 95860ea6b9
8 changed files with 77 additions and 747 deletions

View File

@ -128,8 +128,20 @@
},
}
const drawerCommands = [
{
key: "Mod-Enter",
preventDefault: true,
run: view => {
dispatch("saveCodeEditor", view)
return true
},
},
]
const buildKeymap = () => {
const baseMap = [
...drawerCommands,
...closeBracketsKeymap,
...defaultKeymap,
...historyKeymap,

View File

@ -189,6 +189,7 @@
<CodeEditor
value={hbsValue}
on:change={onChangeHBSValue}
on:saveCodeEditor
bind:getCaretPosition
bind:insertAtPos
completions={[

View File

@ -23,6 +23,7 @@
<BindingPanel
bind:valid
on:saveCodeEditor
bindings={enrichedBindings}
{value}
{allowJS}

View File

@ -13,6 +13,7 @@
readableToRuntimeBinding,
runtimeToReadableBinding,
} from "builderStore/dataBinding"
import { KeyboardShortcut } from "@budibase/frontend-core"
export let componentInstance
@ -56,14 +57,28 @@
<svelte:fragment slot="description">
Custom CSS overrides all other component styles.
</svelte:fragment>
<Button cta slot="buttons" on:click={save}>Save</Button>
<Button cta slot="buttons" on:click={save}>
<div class="button-with-keys">
Save
<KeyboardShortcut action={true} keybind="Ctrl+Enter" />
</div>
</Button>
<svelte:component
this={ClientBindingPanel}
slot="body"
value={tempValue}
on:change={event => (tempValue = event.detail)}
on:saveCodeEditor={save}
allowJS
{bindings}
/>
</Drawer>
{/key}
<style>
.button-with-keys {
display: flex;
gap: 6px;
align-items: center;
}
</style>

View File

@ -1 +1,2 @@
export { default as Grid } from "./layout/Grid.svelte"
export { default as KeyboardShortcut } from "./layout/KeyboardShortcut.svelte"

View File

@ -2,6 +2,7 @@
export let keybind
export let padded = false
export let overlay = false
export let action = false
$: parsedKeys = parseKeys(keybind)
@ -19,7 +20,7 @@
<div class="keys" class:padded class:overlay>
{#each parsedKeys as key}
<div class="key">
<div class={action ? "action-key" : "key"}>
{key}
</div>
{/each}
@ -34,6 +35,18 @@
.keys.padded {
padding: var(--cell-padding);
}
.action-key {
padding: 2px 6px;
font-size: 12px;
font-weight: 600;
background-color: var(--spectrum-global-color-gray-900);
color: var(--spectrum-global-color-blue-600);
border-radius: 4px;
text-align: center;
display: grid;
place-items: center;
text-transform: uppercase;
}
.key {
padding: 2px 6px;
font-size: 12px;

View File

@ -3,4 +3,4 @@ export { default as TestimonialPage } from "./TestimonialPage.svelte"
export { default as Testimonial } from "./Testimonial.svelte"
export { default as UserAvatar } from "./UserAvatar.svelte"
export { default as UserAvatars } from "./UserAvatars.svelte"
export { Grid } from "./grid"
export { Grid, KeyboardShortcut } from "./grid"

775
yarn.lock

File diff suppressed because it is too large Load Diff