Files
genoffice/apps/docs/tests/justify-symbol-live.test.ts
T
merrick-2002andGenOffice 69b4ce0560 Sync snapshot (2026-09-06) (#243)
- Docs: Word-style dark page, phased fast open for long documents, fonts embedded in the DOCX, spellcheck toggle, hyperlink editing, and ~80 Word fidelity fixes (CJK/JP metrics, header/footer, tables, anchored pictures)
- Sheets: hold formula recalculation while file data streams in, large-workbook scroll/load performance, combo charts, duplicate/unique conditional formatting by display text, RTL frozen-pane fix, workbooks whose ZIP entries carry a leading slash
- Slides: MTX-compressed embedded font support, CJK/Latin face selection and PowerPoint script fallbacks, theme colors kept on paragraph defaults and bullets, more reliable AI edits with a layout audit after each batch
- PDF: AI page ops, text block move/align, notes and markup editing, watermark and header/footer, form check boxes, metadata; the cloud Export as Word fallback is removed, conversion is always on-device
- AI: Gemini tool schema translation, OpenCode Zen/Go providers, markdown tables and code blocks in chat, current date in the system prompt
- Shell: Office-style ribbon collapse across all editors, native Windows ARM64 installer, BUILD_DIR override for packaging

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-09-07 00:18:14 +08:00

49 lines
1.6 KiB
TypeScript

/**
* Chromium treats U+2116 and other CJK-codepage symbols as ideographs when
* distributing justification space; Word stretches only the spaces around them.
* Non-CJK justified paragraphs wrap them in .doc-justify-symbol (text-justify:none).
*/
import { Editor } from '@tiptap/core'
import { describe, expect, it } from 'vitest'
import { editorExtensions } from '../src/renderer/editor/extensions'
const symbols = (editor: Editor): string[] =>
Array.from(editor.view.dom.querySelectorAll('.doc-justify-symbol'), (el) => el.textContent ?? '')
const paragraphDoc = (text: string, attrs?: Record<string, unknown>) =>
({
type: 'doc',
content: [
{
type: 'docParagraph',
...(attrs ? { attrs } : {}),
content: [{ type: 'text', text }],
},
],
}) as never
const makeEditor = (content: unknown) =>
new Editor({
element: document.createElement('div'),
extensions: editorExtensions,
content: content as never,
})
describe('justification symbol decorations', () => {
it('wraps the symbols of a justified non-CJK paragraph', () => {
const editor = makeEditor(paragraphDoc('за № 470-EL, 20 ℃', { align: 'justify' }))
expect(symbols(editor)).toEqual(['№', '℃'])
expect(editor.view.dom.textContent).toBe('за № 470-EL, 20 ℃')
editor.destroy()
})
it('leaves left-aligned and CJK paragraphs alone', () => {
const left = makeEditor(paragraphDoc('за № 470-EL'))
expect(symbols(left)).toEqual([])
left.destroy()
const cjk = makeEditor(paragraphDoc('文件 № 470', { align: 'justify' }))
expect(symbols(cjk)).toEqual([])
cjk.destroy()
})
})