Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Sep 23, 2024
2 parents d8ee9f3 + 43d15c9 commit 70fb00e
Show file tree
Hide file tree
Showing 13 changed files with 1,639 additions and 41 deletions.
1 change: 1 addition & 0 deletions app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"jumpToPage": "Jump to the specified page: 1 ~ ${x}",
"pageCountAndSnapshotCount": "Total ${x} pages, ${y} snapshots",
"pageCountAndHistoryCount": "Total ${x} pages, ${y} histories",
"visitCommunityShare": "Visit community share",
"clearContextSucc": "The context has been cleared",
"emptyMobilePlaceholder": "Record something",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"jumpToPage": "Saltar a la página especificada: 1 ~ ${x}",
"pageCountAndSnapshotCount": "Total ${x} páginas, ${y} instantáneas",
"pageCountAndHistoryCount": "Total ${x} páginas, ${y} historias",
"visitCommunityShare": "Visitar la comunidad compartida",
"clearContextSucc": "Se ha borrado el contexto",
"emptyMobilePlaceholder": "Grabar algo",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"jumpToPage": "Aller à la page spécifiée : 1 ~ ${x}",
"pageCountAndSnapshotCount": "Total de ${x} pages, ${y} instantanés",
"pageCountAndHistoryCount": "Total de ${x} pages, ${y} histoires",
"visitCommunityShare": "Visiter le partage communautaire",
"clearContextSucc": "Le contexte a été effacé",
"emptyMobilePlaceholder": "Enregistrer quelque chose",
Expand Down
1,555 changes: 1,555 additions & 0 deletions app/appearance/langs/it_IT.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"jumpToPage": "指定されたページにジャンプ:1 ~ ${x}",
"pageCountAndSnapshotCount": "合計 ${x} ページ、${y} スナップショット",
"pageCountAndHistoryCount": "合計 ${x} ページ、${y} 履歴",
"visitCommunityShare": "コミュニティシェアを訪問",
"clearContextSucc": "コンテキストがクリアされました",
"emptyMobilePlaceholder": "何かを記録する",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"jumpToPage": "跳轉到指定頁:1 ~ ${x}",
"pageCountAndSnapshotCount": "共 ${x} 頁,${y} 個快照",
"pageCountAndHistoryCount": "共 ${x} 頁,${y} 個歷史紀錄",
"visitCommunityShare": "訪問社區分享",
"clearContextSucc": "上下文已清空",
"emptyMobilePlaceholder": "記錄點什麼",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"jumpToPage": "跳转到指定页:1 ~ ${x}",
"pageCountAndSnapshotCount": "共 ${x} 页,${y} 个快照",
"pageCountAndHistoryCount": "共 ${x} 页,${y} 个历史版本",
"visitCommunityShare": "访问社区分享",
"clearContextSucc": "上下文已清空",
"emptyMobilePlaceholder": "记录点什么",
Expand Down
2 changes: 2 additions & 0 deletions app/electron/init.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ <h2>思源笔记</h2>
<option value="zh_CN">简体中文</option>
<option value="zh_CHT">繁體中文</option>
<option value="ja_JP">日本語</option>
<option value="it_IT">Italiano</option>
</select>
</label>
<label class="b3-label">
Expand Down Expand Up @@ -255,6 +256,7 @@ <h2>SiYuan</h2>
<option value="zh_CN">简体中文</option>
<option value="zh_CHT">繁體中文</option>
<option value="ja_JP">日本語</option>
<option value="it_IT">Italiano</option>
</select>
</label>
<label class="b3-label">
Expand Down
1 change: 1 addition & 0 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export abstract class Constants {
fr_FR: "20210808180117-6v0mkxr",
es_ES: "20210808180117-6v0mkxr",
ja_JP: "20240530133126-axarxgx",
it_IT: "20210808180117-6v0mkxr",
};
public static readonly QUICK_DECK_ID = "20230218211946-2kw8jgx";

Expand Down
106 changes: 68 additions & 38 deletions app/src/history/history.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {Dialog} from "../dialog";
import {confirmDialog} from "../dialog/confirmDialog";
import {Constants} from "../constants";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {renderAssetsPreview} from "../asset/renderAssets";
import {Protyle} from "../protyle";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
import { Dialog } from "../dialog";
import { confirmDialog } from "../dialog/confirmDialog";
import { Constants } from "../constants";
import { hasClosestByClassName } from "../protyle/util/hasClosest";
import { renderAssetsPreview } from "../asset/renderAssets";
import { Protyle } from "../protyle";
import { disabledProtyle, onGet } from "../protyle/util/onGet";
import * as dayjs from "dayjs";
import {fetchPost} from "../util/fetch";
import {escapeAttr, escapeHtml} from "../util/escape";
import {isMobile} from "../util/functions";
import {showDiff} from "./diff";
import {setStorageVal} from "../protyle/util/compatibility";
import {openModel} from "../mobile/menu/model";
import {closeModel} from "../mobile/util/closePanel";
import {App} from "../index";
import { fetchPost } from "../util/fetch";
import { escapeAttr, escapeHtml } from "../util/escape";
import { isMobile } from "../util/functions";
import { showDiff } from "./diff";
import { setStorageVal } from "../protyle/util/compatibility";
import { openModel } from "../mobile/menu/model";
import { closeModel } from "../mobile/util/closePanel";
import { App } from "../index";

let historyEditor: Protyle;

Expand All @@ -26,6 +26,9 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
} else {
previousElement.setAttribute("disabled", "disabled");
}
const pageBtn = element.querySelector('button[data-type="jumpHistoryPage"]');
pageBtn.textContent = `${currentPage}`;

const inputElement = element.querySelector(".b3-text-field") as HTMLInputElement;
const opElement = element.querySelector('.b3-select[data-type="opselect"]') as HTMLSelectElement;
const typeElement = element.querySelector('.b3-select[data-type="typeselect"]') as HTMLSelectElement;
Expand Down Expand Up @@ -80,7 +83,10 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
} else {
nextElement.setAttribute("disabled", "disabled");
}
nextElement.nextElementSibling.nextElementSibling.textContent = `${currentPage}/${response.data.pageCount || 1}`;
pageBtn.setAttribute("data-totalpage", (response.data.pageCount || 1).toString());
// nextElement.nextElementSibling.nextElementSibling.textContent = `${currentPage}/${response.data.pageCount || 1}`;
const titleElement = nextElement.nextElementSibling.nextElementSibling;
titleElement.textContent = `${window.siyuan.languages.pageCountAndHistoryCount.replace("${x}", response.data.pageCount).replace("${y}", response.data.totalCount || 1)}`;
if (response.data.histories.length === 0) {
listElement.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
return;
Expand Down Expand Up @@ -241,7 +247,7 @@ ${actionHTML}
const renderRepo = (element: Element, currentPage: number) => {
const selectValue = (element.querySelector(".b3-select") as HTMLSelectElement).value;
element.lastElementChild.innerHTML = '<li style="position: relative;height: 100%;"><div class="fn__loading"><img width="64px" src="/stage/loading-pure.svg"></div></li>';
const pageBtn = element.querySelector('button[data-type="jumpPage"]');
const pageBtn = element.querySelector('button[data-type="jumpRepoPage"]');
pageBtn.textContent = `${currentPage}`;

const previousElement = element.querySelector('[data-type="previous"]');
Expand All @@ -268,7 +274,7 @@ const renderRepo = (element: Element, currentPage: number) => {
previousElement.setAttribute("disabled", "disabled");
}
nextElement.setAttribute("disabled", "disabled");
fetchPost(`/api/repo/${selectValue}`, {page: currentPage}, (response) => {
fetchPost(`/api/repo/${selectValue}`, { page: currentPage }, (response) => {
if (currentPage < response.data.pageCount) {
nextElement.removeAttribute("disabled");
} else {
Expand Down Expand Up @@ -348,10 +354,10 @@ export const openHistory = (app: App) => {
<div style="overflow:auto;">
<div class="block__icons">
<span data-type="docprevious" class="block__icon block__icon--show b3-tooltips b3-tooltips__e" disabled="disabled" aria-label="${window.siyuan.languages.previousLabel}"><svg><use xlink:href='#iconLeft'></use></svg></span>
<span class="fn__space"></span>
<button class="b3-button b3-button--text" data-type="jumpHistoryPage" data-totalpage="1">1</button>
<span data-type="docnext" class="block__icon block__icon--show b3-tooltips b3-tooltips__e" disabled="disabled" aria-label="${window.siyuan.languages.nextLabel}"><svg><use xlink:href='#iconRight'></use></svg></span>
<span class="fn__space"></span>
<span>1/1</span>
<span class="ft__on-surface fn__flex-shrink ft__selectnone">${window.siyuan.languages.pageCountAndHistoryCount}</span>
<span class="fn__space"></span>
<div class="fn__flex-1"></div>
<div style="position: relative">
Expand Down Expand Up @@ -399,7 +405,7 @@ export const openHistory = (app: App) => {
<div style="overflow: auto"">
<div class="block__icons">
<span data-type="previous" class="block__icon block__icon--show b3-tooltips b3-tooltips__e" disabled="disabled" aria-label="${window.siyuan.languages.previousLabel}"><svg><use xlink:href='#iconLeft'></use></svg></span>
<button class="b3-button b3-button--text" data-type="jumpPage">1</button>
<button class="b3-button b3-button--text" data-type="jumpRepoPage">1</button>
<span data-type="next" class="block__icon block__icon--show b3-tooltips b3-tooltips__e" disabled="disabled" aria-label="${window.siyuan.languages.nextLabel}"><svg><use xlink:href='#iconRight'></use></svg></span>
<span class="fn__space"></span>
<span class="ft__on-surface fn__flex-shrink ft__selectnone">${window.siyuan.languages.pageCountAndSnapshotCount}</span>
Expand Down Expand Up @@ -645,7 +651,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
target.parentElement.querySelector(`.b3-list-item[data-id="${idJSON.splice(0, 1)[0].id}"]`)?.classList.remove("b3-list-item--focus");
}
}
idJSON.push({id, time: target.querySelector('[data-type="hCreated"]').textContent});
idJSON.push({ id, time: target.querySelector('[data-type="hCreated"]').textContent });
}

if (idJSON.length === 2) {
Expand Down Expand Up @@ -717,7 +723,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
genRepoDialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
fetchPost("/api/repo/createSnapshot", {memo: textareaElement.value}, () => {
fetchPost("/api/repo/createSnapshot", { memo: textareaElement.value }, () => {
renderRepo(repoElement, 1);
});
genRepoDialog.destroy();
Expand All @@ -728,7 +734,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
} else if (type === "removeRepoTagSnapshot" || type === "removeCloudRepoTagSnapshot") {
const tag = target.parentElement.getAttribute("data-tag");
confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.confirmDelete} <i>${tag}</i>?`, () => {
fetchPost("/api/repo/" + type, {tag}, () => {
fetchPost("/api/repo/" + type, { tag }, () => {
renderRepo(repoElement, 1);
});
});
Expand Down Expand Up @@ -803,24 +809,48 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
event.stopPropagation();
event.preventDefault();
break;
} else if (type === "jumpPage") {
} else if (type === "jumpRepoPage") {
const currentPage = parseInt(repoElement.getAttribute("data-page"));
const totalPage = parseInt(repoElement.getAttribute("total-page") || "1");

confirmDialog(
window.siyuan.languages.jumpToPage.replace("${x}", totalPage),
// eslint-disable-next-line quotes
`<input style="width: 100%;" class="b3-text-field fn__flex-center" type="number" min="1" max="${totalPage}" value="${currentPage}">`,
(dialog: Dialog) => {
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
if (inputElement.value === "") {
return;
if (totalPage > 1) {
confirmDialog(
window.siyuan.languages.jumpToPage.replace("${x}", totalPage),
// eslint-disable-next-line quotes
`<input style="width: 100%;" class="b3-text-field fn__flex-center" type="number" min="1" max="${totalPage}" value="${currentPage}">`,
(dialog: Dialog) => {
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
if (inputElement.value === "") {
return;
}
let page = parseInt(inputElement.value);
page = Math.max(1, Math.min(page, totalPage));
renderRepo(repoElement, page);
}
let page = parseInt(inputElement.value);
page = Math.max(1, Math.min(page, totalPage));
renderRepo(repoElement, page);
}
);
);
}
} else if (type === "jumpHistoryPage") {
const currentPage = parseInt(target.textContent.trim());
const totalPage = parseInt(target.getAttribute("data-totalpage") || "1");

if (totalPage > 1) {
confirmDialog(
window.siyuan.languages.jumpToPage.replace("${x}", totalPage),
// eslint-disable-next-line quotes
`<input style="width: 100%;" class="b3-text-field fn__flex-center" type="number" min="1" max="${totalPage}" value="${currentPage}">`,
(dialog: Dialog) => {
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
if (inputElement.value === "") {
return;
}
let page = parseInt(inputElement.value);
page = Math.max(1, Math.min(page, totalPage));
renderDoc(firstPanelElement, page);
}
);
}


} else if ((type === "docprevious" || type === "docnext") && target.getAttribute("disabled") !== "disabled") {
const currentPage = parseInt(firstPanelElement.getAttribute("data-page"));
renderDoc(firstPanelElement, type === "docprevious" ? currentPage - 1 : currentPage + 1);
Expand Down
6 changes: 5 additions & 1 deletion app/src/layout/dock/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ export class Graph extends Model {
case "NodeSuperBlock":
item.color = {background: rootStyle.getPropertyValue("--b3-graph-super-point").trim()};
break;
case "tag":
case "textmark tag":
item.color = {background: rootStyle.getPropertyValue("--b3-graph-tag-point").trim()};
break;
default:
item.color = {background: rootStyle.getPropertyValue("--b3-graph-p-point").trim()};
break;
Expand Down Expand Up @@ -658,7 +662,7 @@ export class Graph extends Model {
if (!node) {
return;
}
if (node.type === "textmark tag") {
if (-1 < node.type.indexOf("tag")) {
openGlobalSearch(this.app, `#${node.id}#`, !window.siyuan.ctrlIsPressed);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ declare namespace Config {
* User interface language
* Same as {@link IAppearance.lang}
*/
export type TLang = "en_US" | "es_ES" | "fr_FR" | "zh_CHT" | "zh_CN" | "ja_JP";
export type TLang = "en_US" | "es_ES" | "fr_FR" | "zh_CHT" | "zh_CN" | "ja_JP" | "it_IT";

/**
* SiYuan bazaar related configuration
Expand Down
2 changes: 1 addition & 1 deletion kernel/util/working.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Boot() {
readOnly := flag.String("readonly", "false", "read-only mode")
accessAuthCode := flag.String("accessAuthCode", "", "access auth code")
ssl := flag.Bool("ssl", false, "for https and wss")
lang := flag.String("lang", "", "zh_CN/zh_CHT/en_US/fr_FR/es_ES/ja_JP")
lang := flag.String("lang", "", "zh_CN/zh_CHT/en_US/fr_FR/es_ES/ja_JP/it_IT")
mode := flag.String("mode", "prod", "dev/prod")
flag.Parse()

Expand Down

0 comments on commit 70fb00e

Please sign in to comment.