Resource ID not provided Error in Desktop TinyMCE editor

ref:

  1. Links between notes don't work - Support - Joplin Forum (joplinapp.org)
  2. 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 :

  1. 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 Resource link and not a Note. When right-clicking on the link( only the note-links ) and select open, the onAction function directly calls the ResourceEditWatcher.instance().openAndWatch(options.resourceId);. Now, in the packages/lib/services/ResourceEditWatcher/index.ts( joplin/index.ts at ebf92605aeabbd686d57952ab6b946d2db8dcf27 · laurent22/joplin · GitHub ), it calls Resource.load(resourceId) although it is not a resource id, and what happens is that the SQL command in packages/lib/BaseModel.ts( joplin/BaseModel.ts at ebf92605aeabbd686d57952ab6b946d2db8dcf27 · laurent22/joplin · GitHub ) tries to find the given note-id in the resources( As returned by the Resource.tableName() ) table. Definitely, sqlite3 doesn't find any resource with that id (note-id) in the resources table, so finally, the item returned by Resource.load(resourceId) is undefined. In the next line, undefined gets passed to Resource.isReady() which ultimately leads to calling Resourcce.localState() and it throws the Resource ID not provided Error.

  2. On the other hand, if you ctrl+click on the link, the control goes to useMassegeHandler.ts which efficiently handles it by calling const item = await BaseItem.loadItemById(itemId); first. Then it checks if it is a resource or a note. That's why the ctrl+click works whereas right-click+open do not.

So, I posted it in the forum because :

  1. It is given a high-priority label.
  2. It looks like the whole contextMenu.ts needs 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.

4 Likes

Hi @Subhra264 Thanks for identifying the underlying issue.
I would say it's definitely worth fixing and extending the contextMenu to support internal links. If you're planning on working on this fix yourself, I would recommend that you initial try to implement the smallest fix that solves this bug first. And after you have a very clear idea on what the fix is, then you can start planning what changes would be needed to make the entire module more robust. At that stage it will be easier for the devs to get involved and make recommendations.

2 Likes

Thanks for replying

Sure, will try...

1 Like

@Subhra264, did you manage to use the Desktop TinyMCE Editor with Joplin?
I am looking for a way to get full HTML support in Joplin (ex: easily pasting HTML formatted text) but haven't found a satisfying solution so far. Markdown is just too limited for my usage!