- **New app: GenOffice HTML.** Open, edit and generate .html pages: a source pane with a sandboxed live preview, click-to-select elements with a floating toolbar and style panel, device-size preview, image tools and a present mode. AI generates whole pages from a brief with style directions and offers page-wide Restyle, Theme and Summarize. Export to Word runs locally through the built-in html2docx converter (native, editable OOXML; no print-to-PDF detour). - **AI:** separate BYOK providers for web search, image generation and image/video analysis; new Codex App Server provider; Ask AI quotes the selected text and keeps it highlighted while it runs; custom AI panel text size; blocked requests retry through the Chromium network stack. - **App:** global AutoSave setting shared by every editor; AI panel text size and chat spellcheck toggles (genoffice#249); Czech (cs) UI locale (genoffice#259); Save As defaults to the document's folder; PDF export no longer aborts on CJK file paths on Windows. - **Docs:** Export as HTML; comments and replies edit in place from the comments pane; the caret can leave a trailing table (genoffice#266); spellcheck re-marks text as soon as it is re-enabled; AI edits are character-precise on partial selections; zoom keeps the scroll position; pasting a cell from Sheets takes the destination font. - **Sheets:** Find no longer freezes on wide or streamed grids; Replace searches as you type; cached values of external-workbook formulas are kept instead of #ERROR! (genoffice#235); "number stored as text" is a warning, not an error (genoffice#236); paste repeats into the target range like Excel; filter criteria survive save/reopen; saves retry when Windows locks the file; many Excel-fidelity fixes for column widths, row heights, charts, slicers, number formats and CJK fonts. - **Slides:** PDF export works for large presentations (genoffice#264); EMF/WMF picture fonts and East Asian theme fonts resolve correctly; decks with missing layouts or embedded styles still open; outline-only pie slices render. - **PDF:** highlight and underline geometry aligns with the text; Shift+arrows extend the selection instead of paging. - **Markdown:** Find and replace (Ctrl+F / Ctrl+H) (genoffice#253); mermaid code blocks render as diagrams (genoffice#263); better print quality. - Thanks to community contributors @GoodScholar, @aniruddhaadak80 and @Sun8854, and to @hanyscz, @qgzln, @zyp997, @bisslot, @krakotay and @Ben03151 for the reports. Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
4535 lines
181 KiB
TypeScript
4535 lines
181 KiB
TypeScript
import { createHash } from 'node:crypto'
|
||
import {
|
||
existsSync,
|
||
mkdirSync,
|
||
readdirSync,
|
||
readFileSync,
|
||
statSync,
|
||
unlinkSync,
|
||
writeFileSync,
|
||
} from 'node:fs'
|
||
import { copyFile, mkdir, readFile, readdir, stat, unlink, writeFile } from 'node:fs/promises'
|
||
import { basename, join } from 'node:path'
|
||
import {
|
||
BrowserWindow,
|
||
Menu,
|
||
WebContentsView,
|
||
app,
|
||
clipboard,
|
||
dialog,
|
||
ipcMain,
|
||
nativeImage,
|
||
net,
|
||
shell,
|
||
} from 'electron'
|
||
import {
|
||
appMenuLabels,
|
||
buildPrintableHtml,
|
||
configuredDefaultSaveDir,
|
||
contextMenuLabels,
|
||
fetchRemoteImage,
|
||
installContextMenu,
|
||
installNavigationGuard,
|
||
printHtmlToPdf,
|
||
safeExternalUrl,
|
||
saveAsSuggestion,
|
||
showOpenDialogWithMemory,
|
||
showSaveDialogWithMemory,
|
||
toggleDevToolsItem,
|
||
windowMenuTemplate,
|
||
} from '@genoffice/electron-utils'
|
||
import { configureMetricsCache, familyVerticalMetrics } from '@genoffice/font-metrics'
|
||
import { createI18n, getUiLang, normalizeLang, setUiLang } from '@genoffice/i18n'
|
||
import { ProjectStore } from '@genoffice/project-store'
|
||
import type {
|
||
IpcMainInvokeEvent,
|
||
MenuItemConstructorOptions,
|
||
OpenDialogOptions,
|
||
SaveDialogOptions,
|
||
WebContents,
|
||
} from 'electron'
|
||
import { parseFileToText } from '@genoffice/file-parse'
|
||
import {
|
||
AiCreditsError,
|
||
AiTimeoutError,
|
||
isAiNetworkError,
|
||
isAiOverloadedError,
|
||
chatForProvider,
|
||
defaultAiSettings,
|
||
activeProvider,
|
||
testMediaProvider,
|
||
type AiMediaProviderConfig,
|
||
type AiMediaProviderId,
|
||
type AiSearchProviderId,
|
||
resolveAiSettings,
|
||
maxOutputTokensOf,
|
||
setAiUserAgent,
|
||
setRescueFetch,
|
||
streamForProvider,
|
||
type AiChatRequest,
|
||
type AiSettings,
|
||
type AiStreamChunk,
|
||
type AiStreamRequest,
|
||
type GenSparkAccountStatus,
|
||
type LegacyAiSettings,
|
||
} from '@genoffice/ai-provider'
|
||
import { listCodexModels, shutdownCodexAppServers } from '@genoffice/ai-provider/codex-app-server'
|
||
import {
|
||
ensureGenofficeLogin,
|
||
gskApiKey,
|
||
generateImageTool,
|
||
testSearchProvider,
|
||
gskLoginInfo,
|
||
hasGskAuth,
|
||
webSearchTool,
|
||
imageSearchTool,
|
||
} from '@genoffice/ai-search'
|
||
import type {
|
||
AiDocContent,
|
||
AttachmentAddResult,
|
||
AttachmentImageResult,
|
||
AttachmentMeta,
|
||
AttachmentReadResult,
|
||
CreateDocumentRequest,
|
||
CreateDocumentResult,
|
||
DecryptOpenResult,
|
||
DocsTabInfo,
|
||
MenuCommand,
|
||
OpenDocxResult,
|
||
} from '../shared/ipc'
|
||
import { ATTACHMENT_IMAGE_EXTS } from '../shared/ipc'
|
||
import { findDocxPath } from '../shared/open-file'
|
||
import { atomicWriteFile, looksLikeZip } from './atomic-write'
|
||
import {
|
||
commitDocPasswordSave,
|
||
currentDocPasswordIntentRevision,
|
||
decryptDocx,
|
||
decryptRecoveryCopy,
|
||
discardDocPasswordIntents,
|
||
DocxDecryptError,
|
||
docPasswordFor,
|
||
encryptDocx,
|
||
forgetDocPasswords,
|
||
isEncryptedDocx,
|
||
markDiskEncrypted,
|
||
prepareRecoveryDocx,
|
||
rememberDocPassword,
|
||
renameDocPassword,
|
||
setDocPassword,
|
||
snapshotDocPassword,
|
||
} from './docx-encryption'
|
||
import { isExternallyModified, type DiskFileState } from './external-change'
|
||
import { initDocsAutoUpdater } from './updater'
|
||
|
||
/**
|
||
* Docs main-process logic as an embeddable module: no top-level side effects.
|
||
* Standalone mode (apps/docs entry) calls startDocsStandalone(); the unified
|
||
* shell (apps/shell) instead calls configureDocsRuntime() + registerDocsIpc()
|
||
* + createDocsWindow() and owns the app lifecycle itself.
|
||
*/
|
||
|
||
const isDev = !!process.env.ELECTRON_RENDERER_URL
|
||
|
||
const tMain = createI18n({
|
||
zh: {
|
||
dlgOpenDoc: '打开文档',
|
||
filterWord: 'Word 文档',
|
||
dlgSaveAs: '另存为',
|
||
closeUnsavedMsg: '此文档有未保存的更改。',
|
||
closeUnsavedDetail: '关闭前是否保存?',
|
||
closeNoReplyMsg: '文档没有响应,可能有未保存的更改。',
|
||
closeNoReplyDetail: '仍要关闭吗?未保存的更改将丢失。',
|
||
btnCloseAnyway: '仍要关闭',
|
||
autosaveFoundTitle: '发现自动恢复版本',
|
||
autosaveFoundBody: '上次会话有未保存的更改。要恢复自动保存的版本吗?',
|
||
autosaveRestore: '恢复',
|
||
autosaveDiscard: '放弃',
|
||
btnDontSave: '不保存',
|
||
btnCancel: '取消',
|
||
extModifiedMsg: '文件已被其他程序修改。',
|
||
extModifiedDetail: '仍要保存并覆盖磁盘上的更改吗?',
|
||
btnOverwrite: '覆盖',
|
||
dlgInsertImage: '插入图片',
|
||
filterImages: '图片',
|
||
dlgAddAttachment: '添加附件',
|
||
filterSupported: '支持的文件',
|
||
filterAll: '所有文件',
|
||
dlgExportPdf: '导出为 PDF',
|
||
dlgExportHtml: '导出为 HTML',
|
||
errUnsupportedExt: '暂不支持 .{ext} 类型',
|
||
errNotFile: '不是文件',
|
||
errTooLarge: '超过 {mb}MB 上限',
|
||
errImageTooLarge: '图片超过 5MB 上限',
|
||
errUnreadable: '无法读取',
|
||
errFileTooLarge: '文件超过大小上限',
|
||
errParseFailed: '文件解析失败',
|
||
errImageNoText: '图片附件不提供文本,已作为图像随用户消息发送,直接看图即可',
|
||
errNotImage: '不是支持的图片类型',
|
||
errGskNotLoggedIn: '未登录 Genspark:请点击下方「登录 Genspark」完成登录后重试',
|
||
errNoApiKey: '未配置 {provider} 的 API Key',
|
||
errAiBusy: 'AI 服务当前繁忙,请稍后重试',
|
||
errNoModel: '未配置模型名称',
|
||
menuFile: '文件',
|
||
menuNewDoc: '新建文档',
|
||
menuNewWindow: '新建窗口',
|
||
menuOpen: '打开…',
|
||
menuOpenRecent: '打开最近的文档',
|
||
menuNoRecent: '无最近文档',
|
||
menuClose: '关闭',
|
||
menuSave: '保存',
|
||
menuSaveAs: '另存为…',
|
||
menuPageSetup: '页面设置…',
|
||
menuExportPdf: '导出为 PDF…',
|
||
menuExportHtml: '导出为 HTML…',
|
||
menuPrint: '打印…',
|
||
menuEdit: '编辑',
|
||
menuUndo: '撤销',
|
||
menuRedo: '重做',
|
||
menuCut: '剪切',
|
||
menuCopy: '复制',
|
||
menuPaste: '粘贴',
|
||
menuPasteMatch: '粘贴并匹配格式',
|
||
menuFindReplace: '查找和替换…',
|
||
menuSelectAll: '全选',
|
||
menuView: '视图',
|
||
menuZoomIn: '放大',
|
||
menuZoomOut: '缩小',
|
||
menuZoom100: '实际大小 (100%)',
|
||
menuPageWidth: '页宽',
|
||
menuWholePage: '整页',
|
||
menuAiSidebar: 'AI 侧栏',
|
||
menuDarkMode: '深色模式',
|
||
menuFullscreen: '进入全屏',
|
||
menuInsert: '插入',
|
||
menuInsertTable: '表格(3×3)',
|
||
menuInsertImage: '图片…',
|
||
menuInsertPageBreak: '分页符',
|
||
menuInsertLink: '超链接…',
|
||
menuInsertEquation: '公式…',
|
||
menuComment: '批注',
|
||
menuFormat: '格式',
|
||
menuBold: '加粗',
|
||
menuItalic: '斜体',
|
||
menuUnderline: '下划线',
|
||
menuAlign: '对齐',
|
||
menuAlignLeft: '左对齐',
|
||
menuAlignCenter: '居中',
|
||
menuAlignRight: '右对齐',
|
||
menuAlignJustify: '两端对齐',
|
||
menuFont: '字体…',
|
||
menuParagraph: '段落…',
|
||
menuTools: '工具',
|
||
menuWordCount: '字数统计…',
|
||
menuAiProofread: 'AI 校对',
|
||
menuWindow: '窗口',
|
||
menuHelp: '帮助',
|
||
menuShortcuts: '键盘快捷键',
|
||
menuDocsHelp: 'GenOffice Docs 帮助',
|
||
},
|
||
en: {
|
||
dlgOpenDoc: 'Open Document',
|
||
filterWord: 'Word Documents',
|
||
dlgSaveAs: 'Save As',
|
||
closeUnsavedMsg: 'This document has unsaved changes.',
|
||
closeUnsavedDetail: 'Do you want to save them before closing?',
|
||
closeNoReplyMsg: 'The document is not responding and may have unsaved changes.',
|
||
closeNoReplyDetail: 'Close anyway? Unsaved changes will be lost.',
|
||
btnCloseAnyway: 'Close Anyway',
|
||
autosaveFoundTitle: 'Recovered version found',
|
||
autosaveFoundBody:
|
||
'There are unsaved changes from your last session. Restore the autosaved version?',
|
||
autosaveRestore: 'Restore',
|
||
autosaveDiscard: 'Discard',
|
||
btnDontSave: "Don't Save",
|
||
btnCancel: 'Cancel',
|
||
extModifiedMsg: 'The file has been modified by another program.',
|
||
extModifiedDetail: 'Save anyway and overwrite the changes on disk?',
|
||
btnOverwrite: 'Overwrite',
|
||
dlgInsertImage: 'Insert Image',
|
||
filterImages: 'Images',
|
||
dlgAddAttachment: 'Add Attachments',
|
||
filterSupported: 'Supported Files',
|
||
filterAll: 'All Files',
|
||
dlgExportPdf: 'Export as PDF',
|
||
dlgExportHtml: 'Export as HTML',
|
||
errUnsupportedExt: '.{ext} files are not supported',
|
||
errNotFile: 'not a file',
|
||
errTooLarge: 'exceeds the {mb}MB limit',
|
||
errImageTooLarge: 'image exceeds the 5MB limit',
|
||
errUnreadable: 'cannot be read',
|
||
errFileTooLarge: 'File exceeds the size limit',
|
||
errParseFailed: 'Failed to parse file',
|
||
errImageNoText: 'Image attachments have no text; the image is sent along with the user message',
|
||
errNotImage: 'not a supported image type',
|
||
errGskNotLoggedIn:
|
||
'Not signed in to Genspark: click “Sign in to Genspark” below, sign in, then retry',
|
||
errNoApiKey: 'No API key configured for {provider}',
|
||
errAiBusy: 'The AI service is busy right now — please try again in a moment',
|
||
errNoModel: 'No model name configured',
|
||
menuFile: 'File',
|
||
menuNewDoc: 'New Document',
|
||
menuNewWindow: 'New Window',
|
||
menuOpen: 'Open…',
|
||
menuOpenRecent: 'Open Recent',
|
||
menuNoRecent: 'No Recent Documents',
|
||
menuClose: 'Close',
|
||
menuSave: 'Save',
|
||
menuSaveAs: 'Save As…',
|
||
menuPageSetup: 'Page Setup…',
|
||
menuExportPdf: 'Export as PDF…',
|
||
menuExportHtml: 'Export as HTML…',
|
||
menuPrint: 'Print…',
|
||
menuEdit: 'Edit',
|
||
menuUndo: 'Undo',
|
||
menuRedo: 'Redo',
|
||
menuCut: 'Cut',
|
||
menuCopy: 'Copy',
|
||
menuPaste: 'Paste',
|
||
menuPasteMatch: 'Paste and Match Style',
|
||
menuFindReplace: 'Find and Replace…',
|
||
menuSelectAll: 'Select All',
|
||
menuView: 'View',
|
||
menuZoomIn: 'Zoom In',
|
||
menuZoomOut: 'Zoom Out',
|
||
menuZoom100: 'Actual Size (100%)',
|
||
menuPageWidth: 'Page Width',
|
||
menuWholePage: 'Whole Page',
|
||
menuAiSidebar: 'AI Sidebar',
|
||
menuDarkMode: 'Dark Mode',
|
||
menuFullscreen: 'Enter Full Screen',
|
||
menuInsert: 'Insert',
|
||
menuInsertTable: 'Table (3×3)',
|
||
menuInsertImage: 'Image…',
|
||
menuInsertPageBreak: 'Page Break',
|
||
menuInsertLink: 'Hyperlink…',
|
||
menuInsertEquation: 'Equation…',
|
||
menuComment: 'Comment',
|
||
menuFormat: 'Format',
|
||
menuBold: 'Bold',
|
||
menuItalic: 'Italic',
|
||
menuUnderline: 'Underline',
|
||
menuAlign: 'Align',
|
||
menuAlignLeft: 'Align Left',
|
||
menuAlignCenter: 'Center',
|
||
menuAlignRight: 'Align Right',
|
||
menuAlignJustify: 'Justify',
|
||
menuFont: 'Font…',
|
||
menuParagraph: 'Paragraph…',
|
||
menuTools: 'Tools',
|
||
menuWordCount: 'Word Count…',
|
||
menuAiProofread: 'AI Proofread',
|
||
menuWindow: 'Window',
|
||
menuHelp: 'Help',
|
||
menuShortcuts: 'Keyboard Shortcuts',
|
||
menuDocsHelp: 'GenOffice Docs Help',
|
||
},
|
||
ja: {
|
||
dlgOpenDoc: '文書を開く',
|
||
filterWord: 'Word 文書',
|
||
dlgSaveAs: '名前を付けて保存',
|
||
closeUnsavedMsg: 'このドキュメントに未保存の変更があります。',
|
||
closeUnsavedDetail: '閉じる前に保存しますか?',
|
||
closeNoReplyMsg: 'ドキュメントが応答していません。未保存の変更がある可能性があります。',
|
||
closeNoReplyDetail: 'それでも閉じますか?未保存の変更は失われます。',
|
||
btnCloseAnyway: '閉じる',
|
||
autosaveFoundTitle: '自動回復バージョンがあります',
|
||
autosaveFoundBody: '前回のセッションに未保存の変更があります。自動保存版を復元しますか?',
|
||
autosaveRestore: '復元',
|
||
autosaveDiscard: '破棄',
|
||
btnDontSave: '保存しない',
|
||
btnCancel: 'キャンセル',
|
||
extModifiedMsg: 'このファイルは別のプログラムによって変更されています。',
|
||
extModifiedDetail: 'このまま保存してディスク上の変更を上書きしますか?',
|
||
btnOverwrite: '上書き',
|
||
dlgInsertImage: '画像の挿入',
|
||
filterImages: '画像',
|
||
dlgAddAttachment: '添付ファイルの追加',
|
||
filterSupported: 'サポートされているファイル',
|
||
filterAll: 'すべてのファイル',
|
||
dlgExportPdf: 'PDF としてエクスポート',
|
||
dlgExportHtml: 'HTML としてエクスポート',
|
||
errUnsupportedExt: '.{ext} 形式には対応していません',
|
||
errNotFile: 'ファイルではありません',
|
||
errTooLarge: '{mb}MB の上限を超えています',
|
||
errImageTooLarge: '画像が 5MB の上限を超えています',
|
||
errUnreadable: '読み取れません',
|
||
errFileTooLarge: 'ファイルがサイズ上限を超えています',
|
||
errParseFailed: 'ファイルの解析に失敗しました',
|
||
errImageNoText:
|
||
'画像の添付ファイルはテキストを提供しません。画像としてユーザーメッセージと一緒に送信されるため、そのまま画像をご確認ください',
|
||
errNotImage: 'サポートされていない画像形式です',
|
||
errGskNotLoggedIn:
|
||
'Genspark にサインインしていません。下の「Genspark にサインイン」からサインインして再試行してください',
|
||
errNoApiKey: '{provider} の API キーが設定されていません',
|
||
errAiBusy: 'AI サービスが混み合っています。しばらくしてからもう一度お試しください',
|
||
errNoModel: 'モデル名が設定されていません',
|
||
menuFile: 'ファイル',
|
||
menuNewDoc: '新規文書',
|
||
menuNewWindow: '新規ウィンドウ',
|
||
menuOpen: '開く…',
|
||
menuOpenRecent: '最近使った文書を開く',
|
||
menuNoRecent: '最近使った文書はありません',
|
||
menuClose: '閉じる',
|
||
menuSave: '保存',
|
||
menuSaveAs: '名前を付けて保存…',
|
||
menuPageSetup: 'ページ設定…',
|
||
menuExportPdf: 'PDF としてエクスポート…',
|
||
menuExportHtml: 'HTML としてエクスポート…',
|
||
menuPrint: '印刷…',
|
||
menuEdit: '編集',
|
||
menuUndo: '元に戻す',
|
||
menuRedo: 'やり直す',
|
||
menuCut: '切り取り',
|
||
menuCopy: 'コピー',
|
||
menuPaste: '貼り付け',
|
||
menuPasteMatch: '貼り付けて書式を合わせる',
|
||
menuFindReplace: '検索と置換…',
|
||
menuSelectAll: 'すべて選択',
|
||
menuView: '表示',
|
||
menuZoomIn: '拡大',
|
||
menuZoomOut: '縮小',
|
||
menuZoom100: '実際のサイズ (100%)',
|
||
menuPageWidth: 'ページ幅',
|
||
menuWholePage: 'ページ全体',
|
||
menuAiSidebar: 'AI サイドバー',
|
||
menuDarkMode: 'ダークモード',
|
||
menuFullscreen: 'フルスクリーンにする',
|
||
menuInsert: '挿入',
|
||
menuInsertTable: '表 (3×3)',
|
||
menuInsertImage: '画像…',
|
||
menuInsertPageBreak: '改ページ',
|
||
menuInsertLink: 'ハイパーリンク…',
|
||
menuInsertEquation: '数式…',
|
||
menuComment: 'コメント',
|
||
menuFormat: '書式',
|
||
menuBold: '太字',
|
||
menuItalic: '斜体',
|
||
menuUnderline: '下線',
|
||
menuAlign: '配置',
|
||
menuAlignLeft: '左揃え',
|
||
menuAlignCenter: '中央揃え',
|
||
menuAlignRight: '右揃え',
|
||
menuAlignJustify: '両端揃え',
|
||
menuFont: 'フォント…',
|
||
menuParagraph: '段落…',
|
||
menuTools: 'ツール',
|
||
menuWordCount: '文字カウント…',
|
||
menuAiProofread: 'AI 校正',
|
||
menuWindow: 'ウィンドウ',
|
||
menuHelp: 'ヘルプ',
|
||
menuShortcuts: 'キーボードショートカット',
|
||
menuDocsHelp: 'GenOffice Docs ヘルプ',
|
||
},
|
||
ko: {
|
||
dlgOpenDoc: '문서 열기',
|
||
filterWord: 'Word 문서',
|
||
dlgSaveAs: '다른 이름으로 저장',
|
||
closeUnsavedMsg: '이 문서에 저장하지 않은 변경 사항이 있습니다.',
|
||
closeUnsavedDetail: '닫기 전에 저장하시겠습니까?',
|
||
closeNoReplyMsg: '문서가 응답하지 않으며 저장하지 않은 변경 사항이 있을 수 있습니다.',
|
||
closeNoReplyDetail: '그래도 닫을까요? 저장하지 않은 변경 사항은 사라집니다.',
|
||
btnCloseAnyway: '닫기',
|
||
autosaveFoundTitle: '자동 복구 버전 발견',
|
||
autosaveFoundBody:
|
||
'마지막 세션에 저장되지 않은 변경 내용이 있습니다. 자동 저장 버전을 복원할까요?',
|
||
autosaveRestore: '복원',
|
||
autosaveDiscard: '취소',
|
||
btnDontSave: '저장 안 함',
|
||
btnCancel: '취소',
|
||
extModifiedMsg: '이 파일이 다른 프로그램에서 수정되었습니다.',
|
||
extModifiedDetail: '그래도 저장하여 디스크의 변경 사항을 덮어쓸까요?',
|
||
btnOverwrite: '덮어쓰기',
|
||
dlgInsertImage: '그림 삽입',
|
||
filterImages: '그림',
|
||
dlgAddAttachment: '첨부 파일 추가',
|
||
filterSupported: '지원되는 파일',
|
||
filterAll: '모든 파일',
|
||
dlgExportPdf: 'PDF로 내보내기',
|
||
dlgExportHtml: 'HTML로 내보내기',
|
||
errUnsupportedExt: '.{ext} 형식은 지원되지 않습니다',
|
||
errNotFile: '파일이 아닙니다',
|
||
errTooLarge: '{mb}MB 제한을 초과했습니다',
|
||
errImageTooLarge: '이미지가 5MB 제한을 초과했습니다',
|
||
errUnreadable: '읽을 수 없습니다',
|
||
errFileTooLarge: '파일이 크기 제한을 초과했습니다',
|
||
errParseFailed: '파일을 분석하지 못했습니다',
|
||
errImageNoText:
|
||
'이미지 첨부 파일은 텍스트를 제공하지 않으며, 이미지 형태로 사용자 메시지와 함께 전송되므로 이미지를 직접 확인하면 됩니다',
|
||
errNotImage: '지원되지 않는 이미지 형식입니다',
|
||
errGskNotLoggedIn:
|
||
'Genspark에 로그인되어 있지 않습니다. 아래 "Genspark 로그인"을 눌러 로그인한 뒤 다시 시도하세요',
|
||
errNoApiKey: '{provider}의 API 키가 설정되지 않았습니다',
|
||
errAiBusy: 'AI 서비스가 혼잡합니다. 잠시 후 다시 시도해 주세요',
|
||
errNoModel: '모델 이름이 설정되지 않았습니다',
|
||
menuFile: '파일',
|
||
menuNewDoc: '새 문서',
|
||
menuNewWindow: '새 창',
|
||
menuOpen: '열기…',
|
||
menuOpenRecent: '최근 문서 열기',
|
||
menuNoRecent: '최근 문서 없음',
|
||
menuClose: '닫기',
|
||
menuSave: '저장',
|
||
menuSaveAs: '다른 이름으로 저장…',
|
||
menuPageSetup: '페이지 설정…',
|
||
menuExportPdf: 'PDF로 내보내기…',
|
||
menuExportHtml: 'HTML로 내보내기…',
|
||
menuPrint: '인쇄…',
|
||
menuEdit: '편집',
|
||
menuUndo: '실행 취소',
|
||
menuRedo: '다시 실행',
|
||
menuCut: '잘라내기',
|
||
menuCopy: '복사',
|
||
menuPaste: '붙여넣기',
|
||
menuPasteMatch: '서식 맞춰 붙여넣기',
|
||
menuFindReplace: '찾기 및 바꾸기…',
|
||
menuSelectAll: '모두 선택',
|
||
menuView: '보기',
|
||
menuZoomIn: '확대',
|
||
menuZoomOut: '축소',
|
||
menuZoom100: '실제 크기(100%)',
|
||
menuPageWidth: '페이지 너비',
|
||
menuWholePage: '전체 페이지',
|
||
menuAiSidebar: 'AI 사이드바',
|
||
menuDarkMode: '다크 모드',
|
||
menuFullscreen: '전체 화면 시작',
|
||
menuInsert: '삽입',
|
||
menuInsertTable: '표(3×3)',
|
||
menuInsertImage: '그림…',
|
||
menuInsertPageBreak: '페이지 나누기',
|
||
menuInsertLink: '하이퍼링크…',
|
||
menuInsertEquation: '수식…',
|
||
menuComment: '메모',
|
||
menuFormat: '서식',
|
||
menuBold: '굵게',
|
||
menuItalic: '기울임꼴',
|
||
menuUnderline: '밑줄',
|
||
menuAlign: '맞춤',
|
||
menuAlignLeft: '왼쪽 맞춤',
|
||
menuAlignCenter: '가운데 맞춤',
|
||
menuAlignRight: '오른쪽 맞춤',
|
||
menuAlignJustify: '양쪽 맞춤',
|
||
menuFont: '글꼴…',
|
||
menuParagraph: '단락…',
|
||
menuTools: '도구',
|
||
menuWordCount: '단어 개수…',
|
||
menuAiProofread: 'AI 교정',
|
||
menuWindow: '창',
|
||
menuHelp: '도움말',
|
||
menuShortcuts: '키보드 바로 가기',
|
||
menuDocsHelp: 'GenOffice Docs 도움말',
|
||
},
|
||
fr: {
|
||
dlgOpenDoc: 'Ouvrir un document',
|
||
filterWord: 'Documents Word',
|
||
dlgSaveAs: 'Enregistrer sous',
|
||
closeUnsavedMsg: 'Ce document contient des modifications non enregistrées.',
|
||
closeUnsavedDetail: 'Voulez-vous les enregistrer avant de fermer ?',
|
||
closeNoReplyMsg:
|
||
'Le document ne répond pas et peut contenir des modifications non enregistrées.',
|
||
closeNoReplyDetail: 'Fermer quand même ? Les modifications non enregistrées seront perdues.',
|
||
btnCloseAnyway: 'Fermer quand même',
|
||
autosaveFoundTitle: 'Version récupérée trouvée',
|
||
autosaveFoundBody:
|
||
'Des modifications non enregistrées existent. Restaurer la version auto-enregistrée ?',
|
||
autosaveRestore: 'Restaurer',
|
||
autosaveDiscard: 'Ignorer',
|
||
btnDontSave: 'Ne pas enregistrer',
|
||
btnCancel: 'Annuler',
|
||
extModifiedMsg: 'Le fichier a été modifié par un autre programme.',
|
||
extModifiedDetail: 'Enregistrer quand même et écraser les modifications sur le disque ?',
|
||
btnOverwrite: 'Écraser',
|
||
dlgInsertImage: 'Insérer une image',
|
||
filterImages: 'Images',
|
||
dlgAddAttachment: 'Ajouter des pièces jointes',
|
||
filterSupported: 'Fichiers pris en charge',
|
||
filterAll: 'Tous les fichiers',
|
||
dlgExportPdf: 'Exporter au format PDF',
|
||
dlgExportHtml: 'Exporter au format HTML',
|
||
errUnsupportedExt: 'les fichiers .{ext} ne sont pas pris en charge',
|
||
errNotFile: "n'est pas un fichier",
|
||
errTooLarge: 'dépasse la limite de {mb} Mo',
|
||
errImageTooLarge: "l'image dépasse la limite de 5 Mo",
|
||
errUnreadable: 'lecture impossible',
|
||
errFileTooLarge: 'Le fichier dépasse la taille maximale',
|
||
errParseFailed: "Échec de l'analyse du fichier",
|
||
errImageNoText:
|
||
"Les pièces jointes image ne fournissent pas de texte ; l'image est envoyée avec le message de l'utilisateur, consultez-la directement",
|
||
errNotImage: "type d'image non pris en charge",
|
||
errGskNotLoggedIn:
|
||
'Non connecté à Genspark : cliquez sur « Se connecter à Genspark » ci-dessous, connectez-vous puis réessayez',
|
||
errNoApiKey: 'Aucune clé API configurée pour {provider}',
|
||
errAiBusy: "Le service d'IA est actuellement surchargé — réessayez dans un instant",
|
||
errNoModel: 'Aucun nom de modèle configuré',
|
||
menuFile: 'Fichier',
|
||
menuNewDoc: 'Nouveau document',
|
||
menuNewWindow: 'Nouvelle fenêtre',
|
||
menuOpen: 'Ouvrir…',
|
||
menuOpenRecent: 'Ouvrir un document récent',
|
||
menuNoRecent: 'Aucun document récent',
|
||
menuClose: 'Fermer',
|
||
menuSave: 'Enregistrer',
|
||
menuSaveAs: 'Enregistrer sous…',
|
||
menuPageSetup: 'Mise en page…',
|
||
menuExportPdf: 'Exporter au format PDF…',
|
||
menuExportHtml: 'Exporter au format HTML…',
|
||
menuPrint: 'Imprimer…',
|
||
menuEdit: 'Édition',
|
||
menuUndo: 'Annuler',
|
||
menuRedo: 'Rétablir',
|
||
menuCut: 'Couper',
|
||
menuCopy: 'Copier',
|
||
menuPaste: 'Coller',
|
||
menuPasteMatch: 'Coller et adapter le style',
|
||
menuFindReplace: 'Rechercher et remplacer…',
|
||
menuSelectAll: 'Tout sélectionner',
|
||
menuView: 'Affichage',
|
||
menuZoomIn: 'Zoom avant',
|
||
menuZoomOut: 'Zoom arrière',
|
||
menuZoom100: 'Taille réelle (100 %)',
|
||
menuPageWidth: 'Largeur de page',
|
||
menuWholePage: 'Page entière',
|
||
menuAiSidebar: 'Volet IA',
|
||
menuDarkMode: 'Mode sombre',
|
||
menuFullscreen: 'Activer le mode plein écran',
|
||
menuInsert: 'Insertion',
|
||
menuInsertTable: 'Tableau (3×3)',
|
||
menuInsertImage: 'Image…',
|
||
menuInsertPageBreak: 'Saut de page',
|
||
menuInsertLink: 'Lien hypertexte…',
|
||
menuInsertEquation: 'Équation…',
|
||
menuComment: 'Commentaire',
|
||
menuFormat: 'Format',
|
||
menuBold: 'Gras',
|
||
menuItalic: 'Italique',
|
||
menuUnderline: 'Souligné',
|
||
menuAlign: 'Alignement',
|
||
menuAlignLeft: 'Aligner à gauche',
|
||
menuAlignCenter: 'Centrer',
|
||
menuAlignRight: 'Aligner à droite',
|
||
menuAlignJustify: 'Justifier',
|
||
menuFont: 'Police…',
|
||
menuParagraph: 'Paragraphe…',
|
||
menuTools: 'Outils',
|
||
menuWordCount: 'Statistiques…',
|
||
menuAiProofread: 'Relecture IA',
|
||
menuWindow: 'Fenêtre',
|
||
menuHelp: 'Aide',
|
||
menuShortcuts: 'Raccourcis clavier',
|
||
menuDocsHelp: 'Aide GenOffice Docs',
|
||
},
|
||
de: {
|
||
dlgOpenDoc: 'Dokument öffnen',
|
||
filterWord: 'Word-Dokumente',
|
||
dlgSaveAs: 'Speichern unter',
|
||
closeUnsavedMsg: 'Dieses Dokument enthält ungespeicherte Änderungen.',
|
||
closeUnsavedDetail: 'Vor dem Schließen speichern?',
|
||
closeNoReplyMsg:
|
||
'Das Dokument reagiert nicht und enthält möglicherweise ungespeicherte Änderungen.',
|
||
closeNoReplyDetail: 'Trotzdem schließen? Ungespeicherte Änderungen gehen verloren.',
|
||
btnCloseAnyway: 'Trotzdem schließen',
|
||
autosaveFoundTitle: 'Wiederhergestellte Version gefunden',
|
||
autosaveFoundBody:
|
||
'Es gibt ungespeicherte Änderungen. Automatisch gespeicherte Version wiederherstellen?',
|
||
autosaveRestore: 'Wiederherstellen',
|
||
autosaveDiscard: 'Verwerfen',
|
||
btnDontSave: 'Nicht speichern',
|
||
btnCancel: 'Abbrechen',
|
||
extModifiedMsg: 'Die Datei wurde von einem anderen Programm geändert.',
|
||
extModifiedDetail: 'Trotzdem speichern und die Änderungen auf dem Datenträger überschreiben?',
|
||
btnOverwrite: 'Überschreiben',
|
||
dlgInsertImage: 'Bild einfügen',
|
||
filterImages: 'Bilder',
|
||
dlgAddAttachment: 'Anlagen hinzufügen',
|
||
filterSupported: 'Unterstützte Dateien',
|
||
filterAll: 'Alle Dateien',
|
||
dlgExportPdf: 'Als PDF exportieren',
|
||
dlgExportHtml: 'Als HTML exportieren',
|
||
errUnsupportedExt: '.{ext}-Dateien werden nicht unterstützt',
|
||
errNotFile: 'keine Datei',
|
||
errTooLarge: 'überschreitet das Limit von {mb} MB',
|
||
errImageTooLarge: 'Bild überschreitet das Limit von 5 MB',
|
||
errUnreadable: 'kann nicht gelesen werden',
|
||
errFileTooLarge: 'Datei überschreitet die maximale Größe',
|
||
errParseFailed: 'Datei konnte nicht analysiert werden',
|
||
errImageNoText:
|
||
'Bildanlagen liefern keinen Text; das Bild wird mit der Benutzernachricht gesendet und kann direkt betrachtet werden',
|
||
errNotImage: 'kein unterstütztes Bildformat',
|
||
errGskNotLoggedIn:
|
||
'Nicht bei Genspark angemeldet: Klicken Sie unten auf „Bei Genspark anmelden“, melden Sie sich an und versuchen Sie es erneut',
|
||
errNoApiKey: 'Kein API-Schlüssel für {provider} konfiguriert',
|
||
errAiBusy: 'Der KI-Dienst ist derzeit überlastet — bitte gleich erneut versuchen',
|
||
errNoModel: 'Kein Modellname konfiguriert',
|
||
menuFile: 'Datei',
|
||
menuNewDoc: 'Neues Dokument',
|
||
menuNewWindow: 'Neues Fenster',
|
||
menuOpen: 'Öffnen…',
|
||
menuOpenRecent: 'Zuletzt verwendete Dokumente',
|
||
menuNoRecent: 'Keine zuletzt verwendeten Dokumente',
|
||
menuClose: 'Schließen',
|
||
menuSave: 'Speichern',
|
||
menuSaveAs: 'Speichern unter…',
|
||
menuPageSetup: 'Seite einrichten…',
|
||
menuExportPdf: 'Als PDF exportieren…',
|
||
menuExportHtml: 'Als HTML exportieren…',
|
||
menuPrint: 'Drucken…',
|
||
menuEdit: 'Bearbeiten',
|
||
menuUndo: 'Rückgängig',
|
||
menuRedo: 'Wiederholen',
|
||
menuCut: 'Ausschneiden',
|
||
menuCopy: 'Kopieren',
|
||
menuPaste: 'Einfügen',
|
||
menuPasteMatch: 'Einfügen und Stil anpassen',
|
||
menuFindReplace: 'Suchen und Ersetzen…',
|
||
menuSelectAll: 'Alles auswählen',
|
||
menuView: 'Ansicht',
|
||
menuZoomIn: 'Vergrößern',
|
||
menuZoomOut: 'Verkleinern',
|
||
menuZoom100: 'Originalgröße (100 %)',
|
||
menuPageWidth: 'Seitenbreite',
|
||
menuWholePage: 'Ganze Seite',
|
||
menuAiSidebar: 'KI-Seitenleiste',
|
||
menuDarkMode: 'Dunkelmodus',
|
||
menuFullscreen: 'Vollbild ein',
|
||
menuInsert: 'Einfügen',
|
||
menuInsertTable: 'Tabelle (3×3)',
|
||
menuInsertImage: 'Bild…',
|
||
menuInsertPageBreak: 'Seitenumbruch',
|
||
menuInsertLink: 'Hyperlink…',
|
||
menuInsertEquation: 'Formel…',
|
||
menuComment: 'Kommentar',
|
||
menuFormat: 'Format',
|
||
menuBold: 'Fett',
|
||
menuItalic: 'Kursiv',
|
||
menuUnderline: 'Unterstrichen',
|
||
menuAlign: 'Ausrichten',
|
||
menuAlignLeft: 'Linksbündig',
|
||
menuAlignCenter: 'Zentriert',
|
||
menuAlignRight: 'Rechtsbündig',
|
||
menuAlignJustify: 'Blocksatz',
|
||
menuFont: 'Schriftart…',
|
||
menuParagraph: 'Absatz…',
|
||
menuTools: 'Extras',
|
||
menuWordCount: 'Wörter zählen…',
|
||
menuAiProofread: 'KI-Korrektur',
|
||
menuWindow: 'Fenster',
|
||
menuHelp: 'Hilfe',
|
||
menuShortcuts: 'Tastenkombinationen',
|
||
menuDocsHelp: 'GenOffice Docs-Hilfe',
|
||
},
|
||
es: {
|
||
dlgOpenDoc: 'Abrir documento',
|
||
filterWord: 'Documentos de Word',
|
||
dlgSaveAs: 'Guardar como',
|
||
closeUnsavedMsg: 'Este documento tiene cambios sin guardar.',
|
||
closeUnsavedDetail: '¿Desea guardarlos antes de cerrar?',
|
||
closeNoReplyMsg: 'El documento no responde y puede tener cambios sin guardar.',
|
||
closeNoReplyDetail: '¿Cerrar de todos modos? Los cambios sin guardar se perderán.',
|
||
btnCloseAnyway: 'Cerrar de todos modos',
|
||
autosaveFoundTitle: 'Se encontró una versión recuperada',
|
||
autosaveFoundBody:
|
||
'Hay cambios sin guardar de la última sesión. ¿Restaurar la versión autoguardada?',
|
||
autosaveRestore: 'Restaurar',
|
||
autosaveDiscard: 'Descartar',
|
||
btnDontSave: 'No guardar',
|
||
btnCancel: 'Cancelar',
|
||
extModifiedMsg: 'El archivo ha sido modificado por otro programa.',
|
||
extModifiedDetail: '¿Guardar de todos modos y sobrescribir los cambios en el disco?',
|
||
btnOverwrite: 'Sobrescribir',
|
||
dlgInsertImage: 'Insertar imagen',
|
||
filterImages: 'Imágenes',
|
||
dlgAddAttachment: 'Agregar datos adjuntos',
|
||
filterSupported: 'Archivos compatibles',
|
||
filterAll: 'Todos los archivos',
|
||
dlgExportPdf: 'Exportar como PDF',
|
||
dlgExportHtml: 'Exportar como HTML',
|
||
errUnsupportedExt: 'los archivos .{ext} no son compatibles',
|
||
errNotFile: 'no es un archivo',
|
||
errTooLarge: 'supera el límite de {mb} MB',
|
||
errImageTooLarge: 'la imagen supera el límite de 5 MB',
|
||
errUnreadable: 'no se puede leer',
|
||
errFileTooLarge: 'El archivo supera el tamaño máximo',
|
||
errParseFailed: 'No se pudo analizar el archivo',
|
||
errImageNoText:
|
||
'Las imágenes adjuntas no proporcionan texto; la imagen se envía junto con el mensaje del usuario, puedes verla directamente',
|
||
errNotImage: 'no es un tipo de imagen compatible',
|
||
errGskNotLoggedIn:
|
||
'No has iniciado sesión en Genspark: pulsa «Iniciar sesión en Genspark» abajo, inicia sesión y vuelve a intentarlo',
|
||
errNoApiKey: 'No hay clave de API configurada para {provider}',
|
||
errAiBusy:
|
||
'El servicio de IA está saturado en este momento; inténtalo de nuevo en unos instantes',
|
||
errNoModel: 'No se ha configurado el nombre del modelo',
|
||
menuFile: 'Archivo',
|
||
menuNewDoc: 'Nuevo documento',
|
||
menuNewWindow: 'Nueva ventana',
|
||
menuOpen: 'Abrir…',
|
||
menuOpenRecent: 'Abrir recientes',
|
||
menuNoRecent: 'No hay documentos recientes',
|
||
menuClose: 'Cerrar',
|
||
menuSave: 'Guardar',
|
||
menuSaveAs: 'Guardar como…',
|
||
menuPageSetup: 'Configurar página…',
|
||
menuExportPdf: 'Exportar como PDF…',
|
||
menuExportHtml: 'Exportar como HTML…',
|
||
menuPrint: 'Imprimir…',
|
||
menuEdit: 'Edición',
|
||
menuUndo: 'Deshacer',
|
||
menuRedo: 'Rehacer',
|
||
menuCut: 'Cortar',
|
||
menuCopy: 'Copiar',
|
||
menuPaste: 'Pegar',
|
||
menuPasteMatch: 'Pegar con el mismo estilo',
|
||
menuFindReplace: 'Buscar y reemplazar…',
|
||
menuSelectAll: 'Seleccionar todo',
|
||
menuView: 'Ver',
|
||
menuZoomIn: 'Acercar',
|
||
menuZoomOut: 'Alejar',
|
||
menuZoom100: 'Tamaño real (100 %)',
|
||
menuPageWidth: 'Ancho de página',
|
||
menuWholePage: 'Página completa',
|
||
menuAiSidebar: 'Barra lateral de IA',
|
||
menuDarkMode: 'Modo oscuro',
|
||
menuFullscreen: 'Usar pantalla completa',
|
||
menuInsert: 'Insertar',
|
||
menuInsertTable: 'Tabla (3×3)',
|
||
menuInsertImage: 'Imagen…',
|
||
menuInsertPageBreak: 'Salto de página',
|
||
menuInsertLink: 'Hipervínculo…',
|
||
menuInsertEquation: 'Ecuación…',
|
||
menuComment: 'Comentario',
|
||
menuFormat: 'Formato',
|
||
menuBold: 'Negrita',
|
||
menuItalic: 'Cursiva',
|
||
menuUnderline: 'Subrayado',
|
||
menuAlign: 'Alinear',
|
||
menuAlignLeft: 'Alinear a la izquierda',
|
||
menuAlignCenter: 'Centrar',
|
||
menuAlignRight: 'Alinear a la derecha',
|
||
menuAlignJustify: 'Justificar',
|
||
menuFont: 'Fuente…',
|
||
menuParagraph: 'Párrafo…',
|
||
menuTools: 'Herramientas',
|
||
menuWordCount: 'Contar palabras…',
|
||
menuAiProofread: 'Corrección con IA',
|
||
menuWindow: 'Ventana',
|
||
menuHelp: 'Ayuda',
|
||
menuShortcuts: 'Atajos de teclado',
|
||
menuDocsHelp: 'Ayuda de GenOffice Docs',
|
||
},
|
||
th: {
|
||
dlgOpenDoc: 'เปิดเอกสาร',
|
||
filterWord: 'เอกสาร Word',
|
||
dlgSaveAs: 'บันทึกเป็น',
|
||
closeUnsavedMsg: 'เอกสารนี้มีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก',
|
||
closeUnsavedDetail: 'ต้องการบันทึกก่อนปิดหรือไม่?',
|
||
closeNoReplyMsg: 'เอกสารไม่ตอบสนองและอาจมีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก',
|
||
closeNoReplyDetail: 'ปิดต่อไปหรือไม่ การเปลี่ยนแปลงที่ยังไม่ได้บันทึกจะหายไป',
|
||
btnCloseAnyway: 'ปิดต่อไป',
|
||
autosaveFoundTitle: 'พบเวอร์ชันกู้คืนอัตโนมัติ',
|
||
autosaveFoundBody: 'มีการเปลี่ยนแปลงที่ยังไม่ได้บันทึกจากครั้งก่อน ต้องการกู้คืนหรือไม่?',
|
||
autosaveRestore: 'กู้คืน',
|
||
autosaveDiscard: 'ละทิ้ง',
|
||
btnDontSave: 'ไม่บันทึก',
|
||
btnCancel: 'ยกเลิก',
|
||
extModifiedMsg: 'ไฟล์ถูกแก้ไขโดยโปรแกรมอื่น',
|
||
extModifiedDetail: 'บันทึกต่อไปและเขียนทับการเปลี่ยนแปลงบนดิสก์หรือไม่?',
|
||
btnOverwrite: 'เขียนทับ',
|
||
dlgInsertImage: 'แทรกรูปภาพ',
|
||
filterImages: 'รูปภาพ',
|
||
dlgAddAttachment: 'เพิ่มสิ่งที่แนบ',
|
||
filterSupported: 'ไฟล์ที่รองรับ',
|
||
filterAll: 'ไฟล์ทั้งหมด',
|
||
dlgExportPdf: 'ส่งออกเป็น PDF',
|
||
dlgExportHtml: 'ส่งออกเป็น HTML',
|
||
errUnsupportedExt: 'ไม่รองรับไฟล์ .{ext}',
|
||
errNotFile: 'ไม่ใช่ไฟล์',
|
||
errTooLarge: 'เกินขีดจำกัด {mb}MB',
|
||
errImageTooLarge: 'รูปภาพเกินขีดจำกัด 5MB',
|
||
errUnreadable: 'ไม่สามารถอ่านได้',
|
||
errFileTooLarge: 'ไฟล์เกินขนาดสูงสุด',
|
||
errParseFailed: 'แยกวิเคราะห์ไฟล์ไม่สำเร็จ',
|
||
errImageNoText:
|
||
'สิ่งที่แนบเป็นรูปภาพไม่มีข้อความ รูปจะถูกส่งไปพร้อมข้อความของผู้ใช้ ดูรูปได้โดยตรง',
|
||
errNotImage: 'ไม่ใช่ชนิดรูปภาพที่รองรับ',
|
||
errGskNotLoggedIn:
|
||
'ยังไม่ได้ลงชื่อเข้าใช้ Genspark: แตะ “ลงชื่อเข้าใช้ Genspark” ด้านล่าง แล้วลองอีกครั้ง',
|
||
errNoApiKey: 'ยังไม่ได้ตั้งค่า API Key ของ {provider}',
|
||
errAiBusy: 'บริการ AI มีผู้ใช้งานจำนวนมากในขณะนี้ โปรดลองอีกครั้งในอีกสักครู่',
|
||
errNoModel: 'ยังไม่ได้ตั้งค่าชื่อโมเดล',
|
||
menuFile: 'ไฟล์',
|
||
menuNewDoc: 'เอกสารใหม่',
|
||
menuNewWindow: 'หน้าต่างใหม่',
|
||
menuOpen: 'เปิด…',
|
||
menuOpenRecent: 'เปิดเอกสารล่าสุด',
|
||
menuNoRecent: 'ไม่มีเอกสารล่าสุด',
|
||
menuClose: 'ปิด',
|
||
menuSave: 'บันทึก',
|
||
menuSaveAs: 'บันทึกเป็น…',
|
||
menuPageSetup: 'ตั้งค่าหน้ากระดาษ…',
|
||
menuExportPdf: 'ส่งออกเป็น PDF…',
|
||
menuExportHtml: 'ส่งออกเป็น HTML…',
|
||
menuPrint: 'พิมพ์…',
|
||
menuEdit: 'แก้ไข',
|
||
menuUndo: 'เลิกทำ',
|
||
menuRedo: 'ทำซ้ำ',
|
||
menuCut: 'ตัด',
|
||
menuCopy: 'คัดลอก',
|
||
menuPaste: 'วาง',
|
||
menuPasteMatch: 'วางแบบจับคู่ลักษณะ',
|
||
menuFindReplace: 'ค้นหาและแทนที่…',
|
||
menuSelectAll: 'เลือกทั้งหมด',
|
||
menuView: 'มุมมอง',
|
||
menuZoomIn: 'ขยาย',
|
||
menuZoomOut: 'ย่อ',
|
||
menuZoom100: 'ขนาดจริง (100%)',
|
||
menuPageWidth: 'ความกว้างของหน้า',
|
||
menuWholePage: 'ทั้งหน้า',
|
||
menuAiSidebar: 'แถบข้าง AI',
|
||
menuDarkMode: 'โหมดมืด',
|
||
menuFullscreen: 'เข้าสู่โหมดเต็มหน้าจอ',
|
||
menuInsert: 'แทรก',
|
||
menuInsertTable: 'ตาราง (3×3)',
|
||
menuInsertImage: 'รูปภาพ…',
|
||
menuInsertPageBreak: 'ตัวแบ่งหน้า',
|
||
menuInsertLink: 'ไฮเปอร์ลิงก์…',
|
||
menuInsertEquation: 'สมการ…',
|
||
menuComment: 'ข้อคิดเห็น',
|
||
menuFormat: 'รูปแบบ',
|
||
menuBold: 'ตัวหนา',
|
||
menuItalic: 'ตัวเอียง',
|
||
menuUnderline: 'ขีดเส้นใต้',
|
||
menuAlign: 'จัดแนว',
|
||
menuAlignLeft: 'จัดชิดซ้าย',
|
||
menuAlignCenter: 'จัดกึ่งกลาง',
|
||
menuAlignRight: 'จัดชิดขวา',
|
||
menuAlignJustify: 'จัดชิดขอบ',
|
||
menuFont: 'ฟอนต์…',
|
||
menuParagraph: 'ย่อหน้า…',
|
||
menuTools: 'เครื่องมือ',
|
||
menuWordCount: 'นับจำนวนคำ…',
|
||
menuAiProofread: 'พิสูจน์อักษรด้วย AI',
|
||
menuWindow: 'หน้าต่าง',
|
||
menuHelp: 'วิธีใช้',
|
||
menuShortcuts: 'แป้นพิมพ์ลัด',
|
||
menuDocsHelp: 'วิธีใช้ GenOffice Docs',
|
||
},
|
||
id: {
|
||
dlgOpenDoc: 'Buka Dokumen',
|
||
filterWord: 'Dokumen Word',
|
||
dlgSaveAs: 'Simpan Sebagai',
|
||
closeUnsavedMsg: 'Dokumen ini memiliki perubahan yang belum disimpan.',
|
||
closeUnsavedDetail: 'Simpan sebelum menutup?',
|
||
closeNoReplyMsg: 'Dokumen tidak merespons dan mungkin memiliki perubahan yang belum disimpan.',
|
||
closeNoReplyDetail: 'Tetap tutup? Perubahan yang belum disimpan akan hilang.',
|
||
btnCloseAnyway: 'Tetap Tutup',
|
||
autosaveFoundTitle: 'Versi pemulihan ditemukan',
|
||
autosaveFoundBody:
|
||
'Ada perubahan yang belum disimpan dari sesi terakhir. Pulihkan versi tersimpan otomatis?',
|
||
autosaveRestore: 'Pulihkan',
|
||
autosaveDiscard: 'Buang',
|
||
btnDontSave: 'Jangan Simpan',
|
||
btnCancel: 'Batal',
|
||
extModifiedMsg: 'File telah diubah oleh program lain.',
|
||
extModifiedDetail: 'Tetap simpan dan timpa perubahan di disk?',
|
||
btnOverwrite: 'Timpa',
|
||
dlgInsertImage: 'Sisipkan Gambar',
|
||
filterImages: 'Gambar',
|
||
dlgAddAttachment: 'Tambahkan Lampiran',
|
||
filterSupported: 'File yang Didukung',
|
||
filterAll: 'Semua File',
|
||
dlgExportPdf: 'Ekspor sebagai PDF',
|
||
dlgExportHtml: 'Ekspor sebagai HTML',
|
||
errUnsupportedExt: 'file .{ext} tidak didukung',
|
||
errNotFile: 'bukan file',
|
||
errTooLarge: 'melebihi batas {mb}MB',
|
||
errImageTooLarge: 'gambar melebihi batas 5MB',
|
||
errUnreadable: 'tidak dapat dibaca',
|
||
errFileTooLarge: 'File melebihi batas ukuran',
|
||
errParseFailed: 'Gagal mengurai file',
|
||
errImageNoText:
|
||
'Lampiran gambar tidak menyediakan teks; gambar dikirim bersama pesan pengguna dan dapat dilihat langsung',
|
||
errNotImage: 'bukan jenis gambar yang didukung',
|
||
errGskNotLoggedIn: 'Belum masuk ke Genspark: klik “Masuk ke Genspark” di bawah, lalu coba lagi',
|
||
errNoApiKey: 'API Key untuk {provider} belum dikonfigurasi',
|
||
errAiBusy: 'Layanan AI sedang sibuk — silakan coba lagi sebentar lagi',
|
||
errNoModel: 'Nama model belum dikonfigurasi',
|
||
menuFile: 'File',
|
||
menuNewDoc: 'Dokumen Baru',
|
||
menuNewWindow: 'Jendela Baru',
|
||
menuOpen: 'Buka…',
|
||
menuOpenRecent: 'Buka Terbaru',
|
||
menuNoRecent: 'Tidak Ada Dokumen Terbaru',
|
||
menuClose: 'Tutup',
|
||
menuSave: 'Simpan',
|
||
menuSaveAs: 'Simpan Sebagai…',
|
||
menuPageSetup: 'Penyetelan Halaman…',
|
||
menuExportPdf: 'Ekspor sebagai PDF…',
|
||
menuExportHtml: 'Ekspor sebagai HTML…',
|
||
menuPrint: 'Cetak…',
|
||
menuEdit: 'Edit',
|
||
menuUndo: 'Urungkan',
|
||
menuRedo: 'Ulangi',
|
||
menuCut: 'Potong',
|
||
menuCopy: 'Salin',
|
||
menuPaste: 'Tempel',
|
||
menuPasteMatch: 'Tempel dan Samakan Gaya',
|
||
menuFindReplace: 'Temukan dan Ganti…',
|
||
menuSelectAll: 'Pilih Semua',
|
||
menuView: 'Tampilan',
|
||
menuZoomIn: 'Perbesar',
|
||
menuZoomOut: 'Perkecil',
|
||
menuZoom100: 'Ukuran Sebenarnya (100%)',
|
||
menuPageWidth: 'Lebar Halaman',
|
||
menuWholePage: 'Seluruh Halaman',
|
||
menuAiSidebar: 'Bilah Samping AI',
|
||
menuDarkMode: 'Mode Gelap',
|
||
menuFullscreen: 'Masuk Layar Penuh',
|
||
menuInsert: 'Sisipkan',
|
||
menuInsertTable: 'Tabel (3×3)',
|
||
menuInsertImage: 'Gambar…',
|
||
menuInsertPageBreak: 'Pemisah Halaman',
|
||
menuInsertLink: 'Hyperlink…',
|
||
menuInsertEquation: 'Persamaan…',
|
||
menuComment: 'Komentar',
|
||
menuFormat: 'Format',
|
||
menuBold: 'Tebal',
|
||
menuItalic: 'Miring',
|
||
menuUnderline: 'Garis Bawah',
|
||
menuAlign: 'Perataan',
|
||
menuAlignLeft: 'Rata Kiri',
|
||
menuAlignCenter: 'Rata Tengah',
|
||
menuAlignRight: 'Rata Kanan',
|
||
menuAlignJustify: 'Rata Kiri Kanan',
|
||
menuFont: 'Font…',
|
||
menuParagraph: 'Paragraf…',
|
||
menuTools: 'Alat',
|
||
menuWordCount: 'Hitungan Kata…',
|
||
menuAiProofread: 'Koreksi AI',
|
||
menuWindow: 'Jendela',
|
||
menuHelp: 'Bantuan',
|
||
menuShortcuts: 'Pintasan Papan Ketik',
|
||
menuDocsHelp: 'Bantuan GenOffice Docs',
|
||
},
|
||
ru: {
|
||
dlgOpenDoc: 'Открыть документ',
|
||
filterWord: 'Документы Word',
|
||
dlgSaveAs: 'Сохранить как',
|
||
closeUnsavedMsg: 'В этом документе есть несохранённые изменения.',
|
||
closeUnsavedDetail: 'Сохранить их перед закрытием?',
|
||
closeNoReplyMsg: 'Документ не отвечает; возможно, есть несохранённые изменения.',
|
||
closeNoReplyDetail: 'Всё равно закрыть? Несохранённые изменения будут потеряны.',
|
||
btnCloseAnyway: 'Закрыть всё равно',
|
||
autosaveFoundTitle: 'Найдена восстановленная версия',
|
||
autosaveFoundBody:
|
||
'Есть несохранённые изменения из прошлого сеанса. Восстановить автосохранённую версию?',
|
||
autosaveRestore: 'Восстановить',
|
||
autosaveDiscard: 'Отклонить',
|
||
btnDontSave: 'Не сохранять',
|
||
btnCancel: 'Отмена',
|
||
extModifiedMsg: 'Файл был изменён другой программой.',
|
||
extModifiedDetail: 'Всё равно сохранить и перезаписать изменения на диске?',
|
||
btnOverwrite: 'Перезаписать',
|
||
dlgInsertImage: 'Вставить рисунок',
|
||
filterImages: 'Изображения',
|
||
dlgAddAttachment: 'Добавить вложения',
|
||
filterSupported: 'Поддерживаемые файлы',
|
||
filterAll: 'Все файлы',
|
||
dlgExportPdf: 'Экспорт в PDF',
|
||
dlgExportHtml: 'Экспорт в HTML',
|
||
errUnsupportedExt: 'файлы .{ext} не поддерживаются',
|
||
errNotFile: 'не является файлом',
|
||
errTooLarge: 'превышает лимит {mb} МБ',
|
||
errImageTooLarge: 'изображение превышает лимит 5 МБ',
|
||
errUnreadable: 'не удается прочитать',
|
||
errFileTooLarge: 'Файл превышает максимальный размер',
|
||
errParseFailed: 'Не удалось разобрать файл',
|
||
errImageNoText:
|
||
'Вложенные изображения не содержат текста; изображение отправляется вместе с сообщением пользователя, смотрите его напрямую',
|
||
errNotImage: 'неподдерживаемый тип изображения',
|
||
errGskNotLoggedIn:
|
||
'Вы не вошли в Genspark: нажмите «Войти в Genspark» ниже, войдите и повторите попытку',
|
||
errNoApiKey: 'API-ключ для {provider} не настроен',
|
||
errAiBusy: 'Сервис ИИ сейчас перегружен — повторите попытку чуть позже',
|
||
errNoModel: 'Не указано имя модели',
|
||
menuFile: 'Файл',
|
||
menuNewDoc: 'Создать документ',
|
||
menuNewWindow: 'Новое окно',
|
||
menuOpen: 'Открыть…',
|
||
menuOpenRecent: 'Открыть последние',
|
||
menuNoRecent: 'Нет последних документов',
|
||
menuClose: 'Закрыть',
|
||
menuSave: 'Сохранить',
|
||
menuSaveAs: 'Сохранить как…',
|
||
menuPageSetup: 'Параметры страницы…',
|
||
menuExportPdf: 'Экспорт в PDF…',
|
||
menuExportHtml: 'Экспорт в HTML…',
|
||
menuPrint: 'Печать…',
|
||
menuEdit: 'Правка',
|
||
menuUndo: 'Отменить',
|
||
menuRedo: 'Повторить',
|
||
menuCut: 'Вырезать',
|
||
menuCopy: 'Копировать',
|
||
menuPaste: 'Вставить',
|
||
menuPasteMatch: 'Вставить и согласовать стиль',
|
||
menuFindReplace: 'Найти и заменить…',
|
||
menuSelectAll: 'Выделить все',
|
||
menuView: 'Вид',
|
||
menuZoomIn: 'Увеличить',
|
||
menuZoomOut: 'Уменьшить',
|
||
menuZoom100: 'Фактический размер (100%)',
|
||
menuPageWidth: 'По ширине страницы',
|
||
menuWholePage: 'Страница целиком',
|
||
menuAiSidebar: 'Боковая панель ИИ',
|
||
menuDarkMode: 'Темный режим',
|
||
menuFullscreen: 'Перейти в полноэкранный режим',
|
||
menuInsert: 'Вставка',
|
||
menuInsertTable: 'Таблица (3×3)',
|
||
menuInsertImage: 'Рисунок…',
|
||
menuInsertPageBreak: 'Разрыв страницы',
|
||
menuInsertLink: 'Гиперссылка…',
|
||
menuInsertEquation: 'Уравнение…',
|
||
menuComment: 'Примечание',
|
||
menuFormat: 'Формат',
|
||
menuBold: 'Полужирный',
|
||
menuItalic: 'Курсив',
|
||
menuUnderline: 'Подчеркнутый',
|
||
menuAlign: 'Выравнивание',
|
||
menuAlignLeft: 'По левому краю',
|
||
menuAlignCenter: 'По центру',
|
||
menuAlignRight: 'По правому краю',
|
||
menuAlignJustify: 'По ширине',
|
||
menuFont: 'Шрифт…',
|
||
menuParagraph: 'Абзац…',
|
||
menuTools: 'Сервис',
|
||
menuWordCount: 'Статистика…',
|
||
menuAiProofread: 'ИИ-корректура',
|
||
menuWindow: 'Окно',
|
||
menuHelp: 'Справка',
|
||
menuShortcuts: 'Сочетания клавиш',
|
||
menuDocsHelp: 'Справка GenOffice Docs',
|
||
},
|
||
ar: {
|
||
dlgOpenDoc: 'فتح مستند',
|
||
filterWord: 'مستندات Word',
|
||
dlgSaveAs: 'حفظ باسم',
|
||
closeUnsavedMsg: 'يحتوي هذا المستند على تغييرات غير محفوظة.',
|
||
closeUnsavedDetail: 'هل تريد حفظها قبل الإغلاق؟',
|
||
closeNoReplyMsg: 'المستند لا يستجيب وقد يحتوي على تغييرات غير محفوظة.',
|
||
closeNoReplyDetail: 'هل تريد الإغلاق رغم ذلك؟ ستفقد التغييرات غير المحفوظة.',
|
||
btnCloseAnyway: 'إغلاق على أي حال',
|
||
autosaveFoundTitle: 'تم العثور على نسخة مستردة',
|
||
autosaveFoundBody:
|
||
'توجد تغييرات غير محفوظة من الجلسة الأخيرة. هل تريد استعادة النسخة المحفوظة تلقائيًا؟',
|
||
autosaveRestore: 'استعادة',
|
||
autosaveDiscard: 'تجاهل',
|
||
btnDontSave: 'عدم الحفظ',
|
||
btnCancel: 'إلغاء',
|
||
extModifiedMsg: 'تم تعديل الملف بواسطة برنامج آخر.',
|
||
extModifiedDetail: 'هل تريد الحفظ على أي حال والكتابة فوق التغييرات على القرص؟',
|
||
btnOverwrite: 'استبدال',
|
||
dlgInsertImage: 'إدراج صورة',
|
||
filterImages: 'الصور',
|
||
dlgAddAttachment: 'إضافة مرفقات',
|
||
filterSupported: 'الملفات المدعومة',
|
||
filterAll: 'كل الملفات',
|
||
dlgExportPdf: 'تصدير بتنسيق PDF',
|
||
dlgExportHtml: 'تصدير بتنسيق HTML',
|
||
errUnsupportedExt: 'ملفات .{ext} غير مدعومة',
|
||
errNotFile: 'ليس ملفًا',
|
||
errTooLarge: 'يتجاوز الحد {mb}MB',
|
||
errImageTooLarge: 'الصورة تتجاوز حد 5MB',
|
||
errUnreadable: 'تعذرت القراءة',
|
||
errFileTooLarge: 'الملف يتجاوز الحد الأقصى للحجم',
|
||
errParseFailed: 'فشل تحليل الملف',
|
||
errImageNoText:
|
||
'مرفقات الصور لا توفر نصًا؛ تُرسل الصورة مع رسالة المستخدم ويمكن الاطلاع عليها مباشرة',
|
||
errNotImage: 'ليس نوع صورة مدعومًا',
|
||
errGskNotLoggedIn:
|
||
'لم تسجّل الدخول إلى Genspark: انقر على «تسجيل الدخول إلى Genspark» أدناه ثم أعد المحاولة',
|
||
errNoApiKey: 'لم يتم تكوين مفتاح API لـ {provider}',
|
||
errAiBusy: 'خدمة الذكاء الاصطناعي مشغولة حاليًا — يرجى المحاولة مرة أخرى بعد قليل',
|
||
errNoModel: 'لم يتم تكوين اسم النموذج',
|
||
menuFile: 'ملف',
|
||
menuNewDoc: 'مستند جديد',
|
||
menuNewWindow: 'نافذة جديدة',
|
||
menuOpen: 'فتح…',
|
||
menuOpenRecent: 'فتح الأخيرة',
|
||
menuNoRecent: 'لا توجد مستندات أخيرة',
|
||
menuClose: 'إغلاق',
|
||
menuSave: 'حفظ',
|
||
menuSaveAs: 'حفظ باسم…',
|
||
menuPageSetup: 'إعداد الصفحة…',
|
||
menuExportPdf: 'تصدير بتنسيق PDF…',
|
||
menuExportHtml: 'تصدير بتنسيق HTML…',
|
||
menuPrint: 'طباعة…',
|
||
menuEdit: 'تحرير',
|
||
menuUndo: 'تراجع',
|
||
menuRedo: 'إعادة',
|
||
menuCut: 'قص',
|
||
menuCopy: 'نسخ',
|
||
menuPaste: 'لصق',
|
||
menuPasteMatch: 'لصق مع مطابقة النمط',
|
||
menuFindReplace: 'بحث واستبدال…',
|
||
menuSelectAll: 'تحديد الكل',
|
||
menuView: 'عرض',
|
||
menuZoomIn: 'تكبير',
|
||
menuZoomOut: 'تصغير',
|
||
menuZoom100: 'الحجم الفعلي (100%)',
|
||
menuPageWidth: 'عرض الصفحة',
|
||
menuWholePage: 'صفحة كاملة',
|
||
menuAiSidebar: 'الشريط الجانبي للذكاء الاصطناعي',
|
||
menuDarkMode: 'الوضع الداكن',
|
||
menuFullscreen: 'الدخول إلى ملء الشاشة',
|
||
menuInsert: 'إدراج',
|
||
menuInsertTable: 'جدول (3×3)',
|
||
menuInsertImage: 'صورة…',
|
||
menuInsertPageBreak: 'فاصل صفحات',
|
||
menuInsertLink: 'ارتباط تشعبي…',
|
||
menuInsertEquation: 'معادلة…',
|
||
menuComment: 'تعليق',
|
||
menuFormat: 'تنسيق',
|
||
menuBold: 'غامق',
|
||
menuItalic: 'مائل',
|
||
menuUnderline: 'تسطير',
|
||
menuAlign: 'محاذاة',
|
||
menuAlignLeft: 'محاذاة إلى اليسار',
|
||
menuAlignCenter: 'توسيط',
|
||
menuAlignRight: 'محاذاة إلى اليمين',
|
||
menuAlignJustify: 'ضبط',
|
||
menuFont: 'الخط…',
|
||
menuParagraph: 'فقرة…',
|
||
menuTools: 'أدوات',
|
||
menuWordCount: 'عدد الكلمات…',
|
||
menuAiProofread: 'تدقيق بالذكاء الاصطناعي',
|
||
menuWindow: 'نافذة',
|
||
menuHelp: 'تعليمات',
|
||
menuShortcuts: 'اختصارات لوحة المفاتيح',
|
||
menuDocsHelp: 'تعليمات GenOffice Docs',
|
||
},
|
||
pt: {
|
||
dlgOpenDoc: 'Abrir Documento',
|
||
filterWord: 'Documentos do Word',
|
||
dlgSaveAs: 'Salvar Como',
|
||
closeUnsavedMsg: 'Este documento tem alterações não salvas.',
|
||
closeUnsavedDetail: 'Deseja salvá-las antes de fechar?',
|
||
closeNoReplyMsg: 'O documento não está respondendo e pode ter alterações não salvas.',
|
||
closeNoReplyDetail: 'Fechar mesmo assim? As alterações não salvas serão perdidas.',
|
||
btnCloseAnyway: 'Fechar mesmo assim',
|
||
autosaveFoundTitle: 'Versão recuperada encontrada',
|
||
autosaveFoundBody:
|
||
'Há alterações não salvas da sua última sessão. Restaurar a versão salva automaticamente?',
|
||
autosaveRestore: 'Restaurar',
|
||
autosaveDiscard: 'Descartar',
|
||
btnDontSave: 'Não Salvar',
|
||
btnCancel: 'Cancelar',
|
||
extModifiedMsg: 'O arquivo foi modificado por outro programa.',
|
||
extModifiedDetail: 'Salvar mesmo assim e sobrescrever as alterações no disco?',
|
||
btnOverwrite: 'Sobrescrever',
|
||
dlgInsertImage: 'Inserir Imagem',
|
||
filterImages: 'Imagens',
|
||
dlgAddAttachment: 'Adicionar Anexos',
|
||
filterSupported: 'Arquivos Compatíveis',
|
||
filterAll: 'Todos os Arquivos',
|
||
dlgExportPdf: 'Exportar como PDF',
|
||
dlgExportHtml: 'Exportar como HTML',
|
||
errUnsupportedExt: 'arquivos .{ext} não são suportados',
|
||
errNotFile: 'não é um arquivo',
|
||
errTooLarge: 'excede o limite de {mb}MB',
|
||
errImageTooLarge: 'a imagem excede o limite de 5MB',
|
||
errUnreadable: 'não é possível ler',
|
||
errFileTooLarge: 'O arquivo excede o limite de tamanho',
|
||
errParseFailed: 'Falha ao analisar o arquivo',
|
||
errImageNoText:
|
||
'Anexos de imagem não fornecem texto; a imagem é enviada junto com a mensagem do usuário, basta vê-la diretamente',
|
||
errNotImage: 'não é um tipo de imagem suportado',
|
||
errGskNotLoggedIn:
|
||
'Não conectado ao Genspark: clique em “Entrar no Genspark” abaixo, entre e tente novamente',
|
||
errNoApiKey: 'Nenhuma chave de API configurada para {provider}',
|
||
errAiBusy: 'O serviço de IA está sobrecarregado no momento — tente novamente em instantes',
|
||
errNoModel: 'Nenhum nome de modelo configurado',
|
||
menuFile: 'Arquivo',
|
||
menuNewDoc: 'Novo Documento',
|
||
menuNewWindow: 'Nova Janela',
|
||
menuOpen: 'Abrir…',
|
||
menuOpenRecent: 'Abrir Recente',
|
||
menuNoRecent: 'Nenhum Documento Recente',
|
||
menuClose: 'Fechar',
|
||
menuSave: 'Salvar',
|
||
menuSaveAs: 'Salvar Como…',
|
||
menuPageSetup: 'Configurar Página…',
|
||
menuExportPdf: 'Exportar como PDF…',
|
||
menuExportHtml: 'Exportar como HTML…',
|
||
menuPrint: 'Imprimir…',
|
||
menuEdit: 'Editar',
|
||
menuUndo: 'Desfazer',
|
||
menuRedo: 'Refazer',
|
||
menuCut: 'Recortar',
|
||
menuCopy: 'Copiar',
|
||
menuPaste: 'Colar',
|
||
menuPasteMatch: 'Colar com a Mesma Formatação',
|
||
menuFindReplace: 'Localizar e Substituir…',
|
||
menuSelectAll: 'Selecionar Tudo',
|
||
menuView: 'Exibir',
|
||
menuZoomIn: 'Ampliar',
|
||
menuZoomOut: 'Reduzir',
|
||
menuZoom100: 'Tamanho Real (100%)',
|
||
menuPageWidth: 'Largura da Página',
|
||
menuWholePage: 'Página Inteira',
|
||
menuAiSidebar: 'Barra Lateral de IA',
|
||
menuDarkMode: 'Modo Escuro',
|
||
menuFullscreen: 'Entrar em Tela Cheia',
|
||
menuInsert: 'Inserir',
|
||
menuInsertTable: 'Tabela (3×3)',
|
||
menuInsertImage: 'Imagem…',
|
||
menuInsertPageBreak: 'Quebra de Página',
|
||
menuInsertLink: 'Hiperlink…',
|
||
menuInsertEquation: 'Equação…',
|
||
menuComment: 'Comentário',
|
||
menuFormat: 'Formatar',
|
||
menuBold: 'Negrito',
|
||
menuItalic: 'Itálico',
|
||
menuUnderline: 'Sublinhado',
|
||
menuAlign: 'Alinhar',
|
||
menuAlignLeft: 'Alinhar à Esquerda',
|
||
menuAlignCenter: 'Centralizar',
|
||
menuAlignRight: 'Alinhar à Direita',
|
||
menuAlignJustify: 'Justificar',
|
||
menuFont: 'Fonte…',
|
||
menuParagraph: 'Parágrafo…',
|
||
menuTools: 'Ferramentas',
|
||
menuWordCount: 'Contagem de Palavras…',
|
||
menuAiProofread: 'Revisão com IA',
|
||
menuWindow: 'Janela',
|
||
menuHelp: 'Ajuda',
|
||
menuShortcuts: 'Atalhos de Teclado',
|
||
menuDocsHelp: 'Ajuda do GenOffice Docs',
|
||
},
|
||
it: {
|
||
dlgOpenDoc: 'Apri documento',
|
||
filterWord: 'Documenti Word',
|
||
dlgSaveAs: 'Salva con nome',
|
||
closeUnsavedMsg: 'Questo documento contiene modifiche non salvate.',
|
||
closeUnsavedDetail: 'Salvarle prima di chiudere?',
|
||
closeNoReplyMsg: 'Il documento non risponde e potrebbe avere modifiche non salvate.',
|
||
closeNoReplyDetail: 'Chiudere comunque? Le modifiche non salvate andranno perse.',
|
||
btnCloseAnyway: 'Chiudi comunque',
|
||
autosaveFoundTitle: 'Trovata versione recuperata',
|
||
autosaveFoundBody:
|
||
"Ci sono modifiche non salvate dall'ultima sessione. Ripristinare la versione salvata automaticamente?",
|
||
autosaveRestore: 'Ripristina',
|
||
autosaveDiscard: 'Ignora',
|
||
btnDontSave: 'Non salvare',
|
||
btnCancel: 'Annulla',
|
||
extModifiedMsg: 'Il file è stato modificato da un altro programma.',
|
||
extModifiedDetail: 'Salvare comunque e sovrascrivere le modifiche sul disco?',
|
||
btnOverwrite: 'Sovrascrivi',
|
||
dlgInsertImage: 'Inserisci immagine',
|
||
filterImages: 'Immagini',
|
||
dlgAddAttachment: 'Aggiungi allegati',
|
||
filterSupported: 'File supportati',
|
||
filterAll: 'Tutti i file',
|
||
dlgExportPdf: 'Esporta come PDF',
|
||
dlgExportHtml: 'Esporta come HTML',
|
||
errUnsupportedExt: 'i file .{ext} non sono supportati',
|
||
errNotFile: 'non è un file',
|
||
errTooLarge: 'supera il limite di {mb} MB',
|
||
errImageTooLarge: "l'immagine supera il limite di 5 MB",
|
||
errUnreadable: 'impossibile leggere',
|
||
errFileTooLarge: 'Il file supera il limite di dimensione',
|
||
errParseFailed: 'Impossibile analizzare il file',
|
||
errImageNoText:
|
||
"Gli allegati immagine non forniscono testo; l'immagine viene inviata insieme al messaggio dell'utente, basta guardarla direttamente",
|
||
errNotImage: 'tipo di immagine non supportato',
|
||
errGskNotLoggedIn:
|
||
'Accesso a Genspark non effettuato: fai clic su “Accedi a Genspark” qui sotto, accedi e riprova',
|
||
errNoApiKey: 'Nessuna chiave API configurata per {provider}',
|
||
errAiBusy: 'Il servizio IA è momentaneamente sovraccarico — riprova tra poco',
|
||
errNoModel: 'Nessun nome di modello configurato',
|
||
menuFile: 'File',
|
||
menuNewDoc: 'Nuovo documento',
|
||
menuNewWindow: 'Nuova finestra',
|
||
menuOpen: 'Apri…',
|
||
menuOpenRecent: 'Apri recenti',
|
||
menuNoRecent: 'Nessun documento recente',
|
||
menuClose: 'Chiudi',
|
||
menuSave: 'Salva',
|
||
menuSaveAs: 'Salva con nome…',
|
||
menuPageSetup: 'Imposta pagina…',
|
||
menuExportPdf: 'Esporta come PDF…',
|
||
menuExportHtml: 'Esporta come HTML…',
|
||
menuPrint: 'Stampa…',
|
||
menuEdit: 'Modifica',
|
||
menuUndo: 'Annulla',
|
||
menuRedo: 'Ripeti',
|
||
menuCut: 'Taglia',
|
||
menuCopy: 'Copia',
|
||
menuPaste: 'Incolla',
|
||
menuPasteMatch: 'Incolla e adatta lo stile',
|
||
menuFindReplace: 'Trova e sostituisci…',
|
||
menuSelectAll: 'Seleziona tutto',
|
||
menuView: 'Visualizza',
|
||
menuZoomIn: 'Ingrandisci',
|
||
menuZoomOut: 'Riduci',
|
||
menuZoom100: 'Dimensioni effettive (100%)',
|
||
menuPageWidth: 'Larghezza pagina',
|
||
menuWholePage: 'Pagina intera',
|
||
menuAiSidebar: 'Barra laterale IA',
|
||
menuDarkMode: 'Modalità scura',
|
||
menuFullscreen: 'Attiva schermo intero',
|
||
menuInsert: 'Inserisci',
|
||
menuInsertTable: 'Tabella (3×3)',
|
||
menuInsertImage: 'Immagine…',
|
||
menuInsertPageBreak: 'Interruzione di pagina',
|
||
menuInsertLink: 'Collegamento ipertestuale…',
|
||
menuInsertEquation: 'Equazione…',
|
||
menuComment: 'Commento',
|
||
menuFormat: 'Formato',
|
||
menuBold: 'Grassetto',
|
||
menuItalic: 'Corsivo',
|
||
menuUnderline: 'Sottolineato',
|
||
menuAlign: 'Allinea',
|
||
menuAlignLeft: 'Allinea a sinistra',
|
||
menuAlignCenter: 'Centra',
|
||
menuAlignRight: 'Allinea a destra',
|
||
menuAlignJustify: 'Giustifica',
|
||
menuFont: 'Carattere…',
|
||
menuParagraph: 'Paragrafo…',
|
||
menuTools: 'Strumenti',
|
||
menuWordCount: 'Conteggio parole…',
|
||
menuAiProofread: 'Correzione IA',
|
||
menuWindow: 'Finestra',
|
||
menuHelp: 'Aiuto',
|
||
menuShortcuts: 'Scelte rapide da tastiera',
|
||
menuDocsHelp: 'Guida di GenOffice Docs',
|
||
},
|
||
pl: {
|
||
dlgOpenDoc: 'Otwórz dokument',
|
||
filterWord: 'Dokumenty programu Word',
|
||
dlgSaveAs: 'Zapisz jako',
|
||
closeUnsavedMsg: 'Ten dokument zawiera niezapisane zmiany.',
|
||
closeUnsavedDetail: 'Czy zapisać je przed zamknięciem?',
|
||
closeNoReplyMsg: 'Dokument nie odpowiada i może zawierać niezapisane zmiany.',
|
||
closeNoReplyDetail: 'Zamknąć mimo to? Niezapisane zmiany zostaną utracone.',
|
||
btnCloseAnyway: 'Zamknij mimo to',
|
||
autosaveFoundTitle: 'Znaleziono odzyskaną wersję',
|
||
autosaveFoundBody:
|
||
'Istnieją niezapisane zmiany z ostatniej sesji. Przywrócić wersję zapisaną automatycznie?',
|
||
autosaveRestore: 'Przywróć',
|
||
autosaveDiscard: 'Odrzuć',
|
||
btnDontSave: 'Nie zapisuj',
|
||
btnCancel: 'Anuluj',
|
||
extModifiedMsg: 'Plik został zmodyfikowany przez inny program.',
|
||
extModifiedDetail: 'Zapisać mimo to i nadpisać zmiany na dysku?',
|
||
btnOverwrite: 'Nadpisz',
|
||
dlgInsertImage: 'Wstaw obraz',
|
||
filterImages: 'Obrazy',
|
||
dlgAddAttachment: 'Dodaj załączniki',
|
||
filterSupported: 'Obsługiwane pliki',
|
||
filterAll: 'Wszystkie pliki',
|
||
dlgExportPdf: 'Eksportuj jako PDF',
|
||
dlgExportHtml: 'Eksportuj jako HTML',
|
||
errUnsupportedExt: 'pliki .{ext} nie są obsługiwane',
|
||
errNotFile: 'to nie jest plik',
|
||
errTooLarge: 'przekracza limit {mb} MB',
|
||
errImageTooLarge: 'obraz przekracza limit 5 MB',
|
||
errUnreadable: 'nie można odczytać',
|
||
errFileTooLarge: 'Plik przekracza limit rozmiaru',
|
||
errParseFailed: 'Nie udało się przeanalizować pliku',
|
||
errImageNoText:
|
||
'Załączniki graficzne nie zawierają tekstu; obraz jest wysyłany razem z wiadomością użytkownika, wystarczy na niego spojrzeć',
|
||
errNotImage: 'nieobsługiwany typ obrazu',
|
||
errGskNotLoggedIn:
|
||
'Nie zalogowano do Genspark: kliknij „Zaloguj się do Genspark” poniżej, zaloguj się i spróbuj ponownie',
|
||
errNoApiKey: 'Nie skonfigurowano klucza API dla {provider}',
|
||
errAiBusy: 'Usługa AI jest obecnie przeciążona — spróbuj ponownie za chwilę',
|
||
errNoModel: 'Nie skonfigurowano nazwy modelu',
|
||
menuFile: 'Plik',
|
||
menuNewDoc: 'Nowy dokument',
|
||
menuNewWindow: 'Nowe okno',
|
||
menuOpen: 'Otwórz…',
|
||
menuOpenRecent: 'Otwórz ostatnie',
|
||
menuNoRecent: 'Brak ostatnich dokumentów',
|
||
menuClose: 'Zamknij',
|
||
menuSave: 'Zapisz',
|
||
menuSaveAs: 'Zapisz jako…',
|
||
menuPageSetup: 'Ustawienia strony…',
|
||
menuExportPdf: 'Eksportuj jako PDF…',
|
||
menuExportHtml: 'Eksportuj jako HTML…',
|
||
menuPrint: 'Drukuj…',
|
||
menuEdit: 'Edycja',
|
||
menuUndo: 'Cofnij',
|
||
menuRedo: 'Ponów',
|
||
menuCut: 'Wytnij',
|
||
menuCopy: 'Kopiuj',
|
||
menuPaste: 'Wklej',
|
||
menuPasteMatch: 'Wklej i dopasuj styl',
|
||
menuFindReplace: 'Znajdź i zamień…',
|
||
menuSelectAll: 'Zaznacz wszystko',
|
||
menuView: 'Widok',
|
||
menuZoomIn: 'Powiększ',
|
||
menuZoomOut: 'Pomniejsz',
|
||
menuZoom100: 'Rzeczywisty rozmiar (100%)',
|
||
menuPageWidth: 'Szerokość strony',
|
||
menuWholePage: 'Cała strona',
|
||
menuAiSidebar: 'Pasek boczny AI',
|
||
menuDarkMode: 'Tryb ciemny',
|
||
menuFullscreen: 'Przejdź do pełnego ekranu',
|
||
menuInsert: 'Wstaw',
|
||
menuInsertTable: 'Tabela (3×3)',
|
||
menuInsertImage: 'Obraz…',
|
||
menuInsertPageBreak: 'Podział strony',
|
||
menuInsertLink: 'Hiperłącze…',
|
||
menuInsertEquation: 'Równanie…',
|
||
menuComment: 'Komentarz',
|
||
menuFormat: 'Formatowanie',
|
||
menuBold: 'Pogrubienie',
|
||
menuItalic: 'Kursywa',
|
||
menuUnderline: 'Podkreślenie',
|
||
menuAlign: 'Wyrównaj',
|
||
menuAlignLeft: 'Wyrównaj do lewej',
|
||
menuAlignCenter: 'Wyśrodkuj',
|
||
menuAlignRight: 'Wyrównaj do prawej',
|
||
menuAlignJustify: 'Wyjustuj',
|
||
menuFont: 'Czcionka…',
|
||
menuParagraph: 'Akapit…',
|
||
menuTools: 'Narzędzia',
|
||
menuWordCount: 'Statystyka wyrazów…',
|
||
menuAiProofread: 'Korekta AI',
|
||
menuWindow: 'Okno',
|
||
menuHelp: 'Pomoc',
|
||
menuShortcuts: 'Skróty klawiaturowe',
|
||
menuDocsHelp: 'Pomoc GenOffice Docs',
|
||
},
|
||
cs: {
|
||
dlgOpenDoc: 'Otevřít dokument',
|
||
filterWord: 'Dokumenty Wordu',
|
||
dlgSaveAs: 'Uložit jako',
|
||
closeUnsavedMsg: 'Tento dokument obsahuje neuložené změny.',
|
||
closeUnsavedDetail: 'Chcete je před zavřením uložit?',
|
||
closeNoReplyMsg: 'Dokument neodpovídá a může obsahovat neuložené změny.',
|
||
closeNoReplyDetail: 'Přesto zavřít? Neuložené změny budou ztraceny.',
|
||
btnCloseAnyway: 'Přesto zavřít',
|
||
autosaveFoundTitle: 'Nalezena obnovená verze',
|
||
autosaveFoundBody:
|
||
'Z poslední relace existují neuložené změny. Obnovit automaticky uloženou verzi?',
|
||
autosaveRestore: 'Obnovit',
|
||
autosaveDiscard: 'Zahodit',
|
||
btnDontSave: 'Neukládat',
|
||
btnCancel: 'Zrušit',
|
||
extModifiedMsg: 'Soubor byl změněn jiným programem.',
|
||
extModifiedDetail: 'Přesto uložit a přepsat změny na disku?',
|
||
btnOverwrite: 'Přepsat',
|
||
dlgInsertImage: 'Vložit obrázek',
|
||
filterImages: 'Obrázky',
|
||
dlgAddAttachment: 'Přidat přílohy',
|
||
filterSupported: 'Podporované soubory',
|
||
filterAll: 'Všechny soubory',
|
||
dlgExportPdf: 'Exportovat jako PDF',
|
||
dlgExportHtml: 'Exportovat jako HTML',
|
||
errUnsupportedExt: 'soubory .{ext} nejsou podporovány',
|
||
errNotFile: 'není soubor',
|
||
errTooLarge: 'překračuje limit {mb} MB',
|
||
errImageTooLarge: 'obrázek překračuje limit 5 MB',
|
||
errUnreadable: 'nelze přečíst',
|
||
errFileTooLarge: 'Soubor překračuje limit velikosti',
|
||
errParseFailed: 'Soubor se nepodařilo zpracovat',
|
||
errImageNoText:
|
||
'Obrázkové přílohy neobsahují text; obrázek se odesílá spolu se zprávou uživatele',
|
||
errNotImage: 'nepodporovaný typ obrázku',
|
||
errGskNotLoggedIn:
|
||
'Nejste přihlášeni do Genspark: klikněte níže na „Přihlásit se do Genspark“, přihlaste se a zkuste to znovu',
|
||
errNoApiKey: 'Pro {provider} není nakonfigurován žádný klíč API',
|
||
errAiBusy: 'Služba AI je právě zaneprázdněna — zkuste to prosím za chvíli znovu',
|
||
errNoModel: 'Není nakonfigurován název modelu',
|
||
menuFile: 'Soubor',
|
||
menuNewDoc: 'Nový dokument',
|
||
menuNewWindow: 'Nové okno',
|
||
menuOpen: 'Otevřít…',
|
||
menuOpenRecent: 'Otevřít poslední',
|
||
menuNoRecent: 'Žádné poslední dokumenty',
|
||
menuClose: 'Zavřít',
|
||
menuSave: 'Uložit',
|
||
menuSaveAs: 'Uložit jako…',
|
||
menuPageSetup: 'Vzhled stránky…',
|
||
menuExportPdf: 'Exportovat jako PDF…',
|
||
menuExportHtml: 'Exportovat jako HTML…',
|
||
menuPrint: 'Tisk…',
|
||
menuEdit: 'Úpravy',
|
||
menuUndo: 'Zpět',
|
||
menuRedo: 'Znovu',
|
||
menuCut: 'Vyjmout',
|
||
menuCopy: 'Kopírovat',
|
||
menuPaste: 'Vložit',
|
||
menuPasteMatch: 'Vložit a přizpůsobit styl',
|
||
menuFindReplace: 'Najít a nahradit…',
|
||
menuSelectAll: 'Vybrat vše',
|
||
menuView: 'Zobrazení',
|
||
menuZoomIn: 'Zvětšit',
|
||
menuZoomOut: 'Zmenšit',
|
||
menuZoom100: 'Skutečná velikost (100 %)',
|
||
menuPageWidth: 'Šířka stránky',
|
||
menuWholePage: 'Celá stránka',
|
||
menuAiSidebar: 'Boční panel AI',
|
||
menuDarkMode: 'Tmavý režim',
|
||
menuFullscreen: 'Přejít na celou obrazovku',
|
||
menuInsert: 'Vložení',
|
||
menuInsertTable: 'Tabulka (3×3)',
|
||
menuInsertImage: 'Obrázek…',
|
||
menuInsertPageBreak: 'Konec stránky',
|
||
menuInsertLink: 'Hypertextový odkaz…',
|
||
menuInsertEquation: 'Rovnice…',
|
||
menuComment: 'Komentář',
|
||
menuFormat: 'Formát',
|
||
menuBold: 'Tučné',
|
||
menuItalic: 'Kurzíva',
|
||
menuUnderline: 'Podtržení',
|
||
menuAlign: 'Zarovnat',
|
||
menuAlignLeft: 'Zarovnat vlevo',
|
||
menuAlignCenter: 'Zarovnat na střed',
|
||
menuAlignRight: 'Zarovnat vpravo',
|
||
menuAlignJustify: 'Zarovnat do bloku',
|
||
menuFont: 'Písmo…',
|
||
menuParagraph: 'Odstavec…',
|
||
menuTools: 'Nástroje',
|
||
menuWordCount: 'Počet slov…',
|
||
menuAiProofread: 'Korektura AI',
|
||
menuWindow: 'Okno',
|
||
menuHelp: 'Nápověda',
|
||
menuShortcuts: 'Klávesové zkratky',
|
||
menuDocsHelp: 'Nápověda GenOffice Docs',
|
||
},
|
||
nl: {
|
||
dlgOpenDoc: 'Document openen',
|
||
filterWord: 'Word-documenten',
|
||
dlgSaveAs: 'Opslaan als',
|
||
closeUnsavedMsg: 'Dit document bevat niet-opgeslagen wijzigingen.',
|
||
closeUnsavedDetail: 'Wilt u ze opslaan voordat u sluit?',
|
||
closeNoReplyMsg: 'Het document reageert niet en heeft mogelijk niet-opgeslagen wijzigingen.',
|
||
closeNoReplyDetail: 'Toch sluiten? Niet-opgeslagen wijzigingen gaan verloren.',
|
||
btnCloseAnyway: 'Toch sluiten',
|
||
autosaveFoundTitle: 'Herstelde versie gevonden',
|
||
autosaveFoundBody:
|
||
'Er zijn niet-opgeslagen wijzigingen van uw laatste sessie. De automatisch opgeslagen versie herstellen?',
|
||
autosaveRestore: 'Herstellen',
|
||
autosaveDiscard: 'Negeren',
|
||
btnDontSave: 'Niet opslaan',
|
||
btnCancel: 'Annuleren',
|
||
extModifiedMsg: 'Het bestand is door een ander programma gewijzigd.',
|
||
extModifiedDetail: 'Toch opslaan en de wijzigingen op schijf overschrijven?',
|
||
btnOverwrite: 'Overschrijven',
|
||
dlgInsertImage: 'Afbeelding invoegen',
|
||
filterImages: 'Afbeeldingen',
|
||
dlgAddAttachment: 'Bijlagen toevoegen',
|
||
filterSupported: 'Ondersteunde bestanden',
|
||
filterAll: 'Alle bestanden',
|
||
dlgExportPdf: 'Exporteren als PDF',
|
||
dlgExportHtml: 'Exporteren als HTML',
|
||
errUnsupportedExt: '.{ext}-bestanden worden niet ondersteund',
|
||
errNotFile: 'geen bestand',
|
||
errTooLarge: 'overschrijdt de limiet van {mb} MB',
|
||
errImageTooLarge: 'afbeelding overschrijdt de limiet van 5 MB',
|
||
errUnreadable: 'kan niet worden gelezen',
|
||
errFileTooLarge: 'Bestand overschrijdt de maximale grootte',
|
||
errParseFailed: 'Kan bestand niet parseren',
|
||
errImageNoText:
|
||
'Afbeeldingsbijlagen bevatten geen tekst; de afbeelding wordt samen met het gebruikersbericht verzonden en kan direct worden bekeken',
|
||
errNotImage: 'geen ondersteund afbeeldingstype',
|
||
errGskNotLoggedIn:
|
||
'Niet aangemeld bij Genspark: klik hieronder op “Aanmelden bij Genspark”, meld u aan en probeer het opnieuw',
|
||
errNoApiKey: 'Geen API-sleutel geconfigureerd voor {provider}',
|
||
errAiBusy: 'De AI-service is momenteel overbelast — probeer het zo opnieuw',
|
||
errNoModel: 'Geen modelnaam geconfigureerd',
|
||
menuFile: 'Bestand',
|
||
menuNewDoc: 'Nieuw document',
|
||
menuNewWindow: 'Nieuw venster',
|
||
menuOpen: 'Openen…',
|
||
menuOpenRecent: 'Recent geopend',
|
||
menuNoRecent: 'Geen recente documenten',
|
||
menuClose: 'Sluiten',
|
||
menuSave: 'Opslaan',
|
||
menuSaveAs: 'Opslaan als…',
|
||
menuPageSetup: 'Pagina-instelling…',
|
||
menuExportPdf: 'Exporteren als PDF…',
|
||
menuExportHtml: 'Exporteren als HTML…',
|
||
menuPrint: 'Afdrukken…',
|
||
menuEdit: 'Bewerken',
|
||
menuUndo: 'Ongedaan maken',
|
||
menuRedo: 'Opnieuw',
|
||
menuCut: 'Knippen',
|
||
menuCopy: 'Kopiëren',
|
||
menuPaste: 'Plakken',
|
||
menuPasteMatch: 'Plakken met dezelfde stijl',
|
||
menuFindReplace: 'Zoeken en vervangen…',
|
||
menuSelectAll: 'Alles selecteren',
|
||
menuView: 'Beeld',
|
||
menuZoomIn: 'Inzoomen',
|
||
menuZoomOut: 'Uitzoomen',
|
||
menuZoom100: 'Ware grootte (100%)',
|
||
menuPageWidth: 'Paginabreedte',
|
||
menuWholePage: 'Hele pagina',
|
||
menuAiSidebar: 'AI-zijbalk',
|
||
menuDarkMode: 'Donkere modus',
|
||
menuFullscreen: 'Schermvullende weergave',
|
||
menuInsert: 'Invoegen',
|
||
menuInsertTable: 'Tabel (3×3)',
|
||
menuInsertImage: 'Afbeelding…',
|
||
menuInsertPageBreak: 'Pagina-einde',
|
||
menuInsertLink: 'Hyperlink…',
|
||
menuInsertEquation: 'Vergelijking…',
|
||
menuComment: 'Opmerking',
|
||
menuFormat: 'Opmaak',
|
||
menuBold: 'Vet',
|
||
menuItalic: 'Cursief',
|
||
menuUnderline: 'Onderstrepen',
|
||
menuAlign: 'Uitlijnen',
|
||
menuAlignLeft: 'Links uitlijnen',
|
||
menuAlignCenter: 'Centreren',
|
||
menuAlignRight: 'Rechts uitlijnen',
|
||
menuAlignJustify: 'Uitvullen',
|
||
menuFont: 'Lettertype…',
|
||
menuParagraph: 'Alinea…',
|
||
menuTools: 'Extra',
|
||
menuWordCount: 'Woorden tellen…',
|
||
menuAiProofread: 'AI-proeflezen',
|
||
menuWindow: 'Venster',
|
||
menuHelp: 'Help',
|
||
menuShortcuts: 'Sneltoetsen',
|
||
menuDocsHelp: 'GenOffice Docs Help',
|
||
},
|
||
ms: {
|
||
dlgOpenDoc: 'Buka Dokumen',
|
||
filterWord: 'Dokumen Word',
|
||
dlgSaveAs: 'Simpan Sebagai',
|
||
closeUnsavedMsg: 'Dokumen ini mempunyai perubahan yang belum disimpan.',
|
||
closeUnsavedDetail: 'Adakah anda mahu menyimpannya sebelum menutup?',
|
||
closeNoReplyMsg: 'Dokumen tidak bertindak balas dan mungkin ada perubahan yang belum disimpan.',
|
||
closeNoReplyDetail: 'Tutup juga? Perubahan yang belum disimpan akan hilang.',
|
||
btnCloseAnyway: 'Tutup Juga',
|
||
autosaveFoundTitle: 'Versi pulihan ditemui',
|
||
autosaveFoundBody:
|
||
'Terdapat perubahan yang belum disimpan daripada sesi terakhir anda. Pulihkan versi yang disimpan secara automatik?',
|
||
autosaveRestore: 'Pulihkan',
|
||
autosaveDiscard: 'Buang',
|
||
btnDontSave: 'Jangan Simpan',
|
||
btnCancel: 'Batal',
|
||
extModifiedMsg: 'Fail telah diubah oleh program lain.',
|
||
extModifiedDetail: 'Simpan juga dan tulis ganti perubahan pada cakera?',
|
||
btnOverwrite: 'Tulis Ganti',
|
||
dlgInsertImage: 'Sisipkan Imej',
|
||
filterImages: 'Imej',
|
||
dlgAddAttachment: 'Tambah Lampiran',
|
||
filterSupported: 'Fail yang Disokong',
|
||
filterAll: 'Semua Fail',
|
||
dlgExportPdf: 'Eksport sebagai PDF',
|
||
dlgExportHtml: 'Eksport sebagai HTML',
|
||
errUnsupportedExt: 'fail .{ext} tidak disokong',
|
||
errNotFile: 'bukan fail',
|
||
errTooLarge: 'melebihi had {mb}MB',
|
||
errImageTooLarge: 'imej melebihi had 5MB',
|
||
errUnreadable: 'tidak dapat dibaca',
|
||
errFileTooLarge: 'Fail melebihi had saiz',
|
||
errParseFailed: 'Gagal menghurai fail',
|
||
errImageNoText:
|
||
'Lampiran imej tidak menyediakan teks; imej dihantar bersama mesej pengguna dan boleh dilihat terus',
|
||
errNotImage: 'bukan jenis imej yang disokong',
|
||
errGskNotLoggedIn:
|
||
'Belum log masuk ke Genspark: klik “Log masuk ke Genspark” di bawah, kemudian cuba lagi',
|
||
errNoApiKey: 'Kunci API untuk {provider} belum dikonfigurasikan',
|
||
errAiBusy: 'Perkhidmatan AI sedang sibuk — sila cuba lagi sebentar lagi',
|
||
errNoModel: 'Nama model belum dikonfigurasikan',
|
||
menuFile: 'Fail',
|
||
menuNewDoc: 'Dokumen Baharu',
|
||
menuNewWindow: 'Tetingkap Baharu',
|
||
menuOpen: 'Buka…',
|
||
menuOpenRecent: 'Buka Terkini',
|
||
menuNoRecent: 'Tiada Dokumen Terkini',
|
||
menuClose: 'Tutup',
|
||
menuSave: 'Simpan',
|
||
menuSaveAs: 'Simpan Sebagai…',
|
||
menuPageSetup: 'Persediaan Halaman…',
|
||
menuExportPdf: 'Eksport sebagai PDF…',
|
||
menuExportHtml: 'Eksport sebagai HTML…',
|
||
menuPrint: 'Cetak…',
|
||
menuEdit: 'Edit',
|
||
menuUndo: 'Buat Asal',
|
||
menuRedo: 'Buat Semula',
|
||
menuCut: 'Potong',
|
||
menuCopy: 'Salin',
|
||
menuPaste: 'Tampal',
|
||
menuPasteMatch: 'Tampal dan Padankan Gaya',
|
||
menuFindReplace: 'Cari dan Ganti…',
|
||
menuSelectAll: 'Pilih Semua',
|
||
menuView: 'Lihat',
|
||
menuZoomIn: 'Zum Masuk',
|
||
menuZoomOut: 'Zum Keluar',
|
||
menuZoom100: 'Saiz Sebenar (100%)',
|
||
menuPageWidth: 'Lebar Halaman',
|
||
menuWholePage: 'Seluruh Halaman',
|
||
menuAiSidebar: 'Bar Sisi AI',
|
||
menuDarkMode: 'Mod Gelap',
|
||
menuFullscreen: 'Masuk Skrin Penuh',
|
||
menuInsert: 'Sisip',
|
||
menuInsertTable: 'Jadual (3×3)',
|
||
menuInsertImage: 'Imej…',
|
||
menuInsertPageBreak: 'Pemisah Halaman',
|
||
menuInsertLink: 'Hiperpautan…',
|
||
menuInsertEquation: 'Persamaan…',
|
||
menuComment: 'Komen',
|
||
menuFormat: 'Format',
|
||
menuBold: 'Tebal',
|
||
menuItalic: 'Condong',
|
||
menuUnderline: 'Garis Bawah',
|
||
menuAlign: 'Jajarkan',
|
||
menuAlignLeft: 'Jajar Kiri',
|
||
menuAlignCenter: 'Tengah',
|
||
menuAlignRight: 'Jajar Kanan',
|
||
menuAlignJustify: 'Justifikasi',
|
||
menuFont: 'Fon…',
|
||
menuParagraph: 'Perenggan…',
|
||
menuTools: 'Alat',
|
||
menuWordCount: 'Kiraan Perkataan…',
|
||
menuAiProofread: 'Pembacaan Pruf AI',
|
||
menuWindow: 'Tetingkap',
|
||
menuHelp: 'Bantuan',
|
||
menuShortcuts: 'Pintasan Papan Kekunci',
|
||
menuDocsHelp: 'Bantuan GenOffice Docs',
|
||
},
|
||
he: {
|
||
dlgOpenDoc: 'פתיחת מסמך',
|
||
filterWord: 'מסמכי Word',
|
||
dlgSaveAs: 'שמירה בשם',
|
||
closeUnsavedMsg: 'במסמך זה יש שינויים שלא נשמרו.',
|
||
closeUnsavedDetail: 'האם לשמור אותם לפני הסגירה?',
|
||
closeNoReplyMsg: 'המסמך אינו מגיב וייתכן שיש בו שינויים שלא נשמרו.',
|
||
closeNoReplyDetail: 'לסגור בכל זאת? שינויים שלא נשמרו יאבדו.',
|
||
btnCloseAnyway: 'סגור בכל זאת',
|
||
autosaveFoundTitle: 'נמצאה גרסה משוחזרת',
|
||
autosaveFoundBody: 'קיימים שינויים שלא נשמרו מהפעלה הקודמת. לשחזר את הגרסה שנשמרה אוטומטית?',
|
||
autosaveRestore: 'שחזר',
|
||
autosaveDiscard: 'התעלם',
|
||
btnDontSave: 'אל תשמור',
|
||
btnCancel: 'ביטול',
|
||
extModifiedMsg: 'הקובץ שונה על ידי תוכנית אחרת.',
|
||
extModifiedDetail: 'לשמור בכל זאת ולדרוס את השינויים בדיסק?',
|
||
btnOverwrite: 'דרוס',
|
||
dlgInsertImage: 'הוספת תמונה',
|
||
filterImages: 'תמונות',
|
||
dlgAddAttachment: 'הוספת קבצים מצורפים',
|
||
filterSupported: 'קבצים נתמכים',
|
||
filterAll: 'כל הקבצים',
|
||
dlgExportPdf: 'ייצוא כ-PDF',
|
||
dlgExportHtml: 'ייצוא כ-HTML',
|
||
errUnsupportedExt: 'קובצי .{ext} אינם נתמכים',
|
||
errNotFile: 'אינו קובץ',
|
||
errTooLarge: 'חורג מהמגבלה של {mb}MB',
|
||
errImageTooLarge: 'התמונה חורגת מהמגבלה של 5MB',
|
||
errUnreadable: 'לא ניתן לקרוא',
|
||
errFileTooLarge: 'הקובץ חורג ממגבלת הגודל',
|
||
errParseFailed: 'ניתוח הקובץ נכשל',
|
||
errImageNoText:
|
||
'קבצים מצורפים מסוג תמונה אינם מספקים טקסט; התמונה נשלחת יחד עם הודעת המשתמש וניתן לצפות בה ישירות',
|
||
errNotImage: 'סוג תמונה שאינו נתמך',
|
||
errGskNotLoggedIn: 'לא מחובר ל-Genspark: לחץ על "התחבר ל-Genspark" למטה, התחבר ונסה שוב',
|
||
errNoApiKey: 'לא הוגדר מפתח API עבור {provider}',
|
||
errAiBusy: 'שירות ה-AI עמוס כרגע — נסו שוב בעוד רגע',
|
||
errNoModel: 'לא הוגדר שם מודל',
|
||
menuFile: 'קובץ',
|
||
menuNewDoc: 'מסמך חדש',
|
||
menuNewWindow: 'חלון חדש',
|
||
menuOpen: 'פתיחה…',
|
||
menuOpenRecent: 'פתיחת מסמכים אחרונים',
|
||
menuNoRecent: 'אין מסמכים אחרונים',
|
||
menuClose: 'סגירה',
|
||
menuSave: 'שמירה',
|
||
menuSaveAs: 'שמירה בשם…',
|
||
menuPageSetup: 'הגדרת עמוד…',
|
||
menuExportPdf: 'ייצוא כ-PDF…',
|
||
menuExportHtml: 'ייצוא כ-HTML…',
|
||
menuPrint: 'הדפסה…',
|
||
menuEdit: 'עריכה',
|
||
menuUndo: 'בטל',
|
||
menuRedo: 'בצע שוב',
|
||
menuCut: 'גזור',
|
||
menuCopy: 'העתק',
|
||
menuPaste: 'הדבק',
|
||
menuPasteMatch: 'הדבק והתאם סגנון',
|
||
menuFindReplace: 'חיפוש והחלפה…',
|
||
menuSelectAll: 'בחר הכול',
|
||
menuView: 'תצוגה',
|
||
menuZoomIn: 'התקרבות',
|
||
menuZoomOut: 'התרחקות',
|
||
menuZoom100: 'גודל אמיתי (100%)',
|
||
menuPageWidth: 'רוחב עמוד',
|
||
menuWholePage: 'עמוד שלם',
|
||
menuAiSidebar: 'סרגל צד AI',
|
||
menuDarkMode: 'מצב כהה',
|
||
menuFullscreen: 'מעבר למסך מלא',
|
||
menuInsert: 'הוספה',
|
||
menuInsertTable: 'טבלה (3×3)',
|
||
menuInsertImage: 'תמונה…',
|
||
menuInsertPageBreak: 'מעבר עמוד',
|
||
menuInsertLink: 'היפר-קישור…',
|
||
menuInsertEquation: 'משוואה…',
|
||
menuComment: 'הערה',
|
||
menuFormat: 'עיצוב',
|
||
menuBold: 'מודגש',
|
||
menuItalic: 'נטוי',
|
||
menuUnderline: 'קו תחתון',
|
||
menuAlign: 'יישור',
|
||
menuAlignLeft: 'יישור לשמאל',
|
||
menuAlignCenter: 'מרכוז',
|
||
menuAlignRight: 'יישור לימין',
|
||
menuAlignJustify: 'יישור לשני הצדדים',
|
||
menuFont: 'גופן…',
|
||
menuParagraph: 'פסקה…',
|
||
menuTools: 'כלים',
|
||
menuWordCount: 'ספירת מילים…',
|
||
menuAiProofread: 'הגהת AI',
|
||
menuWindow: 'חלון',
|
||
menuHelp: 'עזרה',
|
||
menuShortcuts: 'קיצורי מקלדת',
|
||
menuDocsHelp: 'עזרה של GenOffice Docs',
|
||
},
|
||
hi: {
|
||
dlgOpenDoc: 'दस्तावेज़ खोलें',
|
||
filterWord: 'Word दस्तावेज़',
|
||
dlgSaveAs: 'इस रूप में सहेजें',
|
||
closeUnsavedMsg: 'इस दस्तावेज़ में सहेजे नहीं गए परिवर्तन हैं।',
|
||
closeUnsavedDetail: 'क्या आप बंद करने से पहले उन्हें सहेजना चाहते हैं?',
|
||
closeNoReplyMsg: 'दस्तावेज़ प्रतिक्रिया नहीं दे रहा है और उसमें सहेजे न गए बदलाव हो सकते हैं।',
|
||
closeNoReplyDetail: 'फिर भी बंद करें? सहेजे न गए बदलाव खो जाएँगे।',
|
||
btnCloseAnyway: 'फिर भी बंद करें',
|
||
autosaveFoundTitle: 'पुनर्प्राप्त संस्करण मिला',
|
||
autosaveFoundBody:
|
||
'आपके पिछले सत्र से सहेजे नहीं गए परिवर्तन हैं। स्वतः सहेजा गया संस्करण पुनर्स्थापित करें?',
|
||
autosaveRestore: 'पुनर्स्थापित करें',
|
||
autosaveDiscard: 'छोड़ें',
|
||
btnDontSave: 'न सहेजें',
|
||
btnCancel: 'रद्द करें',
|
||
extModifiedMsg: 'फ़ाइल को किसी अन्य प्रोग्राम ने बदल दिया है।',
|
||
extModifiedDetail: 'फिर भी सहेजें और डिस्क पर मौजूद बदलावों को अधिलेखित करें?',
|
||
btnOverwrite: 'अधिलेखित करें',
|
||
dlgInsertImage: 'छवि सम्मिलित करें',
|
||
filterImages: 'छवियाँ',
|
||
dlgAddAttachment: 'अनुलग्नक जोड़ें',
|
||
filterSupported: 'समर्थित फ़ाइलें',
|
||
filterAll: 'सभी फ़ाइलें',
|
||
dlgExportPdf: 'PDF के रूप में निर्यात करें',
|
||
dlgExportHtml: 'HTML के रूप में निर्यात करें',
|
||
errUnsupportedExt: '.{ext} फ़ाइलें समर्थित नहीं हैं',
|
||
errNotFile: 'फ़ाइल नहीं है',
|
||
errTooLarge: '{mb}MB की सीमा से अधिक है',
|
||
errImageTooLarge: 'छवि 5MB की सीमा से अधिक है',
|
||
errUnreadable: 'पढ़ा नहीं जा सकता',
|
||
errFileTooLarge: 'फ़ाइल आकार सीमा से अधिक है',
|
||
errParseFailed: 'फ़ाइल पार्स करने में विफल',
|
||
errImageNoText:
|
||
'छवि अनुलग्नक टेक्स्ट प्रदान नहीं करते; छवि उपयोगकर्ता संदेश के साथ भेजी जाती है, उसे सीधे देखें',
|
||
errNotImage: 'समर्थित छवि प्रकार नहीं है',
|
||
errGskNotLoggedIn:
|
||
'Genspark में साइन इन नहीं है: नीचे “Genspark में साइन इन करें” पर क्लिक करें, साइन इन करें और फिर से कोशिश करें',
|
||
errNoApiKey: '{provider} के लिए कोई API कुंजी कॉन्फ़िगर नहीं है',
|
||
errAiBusy: 'AI सेवा अभी व्यस्त है — कृपया थोड़ी देर बाद फिर से प्रयास करें',
|
||
errNoModel: 'कोई मॉडल नाम कॉन्फ़िगर नहीं है',
|
||
menuFile: 'फ़ाइल',
|
||
menuNewDoc: 'नया दस्तावेज़',
|
||
menuNewWindow: 'नई विंडो',
|
||
menuOpen: 'खोलें…',
|
||
menuOpenRecent: 'हाल के दस्तावेज़ खोलें',
|
||
menuNoRecent: 'कोई हालिया दस्तावेज़ नहीं',
|
||
menuClose: 'बंद करें',
|
||
menuSave: 'सहेजें',
|
||
menuSaveAs: 'इस रूप में सहेजें…',
|
||
menuPageSetup: 'पृष्ठ सेटअप…',
|
||
menuExportPdf: 'PDF के रूप में निर्यात करें…',
|
||
menuExportHtml: 'HTML के रूप में निर्यात करें…',
|
||
menuPrint: 'प्रिंट करें…',
|
||
menuEdit: 'संपादन',
|
||
menuUndo: 'पूर्ववत करें',
|
||
menuRedo: 'फिर से करें',
|
||
menuCut: 'काटें',
|
||
menuCopy: 'कॉपी करें',
|
||
menuPaste: 'चिपकाएँ',
|
||
menuPasteMatch: 'चिपकाएँ और शैली मिलाएँ',
|
||
menuFindReplace: 'ढूँढें और बदलें…',
|
||
menuSelectAll: 'सभी चुनें',
|
||
menuView: 'दृश्य',
|
||
menuZoomIn: 'ज़ूम इन',
|
||
menuZoomOut: 'ज़ूम आउट',
|
||
menuZoom100: 'वास्तविक आकार (100%)',
|
||
menuPageWidth: 'पृष्ठ चौड़ाई',
|
||
menuWholePage: 'पूरा पृष्ठ',
|
||
menuAiSidebar: 'AI साइडबार',
|
||
menuDarkMode: 'डार्क मोड',
|
||
menuFullscreen: 'पूर्ण स्क्रीन में जाएँ',
|
||
menuInsert: 'सम्मिलित करें',
|
||
menuInsertTable: 'तालिका (3×3)',
|
||
menuInsertImage: 'छवि…',
|
||
menuInsertPageBreak: 'पृष्ठ विराम',
|
||
menuInsertLink: 'हाइपरलिंक…',
|
||
menuInsertEquation: 'समीकरण…',
|
||
menuComment: 'टिप्पणी',
|
||
menuFormat: 'स्वरूप',
|
||
menuBold: 'बोल्ड',
|
||
menuItalic: 'इटैलिक',
|
||
menuUnderline: 'रेखांकित',
|
||
menuAlign: 'संरेखित करें',
|
||
menuAlignLeft: 'बाएँ संरेखित करें',
|
||
menuAlignCenter: 'केंद्र में रखें',
|
||
menuAlignRight: 'दाएँ संरेखित करें',
|
||
menuAlignJustify: 'जस्टिफ़ाई करें',
|
||
menuFont: 'फ़ॉन्ट…',
|
||
menuParagraph: 'अनुच्छेद…',
|
||
menuTools: 'उपकरण',
|
||
menuWordCount: 'शब्द गणना…',
|
||
menuAiProofread: 'AI प्रूफ़रीडिंग',
|
||
menuWindow: 'विंडो',
|
||
menuHelp: 'सहायता',
|
||
menuShortcuts: 'कीबोर्ड शॉर्टकट',
|
||
menuDocsHelp: 'GenOffice Docs सहायता',
|
||
},
|
||
'zh-TW': {
|
||
dlgOpenDoc: '開啟文件',
|
||
filterWord: 'Word 文件',
|
||
dlgSaveAs: '另存新檔',
|
||
closeUnsavedMsg: '此文件有未儲存的變更。',
|
||
closeUnsavedDetail: '關閉前是否要儲存?',
|
||
closeNoReplyMsg: '文件沒有回應,可能有未儲存的變更。',
|
||
closeNoReplyDetail: '仍要關閉嗎?未儲存的變更將遺失。',
|
||
btnCloseAnyway: '仍要關閉',
|
||
autosaveFoundTitle: '發現自動復原版本',
|
||
autosaveFoundBody: '上次工作階段有未儲存的變更。要復原自動儲存的版本嗎?',
|
||
autosaveRestore: '復原',
|
||
autosaveDiscard: '放棄',
|
||
btnDontSave: '不儲存',
|
||
btnCancel: '取消',
|
||
extModifiedMsg: '檔案已被其他程式修改。',
|
||
extModifiedDetail: '仍要儲存並覆寫磁碟上的變更嗎?',
|
||
btnOverwrite: '覆寫',
|
||
dlgInsertImage: '插入圖片',
|
||
filterImages: '圖片',
|
||
dlgAddAttachment: '新增附件',
|
||
filterSupported: '支援的檔案',
|
||
filterAll: '所有檔案',
|
||
dlgExportPdf: '匯出為 PDF',
|
||
dlgExportHtml: '匯出為 HTML',
|
||
errUnsupportedExt: '暫不支援 .{ext} 類型',
|
||
errNotFile: '不是檔案',
|
||
errTooLarge: '超過 {mb}MB 上限',
|
||
errImageTooLarge: '圖片超過 5MB 上限',
|
||
errUnreadable: '無法讀取',
|
||
errFileTooLarge: '檔案超過大小上限',
|
||
errParseFailed: '檔案解析失敗',
|
||
errImageNoText: '圖片附件不提供文字,已作為影像隨使用者訊息傳送,直接看圖即可',
|
||
errNotImage: '不是支援的圖片類型',
|
||
errGskNotLoggedIn: '未登入 Genspark:請點擊下方「登入 Genspark」完成登入後重試',
|
||
errNoApiKey: '未設定 {provider} 的 API Key',
|
||
errAiBusy: 'AI 服務目前繁忙,請稍後重試',
|
||
errNoModel: '未設定模型名稱',
|
||
menuFile: '檔案',
|
||
menuNewDoc: '新增文件',
|
||
menuNewWindow: '新增視窗',
|
||
menuOpen: '開啟…',
|
||
menuOpenRecent: '開啟最近的文件',
|
||
menuNoRecent: '沒有最近的文件',
|
||
menuClose: '關閉',
|
||
menuSave: '儲存',
|
||
menuSaveAs: '另存新檔…',
|
||
menuPageSetup: '版面設定…',
|
||
menuExportPdf: '匯出為 PDF…',
|
||
menuExportHtml: '匯出為 HTML…',
|
||
menuPrint: '列印…',
|
||
menuEdit: '編輯',
|
||
menuUndo: '復原',
|
||
menuRedo: '重做',
|
||
menuCut: '剪下',
|
||
menuCopy: '複製',
|
||
menuPaste: '貼上',
|
||
menuPasteMatch: '貼上並符合格式',
|
||
menuFindReplace: '尋找與取代…',
|
||
menuSelectAll: '全選',
|
||
menuView: '檢視',
|
||
menuZoomIn: '放大',
|
||
menuZoomOut: '縮小',
|
||
menuZoom100: '實際大小 (100%)',
|
||
menuPageWidth: '頁面寬度',
|
||
menuWholePage: '整頁',
|
||
menuAiSidebar: 'AI 側邊欄',
|
||
menuDarkMode: '深色模式',
|
||
menuFullscreen: '進入全螢幕',
|
||
menuInsert: '插入',
|
||
menuInsertTable: '表格(3×3)',
|
||
menuInsertImage: '圖片…',
|
||
menuInsertPageBreak: '分頁符號',
|
||
menuInsertLink: '超連結…',
|
||
menuInsertEquation: '方程式…',
|
||
menuComment: '註解',
|
||
menuFormat: '格式',
|
||
menuBold: '粗體',
|
||
menuItalic: '斜體',
|
||
menuUnderline: '底線',
|
||
menuAlign: '對齊',
|
||
menuAlignLeft: '靠左對齊',
|
||
menuAlignCenter: '置中',
|
||
menuAlignRight: '靠右對齊',
|
||
menuAlignJustify: '左右對齊',
|
||
menuFont: '字型…',
|
||
menuParagraph: '段落…',
|
||
menuTools: '工具',
|
||
menuWordCount: '字數統計…',
|
||
menuAiProofread: 'AI 校對',
|
||
menuWindow: '視窗',
|
||
menuHelp: '說明',
|
||
menuShortcuts: '鍵盤快速鍵',
|
||
menuDocsHelp: 'GenOffice Docs 說明',
|
||
},
|
||
})
|
||
const tm = (key: Parameters<typeof tMain>[1], params?: Parameters<typeof tMain>[2]) =>
|
||
tMain(getUiLang(), key, params)
|
||
|
||
// ---- runtime configuration (paths differ when bundled into the shell) ----
|
||
|
||
interface DocsRuntimeConfig {
|
||
/** absolute path to the docs preload bundle */
|
||
preloadPath: string
|
||
/** dev-server URL for the docs renderer (wins over rendererFile) */
|
||
rendererUrl?: string | undefined
|
||
/** absolute path to the built docs renderer index.html */
|
||
rendererFile: string
|
||
}
|
||
|
||
let runtime: DocsRuntimeConfig = {
|
||
preloadPath: join(__dirname, '../preload/index.js'),
|
||
rendererUrl: process.env.ELECTRON_RENDERER_URL,
|
||
rendererFile: join(__dirname, '../renderer/index.html'),
|
||
}
|
||
|
||
export function configureDocsRuntime(config: DocsRuntimeConfig): void {
|
||
runtime = config
|
||
// shell mode: the shell queues argv files itself (per-tab pendingWindowOpens);
|
||
// the module-scope fallback would leak the double-clicked file into the next
|
||
// blank tab's consume-pending-open
|
||
pendingOpenPath = null
|
||
}
|
||
|
||
let mainWindow: BrowserWindow | null = null
|
||
let rendererReady = false
|
||
let pendingOpenPath = findDocxPath(process.argv)
|
||
/** documents queued for windows/tabs spawned via New Tab, keyed by webContents id */
|
||
const pendingWindowOpens = new Map<number, string>()
|
||
/** webContents ids that should open as a new blank doc instead of the start screen */
|
||
const pendingNewBlankIds = new Set<number>()
|
||
|
||
/** mark a docs webContents as "open blank on first consume" (called by the shell for home:new-doc) */
|
||
export function markDocsNewBlank(wcId: number): void {
|
||
pendingNewBlankIds.add(wcId)
|
||
}
|
||
|
||
/** AI-authored content waiting for its create_document tab, keyed by webContents id */
|
||
const pendingAiDocContents = new Map<number, AiDocContent>()
|
||
|
||
/** queue AI content for a fresh blank docs tab (called by the shell right after creating the view) */
|
||
export function queueDocsAiContent(wcId: number, content: AiDocContent): void {
|
||
pendingAiDocContents.set(wcId, content)
|
||
}
|
||
|
||
/** the single real BrowserWindow hosting the tab strip, used as dialog parent in tab mode */
|
||
let docsShellWindow: BrowserWindow | null = null
|
||
export function setDocsShellWindow(win: BrowserWindow | null): void {
|
||
docsShellWindow = win
|
||
}
|
||
|
||
/** injected by the shell in tab mode: resolves the webContents of the currently active docs tab,
|
||
* used for menu-command forwarding where there is no IpcMainInvokeEvent to key off of. */
|
||
let activeDocsResolver: (() => WebContents | null) | null = null
|
||
export function setActiveDocsResolver(fn: (() => WebContents | null) | null): void {
|
||
activeDocsResolver = fn
|
||
}
|
||
|
||
function activeDocsWebContents(): WebContents | null {
|
||
if (activeDocsResolver) return activeDocsResolver()
|
||
return BrowserWindow.getFocusedWindow()?.webContents ?? mainWindow?.webContents ?? null
|
||
}
|
||
|
||
/** dialog parent for the calling tab (standalone mode falls back to its own BrowserWindow) */
|
||
function dialogParent(event: IpcMainInvokeEvent): BrowserWindow | undefined {
|
||
return docsShellWindow ?? BrowserWindow.fromWebContents(event.sender) ?? undefined
|
||
}
|
||
|
||
async function openDialog(event: IpcMainInvokeEvent, options: OpenDialogOptions) {
|
||
return showOpenDialogWithMemory(dialog, dialogParent(event), options)
|
||
}
|
||
|
||
async function saveDialog(event: IpcMainInvokeEvent, options: SaveDialogOptions) {
|
||
// before any pick is remembered, bare-name suggestions anchor in the
|
||
// configurable default save folder instead of Electron's Downloads pin
|
||
return showSaveDialogWithMemory(dialog, dialogParent(event), options, defaultSaveDir())
|
||
}
|
||
|
||
/** default folder where new files land on their first (silent) save; shared with the other editors via shell. User-configurable (app-settings.json), falls back to <Documents>/GenOffice. */
|
||
export function defaultSaveDir(): string {
|
||
return configuredDefaultSaveDir(app)
|
||
}
|
||
|
||
/** first free path for fileName inside dir: name.ext, name-2.ext, name-3.ext… */
|
||
export function uniquePathIn(dir: string, fileName: string): string {
|
||
const dot = fileName.lastIndexOf('.')
|
||
const base = dot > 0 ? fileName.slice(0, dot) : fileName
|
||
const ext = dot > 0 ? fileName.slice(dot) : ''
|
||
let candidate = join(dir, fileName)
|
||
for (let i = 2; existsSync(candidate); i++) candidate = join(dir, `${base}-${i}${ext}`)
|
||
return candidate
|
||
}
|
||
|
||
export function openExternalDocx(filePath: string | null): void {
|
||
if (!filePath || !/\.docx$/i.test(filePath)) return
|
||
const win = BrowserWindow.getFocusedWindow() ?? mainWindow
|
||
if (!rendererReady || !win) {
|
||
pendingOpenPath = filePath
|
||
return
|
||
}
|
||
void loadDocx(filePath, win.webContents.id)
|
||
.then((result) => {
|
||
if (!result || win.isDestroyed()) return
|
||
if (win.isMinimized()) win.restore()
|
||
win.show()
|
||
win.focus()
|
||
win.webContents.send('docs:opened', result)
|
||
})
|
||
.catch((err) => dialog.showErrorBox(tm('dlgOpenDoc'), String(err)))
|
||
}
|
||
|
||
function userDataPath(...parts: string[]): string {
|
||
return join(app.getPath('userData'), ...parts)
|
||
}
|
||
|
||
function readJson<T>(path: string, fallback: T): T {
|
||
try {
|
||
if (existsSync(path)) return JSON.parse(readFileSync(path, 'utf-8')) as T
|
||
} catch {
|
||
/* corrupted state file: fall back to defaults */
|
||
}
|
||
return fallback
|
||
}
|
||
|
||
function writeJson(path: string, value: unknown): void {
|
||
mkdirSync(join(path, '..'), { recursive: true })
|
||
writeFileSync(path, JSON.stringify(value, null, 2))
|
||
}
|
||
|
||
// ---- recent files ----
|
||
|
||
const RECENT_PATH = () => userDataPath('recent.json')
|
||
|
||
// the home screen lists all of these; the File menu shows only the first few
|
||
const RECENT_LIMIT = 100
|
||
|
||
function pushRecent(filePath: string): void {
|
||
const recent = readJson<string[]>(RECENT_PATH(), [])
|
||
// Every save lands here (autosave = every 30s): skip the write and the menu
|
||
// rebuild when the file is already at the head of the list
|
||
if (recent[0] === filePath) return
|
||
const next = [filePath, ...recent.filter((p) => p !== filePath)].slice(0, RECENT_LIMIT)
|
||
writeJson(RECENT_PATH(), next)
|
||
buildDocsMenu() // keep File > Open Recent in sync
|
||
}
|
||
|
||
/** unified recents for the shell home screen (paths only; type = extension).
|
||
* No existence filter: a transiently unavailable path (disconnected drive,
|
||
* pending mount) must stay listed — the stat layer flags it instead (r158) */
|
||
export function readRecentFiles(): string[] {
|
||
return readJson<string[]>(RECENT_PATH(), [])
|
||
}
|
||
|
||
export function recordRecentFile(filePath: string): void {
|
||
pushRecent(filePath)
|
||
}
|
||
|
||
export function removeRecentFiles(filePaths: string[]): void {
|
||
const drop = new Set(filePaths)
|
||
const recent = readJson<string[]>(RECENT_PATH(), [])
|
||
writeJson(
|
||
RECENT_PATH(),
|
||
recent.filter((p) => !drop.has(p)),
|
||
)
|
||
buildDocsMenu()
|
||
}
|
||
|
||
/** shell notification: the file of an open view was renamed on disk (renamed in
|
||
* the Home list) — push to the matching renderer so it syncs its save path and
|
||
* title bar (docs keeps path state on the renderer side). */
|
||
export function docsFileRenamed(wc: WebContents, oldPath: string, newPath: string): void {
|
||
// keep the save allowlist in sync so docs:save accepts the renamed path
|
||
docWritablePaths.get(wc.id)?.delete(oldPath)
|
||
allowDocWrite(wc.id, newPath)
|
||
const states = docDiskStates.get(wc.id)
|
||
const recorded = states?.get(oldPath)
|
||
if (states && recorded) {
|
||
states.delete(oldPath)
|
||
states.set(newPath, recorded)
|
||
}
|
||
// an encrypted document's password must follow the path, or the next save
|
||
// finds no password under the new name and silently writes plaintext
|
||
renameDocPassword(wc.id, oldPath, newPath)
|
||
wc.send('docs:renamed', { oldPath, newPath })
|
||
}
|
||
|
||
/** keep a renamed file at its old position in the recent/starred lists */
|
||
export function replaceRecentFile(oldPath: string, newPath: string): void {
|
||
const recent = readJson<string[]>(RECENT_PATH(), [])
|
||
writeJson(
|
||
RECENT_PATH(),
|
||
recent.map((p) => (p === oldPath ? newPath : p)),
|
||
)
|
||
const starred = readJson<string[]>(STARRED_PATH(), [])
|
||
if (starred.includes(oldPath)) {
|
||
writeJson(
|
||
STARRED_PATH(),
|
||
starred.map((p) => (p === oldPath ? newPath : p)),
|
||
)
|
||
}
|
||
buildDocsMenu()
|
||
}
|
||
|
||
// ---- starred files (home screen favorites) ----
|
||
|
||
const STARRED_PATH = () => userDataPath('starred.json')
|
||
|
||
/** No existence filter, same rationale as readRecentFiles: a transiently
|
||
* unavailable starred file must keep its star and its Starred-view row —
|
||
* filtering here also desynced the star state shown on recents rows (r158) */
|
||
export function readStarredFiles(): string[] {
|
||
return readJson<string[]>(STARRED_PATH(), [])
|
||
}
|
||
|
||
export function toggleStarredFile(filePath: string): void {
|
||
const starred = readJson<string[]>(STARRED_PATH(), [])
|
||
const next = starred.includes(filePath)
|
||
? starred.filter((p) => p !== filePath)
|
||
: [...starred, filePath]
|
||
writeJson(STARRED_PATH(), next)
|
||
}
|
||
|
||
/** Bulk unstar (in-app delete, or removing an unavailable entry from the
|
||
* recents list): the star must not outlive the row it pointed at (r158) */
|
||
export function removeStarredFiles(filePaths: string[]): void {
|
||
const drop = new Set(filePaths)
|
||
if (drop.size === 0) return
|
||
const starred = readJson<string[]>(STARRED_PATH(), [])
|
||
const next = starred.filter((p) => !drop.has(p))
|
||
if (next.length !== starred.length) writeJson(STARRED_PATH(), next)
|
||
}
|
||
|
||
// ---- original archive (pass-through base: original file archived by content hash) ----
|
||
|
||
async function archiveOriginal(filePath: string, bytes: Buffer): Promise<string> {
|
||
const hash = sha256Hex(bytes)
|
||
const dir = userDataPath('originals')
|
||
await mkdir(dir, { recursive: true })
|
||
const target = join(dir, `${hash}.docx`)
|
||
if (!existsSync(target)) await copyFile(filePath, target)
|
||
void pruneOriginals(dir)
|
||
return hash
|
||
}
|
||
|
||
const ORIGINALS_MAX_BYTES = 500 * 1024 * 1024
|
||
let originalsPruneRunning = false
|
||
|
||
/** cap the archive's total size; oldest by mtime go first (never blocks the open path) */
|
||
async function pruneOriginals(dir: string): Promise<void> {
|
||
if (originalsPruneRunning) return
|
||
originalsPruneRunning = true
|
||
try {
|
||
const files: Array<{ path: string; size: number; mtimeMs: number }> = []
|
||
for (const name of await readdir(dir)) {
|
||
try {
|
||
const s = await stat(join(dir, name))
|
||
if (s.isFile()) files.push({ path: join(dir, name), size: s.size, mtimeMs: s.mtimeMs })
|
||
} catch {
|
||
/* removed concurrently */
|
||
}
|
||
}
|
||
let total = files.reduce((sum, f) => sum + f.size, 0)
|
||
files.sort((a, b) => a.mtimeMs - b.mtimeMs)
|
||
for (const f of files) {
|
||
if (total <= ORIGINALS_MAX_BYTES) break
|
||
try {
|
||
await unlink(f.path)
|
||
total -= f.size
|
||
} catch {
|
||
/* already gone */
|
||
}
|
||
}
|
||
} catch {
|
||
/* directory unreadable: retry on the next archive */
|
||
} finally {
|
||
originalsPruneRunning = false
|
||
}
|
||
}
|
||
|
||
/** per-renderer paths writable via docs:save — populated by open/save-as flows */
|
||
const docWritablePaths = new Map<number, Set<string>>()
|
||
/** per-renderer PDF export targets authorized via the export save dialog */
|
||
const pdfWritablePaths = new Map<number, Set<string>>()
|
||
const tornDownWcIds = new Set<number>()
|
||
|
||
function allowDocWrite(wcId: number, filePath: string): void {
|
||
const set = docWritablePaths.get(wcId) ?? new Set<string>()
|
||
set.add(filePath)
|
||
docWritablePaths.set(wcId, set)
|
||
}
|
||
|
||
function canDocWrite(wcId: number, filePath: string): boolean {
|
||
return docWritablePaths.get(wcId)?.has(filePath) === true
|
||
}
|
||
|
||
function allowPdfWrite(wcId: number, filePath: string): void {
|
||
const set = pdfWritablePaths.get(wcId) ?? new Set<string>()
|
||
set.add(filePath)
|
||
pdfWritablePaths.set(wcId, set)
|
||
}
|
||
|
||
// Fidelity-harness escape hatch: headless runs have no save dialog to authorize
|
||
// paths, so an explicitly configured directory (set only by our test scripts)
|
||
// is treated as pre-authorized for PDF export.
|
||
const testExportDir = process.env.GENOFFICE_TEST_EXPORT_DIR || null
|
||
|
||
function canPdfWrite(wcId: number, filePath: string): boolean {
|
||
if (testExportDir && filePath.startsWith(testExportDir + '/')) return true
|
||
return pdfWritablePaths.get(wcId)?.has(filePath) === true
|
||
}
|
||
|
||
function dropDocWriter(wcId: number): void {
|
||
docWritablePaths.delete(wcId)
|
||
pdfWritablePaths.delete(wcId)
|
||
docDiskStates.delete(wcId)
|
||
// Destroyed renderers count as torn down too: window-close paths never run
|
||
// teardownDocsRenderer, but an in-flight save handler resuming after the
|
||
// destruction must still fail its re-check (wcIds are never reused, so the
|
||
// set only accumulates a few integers per session).
|
||
tornDownWcIds.add(wcId)
|
||
}
|
||
|
||
// ── External-modification detection: remember the disk state at every read/write
|
||
// so docs:save can refuse to clobber edits made by Word/another window ──
|
||
const docDiskStates = new Map<number, Map<string, DiskFileState>>()
|
||
|
||
const sha256Hex = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')
|
||
|
||
async function rememberDiskState(wcId: number, filePath: string, bytes: Buffer): Promise<void> {
|
||
try {
|
||
const s = await stat(filePath)
|
||
const states = docDiskStates.get(wcId) ?? new Map<string, DiskFileState>()
|
||
states.set(filePath, { mtimeMs: s.mtimeMs, size: s.size, hash: sha256Hex(bytes) })
|
||
docDiskStates.set(wcId, states)
|
||
} catch {
|
||
/* unstatable target: skip tracking; the next save simply won't flag a conflict */
|
||
}
|
||
}
|
||
|
||
async function diskChangedExternally(wcId: number, filePath: string): Promise<boolean> {
|
||
let current: { mtimeMs: number; size: number } | null
|
||
try {
|
||
current = await stat(filePath)
|
||
} catch {
|
||
current = null
|
||
}
|
||
return isExternallyModified(docDiskStates.get(wcId)?.get(filePath), current, async () => {
|
||
try {
|
||
return sha256Hex(await readFile(filePath))
|
||
} catch {
|
||
return null
|
||
}
|
||
})
|
||
}
|
||
|
||
/** A closed docs tab detaches without destroying its webContents (shell freeze
|
||
* workaround), so the orphan must lose write access and stop its timers — otherwise
|
||
* its 30s recovery loop resurrects content the user already discarded. */
|
||
export function teardownDocsRenderer(contents: WebContents): void {
|
||
tornDownWcIds.add(contents.id)
|
||
// Sweep recovery copies for this renderer's documents: every non-crash close
|
||
// either saved (docs:save already cleared it) or explicitly discarded, so a
|
||
// copy still on disk here is a leftover from an in-flight recovery write.
|
||
for (const p of docWritablePaths.get(contents.id) ?? []) clearRecoveryCopy(p)
|
||
// reclaim every per-wcId grant, not just doc saves — the orphaned renderer
|
||
// must also lose its dialog-authorized PDF targets and disk-state cache
|
||
docWritablePaths.delete(contents.id)
|
||
pdfWritablePaths.delete(contents.id)
|
||
docDiskStates.delete(contents.id)
|
||
forgetDocPasswords(contents.id)
|
||
if (!contents.isDestroyed()) contents.send('docs:teardown')
|
||
}
|
||
|
||
// ── Crash recovery: dirty renderers push a copy every 30s
|
||
// (docs:write-recovery); a normal save cleans it up; open offers Restore/Discard ──
|
||
const recoveryDir = () => userDataPath('docs-autosave')
|
||
const recoveryPathFor = (filePath: string) =>
|
||
join(recoveryDir(), `${createHash('sha1').update(filePath).digest('hex').slice(0, 16)}.docx`)
|
||
|
||
/** Bumped by every clear: an in-flight docs:write-recovery that started before
|
||
* the bump must not recreate the file it is about to land (stale-recovery race). */
|
||
const recoveryClearEpochs = new Map<string, number>()
|
||
|
||
function clearRecoveryCopy(filePath: string): void {
|
||
recoveryClearEpochs.set(filePath, (recoveryClearEpochs.get(filePath) ?? 0) + 1)
|
||
try {
|
||
unlinkSync(recoveryPathFor(filePath))
|
||
} catch {
|
||
/* nothing to clean */
|
||
}
|
||
}
|
||
|
||
interface MaybeRecoveredDocBytes {
|
||
bytes: Buffer
|
||
recovered: boolean
|
||
}
|
||
|
||
/** On open, if a recovery copy newer than the original exists, ask whether to restore
|
||
* (still points at the original path; only save persists it). */
|
||
async function maybeRecoverDocBytes(
|
||
filePath: string,
|
||
original: Buffer,
|
||
): Promise<MaybeRecoveredDocBytes> {
|
||
const asPath = recoveryPathFor(filePath)
|
||
try {
|
||
if (!existsSync(asPath)) return { bytes: original, recovered: false }
|
||
if (statSync(asPath).mtimeMs <= statSync(filePath).mtimeMs) {
|
||
// a crashed partial write bumps mtime yet corrupts the file — keep the copy
|
||
// then (an encrypted original is a CFB container, not a zip: intact too)
|
||
if (looksLikeZip(original) || isEncryptedDocx(original)) {
|
||
unlinkSync(asPath)
|
||
return { bytes: original, recovered: false }
|
||
}
|
||
}
|
||
} catch {
|
||
return { bytes: original, recovered: false }
|
||
}
|
||
const options = {
|
||
type: 'question' as const,
|
||
buttons: [tm('autosaveRestore'), tm('autosaveDiscard')],
|
||
defaultId: 0,
|
||
cancelId: 1,
|
||
message: tm('autosaveFoundTitle'),
|
||
detail: tm('autosaveFoundBody'),
|
||
}
|
||
const parent = BrowserWindow.getFocusedWindow() ?? mainWindow
|
||
const r =
|
||
parent && !parent.isDestroyed()
|
||
? await dialog.showMessageBox(parent, options)
|
||
: await dialog.showMessageBox(options)
|
||
if (r.response === 0) {
|
||
try {
|
||
return { bytes: await readFile(asPath), recovered: true }
|
||
} catch {
|
||
return { bytes: original, recovered: false }
|
||
}
|
||
}
|
||
clearRecoveryCopy(filePath)
|
||
return { bytes: original, recovered: false }
|
||
}
|
||
|
||
async function loadDocx(
|
||
filePath: string,
|
||
wcId: number,
|
||
password?: string,
|
||
): Promise<OpenDocxResult> {
|
||
if (typeof filePath !== 'string' || !/\.docx$/i.test(filePath)) return null
|
||
if (!existsSync(filePath)) return null
|
||
const original = await readFile(filePath)
|
||
// Password-protected docx (ECMA-376 CFB container): without a password, hand
|
||
// back a marker — the renderer prompts and retries via docs:open-decrypt.
|
||
// No side effects (recents/write grant) until the password checks out.
|
||
let plainBytes: Buffer = original
|
||
const encrypted = isEncryptedDocx(original)
|
||
if (encrypted) {
|
||
const pwd = password ?? docPasswordFor(wcId, filePath)
|
||
if (!pwd) return { needsPassword: true, path: filePath, name: basename(filePath) }
|
||
plainBytes = await decryptDocx(original, pwd) // throws DocxDecryptError
|
||
rememberDocPassword(wcId, filePath, pwd)
|
||
} else {
|
||
rememberDocPassword(wcId, filePath, null)
|
||
}
|
||
// the archive keeps the on-disk original as-is (encrypted ones included: they
|
||
// reopen with the user's password), so a bad save never loses the source file
|
||
const hash = await archiveOriginal(filePath, original)
|
||
const recovery = await maybeRecoverDocBytes(filePath, plainBytes)
|
||
let bytes = recovery.bytes
|
||
let recovered = recovery.recovered
|
||
// recovery copies of a protected document are themselves encrypted (see
|
||
// docs:write-recovery); an unreadable copy falls back to the original
|
||
if (encrypted && isEncryptedDocx(bytes)) {
|
||
try {
|
||
bytes = await decryptRecoveryCopy(wcId, filePath, bytes)
|
||
} catch {
|
||
bytes = plainBytes
|
||
recovered = false
|
||
}
|
||
}
|
||
pushRecent(filePath)
|
||
allowDocWrite(wcId, filePath)
|
||
if (fileOpenedHook) fileOpenedHook(wcId, filePath)
|
||
markDiskEncrypted(wcId, filePath, encrypted)
|
||
// record the on-disk file, not the recovery copy: what matters is what save would overwrite
|
||
await rememberDiskState(wcId, filePath, original)
|
||
return {
|
||
path: filePath,
|
||
name: basename(filePath),
|
||
data: bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer,
|
||
hash,
|
||
encrypted,
|
||
recovered: recovered || undefined,
|
||
}
|
||
}
|
||
|
||
// ---- IPC ----
|
||
|
||
const IMAGE_MIME: Record<string, 'image/png' | 'image/jpeg' | 'image/gif'> = {
|
||
png: 'image/png',
|
||
jpg: 'image/jpeg',
|
||
jpeg: 'image/jpeg',
|
||
gif: 'image/gif',
|
||
}
|
||
|
||
// ---- chat attachments: local files parsed for the agent ----
|
||
|
||
const ATTACHMENT_MAX_BYTES = 50 * 1024 * 1024
|
||
/** plain-text extensions read as UTF-8 */
|
||
const TEXT_EXTS = new Set([
|
||
'txt',
|
||
'md',
|
||
'markdown',
|
||
'csv',
|
||
'tsv',
|
||
'json',
|
||
'yaml',
|
||
'yml',
|
||
'xml',
|
||
'html',
|
||
'htm',
|
||
'log',
|
||
'js',
|
||
'ts',
|
||
'tsx',
|
||
'jsx',
|
||
'py',
|
||
'java',
|
||
'c',
|
||
'h',
|
||
'cpp',
|
||
'go',
|
||
'rs',
|
||
'rb',
|
||
'sh',
|
||
'sql',
|
||
'css',
|
||
])
|
||
/** office/pdf formats get text extracted via @genoffice/file-parse; images skip extraction and go multimodal (files:read-image) */
|
||
const ATTACHMENT_EXTS = new Set([
|
||
...TEXT_EXTS,
|
||
'doc',
|
||
'docx',
|
||
'pdf',
|
||
'pptx',
|
||
'ppt',
|
||
'xlsx',
|
||
'xlsm',
|
||
'xls',
|
||
...ATTACHMENT_IMAGE_EXTS,
|
||
])
|
||
|
||
const ATTACHMENT_IMAGE_MIME: Record<string, string> = {
|
||
png: 'image/png',
|
||
jpg: 'image/jpeg',
|
||
jpeg: 'image/jpeg',
|
||
gif: 'image/gif',
|
||
webp: 'image/webp',
|
||
}
|
||
/** multimodal size cap per image attachment (keeps the context from blowing up) */
|
||
const ATTACHMENT_IMAGE_MAX_BYTES = 5 * 1024 * 1024
|
||
|
||
/** extracted text cache keyed by path; invalidated by mtime+size */
|
||
const attachmentTextCache = new Map<string, { stamp: string; text: string }>()
|
||
|
||
function statAttachment(filePath: string): { meta?: AttachmentMeta; error?: string } {
|
||
const name = basename(filePath)
|
||
const ext = name.split('.').pop()?.toLowerCase() ?? ''
|
||
if (!ATTACHMENT_EXTS.has(ext)) return { error: `${name}: ${tm('errUnsupportedExt', { ext })}` }
|
||
try {
|
||
const stat = statSync(filePath)
|
||
if (!stat.isFile()) return { error: `${name}: ${tm('errNotFile')}` }
|
||
if (stat.size > ATTACHMENT_MAX_BYTES) {
|
||
return {
|
||
error: `${name}: ${tm('errTooLarge', { mb: Math.round(ATTACHMENT_MAX_BYTES / 1024 / 1024) })}`,
|
||
}
|
||
}
|
||
if (ATTACHMENT_IMAGE_EXTS.has(ext) && stat.size > ATTACHMENT_IMAGE_MAX_BYTES) {
|
||
return { error: `${name}: ${tm('errImageTooLarge')}` }
|
||
}
|
||
return { meta: { path: filePath, name, ext, sizeBytes: stat.size } }
|
||
} catch {
|
||
return { error: `${name}: ${tm('errUnreadable')}` }
|
||
}
|
||
}
|
||
|
||
function collectAttachments(paths: string[]): AttachmentAddResult {
|
||
const accepted: AttachmentMeta[] = []
|
||
const rejected: string[] = []
|
||
for (const p of paths) {
|
||
const { meta, error } = statAttachment(p)
|
||
if (meta) accepted.push(meta)
|
||
else if (error) rejected.push(error)
|
||
}
|
||
return { accepted, rejected }
|
||
}
|
||
|
||
/** save clipboard-pasted image bytes to a temp file (screenshots/bitmaps with no local path); returns null for non-images or empty data */
|
||
let pastedImageSeq = 0
|
||
let pastedDirPruned = false
|
||
|
||
/** drop pasted-image temp files older than 7 days (once per app run) */
|
||
function prunePastedImages(dir: string): void {
|
||
if (pastedDirPruned) return
|
||
pastedDirPruned = true
|
||
const cutoff = Date.now() - 7 * 24 * 60 * 60 * 1000
|
||
try {
|
||
for (const name of readdirSync(dir)) {
|
||
const p = join(dir, name)
|
||
try {
|
||
if (statSync(p).mtimeMs < cutoff) unlinkSync(p)
|
||
} catch {
|
||
// ignore: another tab may have removed it already
|
||
}
|
||
}
|
||
} catch {
|
||
// ignore: directory may not exist yet
|
||
}
|
||
}
|
||
function savePastedImage(data: unknown, ext: unknown): string | null {
|
||
const cleanExt = typeof ext === 'string' ? ext.toLowerCase() : ''
|
||
if (!ATTACHMENT_IMAGE_EXTS.has(cleanExt)) return null
|
||
const bytes =
|
||
data instanceof ArrayBuffer
|
||
? Buffer.from(data)
|
||
: ArrayBuffer.isView(data)
|
||
? Buffer.from(data.buffer, data.byteOffset, data.byteLength)
|
||
: null
|
||
if (!bytes || bytes.byteLength === 0) return null
|
||
const dir = join(app.getPath('temp'), 'genoffice-pasted')
|
||
mkdirSync(dir, { recursive: true })
|
||
prunePastedImages(dir)
|
||
const stamp = new Date().toISOString().slice(0, 19).replace(/[-:]/g, '').replace('T', '-')
|
||
const filePath = join(dir, `pasted-${stamp}-${++pastedImageSeq}.${cleanExt}`)
|
||
writeFileSync(filePath, bytes)
|
||
return filePath
|
||
}
|
||
|
||
/** parse an attachment to text via @genoffice/file-parse (docx/pdf/pptx/xlsx/plain text) */
|
||
async function extractAttachmentText(filePath: string): Promise<string> {
|
||
const stat = statSync(filePath)
|
||
const stamp = `${stat.mtimeMs}:${stat.size}`
|
||
const cached = attachmentTextCache.get(filePath)
|
||
if (cached && cached.stamp === stamp) return cached.text
|
||
if (stat.size > ATTACHMENT_MAX_BYTES) throw new Error(tm('errFileTooLarge'))
|
||
const parsed = await parseFileToText(filePath)
|
||
if (!parsed.ok || parsed.kind !== 'text' || parsed.text == null) {
|
||
throw new Error(parsed.error ?? tm('errParseFailed'))
|
||
}
|
||
attachmentTextCache.set(filePath, { stamp, text: parsed.text })
|
||
// keep the cache bounded (a handful of recent files is plenty)
|
||
if (attachmentTextCache.size > 8) {
|
||
const oldest = attachmentTextCache.keys().next().value
|
||
if (oldest) attachmentTextCache.delete(oldest)
|
||
}
|
||
return parsed.text
|
||
}
|
||
|
||
// ---- print / export PDF ----
|
||
|
||
const TWIPS_PER_INCH = 1440
|
||
|
||
// ---- AI settings + chat proxy (main process avoids renderer CORS) ----
|
||
// provider metadata, settings defaults/migration, and per-provider streaming/chat
|
||
// implementations live in @genoffice/ai-provider, shared with apps/sheets.
|
||
|
||
const SETTINGS_PATH = () => userDataPath('ai-settings.json')
|
||
|
||
const activeAiStreams = new Map<string, AbortController>()
|
||
|
||
/**
|
||
* AI settings + chat/stream proxy handlers. Split out so the shell can
|
||
* register them exactly once for all window types (docs, sheets, home) —
|
||
* sheets' standalone AI handlers use the same channel names.
|
||
*/
|
||
export function registerAiIpc(): void {
|
||
app.once('before-quit', shutdownCodexAppServers)
|
||
ipcMain.handle('ai:get-settings', (): AiSettings => {
|
||
const stored = readJson<Partial<AiSettings> & LegacyAiSettings>(SETTINGS_PATH(), {})
|
||
// pre-lock legacy file: genspark selected with cloud tools opted out. The
|
||
// settings UI locks the tools switch on with genspark and apps read this
|
||
// file live, so heal the stored flag once. Judged on the *stored* provider
|
||
// — never the activeProvider fallback below, which must not leak into the
|
||
// file and clobber a saved (half-configured) BYOK selection.
|
||
if ((stored.provider ?? 'genspark') === 'genspark' && stored.gskToolsEnabled === false) {
|
||
stored.gskToolsEnabled = true
|
||
writeJson(SETTINGS_PATH(), stored)
|
||
}
|
||
const settings = resolveAiSettings(stored, defaultAiSettings())
|
||
// a stored BYOK provider is honored when usable; half-filled configs fall back to genspark
|
||
settings.provider = activeProvider(settings)
|
||
return settings
|
||
})
|
||
|
||
// Genspark account (gsk login state): auth source for AI features; the frontend uses it to prompt login when logged out
|
||
ipcMain.handle(
|
||
'ai:gsk-status',
|
||
async (_event, withEmail?: boolean): Promise<GenSparkAccountStatus> => {
|
||
if (!hasGskAuth()) return { loggedIn: false }
|
||
if (!withEmail) return { loggedIn: true }
|
||
const info = await gskLoginInfo()
|
||
return info?.email ? { loggedIn: true, email: info.email } : { loggedIn: true }
|
||
},
|
||
)
|
||
|
||
ipcMain.handle('ai:gsk-login', () => {
|
||
ensureGenofficeLogin((url) => void shell.openExternal(url))
|
||
})
|
||
|
||
ipcMain.handle('ai:set-settings', (_event, settings: AiSettings) => {
|
||
writeJson(SETTINGS_PATH(), settings)
|
||
})
|
||
|
||
ipcMain.handle('ai:codex-models', async (_event, cliPath: unknown) => {
|
||
return listCodexModels(typeof cliPath === 'string' ? cliPath : undefined)
|
||
})
|
||
|
||
ipcMain.handle('ai:stream', async (event, request: AiStreamRequest) => {
|
||
const { requestId, settings, system, messages } = request
|
||
const tools = request.tools ?? []
|
||
const maxTokens = request.maxTokens ?? maxOutputTokensOf(settings)
|
||
const provider = settings.provider
|
||
let config = settings.providers?.[provider]
|
||
// the genspark key never enters the settings file; requests take it from the gsk login state
|
||
if (provider === 'genspark' && config && !config.apiKey) {
|
||
config = { ...config, apiKey: gskApiKey() }
|
||
}
|
||
const send = (chunk: AiStreamChunk) => {
|
||
if (!event.sender.isDestroyed()) event.sender.send('ai:stream-chunk', chunk)
|
||
}
|
||
if (!config || (provider !== 'codex' && !config.apiKey)) {
|
||
send({
|
||
requestId,
|
||
type: 'error',
|
||
error: provider === 'genspark' ? tm('errGskNotLoggedIn') : tm('errNoApiKey', { provider }),
|
||
})
|
||
return
|
||
}
|
||
if (provider !== 'codex' && !config.model) {
|
||
send({ requestId, type: 'error', error: tm('errNoModel') })
|
||
return
|
||
}
|
||
const controller = new AbortController()
|
||
activeAiStreams.set(requestId, controller)
|
||
// wire-activity keepalive: lets the renderer's silence watchdog tell a slow turn from a dead one
|
||
let lastPing = 0
|
||
const ping = () => {
|
||
const now = Date.now()
|
||
if (now - lastPing < 5_000) return
|
||
lastPing = now
|
||
send({ requestId, type: 'ping' })
|
||
}
|
||
try {
|
||
let stopReason: string | undefined
|
||
await streamForProvider(provider, config, system, messages, tools, maxTokens, {
|
||
...(request.sessionId ? { sessionId: request.sessionId } : {}),
|
||
signal: controller.signal,
|
||
onDelta: (text) => send({ requestId, type: 'delta', text }),
|
||
onReasoningDelta: (text) => send({ requestId, type: 'reasoning', text }),
|
||
onToolCall: (toolCall) => send({ requestId, type: 'tool-call', toolCall }),
|
||
onActivity: ping,
|
||
onStopReason: (reason) => {
|
||
stopReason = reason
|
||
},
|
||
})
|
||
send({ requestId, type: 'done', stopReason })
|
||
} catch (err) {
|
||
if (controller.signal.aborted) {
|
||
send({ requestId, type: 'done' })
|
||
} else {
|
||
send({
|
||
requestId,
|
||
type: 'error',
|
||
error: err instanceof Error ? err.message : String(err),
|
||
...(err instanceof AiTimeoutError
|
||
? { errorCode: 'timeout' as const }
|
||
: err instanceof AiCreditsError
|
||
? { errorCode: 'credits' as const }
|
||
: isAiNetworkError(err)
|
||
? { errorCode: 'network' as const }
|
||
: isAiOverloadedError(err)
|
||
? { errorCode: 'overloaded' as const }
|
||
: {}),
|
||
})
|
||
}
|
||
} finally {
|
||
activeAiStreams.delete(requestId)
|
||
}
|
||
})
|
||
|
||
ipcMain.handle('ai:stream-cancel', (_event, requestId: string) => {
|
||
activeAiStreams.get(requestId)?.abort()
|
||
})
|
||
|
||
// shared search tools (content + images): Serper with DuckDuckGo fallback (same source as slides/sheets)
|
||
ipcMain.handle('ai:web-search', async (_event, query: string, maxResults?: number) => {
|
||
try {
|
||
return await webSearchTool(
|
||
SETTINGS_PATH(),
|
||
String(query),
|
||
typeof maxResults === 'number' ? maxResults : 6,
|
||
)
|
||
} catch (err) {
|
||
return { results: [], method: 'error', error: String(err) }
|
||
}
|
||
})
|
||
ipcMain.handle('ai:image-search', async (_event, query: string, maxResults?: number) => {
|
||
try {
|
||
return await imageSearchTool(
|
||
SETTINGS_PATH(),
|
||
String(query),
|
||
typeof maxResults === 'number' ? maxResults : 8,
|
||
)
|
||
} catch (err) {
|
||
return { images: [], method: 'error', error: String(err) }
|
||
}
|
||
})
|
||
|
||
// download image from URL → base64+mime (download in the main process avoids CORS; the renderer builds the image node and measures size itself)
|
||
ipcMain.handle(
|
||
'ai:fetch-image',
|
||
async (_event, url: string): Promise<{ base64: string; mime: string } | null> => {
|
||
try {
|
||
// the URL originates from AI tool calls (prompt-injectable via web search
|
||
// results), so refuse non-http schemes and private/link-local targets;
|
||
// redirects are followed manually so every hop is validated too.
|
||
// fetchRemoteImage adds CDN-friendly headers and transient-error retries.
|
||
const resp = await fetchRemoteImage(String(url))
|
||
if (!resp || !resp.ok) return null
|
||
const buf = Buffer.from(await resp.arrayBuffer())
|
||
const ct = resp.headers.get('content-type') ?? ''
|
||
const mime = ct.includes('png')
|
||
? 'image/png'
|
||
: ct.includes('gif')
|
||
? 'image/gif'
|
||
: 'image/jpeg'
|
||
return { base64: buf.toString('base64'), mime }
|
||
} catch {
|
||
return null
|
||
}
|
||
},
|
||
)
|
||
|
||
// docs-owned (like pdf:generate-image): slides' ai:generate-image is only
|
||
// registered once a slides view exists, so docs needs its own channel
|
||
ipcMain.handle(
|
||
'docs:ai-generate-image',
|
||
(_event, op: { prompt?: unknown; aspectRatio?: unknown }) =>
|
||
generateImageTool(SETTINGS_PATH(), {
|
||
prompt: String(op?.prompt ?? ''),
|
||
aspectRatio: op?.aspectRatio ? String(op.aspectRatio) : undefined,
|
||
}),
|
||
)
|
||
|
||
ipcMain.handle('ai:search-test', (_event, input: unknown) => {
|
||
const { provider, apiKey } = (input ?? {}) as { provider?: AiSearchProviderId; apiKey?: string }
|
||
if (!provider || provider === 'genspark') {
|
||
return hasGskAuth() ? { ok: true } : { ok: false, error: tm('errGskNotLoggedIn') }
|
||
}
|
||
return testSearchProvider(provider, String(apiKey ?? ''))
|
||
})
|
||
|
||
// settings-UI connection test for the media provider (genspark = the gsk login state)
|
||
ipcMain.handle('ai:media-test', (_event, input: unknown) => {
|
||
const { provider, config } = (input ?? {}) as {
|
||
provider?: AiMediaProviderId
|
||
config?: AiMediaProviderConfig
|
||
}
|
||
if (!provider || provider === 'genspark') {
|
||
return hasGskAuth() ? { ok: true } : { ok: false, error: tm('errGskNotLoggedIn') }
|
||
}
|
||
if (!config) return { ok: false, error: 'No media provider configuration' }
|
||
return testMediaProvider(provider, config)
|
||
})
|
||
|
||
ipcMain.handle('ai:chat', async (_event, request: AiChatRequest) => {
|
||
const { settings, system, user } = request
|
||
const provider = settings.provider
|
||
let config = settings.providers?.[provider]
|
||
if (provider === 'genspark' && config && !config.apiKey) {
|
||
config = { ...config, apiKey: gskApiKey() }
|
||
}
|
||
if (!config || (provider !== 'codex' && !config.apiKey)) {
|
||
return {
|
||
ok: false,
|
||
error: provider === 'genspark' ? tm('errGskNotLoggedIn') : tm('errNoApiKey', { provider }),
|
||
}
|
||
}
|
||
if (provider !== 'codex' && !config.model) return { ok: false, error: tm('errNoModel') }
|
||
try {
|
||
const result = await chatForProvider(provider, config, system, user)
|
||
// the one-shot path reports HTTP failures as ok:false with the raw body —
|
||
// replace capacity/rate-limit dumps with the localized "busy" message
|
||
if (!result.ok && isAiOverloadedError(result.error)) {
|
||
return { ok: false, error: tm('errAiBusy') }
|
||
}
|
||
return result
|
||
} catch (err) {
|
||
return { ok: false, error: isAiOverloadedError(err) ? tm('errAiBusy') : String(err) }
|
||
}
|
||
})
|
||
}
|
||
|
||
// ── project-store IPC (shared across docs / slides / sheets) ──────────────
|
||
|
||
let projectStore: ProjectStore | null = null
|
||
let projectIpcRegistered = false
|
||
|
||
function getProjectStore(): ProjectStore {
|
||
if (!projectStore) projectStore = new ProjectStore(app.getPath('userData'))
|
||
return projectStore
|
||
}
|
||
|
||
/**
|
||
* Fired when a save lands on a new path (save-as / first silent save). The shell
|
||
* uses it to sync the tab title/path, record recents and apply a pending project —
|
||
* same contract as the sheets/slides opened hooks. Never called standalone.
|
||
*/
|
||
let fileSavedHook: ((wc: WebContents, filePath: string) => void) | null = null
|
||
|
||
export function setDocsFileSavedHook(hook: (wc: WebContents, filePath: string) => void): void {
|
||
fileSavedHook = hook
|
||
}
|
||
|
||
function notifyFileSaved(wc: WebContents, filePath: string): void {
|
||
if (fileSavedHook) fileSavedHook(wc, filePath)
|
||
}
|
||
|
||
/**
|
||
* Fired when a docx is opened INSIDE an existing tab (File > Open dialog or an
|
||
* explicit path open). Sheets and slides have had this hook from the start;
|
||
* docs only synced the tab on save-as/first-save, so a file opened into an
|
||
* untitled tab kept the "Untitled Document" tab title until a save landed on a
|
||
* NEW path — which a plain Ctrl+S to the original file never does (r115).
|
||
*/
|
||
let fileOpenedHook: ((wcId: number, filePath: string) => void) | null = null
|
||
|
||
export function setDocsFileOpenedHook(hook: (wcId: number, filePath: string) => void): void {
|
||
fileOpenedHook = hook
|
||
}
|
||
|
||
/**
|
||
* Reverse lookup from a sheets sessionId to its file path. In shell mode the
|
||
* project:* handlers are registered by this file, but only sheets-main knows the
|
||
* sessionId mapping; the shell injects it at startup (standalone docs doesn't need it).
|
||
*/
|
||
let sessionPathResolver: ((senderId: number, sessionId: string) => string | null) | null = null
|
||
|
||
export function setSessionPathResolver(
|
||
fn: (senderId: number, sessionId: string) => string | null,
|
||
): void {
|
||
sessionPathResolver = fn
|
||
}
|
||
|
||
/** After a file is renamed/moved on disk, sync project-store (fileMap/chatIdByPath re-key accordingly; history follows the file). */
|
||
export function projectFileRenamed(oldPath: string, newPath: string): void {
|
||
try {
|
||
getProjectStore().fileRenamed(oldPath, newPath)
|
||
} catch (err) {
|
||
console.warn('[project-store] fileRenamed failed:', err)
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Register the project:* IPC handlers (all three apps share the same channel names).
|
||
* Idempotency guard: registered only once in shell mode.
|
||
*/
|
||
export function registerProjectIpc(): void {
|
||
if (projectIpcRegistered) return
|
||
projectIpcRegistered = true
|
||
|
||
/** Resolve projectId + chatId from a file path (sheets without a path resolves via sessionId) */
|
||
ipcMain.handle(
|
||
'project:resolveChat',
|
||
(event, args: { filePath: string | null; tempChatId?: string; sessionId?: string }) => {
|
||
const store = getProjectStore()
|
||
store.ensureDefaultProject()
|
||
let resolvedPath = args.filePath
|
||
if (!resolvedPath && args.sessionId && sessionPathResolver) {
|
||
resolvedPath = sessionPathResolver(event.sender.id, args.sessionId)
|
||
}
|
||
if (!resolvedPath) {
|
||
return {
|
||
projectId: 'default',
|
||
chatId: args.tempChatId ?? `unsaved-${Date.now()}`,
|
||
}
|
||
}
|
||
return store.resolveChatForFile(resolvedPath)
|
||
},
|
||
)
|
||
|
||
/** Append a message */
|
||
ipcMain.handle(
|
||
'project:appendChat',
|
||
(
|
||
_event,
|
||
args: {
|
||
projectId: string
|
||
chatId: string
|
||
role: 'user' | 'assistant'
|
||
text: string
|
||
tools?: Array<{
|
||
name: string
|
||
summary: string
|
||
isError?: boolean
|
||
input?: string
|
||
output?: string
|
||
}>
|
||
attachments?: Array<{ name: string; path?: string; ext?: string; sizeBytes?: number }>
|
||
scope?: { label: string; text?: string }
|
||
},
|
||
) => {
|
||
const store = getProjectStore()
|
||
const msg: Parameters<ProjectStore['appendChatMessage']>[2] = {
|
||
role: args.role,
|
||
text: args.text,
|
||
}
|
||
if (args.tools) msg.tools = args.tools
|
||
if (args.attachments) msg.attachments = args.attachments
|
||
if (args.scope) msg.scope = args.scope
|
||
|
||
store.appendChatMessage(args.projectId, args.chatId, msg)
|
||
},
|
||
)
|
||
|
||
/** Read history */
|
||
ipcMain.handle(
|
||
'project:loadChat',
|
||
(
|
||
_event,
|
||
args: {
|
||
projectId: string
|
||
chatId: string
|
||
limit?: number
|
||
},
|
||
) => {
|
||
const store = getProjectStore()
|
||
return store.loadChat(args.projectId, args.chatId, args.limit ?? 200)
|
||
},
|
||
)
|
||
|
||
/** rebind chat (called after a file first hits disk): newFilePath/sessionId take priority; the main process computes chatId and records fileMap */
|
||
ipcMain.handle(
|
||
'project:rebindChat',
|
||
(
|
||
event,
|
||
args: {
|
||
projectId: string
|
||
tempChatId: string
|
||
newChatId?: string
|
||
newFilePath?: string
|
||
sessionId?: string
|
||
},
|
||
) => {
|
||
const store = getProjectStore()
|
||
let path = args.newFilePath ?? null
|
||
if (!path && args.sessionId && sessionPathResolver) {
|
||
path = sessionPathResolver(event.sender.id, args.sessionId)
|
||
}
|
||
if (path) {
|
||
return store.rebindChatToFile(args.projectId, args.tempChatId, path)
|
||
}
|
||
if (args.newChatId) store.rebindChat(args.projectId, args.tempChatId, args.newChatId)
|
||
return { projectId: args.projectId, chatId: args.newChatId ?? args.tempChatId }
|
||
},
|
||
)
|
||
|
||
// ── P1 extension IPC ─────────────────────────────────────
|
||
|
||
/** List all projects (with file count + last-active time) */
|
||
ipcMain.handle('project:list', () => {
|
||
return getProjectStore().listProjectsSummary()
|
||
})
|
||
|
||
/** List existing files belonging to one project */
|
||
ipcMain.handle('project:files', (_event, args: { projectId: string }) => {
|
||
return getProjectStore().listProjectFiles(args.projectId)
|
||
})
|
||
|
||
/** Create a project */
|
||
ipcMain.handle('project:create', (_event, args: { name: string }) => {
|
||
const store = getProjectStore()
|
||
const data = store.createProject(args.name)
|
||
// returns ProjectSummary shape
|
||
return store.listProjectsSummary().find((s) => s.id === data.id) ?? data
|
||
})
|
||
|
||
/** Rename a project */
|
||
ipcMain.handle('project:rename', (_event, args: { id: string; name: string }) => {
|
||
getProjectStore().renameProject(args.id, args.name)
|
||
})
|
||
|
||
/** Soft-delete a project */
|
||
ipcMain.handle('project:delete', (_event, args: { id: string }) => {
|
||
getProjectStore().deleteProject(args.id)
|
||
})
|
||
|
||
/** Move a file into the given project */
|
||
ipcMain.handle('project:moveFile', (_event, args: { filePath: string; projectId: string }) => {
|
||
getProjectStore().moveFileToProject(args.filePath, args.projectId)
|
||
})
|
||
|
||
/** Get the project timeline */
|
||
ipcMain.handle('project:timeline', (_event, args: { projectId: string; limit?: number }) => {
|
||
return getProjectStore().getProjectTimeline(args.projectId, args.limit ?? 20)
|
||
})
|
||
}
|
||
|
||
/** document/attachment/window IPC (everything except the AI proxy above) */
|
||
export function registerDocsIpc(): void {
|
||
// Node fetch (undici) direct connections get reset under VPN/tun setups; retry over Chromium's stack
|
||
setRescueFetch((url, init) => net.fetch(url, init))
|
||
setAiUserAgent(`GenOffice/${app.getVersion()}`)
|
||
|
||
// shared with the other editor modules — last (identical) registration wins
|
||
ipcMain.removeHandler('app:get-language')
|
||
ipcMain.handle('app:get-language', () => getUiLang())
|
||
|
||
configureMetricsCache(userDataPath('font-metrics'))
|
||
ipcMain.handle('docs:font-metrics', (_event, family: string) =>
|
||
typeof family === 'string' ? familyVerticalMetrics(family) : null,
|
||
)
|
||
|
||
ipcMain.handle('docs:open', async (event) => {
|
||
const result = await openDialog(event, {
|
||
title: tm('dlgOpenDoc'),
|
||
filters: [{ name: tm('filterWord'), extensions: ['docx'] }],
|
||
properties: ['openFile'],
|
||
})
|
||
if (result.canceled || result.filePaths.length === 0) return null
|
||
return loadDocx(result.filePaths[0], event.sender.id)
|
||
})
|
||
|
||
ipcMain.handle('docs:open-path', (event, filePath: string) => loadDocx(filePath, event.sender.id))
|
||
|
||
// Review > Protect > Encrypt with Password: set/clear the open password.
|
||
// Takes effect on the next save (docs:save / save-as / save-new all consult the store).
|
||
ipcMain.handle(
|
||
'docs:set-password',
|
||
(event, filePath: string | null, password: string | null): { ok: boolean } => {
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
if (filePath !== null && typeof filePath !== 'string') return { ok: false }
|
||
if (password !== null && (typeof password !== 'string' || password.length === 0)) {
|
||
return { ok: false }
|
||
}
|
||
// only the document this renderer legitimately has open (same grant as saving)
|
||
if (filePath && !canDocWrite(event.sender.id, filePath)) return { ok: false }
|
||
setDocPassword(event.sender.id, filePath, password)
|
||
return { ok: true }
|
||
},
|
||
)
|
||
|
||
ipcMain.handle('docs:password-intent-revision', (event): number => {
|
||
if (tornDownWcIds.has(event.sender.id)) return -1
|
||
return currentDocPasswordIntentRevision()
|
||
})
|
||
|
||
ipcMain.handle(
|
||
'docs:discard-password-intents',
|
||
(event, throughRevision: unknown): { ok: boolean } => {
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
if (
|
||
typeof throughRevision !== 'number' ||
|
||
!Number.isSafeInteger(throughRevision) ||
|
||
throughRevision < 0
|
||
) {
|
||
return { ok: false }
|
||
}
|
||
discardDocPasswordIntents(event.sender.id, throughRevision)
|
||
return { ok: true }
|
||
},
|
||
)
|
||
|
||
// decrypt-and-open a password-protected docx; wrong-password keeps the renderer's prompt open
|
||
ipcMain.handle(
|
||
'docs:open-decrypt',
|
||
async (event, filePath: string, password: string): Promise<DecryptOpenResult> => {
|
||
if (typeof filePath !== 'string' || typeof password !== 'string' || password.length === 0) {
|
||
return { ok: false, reason: 'error', error: 'invalid arguments' }
|
||
}
|
||
try {
|
||
const result = await loadDocx(filePath, event.sender.id, password)
|
||
if (!result) return { ok: false, reason: 'error', error: 'file not found' }
|
||
// the file was swapped for a plain docx between prompt and submit — still an open
|
||
if ('needsPassword' in result) return { ok: false, reason: 'error', error: 'not encrypted' }
|
||
return { ok: true, result }
|
||
} catch (err) {
|
||
if (err instanceof DocxDecryptError) {
|
||
return { ok: false, reason: err.reason, error: err.message }
|
||
}
|
||
return { ok: false, reason: 'error', error: String(err) }
|
||
}
|
||
},
|
||
)
|
||
|
||
ipcMain.handle('docs:consume-pending-open', (event) => {
|
||
rendererReady = true
|
||
// a tab spawned via New Tab loads the document queued for it specifically
|
||
const queued = pendingWindowOpens.get(event.sender.id)
|
||
if (queued) {
|
||
pendingWindowOpens.delete(event.sender.id)
|
||
return loadDocx(queued, event.sender.id)
|
||
}
|
||
const filePath = pendingOpenPath
|
||
pendingOpenPath = null
|
||
return filePath ? loadDocx(filePath, event.sender.id) : null
|
||
})
|
||
|
||
/** returns true when this tab was opened via "New Document" and should start blank */
|
||
ipcMain.handle('docs:consume-new-blank', (event) => {
|
||
rendererReady = true
|
||
if (pendingNewBlankIds.has(event.sender.id)) {
|
||
pendingNewBlankIds.delete(event.sender.id)
|
||
return true
|
||
}
|
||
return false
|
||
})
|
||
|
||
/** one-shot AI content queued by create_document for this tab; null when none */
|
||
ipcMain.handle('docs:consume-ai-doc-content', (event): AiDocContent | null => {
|
||
const content = pendingAiDocContents.get(event.sender.id) ?? null
|
||
pendingAiDocContents.delete(event.sender.id)
|
||
return content
|
||
})
|
||
|
||
ipcMain.handle(
|
||
'docs:save',
|
||
async (event, filePath: string, data: ArrayBuffer, auto?: boolean) => {
|
||
try {
|
||
// only paths this renderer opened or chose via save-as may be overwritten
|
||
if (typeof filePath !== 'string' || !canDocWrite(event.sender.id, filePath)) {
|
||
return { ok: false, error: 'save target is not an opened document' }
|
||
}
|
||
if (await diskChangedExternally(event.sender.id, filePath)) {
|
||
// autosave must never clobber another program's edits silently; the
|
||
// renderer stays dirty and the next manual save raises the dialog
|
||
if (auto === true) return { ok: false, reason: 'external-modified' }
|
||
const options = {
|
||
type: 'warning' as const,
|
||
message: tm('extModifiedMsg'),
|
||
detail: tm('extModifiedDetail'),
|
||
buttons: [tm('btnOverwrite'), tm('btnCancel')],
|
||
defaultId: 0,
|
||
cancelId: 1,
|
||
noLink: true,
|
||
}
|
||
const parent = dialogParent(event)
|
||
const { response } =
|
||
parent && !parent.isDestroyed()
|
||
? await dialog.showMessageBox(parent, options)
|
||
: await dialog.showMessageBox(options)
|
||
if (response !== 0) return { ok: false, reason: 'external-modified' }
|
||
}
|
||
// The tab may have been closed while the external-change check or the
|
||
// overwrite prompt was pending: a Don't Save close revoked this tab's
|
||
// grants, and landing the write now would persist discarded edits.
|
||
if (tornDownWcIds.has(event.sender.id) || !canDocWrite(event.sender.id, filePath)) {
|
||
return { ok: false, error: 'save target is not an opened document' }
|
||
}
|
||
// Snapshot desired state: the disk password remains unchanged until the
|
||
// atomic write succeeds, and a newer ribbon intent survives this save.
|
||
const passwordState = snapshotDocPassword(event.sender.id, filePath)
|
||
const bytes = passwordState.password
|
||
? encryptDocx(Buffer.from(data), passwordState.password)
|
||
: Buffer.from(data)
|
||
await atomicWriteFile(filePath, bytes)
|
||
// Teardown may have cleared all in-memory secrets while the atomic
|
||
// write was pending. Never resurrect state for an orphaned renderer.
|
||
if (tornDownWcIds.has(event.sender.id)) {
|
||
return { ok: false, error: 'save target is not an opened document' }
|
||
}
|
||
await rememberDiskState(event.sender.id, filePath, bytes)
|
||
if (tornDownWcIds.has(event.sender.id)) {
|
||
return { ok: false, error: 'save target is not an opened document' }
|
||
}
|
||
// Commit immediately after the final await: intents received during
|
||
// post-write bookkeeping are included, with no later async race.
|
||
const passwordIntentPending = commitDocPasswordSave(
|
||
event.sender.id,
|
||
passwordState,
|
||
filePath,
|
||
)
|
||
clearRecoveryCopy(filePath)
|
||
pushRecent(filePath)
|
||
return { ok: true, passwordIntentPending }
|
||
} catch (err) {
|
||
return { ok: false, error: String(err) }
|
||
}
|
||
},
|
||
)
|
||
|
||
// crash-recovery copy from a dirty renderer; best-effort, never surfaces
|
||
ipcMain.handle('docs:write-recovery', async (event, filePath: string, data: ArrayBuffer) => {
|
||
try {
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
if (typeof filePath !== 'string' || !canDocWrite(event.sender.id, filePath))
|
||
return { ok: false }
|
||
// snapshot before any await: a save or discard that clears the recovery
|
||
// copy while this write is in flight bumps the epoch and invalidates it
|
||
const epoch = recoveryClearEpochs.get(filePath) ?? 0
|
||
await mkdir(recoveryDir(), { recursive: true })
|
||
// Recovery follows the current disk state, never the desired next-save
|
||
// password. Missing state for an encrypted disk file skips the tick so
|
||
// plaintext can never be written as its recovery copy.
|
||
const bytes = prepareRecoveryDocx(event.sender.id, filePath, Buffer.from(data))
|
||
if (!bytes) return { ok: false }
|
||
await atomicWriteFile(recoveryPathFor(filePath), bytes)
|
||
// The tab may have been closed ("Don't Save" clears the copy, teardown
|
||
// revokes access) or the document saved (docs:save clears the copy) while
|
||
// the write was in flight. A write that lost either race would offer
|
||
// discarded or already-saved content as recovery on the next open — undo it.
|
||
if (
|
||
tornDownWcIds.has(event.sender.id) ||
|
||
!canDocWrite(event.sender.id, filePath) ||
|
||
(recoveryClearEpochs.get(filePath) ?? 0) !== epoch
|
||
) {
|
||
clearRecoveryCopy(filePath)
|
||
return { ok: false }
|
||
}
|
||
return { ok: true }
|
||
} catch {
|
||
return { ok: false }
|
||
}
|
||
})
|
||
|
||
// Blink only respells an editable as a consequence of real (trusted) typing
|
||
// of a word-committing character inside it: attribute flips, focus cycles,
|
||
// script selection moves, execCommand edits, fresh DOM nodes, synthetic
|
||
// clicks/arrow keys — and even a typed zero-width space — all leave existing
|
||
// typos unmarked (each verified pixel-by-pixel).
|
||
// Type one trusted space; the RENDERER removes it again by script (a
|
||
// trusted Backspace would work too, but its deletion re-suppresses the
|
||
// caret paragraph and that line stays unmarked) with ProseMirror's DOM
|
||
// observer paused, so the round trip never becomes a transaction.
|
||
ipcMain.handle('docs:respell-kick', async (event) => {
|
||
const wc = event.sender
|
||
if (tornDownWcIds.has(wc.id) || wc.isDestroyed()) return
|
||
wc.focus()
|
||
wc.sendInputEvent({ type: 'char', keyCode: ' ' })
|
||
// resolve only after the input pipeline has delivered the keystroke, so
|
||
// the caller can scrub the space it produced
|
||
await new Promise((r) => setTimeout(r, 120))
|
||
})
|
||
|
||
ipcMain.handle(
|
||
'docs:save-as',
|
||
async (event, defaultName: string, data: ArrayBuffer, sourcePath?: string | null) => {
|
||
// an orphaned (closed-tab) renderer must not open dialogs or land new files
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
const result = await saveDialog(event, {
|
||
title: tm('dlgSaveAs'),
|
||
defaultPath: saveAsSuggestion(
|
||
typeof sourcePath === 'string' ? sourcePath : null,
|
||
defaultName,
|
||
),
|
||
filters: [{ name: tm('filterWord'), extensions: ['docx'] }],
|
||
})
|
||
if (result.canceled || !result.filePath) return { ok: false }
|
||
// the tab may have been closed while the dialog was open; checked before the
|
||
// write because Save As may overwrite an existing file (no safe rollback)
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
try {
|
||
const passwordState = snapshotDocPassword(
|
||
event.sender.id,
|
||
typeof sourcePath === 'string' && sourcePath ? sourcePath : null,
|
||
)
|
||
const bytes = passwordState.password
|
||
? encryptDocx(Buffer.from(data), passwordState.password)
|
||
: Buffer.from(data)
|
||
await atomicWriteFile(result.filePath, bytes)
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
allowDocWrite(event.sender.id, result.filePath)
|
||
await rememberDiskState(event.sender.id, result.filePath, bytes)
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
const passwordIntentPending = commitDocPasswordSave(
|
||
event.sender.id,
|
||
passwordState,
|
||
result.filePath,
|
||
)
|
||
pushRecent(result.filePath)
|
||
notifyFileSaved(event.sender, result.filePath)
|
||
return { ok: true, path: result.filePath, passwordIntentPending }
|
||
} catch (err) {
|
||
return { ok: false, error: String(err) }
|
||
}
|
||
},
|
||
)
|
||
|
||
ipcMain.handle('docs:save-new', async (event, defaultName: string, data: ArrayBuffer) => {
|
||
try {
|
||
// a discarded draft in an orphaned renderer must not silently persist
|
||
// itself to the default folder after the user chose Don't Save
|
||
if (tornDownWcIds.has(event.sender.id)) return { ok: false }
|
||
const filePath = uniquePathIn(defaultSaveDir(), defaultName)
|
||
const passwordState = snapshotDocPassword(event.sender.id, null)
|
||
const bytes = passwordState.password
|
||
? encryptDocx(Buffer.from(data), passwordState.password)
|
||
: Buffer.from(data)
|
||
await atomicWriteFile(filePath, bytes)
|
||
// teardown may have happened while the write was in flight — the path is
|
||
// freshly created, so rolling it back is safe (mirrors docs:write-recovery)
|
||
if (tornDownWcIds.has(event.sender.id)) {
|
||
await unlink(filePath).catch(() => {})
|
||
return { ok: false }
|
||
}
|
||
allowDocWrite(event.sender.id, filePath)
|
||
await rememberDiskState(event.sender.id, filePath, bytes)
|
||
if (tornDownWcIds.has(event.sender.id)) {
|
||
await unlink(filePath).catch(() => {})
|
||
return { ok: false }
|
||
}
|
||
const passwordIntentPending = commitDocPasswordSave(event.sender.id, passwordState, filePath)
|
||
pushRecent(filePath)
|
||
notifyFileSaved(event.sender, filePath)
|
||
return { ok: true, path: filePath, passwordIntentPending }
|
||
} catch (err) {
|
||
return { ok: false, error: String(err) }
|
||
}
|
||
})
|
||
|
||
ipcMain.handle(
|
||
'docs:create-document',
|
||
(_event, request: CreateDocumentRequest): Promise<CreateDocumentResult> =>
|
||
createAiDocument(request),
|
||
)
|
||
|
||
ipcMain.handle('docs:recent', () =>
|
||
readJson<string[]>(RECENT_PATH(), []).filter((p) => existsSync(p)),
|
||
)
|
||
|
||
ipcMain.handle('docs:pick-image', async (event) => {
|
||
const result = await openDialog(event, {
|
||
title: tm('dlgInsertImage'),
|
||
filters: [{ name: tm('filterImages'), extensions: ['png', 'jpg', 'jpeg', 'gif'] }],
|
||
properties: ['openFile'],
|
||
})
|
||
if (result.canceled || result.filePaths.length === 0) return null
|
||
const filePath = result.filePaths[0]
|
||
const ext = filePath.split('.').pop()?.toLowerCase() ?? ''
|
||
const mime = IMAGE_MIME[ext]
|
||
if (!mime) return null
|
||
return {
|
||
base64: readFileSync(filePath).toString('base64'),
|
||
mime,
|
||
name: basename(filePath),
|
||
}
|
||
})
|
||
|
||
ipcMain.handle('files:pick', async (event): Promise<AttachmentAddResult | null> => {
|
||
const result = await openDialog(event, {
|
||
title: tm('dlgAddAttachment'),
|
||
filters: [
|
||
{ name: tm('filterSupported'), extensions: [...ATTACHMENT_EXTS] },
|
||
{ name: tm('filterAll'), extensions: ['*'] },
|
||
],
|
||
properties: ['openFile', 'multiSelections'],
|
||
})
|
||
if (result.canceled || result.filePaths.length === 0) return null
|
||
return collectAttachments(result.filePaths)
|
||
})
|
||
|
||
ipcMain.handle('files:add', (_event, paths: string[]) => collectAttachments(paths))
|
||
|
||
ipcMain.handle(
|
||
'files:read',
|
||
async (
|
||
_event,
|
||
filePath: string,
|
||
offset: number,
|
||
maxChars: number,
|
||
): Promise<AttachmentReadResult> => {
|
||
const name = basename(filePath)
|
||
const ext = name.split('.').pop()?.toLowerCase() ?? ''
|
||
if (!ATTACHMENT_EXTS.has(ext)) return { ok: false, error: tm('errUnsupportedExt', { ext }) }
|
||
if (ATTACHMENT_IMAGE_EXTS.has(ext)) {
|
||
return { ok: false, error: tm('errImageNoText') }
|
||
}
|
||
try {
|
||
const text = await extractAttachmentText(filePath)
|
||
const start = Math.max(0, Math.floor(offset) || 0)
|
||
const size = Math.min(Math.max(1, Math.floor(maxChars) || 1), 48_000)
|
||
return {
|
||
ok: true,
|
||
name,
|
||
totalChars: text.length,
|
||
offset: start,
|
||
text: text.slice(start, start + size),
|
||
}
|
||
} catch (e) {
|
||
return { ok: false, error: e instanceof Error ? e.message : String(e) }
|
||
}
|
||
},
|
||
)
|
||
|
||
// image attachments read raw bytes → base64; AiPanel puts them into the user message's images for multimodal
|
||
ipcMain.handle('files:read-image', (_event, filePath: string): AttachmentImageResult => {
|
||
const name = basename(filePath)
|
||
const ext = name.split('.').pop()?.toLowerCase() ?? ''
|
||
const mime = ATTACHMENT_IMAGE_MIME[ext]
|
||
if (!mime) return { ok: false, error: `${name}: ${tm('errNotImage')}` }
|
||
try {
|
||
const stat = statSync(filePath)
|
||
if (stat.size > ATTACHMENT_IMAGE_MAX_BYTES) {
|
||
return { ok: false, error: `${name}: ${tm('errImageTooLarge')}` }
|
||
}
|
||
return { ok: true, base64: readFileSync(filePath).toString('base64'), mime }
|
||
} catch {
|
||
return { ok: false, error: `${name}: ${tm('errUnreadable')}` }
|
||
}
|
||
})
|
||
|
||
// clipboard-pasted images (screenshots and other bitmaps with no local path): saved to a temp file then use the regular attachment path
|
||
ipcMain.handle(
|
||
'files:add-pasted-image',
|
||
(_event, data: unknown, ext: unknown): AttachmentAddResult => {
|
||
const filePath = savePastedImage(data, ext)
|
||
return filePath
|
||
? collectAttachments([filePath])
|
||
: { accepted: [], rejected: [tm('errNotImage')] }
|
||
},
|
||
)
|
||
|
||
// r136: copying an embedded picture must yield a real bitmap for external
|
||
// apps (Gmail pasted blank) plus plain <img> html for cross-document paste
|
||
// (the protected wrapper round-tripped as a "protected content" shell).
|
||
ipcMain.handle(
|
||
'docs:copy-image-to-clipboard',
|
||
(_event, dataUrl: unknown, meta: unknown): boolean => {
|
||
if (typeof dataUrl !== 'string' || !dataUrl.startsWith('data:image/')) return false
|
||
const base64 = dataUrl.slice(dataUrl.indexOf(',') + 1)
|
||
// createFromBuffer, not createFromDataURL — the latter returns an empty
|
||
// image for valid PNGs in this Electron
|
||
const image = nativeImage.createFromBuffer(Buffer.from(base64, 'base64'))
|
||
if (image.isEmpty()) return false
|
||
// the html flavor carries the DISPLAY size + layout meta so an in-app
|
||
// paste keeps size/align/wrap instead of falling back to bitmap pixels
|
||
let width = image.getSize().width
|
||
let height = image.getSize().height
|
||
let metaAttr = ''
|
||
if (typeof meta === 'string' && meta.length <= 2048) {
|
||
try {
|
||
const parsed = JSON.parse(meta) as Record<string, unknown>
|
||
if (typeof parsed.imageWidthPx === 'number' && parsed.imageWidthPx > 0)
|
||
width = Math.round(parsed.imageWidthPx)
|
||
if (typeof parsed.imageHeightPx === 'number' && parsed.imageHeightPx > 0)
|
||
height = Math.round(parsed.imageHeightPx)
|
||
const escaped = meta.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<')
|
||
metaAttr = ` data-image-meta="${escaped}"`
|
||
} catch {
|
||
/* malformed payload: plain img */
|
||
}
|
||
}
|
||
clipboard.write({
|
||
image,
|
||
html: `<img src="${dataUrl}" width="${width}" height="${height}"${metaAttr}>`,
|
||
})
|
||
return true
|
||
},
|
||
)
|
||
|
||
// renderer print scale (inverse of the preview's print zoom, see print-zoom.ts)
|
||
const pdfScale = (scale?: number) => (scale && scale > 0 && scale !== 1 ? { scale } : {})
|
||
const printScale = (scale?: number) =>
|
||
scale && scale > 0 && scale !== 1 ? { scaleFactor: Math.round(scale * 100) } : {}
|
||
|
||
ipcMain.handle('docs:print', async (event, scale?: number) => {
|
||
// print the calling tab's own content; zero margins — the docx page padding provides them.
|
||
// Resolves when the system dialog is dismissed; the print dialog stays open on cancel
|
||
// (ok=false without error) and surfaces real failures.
|
||
return new Promise<{ ok: boolean; error?: string }>((resolve) => {
|
||
event.sender.print(
|
||
{ margins: { marginType: 'none' }, ...printScale(scale) },
|
||
(success, failureReason) => {
|
||
resolve({
|
||
ok: success,
|
||
...(failureReason && !/cancel/i.test(failureReason) ? { error: failureReason } : {}),
|
||
})
|
||
},
|
||
)
|
||
})
|
||
})
|
||
|
||
ipcMain.handle(
|
||
'docs:export-pdf',
|
||
async (
|
||
event,
|
||
defaultName: string,
|
||
pageWidthTwips: number,
|
||
pageHeightTwips: number,
|
||
outPath?: string,
|
||
scale?: number,
|
||
) => {
|
||
// renderer-supplied outPath is only honored when a save dialog authorized it before
|
||
let filePath = outPath ?? null
|
||
if (filePath && !canPdfWrite(event.sender.id, filePath)) {
|
||
return { ok: false, error: 'export target is not an authorized path' }
|
||
}
|
||
if (!filePath) {
|
||
const result = await saveDialog(event, {
|
||
title: tm('dlgExportPdf'),
|
||
defaultPath: defaultName.replace(/\.docx$/i, '') + '.pdf',
|
||
filters: [{ name: 'PDF', extensions: ['pdf'] }],
|
||
})
|
||
if (result.canceled || !result.filePath) return { ok: false }
|
||
filePath = result.filePath
|
||
allowPdfWrite(event.sender.id, filePath)
|
||
}
|
||
try {
|
||
const data = await event.sender.printToPDF({
|
||
printBackground: true,
|
||
// custom pageSize is in inches; the docx page padding provides the margins
|
||
pageSize: {
|
||
width: pageWidthTwips / TWIPS_PER_INCH,
|
||
height: pageHeightTwips / TWIPS_PER_INCH,
|
||
},
|
||
margins: { top: 0, bottom: 0, left: 0, right: 0 },
|
||
...pdfScale(scale),
|
||
})
|
||
writeFileSync(filePath, data)
|
||
openGeneratedFile(filePath)
|
||
return { ok: true, path: filePath }
|
||
} catch (err) {
|
||
// path is already authorized, so the renderer can retry chunked to the same target
|
||
return { ok: false, error: String(err), path: filePath }
|
||
}
|
||
},
|
||
)
|
||
|
||
ipcMain.handle(
|
||
'docs:export-html',
|
||
async (event, defaultName: string, html: string, outPath?: string) => {
|
||
if (typeof html !== 'string' || !html) return { ok: false, error: 'empty document' }
|
||
let filePath = outPath ?? null
|
||
if (filePath && !canPdfWrite(event.sender.id, filePath)) {
|
||
return { ok: false, error: 'export target is not an authorized path' }
|
||
}
|
||
if (!filePath) {
|
||
const result = await saveDialog(event, {
|
||
title: tm('dlgExportHtml'),
|
||
defaultPath: defaultName.replace(/\.docx$/i, '') + '.html',
|
||
filters: [{ name: 'HTML', extensions: ['html'] }],
|
||
})
|
||
if (result.canceled || !result.filePath) return { ok: false }
|
||
filePath = result.filePath
|
||
allowPdfWrite(event.sender.id, filePath)
|
||
}
|
||
try {
|
||
writeFileSync(filePath, html, 'utf8')
|
||
openGeneratedFile(filePath)
|
||
return { ok: true, path: filePath }
|
||
} catch (err) {
|
||
return { ok: false, error: String(err), path: filePath }
|
||
}
|
||
},
|
||
)
|
||
|
||
// mixed paper-size export: the renderer prints group by group per size (other pages hidden via CSS); this produces one group's bytes
|
||
ipcMain.handle(
|
||
'docs:print-pdf-buffer',
|
||
async (event, pageWidthTwips: number, pageHeightTwips: number, scale?: number) => {
|
||
try {
|
||
const data = await event.sender.printToPDF({
|
||
printBackground: true,
|
||
pageSize: {
|
||
width: pageWidthTwips / TWIPS_PER_INCH,
|
||
height: pageHeightTwips / TWIPS_PER_INCH,
|
||
},
|
||
margins: { top: 0, bottom: 0, left: 0, right: 0 },
|
||
...pdfScale(scale),
|
||
})
|
||
return { ok: true, base64: data.toString('base64') }
|
||
} catch (err) {
|
||
return { ok: false, error: String(err) }
|
||
}
|
||
},
|
||
)
|
||
|
||
// merge grouped PDF fragments into one file in page order (pdf-lib)
|
||
ipcMain.handle(
|
||
'docs:save-merged-pdf',
|
||
async (event, defaultName: string, base64Parts: string[], outPath?: string) => {
|
||
let filePath = outPath ?? null
|
||
if (filePath && !canPdfWrite(event.sender.id, filePath)) {
|
||
return { ok: false, error: 'export target is not an authorized path' }
|
||
}
|
||
if (!filePath) {
|
||
const result = await saveDialog(event, {
|
||
title: tm('dlgExportPdf'),
|
||
defaultPath: defaultName.replace(/\.docx$/i, '') + '.pdf',
|
||
filters: [{ name: 'PDF', extensions: ['pdf'] }],
|
||
})
|
||
if (result.canceled || !result.filePath) return { ok: false }
|
||
filePath = result.filePath
|
||
allowPdfWrite(event.sender.id, filePath)
|
||
}
|
||
try {
|
||
const { PDFDocument } = await import('pdf-lib')
|
||
const merged = await PDFDocument.create()
|
||
for (const b64 of base64Parts) {
|
||
const part = await PDFDocument.load(Buffer.from(b64, 'base64'))
|
||
const pages = await merged.copyPages(part, part.getPageIndices())
|
||
for (const page of pages) merged.addPage(page)
|
||
}
|
||
writeFileSync(filePath, Buffer.from(await merged.save()))
|
||
openGeneratedFile(filePath)
|
||
return { ok: true, path: filePath }
|
||
} catch (err) {
|
||
return { ok: false, error: String(err) }
|
||
}
|
||
},
|
||
)
|
||
|
||
ipcMain.handle('win:new', (_event, openPath: string | null) => {
|
||
// A pathless new tab/window starts as a blank document, not the start screen
|
||
const path = openPath ?? undefined
|
||
if (shellHooks) shellHooks.openTab(path, path ? undefined : { newBlank: true })
|
||
else {
|
||
const win = createDocsWindow(path)
|
||
if (!path) markDocsNewBlank(win.webContents.id)
|
||
}
|
||
})
|
||
|
||
ipcMain.handle('win:list', (): DocsTabInfo[] => {
|
||
if (shellHooks) return shellHooks.listTabs()
|
||
return BrowserWindow.getAllWindows().map((w) => ({
|
||
id: String(w.id),
|
||
title: w.getTitle(),
|
||
focused: w.isFocused(),
|
||
}))
|
||
})
|
||
|
||
ipcMain.handle('win:focus', (_event, id: string) => {
|
||
if (shellHooks) {
|
||
shellHooks.focusTab(id)
|
||
return
|
||
}
|
||
const win = BrowserWindow.fromId(Number(id))
|
||
if (!win) return
|
||
if (win.isMinimized()) win.restore()
|
||
win.show()
|
||
win.focus()
|
||
})
|
||
}
|
||
|
||
/** hooks injected by the shell in tab mode; standalone mode leaves these unset
|
||
* and falls back to real multi-BrowserWindow behavior. */
|
||
interface DocsShellHooks {
|
||
openTab(openPath?: string, options?: { newBlank?: boolean }): void
|
||
/** open a blank docs tab that consumes the queued AI content on boot (create_document) */
|
||
openAiDocTab?(content: AiDocContent): void
|
||
listTabs(): DocsTabInfo[]
|
||
focusTab(id: string): void
|
||
/** closes the calling tab instead of the whole shell window (Cmd+W / role:'close') */
|
||
closeActiveTab(): void
|
||
/** Shell router used to open exported PDFs in a new GenOffice tab. */
|
||
openGeneratedPath?(path: string): boolean
|
||
}
|
||
let shellHooks: DocsShellHooks | null = null
|
||
export function setDocsShellHooks(hooks: DocsShellHooks | null): void {
|
||
shellHooks = hooks
|
||
}
|
||
|
||
/** After writing an exported/AI-generated file: open it in the right tab
|
||
* (shell) or reveal it in the folder (standalone). Tab-opening failure must
|
||
* not report the write itself as failed — the file is already persisted. */
|
||
function openGeneratedFile(path: string): void {
|
||
try {
|
||
if (shellHooks?.openGeneratedPath?.(path)) return
|
||
} catch (err) {
|
||
console.warn('[docs] Failed to open generated file:', err)
|
||
}
|
||
shell.showItemInFolder(path)
|
||
}
|
||
|
||
/** Pick a safe file-name stem for an AI-created document. */
|
||
export function sanitizeAiDocFileBase(title: string): string {
|
||
// Control characters are intentionally rejected from generated file names.
|
||
const cleaned = String(title ?? '')
|
||
// eslint-disable-next-line no-control-regex
|
||
.replace(/[/\\:*?"<>|\u0000-\u001f]/g, '_')
|
||
.trim()
|
||
.slice(0, 80)
|
||
.trim()
|
||
return cleaned && cleaned !== '.' && cleaned !== '..' ? cleaned : 'Untitled'
|
||
}
|
||
|
||
/**
|
||
* AI create_document: build a new standalone file in the default folder and
|
||
* open it in a new tab. docx routes through a fresh blank docs tab that
|
||
* inserts the queued content on boot and saves itself (the full-fidelity
|
||
* HTML → docx conversion lives in the docs renderer); pdf and md are written
|
||
* directly here. Also called by other apps' mains via shell-wired hooks.
|
||
*/
|
||
export async function createAiDocument(
|
||
request: CreateDocumentRequest,
|
||
): Promise<CreateDocumentResult> {
|
||
const type = request?.type
|
||
const title = sanitizeAiDocFileBase(request?.title)
|
||
const content = String(request?.content ?? '')
|
||
if (!content.trim()) return { ok: false, error: 'content must not be empty' }
|
||
try {
|
||
if (type === 'docx') {
|
||
const payload: AiDocContent = { title, html: content }
|
||
if (shellHooks?.openAiDocTab) shellHooks.openAiDocTab(payload)
|
||
else {
|
||
const win = createDocsWindow(undefined)
|
||
markDocsNewBlank(win.webContents.id)
|
||
queueDocsAiContent(win.webContents.id, payload)
|
||
}
|
||
return { ok: true }
|
||
}
|
||
if (type === 'pdf') {
|
||
const bytes = await printHtmlToPdf(
|
||
buildPrintableHtml(title, content),
|
||
() =>
|
||
new BrowserWindow({ show: false, webPreferences: { sandbox: true, javascript: false } }),
|
||
)
|
||
const filePath = uniquePathIn(defaultSaveDir(), `${title}.pdf`)
|
||
await writeFile(filePath, bytes)
|
||
openGeneratedFile(filePath)
|
||
return { ok: true, path: filePath }
|
||
}
|
||
if (type === 'md' || type === 'html') {
|
||
const filePath = uniquePathIn(defaultSaveDir(), `${title}.${type}`)
|
||
await writeFile(filePath, content, 'utf8')
|
||
openGeneratedFile(filePath)
|
||
return { ok: true, path: filePath }
|
||
}
|
||
return { ok: false, error: `unsupported document type: ${String(type)}` }
|
||
} catch (err) {
|
||
return { ok: false, error: err instanceof Error ? err.message : String(err) }
|
||
}
|
||
}
|
||
|
||
// ---- application menu ----
|
||
|
||
function sendCommand(command: MenuCommand, payload?: string): void {
|
||
activeDocsWebContents()?.send('menu:command', command, payload)
|
||
}
|
||
|
||
/**
|
||
* Per-tab View-menu toggle state (AI Sidebar / Dark Mode), reported by each
|
||
* renderer whenever it changes. The template can't hardcode `checked` — the
|
||
* state lives in the renderer and differs per tab — so builds read the active
|
||
* tab's last report, and reports from the active tab patch the built menu in
|
||
* place (buildDocsMenu also re-runs on every tab focus switch).
|
||
* Defaults mirror the renderer's initial state: sidebar shown, light canvas.
|
||
*/
|
||
const viewMenuStateByWebContents = new Map<number, { aiSidebar: boolean; darkCanvas: boolean }>()
|
||
|
||
function activeViewMenuState(): { aiSidebar: boolean; darkCanvas: boolean } {
|
||
const id = activeDocsWebContents()?.id
|
||
return (
|
||
(id !== undefined ? viewMenuStateByWebContents.get(id) : undefined) ?? {
|
||
aiSidebar: true,
|
||
darkCanvas: false,
|
||
}
|
||
)
|
||
}
|
||
|
||
/** shell-injected items appended to the File menu (e.g. Back to Home); persists
|
||
* across the internal rebuilds pushRecent() triggers */
|
||
let extraFileMenuItems: MenuItemConstructorOptions[] = []
|
||
|
||
export function setDocsExtraFileMenuItems(items: MenuItemConstructorOptions[]): void {
|
||
extraFileMenuItems = items
|
||
}
|
||
|
||
/** Shell-installed gate: inside the shell the docs menu may only take over the
|
||
* application menu while a docs tab is active — internal rebuilds (pushRecent
|
||
* after opening/saving any file) must not clobber another tab's menu.
|
||
* The standalone docs app registers no gate and always installs. */
|
||
let docsMenuGate: (() => boolean) | null = null
|
||
|
||
export function setDocsMenuGate(gate: () => boolean): void {
|
||
docsMenuGate = gate
|
||
}
|
||
|
||
export function buildDocsMenu(): void {
|
||
if (docsMenuGate && !docsMenuGate()) return
|
||
const isMac = process.platform === 'darwin'
|
||
const recent = readJson<string[]>(RECENT_PATH(), [])
|
||
.filter((p) => existsSync(p))
|
||
.slice(0, 10)
|
||
|
||
const recentSubmenu: MenuItemConstructorOptions[] =
|
||
recent.length > 0
|
||
? recent.map((p) => ({
|
||
label: basename(p),
|
||
sublabel: isMac ? undefined : p,
|
||
toolTip: p,
|
||
click: () => sendCommand('open-path', p),
|
||
}))
|
||
: [{ label: tm('menuNoRecent'), enabled: false }]
|
||
|
||
const template: MenuItemConstructorOptions[] = [
|
||
...(isMac
|
||
? [
|
||
{
|
||
label: app.name,
|
||
submenu: [
|
||
{ role: 'about' as const },
|
||
{ type: 'separator' as const },
|
||
{ role: 'services' as const },
|
||
{ type: 'separator' as const },
|
||
{ role: 'hide' as const },
|
||
{ role: 'hideOthers' as const },
|
||
{ role: 'unhide' as const },
|
||
{ type: 'separator' as const },
|
||
{ role: 'quit' as const },
|
||
],
|
||
},
|
||
]
|
||
: []),
|
||
{
|
||
label: tm('menuFile'),
|
||
submenu: [
|
||
{ label: tm('menuNewDoc'), accelerator: 'CmdOrCtrl+N', click: () => sendCommand('new') },
|
||
{
|
||
label: tm('menuNewWindow'),
|
||
accelerator: 'Shift+CmdOrCtrl+N',
|
||
click: () => {
|
||
if (shellHooks) shellHooks.openTab(undefined, { newBlank: true })
|
||
else markDocsNewBlank(createDocsWindow().webContents.id)
|
||
},
|
||
},
|
||
{ label: tm('menuOpen'), accelerator: 'CmdOrCtrl+O', click: () => sendCommand('open') },
|
||
{ label: tm('menuOpenRecent'), submenu: recentSubmenu },
|
||
...(extraFileMenuItems.length > 0
|
||
? [{ type: 'separator' as const }, ...extraFileMenuItems]
|
||
: []),
|
||
{ type: 'separator' },
|
||
shellHooks
|
||
? {
|
||
label: tm('menuClose'),
|
||
accelerator: 'CmdOrCtrl+W',
|
||
click: () => shellHooks?.closeActiveTab(),
|
||
}
|
||
: { role: 'close' as const, label: tm('menuClose') },
|
||
{ label: tm('menuSave'), accelerator: 'CmdOrCtrl+S', click: () => sendCommand('save') },
|
||
{
|
||
label: tm('menuSaveAs'),
|
||
accelerator: 'Shift+CmdOrCtrl+S',
|
||
click: () => sendCommand('save-as'),
|
||
},
|
||
{ type: 'separator' },
|
||
{ label: tm('menuPageSetup'), click: () => sendCommand('page-setup') },
|
||
{ label: tm('menuExportPdf'), click: () => sendCommand('export-pdf') },
|
||
{ label: tm('menuExportHtml'), click: () => sendCommand('export-html') },
|
||
{
|
||
label: tm('menuPrint'),
|
||
accelerator: 'CmdOrCtrl+P',
|
||
// routed through the renderer: it opens the pagination preview first so each
|
||
// printed sheet is exactly one editor page (WYSIWYG), then invokes docs:print
|
||
click: () => sendCommand('print'),
|
||
},
|
||
],
|
||
},
|
||
{
|
||
label: tm('menuEdit'),
|
||
submenu: [
|
||
{ label: tm('menuUndo'), accelerator: 'CmdOrCtrl+Z', click: () => sendCommand('undo') },
|
||
{
|
||
label: tm('menuRedo'),
|
||
accelerator: 'Shift+CmdOrCtrl+Z',
|
||
click: () => sendCommand('redo'),
|
||
},
|
||
{ type: 'separator' },
|
||
{ role: 'cut', label: tm('menuCut') },
|
||
{ role: 'copy', label: tm('menuCopy') },
|
||
{ role: 'paste', label: tm('menuPaste') },
|
||
{ role: 'pasteAndMatchStyle', label: tm('menuPasteMatch') },
|
||
{ type: 'separator' },
|
||
{
|
||
label: tm('menuFindReplace'),
|
||
accelerator: 'CmdOrCtrl+F',
|
||
click: () => sendCommand('find'),
|
||
},
|
||
{ type: 'separator' },
|
||
{ role: 'selectAll', label: tm('menuSelectAll') },
|
||
],
|
||
},
|
||
{
|
||
label: tm('menuView'),
|
||
submenu: [
|
||
{
|
||
label: tm('menuZoomIn'),
|
||
accelerator: 'CmdOrCtrl+=',
|
||
click: () => sendCommand('zoom-in'),
|
||
},
|
||
{
|
||
label: tm('menuZoomOut'),
|
||
accelerator: 'CmdOrCtrl+-',
|
||
click: () => sendCommand('zoom-out'),
|
||
},
|
||
{
|
||
label: tm('menuZoom100'),
|
||
accelerator: 'CmdOrCtrl+0',
|
||
click: () => sendCommand('zoom-100'),
|
||
},
|
||
{ label: tm('menuPageWidth'), click: () => sendCommand('zoom-page-width') },
|
||
{ label: tm('menuWholePage'), click: () => sendCommand('zoom-whole-page') },
|
||
{ type: 'separator' },
|
||
{
|
||
id: 'docs-menu-ai-sidebar',
|
||
type: 'checkbox',
|
||
checked: activeViewMenuState().aiSidebar,
|
||
label: tm('menuAiSidebar'),
|
||
click: () => sendCommand('toggle-ai'),
|
||
},
|
||
{
|
||
id: 'docs-menu-dark-mode',
|
||
type: 'checkbox',
|
||
checked: activeViewMenuState().darkCanvas,
|
||
label: tm('menuDarkMode'),
|
||
click: () => sendCommand('toggle-dark'),
|
||
},
|
||
{ type: 'separator' },
|
||
{ role: 'togglefullscreen', label: tm('menuFullscreen') },
|
||
...(isDev ? [toggleDevToolsItem(appMenuLabels(getUiLang()))] : []),
|
||
],
|
||
},
|
||
{
|
||
label: tm('menuInsert'),
|
||
submenu: [
|
||
{ label: tm('menuInsertTable'), click: () => sendCommand('insert-table') },
|
||
{ label: tm('menuInsertImage'), click: () => sendCommand('insert-image') },
|
||
// no CmdOrCtrl+Enter accelerator: a menu accelerator would intercept
|
||
// the key before renderer inputs (comments panel / prompt modal use
|
||
// Cmd+Enter to submit); the editor keymap handles it instead
|
||
{ label: tm('menuInsertPageBreak'), click: () => sendCommand('insert-page-break') },
|
||
{
|
||
label: tm('menuInsertLink'),
|
||
accelerator: 'CmdOrCtrl+K',
|
||
click: () => sendCommand('insert-link'),
|
||
},
|
||
{ label: tm('menuInsertEquation'), click: () => sendCommand('insert-equation') },
|
||
{ type: 'separator' },
|
||
{ label: tm('menuComment'), click: () => sendCommand('insert-comment') },
|
||
],
|
||
},
|
||
{
|
||
label: tm('menuFormat'),
|
||
submenu: [
|
||
{ label: tm('menuBold'), accelerator: 'CmdOrCtrl+B', click: () => sendCommand('bold') },
|
||
{ label: tm('menuItalic'), accelerator: 'CmdOrCtrl+I', click: () => sendCommand('italic') },
|
||
{
|
||
label: tm('menuUnderline'),
|
||
accelerator: 'CmdOrCtrl+U',
|
||
click: () => sendCommand('underline'),
|
||
},
|
||
{ type: 'separator' },
|
||
{
|
||
label: tm('menuAlign'),
|
||
submenu: [
|
||
{ label: tm('menuAlignLeft'), click: () => sendCommand('align-left') },
|
||
{ label: tm('menuAlignCenter'), click: () => sendCommand('align-center') },
|
||
{ label: tm('menuAlignRight'), click: () => sendCommand('align-right') },
|
||
{ label: tm('menuAlignJustify'), click: () => sendCommand('align-justify') },
|
||
],
|
||
},
|
||
{ type: 'separator' },
|
||
{
|
||
label: tm('menuFont'),
|
||
accelerator: 'CmdOrCtrl+D',
|
||
click: () => sendCommand('font-dialog'),
|
||
},
|
||
{
|
||
label: tm('menuParagraph'),
|
||
accelerator: 'Alt+CmdOrCtrl+M',
|
||
click: () => sendCommand('paragraph-dialog'),
|
||
},
|
||
],
|
||
},
|
||
{
|
||
// Word for Mac keeps Word Count in the Tools menu, not on the ribbon
|
||
label: tm('menuTools'),
|
||
submenu: [
|
||
{ label: tm('menuWordCount'), click: () => sendCommand('word-count') },
|
||
{ type: 'separator' },
|
||
// Runs the same AI proofread as Review > Editor (renderer shows the one-time ack)
|
||
{ label: tm('menuAiProofread'), click: () => sendCommand('ai-proofread') },
|
||
],
|
||
},
|
||
windowMenuTemplate(process.platform, appMenuLabels(getUiLang())),
|
||
{
|
||
label: tm('menuHelp'),
|
||
role: 'help',
|
||
submenu: [
|
||
{
|
||
label: tm('menuShortcuts'),
|
||
accelerator: 'CmdOrCtrl+/',
|
||
click: () => sendCommand('shortcuts'),
|
||
},
|
||
{ type: 'separator' },
|
||
{ label: tm('menuDocsHelp'), enabled: false },
|
||
],
|
||
},
|
||
]
|
||
|
||
Menu.setApplicationMenu(Menu.buildFromTemplate(template))
|
||
}
|
||
|
||
// ---- window ----
|
||
|
||
export function createDocsWindow(openPath?: string): BrowserWindow {
|
||
const win = new BrowserWindow({
|
||
width: 1360,
|
||
height: 900,
|
||
minWidth: 720,
|
||
minHeight: 550,
|
||
title: 'GenOffice Docs',
|
||
// Word-like custom title bar (document name centered, quick-access buttons)
|
||
...(process.platform === 'darwin'
|
||
? { titleBarStyle: 'hiddenInset' as const }
|
||
: {
|
||
titleBarStyle: 'hidden' as const,
|
||
titleBarOverlay: { color: '#ffffff', symbolColor: '#444444', height: 40 },
|
||
}),
|
||
// packaged builds embed the icon (build/icon.icns|ico); dev needs the file path
|
||
...(isDev && process.platform !== 'darwin'
|
||
? { icon: join(app.getAppPath(), 'build/icon.png') }
|
||
: {}),
|
||
webPreferences: {
|
||
preload: runtime.preloadPath,
|
||
contextIsolation: true,
|
||
nodeIntegration: false,
|
||
sandbox: true,
|
||
backgroundThrottling: false,
|
||
},
|
||
})
|
||
|
||
if (!mainWindow) {
|
||
mainWindow = win
|
||
rendererReady = false
|
||
}
|
||
// captured up front: webContents is already destroyed inside the 'closed' handler
|
||
const webContentsId = win.webContents.id
|
||
if (openPath) pendingWindowOpens.set(webContentsId, openPath)
|
||
|
||
win.webContents.setWindowOpenHandler(({ url }) => {
|
||
const target = safeExternalUrl(url)
|
||
if (target) void shell.openExternal(target)
|
||
return { action: 'deny' }
|
||
})
|
||
|
||
if (runtime.rendererUrl) {
|
||
void win.loadURL(runtime.rendererUrl)
|
||
} else {
|
||
void win.loadFile(runtime.rendererFile)
|
||
}
|
||
// close guard for standalone-window mode (tab mode goes through the same flow via the shell's tab-manager/window-close path)
|
||
let closeConfirmed = false
|
||
win.on('close', (event) => {
|
||
if (closeConfirmed) return
|
||
event.preventDefault()
|
||
void requestDocsClose(win.webContents, win).then((proceed) => {
|
||
if (proceed && !win.isDestroyed()) {
|
||
closeConfirmed = true
|
||
win.close()
|
||
}
|
||
})
|
||
})
|
||
win.on('closed', () => {
|
||
pendingWindowOpens.delete(webContentsId)
|
||
dropDocWriter(webContentsId)
|
||
// release any close-guard waiter still keyed on the gone webContents
|
||
closeCheckWaiters.get(webContentsId)?.({ dirty: false, autoSave: false })
|
||
closeCheckWaiters.delete(webContentsId)
|
||
closeSaveWaiters.get(webContentsId)?.(false)
|
||
closeSaveWaiters.delete(webContentsId)
|
||
if (mainWindow === win) {
|
||
mainWindow = BrowserWindow.getAllWindows().find((w) => w !== win) ?? null
|
||
if (!mainWindow) rendererReady = false
|
||
}
|
||
})
|
||
return win
|
||
}
|
||
|
||
/** tab-mode equivalent of createDocsWindow: same runtime/IPC wiring, no BrowserWindow of its own. */
|
||
// ── Close guard (aligned with sheets/pdf/slides): dirty documents prompt Save/Don't Save/Cancel before closing a tab/window ──
|
||
// docs' dirty state is a composite flag in the renderer; the main process doesn't mirror it and queries once at close time.
|
||
interface DocsCloseState {
|
||
dirty: boolean
|
||
autoSave: boolean
|
||
/** Open file path (for recovery-copy cleanup on "Don't Save") */
|
||
filePath?: string | null
|
||
/** The renderer never replied to the close check (busy or wedged) */
|
||
unresponsive?: boolean
|
||
}
|
||
const closeCheckWaiters = new Map<number, (state: DocsCloseState) => void>()
|
||
const closeSaveWaiters = new Map<number, (ok: boolean) => void>()
|
||
|
||
ipcMain.on('docs:view-menu-state', (event, state: unknown) => {
|
||
const s = state as { aiSidebar?: unknown; darkCanvas?: unknown } | null
|
||
const next = { aiSidebar: s?.aiSidebar === true, darkCanvas: s?.darkCanvas === true }
|
||
if (!viewMenuStateByWebContents.has(event.sender.id)) {
|
||
const id = event.sender.id
|
||
event.sender.once('destroyed', () => viewMenuStateByWebContents.delete(id))
|
||
}
|
||
viewMenuStateByWebContents.set(event.sender.id, next)
|
||
// patch the live menu only for the active tab; an inactive tab's state gets
|
||
// picked up by the buildDocsMenu run its next focus triggers
|
||
if (event.sender.id !== activeDocsWebContents()?.id) return
|
||
const menu = Menu.getApplicationMenu()
|
||
const ai = menu?.getMenuItemById('docs-menu-ai-sidebar')
|
||
if (ai) ai.checked = next.aiSidebar
|
||
const dark = menu?.getMenuItemById('docs-menu-dark-mode')
|
||
if (dark) dark.checked = next.darkCanvas
|
||
})
|
||
|
||
ipcMain.on('docs:close-check-result', (event, state: unknown) => {
|
||
const waiter = closeCheckWaiters.get(event.sender.id)
|
||
if (!waiter) return
|
||
closeCheckWaiters.delete(event.sender.id)
|
||
const s = state as { dirty?: unknown; autoSave?: unknown; filePath?: unknown } | boolean
|
||
waiter(
|
||
typeof s === 'boolean'
|
||
? { dirty: s, autoSave: false }
|
||
: {
|
||
dirty: s?.dirty === true,
|
||
autoSave: s?.autoSave === true,
|
||
filePath: typeof s?.filePath === 'string' ? s.filePath : null,
|
||
},
|
||
)
|
||
})
|
||
|
||
ipcMain.on('docs:close-save-result', (event, ok: unknown) => {
|
||
const waiter = closeSaveWaiters.get(event.sender.id)
|
||
if (!waiter) return
|
||
closeSaveWaiters.delete(event.sender.id)
|
||
waiter(ok === true)
|
||
})
|
||
|
||
/** Ask the renderer for pre-close state (dirty flag + autosave switch); no reply within 2s
|
||
* fails CLOSED — a busy or wedged renderer may well hold unsaved changes, so the caller
|
||
* prompts instead of closing silently. Concurrent callers share one query: a second
|
||
* request must not overwrite the pending waiter (that stranded the first until timeout). */
|
||
const closeStateQueries = new Map<number, Promise<DocsCloseState>>()
|
||
|
||
function queryCloseState(contents: WebContents): Promise<DocsCloseState> {
|
||
if (contents.isDestroyed()) return Promise.resolve({ dirty: false, autoSave: false })
|
||
const pending = closeStateQueries.get(contents.id)
|
||
if (pending) return pending
|
||
const query = new Promise<DocsCloseState>((resolve) => {
|
||
const timer = setTimeout(() => {
|
||
closeCheckWaiters.delete(contents.id)
|
||
resolve({ dirty: true, autoSave: false, unresponsive: true })
|
||
}, 2000)
|
||
closeCheckWaiters.set(contents.id, (state) => {
|
||
clearTimeout(timer)
|
||
resolve(state)
|
||
})
|
||
contents.send('docs:close-check')
|
||
}).finally(() => closeStateQueries.delete(contents.id))
|
||
closeStateQueries.set(contents.id, query)
|
||
return query
|
||
}
|
||
|
||
export async function docsQueryDirty(contents: WebContents): Promise<boolean> {
|
||
return (await queryCloseState(contents)).dirty
|
||
}
|
||
|
||
/** Ask the renderer to run the full save flow and await the result (failure/timeout = false). */
|
||
function requestRendererSave(contents: WebContents): Promise<boolean> {
|
||
return new Promise<boolean>((resolve) => {
|
||
const timer = setTimeout(() => {
|
||
closeSaveWaiters.delete(contents.id)
|
||
resolve(false)
|
||
}, 120_000)
|
||
closeSaveWaiters.set(contents.id, (ok) => {
|
||
clearTimeout(timer)
|
||
resolve(ok)
|
||
})
|
||
contents.send('docs:close-save-request')
|
||
})
|
||
}
|
||
|
||
/**
|
||
* Close guard for the docs renderer: true means proceed with closing.
|
||
* Clean → true; with changes → Save/Don't Save/Cancel. On Save, ask the renderer
|
||
* to run the full save flow (new documents open Save As) and await the result;
|
||
* failure/cancel/timeout keeps the document open.
|
||
*/
|
||
export function requestDocsClose(
|
||
contents: WebContents,
|
||
parent?: BrowserWindow | null,
|
||
): Promise<boolean> {
|
||
// re-entry (close clicked again while the prompt is up) joins the same flow
|
||
// instead of stacking dialogs / stranding the first waiter
|
||
const pending = docsCloseRequests.get(contents.id)
|
||
if (pending) return pending
|
||
const request = performDocsClose(contents, parent).finally(() =>
|
||
docsCloseRequests.delete(contents.id),
|
||
)
|
||
docsCloseRequests.set(contents.id, request)
|
||
return request
|
||
}
|
||
|
||
const docsCloseRequests = new Map<number, Promise<boolean>>()
|
||
|
||
async function performDocsClose(
|
||
contents: WebContents,
|
||
parent?: BrowserWindow | null,
|
||
): Promise<boolean> {
|
||
const state = await queryCloseState(contents)
|
||
if (!state.dirty || contents.isDestroyed()) return true
|
||
if (state.unresponsive) {
|
||
// No reply: saving through the renderer won't work either — offer Close Anyway / Cancel
|
||
const options = {
|
||
type: 'warning' as const,
|
||
message: tm('closeNoReplyMsg'),
|
||
detail: tm('closeNoReplyDetail'),
|
||
buttons: [tm('btnCloseAnyway'), tm('btnCancel')],
|
||
defaultId: 1,
|
||
cancelId: 1,
|
||
noLink: true,
|
||
}
|
||
const { response } =
|
||
parent && !parent.isDestroyed()
|
||
? await dialog.showMessageBox(parent, options)
|
||
: await dialog.showMessageBox(options)
|
||
return response === 0
|
||
}
|
||
// autosave on (and has a path, already checked when the renderer reported): save silently and proceed; only prompt on failure
|
||
if (state.autoSave && (await requestRendererSave(contents))) return true
|
||
const options = {
|
||
type: 'warning' as const,
|
||
message: tm('closeUnsavedMsg'),
|
||
detail: tm('closeUnsavedDetail'),
|
||
buttons: [tm('menuSave'), tm('btnDontSave'), tm('btnCancel')],
|
||
defaultId: 0,
|
||
cancelId: 2,
|
||
noLink: true,
|
||
}
|
||
const { response } =
|
||
parent && !parent.isDestroyed()
|
||
? await dialog.showMessageBox(parent, options)
|
||
: await dialog.showMessageBox(options)
|
||
if (response === 2) return false
|
||
if (response === 1) {
|
||
// Explicitly discarded: also drop the recovery copy so the next open doesn't offer it
|
||
if (state.filePath) clearRecoveryCopy(state.filePath)
|
||
return true
|
||
}
|
||
return requestRendererSave(contents)
|
||
}
|
||
|
||
export function createDocsView(openPath?: string): WebContentsView {
|
||
const view = new WebContentsView({
|
||
webPreferences: {
|
||
preload: runtime.preloadPath,
|
||
contextIsolation: true,
|
||
nodeIntegration: false,
|
||
sandbox: true,
|
||
backgroundThrottling: false,
|
||
},
|
||
})
|
||
|
||
if (openPath) pendingWindowOpens.set(view.webContents.id, openPath)
|
||
|
||
view.webContents.setWindowOpenHandler(({ url }) => {
|
||
const target = safeExternalUrl(url)
|
||
if (target) void shell.openExternal(target)
|
||
return { action: 'deny' }
|
||
})
|
||
|
||
// mode=tab: the shell's tab strip owns the traffic lights / caption buttons,
|
||
// so the ribbon must not reserve space for them
|
||
if (runtime.rendererUrl) {
|
||
// append via URL so a dev URL that already carries query params stays valid
|
||
const devUrl = new URL(runtime.rendererUrl)
|
||
devUrl.searchParams.set('mode', 'tab')
|
||
void view.webContents.loadURL(devUrl.toString())
|
||
} else {
|
||
void view.webContents.loadFile(runtime.rendererFile, { query: { mode: 'tab' } })
|
||
}
|
||
// view.webContents becomes undefined after destroy, so grab the id beforehand
|
||
const wcId = view.webContents.id
|
||
view.webContents.once('destroyed', () => {
|
||
pendingWindowOpens.delete(wcId)
|
||
dropDocWriter(wcId)
|
||
closeCheckWaiters.get(wcId)?.({ dirty: false, autoSave: false })
|
||
closeCheckWaiters.delete(wcId)
|
||
closeSaveWaiters.get(wcId)?.(false)
|
||
closeSaveWaiters.delete(wcId)
|
||
})
|
||
return view
|
||
}
|
||
|
||
/** true when at least one docs window is open (shell menu switching) */
|
||
export function hasDocsWindow(): boolean {
|
||
return mainWindow !== null
|
||
}
|
||
|
||
// ---- standalone lifecycle (apps/docs running on its own) ----
|
||
|
||
export function startDocsStandalone(): void {
|
||
installNavigationGuard(app)
|
||
installContextMenu(app, () => contextMenuLabels(getUiLang()))
|
||
// dev runs must not share the packaged app's userData (recent files, AI settings)
|
||
// or its single-instance lock — otherwise `npm run dev` silently quits whenever
|
||
// the installed GenOffice Docs is open and forwards its argv there instead.
|
||
// AI_OFFICE_USER_DATA: E2E/screenshot runs isolate userData (and the
|
||
// single-instance lock) so parallel automation sessions don't evict each other
|
||
if (process.env.AI_OFFICE_USER_DATA) app.setPath('userData', process.env.AI_OFFICE_USER_DATA)
|
||
else if (isDev) app.setPath('userData', join(app.getPath('appData'), 'GenOffice Docs Dev'))
|
||
|
||
const hasSingleInstanceLock = app.requestSingleInstanceLock()
|
||
if (!hasSingleInstanceLock) {
|
||
app.quit()
|
||
return
|
||
}
|
||
|
||
app.on('open-file', (event, filePath) => {
|
||
event.preventDefault()
|
||
openExternalDocx(filePath)
|
||
})
|
||
|
||
app.on('second-instance', (_event, argv) => {
|
||
openExternalDocx(findDocxPath(argv))
|
||
mainWindow?.show()
|
||
mainWindow?.focus()
|
||
})
|
||
|
||
registerAiIpc()
|
||
registerProjectIpc()
|
||
registerDocsIpc()
|
||
|
||
app.whenReady().then(() => {
|
||
setUiLang(normalizeLang(process.env.GENOFFICE_LANG ?? app.getLocale()))
|
||
// packaged builds get the Dock icon from icon.icns; dev shows Electron's default
|
||
if (isDev && process.platform === 'darwin') {
|
||
app.dock?.setIcon(join(app.getAppPath(), 'build/icon.png'))
|
||
}
|
||
buildDocsMenu()
|
||
createDocsWindow()
|
||
initDocsAutoUpdater(() => mainWindow)
|
||
app.on('activate', () => {
|
||
if (BrowserWindow.getAllWindows().length === 0) createDocsWindow()
|
||
})
|
||
})
|
||
|
||
app.on('window-all-closed', () => {
|
||
if (process.platform !== 'darwin') app.quit()
|
||
})
|
||
}
|