Skip to content

Commit

Permalink
feat: Add ctrl + s (save) shortcut to code editor
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Feb 1, 2025
1 parent 35db077 commit 3b9a0cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 15 additions & 1 deletion frontend/src/components/Controls/CodeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:style="{
height: height,
}">
<span class="text-p-sm font-medium text-ink-gray-8" v-if="label">
<span class="text-p-sm font-medium text-ink-gray-8" v-show="label">
{{ label }}
<span v-if="isDirty" class="text-[10px] text-gray-600">●</span>
</span>
Expand Down Expand Up @@ -121,6 +121,20 @@ const setupEditor = () => {
}
});
if (props.showSaveButton || !props.readonly) {
aceEditor.commands.addCommand({
name: "save",
bindKey: { win: "Ctrl-S", mac: "Cmd-S" },
exec: () => {
if (props.showSaveButton) {
emit("save", aceEditor?.getValue());
} else {
emit("update:modelValue", aceEditor?.getValue());
}
},
});
}
aceEditor.on("blur", () => {
try {
let value = aceEditor?.getValue() || "";
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/PageScript.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const savePageDataScript = (value: string) => {
})
.then(() => {
posthog.capture("builder_page_data_script_saved");
showDialog.value = false;
props.page.page_data_script = value;
store.setPageData(props.page);
toast.success("Data script saved");
Expand Down

0 comments on commit 3b9a0cc

Please sign in to comment.