This commit is contained in:
Vanessa 2023-10-12 20:04:01 +08:00
parent fdaf8d7e59
commit 02ec0f6e5a
2 changed files with 18 additions and 20 deletions

View File

@ -196,7 +196,6 @@
flex-shrink: 0; flex-shrink: 0;
border-right: 1px solid var(--b3-theme-surface-lighter); border-right: 1px solid var(--b3-theme-surface-lighter);
display: flex; display: flex;
align-items: center;
transition: var(--b3-transition); transition: var(--b3-transition);
[data-type="block-ref"], [data-type="block-ref"],
@ -205,11 +204,13 @@
position: absolute; position: absolute;
right: 5px; right: 5px;
font-size: 85%; font-size: 85%;
top: 8px;
} }
.block__icon { .block__icon {
position: absolute; position: absolute;
right: 5px; right: 5px;
top: 5px;
} }
&:hover .block__icon { &:hover .block__icon {
@ -240,29 +241,24 @@
.b3-chip { .b3-chip {
margin: 1px 2px; margin: 1px 2px;
padding: 2px 6px;
} }
&--url { &--url {
text-decoration: underline var(--b3-border-color); text-decoration: underline var(--b3-border-color);
} }
&--date { & > .av__cellicon {
display: flex;
align-items: center;
svg {
margin: 0 5px; margin: 0 5px;
height: 10px; height: 10px;
width: 10px; width: 10px;
flex-shrink: 0;
}
} }
} }
&__firstcol { &__firstcol {
svg { svg {
color: var(--b3-theme-on-surface); color: var(--b3-theme-on-surface);
height: 36px; height: 33px;
width: 24px; width: 24px;
opacity: 0; opacity: 0;
padding: 5px; padding: 5px;

View File

@ -88,9 +88,6 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
urlAttr = ` data-href="${urlContent}"`; urlAttr = ` data-href="${urlContent}"`;
} }
text = `<span class="av__celltext av__celltext--url" data-type="${cell.valueType}"${urlAttr}>${urlContent}</span>`; text = `<span class="av__celltext av__celltext--url" data-type="${cell.valueType}"${urlAttr}>${urlContent}</span>`;
if (cell.value && cell.value[cell.valueType as "url"].content) {
text += `<span data-type="copy" class="b3-tooltips b3-tooltips__n block__icon" aria-label="${window.siyuan.languages.copy}"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
}
} else if (cell.valueType === "block") { } else if (cell.valueType === "block") {
text = `<span class="av__celltext">${cell.value.block.content || ""}</span>`; text = `<span class="av__celltext">${cell.value.block.content || ""}</span>`;
if (cell.value?.isDetached) { if (cell.value?.isDetached) {
@ -102,7 +99,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
text = `<span class="av__celltext" data-content="${cell.value?.number.isNotEmpty ? cell.value?.number.content : ""}">${cell.value?.number.formattedContent || ""}</span>`; text = `<span class="av__celltext" data-content="${cell.value?.number.isNotEmpty ? cell.value?.number.content : ""}">${cell.value?.number.formattedContent || ""}</span>`;
} else if (cell.valueType === "mSelect" || cell.valueType === "select") { } else if (cell.valueType === "mSelect" || cell.valueType === "select") {
cell.value?.mSelect?.forEach((item) => { cell.value?.mSelect?.forEach((item) => {
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>`; text += `<span class="b3-chip" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${item.content}</span>`;
}); });
if (!text) { if (!text) {
text = '<span class="av__celltext"></span>'; text = '<span class="av__celltext"></span>';
@ -110,17 +107,17 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
text = `<span class="av__celltext">${text}</span>`; text = `<span class="av__celltext">${text}</span>`;
} }
} else if (cell.valueType === "date") { } else if (cell.valueType === "date") {
text = '<span class="av__celltext av__celltext--date">'; text = '<span class="av__celltext">';
const dataValue = cell.value ? cell.value.date : null; const dataValue = cell.value ? cell.value.date : null;
if (dataValue && dataValue.isNotEmpty) { if (dataValue && dataValue.isNotEmpty) {
text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm"); text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm");
} }
if (dataValue && dataValue.hasEndDate && dataValue.isNotEmpty && dataValue.isNotEmpty2) { if (dataValue && dataValue.hasEndDate && dataValue.isNotEmpty && dataValue.isNotEmpty2) {
text += `<svg><use xlink:href="#iconForward"></use></svg>${dayjs(dataValue.content2).format("YYYY-MM-DD HH:mm")}`; text += `<svg class="av__cellicon"><use xlink:href="#iconForward"></use></svg>${dayjs(dataValue.content2).format("YYYY-MM-DD HH:mm")}`;
} }
text += "</span>"; text += "</span>";
} else if (["created", "updated"].includes(cell.valueType)) { } else if (["created", "updated"].includes(cell.valueType)) {
text = '<span class="av__celltext av__celltext--date">'; text = '<span class="av__celltext">';
const dataValue = cell.value ? cell.value[cell.valueType as "date"] : null; const dataValue = cell.value ? cell.value[cell.valueType as "date"] : null;
if (dataValue && dataValue.isNotEmpty) { if (dataValue && dataValue.isNotEmpty) {
text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm"); text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm");
@ -131,7 +128,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
if (item.type === "image") { if (item.type === "image") {
text += `<img class="av__cellassetimg" src="${item.content}">`; text += `<img class="av__cellassetimg" src="${item.content}">`;
} else { } else {
text += `<span class="b3-chip b3-chip--middle av__celltext--url" data-url="${item.content}">${item.name}</span>`; text += `<span class="b3-chip av__celltext--url" data-url="${item.content}">${item.name}</span>`;
} }
}); });
if (!text) { if (!text) {
@ -140,6 +137,11 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
text = `<span class="av__celltext">${text}</span>`; text = `<span class="av__celltext">${text}</span>`;
} }
} }
if (["text", "template", "url", "email", "phone", "number", "date", "created", "updated"].includes(cell.valueType)) {
if (cell.value && cell.value[cell.valueType as "url"].content) {
text += `<span data-type="copy" class="b3-tooltips b3-tooltips__n block__icon" aria-label="${window.siyuan.languages.copy}"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
}
}
tableHTML += `<div class="av__cell" data-id="${cell.id}" data-col-id="${data.columns[index].id}" tableHTML += `<div class="av__cell" data-id="${cell.id}" data-col-id="${data.columns[index].id}"
${cell.valueType === "block" ? 'data-block-id="' + (cell.value.block.id || "") + '"' : ""} ${cell.valueType === "block" ? 'data-block-id="' + (cell.value.block.id || "") + '"' : ""}
${cell.value?.isDetached ? ' data-detached="true"' : ""} ${cell.value?.isDetached ? ' data-detached="true"' : ""}