fix ctrl+click on tab, relates to #91

This commit is contained in:
vcoppe
2024-09-12 11:13:55 +02:00
parent dc76c71ae2
commit 3cc4d569f1
3 changed files with 350 additions and 331 deletions

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { isMac, isSafari } from '$lib/utils';
import { onMount } from 'svelte';
import { _ } from 'svelte-i18n';
@@ -7,12 +8,12 @@
export let ctrl: boolean = false;
export let click: boolean = false;
let isMac = false;
let isSafari = false;
let mac = false;
let safari = false;
onMount(() => {
isMac = navigator.userAgent.toUpperCase().indexOf('MAC') >= 0;
isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
mac = isMac();
safari = isSafari();
});
</script>
@@ -20,7 +21,7 @@
class="ml-auto pl-2 text-xs tracking-widest text-muted-foreground flex flex-row gap-0 items-baseline"
>
<span>{shift ? '⇧' : ''}</span>
<span>{ctrl ? (isMac && !isSafari ? '⌘' : $_('menu.ctrl') + '+') : ''}</span>
<span>{ctrl ? (mac && !safari ? '⌘' : $_('menu.ctrl') + '+') : ''}</span>
<span class={key === '+' ? 'font-medium text-sm/4' : ''}>{key}</span>
<span>{click ? $_('menu.click') : ''}</span>
</div>

View File

@@ -22,6 +22,7 @@
type ListItem
} from './FileList';
import { selection } from './Selection';
import { isMac } from '$lib/utils';
import { _ } from 'svelte-i18n';
export let node:
@@ -77,8 +78,13 @@
if (
e.originalEvent &&
!(e.originalEvent.ctrlKey || e.originalEvent.metaKey || e.originalEvent.shiftKey) &&
($selection.size > 1 || !$selection.has(item.extend(getRealId(changed[0]))))
!(
e.originalEvent.ctrlKey ||
e.originalEvent.metaKey ||
e.originalEvent.shiftKey
) &&
($selection.size > 1 ||
!$selection.has(item.extend(getRealId(changed[0]))))
) {
// Fix bug that sometimes causes a single select to be treated as a multi-select
$selection.clear();
@@ -154,7 +160,7 @@
direction: orientation,
forceAutoScrollFallback: true,
multiDrag: true,
multiDragKey: 'Meta',
multiDragKey: isMac() ? 'Meta' : 'Ctrl',
avoidImplicitDeselect: true,
onSelect: updateToSelection,
onDeselect: updateToSelection,
@@ -191,7 +197,9 @@
fromItems = [fromItem.extend('waypoints')];
} else {
let oldIndices: number[] =
e.oldIndicies.length > 0 ? e.oldIndicies.map((i) => i.index) : [e.oldIndex];
e.oldIndicies.length > 0
? e.oldIndicies.map((i) => i.index)
: [e.oldIndex];
oldIndices = oldIndices.filter((i) => i >= 0);
oldIndices.sort((a, b) => a - b);
@@ -206,7 +214,9 @@
}
let newIndices: number[] =
e.newIndicies.length > 0 ? e.newIndicies.map((i) => i.index) : [e.newIndex];
e.newIndicies.length > 0
? e.newIndicies.map((i) => i.index)
: [e.newIndex];
newIndices = newIndices.filter((i) => i >= 0);
newIndices.sort((a, b) => a - b);

View File

@@ -178,6 +178,14 @@ export function setScissorsCursor() {
setCursor(scissorsCursor);
}
export function isMac() {
return navigator.userAgent.toUpperCase().indexOf('MAC') >= 0;
}
export function isSafari() {
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
}
export function getURLForLanguage(lang: string | null | undefined, path: string): string {
let newPath = path.replace(base, '');
let languageInPath = newPath.split('/')[1];