@worktile/theia 3.0.7 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -901,11 +901,12 @@
901
901
  function TheContextService(ngZone) {
902
902
  var _this = this;
903
903
  this.ngZone = ngZone;
904
- this.fileList = [];
904
+ this.uploadingFiles = [];
905
905
  this.paintFormatStatus = {
906
906
  isActive: false,
907
907
  marks: {}
908
908
  };
909
+ this.uploadingStatus$ = new rxjs.Subject();
909
910
  this.ngZone.runOutsideAngular(function () {
910
911
  _this.onMouseUp$ = rxjs.fromEvent(window, "mouseup");
911
912
  _this.onMouseMove$ = rxjs.fromEvent(window, "mousemove");
@@ -940,11 +941,11 @@
940
941
  var firstElementChild = this.getFirstElementChild();
941
942
  return 0.48 * firstElementChild.clientWidth;
942
943
  };
943
- TheContextService.prototype.setUploadFileList = function (file) {
944
- this.fileList.push(file);
944
+ TheContextService.prototype.addUploadingFiles = function (file) {
945
+ this.uploadingFiles.push(file);
945
946
  };
946
947
  TheContextService.prototype.removeUploadImage = function (file) {
947
- this.fileList.splice(this.fileList.findIndex(function (item) { return item.file === file; }), 1);
948
+ this.uploadingFiles.splice(this.uploadingFiles.findIndex(function (item) { return item.url === file.url; }), 1);
948
949
  };
949
950
  return TheContextService;
950
951
  }());
@@ -3099,6 +3100,7 @@
3099
3100
  var inputFile = document.createElement('input');
3100
3101
  inputFile.setAttribute('type', 'file');
3101
3102
  inputFile.setAttribute('accept', 'image/*');
3103
+ inputFile.setAttribute('multiple', 'true');
3102
3104
  inputFile.onchange = function (event) {
3103
3105
  ImageEditor.insertImages(editor, event.target.files);
3104
3106
  };
@@ -3115,10 +3117,7 @@
3115
3117
  var verify = ImageEditor.verifyImage(editor, image);
3116
3118
  if (verify) {
3117
3119
  var url = URL.createObjectURL(image);
3118
- contextService.setUploadFileList({
3119
- url: url,
3120
- file: image
3121
- });
3120
+ contextService.addUploadingFiles({ url: url, file: image });
3122
3121
  imageNodes.push({ type: exports.ElementKinds.image, url: url, children: [text] });
3123
3122
  }
3124
3123
  }
@@ -3290,9 +3289,9 @@
3290
3289
  var _this = this;
3291
3290
  var _a;
3292
3291
  this.layoutDefaultWidth = this.theContextService.layoutDefaultWidth();
3293
- this.file = (_a = this.theContextService.fileList.find(function (item) { return item.url === _this.element.url; })) === null || _a === void 0 ? void 0 : _a.file;
3294
- if (this.file && this.file instanceof File) {
3295
- this.uploadImage(this.file);
3292
+ this.fileItem = this.theContextService.uploadingFiles.find(function (item) { return item.url === _this.element.url; });
3293
+ if (((_a = this.fileItem) === null || _a === void 0 ? void 0 : _a.file) && this.fileItem.file instanceof File) {
3294
+ this.uploadImage(this.fileItem.file);
3296
3295
  }
3297
3296
  _super.prototype.ngOnInit.call(this);
3298
3297
  };
@@ -3317,16 +3316,19 @@
3317
3316
  this.mouseUpSubscription = this.theContextService.onMouseUp$.subscribe(function (e) { return _this.endDrag(e); });
3318
3317
  this.uploadingSubscription = this.imageUploaderService
3319
3318
  .getUploadingItems$()
3320
- .pipe(operators.map(function (fileUploadingItem) { return _this.file && fileUploadingItem.find(function (item) { return item.file === _this.file; }); }))
3319
+ .pipe(operators.map(function (fileUploadingItem) { var _a; return ((_a = _this.fileItem) === null || _a === void 0 ? void 0 : _a.file) && fileUploadingItem.find(function (item) { var _a; return item.file === ((_a = _this.fileItem) === null || _a === void 0 ? void 0 : _a.file); }); }))
3321
3320
  .subscribe(function (uploadingItem) {
3322
3321
  if (!uploadingItem || !uploadingItem.result) {
3323
3322
  return;
3324
3323
  }
3325
3324
  _this.percentage = uploadingItem.result.uploadFile.progress.percentage;
3326
- var _b = uploadingItem.result, status = _b.status, uploadFile = _b.uploadFile;
3327
- if (status === uploader.ThyUploadStatus.done && uploadFile.response && uploadFile.responseStatus === 200) {
3328
- _this.uploading = false;
3325
+ var status = uploadingItem.result.status;
3326
+ // 成功和失败都要上传结束
3327
+ if (status === uploader.ThyUploadStatus.done) {
3329
3328
  _this.uploadingSubscription.unsubscribe();
3329
+ _this.uploading = false;
3330
+ _this.theContextService.removeUploadImage(_this.fileItem);
3331
+ _this.theContextService.uploadingStatus$.next(false);
3330
3332
  }
3331
3333
  _this.cdr.detectChanges();
3332
3334
  });
@@ -3347,6 +3349,7 @@
3347
3349
  thumbUrl: this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(file))
3348
3350
  };
3349
3351
  this.uploading = true;
3352
+ this.theContextService.uploadingStatus$.next(true);
3350
3353
  return [4 /*yield*/, this.imageUploaderService.uploadFileHandle([file]).toPromise()];
3351
3354
  case 2:
3352
3355
  _c = __read.apply(void 0, [_d.sent(), 1]), uploadFileEntity = _c[0];
@@ -14004,6 +14007,7 @@
14004
14007
  _this.theOnSave = new i0.EventEmitter();
14005
14008
  _this.theOnDOMEvent = new i0.EventEmitter();
14006
14009
  _this.theEditorCreated = new i0.EventEmitter();
14010
+ _this.theUploadingStatus = new i0.EventEmitter(); // true 上传结束 false 上传中
14007
14011
  _this.autoScrollView = _.debounce(function (editor, scrollContainer) {
14008
14012
  return autoScrollViewHandle(editor, scrollContainer);
14009
14013
  }, 80);
@@ -14125,7 +14129,18 @@
14125
14129
  configurable: true
14126
14130
  });
14127
14131
  TheEditorComponent.prototype.ngOnInit = function () {
14132
+ var _this = this;
14128
14133
  this.initialize();
14134
+ this.theContextService.uploadingStatus$.subscribe(function (isUploading) {
14135
+ if (isUploading) {
14136
+ _this.theUploadingStatus.emit(true);
14137
+ }
14138
+ else {
14139
+ if (_this.theContextService.uploadingFiles.length === 0) {
14140
+ _this.theUploadingStatus.emit(false);
14141
+ }
14142
+ }
14143
+ });
14129
14144
  this.onErrorHandler();
14130
14145
  };
14131
14146
  TheEditorComponent.prototype.ngOnChanges = function (changes) {
@@ -14354,7 +14369,7 @@
14354
14369
  return TheEditorComponent;
14355
14370
  }(core.mixinUnsubscribe(core.MixinBase)));
14356
14371
  TheEditorComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheEditorComponent, deps: [{ token: TheContextService }, { token: i0__namespace.ViewContainerRef }, { token: i0__namespace.ElementRef }, { token: i0__namespace.NgZone }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
14357
- TheEditorComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheEditorComponent, selector: "the-editor, theEditor", inputs: { theOptions: "theOptions", thePlugins: "thePlugins", theGlobalToolbar: "theGlobalToolbar", theDecorate: "theDecorate", theOnError: "theOnError" }, outputs: { theOnSave: "theOnSave", theOnDOMEvent: "theOnDOMEvent", theEditorCreated: "theEditorCreated" }, host: { properties: { "class.the-editor-readonly": "theOptions?.readonly" }, classAttribute: "the-editor" }, providers: [
14372
+ TheEditorComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheEditorComponent, selector: "the-editor, theEditor", inputs: { theOptions: "theOptions", thePlugins: "thePlugins", theGlobalToolbar: "theGlobalToolbar", theDecorate: "theDecorate", theOnError: "theOnError" }, outputs: { theOnSave: "theOnSave", theOnDOMEvent: "theOnDOMEvent", theEditorCreated: "theEditorCreated", theUploadingStatus: "theUploadingStatus" }, host: { properties: { "class.the-editor-readonly": "theOptions?.readonly" }, classAttribute: "the-editor" }, providers: [
14358
14373
  TheContextService,
14359
14374
  TheColorSelectService,
14360
14375
  {
@@ -14399,6 +14414,8 @@
14399
14414
  type: i0.Output
14400
14415
  }], theEditorCreated: [{
14401
14416
  type: i0.Output
14417
+ }], theUploadingStatus: [{
14418
+ type: i0.Output
14402
14419
  }], templateInstance: [{
14403
14420
  type: i0.ViewChild,
14404
14421
  args: ['templateInstance', { static: true }]