Closed alFlash closed 2 years ago
@alFlash I just found the issue. The dropdown
variable was declared globally, which lead to both editor instances picking up the dropdown of the first editor. I’ve updated the example, it should work fine now.
@fabianmichael Thank you for your fast replay and work!!! Now it works. One little issue was not fixed: If the focus is on instance2 and you click directly the snippets button in instance1 the insert will done in instance2 .
THX so much.
Hi, was it not reproducable? THX
@alFlash I just don’t have any capacity … if this is very important to you, please open a separate ticket, so this does not get lost over time.
Ok. I understand. Any suggestions/ suppositions where I should begin to search? I suppose the button itself has to be inactive and only wake up at the first click without any other action.
@alFlash It’s kinda weird. The toolbar is usually initialized something like this:
Button
and Extension
classes.As far as I understand the code (in the end, I haven’t touched most of it in over a year), my only logical explanation would be that a non-focussed editor instance gets the wrong popup passed. Or maybe CodeMirror’s API sends the text to the wrong editor (the latter is unlikely). If you are willing to investigate this a bit, I’d be very happy. Maybe you are more successful than I was. :-)
@fabianmichael
Yes, its a focus problem. I solved it (for me). Don't know if it is clean, but it works:
I added
this.editor.focus();
before
this.editor.insert(value)
so, in every case the clicked editor has the focus.
Finally the options object look like this:
const dropdown = options.map(({ text: label, value }) => ({
label,
command: () =>{
this.editor.focus();
this.editor.insert(value);
}
}))
Thank you.
@alFlash Thanks for the hint, though I could not reproduce the error anymore. I just updated the example extension. Feels better when the editor focussed upon selecting a snippet from the menu, so is is also still a win for me.
I have 2 instances of a markdown-field. Both are equal and implements the snippets Extension from the examples. If I chose a snippet in the first editor, it is inserted to the second Instance.