Skip to content

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

:sparkles: fix https://github.com/siyuan-note/siyuan/issues/4203

Vanessa1b5bc9f3960d
diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js
index 6058c54034..41859159e0 100644
--- a/app/appearance/icons/ant/icon.js
+++ b/app/appearance/icons/ant/icon.js
@@ -1,5 +1,11 @@
document.body.insertAdjacentHTML('afterBegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>
+ <symbol id="iconLtr" viewBox="0 0 32 32">
+ <path d="M12.4 20.8v-8.8q-2.64 0-4.52-1.72t-1.88-4.28q0-2.52 1.74-4.26t4.26-1.74h11.2v2.4h-3.6v18.4h-2.4v-18.4h-2.4v18.4zM24.56 32l-1.68-1.68 2.96-2.96h-24.24v-2.4h24.24l-2.96-2.96 1.68-1.68 5.84 5.84zM12.4 9.6v-7.2q-1.68 0-2.84 0.96t-1.16 2.64 1.16 2.64 2.84 0.96z"></path>
+ </symbol>
+ <symbol id="iconRtl" viewBox="0 0 32 32">
+ <path d="M7.44 32l-5.84-5.84 5.84-5.84 1.68 1.68-2.96 2.96h24.24v2.4h-24.24l2.96 2.96zM12.4 20.8v-8.8q-2.64 0-4.52-1.72t-1.88-4.28q0-2.52 1.74-4.26t4.26-1.74h11.2v2.4h-3.6v18.4h-2.4v-18.4h-2.4v18.4zM12.4 9.6v-7.2q-1.68 0-2.84 0.96t-1.16 2.64 1.16 2.64 2.84 0.96z"></path>
+ </symbol>
<symbol id="iconBack" viewBox="0 0 32 32">
<path d="M30.135 14.508h-22.973l13.75-11.936c0.22-0.192 0.086-0.55-0.204-0.55h-3.475c-0.153 0-0.298 0.055-0.412 0.153l-14.838 12.874c-0.266 0.231-0.433 0.57-0.433 0.948s0.167 0.717 0.431 0.947l0.002 0.001 14.924 12.953c0.059 0.051 0.13 0.079 0.204 0.079h3.593c0.291 0 0.424-0.361 0.204-0.55l-13.746-11.936h22.973c0.173 0 0.314-0.141 0.314-0.314v-2.356c0-0.173-0.141-0.314-0.314-0.314z"></path>
</symbol>
diff --git a/app/appearance/icons/ant/icon.json b/app/appearance/icons/ant/icon.json
index eb41bc905f..27135c71d1 100644
--- a/app/appearance/icons/ant/icon.json
+++ b/app/appearance/icons/ant/icon.json
@@ -2,5 +2,5 @@
"name": "ant",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
- "version": "1.6.0"
+ "version": "1.7.0"
}
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index 59e7bd0c1d..b250240aed 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -28,6 +28,18 @@
<body>
<h2>SiYuan</h2>
<div class="fn__clear">
+ <div>
+ <svg>
+ <use xlink:href="#iconRtl"></use>
+ </svg>
+ iconRtl
+ </div>
+ <div>
+ <svg>
+ <use xlink:href="#iconLtr"></use>
+ </svg>
+ iconLtr
+ </div>
<div>
<svg>
<use xlink:href="#iconBack"></use>
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js
index fbe742ac02..0e7166ea32 100644
--- a/app/appearance/icons/material/icon.js
+++ b/app/appearance/icons/material/icon.js
@@ -1,5 +1,11 @@
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>
+ <symbol id="iconLtr" viewBox="0 0 32 32">
+ <path d="M12.4 20.8v-8.8q-2.64 0-4.52-1.72t-1.88-4.28q0-2.52 1.74-4.26t4.26-1.74h11.2v2.4h-3.6v18.4h-2.4v-18.4h-2.4v18.4zM24.56 32l-1.68-1.68 2.96-2.96h-24.24v-2.4h24.24l-2.96-2.96 1.68-1.68 5.84 5.84zM12.4 9.6v-7.2q-1.68 0-2.84 0.96t-1.16 2.64 1.16 2.64 2.84 0.96z"></path>
+ </symbol>
+ <symbol id="iconRtl" viewBox="0 0 32 32">
+ <path d="M7.44 32l-5.84-5.84 5.84-5.84 1.68 1.68-2.96 2.96h24.24v2.4h-24.24l2.96 2.96zM12.4 20.8v-8.8q-2.64 0-4.52-1.72t-1.88-4.28q0-2.52 1.74-4.26t4.26-1.74h11.2v2.4h-3.6v18.4h-2.4v-18.4h-2.4v18.4zM12.4 9.6v-7.2q-1.68 0-2.84 0.96t-1.16 2.64 1.16 2.64 2.84 0.96z"></path>
+ </symbol>
<symbol id="iconBack" viewBox="0 0 32 32">
<path d="M16 30.5l-14.5-14.5 14.5-14.5 1.903 1.903-11.237 11.237h23.834v2.719h-23.834l11.237 11.237z"></path>
</symbol>
diff --git a/app/appearance/icons/material/icon.json b/app/appearance/icons/material/icon.json
index b2fbcf241f..f13b501f32 100644
--- a/app/appearance/icons/material/icon.json
+++ b/app/appearance/icons/material/icon.json
@@ -2,5 +2,5 @@
"name": "material",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
- "version": "1.6.0"
+ "version": "1.7.0"
}
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 44e7208461..7a7cce0789 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -116,6 +116,7 @@
"justify": "Justify",
"justifyTip": "Render content side-aligned",
"rtl": "Right to Left (RTL)",
+ "ltr": "Left to Right (LTR)",
"rtlTip": "Render content from right to left",
"height": "Height",
"deactivateUser": "Deactivate Account",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 61ad01ac02..3eeecb32de 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -116,6 +116,7 @@
"justify": "Justificar",
"justifyTip": "Representar contenido alineado lateralmente",
"rtl": "De derecha a izquierda (RTL)",
+ "ltr": "De izquierda a derecha (LTR)",
"rtlTip": "Reproducir contenido de derecha a izquierda",
"height": "Altura",
"deactivateUser": "Desactivar cuenta",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 5ccc762ca2..6ad82b21ee 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -116,6 +116,7 @@
"justify": "Justifier",
"justifyTip": "Rendre le contenu aligné sur les côtés",
"rtl": "De droite à gauche (RTL)",
+ "ltr": "De gauche à droite (LTR)",
"rtlTip": "Rendre le contenu de droite à gauche",
"height": "haut",
"deactivateUser": "Désactiver le compte",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index 0eae26545d..4c0e047006 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -116,6 +116,7 @@
"justify": "兩側對齊",
"justifyTip": "將內容以兩側對齊的方式進行渲染",
"rtl": "從右到左(RTL)",
+ "ltr": "從左到右(LTR)",
"rtlTip": "將內容以從右到左的方式進行渲染",
"height": "高度",
"deactivateUser": "註銷賬號",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index bd39ea8689..5dfe7358b3 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -116,6 +116,7 @@
"justify": "两侧对齐",
"justifyTip": "将内容以两侧对齐的方式进行渲染",
"rtl": "从右到左(RTL)",
+ "ltr": "从左到右(LTR)",
"rtlTip": "将内容以从右到左的方式进行渲染",
"height": "高度",
"deactivateUser": "注销账号",
diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts
index 5cfef4e19f..6b73d46ede 100644
--- a/app/src/config/editor.ts
+++ b/app/src/config/editor.ts
@@ -69,6 +69,22 @@ export const editor = {
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" id="fullWidth" type="checkbox"${window.siyuan.config.editor.fullWidth ? " checked" : ""}/>
</label>
+<label class="fn__flex b3-label">
+ <div class="fn__flex-1">
+ ${window.siyuan.languages.justify}
+ <div class="b3-label__text">${window.siyuan.languages.justifyTip}</div>
+ </div>
+ <span class="fn__space"></span>
+ <input class="b3-switch fn__flex-center" id="justify" type="checkbox"${window.siyuan.config.editor.justify ? " checked" : ""}/>
+</label>
+<label class="fn__flex b3-label">
+ <div class="fn__flex-1">
+ ${window.siyuan.languages.rtl}
+ <div class="b3-label__text">${window.siyuan.languages.rtlTip}</div>
+ </div>
+ <span class="fn__space"></span>
+ <input class="b3-switch fn__flex-center" id="rtl" type="checkbox"${window.siyuan.config.editor.rtl ? " checked" : ""}/>
+</label>
<label class="fn__flex b3-label">
<div class="fn__flex-1">
${window.siyuan.languages.editReadonly}
@@ -273,6 +289,8 @@ export const editor = {
fetchPost("/api/setting/setEditor", {
fullWidth: (editor.element.querySelector("#fullWidth") as HTMLInputElement).checked,
+ justify: (editor.element.querySelector("#justify") as HTMLInputElement).checked,
+ rtl: (editor.element.querySelector("#rtl") as HTMLInputElement).checked,
readOnly: (editor.element.querySelector("#readOnly") as HTMLInputElement).checked,
displayBookmarkIcon: (editor.element.querySelector("#displayBookmarkIcon") as HTMLInputElement).checked,
displayNetImgMark: (editor.element.querySelector("#displayNetImgMark") as HTMLInputElement).checked,
diff --git a/app/src/config/search.ts b/app/src/config/search.ts
index a9fd8c36cd..dcaac4d730 100644
--- a/app/src/config/search.ts
+++ b/app/src/config/search.ts
@@ -16,7 +16,7 @@ export const initConfigSearch = (element: HTMLElement) => {
"md39", "md40", "fontSizeTip", "fontSize", "font", "font1", "generateHistory", "generateHistoryInterval",
"historyRetentionDays", "historyRetentionDaysTip", "clearHistory", "katexMacros", "katexMacrosTip",
"editReadonly", "editReadonlyTip", "embedBlockBreadcrumb", "embedBlockBreadcrumbTip", "outdentTip",
- "outdent", "floatWindowMode", "floatWindowModeTip"
+ "outdent", "floatWindowMode", "floatWindowModeTip", "justify", "justifyTip", "rtl", "rtlTip"
]),
// 文档树
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index eff3e84c1e..e1d0f73caa 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -1478,6 +1478,35 @@ export class Gutter {
e.style.textAlign = "justify";
});
}
+ }, {
+ type: "separator"
+ }, {
+ label: window.siyuan.languages.ltr,
+ icon: "iconRtl",
+ click: () => {
+ this.genClick(nodeElements, protyle, (e: HTMLElement) => {
+ e.style.direction = "ltr";
+ });
+ }
+ }, {
+ label: window.siyuan.languages.rtl,
+ icon: "iconRtl",
+ click: () => {
+ this.genClick(nodeElements, protyle, (e: HTMLElement) => {
+ e.style.direction = "rtl";
+ });
+ }
+ }, {
+ type: "separator"
+ }, {
+ label: window.siyuan.languages.clearFontStyle,
+ icon: "iconTrashcan",
+ click: () => {
+ this.genClick(nodeElements, protyle, (e: HTMLElement) => {
+ e.style.textAlign = "";
+ e.style.direction = "";
+ });
+ }
}]
}).element);
}
@@ -1662,7 +1691,7 @@ export class Gutter {
}]);
}
- public render(protyle:IProtyle, element: Element, wysiwyg: HTMLElement) {
+ public render(protyle: IProtyle, element: Element, wysiwyg: HTMLElement) {
// https://github.com/siyuan-note/siyuan/issues/4659
const titleElement = wysiwyg.parentElement.querySelector(".protyle-title__input");
if (titleElement && titleElement.getAttribute("data-render") !== "true") {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index d24f629fa5..4ac37d757f 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -245,6 +245,8 @@ declare interface IExport {
}
declare interface IEditor {
+ justify: boolean;
+ rtl: boolean;
readOnly: boolean;
listLogicalOutdent: boolean;
katexMacros: string;
diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts
index 787d960298..3dda76bcea 100644
--- a/app/src/util/assets.ts
+++ b/app/src/util/assets.ts
@@ -162,7 +162,8 @@ export const setInlineStyle = (set = true) => {
.protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h1, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h2, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h3, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h4, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h5, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h6 {line-height:${height + 8}px;}
.protyle-wysiwyg [data-node-id].li > .protyle-action:after {height: ${window.siyuan.config.editor.fontSize}px;width: ${window.siyuan.config.editor.fontSize}px;margin:-${window.siyuan.config.editor.fontSize / 2}px 0 0 -${window.siyuan.config.editor.fontSize / 2}px}
.protyle-wysiwyg [data-node-id].li > .protyle-action svg {height: ${Math.max(14, window.siyuan.config.editor.fontSize - 8)}px}
-.protyle-wysiwyg [data-node-id] [spellcheck="false"] {min-height:${height}px}
+.protyle-wysiwyg [data-node-id] [spellcheck="false"] {min-height:${height}px;}
+.protyle-wysiwyg [data-node-id] {${window.siyuan.config.editor.rtl?" direction: rtl;":""}${window.siyuan.config.editor.justify?" text-align: justify;":""}}
.protyle-wysiwyg .li {min-height:${height + 8}px}
.protyle-gutters button svg {height:${height}px}
.protyle-wysiwyg img.emoji, .b3-typography img.emoji {width:${height - 8}px}