Skip to content

Commit

Permalink
🎨 #13719
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 5, 2025
1 parent 58d47ed commit 8322087
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/src/block/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/menus/commonMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
72 changes: 67 additions & 5 deletions app/src/protyle/render/av/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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);
}
Expand Down

0 comments on commit 8322087

Please sign in to comment.