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>
|
||||
</ul>
|
||||
</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>`;
|
||||
}
|
||||
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>
|
||||
<input type="checkbox" id="reposCloudSyncSwitch"${window.siyuan.config.sync.enabled ? " checked='checked'" : ""} class="b3-switch fn__flex-center">
|
||||
</label>
|
||||
<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>
|
||||
${syncModeHTML}
|
||||
<div class="b3-label">
|
||||
<div class="fn__flex">
|
||||
<div class="fn__flex-center">${window.siyuan.languages.cloudSyncDir}</div>
|
||||
|
|
@ -150,7 +162,7 @@ export const repos = {
|
|||
loadingElement.style.height = repos.element.clientHeight + "px";
|
||||
const syncConfigElement = repos.element.querySelector("#reposCloudSyncList");
|
||||
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")) {
|
||||
getSyncCloudList(syncConfigElement);
|
||||
syncConfigElement.classList.remove("fn__none");
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ export class Tab {
|
|||
this.headElement.addEventListener("mouseenter", (event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
let id = ""
|
||||
let id = "";
|
||||
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){
|
||||
const initData = JSON.parse(this.headElement.getAttribute("data-initdata")||"{}")
|
||||
const initData = JSON.parse(this.headElement.getAttribute("data-initdata")||"{}");
|
||||
if (initData) {
|
||||
id = initData.blockId
|
||||
id = initData.blockId;
|
||||
}
|
||||
}
|
||||
if (id) {
|
||||
|
|
|
|||
|
|
@ -255,23 +255,23 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
label: window.siyuan.languages.copyPlainText,
|
||||
click() {
|
||||
focusByRange(getEditorRange(nodeElement));
|
||||
writeText(range.toString())
|
||||
writeText(range.toString());
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copy +" HTML",
|
||||
click() {
|
||||
focusByRange(getEditorRange(nodeElement));
|
||||
let html = ''
|
||||
let html = "";
|
||||
range.cloneContents().childNodes.forEach(item => {
|
||||
if (item.nodeType === 3) {
|
||||
html += item.textContent
|
||||
html += item.textContent;
|
||||
} else {
|
||||
html += (item as Element).outerHTML
|
||||
html += (item as Element).outerHTML;
|
||||
}
|
||||
})
|
||||
const tempElement = document.createElement('template')
|
||||
tempElement.innerHTML = protyle.lute.BlockDOM2HTML(html)
|
||||
});
|
||||
const tempElement = document.createElement("template");
|
||||
tempElement.innerHTML = protyle.lute.BlockDOM2HTML(html);
|
||||
writeText(tempElement.content.firstElementChild.innerHTML);
|
||||
}
|
||||
}).element);
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ export class Gutter {
|
|||
click() {
|
||||
let html = "";
|
||||
selectsElement.forEach(item => {
|
||||
html += item.outerHTML
|
||||
html += item.outerHTML;
|
||||
});
|
||||
writeText(protyle.lute.BlockDOM2HTML(html));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ export class Toolbar {
|
|||
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) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const btnElement = hasClosestByClassName(target, "b3-tooltips");
|
||||
|
|
@ -715,7 +715,7 @@ export class Toolbar {
|
|||
pingElement.classList.add("block__icon--active");
|
||||
pingElement.setAttribute("aria-label", window.siyuan.languages.unpin);
|
||||
}
|
||||
event.preventDefault()
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
return;
|
||||
|
|
@ -866,7 +866,7 @@ export class Toolbar {
|
|||
renderElement.setAttribute("data-content", renderElement.getAttribute("data-content").replace(/\n/g, ""));
|
||||
}
|
||||
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);
|
||||
html = newHTML;
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {focusBlock, focusSideBlock, focusByWbr} from "../util/selection";
|
||||
import {focusBlock, focusByWbr} from "../util/selection";
|
||||
import {
|
||||
getContenteditableElement,
|
||||
getLastBlock,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export const addCloudName = (cloudPanelElement: Element) => {
|
|||
dialog.destroy();
|
||||
});
|
||||
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}, () => {
|
||||
dialog.destroy();
|
||||
getSyncCloudList(cloudPanelElement, true);
|
||||
|
|
@ -49,7 +49,7 @@ export const bindSyncCloudListEvent = (cloudPanelElement: Element) => {
|
|||
break;
|
||||
case "removeCloud":
|
||||
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) => {
|
||||
window.siyuan.config.sync.cloudName = response.data;
|
||||
getSyncCloudList(cloudPanelElement, true);
|
||||
|
|
@ -57,7 +57,7 @@ export const bindSyncCloudListEvent = (cloudPanelElement: Element) => {
|
|||
});
|
||||
break;
|
||||
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")}, () => {
|
||||
window.siyuan.config.sync.cloudName = target.getAttribute("data-name");
|
||||
getSyncCloudList(cloudPanelElement, true);
|
||||
|
|
@ -82,7 +82,7 @@ export const getSyncCloudList = (cloudPanelElement: Element, reload = false) =>
|
|||
if (response.code !== 1) {
|
||||
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 }) => {
|
||||
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" : ""}/>
|
||||
<span class="fn__space"></span>
|
||||
<span>${item.cloudName}</span>
|
||||
|
|
@ -118,7 +118,7 @@ export const syncGuide = (element?: Element) => {
|
|||
return;
|
||||
}
|
||||
fetchPost("/api/sync/performSync", {});
|
||||
}
|
||||
};
|
||||
|
||||
const setSync = (key?: string, dialog?: Dialog) => {
|
||||
if (key) {
|
||||
|
|
@ -130,7 +130,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
</div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button">${window.siyuan.languages.openSyncTip1}</button>
|
||||
</div>`
|
||||
</div>`;
|
||||
if (dialog) {
|
||||
dialog.element.querySelector(".b3-dialog__container").lastElementChild.innerHTML = listHTML;
|
||||
} else {
|
||||
|
|
@ -140,16 +140,16 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
width: isMobile() ? "80vw" : "520px",
|
||||
});
|
||||
}
|
||||
const contentElement = dialog.element.querySelector(".b3-dialog__content")
|
||||
const contentElement = dialog.element.querySelector(".b3-dialog__content");
|
||||
bindSyncCloudListEvent(contentElement);
|
||||
getSyncCloudList(contentElement);
|
||||
dialog.element.querySelector(".b3-button").addEventListener("click", () => {
|
||||
dialog.destroy()
|
||||
dialog.destroy();
|
||||
fetchPost("/api/sync/setSyncEnable", {enabled: true}, (response) => {
|
||||
if (response.code === 1) {
|
||||
showMessage(response.msg);
|
||||
} else {
|
||||
window.siyuan.config.sync.enabled = true
|
||||
window.siyuan.config.sync.enabled = true;
|
||||
confirmDialog(window.siyuan.languages.sync, window.siyuan.languages.syncNow, () => {
|
||||
fetchPost("/api/sync/performSync", {});
|
||||
});
|
||||
|
|
@ -164,7 +164,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
fetchPost("/api/sync/performSync", {});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const setKey = () => {
|
||||
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 {showMessage} from "../dialog/message";
|
||||
import {openHistory} from "./history";
|
||||
import {needSubscribe} from "./needSubscribe";
|
||||
import {Dialog} from "../dialog";
|
||||
import {unicode2Emoji} from "../emoji";
|
||||
import {deleteFile} from "../editor/deleteFile";
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import {fetchPost} from "./fetch";
|
|||
import {mountHelp, newDailyNote} from "./mount";
|
||||
import {MenuItem} from "../menus/Menu";
|
||||
import {initAssets, loadAssets, setInlineStyle} from "./assets";
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {needSubscribe} from "./needSubscribe";
|
||||
import {goBack, goForward} from "./backForward";
|
||||
import {getOpenNotebookCount} from "./pathName";
|
||||
import {openFileById} from "../editor/util";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue