From 08858050e3c5d1fc1c8100d4590626abcbfacbfd Mon Sep 17 00:00:00 2001
From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com>
Date: Mon, 23 Sep 2024 08:43:49 +0800
Subject: [PATCH] Improve /menu (#12547)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* / 菜单
* 优先显示快捷键,其次显示键盘输入
* heading
* 空格
* html
* html
* 更新 index.ts
* b3-menu__accelerator 嵌套了
---
app/src/protyle/gutter/index.ts | 8 ++--
app/src/protyle/hint/extend.ts | 81 ++++++++++++++++++++++++++++-----
app/src/protyle/hint/index.ts | 4 +-
app/src/types/protyle.d.ts | 1 +
4 files changed, 77 insertions(+), 17 deletions(-)
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index bf24e1ebc..d0c09ce2f 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -1454,9 +1454,9 @@ export class Gutter {
submenu: iframeMenu(protyle, nodeElement)
}).element);
} else if (type === "NodeHTMLBlock" && !protyle.disabled) {
- window.siyuan.menus.menu.append(new MenuItem({id: "separator_HTML", type: "separator"}).element);
+ window.siyuan.menus.menu.append(new MenuItem({id: "separator_html", type: "separator"}).element);
window.siyuan.menus.menu.append(new MenuItem({
- id: "HTML",
+ id: "html",
icon: "iconHTML5",
label: "HTML",
click() {
@@ -1989,7 +1989,7 @@ export class Gutter {
}];
["25%", "33%", "50%", "67%", "75%", "100%"].forEach((item) => {
styles.push({
- id: "width" + item,
+ id: "width_" + item,
iconHTML: "",
label: item,
click: () => {
@@ -2079,7 +2079,7 @@ export class Gutter {
}];
["25%", "33%", "50%", "67%", "75%", "100%"].forEach((item) => {
styles.push({
- id: "height" + item,
+ id: "height_" + item,
iconHTML: "",
label: item,
click: () => {
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index 1a72b176c..95527ed14 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -24,234 +24,293 @@ import {avRender} from "../render/av/render";
export const hintSlash = (key: string, protyle: IProtyle) => {
const allList: IHintData[] = [{
filter: ["模版", "moban", "muban", "mb", "template"],
+ id: "template",
value: Constants.ZWSP,
html: `
",
html: '
HTML
',
}, {
value: "",
+ id: "separator_2",
html: "separator",
}, {
filter: ["表情", "biaoqing", "bq", "emoji"],
+ id: "emoji",
value: "emoji",
html: `
${window.siyuan.languages.emoji}:
`,
}, {
filter: ["链接", "lianjie", "lj", "link", "a"],
+ id: "link",
value: "a",
html: `
${window.siyuan.languages.link}
`,
}, {
filter: ["粗体", "cuti", "ct", "bold", "strong"],
+ id: "bold",
value: "strong",
html: `
${window.siyuan.languages.bold}
`,
}, {
filter: ["斜体", "xieti", "xt", "italic", "em"],
+ id: "italic",
value: "em",
html: `
${window.siyuan.languages.italic}
`,
}, {
filter: ["下划线", "xiahuaxian", "xhx", "underline"],
+ id: "underline",
value: "u",
html: `
${window.siyuan.languages.underline}
`,
}, {
filter: ["删除线", "shanchuxian", "scx", "strike"],
+ id: "strike",
value: "s",
html: `
${window.siyuan.languages.strike}
`,
}, {
filter: ["标记", "biaoji", "bj", "mark"],
+ id: "mark",
value: "mark",
html: `
${window.siyuan.languages.mark}
`,
}, {
filter: ["上标", "shangbiao", "sb", "superscript"],
+ id: "sup",
value: "sup",
html: `
${window.siyuan.languages.sup}
`,
}, {
filter: ["下标", "xiaobiao", "xb", "subscript"],
+ id: "sub",
value: "sub",
html: `
${window.siyuan.languages.sub}
`,
}, {
filter: ["标签", "biaoqian", "bq", "tag"],
+ id: "tag",
value: "tag",
html: `
${window.siyuan.languages.tag}
`,
}, {
filter: ["行级代码", "hangjidaima", "hjdm", "行内代码", "hangneidaima", "hndm", "inline code"],
+ id: "inlineCode",
value: "code",
html: `
${window.siyuan.languages["inline-code"]}
`,
}, {
filter: ["行级公式", "hangjigongshi", "hjgs", "行级数学公式", "hangjishuxuegongshi", "hjsxgs", "行内数学公式", "hangneishuxuegongshi", "hnsxgs", "inline math"],
+ id: "inlineMath",
value: "inline-math",
html: `
${window.siyuan.languages["inline-math"]}
`,
}, {
value: "",
+ id: "separator_3",
html: "separator",
}, {
filter: ["插入图片或文件", "upload", "上传", "crtphwj", "sc"],
+ id: "insertAsset",
value: Constants.ZWSP + 3,
html: `
${window.siyuan.languages.insertAsset}
`,
}, {
filter: ["iframe", "嵌入网址", "qianruwangzhan", "qrwz"],
+ id: "insertIframeURL",
value: '
',
html: `
${window.siyuan.languages.insertIframeURL}
`,
}, {
filter: ["插入图片链接", "insert image link", "charutupianlianjie", "crtptp"],
+ id: "insertImgURL",
value: "![]()",
html: `
${window.siyuan.languages.insertImgURL}
`,
}, {
filter: ["插入视频链接", "charushipinlianjie", "crsplj", "insert video url"],
+ id: "insertVideoURL",
value: '
',
html: `
${window.siyuan.languages.insertVideoURL}
`,
}, {
filter: ["插入音频链接", "charuyinpinlianjie", "cryplj", "insert audio url"],
+ id: "insertAudioURL",
value: '
',
html: `
${window.siyuan.languages.insertAudioURL}
`,
}, {
value: "",
+ id: "separator_4",
html: "separator",
}, {
filter: ["五线谱", "wuxianpu", "wxp", "staff"],
+ id: "staff",
value: "```abc\n```",
html: `
ABC${window.siyuan.languages.staff}
`,
}, {
filter: ["图表", "tubiao", "tb", "chart"],
+ id: "chart",
value: "```echarts\n```",
html: `
Chart${window.siyuan.languages.chart}
`,
}, {
filter: ["流程图", "liuchengtu", "lct", "flow chart"],
+ id: "flowChart",
value: "```flowchart\n```",
html: '
FlowChartFlow Chart
',
}, {
filter: ["状态图", "zhuangtaitu", "ztt", "graph viz"],
+ id: "graph",
value: "```graphviz\n```",
html: '
GraphvizGraph
',
}, {
filter: ["流程图", "时序图", "甘特图", "liuchengtu", "shixutu", "gantetu", "lct", "sxt", "gtt", "mermaid"],
+ id: "mermaid",
value: "```mermaid\n```",
html: '
MermaidMermaid
',
}, {
filter: ["脑图", "naotu", "nt", "mind map"],
+ id: "mindmap",
value: "```mindmap\n```",
html: `
Mind map${window.siyuan.languages.mindmap}
`,
}, {
filter: ["统一建模语言", "tongyijianmoyuyan", "tyjmyy", "plant uml"],
+ id: "UML",
value: "```plantuml\n```",
html: '
PlantUMLUML
',
}, {
value: "",
+ id: "separator_5",
html: "separator",
}, {
filter: ["信息样式", "xinxiyangshi", "xxys", "info style"],
+ id: "infoStyle",
value: `style${Constants.ZWSP}color: var(--b3-card-info-color);background-color: var(--b3-card-info-background);`,
html: `
A
${window.siyuan.languages.infoStyle}`,
}, {
filter: ["成功样式", "chenggongyangshi", "cgys", "success style"],
+ id: "successStyle",
value: `style${Constants.ZWSP}color: var(--b3-card-success-color);background-color: var(--b3-card-success-background);`,
html: `
A
${window.siyuan.languages.successStyle}`,
}, {
filter: ["警告样式", "jinggaoyangshi", "jgys", "warning style"],
+ id: "warningStyle",
value: `style${Constants.ZWSP}color: var(--b3-card-warning-color);background-color: var(--b3-card-warning-background);`,
html: `
A
${window.siyuan.languages.warningStyle}`,
}, {
filter: ["错误样式", "cuowuyangshi", "cwys", "error style"],
+ id: "errorStyle",
value: `style${Constants.ZWSP}color: var(--b3-card-error-color);background-color: var(--b3-card-error-background);`,
html: `
A
${window.siyuan.languages.errorStyle}`,
}, {
- filter: ["移除样式", "yichuyangshi", "ycys", "remove style"],
+ filter: ["清除样式", "qingchuyangshi", "qcys", "remove style"],
+ id: "clearFontStyle",
value: `style${Constants.ZWSP}`,
html: `
A
${window.siyuan.languages.clearFontStyle}`,
}, {
value: "",
+ id: "separator_6",
html: "separator",
}];
let hasPlugin = false;
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index d96370f19..7083e8668 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -248,9 +248,9 @@ ${unicode2Emoji(emoji.unicode)}`;
focusClass = " b3-list-item--focus";
}
if (hintData.html === "separator") {
- hintsHTML += '';
+ hintsHTML += ``;
} else {
- hintsHTML += `
`;
+ hintsHTML += `
`;
}
});
return `${hintsHTML}
`;
diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.ts
index 79c1a434c..caa37a9d4 100644
--- a/app/src/types/protyle.d.ts
+++ b/app/src/types/protyle.d.ts
@@ -370,6 +370,7 @@ interface IPreviewActionCustom {
}
interface IHintData {
+ id?: string;
html: string;
value: string;
filter?: string[]