This commit is contained in:
Vanessa 2023-04-18 18:57:20 +08:00
parent bfbcb3c3f0
commit 321b2063bf
3 changed files with 17 additions and 9 deletions

View file

@ -90,7 +90,7 @@ export class Outline extends Model {
<span class="${this.type === "local" ? "fn__none " : ""}fn__space"></span>
<span data-type="min" class="${this.type === "local" ? "fn__none " : ""}block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.min} ${updateHotkeyTip(window.siyuan.config.keymap.general.closeTab.custom)}"><svg><use xlink:href='#iconMin'></use></svg></span>
</div>
<div class="b3-list-item"></div>
<div class="b3-list-item fn__none"></div>
<div class="fn__flex-1" style="margin-bottom: 8px"></div>`;
this.element = options.tab.panelElement.lastElementChild as HTMLElement;
this.headerElement = options.tab.panelElement.firstElementChild as HTMLElement;
@ -176,19 +176,22 @@ export class Outline extends Model {
}
public updateDocTitle(ial?: IObject) {
const docTitleElement = this.headerElement.nextElementSibling as HTMLElement
if (this.type === "pin") {
if (ial) {
let iconHTML = `${unicode2Emoji(ial.icon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true)}`;
if (ial.icon === Constants.ZWSP && this.headerElement.nextElementSibling.firstElementChild) {
iconHTML = this.headerElement.nextElementSibling.firstElementChild.outerHTML;
if (ial.icon === Constants.ZWSP && docTitleElement.firstElementChild) {
iconHTML = docTitleElement.firstElementChild.outerHTML;
}
this.headerElement.nextElementSibling.innerHTML = `${iconHTML}
docTitleElement.innerHTML = `${iconHTML}
<span class="b3-list-item__text">${escapeHtml(ial.title)}</span>`;
this.headerElement.nextElementSibling.setAttribute("title", ial.title);
docTitleElement.setAttribute("title", ial.title);
docTitleElement.classList.remove("fn__none")
} else {
this.headerElement.nextElementSibling.innerHTML = "";
this.headerElement.nextElementSibling.removeAttribute("title");
docTitleElement.classList.add("fn__none")
}
} else {
docTitleElement.classList.add("fn__none")
}
}

View file

@ -29,6 +29,7 @@ import {Backlink} from "./dock/Backlink";
import {openFileById} from "../editor/util";
import {getSearch, isWindow} from "../util/functions";
import {showMessage} from "../dialog/message";
import {setTabPosition} from "../window/setHeader";
export const setPanelFocus = (element: Element) => {
if (element.classList.contains("layout__tab--active") || element.classList.contains("layout__wnd--active")) {
@ -102,6 +103,9 @@ export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
targetWnd.children.forEach((item) => {
if (item.model instanceof Editor) {
const rangeData = rangeDatas.splice(0, 1)[0];
if (!rangeData) {
return;
}
const range = focusByOffset(item.model.editor.protyle.wysiwyg.element.querySelector(`[data-node-id="${rangeData.id}"]`), rangeData.start, rangeData.end);
if (range) {
item.model.editor.protyle.toolbar.range = range;
@ -121,6 +125,7 @@ export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
return true;
}
});
setTabPosition();
};
export const getWndByLayout: (layout: Layout) => Wnd = (layout: Layout) => {

View file

@ -35,10 +35,10 @@ export const setTabPosition = () => {
const headersLastElement = headerElement.lastElementChild as HTMLElement;
if ("darwin" === window.siyuan.config.system.os) {
if (rect.top <= 0 && rect.left <= 0 && !getCurrentWindow().isFullScreen()) {
item.headersElement.style.paddingLeft = "var(--b3-toolbar-left-mac)";
item.headersElement.style.marginLeft = "var(--b3-toolbar-left-mac)";
headersLastElement.style.paddingRight = "42px";
} else {
item.headersElement.style.paddingLeft = "";
item.headersElement.style.marginLeft = "";
headersLastElement.style.paddingRight = "";
}
}