Save drawer shortcut
This commit is contained in:
parent
986eba7a50
commit
95860ea6b9
|
@ -128,8 +128,20 @@
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const drawerCommands = [
|
||||||
|
{
|
||||||
|
key: "Mod-Enter",
|
||||||
|
preventDefault: true,
|
||||||
|
run: view => {
|
||||||
|
dispatch("saveCodeEditor", view)
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
const buildKeymap = () => {
|
const buildKeymap = () => {
|
||||||
const baseMap = [
|
const baseMap = [
|
||||||
|
...drawerCommands,
|
||||||
...closeBracketsKeymap,
|
...closeBracketsKeymap,
|
||||||
...defaultKeymap,
|
...defaultKeymap,
|
||||||
...historyKeymap,
|
...historyKeymap,
|
||||||
|
|
|
@ -189,6 +189,7 @@
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
value={hbsValue}
|
value={hbsValue}
|
||||||
on:change={onChangeHBSValue}
|
on:change={onChangeHBSValue}
|
||||||
|
on:saveCodeEditor
|
||||||
bind:getCaretPosition
|
bind:getCaretPosition
|
||||||
bind:insertAtPos
|
bind:insertAtPos
|
||||||
completions={[
|
completions={[
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
<BindingPanel
|
<BindingPanel
|
||||||
bind:valid
|
bind:valid
|
||||||
|
on:saveCodeEditor
|
||||||
bindings={enrichedBindings}
|
bindings={enrichedBindings}
|
||||||
{value}
|
{value}
|
||||||
{allowJS}
|
{allowJS}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
readableToRuntimeBinding,
|
readableToRuntimeBinding,
|
||||||
runtimeToReadableBinding,
|
runtimeToReadableBinding,
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
|
import { KeyboardShortcut } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
|
|
||||||
|
@ -56,14 +57,28 @@
|
||||||
<svelte:fragment slot="description">
|
<svelte:fragment slot="description">
|
||||||
Custom CSS overrides all other component styles.
|
Custom CSS overrides all other component styles.
|
||||||
</svelte:fragment>
|
</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
|
<svelte:component
|
||||||
this={ClientBindingPanel}
|
this={ClientBindingPanel}
|
||||||
slot="body"
|
slot="body"
|
||||||
value={tempValue}
|
value={tempValue}
|
||||||
on:change={event => (tempValue = event.detail)}
|
on:change={event => (tempValue = event.detail)}
|
||||||
|
on:saveCodeEditor={save}
|
||||||
allowJS
|
allowJS
|
||||||
{bindings}
|
{bindings}
|
||||||
/>
|
/>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
{/key}
|
{/key}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.button-with-keys {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
export { default as Grid } from "./layout/Grid.svelte"
|
export { default as Grid } from "./layout/Grid.svelte"
|
||||||
|
export { default as KeyboardShortcut } from "./layout/KeyboardShortcut.svelte"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
export let keybind
|
export let keybind
|
||||||
export let padded = false
|
export let padded = false
|
||||||
export let overlay = false
|
export let overlay = false
|
||||||
|
export let action = false
|
||||||
|
|
||||||
$: parsedKeys = parseKeys(keybind)
|
$: parsedKeys = parseKeys(keybind)
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
|
|
||||||
<div class="keys" class:padded class:overlay>
|
<div class="keys" class:padded class:overlay>
|
||||||
{#each parsedKeys as key}
|
{#each parsedKeys as key}
|
||||||
<div class="key">
|
<div class={action ? "action-key" : "key"}>
|
||||||
{key}
|
{key}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -34,6 +35,18 @@
|
||||||
.keys.padded {
|
.keys.padded {
|
||||||
padding: var(--cell-padding);
|
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 {
|
.key {
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
|
@ -3,4 +3,4 @@ export { default as TestimonialPage } from "./TestimonialPage.svelte"
|
||||||
export { default as Testimonial } from "./Testimonial.svelte"
|
export { default as Testimonial } from "./Testimonial.svelte"
|
||||||
export { default as UserAvatar } from "./UserAvatar.svelte"
|
export { default as UserAvatar } from "./UserAvatar.svelte"
|
||||||
export { default as UserAvatars } from "./UserAvatars.svelte"
|
export { default as UserAvatars } from "./UserAvatars.svelte"
|
||||||
export { Grid } from "./grid"
|
export { Grid, KeyboardShortcut } from "./grid"
|
||||||
|
|
Loading…
Reference in New Issue