[PR #8303] [CLOSED] Added LaTeX Paste Support to Editor #8342

Closed
opened 2026-03-23 23:23:45 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/8303
Author: @Yazaven
Created: 10/22/2025
Status: Closed

Base: mainHead: feature/8177-addlatexpastesupport


📝 Commits (2)

  • 24e0b51 Added LaTeX Paste Support to Editor
  • 06a943b Refactored the code and fixed issue #8111

📊 Changes

4 files changed (+570 additions, -46 deletions)

View changed files

📝 frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart (+104 -30)
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_latex_utils.dart (+345 -0)
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_math_equation_parser.dart (+77 -0)
📝 frontend/appflowy_flutter/lib/shared/markdown_to_document.dart (+44 -16)

📄 Description

Feature Preview

This PR adds LaTeX paste support to AppFlowy, allowing users to paste mathematical equations from ChatGPT and other sources directly into documents with proper rendering.

Fixes #8177

Summary

This PR implements comprehensive LaTeX equation parsing when pasting mathematical content into AppFlowy documents. Users can now copy LaTeX equations from ChatGPT, Gemini, or any other source and paste them directly into AppFlowy with correct rendering.

What this PR adds:

  • Automatic detection and parsing of LaTeX equations in pasted content
  • Support for piecewise functions with \begin{cases} environments
  • Support for aligned equations with \begin{aligned} environments
  • Support for array environments with \begin{array}
  • Proper handling of integrals, limits, series, and differential equations
  • Automatic line break conversion (single \ to double \\) for multi-line equations
  • Correct spacing for differential notation (, dx\, dx)
  • Smart detection of \text{...} blocks to preserve inline text formatting

Before:

https://github.com/user-attachments/assets/bfdce96d-bf96-44b2-927a-e5cfd72c2baa

After:

https://github.com/user-attachments/assets/dd8f6644-8dc8-4220-95cd-8a08327bad04

PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Enable users to paste LaTeX equations directly into the editor by parsing and rendering mathematical content in both markdown and HTML paste flows.

New Features:

  • Add LaTeX paste support with a custom MarkdownMathEquationParser and preprocessing to detect and convert math blocks (including custom brackets) into rendered equations, handling cases, aligned, array environments, spacing normalization, and line breaks
  • Extend HTML paste workflow to detect mathematical and list content and route such content through markdown conversion for accurate structure and LaTeX rendering

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/8303 **Author:** [@Yazaven](https://github.com/Yazaven) **Created:** 10/22/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/8177-addlatexpastesupport` --- ### 📝 Commits (2) - [`24e0b51`](https://github.com/AppFlowy-IO/AppFlowy/commit/24e0b51bde42029377742ee02cf03cdfc66bfdf9) ✨ Added LaTeX Paste Support to Editor - [`06a943b`](https://github.com/AppFlowy-IO/AppFlowy/commit/06a943bd7e2f1214f56cd9b7077200e199388197) Refactored the code and fixed issue #8111 ### 📊 Changes **4 files changed** (+570 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart` (+104 -30) ➕ `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_latex_utils.dart` (+345 -0) ➕ `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_math_equation_parser.dart` (+77 -0) 📝 `frontend/appflowy_flutter/lib/shared/markdown_to_document.dart` (+44 -16) </details> ### 📄 Description <!--- Thank you for submitting a pull request to AppFlowy. The team will dedicate their best efforts to reviewing and approving your pull request. If you have any questions about the project or feedback for us, please join our [Discord](https://discord.gg/wdjWUXXhtw). --> ## Feature Preview This PR adds LaTeX paste support to AppFlowy, allowing users to paste mathematical equations from ChatGPT and other sources directly into documents with proper rendering. Fixes #8177 ## Summary This PR implements comprehensive LaTeX equation parsing when pasting mathematical content into AppFlowy documents. Users can now copy LaTeX equations from ChatGPT, Gemini, or any other source and paste them directly into AppFlowy with correct rendering. **What this PR adds:** - Automatic detection and parsing of LaTeX equations in pasted content - Support for piecewise functions with `\begin{cases}` environments - Support for aligned equations with `\begin{aligned}` environments - Support for array environments with `\begin{array}` - Proper handling of integrals, limits, series, and differential equations - Automatic line break conversion (single `\` to double `\\`) for multi-line equations - Correct spacing for differential notation (`, dx` → `\, dx`) - Smart detection of `\text{...}` blocks to preserve inline text formatting Before: https://github.com/user-attachments/assets/bfdce96d-bf96-44b2-927a-e5cfd72c2baa After: https://github.com/user-attachments/assets/dd8f6644-8dc8-4220-95cd-8a08327bad04 #### PR Checklist - [ ] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [ ] I've listed at least one issue that this PR fixes in the description above. - [ ] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [ ] All existing tests are passing. ## Summary by Sourcery Enable users to paste LaTeX equations directly into the editor by parsing and rendering mathematical content in both markdown and HTML paste flows. New Features: - Add LaTeX paste support with a custom MarkdownMathEquationParser and preprocessing to detect and convert math blocks (including custom brackets) into rendered equations, handling cases, aligned, array environments, spacing normalization, and line breaks - Extend HTML paste workflow to detect mathematical and list content and route such content through markdown conversion for accurate structure and LaTeX rendering --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 23:23:45 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#8342
No description provided.