mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
save
This commit is contained in:
parent
ad3166a2c9
commit
24a47496a5
@ -398,6 +398,12 @@ async function openLink(uri: string, forceOpenInternally = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getActiveBlockId() {
|
||||||
|
const layoutModel = getLayoutModelForActiveTab();
|
||||||
|
const focusedNode = globalStore.get(layoutModel.focusedNode);
|
||||||
|
return focusedNode?.data?.blockId;
|
||||||
|
}
|
||||||
|
|
||||||
function registerBlockComponentModel(blockId: string, bcm: BlockComponentModel) {
|
function registerBlockComponentModel(blockId: string, bcm: BlockComponentModel) {
|
||||||
blockComponentModelMap.set(blockId, bcm);
|
blockComponentModelMap.set(blockId, bcm);
|
||||||
}
|
}
|
||||||
@ -410,6 +416,11 @@ function getBlockComponentModel(blockId: string): BlockComponentModel {
|
|||||||
return blockComponentModelMap.get(blockId);
|
return blockComponentModelMap.get(blockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getActiveBlockComponentModel(): BlockComponentModel {
|
||||||
|
const blockId = getActiveBlockId();
|
||||||
|
return getBlockComponentModel(blockId);
|
||||||
|
}
|
||||||
|
|
||||||
function refocusNode(blockId: string) {
|
function refocusNode(blockId: string) {
|
||||||
if (blockId == null) {
|
if (blockId == null) {
|
||||||
return;
|
return;
|
||||||
@ -457,6 +468,15 @@ async function loadConnStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function subscribeToBrowserEvents() {
|
||||||
|
window.addEventListener("hashchange", (e) => {
|
||||||
|
console.log("hashchange");
|
||||||
|
});
|
||||||
|
window.addEventListener("popstate", (e) => {
|
||||||
|
console.log("popstate");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function subscribeToConnEvents() {
|
function subscribeToConnEvents() {
|
||||||
waveEventSubscribe({
|
waveEventSubscribe({
|
||||||
eventType: "connchange",
|
eventType: "connchange",
|
||||||
@ -529,6 +549,8 @@ export {
|
|||||||
countersPrint,
|
countersPrint,
|
||||||
createBlock,
|
createBlock,
|
||||||
fetchWaveFile,
|
fetchWaveFile,
|
||||||
|
getActiveBlockComponentModel,
|
||||||
|
getActiveBlockId,
|
||||||
getApi,
|
getApi,
|
||||||
getBlockComponentModel,
|
getBlockComponentModel,
|
||||||
getConnStatusAtom,
|
getConnStatusAtom,
|
||||||
@ -549,6 +571,7 @@ export {
|
|||||||
removeFlashError,
|
removeFlashError,
|
||||||
setNodeFocus,
|
setNodeFocus,
|
||||||
setPlatform,
|
setPlatform,
|
||||||
|
subscribeToBrowserEvents,
|
||||||
subscribeToConnEvents,
|
subscribeToConnEvents,
|
||||||
unregisterBlockComponentModel,
|
unregisterBlockComponentModel,
|
||||||
useBlockAtom,
|
useBlockAtom,
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
// Copyright 2024, Command Line Inc.
|
// Copyright 2024, Command Line Inc.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import { atoms, createBlock, getApi, getBlockComponentModel, globalStore, refocusNode, WOS } from "@/app/store/global";
|
import {
|
||||||
|
atoms,
|
||||||
|
createBlock,
|
||||||
|
getActiveBlockComponentModel,
|
||||||
|
getApi,
|
||||||
|
globalStore,
|
||||||
|
refocusNode,
|
||||||
|
WOS,
|
||||||
|
} from "@/app/store/global";
|
||||||
import * as services from "@/app/store/services";
|
import * as services from "@/app/store/services";
|
||||||
import {
|
import {
|
||||||
deleteLayoutModelForTab,
|
deleteLayoutModelForTab,
|
||||||
@ -163,11 +171,8 @@ function appHandleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
|
|||||||
if (handled) {
|
if (handled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const layoutModel = getLayoutModelForActiveTab();
|
if (shouldDispatchToBlock(waveEvent)) {
|
||||||
const focusedNode = globalStore.get(layoutModel.focusedNode);
|
const bcm = getActiveBlockComponentModel();
|
||||||
const blockId = focusedNode?.data?.blockId;
|
|
||||||
if (blockId != null && shouldDispatchToBlock(waveEvent)) {
|
|
||||||
const bcm = getBlockComponentModel(blockId);
|
|
||||||
const viewModel = bcm?.viewModel;
|
const viewModel = bcm?.viewModel;
|
||||||
if (viewModel?.keyDownHandler) {
|
if (viewModel?.keyDownHandler) {
|
||||||
const handledByBlock = viewModel.keyDownHandler(waveEvent);
|
const handledByBlock = viewModel.keyDownHandler(waveEvent);
|
||||||
@ -264,12 +269,33 @@ function registerGlobalKeys() {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
globalKeyMap.set("Cmd:g", () => {
|
globalKeyMap.set("Cmd:g", () => {
|
||||||
const bcm = getBlockComponentModel(getFocusedBlockInActiveTab());
|
const bcm = getActiveBlockComponentModel();
|
||||||
if (bcm.openSwitchConnection != null) {
|
if (bcm.openSwitchConnection != null) {
|
||||||
bcm.openSwitchConnection();
|
bcm.openSwitchConnection();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const onBrowserBack = () => {
|
||||||
|
console.log("onBrowserBack");
|
||||||
|
const bcm = getActiveBlockComponentModel();
|
||||||
|
const onBack = bcm?.viewModel?.onBack;
|
||||||
|
if (onBack != null) {
|
||||||
|
onBack();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
globalKeyMap.set("BrowserBack", onBrowserBack);
|
||||||
|
globalKeyMap.set("GoBack", onBrowserBack);
|
||||||
|
const onBrowserForward = () => {
|
||||||
|
console.log("onBrowserForward");
|
||||||
|
const bcm = getActiveBlockComponentModel();
|
||||||
|
const onForward = bcm?.viewModel?.onForward;
|
||||||
|
|
||||||
|
onForward();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
globalKeyMap.set("BrowserForward", onBrowserForward);
|
||||||
for (let idx = 1; idx <= 9; idx++) {
|
for (let idx = 1; idx <= 9; idx++) {
|
||||||
globalKeyMap.set(`Cmd:${idx}`, () => {
|
globalKeyMap.set(`Cmd:${idx}`, () => {
|
||||||
switchTabAbs(idx);
|
switchTabAbs(idx);
|
||||||
|
@ -477,7 +477,10 @@ function TableBody({
|
|||||||
model.goHistory(newFileName);
|
model.goHistory(newFileName);
|
||||||
setSearch("");
|
setSearch("");
|
||||||
}}
|
}}
|
||||||
onClick={() => setFocusIndex(idx)}
|
onClick={(e) => {
|
||||||
|
setFocusIndex(idx);
|
||||||
|
console.log("onclick", e.nativeEvent);
|
||||||
|
}}
|
||||||
onContextMenu={(e) => handleFileContextMenu(e, row.getValue("path"), row.getValue("mimetype"))}
|
onContextMenu={(e) => handleFileContextMenu(e, row.getValue("path"), row.getValue("mimetype"))}
|
||||||
>
|
>
|
||||||
{row.getVisibleCells().map((cell) => (
|
{row.getVisibleCells().map((cell) => (
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
initGlobalWaveEventSubs,
|
initGlobalWaveEventSubs,
|
||||||
loadConnStatus,
|
loadConnStatus,
|
||||||
pushFlashError,
|
pushFlashError,
|
||||||
|
subscribeToBrowserEvents,
|
||||||
subscribeToConnEvents,
|
subscribeToConnEvents,
|
||||||
} from "@/store/global";
|
} from "@/store/global";
|
||||||
import * as WOS from "@/store/wos";
|
import * as WOS from "@/store/wos";
|
||||||
@ -67,6 +68,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
await loadConnStatus();
|
await loadConnStatus();
|
||||||
initGlobalWaveEventSubs();
|
initGlobalWaveEventSubs();
|
||||||
subscribeToConnEvents();
|
subscribeToConnEvents();
|
||||||
|
subscribeToBrowserEvents();
|
||||||
|
|
||||||
// ensures client/window/workspace are loaded into the cache before rendering
|
// ensures client/window/workspace are loaded into the cache before rendering
|
||||||
const client = await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", clientId));
|
const client = await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", clientId));
|
||||||
|
Loading…
Reference in New Issue
Block a user