@worktile/theia 21.0.0-next.2 → 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.
@@ -7147,12 +7147,7 @@ class TheCode extends TheBaseElement {
7147
7147
  onContextChange() {
7148
7148
  super.onContextChange();
7149
7149
  if (this.initialized) {
7150
- if (this.isCollapsedAndNonReadonly && !isMobileMode(this.editor)) {
7151
- this.openToolbar();
7152
- }
7153
- else {
7154
- this.closeToolbar();
7155
- }
7150
+ this.useToolbar();
7156
7151
  if (this.options().readonly !== this.readonly) {
7157
7152
  this.useReadonly();
7158
7153
  }
@@ -7197,6 +7192,10 @@ class TheCode extends TheBaseElement {
7197
7192
  }
7198
7193
  });
7199
7194
  });
7195
+ setTimeout(() => {
7196
+ this.useAutofocus();
7197
+ this.useToolbar();
7198
+ }, 0);
7200
7199
  }
7201
7200
  initMaxHeight() {
7202
7201
  this.maxHeight = isPrintMode(this.editor) ? 0 : CODEMIRROR_DEFAULT_MAX_HEIGHT - CODEMIRROR_PADDING_TOP * 2;
@@ -7230,7 +7229,6 @@ class TheCode extends TheBaseElement {
7230
7229
  this.useMode();
7231
7230
  this.useAutoWrap();
7232
7231
  this.useHeight();
7233
- this.useAutofocus();
7234
7232
  }
7235
7233
  codeChange($event) {
7236
7234
  this.isHightLight = false;
@@ -7259,7 +7257,6 @@ class TheCode extends TheBaseElement {
7259
7257
  useAutoWrap() {
7260
7258
  const isPrint = isPrintMode(this.editor);
7261
7259
  const lineWrapping = isPrint ? true : this.element.autoWrap || false;
7262
- console.log('options', { ...this.options(), lineWrapping });
7263
7260
  this.options.set({ ...this.options(), lineWrapping });
7264
7261
  }
7265
7262
  useHeight() {
@@ -7272,10 +7269,18 @@ class TheCode extends TheBaseElement {
7272
7269
  this.options.set({ ...this.options(), readonly: this.readonly, cursorBlinkRate: this.readonly ? -1 : 500 });
7273
7270
  }
7274
7271
  useAutofocus() {
7275
- if (this.isCollapsedAndNonReadonly && Range.isCollapsed(this.editor.selection)) {
7272
+ if (this.isCollapsedAndNonReadonly) {
7276
7273
  this.options.set({ ...this.options(), autofocus: this.readonly ? false : true });
7277
7274
  }
7278
7275
  }
7276
+ useToolbar() {
7277
+ if (this.isCollapsedAndNonReadonly && !isMobileMode(this.editor)) {
7278
+ this.openToolbar();
7279
+ }
7280
+ else {
7281
+ this.closeToolbar();
7282
+ }
7283
+ }
7279
7284
  onResize({ height }) {
7280
7285
  this.resizeHeight = height;
7281
7286
  this.maxHeight = height;
@@ -14302,6 +14307,69 @@ const createHrPlugin = (locale) => createPluginFactory({
14302
14307
  }
14303
14308
  })();
14304
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
+
14305
14373
  class TheImage extends TheBaseElement {
14306
14374
  get isOpen() {
14307
14375
  return this.layoutToolbarRef && this.layoutToolbarRef.getOverlayRef() && this.layoutToolbarRef.getOverlayRef().hasAttached();
@@ -14371,7 +14439,7 @@ class TheImage extends TheBaseElement {
14371
14439
  handle: (e) => this.onDelete(e)
14372
14440
  }
14373
14441
  ];
14374
- this.dragable = false;
14442
+ this.draggable = false;
14375
14443
  this.beforeContextChange = (value) => {
14376
14444
  if (value.element !== this.element && value.element.thumbUrl) {
14377
14445
  let thumbUrl = value.element.thumbUrl;
@@ -14546,7 +14614,7 @@ class TheImage extends TheBaseElement {
14546
14614
  }
14547
14615
  event.preventDefault();
14548
14616
  event.stopPropagation();
14549
- this.dragable = true;
14617
+ this.draggable = true;
14550
14618
  const imgElement = this.img.nativeElement;
14551
14619
  const options = {
14552
14620
  axis,
@@ -14559,7 +14627,7 @@ class TheImage extends TheBaseElement {
14559
14627
  this.mouseMoveSubscription = this.theContextService.onMouseMove$.subscribe(e => this.mouseMoveHandle(e, options));
14560
14628
  }
14561
14629
  mouseMoveHandle(event, options) {
14562
- if (this.dragable) {
14630
+ if (this.draggable) {
14563
14631
  const { axis, printerPositionX, printerPositionY, internalWidth, internalHeight, maxWidth } = options;
14564
14632
  const isReversal = axis.includes('-');
14565
14633
  let offsetX = event.pageX - printerPositionX;
@@ -14611,8 +14679,8 @@ class TheImage extends TheBaseElement {
14611
14679
  }
14612
14680
  }
14613
14681
  endDrag(event) {
14614
- if (this.dragable) {
14615
- this.dragable = false;
14682
+ if (this.draggable) {
14683
+ this.draggable = false;
14616
14684
  this.mouseMoveSubscription.unsubscribe();
14617
14685
  if (this.imageEntry.width === this.theContextService.getOptions().width &&
14618
14686
  this.imageEntry.width <= this.naturalWidth &&
@@ -14765,6 +14833,14 @@ class TheImage extends TheBaseElement {
14765
14833
  });
14766
14834
  }
14767
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
+ }
14768
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 }); }
14769
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"] }] }); }
14770
14846
  }
@@ -14788,8 +14864,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
14788
14864
  args: [ThyImageDirective]
14789
14865
  }] } });
14790
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
+
14791
14878
  const withImage = (editor) => {
14792
- const { customInsertFragmentData, isVoid, renderElement, isBlockCard, mousedown } = editor;
14879
+ const { customInsertFragmentData, isVoid, renderElement, isBlockCard, mousedown, getRoughHeight, isFloating } = editor;
14793
14880
  editor.isVoid = (element) => {
14794
14881
  return element.type === ElementKinds.image || isVoid(element);
14795
14882
  };
@@ -14839,7 +14926,13 @@ const withImage = (editor) => {
14839
14926
  }
14840
14927
  return isBlockCard(element);
14841
14928
  };
14842
- 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);
14843
14936
  };
14844
14937
  const createImagePlugin = (locale) => createPluginFactory({
14845
14938
  key: PluginKeys.image,
@@ -15393,10 +15486,6 @@ const createLinkPlugin = (locale) => createPluginFactory({
15393
15486
  }
15394
15487
  })();
15395
15488
 
15396
- const getListTypes = () => {
15397
- return [ElementKinds.bulletedList, ElementKinds.numberedList];
15398
- };
15399
-
15400
15489
  const normalizeListItem = (editor, { nodeEntry }) => {
15401
15490
  const [listItemNode, listItemPath] = nodeEntry;
15402
15491
  const firstChildPath = listItemPath.concat([0]);