This commit is contained in:
Vanessa 2023-04-09 19:46:57 +08:00
parent ba4bedf3bc
commit e5143a8474
13 changed files with 30 additions and 34 deletions

View file

@ -32,7 +32,7 @@ import {MenuItem} from "../menus/Menu";
import {escapeHtml} from "../util/escape";
import {isWindow} from "../util/functions";
import {hideAllElements} from "../protyle/ui/hideElements";
import {focusByOffset, getSelectionOffset, getSelectionPosition} from "../protyle/util/selection";
import {focusByOffset, getSelectionOffset} from "../protyle/util/selection";
export class Wnd {
public id: string;
@ -760,7 +760,7 @@ export class Wnd {
id: string,
start: number,
end: number
}
};
if (tab.model instanceof Editor && tab.model.editor.protyle.toolbar.range) {
const blockElement = hasClosestBlock(tab.model.editor.protyle.toolbar.range.startContainer);
if (blockElement) {
@ -769,7 +769,7 @@ export class Wnd {
id: blockElement.getAttribute("data-node-id"),
start: startEnd.start,
end: startEnd.end
}
};
}
}
this.element.querySelector(".layout-tab-container").append(tab.panelElement);

View file

@ -94,10 +94,10 @@ export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
id: blockElement.getAttribute("data-node-id"),
start: startEnd.start,
end: startEnd.end
})
});
}
}
})
});
newWnd.element.after(targetWnd.element);
targetWnd.children.forEach((item) => {
if (item.model instanceof Editor) {
@ -107,7 +107,7 @@ export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
item.model.editor.protyle.toolbar.range = range;
}
}
})
});
// 分割线
newWnd.element.after(newWnd.element.previousElementSibling);
newWnd.parent.children.find((item, index) => {

View file

@ -135,7 +135,7 @@ export class Menu {
} else {
this.element.style.transform = "translateY(-100vh)";
}
})
});
this.element.lastElementChild.scrollTop = 0;
}
}

View file

@ -56,7 +56,7 @@ export const onGetnotebookconf = (data: INotebookConf) => {
bindEvent() {
bindSettingEvent(document.querySelector("#model"), data);
}
})
});
} else {
const dialog = new Dialog({
width: "80vw",
@ -94,4 +94,4 @@ const bindSettingEvent = (contentElement: Element, data: INotebookConf) => {
});
});
});
}
};

View file

@ -107,10 +107,10 @@ const updateConfig = (element: Element, newConfig: ISearchOption, config: ISearc
}
const searchPathElement = element.querySelector("#searchPath");
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>`;
} else {
searchPathElement.classList.add("fn__none")
searchPathElement.classList.add("fn__none");
}
if (config.group !== newConfig.group) {
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 listElement = document.querySelector("#searchList")
const listElement = document.querySelector("#searchList");
let resultHTML = "";
data.forEach((item: IBlock, index: number) => {
const title = getNotebookName(item.box) + getDisplayName(item.hPath, false);
@ -191,7 +191,7 @@ ${unicode2Emoji(childItem.ial.icon, false, "b3-list-item__graphic", true)}
</span>
</div>`;
listElement.scrollTop = 0;
let countHTML = ""
let countHTML = "";
if (matchedBlockCount) {
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);
});
const replaceInputElement = element.querySelector(".toolbar .b3-text-field") as HTMLInputElement
replaceInputElement.value = config.r || ""
const replaceInputElement = element.querySelector(".toolbar .b3-text-field") as HTMLInputElement;
replaceInputElement.value = config.r || "";
const criteriaData: ISearchOption[] = [];
initCriteriaMenu(element.querySelector("#criteria"), criteriaData);
@ -285,7 +285,7 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
} else if (type === "remove-path") {
config.idPath = [];
config.hPath = "";
element.querySelector("#searchPath").classList.add("fn__none")
element.querySelector("#searchPath").classList.add("fn__none");
updateSearchResult(config, element);
const includeElement = element.querySelector('[data-type="include"]');
includeElement.classList.remove("toolbar__icon--active");
@ -333,7 +333,7 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
}
config.hPath = hPathList.join(" ");
const searchPathElement = element.querySelector("#searchPath")
const searchPathElement = element.querySelector("#searchPath");
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>`;
@ -405,7 +405,7 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
embedBlock: window.siyuan.config.search.embedBlock,
}
}, config);
})
});
window.siyuan.menus.menu.element.style.zIndex = "220";
window.siyuan.menus.menu.fullscreen();
event.stopPropagation();
@ -413,14 +413,14 @@ const initSearchEvent = (element: Element, config: ISearchOption) => {
break;
} else if (type === "filter") {
filterMenu(config, () => {
updateSearchResult(config, element)
updateSearchResult(config, element);
});
event.stopPropagation();
event.preventDefault();
break;
} else if (type === "query") {
queryMenu(config, () => {
updateSearchResult(config, element)
updateSearchResult(config, element);
});
window.siyuan.menus.menu.element.style.zIndex = "220";
window.siyuan.menus.menu.fullscreen();

View file

@ -1,7 +1,5 @@
import {fetchPost} from "../../util/fetch";
import {setInlineStyle} from "../../util/assets";
import {genOptions} from "../../util/genOptions";
import {reloadProtyle} from "../../protyle/util/reload";
import {openModel} from "../menu/model";
export const initAppearance = () => {

View file

@ -7,7 +7,7 @@ const reloadEditor = (data: IEditor) => {
window.siyuan.config.editor = data;
reloadProtyle(window.siyuan.mobile.editor.protyle);
setInlineStyle();
}
};
export const initEditor = () => {
openModel({
@ -32,16 +32,16 @@ export const initEditor = () => {
modelMainElement.querySelector("#fontSize").textContent = event.target.value + "px";
window.siyuan.config.editor.fontSize = parseInt(event.target.value);
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
reloadEditor(response.data)
reloadEditor(response.data);
});
});
const katexMacrosElement = modelMainElement.querySelector("#katexMacros") as HTMLTextAreaElement;
katexMacrosElement.addEventListener("blur", () => {
window.siyuan.config.editor.katexMacros = katexMacrosElement.value;
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
reloadEditor(response.data)
reloadEditor(response.data);
});
})
});
}
});
};

View file

@ -67,7 +67,7 @@ export class MobileTags {
}
} else {
const searchOption = Object.assign({}, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);
searchOption.k = `#${element.getAttribute("data-label")}#`
searchOption.k = `#${element.getAttribute("data-label")}#`;
popSearch(searchOption);
}
},

View file

@ -260,7 +260,7 @@ export const showKeyboardToolbar = (height: number) => {
toolbarElement.classList.remove("fn__none");
const searchPathElement = document.getElementById("searchPath");
if (searchPathElement) {
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = "42px"
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = "42px";
}
const range = getSelection().getRangeAt(0);
if (!window.siyuan.mobile.editor ||
@ -292,7 +292,7 @@ export const hideKeyboardToolbar = () => {
window.siyuan.mobile.editor.protyle.element.style.marginBottom = "";
const searchPathElement = document.getElementById("searchPath");
if (searchPathElement) {
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = ""
(searchPathElement.nextElementSibling as HTMLElement).style.marginBottom = "";
}
};

View file

@ -166,7 +166,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
if (this.splitChar === "#" ) {
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
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))) {
this.element.classList.add("fn__none");
clearTimeout(this.timeId);

View file

@ -794,8 +794,8 @@ const getQueryTip = (method: number) => {
methodTip += window.siyuan.languages.regex;
break;
}
return methodTip
}
return methodTip;
};
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => {
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");

View file

@ -1,7 +1,6 @@
/// #if !MOBILE
import {exportLayout} from "../layout/util";
/// #endif
import {isWindow} from "./functions";
import {hideMessage, showMessage} from "../dialog/message";
export const processMessage = (response: IWebSocketData) => {

View file

@ -1,7 +1,6 @@
import {exportLayout, getInstanceById} from "../layout/util";
import {Tab} from "../layout/Tab";
import {fetchPost} from "../util/fetch";
import {isWindow} from "../util/functions";
const closeTab = (ipcData: IWebSocketData) => {
const tab = getInstanceById(ipcData.data);