@worktile/theia 20.1.0-next.4 → 20.1.0-next.6

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.
@@ -10,7 +10,7 @@ import { cloneDeep, map, assign, defaults, groupBy, uniq, isEqual } from 'lodash
10
10
  export { assign, cloneDeep, debounce, defaults, groupBy, isEqual, map, uniq } from 'lodash';
11
11
  import { Editor, Element, Span, Range, Path, Node, Point, Text, Transforms, Operation, createEditor } from 'slate';
12
12
  import * as i4 from 'slate-angular';
13
- import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData, BaseElementComponent, IS_SAFARI, ELEMENT_TO_COMPONENT, SlateModule, getBlockCardByNativeElement, SLATE_BLOCK_CARD_CLASS_NAME, BaseElementFlavour, hasBlockCard, isCardLeft, DefaultTextFlavour, defaultScrollSelectionIntoView, getDataTransferClipboard, JUST_NOW_UPDATED_VIRTUAL_VIEW, SLATE_DEBUG_KEY, withAngular } from 'slate-angular';
13
+ import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData, BaseElementComponent, IS_SAFARI, ELEMENT_TO_COMPONENT, SlateModule, getBlockCardByNativeElement, SLATE_BLOCK_CARD_CLASS_NAME, BaseElementFlavour, hasBlockCard, isCardLeft, ELEMENT_KEY_TO_HEIGHTS, DefaultTextFlavour, defaultScrollSelectionIntoView, getDataTransferClipboard, JUST_NOW_UPDATED_VIRTUAL_VIEW, SLATE_DEBUG_KEY, withAngular } from 'slate-angular';
14
14
  import { HistoryEditor, withHistory } from 'slate-history';
15
15
  import { NODE_TO_PARENT, NODE_TO_INDEX, NODE_TO_ELEMENT, DOMEditor, EDITOR_TO_ELEMENT } from 'slate-dom';
16
16
  import { TheiaConverter } from '@atinc/selene';
@@ -14340,6 +14340,10 @@ class TheImage extends TheBaseElement {
14340
14340
  this.subscribeMouseUp();
14341
14341
  this.subscribeImageUploadingState();
14342
14342
  }
14343
+ afterViewInit() {
14344
+ super.afterViewInit();
14345
+ this.setImageMinHeight();
14346
+ }
14343
14347
  onContextChange() {
14344
14348
  super.onContextChange();
14345
14349
  if (this.initialized && !isMobileMode(this.editor)) {
@@ -14352,6 +14356,9 @@ class TheImage extends TheBaseElement {
14352
14356
  }
14353
14357
  }
14354
14358
  ngOnDestroy() {
14359
+ if (this.imageLoadedCacheHeightTimer) {
14360
+ clearTimeout(this.imageLoadedCacheHeightTimer);
14361
+ }
14355
14362
  this.uploadingSubscription.unsubscribe();
14356
14363
  this.theContextService.removeUploadFile(this.fileItem);
14357
14364
  if (this.uploading) {
@@ -14359,6 +14366,28 @@ class TheImage extends TheBaseElement {
14359
14366
  }
14360
14367
  super.ngOnDestroy();
14361
14368
  }
14369
+ cacheImageHeight(height) {
14370
+ const heights = ELEMENT_KEY_TO_HEIGHTS.get(this.editor);
14371
+ const key = AngularEditor.findKey(this.editor, this.element);
14372
+ heights.set(key.id, height);
14373
+ }
14374
+ setImageMinHeight() {
14375
+ const heights = ELEMENT_KEY_TO_HEIGHTS.get(this.editor);
14376
+ const key = AngularEditor.findKey(this.editor, this.element);
14377
+ if (heights && heights.get(key.id)) {
14378
+ const blockCard = getBlockCardByNativeElement(this.nativeElement);
14379
+ if (blockCard) {
14380
+ const style = getComputedStyle(blockCard);
14381
+ blockCard.style.minHeight = heights.get(key.id) - parseFloat(style.marginTop) - parseFloat(style.marginBottom) + 'px';
14382
+ }
14383
+ }
14384
+ }
14385
+ clearMinHeight() {
14386
+ const blockCard = getBlockCardByNativeElement(this.nativeElement);
14387
+ if (blockCard) {
14388
+ blockCard.style.minHeight = '';
14389
+ }
14390
+ }
14362
14391
  setImagePluginOptions() {
14363
14392
  this.imagePluginOptions = getPluginOptions(this.editor, PluginKeys.image);
14364
14393
  }
@@ -14511,6 +14540,7 @@ class TheImage extends TheBaseElement {
14511
14540
  width: this.imageEntry.width,
14512
14541
  height: this.imageEntry.height
14513
14542
  }, { at: this.selection });
14543
+ this.cacheImageHeight(this.getRealHeight());
14514
14544
  }
14515
14545
  }
14516
14546
  cancelUpload() {
@@ -14595,9 +14625,13 @@ class TheImage extends TheBaseElement {
14595
14625
  .withPositions([bottomPosition]);
14596
14626
  }
14597
14627
  imageLoaded(event) {
14628
+ this.clearMinHeight();
14598
14629
  const img = event.target;
14599
14630
  this.naturalWidth = img.naturalWidth;
14600
14631
  this.naturalHeight = img.naturalHeight;
14632
+ this.imageLoadedCacheHeightTimer = setTimeout(() => {
14633
+ this.cacheImageHeight(this.getRealHeight());
14634
+ }, 0);
14601
14635
  }
14602
14636
  imageError(event) {
14603
14637
  const img = event.target;