Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: https://github.com/siyuan-note/siyuan/issues/2911 粗体后还想粗体可使用 ctrl+b

Vanessab3bfa5071bd5
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index de33155207..4dd349723e 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 选中处理