@@ -100,9 +100,7 @@ export default {
100
100
url: this .$panel .urls .api + " /" + this .endpoints .field + " /upload" ,
101
101
multiple: false ,
102
102
on: {
103
- cancel: async () => {
104
- await this .restoreSelection (selectionRange);
105
- },
103
+ cancel: async () => await this .restoreSelection (selectionRange),
106
104
done: async (files ) => {
107
105
await this .restoreSelection (selectionRange);
108
106
await this .insertUpload (files);
@@ -131,24 +129,25 @@ export default {
131
129
},
132
130
methods: {
133
131
dialog (dialog ) {
134
- const restoreSelection = this .restoreSelectionCallback ();
132
+ const selectionRange = this .selectionRange ();
135
133
136
134
this .$panel .dialog .open ({
137
135
component: " k-toolbar-" + dialog + " -dialog" ,
138
136
props: {
139
137
value: this .parseSelection ()
140
138
},
141
139
on: {
142
- cancel: restoreSelection,
143
- submit : (text ) => {
140
+ cancel: async () => await this . restoreSelection (selectionRange) ,
141
+ submit: async (text ) => {
144
142
this .$panel .dialog .close ();
145
- restoreSelection (() => this .insert (text));
143
+ await this .restoreSelection (selectionRange);
144
+ await this .insert (text);
146
145
}
147
146
}
148
147
});
149
148
},
150
149
file () {
151
- const restoreSelection = this .restoreSelectionCallback ();
150
+ const selectionRange = this .selectionRange ();
152
151
153
152
this .$panel .dialog .open ({
154
153
component: " k-files-dialog" ,
@@ -157,9 +156,10 @@ export default {
157
156
multiple: false
158
157
},
159
158
on: {
160
- cancel: restoreSelection,
161
- submit : (file ) => {
162
- restoreSelection (() => this .insertFile (file));
159
+ cancel: async () => await this .restoreSelection (selectionRange),
160
+ submit: async (file ) => {
161
+ await this .restoreSelection (selectionRange);
162
+ await this .insertFile (file);
163
163
this .$panel .dialog .close ();
164
164
}
165
165
}
@@ -176,9 +176,7 @@ export default {
176
176
text = text (this .$refs .input , this .selection ());
177
177
}
178
178
179
- await this .$nextTick ();
180
-
181
- input .focus ();
179
+ this .focus ();
182
180
183
181
// try first via execCommand as this will be considered
184
182
// as a user action and can be undone by the browser's
@@ -300,14 +298,16 @@ export default {
300
298
title: selection
301
299
};
302
300
},
303
- prepend (text ) {
304
- this .insert (text + " " + this .selection ());
301
+ async prepend (text ) {
302
+ await this .insert (text + " " + this .selection ());
305
303
},
306
304
async restoreSelection ({ start, end }) {
307
305
this .$refs .input .setSelectionRange (start, end);
308
-
309
306
return this .$nextTick ();
310
307
},
308
+ /**
309
+ * @deprecated 5.0.0 Use `restoreSelection` instead
310
+ */
311
311
restoreSelectionCallback () {
312
312
// store selection
313
313
const selectionRange = this .selectionRange ();
0 commit comments