mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 23:50:13 +01:00
This commit is contained in:
parent
f25b36ff38
commit
cd40ec50bb
21 changed files with 341 additions and 398 deletions
|
|
@ -287,7 +287,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {
|
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event) && !window.siyuan.config.readonly) {
|
||||||
if (protyle.title?.editElement.contains(range.startContainer)) {
|
if (protyle.title?.editElement.contains(range.startContainer)) {
|
||||||
quickMakeCard(protyle, [protyle.title.element]);
|
quickMakeCard(protyle, [protyle.title.element]);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -316,7 +316,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) {
|
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) {
|
||||||
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
|
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
|
||||||
openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title?.editElement.textContent || window.siyuan.languages.untitled);
|
openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title?.editElement.textContent || window.siyuan.languages.untitled);
|
||||||
});
|
});
|
||||||
|
|
@ -593,7 +593,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
const pathString = liElements[0].getAttribute("data-path");
|
const pathString = liElements[0].getAttribute("data-path");
|
||||||
const isFile = liElements[0].getAttribute("data-type") === "navigation-file";
|
const isFile = liElements[0].getAttribute("data-type") === "navigation-file";
|
||||||
|
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) {
|
||||||
if (isFile) {
|
if (isFile) {
|
||||||
const id = liElements[0].getAttribute("data-node-id");
|
const id = liElements[0].getAttribute("data-node-id");
|
||||||
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => {
|
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => {
|
||||||
|
|
|
||||||
|
|
@ -672,6 +672,9 @@ const emitEvent = (app: App, card: ICard, type: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const openCard = (app: App) => {
|
export const openCard = (app: App) => {
|
||||||
|
if (window.siyuan.config.readonly) {
|
||||||
|
return
|
||||||
|
}
|
||||||
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
|
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
|
||||||
openCardByData(app, cardsResponse.data, "all");
|
openCardByData(app, cardsResponse.data, "all");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -310,12 +310,10 @@ export const editor = {
|
||||||
if (fontFamilyElement.tagName === "SELECT") {
|
if (fontFamilyElement.tagName === "SELECT") {
|
||||||
let fontFamilyHTML = `<option value="">${window.siyuan.languages.default}</option>`;
|
let fontFamilyHTML = `<option value="">${window.siyuan.languages.default}</option>`;
|
||||||
fetchPost("/api/system/getSysFonts", {}, (response) => {
|
fetchPost("/api/system/getSysFonts", {}, (response) => {
|
||||||
if (response.code === 0) {
|
|
||||||
response.data.forEach((item: string) => {
|
response.data.forEach((item: string) => {
|
||||||
fontFamilyHTML += `<option value="${item}"${window.siyuan.config.editor.fontFamily === item ? " selected" : ""}>${item}</option>`;
|
fontFamilyHTML += `<option value="${item}"${window.siyuan.config.editor.fontFamily === item ? " selected" : ""}>${item}</option>`;
|
||||||
});
|
});
|
||||||
fontFamilyElement.innerHTML = fontFamilyHTML;
|
fontFamilyElement.innerHTML = fontFamilyHTML;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
editor.element.querySelector("#clearHistory").addEventListener("click", () => {
|
editor.element.querySelector("#clearHistory").addEventListener("click", () => {
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ export class App {
|
||||||
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
||||||
/// #endif
|
/// #endif
|
||||||
addBaseURL();
|
addBaseURL();
|
||||||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"),
|
|
||||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"),
|
|
||||||
|
|
||||||
this.appId = Constants.SIYUAN_APPID;
|
this.appId = Constants.SIYUAN_APPID;
|
||||||
window.siyuan = {
|
window.siyuan = {
|
||||||
|
|
@ -160,41 +158,25 @@ export class App {
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchPost("/api/system/getConf", {}, async (response) => {
|
fetchPost("/api/system/getConf", {}, async (response) => {
|
||||||
|
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||||
|
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||||
window.siyuan.config = response.data.conf;
|
window.siyuan.config = response.data.conf;
|
||||||
|
await loadPlugins(this);
|
||||||
const promises = [
|
getLocalStorage(() => {
|
||||||
loadPlugins(this),
|
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
|
||||||
new Promise<void>(resolve => getLocalStorage(resolve)),
|
|
||||||
new Promise<void>(resolve => fetchGet(
|
|
||||||
`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`,
|
|
||||||
(lauguages: IObject) => {
|
|
||||||
window.siyuan.languages = lauguages;
|
window.siyuan.languages = lauguages;
|
||||||
resolve();
|
window.siyuan.menus = new Menus(this);
|
||||||
},
|
bootSync();
|
||||||
)),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!window.siyuan.config.readonly) {
|
|
||||||
promises.push(new Promise<void>(resolve => {
|
|
||||||
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
||||||
window.siyuan.user = userResponse.data;
|
window.siyuan.user = userResponse.data;
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises);
|
|
||||||
|
|
||||||
if (!window.siyuan.config.readonly) {
|
|
||||||
bootSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.siyuan.menus = new Menus(this);
|
|
||||||
onGetConfig(response.data.start, this);
|
onGetConfig(response.data.start, this);
|
||||||
account.onSetaccount();
|
account.onSetaccount();
|
||||||
setTitle(window.siyuan.languages.siyuanNote);
|
setTitle(window.siyuan.languages.siyuanNote);
|
||||||
initMessage();
|
initMessage();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
setNoteBook();
|
setNoteBook();
|
||||||
initBlockPopover(this);
|
initBlockPopover(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ export class Wnd {
|
||||||
<ul class="fn__flex layout-tab-bar"></ul>
|
<ul class="fn__flex layout-tab-bar"></ul>
|
||||||
<ul class="layout-tab-bar layout-tab-bar--readonly fn__flex-1">
|
<ul class="layout-tab-bar layout-tab-bar--readonly fn__flex-1">
|
||||||
<li class="item item--readonly">
|
<li class="item item--readonly">
|
||||||
<span data-type="new" class="block__icon block__icon--show ariaLabel" aria-label="${window.siyuan.languages.newFile}"><svg><use xlink:href="#iconAdd"></use></svg></span>
|
<span data-type="new" class="block__icon block__icon--show ariaLabel${window.siyuan.config.readonly ? " fn__none" : ""}" aria-label="${window.siyuan.languages.newFile}"><svg><use xlink:href="#iconAdd"></use></svg></span>
|
||||||
<span class="fn__flex-1"></span>
|
<span class="fn__flex-1"></span>
|
||||||
<span data-type="more" data-menu="true" class="block__icon block__icon--show ariaLabel" aria-label="${window.siyuan.languages.switchTab}"><svg><use xlink:href="#iconDown"></use></svg></span>
|
<span data-type="more" data-menu="true" class="block__icon block__icon--show ariaLabel" aria-label="${window.siyuan.languages.switchTab}"><svg><use xlink:href="#iconDown"></use></svg></span>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -105,7 +105,7 @@ export class Wnd {
|
||||||
this.headersElement.parentElement.addEventListener("click", (event) => {
|
this.headersElement.parentElement.addEventListener("click", (event) => {
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isEqualNode(this.headersElement)) {
|
while (target && !target.isEqualNode(this.headersElement)) {
|
||||||
if (target.classList.contains("block__icon") && target.getAttribute("data-type") === "new" && !window.siyuan.config.readonly) {
|
if (target.classList.contains("block__icon") && target.getAttribute("data-type") === "new") {
|
||||||
setPanelFocus(this.headersElement.parentElement.parentElement);
|
setPanelFocus(this.headersElement.parentElement.parentElement);
|
||||||
newFile({
|
newFile({
|
||||||
app,
|
app,
|
||||||
|
|
|
||||||
|
|
@ -64,16 +64,14 @@ export const initStatus = (isWindow = false) => {
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-name", "statusHelp");
|
window.siyuan.menus.menu.element.setAttribute("data-name", "statusHelp");
|
||||||
if (!isIPad()) {
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.userGuide,
|
label: window.siyuan.languages.userGuide,
|
||||||
icon: "iconHelp",
|
icon: "iconHelp",
|
||||||
disabled: window.siyuan.config.readonly,
|
ignore: isIPad() || window.siyuan.config.readonly,
|
||||||
click: () => {
|
click: () => {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.feedback,
|
label: window.siyuan.languages.feedback,
|
||||||
icon: "iconFeedback",
|
icon: "iconFeedback",
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ export const newCenterEmptyTab = (app: App) => {
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconFilesRoot"></use></svg>
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconFilesRoot"></use></svg>
|
||||||
<span>${window.siyuan.languages.newNotebook}</span>
|
<span>${window.siyuan.languages.newNotebook}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="b3-list-item${isIPad() ? " fn__none" : ""}" id="editorEmptyHelp">
|
<div class="b3-list-item${(isIPad() || window.siyuan.config.readonly) ? " fn__none" : ""}" id="editorEmptyHelp">
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg>
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg>
|
||||||
<span>${window.siyuan.languages.userGuide}</span>
|
<span>${window.siyuan.languages.userGuide}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -301,17 +301,15 @@ export const setZoom = (type: "zoomIn" | "zoomOut" | "restore") => {
|
||||||
|
|
||||||
const openPlugin = (app: App, target: Element) => {
|
const openPlugin = (app: App, target: Element) => {
|
||||||
const menu = new Menu("topBarPlugin");
|
const menu = new Menu("topBarPlugin");
|
||||||
if (!isHuawei()) {
|
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
icon: "iconSettings",
|
icon: "iconSettings",
|
||||||
label: window.siyuan.languages.manage,
|
label: window.siyuan.languages.manage,
|
||||||
disabled: window.siyuan.config.readonly,
|
ignore: isHuawei() || window.siyuan.config.readonly,
|
||||||
click() {
|
click() {
|
||||||
openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click"));
|
openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.addSeparator();
|
menu.addSeparator(undefined, isHuawei() || window.siyuan.config.readonly);
|
||||||
}
|
|
||||||
let hasPlugin = false;
|
let hasPlugin = false;
|
||||||
app.plugins.forEach((plugin) => {
|
app.plugins.forEach((plugin) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,9 @@ export class MenuItem {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
||||||
constructor(options: IMenu) {
|
constructor(options: IMenu) {
|
||||||
|
if (options.ignore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (options.type === "empty") {
|
if (options.type === "empty") {
|
||||||
this.element = document.createElement("div");
|
this.element = document.createElement("div");
|
||||||
this.element.innerHTML = options.label;
|
this.element.innerHTML = options.label;
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,6 @@ export const exportMd = (id: string) => {
|
||||||
label: window.siyuan.languages.template,
|
label: window.siyuan.languages.template,
|
||||||
iconClass: "ft__error",
|
iconClass: "ft__error",
|
||||||
icon: "iconMarkdown",
|
icon: "iconMarkdown",
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click: async () => {
|
click: async () => {
|
||||||
const result = await fetchSyncPost("/api/block/getRefText", {id: id});
|
const result = await fetchSyncPost("/api/block/getRefText", {id: id});
|
||||||
|
|
||||||
|
|
@ -508,9 +507,8 @@ export const exportMd = (id: string) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} else if (response.code === 0) {
|
|
||||||
showMessage(window.siyuan.languages.exportTplSucc);
|
|
||||||
}
|
}
|
||||||
|
showMessage(window.siyuan.languages.exportTplSucc);
|
||||||
});
|
});
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
|
||||||
return window.siyuan.menus.menu;
|
return window.siyuan.menus.menu;
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
|
if (!window.siyuan.config.readonly) {
|
||||||
const riffCardMenu = [{
|
const riffCardMenu = [{
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
|
||||||
|
|
@ -118,6 +119,7 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
|
||||||
submenu: riffCardMenu,
|
submenu: riffCardMenu,
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
|
}
|
||||||
openEditorTab(app, blockIDs);
|
openEditorTab(app, blockIDs);
|
||||||
if (app.plugins) {
|
if (app.plugins) {
|
||||||
emitOpenMenu({
|
emitOpenMenu({
|
||||||
|
|
@ -201,6 +203,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
|
||||||
submenu: subMenu,
|
submenu: subMenu,
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
|
if (!window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.riffCard,
|
label: window.siyuan.languages.riffCard,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
|
|
@ -228,6 +231,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
}).element);
|
}).element);
|
||||||
|
}
|
||||||
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: window.siyuan.config.keymap.general.search.custom,
|
accelerator: window.siyuan.config.keymap.general.search.custom,
|
||||||
|
|
@ -471,6 +475,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
|
if (!window.siyuan.config.readonly) {
|
||||||
const riffCardMenu = [{
|
const riffCardMenu = [{
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.spaceRepetition,
|
label: window.siyuan.languages.spaceRepetition,
|
||||||
|
|
@ -541,6 +546,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
|
||||||
icon: "iconRiffCard",
|
icon: "iconRiffCard",
|
||||||
submenu: riffCardMenu,
|
submenu: riffCardMenu,
|
||||||
}).element);
|
}).element);
|
||||||
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.search,
|
label: window.siyuan.languages.search,
|
||||||
icon: "iconSearch",
|
icon: "iconSearch",
|
||||||
|
|
|
||||||
|
|
@ -391,6 +391,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
submenu
|
submenu
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
|
if (!window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.riffCard,
|
label: window.siyuan.languages.riffCard,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
|
|
@ -410,6 +411,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
}).element);
|
}).element);
|
||||||
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.recentDocs,
|
label: window.siyuan.languages.recentDocs,
|
||||||
icon: "iconFile",
|
icon: "iconFile",
|
||||||
|
|
@ -436,16 +438,14 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
}
|
}
|
||||||
if (!isIPad()) {
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.userGuide,
|
label: window.siyuan.languages.userGuide,
|
||||||
icon: "iconHelp",
|
icon: "iconHelp",
|
||||||
disabled: window.siyuan.config.readonly,
|
ignore: isIPad() || window.siyuan.config.readonly,
|
||||||
click: () => {
|
click: () => {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.feedback,
|
label: window.siyuan.languages.feedback,
|
||||||
icon: "iconFeedback",
|
icon: "iconFeedback",
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,6 @@ class App {
|
||||||
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
||||||
}
|
}
|
||||||
addBaseURL();
|
addBaseURL();
|
||||||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
|
||||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
|
||||||
|
|
||||||
this.appId = Constants.SIYUAN_APPID;
|
this.appId = Constants.SIYUAN_APPID;
|
||||||
window.siyuan = {
|
window.siyuan = {
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
|
|
@ -88,9 +85,34 @@ class App {
|
||||||
updateCardHV();
|
updateCardHV();
|
||||||
});
|
});
|
||||||
fetchPost("/api/system/getConf", {}, async (confResponse) => {
|
fetchPost("/api/system/getConf", {}, async (confResponse) => {
|
||||||
|
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||||
|
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||||
window.siyuan.config = confResponse.data.conf;
|
window.siyuan.config = confResponse.data.conf;
|
||||||
correctHotkey(siyuanApp);
|
correctHotkey(siyuanApp);
|
||||||
|
await loadPlugins(this);
|
||||||
|
getLocalStorage(() => {
|
||||||
|
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
|
||||||
|
window.siyuan.languages = lauguages;
|
||||||
|
window.siyuan.menus = new Menus(this);
|
||||||
|
document.title = window.siyuan.languages.siyuanNote;
|
||||||
|
bootSync();
|
||||||
|
loadAssets(confResponse.data.conf.appearance);
|
||||||
|
initMessage();
|
||||||
|
initAssets();
|
||||||
|
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
||||||
|
window.siyuan.user = userResponse.data;
|
||||||
|
fetchPost("/api/system/getEmojiConf", {}, emojiResponse => {
|
||||||
|
window.siyuan.emojis = emojiResponse.data as IEmoji[];
|
||||||
|
setNoteBook(() => {
|
||||||
|
initFramework(this, confResponse.data.start);
|
||||||
|
initRightMenu(this);
|
||||||
|
openChangelog();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
addGA();
|
||||||
|
});
|
||||||
|
});
|
||||||
document.addEventListener("touchstart", handleTouchStart, false);
|
document.addEventListener("touchstart", handleTouchStart, false);
|
||||||
document.addEventListener("touchmove", handleTouchMove, false);
|
document.addEventListener("touchmove", handleTouchMove, false);
|
||||||
document.addEventListener("touchend", (event) => {
|
document.addEventListener("touchend", (event) => {
|
||||||
|
|
@ -118,51 +140,6 @@ class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const promises = [
|
|
||||||
loadPlugins(this),
|
|
||||||
new Promise<void>(resolve => getLocalStorage(resolve)),
|
|
||||||
new Promise<void>(resolve => fetchGet(
|
|
||||||
`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`,
|
|
||||||
(lauguages: IObject) => {
|
|
||||||
window.siyuan.languages = lauguages;
|
|
||||||
resolve();
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
new Promise<void>(resolve => {
|
|
||||||
fetchPost("/api/setting/getEmojiConf", {}, emojiResponse => {
|
|
||||||
window.siyuan.emojis = emojiResponse.data as IEmoji[];
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!window.siyuan.config.readonly) {
|
|
||||||
promises.push(new Promise<void>(resolve => {
|
|
||||||
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
|
||||||
window.siyuan.user = userResponse.data;
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises);
|
|
||||||
|
|
||||||
if (!window.siyuan.config.readonly) {
|
|
||||||
bootSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.siyuan.menus = new Menus(this);
|
|
||||||
document.title = window.siyuan.languages.siyuanNote;
|
|
||||||
loadAssets(confResponse.data.conf.appearance);
|
|
||||||
initMessage();
|
|
||||||
initAssets();
|
|
||||||
setNoteBook(() => {
|
|
||||||
initFramework(this, confResponse.data.start);
|
|
||||||
initRightMenu(this);
|
|
||||||
openChangelog();
|
|
||||||
});
|
|
||||||
addGA();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ export const initRightMenu = (app: App) => {
|
||||||
<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>
|
<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="b3-menu__separator"></div>
|
<div class="b3-menu__separator"></div>
|
||||||
<div class="b3-menu__item${isIPhone() ? " fn__none" : ""}" id="menuHelp">
|
<div class="b3-menu__item${(isIPhone() || window.siyuan.config.readonly) ? " fn__none" : ""}" id="menuHelp">
|
||||||
<svg class="b3-menu__icon"><use xlink:href="#iconHelp"></use></svg><span class="b3-menu__label">${window.siyuan.languages.userGuide}</span>
|
<svg class="b3-menu__icon"><use xlink:href="#iconHelp"></use></svg><span class="b3-menu__label">${window.siyuan.languages.userGuide}</span>
|
||||||
</div>
|
</div>
|
||||||
<a class="b3-menu__item" href="${"zh_CN" === window.siyuan.config.lang || "zh_CHT" === window.siyuan.config.lang ? "https://ld246.com/article/1649901726096" : "https://liuyun.io/article/1686530886208"}" target="_blank">
|
<a class="b3-menu__item" href="${"zh_CN" === window.siyuan.config.lang || "zh_CHT" === window.siyuan.config.lang ? "https://ld246.com/article/1649901726096" : "https://liuyun.io/article/1686530886208"}" target="_blank">
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export const setEmpty = (app: App) => {
|
||||||
<div class="b3-list-item" id="emptyNewNotebook${window.siyuan.config.readonly ? " fn__none" : ""}">
|
<div class="b3-list-item" id="emptyNewNotebook${window.siyuan.config.readonly ? " fn__none" : ""}">
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconFilesRoot"></use></svg><span class="fn__space"></span><span class="b3-list-item__text">${window.siyuan.languages.newNotebook}</span>
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconFilesRoot"></use></svg><span class="fn__space"></span><span class="b3-list-item__text">${window.siyuan.languages.newNotebook}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="b3-list-item${isIPhone() ? " fn__none" : ""}" id="emptyHelp">
|
<div class="b3-list-item${(isIPhone() || window.siyuan.config.readonly) ? " fn__none" : ""}" id="emptyHelp">
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg><span class="fn__space"></span><span class="b3-list-item__text">${window.siyuan.languages.userGuide}</span>
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg><span class="fn__space"></span><span class="b3-list-item__text">${window.siyuan.languages.userGuide}</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
emptyElement.addEventListener("click", (event) => {
|
emptyElement.addEventListener("click", (event) => {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,10 @@ export class Menu {
|
||||||
return this.menu.addItem(option);
|
return this.menu.addItem(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSeparator(index?: number) {
|
addSeparator(index?: number, ignore = false) {
|
||||||
|
if (ignore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.isOpen) {
|
if (this.isOpen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -797,6 +797,7 @@ export class Gutter {
|
||||||
}
|
}
|
||||||
this.genAlign(selectsElement, protyle);
|
this.genAlign(selectsElement, protyle);
|
||||||
this.genWidths(selectsElement, protyle);
|
this.genWidths(selectsElement, protyle);
|
||||||
|
if (!window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.quickMakeCard,
|
label: window.siyuan.languages.quickMakeCard,
|
||||||
|
|
@ -807,10 +808,10 @@ export class Gutter {
|
||||||
quickMakeCard(protyle, selectsElement);
|
quickMakeCard(protyle, selectsElement);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
if (window.siyuan.config.flashcard.deck) {
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.addToDeck,
|
label: window.siyuan.languages.addToDeck,
|
||||||
icon: "iconRiffCard",
|
icon: "iconRiffCard",
|
||||||
|
ignore: !window.siyuan.config.flashcard.deck,
|
||||||
click() {
|
click() {
|
||||||
const ids: string[] = [];
|
const ids: string[] = [];
|
||||||
selectsElement.forEach(item => {
|
selectsElement.forEach(item => {
|
||||||
|
|
@ -1667,32 +1668,30 @@ export class Gutter {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.wechatReminder,
|
label: window.siyuan.languages.wechatReminder,
|
||||||
icon: "iconMp",
|
icon: "iconMp",
|
||||||
disabled: window.siyuan.config.readonly,
|
ignore: window.siyuan.config.readonly,
|
||||||
click() {
|
click() {
|
||||||
openWechatNotify(nodeElement);
|
openWechatNotify(nodeElement);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
if (type !== "NodeThematicBreak") {
|
if (type !== "NodeThematicBreak" && !window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.quickMakeCard,
|
label: window.siyuan.languages.quickMakeCard,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
|
||||||
iconHTML: '<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>',
|
iconHTML: '<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>',
|
||||||
icon: "iconRiffCard",
|
icon: "iconRiffCard",
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click() {
|
click() {
|
||||||
quickMakeCard(protyle, [nodeElement]);
|
quickMakeCard(protyle, [nodeElement]);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
if (window.siyuan.config.flashcard.deck) {
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.addToDeck,
|
label: window.siyuan.languages.addToDeck,
|
||||||
|
ignore: !window.siyuan.config.flashcard.deck,
|
||||||
icon: "iconRiffCard",
|
icon: "iconRiffCard",
|
||||||
click() {
|
click() {
|
||||||
makeCard(protyle.app, [id]);
|
makeCard(protyle.app, [id]);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,19 +109,18 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
openFileAttr(response.data.ial, "bookmark", protyle);
|
openFileAttr(response.data.ial, "bookmark", protyle);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
|
if (!window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.wechatReminder,
|
label: window.siyuan.languages.wechatReminder,
|
||||||
icon: "iconMp",
|
icon: "iconMp",
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click() {
|
click() {
|
||||||
openFileWechatNotify(protyle);
|
openFileWechatNotify(protyle);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
const riffCardMenu = [{
|
const riffCardMenu: IMenu[] = [{
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.spaceRepetition,
|
label: window.siyuan.languages.spaceRepetition,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom,
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click: () => {
|
click: () => {
|
||||||
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
|
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
|
||||||
openCardByData(protyle.app, response.data, "doc", protyle.block.rootID, response.data.name);
|
openCardByData(protyle.app, response.data, "doc", protyle.block.rootID, response.data.name);
|
||||||
|
|
@ -130,7 +129,6 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
}, {
|
}, {
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.manage,
|
label: window.siyuan.languages.manage,
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click: () => {
|
click: () => {
|
||||||
fetchPost("/api/filetree/getHPathByID", {
|
fetchPost("/api/filetree/getHPathByID", {
|
||||||
id: protyle.block.rootID
|
id: protyle.block.rootID
|
||||||
|
|
@ -142,7 +140,6 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.quickMakeCard,
|
label: window.siyuan.languages.quickMakeCard,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click: () => {
|
click: () => {
|
||||||
let titleElement = protyle.title?.element;
|
let titleElement = protyle.title?.element;
|
||||||
if (!titleElement) {
|
if (!titleElement) {
|
||||||
|
|
@ -157,7 +154,6 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
riffCardMenu.push({
|
riffCardMenu.push({
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.addToDeck,
|
label: window.siyuan.languages.addToDeck,
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
click: () => {
|
click: () => {
|
||||||
makeCard(protyle.app, [protyle.block.rootID]);
|
makeCard(protyle.app, [protyle.block.rootID]);
|
||||||
}
|
}
|
||||||
|
|
@ -168,9 +164,8 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
icon: "iconRiffCard",
|
icon: "iconRiffCard",
|
||||||
submenu: riffCardMenu,
|
submenu: riffCardMenu,
|
||||||
disabled: window.siyuan.config.readonly,
|
|
||||||
}).element);
|
}).element);
|
||||||
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.search,
|
label: window.siyuan.languages.search,
|
||||||
icon: "iconSearch",
|
icon: "iconSearch",
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -702,6 +702,7 @@ interface IMenu {
|
||||||
bind?: (element: HTMLElement) => void
|
bind?: (element: HTMLElement) => void
|
||||||
index?: number
|
index?: number
|
||||||
element?: HTMLElement
|
element?: HTMLElement
|
||||||
|
ignore?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IBazaarItem {
|
interface IBazaarItem {
|
||||||
|
|
|
||||||
|
|
@ -150,10 +150,8 @@ export const initAssets = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (response.code === 0) {
|
|
||||||
window.siyuan.config.appearance = response.data.appearance;
|
window.siyuan.config.appearance = response.data.appearance;
|
||||||
loadAssets(response.data.appearance);
|
loadAssets(response.data.appearance);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@ class App {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
addBaseURL();
|
addBaseURL();
|
||||||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
|
||||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
|
||||||
|
|
||||||
this.appId = Constants.SIYUAN_APPID;
|
this.appId = Constants.SIYUAN_APPID;
|
||||||
window.siyuan = {
|
window.siyuan = {
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
|
|
@ -146,36 +143,23 @@ class App {
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
fetchPost("/api/system/getConf", {}, async (response) => {
|
fetchPost("/api/system/getConf", {}, async (response) => {
|
||||||
|
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||||
|
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||||
window.siyuan.config = response.data.conf;
|
window.siyuan.config = response.data.conf;
|
||||||
|
await loadPlugins(this);
|
||||||
const promises = [
|
getLocalStorage(() => {
|
||||||
loadPlugins(this),
|
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
|
||||||
new Promise<void>(resolve => getLocalStorage(resolve)),
|
|
||||||
new Promise<void>(resolve => fetchGet(
|
|
||||||
`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`,
|
|
||||||
(lauguages: IObject) => {
|
|
||||||
window.siyuan.languages = lauguages;
|
window.siyuan.languages = lauguages;
|
||||||
resolve();
|
window.siyuan.menus = new Menus(this);
|
||||||
},
|
|
||||||
)),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!window.siyuan.config.readonly) {
|
|
||||||
promises.push(new Promise<void>(resolve => {
|
|
||||||
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
||||||
window.siyuan.user = userResponse.data;
|
window.siyuan.user = userResponse.data;
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises);
|
|
||||||
|
|
||||||
window.siyuan.menus = new Menus(this);
|
|
||||||
init(this);
|
init(this);
|
||||||
setTitle(window.siyuan.languages.siyuanNote);
|
setTitle(window.siyuan.languages.siyuanNote);
|
||||||
initMessage();
|
initMessage();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
setNoteBook();
|
setNoteBook();
|
||||||
initBlockPopover(this);
|
initBlockPopover(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue