fix: fix a bug where paste rules doesn’t worked at the start of the document, see #1225
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
packages/core/src/utilities/isNumber.ts
Normal file
3
packages/core/src/utilities/isNumber.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function isNumber(value: any): value is number {
|
||||||
|
return typeof value === 'number'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user