@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.
@@ -29,7 +29,7 @@ import { ThyDividerComponent, ThyDividerModule } from 'ngx-tethys/divider';
29
29
  import * as i2$2 from '@angular/cdk/scrolling';
30
30
  import { CdkScrollable, ScrollingModule } from '@angular/cdk/scrolling';
31
31
  import { mixinUnsubscribe, MixinBase, ScrollToService } from 'ngx-tethys/core';
32
- import { isKeyHotkey } from 'is-hotkey';
32
+ import { isKeyHotkey, isHotkey } from 'is-hotkey';
33
33
  import { Subject, fromEvent, timer, combineLatest, Observable, BehaviorSubject, merge, ReplaySubject } from 'rxjs';
34
34
  import { takeUntil, take, delay, map as map$1, skip, filter, debounceTime, startWith, distinctUntilChanged, share, mapTo, pairwise } from 'rxjs/operators';
35
35
  import * as i5 from 'ngx-tethys/input';
@@ -3139,7 +3139,8 @@ class TheContextService {
3139
3139
  var _a, _b;
3140
3140
  (_a = this.scrollSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
3141
3141
  if ((_b = this.options.theOptions) === null || _b === void 0 ? void 0 : _b.scrollContainer) {
3142
- const containerElement = this.options.nativeElement.closest(this.options.theOptions.scrollContainer);
3142
+ const containerElement = this.options.nativeElement.closest(this.options.theOptions.scrollContainer) ||
3143
+ this.options.nativeElement.querySelector(this.options.theOptions.scrollContainer);
3143
3144
  if (containerElement) {
3144
3145
  this.ngZone.runOutsideAngular(() => {
3145
3146
  this.scrollSubscription = fromEvent(containerElement, 'scroll').subscribe(event => {
@@ -11203,10 +11204,10 @@ function setCellMenuVisibility(editor, menuList, tableInfo) {
11203
11204
  item.visibility = selectCellNodes && selectCellNodes.length === 1 && isCellMerged;
11204
11205
  break;
11205
11206
  case 'delete-selection-rows':
11206
- item.visibility = !isFullscreen || !selectedColumnsIndex.length;
11207
+ item.visibility = !(isFullscreen && selectedColumnsIndex.length);
11207
11208
  break;
11208
11209
  case 'delete-selection-columns':
11209
- item.visibility = !isFullscreen || !selectedRowsIndex.length;
11210
+ item.visibility = !(isFullscreen && selectedRowsIndex.length);
11210
11211
  break;
11211
11212
  case 'delete-table':
11212
11213
  item.visibility = !isFullscreen;
@@ -11301,6 +11302,10 @@ class TableStore {
11301
11302
  this.isCellSelecting = false;
11302
11303
  this.isRightClicking = false;
11303
11304
  this.isModSelecting = false;
11305
+ this.isSelectedAllCell = () => {
11306
+ const pos = this.createTablePosition();
11307
+ return pos.getHeight() * pos.getWidth() === this.selectedCells.length;
11308
+ };
11304
11309
  }
11305
11310
  get selectedCells() {
11306
11311
  return this.selectedCells$.getValue();
@@ -12438,39 +12443,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
12438
12443
  args: [{ name: 'freezeRow' }]
12439
12444
  }] });
12440
12445
 
12441
- const getOsName = () => {
12442
- const userAgent = navigator.userAgent.toLowerCase();
12443
- let name = 'Unknown';
12444
- if (userAgent.indexOf('win') > -1) {
12445
- name = 'Windows';
12446
- }
12447
- else if (userAgent.indexOf('iphone') > -1) {
12448
- name = 'Iphone';
12449
- }
12450
- else if (userAgent.indexOf('mac') > -1) {
12451
- name = 'Mac';
12452
- }
12453
- else if (userAgent.indexOf('x11') > -1 ||
12454
- userAgent.indexOf('unix') > -1 ||
12455
- userAgent.indexOf('sunname') > -1 ||
12456
- userAgent.indexOf('bsd') > -1) {
12457
- name = 'Unix';
12458
- }
12459
- else if (userAgent.indexOf('linux') > -1) {
12460
- if (userAgent.indexOf('android') > -1) {
12461
- name = 'Android';
12462
- }
12463
- else {
12464
- name = 'Linux';
12465
- }
12466
- }
12467
- else {
12468
- name = 'Unknown';
12469
- }
12470
- return name;
12471
- };
12472
- const isMac = () => getOsName() === 'Mac';
12473
-
12474
12446
  const TABLE_SELECTOR = '.the-table';
12475
12447
  const TABLE_WRAPPER_SELECTOR = '.the-table-wrapper';
12476
12448
  const RESIZE_OVERLAY_SELECTOR = '.the-table-resize-overlay-thumb';
@@ -12657,7 +12629,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
12657
12629
  }] } });
12658
12630
 
12659
12631
  class TheTableComponent extends TheBaseElementComponent {
12660
- constructor(elementRef, eventDispatcher, resizeNotifier, tableStore, cdr, ngZone, tableService, theTableContextMenuService, freezeColumnPipe, freezeRowPipe, renderer) {
12632
+ constructor(elementRef, eventDispatcher, resizeNotifier, tableStore, cdr, ngZone, tableService, theTableContextMenuService, freezeColumnPipe, freezeRowPipe, renderer, contextService) {
12661
12633
  super(elementRef, cdr);
12662
12634
  this.eventDispatcher = eventDispatcher;
12663
12635
  this.resizeNotifier = resizeNotifier;
@@ -12669,10 +12641,13 @@ class TheTableComponent extends TheBaseElementComponent {
12669
12641
  this.freezeColumnPipe = freezeColumnPipe;
12670
12642
  this.freezeRowPipe = freezeRowPipe;
12671
12643
  this.renderer = renderer;
12644
+ this.contextService = contextService;
12672
12645
  this.headerRow = false;
12646
+ this.isSelectedAllCell = false;
12673
12647
  this.destroy$ = new Subject();
12674
12648
  this.rowControls = [];
12675
12649
  this.colControls = [];
12650
+ this.tableWrapperMarginTop = 0;
12676
12651
  }
12677
12652
  get columns() {
12678
12653
  return this.element && this.element.columns;
@@ -12684,10 +12659,6 @@ class TheTableComponent extends TheBaseElementComponent {
12684
12659
  var _a;
12685
12660
  return (_a = this.tbodyElement) === null || _a === void 0 ? void 0 : _a.nativeElement;
12686
12661
  }
12687
- get isSelectedAllCell() {
12688
- return (this.tableStore.selectedRowsIndex.length === this.rowControls.length &&
12689
- this.tableStore.selectedColumnsIndex.length === this.colControls.length);
12690
- }
12691
12662
  handleMousedown(event) {
12692
12663
  if (event.target instanceof Element && this.tbodyNativeElement.contains(event.target)) {
12693
12664
  return;
@@ -12724,8 +12695,24 @@ class TheTableComponent extends TheBaseElementComponent {
12724
12695
  .pipe(takeUntil(this.destroy$))
12725
12696
  .subscribe(value => {
12726
12697
  this.tableStore.isFullscreen = value;
12698
+ if (this.tableStore.isFullscreen) {
12699
+ this.previousScrollContainer = this.editor.options.scrollContainer;
12700
+ this.editor.options.scrollContainer = '.the-editable-container';
12701
+ }
12702
+ else {
12703
+ this.editor.options.scrollContainer = this.previousScrollContainer;
12704
+ }
12705
+ this.isStickyTop = false;
12706
+ this.setHeaderRowStyle();
12707
+ this.contextService.rebindContainerScroll();
12727
12708
  });
12728
12709
  }
12710
+ this.tableStore
12711
+ .selectedCellsChange()
12712
+ .pipe(takeUntil(this.destroy$))
12713
+ .subscribe(() => {
12714
+ this.isSelectedAllCell = this.tableStore.isSelectedAllCell();
12715
+ });
12729
12716
  }
12730
12717
  getWrapperWidth() {
12731
12718
  const tableContainer = this.nativeElement.firstChild;
@@ -12784,42 +12771,26 @@ class TheTableComponent extends TheBaseElementComponent {
12784
12771
  }));
12785
12772
  }
12786
12773
  subscribeScrollContainerScroll() {
12787
- if (this.scrollContainerRef) {
12788
- this.scrollContainerRef.unsubscribe();
12789
- this.scrollContainerRef = null;
12790
- }
12791
12774
  this.ngZone.runOutsideAngular(() => {
12792
- var _a;
12793
- const scrollContainer = ((_a = this.editor.options) === null || _a === void 0 ? void 0 : _a.scrollContainer) || DEFAULT_SCROLL_CONTAINER;
12794
- const scrollContainerElement = this.elementRef.nativeElement.closest(scrollContainer);
12795
- this.scrollContainerTop = scrollContainerElement.getBoundingClientRect().top;
12796
- const elementTop = this.elementRef.nativeElement.getBoundingClientRect().top;
12797
- this.scrollContainerRef = fromEvent(scrollContainerElement, 'scroll')
12798
- .pipe(takeUntil(this.destroy$), map$1(() => {
12775
+ this.contextService.containerScrolled$
12776
+ .pipe(takeUntil(this.destroy$), map$1(event => {
12799
12777
  var _a;
12800
- const distance = elementTop - this.scrollContainerTop;
12801
- const scrollTop = scrollContainerElement.scrollTop;
12802
- const buffer = this.isInTable ? 0 : 30;
12803
- const scrollHeight = scrollTop - (distance + buffer);
12804
- this.isStickyTop = scrollHeight > 0;
12778
+ this.scrollContainerTop = event.target.getBoundingClientRect().top;
12779
+ const clientRect = this.theTableElement.nativeElement.getBoundingClientRect();
12780
+ const headerTopHeight = this.isInTable ? -19 : 11;
12805
12781
  const headerRowHeight = (_a = this.calculateRowControls()[0]) === null || _a === void 0 ? void 0 : _a.height;
12782
+ const top = clientRect.top + headerTopHeight - this.tableWrapperMarginTop;
12783
+ this.isStickyTop =
12784
+ top <= this.scrollContainerTop + 8 && clientRect.bottom - this.scrollContainerTop >= headerRowHeight;
12806
12785
  // 标题行内容超过固定高度时移除冻结
12807
12786
  if (this.isStickyTop && this.freezeRowPipe.transform(this.element, this.headerRow)) {
12808
12787
  const maxHeaderRowHeight = (24 + 8) * 11; // 超出 11 行,取消冻结
12809
12788
  this.isStickyTop = headerRowHeight <= maxHeaderRowHeight;
12810
12789
  }
12811
- // 滚动超出表格总高度后移除冻结
12812
- if (this.isStickyTop && this.freezeRowPipe.transform(this.element, this.headerRow)) {
12813
- const tableHeight = this.calculateRowControls().reduce((previous, current) => {
12814
- return previous + current.height;
12815
- }, 0);
12816
- const buffer = this.isInTable ? 11 : 0;
12817
- this.isStickyTop = scrollHeight <= tableHeight - headerRowHeight + buffer;
12818
- }
12819
12790
  return this.isStickyTop;
12820
12791
  }), distinctUntilChanged())
12821
12792
  .subscribe(() => {
12822
- this.setStickyRowStyle();
12793
+ this.setHeaderRowStyle();
12823
12794
  });
12824
12795
  });
12825
12796
  }
@@ -12910,14 +12881,16 @@ class TheTableComponent extends TheBaseElementComponent {
12910
12881
  if (this.isStickyTop && this.freezeRowPipe.transform(this.element, this.headerRow)) {
12911
12882
  this.renderer.addClass(this.nativeElement, stickyTableClass);
12912
12883
  const numberedColumn = (_c = this.element.options) === null || _c === void 0 ? void 0 : _c.numberedColumn;
12913
- this.renderer.setStyle(headerRow, 'top', this.scrollContainerTop + 'px');
12884
+ const top = this.isInTable ? this.scrollContainerTop + 36 : this.scrollContainerTop;
12885
+ this.renderer.setStyle(headerRow, 'top', top + 'px');
12914
12886
  const buffer = ((_d = this.element.options) === null || _d === void 0 ? void 0 : _d.numberedColumn) ? 0 : 8; // margin-bottom
12915
12887
  if (this.isInTable || numberedColumn) {
12916
12888
  [colControl, tableCornerBtn, rowControlButton].map(item => {
12917
12889
  item && this.renderer.setStyle(item, 'top', this.scrollContainerTop + 'px');
12918
12890
  });
12919
12891
  }
12920
- this.renderer.setStyle(this.tableWrapper.nativeElement, 'margin-top', headerRowHeight + buffer + 'px');
12892
+ this.tableWrapperMarginTop = headerRowHeight + buffer;
12893
+ this.renderer.setStyle(this.tableWrapper.nativeElement, 'margin-top', this.tableWrapperMarginTop + 'px');
12921
12894
  }
12922
12895
  else {
12923
12896
  this.renderer.removeClass(this.nativeElement, stickyTableClass);
@@ -12925,6 +12898,7 @@ class TheTableComponent extends TheBaseElementComponent {
12925
12898
  item && this.renderer.setStyle(item, 'top', null);
12926
12899
  });
12927
12900
  this.renderer.setStyle(this.tableWrapper.nativeElement, 'margin-top', null);
12901
+ this.tableWrapperMarginTop = 0;
12928
12902
  }
12929
12903
  }
12930
12904
  bindTableScrollingShadow() {
@@ -13136,10 +13110,11 @@ class TheTableComponent extends TheBaseElementComponent {
13136
13110
  }
13137
13111
  }
13138
13112
  initializeRows() {
13139
- this.element.children.map(row => {
13113
+ this.element.children.map((row, index$1) => {
13140
13114
  if (!row.height) {
13141
13115
  const element = TheEditor.toDOMNode(this.editor, row);
13142
- setNode(this.editor, { height: getElementHeight(element) }, row);
13116
+ let height = getElementHeight(element);
13117
+ setNode(this.editor, { height }, row);
13143
13118
  }
13144
13119
  });
13145
13120
  }
@@ -13147,7 +13122,7 @@ class TheTableComponent extends TheBaseElementComponent {
13147
13122
  const rowElements = this.nativeElement.querySelector('tbody').children;
13148
13123
  if (rowElements) {
13149
13124
  [...rowElements].map((row, index$1) => {
13150
- const height = getElementHeight(row);
13125
+ let height = getElementHeight(row);
13151
13126
  setNode(this.editor, { height }, this.element.children[index$1]);
13152
13127
  });
13153
13128
  }
@@ -13256,21 +13231,18 @@ class TheTableComponent extends TheBaseElementComponent {
13256
13231
  }
13257
13232
  // keydown
13258
13233
  listenKeydownSelectEvents() {
13259
- const ctrlKey = isMac() ? ['Meta'] : ['Control'];
13260
13234
  this.ngZone.runOutsideAngular(() => {
13261
13235
  fromEvent(document, 'keydown')
13262
13236
  .pipe(takeUntil(this.destroy$), filter((e) => !!e))
13263
13237
  .subscribe((event) => {
13264
- if (ctrlKey.includes(event.key) && !this.readonly) {
13238
+ if (isHotkey('mod', event) && !this.readonly) {
13265
13239
  this.tableStore.isModSelecting = true;
13266
13240
  }
13267
13241
  });
13268
13242
  fromEvent(document, 'keyup')
13269
13243
  .pipe(takeUntil(this.destroy$), filter((e) => !!e))
13270
- .subscribe((event) => {
13271
- if (ctrlKey.includes(event.key) && !this.readonly) {
13272
- this.tableStore.isModSelecting = false;
13273
- }
13244
+ .subscribe(() => {
13245
+ this.tableStore.isModSelecting = false;
13274
13246
  });
13275
13247
  });
13276
13248
  }
@@ -13284,13 +13256,9 @@ class TheTableComponent extends TheBaseElementComponent {
13284
13256
  super.ngOnDestroy();
13285
13257
  this.destroy$.next();
13286
13258
  this.destroy$.complete();
13287
- if (this.scrollContainerRef) {
13288
- this.scrollContainerRef.unsubscribe();
13289
- this.scrollContainerRef = null;
13290
- }
13291
13259
  }
13292
13260
  }
13293
- 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 });
13261
+ 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 });
13294
13262
  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: [
13295
13263
  TableStore,
13296
13264
  TableService,
@@ -13323,7 +13291,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
13323
13291
  '[class.the-numberd-table]': 'element?.options?.numberedColumn',
13324
13292
  '[class.the-table-selection-hide]': 'tableStore.isCellSelecting || tableStore.isRightClicking'
13325
13293
  }, 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" }]
13326
- }], 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: [{
13294
+ }], 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: [{
13327
13295
  type: ViewChild,
13328
13296
  args: ['tableWrapper', { read: ElementRef, static: true }]
13329
13297
  }], theTableElement: [{