RhetTbull / macnotesapp

Work with Apple MacOS Notes.app from the command line. Also includes python interface for scripting Notes.app from your own python code.
MIT License
139 stars 6 forks source link

Proposal: Add text to note in CLI #51

Open tonypony220 opened 1 month ago

tonypony220 commented 1 month ago

Very nice project, wdy on give a short commad like extend to add some raw text to some note?

RhetTbull commented 1 month ago

I'd love to be able to do this -- would help my workflow. (I'd probably use append as the command) However, I've not implemented anything like this because I cannot make a guarantee that doing so won't lose formatting and/or data associated with the note. Apple uses a proprietary format to store the actual notes. The AppleScript interface used by macnotesapp is very limited. For example, retrieving the body of a note can be done in either HTML format or plain text. Either loses information associated with the note. For example, check boxes (and the associated checked state) in the note will be lost. Keywords will also be lost. Apple provides no way to append to a note without retrieving the body, appending text (in either HTML or plain text) and setting the note to the new body. This roundtrip also loses text formatting (fonts, sizes, etc). This could work for plain text notes but there's not a way as far as I can tell to determine if a note uses any features that would cause data loss during an append.

I use macOS Ventura as my daily driver. It's possible that Apple has fixed this in a later release of macOS and I'm happy to check when I get a chance but I very much doubt it. They've all but abandoned AppleScript in favor of Shortcuts. There are bugs in the Photos and the Notes AppleScript interfaces that have been present for many years; it doesn't appear Apple wants to spend any resources on improving the scripting interface nor do they provide an API for working with Notes.