Here is an Apple article with how to prepare a Mac for sale:
What to do before you sell, give away, trade in, or recycle your Mac - Apple Support
If you were using iCloud to sync those notes, then you can try using the instructions in the following article to recover them, otherwise you would need to recover them from a backup you made prior to deleting them.
Recover deleted files on iCloud.com - Apple Support
Make sure you always have frequent and regular backups of your computer and all external media (including the cloud) which contains important & unique data. Keep in mind iCloud is not a backup service, iCloud is a file syncing service. As you discovered a catastrophic mistake on one device causes that mistake to affect every other device being synced with iCloud (also pertains to other cloud based file syncing services as well). macOS includes the Time Machine software with macOS so users can easily manage their backups. With newer Macs, there are a lot of new ways to permanently lose access to your data if it is not backed up.