This commit is contained in:
parent
8479aef270
commit
17e77274fa
2 changed files with 10 additions and 7 deletions
|
@ -32,13 +32,13 @@ export const initBlockPopover = (app: App) => {
|
|||
} else {
|
||||
if (aElement.firstElementChild?.getAttribute("data-type") === "url") {
|
||||
if (aElement.firstElementChild.textContent.indexOf("...") > -1) {
|
||||
tip = aElement.firstElementChild.getAttribute("data-href");
|
||||
tip = Lute.EscapeHTMLStr(aElement.firstElementChild.getAttribute("data-href"));
|
||||
}
|
||||
}
|
||||
if (!tip && aElement.dataset.wrap !== "true" && event.target.dataset.type !== "block-more" && !hasClosestByClassName(event.target, "block__icon")) {
|
||||
aElement.style.overflow = "auto";
|
||||
if (aElement.scrollWidth > aElement.clientWidth + 2) {
|
||||
tip = getCellText(aElement);
|
||||
tip = Lute.EscapeHTMLStr(getCellText(aElement));
|
||||
}
|
||||
aElement.style.overflow = "";
|
||||
}
|
||||
|
|
|
@ -30,9 +30,10 @@ const renderCellURL = (urlContent: string) => {
|
|||
}
|
||||
} catch (e) {
|
||||
// 不是 url 地址
|
||||
host = Lute.EscapeHTMLStr(urlContent);
|
||||
}
|
||||
// https://github.com/siyuan-note/siyuan/issues/9291
|
||||
return `<span class="av__celltext av__celltext--url" data-type="url" data-href="${urlContent}"><span>${host}</span><span class="ft__on-surface">${suffix}</span></span>`;
|
||||
return `<span class="av__celltext av__celltext--url" data-type="url" data-href="${escapeAttr(urlContent)}"><span>${host}</span><span class="ft__on-surface">${suffix}</span></span>`;
|
||||
};
|
||||
|
||||
export const getCellText = (cellElement: HTMLElement | false) => {
|
||||
|
@ -149,7 +150,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
|
|||
cellValue = {
|
||||
type: colType,
|
||||
[colType]: {
|
||||
content: ["block", "text", "url", "phone", "email"].includes(colType) ? Lute.EscapeHTMLStr(value) : value
|
||||
content: value
|
||||
}
|
||||
};
|
||||
} else if (colType === "mSelect" || colType === "select") {
|
||||
|
@ -687,10 +688,12 @@ export const renderCellAttr = (cellElement: Element, value: IAVCellValue) => {
|
|||
|
||||
export const renderCell = (cellValue: IAVCellValue, rowIndex = 0) => {
|
||||
let text = "";
|
||||
if (["text", "template"].includes(cellValue.type)) {
|
||||
text = `<span class="av__celltext">${cellValue ? (cellValue[cellValue.type as "text"].content || "") : ""}</span>`;
|
||||
if ("template" === cellValue.type) {
|
||||
text = `<span class="av__celltext">${cellValue ? (cellValue.template.content || "") : ""}</span>`;
|
||||
} else if ("text" === cellValue.type) {
|
||||
text = `<span class="av__celltext">${cellValue ? Lute.EscapeHTMLStr(cellValue.text.content || "") : ""}</span>`;
|
||||
} else if (["email", "phone"].includes(cellValue.type)) {
|
||||
text = `<span class="av__celltext av__celltext--url" data-type="${cellValue.type}">${cellValue ? cellValue[cellValue.type as "email"].content : ""}</span>`;
|
||||
text = `<span class="av__celltext av__celltext--url" data-type="${cellValue.type}">${cellValue ? Lute.EscapeHTMLStr(cellValue[cellValue.type as "email"].content || "") : ""}</span>`;
|
||||
} else if ("url" === cellValue.type) {
|
||||
text = renderCellURL(cellValue?.url?.content || "");
|
||||
} else if (cellValue.type === "block") {
|
||||
|
|
Loading…
Add table
Reference in a new issue