mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
This commit is contained in:
parent
db2bfdbdd6
commit
c202d58bce
3 changed files with 23 additions and 5 deletions
|
|
@ -28,7 +28,7 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
|
|||
return;
|
||||
}
|
||||
if (!e.firstElementChild.classList.contains("protyle-icons")) {
|
||||
e.insertAdjacentHTML("afterbegin", genIconHTML(wysiswgElement));
|
||||
e.insertAdjacentHTML("afterbegin", genIconHTML(wysiswgElement, ["refresh", "edit", "more"]));
|
||||
}
|
||||
const renderElement = e.firstElementChild.nextElementSibling as HTMLElement;
|
||||
if (!e.getAttribute("data-content")) {
|
||||
|
|
@ -41,8 +41,11 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
|
|||
}
|
||||
const chartInstance = window.echarts.getInstanceById(renderElement.lastElementChild?.getAttribute("_echarts_instance_"));
|
||||
const option = await looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
|
||||
if (chartInstance && chartInstance.getOption().series[0]?.type !== option.series[0]?.type) {
|
||||
chartInstance.clear();
|
||||
if (chartInstance) {
|
||||
if (chartInstance.getOption().series[0]?.type !== option.series[0]?.type) {
|
||||
chartInstance.clear();
|
||||
}
|
||||
chartInstance?.resize();
|
||||
}
|
||||
window.echarts.init(renderElement.lastElementChild, window.siyuan.config.appearance.mode === 1 ? "dark" : undefined, {width}).setOption(option);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {isInEmbedBlock} from "../util/hasClosest";
|
||||
import {Constants} from "../../constants";
|
||||
|
||||
export const genIconHTML = (element?: false | HTMLElement) => {
|
||||
export const genIconHTML = (element?: false | HTMLElement, actions = ["edit", "more"]) => {
|
||||
let enable = true;
|
||||
if (element) {
|
||||
const readonly = element.getAttribute("data-readonly");
|
||||
|
|
@ -11,10 +11,18 @@ export const genIconHTML = (element?: false | HTMLElement) => {
|
|||
return '<div class="protyle-icons"></div>';
|
||||
}
|
||||
}
|
||||
return `<div class="protyle-icons">
|
||||
if (actions.length === 3) {
|
||||
return `<div class="protyle-icons">
|
||||
<span aria-label="${window.siyuan.languages.refresh}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__reload"><svg><use xlink:href="#iconRefresh"></use></svg></span>
|
||||
<span aria-label="${window.siyuan.languages.edit}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-action__edit${enable ? "" : " fn__none"}"><svg><use xlink:href="#iconEdit"></use></svg></span>
|
||||
<span aria-label="${window.siyuan.languages.more}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last"><svg><use xlink:href="#iconMore"></use></svg></span>
|
||||
</div>`;
|
||||
} else {
|
||||
return `<div class="protyle-icons">
|
||||
<span aria-label="${window.siyuan.languages.edit}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__edit${enable ? "" : " fn__none"}"><svg><use xlink:href="#iconEdit"></use></svg></span>
|
||||
<span aria-label="${window.siyuan.languages.more}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last${enable ? "" : " protyle-icon--first"}"><svg><use xlink:href="#iconMore"></use></svg></span>
|
||||
</div>`;
|
||||
}
|
||||
};
|
||||
|
||||
export const genRenderFrame = (renderElement: Element) => {
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ import {globalClickHideMenu} from "../../boot/globalEvent/click";
|
|||
import {hideTooltip} from "../../dialog/tooltip";
|
||||
import {openGalleryItemMenu} from "../render/av/gallery/util";
|
||||
import {clearSelect} from "../util/clearSelect";
|
||||
import {chartRender} from "../render/chartRender";
|
||||
|
||||
export class WYSIWYG {
|
||||
public lastHTMLs: { [key: string]: string } = {};
|
||||
|
|
@ -2815,6 +2816,12 @@ export class WYSIWYG {
|
|||
if (embedReloadElement) {
|
||||
embedReloadElement.removeAttribute("data-render");
|
||||
blockRender(protyle, embedReloadElement);
|
||||
} else {
|
||||
const blockElement = hasClosestBlock(reloadElement);
|
||||
if (blockElement && blockElement.getAttribute("data-subtype") === "echarts") {
|
||||
blockElement.removeAttribute("data-render");
|
||||
chartRender(blockElement);
|
||||
}
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue