mirror of
https://github.com/open-webui/computer.git
synced 2026-11-25 23:00:55 -05:00
refac
This commit is contained in:
1 parent
38235c7523
commit
11f5292d48
6 files changed
+248
-122
No files matched your search
@@ -22,6 +22,7 @@
|
||||
import Spinner from './common/Spinner.svelte';
|
||||
import DropdownMenu from './DropdownMenu.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
import { TAB_DRAG_MIME } from '$lib/constants';
|
||||
|
||||
interface FileEntry {
|
||||
name: string;
|
||||
@@ -573,6 +574,12 @@
|
||||
|
||||
// ── Drag to move ────────────────────────────────────────────
|
||||
|
||||
function isTabDrag(e: DragEvent): boolean {
|
||||
return Boolean(
|
||||
e.dataTransfer?.types.includes(TAB_DRAG_MIME) || e.dataTransfer?.types.includes('text/tab-id')
|
||||
);
|
||||
}
|
||||
|
||||
/** Collect all paths being dragged: either selected items (if the dragged item is selected) or just the single item */
|
||||
function getDraggedPaths(entry: TreeEntry): string[] {
|
||||
if (selectedPaths.size > 0 && selectedPaths.has(entry.path)) {
|
||||
@@ -605,6 +612,8 @@
|
||||
}
|
||||
|
||||
function onDragOverDir(e: DragEvent, entry: TreeEntry) {
|
||||
if (isTabDrag(e)) return;
|
||||
|
||||
// Determine the target folder for this entry
|
||||
let targetDir: string | null;
|
||||
if (entry.type === 'directory') {
|
||||
@@ -665,6 +674,8 @@
|
||||
}
|
||||
|
||||
async function onDropOnDir(e: DragEvent, entry: TreeEntry) {
|
||||
if (isTabDrag(e)) return;
|
||||
|
||||
e.preventDefault();
|
||||
if (dragExpandTimer) {
|
||||
clearTimeout(dragExpandTimer);
|
||||
@@ -744,6 +755,11 @@
|
||||
|
||||
// ── Drop zone for uploads ───────────────────────────────────
|
||||
function onDropzoneOver(e: DragEvent) {
|
||||
if (isTabDrag(e)) {
|
||||
dropzoneActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
if (draggedItem) {
|
||||
// Internal drag — allow drop to move to current directory
|
||||
@@ -762,6 +778,8 @@
|
||||
}
|
||||
|
||||
async function onDropzoneDrop(e: DragEvent) {
|
||||
if (isTabDrag(e)) return;
|
||||
|
||||
e.preventDefault();
|
||||
dropzoneActive = false;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
import { tooltip } from '$lib/tooltip';
|
||||
import { t } from '$lib/i18n';
|
||||
import VoiceMemoModal from './VoiceMemoModal.svelte';
|
||||
import { TAB_DRAG_MIME } from '$lib/constants';
|
||||
|
||||
interface Props {
|
||||
group: EditorGroup;
|
||||
@@ -57,6 +58,8 @@
|
||||
// Drop target highlight for cross-group drag
|
||||
let dropHighlight = $state(false);
|
||||
|
||||
type TabDragPayload = { tabId: string; groupId: string };
|
||||
|
||||
const displayTabs = $derived((group?.tabs ?? []).filter((t) => t.type !== 'git'));
|
||||
|
||||
const isActiveGroup = $derived($activeWorkspace?.activeGroupId === group?.id);
|
||||
@@ -89,6 +92,11 @@
|
||||
closeTab(tabId, group.id);
|
||||
}
|
||||
|
||||
function handleCloseGroup(e: Event) {
|
||||
e.stopPropagation();
|
||||
closeGroup(group.id);
|
||||
}
|
||||
|
||||
function handleContextMenu(e: MouseEvent, tab: Tab) {
|
||||
if (!isWideScreen) return;
|
||||
e.preventDefault();
|
||||
@@ -108,11 +116,31 @@
|
||||
// Native drag handlers are NOT needed. Sortable's setData handles it.
|
||||
// We keep the native drop handlers on the bar for cross-group drops.
|
||||
|
||||
function hasTabDrag(dataTransfer: DataTransfer): boolean {
|
||||
return dataTransfer.types.includes(TAB_DRAG_MIME) || dataTransfer.types.includes('text/tab-id');
|
||||
}
|
||||
|
||||
function readTabDragPayload(dataTransfer: DataTransfer): TabDragPayload | null {
|
||||
const raw = dataTransfer.getData(TAB_DRAG_MIME);
|
||||
if (raw) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as Partial<TabDragPayload>;
|
||||
if (typeof parsed.tabId === 'string' && typeof parsed.groupId === 'string') {
|
||||
return { tabId: parsed.tabId, groupId: parsed.groupId };
|
||||
}
|
||||
} catch {
|
||||
// Fall through to the legacy payload below.
|
||||
}
|
||||
}
|
||||
|
||||
const tabId = dataTransfer.getData('text/tab-id');
|
||||
const groupId = dataTransfer.getData('text/group-id');
|
||||
return tabId && groupId ? { tabId, groupId } : null;
|
||||
}
|
||||
|
||||
function handleBarDragOver(e: DragEvent) {
|
||||
// Only accept tab drags (not file uploads)
|
||||
if (!e.dataTransfer?.types.includes('text/tab-id')) return;
|
||||
const sourceGroupId = e.dataTransfer.types.includes('text/group-id') ? 'unknown' : null;
|
||||
if (!sourceGroupId) return;
|
||||
if (!e.dataTransfer || !hasTabDrag(e.dataTransfer)) return;
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
dropHighlight = true;
|
||||
@@ -125,12 +153,11 @@
|
||||
function handleBarDrop(e: DragEvent) {
|
||||
dropHighlight = false;
|
||||
if (!e.dataTransfer) return;
|
||||
const tabId = e.dataTransfer.getData('text/tab-id');
|
||||
const fromGroupId = e.dataTransfer.getData('text/group-id');
|
||||
if (!tabId || !fromGroupId) return;
|
||||
if (fromGroupId === group.id) return; // same group, ignore
|
||||
const payload = readTabDragPayload(e.dataTransfer);
|
||||
if (!payload) return;
|
||||
if (payload.groupId === group.id) return; // same group, ignore
|
||||
e.preventDefault();
|
||||
moveTabToGroup(tabId, fromGroupId, group.id);
|
||||
moveTabToGroup(payload.tabId, payload.groupId, group.id);
|
||||
}
|
||||
|
||||
const plusMenuItems = $derived([
|
||||
@@ -246,6 +273,7 @@
|
||||
touchStartThreshold: 5,
|
||||
setData: (dataTransfer: DataTransfer, dragEl: HTMLElement) => {
|
||||
const tabId = dragEl.dataset.tabId ?? '';
|
||||
dataTransfer.setData(TAB_DRAG_MIME, JSON.stringify({ tabId, groupId: group.id }));
|
||||
dataTransfer.setData('text/tab-id', tabId);
|
||||
dataTransfer.setData('text/group-id', group.id);
|
||||
},
|
||||
@@ -370,7 +398,7 @@
|
||||
{#if canClose}
|
||||
<button
|
||||
class="flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100 shrink-0"
|
||||
onclick={() => closeGroup(group.id)}
|
||||
onclick={handleCloseGroup}
|
||||
aria-label={$t('a11y.closePane')}
|
||||
use:tooltip={$t('a11y.closePane')}
|
||||
>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
} from '$lib/stores/audio';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
import { TAB_DRAG_MIME } from '$lib/constants';
|
||||
|
||||
// Keep screen awake during voice mode conversations
|
||||
let voiceWakeLock: WakeLockSentinel | null = null;
|
||||
@@ -135,6 +136,12 @@
|
||||
>([]);
|
||||
let isDragging = $state(false);
|
||||
|
||||
function isTabDrag(e: DragEvent): boolean {
|
||||
return Boolean(
|
||||
e.dataTransfer?.types.includes(TAB_DRAG_MIME) || e.dataTransfer?.types.includes('text/tab-id')
|
||||
);
|
||||
}
|
||||
|
||||
async function processFiles(files: File[]) {
|
||||
for (const file of files) {
|
||||
const id = Math.random().toString(36).substring(7);
|
||||
@@ -161,6 +168,8 @@
|
||||
}
|
||||
|
||||
function handleDrop(e: DragEvent) {
|
||||
if (isTabDrag(e)) return;
|
||||
|
||||
e.preventDefault();
|
||||
isDragging = false;
|
||||
if (e.dataTransfer?.files) {
|
||||
@@ -962,6 +971,10 @@
|
||||
ondrop={handleDrop}
|
||||
onpaste={handlePaste}
|
||||
ondragover={(e) => {
|
||||
if (isTabDrag(e)) {
|
||||
isDragging = false;
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
isDragging = true;
|
||||
}}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const TAB_DRAG_MIME = 'application/x-cptr-tab';
|
||||
@@ -214,50 +214,6 @@ export const splitTab = derived(currentWorkspace, ($ws) => {
|
||||
return secondGroup?.tabs.find((t) => t.id === secondGroup.activeTabId) ?? null;
|
||||
});
|
||||
|
||||
/** @deprecated Use splitCurrentTab or openInGroup */
|
||||
export function openTabInSplit(tabId: string, direction?: SplitDirection): void {
|
||||
const ws = get(currentWorkspace);
|
||||
if (!ws) return;
|
||||
|
||||
// If already split, move tab to the other group
|
||||
if (ws.groups.length > 1) {
|
||||
const otherGroup = ws.groups.find((g) => g.id !== ws.activeGroupId);
|
||||
if (otherGroup) {
|
||||
moveTabToGroup(tabId, ws.activeGroupId, otherGroup.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, create a new group with this tab
|
||||
const dir = direction ?? ws.splitDirection ?? 'horizontal';
|
||||
|
||||
// Find the tab in any group
|
||||
let sourceTab: Tab | undefined;
|
||||
for (const g of ws.groups) {
|
||||
sourceTab = g.tabs.find((t) => t.id === tabId);
|
||||
if (sourceTab) break;
|
||||
}
|
||||
if (!sourceTab) return;
|
||||
|
||||
const newTab: Tab = { ...sourceTab, id: nextId(), permanent: false };
|
||||
const newGroup: EditorGroup = {
|
||||
id: nextId(),
|
||||
tabs: [newTab],
|
||||
activeTabId: newTab.id
|
||||
};
|
||||
|
||||
currentWorkspace.update((ws) => {
|
||||
if (!ws) return ws;
|
||||
return {
|
||||
...ws,
|
||||
groups: [...ws.groups, newGroup],
|
||||
activeGroupId: newGroup.id,
|
||||
splitDirection: dir,
|
||||
splitRatio: ws.splitRatio ?? 0.5
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** @deprecated Use closeGroup */
|
||||
export function closeSplitPane(): void {
|
||||
const ws = get(currentWorkspace);
|
||||
@@ -1088,23 +1044,33 @@ export function closeGroup(groupId: string): void {
|
||||
currentWorkspace.update((ws) => {
|
||||
if (!ws) return ws;
|
||||
|
||||
// Clean up terminal sessions in this group
|
||||
const group = ws.groups.find((g) => g.id === groupId);
|
||||
if (group) {
|
||||
group.tabs.forEach((t) => {
|
||||
if (t.type === 'terminal' && t.sessionId) deleteSession(t.sessionId);
|
||||
});
|
||||
}
|
||||
const closingGroup = ws.groups.find((g) => g.id === groupId);
|
||||
const remainingGroups = ws.groups.filter((g) => g.id !== groupId);
|
||||
const targetGroup =
|
||||
remainingGroups.find((g) => g.id === ws.activeGroupId) ?? remainingGroups[0];
|
||||
if (!closingGroup || !targetGroup) return ws;
|
||||
|
||||
const existingTabIds = new Set(targetGroup.tabs.map((t) => t.id));
|
||||
const movedTabs = closingGroup.tabs.filter((t) => !existingTabIds.has(t.id));
|
||||
const tabs = [...targetGroup.tabs, ...movedTabs];
|
||||
const activeTabId =
|
||||
ws.activeGroupId === closingGroup.id && tabs.some((t) => t.id === closingGroup.activeTabId)
|
||||
? closingGroup.activeTabId
|
||||
: targetGroup.activeTabId;
|
||||
const newGroups = remainingGroups.map((g) =>
|
||||
g.id === targetGroup.id
|
||||
? {
|
||||
...g,
|
||||
tabs,
|
||||
activeTabId: tabs.some((t) => t.id === activeTabId) ? activeTabId : (tabs[0]?.id ?? '')
|
||||
}
|
||||
: g
|
||||
);
|
||||
|
||||
let newGroups = ws.groups.filter((g) => g.id !== groupId);
|
||||
if (newGroups.length === 0) {
|
||||
newGroups = [createDefaultGroup()];
|
||||
}
|
||||
const activeGroupStillExists = newGroups.some((g) => g.id === ws.activeGroupId);
|
||||
return {
|
||||
...ws,
|
||||
groups: newGroups,
|
||||
activeGroupId: activeGroupStillExists ? ws.activeGroupId : newGroups[0].id
|
||||
activeGroupId: targetGroup.id
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1134,11 +1100,46 @@ export function moveTabToGroup(tabId: string, fromGroupId: string, toGroupId: st
|
||||
newGroups = newGroups.filter((g) => g.tabs.length > 0);
|
||||
if (newGroups.length === 0) newGroups = [createDefaultGroup()];
|
||||
|
||||
const activeGroupStillExists = newGroups.some((g) => g.id === ws.activeGroupId);
|
||||
const targetGroupStillExists = newGroups.some((g) => g.id === toGroupId);
|
||||
return {
|
||||
...ws,
|
||||
groups: newGroups,
|
||||
activeGroupId: activeGroupStillExists ? ws.activeGroupId : newGroups[0].id
|
||||
activeGroupId: targetGroupStillExists ? toGroupId : newGroups[0].id
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function moveTabToNewSplit(
|
||||
tabId: string,
|
||||
fromGroupId: string,
|
||||
direction: SplitDirection,
|
||||
placement: 'before' | 'after' = 'after'
|
||||
): void {
|
||||
currentWorkspace.update((ws) => {
|
||||
if (!ws || ws.groups.length > 1) return ws;
|
||||
const fromGroup = ws.groups.find((g) => g.id === fromGroupId);
|
||||
if (!fromGroup) return ws;
|
||||
const tab = fromGroup.tabs.find((t) => t.id === tabId);
|
||||
if (!tab || tab.permanent) return ws;
|
||||
|
||||
const newGroup: EditorGroup = {
|
||||
id: nextId(),
|
||||
tabs: [tab],
|
||||
activeTabId: tab.id
|
||||
};
|
||||
let groups = ws.groups.map((g) => {
|
||||
if (g.id !== fromGroupId) return g;
|
||||
const tabs = g.tabs.filter((t) => t.id !== tabId);
|
||||
return { ...g, tabs, activeTabId: tabs[0]?.id ?? '' };
|
||||
});
|
||||
groups = groups.filter((g) => g.tabs.length > 0);
|
||||
|
||||
return {
|
||||
...ws,
|
||||
groups: placement === 'before' ? [newGroup, ...groups] : [...groups, newGroup],
|
||||
activeGroupId: newGroup.id,
|
||||
splitDirection: direction,
|
||||
splitRatio: ws.splitRatio ?? 0.5
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
gitReviewOpen,
|
||||
setActiveGroup,
|
||||
setSplitRatio,
|
||||
openTabInSplit,
|
||||
setSplitDirection,
|
||||
moveTabToNewSplit,
|
||||
openChatTab,
|
||||
openFileTab,
|
||||
openTerminalTab,
|
||||
@@ -20,7 +19,7 @@
|
||||
showSearch,
|
||||
pwaPreferences
|
||||
} from '$lib/stores';
|
||||
import type { Tab, EditorGroup, WorkspaceState } from '$lib/stores';
|
||||
import type { Tab, EditorGroup, SplitDirection, WorkspaceState } from '$lib/stores';
|
||||
import { t } from '$lib/i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import { getWelcome, getWorkspaceState } from '$lib/apis/state';
|
||||
@@ -40,6 +39,7 @@
|
||||
import Icon from '$lib/components/Icon.svelte';
|
||||
import WorkspacePicker from '$lib/components/WorkspacePicker.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { TAB_DRAG_MIME } from '$lib/constants';
|
||||
import { isSupportedWorkspacePath } from '$lib/utils/paths';
|
||||
|
||||
let showPicker = $state(false);
|
||||
@@ -639,27 +639,78 @@
|
||||
|
||||
// ── Drag-to-split ─────────────────────────────────────────────
|
||||
|
||||
let dragOverZone = $state<'right' | 'bottom' | null>(null);
|
||||
const SPLIT_EDGE_FRACTION = 0.3;
|
||||
|
||||
type SplitDropZone = 'left' | 'right' | 'top' | 'bottom';
|
||||
type TabDragPayload = { tabId: string; groupId: string };
|
||||
|
||||
let dragOverZone = $state<SplitDropZone | null>(null);
|
||||
|
||||
function hasTabDrag(dataTransfer: DataTransfer): boolean {
|
||||
return dataTransfer.types.includes(TAB_DRAG_MIME) || dataTransfer.types.includes('text/tab-id');
|
||||
}
|
||||
|
||||
function readTabDragPayload(dataTransfer: DataTransfer): TabDragPayload | null {
|
||||
const raw = dataTransfer.getData(TAB_DRAG_MIME);
|
||||
if (raw) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as Partial<TabDragPayload>;
|
||||
if (typeof parsed.tabId === 'string' && typeof parsed.groupId === 'string') {
|
||||
return { tabId: parsed.tabId, groupId: parsed.groupId };
|
||||
}
|
||||
} catch {
|
||||
// Fall through to the legacy payload below.
|
||||
}
|
||||
}
|
||||
|
||||
const tabId = dataTransfer.getData('text/tab-id');
|
||||
const groupId = dataTransfer.getData('text/group-id');
|
||||
return tabId && groupId ? { tabId, groupId } : null;
|
||||
}
|
||||
|
||||
function getSplitDropZone(e: DragEvent): SplitDropZone | null {
|
||||
if (!containerEl || !isWideScreen || hasSplit || !e.dataTransfer) return null;
|
||||
if (e.dataTransfer.types.includes('Files') || !hasTabDrag(e.dataTransfer)) return null;
|
||||
|
||||
const rect = containerEl.getBoundingClientRect();
|
||||
if (
|
||||
e.clientX < rect.left ||
|
||||
e.clientX > rect.right ||
|
||||
e.clientY < rect.top ||
|
||||
e.clientY > rect.bottom
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const horizontalBand = rect.width * SPLIT_EDGE_FRACTION;
|
||||
const verticalBand = rect.height * SPLIT_EDGE_FRACTION;
|
||||
const leftDistance = e.clientX - rect.left;
|
||||
const rightDistance = rect.right - e.clientX;
|
||||
const topDistance = e.clientY - rect.top;
|
||||
const bottomDistance = rect.bottom - e.clientY;
|
||||
const candidates: { zone: SplitDropZone; distance: number }[] = [];
|
||||
|
||||
if (leftDistance <= horizontalBand) candidates.push({ zone: 'left', distance: leftDistance });
|
||||
if (rightDistance <= horizontalBand)
|
||||
candidates.push({ zone: 'right', distance: rightDistance });
|
||||
if (topDistance <= verticalBand) candidates.push({ zone: 'top', distance: topDistance });
|
||||
if (bottomDistance <= verticalBand)
|
||||
candidates.push({ zone: 'bottom', distance: bottomDistance });
|
||||
|
||||
candidates.sort((a, b) => a.distance - b.distance);
|
||||
return candidates[0]?.zone ?? null;
|
||||
}
|
||||
|
||||
function handleContainerDragOver(e: DragEvent) {
|
||||
if (!containerEl || !isWideScreen) return;
|
||||
// Only respond to tab drags, not file uploads
|
||||
if (!e.dataTransfer?.types.includes('text/tab-id')) return;
|
||||
// Only show drop zones when not already split
|
||||
if (hasSplit) return;
|
||||
const zone = getSplitDropZone(e);
|
||||
if (!zone) {
|
||||
dragOverZone = null;
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
const rect = containerEl.getBoundingClientRect();
|
||||
const xRatio = (e.clientX - rect.left) / rect.width;
|
||||
const yRatio = (e.clientY - rect.top) / rect.height;
|
||||
|
||||
if (xRatio > 0.75) {
|
||||
dragOverZone = 'right';
|
||||
} else if (yRatio > 0.75) {
|
||||
dragOverZone = 'bottom';
|
||||
} else {
|
||||
dragOverZone = null;
|
||||
}
|
||||
e.dataTransfer!.dropEffect = 'move';
|
||||
dragOverZone = zone;
|
||||
}
|
||||
|
||||
function handleContainerDragLeave(e: DragEvent) {
|
||||
@@ -670,36 +721,24 @@
|
||||
}
|
||||
|
||||
function handleContainerDrop(e: DragEvent) {
|
||||
if (!dragOverZone || !e.dataTransfer) {
|
||||
dragOverZone = null;
|
||||
return;
|
||||
}
|
||||
// Don't intercept file uploads
|
||||
if (e.dataTransfer.types.includes('Files')) {
|
||||
const zone = dragOverZone ?? getSplitDropZone(e);
|
||||
|
||||
if (!zone || !e.dataTransfer) {
|
||||
dragOverZone = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const tabId = e.dataTransfer.getData('text/tab-id');
|
||||
const fromGroupId = e.dataTransfer.getData('text/group-id');
|
||||
if (!tabId || !fromGroupId) {
|
||||
const payload = readTabDragPayload(e.dataTransfer);
|
||||
if (!payload) {
|
||||
dragOverZone = null;
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
const direction = dragOverZone === 'right' ? 'horizontal' : 'vertical';
|
||||
setSplitDirection(direction as any);
|
||||
|
||||
// Move the dragged tab into a new split pane
|
||||
const ws = $currentWorkspace;
|
||||
if (ws) {
|
||||
const sourceGroup = ws.groups.find((g) => g.id === fromGroupId);
|
||||
const tab = sourceGroup?.tabs.find((t) => t.id === tabId);
|
||||
if (tab) {
|
||||
openTabInSplit(tabId, direction as any);
|
||||
}
|
||||
}
|
||||
const direction: SplitDirection =
|
||||
zone === 'left' || zone === 'right' ? 'horizontal' : 'vertical';
|
||||
const placement = zone === 'left' || zone === 'top' ? 'before' : 'after';
|
||||
moveTabToNewSplit(payload.tabId, payload.groupId, direction, placement);
|
||||
dragOverZone = null;
|
||||
}
|
||||
</script>
|
||||
@@ -883,6 +922,7 @@
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="split-pane"
|
||||
class:split-pane-single={!hasSplit}
|
||||
style={hasSplit
|
||||
? splitDirection === 'horizontal'
|
||||
? `width: ${i === 0 ? splitRatio * 100 : (1 - splitRatio) * 100}%;`
|
||||
@@ -943,9 +983,15 @@
|
||||
{/each}
|
||||
|
||||
<!-- Drop zone indicators for drag-to-split -->
|
||||
{#if dragOverZone === 'left'}
|
||||
<div class="split-drop-zone split-drop-left"></div>
|
||||
{/if}
|
||||
{#if dragOverZone === 'right'}
|
||||
<div class="split-drop-zone split-drop-right"></div>
|
||||
{/if}
|
||||
{#if dragOverZone === 'top'}
|
||||
<div class="split-drop-zone split-drop-top"></div>
|
||||
{/if}
|
||||
{#if dragOverZone === 'bottom'}
|
||||
<div class="split-drop-zone split-drop-bottom"></div>
|
||||
{/if}
|
||||
@@ -1003,8 +1049,8 @@
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* Single pane takes all space */
|
||||
.split-pane:only-child {
|
||||
/* Single pane takes all space even while preview overlays are mounted. */
|
||||
.split-pane-single {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -1097,24 +1143,43 @@
|
||||
.split-drop-zone {
|
||||
position: absolute;
|
||||
z-index: 15;
|
||||
background: oklch(0.65 0.15 250 / 0.08);
|
||||
border: 0.125rem dashed oklch(0.65 0.15 250 / 0.3);
|
||||
border-radius: 0.5rem;
|
||||
display: block;
|
||||
flex: none;
|
||||
contain: layout paint;
|
||||
pointer-events: none;
|
||||
--split-tabbar-height: 2.25rem;
|
||||
background: color-mix(in oklab, var(--app-fg) 6%, transparent);
|
||||
box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--app-fg) 16%, transparent);
|
||||
}
|
||||
|
||||
.split-drop-left,
|
||||
.split-drop-right {
|
||||
top: var(--split-tabbar-height);
|
||||
bottom: 0;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.split-drop-left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.split-drop-right {
|
||||
top: 0.5rem;
|
||||
right: 0.5rem;
|
||||
bottom: 0.5rem;
|
||||
width: 45%;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.split-drop-top,
|
||||
.split-drop-bottom {
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: calc((100% - var(--split-tabbar-height)) / 2);
|
||||
}
|
||||
|
||||
.split-drop-top {
|
||||
top: var(--split-tabbar-height);
|
||||
}
|
||||
|
||||
.split-drop-bottom {
|
||||
left: 0.5rem;
|
||||
right: 0.5rem;
|
||||
bottom: 0.5rem;
|
||||
height: 45%;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
/* ── Persisted file editor tabs ────────────────────── */
|
||||
|
||||
Reference in new issue
Block a user