fix more linting errors

This commit is contained in:
Philipp Kühn
2020-09-24 00:29:05 +02:00
parent aefb4ca8e6
commit ac33eb483e
106 changed files with 310 additions and 274 deletions

View File

@@ -1,8 +1,8 @@
import { DOMParser } from 'prosemirror-model'
import { Selection, Transaction } from 'prosemirror-state'
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform'
import { Command } from '../Editor'
import elementFromString from '../utils/elementFromString'
import {ReplaceStep, ReplaceAroundStep} from "prosemirror-transform"
type InsertHTMLCommand = (value: string) => Command
@@ -15,13 +15,13 @@ declare module '../Editor' {
// TODO: move to utils
// https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466
function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number) {
let last = tr.steps.length - 1
const last = tr.steps.length - 1
if (last < startLen) return
let step = tr.steps[last]
const step = tr.steps[last]
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) return
let map = tr.mapping.maps[last]
const map = tr.mapping.maps[last]
let end = 0
map.forEach((_from, _to, _newFrom, newTo) => { if (end == 0) end = newTo })
map.forEach((_from, _to, _newFrom, newTo) => { if (end === 0) end = newTo })
tr.setSelection(Selection.near(tr.doc.resolve(end as unknown as number), bias))
}
@@ -34,4 +34,4 @@ export const insertHTML: InsertHTMLCommand = value => ({ tr, state }) => {
selectionToInsertionEnd(tr, tr.steps.length - 1, -1)
return true
}
}