@talrace/ngx-noder 19.0.59 → 19.0.61

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.
@@ -633,7 +633,13 @@ class EditorService {
633
633
  this._clipboardData$ = new BehaviorSubject('');
634
634
  this._hasSelection$ = new BehaviorSubject(false);
635
635
  this._historyInfo$ = new BehaviorSubject(new OperationsHistoryInfoModel(-1, -1));
636
- this._toggleSidenav$ = new Subject();
636
+ this._toggleSidenav$ = new BehaviorSubject({
637
+ open: false,
638
+ component: null,
639
+ focus: false,
640
+ data: null
641
+ });
642
+ this._isSidenavLocked = false;
637
643
  this._displayGrammarError$ = new Subject();
638
644
  this._applyGrammarSuggestion$ = new Subject();
639
645
  this._ignoreGrammarError$ = new Subject();
@@ -763,6 +769,9 @@ class EditorService {
763
769
  get toggleSidenav$() {
764
770
  return this._toggleSidenav$.asObservable();
765
771
  }
772
+ get isSidenavLocked() {
773
+ return this._isSidenavLocked;
774
+ }
766
775
  get displayGrammarError$() {
767
776
  return this._displayGrammarError$.asObservable();
768
777
  }
@@ -1177,8 +1186,14 @@ class EditorService {
1177
1186
  this._toggleSidenav$.next({ open: true, component, focus });
1178
1187
  }
1179
1188
  closeSidenav() {
1189
+ if (this.isSidenavLocked) {
1190
+ return;
1191
+ }
1180
1192
  this._toggleSidenav$.next({ open: false, component: null, focus: false });
1181
1193
  }
1194
+ lockSidenav(value) {
1195
+ this._isSidenavLocked = value;
1196
+ }
1182
1197
  changedTableSize(insertIndex, sessionId) {
1183
1198
  this._changedTableSize$.next({ insertIndex, sessionId });
1184
1199
  }
@@ -8185,8 +8200,8 @@ class DisplayData extends EventEmitting {
8185
8200
  paragraphSettings.calculateDistanceFromTop(pageHeight, this.pagesSpace, pageVerticalData.marginTop, prevFormatsData);
8186
8201
  }
8187
8202
  this.pagesFormat.forEach((x, i) => {
8188
- const pagesHeight = this.getPageFormatParagraphs(i).reduce((sum, y) => sum + y.paragraphSettings.height, 0);
8189
- x.updateData(pagesHeight);
8203
+ const paragraphs = this.getPageFormatParagraphs(i);
8204
+ x.updateData(this.getPhysicalHeight(paragraphs));
8190
8205
  });
8191
8206
  this.allPagesHeight = 0;
8192
8207
  this.pagesFormat.forEach((x, i) => {
@@ -8207,7 +8222,7 @@ class DisplayData extends EventEmitting {
8207
8222
  });
8208
8223
  }
8209
8224
  getAllParagraphsHeight() {
8210
- return this.paragraphs.reduce((sum, x) => sum + x.paragraphSettings.height, 0);
8225
+ return this.getPhysicalHeight(this.paragraphs);
8211
8226
  }
8212
8227
  destroy() {
8213
8228
  this.removeAllListeners('pagesCountChanged');
@@ -8646,6 +8661,15 @@ class DisplayData extends EventEmitting {
8646
8661
  paragraph.paragraphSettings.startInsertIndex = paragraph.startIndex;
8647
8662
  }
8648
8663
  }
8664
+ getPhysicalHeight(paragraphs) {
8665
+ const bounds = paragraphs
8666
+ .flatMap(x => x.paragraphSettings?.textLinesInfo || [])
8667
+ .reduce((acc, line) => ({
8668
+ cursorY: acc.cursorY + line.offsetBefore + line.height + line.offsetAfter + (line.endPageOffset || 0),
8669
+ maxBottom: Math.max(acc.maxBottom, acc.cursorY + line.offsetBefore + line.height)
8670
+ }), { cursorY: 0, maxBottom: 0 });
8671
+ return Math.max(bounds.cursorY, bounds.maxBottom);
8672
+ }
8649
8673
  }
8650
8674
 
8651
8675
  class NoderEdgeComponent extends DestroyComponent {
@@ -10066,6 +10090,7 @@ class GrammarChecker {
10066
10090
  const filteredErrors = this.filterErrors(errors);
10067
10091
  this.paragraphErrorMap.set(key, filteredErrors);
10068
10092
  session.renderer.updateGrammarHighlights(+paragraphId, filteredErrors);
10093
+ session.renderer.scheduleChanges({ grammar: true });
10069
10094
  }
10070
10095
  }
10071
10096
  destroy() {
@@ -10097,6 +10122,7 @@ class GrammarChecker {
10097
10122
  this.paragraphErrorMap.set(result.paragraphId, filteredErrors);
10098
10123
  const id = +result.paragraphId.split('-')[1];
10099
10124
  session.renderer.updateGrammarHighlights(id, filteredErrors);
10125
+ session.renderer.scheduleChanges({ grammar: true });
10100
10126
  }
10101
10127
  }
10102
10128
  processParagraphChange(session, change) {
@@ -10113,6 +10139,7 @@ class GrammarChecker {
10113
10139
  return;
10114
10140
  }
10115
10141
  this.adjustHighlights(change, session);
10142
+ session.renderer.scheduleChanges({ grammar: true });
10116
10143
  this.grammarService.updateParagraphContent(session.sessionId, change.paragraph);
10117
10144
  }
10118
10145
  adjustHighlights(changes, session) {
@@ -11049,7 +11076,6 @@ class Renderer extends EventEmitting {
11049
11076
  }
11050
11077
  updateGrammarHighlights(paragraphId, errors) {
11051
11078
  this.grammarHighlightLayer.setErrors(paragraphId, errors);
11052
- this.scheduleChanges({ grammar: true });
11053
11079
  }
11054
11080
  removeGrammarHighlights(paragraphId) {
11055
11081
  this.grammarHighlightLayer.removeParagraphHighlights(paragraphId);
@@ -14809,8 +14835,12 @@ class Selection {
14809
14835
  this.keepLinePositionX = null;
14810
14836
  }
14811
14837
  blur() {
14812
- this.focusedComponent?.instance.blur();
14838
+ if (!this.focusedComponent) {
14839
+ return;
14840
+ }
14841
+ const currentComponent = this.focusedComponent;
14813
14842
  this.focusedComponent = null;
14843
+ currentComponent.instance.blur();
14814
14844
  }
14815
14845
  placeCursor(cursor) {
14816
14846
  this.anchor = null;
@@ -16685,6 +16715,7 @@ class Editor {
16685
16715
  links: [],
16686
16716
  comments: []
16687
16717
  });
16718
+ this.editorService.lockSidenav(true);
16688
16719
  this.insertContent(insertIndex, nextElementContents);
16689
16720
  setTimeout(() => {
16690
16721
  // Need to skip micro tasks for a render element before focus
@@ -16695,6 +16726,7 @@ class Editor {
16695
16726
  this.onSelectionChange();
16696
16727
  this.scrollCursorIntoMainView();
16697
16728
  }
16729
+ this.editorService.lockSidenav(false);
16698
16730
  });
16699
16731
  }
16700
16732
  insertContent(insertIndex, contents) {
@@ -16910,7 +16942,7 @@ class Editor {
16910
16942
  const beforeTable = ContentHelper.documentIndexToParagraphIndex(this.session.displayData.paragraphs, insertIndex);
16911
16943
  this.selection.placeCursor(beforeTable);
16912
16944
  this.history.pushRemoveTableRows(insertIndex, startIndex, endIndex);
16913
- this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableRowsCommand(startIndex, endIndex, insertIndex, this.targets));
16945
+ this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableRowsCommand(insertIndex, startIndex, endIndex, this.targets));
16914
16946
  this.session.removeTableRows(insertIndex, startIndex, endIndex);
16915
16947
  this.changedTableSize(insertIndex, sessionId);
16916
16948
  this.onContentChange();
@@ -16920,7 +16952,7 @@ class Editor {
16920
16952
  const beforeTable = ContentHelper.documentIndexToParagraphIndex(this.session.displayData.paragraphs, insertIndex);
16921
16953
  this.selection.placeCursor(beforeTable);
16922
16954
  this.history.pushRemoveTableColumns(insertIndex, startIndex, endIndex);
16923
- this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableColumnsCommand(startIndex, endIndex, insertIndex, this.targets));
16955
+ this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableColumnsCommand(insertIndex, startIndex, endIndex, this.targets));
16924
16956
  this.session.removeTableColumns(insertIndex, startIndex, endIndex);
16925
16957
  this.changedTableSize(insertIndex, sessionId);
16926
16958
  this.onContentChange();
@@ -17997,7 +18029,14 @@ class EditorComponent {
17997
18029
  }
17998
18030
  toggleSidenavSubscription() {
17999
18031
  return this.editorService.toggleSidenav$.subscribe(data => {
18000
- if (this.sidenavComponentRef?.componentType === data.component) {
18032
+ const isSameComponent = this.sidenavComponentRef?.componentType === data.component;
18033
+ if (data.open && (isSameComponent || this.editorService.isSidenavLocked)) {
18034
+ const instance = this.sidenavComponentRef.instance;
18035
+ for (const [key, value] of Object.entries(data.data || {})) {
18036
+ if (key in instance) {
18037
+ this.sidenavComponentRef.setInput(key, value);
18038
+ }
18039
+ }
18001
18040
  return;
18002
18041
  }
18003
18042
  this.removeSidenavComponent();
@@ -18015,6 +18054,9 @@ class EditorComponent {
18015
18054
  this.sidenav.close().catch(() => {
18016
18055
  // continue regardless of error
18017
18056
  });
18057
+ if (this.editor.selection.isFocused) {
18058
+ this.editor.selection.blur();
18059
+ }
18018
18060
  }
18019
18061
  this.cdr.markForCheck();
18020
18062
  });