Vanessa 2023-10-01 17:41:00 +08:00
parent b833087cb6
commit b709c84585
4 changed files with 9 additions and 11 deletions

View File

@ -48,7 +48,7 @@ export const genAVValueHTML = (value: IAVCellValue) => {
<a href="tel:${value.phone.content}" target="_blank" aria-label="${window.siyuan.languages.openBy}" class="block__icon block__icon--show fn__flex-center b3-tooltips__w b3-tooltips"><svg><use xlink:href="#iconPhone"></use></svg></a>`; <a href="tel:${value.phone.content}" target="_blank" aria-label="${window.siyuan.languages.openBy}" class="block__icon block__icon--show fn__flex-center b3-tooltips__w b3-tooltips"><svg><use xlink:href="#iconPhone"></use></svg></a>`;
break; break;
case "template": case "template":
html = `<input value="${value.template.content}" class="b3-text-field b3-text-field--text fn__flex-1">`; html = `<div class="fn__flex-1">${value.template.content}</div>`;
break; break;
case "email": case "email":
html = `<input value="${value.email.content}" class="b3-text-field b3-text-field--text fn__flex-1"> html = `<input value="${value.email.content}" class="b3-text-field b3-text-field--text fn__flex-1">
@ -120,7 +120,7 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "templat
element.querySelectorAll(".b3-text-field--text").forEach((item: HTMLInputElement) => { element.querySelectorAll(".b3-text-field--text").forEach((item: HTMLInputElement) => {
item.addEventListener("change", () => { item.addEventListener("change", () => {
let value; let value;
if (["url", "text", "email", "phone", "template"].includes(item.parentElement.dataset.type)) { if (["url", "text", "email", "phone"].includes(item.parentElement.dataset.type)) {
value = { value = {
[item.parentElement.dataset.type]: { [item.parentElement.dataset.type]: {
content: item.value content: item.value

View File

@ -85,7 +85,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
} }
}; };
} }
} else if (["text", "block", "url", "phone", "email", "template"].includes(colType)) { } else if (["text", "block", "url", "phone", "email"].includes(colType)) {
cellValue = { cellValue = {
type: colType, type: colType,
[colType]: { [colType]: {
@ -344,6 +344,9 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
if (!type) { if (!type) {
type = cellElements[0].parentElement.parentElement.firstElementChild.querySelector(`[data-col-id="${cellElements[0].getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol; type = cellElements[0].parentElement.parentElement.firstElementChild.querySelector(`[data-col-id="${cellElements[0].getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol;
} }
if (type === "template") {
return;
}
if (type === "block" && (cellElements.length > 1 || !cellElements[0].getAttribute("data-detached"))) { if (type === "block" && (cellElements.length > 1 || !cellElements[0].getAttribute("data-detached"))) {
return; return;
} }
@ -353,9 +356,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
const blockElement = hasClosestBlock(cellElements[0]); const blockElement = hasClosestBlock(cellElements[0]);
if (["text", "url", "email", "phone", "block"].includes(type)) { if (["text", "url", "email", "phone", "block"].includes(type)) {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`; html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`;
} else if (type === "template") { } else if (type === "number") {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.getAttribute("data-content")}</textarea>`;
}else if (type === "number") {
html = `<input type="number" value="${cellElements[0].firstElementChild.getAttribute("data-content")}" ${style} class="b3-text-field">`; html = `<input type="number" value="${cellElements[0].firstElementChild.getAttribute("data-content")}" ${style} class="b3-text-field">`;
} else if (["select", "mSelect"].includes(type) && blockElement) { } else if (["select", "mSelect"].includes(type) && blockElement) {
openMenuPanel({protyle, blockElement, type: "select", cellElements}); openMenuPanel({protyle, blockElement, type: "select", cellElements});

View File

@ -62,10 +62,8 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
return; return;
} }
let text = ""; let text = "";
if (cell.valueType === "text") { if (["text", "template"].includes(cell.valueType)) {
text = `<span class="av__celltext">${cell.value?.text.content || ""}</span>`; text = `<span class="av__celltext">${cell.value ? cell.value[cell.valueType as "text"].content : ""}</span>`;
} else if (cell.valueType === "template") {
text = `<span class="av__celltext" data-content="${cell.value?.template.content || ""}">${cell.value?.template.renderedContent || ""}</span>`;
} else if (["url", "email", "phone"].includes(cell.valueType)) { } else if (["url", "email", "phone"].includes(cell.valueType)) {
const urlContent = cell.value ? cell.value[cell.valueType as "url"].content : ""; const urlContent = cell.value ? cell.value[cell.valueType as "url"].content : "";
// https://github.com/siyuan-note/siyuan/issues/9291 // https://github.com/siyuan-note/siyuan/issues/9291

View File

@ -1075,7 +1075,6 @@ interface IAVCellValue {
} }
template?: { template?: {
content: string content: string
renderedContent?:string
} }
date?: IAVCellDateValue date?: IAVCellDateValue
} }