mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-01 18:30:16 +01:00
This commit is contained in:
parent
1b2a6b8d69
commit
0df92e59fa
2 changed files with 15 additions and 4 deletions
|
|
@ -125,6 +125,17 @@ export const selectAll = (protyle: IProtyle, nodeElement: Element, range: Range)
|
|||
countBlockWord(ids, protyle.block.rootID);
|
||||
};
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/8196
|
||||
export const getRangeByPoint = (x: number, y: number) => {
|
||||
const range = document.caretRangeFromPoint(x, y);
|
||||
const imgElement = hasClosestByAttribute(range.startContainer, "data-type", "img")
|
||||
if (imgElement) {
|
||||
range.setStart(imgElement.nextSibling, 0);
|
||||
range.collapse();
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
export const getEditorRange = (element: Element) => {
|
||||
let range: Range;
|
||||
if (getSelection().rangeCount > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue