This pull request includes significant updates to the DocumentTab and related components to support a new edit mode and handle document dirty state. The changes involve adding new properties and methods to manage the edit mode and dirty state, as well as updating the UI components to reflect these changes.
Enhancements to DocumentTab functionality:
src/panels/DocumentTab.ts: Introduced _mode and isDirty properties, along with corresponding getter and setter for mode. The setter includes logic to prevent switching from 'edit' to 'view' if the document is dirty. Added new commands setMode and setDirty to handle mode changes and dirty state. [1][2][3][4][5]
This pull request includes significant updates to the
DocumentTab
and related components to support a new edit mode and handle document dirty state. The changes involve adding new properties and methods to manage the edit mode and dirty state, as well as updating the UI components to reflect these changes.Enhancements to DocumentTab functionality:
src/panels/DocumentTab.ts
: Introduced_mode
andisDirty
properties, along with corresponding getter and setter formode
. The setter includes logic to prevent switching from 'edit' to 'view' if the document is dirty. Added new commandssetMode
andsetDirty
to handle mode changes and dirty state. [1] [2] [3] [4] [5]Updates to UI components:
src/webviews/Document/DocumentPanel.tsx
: Added auseEffect
hook to notify the dispatcher when the document's dirty state changes. [1] [2]src/webviews/Document/DocumentToolbar.tsx
: Added anEdit
button to enable edit mode and updated theSave
button to be hidden when in read-only mode. [1] [2] [3]Dispatcher and state management updates:
src/webviews/Document/state/DocumentContextProvider.tsx
: AddedsetMode
andnotifyDirty
methods to send commands for mode changes and dirty state updates. Added an event listener formodeChanged
to update the state accordingly. [1] [2]src/webviews/Document/state/DocumentState.tsx
: Updated the state reducer to handle the newsetMode
action. [1] [2]