mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
9044438108
commit
70baabd82a
3 changed files with 35 additions and 30 deletions
|
|
@ -269,7 +269,6 @@ export const openEmojiPanel = (id: string, target: HTMLElement, isNotebook = fal
|
|||
window.siyuan.menus.menu.remove();
|
||||
addEmoji(unicode);
|
||||
updateFileTreeEmoji(unicode, id);
|
||||
updateFileEmoji(unicode, id);
|
||||
updateOutlineEmoji(unicode, id);
|
||||
});
|
||||
}
|
||||
|
|
@ -359,7 +358,6 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
|||
}, () => {
|
||||
window.siyuan.menus.menu.remove();
|
||||
updateFileTreeEmoji("", id);
|
||||
updateFileEmoji("", id);
|
||||
updateOutlineEmoji("", id);
|
||||
});
|
||||
}
|
||||
|
|
@ -389,7 +387,6 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
|||
}, () => {
|
||||
addEmoji(unicode);
|
||||
updateFileTreeEmoji(unicode, id);
|
||||
updateFileEmoji(unicode, id);
|
||||
updateOutlineEmoji(unicode, id);
|
||||
});
|
||||
}
|
||||
|
|
@ -413,11 +410,14 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFil
|
|||
/// #if MOBILE
|
||||
emojiElement = document.querySelector(`#sidebar [data-type="sidebar-file"] [data-node-id="${id}"] .b3-list-item__icon`);
|
||||
/// #else
|
||||
const files = getDockByType("file").data.file as Files;
|
||||
if (icon === "iconFile") {
|
||||
emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`);
|
||||
} else {
|
||||
emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`) || files.element.querySelector(`[data-url="${id}"] .b3-list-item__icon`) || files.closeElement.querySelector(`[data-url="${id}"] .b3-list-item__icon`);
|
||||
const dockFile = getDockByType("file")
|
||||
if (dockFile) {
|
||||
const files = dockFile.data.file as Files;
|
||||
if (icon === "iconFile") {
|
||||
emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`);
|
||||
} else {
|
||||
emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`) || files.element.querySelector(`[data-url="${id}"] .b3-list-item__icon`) || files.closeElement.querySelector(`[data-url="${id}"] .b3-list-item__icon`);
|
||||
}
|
||||
}
|
||||
/// #endif
|
||||
if (emojiElement) {
|
||||
|
|
@ -427,21 +427,3 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFil
|
|||
setNoteBook();
|
||||
}
|
||||
};
|
||||
|
||||
const updateFileEmoji = (unicode: string, id: string) => {
|
||||
/// #if MOBILE
|
||||
if (window.siyuan.mobile.editor.protyle.block.rootID === id) {
|
||||
window.siyuan.mobile.editor.protyle.background.ial.icon = unicode;
|
||||
window.siyuan.mobile.editor.protyle.background.render(window.siyuan.mobile.editor.protyle.background.ial, window.siyuan.mobile.editor.protyle.block.rootID);
|
||||
}
|
||||
/// #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, item.editor.protyle.block.rootID);
|
||||
item.parent.setDocIcon(unicode);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,13 @@ import {getRandom, isMobile} from "../../util/functions";
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
import {uploadFiles} from "../upload";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {getRandomEmoji, openEmojiPanel, unicode2Emoji, updateFileTreeEmoji, updateOutlineEmoji} from "../../emoji";
|
||||
import {
|
||||
getRandomEmoji,
|
||||
openEmojiPanel,
|
||||
unicode2Emoji,
|
||||
updateFileTreeEmoji,
|
||||
updateOutlineEmoji
|
||||
} from "../../emoji";
|
||||
import {upDownHint} from "../../util/upDownHint";
|
||||
/// #if !MOBILE
|
||||
import {openGlobalSearch} from "../../search/util";
|
||||
|
|
@ -259,8 +265,6 @@ export class Background {
|
|||
} else if (type === "icon") {
|
||||
const emoji = getRandomEmoji();
|
||||
if (emoji) {
|
||||
this.ial.icon = emoji;
|
||||
this.render(this.ial, protyle.block.rootID);
|
||||
updateFileTreeEmoji(emoji, protyle.block.rootID);
|
||||
updateOutlineEmoji(emoji, protyle.block.rootID);
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
|
|
|
|||
|
|
@ -450,6 +450,20 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
}
|
||||
protyle.title.element.querySelector(".protyle-attr").innerHTML = nodeAttrHTML;
|
||||
protyle.wysiwyg.renderCustom(attrsResult);
|
||||
if (data.new.icon !== data.old.icon) {
|
||||
/// #if MOBILE
|
||||
if (window.siyuan.mobile.editor.protyle.background.ial.icon !== data.new.icon) {
|
||||
window.siyuan.mobile.editor.protyle.background.ial.icon = data.new.icon;
|
||||
window.siyuan.mobile.editor.protyle.background.render(window.siyuan.mobile.editor.protyle.background.ial, window.siyuan.mobile.editor.protyle.block.rootID);
|
||||
}
|
||||
/// #else
|
||||
if (protyle.background.ial.icon !== data.new.icon) {
|
||||
protyle.background.ial.icon = data.new.icon;
|
||||
protyle.background.render(protyle.background.ial, protyle.block.rootID);
|
||||
protyle.model?.parent.setDocIcon(data.new.icon);
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
|
||||
|
|
@ -618,7 +632,12 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
}
|
||||
};
|
||||
|
||||
export const turnsIntoOneTransaction = (options: { protyle: IProtyle, selectsElement: Element[], type: string, level?: string }) => {
|
||||
export const turnsIntoOneTransaction = (options: {
|
||||
protyle: IProtyle,
|
||||
selectsElement: Element[],
|
||||
type: string,
|
||||
level?: string
|
||||
}) => {
|
||||
let parentElement: Element;
|
||||
const id = Lute.NewNodeID();
|
||||
if (options.type === "BlocksMergeSuperBlock") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue