From d87fd0f1094f24c5b57092ead487c694bca0f058 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 5 Oct 2023 11:16:44 +0800 Subject: [PATCH] :sparkles: https://github.com/siyuan-note/siyuan/issues/9304 --- app/src/emoji/index.ts | 8 ++++---- app/src/protyle/render/av/col.ts | 12 ++++++++++++ app/src/protyle/render/av/render.ts | 5 +++-- app/src/protyle/wysiwyg/transaction.ts | 2 +- app/src/types/index.d.ts | 1 + 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/emoji/index.ts b/app/src/emoji/index.ts index 8decc1171..8d94bb06b 100644 --- a/app/src/emoji/index.ts +++ b/app/src/emoji/index.ts @@ -191,7 +191,7 @@ export const addEmoji = (unicode: string) => { fetchPost("/api/setting/setEmoji", {emoji: window.siyuan.config.editor.emoji}); }; -export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition) => { +export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition, avCB?: (emoji: string) => void) => { if (type !== "av") { window.siyuan.menus.menu.remove(); } else { @@ -303,7 +303,7 @@ export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", posi updateOutlineEmoji(unicode, id); }); } else { - + avCB(unicode); } event.preventDefault(); event.stopPropagation(); @@ -395,7 +395,7 @@ ${unicode2Emoji(emoji.unicode)}`; updateOutlineEmoji("", id); }); } else { - + avCB(""); } return; } @@ -429,7 +429,7 @@ ${unicode2Emoji(emoji.unicode)}`; updateOutlineEmoji(unicode, id); }); } else { - + avCB(unicode); } return; } diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 10e3f542f..4d3dabd2e 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -399,6 +399,18 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen y: rect.bottom, h: rect.height, w: rect.width + }, (unicode) => { + transaction(protyle, [{ + action: "setAttrViewColIcon", + id: colId, + avID, + data: unicode, + }], [{ + action: "setAttrViewColIcon", + id: colId, + avID, + data: cellElement.dataset.icon, + }]); }); event.preventDefault(); event.stopPropagation(); diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index 3b08698d4..dd71482ec 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -3,6 +3,7 @@ import {getColIconByType} from "./col"; import {Constants} from "../../../constants"; import {getCalcValue} from "./cell"; import * as dayjs from "dayjs"; +import {unicode2Emoji} from "../../../emoji"; export const avRender = (element: Element, protyle: IProtyle, cb?: () => void) => { let avElements: Element[] = []; @@ -32,11 +33,11 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void) = if (column.hidden) { return; } - tableHTML += `
- + ${column.icon ? unicode2Emoji(column.icon) : ``} ${column.name}
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 4279e73c3..917e9e140 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -709,7 +709,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo: "updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden", "setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters", "setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", - "replaceAttrViewBlock", "updateAttrViewColTemplate"].includes(operation.action)) { + "replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColIcon"].includes(operation.action)) { refreshAV(protyle, operation); } }; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index fa9926500..d803058a8 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -34,6 +34,7 @@ type TOperation = | "removeAttrViewColOption" | "updateAttrViewColOption" | "setAttrViewName" + | "setAttrViewColIcon" | "setAttrViewFilters" | "setAttrViewSorts" | "setAttrViewColCalc"