Optimizing ProseMirror Custom Style Plugin for Large Documents

Our current ProseMirror editor uses a custom style plugin that manages all style properties and related marks. Each mark includes an ‘override’ flag, allowing users to apply specific style attributes independently. For example, if a predefined style applies only italics, and the user manually adds bold text, the bold attribute is treated as an override.

All style definitions are stored at the document level. When a style is applied, its definitions are loaded from the cache and applied to the paragraph node. However, this approach causes performance issues when dealing with documents exceeding 100 pages. I’d like to confirm if this implementation is optimal or if there’s a better approach to improve performance. Thank you!