shibacomputer / txt

A simple, private writing app.
https://newdesigncongress.org
GNU General Public License v3.0
94 stars 7 forks source link

Simple Track Changes Support in Txt's editor #42

Open shibacomputer opened 4 years ago

shibacomputer commented 4 years ago

Txt uses CriticMarkup to track changes within a document. This is because each document created or edited with Txt must be inter-operable in other applications with minimal data loss. Embedding comments, changes, substitutions and other simple document edits in a plaintext document fits the scope of this philosophy.

As per the spec, CriticMarkup uses a simple set of actions for editing and annotating plain text: addition {++ ... ++}, deletion {-- ... --}, substitution {~~ ... ~> ... ~~}, comment {>> <<}, and highlight {== ... ==}{>> ... <<}

Desired Behaviour

Enabling Tracked Changes

Tracking Changes is enabled via a keyboard shortcut, or via the application menu Edit > Track Changes. This send a command via IPC to the renderer to trigger an context:update event with the flag trackChanges in Txt's context state updated to represent enabling or disabling this editing mode.

When trackChanges is true in Txt's context, the doc state should immediately create a copy of contents, as trackedContents. Importantly, this is not a copy of staleContents - which is the state of the document since last save.

Disabling Tracked Changes

When trackChanges switches to false, Txt maintains all of the syntax highlighting and any existing CriticMarkup syntax within the document. However, trackedContents is erased from the doc state.

Handling cursor positioning and syntax

When trackChanges is ON, the cursor should always jump past CriticMarkup syntax. If the user clicks on syntax directly, jump to the nearest available space on either side of the syntax. Always leave 1 white space character on either side of the syntax. When trackChanges is OFF, the editor should treat CriticMarkup syntax as normal text.

Editing with Tracked Changes

Once created, the user's text interactions should be compared against trackedContents and make decisions about what to add into the document relevant to the user's cursor and their action.

Additions

Deletion

Substitution

Comments

-- This is a living issue, and behaviour will be added to and tweaked over time!