An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Support database filter composition https://github.com/siyuan-note/siyuan/issues/10550
Daniel000e38f9591d
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scssindex 2644ed5094..d1d719534f 100644--- a/app/src/assets/scss/business/_av.scss+++ b/app/src/assets/scss/business/_av.scss@@ -921,12 +921,28 @@padding: 0 8px;margin: 6px 0;gap: 6px;+ display: flex;+ align-items: center;&:hover > .b3-menu__action {opacity: 1;}}+ .av__filter-andor {+ margin: 0;+ flex-shrink: 0;+ box-sizing: border-box;+ height: 28px;+ line-height: 20px;+ font-size: 14px;+ padding: 0 20px 0 6px;+ display: inline-flex;+ align-items: center;+ color: var(--b3-theme-on-background);+ border: 1px solid transparent;+ }+.av__filter-group-left {flex-shrink: 0;display: flex;@@ -967,6 +983,21 @@justify-content: flex-start;gap: 6px;padding-left: 8px;++ .block__icon {+ font-size: 14px;+ cursor: pointer;+ display: inline-flex;+ align-items: center;+ gap: 2px;+ padding: 0;++ svg {+ width: 10px;+ height: 10px;+ flex-shrink: 0;+ }+ }}&__item[data-type="nobg"] {@@ -981,6 +1012,15 @@.b3-menu__item.av__filter-row {margin: 6px 0;gap: 6px;+ align-items: center;+ }++ .av__filter-rowinner {+ display: flex;+ flex-wrap: nowrap;+ align-items: center;+ min-height: 28px;+ gap: 6px;}.av__filter-group-children .b3-menu__item.av__filter-row,@@ -997,6 +1037,16 @@}.av__field-wrapper {+ display: flex;+ align-items: center;+ flex-shrink: 0;+ height: 28px;+ background: transparent;+ border: 1px solid var(--b3-theme-surface-lighter);+ border-radius: var(--b3-border-radius);+ padding: 0 4px 0 6px;+ gap: 2px;+ box-sizing: border-box;background-color: var(--b3-menu-background) !important;}@@ -1024,6 +1074,106 @@background-color: transparent !important;color: var(--b3-theme-on-surface) !important;}++ .av__filter-select {+ margin: 0;+ flex-shrink: 0;+ min-width: 60px;+ height: 28px;+ line-height: 20px;+ font-size: 14px;+ box-shadow: none;+ padding-left: 6px;+ background: transparent url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="%23888" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>') no-repeat right 6px center;+ padding-right: 20px;+ }++ .av__filter-input {+ margin: 0;+ box-shadow: none;+ background: transparent;+ flex: 1;+ min-width: 60px;+ height: 28px;+ font-size: 14px;+ }++ .av__filter-value {+ display: inline-flex;+ align-items: center;+ flex: 1;+ min-width: 60px;+ }++ &.av__filter-panel {+ min-width: 340px;+ max-width: 80vw;+ width: fit-content;+ }++ .av__filter-date-row {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ flex-wrap: wrap;+ }++ .av__filter-date-input {+ margin: 0;+ box-shadow: none;+ background: transparent;+ height: 28px;+ line-height: 20px;+ font-size: 14px;+ }++ .av__filter-date-col {+ display: inline-flex;+ flex-direction: column;+ gap: 6px;+ }++ .av__select-trigger {+ display: inline-flex;+ align-items: center;+ flex: 1;+ min-width: 60px;+ cursor: pointer;+ overflow: hidden;+ padding-right: 20px;+ background: transparent url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="%23888" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>') no-repeat right 6px center;++ .ft__on-surface {+ font-size: 14px;+ }+ }++ .av__select-dropdown {+ width: fit-content;+ min-width: 120px;+ max-height: 240px;+ overflow-x: hidden;+ overflow-y: auto;+ padding: 4px;+ box-shadow: var(--b3-dialog-shadow);+ border-radius: var(--b3-border-radius);+ background-color: var(--b3-menu-background);+ }++ .av__select-options {+ display: flex;+ flex-direction: column;+ width: 100%;+ overflow: hidden;+ }++ // 下拉内搜索框,复用 input 的外观但占满宽度+ .av__select-dropdown .b3-text-field {+ margin: 0 0 4px 0;+ height: 28px;+ font-size: 14px;+ width: 100%;+ }}}diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex 909fcf776f..483407aa01 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -868,6 +868,8 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemenoperator: getDefaultOperatorByType(type),value: genCellValue(type, ""),};+ // 深拷贝旧值用于 undo,撤销时恢复完整筛选状态而非清空全部+ const oldFilters = JSON.parse(JSON.stringify(avData.view.filters));getEditableFilters(avData).push(filter);transaction(protyle, [{action: "setAttrViewFilters",@@ -877,7 +879,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen}], [{action: "setAttrViewFilters",avID,- data: [], // undo 时移除新增条件(简化处理)+ data: oldFilters,blockID: blockElement.getAttribute("data-node-id")}]);}diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.tsindex 43c2bf72fa..0aef7cd85c 100644--- a/app/src/protyle/render/av/filter.ts+++ b/app/src/protyle/render/av/filter.ts@@ -220,13 +220,13 @@ export const getFiltersHTML = (data: IAV) => {document.body.removeChild(measureEl);const andOrControlWidth = andOrTextWidth + 28;const genAndOrSelect = (groupPath: string, combination: string) =>- `<select class="b3-select" data-type="toggleCombination" data-path="${groupPath}" style="margin:0;flex-shrink:0;width:${andOrControlWidth}px;box-sizing:border-box;height:28px;line-height:20px;font-size:14px;box-shadow:none;padding-left:6px;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;padding-right:20px;"><option value="and" ${combination === "and" ? "selected" : ""}>${window.siyuan.languages.filterCombinationAnd}</option><option value="or" ${combination === "or" ? "selected" : ""}>${window.siyuan.languages.filterCombinationOr}</option></select>`;+ `<select class="b3-select av__filter-select" data-type="toggleCombination" data-path="${groupPath}" style="min-width:0;width:${andOrControlWidth}px;"><option value="and" ${combination === "and" ? "selected" : ""}>${window.siyuan.languages.filterCombinationAnd}</option><option value="or" ${combination === "or" ? "selected" : ""}>${window.siyuan.languages.filterCombinationOr}</option></select>`;const genWhenLabel = () =>- `<span style="margin:0;flex-shrink:0;width:${andOrControlWidth}px;box-sizing:border-box;height:28px;line-height:20px;font-size:14px;padding:0 20px 0 6px;display:inline-flex;align-items:center;color:var(--b3-theme-on-background);border:1px solid transparent;">${window.siyuan.languages.filterWhen}</span>`;+ `<span class="av__filter-andor" style="width:${andOrControlWidth}px;">${window.siyuan.languages.filterWhen}</span>`;const genAndOrLabel = (combination: string) =>- `<span style="margin:0;flex-shrink:0;width:${andOrControlWidth}px;box-sizing:border-box;height:28px;line-height:20px;font-size:14px;padding:0 20px 0 6px;display:inline-flex;align-items:center;color:var(--b3-theme-on-background);border:1px solid transparent;">${combination === "or" ? window.siyuan.languages.filterCombinationOr : window.siyuan.languages.filterCombinationAnd}</span>`;+ `<span class="av__filter-andor" style="width:${andOrControlWidth}px;">${combination === "or" ? window.siyuan.languages.filterCombinationOr : window.siyuan.languages.filterCombinationAnd}</span>`;const genNodeHTML = (node: IAVFilter, path: string, depth: number, groupPath: string, groupCombination: string, index: number = 0): string => {if (!node) {@@ -247,11 +247,11 @@ export const getFiltersHTML = (data: IAV) => {const depthClass = `av__filter-group-children--depth${Math.min(depth, 3)}`;const addConditionBtn = depth >= 3- ? `<span class="block__icon ariaLabel" data-position="4north" data-type="addFilter" data-path="${path}" aria-label="${window.siyuan.languages.addFilterCondition}" style="font-size:14px;cursor:pointer;display:inline-flex;align-items:center;gap:2px;padding:0;"><svg style="width:10px;height:10px;"><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.addFilterCondition}</span>`- : `<span class="block__icon ariaLabel" data-position="4north" data-type="addFilterCondition" data-path="${path}" data-depth="${depth}" aria-label="${window.siyuan.languages.addFilterCondition}" style="font-size:14px;cursor:pointer;display:inline-flex;align-items:center;gap:2px;padding:0;"><svg style="width:10px;height:10px;"><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.addFilterCondition}<svg style="width:10px;height:10px;flex-shrink:0;"><use xlink:href="#iconDown"></use></svg></span>`;+ ? `<span class="block__icon ariaLabel" data-position="4north" data-type="addFilter" data-path="${path}" aria-label="${window.siyuan.languages.addFilterCondition}"><svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.addFilterCondition}</span>`+ : `<span class="block__icon ariaLabel" data-position="4north" data-type="addFilterCondition" data-path="${path}" data-depth="${depth}" aria-label="${window.siyuan.languages.addFilterCondition}"><svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.addFilterCondition}<svg><use xlink:href="#iconDown"></use></svg></span>`;const andOrHTML = 0 === index ? genWhenLabel() : 1 === index ? genAndOrSelect(groupPath, groupCombination) : genAndOrLabel(groupCombination);- return `<div class="av__filter-group-item" data-path="${path}" style="display:flex;align-items:center;">+ return `<div class="av__filter-group-item" data-path="${path}"><span class="av__filter-group-left">${andOrHTML}</span>@@ -279,11 +279,11 @@ export const getFiltersHTML = (data: IAV) => {const fieldOptions = fields.filter((f: IAVColumn) => f.type !== "lineNumber").map((f: IAVColumn) =>`<option value="${f.id}" ${f.id === node.column ? "selected" : ""}>${escapeHtml(f.name)}</option>`).join("");- const fieldSelect = `<select class="b3-select" data-type="fieldSelect" data-path="${path}" style="margin:0;flex-shrink:0;min-width:80px;max-width:120px;height:28px;line-height:20px;font-size:14px;box-shadow:none;padding-left:0;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;padding-right:20px;">${fieldOptions}</select>`;- const fieldWrapper = `<span class="av__field-wrapper ariaLabel" data-position="4west" aria-label="${escapeAttr(colData.name)}" style="display:flex;align-items:center;flex-shrink:0;height:28px;background:transparent;border:1px solid var(--b3-theme-surface-lighter);border-radius:var(--b3-border-radius);padding:0 4px 0 6px;gap:2px;box-sizing:border-box;">${iconHTML}${fieldSelect}</span>`;+ const fieldSelect = `<select class="b3-select av__filter-select" data-type="fieldSelect" data-path="${path}" style="min-width:80px;max-width:120px;padding-left:0;">${fieldOptions}</select>`;+ const fieldWrapper = `<span class="av__field-wrapper ariaLabel" data-position="4west" aria-label="${escapeAttr(colData.name)}">${iconHTML}${fieldSelect}</span>`;const inlineHTML = genInlineFilterHTML(node, colData, path);const leafAndOrHTML = 0 === index ? genWhenLabel() : 1 === index ? genAndOrSelect(groupPath, groupCombination) : genAndOrLabel(groupCombination);- return `<div class="b3-menu__item av__filter-row" data-path="${path}" data-column="${node.column}" style="align-items:center;">${leafAndOrHTML}<div class="fn__flex-1" style="display:flex;flex-wrap:nowrap;align-items:center;min-height:28px;gap:6px;">${fieldWrapper}${inlineHTML}</div><svg class="b3-menu__action ariaLabel" data-position="4west" data-type="moreFilter" data-path="${path}" aria-label="${window.siyuan.languages.more}"><use xlink:href="#iconMore"></use></svg></div>`;+ return `<div class="b3-menu__item av__filter-row" data-path="${path}" data-column="${node.column}">${leafAndOrHTML}<div class="fn__flex-1 av__filter-rowinner">${fieldWrapper}${inlineHTML}</div><svg class="b3-menu__action ariaLabel" data-position="4west" data-type="moreFilter" data-path="${path}" aria-label="${window.siyuan.languages.more}"><use xlink:href="#iconMore"></use></svg></div>`;};const isRootGroup = data.view.filters.length === 1 && (data.view.filters[0].filters || data.view.filters[0].combination);@@ -447,11 +447,11 @@ const genInlineFilterHTML = (filter: IAVFilter, colData: IAVColumn, path: stringconst valueHidden = isEmptyOp ? " fn__none" : "";// 操作符 select- const operatorSelect = `<select class="b3-select" style="margin:0;flex-shrink:0;min-width:60px;height:28px;line-height:20px;font-size:14px;box-shadow:none;padding-left:6px;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;padding-right:20px;" data-type="operation" data-path="${path}">${getOperatorSelectByType(valueType, operator)}</select>`;+ const operatorSelect = `<select class="b3-select av__filter-select" data-type="operation" data-path="${path}">${getOperatorSelectByType(valueType, operator)}</select>`;// 量化器 select(rollup/mAsset 才有)const quantifierSelect = (isRollup || valueType === "mAsset")- ? `<select class="b3-select" style="margin:0;flex-shrink:0;min-width:60px;height:28px;line-height:20px;font-size:14px;box-shadow:none;padding-left:6px;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;padding-right:20px;" data-type="quantifier" data-path="${path}">+ ? `<select class="b3-select av__filter-select" data-type="quantifier" data-path="${path}"><option ${(!filter.quantifier || filter.quantifier === "Any") ? "selected" : ""} value="Any">${window.siyuan.languages.filterQuantifierAny}</option><option ${filter.quantifier === "All" ? "selected" : ""} value="All">${window.siyuan.languages.filterQuantifierAll}</option><option ${filter.quantifier === "None" ? "selected" : ""} value="None">${window.siyuan.languages.filterQuantifierNone}</option>@@ -464,16 +464,16 @@ const genInlineFilterHTML = (filter: IAVFilter, colData: IAVColumn, path: stringconst filterValue = filter.value;if (["text", "url", "block", "email", "phone", "template"].includes(valueType)) {const content = filterValue?.[valueType as "text"]?.content || "";- valueHTML = `<input class="b3-text-field b3-text-field--text" style="margin:0;box-shadow:none;background:transparent;flex:1;min-width:60px;height:28px;font-size:14px;" value="${escapeHtml(content)}" data-type="filterValue" data-path="${path}">`;+ valueHTML = `<input class="b3-text-field b3-text-field--text av__filter-input" value="${escapeHtml(content)}" data-type="filterValue" data-path="${path}">`;} else if (valueType === "mAsset") {const content = filterValue?.mAsset?.[0]?.content || "";- valueHTML = `<input class="b3-text-field b3-text-field--text" style="margin:0;box-shadow:none;background:transparent;flex:1;min-width:60px;height:28px;font-size:14px;" value="${escapeHtml(content)}" data-type="filterValue" data-path="${path}">`;+ valueHTML = `<input class="b3-text-field b3-text-field--text av__filter-input" value="${escapeHtml(content)}" data-type="filterValue" data-path="${path}">`;} else if (valueType === "number") {const content = filterValue?.number?.isNotEmpty ? filterValue.number.content : "";- valueHTML = `<input class="b3-text-field b3-text-field--text" style="margin:0;box-shadow:none;background:transparent;flex:1;min-width:50px;height:28px;font-size:14px;" value="${content}" data-type="filterValue" data-path="${path}">`;+ valueHTML = `<input class="b3-text-field b3-text-field--text av__filter-input" style="min-width:50px;" value="${content}" data-type="filterValue" data-path="${path}">`;} else if (valueType === "checkbox") {const isChecked = filterValue?.checkbox?.checked;- valueHTML = `<select class="b3-select" data-type="filterValue" data-path="${path}" style="margin:0;flex-shrink:0;min-width:60px;height:28px;line-height:20px;font-size:14px;box-shadow:none;padding-left:6px;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;padding-right:20px;"><option value="true" ${isChecked ? "selected" : ""}>${window.siyuan.languages.checked}</option><option value="false" ${!isChecked ? "selected" : ""}>${window.siyuan.languages.unchecked}</option></select>`;+ valueHTML = `<select class="b3-select av__filter-select" data-type="filterValue" data-path="${path}"><option value="true" ${isChecked ? "selected" : ""}>${window.siyuan.languages.checked}</option><option value="false" ${!isChecked ? "selected" : ""}>${window.siyuan.languages.unchecked}</option></select>`;} else if (["date", "created", "updated"].includes(valueType)) {valueHTML = genInlineDateHTML(filter, valueType, path);} else if (valueType === "select" || valueType === "mSelect") {@@ -482,10 +482,10 @@ const genInlineFilterHTML = (filter: IAVFilter, colData: IAVColumn, path: stringextraHTML = dropdown; // 下拉面板放 valueContainer 外,fixed 定位不影响行宽} else if (valueType === "relation") {const content = filterValue?.relation?.blockIDs?.[0] || "";- valueHTML = `<input class="b3-text-field b3-text-field--text" style="margin:0;box-shadow:none;background:transparent;flex:1;min-width:60px;height:28px;font-size:14px;" value="${escapeHtml(content)}" data-type="filterValue" data-type-rel="relation" data-path="${path}">`;+ valueHTML = `<input class="b3-text-field b3-text-field--text av__filter-input" value="${escapeHtml(content)}" data-type="filterValue" data-type-rel="relation" data-path="${path}">`;}- return `${quantifierSelect}${operatorSelect}<span class="av__filter-value${valueHidden}" data-type="valueContainer" data-path="${path}" style="display:inline-flex;align-items:center;flex:1;min-width:60px;">${valueHTML}</span>${extraHTML}`;+ return `${quantifierSelect}${operatorSelect}<span class="av__filter-value${valueHidden}" data-type="valueContainer" data-path="${path}">${valueHTML}</span>${extraHTML}`;};// genInlineDateHTML 生成日期类型的内联控件(绝对/相对切换 + Is between 结束日期)。@@ -496,30 +496,29 @@ const genInlineDateHTML = (filter: IAVFilter, valueType: TAVCol, path: string):const isBetween = filter.operator === "Is between";const dateBlock = (suffix: "" | "2", relativeDate: IAVRelativeDate, dateVal: any, showToday: boolean): string => {- const borderlessSelect = "margin:0;flex-shrink:0;min-width:60px;height:28px;line-height:20px;font-size:14px;box-shadow:none;padding-left:6px;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;padding-right:20px;";- const dateTypeSel = `<select class="b3-select" data-type="dateType${suffix}" data-path="${path}" style="${borderlessSelect}">+ const dateTypeSel = `<select class="b3-select av__filter-select" data-type="dateType${suffix}" data-path="${path}"><option value="time"${!relativeDate ? " selected" : ""}>${window.siyuan.languages.includeTime}</option><option value="custom"${relativeDate ? " selected" : ""}>${window.siyuan.languages.relativeToToday}</option></select>`;- const absDate = `<input value="${(dateVal && (dateVal.isNotEmpty || (suffix === "2" ? dateVal.isNotEmpty2 : valueType !== "date"))) ? dayjs(suffix === "2" ? dateVal.content2 : dateVal.content).format("YYYY-MM-DD") : ""}" type="date" max="9999-12-31" class="b3-text-field b3-text-field--text" data-type="absDate${suffix}" data-path="${path}" style="margin:0;box-shadow:none;background:transparent;height:28px;line-height:20px;font-size:14px;${relativeDate ? "display:none;" : ""}">`;- const relDir = `<select class="b3-select" data-type="dataDirection${suffix}" data-path="${path}" style="${borderlessSelect}${!relativeDate ? "display:none;" : ""}">+ const absDate = `<input value="${(dateVal && (dateVal.isNotEmpty || (suffix === "2" ? dateVal.isNotEmpty2 : valueType !== "date"))) ? dayjs(suffix === "2" ? dateVal.content2 : dateVal.content).format("YYYY-MM-DD") : ""}" type="date" max="9999-12-31" class="b3-text-field b3-text-field--text av__filter-date-input" data-type="absDate${suffix}" data-path="${path}" style="${relativeDate ? "display:none;" : ""}">`;+ const relDir = `<select class="b3-select av__filter-select" data-type="dataDirection${suffix}" data-path="${path}" style="${!relativeDate ? "display:none;" : ""}"><option value="-1"${relativeDate?.direction === -1 ? " selected" : ""}>${window.siyuan.languages.pastDate}</option><option value="1"${relativeDate?.direction === 1 ? " selected" : ""}>${window.siyuan.languages.nextDate}</option><option value="0"${showToday ? " selected" : ""}>${window.siyuan.languages.current}</option></select>`;- const relCount = `<input type="number" min="1" step="1" value="${relativeDate?.count || 1}" class="b3-text-field b3-text-field--text" data-type="relCount${suffix}" data-path="${path}" style="margin:0;box-shadow:none;background:transparent;height:28px;line-height:20px;font-size:14px;width:50px;${(!relativeDate || showToday) ? "display:none;" : ""}">`;- const relUnit = `<select class="b3-select" data-type="relUnit${suffix}" data-path="${path}" style="${borderlessSelect}${(!relativeDate || showToday) ? "display:none;" : ""}">+ const relCount = `<input type="number" min="1" step="1" value="${relativeDate?.count || 1}" class="b3-text-field b3-text-field--text av__filter-date-input" data-type="relCount${suffix}" data-path="${path}" style="width:50px;${(!relativeDate || showToday) ? "display:none;" : ""}">`;+ const relUnit = `<select class="b3-select av__filter-select" data-type="relUnit${suffix}" data-path="${path}" style="${(!relativeDate || showToday) ? "display:none;" : ""}"><option value="0"${relativeDate?.unit === 0 ? " selected" : ""}>${window.siyuan.languages.day}</option><option value="1"${(!relativeDate || relativeDate?.unit === 1) ? " selected" : ""}>${window.siyuan.languages.week}</option><option value="2"${relativeDate?.unit === 2 ? " selected" : ""}>${window.siyuan.languages.month}</option><option value="3"${relativeDate?.unit === 3 ? " selected" : ""}>${window.siyuan.languages.year}</option></select>`;- return `<span style="display:inline-flex;align-items:center;gap:6px;flex-wrap:wrap;">${dateTypeSel}${absDate}${relDir}${relCount}${relUnit}</span>`;+ return `<span class="av__filter-date-row">${dateTypeSel}${absDate}${relDir}${relCount}${relUnit}</span>`;};const filter1 = dateBlock("", filter.relativeDate, dateValue, showToday1);const filter2 = dateBlock("2", filter.relativeDate2, dateValue, showToday2);- return `<span style="display:inline-flex;flex-direction:column;gap:6px;">${filter1}<span data-type="filter2Wrap" data-path="${path}" style="${isBetween ? "" : "display:none;"}">${filter2}</span></span>`;+ return `<span class="av__filter-date-col">${filter1}<span data-type="filter2Wrap" data-path="${path}" style="${isBetween ? "" : "display:none;"}">${filter2}</span></span>`;};// genInlineSelectHTML 生成 select/mSelect 的内联多选 chip 列表 + 搜索。@@ -533,12 +532,12 @@ const genInlineSelectHTML = (filter: IAVFilter, colData: IAVColumn, path: stringconst selectedChips = selectedValues.map((item: IAVCellSelectValue) => {return `<span class="b3-chip b3-chip--middle" style="margin:1px 2px;background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${escapeHtml(item.content)}</span>`;}).join("");- const triggerContent = selectedChips || `<span class="ft__on-surface fn__ellipsis" style="font-size:14px;">${placeholder}</span>`;- const trigger = `<span data-type="selectTrigger" data-path="${path}" style="display:inline-flex;align-items:center;flex:1;min-width:60px;cursor:pointer;overflow:hidden;padding-right:20px;background:transparent url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%23888%22 stroke-width=%221.7%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22m6 9 6 6 6-6%22/></svg>') no-repeat right 6px center;">${triggerContent}</span>`;+ const triggerContent = selectedChips || `<span class="ft__on-surface fn__ellipsis">${placeholder}</span>`;+ const trigger = `<span class="av__select-trigger" data-type="selectTrigger" data-path="${path}">${triggerContent}</span>`;// 下拉面板const searchInput = options.length > 5- ? `<input class="b3-text-field" placeholder="${window.siyuan.languages.search}" data-type="filterSearch" data-path="${path}" style="margin:0 0 4px 0;height:28px;font-size:14px;width:100%;">`+ ? `<input class="b3-text-field" placeholder="${window.siyuan.languages.search}" data-type="filterSearch" data-path="${path}">`: "";const chips = options.map((option: { name: string; color: string; desc?: string }) => {const selected = selectedValues.some((s: IAVCellSelectValue) => s.content === option.name);@@ -547,8 +546,8 @@ const genInlineSelectHTML = (filter: IAVFilter, colData: IAVColumn, path: string<span class="fn__ellipsis" style="min-width:0;">${escapeHtml(option.name)}</span></span>`;}).join("");- const dropdown = `<div data-type="selectDropdown" data-path="${path}" data-single="${isSingle ? "true" : "false"}" style="display:none;position:fixed;z-index:9999;width:fit-content;min-width:120px;max-height:240px;overflow-x:hidden;overflow-y:auto;padding:4px;box-shadow:var(--b3-dialog-shadow);border-radius:var(--b3-border-radius);background-color:var(--b3-menu-background);">-${searchInput}<div data-type="selectOptions" data-path="${path}" style="display:flex;flex-direction:column;width:100%;overflow:hidden;">${chips}</div>+ const dropdown = `<div class="av__select-dropdown" data-type="selectDropdown" data-path="${path}" data-single="${isSingle ? "true" : "false"}" style="display:none;position:fixed;z-index:9999;">+${searchInput}<div class="av__select-options" data-type="selectOptions" data-path="${path}">${chips}</div></div>`;return {trigger, dropdown};};@@ -882,7 +881,7 @@ export const bindInlineFilterEvents = (panelElement: HTMLElement, data: IAV, proselectedChips.push(`<span class="b3-chip b3-chip--middle" style="margin:1px 2px;background-color:var(--b3-font-background${color});color:var(--b3-font-color${color})">${escapeHtml(name)}</span>`);}});- const contentHTML = selectedChips.join("") || `<span class="ft__on-surface fn__ellipsis" style="font-size:14px;">${placeholderStr}</span>`;+ const contentHTML = selectedChips.join("") || `<span class="ft__on-surface fn__ellipsis">${placeholderStr}</span>`;triggerEl.innerHTML = contentHTML;}saveRow(row, path, false);diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex 33801bf540..11e050f111 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -169,7 +169,7 @@ export const openMenuPanel = (options: {document.body.insertAdjacentHTML("beforeend", `<div class="av__panel" style="z-index: ${++window.siyuan.zIndex};"><div class="b3-dialog__scrim" data-type="close"></div>- <div class="b3-menu" ${["select", "date", "asset", "relation", "rollup"].includes(options.type) ? `style="${["select", "asset", "relation"].includes(options.type) ? "max-height: calc(100vh - 32px);display: flex;flex-direction: column;" : ""}min-width: 200px;${isMobile() ? "max-width: 90vw;" : "max-width: 50vw;"}"` : (options.type === "filters" ? 'style="min-width: 340px;max-width: 80vw;width: fit-content;"' : "")}>${html}</div>+ <div class="b3-menu${options.type === "filters" ? " av__filter-panel" : ""}" ${["select", "date", "asset", "relation", "rollup"].includes(options.type) ? `style="${["select", "asset", "relation"].includes(options.type) ? "max-height: calc(100vh - 32px);display: flex;flex-direction: column;" : ""}min-width: 200px;${isMobile() ? "max-width: 90vw;" : "max-width: 50vw;"}"` : ""}>${html}</div></div>`);avPanelElement = document.querySelector(".av__panel");let closeCB: () => void;@@ -371,6 +371,7 @@ export const openMenuPanel = (options: {event.stopPropagation();break;} else if (type === "go-config") {+ menuElement.classList.remove("av__filter-panel");menuElement.innerHTML = getViewHTML(data);setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);bindViewEvent({protyle: options.protyle, data, menuElement, blockElement: options.blockElement});@@ -381,6 +382,7 @@ export const openMenuPanel = (options: {} else if (type === "go-properties") {// 复制列后点击返回到属性面板,宽度不一致,需重新计算tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();+ menuElement.classList.remove("av__filter-panel");menuElement.innerHTML = getPropertiesHTML(fields);setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);window.siyuan.menus.menu.remove();@@ -388,6 +390,7 @@ export const openMenuPanel = (options: {event.stopPropagation();break;} else if (type === "go-layout") {+ menuElement.classList.remove("av__filter-panel");menuElement.innerHTML = getLayoutHTML(data);setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);bindLayoutEvent({protyle: options.protyle, data, menuElement, blockElement: options.blockElement});@@ -396,6 +399,7 @@ export const openMenuPanel = (options: {event.stopPropagation();break;} else if (type === "goSorts") {+ menuElement.classList.remove("av__filter-panel");menuElement.innerHTML = getSortsHTML(fields, data.view.sorts);bindSortsEvent(options.protyle, menuElement, data, blockID);setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);@@ -462,7 +466,7 @@ export const openMenuPanel = (options: {break;} else if (type === "goFilters") {menuElement.innerHTML = getFiltersHTML(data);- menuElement.setAttribute("style", "min-width: 340px;max-width: 80vw;width: fit-content;");+ menuElement.classList.add("av__filter-panel");bindInlineFilterEvents(avPanelElement as HTMLElement, data, options.protyle, blockID, avID);setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);window.siyuan.menus.menu.remove();