text icon indicating copy to clipboard operation
text copied to clipboard

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

Open max-nextcloud opened this issue 1 year ago • 3 comments

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 avatar Jun 06 '24 07:06 max-nextcloud

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

max-nextcloud avatar Jun 10 '24 10:06 max-nextcloud

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.

mejo- avatar Jun 10 '24 10:06 mejo-

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

juliusknorr avatar Jun 10 '24 10:06 juliusknorr