export const avRender = (element: Element) => { let avElements: Element[] = []; if (element.getAttribute("data-type") === "NodeAttributeView") { // 编辑器内代码块编辑渲染 avElements = [element]; } else { avElements = Array.from(element.querySelectorAll('[data-type="NodeAttributeView"]')); } if (avElements.length === 0) { return; } if (avElements.length > 0) { avElements.forEach((e: HTMLDivElement) => { if (e.getAttribute("data-render") === "true") { return; } const data = { title: "table", filter: {}, sorts: {}, columns: [{ width: 500, icon: "", id: "", name: "columnA", wrap: false, type: "", }, { width: 500, icon: "", id: "", name: "columnB", wrap: false, type: "", }], rows: [{ id: "", cells: [{ value: "a", }, { color: "var(--b3-card-error-color)", bgColor: "var(--b3-card-error-background)", value: "a1", }] }, { id: "", cells: [{ color: "var(--b3-card-success-color)", bgColor: "var(--b3-card-success-background)", value: "b", }, { value: "b1", }] }] }; let tableHTML = "
"; data.columns.forEach((column) => { tableHTML += `
${column.name}
` }); tableHTML += "
"; data.rows.forEach((row) => { tableHTML += "
"; row.cells.forEach((cell, index) => { tableHTML += `
${cell.value}
` }); tableHTML += "
"; }); const paddingLeft = e.parentElement.style.paddingLeft; const paddingRight = e.parentElement.style.paddingRight; // 10: ::-webkit-scrollbar width e.style.width = (e.parentElement.clientWidth - 10) + "px"; e.style.alignSelf = "center"; e.firstElementChild.outerHTML = `
tab1
${data.title}
${tableHTML}
add
`; e.setAttribute("data-render", "true"); }); } };