linting
This commit is contained in:
@@ -34,6 +34,84 @@ const DEBUG_DRAG = false;
|
|||||||
const DEBUG_FOCUS = true;
|
const DEBUG_FOCUS = true;
|
||||||
const DEBUG_DROP = true;
|
const DEBUG_DROP = true;
|
||||||
|
|
||||||
|
const signedDistance = (ax, ay, bx, by, px, py) => (bx - ax) * (py - ay) - (by - ay) * (px - ax);
|
||||||
|
|
||||||
|
const clipPolygonWithEdge = (subject, edgeStart, edgeEnd) => {
|
||||||
|
if (!subject.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const result = [];
|
||||||
|
let prev = subject[subject.length - 1];
|
||||||
|
let prevInside = signedDistance(edgeStart.x, edgeStart.y, edgeEnd.x, edgeEnd.y, prev.x, prev.y) >= 0;
|
||||||
|
subject.forEach((curr) => {
|
||||||
|
const currInside = signedDistance(edgeStart.x, edgeStart.y, edgeEnd.x, edgeEnd.y, curr.x, curr.y) >= 0;
|
||||||
|
if (currInside !== prevInside) {
|
||||||
|
const dx = curr.x - prev.x;
|
||||||
|
const dy = curr.y - prev.y;
|
||||||
|
const denom = (edgeEnd.x - edgeStart.x) * dy - (edgeEnd.y - edgeStart.y) * dx;
|
||||||
|
if (Math.abs(denom) > 1e-9) {
|
||||||
|
const t = ((edgeStart.x - prev.x) * dy - (edgeStart.y - prev.y) * dx) / denom;
|
||||||
|
result.push({
|
||||||
|
x: edgeStart.x + t * (edgeEnd.x - edgeStart.x),
|
||||||
|
y: edgeStart.y + t * (edgeEnd.y - edgeStart.y),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currInside) {
|
||||||
|
result.push(curr);
|
||||||
|
}
|
||||||
|
prev = curr;
|
||||||
|
prevInside = currInside;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const clipPolygon = (subject, clipShape) => {
|
||||||
|
if (!subject.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
let output = subject;
|
||||||
|
let prev = clipShape[clipShape.length - 1];
|
||||||
|
for (let index = 0; index < clipShape.length; index += 1) {
|
||||||
|
const curr = clipShape[index];
|
||||||
|
output = clipPolygonWithEdge(output, prev, curr);
|
||||||
|
if (!output.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
prev = curr;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isPointInsideConvex = (point, polygon) => {
|
||||||
|
if (!polygon.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let prev = polygon[polygon.length - 1];
|
||||||
|
for (let index = 0; index < polygon.length; index += 1) {
|
||||||
|
const curr = polygon[index];
|
||||||
|
if (signedDistance(prev.x, prev.y, curr.x, curr.y, point.x, point.y) < -1e-6) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
prev = curr;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const polygonCentroid = (polygon) => {
|
||||||
|
let x = 0;
|
||||||
|
let y = 0;
|
||||||
|
polygon.forEach((point) => {
|
||||||
|
x += point.x;
|
||||||
|
y += point.y;
|
||||||
|
});
|
||||||
|
const count = polygon.length || 1;
|
||||||
|
return {
|
||||||
|
x: x / count,
|
||||||
|
y: y / count,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const readTransferData = (dataTransfer, mimeTypes) => {
|
const readTransferData = (dataTransfer, mimeTypes) => {
|
||||||
if (!dataTransfer) {
|
if (!dataTransfer) {
|
||||||
return null;
|
return null;
|
||||||
@@ -866,84 +944,6 @@ const DesktopWorkspace = ({
|
|||||||
},
|
},
|
||||||
[resolvePreviewDimensions],
|
[resolvePreviewDimensions],
|
||||||
);
|
);
|
||||||
const signedDistance = (ax, ay, bx, by, px, py) => (bx - ax) * (py - ay) - (by - ay) * (px - ax);
|
|
||||||
|
|
||||||
const clipPolygonWithEdge = (subject, edgeStart, edgeEnd) => {
|
|
||||||
if (!subject.length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const result = [];
|
|
||||||
let prev = subject[subject.length - 1];
|
|
||||||
let prevInside = signedDistance(edgeStart.x, edgeStart.y, edgeEnd.x, edgeEnd.y, prev.x, prev.y) >= 0;
|
|
||||||
subject.forEach((curr) => {
|
|
||||||
const currInside = signedDistance(edgeStart.x, edgeStart.y, edgeEnd.x, edgeEnd.y, curr.x, curr.y) >= 0;
|
|
||||||
if (currInside !== prevInside) {
|
|
||||||
const dx = curr.x - prev.x;
|
|
||||||
const dy = curr.y - prev.y;
|
|
||||||
const denom = (edgeEnd.x - edgeStart.x) * dy - (edgeEnd.y - edgeStart.y) * dx;
|
|
||||||
if (Math.abs(denom) > 1e-9) {
|
|
||||||
const t = ((edgeStart.x - prev.x) * dy - (edgeStart.y - prev.y) * dx) / denom;
|
|
||||||
result.push({
|
|
||||||
x: edgeStart.x + t * (edgeEnd.x - edgeStart.x),
|
|
||||||
y: edgeStart.y + t * (edgeEnd.y - edgeStart.y),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currInside) {
|
|
||||||
result.push(curr);
|
|
||||||
}
|
|
||||||
prev = curr;
|
|
||||||
prevInside = currInside;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
const clipPolygon = (subject, clipShape) => {
|
|
||||||
if (!subject.length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
let output = subject;
|
|
||||||
let prev = clipShape[clipShape.length - 1];
|
|
||||||
for (let index = 0; index < clipShape.length; index += 1) {
|
|
||||||
const curr = clipShape[index];
|
|
||||||
output = clipPolygonWithEdge(output, prev, curr);
|
|
||||||
if (!output.length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
prev = curr;
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isPointInsideConvex = (point, polygon) => {
|
|
||||||
if (!polygon.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
let prev = polygon[polygon.length - 1];
|
|
||||||
for (let index = 0; index < polygon.length; index += 1) {
|
|
||||||
const curr = polygon[index];
|
|
||||||
if (signedDistance(prev.x, prev.y, curr.x, curr.y, point.x, point.y) < -1e-6) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
prev = curr;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const polygonCentroid = (polygon) => {
|
|
||||||
let x = 0;
|
|
||||||
let y = 0;
|
|
||||||
polygon.forEach((point) => {
|
|
||||||
x += point.x;
|
|
||||||
y += point.y;
|
|
||||||
});
|
|
||||||
const count = polygon.length || 1;
|
|
||||||
return {
|
|
||||||
x: x / count,
|
|
||||||
y: y / count,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const recalcVisibleDocIds = useCallback(() => {
|
const recalcVisibleDocIds = useCallback(() => {
|
||||||
const layoutMap = layoutRef.current;
|
const layoutMap = layoutRef.current;
|
||||||
const canvasWidth = canvasSize.width || DEFAULT_CANVAS_WIDTH;
|
const canvasWidth = canvasSize.width || DEFAULT_CANVAS_WIDTH;
|
||||||
@@ -1069,7 +1069,6 @@ const recalcVisibleDocIds = useCallback(() => {
|
|||||||
canvasSize.height,
|
canvasSize.height,
|
||||||
ensureDocumentSize,
|
ensureDocumentSize,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
docSizeVersion,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const syncLayoutSnapshot = useCallback(() => {
|
const syncLayoutSnapshot = useCallback(() => {
|
||||||
@@ -1080,7 +1079,8 @@ const syncLayoutSnapshot = useCallback(() => {
|
|||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
if (!container) return () => {};
|
if (!container) return () => {};
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
const nodeEnv = typeof globalThis !== 'undefined' ? globalThis.process?.env?.NODE_ENV : undefined;
|
||||||
|
if (nodeEnv !== 'production') {
|
||||||
console.log('[skeuo] canvas element', container);
|
console.log('[skeuo] canvas element', container);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,7 +1207,7 @@ const syncLayoutSnapshot = useCallback(() => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
recalcVisibleDocIds();
|
recalcVisibleDocIds();
|
||||||
}, [recalcVisibleDocIds, items.length, canvasSize.width, canvasSize.height]);
|
}, [recalcVisibleDocIds, items.length, canvasSize.width, canvasSize.height, docSizeVersion]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (draggingId && !items.some((doc) => doc.id === draggingId)) {
|
if (draggingId && !items.some((doc) => doc.id === draggingId)) {
|
||||||
@@ -1849,16 +1849,12 @@ const DesktopWorkspaceView = () => {
|
|||||||
closeOverlay,
|
closeOverlay,
|
||||||
overlayOriginRect,
|
overlayOriginRect,
|
||||||
overlayOriginTransform,
|
overlayOriginTransform,
|
||||||
docSizeVersion,
|
|
||||||
} = useDesktopContext();
|
} = useDesktopContext();
|
||||||
|
|
||||||
const { handlePointerDown, handlePointerMove, handlePointerUp, handlePointerCancel } =
|
const { handlePointerDown, handlePointerMove, handlePointerUp, handlePointerCancel } =
|
||||||
useDocumentDrag();
|
useDocumentDrag();
|
||||||
|
|
||||||
const allSizesReady = useMemo(
|
const allSizesReady = items.every((doc) => ensureDocumentSize(doc));
|
||||||
() => items.every((doc) => ensureDocumentSize(doc)),
|
|
||||||
[items, ensureDocumentSize, docSizeVersion],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ const useDocumentDrag = () => {
|
|||||||
recalcVisibleDocIds();
|
recalcVisibleDocIds();
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
bringToFront,
|
||||||
canvasPadding,
|
canvasPadding,
|
||||||
canvasSize.height,
|
canvasSize.height,
|
||||||
canvasSize.width,
|
canvasSize.width,
|
||||||
|
|||||||
@@ -828,11 +828,13 @@ const DetailPanel = ({
|
|||||||
warmNavigator(stackPreviewNavigator);
|
warmNavigator(stackPreviewNavigator);
|
||||||
}, [
|
}, [
|
||||||
ensureAssetUrl,
|
ensureAssetUrl,
|
||||||
|
singlePreviewNavigator,
|
||||||
singlePreviewNavigator.documentId,
|
singlePreviewNavigator.documentId,
|
||||||
singlePreviewNavigator.asset,
|
singlePreviewNavigator.asset,
|
||||||
singlePreviewNavigator.ordinal,
|
singlePreviewNavigator.ordinal,
|
||||||
singlePreviewNavigator.canGoPrev,
|
singlePreviewNavigator.canGoPrev,
|
||||||
singlePreviewNavigator.canGoNext,
|
singlePreviewNavigator.canGoNext,
|
||||||
|
stackPreviewNavigator,
|
||||||
stackPreviewNavigator.documentId,
|
stackPreviewNavigator.documentId,
|
||||||
stackPreviewNavigator.asset,
|
stackPreviewNavigator.asset,
|
||||||
stackPreviewNavigator.ordinal,
|
stackPreviewNavigator.ordinal,
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ const DocumentThumbnailImage = ({
|
|||||||
} else {
|
} else {
|
||||||
delete node.dataset.thumbnailAspect;
|
delete node.dataset.thumbnailAspect;
|
||||||
}
|
}
|
||||||
}, [aspectRatio]);
|
}, [aspectRatio, visibilityRef]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="document-thumbnail-wrapper" ref={visibilityRef}>
|
<div className="document-thumbnail-wrapper" ref={visibilityRef}>
|
||||||
|
|||||||
+550
-274
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React from 'react';
|
||||||
import { formatFileSize } from '../utils/format';
|
import { formatFileSize } from '../utils/format';
|
||||||
import { DownloadIcon, TextScanIcon, AnalyzeIcon, CloseIcon } from '../ui/icons';
|
import { DownloadIcon, TextScanIcon, AnalyzeIcon, CloseIcon } from '../ui/icons';
|
||||||
import { openOcrTextInNewTab } from '../utils/ocr';
|
import { openOcrTextInNewTab } from '../utils/ocr';
|
||||||
@@ -24,7 +24,7 @@ const PreviewWorkspace = ({
|
|||||||
const tags = Array.isArray(document.tags) ? document.tags : [];
|
const tags = Array.isArray(document.tags) ? document.tags : [];
|
||||||
const correspondents = Array.isArray(document.correspondents) ? document.correspondents : [];
|
const correspondents = Array.isArray(document.correspondents) ? document.correspondents : [];
|
||||||
|
|
||||||
const metadataSummary = useMemo(() => {
|
const metadataSummary = (() => {
|
||||||
const rows = [];
|
const rows = [];
|
||||||
if (mime) rows.push(['Type', mime]);
|
if (mime) rows.push(['Type', mime]);
|
||||||
if (sizeLabel) rows.push(['Size', sizeLabel]);
|
if (sizeLabel) rows.push(['Size', sizeLabel]);
|
||||||
@@ -45,7 +45,7 @@ const PreviewWorkspace = ({
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}, [mime, sizeLabel, issuedAt, createdAt, updatedAt, folderName, tags, correspondents]);
|
})();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="preview-workspace">
|
<section className="preview-workspace">
|
||||||
|
|||||||
Reference in New Issue
Block a user