@worktile/theia 14.3.12 → 14.3.13

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.
@@ -28,7 +28,7 @@ import { ThyDividerComponent, ThyDividerModule } from 'ngx-tethys/divider';
28
28
  import * as i2$2 from '@angular/cdk/scrolling';
29
29
  import { CdkScrollable, ScrollingModule } from '@angular/cdk/scrolling';
30
30
  import { mixinUnsubscribe, MixinBase, ScrollToService } from 'ngx-tethys/core';
31
- import { isKeyHotkey } from 'is-hotkey';
31
+ import { isKeyHotkey, isHotkey } from 'is-hotkey';
32
32
  import { Subject, fromEvent, timer, combineLatest, Observable, BehaviorSubject, merge, ReplaySubject } from 'rxjs';
33
33
  import { takeUntil, take, delay, map as map$1, skip, filter, debounceTime, startWith, distinctUntilChanged, share, mapTo, pairwise } from 'rxjs/operators';
34
34
  import * as i5 from 'ngx-tethys/input';
@@ -3147,7 +3147,8 @@ class TheContextService {
3147
3147
  rebindContainerScroll() {
3148
3148
  this.scrollSubscription?.unsubscribe();
3149
3149
  if (this.options.theOptions?.scrollContainer) {
3150
- const containerElement = this.options.nativeElement.closest(this.options.theOptions.scrollContainer);
3150
+ const containerElement = this.options.nativeElement.closest(this.options.theOptions.scrollContainer) ||
3151
+ this.options.nativeElement.querySelector(this.options.theOptions.scrollContainer);
3151
3152
  if (containerElement) {
3152
3153
  this.ngZone.runOutsideAngular(() => {
3153
3154
  this.scrollSubscription = fromEvent(containerElement, 'scroll').subscribe(event => {
@@ -11193,10 +11194,10 @@ function setCellMenuVisibility(editor, menuList, tableInfo) {
11193
11194
  item.visibility = selectCellNodes && selectCellNodes.length === 1 && isCellMerged;
11194
11195
  break;
11195
11196
  case 'delete-selection-rows':
11196
- item.visibility = !isFullscreen || !selectedColumnsIndex.length;
11197
+ item.visibility = !(isFullscreen && selectedColumnsIndex.length);
11197
11198
  break;
11198
11199
  case 'delete-selection-columns':
11199
- item.visibility = !isFullscreen || !selectedRowsIndex.length;
11200
+ item.visibility = !(isFullscreen && selectedRowsIndex.length);
11200
11201
  break;
11201
11202
  case 'delete-table':
11202
11203
  item.visibility = !isFullscreen;
@@ -11291,6 +11292,10 @@ class TableStore {
11291
11292
  this.isCellSelecting = false;
11292
11293
  this.isRightClicking = false;
11293
11294
  this.isModSelecting = false;
11295
+ this.isSelectedAllCell = () => {
11296
+ const pos = this.createTablePosition();
11297
+ return pos.getHeight() * pos.getWidth() === this.selectedCells.length;
11298
+ };
11294
11299
  }
11295
11300
  get selectedCells() {
11296
11301
  return this.selectedCells$.getValue();
@@ -12428,39 +12433,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
12428
12433
  args: [{ name: 'freezeRow' }]
12429
12434
  }] });
12430
12435
 
12431
- const getOsName = () => {
12432
- const userAgent = navigator.userAgent.toLowerCase();
12433
- let name = 'Unknown';
12434
- if (userAgent.indexOf('win') > -1) {
12435
- name = 'Windows';
12436
- }
12437
- else if (userAgent.indexOf('iphone') > -1) {
12438
- name = 'Iphone';
12439
- }
12440
- else if (userAgent.indexOf('mac') > -1) {
12441
- name = 'Mac';
12442
- }
12443
- else if (userAgent.indexOf('x11') > -1 ||
12444
- userAgent.indexOf('unix') > -1 ||
12445
- userAgent.indexOf('sunname') > -1 ||
12446
- userAgent.indexOf('bsd') > -1) {
12447
- name = 'Unix';
12448
- }
12449
- else if (userAgent.indexOf('linux') > -1) {
12450
- if (userAgent.indexOf('android') > -1) {
12451
- name = 'Android';
12452
- }
12453
- else {
12454
- name = 'Linux';
12455
- }
12456
- }
12457
- else {
12458
- name = 'Unknown';
12459
- }
12460
- return name;
12461
- };
12462
- const isMac = () => getOsName() === 'Mac';
12463
-
12464
12436
  const TABLE_SELECTOR = '.the-table';
12465
12437
  const TABLE_WRAPPER_SELECTOR = '.the-table-wrapper';
12466
12438
  const RESIZE_OVERLAY_SELECTOR = '.the-table-resize-overlay-thumb';
@@ -12645,7 +12617,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
12645
12617
  }] } });
12646
12618
 
12647
12619
  class TheTableComponent extends TheBaseElementComponent {
12648
- constructor(elementRef, eventDispatcher, resizeNotifier, tableStore, cdr, ngZone, tableService, theTableContextMenuService, freezeColumnPipe, freezeRowPipe, renderer) {
12620
+ constructor(elementRef, eventDispatcher, resizeNotifier, tableStore, cdr, ngZone, tableService, theTableContextMenuService, freezeColumnPipe, freezeRowPipe, renderer, contextService) {
12649
12621
  super(elementRef, cdr);
12650
12622
  this.eventDispatcher = eventDispatcher;
12651
12623
  this.resizeNotifier = resizeNotifier;
@@ -12657,10 +12629,13 @@ class TheTableComponent extends TheBaseElementComponent {
12657
12629
  this.freezeColumnPipe = freezeColumnPipe;
12658
12630
  this.freezeRowPipe = freezeRowPipe;
12659
12631
  this.renderer = renderer;
12632
+ this.contextService = contextService;
12660
12633
  this.headerRow = false;
12634
+ this.isSelectedAllCell = false;
12661
12635
  this.destroy$ = new Subject();
12662
12636
  this.rowControls = [];
12663
12637
  this.colControls = [];
12638
+ this.tableWrapperMarginTop = 0;
12664
12639
  }
12665
12640
  get columns() {
12666
12641
  return this.element && this.element.columns;
@@ -12671,10 +12646,6 @@ class TheTableComponent extends TheBaseElementComponent {
12671
12646
  get tbodyNativeElement() {
12672
12647
  return this.tbodyElement?.nativeElement;
12673
12648
  }
12674
- get isSelectedAllCell() {
12675
- return (this.tableStore.selectedRowsIndex.length === this.rowControls.length &&
12676
- this.tableStore.selectedColumnsIndex.length === this.colControls.length);
12677
- }
12678
12649
  handleMousedown(event) {
12679
12650
  if (event.target instanceof Element && this.tbodyNativeElement.contains(event.target)) {
12680
12651
  return;
@@ -12711,8 +12682,24 @@ class TheTableComponent extends TheBaseElementComponent {
12711
12682
  .pipe(takeUntil(this.destroy$))
12712
12683
  .subscribe(value => {
12713
12684
  this.tableStore.isFullscreen = value;
12685
+ if (this.tableStore.isFullscreen) {
12686
+ this.previousScrollContainer = this.editor.options.scrollContainer;
12687
+ this.editor.options.scrollContainer = '.the-editable-container';
12688
+ }
12689
+ else {
12690
+ this.editor.options.scrollContainer = this.previousScrollContainer;
12691
+ }
12692
+ this.isStickyTop = false;
12693
+ this.setHeaderRowStyle();
12694
+ this.contextService.rebindContainerScroll();
12714
12695
  });
12715
12696
  }
12697
+ this.tableStore
12698
+ .selectedCellsChange()
12699
+ .pipe(takeUntil(this.destroy$))
12700
+ .subscribe(() => {
12701
+ this.isSelectedAllCell = this.tableStore.isSelectedAllCell();
12702
+ });
12716
12703
  }
12717
12704
  getWrapperWidth() {
12718
12705
  const tableContainer = this.nativeElement.firstChild;
@@ -12769,40 +12756,25 @@ class TheTableComponent extends TheBaseElementComponent {
12769
12756
  });
12770
12757
  }
12771
12758
  subscribeScrollContainerScroll() {
12772
- if (this.scrollContainerRef) {
12773
- this.scrollContainerRef.unsubscribe();
12774
- this.scrollContainerRef = null;
12775
- }
12776
12759
  this.ngZone.runOutsideAngular(() => {
12777
- const scrollContainer = this.editor.options?.scrollContainer || DEFAULT_SCROLL_CONTAINER;
12778
- const scrollContainerElement = this.elementRef.nativeElement.closest(scrollContainer);
12779
- this.scrollContainerTop = scrollContainerElement.getBoundingClientRect().top;
12780
- const elementTop = this.elementRef.nativeElement.getBoundingClientRect().top;
12781
- this.scrollContainerRef = fromEvent(scrollContainerElement, 'scroll')
12782
- .pipe(takeUntil(this.destroy$), map$1(() => {
12783
- const distance = elementTop - this.scrollContainerTop;
12784
- const scrollTop = scrollContainerElement.scrollTop;
12785
- const buffer = this.isInTable ? 0 : 30;
12786
- const scrollHeight = scrollTop - (distance + buffer);
12787
- this.isStickyTop = scrollHeight > 0;
12760
+ this.contextService.containerScrolled$
12761
+ .pipe(takeUntil(this.destroy$), map$1(event => {
12762
+ this.scrollContainerTop = event.target.getBoundingClientRect().top;
12763
+ const clientRect = this.theTableElement.nativeElement.getBoundingClientRect();
12764
+ const headerTopHeight = this.isInTable ? -19 : 11;
12788
12765
  const headerRowHeight = this.calculateRowControls()[0]?.height;
12766
+ const top = clientRect.top + headerTopHeight - this.tableWrapperMarginTop;
12767
+ this.isStickyTop =
12768
+ top <= this.scrollContainerTop + 8 && clientRect.bottom - this.scrollContainerTop >= headerRowHeight;
12789
12769
  // 标题行内容超过固定高度时移除冻结
12790
12770
  if (this.isStickyTop && this.freezeRowPipe.transform(this.element, this.headerRow)) {
12791
12771
  const maxHeaderRowHeight = (24 + 8) * 11; // 超出 11 行,取消冻结
12792
12772
  this.isStickyTop = headerRowHeight <= maxHeaderRowHeight;
12793
12773
  }
12794
- // 滚动超出表格总高度后移除冻结
12795
- if (this.isStickyTop && this.freezeRowPipe.transform(this.element, this.headerRow)) {
12796
- const tableHeight = this.calculateRowControls().reduce((previous, current) => {
12797
- return previous + current.height;
12798
- }, 0);
12799
- const buffer = this.isInTable ? 11 : 0;
12800
- this.isStickyTop = scrollHeight <= tableHeight - headerRowHeight + buffer;
12801
- }
12802
12774
  return this.isStickyTop;
12803
12775
  }), distinctUntilChanged())
12804
12776
  .subscribe(() => {
12805
- this.setStickyRowStyle();
12777
+ this.setHeaderRowStyle();
12806
12778
  });
12807
12779
  });
12808
12780
  }
@@ -12890,14 +12862,16 @@ class TheTableComponent extends TheBaseElementComponent {
12890
12862
  if (this.isStickyTop && this.freezeRowPipe.transform(this.element, this.headerRow)) {
12891
12863
  this.renderer.addClass(this.nativeElement, stickyTableClass);
12892
12864
  const numberedColumn = this.element.options?.numberedColumn;
12893
- this.renderer.setStyle(headerRow, 'top', this.scrollContainerTop + 'px');
12865
+ const top = this.isInTable ? this.scrollContainerTop + 36 : this.scrollContainerTop;
12866
+ this.renderer.setStyle(headerRow, 'top', top + 'px');
12894
12867
  const buffer = this.element.options?.numberedColumn ? 0 : 8; // margin-bottom
12895
12868
  if (this.isInTable || numberedColumn) {
12896
12869
  [colControl, tableCornerBtn, rowControlButton].map(item => {
12897
12870
  item && this.renderer.setStyle(item, 'top', this.scrollContainerTop + 'px');
12898
12871
  });
12899
12872
  }
12900
- this.renderer.setStyle(this.tableWrapper.nativeElement, 'margin-top', headerRowHeight + buffer + 'px');
12873
+ this.tableWrapperMarginTop = headerRowHeight + buffer;
12874
+ this.renderer.setStyle(this.tableWrapper.nativeElement, 'margin-top', this.tableWrapperMarginTop + 'px');
12901
12875
  }
12902
12876
  else {
12903
12877
  this.renderer.removeClass(this.nativeElement, stickyTableClass);
@@ -12905,6 +12879,7 @@ class TheTableComponent extends TheBaseElementComponent {
12905
12879
  item && this.renderer.setStyle(item, 'top', null);
12906
12880
  });
12907
12881
  this.renderer.setStyle(this.tableWrapper.nativeElement, 'margin-top', null);
12882
+ this.tableWrapperMarginTop = 0;
12908
12883
  }
12909
12884
  }
12910
12885
  bindTableScrollingShadow() {
@@ -13114,10 +13089,11 @@ class TheTableComponent extends TheBaseElementComponent {
13114
13089
  }
13115
13090
  }
13116
13091
  initializeRows() {
13117
- this.element.children.map(row => {
13092
+ this.element.children.map((row, index$1) => {
13118
13093
  if (!row.height) {
13119
13094
  const element = TheEditor.toDOMNode(this.editor, row);
13120
- setNode(this.editor, { height: getElementHeight(element) }, row);
13095
+ let height = getElementHeight(element);
13096
+ setNode(this.editor, { height }, row);
13121
13097
  }
13122
13098
  });
13123
13099
  }
@@ -13125,7 +13101,7 @@ class TheTableComponent extends TheBaseElementComponent {
13125
13101
  const rowElements = this.nativeElement.querySelector('tbody').children;
13126
13102
  if (rowElements) {
13127
13103
  [...rowElements].map((row, index$1) => {
13128
- const height = getElementHeight(row);
13104
+ let height = getElementHeight(row);
13129
13105
  setNode(this.editor, { height }, this.element.children[index$1]);
13130
13106
  });
13131
13107
  }
@@ -13234,21 +13210,18 @@ class TheTableComponent extends TheBaseElementComponent {
13234
13210
  }
13235
13211
  // keydown
13236
13212
  listenKeydownSelectEvents() {
13237
- const ctrlKey = isMac() ? ['Meta'] : ['Control'];
13238
13213
  this.ngZone.runOutsideAngular(() => {
13239
13214
  fromEvent(document, 'keydown')
13240
13215
  .pipe(takeUntil(this.destroy$), filter((e) => !!e))
13241
13216
  .subscribe((event) => {
13242
- if (ctrlKey.includes(event.key) && !this.readonly) {
13217
+ if (isHotkey('mod', event) && !this.readonly) {
13243
13218
  this.tableStore.isModSelecting = true;
13244
13219
  }
13245
13220
  });
13246
13221
  fromEvent(document, 'keyup')
13247
13222
  .pipe(takeUntil(this.destroy$), filter((e) => !!e))
13248
- .subscribe((event) => {
13249
- if (ctrlKey.includes(event.key) && !this.readonly) {
13250
- this.tableStore.isModSelecting = false;
13251
- }
13223
+ .subscribe(() => {
13224
+ this.tableStore.isModSelecting = false;
13252
13225
  });
13253
13226
  });
13254
13227
  }
@@ -13262,13 +13235,9 @@ class TheTableComponent extends TheBaseElementComponent {
13262
13235
  super.ngOnDestroy();
13263
13236
  this.destroy$.next();
13264
13237
  this.destroy$.complete();
13265
- if (this.scrollContainerRef) {
13266
- this.scrollContainerRef.unsubscribe();
13267
- this.scrollContainerRef = null;
13268
- }
13269
13238
  }
13270
13239
  }
13271
- TheTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TheTableComponent, deps: [{ token: i0.ElementRef }, { token: TableCellEventDispatcher }, { token: ColumnResizeNotifierSource }, { token: TableStore }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: TableService }, { token: TheTableContextMenuService }, { token: TableFreezeColumnPipe }, { token: TableFreezeRowPipe }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
13240
+ TheTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TheTableComponent, deps: [{ token: i0.ElementRef }, { token: TableCellEventDispatcher }, { token: ColumnResizeNotifierSource }, { token: TableStore }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: TableService }, { token: TheTableContextMenuService }, { token: TableFreezeColumnPipe }, { token: TableFreezeRowPipe }, { token: i0.Renderer2 }, { token: TheContextService }], target: i0.ɵɵFactoryTarget.Component });
13272
13241
  TheTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: TheTableComponent, selector: "the-table, [theTable]", host: { listeners: { "mousedown": "handleMousedown($event)" }, properties: { "class.the-table-with-controls": "isInTable || tableStore.isCellSelecting", "class.the-numberd-table": "element?.options?.numberedColumn", "class.the-table-selection-hide": "tableStore.isCellSelecting || tableStore.isRightClicking" } }, providers: [
13273
13242
  TableStore,
13274
13243
  TableService,
@@ -13301,7 +13270,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
13301
13270
  '[class.the-numberd-table]': 'element?.options?.numberedColumn',
13302
13271
  '[class.the-table-selection-hide]': 'tableStore.isCellSelecting || tableStore.isRightClicking'
13303
13272
  }, template: "<div class=\"the-table-container\" theColumnResize>\n <div class=\"the-table-row-controls-wrapper\">\n <div\n class=\"the-table-corner-controls the-sticky-corner-controls\"\n #cornerControl\n [ngClass]=\"{\n visible: !readonly && (isInTable || tableStore.isCellSelecting),\n active: isSelectedAllCell,\n dangerous: tableStore.isSelectedTable && tableStore.dangerousCells.length > 0\n }\"\n >\n <div class=\"the-table-corner-button\" (mousedown)=\"onSelectTable($event)\"></div>\n <div class=\"the-table-corner-controls-insert-row-marker\" *ngIf=\"!element.options?.headerRow\">\n <the-table-insert-mark type=\"row\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n <div class=\"the-table-corner-controls-insert-column-marker\" *ngIf=\"!element.options?.headerColumn\">\n <the-table-insert-mark type=\"column\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n </div>\n <div class=\"the-table-row-controls\">\n <div class=\"the-table-row-controls-inner\">\n <div\n class=\"the-table-row-controls-button-wrap\"\n #rowControlsButtonWrapper\n *ngFor=\"let control of rowControls; let i = index; trackBy: trackByFnRowControls\"\n [ngClass]=\"{\n active: tableStore.selectedRowsIndex.includes(control.rowIndex),\n dangerous: tableStore.dangerousRowsIndex.includes(control.rowIndex) && tableStore.dangerousCells.length > 0\n }\"\n >\n <ng-container *ngIf=\"!readonly && (isInTable || tableStore.isCellSelecting) && !element?.options?.numberedColumn\">\n <button\n (mousedown)=\"onRowMousedown($event, control.rowIndex)\"\n type=\"button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n class=\"the-table-row-controls-button the-table-controls-button\"\n ></button>\n </ng-container>\n <ng-container *ngIf=\"element?.options?.numberedColumn\">\n <div\n [contentEditable]=\"false\"\n contenteditable=\"false\"\n (mousedown)=\"onRowMousedown($event, control.rowIndex)\"\n class=\"the-table-numbered-controls-button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n >\n <p class=\"row-number d-flex align-items-center\">{{ headerRow && i === 0 ? '' : headerRow ? i : i + 1 }}</p>\n </div>\n </ng-container>\n <the-table-insert-mark type=\"row\" [at]=\"control.rowIndex + 1\" [tableStore]=\"tableStore\"> </the-table-insert-mark>\n </div>\n </div>\n </div>\n </div>\n <div class=\"the-table-wrapper\" #tableWrapper [ngClass]=\"{ 'the-table-numbered': element?.options?.numberedColumn }\">\n <table class=\"the-table\" #theTable>\n <colgroup *ngIf=\"columns\">\n <col *ngFor=\"let col of columns\" [ngStyle]=\"{ width: col.width + 'px' }\" />\n </colgroup>\n <thead>\n <tr class=\"the-table-col-controls-wrapper the-sticky-row\" #columnControlsWrapper>\n <th\n #colControl\n class=\"the-table-col-controls\"\n [ngClass]=\"{\n 'the-sticky-cell': i === 0 && element | freezeColumn : tablePluginOptions,\n active: tableStore.selectedColumnsIndex.includes(i),\n dangerous: tableStore.dangerousColumnsIndex.includes(i) && tableStore.dangerousCells.length > 0\n }\"\n (mousedown)=\"onColMousedown($event, i)\"\n *ngFor=\"let control of colControls; let i = index; trackBy: trackByFnColControls\"\n >\n <the-table-insert-mark\n *ngIf=\"isInTable || tableStore.isCellSelecting\"\n type=\"column\"\n [at]=\"i + 1\"\n [tableStore]=\"tableStore\"\n [parentElement]=\"colControl\"\n >\n </the-table-insert-mark>\n </th>\n </tr>\n </thead>\n <tbody #tbody>\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"> </slate-children>\n </tbody>\n </table>\n </div>\n</div>\n" }]
13304
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: TableCellEventDispatcher }, { type: ColumnResizeNotifierSource }, { type: TableStore }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: TableService }, { type: TheTableContextMenuService }, { type: TableFreezeColumnPipe }, { type: TableFreezeRowPipe }, { type: i0.Renderer2 }]; }, propDecorators: { tableWrapper: [{
13273
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: TableCellEventDispatcher }, { type: ColumnResizeNotifierSource }, { type: TableStore }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: TableService }, { type: TheTableContextMenuService }, { type: TableFreezeColumnPipe }, { type: TableFreezeRowPipe }, { type: i0.Renderer2 }, { type: TheContextService }]; }, propDecorators: { tableWrapper: [{
13305
13274
  type: ViewChild,
13306
13275
  args: ['tableWrapper', { read: ElementRef, static: true }]
13307
13276
  }], theTableElement: [{