mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 00:20:12 +01:00
🚨
This commit is contained in:
parent
190b24d7e4
commit
16ea87b398
9 changed files with 51 additions and 42 deletions
|
|
@ -63,6 +63,28 @@ export const repos = {
|
||||||
<li>${window.siyuan.languages.cloudIntro11}</li>
|
<li>${window.siyuan.languages.cloudIntro11}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
let syncModeHTML = `<label class="fn__flex b3-label">
|
||||||
|
<div class="fn__flex-1">
|
||||||
|
${window.siyuan.languages.syncMode}
|
||||||
|
<div class="b3-label__text">${window.siyuan.languages.syncModeTip}</div>
|
||||||
|
</div>
|
||||||
|
<span class="fn__space"></span>
|
||||||
|
<select id="syncMode" class="b3-select fn__flex-center fn__size200">
|
||||||
|
<option value="1" ${window.siyuan.config.sync.mode === 1 ? "selected" : ""}>${window.siyuan.languages.syncMode1}</option>
|
||||||
|
<option value="2" ${window.siyuan.config.sync.mode === 2 ? "selected" : ""}>${window.siyuan.languages.syncMode2}</option>
|
||||||
|
</select>
|
||||||
|
</label>`;
|
||||||
|
if (isMobile()) {
|
||||||
|
syncModeHTML = `<div class="b3-label">
|
||||||
|
${window.siyuan.languages.syncMode}
|
||||||
|
<div class="fn__hr"></div>
|
||||||
|
<select id="syncMode" class="b3-select fn__block">
|
||||||
|
<option value="1" ${window.siyuan.config.sync.mode === 1 ? "selected" : ""}>${window.siyuan.languages.syncMode1}</option>
|
||||||
|
<option value="2" ${window.siyuan.config.sync.mode === 2 ? "selected" : ""}>${window.siyuan.languages.syncMode2}</option>
|
||||||
|
</select>
|
||||||
|
<div class="b3-label__text">${window.siyuan.languages.syncModeTip}</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
return `<div><div style="position: fixed;width: 800px;height: 434px;box-sizing: border-box;text-align: center;display: flex;align-items: center;justify-content: center;z-index: 1;" id="reposLoading">
|
return `<div><div style="position: fixed;width: 800px;height: 434px;box-sizing: border-box;text-align: center;display: flex;align-items: center;justify-content: center;z-index: 1;" id="reposLoading">
|
||||||
|
|
@ -86,17 +108,7 @@ export const repos = {
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<input type="checkbox" id="reposCloudSyncSwitch"${window.siyuan.config.sync.enabled ? " checked='checked'" : ""} class="b3-switch fn__flex-center">
|
<input type="checkbox" id="reposCloudSyncSwitch"${window.siyuan.config.sync.enabled ? " checked='checked'" : ""} class="b3-switch fn__flex-center">
|
||||||
</label>
|
</label>
|
||||||
<label class="fn__flex b3-label">
|
${syncModeHTML}
|
||||||
<div class="fn__flex-1">
|
|
||||||
${window.siyuan.languages.syncMode}
|
|
||||||
<div class="b3-label__text">${window.siyuan.languages.syncModeTip}</div>
|
|
||||||
</div>
|
|
||||||
<span class="fn__space"></span>
|
|
||||||
<select id="syncMode" class="b3-select fn__flex-center fn__size200">
|
|
||||||
<option value="1" ${window.siyuan.config.sync.mode === 1 ? "selected" : ""}>${window.siyuan.languages.syncMode1}</option>
|
|
||||||
<option value="2" ${window.siyuan.config.sync.mode === 2 ? "selected" : ""}>${window.siyuan.languages.syncMode2}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<div class="b3-label">
|
<div class="b3-label">
|
||||||
<div class="fn__flex">
|
<div class="fn__flex">
|
||||||
<div class="fn__flex-center">${window.siyuan.languages.cloudSyncDir}</div>
|
<div class="fn__flex-center">${window.siyuan.languages.cloudSyncDir}</div>
|
||||||
|
|
@ -150,7 +162,7 @@ export const repos = {
|
||||||
loadingElement.style.height = repos.element.clientHeight + "px";
|
loadingElement.style.height = repos.element.clientHeight + "px";
|
||||||
const syncConfigElement = repos.element.querySelector("#reposCloudSyncList");
|
const syncConfigElement = repos.element.querySelector("#reposCloudSyncList");
|
||||||
bindSyncCloudListEvent(syncConfigElement);
|
bindSyncCloudListEvent(syncConfigElement);
|
||||||
repos.element.querySelector('[data-type="config"]').addEventListener("click", (event) => {
|
repos.element.querySelector('[data-type="config"]').addEventListener("click", () => {
|
||||||
if (syncConfigElement.classList.contains("fn__none")) {
|
if (syncConfigElement.classList.contains("fn__none")) {
|
||||||
getSyncCloudList(syncConfigElement);
|
getSyncCloudList(syncConfigElement);
|
||||||
syncConfigElement.classList.remove("fn__none");
|
syncConfigElement.classList.remove("fn__none");
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,13 @@ export class Tab {
|
||||||
this.headElement.addEventListener("mouseenter", (event) => {
|
this.headElement.addEventListener("mouseenter", (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let id = ""
|
let id = "";
|
||||||
if (this.model instanceof Editor && this.model.editor?.protyle?.block?.rootID) {
|
if (this.model instanceof Editor && this.model.editor?.protyle?.block?.rootID) {
|
||||||
id = (this.model as Editor).editor.protyle.block.rootID
|
id = (this.model as Editor).editor.protyle.block.rootID;
|
||||||
} else if (!this.model){
|
} else if (!this.model){
|
||||||
const initData = JSON.parse(this.headElement.getAttribute("data-initdata")||"{}")
|
const initData = JSON.parse(this.headElement.getAttribute("data-initdata")||"{}");
|
||||||
if (initData) {
|
if (initData) {
|
||||||
id = initData.blockId
|
id = initData.blockId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
|
|
|
||||||
|
|
@ -255,23 +255,23 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
||||||
label: window.siyuan.languages.copyPlainText,
|
label: window.siyuan.languages.copyPlainText,
|
||||||
click() {
|
click() {
|
||||||
focusByRange(getEditorRange(nodeElement));
|
focusByRange(getEditorRange(nodeElement));
|
||||||
writeText(range.toString())
|
writeText(range.toString());
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.copy +" HTML",
|
label: window.siyuan.languages.copy +" HTML",
|
||||||
click() {
|
click() {
|
||||||
focusByRange(getEditorRange(nodeElement));
|
focusByRange(getEditorRange(nodeElement));
|
||||||
let html = ''
|
let html = "";
|
||||||
range.cloneContents().childNodes.forEach(item => {
|
range.cloneContents().childNodes.forEach(item => {
|
||||||
if (item.nodeType === 3) {
|
if (item.nodeType === 3) {
|
||||||
html += item.textContent
|
html += item.textContent;
|
||||||
} else {
|
} else {
|
||||||
html += (item as Element).outerHTML
|
html += (item as Element).outerHTML;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
const tempElement = document.createElement('template')
|
const tempElement = document.createElement("template");
|
||||||
tempElement.innerHTML = protyle.lute.BlockDOM2HTML(html)
|
tempElement.innerHTML = protyle.lute.BlockDOM2HTML(html);
|
||||||
writeText(tempElement.content.firstElementChild.innerHTML);
|
writeText(tempElement.content.firstElementChild.innerHTML);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
|
|
|
||||||
|
|
@ -503,7 +503,7 @@ export class Gutter {
|
||||||
click() {
|
click() {
|
||||||
let html = "";
|
let html = "";
|
||||||
selectsElement.forEach(item => {
|
selectsElement.forEach(item => {
|
||||||
html += item.outerHTML
|
html += item.outerHTML;
|
||||||
});
|
});
|
||||||
writeText(protyle.lute.BlockDOM2HTML(html));
|
writeText(protyle.lute.BlockDOM2HTML(html));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -701,7 +701,7 @@ export class Toolbar {
|
||||||
setPosition(this.subElement, nodeRect.right, nodeRect.bottom);
|
setPosition(this.subElement, nodeRect.right, nodeRect.bottom);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const headerElement = this.subElement.querySelector(".block__icons")
|
const headerElement = this.subElement.querySelector(".block__icons");
|
||||||
headerElement.addEventListener("click", (event: MouseEvent) => {
|
headerElement.addEventListener("click", (event: MouseEvent) => {
|
||||||
const target = event.target as HTMLElement;
|
const target = event.target as HTMLElement;
|
||||||
const btnElement = hasClosestByClassName(target, "b3-tooltips");
|
const btnElement = hasClosestByClassName(target, "b3-tooltips");
|
||||||
|
|
@ -715,7 +715,7 @@ export class Toolbar {
|
||||||
pingElement.classList.add("block__icon--active");
|
pingElement.classList.add("block__icon--active");
|
||||||
pingElement.setAttribute("aria-label", window.siyuan.languages.unpin);
|
pingElement.setAttribute("aria-label", window.siyuan.languages.unpin);
|
||||||
}
|
}
|
||||||
event.preventDefault()
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -866,7 +866,7 @@ export class Toolbar {
|
||||||
renderElement.setAttribute("data-content", renderElement.getAttribute("data-content").replace(/\n/g, ""));
|
renderElement.setAttribute("data-content", renderElement.getAttribute("data-content").replace(/\n/g, ""));
|
||||||
}
|
}
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
const newHTML = protyle.lute.SpinBlockDOM(nodeElement.outerHTML)
|
const newHTML = protyle.lute.SpinBlockDOM(nodeElement.outerHTML);
|
||||||
updateTransaction(protyle, id, newHTML, html);
|
updateTransaction(protyle, id, newHTML, html);
|
||||||
html = newHTML;
|
html = newHTML;
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {focusBlock, focusSideBlock, focusByWbr} from "../util/selection";
|
import {focusBlock, focusByWbr} from "../util/selection";
|
||||||
import {
|
import {
|
||||||
getContenteditableElement,
|
getContenteditableElement,
|
||||||
getLastBlock,
|
getLastBlock,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export const addCloudName = (cloudPanelElement: Element) => {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
});
|
});
|
||||||
btnsElement[1].addEventListener("click", () => {
|
btnsElement[1].addEventListener("click", () => {
|
||||||
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">'
|
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">';
|
||||||
fetchPost("/api/sync/createCloudSyncDir", {name: inputElement.value}, () => {
|
fetchPost("/api/sync/createCloudSyncDir", {name: inputElement.value}, () => {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
getSyncCloudList(cloudPanelElement, true);
|
getSyncCloudList(cloudPanelElement, true);
|
||||||
|
|
@ -49,7 +49,7 @@ export const bindSyncCloudListEvent = (cloudPanelElement: Element) => {
|
||||||
break;
|
break;
|
||||||
case "removeCloud":
|
case "removeCloud":
|
||||||
confirmDialog(window.siyuan.languages.confirm, `${window.siyuan.languages.confirmDeleteCloudDir} <i>${target.parentElement.getAttribute("data-name")}</i>`, () => {
|
confirmDialog(window.siyuan.languages.confirm, `${window.siyuan.languages.confirmDeleteCloudDir} <i>${target.parentElement.getAttribute("data-name")}</i>`, () => {
|
||||||
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">'
|
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">';
|
||||||
fetchPost("/api/sync/removeCloudSyncDir", {name: target.parentElement.getAttribute("data-name")}, (response) => {
|
fetchPost("/api/sync/removeCloudSyncDir", {name: target.parentElement.getAttribute("data-name")}, (response) => {
|
||||||
window.siyuan.config.sync.cloudName = response.data;
|
window.siyuan.config.sync.cloudName = response.data;
|
||||||
getSyncCloudList(cloudPanelElement, true);
|
getSyncCloudList(cloudPanelElement, true);
|
||||||
|
|
@ -57,7 +57,7 @@ export const bindSyncCloudListEvent = (cloudPanelElement: Element) => {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "selectCloud":
|
case "selectCloud":
|
||||||
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">'
|
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">';
|
||||||
fetchPost("/api/sync/setCloudSyncDir", {name: target.getAttribute("data-name")}, () => {
|
fetchPost("/api/sync/setCloudSyncDir", {name: target.getAttribute("data-name")}, () => {
|
||||||
window.siyuan.config.sync.cloudName = target.getAttribute("data-name");
|
window.siyuan.config.sync.cloudName = target.getAttribute("data-name");
|
||||||
getSyncCloudList(cloudPanelElement, true);
|
getSyncCloudList(cloudPanelElement, true);
|
||||||
|
|
@ -82,7 +82,7 @@ export const getSyncCloudList = (cloudPanelElement: Element, reload = false) =>
|
||||||
if (response.code !== 1) {
|
if (response.code !== 1) {
|
||||||
syncListHTML = '<div class="fn__hr"></div><ul class="b3-list b3-list--background fn__flex-1" style="overflow: auto;">';
|
syncListHTML = '<div class="fn__hr"></div><ul class="b3-list b3-list--background fn__flex-1" style="overflow: auto;">';
|
||||||
response.data.syncDirs.forEach((item: { hSize: string, cloudName: string, updated: string }) => {
|
response.data.syncDirs.forEach((item: { hSize: string, cloudName: string, updated: string }) => {
|
||||||
syncListHTML += `<li data-type="selectCloud" data-name="${item.cloudName}" class="b3-list-item b3-list-item--hide-action">
|
syncListHTML += `<li data-type="selectCloud" data-name="${item.cloudName}" class="b3-list-item${isMobile() ? "" : " b3-list-item--hide-action"}">
|
||||||
<input type="radio" name="cloudName"${item.cloudName === response.data.checkedSyncDir ? " checked" : ""}/>
|
<input type="radio" name="cloudName"${item.cloudName === response.data.checkedSyncDir ? " checked" : ""}/>
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<span>${item.cloudName}</span>
|
<span>${item.cloudName}</span>
|
||||||
|
|
@ -118,7 +118,7 @@ export const syncGuide = (element?: Element) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPost("/api/sync/performSync", {});
|
fetchPost("/api/sync/performSync", {});
|
||||||
}
|
};
|
||||||
|
|
||||||
const setSync = (key?: string, dialog?: Dialog) => {
|
const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
if (key) {
|
if (key) {
|
||||||
|
|
@ -130,7 +130,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
</div>
|
</div>
|
||||||
<div class="b3-dialog__action">
|
<div class="b3-dialog__action">
|
||||||
<button class="b3-button">${window.siyuan.languages.openSyncTip1}</button>
|
<button class="b3-button">${window.siyuan.languages.openSyncTip1}</button>
|
||||||
</div>`
|
</div>`;
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
dialog.element.querySelector(".b3-dialog__container").lastElementChild.innerHTML = listHTML;
|
dialog.element.querySelector(".b3-dialog__container").lastElementChild.innerHTML = listHTML;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -140,16 +140,16 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
width: isMobile() ? "80vw" : "520px",
|
width: isMobile() ? "80vw" : "520px",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const contentElement = dialog.element.querySelector(".b3-dialog__content")
|
const contentElement = dialog.element.querySelector(".b3-dialog__content");
|
||||||
bindSyncCloudListEvent(contentElement);
|
bindSyncCloudListEvent(contentElement);
|
||||||
getSyncCloudList(contentElement);
|
getSyncCloudList(contentElement);
|
||||||
dialog.element.querySelector(".b3-button").addEventListener("click", () => {
|
dialog.element.querySelector(".b3-button").addEventListener("click", () => {
|
||||||
dialog.destroy()
|
dialog.destroy();
|
||||||
fetchPost("/api/sync/setSyncEnable", {enabled: true}, (response) => {
|
fetchPost("/api/sync/setSyncEnable", {enabled: true}, (response) => {
|
||||||
if (response.code === 1) {
|
if (response.code === 1) {
|
||||||
showMessage(response.msg);
|
showMessage(response.msg);
|
||||||
} else {
|
} else {
|
||||||
window.siyuan.config.sync.enabled = true
|
window.siyuan.config.sync.enabled = true;
|
||||||
confirmDialog(window.siyuan.languages.sync, window.siyuan.languages.syncNow, () => {
|
confirmDialog(window.siyuan.languages.sync, window.siyuan.languages.syncNow, () => {
|
||||||
fetchPost("/api/sync/performSync", {});
|
fetchPost("/api/sync/performSync", {});
|
||||||
});
|
});
|
||||||
|
|
@ -164,7 +164,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
fetchPost("/api/sync/performSync", {});
|
fetchPost("/api/sync/performSync", {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const setKey = () => {
|
const setKey = () => {
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
|
@ -260,4 +260,4 @@ const setKey = () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ import {initFileMenu, initNavigationMenu} from "../menus/navigation";
|
||||||
import {bindMenuKeydown} from "../menus/Menu";
|
import {bindMenuKeydown} from "../menus/Menu";
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
import {openHistory} from "./history";
|
import {openHistory} from "./history";
|
||||||
import {needSubscribe} from "./needSubscribe";
|
|
||||||
import {Dialog} from "../dialog";
|
import {Dialog} from "../dialog";
|
||||||
import {unicode2Emoji} from "../emoji";
|
import {unicode2Emoji} from "../emoji";
|
||||||
import {deleteFile} from "../editor/deleteFile";
|
import {deleteFile} from "../editor/deleteFile";
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ import {fetchPost} from "./fetch";
|
||||||
import {mountHelp, newDailyNote} from "./mount";
|
import {mountHelp, newDailyNote} from "./mount";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
import {initAssets, loadAssets, setInlineStyle} from "./assets";
|
import {initAssets, loadAssets, setInlineStyle} from "./assets";
|
||||||
import {showMessage} from "../dialog/message";
|
|
||||||
import {needSubscribe} from "./needSubscribe";
|
|
||||||
import {goBack, goForward} from "./backForward";
|
import {goBack, goForward} from "./backForward";
|
||||||
import {getOpenNotebookCount} from "./pathName";
|
import {getOpenNotebookCount} from "./pathName";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue