From 3204c78138990c89c024042fc5f0ffe4975f50f4 Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Tue, 16 Dec 2025 15:12:45 +0800 Subject: [PATCH] :art: Marketplace package funding button supports copying non-link text on click --- app/src/config/bazaar.ts | 34 ++++++++++++++++++++++----- app/src/protyle/util/compatibility.ts | 2 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts index eb294f5c3..ab878fedd 100644 --- a/app/src/config/bazaar.ts +++ b/app/src/config/bazaar.ts @@ -8,7 +8,7 @@ import {Constants} from "../constants"; import * as path from "path"; /// #endif import {getFrontend, isBrowser} from "../util/functions"; -import {setStorageVal} from "../protyle/util/compatibility"; +import {setStorageVal, writeText} from "../protyle/util/compatibility"; import {hasClosestByAttribute, hasClosestByClassName} from "../protyle/util/hasClosest"; import {Plugin} from "../plugin"; import {App} from "../index"; @@ -230,6 +230,17 @@ export const bazaar = {
`; }, + _genFundingHTML(funding: string): string { + if (!funding) { + return ""; + } + const isLink = funding.startsWith("http://") || funding.startsWith("https://"); + if (isLink) { + return ``; + } else { + return ``; + } + }, _genCardHTML(item: IBazaarItem, bazaarType: TBazaarType) { let hide = false; let themeMode = ""; @@ -273,7 +284,7 @@ export const bazaar = { ${item.downloads} - ${item.preferredFunding ? `` : ""} + ${item.preferredFunding ? `${bazaar._genFundingHTML(item.preferredFunding)}` : ""}
@@ -310,7 +321,7 @@ export const bazaar = {
${item.incompatible ? `${window.siyuan.languages.incompatible}` : ""} - ${item.preferredFunding ? `` : ""} + ${item.preferredFunding ? bazaar._genFundingHTML(item.preferredFunding) : ""} @@ -419,7 +430,7 @@ export const bazaar = {
${item.incompatible ? `${window.siyuan.languages.incompatible}` : ""} - ${item.preferredFunding ? `` : ""} + ${item.preferredFunding ? bazaar._genFundingHTML(item.preferredFunding) : ""} @@ -508,8 +519,8 @@ export const bazaar = {
${data.preferredFunding ? - `` : - `` + bazaar._genFundingHTML(data.preferredFunding) : + `` } ${data.author} @@ -618,6 +629,17 @@ export const bazaar = { const type = target.getAttribute("data-type"); if (target.tagName === "A") { break; + } + const copyFundingElement = hasClosestByAttribute(target, "data-type", "copy-funding"); + if (copyFundingElement) { + const funding = copyFundingElement.getAttribute("data-funding"); + if (funding) { + writeText(funding); + showMessage(window.siyuan.languages.copied); + } + event.preventDefault(); + event.stopPropagation(); + break; } else if (type === "open" && dataObj) { /// #if !BROWSER const dirName = dataObj.bazaarType; diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index c790f992a..39bb20575 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -238,7 +238,7 @@ export const writeText = (text: string) => { export const copyPlainText = async (text: string) => { text = text.replace(new RegExp(Constants.ZWSP, "g"), ""); // `复制纯文本` 时移除所有零宽空格 https://github.com/siyuan-note/siyuan/issues/6674 - await writeText(text); + writeText(text); }; // 用户 iPhone 点击延迟/需要双击的处理