Skip to content

Commit

Permalink
fix: fix a bug where paste rules doesn’t worked at the start of the d…
Browse files Browse the repository at this point in the history
…ocument, see #1225
  • Loading branch information
philippkuehn committed Oct 22, 2021
1 parent 7ffabf2 commit ff67ee1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/PasteRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Editor } from './Editor'
import CommandManager from './CommandManager'
import createChainableState from './helpers/createChainableState'
import isRegExp from './utilities/isRegExp'
import isNumber from './utilities/isNumber'
import {
Range,
ExtendedRegExpMatchArray,
Expand Down Expand Up @@ -177,7 +178,7 @@ export function pasteRulesPlugin(props: { editor: Editor, rules: PasteRule[] }):
const from = before.content.findDiffStart(doc.content)
const to = before.content.findDiffEnd(doc.content)

if (!from || !to || from === to.b) {
if (!isNumber(from) || !to || from === to.b) {
return
}

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/utilities/isNumber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function isNumber(value: any): value is number {
return typeof value === 'number'
}

0 comments on commit ff67ee1

Please sign in to comment.