Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13719

Vanessa8322087cba00
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 663dd1e767..87f33bae66 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -82,6 +82,8 @@ export const initBlockPopover = (app: App) => {
if (href) {
tip = `<span style="word-break: break-all">${href.substring(0, Constants.SIZE_TITLE)}</span>`;
tooltipClass = "href"; // 为超链接添加 class https://github.com/siyuan-note/siyuan/issues/11440#issuecomment-2119080691
+ } else {
+ tip = "";
}
const title = aElement.getAttribute("data-title");
if (tip && isLocalPath(href) && !aElement.classList.contains("b3-tooltips")) {
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index cc4fa0cec4..4dbeb123f8 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -423,7 +423,7 @@ export const copySubMenu = (ids: string[], accelerator = true, focusElement?: El
iconHTML: "",
label: window.siyuan.languages.copyHPath,
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined,
- click: () => {
+ click: () => {
copyTextByType(ids, "hPath");
if (focusElement) {
focusBlock(focusElement);
diff --git a/app/src/protyle/render/av/asset.ts b/app/src/protyle/render/av/asset.ts
index 6e6c37ca76..fac6c0df59 100644
--- a/app/src/protyle/render/av/asset.ts
+++ b/app/src/protyle/render/av/asset.ts
@@ -212,19 +212,72 @@ export const editAssetItem = (options: {
menu.addItem({
iconHTML: "",
type: "readonly",
- label: `${window.siyuan.languages.link}
+ label: `<div class="fn__flex">
+ <span class="fn__flex-center">${window.siyuan.languages.link}</span>
+ <span class="fn__space"></span>
+ <span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
+ <svg><use xlink:href="#iconCopy"></use></svg>
+ </span>
+</div>
<textarea rows="1" style="margin:4px 0;width: ${isMobile() ? "200" : "360"}px;resize: vertical;" class="b3-text-field"></textarea>
<div class="fn__hr"></div>
-${window.siyuan.languages.title}
+<div class="fn__flex">
+ <span class="fn__flex-center">${window.siyuan.languages.title}</span>
+ <span class="fn__space"></span>
+ <span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
+ <svg><use xlink:href="#iconCopy"></use></svg>
+ </span>
+</div>
<textarea style="width: ${isMobile() ? "200" : "360"}px;margin: 4px 0;resize: vertical;" rows="1" class="b3-text-field"></textarea>`,
+ bind(element) {
+ element.addEventListener("click", (event) => {
+ let target = event.target as HTMLElement;
+ while (target) {
+ if (target.dataset.action === "copy") {
+ writeText((target.parentElement.nextElementSibling as HTMLTextAreaElement).value);
+ showMessage(window.siyuan.languages.copied);
+ break;
+ }
+ target = target.parentElement;
+ }
+ });
+ }
+ });
+ menu.addSeparator()
+ menu.addItem({
+ label: window.siyuan.languages.copy,
+ icon: "iconCopy",
+ click() {
+ writeText(`[${textElements[1].value || textElements[0].value}](${textElements[0].value})`);
+ }
});
} else {
menu.addItem({
iconHTML: "",
type: "readonly",
- label: `${window.siyuan.languages.link}
+ label: `<div class="fn__flex">
+ <span class="fn__flex-center">${window.siyuan.languages.link}</span>
+ <span class="fn__space"></span>
+ <span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
+ <svg><use xlink:href="#iconCopy"></use></svg>
+ </span>
+</div>
<textarea rows="1" style="margin:4px 0;width: ${isMobile() ? "200" : "360"}px;resize: vertical;" class="b3-text-field"></textarea>`,
+ bind(element) {
+ element.addEventListener("click", (event) => {
+ let target = event.target as HTMLElement;
+ while (target) {
+ if (target.dataset.action === "copy") {
+ writeText((target.parentElement.nextElementSibling as HTMLTextAreaElement).value);
+ showMessage(window.siyuan.languages.copied);
+ break;
+ }
+ target = target.parentElement;
+ }
+ });
+ }
});
+ menu.addSeparator();
menu.addItem({
label: window.siyuan.languages.copy,
icon: "iconCopy",
@@ -262,7 +315,10 @@ ${window.siyuan.languages.title}
}
});
}
- menu.addSeparator();
+ const openSubMenu = openMenu(options.protyle ? options.protyle.app : window.siyuan.ws.app, linkAddress, true, false);
+ if (type !== "file" || openSubMenu.length > 0) {
+ menu.addSeparator();
+ }
if (type !== "file") {
menu.addItem({
icon: "iconPreview",
@@ -272,7 +328,13 @@ ${window.siyuan.languages.title}
}
});
}
- openMenu(options.protyle ? options.protyle.app : window.siyuan.ws.app, linkAddress, false, false);
+ if (openSubMenu.length > 0) {
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.openBy,
+ icon: "iconOpen",
+ submenu: openSubMenu
+ }).element);
+ }
if (linkAddress?.startsWith("assets/")) {
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element);
}