Files
NapCatQQ/.pnpm-store/v3/files/29/d206772decd77b10335026762c519f7794cebe1ed59c6c1a2b3dcbc0b68c540224c0828aec30d14fbafd10cdfbfacf726c807fdf5fd4ab834e0df2fcac3d7d
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

33 lines
826 B
Plaintext

import Embed from '../blots/embed.js';
class Formula extends Embed {
static blotName = 'formula';
static className = 'ql-formula';
static tagName = 'SPAN';
static create(value) {
// @ts-expect-error
if (window.katex == null) {
throw new Error('Formula module requires KaTeX.');
}
const node = super.create(value);
if (typeof value === 'string') {
// @ts-expect-error
window.katex.render(value, node, {
throwOnError: false,
errorColor: '#f00'
});
node.setAttribute('data-value', value);
}
return node;
}
static value(domNode) {
return domNode.getAttribute('data-value');
}
html() {
const {
formula
} = this.value();
return `<span>${formula}</span>`;
}
}
export default Formula;
//# sourceMappingURL=formula.js.map