Vanessa 2023-08-03 23:23:28 +08:00
parent 2baa74fb39
commit eb7548962f
11 changed files with 36 additions and 4 deletions

View file

@ -1,4 +1,5 @@
{
"format": "Number format",
"numberFormatNone": "Number",
"numberFormatCommas": "Number with commas",
"numberFormatPercent": "Percent",

View file

@ -1,4 +1,5 @@
{
"format": "Formato de número",
"numberFormatNone": "Número",
"numberFormatCommas": "Número con comas",
"numberFormatPercent": "Porcentaje",

View file

@ -1,4 +1,5 @@
{
"format": "Format des nombres",
"numberFormatNone": "Numéro",
"numberFormatCommas": "Nombre avec des virgules",
"numberFormatPercent": "Pourcentage",

View file

@ -1,4 +1,5 @@
{
"format": "格式化",
"numberFormatNone": "數字",
"numberFormatCommas": "千分位",
"numberFormatPercent": "百分比",

View file

@ -1,4 +1,5 @@
{
"format": "格式化",
"numberFormatNone": "数字",
"numberFormatCommas": "千分位",
"numberFormatPercent": "百分比",

View file

@ -219,6 +219,18 @@
&--url {
text-decoration: underline var(--b3-border-color);
}
&--date {
display: flex;
align-items: center;
svg {
margin: 0 5px;
height: 10px;
width: 10px;
flex-shrink: 0;
}
}
}
&__firstcol {

View file

@ -351,7 +351,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[]) => {
if (["text", "url", "email", "phone"].includes(type)) {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`;
} else if (type === "number") {
html = `<input type="number" value="${cellElements[0].textContent}" ${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) {
openMenuPanel({protyle, blockElement, type: "select", cellElements});
return;

View file

@ -115,6 +115,14 @@ export const getEditHTML = (options: {
</button>`;
});
}
if (colData.type === "number") {
html += `<button class="b3-menu__separator"></button>
<button class="b3-menu__item" data-type="numberFormat">
<svg class="b3-menu__icon"><use xlink:href="#iconFormat"></use></svg>
<span class="b3-menu__label">${window.siyuan.languages.format}</span>
<span class="b3-menu__accelerator">${colData.numberFormat}</span>
</button>`;
}
return `<div class="b3-menu__items">
${html}
<button class="b3-menu__separator"></button>

View file

@ -427,6 +427,11 @@ export const openMenuPanel = (options: {
return true;
}
});
event.preventDefault();
event.stopPropagation();
break;
} else if (type === "numberFormat") {
event.preventDefault();
event.stopPropagation();
break;

View file

@ -79,7 +79,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-ref" data-id="${cell.value.block.id}" data-subtype="s">${window.siyuan.languages.openBy}</span>`;
}
} else if (cell.valueType === "number") {
text = `<span class="av__celltext">${cell.value?.number.content || ""}</span>`;
text = `<span class="av__celltext" data-content="${cell.value?.number.content || ""}">${cell.value?.number.formattedContent || ""}</span>`;
} else if (cell.valueType === "mSelect" || cell.valueType === "select") {
cell.value?.mSelect?.forEach((item: { content: string, color: string }) => {
text += `<span class="b3-chip b3-chip--middle" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${item.content}</span>`;
@ -90,12 +90,12 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
text = `<span class="av__celltext">${text}</span>`;
}
} else if (cell.valueType === "date") {
text = '<span class="av__celltext">';
text = '<span class="av__celltext av__celltext--date">';
if (cell.value?.date.isNotEmpty) {
text += dayjs(cell.value.date.content).format("YYYY-MM-DD HH:mm");
}
if (cell.value?.date.hasEndDate && cell.value?.date.isNotEmpty && cell.value?.date.isNotEmpty2) {
text += `<svg style="margin-left: 5px"><use xlink:href="#iconForward"></use></svg>${dayjs(cell.value.date.content2).format("YYYY-MM-DD HH:mm")}`;
text += `<svg><use xlink:href="#iconForward"></use></svg>${dayjs(cell.value.date.content2).format("YYYY-MM-DD HH:mm")}`;
}
text += "</span>";
}
@ -104,6 +104,7 @@ ${cell.valueType === "block" ? 'data-block-id="' + (cell.value.block.id || "") +
style="width: ${data.columns[index].width || "200px"};
${cell.bgColor ? `background-color:${cell.bgColor};` : ""}
${data.columns[index].wrap ? "" : "white-space: nowrap;"}
${cell.valueType !== "number" ? "" : "flex-direction: row-reverse;"}
${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
});
tableHTML += "<div></div></div>";

View file

@ -912,6 +912,7 @@ interface IAVColumn {
wrap: boolean,
hidden: boolean,
type: TAVCol,
numberFormat: string,
calc: {
operator: string,
result: IAVCellValue