An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support custom card width and preview aspect ratio in database gallery and kanban views https://github.com/siyuan-note/siyuan/issues/15863
Danielf015545cd7e5
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scssindex f38e1489e0..db2f0e0558 100644--- a/app/src/assets/scss/business/_av.scss+++ b/app/src/assets/scss/business/_av.scss@@ -347,8 +347,10 @@}&__gallery {+ --b3-av-card-width: 260px;+display: grid;- grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));+ grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--b3-av-card-width)), 1fr));gap: 16px;width: 100%;margin-top: 8px;@@ -358,11 +360,11 @@}&--small {- grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));+ --b3-av-card-width: 180px;}&--big {- grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));+ --b3-av-card-width: 320px;}&-item {@@ -404,33 +406,34 @@overflow: hidden;position: relative;cursor: pointer;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 16/9);&--0 {- aspect-ratio: 16/9;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 16/9);}&--1 {- aspect-ratio: 9/16;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 9/16);}&--2 {- aspect-ratio: 4/3;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 4/3);}&--3 {- aspect-ratio: 3/4;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 3/4);}&--4 {- aspect-ratio: 3/2;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 3/2);}&--5 {- aspect-ratio: 2/3;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 2/3);}&--6 {- aspect-ratio: 1;+ aspect-ratio: var(--b3-av-card-aspect-ratio, 1);}}@@ -1607,6 +1610,10 @@display: flex;align-items: flex-start;+ .av__gallery {+ grid-template-columns: minmax(0, 1fr);+ }+&--bg {.av__kanban-group::before {content: "";@@ -1660,7 +1667,7 @@}&-group {- width: 260px;+ width: var(--b3-av-card-width, 260px);padding: 8px;border-radius: var(--b3-border-radius);position: relative;@@ -1694,11 +1701,11 @@}&--small {- width: 180px;+ width: var(--b3-av-card-width, 180px);}&--big {- width: 320px;+ width: var(--b3-av-card-width, 320px);}.av__group-title {diff --git a/app/src/protyle/render/av/gallery/render.ts b/app/src/protyle/render/av/gallery/render.tsindex 54a45ebf28..9fd81a287e 100644--- a/app/src/protyle/render/av/gallery/render.ts+++ b/app/src/protyle/render/av/gallery/render.ts@@ -10,6 +10,7 @@ import {renderKanban} from "../kanban/render";import {getBodyVirtualData, initVirtualScroll} from "../virtualScroll";import {getRowHTML, updateHeader} from "../row";import {beginAVRender, finishAVLocate, getAVLocateParams, isCurrentAVRender, prepareAVLocate} from "../locate";+import {getCardStyle} from "./style";interface IIds {groupId: string,@@ -57,7 +58,7 @@ const getGalleryHTML = (data: IAVGallery, e: HTMLElement, virtualData: IAVVirtuareturn false;});galleryHTML += `<div class="av__gallery-add" data-type="av-add-bottom"><svg class="svg"><use xlink:href="#iconAdd"></use></svg><span class="fn__space"></span>${window.siyuan.languages.newRow}</div>`;- return `<div class="av__gallery${data.cardSize === 0 ? " av__gallery--small" : (data.cardSize === 2 ? " av__gallery--big" : "")}">+ return `<div class="av__gallery${data.cardSize === 0 ? " av__gallery--small" : (data.cardSize === 2 ? " av__gallery--big" : "")}" style="${getCardStyle(data)}">${virtualData?.topSpacerHeight ? `<div class="av__spacer" style="height: ${virtualData.topSpacerHeight}px;"></div>` : ""}${galleryHTML}</div><div class="av__gallery-load${data.cardCount > data.cards.length ? "" : " fn__none"}">diff --git a/app/src/protyle/render/av/gallery/style.test.ts b/app/src/protyle/render/av/gallery/style.test.tsnew file mode 100644index 0000000000..6f12402c7a--- /dev/null+++ b/app/src/protyle/render/av/gallery/style.test.ts@@ -0,0 +1,43 @@+import {describe, it} from "node:test";+import * as assert from "node:assert/strict";+import {+ getCardAspectRatioLabel,+ getCardAspectRatioValue,+ getCardStyle,+ getCardWidth+} from "./style";++const getView = (values: Partial<IAVGallery> = {}) => ({+ cardSize: 1,+ cardWidth: 0,+ cardAspectRatio: 0,+ cardAspectRatioValue: 0,+ ...values+}) as IAVGallery;++describe("attribute view card style", () => {+ it("uses custom widths and falls back to legacy size presets", () => {+ assert.equal(getCardWidth(getView({cardWidth: 410})), 410);+ assert.equal(getCardWidth(getView({cardSize: 0})), 180);+ assert.equal(getCardWidth(getView({cardSize: 2, cardWidth: 700})), 320);+ });++ it("uses custom aspect ratios and falls back to legacy presets", () => {+ assert.equal(getCardAspectRatioValue(getView({cardAspectRatioValue: 0.25})), 0.25);+ assert.equal(getCardAspectRatioValue(getView({cardAspectRatioValue: 1.25})), 1.25);+ assert.equal(getCardAspectRatioValue(getView({cardAspectRatioValue: 2.5})), 2.5);+ assert.equal(getCardAspectRatioValue(getView({cardAspectRatio: 3})), 3 / 4);+ assert.equal(getCardAspectRatioValue(getView({cardAspectRatio: 5, cardAspectRatioValue: 2.55})), 2 / 3);+ });++ it("formats decimal labels and sanitized inline styles", () => {+ assert.equal(getCardAspectRatioLabel(0.25), "0.25");+ assert.equal(getCardAspectRatioLabel(4 / 3), "1.33");+ assert.equal(getCardAspectRatioLabel(1.25), "1.25");+ assert.equal(getCardAspectRatioLabel(2.5), "2.50");+ assert.equal(+ getCardStyle(getView({cardWidth: 410, cardAspectRatioValue: 1.25})),+ "--b3-av-card-width: 410px; --b3-av-card-aspect-ratio: 1.25;"+ );+ });+});diff --git a/app/src/protyle/render/av/gallery/style.ts b/app/src/protyle/render/av/gallery/style.tsnew file mode 100644index 0000000000..8f5dff9a21--- /dev/null+++ b/app/src/protyle/render/av/gallery/style.ts@@ -0,0 +1,51 @@+export const CARD_WIDTH_MIN = 140;+export const CARD_WIDTH_MAX = 600;+export const CARD_ASPECT_RATIO_MIN = 0.25;+export const CARD_ASPECT_RATIO_MAX = 2.5;++export const CARD_WIDTH_PRESETS = [180, 260, 320];+export const CARD_ASPECT_RATIO_PRESETS = [16 / 9, 9 / 16, 4 / 3, 3 / 4, 3 / 2, 2 / 3, 1];++export const getCardWidth = (view: IAVGallery | IAVKanban) => {+ if (Number.isInteger(view.cardWidth) && view.cardWidth >= CARD_WIDTH_MIN && view.cardWidth <= CARD_WIDTH_MAX) {+ return view.cardWidth;+ }+ return CARD_WIDTH_PRESETS[view.cardSize] || CARD_WIDTH_PRESETS[1];+};++export const getCardAspectRatioValue = (view: IAVGallery | IAVKanban) => {+ if (Number.isFinite(view.cardAspectRatioValue) &&+ view.cardAspectRatioValue >= CARD_ASPECT_RATIO_MIN &&+ view.cardAspectRatioValue <= CARD_ASPECT_RATIO_MAX) {+ return view.cardAspectRatioValue;+ }+ return CARD_ASPECT_RATIO_PRESETS[view.cardAspectRatio] || CARD_ASPECT_RATIO_PRESETS[0];+};++export const getCardAspectRatio = (ratio: number) => {+ switch (ratio) {+ case 0:+ return "16:9";+ case 1:+ return "9:16";+ case 2:+ return "4:3";+ case 3:+ return "3:4";+ case 4:+ return "3:2";+ case 5:+ return "2:3";+ case 6:+ return "1:1";+ }+ return "16:9";+};++export const getCardAspectRatioLabel = (ratio: number) => {+ return ratio.toFixed(2);+};++export const getCardStyle = (view: IAVGallery | IAVKanban) => {+ return `--b3-av-card-width: ${getCardWidth(view)}px; --b3-av-card-aspect-ratio: ${getCardAspectRatioValue(view)};`;+};diff --git a/app/src/protyle/render/av/gallery/util.ts b/app/src/protyle/render/av/gallery/util.tsindex 4af86610d5..012730bb4e 100644--- a/app/src/protyle/render/av/gallery/util.ts+++ b/app/src/protyle/render/av/gallery/util.ts@@ -5,6 +5,25 @@ import {unicode2Emoji} from "../../../../emoji";import {getColIconByType} from "../col";import {avContextmenu} from "../action";import {Constants} from "../../../../constants";+import {+ CARD_ASPECT_RATIO_MAX,+ CARD_ASPECT_RATIO_MIN,+ CARD_ASPECT_RATIO_PRESETS,+ CARD_WIDTH_MAX,+ CARD_WIDTH_MIN,+ CARD_WIDTH_PRESETS,+ getCardAspectRatio,+ getCardAspectRatioLabel,+ getCardAspectRatioValue,+ getCardWidth+} from "./style";++const updateCardPreview = (nodeElement: Element, property: string, value: string) => {+ const selector = nodeElement.getAttribute("data-av-type") === "kanban" ? ".av__kanban" : ".av__gallery";+ nodeElement.querySelectorAll<HTMLElement>(selector).forEach(item => {+ item.style.setProperty(property, value);+ });+};export const setGalleryCover = (options: {view: IAVGallery@@ -16,6 +35,9 @@ export const setGalleryCover = (options: {const blockID = options.nodeElement.getAttribute("data-node-id");const targetNameElement = options.target.querySelector(".b3-menu__accelerator");const menu = new Menu();+ const updateRatioDisabled = (disabled: boolean) => {+ (options.target.parentElement.querySelector('[data-type="set-gallery-ratio"]') as HTMLButtonElement).disabled = disabled;+ };menu.addItem({iconHTML: "",checked: options.view.coverFrom === 0,@@ -34,6 +56,7 @@ export const setGalleryCover = (options: {}]);options.view.coverFrom = 0;targetNameElement.textContent = window.siyuan.languages.calcOperatorNone;+ updateRatioDisabled(true);}});menu.addItem({@@ -54,6 +77,7 @@ export const setGalleryCover = (options: {}]);options.view.coverFrom = 3;targetNameElement.textContent = window.siyuan.languages.contentBlock;+ updateRatioDisabled(false);}});menu.addItem({@@ -74,6 +98,7 @@ export const setGalleryCover = (options: {}]);options.view.coverFrom = 1;targetNameElement.textContent = window.siyuan.languages.contentImage;+ updateRatioDisabled(false);}});let addedSeparator = false;@@ -112,6 +137,7 @@ export const setGalleryCover = (options: {options.view.coverFrom = 2;options.view.coverFromAssetKeyID = item.id;targetNameElement.textContent = item.name;+ updateRatioDisabled(false);}});}@@ -121,7 +147,7 @@ export const setGalleryCover = (options: {};export const setGallerySize = (options: {- view: IAVGallery+ view: IAVGallery | IAVKanbannodeElement: Element,protyle: IProtyle,target: HTMLElement@@ -131,98 +157,74 @@ export const setGallerySize = (options: {const blockID = options.nodeElement.getAttribute("data-node-id");const viewID = options.nodeElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW);const targetNameElement = options.target.querySelector(".b3-menu__accelerator");- menu.addItem({- iconHTML: "",- checked: options.view.cardSize === 0,- label: window.siyuan.languages.small,- click() {- transaction(options.protyle, [{- action: "setAttrViewCardSize",- avID,- blockID,- data: 0,- viewID- }], [{- action: "setAttrViewCardSize",- avID,- blockID,- data: options.view.cardSize,- viewID- }]);- options.view.cardSize = 0;- targetNameElement.textContent = window.siyuan.languages.small;- }- });- menu.addItem({- iconHTML: "",- checked: options.view.cardSize === 1,- label: window.siyuan.languages.medium,- click() {- transaction(options.protyle, [{- action: "setAttrViewCardSize",- avID,- blockID,- data: 1,- viewID- }], [{- action: "setAttrViewCardSize",- avID,- blockID,- data: options.view.cardSize,- viewID- }]);- options.view.cardSize = 1;- targetNameElement.textContent = window.siyuan.languages.medium;- }+ const previousWidth = getCardWidth(options.view);+ [window.siyuan.languages.small, window.siyuan.languages.medium, window.siyuan.languages.large].forEach((label, index) => {+ const width = CARD_WIDTH_PRESETS[index];+ menu.addItem({+ iconHTML: "",+ checked: previousWidth === width,+ label,+ click() {+ transaction(options.protyle, [{+ action: "setAttrViewCardWidth",+ avID,+ blockID,+ data: width,+ viewID+ }], [{+ action: "setAttrViewCardWidth",+ avID,+ blockID,+ data: previousWidth,+ viewID+ }]);+ options.view.cardWidth = width;+ targetNameElement.textContent = `${width}px`;+ }+ });});+ menu.addSeparator();menu.addItem({iconHTML: "",- checked: options.view.cardSize === 2,- label: window.siyuan.languages.large,- click() {- transaction(options.protyle, [{- action: "setAttrViewCardSize",- avID,- blockID,- data: 2,- viewID- }], [{- action: "setAttrViewCardSize",- avID,- blockID,- data: options.view.cardSize,- viewID- }]);- options.view.cardSize = 2;- targetNameElement.textContent = window.siyuan.languages.large;+ type: "readonly",+ label: `<div class="b3-tooltips b3-tooltips__n" aria-label="${previousWidth}px" style="margin: 4px 0;">+ <input class="b3-slider fn__block" max="${CARD_WIDTH_MAX}" min="${CARD_WIDTH_MIN}" step="10" type="range" value="${previousWidth}">+</div>`,+ bind(element) {+ const rangeElement = element.querySelector("input") as HTMLInputElement;+ rangeElement.addEventListener("input", () => {+ updateCardPreview(options.nodeElement, "--b3-av-card-width", `${rangeElement.value}px`);+ rangeElement.parentElement.setAttribute("aria-label", `${rangeElement.value}px`);+ });+ rangeElement.addEventListener("change", () => {+ const width = parseInt(rangeElement.value);+ if (width !== previousWidth) {+ transaction(options.protyle, [{+ action: "setAttrViewCardWidth",+ avID,+ blockID,+ data: width,+ viewID+ }], [{+ action: "setAttrViewCardWidth",+ avID,+ blockID,+ data: previousWidth,+ viewID+ }]);+ options.view.cardWidth = width;+ targetNameElement.textContent = `${width}px`;+ }+ menu.close();+ });}});const rect = options.target.getBoundingClientRect();menu.open({x: rect.left, y: rect.bottom});};-export const getCardAspectRatio = (ratio: number) => {- switch (ratio) {- case 0:- return "16:9";- case 1:- return "9:16";- case 2:- return "4:3";- case 3:- return "3:4";- case 4:- return "3:2";- case 5:- return "2:3";- case 6:- return "1:1";- }- return "16:9";-};-export const setGalleryRatio = (options: {- view: IAVGallery+ view: IAVGallery | IAVKanbannodeElement: Element,protyle: IProtyle,target: HTMLElement@@ -232,30 +234,69 @@ export const setGalleryRatio = (options: {const blockID = options.nodeElement.getAttribute("data-node-id");const viewID = options.nodeElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW);const targetNameElement = options.target.querySelector(".b3-menu__accelerator");+ const previousRatio = getCardAspectRatioValue(options.view);[0, 1, 2, 3, 4, 5, 6].forEach(ratio => {+ const ratioValue = CARD_ASPECT_RATIO_PRESETS[ratio];menu.addItem({iconHTML: "",- checked: options.view.cardAspectRatio === ratio,+ checked: Math.abs(previousRatio - ratioValue) < 0.0001,label: getCardAspectRatio(ratio),click() {transaction(options.protyle, [{- action: "setAttrViewCardAspectRatio",+ action: "setAttrViewCardAspectRatioValue",avID,blockID,- data: ratio,+ data: ratioValue,viewID}], [{- action: "setAttrViewCardAspectRatio",+ action: "setAttrViewCardAspectRatioValue",avID,blockID,- data: options.view.cardAspectRatio,+ data: previousRatio,viewID}]);- options.view.cardAspectRatio = ratio;- targetNameElement.textContent = getCardAspectRatio(ratio);+ options.view.cardAspectRatioValue = ratioValue;+ targetNameElement.textContent = getCardAspectRatioLabel(ratioValue);}});});+ menu.addSeparator();+ menu.addItem({+ iconHTML: "",+ type: "readonly",+ label: `<div class="b3-tooltips b3-tooltips__n" aria-label="${getCardAspectRatioLabel(previousRatio)}" style="margin: 4px 0;">+ <input class="b3-slider fn__block" max="${CARD_ASPECT_RATIO_MAX}" min="${CARD_ASPECT_RATIO_MIN}" step="0.05" type="range" value="${previousRatio}">+</div>`,+ bind(element) {+ const rangeElement = element.querySelector("input") as HTMLInputElement;+ rangeElement.addEventListener("input", () => {+ const ratio = parseFloat(rangeElement.value);+ updateCardPreview(options.nodeElement, "--b3-av-card-aspect-ratio", rangeElement.value);+ rangeElement.parentElement.setAttribute("aria-label", getCardAspectRatioLabel(ratio));+ });+ rangeElement.addEventListener("change", () => {+ const ratio = parseFloat(rangeElement.value);+ if (ratio !== previousRatio) {+ transaction(options.protyle, [{+ action: "setAttrViewCardAspectRatioValue",+ avID,+ blockID,+ data: ratio,+ viewID+ }], [{+ action: "setAttrViewCardAspectRatioValue",+ avID,+ blockID,+ data: previousRatio,+ viewID+ }]);+ options.view.cardAspectRatioValue = ratio;+ targetNameElement.textContent = getCardAspectRatioLabel(ratio);+ }+ menu.close();+ });+ }+ });const rect = options.target.getBoundingClientRect();menu.open({x: rect.left, y: rect.bottom});};diff --git a/app/src/protyle/render/av/kanban/render.ts b/app/src/protyle/render/av/kanban/render.tsindex 9b08b5c848..efbdf6f90f 100644--- a/app/src/protyle/render/av/kanban/render.ts+++ b/app/src/protyle/render/av/kanban/render.ts@@ -8,6 +8,7 @@ import {escapeAttr, escapeHtml} from "../../../../util/escape";import {getRowHTML} from "../row";import {getBodyVirtualData} from "../virtualScroll";import {beginAVRender, getAVLocateParams, isCurrentAVRender, prepareAVLocate} from "../locate";+import {getCardStyle} from "../gallery/style";interface IIds {groupId: string,@@ -204,7 +205,7 @@ export const renderKanban = async (options: {if (options.renderAll) {options.blockElement.firstElementChild.outerHTML = `<div class="av__container fn__block">${genTabHeaderHTML(data, resetData.isSearching || !!resetData.query, !options.protyle.disabled && !hasClosestByAttribute(options.blockElement, "data-type", "NodeBlockQueryEmbed"))}- <div class="av__kanban${isSelectGroup ? " av__kanban--bg" : ""}">+ <div class="av__kanban${isSelectGroup ? " av__kanban--bg" : ""}" style="${getCardStyle(view)}">${bodyHTML}</div><div class="av__cursor" contenteditable="true">${Constants.ZWSP}</div>diff --git a/app/src/protyle/render/av/layout.ts b/app/src/protyle/render/av/layout.tsindex 65214bf330..cefd6619d9 100644--- a/app/src/protyle/render/av/layout.ts+++ b/app/src/protyle/render/av/layout.ts@@ -2,7 +2,7 @@ import {transaction} from "../../wysiwyg/transaction";import {Constants} from "../../../constants";import {fetchSyncPost} from "../../../util/fetch";import {setPosition} from "../../../util/setPosition";-import {getCardAspectRatio} from "./gallery/util";+import {getCardAspectRatioLabel, getCardAspectRatioValue, getCardWidth} from "./gallery/style";import {getFieldsByData} from "./view";export const getLayoutHTML = (data: IAV) => {@@ -30,16 +30,16 @@ export const getLayoutHTML = (data: IAV) => {<span class="b3-menu__accelerator">${coverFromTitle}</span><svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg></button>-<button class="b3-menu__item" data-type="set-gallery-ratio">+<button class="b3-menu__item" data-type="set-gallery-ratio"${view.coverFrom === 0 ? " disabled" : ""}><span class="fn__flex-center">${window.siyuan.languages.cardAspectRatio}</span><span class="fn__flex-1"></span>- <span class="b3-menu__accelerator">${getCardAspectRatio(view.cardAspectRatio)}</span>+ <span class="b3-menu__accelerator">${getCardAspectRatioLabel(getCardAspectRatioValue(view))}</span><svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg></button><button class="b3-menu__item" data-type="set-gallery-size"><span class="fn__flex-center">${window.siyuan.languages.cardSize}</span><span class="fn__flex-1"></span>- <span class="b3-menu__accelerator">${view.cardSize === 0 ? window.siyuan.languages.small : (view.cardSize === 1 ? window.siyuan.languages.medium : window.siyuan.languages.large)}</span>+ <span class="b3-menu__accelerator">${getCardWidth(view)}px</span><svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg></button><label class="b3-menu__item">diff --git a/app/src/protyle/render/av/locate.ts b/app/src/protyle/render/av/locate.tsindex 6f58e8ff11..74753e0a46 100644--- a/app/src/protyle/render/av/locate.ts+++ b/app/src/protyle/render/av/locate.ts@@ -1,4 +1,5 @@import {Constants} from "../../../constants";+import {getCardWidth} from "./gallery/style";import {showMessage} from "../../../dialog/message";import {transaction} from "../../wysiwyg/transaction";import {clearSelect} from "../../util/clear";@@ -277,7 +278,7 @@ export const prepareAVLocate = (blockElement: HTMLElement, data: IAV, resetData:const itemHeight = (currentBody?.querySelector(".av__gallery-item") as HTMLElement)?.offsetHeight || 180;let columns = 1;if (data.viewType === "gallery") {- const minWidth = (view as IAVGallery)?.cardSize === 0 ? 180 : ((view as IAVGallery)?.cardSize === 2 ? 320 : 260);+ const minWidth = getCardWidth(view as IAVGallery);columns = Math.max(1, Math.floor((blockElement.clientWidth + 16) / (minWidth + 16)));renderedStart -= renderedStart % columns;}diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex 0bce16d0d5..17bd60d90b 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -738,38 +738,6 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {});return;}- if (operation.action === "setAttrViewCardSize") {- getAVElements(protyle, operation.avID, operation.viewID).forEach((item) => {- if (item.getAttribute("data-av-type") === "kanban") {- item.querySelectorAll(".av__kanban-group").forEach(galleryItem => {- galleryItem.classList.remove("av__kanban-group--small", "av__kanban-group--big");- if (operation.data === 0) {- galleryItem.classList.add("av__kanban-group--small");- } else if (operation.data === 2) {- galleryItem.classList.add("av__kanban-group--big");- }- });- } else {- item.querySelectorAll(".av__gallery").forEach(galleryItem => {- galleryItem.classList.remove("av__gallery--small", "av__gallery--big");- if (operation.data === 0) {- galleryItem.classList.add("av__gallery--small");- } else if (operation.data === 2) {- galleryItem.classList.add("av__gallery--big");- }- });- }- });- return;- }- if (operation.action === "setAttrViewCardAspectRatio") {- getAVElements(protyle, operation.avID, operation.viewID).forEach((item) => {- item.querySelectorAll(".av__gallery-cover").forEach(coverItem => {- coverItem.className = "av__gallery-cover av__gallery-cover--" + operation.data;- });- });- return;- }if (operation.action === "hideAttrViewName") {getAVElements(protyle, operation.avID, operation.viewID).forEach((item) => {const titleElement = item.querySelector(".av__title");@@ -895,6 +863,12 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {}getAVElements(protyle, avID).forEach((item) => {item.removeAttribute("data-render");+ if (["setAttrViewCardSize", "setAttrViewCardWidth", "setAttrViewCardAspectRatio",+ "setAttrViewCardAspectRatioValue"].includes(operation.action) &&+ (!operation.viewID || getViewIDByAVElement(item) === operation.viewID)) {+ // 卡片宽度和宽高比变化后原虚拟滚动占位高度已失效,重渲时从首项重新初始化。+ item.removeAttribute(Constants.ATTRIBUTE_V_SCROLL);+ }if (operation.action === "replaceAttrViewBlock" && operation.retData?.duplicate &&(!operation.blockID || operation.blockID === item.dataset.nodeId) &&(!operation.context?.protyleID || operation.context.protyleID === protyle.id)) {diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 91b4abca19..fa6c63ad8a 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -1162,7 +1162,8 @@ export const onTransaction = (protyle: IProtyle, operations: IOperation[], isUnd"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "duplicateAttrViewRow", "sortAttrViewView","updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup", "sortAttrViewKey", "setAttrViewColDesc","duplicateAttrViewKey", "setAttrViewViewDesc", "setAttrViewCoverFrom", "setAttrViewCoverFromAssetKeyID",- "setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardAspectRatio", "hideAttrViewName", "setAttrViewShowIcon",+ "setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardWidth", "setAttrViewCardAspectRatio",+ "setAttrViewCardAspectRatioValue", "hideAttrViewName", "setAttrViewShowIcon","setAttrViewWrapField", "setAttrViewGroup", "removeAttrViewGroup", "hideAttrViewGroup", "sortAttrViewGroup","foldAttrViewGroup", "hideAttrViewAllGroups", "setAttrViewFitImage", "setAttrViewDisplayFieldName", "setAttrViewDisplayEmptyFields","insertAttrViewBlock", "setAttrViewColDateFillSpecificTime", "setAttrViewFillColBackgroundColor", "setAttrViewUpdatedIncludeTime",diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 4c0dcf26ea..5d7009afc6 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -58,7 +58,9 @@ type TOperation =| "updateAttrViewColRollup"| "hideAttrViewName"| "setAttrViewCardSize"+ | "setAttrViewCardWidth"| "setAttrViewCardAspectRatio"+ | "setAttrViewCardAspectRatioValue"| "setAttrViewCoverFrom"| "setAttrViewCoverFromAssetKeyID"| "setAttrViewFitImage"@@ -1078,7 +1080,9 @@ interface IAVGallery extends IAVView {coverFrom: number; // 0:无,1:内容图,2:资源字段,3:内容块coverFromAssetKeyID?: string;cardSize: number; // 0:小卡片,1:中卡片,2:大卡片+ cardWidth: number;cardAspectRatio: number;+ cardAspectRatioValue: number;displayFieldName: boolean;displayEmptyFields: boolean;fitImage: boolean;@@ -1092,7 +1096,9 @@ interface IAVKanban extends IAVView {coverFrom: number; // 0:无,1:内容图,2:资源字段,3:内容块coverFromAssetKeyID?: string;cardSize: number; // 0:小卡片,1:中卡片,2:大卡片+ cardWidth: number;cardAspectRatio: number;+ cardAspectRatioValue: number;displayFieldName: boolean;displayEmptyFields: boolean;fitImage: boolean;diff --git a/kernel/av/av_fix.go b/kernel/av/av_fix.goindex 26b33544c8..7c718f325b 100644--- a/kernel/av/av_fix.go+++ b/kernel/av/av_fix.go@@ -24,7 +24,7 @@ import ("github.com/siyuan-note/siyuan/kernel/util")-const CurrentSpec = 5+const CurrentSpec = 6const MaxFilterNestingDepth = 3@@ -38,6 +38,7 @@ func UpgradeSpec(av *AttributeView) {upgradeSpec3(av)upgradeSpec4(av)upgradeSpec5(av)+ upgradeSpec6(av)}func CheckSpec(av *AttributeView) (err error) {@@ -49,6 +50,26 @@ func CheckSpec(av *AttributeView) (err error) {return}+// upgradeSpec6 将卡片和看板的预设尺寸转换为可连续调节的实际宽度和宽高比。+func upgradeSpec6(av *AttributeView) {+ if 6 <= av.Spec {+ return+ }++ for _, view := range av.Views {+ if nil != view.Gallery {+ view.Gallery.CardWidth = CardWidthBySize(view.Gallery.CardSize)+ view.Gallery.CardAspectRatioValue = CardAspectRatioValueByPreset(view.Gallery.CardAspectRatio)+ }+ if nil != view.Kanban {+ view.Kanban.CardWidth = CardWidthBySize(view.Kanban.CardSize)+ view.Kanban.CardAspectRatioValue = CardAspectRatioValueByPreset(view.Kanban.CardAspectRatio)+ }+ }++ av.Spec = 6+}+// upgradeSpec5 将旧的扁平过滤规则数组包装为单个隐式 AND 根组,支持递归嵌套分组。// 原有叶子条件一条不丢,整体作为根组的子节点保留。func upgradeSpec5(av *AttributeView) {diff --git a/kernel/av/av_fix_test.go b/kernel/av/av_fix_test.gonew file mode 100644index 0000000000..36ebc4131a--- /dev/null+++ b/kernel/av/av_fix_test.go@@ -0,0 +1,56 @@+// SiYuan - Refactor your thinking+// Copyright (c) 2020-present, b3log.org+//+// This program is free software: you can redistribute it and/or modify+// it under the terms of the GNU Affero General Public License as published by+// the Free Software Foundation, either version 3 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU Affero General Public License for more details.+//+// You should have received a copy of the GNU Affero General Public License+// along with this program. If not, see <https://www.gnu.org/licenses/>.++package av++import (+ "math"+ "testing"+)++func TestUpgradeSpec6CardConfiguration(t *testing.T) {+ attrView := &AttributeView{+ Spec: 5,+ Views: []*View{{+ Gallery: &LayoutGallery{+ CardSize: CardSizeSmall,+ CardAspectRatio: CardAspectRatio3_4,+ },+ Kanban: &LayoutKanban{+ CardSize: CardSizeLarge,+ CardAspectRatio: CardAspectRatio2_3,+ },+ }},+ }++ UpgradeSpec(attrView)++ if CurrentSpec != attrView.Spec {+ t.Fatalf("expected spec %d, got %d", CurrentSpec, attrView.Spec)+ }+ if 180 != attrView.Views[0].Gallery.CardWidth {+ t.Fatalf("expected gallery width 180, got %d", attrView.Views[0].Gallery.CardWidth)+ }+ if math.Abs(3.0/4.0-attrView.Views[0].Gallery.CardAspectRatioValue) > 1e-9 {+ t.Fatalf("unexpected gallery aspect ratio %v", attrView.Views[0].Gallery.CardAspectRatioValue)+ }+ if 320 != attrView.Views[0].Kanban.CardWidth {+ t.Fatalf("expected kanban width 320, got %d", attrView.Views[0].Kanban.CardWidth)+ }+ if math.Abs(2.0/3.0-attrView.Views[0].Kanban.CardAspectRatioValue) > 1e-9 {+ t.Fatalf("unexpected kanban aspect ratio %v", attrView.Views[0].Kanban.CardAspectRatioValue)+ }+}diff --git a/kernel/av/layout_gallery.go b/kernel/av/layout_gallery.goindex 6518240574..1e18f7b595 100644--- a/kernel/av/layout_gallery.go+++ b/kernel/av/layout_gallery.go@@ -24,13 +24,15 @@ import (type LayoutGallery struct {*BaseLayout- CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段- CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效- CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比- CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片- FitImage bool `json:"fitImage"` // 是否适应封面图片大小- DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称- DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段+ CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段+ CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效+ CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比+ CardAspectRatioValue float64 `json:"cardAspectRatioValue"` // 卡片宽高比实际值,宽除以高+ CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片+ CardWidth int `json:"cardWidth"` // 卡片宽度,单位为像素+ FitImage bool `json:"fitImage"` // 是否适应封面图片大小+ DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称+ DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段CardFields []*ViewGalleryCardField `json:"fields"` // 卡片字段@@ -46,9 +48,11 @@ func NewLayoutGallery() *LayoutGallery {ID: ast.NewNodeID(),ShowIcon: true,},- CoverFrom: CoverFromContentImage,- CardAspectRatio: CardAspectRatio16_9,- CardSize: CardSizeMedium,+ CoverFrom: CoverFromContentImage,+ CardAspectRatio: CardAspectRatio16_9,+ CardAspectRatioValue: CardAspectRatioValueByPreset(CardAspectRatio16_9),+ CardSize: CardSizeMedium,+ CardWidth: CardWidthBySize(CardSizeMedium),}}@@ -72,6 +76,43 @@ const (CardSizeLarge // 大卡片)+const (+ CardWidthMin = 140+ CardWidthMax = 600+ CardAspectRatioValueMin = 0.25+ CardAspectRatioValueMax = 2.5+)++func CardWidthBySize(size CardSize) int {+ switch size {+ case CardSizeSmall:+ return 180+ case CardSizeLarge:+ return 320+ default:+ return 260+ }+}++func CardAspectRatioValueByPreset(ratio CardAspectRatio) float64 {+ switch ratio {+ case CardAspectRatio9_16:+ return 9.0 / 16.0+ case CardAspectRatio4_3:+ return 4.0 / 3.0+ case CardAspectRatio3_4:+ return 3.0 / 4.0+ case CardAspectRatio3_2:+ return 3.0 / 2.0+ case CardAspectRatio2_3:+ return 2.0 / 3.0+ case CardAspectRatio1_1:+ return 1+ default:+ return 16.0 / 9.0+ }+}+// CoverFrom 描述了卡片封面来源的枚举类型。type CoverFrom int@@ -91,16 +132,18 @@ type ViewGalleryCardField struct {type Gallery struct {*BaseInstance- CoverFrom CoverFrom `json:"coverFrom"` // 封面来源- CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 CoverFromAssetField 时有效- CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比- CardSize CardSize `json:"cardSize"` // 卡片大小- FitImage bool `json:"fitImage"` // 是否适应封面图片大小- DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称- DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段- Fields []*GalleryField `json:"fields"` // 卡片字段- Cards []*GalleryCard `json:"cards"` // 卡片- CardCount int `json:"cardCount"` // 总卡片数+ CoverFrom CoverFrom `json:"coverFrom"` // 封面来源+ CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 CoverFromAssetField 时有效+ CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比+ CardAspectRatioValue float64 `json:"cardAspectRatioValue"` // 卡片宽高比实际值,宽除以高+ CardSize CardSize `json:"cardSize"` // 卡片大小+ CardWidth int `json:"cardWidth"` // 卡片宽度,单位为像素+ FitImage bool `json:"fitImage"` // 是否适应封面图片大小+ DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称+ DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段+ Fields []*GalleryField `json:"fields"` // 卡片字段+ Cards []*GalleryCard `json:"cards"` // 卡片+ CardCount int `json:"cardCount"` // 总卡片数}// GalleryCard 描述了卡片实例的结构。diff --git a/kernel/av/layout_kanban.go b/kernel/av/layout_kanban.goindex 2ce83ed1e5..6f23e9c5cc 100644--- a/kernel/av/layout_kanban.go+++ b/kernel/av/layout_kanban.go@@ -24,13 +24,15 @@ import (type LayoutKanban struct {*BaseLayout- CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段- CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效- CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比- CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片- FitImage bool `json:"fitImage"` // 是否适应封面图片大小- DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称- DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段+ CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段+ CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效+ CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比+ CardAspectRatioValue float64 `json:"cardAspectRatioValue"` // 卡片宽高比实际值,宽除以高+ CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片+ CardWidth int `json:"cardWidth"` // 卡片宽度,单位为像素+ FitImage bool `json:"fitImage"` // 是否适应封面图片大小+ DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称+ DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段FillColBackgroundColor bool `json:"fillColBackgroundColor"` // 是否填充列背景颜色@@ -44,9 +46,11 @@ func NewLayoutKanban() *LayoutKanban {ID: ast.NewNodeID(),ShowIcon: true,},- CoverFrom: CoverFromContentImage,- CardAspectRatio: CardAspectRatio16_9,- CardSize: CardSizeMedium,+ CoverFrom: CoverFromContentImage,+ CardAspectRatio: CardAspectRatio16_9,+ CardAspectRatioValue: CardAspectRatioValueByPreset(CardAspectRatio16_9),+ CardSize: CardSizeMedium,+ CardWidth: CardWidthBySize(CardSizeMedium),}}@@ -62,7 +66,9 @@ type Kanban struct {CoverFrom CoverFrom `json:"coverFrom"` // 封面来源CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 CoverFromAssetField 时有效CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比+ CardAspectRatioValue float64 `json:"cardAspectRatioValue"` // 卡片宽高比实际值,宽除以高CardSize CardSize `json:"cardSize"` // 卡片大小+ CardWidth int `json:"cardWidth"` // 卡片宽度,单位为像素FitImage bool `json:"fitImage"` // 是否适应封面图片大小DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称DisplayEmptyFields bool `json:"displayEmptyFields"` // 是否显示空字段diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex b1e37e37ff..7a521b1f98 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -20,6 +20,7 @@ import ("bytes""errors""fmt"+ "math""math/rand""os""path/filepath"@@ -961,6 +962,15 @@ func (tx *Transaction) doSetAttrViewCardAspectRatio(operation *Operation) (ret *}func setAttrViewCardAspectRatio(operation *Operation) (err error) {+ value, err := getAttrViewOperationNumber(operation)+ if nil != err {+ return+ }+ ratio := av.CardAspectRatio(value)+ if value != math.Trunc(value) || ratio < av.CardAspectRatio16_9 || av.CardAspectRatio1_1 < ratio {+ return fmt.Errorf("invalid card aspect ratio preset [%v]", value)+ }+attrView, err := av.ParseAttributeView(operation.AvID)if err != nil {return@@ -975,9 +985,50 @@ func setAttrViewCardAspectRatio(operation *Operation) (err error) {case av.LayoutTypeTable:returncase av.LayoutTypeGallery:- view.Gallery.CardAspectRatio = av.CardAspectRatio(operation.Data.(float64))+ view.Gallery.CardAspectRatio = ratio+ view.Gallery.CardAspectRatioValue = av.CardAspectRatioValueByPreset(ratio)case av.LayoutTypeKanban:- view.Kanban.CardAspectRatio = av.CardAspectRatio(operation.Data.(float64))+ view.Kanban.CardAspectRatio = ratio+ view.Kanban.CardAspectRatioValue = av.CardAspectRatioValueByPreset(ratio)+ }++ err = av.SaveAttributeView(attrView)+ return+}++func (tx *Transaction) doSetAttrViewCardAspectRatioValue(operation *Operation) (ret *TxErr) {+ if err := setAttrViewCardAspectRatioValue(operation); nil != err {+ return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}+ }+ return+}++func setAttrViewCardAspectRatioValue(operation *Operation) (err error) {+ ratio, err := getAttrViewOperationNumber(operation)+ if nil != err {+ return+ }+ if math.IsNaN(ratio) || math.IsInf(ratio, 0) ||+ ratio < av.CardAspectRatioValueMin || av.CardAspectRatioValueMax < ratio {+ return fmt.Errorf("invalid card aspect ratio [%v]", ratio)+ }++ attrView, err := av.ParseAttributeView(operation.AvID)+ if err != nil {+ return+ }+ view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)+ if err != nil {+ return+ }++ switch view.LayoutType {+ case av.LayoutTypeTable:+ return+ case av.LayoutTypeGallery:+ view.Gallery.CardAspectRatioValue = ratio+ case av.LayoutTypeKanban:+ view.Kanban.CardAspectRatioValue = ratio}err = av.SaveAttributeView(attrView)@@ -1341,6 +1392,15 @@ func (tx *Transaction) doSetAttrViewCardSize(operation *Operation) (ret *TxErr)}func setAttrViewCardSize(operation *Operation) (err error) {+ value, err := getAttrViewOperationNumber(operation)+ if nil != err {+ return+ }+ size := av.CardSize(value)+ if value != math.Trunc(value) || size < av.CardSizeSmall || av.CardSizeLarge < size {+ return fmt.Errorf("invalid card size preset [%v]", value)+ }+attrView, err := av.ParseAttributeView(operation.AvID)if err != nil {return@@ -1355,15 +1415,65 @@ func setAttrViewCardSize(operation *Operation) (err error) {case av.LayoutTypeTable:returncase av.LayoutTypeGallery:- view.Gallery.CardSize = av.CardSize(operation.Data.(float64))+ view.Gallery.CardSize = size+ view.Gallery.CardWidth = av.CardWidthBySize(size)case av.LayoutTypeKanban:- view.Kanban.CardSize = av.CardSize(operation.Data.(float64))+ view.Kanban.CardSize = size+ view.Kanban.CardWidth = av.CardWidthBySize(size)}err = av.SaveAttributeView(attrView)return}+func (tx *Transaction) doSetAttrViewCardWidth(operation *Operation) (ret *TxErr) {+ if err := setAttrViewCardWidth(operation); nil != err {+ return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}+ }+ return+}++func setAttrViewCardWidth(operation *Operation) (err error) {+ value, err := getAttrViewOperationNumber(operation)+ if nil != err {+ return+ }+ if math.IsNaN(value) || math.IsInf(value, 0) || value != math.Trunc(value) ||+ value < av.CardWidthMin || av.CardWidthMax < value {+ return fmt.Errorf("invalid card width [%v]", value)+ }+ width := int(value)++ attrView, err := av.ParseAttributeView(operation.AvID)+ if err != nil {+ return+ }+ view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)+ if err != nil {+ return+ }++ switch view.LayoutType {+ case av.LayoutTypeTable:+ return+ case av.LayoutTypeGallery:+ view.Gallery.CardWidth = width+ case av.LayoutTypeKanban:+ view.Kanban.CardWidth = width+ }++ err = av.SaveAttributeView(attrView)+ return+}++func getAttrViewOperationNumber(operation *Operation) (ret float64, err error) {+ var ok bool+ if ret, ok = operation.Data.(float64); !ok {+ err = fmt.Errorf("invalid card configuration value [%v]", operation.Data)+ }+ return+}+func (tx *Transaction) doSetAttrViewCoverFromAssetKeyID(operation *Operation) (ret *TxErr) {err := setAttrViewCoverFromAssetKeyID(operation)if err != nil {@@ -3641,7 +3751,10 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErrview.Gallery.CoverFrom = masterView.Gallery.CoverFromview.Gallery.CoverFromAssetKeyID = masterView.Gallery.CoverFromAssetKeyID+ view.Gallery.CardAspectRatio = masterView.Gallery.CardAspectRatio+ view.Gallery.CardAspectRatioValue = masterView.Gallery.CardAspectRatioValueview.Gallery.CardSize = masterView.Gallery.CardSize+ view.Gallery.CardWidth = masterView.Gallery.CardWidthview.Gallery.FitImage = masterView.Gallery.FitImageview.Gallery.DisplayFieldName = masterView.Gallery.DisplayFieldNameview.Gallery.DisplayEmptyFields = masterView.Gallery.DisplayEmptyFields@@ -3661,7 +3774,10 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErrview.Kanban.CoverFrom = masterView.Kanban.CoverFromview.Kanban.CoverFromAssetKeyID = masterView.Kanban.CoverFromAssetKeyID+ view.Kanban.CardAspectRatio = masterView.Kanban.CardAspectRatio+ view.Kanban.CardAspectRatioValue = masterView.Kanban.CardAspectRatioValueview.Kanban.CardSize = masterView.Kanban.CardSize+ view.Kanban.CardWidth = masterView.Kanban.CardWidthview.Kanban.FitImage = masterView.Kanban.FitImageview.Kanban.DisplayFieldName = masterView.Kanban.DisplayFieldNameview.Kanban.DisplayEmptyFields = masterView.Kanban.DisplayEmptyFieldsdiff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex f1b7c49a22..c4b5ffacde 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -376,6 +376,8 @@ func performTx(tx *Transaction) (ret *TxErr) {ret = tx.doSetAttrViewCoverFromAssetKeyID(op)case "setAttrViewCardSize":ret = tx.doSetAttrViewCardSize(op)+ case "setAttrViewCardWidth":+ ret = tx.doSetAttrViewCardWidth(op)case "setAttrViewFitImage":ret = tx.doSetAttrViewFitImage(op)case "setAttrViewDisplayFieldName":@@ -394,6 +396,8 @@ func performTx(tx *Transaction) (ret *TxErr) {ret = tx.doSetAttrViewBlockView(op)case "setAttrViewCardAspectRatio":ret = tx.doSetAttrViewCardAspectRatio(op)+ case "setAttrViewCardAspectRatioValue":+ ret = tx.doSetAttrViewCardAspectRatioValue(op)case "setAttrViewGroup":ret = tx.doSetAttrViewGroup(op)case "hideAttrViewGroup":diff --git a/kernel/sql/av.go b/kernel/sql/av.goindex 1ff3eb2e8e..f02d4ce8df 100644--- a/kernel/sql/av.go+++ b/kernel/sql/av.go@@ -50,7 +50,9 @@ func RenderGroupView(attrView *av.AttributeView, view, groupView *av.View, querygroupView.Gallery.CoverFrom = view.Gallery.CoverFromgroupView.Gallery.CoverFromAssetKeyID = view.Gallery.CoverFromAssetKeyIDgroupView.Gallery.CardAspectRatio = view.Gallery.CardAspectRatio+ groupView.Gallery.CardAspectRatioValue = view.Gallery.CardAspectRatioValuegroupView.Gallery.CardSize = view.Gallery.CardSize+ groupView.Gallery.CardWidth = view.Gallery.CardWidthgroupView.Gallery.FitImage = view.Gallery.FitImagegroupView.Gallery.DisplayFieldName = view.Gallery.DisplayFieldNamegroupView.Gallery.DisplayEmptyFields = view.Gallery.DisplayEmptyFields@@ -62,7 +64,9 @@ func RenderGroupView(attrView *av.AttributeView, view, groupView *av.View, querygroupView.Kanban.CoverFrom = view.Kanban.CoverFromgroupView.Kanban.CoverFromAssetKeyID = view.Kanban.CoverFromAssetKeyIDgroupView.Kanban.CardAspectRatio = view.Kanban.CardAspectRatio+ groupView.Kanban.CardAspectRatioValue = view.Kanban.CardAspectRatioValuegroupView.Kanban.CardSize = view.Kanban.CardSize+ groupView.Kanban.CardWidth = view.Kanban.CardWidthgroupView.Kanban.FitImage = view.Kanban.FitImagegroupView.Kanban.DisplayFieldName = view.Kanban.DisplayFieldNamegroupView.Kanban.DisplayEmptyFields = view.Kanban.DisplayEmptyFieldsdiff --git a/kernel/sql/av_gallery.go b/kernel/sql/av_gallery.goindex 5baaece9cf..72a8b74f05 100644--- a/kernel/sql/av_gallery.go+++ b/kernel/sql/av_gallery.go@@ -26,16 +26,18 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query}ret = &av.Gallery{- BaseInstance: av.NewViewBaseInstance(view),- CoverFrom: view.Gallery.CoverFrom,- CoverFromAssetKeyID: view.Gallery.CoverFromAssetKeyID,- CardAspectRatio: view.Gallery.CardAspectRatio,- CardSize: view.Gallery.CardSize,- FitImage: view.Gallery.FitImage,- DisplayFieldName: view.Gallery.DisplayFieldName,- DisplayEmptyFields: view.Gallery.DisplayEmptyFields,- Fields: []*av.GalleryField{},- Cards: []*av.GalleryCard{},+ BaseInstance: av.NewViewBaseInstance(view),+ CoverFrom: view.Gallery.CoverFrom,+ CoverFromAssetKeyID: view.Gallery.CoverFromAssetKeyID,+ CardAspectRatio: view.Gallery.CardAspectRatio,+ CardAspectRatioValue: view.Gallery.CardAspectRatioValue,+ CardSize: view.Gallery.CardSize,+ CardWidth: view.Gallery.CardWidth,+ FitImage: view.Gallery.FitImage,+ DisplayFieldName: view.Gallery.DisplayFieldName,+ DisplayEmptyFields: view.Gallery.DisplayEmptyFields,+ Fields: []*av.GalleryField{},+ Cards: []*av.GalleryCard{},}// 组装字段diff --git a/kernel/sql/av_kanban.go b/kernel/sql/av_kanban.goindex b0b8e1cfa3..668a9fa8ea 100644--- a/kernel/sql/av_kanban.go+++ b/kernel/sql/av_kanban.go@@ -24,7 +24,9 @@ func RenderAttributeViewKanban(attrView *av.AttributeView, view *av.View, queryCoverFrom: view.Kanban.CoverFrom,CoverFromAssetKeyID: view.Kanban.CoverFromAssetKeyID,CardAspectRatio: view.Kanban.CardAspectRatio,+ CardAspectRatioValue: view.Kanban.CardAspectRatioValue,CardSize: view.Kanban.CardSize,+ CardWidth: view.Kanban.CardWidth,FitImage: view.Kanban.FitImage,DisplayFieldName: view.Kanban.DisplayFieldName,DisplayEmptyFields: view.Kanban.DisplayEmptyFields,