nextcloud / text

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

Version difference extraction #4422

Open juliushaertl opened 1 year ago

juliushaertl commented 1 year ago

When trying to summarize changes that happened since a file was last viewed or to compare the difference of versions in a overview we would need a way to extract the difference between two files in some structured way.

When brainstorming with @AndyScherzinger and @marcoambrosini today we came up with the following idea:

As a first step we'd need to:

If this works out fine we can align with the design team on how to further make use of this, some possible candidates:

For implementation we may want approach it in a flexible API approach so that apps could provide their own extractors for file types which could be text for markdown and a different implementation in richdocuments for office files, though that is something to still evaluate in further detail after the first feasibility exploration.

juliushaertl commented 1 year ago

We probably could use https://commonmark.thephpleague.com/2.4/customization/abstract-syntax-tree/ and try to walk over the output from two versions to generate some sort of diff.

juliushaertl commented 1 year ago

https://github.com/swaggest/json-diff might be useful for this

juliushaertl commented 1 year ago

https://codepen.io/benbowes/pen/pVaMpv could be interesting to show changes inline in the version preview of text.

Doesn't seem to be actively maintained though https://github.com/dfoverdx/htmldiff-js

juliushaertl commented 10 months ago

Summarizing different approaches that we've checked:

Generate HTML diff in the backend

Generate HTML diff in the frontend

Generating structured diff data

Use tiptap to display changes