compose: Fix bug in undo operation

This fixes compose.test_video_link_compose_clicked to just
use a stub for compose_ui.insert_syntax_and_focus.

It also adds direct tests for compose_ui.insert_syntax_and_focus.

Fixes #6362
This commit is contained in:
Steve Howell
2017-12-08 07:17:20 -08:00
parent e5c05f128a
commit 36ade63d84
3 changed files with 41 additions and 7 deletions

View File

@@ -27,8 +27,15 @@ exports.smart_insert = function (textarea, syntax) {
}
}
textarea.caret(syntax);
textarea.focus();
// We prefer to use insertText, which supports things like undo better
// for rich-text editing features like inserting links. But we fall
// back to textarea.caret if the browser doesn't support insertText.
if (!document.execCommand("insertText", false, syntax)) {
textarea.caret(syntax);
}
// This should just call exports.autosize_textarea, but it's a bit
// annoying for the unit tests, so we don't do that.
textarea.trigger("autosize.resize");