mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
🚨
This commit is contained in:
parent
ba4bedf3bc
commit
e5143a8474
13 changed files with 30 additions and 34 deletions
|
|
@ -32,7 +32,7 @@ import {MenuItem} from "../menus/Menu";
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
import {isWindow} from "../util/functions";
|
import {isWindow} from "../util/functions";
|
||||||
import {hideAllElements} from "../protyle/ui/hideElements";
|
import {hideAllElements} from "../protyle/ui/hideElements";
|
||||||
import {focusByOffset, getSelectionOffset, getSelectionPosition} from "../protyle/util/selection";
|
import {focusByOffset, getSelectionOffset} from "../protyle/util/selection";
|
||||||
|
|
||||||
export class Wnd {
|
export class Wnd {
|
||||||
public id: string;
|
public id: string;
|
||||||
|
|
@ -760,7 +760,7 @@ export class Wnd {
|
||||||
id: string,
|
id: string,
|
||||||
start: number,
|
start: number,
|
||||||
end: number
|
end: number
|
||||||
}
|
};
|
||||||
if (tab.model instanceof Editor && tab.model.editor.protyle.toolbar.range) {
|
if (tab.model instanceof Editor && tab.model.editor.protyle.toolbar.range) {
|
||||||
const blockElement = hasClosestBlock(tab.model.editor.protyle.toolbar.range.startContainer);
|
const blockElement = hasClosestBlock(tab.model.editor.protyle.toolbar.range.startContainer);
|
||||||
if (blockElement) {
|
if (blockElement) {
|
||||||
|
|
@ -769,7 +769,7 @@ export class Wnd {
|
||||||
id: blockElement.getAttribute("data-node-id"),
|
id: blockElement.getAttribute("data-node-id"),
|
||||||
start: startEnd.start,
|
start: startEnd.start,
|
||||||
end: startEnd.end
|
end: startEnd.end
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.element.querySelector(".layout-tab-container").append(tab.panelElement);
|
this.element.querySelector(".layout-tab-container").append(tab.panelElement);
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,10 @@ export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
|
||||||
id: blockElement.getAttribute("data-node-id"),
|
id: blockElement.getAttribute("data-node-id"),
|
||||||
start: startEnd.start,
|
start: startEnd.start,
|
||||||
end: startEnd.end
|
end: startEnd.end
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
newWnd.element.after(targetWnd.element);
|
newWnd.element.after(targetWnd.element);
|
||||||
targetWnd.children.forEach((item) => {
|
targetWnd.children.forEach((item) => {
|
||||||
if (item.model instanceof Editor) {
|
if (item.model instanceof Editor) {
|
||||||
|
|
@ -107,7 +107,7 @@ export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
|
||||||
item.model.editor.protyle.toolbar.range = range;
|
item.model.editor.protyle.toolbar.range = range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
// 分割线
|
// 分割线
|
||||||
newWnd.element.after(newWnd.element.previousElementSibling);
|
newWnd.element.after(newWnd.element.previousElementSibling);
|
||||||
newWnd.parent.children.find((item, index) => {
|
newWnd.parent.children.find((item, index) => {
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ export class Menu {
|
||||||
} else {
|
} else {
|
||||||
this.element.style.transform = "translateY(-100vh)";
|
this.element.style.transform = "translateY(-100vh)";
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
this.element.lastElementChild.scrollTop = 0;
|
this.element.lastElementChild.scrollTop = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ export const onGetnotebookconf = (data: INotebookConf) => {
|
||||||
bindEvent() {
|
bindEvent() {
|
||||||
bindSettingEvent(document.querySelector("#model"), data);
|
bindSettingEvent(document.querySelector("#model"), data);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
width: "80vw",
|
width: "80vw",
|
||||||
|
|
@ -94,4 +94,4 @@ const bindSettingEvent = (contentElement: Element, data: INotebookConf) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,10 @@ const updateConfig = (element: Element, newConfig: ISearchOption, config: ISearc
|
||||||
}
|
}
|
||||||
const searchPathElement = element.querySelector("#searchPath");
|
const searchPathElement = element.querySelector("#searchPath");
|
||||||
if (newConfig.hPath) {
|
if (newConfig.hPath) {
|
||||||
searchPathElement.classList.remove("fn__none")
|
searchPathElement.classList.remove("fn__none");
|
||||||
searchPathElement.innerHTML = `<div class="b3-chip b3-chip--middle">${escapeHtml(newConfig.hPath)}<svg data-type="remove-path" class="b3-chip__close"><use xlink:href="#iconCloseRound"></use></svg></div>`;
|
searchPathElement.innerHTML = `<div class="b3-chip b3-chip--middle">${escapeHtml(newConfig.hPath)}<svg data-type="remove-path" class="b3-chip__close"><use xlink:href="#iconCloseRound"></use></svg></div>`;
|
||||||
} else {
|
} else {
|
||||||
searchPathElement.classList.add("fn__none")
|
searchPathElement.classList.add("fn__none");
|
||||||
}
|
}
|
||||||
if (config.group !== newConfig.group) {
|
if (config.group !== newConfig.group) {
|
||||||
if (newConfig.group === 0) {
|
if (newConfig.group === 0) {
|
||||||
|
|
@ -152,7 +152,7 @@ const updateConfig = (element: Element, newConfig: ISearchOption, config: ISearc
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRecentBlocks = (data: IBlock[], matchedRootCount?: number, matchedBlockCount?: number) => {
|
const onRecentBlocks = (data: IBlock[], matchedRootCount?: number, matchedBlockCount?: number) => {
|
||||||
const listElement = document.querySelector("#searchList")
|
const listElement = document.querySelector("#searchList");
|
||||||
let resultHTML = "";
|
let resultHTML = "";
|
||||||
data.forEach((item: IBlock, index: number) => {
|
data.forEach((item: IBlock, index: number) => {
|
||||||
const title = getNotebookName(item.box) + getDisplayName(item.hPath, false);
|
const title = getNotebookName(item.box) + getDisplayName(item.hPath, false);
|
||||||
|
|
@ -191,7 +191,7 @@ ${unicode2Emoji(childItem.ial.icon, false, "b3-list-item__graphic", true)}
|
||||||
</span>
|
</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
listElement.scrollTop = 0;
|
listElement.scrollTop = 0;
|
||||||
let countHTML = ""
|
let countHTML = "";
|
||||||
if (matchedBlockCount) {
|
if (matchedBlockCount) {
|
||||||
countHTML = `<div class="b3-list--empty">${window.siyuan.languages.findInDoc.replace("${x}", matchedRootCount).replace("${y}", matchedBlockCount)}</div>`;
|
countHTML = `<div class="b3-list--empty">${window.siyuan.languages.findInDoc.replace("${x}", matchedRootCount).replace("${y}", matchedBlockCount)}</div>`;
|
||||||
}
|
}
|
||||||
|
|
@ -242,8 +242,8 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
|
||||||
}
|
}
|
||||||
updateSearchResult(config, element);
|
updateSearchResult(config, element);
|
||||||
});
|
});
|
||||||
const replaceInputElement = element.querySelector(".toolbar .b3-text-field") as HTMLInputElement
|
const replaceInputElement = element.querySelector(".toolbar .b3-text-field") as HTMLInputElement;
|
||||||
replaceInputElement.value = config.r || ""
|
replaceInputElement.value = config.r || "";
|
||||||
|
|
||||||
const criteriaData: ISearchOption[] = [];
|
const criteriaData: ISearchOption[] = [];
|
||||||
initCriteriaMenu(element.querySelector("#criteria"), criteriaData);
|
initCriteriaMenu(element.querySelector("#criteria"), criteriaData);
|
||||||
|
|
@ -285,7 +285,7 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
|
||||||
} else if (type === "remove-path") {
|
} else if (type === "remove-path") {
|
||||||
config.idPath = [];
|
config.idPath = [];
|
||||||
config.hPath = "";
|
config.hPath = "";
|
||||||
element.querySelector("#searchPath").classList.add("fn__none")
|
element.querySelector("#searchPath").classList.add("fn__none");
|
||||||
updateSearchResult(config, element);
|
updateSearchResult(config, element);
|
||||||
const includeElement = element.querySelector('[data-type="include"]');
|
const includeElement = element.querySelector('[data-type="include"]');
|
||||||
includeElement.classList.remove("toolbar__icon--active");
|
includeElement.classList.remove("toolbar__icon--active");
|
||||||
|
|
@ -333,7 +333,7 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
|
||||||
}
|
}
|
||||||
config.hPath = hPathList.join(" ");
|
config.hPath = hPathList.join(" ");
|
||||||
|
|
||||||
const searchPathElement = element.querySelector("#searchPath")
|
const searchPathElement = element.querySelector("#searchPath");
|
||||||
searchPathElement.classList.remove("fn__none");
|
searchPathElement.classList.remove("fn__none");
|
||||||
element.querySelector("#searchPath").innerHTML = `<div class="b3-chip b3-chip--middle">${escapeHtml(config.hPath)}<svg data-type="remove-path" class="b3-chip__close"><use xlink:href="#iconCloseRound"></use></svg></div>`;
|
element.querySelector("#searchPath").innerHTML = `<div class="b3-chip b3-chip--middle">${escapeHtml(config.hPath)}<svg data-type="remove-path" class="b3-chip__close"><use xlink:href="#iconCloseRound"></use></svg></div>`;
|
||||||
|
|
||||||
|
|
@ -405,7 +405,7 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
|
||||||
embedBlock: window.siyuan.config.search.embedBlock,
|
embedBlock: window.siyuan.config.search.embedBlock,
|
||||||
}
|
}
|
||||||
}, config);
|
}, config);
|
||||||
})
|
});
|
||||||
window.siyuan.menus.menu.element.style.zIndex = "220";
|
window.siyuan.menus.menu.element.style.zIndex = "220";
|
||||||
window.siyuan.menus.menu.fullscreen();
|
window.siyuan.menus.menu.fullscreen();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
@ -413,14 +413,14 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
|
||||||
break;
|
break;
|
||||||
} else if (type === "filter") {
|
} else if (type === "filter") {
|
||||||
filterMenu(config, () => {
|
filterMenu(config, () => {
|
||||||
updateSearchResult(config, element)
|
updateSearchResult(config, element);
|
||||||
});
|
});
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
} else if (type === "query") {
|
} else if (type === "query") {
|
||||||
queryMenu(config, () => {
|
queryMenu(config, () => {
|
||||||
updateSearchResult(config, element)
|
updateSearchResult(config, element);
|
||||||
});
|
});
|
||||||
window.siyuan.menus.menu.element.style.zIndex = "220";
|
window.siyuan.menus.menu.element.style.zIndex = "220";
|
||||||
window.siyuan.menus.menu.fullscreen();
|
window.siyuan.menus.menu.fullscreen();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {setInlineStyle} from "../../util/assets";
|
|
||||||
import {genOptions} from "../../util/genOptions";
|
import {genOptions} from "../../util/genOptions";
|
||||||
import {reloadProtyle} from "../../protyle/util/reload";
|
|
||||||
import {openModel} from "../menu/model";
|
import {openModel} from "../menu/model";
|
||||||
|
|
||||||
export const initAppearance = () => {
|
export const initAppearance = () => {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ const reloadEditor = (data: IEditor) => {
|
||||||
window.siyuan.config.editor = data;
|
window.siyuan.config.editor = data;
|
||||||
reloadProtyle(window.siyuan.mobile.editor.protyle);
|
reloadProtyle(window.siyuan.mobile.editor.protyle);
|
||||||
setInlineStyle();
|
setInlineStyle();
|
||||||
}
|
};
|
||||||
|
|
||||||
export const initEditor = () => {
|
export const initEditor = () => {
|
||||||
openModel({
|
openModel({
|
||||||
|
|
@ -32,16 +32,16 @@ export const initEditor = () => {
|
||||||
modelMainElement.querySelector("#fontSize").textContent = event.target.value + "px";
|
modelMainElement.querySelector("#fontSize").textContent = event.target.value + "px";
|
||||||
window.siyuan.config.editor.fontSize = parseInt(event.target.value);
|
window.siyuan.config.editor.fontSize = parseInt(event.target.value);
|
||||||
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
|
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
|
||||||
reloadEditor(response.data)
|
reloadEditor(response.data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const katexMacrosElement = modelMainElement.querySelector("#katexMacros") as HTMLTextAreaElement;
|
const katexMacrosElement = modelMainElement.querySelector("#katexMacros") as HTMLTextAreaElement;
|
||||||
katexMacrosElement.addEventListener("blur", () => {
|
katexMacrosElement.addEventListener("blur", () => {
|
||||||
window.siyuan.config.editor.katexMacros = katexMacrosElement.value;
|
window.siyuan.config.editor.katexMacros = katexMacrosElement.value;
|
||||||
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
|
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
|
||||||
reloadEditor(response.data)
|
reloadEditor(response.data);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ export class MobileTags {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const searchOption = Object.assign({}, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);
|
const searchOption = Object.assign({}, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);
|
||||||
searchOption.k = `#${element.getAttribute("data-label")}#`
|
searchOption.k = `#${element.getAttribute("data-label")}#`;
|
||||||
popSearch(searchOption);
|
popSearch(searchOption);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ export const showKeyboardToolbar = (height: number) => {
|
||||||
toolbarElement.classList.remove("fn__none");
|
toolbarElement.classList.remove("fn__none");
|
||||||
const searchPathElement = document.getElementById("searchPath");
|
const searchPathElement = document.getElementById("searchPath");
|
||||||
if (searchPathElement) {
|
if (searchPathElement) {
|
||||||
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = "42px"
|
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = "42px";
|
||||||
}
|
}
|
||||||
const range = getSelection().getRangeAt(0);
|
const range = getSelection().getRangeAt(0);
|
||||||
if (!window.siyuan.mobile.editor ||
|
if (!window.siyuan.mobile.editor ||
|
||||||
|
|
@ -292,7 +292,7 @@ export const hideKeyboardToolbar = () => {
|
||||||
window.siyuan.mobile.editor.protyle.element.style.marginBottom = "";
|
window.siyuan.mobile.editor.protyle.element.style.marginBottom = "";
|
||||||
const searchPathElement = document.getElementById("searchPath");
|
const searchPathElement = document.getElementById("searchPath");
|
||||||
if (searchPathElement) {
|
if (searchPathElement) {
|
||||||
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = ""
|
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
if (this.splitChar === "#" ) {
|
if (this.splitChar === "#" ) {
|
||||||
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
||||||
if (blockElement && blockElement.getAttribute("data-type") === "NodeHeading") {
|
if (blockElement && blockElement.getAttribute("data-type") === "NodeHeading") {
|
||||||
const blockIndex = getSelectionOffset(protyle.toolbar.range.startContainer, blockElement).start
|
const blockIndex = getSelectionOffset(protyle.toolbar.range.startContainer, blockElement).start;
|
||||||
if (blockElement.textContent.startsWith("#".repeat(blockIndex))) {
|
if (blockElement.textContent.startsWith("#".repeat(blockIndex))) {
|
||||||
this.element.classList.add("fn__none");
|
this.element.classList.add("fn__none");
|
||||||
clearTimeout(this.timeId);
|
clearTimeout(this.timeId);
|
||||||
|
|
|
||||||
|
|
@ -794,8 +794,8 @@ const getQueryTip = (method: number) => {
|
||||||
methodTip += window.siyuan.languages.regex;
|
methodTip += window.siyuan.languages.regex;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return methodTip
|
return methodTip;
|
||||||
}
|
};
|
||||||
|
|
||||||
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => {
|
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => {
|
||||||
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
|
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isWindow} from "./functions";
|
|
||||||
import {hideMessage, showMessage} from "../dialog/message";
|
import {hideMessage, showMessage} from "../dialog/message";
|
||||||
|
|
||||||
export const processMessage = (response: IWebSocketData) => {
|
export const processMessage = (response: IWebSocketData) => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {exportLayout, getInstanceById} from "../layout/util";
|
import {exportLayout, getInstanceById} from "../layout/util";
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {isWindow} from "../util/functions";
|
|
||||||
|
|
||||||
const closeTab = (ipcData: IWebSocketData) => {
|
const closeTab = (ipcData: IWebSocketData) => {
|
||||||
const tab = getInstanceById(ipcData.data);
|
const tab = getInstanceById(ipcData.data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue