Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/8083

Vanessadb16d8f76c2f
diff --git a/app/src/constants.ts b/app/src/constants.ts
index afda6e32e5..43238e25c9 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -40,6 +40,7 @@ export abstract class Constants {
public static readonly SIYUAN_AUTO_LAUNCH: string = "siyuan-auto-launch";
// size
+ public static readonly SIZE_LINK_TEXT_MAX: number = 24;
public static readonly SIZE_TOOLBAR_HEIGHT: number = isMobile() ? 0 : 32;
public static readonly SIZE_GET_MAX = 102400;
public static readonly SIZE_UNDO = 64;
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index 7d29d93a07..01aa5fba05 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -437,60 +437,68 @@ export const openAttr = (nodeElement: Element, protyle: IProtyle, focusName = "b
};
export const copySubMenu = (id: string, accelerator = true, focusElement?: Element) => {
- return [
- {
- icon: "iconRef",
- accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockRef.custom : undefined,
- label: window.siyuan.languages.copyBlockRef,
- click: () => {
- fetchPost("/api/block/getRefText", {id}, (response) => {
- writeText(`((${id} '${response.data}'))`);
- });
- if (focusElement) {
- focusBlock(focusElement);
- }
+ return [{
+ icon: "iconRef",
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockRef.custom : undefined,
+ label: window.siyuan.languages.copyBlockRef,
+ click: () => {
+ fetchPost("/api/block/getRefText", {id}, (response) => {
+ writeText(`((${id} '${response.data}'))`);
+ });
+ if (focusElement) {
+ focusBlock(focusElement);
}
- }, {
- icon: "iconSQL",
- label: window.siyuan.languages.copyBlockEmbed,
- accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom : undefined,
- click: () => {
- writeText(`{{select * from blocks where id='${id}'}}`);
- if (focusElement) {
- focusBlock(focusElement);
- }
+ }
+ }, {
+ icon: "iconSQL",
+ label: window.siyuan.languages.copyBlockEmbed,
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom : undefined,
+ click: () => {
+ writeText(`{{select * from blocks where id='${id}'}}`);
+ if (focusElement) {
+ focusBlock(focusElement);
}
- }, {
- icon: "iconSiYuan",
- label: window.siyuan.languages.copyProtocol,
- accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocol.custom : undefined,
- click: () => {
- writeText(`siyuan://blocks/${id}`);
- if (focusElement) {
- focusBlock(focusElement);
- }
+ }
+ }, {
+ icon: "iconSiYuan",
+ label: window.siyuan.languages.copyProtocol,
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocol.custom : undefined,
+ click: () => {
+ writeText(`siyuan://blocks/${id}`);
+ if (focusElement) {
+ focusBlock(focusElement);
}
- }, {
- label: window.siyuan.languages.copyHPath,
- accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined,
- click: () => {
- fetchPost("/api/filetree/getHPathByID", {
- id
- }, (response) => {
- writeText(response.data);
- });
+ }
+ }, {
+ label: window.siyuan.languages.copyProtocol,
+ click: () => {
+ fetchPost("/api/block/getRefText", {id}, (response) => {
+ writeText(`[${response.data.substring(0, Constants.SIZE_LINK_TEXT_MAX)}](siyuan://blocks/${id})`);
+ });
+ if (focusElement) {
+ focusBlock(focusElement);
}
- }, {
- label: window.siyuan.languages.copyID,
- accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyID.custom : undefined,
- click: () => {
- writeText(id);
- if (focusElement) {
- focusBlock(focusElement);
- }
+ }
+ }, {
+ label: window.siyuan.languages.copyHPath,
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined,
+ click: () => {
+ fetchPost("/api/filetree/getHPathByID", {
+ id
+ }, (response) => {
+ writeText(response.data);
+ });
+ }
+ }, {
+ label: window.siyuan.languages.copyID,
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyID.custom : undefined,
+ click: () => {
+ writeText(id);
+ if (focusElement) {
+ focusBlock(focusElement);
}
}
- ];
+ }];
};
export const exportMd = (id: string) => {
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 54be10d2b8..6ce473524a 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -762,7 +762,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
if (!anchor && linkAddress) {
anchor = linkAddress.replace("https://", "").replace("http://", "");
if (anchor.length > 24) {
- anchor = anchor.substring(0, 24) + "...";
+ anchor = anchor.substring(0, Constants.SIZE_LINK_TEXT_MAX) + "...";
}
linkElement.innerHTML = Lute.EscapeHTMLStr(anchor);
}