mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
a66096cdf9
#### PR Dependency Tree * **PR #12946** * **PR #12947** 👈 * **PR #12948** This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
|
import { StdIdentifier } from '@blocksuite/std';
|
|
import { InlineSpecExtension } from '@blocksuite/std/inline';
|
|
import { html } from 'lit';
|
|
import { z } from 'zod';
|
|
|
|
export const LatexInlineSpecExtension =
|
|
InlineSpecExtension<AffineTextAttributes>('latex', provider => {
|
|
const std = provider.get(StdIdentifier);
|
|
return {
|
|
name: 'latex',
|
|
schema: z.object({
|
|
latex: z.string().optional().nullable().catch(undefined),
|
|
}),
|
|
match: delta => typeof delta.attributes?.latex === 'string',
|
|
renderer: ({ delta, selected, editor, startOffset, endOffset }) => {
|
|
return html`<affine-latex-node
|
|
.std=${std}
|
|
.delta=${delta}
|
|
.selected=${selected}
|
|
.editor=${editor}
|
|
.startOffset=${startOffset}
|
|
.endOffset=${endOffset}
|
|
></affine-latex-node>`;
|
|
},
|
|
embed: true,
|
|
};
|
|
});
|
|
|
|
export const LatexEditorUnitSpecExtension =
|
|
InlineSpecExtension<AffineTextAttributes>({
|
|
name: 'latex-editor-unit',
|
|
schema: z.object({
|
|
'latex-editor-unit': z.undefined(),
|
|
}),
|
|
match: () => true,
|
|
renderer: ({ delta }) => {
|
|
return html`<latex-editor-unit .delta=${delta}></latex-editor-unit>`;
|
|
},
|
|
});
|