diff --git a/src/zotero_kb/templates/index.html b/src/zotero_kb/templates/index.html
index 2be9326..6a0f25e 100644
--- a/src/zotero_kb/templates/index.html
+++ b/src/zotero_kb/templates/index.html
@@ -490,12 +490,39 @@
const importSessionState = readImportSessionState();
+ const WINDOW_SESSION_STORAGE_KEY = "zotero-kb.import-window";
+
+ function readWindowSessionState() {
+ try {
+ const raw = window.sessionStorage.getItem(WINDOW_SESSION_STORAGE_KEY);
+ if (!raw) return {};
+ const payload = JSON.parse(raw);
+ return typeof payload === "object" && payload ? payload : {};
+ } catch (_error) {
+ return {};
+ }
+ }
+
+ const windowSessionState = readWindowSessionState();
+
const state = {
projects: [],
currentProjectId: null,
currentCards: [],
collectionTree: [],
isImportModalOpen: false,
+ isImportWindowOpen: false,
+ windowX: typeof windowSessionState.x === "number" ? windowSessionState.x : null,
+ windowY: typeof windowSessionState.y === "number" ? windowSessionState.y : null,
+ windowWidth: typeof windowSessionState.width === "number" ? windowSessionState.width : null,
+ windowHeight: typeof windowSessionState.height === "number" ? windowSessionState.height : null,
+ isWindowMinimized: Boolean(windowSessionState.isMinimized),
+ isWindowMaximized: Boolean(windowSessionState.isMaximized),
+ isWindowDragging: false,
+ windowDragStartX: 0,
+ windowDragStartY: 0,
+ windowDragStartLeft: 0,
+ windowDragStartTop: 0,
selectedCollectionKey: typeof importSessionState.selectedCollectionKey === "string"
? importSessionState.selectedCollectionKey
: null,
@@ -523,17 +550,22 @@
projectForm: document.getElementById("create-project-form"),
projectStatus: document.getElementById("project-status"),
projectList: document.getElementById("project-list"),
- importModal: document.getElementById("import-modal"),
- importModalOverlay: document.getElementById("import-modal-overlay"),
+ importWindowShell: document.getElementById("import-window-shell"),
+ importWindow: document.getElementById("import-window"),
+ windowToolbar: document.getElementById("import-window-toolbar"),
+ windowMinimizeButton: document.getElementById("window-minimize-button"),
+ windowMaximizeButton: document.getElementById("window-maximize-button"),
+ windowCloseButton: document.getElementById("window-close-button"),
+ windowRestoreButton: document.getElementById("window-restore-button"),
+ importWindowMinimizedBar: document.getElementById("import-window-minimized-bar"),
openImportModalButton: document.getElementById("open-import-modal-button"),
- closeImportModalButton: document.getElementById("close-import-modal-button"),
- importModalProjectLabel: document.getElementById("import-modal-project-label"),
- collectionStatus: document.getElementById("collection-status"),
- collectionTree: document.getElementById("modal-collection-tree"),
- collectionItems: document.getElementById("modal-collection-items"),
- selectedCount: document.getElementById("modal-selected-count"),
- clearSelectionButton: document.getElementById("modal-clear-selection-button"),
- importSelectedItemsButton: document.getElementById("modal-import-selected-items-button"),
+ windowProjectLabel: document.getElementById("import-window-project-label"),
+ windowSelectedCount: document.getElementById("window-selected-count"),
+ windowClearSelectionButton: document.getElementById("window-clear-selection-button"),
+ windowImportSelectedItemsButton: document.getElementById("window-import-selected-items-button"),
+ windowCollectionStatus: document.getElementById("window-collection-status"),
+ windowCollectionTree: document.getElementById("window-collection-tree"),
+ windowCollectionItems: document.getElementById("window-collection-items"),
previewPopover: document.getElementById("item-preview-popover"),
currentProjectLabel: document.getElementById("current-project-label"),
cardList: document.getElementById("card-list"),
@@ -563,6 +595,27 @@
);
}
+ function persistWindowSessionState() {
+ const fw = elements.importWindow;
+ if (!fw) return;
+ const style = window.getComputedStyle(fw);
+ const width = parseFloat(style.width);
+ const height = parseFloat(style.height);
+ const left = parseFloat(style.left);
+ const top = parseFloat(style.top);
+ window.sessionStorage.setItem(
+ WINDOW_SESSION_STORAGE_KEY,
+ JSON.stringify({
+ x: left,
+ y: top,
+ width: width,
+ height: height,
+ isMinimized: state.isWindowMinimized,
+ isMaximized: state.isWindowMaximized,
+ })
+ );
+ }
+
function setStatus(target, message, isError = false) {
target.textContent = message || "";
target.classList.toggle("error", Boolean(isError));