From 44bfdba62b2004807e2dd20b9e7c1593ee22cfb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pacanovsk=C3=BD?= Date: Thu, 7 May 2026 20:45:41 +0200 Subject: [PATCH 1/4] Make the ability to hide cells in source editing mode Now you can toggle source editing mode and next to the merge cell button is a new button in a shape of an "eyeball", this allows users to hide or unhide certain cells. Once you leave the source editing mode, the cells will no longer be visible. They can be toggled in the source editing mode. This feature will help with the future Biblica files to hide unwanted cells containing no text or nothing significant. --- .../codexCellEditorMessagehandling.ts | 60 +++++++++ .../codexCellEditorProvider.ts | 120 +++++++++++++++++- .../utils/cellUtils.ts | 1 + types/index.d.ts | 9 ++ .../CodexCellEditor/CellContentDisplay.tsx | 35 ++++- .../src/CodexCellEditor/CellList.tsx | 14 +- 6 files changed, 229 insertions(+), 10 deletions(-) diff --git a/src/providers/codexCellEditorProvider/codexCellEditorMessagehandling.ts b/src/providers/codexCellEditorProvider/codexCellEditorMessagehandling.ts index 5a5c84ae1..0bd12f297 100644 --- a/src/providers/codexCellEditorProvider/codexCellEditorMessagehandling.ts +++ b/src/providers/codexCellEditorProvider/codexCellEditorMessagehandling.ts @@ -1787,6 +1787,66 @@ const messageHandlers: Record Promise { + const typedEvent = event as Extract; + const { cellId, hidden } = typedEvent.content; + + debug("toggleCellVisibility message received for cell:", cellId, "hidden:", hidden); + + try { + const currentCellData = document.getCellData(cellId) || {}; + + document.updateCellData(cellId, { + ...currentCellData, + hidden, + }); + + try { + const cellForEdits = document.getCell(cellId); + if (cellForEdits) { + if (!cellForEdits.metadata.edits) { + cellForEdits.metadata.edits = [] as any; + } + const ts = Date.now(); + let user = "anonymous"; + try { + const authApi = await provider.getAuthApi(); + const userInfo = await authApi?.getUserInfo(); + user = userInfo?.username || "anonymous"; + } catch { /* ignore */ } + (cellForEdits.metadata.edits as any[]).push({ + editMap: EditMapUtils.metadataNested("data", "hidden"), + value: hidden, + timestamp: ts, + type: EditType.USER_EDIT, + author: user, + validatedBy: [], + }); + } + } catch (e) { + console.warn("Failed to record visibility edit entry on cell", e); + } + + await document.save(new vscode.CancellationTokenSource().token); + + debug(`Successfully toggled visibility for cell: ${cellId}, hidden: ${hidden}`); + + const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri); + if (workspaceFolder) { + await provider.toggleCellVisibilityInPairedFile(cellId, hidden, document.uri.toString(), workspaceFolder); + } else { + console.warn("No workspace folder found, skipping paired file visibility toggle"); + } + + updateWebview(); + } catch (error) { + console.error("Error toggling cell visibility:", cellId, error); + vscode.window.showErrorMessage( + `Failed to toggle cell visibility: ${error instanceof Error ? error.message : String(error)}` + ); + } + }, + triggerReindexing: async () => { debug("Triggering reindexing after all translations completed"); await vscode.commands.executeCommand("codex-editor-extension.forceReindex"); diff --git a/src/providers/codexCellEditorProvider/codexCellEditorProvider.ts b/src/providers/codexCellEditorProvider/codexCellEditorProvider.ts index af5d5ed0c..200ab2931 100755 --- a/src/providers/codexCellEditorProvider/codexCellEditorProvider.ts +++ b/src/providers/codexCellEditorProvider/codexCellEditorProvider.ts @@ -2362,6 +2362,7 @@ export class CodexCellEditorProvider implements vscode.CustomEditorProvider