Skip to content

Commit e706b29

Browse files
author
Zaydek Michels-Gualtieri
committed
Another technique we could try is to use parseInlineElements on state.nodes[state.pos1.y].data and see how deep state.pos.x is. The problem is edge cases like https:// where typing a character does not actually extend the link. This may very well be a side effect of syncPos works?
1 parent f387ddf commit e706b29

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Editor/useEditor.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,19 @@ const methods = state => ({
448448
// if (nextElement) {
449449
// nextElement.reactKey = uuidv4().slice(0, 8)
450450
// }
451-
const mustRerender = (
452-
state.pos1.x - 1 >= 0 &&
453-
ascii.isPunctuation(state.nodes[state.pos1.y].data[state.pos1.x - 1])
454-
)
451+
452+
const substr = state.nodes[state.pos1.y].data.slice(state.pos1.x - 2, state.pos1.x + 1)
453+
const mustRerender = false // substr
454+
// .split("")
455+
// .some(each => ascii.isPunctuation(each))
456+
455457
const prevElement = state.elements.find(each => each.id === id)
456458
const nextElement = nextElements.find(each => each.id === id)
457-
if (prevElement && nextElement && (mustRerender || !areEqualElements(prevElement, nextElement))) {
458-
console.log("forced a rerender key")
459+
if (prevElement && nextElement) {
460+
if (areEqualElements(prevElement, nextElement)) {
461+
// No-op
462+
return
463+
}
459464
nextElement.reactKey = uuidv4().slice(0, 8)
460465
}
461466
}

0 commit comments

Comments
 (0)