nextcloud / text

📑 Collaborative document editing using Markdown
GNU Affero General Public License v3.0
528 stars 85 forks source link

Initializing the table of contents creates a transaction even in read only mode #5861

Open max-nextcloud opened 4 weeks ago

max-nextcloud commented 4 weeks ago

Describe the bug

  1. Document opens
  2. Table of contents is initialized
  3. Headings are parsed and get an id
  4. ids are added to heading nodes creating a transaction
  5. transaction updates document state leading to steps pushed even in read only mode.

To Reproduce

Steps to reproduce the behavior:

  1. Create a markdown file with headings and a public read only share of it
  2. observe network traffic
  3. 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

max-nextcloud commented 3 weeks ago

This is related to https://github.com/nextcloud/text/issues/5800#issuecomment-2145591803

mejo- commented 3 weeks ago

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.

juliushaertl commented 3 weeks ago

Ah sounds like a good idea, haven't thought of that with my comment in https://github.com/nextcloud/text/issues/5800#issuecomment-2154775155