mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-11 06:30:57 +08:00
⚡ 划选结束后再统计字数
This commit is contained in:
parent
721676d07a
commit
548f55e608
@ -823,7 +823,6 @@ export class WYSIWYG {
|
|||||||
mouseElement = newMouseElement;
|
mouseElement = newMouseElement;
|
||||||
}
|
}
|
||||||
hideElements(["select"], protyle);
|
hideElements(["select"], protyle);
|
||||||
countBlockWord([]);
|
|
||||||
let firstElement = document.elementFromPoint(newLeft - 1, newTop);
|
let firstElement = document.elementFromPoint(newLeft - 1, newTop);
|
||||||
if (!firstElement) {
|
if (!firstElement) {
|
||||||
return;
|
return;
|
||||||
@ -886,14 +885,11 @@ export class WYSIWYG {
|
|||||||
// 只有一个 p 时不选中
|
// 只有一个 p 时不选中
|
||||||
protyle.selectElement.style.backgroundColor = "transparent";
|
protyle.selectElement.style.backgroundColor = "transparent";
|
||||||
} else {
|
} else {
|
||||||
const ids: string[] = [];
|
|
||||||
selectElements.forEach(item => {
|
selectElements.forEach(item => {
|
||||||
if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) {
|
if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) {
|
||||||
item.classList.add("protyle-wysiwyg--select");
|
item.classList.add("protyle-wysiwyg--select");
|
||||||
ids.push(item.getAttribute("data-node-id"));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
countBlockWord(ids);
|
|
||||||
protyle.selectElement.style.backgroundColor = "";
|
protyle.selectElement.style.backgroundColor = "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1125,6 +1121,13 @@ export class WYSIWYG {
|
|||||||
setPosition(window.siyuan.menus.menu.element, mouseUpEvent.clientX - 16, mouseUpEvent.clientY - 46);
|
setPosition(window.siyuan.menus.menu.element, mouseUpEvent.clientX - 16, mouseUpEvent.clientY - 46);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ids: string[] = [];
|
||||||
|
const selectElement = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")
|
||||||
|
selectElement.forEach(item => {
|
||||||
|
ids.push(item.getAttribute("data-node-id"));
|
||||||
|
});
|
||||||
|
countBlockWord(ids);
|
||||||
// 划选后不能存在跨块的 range https://github.com/siyuan-note/siyuan/issues/4473
|
// 划选后不能存在跨块的 range https://github.com/siyuan-note/siyuan/issues/4473
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
const range = getSelection().getRangeAt(0);
|
const range = getSelection().getRangeAt(0);
|
||||||
@ -1133,7 +1136,7 @@ export class WYSIWYG {
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
|
if (selectElement.length > 0) {
|
||||||
range.collapse(true);
|
range.collapse(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,7 @@ export const globalShortcut = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("keyup", (event) => {
|
window.addEventListener("keyup", (event) => {
|
||||||
|
console.log(event)
|
||||||
window.siyuan.ctrlIsPressed = false;
|
window.siyuan.ctrlIsPressed = false;
|
||||||
window.siyuan.shiftIsPressed = false;
|
window.siyuan.shiftIsPressed = false;
|
||||||
window.siyuan.altIsPressed = false;
|
window.siyuan.altIsPressed = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user