mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 23:35:59 +00:00
Merge branch 'master' into develop
This commit is contained in:
13
packages/web/src/utility/contextMenuActivator.ts
Normal file
13
packages/web/src/utility/contextMenuActivator.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export default function contextMenuActivator(node, activator) {
|
||||
const handleContextMenu = async e => {
|
||||
activator.activate();
|
||||
};
|
||||
|
||||
node.addEventListener('contextmenu', handleContextMenu);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('contextmenu', handleContextMenu);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import { getContext } from 'svelte';
|
||||
import { get_current_component, onMount, setContext } from 'svelte/internal';
|
||||
import invalidateCommands from '../commands/invalidateCommands';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
const lastActiveDictionary = {};
|
||||
|
||||
export const isComponentActiveStore = writable((key: string, component) => false as boolean);
|
||||
|
||||
function isParent(parent, child) {
|
||||
while (child && child.activator) {
|
||||
if (parent == child) return true;
|
||||
@@ -54,7 +57,7 @@ export default function createActivator(
|
||||
}
|
||||
|
||||
// console.log('toDelete', toDelete);
|
||||
|
||||
|
||||
for (const del of toDelete) {
|
||||
delete lastActiveDictionary[del];
|
||||
}
|
||||
@@ -63,6 +66,10 @@ export default function createActivator(
|
||||
parentActivatorInstance.activator.activate();
|
||||
}
|
||||
// console.log('Active components', lastActiveDictionary);
|
||||
|
||||
isComponentActiveStore.set((key, component) => {
|
||||
return lastActiveDictionary[key] == component;
|
||||
});
|
||||
};
|
||||
|
||||
const getTabVisible = () => tabVisibleValue;
|
||||
|
||||
Reference in New Issue
Block a user