facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
19.98k stars 1.7k forks source link

Export DOMExportOutputMap from Lexical Core to Improve Reusability and Type Safety #6802

Closed Kingscliq closed 2 weeks ago

Kingscliq commented 2 weeks ago

Lexical version: V0.19.0

Steps To Reproduce

  1. Currently, Lexical does not export DOMExportOutputMap as a standalone type.
  2. Developers creating custom export configurations in the html property for CreateEditorArgs have to define DOMExportOutputMap manually, which is error-prone and inconsistent.

Link to code example: https://github.com/facebook/lexical/blob/a4e70168a13271dfdaa8e2684f5fc99658f3236c/examples/react-rich/src/App.tsx#L56

The current behavior

Currently, when developers need to customize the html export configuration, they must re-create the structure for DOMExportOutputMap, which leads to redundant code and increases the risk of type errors due to misconfiguration. This is especially relevant when dealing with complex export setups where nodes have specific styles or properties that need to be customized for DOM output.

The expected behavior

DOMExportOutputMap should be exported directly from the Lexical core library, allowing developers to import and use this type immediately in any export configuration of the html property. This would improve type safety, reduce code duplication, and streamline custom DOM export setups.

Impact of fix

  1. Low-to-Moderate, as this mainly affects type handling and reusability rather than functionality.
  2. Developers like me working with custom DOM export configurations in Lexical editors, especially in applications that need highly customized export logic, will greatly benefit from it. Had to create a custom type instead of just using the DOM
  3. Improved development efficiency and reduced risk of type-related errors for all users implementing html.export in CreateEditorArgs.