This commit is contained in:
Vanessa 2022-05-28 22:43:27 +08:00
parent 410251677c
commit 4837f35487
5 changed files with 23 additions and 18 deletions

View File

@ -62,6 +62,12 @@ progressLoading: 400 // 需大于 .b3-dialog
} }
} }
.outline__title {
padding: 0 8px;
white-space: nowrap;
line-height: 30px;
}
.fullscreen { .fullscreen {
position: fixed; position: fixed;
top: 0; top: 0;

View File

@ -439,6 +439,7 @@ const updateOutline = (models: IModels, protyle: IProtyle, reload = false) => {
fetchPost("/api/outline/getDocOutline", { fetchPost("/api/outline/getDocOutline", {
id: blockId, id: blockId,
}, response => { }, response => {
item.updateDocTitle(protyle.title.editElement.textContent);
item.update(response, blockId); item.update(response, blockId);
if (protyle && getSelection().rangeCount > 0) { if (protyle && getSelection().rangeCount > 0) {
const startContainer = getSelection().getRangeAt(0).startContainer; const startContainer = getSelection().getRangeAt(0).startContainer;

View File

@ -10,6 +10,7 @@ import {openFileById, updateBacklinkGraph} from "../../editor/util";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {focusBlock} from "../../protyle/util/selection"; import {focusBlock} from "../../protyle/util/selection";
import {pushBack} from "../../util/backForward"; import {pushBack} from "../../util/backForward";
import {escapeHtml} from "../../util/escape";
export class Outline extends Model { export class Outline extends Model {
private tree: Tree; private tree: Tree;
@ -45,11 +46,7 @@ export class Outline extends Model {
if (this.type === "local" && this.blockId === data.data.id) { if (this.type === "local" && this.blockId === data.data.id) {
this.parent.updateTitle(data.data.title); this.parent.updateTitle(data.data.title);
} else { } else {
fetchPost("/api/outline/getDocOutline", { this.updateDocTitle(data.data.title);
id: this.blockId,
}, response => {
this.update(response);
});
} }
break; break;
case "unmount": case "unmount":
@ -84,6 +81,7 @@ export class Outline extends Model {
<span class="${this.type === "local" ? "fn__none " : ""}fn__space"></span> <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> <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>
<div class="fn__ellipsis outline__title"></div>
<div class="fn__flex-1"></div>`; <div class="fn__flex-1"></div>`;
this.element = options.tab.panelElement.lastElementChild as HTMLElement; this.element = options.tab.panelElement.lastElementChild as HTMLElement;
this.headerElement = options.tab.panelElement.firstElementChild as HTMLElement; this.headerElement = options.tab.panelElement.firstElementChild as HTMLElement;
@ -117,7 +115,7 @@ export class Outline extends Model {
}); });
// 为了快捷键的 dispatch // 为了快捷键的 dispatch
options.tab.panelElement.querySelector('[data-type="collapse"]').addEventListener("click", () => { options.tab.panelElement.querySelector('[data-type="collapse"]').addEventListener("click", () => {
this.tree.collapseAll(true); this.tree.collapseAll();
}); });
options.tab.panelElement.querySelector('[data-type="expand"]').addEventListener("click", (event: MouseEvent & { target: Element }) => { options.tab.panelElement.querySelector('[data-type="expand"]').addEventListener("click", (event: MouseEvent & { target: Element }) => {
const iconElement = hasClosestByClassName(event.target, "block__icon"); const iconElement = hasClosestByClassName(event.target, "block__icon");
@ -154,6 +152,7 @@ export class Outline extends Model {
fetchPost("/api/outline/getDocOutline", { fetchPost("/api/outline/getDocOutline", {
id: this.blockId, id: this.blockId,
}, response => { }, response => {
this.updateDocTitle();
this.update(response); this.update(response);
}); });
@ -162,6 +161,13 @@ export class Outline extends Model {
} }
} }
public updateDocTitle(title = "") {
if (this.type === "pin") {
this.headerElement.nextElementSibling.innerHTML = escapeHtml(title);
this.headerElement.nextElementSibling.setAttribute("title", title);
}
}
private onTransaction(data: IWebSocketData) { private onTransaction(data: IWebSocketData) {
let needReload = false; let needReload = false;
data.data[0].doOperations.forEach((item: IOperation) => { data.data[0].doOperations.forEach((item: IOperation) => {

View File

@ -45,7 +45,7 @@ export class MobileOutline {
} }
}); });
this.element.firstElementChild.querySelector('[data-type="collapse"]').addEventListener(getEventName(), () => { this.element.firstElementChild.querySelector('[data-type="collapse"]').addEventListener(getEventName(), () => {
this.tree.collapseAll(true); this.tree.collapseAll();
}); });
const expandElement = this.element.firstElementChild.querySelector('[data-type="expand"]'); const expandElement = this.element.firstElementChild.querySelector('[data-type="expand"]');
expandElement.addEventListener(getEventName(), () => { expandElement.addEventListener(getEventName(), () => {

View File

@ -226,22 +226,14 @@ data-def-path="${item.defPath}">
}); });
} }
public collapseAll(isFirst = false) { public collapseAll() {
this.element.querySelectorAll("ul").forEach(item => { this.element.querySelectorAll("ul").forEach(item => {
if (!item.classList.contains("b3-list")) { if (!item.classList.contains("b3-list")) {
if (isFirst && item.parentElement.classList.contains("b3-list")) {
// 第一层级不进行缩放
} else {
item.classList.add("fn__none"); item.classList.add("fn__none");
} }
}
}); });
this.element.querySelectorAll(".b3-list-item__arrow").forEach(item => { this.element.querySelectorAll(".b3-list-item__arrow").forEach(item => {
if (isFirst && item.parentElement.parentElement.parentElement.classList.contains("b3-list")) {
// 第一层级不进行缩放
} else {
item.classList.remove("b3-list-item__arrow--open"); item.classList.remove("b3-list-item__arrow--open");
}
}); });
} }