Skip to content

BARTlab/obsidian-local-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Local History - Line Change Tracker

GitHub release (latest SemVer) GitHub All Releases

A powerful Obsidian plugin that tracks and visually highlights changed lines in your documents, providing real-time feedback on your editing progress with intuitive visual indicators.

Philosophy

Plugin is built with the philosophy of minimal interference and maximum informativeness. Follows the principle of "show, but don't interfere" โ€” it provides valuable information about your changes while remaining unobtrusive and not disrupting your familiar workflow.

Reasons for Creation

When working with large documents or during lengthy editing sessions, it's easy to lose track of what exactly has been changed. This is especially relevant when:

  • Refactoring large notes โ€” when you need to restructure content without losing important details
  • Collaborative work โ€” when multiple people edit documents and you need to track each person's contribution
  • Text experiments โ€” when trying different formulations and wanting to easily return to previous versions
  • Long editing sessions โ€” when many small changes accumulate over several hours of work

โœจ Features

๐ŸŽฏ Smart Change Detection

  • Source Mode Only: Activates exclusively when files are open in Source mode for precise tracking
  • Existing Files Focus: Works only with previously saved files, ignoring new unsaved documents
  • Real-time Tracking: Monitors changes as you type using CodeMirror 6 API

๐ŸŽจ Visual Indicators

  • Line Markers: Highlights changed lines with customizable colored indicators
  • Gutter Dots: Alternative display mode with character indicators in the editor gutter
  • Auto-removal: Markers automatically disappear when lines return to their original state
  • Multiple Change Types: Different colors for added, modified, restored, and removed lines

๐Ÿ“Š Advanced History Features

  • Original Content Preservation: Stores the initial file state for accurate comparison
  • Diff Viewer: Built-in modal with side-by-side and line-by-line diff views
  • Clean Patch Export: Generate and copy clean patches with zero context
  • Smart Deletion Handling: Properly tracks removed lines without affecting subsequent content

๐Ÿ“ธ Screenshots

editor-lines editor-gutters

The plugin highlighting changed lines in the editor

diff-line-by-line diff-side-by-side diff-patch

Built-in diff viewer showing changes side-by-side

settings

Customizable settings for different indicator types

๐Ÿš€ Installation

Automatic Installation (Recommended)

  1. Open Obsidian
  2. Go to Settings โ†’ Community plugins
  3. Disable Safe mode if it's enabled
  4. Click Browse and search for "Local history" or "Line Change Tracker"
  5. Click Install and then Enable

Manual Installation

  1. Download the latest release from the GitHub releases page
  2. Extract the files to your vault's plugins folder: VaultFolder/.obsidian/plugins/local-history/
  3. Reload Obsidian
  4. Enable the plugin in Settings โ†’ Community plugins

๐ŸŽฎ Usage

Basic Operation

  1. Open an existing file in Source mode
  2. Start editing - the plugin automatically captures the original state
  3. See visual feedback as you make changes:
    • โšช Blue: Modified lines
    • โšช Orange: Added lines
    • โšช Base: Removed lines
    • โšช Gray: Restored lines

Viewing Change History

  • Use the command palette (Ctrl/Cmd + P) and search for "Show all changes"
  • Or access via the plugin's commands to open the diff viewer modal

Diff Viewer Features

  • Side-by-side view: Compare original and current versions
  • Line-by-line view: Unified diff format
  • Patch export: Generate clean patches for external use
  • Synchronized scrolling: Both panels scroll together in side-by-side mode

โš™๏ธ Configuration

Access plugin settings via Settings โ†’ Plugin Options โ†’ Local History

Display Options

  • Indicator Type: Choose between line markers or gutter dots
  • Show Indicators For: Toggle visibility for different change types
    • Changed lines
    • Added lines
    • Removed lines
    • Restored lines

History Management

  • Keep History Until: Choose when to clear tracking data
    • App close: Clear when Obsidian closes
    • File close: Clear when file tab closes

Customization

  • Line Width: Adjust the width of line indicators
  • Gutter Character: Customize the character used in gutter mode
  • Colors: Modify indicator colors via CSS snippets

Custom CSS Example

/* Customize line change colors */
.lct-line.lct-changed:not(.mk-placeholder)::before {
    background-color: #ff6b35; /* Orange for changed lines */
}

.lct-line.lct-added:not(.mk-placeholder)::before {
    background-color: #4ecdc4; /* Teal for added lines */
}

.lct-line.lct-restored:not(.mk-placeholder)::after {
    background-color: #fcdb89; /* Yellow for restored lines */
}

.lct-line.lct-removed:not(.mk-placeholder)::after {
    background-color: #b6b6b6; /* Gray for removed lines */
}

๐Ÿ”ง Compatibility

  • Minimum Obsidian Version: 0.15.0
  • Platform Support: Desktop and Mobile
  • File Types: Plain text files (.md, .txt, .csv, .json, .yaml)

๐Ÿ’– Support the Development

If you find this plugin helpful, consider supporting its development:

Buy Me A Coffee

Your support helps maintain and improve the plugin with new features and bug fixes!

๐Ÿ› Issues and Feedback

Found a bug or have a feature request? Please help improve the plugin:

  1. Check existing issues on GitHub Issues
  2. Create a new issue with:
    • Detailed description of the problem
    • Steps to reproduce
    • Your Obsidian version
    • Your operating system
    • Screenshots if applicable

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ› ๏ธ For Developers

Development Setup

Prerequisites

  • Node.js (version 18 or higher)
  • npm or yarn
  • Git

Getting Started

  1. Clone the repository

    git clone https://github.com/bartlab/obsidian-local-history.git
    cd obsidian-local-history
  2. Install dependencies

    npm install
  3. Start development mode

    npm run dev
  4. Build for production

    npm run build

Project Structure

obsidian-local-history/
โ”œโ”€โ”€ src/                          # Source code
โ”‚   โ”œโ”€โ”€ commands/                 # Command definitions
โ”‚   โ”œโ”€โ”€ decorators/              # TypeScript decorators
โ”‚   โ”œโ”€โ”€ events/                  # Event handlers
โ”‚   โ”œโ”€โ”€ extensions/              # CodeMirror extensions
โ”‚   โ”œโ”€โ”€ helpers/                 # Utility functions
โ”‚   โ”œโ”€โ”€ lines/                   # Line tracking logic
โ”‚   โ”œโ”€โ”€ maps/                    # Data structures
โ”‚   โ”œโ”€โ”€ modals/                  # UI modals
โ”‚   โ”œโ”€โ”€ services/                # Core services
โ”‚   โ”œโ”€โ”€ settings/                # Settings management
โ”‚   โ”œโ”€โ”€ snapshots/               # File snapshot handling
โ”‚   โ”œโ”€โ”€ main.ts                  # Plugin entry point
โ”‚   โ””โ”€โ”€ types.ts                 # TypeScript type definitions
โ”œโ”€โ”€ styles.css                   # Plugin styles
โ”œโ”€โ”€ manifest.json                # Plugin manifest
โ”œโ”€โ”€ package.json                 # Dependencies and scripts
โ”œโ”€โ”€ tsconfig.json               # TypeScript configuration
โ”œโ”€โ”€ esbuild.config.mjs          # Build configuration
โ””โ”€โ”€ README.md                   # This file

Architecture Overview

The plugin follows a service-oriented architecture with dependency injection:

  • Services: Core functionality (snapshots, settings, events)
  • Extensions: CodeMirror 6 integrations for editor features
  • Commands: Obsidian command palette integrations
  • Modals: UI components for diff viewing
  • Helpers: Utility functions and DOM manipulation

Key Technologies

  • TypeScript: Type-safe development
  • CodeMirror 6: Editor integration and decorations
  • diff: Text comparison and patch generation
  • diff2html: HTML diff rendering
  • Obsidian API: Plugin framework integration

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes following the existing code style
  4. Add tests if applicable
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Code Style

This project follows the Google TypeScript Style Guide. Please ensure your contributions adhere to these standards.

Testing

# Run tests (when available)
npm test

# Run linting
npm run lint

# Type checking
npm run type-check

Release Process

  1. Update version in manifest.json and package.json
  2. Update versions.json with compatibility info
  3. Create a git tag: git tag -a 1.0.0 -m "Release 1.0.0"
  4. Push tags: git push origin --tags
  5. GitHub Actions will automatically create a release

Made with โค๏ธ for the Obsidian community

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published