mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +08:00
Fix error handling for tinymce [SCI-7127]
This commit is contained in:
parent
17d69131f3
commit
5f21c06b26
1 changed files with 13 additions and 14 deletions
|
|
@ -88,17 +88,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
characterCount() {
|
characterCount() {
|
||||||
if(this.error) {
|
if (this.editorInstance()) {
|
||||||
this.editorInstance.blurDisabled = true;
|
this.editorInstance().blurDisabled = this.error != false ;
|
||||||
} else {
|
|
||||||
this.editorInstance.blurDisabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
editorInstance() {
|
|
||||||
return tinyMCE.editors[0];
|
|
||||||
},
|
|
||||||
error() {
|
error() {
|
||||||
if(this.characterLimit && this.characterCount > this.characterLimit) {
|
if(this.characterLimit && this.characterCount > this.characterLimit) {
|
||||||
return(
|
return(
|
||||||
|
|
@ -124,11 +119,13 @@
|
||||||
initTinymce(e) {
|
initTinymce(e) {
|
||||||
let textArea = `#${this.objectType}_textarea_${this.objectId}`;
|
let textArea = `#${this.objectType}_textarea_${this.objectId}`;
|
||||||
|
|
||||||
|
if (this.active) return
|
||||||
if (e && $(e.target).hasClass('atwho-user-popover')) return
|
if (e && $(e.target).hasClass('atwho-user-popover')) return
|
||||||
if (e && $(e.target).hasClass('record-info-link')) return
|
if (e && $(e.target).hasClass('record-info-link')) return
|
||||||
if (e && $(e.target).parent().hasClass('atwho-inserted')) return
|
if (e && $(e.target).parent().hasClass('atwho-inserted')) return
|
||||||
|
|
||||||
TinyMCE.init(textArea, (data) => {
|
TinyMCE.init(textArea, (data) => {
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
this.$emit('update', data)
|
this.$emit('update', data)
|
||||||
}
|
}
|
||||||
|
|
@ -136,27 +133,29 @@
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.initCharacterCount();
|
this.initCharacterCount();
|
||||||
|
this.$emit('editingEnabled');
|
||||||
});
|
});
|
||||||
this.$emit('editingEnabled')
|
|
||||||
},
|
},
|
||||||
getStaticUrl(name) {
|
getStaticUrl(name) {
|
||||||
return $(`meta[name=\'${name}\']`).attr('content');
|
return $(`meta[name=\'${name}\']`).attr('content');
|
||||||
},
|
},
|
||||||
initCharacterCount() {
|
initCharacterCount() {
|
||||||
if (!this.editorInstance) return;
|
if (!this.editorInstance()) return;
|
||||||
|
|
||||||
this.characterCount = $(this.editorInstance.getContent()).text().length
|
this.characterCount = $(this.editorInstance().getContent()).text().length;
|
||||||
|
this.editorInstance().on('input change paste keydown', (e) => {
|
||||||
this.editorInstance.on('input change paste keydown', (e) => {
|
|
||||||
e.currentTarget && (this.characterCount = (e.currentTarget).innerText.length);
|
e.currentTarget && (this.characterCount = (e.currentTarget).innerText.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editorInstance.on('remove', () => this.active = false)
|
this.editorInstance().on('remove', () => this.active = false);
|
||||||
|
|
||||||
// clear error on cancel
|
// clear error on cancel
|
||||||
$(this.editorInstance.container).find('.tinymce-cancel-button').on('click', ()=> {
|
$(this.editorInstance().container).find('.tinymce-cancel-button').on('click', ()=> {
|
||||||
this.characterCount = 0;
|
this.characterCount = 0;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
editorInstance() {
|
||||||
|
return tinyMCE.editors[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue