feat: Support LaTeX and AsciiMath via MathJax on stem.excalidraw.com

This commit is contained in:
Daniel J. Geiger
2022-12-27 15:11:52 -06:00
parent c8370b394c
commit 86f5c2ebcf
84 changed files with 8331 additions and 289 deletions

View File

@@ -31,6 +31,7 @@ import { getCornerRadius, isPathALoop } from "../math";
import rough from "roughjs/bin/rough";
import { AppState, BinaryFiles, Zoom } from "../types";
import { getDefaultAppState } from "../appState";
import { getSubtypeMethods } from "../subtypes";
import {
BOUND_TEXT_PADDING,
MAX_DECIMALS_FOR_SVG_EXPORT,
@@ -206,6 +207,12 @@ const drawElementOnCanvas = (
renderConfig: RenderConfig,
) => {
context.globalAlpha = element.opacity / 100;
const map = getSubtypeMethods(element.subtype);
if (map?.render) {
map.render(element, context, renderConfig.renderCb);
context.globalAlpha = 1;
return;
}
switch (element.type) {
case "rectangle":
case "diamond":
@@ -1053,6 +1060,11 @@ export const renderElementToSvg = (
root = anchorTag;
}
const map = getSubtypeMethods(element.subtype);
if (map?.renderSvg) {
map.renderSvg(svgRoot, root, element, { offsetX, offsetY });
return;
}
switch (element.type) {
case "selection": {
// Since this is used only during editing experience, which is canvas based,