fix ts errors

This commit is contained in:
Philipp Kühn
2020-09-21 23:44:35 +02:00
parent 4da71ecfbb
commit 78ff453030
6 changed files with 19 additions and 20 deletions

View File

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