Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Nov 11, 2024
1 parent 6b6ce37 commit 7614102
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/appearance/langs/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Auslösermethode für schwebendes Fenster",
"floatWindowModeTip": "Wählen Sie, wie das schwebende Fenster ausgelöst wird, wenn die Maus über das Blocksymbol, das Breadcrumb-Symbol usw. schwebt.",
"floatWindowMode0": "Schweben",
"floatWindowMode1": "Drücken und halten Sie <code class='fn__code'>${hotkey}</code> + Schwellen",
"floatWindowMode1": "Drücken und halten Sie ${hotkey} + Schwellen",
"floatWindowMode2": "Nicht auslösen",
"codeSnippet": "Code-Schnipsel",
"codeSnippetTip": "Feinabstimmung der Oberfläche oder Funktionalität durch Code-Schnipsel",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Floating window trigger method",
"floatWindowModeTip": "Choose how to trigger the floating window when the mouse hovers over the block icon, breadcrumb icon, etc.",
"floatWindowMode0": "Hover",
"floatWindowMode1": "Press and hold <code class='fn__code'>${hotkey}</code>+Hover",
"floatWindowMode1": "Press and hold ${hotkey} + Hover",
"floatWindowMode2": "Do not trigger",
"codeSnippet": "Code Snippet",
"codeSnippetTip": "Fine-tune the interface or functionality through code snippets",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Método de activación de ventana flotante",
"floatWindowModeTip": "Elija cómo activar la ventana flotante cuando el mouse pasa sobre el ícono de bloque, el ícono de ruta de navegación, etc.",
"floatWindowMode0": "Flotar",
"floatWindowMode1": "Presione y mantenga presionado <code class='fn__code'>${hotkey}</code>+Flotar",
"floatWindowMode1": "Presione y mantenga presionado ${hotkey} + Flotar",
"floatWindowMode2": "No activar",
"codeSnippet": "Fragmento de código",
"codeSnippetTip": "Ajusta la interfaz o la funcionalidad mediante fragmentos de código",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Méthode de déclenchement de fenêtre flottante",
"floatWindowModeTip": "Choisissez comment déclencher la fenêtre flottante lorsque la souris survole l'icône de bloc, l'icône de fil d'Ariane, etc.",
"floatWindowMode0": "Flotter",
"floatWindowMode1": "Appuyez et maintenez <code class='fn__code'>${hotkey}</code>+Flotter",
"floatWindowMode1": "Appuyez et maintenez ${hotkey} + Flotter",
"floatWindowMode2": "Ne pas déclencher",
"codeSnippet": "Extrait de code",
"codeSnippetTip": "Affiner l'interface ou les fonctionnalités grâce à des extraits de code",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/he_IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "שיטת הפעלת חלון צף",
"floatWindowModeTip": "בחר כיצד להפעיל את חלון הצף כאשר העכבר מרחף מעל אייקון הבלוק, אייקוןBreadcrumb וכדומה.",
"floatWindowMode0": "מרחף",
"floatWindowMode1": "לחץ והחזק <code class='fn__code'>${hotkey}</code>+מרחף",
"floatWindowMode1": "לחץ והחזק ${hotkey} + מרחף",
"floatWindowMode2": "אל תניע",
"codeSnippet": "קטע קוד",
"codeSnippetTip": "שפר את הממשק או הפונקציה באמצעות קטעי קוד",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Metodo di attivazione della finestra flottante",
"floatWindowModeTip": "Scegli come attivare la finestra flottante quando il mouse passa sopra l'icona del blocco, l'icona del breadcrumb, ecc.",
"floatWindowMode0": "Passa il mouse",
"floatWindowMode1": "Tieni premuto <code class='fn__code'>${hotkey}</code>+Passa il mouse",
"floatWindowMode1": "Tieni premuto ${hotkey} + Passa il mouse",
"floatWindowMode2": "Non attivare",
"codeSnippet": "Snippet di codice",
"codeSnippetTip": "Affina l'interfaccia o la funzionalità tramite frammenti di codice",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "フローティングウィンドウのトリガー方法",
"floatWindowModeTip": "ブロックアイコンやパンくずリストアイコンなどにマウスカーソルを合わせたときにフローティングウィンドウを表示する方法を選択します",
"floatWindowMode0": "ホバー",
"floatWindowMode1": "<code class='fn__code'>${hotkey}</code> を押しながらホバー",
"floatWindowMode1": "${hotkey} を押しながらホバー",
"floatWindowMode2": "表示しない",
"codeSnippet": "コードスニペット",
"codeSnippetTip": "コードスニペットを使用してインターフェースや機能を微調整します",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Metoda wywoływania okna pływającego",
"floatWindowModeTip": "Wybierz, jak wywoływać pływające okno, gdy mysz znajduje się nad ikoną bloku, ikoną okruszków, itp.",
"floatWindowMode0": "Najedź",
"floatWindowMode1": "Naciśnij i przytrzymaj <code class='fn__code'>${hotkey}</code>+Najedź",
"floatWindowMode1": "Naciśnij i przytrzymaj ${hotkey} + Najedź",
"floatWindowMode2": "Nie wywołuj",
"codeSnippet": "Fragment kodu",
"codeSnippetTip": "Dostosuj interfejs lub funkcjonalność za pomocą fragmentów kodu",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "Способ активации плавающего окна",
"floatWindowModeTip": "Выберите способ вызова плавающего окна, когда мышь наводится на значок блока, значок хлебных крошек и т. д.",
"floatWindowMode0": "Наведение",
"floatWindowMode1": "Нажмите и удерживайте <code class='fn__code'>${hotkey}</code> + Наведение",
"floatWindowMode1": "Нажмите и удерживайте ${hotkey} + Наведение",
"floatWindowMode2": "Не вызывать",
"codeSnippet": "Фрагмент кода",
"codeSnippetTip": "Тонкая настройка интерфейса или функциональности с помощью фрагментов кода",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "浮窗觸發方式",
"floatWindowModeTip": "選擇滑鼠懸停塊引、麵包屑塊標等位置觸發浮窗的方式",
"floatWindowMode0": "懸停",
"floatWindowMode1": "按住 <code class='fn__code'>${hotkey}</code>+懸停",
"floatWindowMode1": "按住 ${hotkey}+懸停",
"floatWindowMode2": "不觸發浮窗",
"codeSnippet": "代碼片段",
"codeSnippetTip": "透過程式碼片段對介面或功能進行微調",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"floatWindowMode": "浮窗触发方式",
"floatWindowModeTip": "选择鼠标悬停块引、面包屑块标等位置触发浮窗的方式",
"floatWindowMode0": "悬停",
"floatWindowMode1": "按住 <code class='fn__code'>${hotkey}</code>+悬停",
"floatWindowMode1": "按住 ${hotkey}+悬停",
"floatWindowMode2": "不触发浮窗",
"codeSnippet": "代码片段",
"codeSnippetTip": "通过代码片段对界面或功能进行微调",
Expand Down
34 changes: 34 additions & 0 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,40 @@ export abstract class Constants {
public static readonly SIYUAN_RENDER_CODE_LANGUAGES: string[] = [
"abc", "plantuml", "mermaid", "flowchart", "echarts", "mindmap", "graphviz", "math"
];
public static readonly PROTYLE_TOOLBAR: string[] = isMobile() ? [
"block-ref",
"a",
"|",
"text",
"strong",
"em",
"u",
"clear",
"|",
"code",
"tag",
"inline-math",
"inline-memo",
] : [
"block-ref",
"a",
"|",
"text",
"strong",
"em",
"u",
"s",
"mark",
"sup",
"sub",
"clear",
"|",
"code",
"kbd",
"tag",
"inline-math",
"inline-memo",
]

// Google Analytics 事件
public static readonly ANALYTICS_EVT_ON_GET_CONFIG: string = "siyuan.onGetConfig";
Expand Down
4 changes: 4 additions & 0 deletions app/src/plugin/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {getFrontend, isMobile, isWindow} from "../util/functions";
import {Constants} from "../constants";
import {uninstall} from "./uninstall";
import {setStorageVal} from "../protyle/util/compatibility";
import { getAllEditor } from "../layout/getAll";

const requireFunc = (key: string) => {
const modules = {
Expand Down Expand Up @@ -85,6 +86,9 @@ export const loadPlugin = async (app: App, item: IPluginData) => {
document.head.append(styleElement);
afterLoadPlugin(plugin);
saveLayout();
getAllEditor().forEach(editor => {
editor.protyle.toolbar.update(editor.protyle);
});
return plugin;
};

Expand Down
5 changes: 5 additions & 0 deletions app/src/plugin/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {resizeTopBar} from "../layout/util";
/// #endif
import {Constants} from "../constants";
import {setStorageVal} from "../protyle/util/compatibility";
import {getAllEditor} from "../layout/getAll";

export const uninstall = (app: App, name: string, isUninstall = false) => {
app.plugins.find((plugin: Plugin, index) => {
Expand Down Expand Up @@ -61,6 +62,10 @@ export const uninstall = (app: App, name: string, isUninstall = false) => {
});
// rm plugin
app.plugins.splice(index, 1);
// rm protyle toolbar
getAllEditor().forEach(editor => {
editor.protyle.toolbar.update(editor.protyle);
});
return true;
}
});
Expand Down
12 changes: 12 additions & 0 deletions app/src/protyle/toolbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ export class Toolbar {
});
}

public update(protyle: IProtyle) {
this.element.innerHTML = "";
protyle.options.toolbar = toolbarKeyToMenu(Constants.PROTYLE_TOOLBAR);
protyle.app.plugins.forEach(item => {
protyle.options.toolbar = toolbarKeyToMenu(item.updateProtyleToolbar(protyle.options.toolbar));
});
protyle.options.toolbar.forEach((menuItem: IMenuItem) => {
const itemElement = this.genItem(protyle, menuItem);
this.element.appendChild(itemElement);
});
}

public render(protyle: IProtyle, range: Range, event?: KeyboardEvent) {
this.range = range;
let nodeElement = hasClosestBlock(range.startContainer);
Expand Down
35 changes: 1 addition & 34 deletions app/src/protyle/util/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,7 @@ export class Options {
},
mode: "both",
},
toolbar: isMobile() ? [
"block-ref",
"a",
"|",
"text",
"strong",
"em",
"u",
"clear",
"|",
"code",
"tag",
"inline-math",
"inline-memo",
] : [
"block-ref",
"a",
"|",
"text",
"strong",
"em",
"u",
"s",
"mark",
"sup",
"sub",
"clear",
"|",
"code",
"kbd",
"tag",
"inline-math",
"inline-memo",
],
toolbar: Constants.PROTYLE_TOOLBAR,
typewriterMode: false,
upload: {
max: 1024 * 1024 * 1024 * 4,
Expand Down

0 comments on commit 7614102

Please sign in to comment.