add newline-after-var rule to eslint config

This commit is contained in:
Philipp Kühn 2021-12-03 00:03:39 +01:00
parent 6360278660
commit 40a9404c94
23 changed files with 40 additions and 2 deletions

View File

@ -36,6 +36,7 @@ module.exports = {
],
rules: {
curly: ['error', 'all'],
'newline-after-var': ['error', 'always'],
'no-continue': 'off',
'no-alert': 'off',
'no-console': ['warn', { allow: ['warn', 'error'] }],

View File

@ -230,7 +230,10 @@ export default {
mounted() {
// TODO: load language from url params
const intitialTab = localStorage.tab && this.tabs.some(tab => tab.name === localStorage.tab) ? localStorage.tab : this.sortedTabs[0]?.name
const intitialTab = localStorage.tab && this.tabs.some(tab => tab.name === localStorage.tab)
? localStorage.tab
: this.sortedTabs[0]?.name
this.setTab(intitialTab, false)
window.document.addEventListener('editor', this.onEditor, false)

View File

@ -66,6 +66,7 @@ export default {
mounted() {
const ydoc = new Y.Doc()
this.provider = new HocuspocusProvider({
url: 'wss://connect.hocuspocus.cloud',
parameters: {

View File

@ -58,13 +58,16 @@ export default Node.create<DetailsOptions>({
addNodeView() {
return ({ HTMLAttributes }) => {
const item = document.createElement('div')
item.setAttribute('data-type', 'details')
const toggle = document.createElement('div')
toggle.setAttribute('data-type', 'detailsToggle')
item.append(toggle)
const content = document.createElement('div')
content.setAttribute('data-type', 'detailsContent')
item.append(content)

View File

@ -68,8 +68,8 @@ export default Extension.create({
e.dataTransfer.setData('text/plain', text)
const el = document.querySelector('.ProseMirror-selectednode')
e.dataTransfer?.setDragImage(el, 0, 0)
e.dataTransfer?.setDragImage(el, 0, 0)
view.dragging = { slice, move: true }
}
}

View File

@ -70,6 +70,7 @@ export const Linter = Extension.create<LinterOptions>({
},
handleClick(view, _, event) {
const target = (event.target as IconDivElement)
if (/lint-icon/.test(target.className) && target.issue) {
const { from, to } = target.issue
@ -86,6 +87,7 @@ export const Linter = Extension.create<LinterOptions>({
},
handleDoubleClick(view, _, event) {
const target = (event.target as IconDivElement)
if (/lint-icon/.test((event.target as HTMLElement).className) && target.issue) {
const prob = target.issue

View File

@ -53,6 +53,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
state: {
init: (_, state) => {
const lastNode = state.tr.doc.lastChild
return !nodeEqualsType({ node: lastNode, types: disabledNodes })
},
apply: (tr, value) => {
@ -61,6 +62,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
}
const lastNode = tr.doc.lastChild
return !nodeEqualsType({ node: lastNode, types: disabledNodes })
},
},

View File

@ -26,6 +26,7 @@ export default {
mounted() {
const ydoc = new Y.Doc()
this.provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
this.editor = new Editor({

View File

@ -27,6 +27,7 @@ export default {
mounted() {
const ydoc = new Y.Doc()
this.provider = new WebrtcProvider('tiptap-collaboration-cursor-extension', ydoc)
this.editor = new Editor({

View File

@ -45,16 +45,20 @@ export default Node.create({
*/
const dom = document.createElement('div')
dom.classList.add('node-view')
const label = document.createElement('span')
label.classList.add('label')
label.innerHTML = 'Node view'
const content = document.createElement('div')
content.classList.add('content')
const button = document.createElement('button')
button.innerHTML = `This button has been clicked ${node.attrs.count} times.`
button.addEventListener('click', () => {
if (typeof getPos === 'function') {

View File

@ -31,14 +31,17 @@ export default Node.create({
*/
const dom = document.createElement('div')
dom.classList.add('node-view')
const label = document.createElement('span')
label.classList.add('label')
label.innerHTML = 'Node view'
label.contentEditable = false
const content = document.createElement('div')
content.classList.add('content')
dom.append(label, content)

View File

@ -61,6 +61,7 @@ context('/src/Nodes/Table/React/', () => {
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false })
const html = editor.getHTML()
expect(html).to.equal(
'<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>',
)
@ -72,6 +73,7 @@ context('/src/Nodes/Table/React/', () => {
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: true })
const html = editor.getHTML()
expect(html).to.equal(
'<table><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>',
)

View File

@ -61,6 +61,7 @@ context('/src/Nodes/Table/Vue/', () => {
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false })
const html = editor.getHTML()
expect(html).to.equal('<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>')
})
})
@ -70,6 +71,7 @@ context('/src/Nodes/Table/Vue/', () => {
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: true })
const html = editor.getHTML()
expect(html).to.equal('<table><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>')
})
})

View File

@ -281,6 +281,7 @@ export class Editor extends EventEmitter<EditorEvents> {
// Lets store the editor instance in the DOM element.
// So well have access to it for tests.
const dom = this.view.dom as HTMLElement
dom.editor = this
}

View File

@ -31,6 +31,7 @@ export const undoInputRule: RawCommands['undoInputRule'] = () => ({ state, dispa
if (undoable.text) {
const marks = tr.doc.resolve(undoable.from).marks()
tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks))
} else {
tr.delete(undoable.from, undoable.to)

View File

@ -7,6 +7,7 @@ export default function getHTMLFromFragment(fragment: Fragment, schema: Schema):
const temporaryDocument = document.implementation.createHTMLDocument()
const container = temporaryDocument.createElement('div')
container.appendChild(documentFragment)
return container.innerHTML

View File

@ -37,6 +37,7 @@ export default function nodeInputRule(config: {
// insert last typed character
const lastChar = match[0][match[0].length - 1]
tr.insertText(lastChar, start + match[0].length - 1)
// insert node from input rule

View File

@ -55,10 +55,12 @@ export const CollaborationCursor = Extension.create<CollaborationCursorOptions,
},
render: user => {
const cursor = document.createElement('span')
cursor.classList.add('collaboration-cursor__caret')
cursor.setAttribute('style', `border-color: ${user.color}`)
const label = document.createElement('div')
label.classList.add('collaboration-cursor__label')
label.setAttribute('style', `background-color: ${user.color}`)
label.insertBefore(document.createTextNode(user.name), null)

View File

@ -14,6 +14,7 @@ export function updateColumns(node: ProseMirrorNode, colgroup: Element, table: E
for (let j = 0; j < colspan; j += 1, col += 1) {
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j]
const cssWidth = hasWidth ? `${hasWidth}px` : ''
totalWidth += hasWidth || cellMinWidth
if (!hasWidth) {
@ -34,6 +35,7 @@ export function updateColumns(node: ProseMirrorNode, colgroup: Element, table: E
while (nextDOM) {
const after = nextDOM.nextSibling
nextDOM.parentNode.removeChild(nextDOM)
nextDOM = after
}

View File

@ -83,6 +83,7 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
}
let as = this.node.isInline ? 'span' : 'div'
if (this.options.as) {
as = this.options.as
}

View File

@ -21,6 +21,7 @@ export class VueRenderer {
// prevents `Avoid mutating a prop directly` error message
const originalSilent = Vue.config.silent
Vue.config.silent = true
Object

View File

@ -16,6 +16,7 @@ describe('code block highlight', () => {
const createEditorEl = () => {
const editorEl = document.createElement('div')
editorEl.classList.add(editorElClass)
document.body.appendChild(editorEl)

View File

@ -79,6 +79,7 @@ Cypress.Commands.add(
const data = pasteType === 'application/json' ? JSON.stringify(pastePayload) : pastePayload
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
const clipboardData = new DataTransfer()
clipboardData.setData(pasteType, data)
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
const pasteEvent = new ClipboardEvent('paste', {
@ -88,6 +89,7 @@ Cypress.Commands.add(
data,
clipboardData,
})
subject[0].dispatchEvent(pasteEvent)
return subject