ci: fix code style linting errors

This commit is contained in:
svenadlung
2021-11-16 12:04:44 +00:00
committed by GitHub Actions
parent 60fa25c1ca
commit 761a91f0bb
2 changed files with 96 additions and 96 deletions

View File

@@ -1,10 +1,10 @@
import React from "react"; import React from 'react'
import { useEditor, EditorContent } from "@tiptap/react"; import { useEditor, EditorContent } from '@tiptap/react'
import Document from "@tiptap/extension-document"; import Document from '@tiptap/extension-document'
import Paragraph from "@tiptap/extension-paragraph"; import Paragraph from '@tiptap/extension-paragraph'
import Heading from "@tiptap/extension-heading"; import Heading from '@tiptap/extension-heading'
import Text from "@tiptap/extension-text"; import Text from '@tiptap/extension-text'
import TextAlign from "@tiptap/extension-text-align"; import TextAlign from '@tiptap/extension-text-align'
export default () => { export default () => {
const editor = useEditor({ const editor = useEditor({
@@ -14,7 +14,7 @@ export default () => {
Text, Text,
Heading, Heading,
TextAlign.configure({ TextAlign.configure({
types: ["heading", "paragraph"], types: ['heading', 'paragraph'],
}), }),
], ],
content: ` content: `
@@ -22,40 +22,40 @@ export default () => {
<p style="text-align: center">first paragraph</p> <p style="text-align: center">first paragraph</p>
<p style="text-align: right">second paragraph</p> <p style="text-align: right">second paragraph</p>
`, `,
}); })
if (!editor) { if (!editor) {
return null; return null
} }
return ( return (
<div> <div>
<button <button
onClick={() => editor.chain().focus().setTextAlign("left").run()} onClick={() => editor.chain().focus().setTextAlign('left').run()}
className={editor.isActive({ textAlign: "left" }) ? "is-active" : ""} className={editor.isActive({ textAlign: 'left' }) ? 'is-active' : ''}
> >
left left
</button> </button>
<button <button
onClick={() => editor.chain().focus().setTextAlign("center").run()} onClick={() => editor.chain().focus().setTextAlign('center').run()}
className={editor.isActive({ textAlign: "center" }) ? "is-active" : ""} className={editor.isActive({ textAlign: 'center' }) ? 'is-active' : ''}
> >
center center
</button> </button>
<button <button
onClick={() => editor.chain().focus().setTextAlign("right").run()} onClick={() => editor.chain().focus().setTextAlign('right').run()}
className={editor.isActive({ textAlign: "right" }) ? "is-active" : ""} className={editor.isActive({ textAlign: 'right' }) ? 'is-active' : ''}
> >
right right
</button> </button>
<button <button
onClick={() => editor.chain().focus().setTextAlign("justify").run()} onClick={() => editor.chain().focus().setTextAlign('justify').run()}
className={editor.isActive({ textAlign: "justify" }) ? "is-active" : ""} className={editor.isActive({ textAlign: 'justify' }) ? 'is-active' : ''}
> >
justify justify
</button> </button>
<button onClick={() => editor.chain().focus().unsetTextAlign().run()}>unsetTextAlign</button> <button onClick={() => editor.chain().focus().unsetTextAlign().run()}>unsetTextAlign</button>
<EditorContent editor={editor} /> <EditorContent editor={editor} />
</div> </div>
); )
}; }

View File

@@ -1,97 +1,97 @@
context("/src/Extensions/TextAlign/React/", () => { context('/src/Extensions/TextAlign/React/', () => {
before(() => { before(() => {
cy.visit("/src/Extensions/TextAlign/React/"); cy.visit('/src/Extensions/TextAlign/React/')
}); })
beforeEach(() => { beforeEach(() => {
cy.get(".ProseMirror").then(([{ editor }]) => { cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent("<p>Example Text</p>"); editor.commands.setContent('<p>Example Text</p>')
}); })
}); })
it("should parse left align text correctly (and not render)", () => { it('should parse left align text correctly (and not render)', () => {
cy.get(".ProseMirror").then(([{ editor }]) => { cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent('<p style="text-align: left">Example Text</p>'); editor.commands.setContent('<p style="text-align: left">Example Text</p>')
expect(editor.getHTML()).to.eq("<p>Example Text</p>"); expect(editor.getHTML()).to.eq('<p>Example Text</p>')
}); })
}); })
it("should parse center align text correctly", () => { it('should parse center align text correctly', () => {
cy.get(".ProseMirror").then(([{ editor }]) => { cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent('<p style="text-align: center">Example Text</p>'); editor.commands.setContent('<p style="text-align: center">Example Text</p>')
expect(editor.getHTML()).to.eq('<p style="text-align: center">Example Text</p>'); expect(editor.getHTML()).to.eq('<p style="text-align: center">Example Text</p>')
}); })
}); })
it("should parse right align text correctly", () => { it('should parse right align text correctly', () => {
cy.get(".ProseMirror").then(([{ editor }]) => { cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent('<p style="text-align: right">Example Text</p>'); editor.commands.setContent('<p style="text-align: right">Example Text</p>')
expect(editor.getHTML()).to.eq('<p style="text-align: right">Example Text</p>'); expect(editor.getHTML()).to.eq('<p style="text-align: right">Example Text</p>')
}); })
}); })
it("should parse left justify text correctly", () => { it('should parse left justify text correctly', () => {
cy.get(".ProseMirror").then(([{ editor }]) => { cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent('<p style="text-align: justify">Example Text</p>'); editor.commands.setContent('<p style="text-align: justify">Example Text</p>')
expect(editor.getHTML()).to.eq('<p style="text-align: justify">Example Text</p>'); expect(editor.getHTML()).to.eq('<p style="text-align: justify">Example Text</p>')
}); })
}); })
it("aligns the text left on the 1st button", () => { it('aligns the text left on the 1st button', () => {
cy.get("button:nth-child(1)").click(); cy.get('button:nth-child(1)').click()
cy.get(".ProseMirror").find("p").should("not.have.css", "text-align", "left"); cy.get('.ProseMirror').find('p').should('not.have.css', 'text-align', 'left')
}); })
it("aligns the text center on the 2nd button", () => { it('aligns the text center on the 2nd button', () => {
cy.get("button:nth-child(2)").click(); cy.get('button:nth-child(2)').click()
cy.get(".ProseMirror").find("p").should("have.css", "text-align", "center"); cy.get('.ProseMirror').find('p').should('have.css', 'text-align', 'center')
}); })
it("aligns the text right on the 3rd button", () => { it('aligns the text right on the 3rd button', () => {
cy.get("button:nth-child(3)").click(); cy.get('button:nth-child(3)').click()
cy.get(".ProseMirror").find("p").should("have.css", "text-align", "right"); cy.get('.ProseMirror').find('p').should('have.css', 'text-align', 'right')
}); })
it("aligns the text justified on the 4th button", () => { it('aligns the text justified on the 4th button', () => {
cy.get("button:nth-child(4)").click(); cy.get('button:nth-child(4)').click()
cy.get(".ProseMirror").find("p").should("have.css", "text-align", "justify"); cy.get('.ProseMirror').find('p').should('have.css', 'text-align', 'justify')
}); })
it("aligns the text default on the 5th button", () => { it('aligns the text default on the 5th button', () => {
cy.get("button:nth-child(5)").click(); cy.get('button:nth-child(5)').click()
cy.get(".ProseMirror").find("p").should("not.have.css", "text-align", "left"); cy.get('.ProseMirror').find('p').should('not.have.css', 'text-align', 'left')
}); })
it("aligns the text left when pressing the keyboard shortcut", () => { it('aligns the text left when pressing the keyboard shortcut', () => {
cy.get(".ProseMirror") cy.get('.ProseMirror')
.trigger("keydown", { modKey: true, shiftKey: true, key: "l" }) .trigger('keydown', { modKey: true, shiftKey: true, key: 'l' })
.find("p") .find('p')
.should("not.have.css", "text-align", "left"); .should('not.have.css', 'text-align', 'left')
}); })
it("aligns the text center when pressing the keyboard shortcut", () => { it('aligns the text center when pressing the keyboard shortcut', () => {
cy.get(".ProseMirror") cy.get('.ProseMirror')
.trigger("keydown", { modKey: true, shiftKey: true, key: "e" }) .trigger('keydown', { modKey: true, shiftKey: true, key: 'e' })
.find("p") .find('p')
.should("have.css", "text-align", "center"); .should('have.css', 'text-align', 'center')
}); })
it("aligns the text right when pressing the keyboard shortcut", () => { it('aligns the text right when pressing the keyboard shortcut', () => {
cy.get(".ProseMirror") cy.get('.ProseMirror')
.trigger("keydown", { modKey: true, shiftKey: true, key: "r" }) .trigger('keydown', { modKey: true, shiftKey: true, key: 'r' })
.find("p") .find('p')
.should("have.css", "text-align", "right"); .should('have.css', 'text-align', 'right')
}); })
it("aligns the text justified when pressing the keyboard shortcut", () => { it('aligns the text justified when pressing the keyboard shortcut', () => {
cy.get(".ProseMirror") cy.get('.ProseMirror')
.trigger("keydown", { modKey: true, shiftKey: true, key: "j" }) .trigger('keydown', { modKey: true, shiftKey: true, key: 'j' })
.find("p") .find('p')
.should("have.css", "text-align", "justify"); .should('have.css', 'text-align', 'justify')
}); })
}); })