fix: fix a bug where paste rules doesn’t worked at the start of the document, see #1225

This commit is contained in:
Philipp Kühn
2021-10-22 09:04:09 +02:00
parent 7ffabf251c
commit ff67ee1da3
2 changed files with 5 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import { Editor } from './Editor'
import CommandManager from './CommandManager' import CommandManager from './CommandManager'
import createChainableState from './helpers/createChainableState' import createChainableState from './helpers/createChainableState'
import isRegExp from './utilities/isRegExp' import isRegExp from './utilities/isRegExp'
import isNumber from './utilities/isNumber'
import { import {
Range, Range,
ExtendedRegExpMatchArray, ExtendedRegExpMatchArray,
@@ -177,7 +178,7 @@ export function pasteRulesPlugin(props: { editor: Editor, rules: PasteRule[] }):
const from = before.content.findDiffStart(doc.content) const from = before.content.findDiffStart(doc.content)
const to = before.content.findDiffEnd(doc.content) const to = before.content.findDiffEnd(doc.content)
if (!from || !to || from === to.b) { if (!isNumber(from) || !to || from === to.b) {
return return
} }

View File

@@ -0,0 +1,3 @@
export default function isNumber(value: any): value is number {
return typeof value === 'number'
}