From b3bfa5071bd5f01fd3234892b3b0efcf3e85cc7c Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 16 Sep 2022 10:11:56 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20https://github.com/siyuan-note/siy?= =?UTF-8?q?uan/issues/2911=20=E7=B2=97=E4=BD=93=E5=90=8E=E8=BF=98=E6=83=B3?= =?UTF-8?q?=E7=B2=97=E4=BD=93=E5=8F=AF=E4=BD=BF=E7=94=A8=20ctrl+b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/toolbar/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index de3315520..4dd349723 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -133,7 +133,7 @@ export class Toolbar { }); } - public getCurrentType(range = this.range) { + public getCurrentType(range = this.range, useEndType = true) { let types: string[] = []; let startElement = range.startContainer as HTMLElement; if (startElement.nodeType === 3) { @@ -145,7 +145,7 @@ export class Toolbar { return []; } if (!["DIV", "TD", "TH", "TR"].includes(startElement.tagName)) { - if (range.startContainer.textContent.length === range.startOffset && !hasNextSibling(range.startContainer)) { + if (!useEndType && range.startContainer.textContent.length === range.startOffset && !hasNextSibling(range.startContainer)) { // 光标在 span 结尾不算 type,否则如在粗体后 ctrl+b 就无法继续使用粗体了 } else { types = (startElement.getAttribute("data-type") || "").split(" "); @@ -253,7 +253,7 @@ export class Toolbar { if (!nodeElement) { return; } - const rangeTypes = this.getCurrentType(); + const rangeTypes = this.getCurrentType(this.range, false); const selectText = this.range.toString(); // table 选中处理