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:
@@ -0,0 +1,50 @@
|
||||
import { Editor } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
import { LineHeight, TextStyle } from '@tiptap/extension-text-style'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vite-plus/test'
|
||||
|
||||
describe('LineHeight commands', () => {
|
||||
let editor: Editor
|
||||
|
||||
beforeEach(() => {
|
||||
const element = document.createElement('div')
|
||||
document.body.appendChild(element)
|
||||
editor = new Editor({
|
||||
element,
|
||||
extensions: [Document, Paragraph, Text, TextStyle, LineHeight],
|
||||
content: '<p>Example Text</p>',
|
||||
})
|
||||
editor.commands.selectAll()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
editor.destroy()
|
||||
})
|
||||
|
||||
const cases = [
|
||||
{ value: '1.5', style: '1.5' },
|
||||
{ value: '2.0', style: '2' },
|
||||
{ value: '4.0', style: '4' },
|
||||
]
|
||||
|
||||
cases.forEach(({ value, style }) => {
|
||||
it(`sets line-height ${value} for the selected text`, () => {
|
||||
expect(editor.isActive('textStyle', { lineHeight: value })).toBe(false)
|
||||
editor.commands.toggleTextStyle({ lineHeight: value })
|
||||
expect(editor.isActive('textStyle', { lineHeight: value })).toBe(true)
|
||||
const span = editor.view.dom.querySelector('span')
|
||||
expect(span?.textContent).toBe('Example Text')
|
||||
expect(span?.style.lineHeight).toBe(style)
|
||||
})
|
||||
})
|
||||
|
||||
it('removes the line-height of the selected text', () => {
|
||||
editor.commands.toggleTextStyle({ lineHeight: '1.5' })
|
||||
expect(editor.view.dom.querySelector('span')?.style.lineHeight).toBe('1.5')
|
||||
|
||||
editor.commands.unsetLineHeight()
|
||||
expect(editor.getHTML()).not.toContain('<span')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user