From 2fca1828d83e12400aa18fd54ad71d65d348627a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 19 Sep 2022 22:48:47 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20table=20=E5=89=8D=E6=88=96=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E4=B8=AA=20cell=20=E4=B8=89=E5=87=BB?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/wysiwyg/index.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index bb9f0d05f..cfe6aca0c 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/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) {