mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 16:31:22 +08:00
🎨 outline add emoji
This commit is contained in:
parent
aae6247e3c
commit
feb2bc9a0d
@ -62,12 +62,6 @@ 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;
|
||||||
|
@ -441,7 +441,7 @@ const updateOutline = (models: IModels, protyle: IProtyle, reload = false) => {
|
|||||||
}, response => {
|
}, response => {
|
||||||
item.update(response, blockId);
|
item.update(response, blockId);
|
||||||
if (protyle) {
|
if (protyle) {
|
||||||
item.updateDocTitle(protyle.title.editElement.textContent);
|
item.updateDocTitle(protyle.background.ial);
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
const startContainer = getSelection().getRangeAt(0).startContainer;
|
const startContainer = getSelection().getRangeAt(0).startContainer;
|
||||||
if (protyle.wysiwyg.element.contains(startContainer)) {
|
if (protyle.wysiwyg.element.contains(startContainer)) {
|
||||||
|
@ -266,6 +266,7 @@ export const openEmojiPanel = (id: string, target: HTMLElement, isNotebook = fal
|
|||||||
addEmoji(unicode);
|
addEmoji(unicode);
|
||||||
updateFileTreeEmoji(unicode, id);
|
updateFileTreeEmoji(unicode, id);
|
||||||
updateFileEmoji(unicode, id);
|
updateFileEmoji(unicode, id);
|
||||||
|
updateOutlineEmoji(unicode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -344,6 +345,7 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
|||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
updateFileTreeEmoji("", id);
|
updateFileTreeEmoji("", id);
|
||||||
updateFileEmoji("", id);
|
updateFileEmoji("", id);
|
||||||
|
updateOutlineEmoji("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -373,6 +375,7 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
|||||||
addEmoji(unicode);
|
addEmoji(unicode);
|
||||||
updateFileTreeEmoji(unicode, id);
|
updateFileTreeEmoji(unicode, id);
|
||||||
updateFileEmoji(unicode, id);
|
updateFileEmoji(unicode, id);
|
||||||
|
updateOutlineEmoji(unicode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -380,6 +383,12 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateOutlineEmoji = (unicode: string) => {
|
||||||
|
getAllModels().outline.forEach(model => {
|
||||||
|
model.headerElement.nextElementSibling.firstElementChild.innerHTML = unicode2Emoji(unicode || Constants.SIYUAN_IMAGE_FILE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFile") => {
|
export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFile") => {
|
||||||
let emojiElement;
|
let emojiElement;
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
|
@ -11,11 +11,12 @@ 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";
|
import {escapeHtml} from "../../util/escape";
|
||||||
|
import {unicode2Emoji} from "../../emoji";
|
||||||
|
|
||||||
export class Outline extends Model {
|
export class Outline extends Model {
|
||||||
private tree: Tree;
|
private tree: Tree;
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
private headerElement: HTMLElement;
|
public headerElement: HTMLElement;
|
||||||
public type: "pin" | "local";
|
public type: "pin" | "local";
|
||||||
public blockId: string;
|
public blockId: string;
|
||||||
private openNodes: { [key: string]: string[] } = {};
|
private openNodes: { [key: string]: string[] } = {};
|
||||||
@ -46,7 +47,9 @@ 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 {
|
||||||
this.updateDocTitle(data.data.title);
|
this.updateDocTitle({
|
||||||
|
title: data.data.title
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "unmount":
|
case "unmount":
|
||||||
@ -81,7 +84,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="b3-list-item"></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;
|
||||||
@ -160,10 +163,20 @@ export class Outline extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateDocTitle(title = "") {
|
public updateDocTitle(ial?:IObject) {
|
||||||
if (this.type === "pin") {
|
if (this.type === "pin") {
|
||||||
this.headerElement.nextElementSibling.innerHTML = escapeHtml(title);
|
if (ial) {
|
||||||
this.headerElement.nextElementSibling.setAttribute("title", title);
|
let iconHTML = `<span class="b3-list-item__graphic">${unicode2Emoji(ial.icon || Constants.SIYUAN_IMAGE_FILE)}</span>`
|
||||||
|
if (typeof ial.icon === "undefined" && this.headerElement.nextElementSibling.firstElementChild) {
|
||||||
|
iconHTML = this.headerElement.nextElementSibling.firstElementChild.outerHTML;
|
||||||
|
}
|
||||||
|
this.headerElement.nextElementSibling.innerHTML = `${iconHTML}
|
||||||
|
<span class="b3-list-item__text">${escapeHtml(ial.title)}</span>`;
|
||||||
|
this.headerElement.nextElementSibling.setAttribute("title", ial.title);
|
||||||
|
} else {
|
||||||
|
this.headerElement.nextElementSibling.innerHTML = "";
|
||||||
|
this.headerElement.nextElementSibling.removeAttribute("title");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ export class Dock {
|
|||||||
blockId: editor?.protyle?.block?.rootID,
|
blockId: editor?.protyle?.block?.rootID,
|
||||||
});
|
});
|
||||||
if (editor?.protyle?.title?.editElement) {
|
if (editor?.protyle?.title?.editElement) {
|
||||||
outline.updateDocTitle(editor.protyle.title.editElement.textContent);
|
outline.updateDocTitle(editor.protyle?.background?.ial);
|
||||||
}
|
}
|
||||||
tab.addModel(outline);
|
tab.addModel(outline);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import {hideElements} from "../ui/hideElements";
|
|||||||
import {uploadFiles} from "../upload";
|
import {uploadFiles} from "../upload";
|
||||||
import {hideMessage} from "../../dialog/message";
|
import {hideMessage} from "../../dialog/message";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {getRandomEmoji, openEmojiPanel, unicode2Emoji, updateFileTreeEmoji} from "../../emoji";
|
import {getRandomEmoji, openEmojiPanel, unicode2Emoji, updateFileTreeEmoji, updateOutlineEmoji} from "../../emoji";
|
||||||
import {upDownHint} from "../../util/upDownHint";
|
import {upDownHint} from "../../util/upDownHint";
|
||||||
import {setPosition} from "../../util/setPosition";
|
import {setPosition} from "../../util/setPosition";
|
||||||
import {openGlobalSearch} from "../../search/util";
|
import {openGlobalSearch} from "../../search/util";
|
||||||
@ -232,6 +232,7 @@ export class Background {
|
|||||||
this.ial.icon = emoji;
|
this.ial.icon = emoji;
|
||||||
this.render(this.ial, protyle.block.rootID);
|
this.render(this.ial, protyle.block.rootID);
|
||||||
updateFileTreeEmoji(emoji, protyle.block.rootID);
|
updateFileTreeEmoji(emoji, protyle.block.rootID);
|
||||||
|
updateOutlineEmoji(emoji);
|
||||||
fetchPost("/api/attr/setBlockAttrs", {
|
fetchPost("/api/attr/setBlockAttrs", {
|
||||||
id: protyle.block.rootID,
|
id: protyle.block.rootID,
|
||||||
attrs: {"icon": emoji}
|
attrs: {"icon": emoji}
|
||||||
|
Loading…
Reference in New Issue
Block a user