@seafile/sdoc-editor 0.4.19 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -115,7 +115,8 @@ const generateRangeWhenWrapLine = (editor, path, index, count, domRange, baseHei
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
const subRange = ReactEditor.toDOMRange(editor, subSplitRange);
|
|
118
|
-
|
|
118
|
+
const subRangeHeight = Math.round(subRange.getBoundingClientRect().height);
|
|
119
|
+
if (subRangeHeight === baseHeight) {
|
|
119
120
|
isOverrideForwardRange && subHighlightInfos.pop();
|
|
120
121
|
if (!isOverrideForwardRange) isOverrideForwardRange = true;
|
|
121
122
|
subHighlightInfos.push({
|
|
@@ -167,7 +168,9 @@ const getBaseHeight = (editor, range) => {
|
|
|
167
168
|
offset: 1
|
|
168
169
|
}
|
|
169
170
|
};
|
|
170
|
-
|
|
171
|
+
const letterHeight = ReactEditor.toDOMRange(editor, subRange).getBoundingClientRect().height;
|
|
172
|
+
const baseHeight = Math.round(letterHeight);
|
|
173
|
+
return baseHeight;
|
|
171
174
|
};
|
|
172
175
|
export const getHighlightInfos = (editor, keyword) => {
|
|
173
176
|
if (keyword === '') return [];
|
|
@@ -177,7 +180,9 @@ export const getHighlightInfos = (editor, keyword) => {
|
|
|
177
180
|
const rangeInfo = domRange.getBoundingClientRect();
|
|
178
181
|
const baseHeight = getBaseHeight(editor, range);
|
|
179
182
|
// highlight word wrap line, assume line height is more then letter height
|
|
180
|
-
|
|
183
|
+
// Windows systems may have precision issues. truncate decimal to avoid this problem
|
|
184
|
+
const currentRangeHeight = Math.round(rangeInfo.height);
|
|
185
|
+
if (currentRangeHeight > baseHeight) return generateRangeWhenWrapLine(editor, range.anchor.path, range.anchor.offset, keyword.length, domRange, baseHeight);
|
|
181
186
|
return [{
|
|
182
187
|
rangeInfo,
|
|
183
188
|
domRange
|
|
@@ -38,7 +38,7 @@ const SearchReplaceMenu = _ref => {
|
|
|
38
38
|
clientHeight
|
|
39
39
|
};
|
|
40
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
}, [isOpenPopover]);
|
|
41
|
+
}, [isOpenPopover, editor.children]);
|
|
42
42
|
const renderCanvasses = useMemo(() => {
|
|
43
43
|
if (!isOpenPopover) return false;
|
|
44
44
|
const generateCount = Math.ceil(articleContainerSize.offsetHeight / 5000);
|