|
@@ -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", {
|
|
|
|
- id: this.blockId,
|
|
|
|
- }, response => {
|
|
|
|
- this.update(response);
|
|
|
|
- });
|
|
|
|
|
|
+ this.updateDocTitle(data.data.title);
|
|
}
|
|
}
|
|
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) => {
|