text
text copied to clipboard
Initializing the table of contents creates a transaction even in read only mode
Describe the bug
- Document opens
- Table of contents is initialized
- Headings are parsed and get an id
- ids are added to heading nodes creating a transaction
- transaction updates document state leading to steps pushed even in read only mode.
To Reproduce
Steps to reproduce the behavior:
- Create a markdown file with headings and a public read only share of it
- observe network traffic
- Notice step send in one of the push requests
Expected behavior Opening the document read only should not alter the state.
Screenshots will attach later
This is related to https://github.com/nextcloud/text/issues/5800#issuecomment-2145591803
Probably the way forward would be to migrate extractHeadings() to use ProseMirror Decorations for setting the id attribute locally, instead of altering the document state. See this example.
Ah sounds like a good idea, haven't thought of that with my comment in https://github.com/nextcloud/text/issues/5800#issuecomment-2154775155