mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-28 19:26:09 +01:00
This commit is contained in:
parent
7328e34632
commit
0c662dc317
5 changed files with 29 additions and 23 deletions
|
|
@ -422,13 +422,13 @@ const updateFileEmoji = (unicode: string, id: string) => {
|
|||
/// #if MOBILE
|
||||
if (window.siyuan.mobileEditor.protyle.block.rootID === id) {
|
||||
window.siyuan.mobileEditor.protyle.background.ial.icon = unicode;
|
||||
window.siyuan.mobileEditor.protyle.background.render(window.siyuan.mobileEditor.protyle.background.ial, id);
|
||||
window.siyuan.mobileEditor.protyle.background.render(window.siyuan.mobileEditor.protyle.background.ial);
|
||||
}
|
||||
/// #else
|
||||
getAllModels().editor.find(item => {
|
||||
if (item.editor.protyle.block.rootID === id) {
|
||||
item.editor.protyle.background.ial.icon = unicode;
|
||||
item.editor.protyle.background.render(item.editor.protyle.background.ial, id);
|
||||
item.editor.protyle.background.render(item.editor.protyle.background.ial);
|
||||
item.parent.setDocIcon(unicode);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const focusStack = (backStack: IBackStack) => {
|
|||
id: backStack.id,
|
||||
}, (response) => {
|
||||
(document.getElementById("toolbarName") as HTMLInputElement).value = response.data.name === "Untitled" ? "" : response.data.name;
|
||||
protyle.background.render(response.data.ial, protyle.block.rootID);
|
||||
protyle.background.render(response.data.ial);
|
||||
protyle.wysiwyg.renderCustom(response.data.ial);
|
||||
});
|
||||
}
|
||||
|
|
@ -56,7 +56,15 @@ const focusStack = (backStack: IBackStack) => {
|
|||
startID: startEndId[0],
|
||||
endID: startEndId[1],
|
||||
}, getResponse => {
|
||||
protyle.block.parentID = getResponse.data.parentID;
|
||||
protyle.block.parent2ID = getResponse.data.parent2ID;
|
||||
protyle.block.rootID = getResponse.data.rootID;
|
||||
protyle.block.showAll = false;
|
||||
protyle.block.mode = getResponse.data.mode;
|
||||
protyle.block.blockCount = getResponse.data.blockCount;
|
||||
protyle.block.id = getResponse.data.id;
|
||||
protyle.block.action = backStack.callback;
|
||||
protyle.wysiwyg.element.setAttribute("data-doc-type", getResponse.data.type);
|
||||
protyle.wysiwyg.element.innerHTML = getResponse.data.content;
|
||||
processRender(protyle.wysiwyg.element);
|
||||
highlightRender(protyle.wysiwyg.element);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ export class Background {
|
|||
const response = JSON.parse(responseText);
|
||||
const style = `background-image:url("${response.data.succMap[Object.keys(response.data.succMap)[0]]}")`;
|
||||
this.ial["title-img"] = style;
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id: protyle.block.rootID,
|
||||
attrs: {"title-img": style}
|
||||
|
|
@ -118,7 +118,7 @@ export class Background {
|
|||
attrs: {"title-img": style}
|
||||
});
|
||||
} else {
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
@ -207,7 +207,7 @@ export class Background {
|
|||
];
|
||||
const style = bgs[getRandom(0, bgs.length - 1)];
|
||||
this.ial["title-img"] = style;
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id: protyle.block.rootID,
|
||||
attrs: {"title-img": this.ial["title-img"]}
|
||||
|
|
@ -217,7 +217,7 @@ export class Background {
|
|||
break;
|
||||
} else if (type === "remove") {
|
||||
delete this.ial["title-img"];
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id: protyle.block.rootID,
|
||||
attrs: {"title-img": ""}
|
||||
|
|
@ -229,7 +229,7 @@ export class Background {
|
|||
const emoji = getRandomEmoji();
|
||||
if (emoji) {
|
||||
this.ial.icon = emoji;
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
updateFileTreeEmoji(emoji, protyle.block.rootID);
|
||||
updateOutlineEmoji(emoji);
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
|
|
@ -244,7 +244,7 @@ export class Background {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "tag") {
|
||||
this.openTag();
|
||||
this.openTag(protyle);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
|
|
@ -267,7 +267,7 @@ export class Background {
|
|||
btnsElement[1].addEventListener("click", () => {
|
||||
const style = `background-image:url(${dialog.element.querySelector("input").value});`;
|
||||
this.ial["title-img"] = style;
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id: protyle.block.rootID,
|
||||
attrs: {"title-img": this.ial["title-img"]}
|
||||
|
|
@ -297,7 +297,7 @@ export class Background {
|
|||
} else {
|
||||
this.ial.tags = tags.toString();
|
||||
}
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
this.render(this.ial);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
|
|
@ -307,12 +307,11 @@ export class Background {
|
|||
});
|
||||
}
|
||||
|
||||
public render(ial: IObject, id: string) {
|
||||
public render(ial: IObject) {
|
||||
const img = ial["title-img"];
|
||||
const icon = ial.icon;
|
||||
const tags = ial.tags;
|
||||
this.ial = ial;
|
||||
this.element.setAttribute("data-node-id", id);
|
||||
if (tags) {
|
||||
let html = "";
|
||||
tags.split(",").forEach((item, index) => {
|
||||
|
|
@ -360,7 +359,7 @@ export class Background {
|
|||
}
|
||||
}
|
||||
|
||||
private openTag() {
|
||||
private openTag(protyle:IProtyle) {
|
||||
fetchPost("/api/search/searchTag", {
|
||||
k: "",
|
||||
}, (response) => {
|
||||
|
|
@ -384,9 +383,9 @@ export class Background {
|
|||
if (event.key === "Enter") {
|
||||
const currentElement = listElement.querySelector(".b3-list-item--focus");
|
||||
if (currentElement) {
|
||||
this.addTags(currentElement.textContent);
|
||||
this.addTags(currentElement.textContent, protyle);
|
||||
} else {
|
||||
this.addTags(inputElement.value);
|
||||
this.addTags(inputElement.value, protyle);
|
||||
}
|
||||
window.siyuan.menus.menu.remove();
|
||||
} else if (event.key === "Escape") {
|
||||
|
|
@ -419,7 +418,7 @@ export class Background {
|
|||
if (!listItemElement) {
|
||||
return;
|
||||
}
|
||||
this.addTags(listItemElement.textContent);
|
||||
this.addTags(listItemElement.textContent, protyle);
|
||||
});
|
||||
const rect = this.iconElement.nextElementSibling.getBoundingClientRect();
|
||||
window.siyuan.menus.menu.popup({x: rect.left, y: rect.top + rect.height});
|
||||
|
|
@ -435,19 +434,18 @@ export class Background {
|
|||
return tags;
|
||||
}
|
||||
|
||||
private addTags(tag: string) {
|
||||
private addTags(tag: string, protyle:IProtyle) {
|
||||
window.siyuan.menus.menu.remove();
|
||||
const tags = this.getTags();
|
||||
if (tags.includes(tag)) {
|
||||
return;
|
||||
}
|
||||
tags.push(tag);
|
||||
const id = this.element.getAttribute("data-node-id");
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id,
|
||||
id:protyle.block.rootID,
|
||||
attrs: {"tags": tags.toString()}
|
||||
});
|
||||
this.ial.tags = tags.toString();
|
||||
this.render(this.ial, id);
|
||||
this.render(this.ial);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))
|
|||
return false;
|
||||
}
|
||||
setTitle(response.data.ial.title);
|
||||
protyle.background.render(response.data.ial, protyle.block.rootID);
|
||||
protyle.background.render(response.data.ial);
|
||||
protyle.wysiwyg.renderCustom(response.data.ial);
|
||||
this.editElement.setAttribute("data-render", "true");
|
||||
this.setTitle(response.data.ial.title);
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
|
|||
// 页签没有打开
|
||||
protyle.title.render(protyle, response, renderTitle);
|
||||
} else if (protyle.options.render.background) {
|
||||
protyle.background.render(response.data.ial, protyle.block.rootID);
|
||||
protyle.background.render(response.data.ial);
|
||||
protyle.wysiwyg.renderCustom(response.data.ial);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue