fix rce image insertion when editing html

fixes CORE-1625

test plan:
- edit a wiki page
- switch to html editor
- upload multiple images from the sidebar
- multiple uploads should work

Change-Id: Iad9759ce73b7c2fd1ccd136269d4bd3fc2c99a60
Reviewed-on: https://gerrit.instructure.com/157401
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
This commit is contained in:
Brent Burgoyne 2018-07-14 00:30:26 -06:00
parent 6079689a45
commit 666a09b6de
2 changed files with 10 additions and 2 deletions

View File

@ -99,9 +99,9 @@ export default class RCEWrapper extends React.Component {
insertImage(image) {
const editor = this.mceInstance();
const element = contentInsertion.insertImage(editor, image);
if (element.complete) {
if (element && element.complete) {
this.contentInserted(element);
} else {
} else if (element) {
element.onload = () => this.contentInserted(element);
element.onerror = () => this.checkImageLoadError(element);
}

View File

@ -248,6 +248,14 @@ describe("RCEWrapper", () => {
contentInsertion.insertLink.restore();
});
describe("insert image", () => {
it("works when no element is returned from content insertion", () => {
sinon.stub(contentInsertion, "insertImage").returns(null);
instance.insertImage({});
contentInsertion.insertImage.restore();
})
})
describe("indicator", () => {
it("does not indicate() if editor is hidden", () => {
let indicateDefaultStub = sinon.stub(indicateModule, "default");