Skip to content

Commit

Permalink
Merge pull request #19 from TCOTC/dev-extend
Browse files Browse the repository at this point in the history
Dev extend
  • Loading branch information
TCOTC authored Jul 27, 2024
2 parents c53cdc6 + 0603bda commit ce48956
Show file tree
Hide file tree
Showing 42 changed files with 612 additions and 416 deletions.
232 changes: 214 additions & 18 deletions app/appearance/emojis/conf.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"addToDatabase": "Add to Database",
"clearContext": "Clear context",
"cloudStoragePurge": "Purge cloud storage",
"cloudStoragePurgeConfirm": "Note:<ul class='fn__list'><li>Please ensure that other devices have paused sync before execution</li><li>The purge operation is very time-consuming, please ensure that the network is stable</li></ul>Are you sure to execute it now?",
"cloudStoragePurgeConfirm": "Purging the cloud storage will completely delete all unreferenced snapshots and related data objects. <ul class='fn__list'><li>Please ensure that other devices have paused sync before execution</li><li>The purge operation is very time-consuming, please ensure that the network is stable</li></ul>Are you sure to execute it now?",
"dragFill": "Drag vertically to fill value",
"switchReadonly": "Switch read-only mode",
"original": "Original",
Expand Down Expand Up @@ -525,6 +525,7 @@
"tagSnapshotTip": "Do not include symbols \\ / : * ? &quot; &#039; &lt; &gt; |",
"dataRepo": "Data repo",
"newSubDoc": "Create sub doc",
"newSubDocRef": "Create sub Doc with reference",
"newDocBelow": "Create doc below",
"newDocAbove": "Create doc above",
"fullWidth": "Adaptive Width",
Expand Down Expand Up @@ -1108,6 +1109,7 @@
"paragraphBeginningSpace": "Two empty spaces at the beginning of the paragraph",
"outline": "Outline",
"newFile": "New Doc",
"newFileRef": "Create new Doc with reference",
"close": "Close",
"delete": "Delete",
"rename": "Rename",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"addToDatabase": "Agregar a la base de datos",
"clearContext": "Borrar contexto",
"cloudStoragePurge": "Borrar almacenamiento en la nube",
"cloudStoragePurgeConfirm": "Nota:<ul class='fn__list'><li>Asegúrese de que otros dispositivos hayan pausado la sincronización antes de la ejecución</li><li>La operación de purga requiere mucho tiempo; asegúrese de que la red esté estable</li></ul>¿Está seguro de ejecutarla ahora?",
"cloudStoragePurgeConfirm": "Al purgar el almacenamiento en la nube se eliminarán por completo todas las instantáneas sin referencia y los objetos de datos relacionados.<ul class='fn__list'><li>Asegúrese de que otros dispositivos hayan pausado la sincronización antes de la ejecución</li><li>La operación de purga requiere mucho tiempo; asegúrese de que la red esté estable</li></ul>¿Está seguro de ejecutarla ahora?",
"dragFill": "Arrastra verticalmente para rellenar el valor",
"switchReadonly": "Cambiar modo de sólo lectura",
"original": "Original",
Expand Down Expand Up @@ -525,6 +525,7 @@
"tagSnapshotTip": "No incluir símbolos \\ / : * ? &quot; &#039; &lt; &gt; |",
"dataRepo": "Repositorio de datos",
"newSubDoc": "Crear subdocumento",
"newSubDocRef": "Crear subdocumento y hacer referencia",
"newDocBelow": "Crear documento a continuación",
"newDocAbove": "Crear documento arriba",
"fullWidth": "Ancho adaptable",
Expand Down Expand Up @@ -1108,6 +1109,7 @@
"paragraphBeginningSpace": "Dos espacios vacíos al principio del párrafo",
"outline": "Esquema",
"newFile": "Nuevo documento",
"newFileRef": "Crear un nuevo documento y hacer referencia",
"close": "Cerrar",
"delete": "Borrar",
"rename": "Cambiar nombre",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"addToDatabase": "Ajouter à la base de données",
"clearContext": "Effacer le contexte",
"cloudStoragePurge": "Purger le stockage cloud",
"cloudStoragePurgeConfirm": "Remarque :<ul class='fn__list'><li>Veuillez vous assurer que la synchronisation des autres appareils a été suspendue avant l'exécution</li><li>L'opération de purge prend beaucoup de temps, veuillez vous assurer que le réseau est stable</li></ul>Êtes-vous sûr de l'exécuter maintenant ?",
"cloudStoragePurgeConfirm": "La purge du stockage cloud supprimera complètement tous les instantanés non référencés et les objets de données associés. <ul class='fn__list'><li>Veuillez vous assurer que la synchronisation des autres appareils a été suspendue avant l'exécution</li><li>L'opération de purge prend beaucoup de temps, veuillez vous assurer que le réseau est stable</li></ul>Êtes-vous sûr de l'exécuter maintenant ?",
"dragFill": "Arrastra verticalmente para rellenar el valor",
"switchReadonly": "Changer de mode lecture seule",
"original": "Originale",
Expand Down Expand Up @@ -525,6 +525,7 @@
"tagSnapshotTip": "Ne pas inclure les symboles \\ / : * ? &quot; &#039; &lt; &gt; |",
"dataRepo": "Dépôt de données",
"newSubDoc": "Créer un sous-doc",
"newSubDocRef": "Créer un sous-doc et le référencer",
"newDocBelow": "Créer un document ci-dessous",
"newDocAbove": "Créer un document ci-dessus",
"fullWidth": "Largeur adaptative",
Expand Down Expand Up @@ -1108,6 +1109,7 @@
"paragraphBeginningSpace": "Deux espaces vides au début du paragraphe",
"outline": "Outline",
"newFile": "Nouveau Doc",
"newFileRef": "Créer un nouveau document et le citer",
"close": "Fermer",
"delete": "Supprimer",
"rename": "Renommer",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"addToDatabase": "データベースに追加",
"clearContext": "コンテキストを消去",
"cloudStoragePurge": "クラウドストレージを消去",
"cloudStoragePurgeConfirm": "注意: <ul class='fn__list'><li>実行前に他のデバイスが同期を一時停止していることを確認してください</li><li>消去操作は非常に時間がかかるため、ネットワークが安定していることを確認してください</li></ul>今すぐ実行してもよろしいですか?",
"cloudStoragePurgeConfirm": "クラウド ストレージを消去すると、参照されていないスナップショットと関連データ オブジェクトがすべて完全に削除されます。<ul class='fn__list'><li>実行前に他のデバイスが同期を一時停止していることを確認してください</li><li>消去操作は非常に時間がかかるため、ネットワークが安定していることを確認してください</li></ul>今すぐ実行してもよろしいですか?",
"dragFill": "ドロップダウンで値を入力する",
"switchReadonly": "読み取り専用モードの切り替え",
"original": "元の値",
Expand Down Expand Up @@ -525,6 +525,7 @@
"tagSnapshotTip": "次の記号を含めないでください \\ / : * ? &quot; &#039; &lt; &gt; |",
"dataRepo": "データリポジトリ",
"newSubDoc": "サブドキュメントを作成",
"newSubDocRef": "サブドキュメントを作成して参照する",
"newDocBelow": "下にドキュメントを作成",
"newDocAbove": "上にドキュメントを作成",
"fullWidth": "幅に合わせる",
Expand Down Expand Up @@ -1108,6 +1109,7 @@
"paragraphBeginningSpace": "段落の先頭にスペースを2つ挿入",
"outline": "アウトライン",
"newFile": "新規ドキュメント",
"newFileRef": "新規ドキュメントを作成して引用する",
"close": "閉じる",
"delete": "削除",
"rename": "名前の変更",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"addToDatabase": "新增至資料庫",
"clearContext": "清空上下文",
"cloudStoragePurge": "清理雲端儲存",
"cloudStoragePurgeConfirm": "請注意:<ul class='fn__list'><li>執行前請確保其他設備已經暫停同步</li><li>清理作業非常耗時,請確保網路穩定</li></ul>確定現在就執行嗎?",
"cloudStoragePurgeConfirm": "清理雲端儲存會徹底刪除所有未引用的快照和相關資料物件。<ul class='fn__list'><li>執行前請確保其他設備已經暫停同步</li><li>清理作業非常耗時,請確保網路穩定</li></ul>確定現在就執行嗎?",
"dragFill": "下拉填滿資料",
"switchReadonly": "唯讀模式切換",
"original": "原值",
Expand Down Expand Up @@ -525,6 +525,7 @@
"tagSnapshotTip": "請勿包含符號 \\ / : * ? &quot; &#039; &lt; &gt; |",
"dataRepo": "資料倉庫",
"newSubDoc": "新建子文檔",
"newSubDocRef": "新建子文檔並引用",
"newDocBelow": "在下方新建文檔",
"newDocAbove": "在上方新建文檔",
"fullWidth": "自適應寬度",
Expand Down Expand Up @@ -1108,6 +1109,7 @@
"paragraphBeginningSpace": "段落開頭空兩格",
"outline": "大綱",
"newFile": "新建文檔",
"newFileRef": "新建文檔並引用",
"close": "關閉",
"delete": "刪除",
"rename": "重命名",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"addToDatabase": "添加到数据库",
"clearContext": "清空上下文",
"cloudStoragePurge": "清理云端存储",
"cloudStoragePurgeConfirm": "请注意:<ul class='fn__list'><li>执行前请确保其他设备已经暂停同步</li><li>清理操作非常耗时,请确保网络稳定</li></ul> 确定现在就执行吗?",
"cloudStoragePurgeConfirm": "清理云端存储会彻底删除所有未引用的快照和相关数据对象。<ul class='fn__list'><li>执行前请确保其他设备已经暂停同步</li><li>清理操作非常耗时,请确保网络稳定</li></ul> 确定现在就执行吗?",
"dragFill": "下拉填充数据",
"switchReadonly": "只读模式切换",
"original": "原值",
Expand Down Expand Up @@ -525,6 +525,7 @@
"tagSnapshotTip": "请勿包含符号 \\ / : * ? &quot; &#039; &lt; &gt; |",
"dataRepo": "数据仓库",
"newSubDoc": "新建子文档",
"newSubDocRef": "新建子文档并引用",
"newDocBelow": "在下方新建文档",
"newDocAbove": "在上方新建文档",
"fullWidth": "自适应宽度",
Expand Down Expand Up @@ -1108,6 +1109,7 @@
"paragraphBeginningSpace": "段落开头空两格",
"outline": "大纲",
"newFile": "新建文档",
"newFileRef": "新建文档并引用",
"close": "关闭",
"delete": "删除",
"rename": "重命名",
Expand Down
8 changes: 6 additions & 2 deletions app/src/boot/globalEvent/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {Constants} from "../../constants";
import {isIPad} from "../../protyle/util/compatibility";
import {globalTouchEnd, globalTouchStart} from "./touch";
import {initDockMenu} from "../../menus/dock";
import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByAttribute} from "../../protyle/util/hasClosest";
import {
hasClosestByAttribute,
hasClosestByClassName,
isInEmbedBlock
} from "../../protyle/util/hasClosest";
import {initTabMenu} from "../../menus/tab";
import {getInstanceById} from "../../layout/util";
import {Tab} from "../../layout/Tab";
Expand Down Expand Up @@ -85,7 +89,7 @@ export const initWindowEvent = (app: App) => {
}
return;
}
const embedBlockElement = hasTopClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed");
const embedBlockElement = isInEmbedBlock(target);
if (embedBlockElement) {
embedBlockElement.firstElementChild.classList.toggle("protyle-icons--show");
return;
Expand Down
9 changes: 7 additions & 2 deletions app/src/boot/globalEvent/touch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {isIPad} from "../../protyle/util/compatibility";
import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByTag} from "../../protyle/util/hasClosest";
import {
hasClosestByAttribute,
hasClosestByClassName,
hasTopClosestByTag,
isInEmbedBlock
} from "../../protyle/util/hasClosest";
import {initFileMenu, initNavigationMenu} from "../../menus/navigation";
import {fileAnnotationRefMenu, inlineMathMenu, linkMenu, refMenu, tagMenu} from "../../menus/protyle";
import {App} from "../../index";
Expand Down Expand Up @@ -80,7 +85,7 @@ export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, a
return true;
}
// 内元素弹出菜单
if (target.tagName === "SPAN" && !hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed")) {
if (target.tagName === "SPAN" && !isInEmbedBlock(target)) {
let editor: Protyle;
/// #if !MOBILE
const tabContainerElement = hasClosestByClassName(target, "protyle", true);
Expand Down
13 changes: 9 additions & 4 deletions app/src/config/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const initConfigSearch = (element: HTMLElement, app: App) => {
"apiKeyTip", "apiProxy", "apiProxyTip", "apiBaseURL", "apiBaseURLTip", "apiUserAgentTip", "apiVersion", "apiVersionTip",
"apiProvider", "apiProviderTip", "apiTemperature", "apiTemperatureTip", "apiMaxContexts", "apiMaxContextsTip"])),

// 图片
// 资源
getLang(["assets", "unreferencedAssets", "missingAssets"]),

// 导出
Expand Down Expand Up @@ -76,15 +76,20 @@ export const initConfigSearch = (element: HTMLElement, app: App) => {
.concat(Object.keys(Constants.SIYUAN_KEYMAP.editor.list))
.concat(Object.keys(Constants.SIYUAN_KEYMAP.editor.table))),

// 账号
getLang(["accountTip", "accountName", "password", "captcha", "forgetPassword", "login", "register",
"twoFactorCaptcha", "account1", "account2", "account5"]),

// 云端
getLang(["cloudStorage", "trafficStat", "sync", "backup", "cdn", "total", "sizeLimit", "cloudBackup",
"cloudBackupTip", "updatePath", "cloudSync", "upload", "download", "syncMode", "syncModeTip",
"generateConflictDoc", "generateConflictDocTip", "syncProvider", "syncProviderTip",
"syncMode1", "syncMode2", "reposTip", "openSyncTip1", "openSyncTip2", "cloudSyncDir", "config"]),

// 账号
getLang(["accountTip", "accountName", "password", "captcha", "forgetPassword", "login", "register",
"twoFactorCaptcha", "account1", "account2", "account5"]),
// 发布
getLang(["publishService", "publishServiceTip", "publishServicePort", "publishServicePortTip",
"publishServiceAddresses", "publishServiceAddressesTip", "publishServiceAuth", "publishServiceAuthTip",
"publishServiceAuthAccounts", "publishServiceAuthAccountsTip"]),

// 关于
getLang(["autoLaunch", "autoLaunchTip", "about", "about1", "about2", "about3", "about4", "about5", "about6",
Expand Down
9 changes: 7 additions & 2 deletions app/src/editor/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import {ipcRenderer, shell} from "electron";
import {pushBack} from "../util/backForward";
import {Asset} from "../asset";
import {Layout} from "../layout";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName,} from "../protyle/util/hasClosest";
import {
hasClosestBlock,
hasClosestByAttribute,
hasClosestByClassName,
isInEmbedBlock,
} from "../protyle/util/hasClosest";
import {zoomOut} from "../menus/protyle";
import {countBlockWord, countSelectWord} from "../layout/status";
import {showMessage} from "../dialog/message";
Expand Down Expand Up @@ -349,7 +354,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod
}
let nodeElement: Element;
Array.from(editor.editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${options.id}"]`)).find(item => {
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
if (!isInEmbedBlock(item)) {
nodeElement = item;
return true;
}
Expand Down
9 changes: 7 additions & 2 deletions app/src/layout/Wnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {Tab} from "./Tab";
import {Model} from "./Model";
import {Editor} from "../editor";
import {Graph} from "./dock/Graph";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../protyle/util/hasClosest";
import {
hasClosestBlock,
hasClosestByAttribute,
hasClosestByClassName,
isInEmbedBlock
} from "../protyle/util/hasClosest";
import {Constants} from "../constants";
/// #if !BROWSER
import {webFrame, ipcRenderer} from "electron";
Expand Down Expand Up @@ -460,7 +465,7 @@ export class Wnd {
// 在新页签中打开,但不跳转到新页签,但切换到新页签时需调整滚动
let nodeElement: HTMLElement;
Array.from(currentTab.model.editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${keepCursorId}"]`)).find((item: HTMLElement) => {
if (!hasClosestByAttribute(item, "data-type", "NodeBlockQueryEmbed", true)) {
if (!isInEmbedBlock(item)) {
nodeElement = item;
return true;
}
Expand Down
11 changes: 9 additions & 2 deletions app/src/menus/protyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
let submenu: IMenu[] = [];
if (element.getAttribute("data-subtype") === "s") {
submenu.push({
iconHTML: "",
label: window.siyuan.languages.turnToDynamic,
click() {
element.setAttribute("data-subtype", "d");
Expand All @@ -485,6 +486,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
} else {
submenu.push({
iconHTML: "",
label: window.siyuan.languages.turnToStatic,
click() {
element.setAttribute("data-subtype", "s");
Expand All @@ -496,6 +498,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
}
submenu = submenu.concat([{
iconHTML: "",
label: window.siyuan.languages.text,
click() {
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
Expand All @@ -504,6 +507,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
oldHTML = nodeElement.outerHTML;
}
}, {
iconHTML: "",
label: "*",
click() {
element.setAttribute("data-subtype", "s");
Expand All @@ -514,6 +518,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
oldHTML = nodeElement.outerHTML;
}
}, {
iconHTML: "",
label: window.siyuan.languages.text + " *",
click() {
element.insertAdjacentHTML("beforebegin", element.innerHTML + " ");
Expand All @@ -526,7 +531,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}
}, {
label: window.siyuan.languages.link,
icon: "iconLink",
iconHTML: "",
click() {
element.outerHTML = `<span data-type="a" data-href="siyuan://blocks/${element.getAttribute("data-id")}">${element.innerHTML}</span><wbr>`;
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
Expand All @@ -537,8 +542,8 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}]);
if (element.parentElement.textContent.trim() === element.textContent.trim() && element.parentElement.tagName === "DIV") {
submenu.push({
iconHTML: "",
label: window.siyuan.languages.blockEmbed,
icon: "iconSQL",
click() {
const html = `<div data-content="select * from blocks where id='${refBlockId}'" data-node-id="${id}" data-type="NodeBlockQueryEmbed" class="render-node" updated="${dayjs().format("YYYYMMDDHHmmss")}">${nodeElement.querySelector(".protyle-attr").outerHTML}</div>`;
nodeElement.outerHTML = html;
Expand All @@ -549,6 +554,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
}
submenu.push({
iconHTML: "",
label: window.siyuan.languages.defBlock,
click() {
fetchPost("/api/block/swapBlockRef", {
Expand All @@ -559,6 +565,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}
});
submenu.push({
iconHTML: "",
label: window.siyuan.languages.defBlockChildren,
click() {
fetchPost("/api/block/swapBlockRef", {
Expand Down
Loading

0 comments on commit ce48956

Please sign in to comment.