mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 09:04:44 -04:00
Upgrade to CodeMirror 6 (#1787)
Upgrade to CodeMirror 6 Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
1a09bfa5f1
commit
6a6f6105b9
103 changed files with 1906 additions and 2615 deletions
|
@ -9,91 +9,78 @@ import { addLink } from './add-link'
|
|||
describe('add link', () => {
|
||||
describe('without to-cursor', () => {
|
||||
it('inserts a link', () => {
|
||||
const actual = addLink([''], { from: { line: 0, character: 0 } }, '')
|
||||
expect(actual).toEqual(['[](https://)'])
|
||||
const actual = addLink('', { from: 0 }, '')
|
||||
expect(actual).toEqual(['[](https://)', { from: 0, to: 12 }])
|
||||
})
|
||||
|
||||
it('inserts a link into a line', () => {
|
||||
const actual = addLink(['aa'], { from: { line: 0, character: 1 } }, '')
|
||||
expect(actual).toEqual(['a[](https://)a'])
|
||||
const actual = addLink('aa', { from: 1 }, '')
|
||||
expect(actual).toEqual(['a[](https://)a', { from: 1, to: 13 }])
|
||||
})
|
||||
|
||||
it('inserts a link with a prefix', () => {
|
||||
const actual = addLink([''], { from: { line: 0, character: 0 } }, 'prefix')
|
||||
expect(actual).toEqual(['prefix[](https://)'])
|
||||
const actual = addLink('', { from: 0 }, 'prefix')
|
||||
expect(actual).toEqual(['prefix[](https://)', { from: 0, to: 18 }])
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a normal text selected', () => {
|
||||
it('wraps the selection', () => {
|
||||
const actual = addLink(
|
||||
['a'],
|
||||
'a',
|
||||
{
|
||||
from: { line: 0, character: 0 },
|
||||
to: {
|
||||
line: 0,
|
||||
character: 1
|
||||
}
|
||||
from: 0,
|
||||
to: 1
|
||||
},
|
||||
''
|
||||
)
|
||||
expect(actual).toEqual(['[a](https://)'])
|
||||
expect(actual).toEqual(['[a](https://)', { from: 0, to: 13 }])
|
||||
})
|
||||
|
||||
it('wraps the selection inside of a line', () => {
|
||||
const actual = addLink(['aba'], { from: { line: 0, character: 1 }, to: { line: 0, character: 2 } }, '')
|
||||
expect(actual).toEqual(['a[b](https://)a'])
|
||||
const actual = addLink('aba', { from: 1, to: 2 }, '')
|
||||
expect(actual).toEqual(['a[b](https://)a', { from: 1, to: 14 }])
|
||||
})
|
||||
|
||||
it('wraps the selection with a prefix', () => {
|
||||
const actual = addLink(['a'], { from: { line: 0, character: 0 }, to: { line: 0, character: 1 } }, 'prefix')
|
||||
expect(actual).toEqual(['prefix[a](https://)'])
|
||||
const actual = addLink('a', { from: 0, to: 1 }, 'prefix')
|
||||
expect(actual).toEqual(['prefix[a](https://)', { from: 0, to: 19 }])
|
||||
})
|
||||
|
||||
it('wraps a multi line selection', () => {
|
||||
const actual = addLink(['a', 'b', 'c'], { from: { line: 0, character: 0 }, to: { line: 2, character: 1 } }, '')
|
||||
expect(actual).toEqual(['[a', 'b', 'c](https://)'])
|
||||
const actual = addLink('a\nb\nc', { from: 0, to: 5 }, '')
|
||||
expect(actual).toEqual(['[a\nb\nc](https://)', { from: 0, to: 17 }])
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a url selected', () => {
|
||||
it('wraps the selection', () => {
|
||||
const actual = addLink(
|
||||
['https://google.com'],
|
||||
'https://google.com',
|
||||
{
|
||||
from: { line: 0, character: 0 },
|
||||
to: {
|
||||
line: 0,
|
||||
character: 18
|
||||
}
|
||||
from: 0,
|
||||
to: 18
|
||||
},
|
||||
''
|
||||
)
|
||||
expect(actual).toEqual(['[](https://google.com)'])
|
||||
expect(actual).toEqual(['[](https://google.com)', { from: 0, to: 22 }])
|
||||
})
|
||||
|
||||
it('wraps the selection with a prefix', () => {
|
||||
const actual = addLink(
|
||||
['https://google.com'],
|
||||
'https://google.com',
|
||||
{
|
||||
from: { line: 0, character: 0 },
|
||||
to: {
|
||||
line: 0,
|
||||
character: 18
|
||||
}
|
||||
from: 0,
|
||||
to: 18
|
||||
},
|
||||
'prefix'
|
||||
)
|
||||
expect(actual).toEqual(['prefix[](https://google.com)'])
|
||||
expect(actual).toEqual(['prefix[](https://google.com)', { from: 0, to: 28 }])
|
||||
})
|
||||
|
||||
it(`wraps a multi line selection not as link`, () => {
|
||||
const actual = addLink(
|
||||
['a', 'https://google.com', 'c'],
|
||||
{ from: { line: 0, character: 0 }, to: { line: 2, character: 1 } },
|
||||
''
|
||||
)
|
||||
expect(actual).toEqual(['[a', 'https://google.com', 'c](https://)'])
|
||||
const actual = addLink('a\nhttps://google.com\nc', { from: 0, to: 22 }, '')
|
||||
expect(actual).toEqual(['[a\nhttps://google.com\nc](https://)', { from: 0, to: 34 }])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue