diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-09-17 19:37:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 19:37:38 +0300 |
commit | 0c34566aefc99cb0d59e60226a3bba841f05f481 (patch) | |
tree | 118844e09bbda941eb1d8daa7de87da1933a12e2 /client/components/main/editor.js | |
parent | 158ddadf543d1809b36866ea16af5f75cfc64360 (diff) | |
parent | f29d7daa1d687df535a7c6ac5c53cc6f067c44cb (diff) | |
download | wekan-0c34566aefc99cb0d59e60226a3bba841f05f481.tar.gz wekan-0c34566aefc99cb0d59e60226a3bba841f05f481.tar.bz2 wekan-0c34566aefc99cb0d59e60226a3bba841f05f481.zip |
Merge pull request #2717 from whowillcare/master
BugFix: in richer editor @ autocomplete doesn't really insert the username properly
Diffstat (limited to 'client/components/main/editor.js')
-rwxr-xr-x | client/components/main/editor.js | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 91403086..b1725227 100755 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -156,25 +156,45 @@ Template.editor.onRendered(() => { } return undefined; }; + let popupShown = false; inputs.each(function(idx, input) { mSummernotes[idx] = $(input).summernote({ placeholder, callbacks: { + onKeydown(e) { + if (popupShown) { + e.preventDefault(); + } + }, + onKeyup(e) { + if (popupShown) { + e.preventDefault(); + } + }, onInit(object) { const originalInput = this; + const setAutocomplete = function(jEditor) { + if (jEditor !== undefined) { + jEditor.escapeableTextComplete(mentions).on({ + 'textComplete:show'() { + popupShown = true; + }, + 'textComplete:hide'() { + popupShown = false; + }, + }); + } + }; $(originalInput).on('submitted', function() { // resetCommentInput has been called if (!this.value) { const sn = getSummernote(this); - sn && sn.summernote('reset'); - object && object.editingArea.find('.note-placeholder').show(); + sn && sn.summernote('code', ''); } }); const jEditor = object && object.editable; const toolbar = object && object.toolbar; - if (jEditor !== undefined) { - jEditor.escapeableTextComplete(mentions); - } + setAutocomplete(jEditor); if (toolbar !== undefined) { const fBtn = toolbar.find('.btn-fullscreen'); fBtn.on('click', function() { @@ -264,7 +284,7 @@ Template.editor.onRendered(() => { const someNote = getSummernote(object); const original = someNote.summernote('code'); const cleaned = cleanPastedHTML(original); //this is where to call whatever clean function you want. I have mine in a different file, called CleanPastedHTML. - someNote.summernote('reset'); //clear original + someNote.summernote('code', ''); //clear original someNote.summernote('pasteHTML', cleaned); //this sets the displayed content editor to the cleaned pasted code. }; setTimeout(function() { |