TriliumNext / Notes

Build your personal knowledge base with TriliumNext Notes
GNU Affero General Public License v3.0
684 stars 33 forks source link

(Bug report) "Create and link new note" context menu moves the link to beginning of parent note #406

Open diyoyo opened 1 week ago

diyoyo commented 1 week ago

TriliumNext Version

0.90.4

What operating system are you using?

macOS

What is your setup?

Local + server sync

Operating System Version

macOS latest + server on Debian 12

Description

I had described this bug and gave up on it a long time ago in the original zadam github repo. Just realized it still exists, so maybe it's time for a repost.

Basically, when using the @ followed by a new note, and then hitting Enter instead of using the mouse to click on the context menu button 'Create and link', then the link is moved to top of note.

Here are some screenshots of it.

Error logs

No response

eliandoran commented 1 week ago

Huh, that's crazy.

On my side the issue is only reproducible if I press enter to trigger the modal, but click on the new note type. Pressing enter to confirm the dialog does not cause the issue. I will look into it.

JYC333 commented 1 week ago

For me it happens when I create a new note with @ from template, also when using enter to select "Create and link". For a text note it won't jump to the beginning of the current note, and other default notes I didn't try.

alexpietsch commented 1 week ago

I was debugging this for a few hours now, but couldn't find anything. It could be a bug with CKEditor, but I have no idea right now.

eliandoran commented 1 week ago

@alexpietsch , I looked a bit into the issue on my side and it's a really tough one.

The issue appears to be in the CKEditor indeed, but not in the upstream implementation but in our injection of the link. Here are my short notes on this subject:

Most likely culprit is that the range is lost in ckeditor plugin in packages\ckeditor5-build-balloon-block\src\mention_customization.js, where there is a dedicated check for the range:

const range = options.range || selection.getFirstRange();