TagSpaces is an offline, open source, document manager with tagging support
Integrate new splitter component (#2437)
Ilian08262f843b76
diff --git a/package-lock.json b/package-lock.jsonindex 78f3cffa4..1707b090c 100644--- a/package-lock.json+++ b/package-lock.json@@ -77,7 +77,6 @@"semver": "7.7.4","swiper": "12.1.3","tga-js": "1.1.1",- "ts-react-splitter": "3.0.0","utif.ts": "3.1.1","uuid": "13.0.0","zod": "3.25.67",@@ -27392,10 +27391,6 @@"url": "https://github.com/sponsors/ljharb"}},- "node_modules/get-node-dimensions": {- "version": "1.2.1",- "license": "MIT"- },"node_modules/get-package-type": {"version": "0.1.0","license": "MIT",@@ -36163,20 +36158,6 @@"react-leaflet": "^4.0.0"}},- "node_modules/react-measure": {- "version": "2.5.2",- "license": "MIT",- "dependencies": {- "@babel/runtime": "^7.2.0",- "get-node-dimensions": "^1.2.1",- "prop-types": "^15.6.2",- "resize-observer-polyfill": "^1.5.0"- },- "peerDependencies": {- "react": ">0.13.0",- "react-dom": ">0.13.0"- }- },"node_modules/react-qrcode-logo": {"version": "2.10.0","license": "MIT",@@ -39370,17 +39351,6 @@"node": ">=0.4.0"}},- "node_modules/ts-react-splitter": {- "version": "3.0.0",- "license": "MIT",- "dependencies": {- "react-measure": "^2.5.2"- },- "peerDependencies": {- "react": ">=16.13.1",- "react-dom": ">=16.13.1"- }- },"node_modules/tsconfig-paths": {"version": "3.15.0","dev": true,diff --git a/package.json b/package.jsonindex 66cf0d408..1add4c183 100644--- a/package.json+++ b/package.json@@ -235,7 +235,6 @@"semver": "7.7.4","swiper": "12.1.3","tga-js": "1.1.1",- "ts-react-splitter": "3.0.0","utif.ts": "3.1.1","uuid": "13.0.0","zod": "3.25.67",diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsxindex 500b82980..505bfa6cc 100644--- a/src/renderer/components/EntryContainer.tsx+++ b/src/renderer/components/EntryContainer.tsx@@ -21,6 +21,7 @@ import EntryContainerNav from '-/components/EntryContainerNav';import EntryContainerTabs from '-/components/EntryContainerTabs';import EntryContainerTitle from '-/components/EntryContainerTitle';import FileView from '-/components/FileView';+import { Splitter } from '-/components/Splitter';import { useResolveConflictContext } from '-/components/dialogs/hooks/useResolveConflictContext';import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';@@ -33,14 +34,16 @@ import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsConteimport { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';import { AppDispatch } from '-/reducers/app';import {+ actions as SettingsActions,getEntryContainerTab,+ getEntrySplitSize,getKeyBindingObject,isDesktopMode,} from '-/reducers/settings';import { getResizedImageThumbnail } from '-/services/thumbsgenerator';import { TS } from '-/tagspaces.namespace';import { base64ToUint8Array } from '-/utils/dom';-import { Tooltip, useMediaQuery } from '@mui/material';+import { useMediaQuery } from '@mui/material';import Box from '@mui/material/Box';import { useTheme } from '@mui/material/styles';import { extractContainingDirectoryPath } from '@tagspaces/tagspaces-common/paths';@@ -82,19 +85,18 @@ function EntryContainer() {const desktopMode = useSelector(isDesktopMode);const theme = useTheme();const timer = useRef<NodeJS.Timeout>(null);- const isDraggingRef = useRef<boolean>(false);- const startYRef = useRef<number>(0);- const startHeightRef = useRef<number>(0);- const storageBufferRef = useRef<number | null>(null);- const storageTimerRef = useRef<NodeJS.Timeout | null>(null);- const [entryPropertiesHeight, setEntryPropertiesHeight] = useState<number>(- parseFloat(localStorage.getItem('tsEntryPropertiesHeight') || '200'),- );+ const propsSize = useSelector(getEntrySplitSize);+ const setPropsSize = (size: number) =>+ dispatch(SettingsActions.setEntryPropertiesSplitSize(size));++ // One-shot cleanup: the old localStorage key stored a broken "flex-basis %"+ // value interpolated as e.g. `flex: '1 1 200%'`. New storage is pixels in Redux.+ useEffect(() => {+ if (localStorage.getItem('tsEntryPropertiesHeight') != null) {+ localStorage.removeItem('tsEntryPropertiesHeight');+ }+ }, []);- const openedPanelStyle: React.CSSProperties = {- display: 'flex',- flexDirection: 'column',- };const [isPanelOpened, setPanelOpened] = useState<boolean>(tabIndex !== TabNames.closedTabs,);@@ -514,89 +516,6 @@ function EntryContainer() {setActions(action);};- const toggleEntryPropertiesHeight = () => {- if (desktopMode) return;- let newHeight: number;- if (entryPropertiesHeight === 100) {- newHeight = 200;- } else if (entryPropertiesHeight === 200) {- newHeight = 350;- } else if (entryPropertiesHeight === 350) {- newHeight = 50;- } else if (entryPropertiesHeight === 50) {- newHeight = 100;- } else {- newHeight = 200;- }- setEntryPropertiesHeight(newHeight);- localStorage.setItem('tsEntryPropertiesHeight', newHeight.toString());- };-- const handleSeparatorMouseDown = (e: React.PointerEvent<HTMLDivElement>) => {- if (!desktopMode) return;- const target = e.currentTarget as HTMLDivElement;- isDraggingRef.current = true;- startYRef.current = e.clientY;- startHeightRef.current = entryPropertiesHeight;- target.setPointerCapture(e.pointerId);-- const handleGlobalPointerMove = (moveEvent: PointerEvent) => {- if (!isDraggingRef.current) return;-- const delta = moveEvent.clientY - startYRef.current;- const containerHeight =- fileViewerContainer.current?.parentElement?.clientHeight ||- window.innerHeight;- const newHeightPercent = Math.max(- 10,- Math.min(200, startHeightRef.current + (delta / containerHeight) * 100),- );- setEntryPropertiesHeight(newHeightPercent);-- // Buffer the localStorage write- storageBufferRef.current = newHeightPercent;-- // Clear existing timer- if (storageTimerRef.current) {- clearTimeout(storageTimerRef.current);- }-- // Debounce localStorage write by 100ms- storageTimerRef.current = setTimeout(flushStorageBuffer, 100);- };-- document.addEventListener('pointermove', handleGlobalPointerMove);-- const handlePointerUp = () => {- document.removeEventListener('pointermove', handleGlobalPointerMove);- document.removeEventListener('pointerup', handlePointerUp);- };-- document.addEventListener('pointerup', handlePointerUp);- };-- const flushStorageBuffer = () => {- if (storageBufferRef.current !== null) {- localStorage.setItem(- 'tsEntryPropertiesHeight',- storageBufferRef.current.toString(),- );- storageBufferRef.current = null;- }- };-- const handleSeparatorMouseUp = (e: React.PointerEvent<HTMLDivElement>) => {- isDraggingRef.current = false;- const target = e.currentTarget as HTMLDivElement;- target.releasePointerCapture(e.pointerId);-- // Flush any pending buffer on mouse up- if (storageTimerRef.current) {- clearTimeout(storageTimerRef.current);- }- flushStorageBuffer();- };-const tabsElement = useMemo(() => (<EntryContainerTabs@@ -639,93 +558,91 @@ function EntryContainer() {toggleFullScreen: keyBindings.toggleFullScreen,}}>- <Box- sx={{- height: '100%',- ...(isPanelOpened && openedPanelStyle),- }}- >- <Box- sx={{- width: '100%',- flexDirection: 'column',- flex: '1 1 ' + entryPropertiesHeight + '%',- display: 'flex',- backgroundColor: theme.palette.background.default,- overflow: 'hidden',- marginBottom: '1px',- }}- >+ {(() => {+ const topPane = (<Boxsx={{- paddingLeft: 0,- paddingRight: '55px',- paddingTop: 0,- minHeight: '48px',+ width: '100%',display: 'flex',- flexDirection: 'row',- justifyContent: 'flex-start',+ flexDirection: 'column',+ height: '100%',+ backgroundColor: theme.palette.background.default,+ overflow: 'hidden',}}>- <EntryContainerTitle- reloadDocument={reloadDocument}- startClosingEntry={startClosingEntry}- isEntryInFullWidth={isEntryInFullWidth}- fileViewerContainer={fileViewerContainer.current}- desktopMode={desktopMode}- smallScreen={smallScreen}- />- <EntryContainerNav- isFile={openedEntry.isFile}- startClosingEntry={startClosingEntry}- smallScreen={smallScreen}- />+ <Box+ sx={{+ paddingLeft: 0,+ paddingRight: '55px',+ paddingTop: 0,+ minHeight: '48px',+ display: 'flex',+ flexDirection: 'row',+ justifyContent: 'flex-start',+ }}+ >+ <EntryContainerTitle+ reloadDocument={reloadDocument}+ startClosingEntry={startClosingEntry}+ isEntryInFullWidth={isEntryInFullWidth}+ fileViewerContainer={fileViewerContainer.current}+ desktopMode={desktopMode}+ smallScreen={smallScreen}+ />+ <EntryContainerNav+ isFile={openedEntry.isFile}+ startClosingEntry={startClosingEntry}+ smallScreen={smallScreen}+ />+ </Box>+ {tabsElement}</Box>- {tabsElement}- {openedEntry.isFile && isPanelOpened && (- <Tooltip title={desktopMode ? '' : t('core:togglePreviewSize')}>- <Box- sx={{- textAlign: 'center',- minHeight: '8px',- paddingTop: '2px',- backgroundColor: 'background.default',- borderBottom: '1px solid ' + theme.palette.divider,- cursor: 'row-resize',- userSelect: 'none',- '&:hover': {- backgroundColor: theme.palette.action.hover,- },- }}- onClick={toggleEntryPropertiesHeight}- onPointerDown={handleSeparatorMouseDown}- onPointerUp={handleSeparatorMouseUp}- onPointerCancel={handleSeparatorMouseUp}- >- <Box- sx={{- width: '10%',- border: '1px dashed ' + theme.palette.text.secondary,- margin: '2px auto',- pointerEvents: 'none',- }}- ></Box>- </Box>- </Tooltip>- )}- </Box>- {openedEntry.isFile && (+ );++ const fileView = openedEntry.isFile ? (<FileViewkey="FileViewID"fileViewer={fileViewer}fileViewerContainer={fileViewerContainer}- height={- tabIndex !== TabNames.closedTabs ? '100%' : 'calc(100% - 100px)'- }+ height="100%"handleMessage={handleMessage}/>- )}- </Box>+ ) : null;++ if (openedEntry.isFile && isPanelOpened) {+ return (+ <Box sx={{ height: '100%' }}>+ <Splitter+ direction="horizontal"+ size={propsSize}+ min={150}+ defaultSize={200}+ onChange={setPropsSize}+ ariaLabel={t('core:togglePreviewSize')}+ >+ {topPane}+ {fileView}+ </Splitter>+ </Box>+ );+ }++ // Panel closed or folder entry — simple column layout, no splitter.+ return (+ <Box+ sx={{+ height: '100%',+ display: 'flex',+ flexDirection: 'column',+ }}+ >+ <Box sx={{ flex: '0 0 auto' }}>{topPane}</Box>+ {fileView && (+ <Box sx={{ flex: '1 1 auto', minHeight: 0 }}>{fileView}</Box>+ )}+ </Box>+ );+ })()}</GlobalHotKeys>);}diff --git a/src/renderer/components/HelpFeedbackPanel.tsx b/src/renderer/components/HelpFeedbackPanel.tsxindex 6a93a7ffd..df21d369a 100644--- a/src/renderer/components/HelpFeedbackPanel.tsx+++ b/src/renderer/components/HelpFeedbackPanel.tsx@@ -81,7 +81,7 @@ function HelpFeedbackPanel(props: Props) {display: 'flex',flexDirection: 'column',paddingLeft: '5px',- paddingRight: 0,+ paddingRight: '5px',height: '100%',}}>diff --git a/src/renderer/components/LocationManager.tsx b/src/renderer/components/LocationManager.tsxindex cb2a523ea..628845a4c 100644--- a/src/renderer/components/LocationManager.tsx+++ b/src/renderer/components/LocationManager.tsx@@ -17,6 +17,7 @@*/import LocationView from '-/components/LocationView';+import TsButton from '-/components/TsButton';import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';import LocationContextMenu from '-/components/menus/LocationContextMenu';import LocationManagerMenu from '-/components/menus/LocationManagerMenu';@@ -25,10 +26,9 @@ import { Pro } from '-/pro';import { getLocations } from '-/reducers/locations';import { TS } from '-/tagspaces.namespace';import { Box, List, Typography } from '@mui/material';-import TsButton from '-/components/TsButton';import { useContext, useEffect, useRef, useState } from 'react';-import { useTranslation } from 'react-i18next';import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';+import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';interface Props {@@ -117,7 +117,8 @@ function LocationManager(props: Props) {flexDirection: 'column',height: '100%',paddingLeft: '5px',- paddingRight: 0,+ paddingRight: '5px',+ position: 'relative',}}>{currentLocation &&@@ -139,7 +140,8 @@ function LocationManager(props: Props) {position: 'absolute',zIndex: 1000,height: 'calc(100% - 150px)',- width: 310,+ left: 0,+ right: 0,backdropFilter: 'grayscale(1)',animation: 'hide 1ms linear 5s 1 forwards',}}@@ -161,7 +163,7 @@ function LocationManager(props: Props) {data-tid="locationList"sx={{height: 'calc(100% - ' + reduceHeightBy + 'px)',- width: '310px',+ width: '100%',borderRadius: '5px',paddingTop: 0,marginTop: 0,diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsxindex c218897d4..9db98280b 100644--- a/src/renderer/components/MobileNavigation.tsx+++ b/src/renderer/components/MobileNavigation.tsx@@ -98,6 +98,7 @@ import UserDetailsPopover from './UserDetailsPopover';interface Props {hideDrawer?: () => void;width?: number;+ widthVar?: string;}function MobileNavigation(props: Props) {@@ -123,7 +124,10 @@ function MobileNavigation(props: Props) {const [showTeaserBanner, setShowTeaserBanner] = useState(true);const [anchorUser, setAnchorUser] = useState<HTMLButtonElement | null>(null);const showProTeaser = !hideProFeatures && !Pro && showTeaserBanner;- const { hideDrawer, width } = props;+ const { hideDrawer, width, widthVar } = props;+ const widthValue = widthVar+ ? `var(${widthVar}, ${width || 320}px)`+ : width || 320;const switchTheme = useCallback(() => dispatch(SettingsActions.switchTheme()),[dispatch],@@ -207,8 +211,8 @@ function MobileNavigation(props: Props) {backdropFilter: 'blur(5px)',height: '100%',overflow: 'hidden',- width: width || 320,- maxWidth: width || 320,+ width: widthValue,+ maxWidth: widthValue,}}><Boxdiff --git a/src/renderer/components/RenderHistory.tsx b/src/renderer/components/RenderHistory.tsxindex 7eac2cad1..de88e279f 100644--- a/src/renderer/components/RenderHistory.tsx+++ b/src/renderer/components/RenderHistory.tsx@@ -172,7 +172,7 @@ function RenderHistory({return (<ListItemdense- sx={{ paddingLeft: 0, height: 40 }}+ sx={{ paddingLeft: 0, height: 40, gap: '4px' }}key={item.creationTimeStamp}><TsButton@@ -182,8 +182,8 @@ function RenderHistory({textTransform: 'none',fontWeight: 'normal',justifyContent: 'start',- minWidth: 260,- maxWidth: 260,+ flex: 1,+ minWidth: 0,}}onClick={() => openHistoryItem(item as TS.HistoryItem)}>@@ -213,8 +213,10 @@ function RenderHistory({whiteSpace: 'nowrap',textOverflow: 'ellipsis',overflow: 'hidden',- maxWidth: 220,+ flex: 1,+ minWidth: 0,marginLeft: '5px',+ textAlign: 'left',}}>{itemName}diff --git a/src/renderer/components/Splitter.tsx b/src/renderer/components/Splitter.tsxnew file mode 100644index 000000000..b9e02954e--- /dev/null+++ b/src/renderer/components/Splitter.tsx@@ -0,0 +1,364 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2026-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import Box from '@mui/material/Box';+import { useTheme } from '@mui/material/styles';+import React, { useEffect, useRef } from 'react';++/** Shared visual constants for every gutter in the app. */+export const GUTTER_VISIBLE_SIZE = 1;+export const GUTTER_HIT_SIZE = 14;+export const GUTTER_HOVER_SIZE = 4;++export interface SplitterGutterProps {+ direction: 'vertical' | 'horizontal';+ disabled?: boolean;+ ariaLabel?: string;+ ariaValueNow?: number;+ ariaValueMin?: number;+ ariaValueMax?: number;+ onPointerDown: (e: React.PointerEvent) => void;+ onPointerMove: (e: React.PointerEvent) => void;+ onPointerUp: (e: React.PointerEvent) => void;+ onDoubleClick?: () => void;+ onKeyDown?: (e: React.KeyboardEvent) => void;+ /** Extra positioning (absolute for overlay cases, e.g. Drawer). */+ style?: React.CSSProperties;+}++/**+ * The single visual/ARIA primitive every splitter in the app uses.+ * One look, one feel: a 1 px divider that thickens to 4 px with accent+ * colour on hover/focus, with a 14 px invisible hit area around it.+ */+export function SplitterGutter(props: SplitterGutterProps) {+ const {+ direction,+ disabled,+ ariaLabel,+ ariaValueNow,+ ariaValueMin,+ ariaValueMax,+ onPointerDown,+ onPointerMove,+ onPointerUp,+ onDoubleClick,+ onKeyDown,+ style,+ } = props;+ const theme = useTheme();+ const isVert = direction === 'vertical';++ const dividerColor = theme.palette.divider;+ const hoverColor = theme.palette.primary.main;++ const hitOverflow = (GUTTER_HIT_SIZE - GUTTER_VISIBLE_SIZE) / 2;++ return (+ <Box+ role="separator"+ aria-orientation={isVert ? 'vertical' : 'horizontal'}+ aria-valuenow={ariaValueNow}+ aria-valuemin={ariaValueMin}+ aria-valuemax={ariaValueMax}+ aria-label={ariaLabel}+ aria-disabled={disabled || undefined}+ tabIndex={disabled ? -1 : 0}+ onPointerDown={onPointerDown}+ onPointerMove={onPointerMove}+ onPointerUp={onPointerUp}+ onPointerCancel={onPointerUp}+ onLostPointerCapture={onPointerUp}+ onDoubleClick={onDoubleClick}+ onKeyDown={onKeyDown}+ sx={{+ position: 'relative',+ cursor: disabled ? 'default' : isVert ? 'col-resize' : 'row-resize',+ touchAction: 'none',+ outline: 'none',+ ...(isVert+ ? { width: GUTTER_VISIBLE_SIZE + 'px', height: '100%' }+ : { height: GUTTER_VISIBLE_SIZE + 'px', width: '100%' }),+ // invisible hit area via ::before+ '&::before': {+ content: '""',+ position: 'absolute',+ background: 'transparent',+ ...(isVert+ ? {+ top: 0,+ bottom: 0,+ left: -hitOverflow + 'px',+ right: -hitOverflow + 'px',+ }+ : {+ left: 0,+ right: 0,+ top: -hitOverflow + 'px',+ bottom: -hitOverflow + 'px',+ }),+ },+ // visible divider via ::after — animates to hoverColor/thicker+ '&::after': {+ content: '""',+ position: 'absolute',+ inset: 0,+ background: dividerColor,+ pointerEvents: 'none',+ transition:+ 'background-color 120ms ease, width 120ms ease, height 120ms ease, left 120ms ease, top 120ms ease',+ },+ '&:hover::after, &:focus-visible::after, &[data-dragging="true"]::after':+ {+ background: hoverColor,+ ...(isVert+ ? {+ width: GUTTER_HOVER_SIZE + 'px',+ left: -(GUTTER_HOVER_SIZE - GUTTER_VISIBLE_SIZE) / 2 + 'px',+ }+ : {+ height: GUTTER_HOVER_SIZE + 'px',+ top: -(GUTTER_HOVER_SIZE - GUTTER_VISIBLE_SIZE) / 2 + 'px',+ }),+ },+ ...style,+ }}+ />+ );+}++export interface SplitterProps {+ direction: 'vertical' | 'horizontal';+ size: number;+ onChange: (size: number) => void;+ onResize?: (size: number) => void;+ min?: number;+ max?: number;+ defaultSize?: number;+ disabled?: boolean;+ hidden?: boolean;+ hiddenTake?: 'primary' | 'secondary';+ ariaLabel?: string;+ children: [React.ReactNode, React.ReactNode];+}++export function Splitter(props: SplitterProps) {+ const {+ direction,+ size,+ onChange,+ onResize,+ min = 150,+ max,+ defaultSize,+ disabled,+ hidden,+ hiddenTake = 'primary',+ ariaLabel,+ children: [primary, secondary],+ } = props;++ const isVert = direction === 'vertical';+ const rootRef = useRef<HTMLDivElement>(null);+ const liveSizeRef = useRef<number>(size);+ const dragRef = useRef<{+ startPos: number;+ startSize: number;+ lo: number;+ hi: number;+ } | null>(null);+ const rafRef = useRef<number | null>(null);+ const overlayRef = useRef<HTMLDivElement | null>(null);++ useEffect(() => {+ liveSizeRef.current = size;+ rootRef.current?.style.setProperty('--sp-size', size + 'px');+ }, [size]);++ const measureBounds = (): { lo: number; hi: number } => {+ const rect = rootRef.current?.getBoundingClientRect();+ const total = rect ? (isVert ? rect.width : rect.height) : 0;+ const lo = min;+ const hi = max ?? Math.max(min, total - min - GUTTER_VISIBLE_SIZE);+ return { lo, hi };+ };++ const clampTo = (v: number, lo: number, hi: number) =>+ Math.max(lo, Math.min(hi, v));++ const writeLive = (v: number) => {+ liveSizeRef.current = v;+ if (rafRef.current != null) return;+ rafRef.current = requestAnimationFrame(() => {+ rafRef.current = null;+ rootRef.current?.style.setProperty(+ '--sp-size',+ liveSizeRef.current + 'px',+ );+ onResize?.(liveSizeRef.current);+ });+ };++ const mountOverlay = () => {+ if (overlayRef.current) return;+ const div = document.createElement('div');+ div.style.cssText = `+ position:fixed;inset:0;z-index:99999;cursor:${+ isVert ? 'col-resize' : 'row-resize'+ };+ background:transparent;+ `;+ document.body.appendChild(div);+ overlayRef.current = div;+ };++ const unmountOverlay = () => {+ if (overlayRef.current) {+ document.body.removeChild(overlayRef.current);+ overlayRef.current = null;+ }+ };++ const setDraggingAttr = (on: boolean) => {+ const gutterEl = rootRef.current?.querySelector(+ '[role="separator"]',+ ) as HTMLElement | null;+ if (gutterEl) {+ if (on) gutterEl.setAttribute('data-dragging', 'true');+ else gutterEl.removeAttribute('data-dragging');+ }+ };++ const onPointerDown = (e: React.PointerEvent) => {+ if (disabled || hidden) return;+ const { lo, hi } = measureBounds();+ dragRef.current = {+ startPos: isVert ? e.clientX : e.clientY,+ startSize: liveSizeRef.current,+ lo,+ hi,+ };+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);+ document.body.style.cursor = isVert ? 'col-resize' : 'row-resize';+ document.body.style.userSelect = 'none';+ mountOverlay();+ setDraggingAttr(true);+ };++ const onPointerMove = (e: React.PointerEvent) => {+ const d = dragRef.current;+ if (!d) return;+ const pos = isVert ? e.clientX : e.clientY;+ writeLive(clampTo(d.startSize + (pos - d.startPos), d.lo, d.hi));+ };++ const finishDrag = (e: React.PointerEvent) => {+ if (!dragRef.current) return;+ dragRef.current = null;+ try {+ (e.currentTarget as HTMLElement).releasePointerCapture(e.pointerId);+ } catch {+ /* capture may already be released */+ }+ document.body.style.cursor = '';+ document.body.style.userSelect = '';+ unmountOverlay();+ setDraggingAttr(false);+ onChange(liveSizeRef.current);+ };++ const onDoubleClick = () => {+ if (defaultSize == null || disabled || hidden) return;+ const { lo, hi } = measureBounds();+ onChange(clampTo(defaultSize, lo, hi));+ };++ const onKeyDown = (e: React.KeyboardEvent) => {+ if (disabled || hidden) return;+ const step = e.shiftKey ? 40 : 8;+ const plus = isVert ? 'ArrowRight' : 'ArrowDown';+ const minus = isVert ? 'ArrowLeft' : 'ArrowUp';+ const { lo, hi } = measureBounds();+ if (e.key === plus) {+ onChange(clampTo(liveSizeRef.current + step, lo, hi));+ e.preventDefault();+ } else if (e.key === minus) {+ onChange(clampTo(liveSizeRef.current - step, lo, hi));+ e.preventDefault();+ } else if (e.key === 'Home') {+ onChange(lo);+ e.preventDefault();+ } else if (e.key === 'End') {+ onChange(hi);+ e.preventDefault();+ }+ };++ const template = hidden+ ? hiddenTake === 'primary'+ ? '1fr 0 0'+ : '0 0 1fr'+ : `var(--sp-size) ${GUTTER_VISIBLE_SIZE}px 1fr`;++ const rootStyle: React.CSSProperties = {+ display: 'grid',+ width: '100%',+ height: '100%',+ overflow: 'hidden',+ position: 'relative',+ [isVert ? 'gridTemplateColumns' : 'gridTemplateRows']: template,+ [isVert ? 'gridTemplateRows' : 'gridTemplateColumns']: '1fr',+ ['--sp-size' as any]: size + 'px',+ };++ const paneStyle: React.CSSProperties = {+ minWidth: 0,+ minHeight: 0,+ overflow: 'hidden',+ position: 'relative',+ // Isolate child layout so grid-track size changes during drag+ // don't trigger full-page relayout of descendant content.+ contain: 'layout paint',+ };++ return (+ <div ref={rootRef} style={rootStyle}>+ <div style={paneStyle}>{primary}</div>+ {hidden ? (+ <div />+ ) : (+ <SplitterGutter+ direction={direction}+ disabled={disabled}+ ariaLabel={ariaLabel}+ ariaValueNow={Math.round(size)}+ ariaValueMin={min}+ ariaValueMax={max}+ onPointerDown={onPointerDown}+ onPointerMove={onPointerMove}+ onPointerUp={finishDrag}+ onDoubleClick={onDoubleClick}+ onKeyDown={onKeyDown}+ />+ )}+ <div style={paneStyle}>{secondary}</div>+ </div>+ );+}++export default Splitter;diff --git a/src/renderer/components/StoredSearches.tsx b/src/renderer/components/StoredSearches.tsxindex 9176697c7..0bf299d28 100644--- a/src/renderer/components/StoredSearches.tsx+++ b/src/renderer/components/StoredSearches.tsx@@ -153,7 +153,7 @@ function StoredSearches(props: Props) {paddingTop: 0,marginTop: 0,height: 'calc(100% - ' + reduceHeightBy + 'px)',- width: 305,+ width: '100%',overflowY: 'auto',overflowX: 'hidden',}}@@ -232,6 +232,8 @@ function StoredSearches(props: Props) {textTransform: 'none',fontWeight: 'normal',justifyContent: 'start',+ width: '100%',+ minWidth: 0,}}onClick={() => findFromSavedSearch(search.uuid)}>@@ -242,7 +244,9 @@ function StoredSearches(props: Props) {whiteSpace: 'nowrap',textOverflow: 'ellipsis',overflow: 'hidden',- maxWidth: 220,+ flex: 1,+ minWidth: 0,+ textAlign: 'left',}}>{search.title}diff --git a/src/renderer/components/TagLibrary.tsx b/src/renderer/components/TagLibrary.tsxindex bd0819732..2eeb2f66f 100644--- a/src/renderer/components/TagLibrary.tsx+++ b/src/renderer/components/TagLibrary.tsx@@ -279,7 +279,7 @@ function TagLibrary({ reduceHeightBy }: Props) {sx={{height: '100%',paddingLeft: '5px',- paddingRight: 0,+ paddingRight: '5px',display: 'flex',flexDirection: 'column',}}@@ -371,7 +371,7 @@ function TagLibrary({ reduceHeightBy }: Props) {marginTop: 0,borderRadius: '5px',height: `calc(100% - ${reduceHeightBy}px)`,- width: 310,+ width: '100%',overflowY: 'auto',overflowX: 'hidden',}}diff --git a/src/renderer/containers/MainPage.tsx b/src/renderer/containers/MainPage.tsxindex c26657442..ba6273b1d 100644--- a/src/renderer/containers/MainPage.tsx+++ b/src/renderer/containers/MainPage.tsx@@ -29,59 +29,50 @@ import { Box, useMediaQuery } from '@mui/material';import Drawer from '@mui/material/Drawer';import SwipeableDrawer from '@mui/material/SwipeableDrawer';import { styled, useTheme } from '@mui/material/styles';-import { buffer } from '@tagspaces/tagspaces-common/misc';import clsx from 'clsx';import React, {useCallback,useEffect,useMemo,- useReducer,useRef,useState,} from 'react';import { GlobalHotKeys } from 'react-hotkeys';import { useDispatch, useSelector } from 'react-redux';-import { Split } from 'ts-react-splitter';import EntryContainer from '../components/EntryContainer';import FolderContainer from '../components/FolderContainer';import MobileNavigation from '../components/MobileNavigation';+import { Splitter, SplitterGutter } from '../components/Splitter';import {actions as SettingsActions,getDesktopMode,getKeyBindingObject,+ getLeftPanelWidth,getMainVerticalSplitSize,} from '../reducers/settings';-const drawerWidth = 320;-const bufferedLeftSplitResize = buffer({- timeout: 300,- id: 'buffered-leftsplit-resize',-});+const DRAWER_MIN_WIDTH = 310;+const DRAWER_MAX_WIDTH = 600;+const DRAWER_DEFAULT_WIDTH = 320;+const MOBILE_DRAWER_WIDTH = 320;+const DRAWER_WIDTH_VAR = '--tagspaces-drawer-width';const classes = {content: `MainPage-content`,contentShift: `MainPage-contentShift`,};-const Root = styled('div')(({ theme }) => ({+const Root = styled('div')(() => ({height: '100%',[`& .${classes.content}`]: {height: '100%',flexGrow: 1,padding: 0,- paddingLeft: drawerWidth,- transition: theme.transitions.create('margin', {- easing: theme.transitions.easing.sharp,- duration: theme.transitions.duration.leavingScreen,- }),+ paddingLeft: 'var(--tagspaces-drawer-width, 320px)',},[`& .${classes.contentShift}`]: {height: '100%',padding: 0,- transition: theme.transitions.create('margin', {- easing: theme.transitions.easing.easeOut,- duration: theme.transitions.duration.enteringScreen,- }),marginLeft: 0,},}));@@ -102,13 +93,14 @@ function MainPage() {} = useDirectoryContentContext();const { showPanel } = usePanelsContext();const { isLoggedIn } = useUserContext();- const percent = useRef<number | undefined>(undefined);- const [, forceUpdate] = useReducer((x) => x + 1, 0);+ const mainSplitContainerRef = useRef<HTMLDivElement>(null);+ const [sizePx, setSizePx] = useState<number>(0);const [drawerOpened, setDrawerOpened] = useState<boolean>(true);const isDesktopMode: boolean = useSelector(getDesktopMode);const keyBindings = useSelector(getKeyBindingObject);const mainSplitSize = useSelector(getMainVerticalSplitSize);+ const drawerWidth = useSelector(getLeftPanelWidth);// Redux actions as callbacksconst toggleShowUnixHiddenEntries = useCallback(@@ -120,6 +112,10 @@ function MainPage() {dispatch(SettingsActions.setMainVerticalSplitSize(splitSize)),[dispatch],);+ const setLeftPanelWidth = useCallback(+ (w: number) => dispatch(SettingsActions.setLeftPanelWidth(w)),+ [dispatch],+ );useEventListener('message', (e) => {if (typeof e.data === 'string') {@@ -150,6 +146,22 @@ function MainPage() {}}, [isEntryInFullWidth]);+ // Expose desktop drawer width to CSS so the main content's paddingLeft+ // tracks the drawer size without re-creating the styled component on every drag.+ // The .contentShift class zeroes padding when the drawer is closed, so the+ // var stays at the live width regardless of drawerOpened. The drag handler+ // also writes this var directly during drag — keep it consistent on commit.+ useEffect(() => {+ if (!isDesktopMode) {+ document.documentElement.style.removeProperty(DRAWER_WIDTH_VAR);+ return;+ }+ document.documentElement.style.setProperty(+ DRAWER_WIDTH_VAR,+ drawerWidth + 'px',+ );+ }, [drawerWidth, isDesktopMode]);+useEffect(() => {updateDimensions();// eslint-disable-next-line@@ -234,39 +246,42 @@ function MainPage() {[keyBindings],);- const setPercent = useCallback(- (p: number | undefined) => {- percent.current = p;- if (p !== undefined) {- bufferedLeftSplitResize(() => {- if (mainSplitSize !== p + '%') {- setMainVerticalSplitSize(p + '%');- }- });+ const hideSplit = !openedEntry || isEntryInFullWidth;++ // Keep sizePx in sync with persisted percentage and container width.+ useEffect(() => {+ const el = mainSplitContainerRef.current;+ if (!el || hideSplit) return;+ const pct = parseFloat(mainSplitSize);+ if (!isFinite(pct)) return;+ const next = Math.round((el.clientWidth * pct) / 100);+ setSizePx(next);+ }, [mainSplitSize, hideSplit]);++ // Recompute sizePx on window resize to preserve the persisted percentage.+ useEventListener('resize', () => {+ const el = mainSplitContainerRef.current;+ if (!el || hideSplit) return;+ const pct = parseFloat(mainSplitSize);+ if (!isFinite(pct)) return;+ setSizePx(Math.round((el.clientWidth * pct) / 100));+ });++ const onMainSplitChange = useCallback(+ (px: number) => {+ setSizePx(px);+ const el = mainSplitContainerRef.current;+ if (!el || el.clientWidth === 0) return;+ const pct = Math.round((px / el.clientWidth) * 100);+ const next = pct + '%';+ if (mainSplitSize !== next) {+ setMainVerticalSplitSize(next);}- forceUpdate();},[mainSplitSize, setMainVerticalSplitSize],);function renderContainers() {- let initialPrimarySize = mainSplitSize;- let minPrimarySize = '250px';- let minSecondarySize = '250px';- let renderSplitter: (() => React.ReactNode) | undefined;-- if (!openedEntry) {- percent.current = undefined;- initialPrimarySize = '100%';- minSecondarySize = '0%';- renderSplitter = () => null;- }- if (isEntryInFullWidth) {- percent.current = undefined;- initialPrimarySize = '0%';- minPrimarySize = '0%';- renderSplitter = () => null;- }if (smallScreen && openedEntry) {return (<>@@ -284,26 +299,31 @@ function MainPage() {);}return (- <Split- initialPrimarySize={initialPrimarySize}- minPrimarySize={minPrimarySize}- minSecondarySize={minSecondarySize}- renderSplitter={renderSplitter}- percent={percent.current}- setPercent={setPercent}- >- <FolderContainer- toggleDrawer={toggleDrawer}- drawerOpened={drawerOpened}- />- <FilePropertiesContextProvider>- {openedEntry && (- <FullScreenContextProvider>- <EntryContainer key="EntryContainerID" />- </FullScreenContextProvider>- )}- </FilePropertiesContextProvider>- </Split>+ <div ref={mainSplitContainerRef} style={{ height: '100%' }}>+ <Splitter+ direction="vertical"+ size={sizePx}+ min={400}+ hidden={hideSplit}+ hiddenTake={isEntryInFullWidth ? 'secondary' : 'primary'}+ onChange={onMainSplitChange}+ ariaLabel="Resize file list and preview"+ >+ <FolderContainer+ toggleDrawer={toggleDrawer}+ drawerOpened={drawerOpened}+ />+ <FilePropertiesContextProvider>+ {openedEntry ? (+ <FullScreenContextProvider>+ <EntryContainer key="EntryContainerID" />+ </FullScreenContextProvider>+ ) : (+ <div />+ )}+ </FilePropertiesContextProvider>+ </Splitter>+ </div>);}@@ -322,43 +342,31 @@ function MainPage() {body { background-color: ${theme.palette.background.default} !important;}- .default-splitter {- --default-splitter-line-margin: 2px !important;- --default-splitter-line-size: 1px !important;- --default-splitter-line-color: ${- theme.palette.divider- } !important;- }-- .react-split .split-container.vertical .splitter {- background-color: ${theme.palette.background.default};- }-- .react-split .split-container {- --react-split-splitter: ${- !openedEntry || isEntryInFullWidth ? '0' : '3px'- } !important;- }- .react-split .secondary .full-content {- display: flex;- flex-direction: column;- overflow: clip;- }-- .react-split > .split-container.vertical > .splitter {- z-index: 1;- }`}</style>{isDesktopMode || (AppConfig.ExtIsAmplify && !isLoggedIn()) ? (<><Drawer- sx={{ backgroundColor: 'unset' }}+ sx={{+ backgroundColor: 'unset',+ // The DrawerResizeHandle's hit area extends 6.5px past the+ // drawer's right edge (SplitterGutter's invisible hit zone).+ // Without this, the Paper allows a few pixels of horizontal+ // scroll into that empty overflow.+ '& .MuiDrawer-paper': { overflowX: 'hidden' },+ }}variant="persistent"anchor="left"open={drawerOpened}>- <MobileNavigation width={drawerWidth} />+ <MobileNavigation+ width={drawerWidth}+ widthVar={DRAWER_WIDTH_VAR}+ />+ <DrawerResizeHandle+ width={drawerWidth}+ onChange={setLeftPanelWidth}+ /></Drawer><mainclassName={clsx(classes.content, {@@ -379,7 +387,7 @@ function MainPage() {disableDiscovery={AppConfig.isIOS}><MobileNavigation- width={drawerWidth}+ width={MOBILE_DRAWER_WIDTH}hideDrawer={() => setDrawerOpened(false)}/></SwipeableDrawer>@@ -392,4 +400,101 @@ function MainPage() {);}+interface DrawerResizeHandleProps {+ width: number;+ onChange: (w: number) => void;+}++function DrawerResizeHandle({ width, onChange }: DrawerResizeHandleProps) {+ const dragRef = useRef<{ sx: number; sw: number } | null>(null);+ const liveRef = useRef<number>(width);+ const rafRef = useRef<number | null>(null);++ useEffect(() => {+ liveRef.current = width;+ }, [width]);++ const clamp = (v: number) =>+ Math.max(DRAWER_MIN_WIDTH, Math.min(DRAWER_MAX_WIDTH, v));++ // During drag we bypass Redux entirely and write straight to the CSS var+ // that both the main content's paddingLeft and MobileNavigation's width+ // resolve from. This avoids a per-frame store update / re-render of the+ // (heavy) MobileNavigation tree.+ const writeLive = (v: number) => {+ liveRef.current = clamp(v);+ if (rafRef.current != null) return;+ rafRef.current = requestAnimationFrame(() => {+ rafRef.current = null;+ document.documentElement.style.setProperty(+ DRAWER_WIDTH_VAR,+ liveRef.current + 'px',+ );+ });+ };++ const onPointerDown = (e: React.PointerEvent) => {+ dragRef.current = { sx: e.clientX, sw: liveRef.current };+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);+ document.body.style.cursor = 'col-resize';+ document.body.style.userSelect = 'none';+ };+ const onPointerMove = (e: React.PointerEvent) => {+ const d = dragRef.current;+ if (!d) return;+ writeLive(d.sw + (e.clientX - d.sx));+ };+ const finish = (e: React.PointerEvent) => {+ if (!dragRef.current) return;+ dragRef.current = null;+ try {+ (e.currentTarget as HTMLElement).releasePointerCapture(e.pointerId);+ } catch {+ /* already released */+ }+ document.body.style.cursor = '';+ document.body.style.userSelect = '';+ onChange(liveRef.current);+ };+ const onDoubleClick = () => onChange(DRAWER_DEFAULT_WIDTH);+ const onKeyDown = (e: React.KeyboardEvent) => {+ const step = e.shiftKey ? 40 : 8;+ if (e.key === 'ArrowRight') {+ onChange(clamp(width + step));+ e.preventDefault();+ } else if (e.key === 'ArrowLeft') {+ onChange(clamp(width - step));+ e.preventDefault();+ } else if (e.key === 'Home') {+ onChange(DRAWER_MIN_WIDTH);+ e.preventDefault();+ } else if (e.key === 'End') {+ onChange(DRAWER_MAX_WIDTH);+ e.preventDefault();+ }+ };++ return (+ <SplitterGutter+ direction="vertical"+ ariaLabel="Resize navigation panel"+ ariaValueNow={width}+ ariaValueMin={DRAWER_MIN_WIDTH}+ ariaValueMax={DRAWER_MAX_WIDTH}+ onPointerDown={onPointerDown}+ onPointerMove={onPointerMove}+ onPointerUp={finish}+ onDoubleClick={onDoubleClick}+ onKeyDown={onKeyDown}+ style={{+ position: 'absolute',+ top: 0,+ right: 0,+ height: '100%',+ zIndex: 1300,+ }}+ />+ );+}+export default React.memo(MainPage);diff --git a/src/renderer/reducers/settings-default.ts b/src/renderer/reducers/settings-default.tsindex 2f69be295..ef1af821c 100644--- a/src/renderer/reducers/settings-default.ts+++ b/src/renderer/reducers/settings-default.ts@@ -77,7 +77,6 @@ export default {'<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body></body></html>',showUnixHiddenEntries: false,entryContainerTab: 0,- entryPropertiesHeight: 100,checkForUpdates,reorderTags: false,coloredFileExtension: false,@@ -114,8 +113,9 @@ export default {enableGlobalKeyboardShortcuts: false,zoomFactor: 1,lastPublishedVersion: '',- entrySplitSize: '45%', // AppConfig.isElectron ? '560px' : '360px',+ entrySplitSize: 200, // px — height of the title+tabs pane inside EntryContainermainVSplitSize: '50%',+ leftPanelWidth: 320, // px — desktop drawer width (bounds 250–600)supportedGeoTagging: ['pluscodes', 'mgrs'],supportedThemes: ['light', 'dark', 'system'],tsLastOpenedFilesHistory: 10,diff --git a/src/renderer/reducers/settings.ts b/src/renderer/reducers/settings.tsindex ef8e18990..965d5e56c 100644--- a/src/renderer/reducers/settings.ts+++ b/src/renderer/reducers/settings.ts@@ -95,6 +95,7 @@ export const types = {SET_LAST_PUBLISHED_VERSION: 'SETTINGS/SET_LAST_PUBLISHED_VERSION',SET_ENTRY_PROPERTIES_SPLIT_SIZE: 'SETTINGS/SET_ENTRY_PROPERTIES_SPLIT_SIZE',SET_MAIN_VSPLIT_SIZE: 'SETTINGS/SET_MAIN_VSPLIT_SIZE',+ SET_LEFT_PANEL_WIDTH: 'SETTINGS/SET_LEFT_PANEL_WIDTH',SET_FIRST_RUN: 'SETTINGS/SET_FIRST_RUN',SET_ONBOARDING_COMPLETED: 'SETTINGS/SET_ONBOARDING_COMPLETED',SET_HIDE_HOWTOSTART: 'SETTINGS/SET_HIDE_HOWTOSTART',@@ -501,6 +502,12 @@ export default (state: any = defaultSettings, action: any) => {mainVSplitSize: action.mainVSplitSize,};}+ case types.SET_LEFT_PANEL_WIDTH: {+ return {+ ...state,+ leftPanelWidth: action.leftPanelWidth,+ };+ }case types.SET_LAST_PUBLISHED_VERSION: {return {...state,@@ -898,7 +905,7 @@ export const actions = {type: types.SET_SUPPORTED_FILE_TYPES,supportedFileTypes,}),- setEntryPropertiesSplitSize: (entrySplitSize: string) => ({+ setEntryPropertiesSplitSize: (entrySplitSize: number) => ({type: types.SET_ENTRY_PROPERTIES_SPLIT_SIZE,entrySplitSize,}),@@ -906,6 +913,10 @@ export const actions = {type: types.SET_MAIN_VSPLIT_SIZE,mainVSplitSize,}),+ setLeftPanelWidth: (leftPanelWidth: number) => ({+ type: types.SET_LEFT_PANEL_WIDTH,+ leftPanelWidth,+ }),setFirstRun: (firstRun: boolean) => ({type: types.SET_FIRST_RUN,firstRun,@@ -987,7 +998,15 @@ function getDefaultAI(aiProviderId: string, aiProviders: AIProvider[]) {}// Selectors-export const getEntrySplitSize = (state: any) => state.settings.entrySplitSize;+export const getEntrySplitSize = (state: any): number => {+ const raw = state.settings.entrySplitSize;+ // Legacy values were strings like '45%' and are no longer valid (value is now pixels).+ return typeof raw === 'number' && isFinite(raw) ? raw : 200;+};+export const getLeftPanelWidth = (state: any): number => {+ const raw = state.settings.leftPanelWidth;+ return typeof raw === 'number' && isFinite(raw) ? raw : 320;+};export const getMapTileServer = (state: any): TS.MapTileServer =>AppConfig.ExtMapTileServers? AppConfig.ExtMapTileServers[0]@@ -1048,8 +1067,6 @@ export const getShowUnixHiddenEntries = (state: any) =>state.settings.showUnixHiddenEntries;export const getEntryContainerTab = (state: any) =>state.settings.entryContainerTab;-export const getEntryPropertiesHeight = (state: any) =>- state.settings.entryPropertiesHeight;export const getUseDefaultLocation = (state: any) =>state.settings.useDefaultLocation;export const getDefaultPerspective = (state: any) =>