|
226 | 226 | var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
|
227 | 227 | var insertButton = insertImageModal.find('a.btn-primary');
|
228 | 228 | var initialValue = urlInput.val();
|
| 229 | + var caretBookmark; |
229 | 230 |
|
230 | 231 | var insertImage = function() {
|
231 | 232 | var url = urlInput.val();
|
232 | 233 | urlInput.val(initialValue);
|
233 | 234 | self.editor.currentView.element.focus();
|
| 235 | + if (caretBookmark) { |
| 236 | + self.editor.composer.selection.setBookmark(caretBookmark); |
| 237 | + caretBookmark = null; |
| 238 | + } |
234 | 239 | self.editor.composer.commands.exec("insertImage", url);
|
235 | 240 | };
|
236 | 241 |
|
|
255 | 260 | var activeButton = $(this).hasClass("wysihtml5-command-active");
|
256 | 261 |
|
257 | 262 | if (!activeButton) {
|
| 263 | + self.editor.currentView.element.focus(false); |
| 264 | + caretBookmark = self.editor.composer.selection.getBookmark(); |
258 | 265 | insertImageModal.modal('show');
|
259 | 266 | insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
260 | 267 | e.stopPropagation();
|
|
273 | 280 | var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
|
274 | 281 | var insertButton = insertLinkModal.find('a.btn-primary');
|
275 | 282 | var initialValue = urlInput.val();
|
| 283 | + var caretBookmark; |
276 | 284 |
|
277 | 285 | var insertLink = function() {
|
278 | 286 | var url = urlInput.val();
|
279 | 287 | urlInput.val(initialValue);
|
280 | 288 | self.editor.currentView.element.focus();
|
| 289 | + if (caretBookmark) { |
| 290 | + self.editor.composer.selection.setBookmark(caretBookmark); |
| 291 | + caretBookmark = null; |
| 292 | + } |
281 | 293 | self.editor.composer.commands.exec("createLink", {
|
282 | 294 | href: url,
|
283 | 295 | target: "_blank",
|
|
307 | 319 | var activeButton = $(this).hasClass("wysihtml5-command-active");
|
308 | 320 |
|
309 | 321 | if (!activeButton) {
|
| 322 | + self.editor.currentView.element.focus(false); |
| 323 | + caretBookmark = self.editor.composer.selection.getBookmark(); |
310 | 324 | insertLinkModal.appendTo('body').modal('show');
|
311 | 325 | insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
312 | 326 | e.stopPropagation();
|
|
0 commit comments