Thanks for the great component, I am integrating it within Gollum in my fork and so far the results are awesome!
1.2.6
Browser: Chrome Version 68.0.3440.75 (Official Build) (64-bit)
OS: Ubuntu 18.04.1 LTS
I have added a new command to switch between markdown and wysiwyg mode:
toggleWysiwyg: TuiEditor.CommandManager.command(
'global', {
name: 'toggleWysiwyg',
keyMap: ['CTRL+ENTER', 'META+ENTER'],
exec(mde) {
if (mde.isWysiwygMode()) {
mde.changeMode('markdown', false);
}
else {
mde.changeMode('wysiwyg', false);
}
}
}
),
Then by pressing ctrl+enter I can switch to wysiwyg mode and see how it looks (or edit it), and by pressing the shortcut again it will go back to markdown mode (I am not using preview mode.)
The issue is that by issuing changeMode both editors either jump to the beginning or the end of the document (depending on passing isWithoutFocus with false/true.) I am guessing this is due to this line this.getCodeMirror().refresh(); at editor.js:629
I think the cursor should remain at the same place when switching between these two modes so you can seamlessly edit in both modes.
I am not sure if I am doing it wrong or there is a better workaround for it.
I came here to report exactly the same. You can see this happen on all the demo/example pages, even when clicking the "WYSIWYG" button in the lower bottom right corner of the editor. The whole page jumps to the top. This is currently a show-stopper for me to use this editor at all.
@existme @Connum I'm sorry for late reply. I think when change mode, codemirror should be refreshed. We need more investigation for stay position when change mode. If you have idea, please make a PR.
I stumbled over the same problems mentioned above where I cannot retain the caret position after switching modes. It sounds like 3.0 might address this issue. Can anyone confirm this? Unfortunately, this has to work for me if I want to keep using this long-term.
Most helpful comment
@existme @Connum I'm sorry for late reply. I think when change mode, codemirror should be refreshed. We need more investigation for stay position when change mode. If you have idea, please make a PR.