mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
feat(editor): support markdown adapter preprocessed with latex delimiters (#11431)
To close [BS-2870](https://linear.app/affine-design/issue/BS-2870/支持识别-和-[-包裹内容为公式) ## Add Markdown Preprocessor Extension and Enhanced LaTeX Support ### Markdown Preprocessor Extension This PR introduces a new preprocessor extension for Markdown adapters that allows preprocessing of content before conversion: Adds a new PreprocessorManager for handling text transformations Introduces extensible preprocessor interface that supports different processing levels (block/slice/doc) Integrates preprocessor extension into the existing Markdown adapter workflow ### LaTeX Support Enhancement Extends LaTeX support to handle both traditional and alternative syntax: Adds support for backslash LaTeX syntax: Block math: ```\[...\] ``` alongside existing ```$$...$$``` Inline math: ```\(...\) ``` alongside existing ```$...$``` Implements LaTeX preprocessor to standardize syntax before conversion Updates tests to cover both syntax variants
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createReactComponentFromLit } from '@affine/component';
|
||||
import { defaultBlockMarkdownAdapterMatchers } from '@blocksuite/affine/adapters';
|
||||
import { MarkdownAdapterExtension } from '@blocksuite/affine/adapters';
|
||||
import {
|
||||
defaultImageProxyMiddleware,
|
||||
ImageProxyService,
|
||||
@@ -7,10 +7,6 @@ import {
|
||||
import { PageEditorBlockSpecs } from '@blocksuite/affine/extensions';
|
||||
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
||||
import {
|
||||
InlineDeltaToMarkdownAdapterExtensions,
|
||||
MarkdownInlineToDeltaAdapterExtensions,
|
||||
} from '@blocksuite/affine/inlines/preset';
|
||||
import { codeBlockWrapMiddleware } from '@blocksuite/affine/shared/adapters';
|
||||
import { LinkPreviewerService } from '@blocksuite/affine/shared/services';
|
||||
import {
|
||||
@@ -215,11 +211,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
provider = this.host.std.provider;
|
||||
} else {
|
||||
const container = new Container();
|
||||
[
|
||||
...MarkdownInlineToDeltaAdapterExtensions,
|
||||
...defaultBlockMarkdownAdapterMatchers,
|
||||
...InlineDeltaToMarkdownAdapterExtensions,
|
||||
].forEach(ext => {
|
||||
[...MarkdownAdapterExtension].forEach(ext => {
|
||||
ext.setup(container);
|
||||
});
|
||||
|
||||
|
||||
+2
-10
@@ -1,20 +1,12 @@
|
||||
import { defaultBlockMarkdownAdapterMatchers } from '@blocksuite/affine/adapters';
|
||||
import { MarkdownAdapterExtension } from '@blocksuite/affine/adapters';
|
||||
import { Container } from '@blocksuite/affine/global/di';
|
||||
import {
|
||||
InlineDeltaToMarkdownAdapterExtensions,
|
||||
MarkdownInlineToDeltaAdapterExtensions,
|
||||
} from '@blocksuite/affine/inlines/preset';
|
||||
import { TestWorkspace } from '@blocksuite/affine/store/test';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import { markdownToMindmap } from '../mindmap-preview.js';
|
||||
|
||||
const container = new Container();
|
||||
[
|
||||
...MarkdownInlineToDeltaAdapterExtensions,
|
||||
...defaultBlockMarkdownAdapterMatchers,
|
||||
...InlineDeltaToMarkdownAdapterExtensions,
|
||||
].forEach(ext => {
|
||||
[...MarkdownAdapterExtension].forEach(ext => {
|
||||
ext.setup(container);
|
||||
});
|
||||
const provider = container.provider();
|
||||
|
||||
Reference in New Issue
Block a user