Vanessa 2022-07-09 16:47:02 +08:00
parent f788aa96e2
commit 3ae4585c0c

View file

@ -285,7 +285,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (selectElements.length > 0) {
event.stopPropagation();
event.preventDefault();
}
} else {
const start = getSelectionOffset(nodeElement, editorElement, range).start;
if (start !== 0) {
const editElement = getContenteditableElement(nodeElement);
@ -299,6 +299,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
}
}
range.collapse(true);
hideElements(["toolbar"], protyle);
if (selectElements.length === 0) {
@ -332,7 +333,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (selectElements.length > 0) {
event.stopPropagation();
event.preventDefault();
}
} else {
const editElement = getContenteditableElement(nodeElement);
const end = getSelectionOffset(nodeElement, editorElement, range).end;
if (end < editElement.textContent.length) {
@ -345,6 +346,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
}
}
range.collapse(false);
hideElements(["toolbar"], protyle);
const selectLastElement = selectElements[selectElements.length - 1];
@ -985,6 +987,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
item.classList.remove("protyle-wysiwyg--select");
});
range.collapse(false);
nodeElement.classList.add("protyle-wysiwyg--select");
countBlockWord([nodeElement.getAttribute("data-node-id")]);
}