Files
RawMark/web/src/editor/table.test.ts
T
eezd 75000fc571 Add Typora extension syntax
- Parser extensions shared by the editor and the HTML renderer: ==highlight==, $inline math$
  (Pandoc rules, so amounts like $5 are not math), $$ math blocks, footnote references and
  definitions, [TOC], and YAML front matter
- Live preview: highlight, superscript/subscript, emoji names (gemoji), footnote references
  with the definition as tooltip, a clickable table of contents, styled front matter
- Math (KaTeX) and Mermaid render in place; while editing a block the source is shown with a
  live preview below. KaTeX, Mermaid and the emoji table are loaded only when a note uses them
- KaTeX is pinned to 0.18 so Mermaid shares the same copy
- Move editor focus tracking out of table.ts so block widgets and tables use the same state
2026-10-17 13:38:53 +08:00

21 lines
853 B
TypeScript

import { describe, expect, it } from 'vitest'
import { createEditorState } from './index'
import { setEditorFocus } from './focus'
import { tableField } from './table'
const doc = '| a | b |\n| --- | --- |\n| 1 | 2 |\n\n正文'
describe('表格渲染', () => {
it('光标在文首但编辑器未聚焦时,开头的表格仍渲染', () => {
const state = createEditorState({ doc })
expect(state.selection.main.head).toBe(0)
expect(state.field(tableField).size).toBe(1)
})
it('编辑器聚焦且光标在表格内时显示源码,移出后恢复渲染', () => {
let state = createEditorState({ doc }).update({ effects: setEditorFocus.of(true) }).state
expect(state.field(tableField).size).toBe(0)
state = state.update({ selection: { anchor: doc.length } }).state
expect(state.field(tableField).size).toBe(1)
})
})