open as worspace implementation
This commit is contained in:
31
src/workspace/workspaceSelection.ts
Normal file
31
src/workspace/workspaceSelection.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { PageRef } from '../pdf/pdfTypes';
|
||||
|
||||
export function getSelectedPagesInVisualOrder(
|
||||
pages: PageRef[],
|
||||
selectedPageIds: string[]
|
||||
): PageRef[] {
|
||||
if (pages.length === 0 || selectedPageIds.length === 0) return [];
|
||||
|
||||
const selectedSet = new Set(selectedPageIds);
|
||||
return pages.filter((page) => selectedSet.has(page.id));
|
||||
}
|
||||
|
||||
export function createSelectionWorkspaceName(
|
||||
pdfName: string,
|
||||
selectedPageCount: number
|
||||
): string {
|
||||
const baseName = pdfName.replace(/\.pdf$/i, '') || 'Untitled';
|
||||
const suffix =
|
||||
selectedPageCount === 1
|
||||
? '1-page-selection'
|
||||
: `${selectedPageCount}-page-selection`;
|
||||
|
||||
return `${baseName} - ${suffix}`;
|
||||
}
|
||||
|
||||
export function createSelectionPdfName(
|
||||
pdfName: string,
|
||||
selectedPageCount: number
|
||||
): string {
|
||||
return `${createSelectionWorkspaceName(pdfName, selectedPageCount)}.pdf`;
|
||||
}
|
||||
Reference in New Issue
Block a user