Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -18,9 +18,10 @@
|
||||
tabActions?: (tab: WorkbenchTab) => ActionMenuItem[];
|
||||
tabDragData?: (tab: WorkbenchTab) => string | undefined;
|
||||
onDropTab?: (data: string, index: number) => void;
|
||||
onDetach?: (tab: WorkbenchTab) => void;
|
||||
};
|
||||
|
||||
let { tabs, activePath, onSelect, onClose, onMove, onCloseTabs, onPin, fileActions, tabActions = () => [], tabDragData = () => undefined, onDropTab }: Props = $props();
|
||||
let { tabs, activePath, onSelect, onClose, onMove, onCloseTabs, onPin, fileActions, tabActions = () => [], tabDragData = () => undefined, onDropTab, onDetach }: Props = $props();
|
||||
const transferType = "application/x-runestone-tab";
|
||||
let bar: HTMLDivElement;
|
||||
let dragged = $state<string | null>(null);
|
||||
@@ -168,6 +169,8 @@
|
||||
cancelDrag();
|
||||
closeMenu();
|
||||
suppressClick = false;
|
||||
const pointerTarget = event.currentTarget as HTMLElement;
|
||||
pointerTarget.setPointerCapture(event.pointerId);
|
||||
const startX = event.clientX, startY = event.clientY, pointerId = event.pointerId;
|
||||
let x = startX, y = startY, started = false, destination: number | null = null, frame = 0;
|
||||
const update = () => {
|
||||
@@ -192,6 +195,7 @@
|
||||
frame = requestAnimationFrame(scroll);
|
||||
};
|
||||
const clean = () => {
|
||||
if (pointerTarget.hasPointerCapture(pointerId)) pointerTarget.releasePointerCapture(pointerId);
|
||||
cancelAnimationFrame(frame);
|
||||
dragged = dropBefore = dropAfter = null;
|
||||
window.removeEventListener("pointermove", onMovePointer);
|
||||
@@ -216,6 +220,10 @@
|
||||
const target = destination;
|
||||
clean();
|
||||
if (started && target !== null) void move(path, target);
|
||||
else if (started && (x < 0 || y < 0 || x > window.innerWidth || y > window.innerHeight)) {
|
||||
const tab = tabs.find(tab => tab.relPath === path);
|
||||
if (tab) onDetach?.(tab);
|
||||
}
|
||||
};
|
||||
const onEscape = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); clean(); }
|
||||
@@ -267,7 +275,11 @@
|
||||
onpointerdown={(event) => { if (!tab.draggable) startDrag(event, tab.relPath); else suppressClick = false; }}
|
||||
draggable={!!tab.draggable}
|
||||
ondragstart={(event) => startTabTransfer(event, tab)}
|
||||
ondragend={finishTabTransfer}
|
||||
ondragend={(event) => {
|
||||
const outside = event.clientX < 0 || event.clientY < 0 || event.clientX > window.innerWidth || event.clientY > window.innerHeight;
|
||||
if (dragged && event.dataTransfer?.dropEffect === "none" && outside) onDetach?.(tab);
|
||||
finishTabTransfer();
|
||||
}}
|
||||
onkeydown={(event) => onKey(event, tab.relPath)}
|
||||
oncontextmenu={(event) => { event.preventDefault(); event.stopPropagation(); showMenu(event.currentTarget, tab.relPath, event.clientX, event.clientY); }}
|
||||
onmousedown={onMiddleDown}
|
||||
@@ -300,7 +312,7 @@
|
||||
min-height: 32px;
|
||||
overflow-x: auto;
|
||||
background: var(--rs-bg-elevated);
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
box-shadow: inset 0 -1px var(--rs-border);
|
||||
}
|
||||
.tabs:empty { min-width: 80px; }
|
||||
.tabs.receiving { box-shadow: inset 0 -2px var(--rs-accent); }
|
||||
@@ -311,17 +323,19 @@
|
||||
align-items: center;
|
||||
max-width: 220px;
|
||||
flex-shrink: 0;
|
||||
border-radius: var(--rs-item-selection-radius);
|
||||
border-radius: var(--rs-item-selection-radius) var(--rs-item-selection-radius) 0 0;
|
||||
border-right: 1px solid var(--rs-border);
|
||||
background: var(--rs-bg);
|
||||
background: transparent;
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
background: var(--rs-item-selection-bg);
|
||||
box-shadow: inset 0 0 0 var(--rs-item-selection-width) var(--rs-item-selection-border);
|
||||
background: var(--rs-bg);
|
||||
border-bottom-color: transparent;
|
||||
}
|
||||
|
||||
.tab:hover { background: var(--rs-bg-active); }
|
||||
.tab:focus-within { box-shadow: inset 0 0 0 var(--rs-item-selection-width) var(--rs-item-selection-border); }
|
||||
.tab:not(.active):hover { background: var(--rs-bg-active); }
|
||||
.tab.dragging { opacity: 0.5; }
|
||||
.tabs:has(.dragging) .tab > button:first-child { cursor: grabbing; }
|
||||
.tab.drop-before::before, .tab.drop-after::after {
|
||||
|
||||
Reference in New Issue
Block a user