-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: update examples for trailing-node and selection extension (#6065)
- Loading branch information
1 parent
32958d6
commit e80ba58
Showing
13 changed files
with
301 additions
and
76 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
context('/src/Extensions/Selection/React/', () => { | ||
beforeEach(() => { | ||
cy.visit('/src/Extensions/Selection/React/') | ||
}) | ||
|
||
it('should have class', () => { | ||
cy.get('.tiptap span:first').should('have.class', 'selection') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import './styles.scss' | ||
|
||
import Code from '@tiptap/extension-code' | ||
import Document from '@tiptap/extension-document' | ||
import { BulletList, ListItem } from '@tiptap/extension-list' | ||
import Paragraph from '@tiptap/extension-paragraph' | ||
import Text from '@tiptap/extension-text' | ||
import { Selection } from '@tiptap/extensions' | ||
import { EditorContent, useEditor } from '@tiptap/react' | ||
import React from 'react' | ||
|
||
export default () => { | ||
const editor = useEditor({ | ||
extensions: [ | ||
Document, | ||
Paragraph, | ||
Text, | ||
Selection.configure({ | ||
className: 'selection', | ||
}), | ||
Code, | ||
BulletList, | ||
ListItem, | ||
], | ||
content: ` | ||
<p> | ||
The selection extension adds a class to the selection when the editor is blurred. That enables you to visually preserve the selection even though the editor is blurred. By default, it’ll add <code>.selection</code> classname. | ||
</p> | ||
`, | ||
|
||
onCreate: ctx => { | ||
ctx.editor.commands.setTextSelection({ from: 5, to: 30 }) | ||
}, | ||
}) | ||
|
||
return <EditorContent editor={editor} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Basic editor styles */ | ||
.tiptap { | ||
:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
/* List styles */ | ||
ul, | ||
ol { | ||
padding: 0 1rem; | ||
margin: 1.25rem 1rem 1.25rem 0.4rem; | ||
|
||
li p { | ||
margin-top: 0.25em; | ||
margin-bottom: 0.25em; | ||
} | ||
} | ||
|
||
/* Code and preformatted text styles */ | ||
code { | ||
background-color: var(--purple-light); | ||
border-radius: 0.4rem; | ||
color: var(--black); | ||
font-size: 0.85rem; | ||
padding: 0.25em 0.3em; | ||
} | ||
|
||
|
||
// Selection styles | ||
.selection { | ||
box-shadow: 0 0 0 2px var(--purple); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
context('/src/Extensions/Selection/Vue/', () => { | ||
beforeEach(() => { | ||
cy.visit('/src/Extensions/Selection/Vue/') | ||
}) | ||
|
||
it('should have class', () => { | ||
cy.get('.tiptap span:first').should('have.class', 'selection') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<editor-content :editor="editor" /> | ||
</template> | ||
|
||
<script> | ||
import Code from '@tiptap/extension-code' | ||
import Document from '@tiptap/extension-document' | ||
import { BulletList, ListItem } from '@tiptap/extension-list' | ||
import Paragraph from '@tiptap/extension-paragraph' | ||
import Text from '@tiptap/extension-text' | ||
import { Selection } from '@tiptap/extensions' | ||
import { Editor, EditorContent } from '@tiptap/vue-3' | ||
export default { | ||
components: { | ||
EditorContent, | ||
}, | ||
data() { | ||
return { | ||
editor: null, | ||
} | ||
}, | ||
mounted() { | ||
this.editor = new Editor({ | ||
extensions: [ | ||
Document, | ||
Paragraph, | ||
Text, | ||
Selection.configure({ | ||
className: 'selection', | ||
}), | ||
Code, | ||
BulletList, | ||
ListItem, | ||
], | ||
content: ` | ||
<p> | ||
The selection extension adds a class to the selection when the editor is blurred. That enables you to visually preserve the selection even though the editor is blurred. By default, it’ll add <code>.selection</code> classname. | ||
</p> | ||
`, | ||
onCreate: ({ editor }) => { | ||
editor.commands.setTextSelection({ from: 5, to: 30 }) | ||
}, | ||
}) | ||
}, | ||
beforeUnmount() { | ||
this.editor.destroy() | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
/* Basic editor styles */ | ||
.tiptap { | ||
:first-child { | ||
margin-top: 0; | ||
} | ||
/* List styles */ | ||
ul, | ||
ol { | ||
padding: 0 1rem; | ||
margin: 1.25rem 1rem 1.25rem 0.4rem; | ||
li p { | ||
margin-top: 0.25em; | ||
margin-bottom: 0.25em; | ||
} | ||
} | ||
/* Code and preformatted text styles */ | ||
code { | ||
background-color: var(--purple-light); | ||
border-radius: 0.4rem; | ||
color: var(--black); | ||
font-size: 0.85rem; | ||
padding: 0.25em 0.3em; | ||
} | ||
// Selection styles | ||
.selection { | ||
box-shadow: 0 0 0 2px var(--purple); | ||
} | ||
} | ||
</style> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import './styles.scss' | ||
|
||
import Code from '@tiptap/extension-code' | ||
import CodeBlock from '@tiptap/extension-code-block' | ||
import Document from '@tiptap/extension-document' | ||
import { BulletList, ListItem } from '@tiptap/extension-list' | ||
import Paragraph from '@tiptap/extension-paragraph' | ||
import Text from '@tiptap/extension-text' | ||
import { TrailingNode } from '@tiptap/extensions' | ||
import { EditorContent, useEditor } from '@tiptap/react' | ||
import React from 'react' | ||
|
||
export default () => { | ||
const editor = useEditor({ | ||
extensions: [Document, Paragraph, Text, TrailingNode, Code, BulletList, ListItem, CodeBlock], | ||
content: ` | ||
<p>A paragraph</p> | ||
<pre><code>There should be a paragraph right after this one, because it is a code-block</code></pre> | ||
`, | ||
}) | ||
|
||
return <EditorContent editor={editor} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
/* Basic editor styles */ | ||
.tiptap { | ||
:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
/* List styles */ | ||
ul, | ||
ol { | ||
padding: 0 1rem; | ||
margin: 1.25rem 1rem 1.25rem 0.4rem; | ||
|
||
li p { | ||
margin-top: 0.25em; | ||
margin-bottom: 0.25em; | ||
} | ||
} | ||
|
||
/* Heading styles */ | ||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6 { | ||
line-height: 1.1; | ||
margin-top: 2.5rem; | ||
text-wrap: pretty; | ||
} | ||
|
||
h1, | ||
h2 { | ||
margin-top: 3.5rem; | ||
margin-bottom: 1.5rem; | ||
} | ||
|
||
h1 { | ||
font-size: 1.4rem; | ||
} | ||
|
||
h2 { | ||
font-size: 1.2rem; | ||
} | ||
|
||
h3 { | ||
font-size: 1.1rem; | ||
} | ||
|
||
h4, | ||
h5, | ||
h6 { | ||
font-size: 1rem; | ||
} | ||
|
||
/* Code and preformatted text styles */ | ||
code { | ||
background-color: var(--purple-light); | ||
border-radius: 0.4rem; | ||
color: var(--black); | ||
font-size: 0.85rem; | ||
padding: 0.25em 0.3em; | ||
} | ||
|
||
pre { | ||
background: var(--black); | ||
border-radius: 0.5rem; | ||
color: var(--white); | ||
font-family: 'JetBrainsMono', monospace; | ||
margin: 1.5rem 0; | ||
padding: 0.75rem 1rem; | ||
|
||
code { | ||
background: none; | ||
color: inherit; | ||
font-size: 0.8rem; | ||
padding: 0; | ||
} | ||
} | ||
|
||
blockquote { | ||
border-left: 3px solid var(--gray-3); | ||
margin: 1.5rem 0; | ||
padding-left: 1rem; | ||
} | ||
|
||
hr { | ||
border: none; | ||
border-top: 1px solid var(--gray-2); | ||
margin: 2rem 0; | ||
} | ||
} |
Empty file.
Oops, something went wrong.