Skip to content

Commit b735fd7

Browse files
authored
fix: BROS-476: Fix span resizing in edge cases (#8979) (#9015)
Co-authored-by: hlomzik <hlomzik@users.noreply.github.com>
1 parent a10fc95 commit b735fd7

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

web/libs/editor/src/tags/object/RichText/view.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { htmlEscape, matchesSelector } from "../../../utils/html";
1414
import {
1515
applyTextGranularity,
1616
fixCodePointsInRange,
17+
fixRange,
1718
rangeToGlobalOffset,
1819
trimSelection,
1920
} from "../../../utils/selection-tools";
@@ -194,7 +195,7 @@ class RichTextPieceView extends Component {
194195
if (selection.isCollapsed) return false;
195196
if (!area) return false;
196197

197-
let range = selection.getRangeAt(0);
198+
let range = fixRange(selection.getRangeAt(0));
198199

199200
// @todo would be more convenient to try to reduce the range to be within the root,
200201
// @todo so for example if we drag to the left and the range is outside of the root, we would

web/libs/editor/src/utils/selection-tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ const textNodeLookup = (commonContainer, node, offset, direction = "forward") =>
303303
* not root, not some previous element with `startOffset` on the last char.
304304
* @param {Range} range
305305
*/
306-
const fixRange = (range) => {
306+
export const fixRange = (range) => {
307307
const { endOffset, commonAncestorContainer: commonContainer } = range;
308308
let { startOffset, startContainer, endContainer } = range;
309309

0 commit comments

Comments
 (0)