mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
d9d04b6ba5
commit
90c23714fb
3 changed files with 15 additions and 4 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue