Merge branch 'main' of github.com:ueberdosis/tiptap into main

This commit is contained in:
Hans Pagel
2021-05-05 20:55:12 +02:00
29 changed files with 191 additions and 201 deletions

View File

@@ -1,12 +1,18 @@
context('/demos/Guide/Content/ReadOnly', () => {
beforeEach(() => {
before(() => {
cy.visit('/demos/Guide/Content/ReadOnly')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.clearContent()
})
})
it('should be read-only', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setEditable(false)
editor.commands.insertContent('Edited: ')
cy.get('.ProseMirror').type('Edited: ')
cy.get('.ProseMirror p:first').should('not.contain', 'Edited: ')
})
@@ -15,7 +21,7 @@ context('/demos/Guide/Content/ReadOnly', () => {
it('should be editable', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setEditable(true)
editor.commands.insertContent('Edited: ')
cy.get('.ProseMirror').type('Edited: ')
cy.get('.ProseMirror p:first').should('contain', 'Edited: ')
})

View File

@@ -47,10 +47,17 @@ context('/demos/Marks/Link', () => {
})
})
it('detects a pasted URL within a text', () => {
cy.get('.ProseMirror').paste({ pastePayload: 'some text https://example.com around an url', pasteType: 'text/plain' })
.find('a')
.should('contain', 'https://example.com')
.should('have.attr', 'href', 'https://example.com')
})
it('detects a pasted URL', () => {
cy.get('.ProseMirror').paste({ pastePayload: 'https://example.com', pasteType: 'text/plain' })
.find('a')
.should('contain', 'https://example.com')
.should('contain', 'Example Text')
.should('have.attr', 'href', 'https://example.com')
})

View File

@@ -154,11 +154,12 @@ export default () => ({ commands }) => {
Have a look at all of the core commands listed below. They should give you a good first impression of whats possible.
### Content
| Command | Description | Links |
| ---------------- | -------------------------------------------------------- | ------------------------------------ |
| .clearContent() | Clear the whole document. | [More](/api/commands/clear-content) |
| .insertContent() | Insert a node or string of HTML at the current position. | [More](/api/commands/insert-content) |
| .setContent() | Replace the whole document with new content. | [More](/api/commands/set-content) |
| Command | Description | Links |
| ------------------ | -------------------------------------------------------- | --------------------------------------- |
| .clearContent() | Clear the whole document. | [More](/api/commands/clear-content) |
| .insertContent() | Insert a node or string of HTML at the current position. | [More](/api/commands/insert-content) |
| .insertContentAt() | Insert a node or string of HTML at a specific position. | [More](/api/commands/insert-content-at) |
| .setContent() | Replace the whole document with new content. | [More](/api/commands/set-content) |
### Nodes & Marks
| Command | Description | Links |
@@ -172,8 +173,6 @@ Have a look at all of the core commands listed below. They should give you a goo
| .lift() | Removes an existing wrap. | [More](/api/commands/lift) |
| .liftEmptyBlock() | Lift block if empty. | [More](/api/commands/lift-empty-block) |
| .newlineInCode() | Add a newline character in code. | [More](/api/commands/newline-in-code) |
| .replace() | Replaces text with a node. | [More](/api/commands/replace) |
| .replaceRange() | Replaces text with a node within a range. | [More](/api/commands/replace-range) |
| .resetAttributes() | Resets some node or mark attributes to the default value. | [More](/api/commands/reset-attributes) |
| .setMark() | Add a mark with new attributes. | [More](/api/commands/set-mark) |
| .setNode() | Replace a given range with a node. | [More](/api/commands/set-node) |

View File

@@ -1,3 +1,3 @@
# replaceRange
# insertContentAt
<ContentMissing />

View File

@@ -29,5 +29,27 @@ editor.commands.insertContent({
},
],
})
// Multiple nodes at once
editor.commands.insertContent([
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'First paragraph',
},
],
},
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Second paragraph',
},
],
},
])
```

View File

@@ -1,3 +0,0 @@
# replace
<ContentMissing />

View File

@@ -157,6 +157,9 @@
type: draft
- title: insertContent
link: /api/commands/insert-content
- title: insertContentAt
link: /api/commands/insert-content-at
type: draft
- title: joinBackward
link: /api/commands/join-backward
type: draft
@@ -178,12 +181,6 @@
- title: newlineInCode
link: /api/commands/newline-in-code
type: draft
- title: replaceRange
link: /api/commands/replace-range
type: draft
- title: replace
link: /api/commands/replace
type: draft
- title: resetAttributes
link: /api/commands/reset-attributes
type: draft