Skip to content

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

:bug: sync tip 转义及支持点击

Vanessa887443c321ff
diff --git a/app/src/assets/scss/component/_tooltips.scss b/app/src/assets/scss/component/_tooltips.scss
index 14e106c67f..2fb9745ade 100644
--- a/app/src/assets/scss/component/_tooltips.scss
+++ b/app/src/assets/scss/component/_tooltips.scss
@@ -1,5 +1,5 @@
.tooltip {
- pointer-events: none;
+ user-select: none; // 同步悬浮需要点击链接,因此不能使用 pointer-events: none;
position: fixed;
z-index: 1000000;
padding: 4px 8px;
@@ -16,6 +16,14 @@
animation-fill-mode: both;
animation-name: zoomIn;
+ a {
+ color: var(--b3-theme-secondary);
+
+ &:hover {
+ text-decoration: underline;
+ }
+ }
+
&--error {
background: var(--b3-theme-error);
}
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index e161084898..caef260f4c 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -37,7 +37,7 @@ export const initBlockPopover = (app: App) => {
event.stopPropagation();
return;
}
- } else if (!aElement) {
+ } else if (!aElement && !hasClosestByAttribute(event.target, "id", "tooltip", true)) {
hideTooltip();
}
if (window.siyuan.config.editor.floatWindowMode === 1 || window.siyuan.shiftIsPressed) {
diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts
index 3ace549938..1f10b41e3c 100644
--- a/app/src/dialog/tooltip.ts
+++ b/app/src/dialog/tooltip.ts
@@ -26,13 +26,16 @@ export const showTooltip = (message: string, target: Element, error = false) =>
messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161
}
let left = targetRect.left;
+ let topSpace = 8
const position = target.getAttribute("data-position");
if (position === "right") {
left = targetRect.right - messageElement.clientWidth;
} else if (position === "center") {
left = targetRect.left + (targetRect.width - messageElement.clientWidth) / 2;
+ } else if (position === "top") {
+ topSpace = 0;
}
- setPosition(messageElement, left, targetRect.top + targetRect.height + 8, targetRect.height * 2 + 8);
+ setPosition(messageElement, left, targetRect.top + targetRect.height + topSpace, targetRect.height * 2 + 8);
};
export const hideTooltip = () => {
diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.ts
index 3b2e27dfd7..67e477576c 100644
--- a/app/src/layout/topBar.ts
+++ b/app/src/layout/topBar.ts
@@ -41,7 +41,7 @@ export const initBar = (app: App) => {
<span class="toolbar__text">${getWorkspaceName()}</span>
<svg class="toolbar__svg"><use xlink:href="#iconDown"></use></svg>
</div>
-<div id="barSync" class="toolbar__item b3-tooltips b3-tooltips__se${window.siyuan.config.readonly ? " fn__none" : ""}" aria-label="${window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom))}">
+<div id="barSync" data-position="top" data-type="a" class="toolbar__item${window.siyuan.config.readonly ? " fn__none" : ""}">
<svg><use xlink:href="#iconCloudSucc"></use></svg>
</div>
<button id="barBack" data-menu="true" class="toolbar__item toolbar__item--disabled b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.languages.goBack} ${updateHotkeyTip(window.siyuan.config.keymap.general.goBack.custom)}">
@@ -240,26 +240,27 @@ export const initBar = (app: App) => {
if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) {
html = response.data.stat;
} else {
- html = window.siyuan.languages._kernel[82].replace("%s", dayjs(response.data.synced).format("YYYY-MM-DD HH:mm")) + "\n"
+ html = window.siyuan.languages._kernel[82].replace("%s", dayjs(response.data.synced).format("YYYY-MM-DD HH:mm")) + "<br>"
html += " " + response.data.stat;
if (response.data.kernels.length > 0) {
- html += "\n"
- html += window.siyuan.languages.currentKernel + "\n"
- html += " " + response.data.kernel + "/" + window.siyuan.config.system.kernelVersion + " (" + window.siyuan.config.system.os + "/" + window.siyuan.config.system.name + ")\n"
- html += window.siyuan.languages.otherOnlineKernels + "\n"
+ html += "<br>"
+ html += window.siyuan.languages.currentKernel + "<br>"
+ html += " " + response.data.kernel + "/" + window.siyuan.config.system.kernelVersion + " (" + window.siyuan.config.system.os + "/" + window.siyuan.config.system.name + ")<br>"
+ html += window.siyuan.languages.otherOnlineKernels + "<br>"
response.data.kernels.forEach((item: {
os: string;
ver: string;
hostname: string;
id: string;
}) => {
- html += ` ${item.id}/${item.ver} (${item.os}/${item.hostname}) \n`
+ html += ` ${item.id}/${item.ver} (${item.os}/${item.hostname}) <br>`
})
}
}
- barSyncElement.setAttribute("aria-label", escapeAttr(html));
+ barSyncElement.setAttribute("aria-label", html);
})
})
+ barSyncElement.setAttribute("aria-label", window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom)));
};
export const setZoom = (type: "zoomIn" | "zoomOut" | "restore") => {