New Features
- Tooltip for Dates: Added functionality to display a tooltip showing the number of days since a date when hovering over file names or selecting text within files. The tooltip appears only if a valid date format is detected.
- File Viewer Integration: Tooltip functionality is now integrated with the file viewer, providing dynamic date information when hovering over file names.
- Theme Matching: Tooltip styling now matches the active Obsidian theme, ensuring consistent look and feel.
Enhancements
- Improved Tooltip Readability: Added a border and a light shadow to the tooltip to enhance readability and contrast.
- Selection Handling: Tooltip displays only when a single date or a date with one space on either side is selected, preventing false positives when large chunks of text are selected.
Bug Fixes
- Error Handling: Fixed an issue where getRangeAt would throw a DOMException when called on an empty selection.
- CSS Injection: Resolved Content Security Policy (CSP) restrictions by injecting CSS styles directly into the document head, ensuring compatibility with Obsidian's security settings.
Detailed Changes
- Added handleSelection method to display the tooltip based on text selection.
- Added handleHover method to display the tooltip based on hovering over file names in the file viewer.
- Added injectStyles method to inject CSS styles directly into the document head, avoiding CSP issues.
- Improved tooltip styling with added border and box shadow for better contrast and readability.
- Ensured tooltip functionality only triggers for exact date selections or file names within the file viewer.
(Integrated into main.ts) Added styles for .plugin-tooltip to match the active Obsidian theme and improve tooltip readability.
How to Use
- Hover Over File Names: Hover over file names in the file viewer to see a tooltip showing the number of days since the date in the file name.
- Select Text: Select a date or a date with one space on either side within a file to see the tooltip with the number of days since the selected date.