Преглед на файлове

:bug: table 前或最后一个 cell 三击状态不对

Vanessa преди 2 години
родител
ревизия
2fca1828d8
променени са 1 файла, в които са добавени 16 реда и са изтрити 1 реда
  1. 16 1
      app/src/protyle/wysiwyg/index.ts

+ 16 - 1
app/src/protyle/wysiwyg/index.ts

@@ -12,7 +12,7 @@ import {
     focusByWbr,
     focusSideBlock,
     getEditorRange,
-    getSelectionOffset,
+    getSelectionOffset, setLastNodeRange,
 } from "../util/selection";
 import {Constants} from "../../constants";
 import {getSearch, isMobile} from "../../util/functions";
@@ -841,6 +841,21 @@ export class WYSIWYG {
                     if (range.toString() === "" ||
                         window.siyuan.shiftIsPressed  // https://ld246.com/article/1650096678723
                     ) {
+                        if (event.detail === 3) {
+                            // table 前或最后一个 cell 三击状态不对
+                            let cursorElement = hasClosestBlock(range.startContainer) as Element;
+                            if (cursorElement) {
+                                if (cursorElement.nextElementSibling?.classList.contains("table")) {
+                                    setLastNodeRange(getContenteditableElement(cursorElement), range, false)
+                                } else if (cursorElement.classList.contains("table")) {
+                                    const cellElements = cursorElement.querySelectorAll("th, td");
+                                    cursorElement = cellElements[cellElements.length - 1];
+                                    if (cursorElement.contains(range.startContainer)) {
+                                        setLastNodeRange(cursorElement, range, false)
+                                    }
+                                }
+                            }
+                        }
                         return;
                     }
                     if (selectElement.length > 0) {