Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit d5258cd

Browse files
hlomziknick-skriabinmakseq
authored
fix: DEV-1220: fix HTML misplacements (#432)
* fix: DEV-1220: draft right after HyperText loaded HyperText with regions creates new state in history, so new draft is triggered. Reinit history after deserialization. * fix: DEV-1220: labeling HyperText with emoji Text was fixed, but HyperText still has shifted offsets for regions in the text after emoji. * fix: undo/redo for annotation from prediction * fix: update regions in fresh suggestions Co-authored-by: Nick Skriabin <[email protected]> Co-authored-by: Max Tkachenko <[email protected]>
1 parent 723d4d7 commit d5258cd

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/stores/AnnotationStore.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ const Annotation = types
840840
});
841841
}
842842

843-
self.objects.forEach(obj => obj.needsUpdate?.());
843+
self.updateObjects();
844844
},
845845

846846
/**
@@ -1332,7 +1332,8 @@ export default types
13321332

13331333
selectAnnotation(c.id);
13341334
c.deserializeResults(s);
1335-
c.updateObjects();
1335+
// reinit will trigger `updateObjects()` so we omit it here
1336+
c.reinitHistory();
13361337

13371338
// parent link for the new annotations
13381339
if (entity.pk) {

src/tags/object/RichText/view.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class RichTextPieceView extends Component {
260260
// @todo both loops should be merged to fix old broken xpath using "dirty" html
261261
if (initial) {
262262
item.initGlobalOffsets(root);
263+
// lot of changes possibly made during regions preparation, so clear the history
264+
item.annotation.reinitHistory();
263265
}
264266

265267
// Apply highlight to ranges of a current tag

src/utils/selection-tools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { clamp } from "./utilities";
1+
import { clamp, isDefined } from "./utilities";
22

33
const isTextNode = node => node && node.nodeType === Node.TEXT_NODE;
44

@@ -685,7 +685,7 @@ const findGlobalOffset = (node, position, root) => {
685685
}
686686

687687
if (isText || isBR) {
688-
let length = currentNode.length ?? 1;
688+
let length = isDefined(currentNode.length) ? [...currentNode.textContent].length : 1;
689689

690690
if (atTargetNode) {
691691
length = Math.min(position, length);

0 commit comments

Comments
 (0)