mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
➖
This commit is contained in:
parent
77560d6601
commit
c5f35969eb
7 changed files with 52 additions and 62 deletions
|
|
@ -10,8 +10,8 @@ import {Dialog} from "./index";
|
||||||
import {isMobile} from "../util/functions";
|
import {isMobile} from "../util/functions";
|
||||||
import {confirmDialog} from "./confirmDialog";
|
import {confirmDialog} from "./confirmDialog";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
import {getCurrentWindow} from "@electron/remote";
|
||||||
import {getWorkspaceName} from "../menus/workspace";
|
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
|
import {getWorkspaceName} from "../util/noRelyPCFunction";
|
||||||
|
|
||||||
export const lockScreen = () => {
|
export const lockScreen = () => {
|
||||||
/// #if BROWSER
|
/// #if BROWSER
|
||||||
|
|
@ -278,13 +278,18 @@ export const setTitle = (title: string, protyle?: IProtyle) => {
|
||||||
if (title === window.siyuan.languages.siyuanNote) {
|
if (title === window.siyuan.languages.siyuanNote) {
|
||||||
const versionTitle = `${title} - ${workspaceName} - v${Constants.SIYUAN_VERSION}`;
|
const versionTitle = `${title} - ${workspaceName} - v${Constants.SIYUAN_VERSION}`;
|
||||||
document.title = versionTitle;
|
document.title = versionTitle;
|
||||||
dragElement.textContent = versionTitle;
|
if (dragElement) {
|
||||||
dragElement.setAttribute("title", versionTitle);
|
dragElement.textContent = versionTitle;
|
||||||
|
dragElement.setAttribute("title", versionTitle);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
title = title || "Untitled";
|
title = title || "Untitled";
|
||||||
document.title = `${title} - ${workspaceName} - ${window.siyuan.languages.siyuanNote} v${Constants.SIYUAN_VERSION}`;
|
document.title = `${title} - ${workspaceName} - ${window.siyuan.languages.siyuanNote} v${Constants.SIYUAN_VERSION}`;
|
||||||
|
if (!dragElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dragElement.setAttribute("title", title);
|
dragElement.setAttribute("title", title);
|
||||||
title = escapeHtml(title)
|
title = escapeHtml(title);
|
||||||
if (protyle && protyle.disabled) {
|
if (protyle && protyle.disabled) {
|
||||||
title = `${title}<span class="fn__space"></span><button id="barExitReadOnly" class="b3-button b3-button--small b3-button--success">${window.siyuan.languages.exitReadOnly}</button>`;
|
title = `${title}<span class="fn__space"></span><button id="barExitReadOnly" class="b3-button b3-button--small b3-button--success">${window.siyuan.languages.exitReadOnly}</button>`;
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +302,6 @@ export const setTitle = (title: string, protyle?: IProtyle) => {
|
||||||
|
|
||||||
export const updateTitle = (readonly?: boolean, zoomIn?: boolean, zoomInId?: string) => {
|
export const updateTitle = (readonly?: boolean, zoomIn?: boolean, zoomInId?: string) => {
|
||||||
const dragElement = document.getElementById("drag");
|
const dragElement = document.getElementById("drag");
|
||||||
const title = dragElement.textContent;
|
|
||||||
if (typeof readonly === "boolean") {
|
if (typeof readonly === "boolean") {
|
||||||
const barExitReadOnlyElement = dragElement.querySelector("#barExitReadOnly")
|
const barExitReadOnlyElement = dragElement.querySelector("#barExitReadOnly")
|
||||||
if (readonly && !barExitReadOnlyElement) {
|
if (readonly && !barExitReadOnlyElement) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {openGlobalSearch} from "../../search/util";
|
||||||
import {MenuItem} from "../../menus/Menu";
|
import {MenuItem} from "../../menus/Menu";
|
||||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||||
import {escapeHtml} from "../../util/escape";
|
import {escapeHtml} from "../../util/escape";
|
||||||
import {renameTag} from "./util";
|
import {renameTag} from "../../util/noRelyPCFunction";
|
||||||
|
|
||||||
export class Tag extends Model {
|
export class Tag extends Model {
|
||||||
private openNodes: string[];
|
private openNodes: string[];
|
||||||
|
|
|
||||||
|
|
@ -87,28 +87,3 @@ export const openOutline = (protyle: IProtyle) => {
|
||||||
newWnd.element.style.width = "200px";
|
newWnd.element.style.width = "200px";
|
||||||
switchWnd(newWnd, protyle.model.parent.parent);
|
switchWnd(newWnd, protyle.model.parent.parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const renameTag = (labelName: string) => {
|
|
||||||
const dialog = new Dialog({
|
|
||||||
title: window.siyuan.languages.rename,
|
|
||||||
content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value="${labelName}"></div>
|
|
||||||
<div class="b3-dialog__action">
|
|
||||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
|
||||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
|
||||||
</div>`,
|
|
||||||
width: "520px",
|
|
||||||
});
|
|
||||||
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
|
||||||
btnsElement[0].addEventListener("click", () => {
|
|
||||||
dialog.destroy();
|
|
||||||
});
|
|
||||||
const inputElement = dialog.element.querySelector("input");
|
|
||||||
dialog.bindInput(inputElement, () => {
|
|
||||||
(btnsElement[1] as HTMLButtonElement).click();
|
|
||||||
});
|
|
||||||
inputElement.focus();
|
|
||||||
inputElement.select();
|
|
||||||
btnsElement[1].addEventListener("click", () => {
|
|
||||||
fetchPost("/api/tag/renameTag", {oldLabel: labelName, newLabel: inputElement.value});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,9 @@ import {getAllModels} from "../layout/getAll";
|
||||||
import {pasteAsPlainText, pasteText} from "../protyle/util/paste";
|
import {pasteAsPlainText, pasteText} from "../protyle/util/paste";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {openFileById, updateBacklinkGraph} from "../editor/util";
|
import {openFileById, updateBacklinkGraph} from "../editor/util";
|
||||||
|
import {openGlobalSearch} from "../search/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isMobile} from "../util/functions";
|
import {getSearch, isMobile} from "../util/functions";
|
||||||
import {removeFoldHeading} from "../protyle/util/heading";
|
import {removeFoldHeading} from "../protyle/util/heading";
|
||||||
import {lineNumberRender} from "../protyle/markdown/highlightRender";
|
import {lineNumberRender} from "../protyle/markdown/highlightRender";
|
||||||
import * as dayjs from "dayjs";
|
import * as dayjs from "dayjs";
|
||||||
|
|
@ -46,8 +47,7 @@ import {removeLink} from "../protyle/toolbar/Link";
|
||||||
import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";
|
import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";
|
||||||
import {getEnableHTML} from "../protyle/wysiwyg/removeEmbed";
|
import {getEnableHTML} from "../protyle/wysiwyg/removeEmbed";
|
||||||
import {updateTitle} from "../dialog/processSystem";
|
import {updateTitle} from "../dialog/processSystem";
|
||||||
import {renameTag} from "../layout/dock/util";
|
import {renameTag} from "../util/noRelyPCFunction";
|
||||||
import {openGlobalSearch} from "../search/util";
|
|
||||||
|
|
||||||
export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
const nodeElement = hasClosestBlock(element);
|
const nodeElement = hasClosestBlock(element);
|
||||||
|
|
@ -948,6 +948,7 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
|
/// #if !MOBILE
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.search,
|
label: window.siyuan.languages.search,
|
||||||
accelerator: "Click",
|
accelerator: "Click",
|
||||||
|
|
@ -956,6 +957,7 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
|
||||||
openGlobalSearch(`#${tagElement.textContent}#`, false);
|
openGlobalSearch(`#${tagElement.textContent}#`, false);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
|
/// #endif
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: `${window.siyuan.languages.turnInto} <b>${window.siyuan.languages.text}</b>`,
|
label: `${window.siyuan.languages.turnInto} <b>${window.siyuan.languages.text}</b>`,
|
||||||
icon: "iconRefresh",
|
icon: "iconRefresh",
|
||||||
|
|
@ -1018,7 +1020,7 @@ export const iframeMenu = (protyle: IProtyle, nodeElement: Element) => {
|
||||||
const biliMatch = value.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/);
|
const biliMatch = value.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/);
|
||||||
if (value.indexOf("bilibili.com") > -1 && (value.indexOf("bvid=") > -1 || (biliMatch && biliMatch[1]))) {
|
if (value.indexOf("bilibili.com") > -1 && (value.indexOf("bvid=") > -1 || (biliMatch && biliMatch[1]))) {
|
||||||
const params: IObject = {
|
const params: IObject = {
|
||||||
bvid: value.indexOf("bvid=") > -1 ? value.split("bvid=")[1].split("&")[0] : (biliMatch && biliMatch[1]),
|
bvid: getSearch("bvid", value) || (biliMatch && biliMatch[1]),
|
||||||
page: "1",
|
page: "1",
|
||||||
high_quality: "1",
|
high_quality: "1",
|
||||||
as_wide: "1",
|
as_wide: "1",
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,3 @@ const workspaceItem = (item: IWorkspace) => {
|
||||||
};
|
};
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWorkspaceName = () => {
|
|
||||||
return window.siyuan.config.system.workspaceDir.replace(/^.*[\\\/]/, "");
|
|
||||||
};
|
|
||||||
|
|
|
||||||
33
app/src/util/noRelyPCFunction.ts
Normal file
33
app/src/util/noRelyPCFunction.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
import {Dialog} from "../dialog";
|
||||||
|
import {fetchPost} from "./fetch";
|
||||||
|
import {isMobile} from "./functions";
|
||||||
|
|
||||||
|
// 需独立出来,否则移动端引用的时候会引入 pc 端大量无用代码
|
||||||
|
export const renameTag = (labelName: string) => {
|
||||||
|
const dialog = new Dialog({
|
||||||
|
title: window.siyuan.languages.rename,
|
||||||
|
content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value="${labelName}"></div>
|
||||||
|
<div class="b3-dialog__action">
|
||||||
|
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||||
|
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||||
|
</div>`,
|
||||||
|
width: isMobile() ? "80vw": "520px",
|
||||||
|
});
|
||||||
|
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||||
|
btnsElement[0].addEventListener("click", () => {
|
||||||
|
dialog.destroy();
|
||||||
|
});
|
||||||
|
const inputElement = dialog.element.querySelector("input");
|
||||||
|
dialog.bindInput(inputElement, () => {
|
||||||
|
(btnsElement[1] as HTMLButtonElement).click();
|
||||||
|
});
|
||||||
|
inputElement.focus();
|
||||||
|
inputElement.select();
|
||||||
|
btnsElement[1].addEventListener("click", () => {
|
||||||
|
fetchPost("/api/tag/renameTag", {oldLabel: labelName, newLabel: inputElement.value});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getWorkspaceName = () => {
|
||||||
|
return window.siyuan.config.system.workspaceDir.replace(/^.*[\\\/]/, "");
|
||||||
|
};
|
||||||
|
|
@ -27,10 +27,11 @@ import {showMessage} from "../dialog/message";
|
||||||
import {editor} from "../config/editor";
|
import {editor} from "../config/editor";
|
||||||
import {goBack, goForward} from "./backForward";
|
import {goBack, goForward} from "./backForward";
|
||||||
import {replaceLocalPath} from "../editor/rename";
|
import {replaceLocalPath} from "../editor/rename";
|
||||||
import {getWorkspaceName, workspaceMenu} from "../menus/workspace";
|
import {workspaceMenu} from "../menus/workspace";
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
import {zoomOut} from "../menus/protyle";
|
import {zoomOut} from "../menus/protyle";
|
||||||
|
import { getWorkspaceName } from "./noRelyPCFunction";
|
||||||
|
|
||||||
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
||||||
if (key1 === "general") {
|
if (key1 === "general") {
|
||||||
|
|
@ -105,16 +106,7 @@ export const setProxy = () => {
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
// 获取 location.search 里特定参数,失败返回false
|
|
||||||
function getUrlArg(arg_name: string) {
|
|
||||||
var query = window.location.search.substring(1);
|
|
||||||
var vars = query.split("&");
|
|
||||||
for (var i=0;i<vars.length;i++) {
|
|
||||||
var pair = vars[i].split("=");
|
|
||||||
if(pair[0] == arg_name){return pair[1];}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
export const onGetConfig = (isStart: boolean) => {
|
export const onGetConfig = (isStart: boolean) => {
|
||||||
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
||||||
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
||||||
|
|
@ -188,18 +180,6 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
}
|
}
|
||||||
addGA();
|
addGA();
|
||||||
//根据url里的id参数打开相应的块,用于浏览器访问
|
|
||||||
let url_doc_id=getUrlArg("id")
|
|
||||||
if (url_doc_id) {
|
|
||||||
fetchPost("/api/block/getBlockInfo", {id: url_doc_id}, response => {
|
|
||||||
if (response.code === 0 && typeof url_doc_id === "string") {
|
|
||||||
openFileById({
|
|
||||||
id: url_doc_id,
|
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT,]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const initBar = () => {
|
const initBar = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue