mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-07 09:18:49 +01:00
This commit is contained in:
parent
0ebafadd43
commit
74a9ef4b51
2 changed files with 18 additions and 8 deletions
|
|
@ -437,7 +437,7 @@ export class Toolbar {
|
|||
} else if (type === "sup" && types.includes("sub")) {
|
||||
types.find((item, index) => {
|
||||
if (item === "sub") {
|
||||
types.splice(index, 1)
|
||||
types.splice(index, 1);
|
||||
if (!this.element.classList.contains("fn__none")) {
|
||||
this.element.querySelector(`[data-type="sub"]`).classList.remove("protyle-toolbar__item--current");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,14 +295,24 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
const start = getSelectionOffset(nodeElement, editorElement, range).start;
|
||||
if (start !== 0) {
|
||||
const editElement = getContenteditableElement(nodeElement);
|
||||
const firstIndex = editElement.textContent.indexOf("\n");
|
||||
if (firstIndex === -1 || start < firstIndex || start === editElement.textContent.replace("\n", " ").indexOf("\n")) {
|
||||
setFirstNodeRange(editElement, range);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
if (editElement.tagName === "TABLE") {
|
||||
const cellElement = hasClosestByMatchTag(range.startContainer, "TH") || hasClosestByMatchTag(range.startContainer, "TD") || editElement.querySelector("th, td")
|
||||
if (getSelectionOffset(cellElement, cellElement, range).start !== 0) {
|
||||
setFirstNodeRange(cellElement, range);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
const firstIndex = editElement.textContent.indexOf("\n");
|
||||
if (firstIndex === -1 || start <= firstIndex || start === editElement.textContent.replace("\n", " ").indexOf("\n")) {
|
||||
setFirstNodeRange(editElement, range);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue