mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-12 04:33:34 +08:00
fix: fix mappes positions for paste rules, fix #2002
This commit is contained in:
parent
ed00dbbe56
commit
770c4e18e1
@ -104,7 +104,7 @@ function run(config: {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = resolvedFrom + match.index
|
const start = resolvedFrom + match.index + 1
|
||||||
const end = start + match[0].length
|
const end = start + match[0].length
|
||||||
const range = {
|
const range = {
|
||||||
from: state.tr.mapping.map(start),
|
from: state.tr.mapping.map(start),
|
||||||
@ -118,7 +118,7 @@ function run(config: {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}, from)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,7 +141,7 @@ export function pasteRulesPlugin(rules: PasteRule[]): Plugin {
|
|||||||
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) {
|
if (!from || !to || from === to.b) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ export function pasteRulesPlugin(rules: PasteRule[]): Plugin {
|
|||||||
|
|
||||||
run({
|
run({
|
||||||
state: chainableState,
|
state: chainableState,
|
||||||
from,
|
from: Math.max(from - 1, 0),
|
||||||
to: to.b,
|
to: to.b,
|
||||||
rules,
|
rules,
|
||||||
plugin,
|
plugin,
|
||||||
|
Loading…
Reference in New Issue
Block a user