mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
a6798192ae
commit
a5c2053218
2 changed files with 23 additions and 21 deletions
|
|
@ -733,7 +733,7 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLEleme
|
||||||
let item = cellElements[elementIndex] as HTMLElement;
|
let item = cellElements[elementIndex] as HTMLElement;
|
||||||
const rowID = getFieldIdByCellElement(item, viewType);
|
const rowID = getFieldIdByCellElement(item, viewType);
|
||||||
if (!rowID) {
|
if (!rowID) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
if (!nodeElement.contains(item)) {
|
if (!nodeElement.contains(item)) {
|
||||||
if (viewType === "table") {
|
if (viewType === "table") {
|
||||||
|
|
@ -746,11 +746,11 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLEleme
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
// 兼容新增行后台隐藏
|
// 兼容新增行后台隐藏
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
const type = getTypeByCellElement(item) || item.dataset.type as TAVCol;
|
const type = getTypeByCellElement(item) || item.dataset.type as TAVCol;
|
||||||
if (["created", "updated", "template", "rollup"].includes(type)) {
|
if (["created", "updated", "template", "rollup"].includes(type)) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
const cellId = item.dataset.id; // 刚创建时无 id,更新需和 oldValue 保持一致
|
const cellId = item.dataset.id; // 刚创建时无 id,更新需和 oldValue 保持一致
|
||||||
const colId = getColId(item, viewType);
|
const colId = getColId(item, viewType);
|
||||||
|
|
@ -794,7 +794,7 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLEleme
|
||||||
name = value;
|
name = value;
|
||||||
}
|
}
|
||||||
if (!link && !name && !imgSrc) {
|
if (!link && !name && !imgSrc) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
if (imgSrc) {
|
if (imgSrc) {
|
||||||
// 支持解析 ![]() https://github.com/siyuan-note/siyuan/issues/11487
|
// 支持解析 ![]() https://github.com/siyuan-note/siyuan/issues/11487
|
||||||
|
|
@ -858,7 +858,7 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLEleme
|
||||||
cellValue.id = cellId;
|
cellValue.id = cellId;
|
||||||
if ((cellValue.type === "date" && typeof cellValue.date === "string") ||
|
if ((cellValue.type === "date" && typeof cellValue.date === "string") ||
|
||||||
(cellValue.type === "relation" && typeof cellValue.relation === "string")) {
|
(cellValue.type === "relation" && typeof cellValue.relation === "string")) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
if (columns && (type === "select" || type === "mSelect")) {
|
if (columns && (type === "select" || type === "mSelect")) {
|
||||||
const operations = mergeAddOption(columns.find(e => e.id === colId), cellValue, avID);
|
const operations = mergeAddOption(columns.find(e => e.id === colId), cellValue, avID);
|
||||||
|
|
@ -876,7 +876,7 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLEleme
|
||||||
cellValue.date.formattedContent = oldValue.date.formattedContent;
|
cellValue.date.formattedContent = oldValue.date.formattedContent;
|
||||||
}
|
}
|
||||||
if (objEquals(cellValue, oldValue)) {
|
if (objEquals(cellValue, oldValue)) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const avID = blockElement.dataset.avId;
|
const avID = blockElement.dataset.avId;
|
||||||
fetchPost("/api/av/getAttributeViewKeysByAvID", {avID}, (response) => {
|
fetchPost("/api/av/getAttributeViewKeysByAvID", {avID}, async (response) => {
|
||||||
const columns: IAVColumn[] = response.data;
|
const columns: IAVColumn[] = response.data;
|
||||||
const cellElements: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];
|
const cellElements: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];
|
||||||
if (values && Array.isArray(values) && values.length > 0) {
|
if (values && Array.isArray(values) && values.length > 0) {
|
||||||
|
|
@ -61,17 +61,18 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
const id = blockElement.dataset.nodeId;
|
const id = blockElement.dataset.nodeId;
|
||||||
let currentRowElement: Element;
|
let currentRowElement: Element;
|
||||||
const firstColIndex = cellElements[0].getAttribute("data-col-id");
|
const firstColIndex = cellElements[0].getAttribute("data-col-id");
|
||||||
values.find(rowItem => {
|
for (let i = 0; i < values.length; i++) {
|
||||||
if (!currentRowElement) {
|
if (!currentRowElement) {
|
||||||
currentRowElement = hasClosestByClassName(cellElements[0].parentElement, "av__row") as HTMLElement;
|
currentRowElement = hasClosestByClassName(cellElements[0].parentElement, "av__row") as HTMLElement;
|
||||||
} else {
|
} else {
|
||||||
currentRowElement = currentRowElement.nextElementSibling;
|
currentRowElement = currentRowElement.nextElementSibling;
|
||||||
}
|
}
|
||||||
if (!currentRowElement.classList.contains("av__row")) {
|
if (!currentRowElement.classList.contains("av__row")) {
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
let cellElement: HTMLElement;
|
let cellElement: HTMLElement;
|
||||||
rowItem.find(cellValue => {
|
for (let j = 0; j < values[i].length; j++) {
|
||||||
|
const cellValue = values[i][j];
|
||||||
if (!cellElement) {
|
if (!cellElement) {
|
||||||
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
|
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -82,16 +83,16 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!cellElement.classList.contains("av__cell")) {
|
if (!cellElement.classList.contains("av__cell")) {
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
const operations = updateCellsValue(protyle, blockElement as HTMLElement,
|
const operations = await updateCellsValue(protyle, blockElement as HTMLElement,
|
||||||
cellValue, [cellElement], columns, html, true);
|
cellValue, [cellElement], columns, html, true);
|
||||||
if (operations.doOperations.length > 0) {
|
if (operations.doOperations.length > 0) {
|
||||||
doOperations.push(...operations.doOperations);
|
doOperations.push(...operations.doOperations);
|
||||||
undoOperations.push(...operations.undoOperations);
|
undoOperations.push(...operations.undoOperations);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
if (doOperations.length > 0) {
|
if (doOperations.length > 0) {
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
action: "doUpdateUpdated",
|
action: "doUpdateUpdated",
|
||||||
|
|
@ -162,17 +163,17 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
const undoOperations: IOperation[] = [];
|
const undoOperations: IOperation[] = [];
|
||||||
const firstColIndex = cellElements[0].getAttribute("data-col-id");
|
const firstColIndex = cellElements[0].getAttribute("data-col-id");
|
||||||
textJSON.forEach((rowValue) => {
|
for (let i = 0; i < textJSON.length; i++) {
|
||||||
if (!currentRowElement) {
|
if (!currentRowElement) {
|
||||||
currentRowElement = hasClosestByClassName(cellElements[0].parentElement, "av__row") as HTMLElement;
|
currentRowElement = hasClosestByClassName(cellElements[0].parentElement, "av__row") as HTMLElement;
|
||||||
} else {
|
} else {
|
||||||
currentRowElement = currentRowElement.nextElementSibling;
|
currentRowElement = currentRowElement.nextElementSibling;
|
||||||
}
|
}
|
||||||
if (!currentRowElement.classList.contains("av__row")) {
|
if (!currentRowElement.classList.contains("av__row")) {
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
let cellElement: HTMLElement;
|
let cellElement: HTMLElement;
|
||||||
rowValue.forEach((cellValue) => {
|
for (let j = 0; j < textJSON[i].length; j++) {
|
||||||
if (!cellElement) {
|
if (!cellElement) {
|
||||||
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
|
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -183,15 +184,16 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!cellElement.classList.contains("av__cell")) {
|
if (!cellElement.classList.contains("av__cell")) {
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
const operations = updateCellsValue(protyle, blockElement as HTMLElement, cellValue, [cellElement], columns, html, true);
|
const cellValue = textJSON[i][j];
|
||||||
|
const operations = await updateCellsValue(protyle, blockElement as HTMLElement, cellValue, [cellElement], columns, html, true);
|
||||||
if (operations.doOperations.length > 0) {
|
if (operations.doOperations.length > 0) {
|
||||||
doOperations.push(...operations.doOperations);
|
doOperations.push(...operations.doOperations);
|
||||||
undoOperations.push(...operations.undoOperations);
|
undoOperations.push(...operations.undoOperations);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
if (doOperations.length > 0) {
|
if (doOperations.length > 0) {
|
||||||
const id = blockElement.getAttribute("data-node-id");
|
const id = blockElement.getAttribute("data-node-id");
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue