mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 11:45:15 +08:00
add newline-after-var rule to eslint config
This commit is contained in:
parent
6360278660
commit
40a9404c94
@ -36,6 +36,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
curly: ['error', 'all'],
|
curly: ['error', 'all'],
|
||||||
|
'newline-after-var': ['error', 'always'],
|
||||||
'no-continue': 'off',
|
'no-continue': 'off',
|
||||||
'no-alert': 'off',
|
'no-alert': 'off',
|
||||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||||
|
@ -230,7 +230,10 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
// TODO: load language from url params
|
// 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)
|
this.setTab(intitialTab, false)
|
||||||
|
|
||||||
window.document.addEventListener('editor', this.onEditor, false)
|
window.document.addEventListener('editor', this.onEditor, false)
|
||||||
|
@ -66,6 +66,7 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
const ydoc = new Y.Doc()
|
const ydoc = new Y.Doc()
|
||||||
|
|
||||||
this.provider = new HocuspocusProvider({
|
this.provider = new HocuspocusProvider({
|
||||||
url: 'wss://connect.hocuspocus.cloud',
|
url: 'wss://connect.hocuspocus.cloud',
|
||||||
parameters: {
|
parameters: {
|
||||||
|
@ -58,13 +58,16 @@ export default Node.create<DetailsOptions>({
|
|||||||
addNodeView() {
|
addNodeView() {
|
||||||
return ({ HTMLAttributes }) => {
|
return ({ HTMLAttributes }) => {
|
||||||
const item = document.createElement('div')
|
const item = document.createElement('div')
|
||||||
|
|
||||||
item.setAttribute('data-type', 'details')
|
item.setAttribute('data-type', 'details')
|
||||||
|
|
||||||
const toggle = document.createElement('div')
|
const toggle = document.createElement('div')
|
||||||
|
|
||||||
toggle.setAttribute('data-type', 'detailsToggle')
|
toggle.setAttribute('data-type', 'detailsToggle')
|
||||||
item.append(toggle)
|
item.append(toggle)
|
||||||
|
|
||||||
const content = document.createElement('div')
|
const content = document.createElement('div')
|
||||||
|
|
||||||
content.setAttribute('data-type', 'detailsContent')
|
content.setAttribute('data-type', 'detailsContent')
|
||||||
item.append(content)
|
item.append(content)
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ export default Extension.create({
|
|||||||
e.dataTransfer.setData('text/plain', text)
|
e.dataTransfer.setData('text/plain', text)
|
||||||
|
|
||||||
const el = document.querySelector('.ProseMirror-selectednode')
|
const el = document.querySelector('.ProseMirror-selectednode')
|
||||||
e.dataTransfer?.setDragImage(el, 0, 0)
|
|
||||||
|
|
||||||
|
e.dataTransfer?.setDragImage(el, 0, 0)
|
||||||
view.dragging = { slice, move: true }
|
view.dragging = { slice, move: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ export const Linter = Extension.create<LinterOptions>({
|
|||||||
},
|
},
|
||||||
handleClick(view, _, event) {
|
handleClick(view, _, event) {
|
||||||
const target = (event.target as IconDivElement)
|
const target = (event.target as IconDivElement)
|
||||||
|
|
||||||
if (/lint-icon/.test(target.className) && target.issue) {
|
if (/lint-icon/.test(target.className) && target.issue) {
|
||||||
const { from, to } = target.issue
|
const { from, to } = target.issue
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ export const Linter = Extension.create<LinterOptions>({
|
|||||||
},
|
},
|
||||||
handleDoubleClick(view, _, event) {
|
handleDoubleClick(view, _, event) {
|
||||||
const target = (event.target as IconDivElement)
|
const target = (event.target as IconDivElement)
|
||||||
|
|
||||||
if (/lint-icon/.test((event.target as HTMLElement).className) && target.issue) {
|
if (/lint-icon/.test((event.target as HTMLElement).className) && target.issue) {
|
||||||
const prob = target.issue
|
const prob = target.issue
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
|
|||||||
state: {
|
state: {
|
||||||
init: (_, state) => {
|
init: (_, state) => {
|
||||||
const lastNode = state.tr.doc.lastChild
|
const lastNode = state.tr.doc.lastChild
|
||||||
|
|
||||||
return !nodeEqualsType({ node: lastNode, types: disabledNodes })
|
return !nodeEqualsType({ node: lastNode, types: disabledNodes })
|
||||||
},
|
},
|
||||||
apply: (tr, value) => {
|
apply: (tr, value) => {
|
||||||
@ -61,6 +62,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const lastNode = tr.doc.lastChild
|
const lastNode = tr.doc.lastChild
|
||||||
|
|
||||||
return !nodeEqualsType({ node: lastNode, types: disabledNodes })
|
return !nodeEqualsType({ node: lastNode, types: disabledNodes })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -26,6 +26,7 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
const ydoc = new Y.Doc()
|
const ydoc = new Y.Doc()
|
||||||
|
|
||||||
this.provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
|
this.provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
|
||||||
|
|
||||||
this.editor = new Editor({
|
this.editor = new Editor({
|
||||||
|
@ -27,6 +27,7 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
const ydoc = new Y.Doc()
|
const ydoc = new Y.Doc()
|
||||||
|
|
||||||
this.provider = new WebrtcProvider('tiptap-collaboration-cursor-extension', ydoc)
|
this.provider = new WebrtcProvider('tiptap-collaboration-cursor-extension', ydoc)
|
||||||
|
|
||||||
this.editor = new Editor({
|
this.editor = new Editor({
|
||||||
|
@ -45,16 +45,20 @@ export default Node.create({
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const dom = document.createElement('div')
|
const dom = document.createElement('div')
|
||||||
|
|
||||||
dom.classList.add('node-view')
|
dom.classList.add('node-view')
|
||||||
|
|
||||||
const label = document.createElement('span')
|
const label = document.createElement('span')
|
||||||
|
|
||||||
label.classList.add('label')
|
label.classList.add('label')
|
||||||
label.innerHTML = 'Node view'
|
label.innerHTML = 'Node view'
|
||||||
|
|
||||||
const content = document.createElement('div')
|
const content = document.createElement('div')
|
||||||
|
|
||||||
content.classList.add('content')
|
content.classList.add('content')
|
||||||
|
|
||||||
const button = document.createElement('button')
|
const button = document.createElement('button')
|
||||||
|
|
||||||
button.innerHTML = `This button has been clicked ${node.attrs.count} times.`
|
button.innerHTML = `This button has been clicked ${node.attrs.count} times.`
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
if (typeof getPos === 'function') {
|
if (typeof getPos === 'function') {
|
||||||
|
@ -31,14 +31,17 @@ export default Node.create({
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const dom = document.createElement('div')
|
const dom = document.createElement('div')
|
||||||
|
|
||||||
dom.classList.add('node-view')
|
dom.classList.add('node-view')
|
||||||
|
|
||||||
const label = document.createElement('span')
|
const label = document.createElement('span')
|
||||||
|
|
||||||
label.classList.add('label')
|
label.classList.add('label')
|
||||||
label.innerHTML = 'Node view'
|
label.innerHTML = 'Node view'
|
||||||
label.contentEditable = false
|
label.contentEditable = false
|
||||||
|
|
||||||
const content = document.createElement('div')
|
const content = document.createElement('div')
|
||||||
|
|
||||||
content.classList.add('content')
|
content.classList.add('content')
|
||||||
|
|
||||||
dom.append(label, content)
|
dom.append(label, content)
|
||||||
|
@ -61,6 +61,7 @@ context('/src/Nodes/Table/React/', () => {
|
|||||||
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false })
|
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false })
|
||||||
|
|
||||||
const html = editor.getHTML()
|
const html = editor.getHTML()
|
||||||
|
|
||||||
expect(html).to.equal(
|
expect(html).to.equal(
|
||||||
'<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>',
|
'<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 })
|
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: true })
|
||||||
|
|
||||||
const html = editor.getHTML()
|
const html = editor.getHTML()
|
||||||
|
|
||||||
expect(html).to.equal(
|
expect(html).to.equal(
|
||||||
'<table><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>',
|
'<table><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>',
|
||||||
)
|
)
|
||||||
|
@ -61,6 +61,7 @@ context('/src/Nodes/Table/Vue/', () => {
|
|||||||
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false })
|
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false })
|
||||||
|
|
||||||
const html = editor.getHTML()
|
const html = editor.getHTML()
|
||||||
|
|
||||||
expect(html).to.equal('<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>')
|
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 })
|
editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: true })
|
||||||
|
|
||||||
const html = editor.getHTML()
|
const html = editor.getHTML()
|
||||||
|
|
||||||
expect(html).to.equal('<table><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>')
|
expect(html).to.equal('<table><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -281,6 +281,7 @@ export class Editor extends EventEmitter<EditorEvents> {
|
|||||||
// Let’s store the editor instance in the DOM element.
|
// Let’s store the editor instance in the DOM element.
|
||||||
// So we’ll have access to it for tests.
|
// So we’ll have access to it for tests.
|
||||||
const dom = this.view.dom as HTMLElement
|
const dom = this.view.dom as HTMLElement
|
||||||
|
|
||||||
dom.editor = this
|
dom.editor = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ export const undoInputRule: RawCommands['undoInputRule'] = () => ({ state, dispa
|
|||||||
|
|
||||||
if (undoable.text) {
|
if (undoable.text) {
|
||||||
const marks = tr.doc.resolve(undoable.from).marks()
|
const marks = tr.doc.resolve(undoable.from).marks()
|
||||||
|
|
||||||
tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks))
|
tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks))
|
||||||
} else {
|
} else {
|
||||||
tr.delete(undoable.from, undoable.to)
|
tr.delete(undoable.from, undoable.to)
|
||||||
|
@ -7,6 +7,7 @@ export default function getHTMLFromFragment(fragment: Fragment, schema: Schema):
|
|||||||
|
|
||||||
const temporaryDocument = document.implementation.createHTMLDocument()
|
const temporaryDocument = document.implementation.createHTMLDocument()
|
||||||
const container = temporaryDocument.createElement('div')
|
const container = temporaryDocument.createElement('div')
|
||||||
|
|
||||||
container.appendChild(documentFragment)
|
container.appendChild(documentFragment)
|
||||||
|
|
||||||
return container.innerHTML
|
return container.innerHTML
|
||||||
|
@ -37,6 +37,7 @@ export default function nodeInputRule(config: {
|
|||||||
|
|
||||||
// insert last typed character
|
// insert last typed character
|
||||||
const lastChar = match[0][match[0].length - 1]
|
const lastChar = match[0][match[0].length - 1]
|
||||||
|
|
||||||
tr.insertText(lastChar, start + match[0].length - 1)
|
tr.insertText(lastChar, start + match[0].length - 1)
|
||||||
|
|
||||||
// insert node from input rule
|
// insert node from input rule
|
||||||
|
@ -55,10 +55,12 @@ export const CollaborationCursor = Extension.create<CollaborationCursorOptions,
|
|||||||
},
|
},
|
||||||
render: user => {
|
render: user => {
|
||||||
const cursor = document.createElement('span')
|
const cursor = document.createElement('span')
|
||||||
|
|
||||||
cursor.classList.add('collaboration-cursor__caret')
|
cursor.classList.add('collaboration-cursor__caret')
|
||||||
cursor.setAttribute('style', `border-color: ${user.color}`)
|
cursor.setAttribute('style', `border-color: ${user.color}`)
|
||||||
|
|
||||||
const label = document.createElement('div')
|
const label = document.createElement('div')
|
||||||
|
|
||||||
label.classList.add('collaboration-cursor__label')
|
label.classList.add('collaboration-cursor__label')
|
||||||
label.setAttribute('style', `background-color: ${user.color}`)
|
label.setAttribute('style', `background-color: ${user.color}`)
|
||||||
label.insertBefore(document.createTextNode(user.name), null)
|
label.insertBefore(document.createTextNode(user.name), null)
|
||||||
|
@ -14,6 +14,7 @@ export function updateColumns(node: ProseMirrorNode, colgroup: Element, table: E
|
|||||||
for (let j = 0; j < colspan; j += 1, col += 1) {
|
for (let j = 0; j < colspan; j += 1, col += 1) {
|
||||||
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j]
|
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j]
|
||||||
const cssWidth = hasWidth ? `${hasWidth}px` : ''
|
const cssWidth = hasWidth ? `${hasWidth}px` : ''
|
||||||
|
|
||||||
totalWidth += hasWidth || cellMinWidth
|
totalWidth += hasWidth || cellMinWidth
|
||||||
|
|
||||||
if (!hasWidth) {
|
if (!hasWidth) {
|
||||||
@ -34,6 +35,7 @@ export function updateColumns(node: ProseMirrorNode, colgroup: Element, table: E
|
|||||||
|
|
||||||
while (nextDOM) {
|
while (nextDOM) {
|
||||||
const after = nextDOM.nextSibling
|
const after = nextDOM.nextSibling
|
||||||
|
|
||||||
nextDOM.parentNode.removeChild(nextDOM)
|
nextDOM.parentNode.removeChild(nextDOM)
|
||||||
nextDOM = after
|
nextDOM = after
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
|
|||||||
}
|
}
|
||||||
|
|
||||||
let as = this.node.isInline ? 'span' : 'div'
|
let as = this.node.isInline ? 'span' : 'div'
|
||||||
|
|
||||||
if (this.options.as) {
|
if (this.options.as) {
|
||||||
as = this.options.as
|
as = this.options.as
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ export class VueRenderer {
|
|||||||
|
|
||||||
// prevents `Avoid mutating a prop directly` error message
|
// prevents `Avoid mutating a prop directly` error message
|
||||||
const originalSilent = Vue.config.silent
|
const originalSilent = Vue.config.silent
|
||||||
|
|
||||||
Vue.config.silent = true
|
Vue.config.silent = true
|
||||||
|
|
||||||
Object
|
Object
|
||||||
|
@ -16,6 +16,7 @@ describe('code block highlight', () => {
|
|||||||
|
|
||||||
const createEditorEl = () => {
|
const createEditorEl = () => {
|
||||||
const editorEl = document.createElement('div')
|
const editorEl = document.createElement('div')
|
||||||
|
|
||||||
editorEl.classList.add(editorElClass)
|
editorEl.classList.add(editorElClass)
|
||||||
|
|
||||||
document.body.appendChild(editorEl)
|
document.body.appendChild(editorEl)
|
||||||
|
@ -79,6 +79,7 @@ Cypress.Commands.add(
|
|||||||
const data = pasteType === 'application/json' ? JSON.stringify(pastePayload) : pastePayload
|
const data = pasteType === 'application/json' ? JSON.stringify(pastePayload) : pastePayload
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
|
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
|
||||||
const clipboardData = new DataTransfer()
|
const clipboardData = new DataTransfer()
|
||||||
|
|
||||||
clipboardData.setData(pasteType, data)
|
clipboardData.setData(pasteType, data)
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
|
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
|
||||||
const pasteEvent = new ClipboardEvent('paste', {
|
const pasteEvent = new ClipboardEvent('paste', {
|
||||||
@ -88,6 +89,7 @@ Cypress.Commands.add(
|
|||||||
data,
|
data,
|
||||||
clipboardData,
|
clipboardData,
|
||||||
})
|
})
|
||||||
|
|
||||||
subject[0].dispatchEvent(pasteEvent)
|
subject[0].dispatchEvent(pasteEvent)
|
||||||
|
|
||||||
return subject
|
return subject
|
||||||
|
Loading…
Reference in New Issue
Block a user