You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the cursor range is collapsed in the demo, clicking on Bold or Italic buttons does not work (presumably because the focus from the text area is lost). On the other hand, shortcuts like Ctrl+B and Ctrl+I still work as expected in this case, which creates inconsistencies between those two ways of modyfing the markup.
In my code, I use an ugly hack of reverting the editState to make toolbar buttons behave the same as the keyboard shortcuts:
Obviously, the ideal API would be such that just the line editor.toggleMarkup(markupTagName); and perhaps this.$('.content-kit-editor').focus(); would do the job. I didn't look deeply into the code, do you think this change would be simple?
The text was updated successfully, but these errors were encountered:
@fbarl Thanks for raising this. The mouseup handler here is re-setting the editor's state by reading it from DOM in a new frame of JavaScript after the button's action (editor.toggleMarkup(markupName)) has settled. The fix is likely to make the mouseup handler a bit smarter about not resetting the active markups if the editor's range hasn't actually changed. I will look into this.
Ensures that we refocus the editor element after `toggleMarkup`.
Clicking a button can cause the button to become focused (e.g.
`document.activeElement === buttonElement`) but the window's
`getSelection` is still in the editor.
When the selection is in the editor but it is not focused, key
up/down/press events don't fire on it. Since it has the selection,
typing causes the browser to mutate the editor element's dom and bypass
the key* event handlers. In addition to being generally unwanted, this has the
downside that the mutation will insert text to match its surrounding
style, so the `toggleMarkup` ends up having no effect.
After this change, it is possible to click e.g. the "bold" button when
the selection is collapsed, and the next characters typed will be bold,
as expected.
When the cursor range is collapsed in the demo, clicking on
Bold
orItalic
buttons does not work (presumably because the focus from the text area is lost). On the other hand, shortcuts likeCtrl+B
andCtrl+I
still work as expected in this case, which creates inconsistencies between those two ways of modyfing the markup.In my code, I use an ugly hack of reverting the
editState
to make toolbar buttons behave the same as the keyboard shortcuts:Obviously, the ideal API would be such that just the line
editor.toggleMarkup(markupTagName);
and perhapsthis.$('.content-kit-editor').focus();
would do the job. I didn't look deeply into the code, do you think this change would be simple?The text was updated successfully, but these errors were encountered: