@worktile/theia 21.0.0 → 21.1.0

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.
@@ -14307,6 +14307,69 @@ const createHrPlugin = (locale) => createPluginFactory({
14307
14307
  }
14308
14308
  })();
14309
14309
 
14310
+ const getListTypes = () => {
14311
+ return [ElementKinds.bulletedList, ElementKinds.numberedList];
14312
+ };
14313
+
14314
+ const EDITOR_TO_IMAGE_TO_FLOATING_MAP = new WeakMap();
14315
+ const getImageWithFloatingMap = (editor) => {
14316
+ let imageWithFloatingMap = EDITOR_TO_IMAGE_TO_FLOATING_MAP.get(editor);
14317
+ if (!imageWithFloatingMap) {
14318
+ imageWithFloatingMap = new Map();
14319
+ EDITOR_TO_IMAGE_TO_FLOATING_MAP.set(editor, imageWithFloatingMap);
14320
+ }
14321
+ return imageWithFloatingMap;
14322
+ };
14323
+ const isFloatingElementByType = (element) => {
14324
+ return (element.type === ElementKinds.paragraph ||
14325
+ element.type === ElementKinds.blockquote ||
14326
+ isHeadingElement(element) ||
14327
+ getListTypes().includes(element.type));
14328
+ };
14329
+ const isImageWithFloating = (element) => {
14330
+ return element.layout === LayoutTypes.wrapLeft || element.layout === LayoutTypes.wrapRight;
14331
+ };
14332
+ const getFloatingElementsAndAccumulatedHeight = (editor, element, imageHeight) => {
14333
+ const index = editor.children.indexOf(element);
14334
+ let accumulatedHeight = 0;
14335
+ const floatingElements = [];
14336
+ for (let i = index + 1; i < editor.children.length; i++) {
14337
+ const child = editor.children[i];
14338
+ if (isFloatingElementByType(child) && accumulatedHeight <= imageHeight) {
14339
+ const currentHeight = getCachedHeightByElement(editor, child) || editor.getRoughHeight(child);
14340
+ accumulatedHeight += currentHeight;
14341
+ floatingElements.push(child);
14342
+ }
14343
+ else {
14344
+ break;
14345
+ }
14346
+ }
14347
+ return [floatingElements, accumulatedHeight];
14348
+ };
14349
+ const calcFloatingElements = (editor, element, imageHeight) => {
14350
+ const imageWithFloatingMap = getImageWithFloatingMap(editor);
14351
+ if (isImageWithFloating(element)) {
14352
+ const [floatingElements, accumulatedHeight] = getFloatingElementsAndAccumulatedHeight(editor, element, imageHeight);
14353
+ if (accumulatedHeight > 0 && floatingElements.length > 0) {
14354
+ const value = {};
14355
+ floatingElements.forEach(ele => (value[ele.key] = true));
14356
+ imageWithFloatingMap.set(element.key, value);
14357
+ return [floatingElements, accumulatedHeight];
14358
+ }
14359
+ }
14360
+ else {
14361
+ imageWithFloatingMap.delete(element.key);
14362
+ }
14363
+ return [[], 0];
14364
+ };
14365
+ const isFloatingElement = (editor, element) => {
14366
+ const imageWithFloatingMap = getImageWithFloatingMap(editor);
14367
+ for (const [, value] of imageWithFloatingMap) {
14368
+ return !!value[element.key];
14369
+ }
14370
+ return false;
14371
+ };
14372
+
14310
14373
  class TheImage extends TheBaseElement {
14311
14374
  get isOpen() {
14312
14375
  return this.layoutToolbarRef && this.layoutToolbarRef.getOverlayRef() && this.layoutToolbarRef.getOverlayRef().hasAttached();
@@ -14376,7 +14439,7 @@ class TheImage extends TheBaseElement {
14376
14439
  handle: (e) => this.onDelete(e)
14377
14440
  }
14378
14441
  ];
14379
- this.dragable = false;
14442
+ this.draggable = false;
14380
14443
  this.beforeContextChange = (value) => {
14381
14444
  if (value.element !== this.element && value.element.thumbUrl) {
14382
14445
  let thumbUrl = value.element.thumbUrl;
@@ -14551,7 +14614,7 @@ class TheImage extends TheBaseElement {
14551
14614
  }
14552
14615
  event.preventDefault();
14553
14616
  event.stopPropagation();
14554
- this.dragable = true;
14617
+ this.draggable = true;
14555
14618
  const imgElement = this.img.nativeElement;
14556
14619
  const options = {
14557
14620
  axis,
@@ -14564,7 +14627,7 @@ class TheImage extends TheBaseElement {
14564
14627
  this.mouseMoveSubscription = this.theContextService.onMouseMove$.subscribe(e => this.mouseMoveHandle(e, options));
14565
14628
  }
14566
14629
  mouseMoveHandle(event, options) {
14567
- if (this.dragable) {
14630
+ if (this.draggable) {
14568
14631
  const { axis, printerPositionX, printerPositionY, internalWidth, internalHeight, maxWidth } = options;
14569
14632
  const isReversal = axis.includes('-');
14570
14633
  let offsetX = event.pageX - printerPositionX;
@@ -14616,8 +14679,8 @@ class TheImage extends TheBaseElement {
14616
14679
  }
14617
14680
  }
14618
14681
  endDrag(event) {
14619
- if (this.dragable) {
14620
- this.dragable = false;
14682
+ if (this.draggable) {
14683
+ this.draggable = false;
14621
14684
  this.mouseMoveSubscription.unsubscribe();
14622
14685
  if (this.imageEntry.width === this.theContextService.getOptions().width &&
14623
14686
  this.imageEntry.width <= this.naturalWidth &&
@@ -14770,6 +14833,14 @@ class TheImage extends TheBaseElement {
14770
14833
  });
14771
14834
  }
14772
14835
  }
14836
+ calcHeight() {
14837
+ const height = super.calcHeight();
14838
+ const [, accumulatedHeight] = calcFloatingElements(this.editor, this.element, height);
14839
+ if (accumulatedHeight > height) {
14840
+ return accumulatedHeight;
14841
+ }
14842
+ return height;
14843
+ }
14773
14844
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: TheImage, deps: [{ token: i0.ChangeDetectorRef }, { token: i1$1.ThyImageGroup }, { token: THE_IMAGE_SERVICE_TOKEN }, { token: TheContextService }, { token: i1.ThyPopover }, { token: i2.Overlay }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component }); }
14774
14845
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.6", type: TheImage, isStandalone: true, selector: "the-image, [theImage]", providers: [ThyImageService], viewQueries: [{ propertyName: "imageContent", first: true, predicate: ["imageContent"], descendants: true }, { propertyName: "img", first: true, predicate: ["img"], descendants: true }, { propertyName: "layoutToolbar", first: true, predicate: ["layoutToolbar"], descendants: true, static: true }, { propertyName: "imageDirective", first: true, predicate: ThyImageDirective, descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"the-image-container\" contenteditable=\"false\" [style.textAlign]=\"imageEntry.align\">\n @if (imageEntry.thumbUrl) {\n <div #imageContent class=\"image-content\" contenteditable=\"false\" [class.cursor-pointer]=\"!selection\">\n <img\n #img\n thyImage\n class=\"main-image\"\n [class.image-collapsed]=\"selection && !uploading\"\n [ngStyle]=\"{ 'width.px': imageBindingWidth }\"\n [alt]=\"imageEntry.name\"\n [thySrc]=\"imageEntry.thumbUrl\"\n [thyPreviewSrc]=\"imageEntry.thumbUrl\"\n [thyOriginSrc]=\"imageEntry.originUrl\"\n [thyDisablePreview]=\"disablePreview\"\n [thyImageMeta]=\"{ name: imageEntry.name, size: imageEntry.size }\"\n (load)=\"imageLoaded($event)\"\n (mousedown)=\"preventDefault($event)\"\n (error)=\"imageError($event)\"\n (click)=\"imageClick($event)\"\n />\n @if (isCollapsedAndNonReadonly) {\n <div class=\"image-profile\" [class.outline]=\"selection\">\n @if (!loadImageError) {\n <span (mousedown)=\"startDrag($event, '-xl')\" class=\"image-pointer left top\"></span>\n <span (mousedown)=\"startDrag($event, 'xl')\" class=\"image-pointer right top\"></span>\n <span (mousedown)=\"startDrag($event, 'xl')\" class=\"image-pointer right bottom\"></span>\n <span (mousedown)=\"startDrag($event, '-xl')\" class=\"image-pointer left bottom\"></span>\n }\n </div>\n }\n <ng-template [ngTemplateOutlet]=\"imageUploading\"></ng-template>\n @if (!uploading) {\n <div class=\"layer\" [class.readonly]=\"readonly\"></div>\n }\n </div>\n } @else {\n @if (!imageEntry.thumbUrl) {\n <div class=\"image-loading cursor-pointer\" contenteditable=\"false\">\n <thy-icon thyIconName=\"image\"></thy-icon>\n </div>\n }\n <ng-template [ngTemplateOutlet]=\"imageUploading\"></ng-template>\n }\n</div>\n\n<ng-template #layoutToolbar>\n <thy-actions thySize=\"xxs\">\n @for (item of layoutOptions; track $index) {\n @if (item.key !== 'split') {\n <a\n href=\"javascript:;\"\n thyAction\n [thyType]=\"item.key === 'remove' ? 'danger' : 'primary'\"\n [thyActionIcon]=\"item.icon\"\n [thyActionActive]=\"layoutActive(item.key)\"\n [thyTooltip]=\"item.name\"\n thyTooltipPlacement=\"top\"\n (mousedown)=\"item?.handle($event, item.key)\"\n ></a>\n }\n @if (item.key === 'split') {\n <thy-divider class=\"mr-2 ml-1 align-self-center\" [thyVertical]=\"true\" thyColor=\"light\"></thy-divider>\n }\n }\n </thy-actions>\n</ng-template>\n\n<ng-template #imageUploading>\n @if (uploading) {\n <div class=\"uploading\">\n <div class=\"uploading-percentage\">\n <thy-progress thyType=\"primary\" [thyValue]=\"percentage\" thySize=\"sm\"></thy-progress>\n <thy-icon (click)=\"cancelUpload($event)\" thyIconName=\"close-circle-bold-fill\" thyIconLegging=\"true\"> </thy-icon>\n </div>\n </div>\n }\n</ng-template>\n", dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: ThyImageDirective, selector: "img[thyImage]", inputs: ["thySrc", "thyPreviewSrc", "thyOriginSrc", "thyImageMeta", "thyDisablePreview", "thyResolveSize"], exportAs: ["thyImage"] }, { kind: "component", type: ThyAction, selector: "thy-action, [thyAction]", inputs: ["thyType", "thyIcon", "thyActionIcon", "thyActive", "thyActionActive", "thyTheme", "thyHoverIcon", "thyDisabled"] }, { kind: "component", type: ThyDivider, selector: "thy-divider", inputs: ["thyVertical", "thyStyle", "thyColor", "thyText", "thyTextDirection", "thyDeeper"] }, { kind: "component", type: ThyActions, selector: "thy-actions", inputs: ["thySize"] }, { kind: "directive", type: ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }, { kind: "component", type: ThyProgress, selector: "thy-progress", inputs: ["thyType", "thySize", "thyValue", "thyMax", "thyTips", "thyShape", "thyGapDegree", "thyGapPosition", "thyStrokeWidth"] }] }); }
14775
14846
  }
@@ -14793,8 +14864,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
14793
14864
  args: [ThyImageDirective]
14794
14865
  }] } });
14795
14866
 
14867
+ const withFloating = (editor) => {
14868
+ const { isFloating } = editor;
14869
+ editor.isFloating = (element) => {
14870
+ if (isFloatingElement(editor, element)) {
14871
+ return true;
14872
+ }
14873
+ return isFloating(element);
14874
+ };
14875
+ return editor;
14876
+ };
14877
+
14796
14878
  const withImage = (editor) => {
14797
- const { customInsertFragmentData, isVoid, renderElement, isBlockCard, mousedown } = editor;
14879
+ const { customInsertFragmentData, isVoid, renderElement, isBlockCard, mousedown, getRoughHeight, isFloating } = editor;
14798
14880
  editor.isVoid = (element) => {
14799
14881
  return element.type === ElementKinds.image || isVoid(element);
14800
14882
  };
@@ -14844,7 +14926,13 @@ const withImage = (editor) => {
14844
14926
  }
14845
14927
  return isBlockCard(element);
14846
14928
  };
14847
- return editor;
14929
+ editor.getRoughHeight = (element) => {
14930
+ if (element.type === ElementKinds.image && isImageWithFloating(element)) {
14931
+ return 0;
14932
+ }
14933
+ return getRoughHeight(element);
14934
+ };
14935
+ return withFloating(editor);
14848
14936
  };
14849
14937
  const createImagePlugin = (locale) => createPluginFactory({
14850
14938
  key: PluginKeys.image,
@@ -15398,10 +15486,6 @@ const createLinkPlugin = (locale) => createPluginFactory({
15398
15486
  }
15399
15487
  })();
15400
15488
 
15401
- const getListTypes = () => {
15402
- return [ElementKinds.bulletedList, ElementKinds.numberedList];
15403
- };
15404
-
15405
15489
  const normalizeListItem = (editor, { nodeEntry }) => {
15406
15490
  const [listItemNode, listItemPath] = nodeEntry;
15407
15491
  const firstChildPath = listItemPath.concat([0]);