mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 14:13:21 +08:00
fix ts errors
This commit is contained in:
parent
4da71ecfbb
commit
78ff453030
@ -71,7 +71,7 @@ module.exports = function (api) {
|
||||
.test(/\.tsx?$/)
|
||||
.use()
|
||||
.loader('ts-loader')
|
||||
.options({ transpileOnly: true, appendTsSuffixTo: [/\.vue$/] })
|
||||
.options({ transpileOnly: false, appendTsSuffixTo: [/\.vue$/] })
|
||||
|
||||
config.module
|
||||
.rule('jsx')
|
||||
|
@ -134,15 +134,16 @@ export class Editor extends EventEmitter {
|
||||
tr,
|
||||
}
|
||||
|
||||
const self = this
|
||||
Object.defineProperty(props, 'commands', {
|
||||
get: function() {
|
||||
return Object.fromEntries(Object
|
||||
.entries(this.commands)
|
||||
.entries(self.commands)
|
||||
.map(([name, command]) => {
|
||||
return [name, (...args) => command(...args)(props)]
|
||||
return [name, (...args: any[]) => command(...args)(props)]
|
||||
}))
|
||||
}.bind(this)
|
||||
});
|
||||
})
|
||||
|
||||
const callback = command(...args)(props)
|
||||
|
||||
@ -154,7 +155,7 @@ export class Editor extends EventEmitter {
|
||||
|
||||
public chain() {
|
||||
const { tr } = this.state
|
||||
const callbacks = []
|
||||
const callbacks: boolean[] = []
|
||||
|
||||
return new Proxy({}, {
|
||||
get: (target, name: string, proxy) => {
|
||||
@ -179,12 +180,13 @@ export class Editor extends EventEmitter {
|
||||
tr,
|
||||
}
|
||||
|
||||
const self = this
|
||||
Object.defineProperty(props, 'commands', {
|
||||
get: function() {
|
||||
return Object.fromEntries(Object
|
||||
.entries(this.commands)
|
||||
.entries(self.commands)
|
||||
.map(([name, command]) => {
|
||||
return [name, (...args) => command(...args)(props)]
|
||||
return [name, (...args: any[]) => command(...args)(props)]
|
||||
}))
|
||||
}.bind(this)
|
||||
});
|
||||
|
@ -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 }) => {
|
||||
|
@ -8,7 +8,7 @@ declare module '../Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export const removeMarks: RemoveMarksCommand = () => ({ tr, state }) => {
|
||||
export const removeMarks: RemoveMarksCommand = () => ({ tr, state, view }) => {
|
||||
const { selection } = tr
|
||||
const { from, to, empty } = selection
|
||||
|
||||
@ -19,7 +19,7 @@ export const removeMarks: RemoveMarksCommand = () => ({ tr, state }) => {
|
||||
Object
|
||||
.entries(state.schema.marks)
|
||||
.forEach(([name, mark]) => {
|
||||
tr.removeMark(from, to, mark)
|
||||
tr.removeMark(from, to, mark as any)
|
||||
})
|
||||
|
||||
return true
|
||||
|
@ -13,11 +13,7 @@ declare module '../Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export const setContent: SetContentCommand = (content = null, emitUpdate = false, parseOptions = {}) => ({ tr, editor }) => {
|
||||
if (content === null) {
|
||||
return false
|
||||
}
|
||||
|
||||
export const setContent: SetContentCommand = (content = '', emitUpdate = false, parseOptions = {}) => ({ tr, editor }) => {
|
||||
const { createDocument } = editor
|
||||
const { doc } = tr
|
||||
const document = createDocument(content, parseOptions)
|
||||
|
@ -12,7 +12,7 @@ export default new Node()
|
||||
toDOM: () => ['li', 0],
|
||||
}))
|
||||
.keys(({ editor, name }) => ({
|
||||
Enter: () => editor.splitListItem(name).focus()
|
||||
// Enter: () => editor.chain().focus().splitListItem(name).run()
|
||||
// Tab: () => editor.sinkListItem(name),
|
||||
// 'Shift-Tab': () => editor.liftListItem(name),
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user