mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-08 01:53:04 +08:00
ci: fix code style linting errors
This commit is contained in:
parent
de39853026
commit
b4ab7f079b
@ -263,6 +263,7 @@ export class Editor extends EventEmitter<EditorEvents> {
|
|||||||
private createView(): void {
|
private createView(): void {
|
||||||
const doc = createDocument(this.options.content, this.schema, this.options.parseOptions)
|
const doc = createDocument(this.options.content, this.schema, this.options.parseOptions)
|
||||||
const selection = resolveFocusPosition(doc, this.options.autofocus)
|
const selection = resolveFocusPosition(doc, this.options.autofocus)
|
||||||
|
|
||||||
this.view = new EditorView(this.options.element, {
|
this.view = new EditorView(this.options.element, {
|
||||||
...this.options.editorProps,
|
...this.options.editorProps,
|
||||||
dispatchTransaction: this.dispatchTransaction.bind(this),
|
dispatchTransaction: this.dispatchTransaction.bind(this),
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
import { Node as ProseMirrorNode } from 'prosemirror-model'
|
import { Node as ProseMirrorNode } from 'prosemirror-model'
|
||||||
import { Selection, TextSelection } from 'prosemirror-state'
|
import { Selection, TextSelection } from 'prosemirror-state'
|
||||||
import { FocusPosition } from '../types'
|
import { FocusPosition } from '../types'
|
||||||
import minMax from '../utilities/minMax'
|
import minMax from '../utilities/minMax'
|
||||||
|
|
||||||
export default function resolveFocusPosition(
|
export default function resolveFocusPosition(
|
||||||
doc: ProseMirrorNode,
|
doc: ProseMirrorNode,
|
||||||
position: FocusPosition = null
|
position: FocusPosition = null,
|
||||||
): Selection | null {
|
): Selection | null {
|
||||||
|
|
||||||
if (!position) return null
|
if (!position) { return null }
|
||||||
if (position === 'start' || position === true) return Selection.atStart(doc)
|
if (position === 'start' || position === true) { return Selection.atStart(doc) }
|
||||||
if (position === 'end') return Selection.atEnd(doc)
|
if (position === 'end') { return Selection.atEnd(doc) }
|
||||||
if (position === 'all') return TextSelection.create(doc, 0, doc.content.size)
|
if (position === 'all') { return TextSelection.create(doc, 0, doc.content.size) }
|
||||||
|
|
||||||
// Check if `position` is in bounds of the doc if `position` is a number.
|
// Check if `position` is in bounds of the doc if `position` is a number.
|
||||||
const minPos = Selection.atStart(doc).from
|
const minPos = Selection.atStart(doc).from
|
||||||
const maxPos = Selection.atEnd(doc).to
|
const maxPos = Selection.atEnd(doc).to
|
||||||
const resolvedFrom = minMax(position, minPos, maxPos)
|
const resolvedFrom = minMax(position, minPos, maxPos)
|
||||||
const resolvedEnd = minMax(position, minPos, maxPos)
|
const resolvedEnd = minMax(position, minPos, maxPos)
|
||||||
return TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
|
||||||
}
|
return TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user