Closed nothingislost closed 3 years ago
This implementation is problematic in scenarios where cm.refresh() is being called often. For example, when resizing the window, all of the attributes are removed and re-added repeatedly. If you create a style that relies on the data attributes, you will see that style flicker on an off while resizing.
I'm thinking through a more effective way to apply the attributes but open to any suggestions.
Closing this as there hasn't seemed to be much interest. I'll add it as a feature in CodeMirror Options.
@nothingislost Apologies, this PR totally fell off my radar as things got busy at school. I'd be happy to take a look, but if you'd like more control over the pacing of development, adding it to your plugin may be the way to go.
Here's my take on enabling Contextual Typography in edit mode. This should replicate the preview functionality almost exactly. The following data attributes are automatically added to parent elements:
This makes use of the CodeMirror "renderLine" event and from my testing so far, seems to be pretty efficient.
It should be fairly easy to add support for additional HTML elements. We just need to pick out the appropriate CM tokens and add them to the switch statement.