@worktile/theia 21.0.0-next.1 → 21.0.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,22 +7147,18 @@ 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
  }
7159
7154
  if (this.options().mode !== this.element.language) {
7160
7155
  this.useMode();
7161
7156
  }
7162
- if (this.options().lineWrapping !== this.element.autoWrap) {
7157
+ const lineWrapping = this.element.autoWrap || false;
7158
+ if (this.options().lineWrapping !== lineWrapping) {
7163
7159
  this.useAutoWrap();
7164
7160
  }
7165
- if (this.resizeHeight !== this.element.height) {
7161
+ if (this.element.height && this.resizeHeight && this.resizeHeight !== this.element.height) {
7166
7162
  this.useHeight();
7167
7163
  }
7168
7164
  }
@@ -7196,6 +7192,10 @@ class TheCode extends TheBaseElement {
7196
7192
  }
7197
7193
  });
7198
7194
  });
7195
+ setTimeout(() => {
7196
+ this.useAutofocus();
7197
+ this.useToolbar();
7198
+ }, 0);
7199
7199
  }
7200
7200
  initMaxHeight() {
7201
7201
  this.maxHeight = isPrintMode(this.editor) ? 0 : CODEMIRROR_DEFAULT_MAX_HEIGHT - CODEMIRROR_PADDING_TOP * 2;
@@ -7229,7 +7229,6 @@ class TheCode extends TheBaseElement {
7229
7229
  this.useMode();
7230
7230
  this.useAutoWrap();
7231
7231
  this.useHeight();
7232
- this.useAutofocus();
7233
7232
  }
7234
7233
  codeChange($event) {
7235
7234
  this.isHightLight = false;
@@ -7270,10 +7269,18 @@ class TheCode extends TheBaseElement {
7270
7269
  this.options.set({ ...this.options(), readonly: this.readonly, cursorBlinkRate: this.readonly ? -1 : 500 });
7271
7270
  }
7272
7271
  useAutofocus() {
7273
- if (this.isCollapsedAndNonReadonly && Range.isCollapsed(this.editor.selection)) {
7272
+ if (this.isCollapsedAndNonReadonly) {
7274
7273
  this.options.set({ ...this.options(), autofocus: this.readonly ? false : true });
7275
7274
  }
7276
7275
  }
7276
+ useToolbar() {
7277
+ if (this.isCollapsedAndNonReadonly && !isMobileMode(this.editor)) {
7278
+ this.openToolbar();
7279
+ }
7280
+ else {
7281
+ this.closeToolbar();
7282
+ }
7283
+ }
7277
7284
  onResize({ height }) {
7278
7285
  this.resizeHeight = height;
7279
7286
  this.maxHeight = height;
@@ -13542,9 +13549,9 @@ const withMoveSelection = (editor) => {
13542
13549
  editor.onClick = (event) => {
13543
13550
  const domSelection = window.getSelection();
13544
13551
  if (domSelection && !domSelection.isCollapsed && event.detail >= 2 && editor.selection) {
13545
- const slateSelection = AngularEditor.toSlateRange(editor, domSelection, { exactMatch: false, suppressThrow: false });
13546
- const isNextStart = slateSelection.focus.offset === 0;
13547
- if (Range.isExpanded(slateSelection) && Range.isForward(slateSelection) && isNextStart) {
13552
+ const slateSelection = AngularEditor.toSlateRange(editor, domSelection, { exactMatch: false, suppressThrow: true });
13553
+ const isNextStart = slateSelection && slateSelection.focus.offset === 0;
13554
+ if (slateSelection && Range.isExpanded(slateSelection) && Range.isForward(slateSelection) && isNextStart) {
13548
13555
  const beforePoint = Editor.before(editor, slateSelection.focus);
13549
13556
  const changedRange = Editor.range(editor, slateSelection.anchor, beforePoint);
13550
13557
  // slate-angular throttle 80ms, so wait selectionchange complete
@@ -17527,15 +17534,17 @@ const withTable = (editor) => {
17527
17534
  if (event.detail === 3) {
17528
17535
  const isMergedCell = isSelectedCellMerged(editor);
17529
17536
  const domSelection = window.getSelection();
17530
- if (domSelection && !domSelection.isCollapsed && editor.selection) {
17531
- const slateSelection = AngularEditor.toSlateRange(editor, domSelection, { exactMatch: false, suppressThrow: false });
17532
- const opts = new TableOptions();
17533
- const startPosition = TablePosition.create(opts, editor, slateSelection.anchor.path);
17534
- const endPosition = TablePosition.create(opts, editor, slateSelection.focus.path);
17535
- if (isMergedCell && startPosition.cell !== endPosition.cell) {
17536
- timer(81).subscribe(() => {
17537
- Transforms.select(editor, slateSelection.anchor.path);
17538
- });
17537
+ if (domSelection && isMergedCell && !domSelection.isCollapsed && editor.selection) {
17538
+ const slateSelection = AngularEditor.toSlateRange(editor, domSelection, { exactMatch: false, suppressThrow: true });
17539
+ if (slateSelection) {
17540
+ const opts = new TableOptions();
17541
+ const startPosition = TablePosition.create(opts, editor, slateSelection.anchor.path);
17542
+ const endPosition = TablePosition.create(opts, editor, slateSelection.focus.path);
17543
+ if (startPosition.cell !== endPosition.cell) {
17544
+ timer(81).subscribe(() => {
17545
+ Transforms.select(editor, slateSelection.anchor.path);
17546
+ });
17547
+ }
17539
17548
  }
17540
17549
  }
17541
17550
  }