Skip to content

Commit

Permalink
feat(image): 💫 show loading when image uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
Leecason committed Mar 28, 2020
1 parent 9791533 commit c915aea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/MenuCommands/Image/InsertImageCommandButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

<script lang="ts">
import { Component, Prop, Mixins } from 'vue-property-decorator';
import { Dialog, Upload, MessageBox, Popover } from 'element-ui';
import { Dialog, Upload, MessageBox, Popover, Loading } from 'element-ui';
import { HttpRequestOptions } from 'element-ui/types/upload';
import { MenuData } from 'tiptap';
import i18nMixin from '@/mixins/i18nMixin';
Expand Down Expand Up @@ -105,15 +105,19 @@ export default class ImageCommandButton extends Mixins(i18nMixin) {
const uploadRequest = this.imageNodeOptions.uploadRequest;
const loadingInstance = Loading.service({
target: '.el-tiptap-upload',
});
try {
this.uploading = true;
const url = await (uploadRequest ? uploadRequest(file) : readFileDataUrl(file));
this.editorContext.commands.image({ src: url });
this.imageUploadDialogVisible = false;
} catch (e) {
Logger.error(e);
} finally {
this.uploading = false;
this.$nextTick(() => {
loadingInstance.close();
});
}
}
};
Expand Down

0 comments on commit c915aea

Please sign in to comment.