1 ? 'clip' : undefined }}
contentEditable={isEditing || undefined}
suppressContentEditableWarning
spellCheck={false}
@@ -842,7 +870,7 @@ export function DocxView({ client, onStatus, initialZoom = 'fit' }: DocxViewProp
blocks={st.blocks}
meta={meta}
page={page}
- top={tops[i]}
+ top={tops[i] - scrollOffset}
left={left}
height={pageHeights[i]}
zoom={z}
@@ -854,7 +882,7 @@ export function DocxView({ client, onStatus, initialZoom = 'fit' }: DocxViewProp
/>
),
)}
- {skeleton > 0 &&
}
+ {skeleton > 0 &&
}
{imgBox && (
diff --git a/test/plain.test.ts b/test/plain.test.ts
index ceb8b07..2a02f7b 100644
--- a/test/plain.test.ts
+++ b/test/plain.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test'
import type { Block, Paragraph } from '../src/core/docx/types'
import { htmlToParas, parseHtml } from '../src/core/html'
-import { decodeText, plainFormat } from '../src/core/plain'
+import { decodeText, htmlParas, markdownParas, plainFormat } from '../src/core/plain'
import { svgImage } from '../src/core/svgfile'
import { Engine } from '../src/core/worker/engine'
@@ -156,6 +156,36 @@ describe('plain sources open as Office files', () => {
})
})
+describe('large plain documents', () => {
+ const count = 150_000
+ const importedText = (p: { runs: { text: string }[] }) => p.runs.map((r) => r.text).join('')
+
+ test('Markdown keeps every paragraph beyond the browser function-argument limit', () => {
+ const ps = markdownParas('# First\n\n' + 'paragraph\n\n'.repeat(count) + '# Last\n', false)
+ expect(ps).toHaveLength(count + 2)
+ expect(ps[0].heading).toBe(1)
+ expect(importedText(ps[0])).toBe('First')
+ expect(importedText(ps[1])).toBe('paragraph')
+ expect(importedText(ps[count])).toBe('paragraph')
+ expect(importedText(ps[count + 1])).toBe('Last')
+ })
+
+ test('HTML keeps every paragraph beyond the browser function-argument limit', () => {
+ const ps = htmlParas('
First
' + '
paragraph
'.repeat(count) + '
Last
', false)
+ expect(ps).toHaveLength(count + 2)
+ expect(importedText(ps[0])).toBe('First')
+ expect(importedText(ps[count])).toBe('paragraph')
+ expect(importedText(ps[count + 1])).toBe('Last')
+ })
+
+ test('Markdown keeps a fenced code block with more lines than the function-argument limit', () => {
+ const ps = markdownParas('```text\n' + 'line\n'.repeat(count) + '```\n\nAfter\n', false)
+ expect(ps).toHaveLength(2)
+ expect(importedText(ps[0]).split('line')).toHaveLength(count + 1)
+ expect(importedText(ps[1])).toBe('After')
+ })
+})
+
describe('plain format detection', () => {
const fmt = (name: string | undefined, type: string | undefined, s: string, whole = true) => plainFormat(name, type, enc(s), whole)