File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,24 @@ export default {
98
98
insertAtCursor (text ) {
99
99
this .textarea .focus ();
100
100
101
- document .execCommand (" insertText" , false /* no UI*/ , text);
102
- this .content = this .textarea .value ;
101
+ const isSuccessful = document .execCommand (
102
+ " insertText" ,
103
+ false ,
104
+ text
105
+ );
106
+
107
+ // Firefox (non-standard method)
108
+ if (! isSuccessful && typeof input .setRangeText === " function" ) {
109
+ const start = input .selectionStart ;
110
+ input .setRangeText (text);
111
+ // update cursor to be at the end of insertion
112
+ input .selectionStart = input .selectionEnd = start + text .length ;
113
+
114
+ // Notify any possible listeners of the change
115
+ const e = document .createEvent (" UIEvent" );
116
+ e .initEvent (" input" , true , false );
117
+ input .dispatchEvent (e);
118
+ }
103
119
},
104
120
insertImage (placeholder , url ) {
105
121
this .content = this .content .replace (
You can’t perform that action at this time.
0 commit comments