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