ref:
- Links between notes don't work - Support - Joplin Forum (joplinapp.org)
- Resource ID not provided error when click link with markdown pane closed · Issue #4891 · laurent22/joplin (github.com)
Hello, devs!
while working on the issue( stated above ), I found the following reasons behind it :
-
The issue is solely with the joplin/contextMenu.ts at dev · laurent22/joplin (github.com) file. The whole file is written assuming that the selected link is a
Resourcelink and not aNote. When right-clicking on the link( only the note-links ) and select open, theonActionfunction directly calls theResourceEditWatcher.instance().openAndWatch(options.resourceId);. Now, in thepackages/lib/services/ResourceEditWatcher/index.ts( joplin/index.ts at ebf92605aeabbd686d57952ab6b946d2db8dcf27 · laurent22/joplin · GitHub ), it callsResource.load(resourceId)although it is not a resource id, and what happens is that the SQL command inpackages/lib/BaseModel.ts( joplin/BaseModel.ts at ebf92605aeabbd686d57952ab6b946d2db8dcf27 · laurent22/joplin · GitHub ) tries to find the given note-id in theresources( As returned by theResource.tableName()) table. Definitely,sqlite3doesn't find any resource with that id (note-id) in theresourcestable, so finally, the item returned byResource.load(resourceId)is undefined. In the next line,undefinedgets passed toResource.isReady()which ultimately leads to callingResourcce.localState()and it throws theResource ID not providedError. -
On the other hand, if you
ctrl+clickon the link, the control goes touseMassegeHandler.tswhich efficiently handles it by callingconst item = await BaseItem.loadItemById(itemId);first. Then it checks if it is a resource or a note. That's why thectrl+clickworks whereasright-click+opendo not.
So, I posted it in the forum because :
- It is given a high-priority label.
- It looks like the whole
contextMenu.tsneeds to be updated which would be a kind of breaking change and can affect many things. Also, it might lead to a change of around 50 lines of code.
Any comments/suggestions/opinions on it (like how to fix it or even if it is worth fixing as it has a workaround using ctrl+click ) from any dev are highly appreciated.