snapshot of https://github.com/ueberdosis/tiptap.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
Verify / Install node dependencies (push) Failing after 2s
Verify / Build packages (push) Has been skipped
Verify / Check linting & formatting (push) Has been skipped
Verify / Run unit tests (push) Has been skipped
Verify / Run e2e tests (shard 1/4) (push) Has been skipped
Verify / Run e2e tests (shard 2/4) (push) Has been skipped
Verify / Run e2e tests (shard 3/4) (push) Has been skipped
Verify / Run e2e tests (shard 4/4) (push) Has been skipped
Publish / Resolve publish config (push) Failing after 2s
Publish / Send notification to Slack (push) Has been skipped
Publish / Send failure notification to Slack (push) Failing after 8s
Verify / Merge e2e reports (push) Has been skipped
Publish / Build (push) Has been skipped
Publish / Bump Versions OR Release to Registry (push) Has been skipped
Some checks failed
Verify / Install node dependencies (push) Failing after 2s
Verify / Build packages (push) Has been skipped
Verify / Check linting & formatting (push) Has been skipped
Verify / Run unit tests (push) Has been skipped
Verify / Run e2e tests (shard 1/4) (push) Has been skipped
Verify / Run e2e tests (shard 2/4) (push) Has been skipped
Verify / Run e2e tests (shard 3/4) (push) Has been skipped
Verify / Run e2e tests (shard 4/4) (push) Has been skipped
Publish / Resolve publish config (push) Failing after 2s
Publish / Send notification to Slack (push) Has been skipped
Publish / Send failure notification to Slack (push) Failing after 8s
Verify / Merge e2e reports (push) Has been skipped
Publish / Build (push) Has been skipped
Publish / Bump Versions OR Release to Registry (push) Has been skipped
This commit is contained in:
52
packages/markdown/tests/integration/list-indentation.test.ts
Normal file
52
packages/markdown/tests/integration/list-indentation.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Document } from '@tiptap/extension-document'
|
||||
import { BulletList, ListItem, OrderedList } from '@tiptap/extension-list'
|
||||
import { Paragraph } from '@tiptap/extension-paragraph'
|
||||
import { Text } from '@tiptap/extension-text'
|
||||
import { MarkdownManager } from '@tiptap/markdown'
|
||||
import { describe, expect, it } from 'vite-plus/test'
|
||||
|
||||
const manager = (indentation?: { style?: 'space' | 'tab'; size?: number }) =>
|
||||
new MarkdownManager({
|
||||
extensions: [Document, Paragraph, Text, BulletList, OrderedList, ListItem],
|
||||
...(indentation ? { indentation } : {}),
|
||||
} as any)
|
||||
|
||||
const roundTrip = (mm: MarkdownManager, markdown: string) => mm.serialize(mm.parse(markdown) as any)
|
||||
|
||||
const ordered = ['1. one', ' 1. inner', '2. two'].join('\n')
|
||||
const orderedWide = ['10. ten', ' 1. inner', '11. eleven'].join('\n')
|
||||
const bullet = ['- one', ' - inner', '- two'].join('\n')
|
||||
|
||||
describe('list indentation on serialize', () => {
|
||||
it('indents a nested ordered list to the marker width', () => {
|
||||
expect(roundTrip(manager(), ordered)).toBe(ordered)
|
||||
})
|
||||
|
||||
it('widens the indent for a marker wider than the indent size', () => {
|
||||
expect(roundTrip(manager({ style: 'space', size: 2 }), orderedWide)).toBe(orderedWide)
|
||||
})
|
||||
|
||||
it('keeps a configured indent that is already past the marker', () => {
|
||||
expect(roundTrip(manager({ style: 'space', size: 4 }), ordered)).toBe(
|
||||
['1. one', ' 1. inner', '2. two'].join('\n'),
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps tab indentation on an ordered list, since a tab clears the marker', () => {
|
||||
expect(roundTrip(manager({ style: 'tab', size: 1 }), orderedWide)).toBe(
|
||||
['10. ten', '\t1. inner', '11. eleven'].join('\n'),
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves bullet lists on the configured indent size', () => {
|
||||
expect(roundTrip(manager({ style: 'space', size: 4 }), bullet)).toBe(
|
||||
['- one', ' - inner', '- two'].join('\n'),
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves bullet lists on tab indentation', () => {
|
||||
expect(roundTrip(manager({ style: 'tab', size: 1 }), bullet)).toBe(
|
||||
['- one', '\t- inner', '- two'].join('\n'),
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user