From 4a945303a4f683ebb47fa5e15e4995e23ab9f610 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 7 Jun 2023 11:55:45 +0800 Subject: [PATCH] :sparkles: https://github.com/siyuan-note/siyuan/issues/7536 --- app/src/protyle/hint/index.ts | 3 +++ app/src/protyle/render/av/index.ts | 35 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 508badecb..6b16a9c61 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -32,6 +32,7 @@ import {processRender} from "../util/processCode"; import {AIChat} from "../../ai/chat"; import {isMobile} from "../../util/functions"; import {isCtrl} from "../util/compatibility"; +import {avRender} from "../render/av"; export class Hint { public timeId: number; @@ -683,6 +684,8 @@ ${unicode2Emoji(emoji.unicode)}`; nodeElement.querySelectorAll("colgroup col").forEach((item: HTMLElement) => { item.style.minWidth = "60px"; }); + } else if (nodeElement.classList.contains("av")) { + avRender(nodeElement) } transaction(protyle, [{ data: oldHTML, diff --git a/app/src/protyle/render/av/index.ts b/app/src/protyle/render/av/index.ts index a4028eac8..1d15aeb4e 100644 --- a/app/src/protyle/render/av/index.ts +++ b/app/src/protyle/render/av/index.ts @@ -1,3 +1,36 @@ -export const avRender = (element: Element) => { +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 = { + filter:{}, + sorts: {}, + columns:[{ + id:"", + name:"", + type:"", + }], + rows:[{ + id:"", + cells:[{ + value:"", + }] + }] + } + e.setAttribute("data-render", "true"); + }); + } }