diff --git a/README.md b/README.md index 1f93d87..afecacf 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ [![License: Apache-2.0](https://img.shields.io/github/license/genspark-ai/genoffice)](LICENSE) [![Latest release](https://img.shields.io/github/v/release/genspark-ai/genoffice)](https://github.com/genspark-ai/genoffice/releases/latest) [![Downloads](https://img.shields.io/github/downloads/genspark-ai/genoffice/total)](https://github.com/genspark-ai/genoffice/releases) -[![GitHub stars](https://img.shields.io/github/stars/genspark-ai/genoffice?style=flat)](https://github.com/genspark-ai/genoffice/stargazers) -![Platforms: macOS | Windows | Linux](https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-lightgrey) [Website](https://genoffice.ai/) · [Download](https://github.com/genspark-ai/genoffice/releases/latest) · [Demo](https://www.youtube.com/watch?v=B2pLdMX95v4) @@ -40,12 +38,12 @@ layer. | Platform | Requirements | Download | | ------------------------------------ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| **macOS** — Apple Silicon (arm64) | macOS 11+ | [GenOffice-0.6.101-arm64.dmg](https://github.com/genspark-ai/genoffice/releases/download/v0.6.101/GenOffice-0.6.101-arm64.dmg) | -| **macOS** — Intel (x64) | macOS 11+ | [GenOffice-0.6.101.dmg](https://github.com/genspark-ai/genoffice/releases/download/v0.6.101/GenOffice-0.6.101.dmg) | -| **Windows** (x64) | Windows 10+ | [GenOfficeSetup-v0.6.101.exe](https://github.com/genspark-ai/genoffice/releases/download/v0.6.101/GenOfficeSetup-v0.6.101.exe) | -| **Linux** — Debian / Ubuntu | x86_64, glibc 2.34+ (Ubuntu 22.04 or newer) | [genoffice_0.6.101_amd64.deb](https://github.com/genspark-ai/genoffice/releases/download/v0.6.101/genoffice_0.6.101_amd64.deb) | -| **Linux** — Fedora / RHEL / openSUSE | x86_64, glibc 2.34+ (Fedora 35+, RHEL 9+, Leap 15.6+) | [genoffice-0.6.101.x86_64.rpm](https://github.com/genspark-ai/genoffice/releases/download/v0.6.101/genoffice-0.6.101.x86_64.rpm) | -| **Linux** — other distributions | x86_64, glibc 2.34+, FUSE 2 | [GenOffice-0.6.101.AppImage](https://github.com/genspark-ai/genoffice/releases/download/v0.6.101/GenOffice-0.6.101.AppImage) | +| **macOS** — Apple Silicon (arm64) | macOS 11+ | [GenOffice-0.6.389-arm64.dmg](https://github.com/genspark-ai/genoffice/releases/download/v0.6.389/GenOffice-0.6.389-arm64.dmg) | +| **macOS** — Intel (x64) | macOS 11+ | [GenOffice-0.6.389.dmg](https://github.com/genspark-ai/genoffice/releases/download/v0.6.389/GenOffice-0.6.389.dmg) | +| **Windows** (x64) | Windows 10+ | [GenOfficeSetup-v0.6.389.exe](https://github.com/genspark-ai/genoffice/releases/download/v0.6.389/GenOfficeSetup-v0.6.389.exe) | +| **Linux** — Debian / Ubuntu | x86_64, glibc 2.34+ (Ubuntu 22.04 or newer) | [genoffice_0.6.389_amd64.deb](https://github.com/genspark-ai/genoffice/releases/download/v0.6.389/genoffice_0.6.389_amd64.deb) | +| **Linux** — Fedora / RHEL / openSUSE | x86_64, glibc 2.34+ (Fedora 35+, RHEL 9+, Leap 15.6+) | [genoffice-0.6.389.x86_64.rpm](https://github.com/genspark-ai/genoffice/releases/download/v0.6.389/genoffice-0.6.389.x86_64.rpm) | +| **Linux** — other distributions | x86_64, glibc 2.34+, FUSE 2 | [GenOffice-0.6.389.AppImage](https://github.com/genspark-ai/genoffice/releases/download/v0.6.389/GenOffice-0.6.389.AppImage) | All builds come from `main`; the macOS and Windows installers are signed. Older versions are on the [Releases](https://github.com/genspark-ai/genoffice/releases) page. @@ -56,14 +54,14 @@ The deb installs with apt — it pulls in the dependencies and adds GenOffice to the applications menu: ```bash -sudo apt install ./genoffice_0.6.101_amd64.deb +sudo apt install ./genoffice_0.6.389_amd64.deb ``` On Fedora / RHEL-family / openSUSE, install the rpm instead: ```bash -sudo dnf install ./genoffice-0.6.101.x86_64.rpm # Fedora / RHEL family -sudo zypper install ./genoffice-0.6.101.x86_64.rpm # openSUSE +sudo dnf install ./genoffice-0.6.389.x86_64.rpm # Fedora / RHEL family +sudo zypper install ./genoffice-0.6.389.x86_64.rpm # openSUSE ``` The AppImage instead runs in place: install the FUSE 2 runtime @@ -71,8 +69,8 @@ The AppImage instead runs in place: install the FUSE 2 runtime make the file executable, then run it: ```bash -chmod +x GenOffice-0.6.101.AppImage -./GenOffice-0.6.101.AppImage +chmod +x GenOffice-0.6.389.AppImage +./GenOffice-0.6.389.AppImage ``` ## Apps diff --git a/apps/docs/src/main/docs-main.ts b/apps/docs/src/main/docs-main.ts index 8af67ba..532659b 100644 --- a/apps/docs/src/main/docs-main.ts +++ b/apps/docs/src/main/docs-main.ts @@ -3103,9 +3103,18 @@ export function registerDocsIpc(): void { }, ) - ipcMain.handle('docs:print', (event) => { - // print the calling tab's own content; zero margins — the docx page padding provides them - event.sender.print({ margins: { marginType: 'none' } }) + ipcMain.handle('docs:print', async (event) => { + // 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' } }, (success, failureReason) => { + resolve({ + ok: success, + ...(failureReason && !/cancel/i.test(failureReason) ? { error: failureReason } : {}), + }) + }) + }) }) ipcMain.handle( @@ -3367,7 +3376,9 @@ export function buildDocsMenu(): void { { label: tm('menuPrint'), accelerator: 'CmdOrCtrl+P', - click: () => activeDocsWebContents()?.print({}), + // 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'), }, ], }, diff --git a/apps/docs/src/renderer/App.tsx b/apps/docs/src/renderer/App.tsx index 87d5c24..9be113c 100644 --- a/apps/docs/src/renderer/App.tsx +++ b/apps/docs/src/renderer/App.tsx @@ -40,6 +40,7 @@ import { CommentsPanel } from './components/CommentsPanel' import { EquationModal } from './components/EquationModal' import { HeaderFooterArea } from './components/HeaderFooterArea' import { PaginationPreview } from './components/PaginationPreview' +import { PrintDialog } from './components/PrintDialog' import { appendEndnotesBlock, assignSections, @@ -76,6 +77,7 @@ import { hfHasVisibleContent, makeGapHfEl } from './editor/hf-dom' import { estimateFootnoteHeight, estimateHfHeight, + footnoteLineHeightPx, FOOTNOTE_SEPARATOR_H, textHasCjk, } from './line-metrics' @@ -142,6 +144,7 @@ import { exportPdf as exportPdfImpl, loadFile as loadFileImpl, newFile as newFileImpl, + printDoc as printDocImpl, save as saveImpl, writeRecoveryCopy as writeRecoveryCopyImpl, type FileActionContext, @@ -239,6 +242,7 @@ function makeGapNotesEl( leftPx: number, widthPx: number, heightPx: number, + lineHeightPx: number, onEdit: (id: string) => void, ): HTMLElement { const wrap = document.createElement('div') @@ -246,12 +250,14 @@ function makeGapNotesEl( wrap.style.left = `${leftPx}px` wrap.style.width = `${widthPx}px` wrap.style.height = `${heightPx}px` + // same line height as estimateFootnoteHeight; min-height keeps rows at the + // reserved size while letting long entries overflow instead of clipping + wrap.style.lineHeight = `${lineHeightPx}px` for (const it of items) { const row = document.createElement('div') row.className = 'page-gap-note' row.title = t('appDblclickEditFootnote') - // entries get fixed heights from the estimates: rendering matches the engine's reservation bookkeeping exactly, no more overflow - row.style.height = `${it.height}px` + row.style.minHeight = `${it.height}px` const sup = document.createElement('sup') sup.textContent = String(it.no) row.append(sup) @@ -267,6 +273,8 @@ function makeGapNotesEl( if (deco.length > 0) span.style.textDecoration = deco.join(' ') if (run.color) span.style.color = `#${run.color}` if (run.sizeHalfPoints) span.style.fontSize = `${run.sizeHalfPoints / 2}pt` + if (run.caps === 'all') span.style.textTransform = 'uppercase' + else if (run.caps === 'small') span.style.fontVariantCaps = 'small-caps' row.append(span) } }) @@ -423,19 +431,23 @@ export function App() { const hfImagesOf = (kind: 'header' | 'footer') => { const parsed = doc?.parsed if (!parsed) return undefined - const view = kind === 'header' ? headerAreaView : footerAreaView - if (view === 'first') { - return (kind === 'header' ? parsed.headerFirst : parsed.footerFirst)?.images - } - if (view === 'even') { - return (kind === 'header' ? parsed.headerEven : parsed.footerEven)?.images - } - if (multiHf) { - const rId = effRefsAll[hfSectionClamped]?.[kind]?.default - const fromPart = rId ? parsed.hfParts?.[rId]?.images : undefined - if (fromPart?.length) return fromPart - } - return (kind === 'header' ? parsed.headerImages : parsed.footerImages) ?? undefined + const raw = (() => { + const view = kind === 'header' ? headerAreaView : footerAreaView + if (view === 'first') { + return (kind === 'header' ? parsed.headerFirst : parsed.footerFirst)?.images + } + if (view === 'even') { + return (kind === 'header' ? parsed.headerEven : parsed.footerEven)?.images + } + if (multiHf) { + const rId = effRefsAll[hfSectionClamped]?.[kind]?.default + const fromPart = rId ? parsed.hfParts?.[rId]?.images : undefined + if (fromPart?.length) return fromPart + } + return (kind === 'header' ? parsed.headerImages : parsed.footerImages) ?? undefined + })() + // floating shapes (watermarks) must not stack into the strip (mirrors PaginationPreview) + return raw?.filter((img) => !img.floating) } const commitHf = (kind: 'header' | 'footer', next: HeaderFooter) => { @@ -804,6 +816,10 @@ export function App() { // Mixed-paper menu export: after the preview mounts and renders, the merge export resumes automatically const pendingMixedExportRef = useRef(false) + // Print dialog (Word-style preview + range); the pagination preview is its print source + const [showPrintDialog, setShowPrintDialog] = useState(false) + // the dialog auto-opened the pagination preview: close it again with the dialog + const printAutoOpenedPreviewRef = useRef(false) /** App state bundle for the extracted file actions (file-actions.ts); refreshed every render. */ const fileCtxRef = useRef(null as unknown as FileActionContext) @@ -814,6 +830,8 @@ export function App() { saveInFlightRef, saveIncompleteRef, pendingMixedExportRef, + printAutoOpenedPreviewRef, + setShowPrintDialog, setStatus, setRecent, setShowAi, @@ -1231,6 +1249,7 @@ export function App() { (outPath?: string) => exportPdfImpl(fileCtxRef.current, outPath), [], ) + const printDoc = useCallback(() => printDocImpl(fileCtxRef.current), []) // for real-device verification: trigger export directly via CDP (same as __pageDebug) useEffect(() => { @@ -1247,6 +1266,14 @@ export function App() { return () => window.clearTimeout(timer) }, [showPagePreview, exportPdf]) + const closePrintDialog = useCallback(() => { + setShowPrintDialog(false) + if (printAutoOpenedPreviewRef.current) { + printAutoOpenedPreviewRef.current = false + setShowPagePreview(false) + } + }, []) + // ---- References: footnotes / endnotes ---- const [notePrompt, setNotePrompt] = useState(null) @@ -1501,12 +1528,14 @@ export function App() { const styleDisplay = b.styleId ? doc?.parsed.styles.get(b.styleId)?.display : undefined const keepNext = b.format?.keepNext ?? styleDisplay?.keepNext const keepLines = b.format?.keepLines ?? styleDisplay?.keepLines + const breakBefore = b.format?.pageBreakBefore ?? styleDisplay?.pageBreakBefore const widowOff = b.format?.widowControl === false const fnExtra = footnoteExtraOf(b) - if (!keepNext && !keepLines && !widowOff && fnExtra === 0) return undefined + if (!keepNext && !keepLines && !breakBefore && !widowOff && fnExtra === 0) return undefined return { ...(keepNext ? { keepNext: true } : {}), ...(keepLines ? { keepLines: true } : {}), + ...(breakBefore ? { breakBefore: true } : {}), ...(widowOff ? { widowControl: false as const } : {}), ...(fnExtra > 0 ? { footnoteExtraPx: fnExtra } : {}), } @@ -1668,6 +1697,7 @@ export function App() { const contentH = twipsToPx(section.pageHeight) - effTopSingle - effBottomSingle let slices: PageSlice[] = [] let timer: number | null = null + let suppressSig = '' const pmEl = () => document.querySelector('.editor-scroll .ProseMirror') as HTMLElement | null const locate = () => { const pm = pmEl() @@ -1797,6 +1827,8 @@ export function App() { const firsts = sectionFirstPages(slices) const effRefs = secList ? effectiveHfRefs(secList) : null const parsed = doc.parsed + // floating shapes (watermarks) must not stack into the strip (mirrors PaginationPreview) + const stripImgs = (imgs?: HfImage[] | null) => imgs?.filter((img) => !img.floating) const pageHfOf = ( pageIdx: number, kind: 'header' | 'footer', @@ -1805,17 +1837,17 @@ export function App() { if (!secList || secList.length <= 1) { if (titlePg && pageIdx === 0) { return kind === 'header' - ? { value: hfVariants.headerFirst, images: parsed.headerFirst?.images } - : { value: hfVariants.footerFirst, images: parsed.footerFirst?.images } + ? { value: hfVariants.headerFirst, images: stripImgs(parsed.headerFirst?.images) } + : { value: hfVariants.footerFirst, images: stripImgs(parsed.footerFirst?.images) } } if (evenOddHf && pageNo % 2 === 0) { return kind === 'header' - ? { value: hfVariants.headerEven, images: parsed.headerEven?.images } - : { value: hfVariants.footerEven, images: parsed.footerEven?.images } + ? { value: hfVariants.headerEven, images: stripImgs(parsed.headerEven?.images) } + : { value: hfVariants.footerEven, images: stripImgs(parsed.footerEven?.images) } } return kind === 'header' - ? { value: header, images: parsed.headerImages ?? undefined } - : { value: footer, images: parsed.footerImages ?? undefined } + ? { value: header, images: stripImgs(parsed.headerImages) } + : { value: footer, images: stripImgs(parsed.footerImages) } } const pageSlice = slices[pageIdx] const sec = secList[Math.min(pageSlice.section, secList.length - 1)] @@ -1830,7 +1862,7 @@ export function App() { const rId = refs[kind][variant] return { value: ov ?? hfFromPart(rId ? parsed.hfParts?.[rId] : null), - images: rId ? parsed.hfParts?.[rId]?.images : undefined, + images: stripImgs(rId ? parsed.hfParts?.[rId]?.images : undefined), } } const pageNoTextOf = (pageIdx: number) => @@ -1875,7 +1907,7 @@ export function App() { }) el.style.top = 'auto' el.style.bottom = `${GAP_BAND + metrics.marginTop + box.footerDist}px` - el.style.width = `${Math.min(box.width, canvasPaperW) - 120}px` + el.style.width = `${Math.min(box.contentWidth, canvasPaperW)}px` hfEls.push(el) } if (hfHasVisibleContent(gapHeader.value, gapHeader.images)) { @@ -1889,7 +1921,7 @@ export function App() { }) el.style.bottom = 'auto' el.style.top = `calc(100% - ${Math.max(0, metrics.marginTop - box.headerDist)}px)` - el.style.width = `${Math.min(box.width, canvasPaperW) - 120}px` + el.style.width = `${Math.min(box.contentWidth, canvasPaperW)}px` hfEls.push(el) } const hfProps = @@ -1912,8 +1944,13 @@ export function App() { const contentW = twipsToPx( prevSec.pageWidth - prevSec.marginLeft - prevSec.marginRight, ) - notes = makeGapNotesEl(items, twipsToPx(prevSec.marginLeft), contentW, fnH, (id) => - editNote('footnote', id), + notes = makeGapNotesEl( + items, + twipsToPx(prevSec.marginLeft), + contentW, + fnH, + footnoteLineHeightPx(prevSec.docGrid), + (id) => editNote('footnote', id), ) notesKey = `${Math.round(fnH)}:${items.map((n) => `${n.no}${n.text}`).join('|')}` notesMetrics = { ...metrics, marginBottom: metrics.marginBottom + fnH } @@ -1924,6 +1961,9 @@ export function App() { gaps.push({ el: blocks[i].el!, metrics: notesMetrics, + ...(blocks[i].breakBefore || (i > 0 && blocks[i - 1].breakAfter) + ? { suppressLeadMt: true } + : {}), ...(notes ? { notes, notesKey } : {}), ...hfProps, }) @@ -2028,8 +2068,9 @@ export function App() { kind: 'cell', metrics: { ...metrics, - marginLeft: metrics.marginLeft + (r.left - pmRect.left) / factor, - marginRight: metrics.marginRight + (pmRect.right - r.right) / factor, + // rect offsets from the paper edge already include the page margins + marginLeft: (r.left - pmRect.left) / factor, + marginRight: (pmRect.right - r.right) / factor, }, ...hfProps, }) @@ -2043,14 +2084,14 @@ export function App() { const anchor = lineStartAnchor(b.el, slice.start - b.top, factor) const pos = anchor ? posFromAnchor(editor.view, anchor) : undefined if (pos == null) return - // fold the block's horizontal indent relative to the content area into negative margins so the gap spans the full paper width + // fold the block's offset from the paper edge (page margin + indent) into negative margins so the gap spans exactly the paper width const elRect = b.el.getBoundingClientRect() gaps.push({ pos, metrics: { ...notesMetrics, - marginLeft: metrics.marginLeft + (elRect.left - pmRect.left) / factor, - marginRight: metrics.marginRight + (pmRect.right - elRect.right) / factor, + marginLeft: (elRect.left - pmRect.left) / factor, + marginRight: (pmRect.right - elRect.right) / factor, }, ...(notes ? { notes, notesKey } : {}), ...hfProps, @@ -2087,6 +2128,12 @@ export function App() { const tSet0 = performance.now() setPageGaps(editor.view, gaps) tSetGaps = performance.now() - tSet0 + // suppression collapses the DOM after this pass sliced; one follow-up remeasure re-syncs (sig goes stable, no loop) + const sig = gaps.reduce((s, g, n) => (g.suppressLeadMt ? `${s},${n}` : s), '') + if (sig !== suppressSig) { + suppressSig = sig + onUpdate() + } // the last page paints as a full sheet like the ones above it: // extend the canvas to that page's paper bottom, measured from the last gap const gapEls = pm.querySelectorAll('.page-gap') @@ -2485,6 +2532,9 @@ export function App() { case 'export-pdf': void exportPdf() break + case 'print': + if (doc) void printDoc() + break } }) }, [ @@ -2495,6 +2545,7 @@ export function App() { openRecent, save, exportPdf, + printDoc, zoomFit, openStats, startNewComment, @@ -2700,7 +2751,8 @@ export function App() { <> -