This commit is contained in:
Vanessa 2023-05-29 11:20:08 +08:00
parent 6c4753d290
commit e4b14a12c6
8 changed files with 32 additions and 29 deletions

View file

@ -45,9 +45,6 @@ export const openFileById = async (options: {
showMessage(data.msg);
return;
}
if (typeof options.removeCurrentTab === "undefined") {
options.removeCurrentTab = true;
}
openFile({
app: options.app,
fileName: data.data.rootTitle,
@ -80,6 +77,9 @@ export const openAsset = (app: App, assetPath: string, page: number | string, po
};
export const openFile = (options: IOpenFileOptions) => {
if (typeof options.removeCurrentTab === "undefined") {
options.removeCurrentTab = true;
}
const allModels = getAllModels();
// 文档已打开
if (options.assetPath) {

View file

@ -221,7 +221,7 @@ export class Outline extends Model {
if (getSelection().rangeCount > 0) {
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
if (blockElement && blockElement.getAttribute("data-type") === "NodeHeading") {
this.setCurrent(blockElement)
this.setCurrent(blockElement);
}
}
});

View file

@ -584,43 +584,43 @@ export const resizeTopbar = () => {
const dragElement = toolbarElement.querySelector("#drag") as HTMLElement;
dragElement.style.padding = "";
const barMoreElement = toolbarElement.querySelector("#barMore")
barMoreElement.classList.remove("fn__none")
barMoreElement.removeAttribute("data-hideids")
const barMoreElement = toolbarElement.querySelector("#barMore");
barMoreElement.classList.remove("fn__none");
barMoreElement.removeAttribute("data-hideids");
Array.from(toolbarElement.querySelectorAll('[data-hide="true"]')).forEach((item) => {
item.classList.remove("fn__none")
item.classList.remove("fn__none");
item.removeAttribute("data-hide");
})
});
let afterDragElement = dragElement.nextElementSibling
const hideIds: string[] = []
let afterDragElement = dragElement.nextElementSibling;
const hideIds: string[] = [];
while (toolbarElement.scrollWidth > toolbarElement.clientWidth + 2) {
hideIds.push(afterDragElement.id)
afterDragElement.classList.add("fn__none")
afterDragElement.setAttribute("data-hide", "true")
afterDragElement = afterDragElement.nextElementSibling
hideIds.push(afterDragElement.id);
afterDragElement.classList.add("fn__none");
afterDragElement.setAttribute("data-hide", "true");
afterDragElement = afterDragElement.nextElementSibling;
if (afterDragElement.id === "barMore") {
break;
}
}
let beforeDragElement = dragElement.previousElementSibling
let beforeDragElement = dragElement.previousElementSibling;
while (toolbarElement.scrollWidth > toolbarElement.clientWidth + 2) {
hideIds.push(beforeDragElement.id)
beforeDragElement.classList.add("fn__none")
beforeDragElement.setAttribute("data-hide", "true")
beforeDragElement = beforeDragElement.previousElementSibling
hideIds.push(beforeDragElement.id);
beforeDragElement.classList.add("fn__none");
beforeDragElement.setAttribute("data-hide", "true");
beforeDragElement = beforeDragElement.previousElementSibling;
if (beforeDragElement.id === "barWorkspace") {
break;
}
}
if (hideIds.length > 0) {
barMoreElement.classList.remove("fn__none")
barMoreElement.classList.remove("fn__none");
} else {
barMoreElement.classList.add("fn__none")
barMoreElement.classList.add("fn__none");
}
barMoreElement.setAttribute("data-hideids", hideIds.join(","))
barMoreElement.setAttribute("data-hideids", hideIds.join(","));
const width = dragElement.clientWidth;
const dragRect = dragElement.getBoundingClientRect();

View file

@ -1190,16 +1190,16 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
}
});
}
const isPinHead = nodeElement.getAttribute("custom-pinthead")
const isPinHead = nodeElement.getAttribute("custom-pinthead");
menus.push({
icon: "iconPin",
label: isPinHead ? window.siyuan.languages.unpinTableHead : window.siyuan.languages.pinTableHead,
click: () => {
const html = nodeElement.outerHTML;
if (isPinHead) {
nodeElement.removeAttribute("custom-pinthead")
nodeElement.removeAttribute("custom-pinthead");
} else {
nodeElement.setAttribute("custom-pinthead", "true")
nodeElement.setAttribute("custom-pinthead", "true");
}
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
}

View file

@ -194,7 +194,7 @@ openTab = (options: {
return;
}
}
};
/// #endif
export const API = {

View file

@ -34,7 +34,7 @@ export const processPasteCode = (html: string, text: string) => {
return `<div data-type="NodeCodeBlock" class="code-block" data-node-id="${Lute.NewNodeID()}"><div class="protyle-action"><span class="protyle-action--first protyle-action__language" contenteditable="false">${window.siyuan.storage[Constants.LOCAL_CODELANG]}</span><span class="fn__flex-1"></span><span class="protyle-icon protyle-icon--first protyle-action__copy"><svg><use xlink:href="#iconCopy"></use></svg></span><span class="protyle-icon protyle-icon--last protyle-action__menu"><svg><use xlink:href="#iconMore"></use></svg></span></div><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${code.replace(/&/g, "&amp;").replace(/</g, "&lt;")}<wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
} else {
// Paste code from IDE no longer escape `<` and `>` https://github.com/siyuan-note/siyuan/issues/8340
code = code.replace("<", "&lt;").replace('>', "&gt;");
code = code.replace("<", "&lt;").replace(">", "&gt;");
return "`" + code + "`";
}
}

View file

@ -15,6 +15,9 @@ export class Search extends Model {
app: options.app,
id: options.tab.id,
});
if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
options.tab.headElement?.classList.add("item--unupdate");
}
this.element = options.tab.panelElement as HTMLElement;
this.config = options.config;
this.edit = genSearch(options.app, this.config, this.element);

View file

@ -66,4 +66,4 @@ const afterLayout = (app:App) => {
const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
tab.parent.switchTab(item, false, false);
});
}
};