|
@@ -42,16 +42,7 @@
|
|
let pos = getCaretPos();
|
|
let pos = getCaretPos();
|
|
if(pos) {
|
|
if(pos) {
|
|
index = -1;
|
|
index = -1;
|
|
- let rawOptions = $(_input).closest('[data-shortcuts]').attr('data-shortcuts');
|
|
|
|
- options = [];
|
|
|
|
- rawOptions = rawOptions.split('^^^');
|
|
|
|
- for (let i = 0; i < rawOptions.length; i++) {
|
|
|
|
- let parts = rawOptions[i].split('|||');
|
|
|
|
- options.push({
|
|
|
|
- name: parts[0],
|
|
|
|
- value: parts[1]
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ options = window.userShortcuts;
|
|
menu.empty();
|
|
menu.empty();
|
|
for(let i = 0; i < options.length; i++) {
|
|
for(let i = 0; i < options.length; i++) {
|
|
menu.append(
|
|
menu.append(
|
|
@@ -212,10 +203,10 @@
|
|
if(!this.checkValidity()) return false;
|
|
if(!this.checkValidity()) return false;
|
|
$.post('/api/proTextShortcut/create', $(this).serialize(), function(_data) {
|
|
$.post('/api/proTextShortcut/create', $(this).serialize(), function(_data) {
|
|
if(_data && _data.success && input) {
|
|
if(_data && _data.success && input) {
|
|
- var options = [$(input).closest('[data-shortcuts]').attr('data-shortcuts')]
|
|
|
|
- options.push(label + '|||' + content);
|
|
|
|
- options = options.join('^^^');
|
|
|
|
- $(input).closest('[data-shortcuts]').attr('data-shortcuts', options);
|
|
|
|
|
|
+ window.userShortcuts.push({
|
|
|
|
+ name: label,
|
|
|
|
+ value: content
|
|
|
|
+ });
|
|
toastr.success('Shortcut saved');
|
|
toastr.success('Shortcut saved');
|
|
hideMoeFormMask();
|
|
hideMoeFormMask();
|
|
$('#create-shortcut-form').hide();
|
|
$('#create-shortcut-form').hide();
|