zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.2k stars 1.9k forks source link

No NoteContextAwareWidget events fire when a readonly note changes to editable via the "edit this note" button #2828

Closed antoniotejada closed 2 years ago

antoniotejada commented 2 years ago

Trilium Version

0.50.3

What operating system are you using?

Windows

What is your setup?

Local (no sync)

Operating System Version

Windows 10

Description

When a readonly note is temporarily changed to editable via the pen button, no NoteContextAwareWidget events are fired.

This is contrary to what happens if you toggle the readonly state by using the "Editable:" drop down, in that case an entitiesReloadedEvent is generated.

In addition, widgets that may rely on whether a note is rendered with a CKEditor (editable notes) or with raw html (readonly notes) may need that event to refresh the widget.

The Table of Contents Widget is one example of such widgets, the TOC navigation is done differently depending on whether the note is rendered with CKEditor or with raw html.

Right now this is being worked around in the TOC widget by checking the note type at TOC navigation time instead of at TOC generation time.

zadam commented 2 years ago

You can listen to this event like this:

https://github.com/zadam/trilium/blob/f705c432fd1dcea973413655ba9a1cbc082eb01a/src/public/app/widgets/note_detail.js#L298-L302