add tests to the link extension page

This commit is contained in:
Hans Pagel
2020-09-25 19:36:43 +02:00
parent 304504da73
commit 8a0a25aeb0
3 changed files with 30 additions and 3 deletions

View File

@@ -9,4 +9,28 @@ context('/api/extensions/link', () => {
editor.selectAll()
})
})
it('the button should add a link to the selected text', () => {
cy.window().then(win => {
cy.stub(win, 'prompt').returns('https://tiptap.dev')
cy.get('.demo__preview button:first')
.click()
cy.get('.ProseMirror')
.find('a')
.should('contain', 'Example Text')
.should('have.attr', 'href', 'https://tiptap.dev')
})
})
it.skip('links should be auto detected', () => {
cy.get('.ProseMirror')
.then($span => {
$span.text('https://example.com')
})
.find('a')
.should('contain', 'https://example.com')
.should('have.attr', 'href', 'https://example.com')
})
})

View File

@@ -39,7 +39,10 @@ export default {
],
content: `
<p>
Try to add some links to the <a href="https://en.wikipedia.org/wiki/World_Wide_Web" target="_self">world wide web</a>. By default every link will get a <code>rel="noopener noreferrer nofollow"</code> attribute.
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web" target="_self">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isnt that cool? Lets try <a href="https://statamic.com/" target="_self">another one!</a> Yep, seems to work.
</p>
<p>
By default every link will get a \`rel="noopener noreferrer nofollow"\` attribute. Its configurable though.
</p>
`,
})

View File

@@ -18,9 +18,9 @@ yarn add @tiptap/extension-link
| Option | Type | Default | Description |
| ----------- | ------- | ---------------------------- | -------------------------------------------- |
| class | string | | Add a custom class to the rendered HTML tag. |
| openOnClick | Boolean | true | If enabled, links will be opened on click. |
| openOnClick | boolean | true | If enabled, links will be opened on click. |
| rel | string | noopener noreferrer nofollow | Configure the `rel` attribute. |
| target | _self | | Set the default `target` of links. |
| target | string | _self | Set the default `target` of links. |
## Commands
| Command | Options | Description |