- Docs: DOCX rendering fidelity - drop caps, hidden (vanish) runs, paragraph pattern shading, floating-table anchoring and clamping, footnote sizing, justified-line spacing - Docs: editing - page breaks split the paragraph correctly, URLs auto-linkify, Insert Hyperlink prefills from the selection, more stable table pagination - Sheets: large streamed workbooks are splittable and formula-capable for the AI; copy_range carries live formulas; range sort up to 200k cells; 1M-cell copies over 2x faster - Sheets: correctness - sort by raw values, shared-formula edits, typed cached strings, empty-string cells, note edits reach the save; risky structural deletes are rejected up front - Sheets: AI chat can export sheets as standalone files; the formula bar grows to fit wrapped formulas - Slides: right-to-left support - paragraph direction toggle, RTL tables, mirrored margins and bullets - Slides: rendering - scaled gradients, embedded fonts, complex-script shaping, chart plot layouts and legends, theme-override colors - Shell: open documents by dropping them onto the window; per-type document icons for OS file associations - AI: localized busy message for overloaded providers; degenerate tool loops stopped with a unified turn budget - Markdown: prompts to save before pasting images into untitled documents Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
111 lines
3.4 KiB
TypeScript
111 lines
3.4 KiB
TypeScript
/**
|
|
* Word AutoFormat parity (alpha ledger r151): a URL followed by space or
|
|
* Enter becomes a hyperlink; trailing punctuation stays outside; existing
|
|
* links and non-URLs are untouched.
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import { Editor } from '@tiptap/core'
|
|
import { editorExtensions } from '../src/renderer/editor/extensions'
|
|
|
|
const makeEditor = (text: string) =>
|
|
new Editor({
|
|
element: document.createElement('div'),
|
|
extensions: editorExtensions,
|
|
content: {
|
|
type: 'doc',
|
|
content: [{ type: 'docParagraph', content: [{ type: 'text', text }] }],
|
|
},
|
|
})
|
|
|
|
const pressAtEnd = (editor: Editor, key: string) => {
|
|
editor.commands.setTextSelection(editor.state.doc.content.size - 1)
|
|
const event = new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true })
|
|
editor.view.dom.dispatchEvent(event)
|
|
}
|
|
|
|
const linkOf = (editor: Editor) => {
|
|
const found: { href: string; from: number; to: number }[] = []
|
|
editor.state.doc.descendants((node, pos) => {
|
|
const mark = node.marks.find((m) => m.type.name === 'link')
|
|
if (mark) found.push({ href: mark.attrs.href as string, from: pos, to: pos + node.nodeSize })
|
|
})
|
|
return found.at(-1) ?? null
|
|
}
|
|
|
|
describe('auto-link on delimiter (r151)', () => {
|
|
it('linkifies a pasted/typed https URL on Enter', () => {
|
|
const editor = makeEditor('see https://example.com/page')
|
|
pressAtEnd(editor, 'Enter')
|
|
expect(linkOf(editor)?.href).toBe('https://example.com/page')
|
|
editor.destroy()
|
|
})
|
|
|
|
it('linkifies on space and keeps trailing punctuation outside', () => {
|
|
const editor = makeEditor('see https://example.com/page.')
|
|
pressAtEnd(editor, ' ')
|
|
const link = linkOf(editor)
|
|
expect(link?.href).toBe('https://example.com/page')
|
|
editor.destroy()
|
|
})
|
|
|
|
it('prefixes www. links with http://', () => {
|
|
const editor = makeEditor('go www.example.com')
|
|
pressAtEnd(editor, 'Enter')
|
|
expect(linkOf(editor)?.href).toBe('http://www.example.com')
|
|
editor.destroy()
|
|
})
|
|
|
|
it('does not swallow an inline atom (hard break) into the URL', () => {
|
|
const editor = new Editor({
|
|
element: document.createElement('div'),
|
|
extensions: editorExtensions,
|
|
content: {
|
|
type: 'doc',
|
|
content: [
|
|
{
|
|
type: 'docParagraph',
|
|
content: [
|
|
{ type: 'text', text: 'see https://example.com' },
|
|
{ type: 'hardBreak' },
|
|
{ type: 'text', text: 'tail' },
|
|
],
|
|
},
|
|
],
|
|
} as never,
|
|
})
|
|
pressAtEnd(editor, ' ')
|
|
expect(linkOf(editor)).toBeNull()
|
|
editor.destroy()
|
|
})
|
|
|
|
it('leaves plain text and existing links alone', () => {
|
|
const plain = makeEditor('nothing to see here')
|
|
pressAtEnd(plain, 'Enter')
|
|
expect(linkOf(plain)).toBeNull()
|
|
plain.destroy()
|
|
|
|
const linked = new Editor({
|
|
element: document.createElement('div'),
|
|
extensions: editorExtensions,
|
|
content: {
|
|
type: 'doc',
|
|
content: [
|
|
{
|
|
type: 'docParagraph',
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: 'https://kept.example.com',
|
|
marks: [{ type: 'link', attrs: { href: 'https://original.example.com' } }],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
} as never,
|
|
})
|
|
pressAtEnd(linked, ' ')
|
|
expect(linkOf(linked)?.href).toBe('https://original.example.com')
|
|
linked.destroy()
|
|
})
|
|
})
|