Merge branch 'sandbox-execute-hotkey' into 'development'
Add control S hotkey to execute code See merge request GeneralProtocols/xo/stack!60
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
maxLines: props.fullHeight ? null : 20,
|
||||
showPrintMargin: false
|
||||
}"
|
||||
@keydown="handleExecuteHotkey"
|
||||
/>
|
||||
<div class="editor-buttons">
|
||||
<button v-if="!hideRunButton" @click="executeCode" class="primary-button">Run Code</button>
|
||||
@@ -291,6 +292,30 @@ const handleMessage = (event: MessageEvent) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Platform detection for keyboard shortcuts
|
||||
const isMac = computed(() => {
|
||||
// Modern browsers
|
||||
if ('userAgentData' in navigator) {
|
||||
return (navigator as any).userAgentData.platform === 'macOS';
|
||||
}
|
||||
|
||||
// Legacy browsers
|
||||
return /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
||||
});
|
||||
|
||||
// Handle keyboard shortcuts for code execution
|
||||
const handleExecuteHotkey = (event: KeyboardEvent) => {
|
||||
// Check if the save hotkey was pressed
|
||||
const isSaveShortcut = event.key.toLowerCase() === 's' &&
|
||||
(isMac.value ? event.metaKey : event.ctrlKey);
|
||||
|
||||
// If the save hotkey was pressed, then execute the code
|
||||
if (isSaveShortcut) {
|
||||
event.preventDefault();
|
||||
executeCode();
|
||||
}
|
||||
};
|
||||
|
||||
// Lifecycle hooks
|
||||
onMounted(() => {
|
||||
// Check if there's code in the URL hash fragment
|
||||
|
||||
Reference in New Issue
Block a user