Vanessa 2025-06-09 22:33:09 +08:00
parent d9d04b6ba5
commit 90c23714fb
3 changed files with 15 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import {focusBlock} from "../../../util/selection";
import {electronUndo} from "../../../undo";
import {addClearButton} from "../../../../util/addClearButton";
import {updateSearch} from "../render";
import {getViewIcon} from "../view";
export const renderGallery = (options: {
blockElement: HTMLElement,
@ -86,7 +87,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
let viewData: IAVView;
response.data.views.forEach((item: IAVView) => {
tabHTML += `<div data-position="north" data-av-type="${item.type}" data-id="${item.id}" data-page="${item.pageSize}" data-desc="${escapeAriaLabel(item.desc || "")}" class="ariaLabel item${item.id === response.data.viewID ? " item--focus" : ""}">
${item.icon ? unicode2Emoji(item.icon, "item__graphic", true) : '<svg class="item__graphic"><use xlink:href="#iconTable"></use></svg>'}
${item.icon ? unicode2Emoji(item.icon, "item__graphic", true) : `<svg class="item__graphic"><use xlink:href="#${getViewIcon(item.type)}"></use></svg>`}
<span class="item__text">${escapeHtml(item.name)}</span>
</div>`;
if (item.id === response.data.viewID) {

View file

@ -15,6 +15,7 @@ import {electronUndo} from "../../undo";
import {isInAndroid, isInHarmony, isInIOS} from "../../util/compatibility";
import {isMobile} from "../../../util/functions";
import {renderGallery} from "./gallery/render";
import {getViewIcon} from "./view";
export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, viewID?: string, renderAll = true) => {
let avElements: Element[] = [];
@ -215,7 +216,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
let viewData: IAVView;
response.data.views.forEach((item: IAVView) => {
tabHTML += `<div data-position="north" data-av-type="${item.type}" data-id="${item.id}" data-page="${item.pageSize}" data-desc="${escapeAriaLabel(item.desc || "")}" class="ariaLabel item${item.id === response.data.viewID ? " item--focus" : ""}">
${item.icon ? unicode2Emoji(item.icon, "item__graphic", true) : '<svg class="item__graphic"><use xlink:href="#iconTable"></use></svg>'}
${item.icon ? unicode2Emoji(item.icon, "item__graphic", true) : `<svg class="item__graphic"><use xlink:href="#${getViewIcon(item.type)}"></use></svg>`}
<span class="item__text">${escapeHtml(item.name)}</span>
</div>`;
if (item.id === response.data.viewID) {

View file

@ -376,12 +376,12 @@ export const addView = (protyle: IProtyle, blockElement: Element) => {
transaction(protyle, [{
action: "addAttrViewView",
avID,
layout:"gallery",
layout: "gallery",
id,
blockID: blockElement.getAttribute("data-node-id")
}], [{
action: "removeAttrViewView",
layout:"gallery",
layout: "gallery",
avID,
id,
blockID: blockElement.getAttribute("data-node-id")
@ -397,3 +397,12 @@ export const addView = (protyle: IProtyle, blockElement: Element) => {
y: addRect.bottom + 8
});
};
export const getViewIcon = (type: string) => {
switch (type) {
case "table":
return "iconTable";
case "gallery":
return "iconGallery";
}
};