@talrace/ngx-noder 19.0.50 → 19.0.52

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.
@@ -8361,14 +8361,14 @@ class NoderEdgeComponent extends DestroyComponent {
8361
8361
  // todo need make in diff Task for get correct contentHeight
8362
8362
  return this.session.displayData.pagesFormat[0].defaultVerticalData.contentHeight;
8363
8363
  }
8364
- constructor(regulatorService, editorService, translateService, cdr) {
8364
+ constructor(regulatorService, editorService, translateService, cdr, elementRef) {
8365
8365
  super();
8366
8366
  this.regulatorService = regulatorService;
8367
8367
  this.editorService = editorService;
8368
8368
  this.translateService = translateService;
8369
8369
  this.cdr = cdr;
8370
+ this.elementRef = elementRef;
8370
8371
  this.initialized = false;
8371
- this.isVisible = false;
8372
8372
  this.pagesCountChangedHandler = (event) => {
8373
8373
  if (this._height === event.pageHeight) {
8374
8374
  return;
@@ -8381,11 +8381,10 @@ class NoderEdgeComponent extends DestroyComponent {
8381
8381
  ngOnDestroy() {
8382
8382
  this.session?.displayData.removeEventListener('pagesCountChanged', this.pagesCountChangedHandler);
8383
8383
  this.regulatorService.removeSession(this.sessionId);
8384
- this.intersectionObserver?.disconnect();
8385
8384
  super.ngOnDestroy();
8386
8385
  }
8387
8386
  initialize() {
8388
- this.edgeSession = this.regulatorService.addEdgeSession(this);
8387
+ this.edgeSession = this.regulatorService.addEdgeSession(this, this.elementRef.nativeElement);
8389
8388
  this.sessionId = this.edgeSession.sessionId;
8390
8389
  this.container.nativeElement.parentElement.setAttribute('data-session-id', `${this.sessionId}`);
8391
8390
  DomHelper.setStyle(this.container.nativeElement.style, 'overflow', 'hidden');
@@ -8400,8 +8399,6 @@ class NoderEdgeComponent extends DestroyComponent {
8400
8399
  this.edgeNameByType = this.getEdgeNameByType();
8401
8400
  this.cdr.detectChanges();
8402
8401
  });
8403
- this.intersectionObserver = this.initializeIntersectionObserver();
8404
- this.intersectionObserver.observe(this.container.nativeElement);
8405
8402
  }
8406
8403
  enterEditMode() {
8407
8404
  DomHelper.addCssClass(this.container.nativeElement, this.editModeClass);
@@ -8444,29 +8441,13 @@ class NoderEdgeComponent extends DestroyComponent {
8444
8441
  const height = this.contentHeight > maxHeight ? maxHeight : this.contentHeight;
8445
8442
  DomHelper.setStyle(this.typeContainer.nativeElement.style, this.typeContainerPosition, `${height}px`);
8446
8443
  }
8447
- initializeIntersectionObserver() {
8448
- const options = {
8449
- root: null,
8450
- rootMargin: '50px',
8451
- threshold: 0.01
8452
- };
8453
- return new IntersectionObserver(entries => {
8454
- entries.forEach(entry => {
8455
- const wasVisible = this.isVisible;
8456
- this.isVisible = entry.isIntersecting;
8457
- if (this.isVisible !== wasVisible) {
8458
- this.renderer.setVisibility(this.isVisible);
8459
- }
8460
- });
8461
- }, options);
8462
- }
8463
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderEdgeComponent, deps: [{ token: RegulatorService }, { token: EditorService }, { token: i6.TranslateService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
8444
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderEdgeComponent, deps: [{ token: RegulatorService }, { token: EditorService }, { token: i6.TranslateService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
8464
8445
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.5", type: NoderEdgeComponent, isStandalone: false, selector: "app-nod-edge", inputs: { model: "model", generalProperties: "generalProperties", margins: "margins", width: "width", parentSessionId: "parentSessionId", isEvenEdgesExist: "isEvenEdgesExist", type: "type" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, static: true }, { propertyName: "typeContainer", first: true, predicate: ["locationType"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div\n #container\n class=\"edit-container\"></div>\n<div\n #locationType\n class=\"location-type\">\n <span>{{ edgeNameByType }}</span>\n</div>\n", styles: [":host{height:100%;width:100%;background:transparent;display:block}.location-type{position:absolute;height:auto;width:auto;font-size:9pt;color:#333;background-color:#f2f2f2;border:1px solid #838282;border-radius:2px;padding:4px;margin-left:5px;z-index:2}.header-edit-mode{border-bottom:1px dashed #838282}.footer-edit-mode{border-top:1px dashed #838282}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
8465
8446
  }
8466
8447
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderEdgeComponent, decorators: [{
8467
8448
  type: Component,
8468
8449
  args: [{ selector: 'app-nod-edge', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div\n #container\n class=\"edit-container\"></div>\n<div\n #locationType\n class=\"location-type\">\n <span>{{ edgeNameByType }}</span>\n</div>\n", styles: [":host{height:100%;width:100%;background:transparent;display:block}.location-type{position:absolute;height:auto;width:auto;font-size:9pt;color:#333;background-color:#f2f2f2;border:1px solid #838282;border-radius:2px;padding:4px;margin-left:5px;z-index:2}.header-edit-mode{border-bottom:1px dashed #838282}.footer-edit-mode{border-top:1px dashed #838282}\n"] }]
8469
- }], ctorParameters: () => [{ type: RegulatorService }, { type: EditorService }, { type: i6.TranslateService }, { type: i0.ChangeDetectorRef }], propDecorators: { model: [{
8450
+ }], ctorParameters: () => [{ type: RegulatorService }, { type: EditorService }, { type: i6.TranslateService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }], propDecorators: { model: [{
8470
8451
  type: Input
8471
8452
  }], generalProperties: [{
8472
8453
  type: Input
@@ -9969,13 +9950,11 @@ class CommentHighlightLayer extends HighlightLayer {
9969
9950
  this.commentService = commentService;
9970
9951
  this.className = 'noder-highlight';
9971
9952
  this.selectedCommentClassName = 'noder-selected-highlight';
9972
- this.selectedCommentId = null;
9973
9953
  }
9974
9954
  update(config) {
9975
9955
  const comments = this.session.model.comments;
9976
9956
  if (!config?.isVisible || !comments?.length || !this.enabled) {
9977
9957
  this.element.innerHTML = '';
9978
- this.commentService.removeCommentsFromRender(this.session.sessionId);
9979
9958
  return;
9980
9959
  }
9981
9960
  this.config = config;
@@ -9992,7 +9971,7 @@ class CommentHighlightLayer extends HighlightLayer {
9992
9971
  continue;
9993
9972
  }
9994
9973
  if (!screenRange.isEmpty) {
9995
- const className = comment.commentId === this.selectedCommentId ? this.selectedCommentClassName : this.className;
9974
+ const className = comment.commentId === this.commentService.selectedCommentId ? this.selectedCommentClassName : this.className;
9996
9975
  const result = screenRange.isSingleLine
9997
9976
  ? this.drawSingleLineMarker(screenRange, className)
9998
9977
  : this.drawMultiLineMarker(screenRange, className);
@@ -10006,13 +9985,12 @@ class CommentHighlightLayer extends HighlightLayer {
10006
9985
  }
10007
9986
  }
10008
9987
  }
10009
- setSelectedComment(id) {
10010
- if (this.selectedCommentId) {
10011
- this.commentService.setCommentSelected(this.selectedCommentId, false);
10012
- }
10013
- this.selectedCommentId = id;
10014
- if (id) {
10015
- this.commentService.setCommentSelected(id);
9988
+ removeComment(id) {
9989
+ this.commentService.removeCommentFromRender(this.session.sessionId, id);
9990
+ }
9991
+ clearSessionComments() {
9992
+ if (this.session.model.comments.length) {
9993
+ this.commentService.removeCommentsFromRender(this.session.sessionId);
10016
9994
  }
10017
9995
  }
10018
9996
  requestCommentRender(highlight, id) {
@@ -10176,6 +10154,7 @@ class RenderChangesModel {
10176
10154
  this.selection ||
10177
10155
  this.search ||
10178
10156
  this.grammar ||
10157
+ this.commentHighlights ||
10179
10158
  this.comments ||
10180
10159
  this.scroll ||
10181
10160
  this.size ||
@@ -10191,6 +10170,7 @@ class RenderChangesModel {
10191
10170
  this.selection = false;
10192
10171
  this.search = false;
10193
10172
  this.grammar = false;
10173
+ this.commentHighlights = false;
10194
10174
  this.comments = false;
10195
10175
  this.scroll = false;
10196
10176
  this.size = false;
@@ -10209,48 +10189,6 @@ class RenderChangesModel {
10209
10189
  }
10210
10190
  }
10211
10191
 
10212
- class EventHelper {
10213
- static get nextFrame() {
10214
- if (!this._nextFrame) {
10215
- const nextFrame = (callback) => {
10216
- setTimeout(callback, 17);
10217
- };
10218
- this._nextFrame =
10219
- window.requestAnimationFrame ||
10220
- window['webkitRequestAnimationFrame'] ||
10221
- window['mozRequestAnimationFrame'] ||
10222
- window['msRequestAnimationFrame'] ||
10223
- window['oRequestAnimationFrame'] ||
10224
- nextFrame;
10225
- }
10226
- return this._nextFrame;
10227
- }
10228
- }
10229
-
10230
- class RenderLoop {
10231
- constructor(onRender) {
10232
- this.changes = new RenderChangesModel();
10233
- this.flush = () => {
10234
- const changes = this.changes;
10235
- if (changes.any) {
10236
- this.changes = new RenderChangesModel();
10237
- onRender(changes);
10238
- }
10239
- if (this.changes.any) {
10240
- this.schedule();
10241
- }
10242
- };
10243
- }
10244
- schedule(changes) {
10245
- if (changes) {
10246
- this.changes.apply(changes);
10247
- }
10248
- if (this.changes) {
10249
- EventHelper.nextFrame(this.flush);
10250
- }
10251
- }
10252
- }
10253
-
10254
10192
  class CustomElementInfo {
10255
10193
  constructor(init) {
10256
10194
  Object.assign(this, init);
@@ -10614,9 +10552,11 @@ class Renderer extends EventEmitting {
10614
10552
  get paragraphsAppeared$() {
10615
10553
  return this.paragraphsAppeared.asObservable();
10616
10554
  }
10617
- constructor(parentContainer, commentsService, session) {
10555
+ constructor(parentContainer, commentsService, session, loop) {
10618
10556
  super();
10619
10557
  this.session = session;
10558
+ this.loop = loop;
10559
+ this.grammarChecksEnabled = false;
10620
10560
  this.layerConfig = {
10621
10561
  width: 1,
10622
10562
  contentRange: new DistanceModel({ start: 0, end: 0 }), // paragraphs
@@ -10646,7 +10586,7 @@ class Renderer extends EventEmitting {
10646
10586
  width: 1
10647
10587
  };
10648
10588
  this.pagesCountChangedHandler = () => {
10649
- this.loop.schedule({ lines: true, selection: true });
10589
+ this.scheduleChanges({ lines: true, selection: true });
10650
10590
  };
10651
10591
  this.container = parentContainer;
10652
10592
  this.container.className += ' noder-editor';
@@ -10658,10 +10598,10 @@ class Renderer extends EventEmitting {
10658
10598
  this.commentsLayer = new CommentHighlightLayer(this.content, 'comments-highlight', this.session, commentsService);
10659
10599
  this.cursorLayer = new CursorLayer(this.content, this.session);
10660
10600
  this.dragAndDropSelectionLayer = new SelectionLayer(this.content, 'drag-and-drop-selection', this.session);
10661
- this.loop = new RenderLoop(changes => this.renderChanges(changes));
10601
+ loop.registerSession(this.session.sessionId, changes => this.renderChanges(changes));
10662
10602
  this.session.displayData.addEventListener('pagesCountChanged', this.pagesCountChangedHandler);
10663
10603
  this.visibilitySubscription = this.visibilitySubject
10664
- .pipe(debounceTime(3000), filter(x => x))
10604
+ .pipe(filter(() => this.grammarChecksEnabled), debounceTime(3000), filter(x => x))
10665
10605
  .subscribe(() => this.paragraphsScrolledIntoView());
10666
10606
  }
10667
10607
  renderChanges(changes, force) {
@@ -10679,7 +10619,7 @@ class Renderer extends EventEmitting {
10679
10619
  changes.scroll ||
10680
10620
  changes.search ||
10681
10621
  changes.grammar ||
10682
- changes.comments ||
10622
+ changes.commentHighlights ||
10683
10623
  changes.visibilityChanged) {
10684
10624
  changes.apply(this.computeLayerConfig());
10685
10625
  DomHelper.translate(this.content, 0, -this.layerConfig.offset);
@@ -10706,8 +10646,8 @@ class Renderer extends EventEmitting {
10706
10646
  if (changes.grammar) {
10707
10647
  this.renderGrammarHighlights();
10708
10648
  }
10709
- if (changes.comments) {
10710
- this.renderComments();
10649
+ if (changes.commentHighlights) {
10650
+ this.renderCommentHighlights();
10711
10651
  }
10712
10652
  if (changes.dragAndDrop) {
10713
10653
  this.renderDragAndDropSelection();
@@ -10715,7 +10655,7 @@ class Renderer extends EventEmitting {
10715
10655
  if (changes.visibilityChanged) {
10716
10656
  this.renderSearchHighlights();
10717
10657
  this.renderGrammarHighlights();
10718
- this.renderComments();
10658
+ this.renderCommentHighlights();
10719
10659
  this.visibilitySubject.next(this.isVisible);
10720
10660
  }
10721
10661
  this.session.onRendered();
@@ -10730,7 +10670,7 @@ class Renderer extends EventEmitting {
10730
10670
  if (lastRow < this.layerConfig.contentRange.start || firstRow > this.layerConfig.contentRange.end) {
10731
10671
  return;
10732
10672
  }
10733
- this.loop.schedule({ lines: true });
10673
+ this.scheduleChanges({ lines: true });
10734
10674
  }
10735
10675
  moveTextAreaToCursor() {
10736
10676
  if (!this.textarea) {
@@ -10752,38 +10692,38 @@ class Renderer extends EventEmitting {
10752
10692
  updateSelection(range) {
10753
10693
  if (range.isEmpty && this.selectionLayer.marker) {
10754
10694
  this.selectionLayer.marker = null;
10755
- this.loop.schedule({ selection: true });
10695
+ this.scheduleChanges({ selection: true });
10756
10696
  }
10757
10697
  else if (!range.isEmpty && !this.selectionLayer.marker?.isEqual(range)) {
10758
10698
  this.selectionLayer.marker = range;
10759
- this.loop.schedule({ selection: true });
10699
+ this.scheduleChanges({ selection: true });
10760
10700
  }
10761
10701
  }
10762
10702
  updateSearchHighlights(ranges) {
10763
10703
  if (this.searchHighlightLayer.markers.length !== ranges.length ||
10764
10704
  !this.searchHighlightLayer.markers.every(x => ranges.some(y => x.isEqual(y)))) {
10765
10705
  this.searchHighlightLayer.markers = ranges;
10766
- this.loop.schedule({ search: true });
10706
+ this.scheduleChanges({ search: true });
10767
10707
  }
10768
10708
  }
10769
10709
  updateCustomElementHighlights(ranges) {
10770
10710
  this.searchHighlightLayer.customElementsRanges = ranges;
10771
- this.loop.schedule({ search: true });
10711
+ this.scheduleChanges({ search: true });
10772
10712
  }
10773
10713
  updateActiveSearchHighlight(active) {
10774
10714
  this.searchHighlightLayer.active = active;
10775
- this.loop.schedule({ search: true });
10715
+ this.scheduleChanges({ search: true });
10776
10716
  }
10777
10717
  updateGrammarHighlights(paragraphId, errors) {
10778
10718
  this.grammarHighlightLayer.setErrors(paragraphId, errors);
10779
- this.loop.schedule({ grammar: true });
10719
+ this.scheduleChanges({ grammar: true });
10780
10720
  }
10781
10721
  removeGrammarHighlights(paragraphId) {
10782
10722
  this.grammarHighlightLayer.removeParagraphHighlights(paragraphId);
10783
10723
  }
10784
10724
  clearGrammarHighlights() {
10785
10725
  this.grammarHighlightLayer.clearHighlights();
10786
- this.loop.schedule({ grammar: true });
10726
+ this.scheduleChanges({ grammar: true });
10787
10727
  }
10788
10728
  paragraphsScrolledIntoView() {
10789
10729
  if (!this.layerConfig.visibleRange) {
@@ -10796,11 +10736,11 @@ class Renderer extends EventEmitting {
10796
10736
  updateDragAndDropSelection(range) {
10797
10737
  if (range.isEmpty && this.dragAndDropSelectionLayer.marker) {
10798
10738
  this.dragAndDropSelectionLayer.marker = null;
10799
- this.loop.schedule({ dragAndDrop: true });
10739
+ this.scheduleChanges({ dragAndDrop: true });
10800
10740
  }
10801
10741
  else if (!range.isEmpty && !this.dragAndDropSelectionLayer.marker?.isEqual(range)) {
10802
10742
  this.dragAndDropSelectionLayer.marker = range;
10803
- this.loop.schedule({ dragAndDrop: true });
10743
+ this.scheduleChanges({ dragAndDrop: true });
10804
10744
  }
10805
10745
  }
10806
10746
  clearDragAndDropSelection() {
@@ -10808,28 +10748,31 @@ class Renderer extends EventEmitting {
10808
10748
  return;
10809
10749
  }
10810
10750
  this.dragAndDropSelectionLayer.marker = null;
10811
- this.loop.schedule({ dragAndDrop: true });
10751
+ this.scheduleChanges({ dragAndDrop: true });
10812
10752
  }
10813
10753
  setVisibility(isVisible) {
10814
10754
  if (this.isVisible !== isVisible) {
10815
10755
  this.isVisible = isVisible;
10816
- this.loop.schedule({ visibilityChanged: true });
10756
+ if (!isVisible) {
10757
+ this.commentsLayer.clearSessionComments();
10758
+ }
10759
+ this.scheduleChanges({ visibilityChanged: true });
10817
10760
  }
10818
10761
  }
10819
10762
  /**
10820
10763
  * Triggers a full update of the text, for all the rows.
10821
10764
  **/
10822
10765
  updateText() {
10823
- this.loop.schedule({ text: true });
10766
+ this.scheduleChanges({ text: true });
10824
10767
  }
10825
10768
  updateTextAndCursor() {
10826
- this.loop.schedule({ text: true, cursor: true });
10769
+ this.scheduleChanges({ text: true, cursor: true });
10827
10770
  }
10828
10771
  updateMarker() {
10829
- this.loop.schedule({ marker: true });
10772
+ this.scheduleChanges({ marker: true });
10830
10773
  }
10831
10774
  updateCursor() {
10832
- this.loop.schedule({ cursor: true });
10775
+ this.scheduleChanges({ cursor: true });
10833
10776
  }
10834
10777
  // tokenDivider - used to measure if token fits (1 - should be fully fit, 2 - half of token, 3 - third part, ...) to be included
10835
10778
  screenToParagraph(x, y, tokenDivider = 1, rect) {
@@ -10883,15 +10826,24 @@ class Renderer extends EventEmitting {
10883
10826
  renderGrammarHighlights() {
10884
10827
  this.grammarHighlightLayer.update(this.layerConfig);
10885
10828
  }
10886
- renderComments() {
10829
+ renderCommentHighlights() {
10887
10830
  this.commentsLayer.update(this.layerConfig);
10888
10831
  }
10889
- setSelectedComment(comment) {
10890
- this.commentsLayer.setSelectedComment(comment);
10832
+ removeComment(id) {
10833
+ this.commentsLayer.removeComment(id);
10834
+ }
10835
+ clearComments() {
10836
+ this.commentsLayer.clearSessionComments();
10891
10837
  }
10892
10838
  setCommentsVisibility(value) {
10839
+ if (!value) {
10840
+ this.commentsLayer.clearSessionComments();
10841
+ }
10893
10842
  this.commentsLayer.enabled = value;
10894
10843
  }
10844
+ scheduleChanges(changes) {
10845
+ this.loop.schedule(this.session.sessionId, changes);
10846
+ }
10895
10847
  renderDragAndDropSelection() {
10896
10848
  this.dragAndDropSelectionLayer.update(this.layerConfig);
10897
10849
  }
@@ -10922,6 +10874,65 @@ class Renderer extends EventEmitting {
10922
10874
  }
10923
10875
  }
10924
10876
 
10877
+ class EventHelper {
10878
+ static get nextFrame() {
10879
+ if (!this._nextFrame) {
10880
+ const nextFrame = (callback) => {
10881
+ setTimeout(callback, 17);
10882
+ };
10883
+ this._nextFrame =
10884
+ window.requestAnimationFrame ||
10885
+ window['webkitRequestAnimationFrame'] ||
10886
+ window['mozRequestAnimationFrame'] ||
10887
+ window['msRequestAnimationFrame'] ||
10888
+ window['oRequestAnimationFrame'] ||
10889
+ nextFrame;
10890
+ }
10891
+ return this._nextFrame;
10892
+ }
10893
+ }
10894
+
10895
+ class RenderLoop {
10896
+ constructor() {
10897
+ this.sessionCallbacks = new Map();
10898
+ this.sessionChanges = new Map();
10899
+ this.flush = () => {
10900
+ const sessionsToRender = Array.from(this.sessionChanges.entries());
10901
+ const hasChanges = sessionsToRender.filter(([_, changes]) => changes.any);
10902
+ if (!hasChanges.length) {
10903
+ return;
10904
+ }
10905
+ for (const [sessionId, changes] of hasChanges) {
10906
+ const callback = this.sessionCallbacks.get(sessionId);
10907
+ callback(new RenderChangesModel(changes));
10908
+ this.sessionChanges.set(sessionId, new RenderChangesModel());
10909
+ }
10910
+ const hasMoreChanges = Array.from(this.sessionChanges.values()).some(changes => changes.any);
10911
+ if (hasMoreChanges) {
10912
+ EventHelper.nextFrame(this.flush);
10913
+ }
10914
+ };
10915
+ }
10916
+ registerSession(sessionId, onRender) {
10917
+ this.sessionCallbacks.set(sessionId, onRender);
10918
+ if (!this.sessionChanges.has(sessionId)) {
10919
+ this.sessionChanges.set(sessionId, new RenderChangesModel());
10920
+ }
10921
+ }
10922
+ unregisterSession(sessionId) {
10923
+ this.sessionCallbacks.delete(sessionId);
10924
+ this.sessionChanges.delete(sessionId);
10925
+ }
10926
+ schedule(sessionId, changes) {
10927
+ if (changes) {
10928
+ this.sessionChanges.get(sessionId).apply(changes);
10929
+ }
10930
+ if (this.sessionChanges.get(sessionId).any) {
10931
+ EventHelper.nextFrame(this.flush);
10932
+ }
10933
+ }
10934
+ }
10935
+
10925
10936
  /**
10926
10937
  * Represents a vertical scroll bar.
10927
10938
  * @class ScrollBar
@@ -11009,12 +11020,13 @@ class ScrollBar {
11009
11020
  }
11010
11021
 
11011
11022
  class SessionModel {
11012
- constructor(session, renderer, sessionId, parentSessionId, source) {
11023
+ constructor(session, renderer, sessionId, parentSessionId, source, nativeElement) {
11013
11024
  this.session = session;
11014
11025
  this.renderer = renderer;
11015
11026
  this.sessionId = sessionId;
11016
11027
  this.parentSessionId = parentSessionId;
11017
11028
  this.source = source;
11029
+ this.nativeElement = nativeElement;
11018
11030
  }
11019
11031
  }
11020
11032
 
@@ -11039,19 +11051,20 @@ class RenderComments {
11039
11051
  }
11040
11052
 
11041
11053
  class CommentLayer {
11042
- constructor(parentEl, commentService) {
11054
+ constructor(parentEl) {
11043
11055
  this.commentPadding = 8;
11044
11056
  this.rendersBySession = new Map();
11057
+ this.enabled = false;
11045
11058
  this.element = document.createElement('div');
11046
11059
  this.element.className = `noder-comments-layer`;
11047
11060
  parentEl.appendChild(this.element);
11048
- this.commentSubscription = commentService.commentRenderRequests$.subscribe(x => {
11049
- this.applyChanges(x);
11050
- this.renderComments();
11051
- });
11052
11061
  }
11053
- destroy() {
11054
- this.commentSubscription.unsubscribe();
11062
+ enable() {
11063
+ this.enabled = true;
11064
+ }
11065
+ disable() {
11066
+ this.enabled = false;
11067
+ this.element.innerHTML = '';
11055
11068
  }
11056
11069
  scrollComments(offsetY) {
11057
11070
  for (const [sessionId, comments] of this.rendersBySession) {
@@ -11064,6 +11077,9 @@ class CommentLayer {
11064
11077
  }
11065
11078
  }
11066
11079
  renderComments() {
11080
+ if (!this.enabled) {
11081
+ return;
11082
+ }
11067
11083
  this.element.innerHTML = '';
11068
11084
  const topOffset = this.element.getBoundingClientRect().top;
11069
11085
  const sortedComments = Array.from(this.rendersBySession.values())
@@ -11094,7 +11110,7 @@ class CommentLayer {
11094
11110
  }
11095
11111
  return;
11096
11112
  }
11097
- let lastCommentBounds = { from: 0, to: 0 };
11113
+ let lastCommentBounds = { from: -Infinity, to: -Infinity };
11098
11114
  for (let i = selectedIndex + 1; i < sortedComments.length; i++) {
11099
11115
  const comment = sortedComments[i];
11100
11116
  let top = comment.highlightTop - topOffset;
@@ -11255,12 +11271,6 @@ class VirtualRenderer {
11255
11271
  get cursorLayer() {
11256
11272
  return this.renderer.cursorLayer;
11257
11273
  }
11258
- get loop() {
11259
- return this.renderer.loop;
11260
- }
11261
- set loop(val) {
11262
- this.renderer.loop = val;
11263
- }
11264
11274
  get textarea() {
11265
11275
  return this.renderer.textarea;
11266
11276
  }
@@ -11276,9 +11286,12 @@ class VirtualRenderer {
11276
11286
  get paragraphsAppeared$() {
11277
11287
  return this.renderer.paragraphsAppeared.asObservable();
11278
11288
  }
11279
- constructor(parentContainer, mainSession, commentService, scrollBar) {
11289
+ constructor(parentContainer, mainSession, commentService, loop, scrollBar) {
11290
+ this.commentService = commentService;
11291
+ this.loop = loop;
11280
11292
  this.scrollBar = scrollBar;
11281
11293
  this.changes = new RenderChangesModel();
11294
+ this.grammarChecksEnabled = false;
11282
11295
  this.size = {
11283
11296
  width: 0,
11284
11297
  height: 0,
@@ -11289,18 +11302,19 @@ class VirtualRenderer {
11289
11302
  this.paragraphsScrolledIntoViewSubject = new Subject();
11290
11303
  this.container = parentContainer;
11291
11304
  this.createScroller();
11292
- this.renderer = new Renderer(parentContainer, commentService, mainSession);
11305
+ this.renderer = new Renderer(parentContainer, commentService, mainSession, loop);
11306
+ loop.registerSession(0, changes => this.renderChanges(changes));
11293
11307
  this.pagesLayer = new PagesLayer(this.renderer.content, mainSession);
11294
11308
  this.edgesLayer = new EdgesLayer(this.renderer.content, mainSession);
11295
- this.commentLayer = new CommentLayer(this.renderer.content, commentService);
11309
+ this.commentLayer = new CommentLayer(this.renderer.content);
11296
11310
  this.scrollSubscription = this.scrollBar.scrolled$.subscribe(x => {
11297
- this.loop.schedule({ scroll: true });
11298
11311
  this.commentLayer.scrollComments(x);
11312
+ this.scheduleChanges({ scroll: true, comments: true });
11299
11313
  });
11300
- this.createRenderLoop();
11301
11314
  this.paragraphsScrolledIntoViewSubscription = this.paragraphsScrolledIntoViewSubject
11302
- .pipe(debounceTime(3000))
11315
+ .pipe(filter(() => this.grammarChecksEnabled), debounceTime(3000))
11303
11316
  .subscribe(() => this.paragraphsScrolledIntoView());
11317
+ this.scheduleChanges({ full: true });
11304
11318
  }
11305
11319
  renderChanges(changes, force) {
11306
11320
  changes.apply(this.changes);
@@ -11343,7 +11357,7 @@ class VirtualRenderer {
11343
11357
  }
11344
11358
  if (changes.cursor) {
11345
11359
  this.renderCursor();
11346
- this.renderComments();
11360
+ this.renderCommentHighlights();
11347
11361
  }
11348
11362
  if (changes.marker || changes.selection) {
11349
11363
  this.renderSelection();
@@ -11354,8 +11368,11 @@ class VirtualRenderer {
11354
11368
  if (changes.grammar) {
11355
11369
  this.renderGrammarHighlights();
11356
11370
  }
11371
+ if (changes.commentHighlights) {
11372
+ this.renderCommentHighlights();
11373
+ }
11357
11374
  if (changes.comments) {
11358
- this.renderComments();
11375
+ this.commentLayer.renderComments();
11359
11376
  }
11360
11377
  if (changes.dragAndDrop) {
11361
11378
  this.renderDragAndDropSelection();
@@ -11376,7 +11393,7 @@ class VirtualRenderer {
11376
11393
  this.renderChanges(changes, true);
11377
11394
  }
11378
11395
  else {
11379
- this.loop.schedule(changes);
11396
+ this.scheduleChanges(changes);
11380
11397
  }
11381
11398
  this.scrollBar.setScrollTop(0);
11382
11399
  }
@@ -11406,11 +11423,34 @@ class VirtualRenderer {
11406
11423
  this.size.dirty = !width || !height;
11407
11424
  return changes;
11408
11425
  }
11409
- setSelectedComment(commentId) {
11410
- this.renderer.setSelectedComment(commentId);
11426
+ setSelectedComment(id) {
11427
+ const oldId = this.commentService.selectedCommentId;
11428
+ this.commentService.setSelectedComment(id);
11429
+ if (this.commentService.selectedCommentId !== oldId) {
11430
+ this.scheduleChanges({ comments: true });
11431
+ }
11411
11432
  }
11412
11433
  setCommentsVisibility(value) {
11434
+ if (value && !this.commentsSubscription) {
11435
+ this.commentLayer.enable();
11436
+ this.commentsSubscription = this.commentService.commentRenderRequests$.subscribe(x => {
11437
+ this.commentLayer.applyChanges(x);
11438
+ setTimeout(() => this.scheduleChanges({ comments: true }));
11439
+ });
11440
+ }
11441
+ else {
11442
+ this.commentLayer.disable();
11443
+ this.commentsSubscription?.unsubscribe();
11444
+ this.commentsSubscription = null;
11445
+ }
11413
11446
  this.renderer.setCommentsVisibility(value);
11447
+ this.scheduleChanges({ comments: true });
11448
+ }
11449
+ removeComment(id) {
11450
+ this.renderer.removeComment(id);
11451
+ }
11452
+ clearComments() {
11453
+ this.renderer.clearComments();
11414
11454
  }
11415
11455
  moveTextAreaToCursor() {
11416
11456
  if (!this.textarea) {
@@ -11471,6 +11511,9 @@ class VirtualRenderer {
11471
11511
  setVisibility(isVisible) {
11472
11512
  this.renderer.setVisibility(isVisible);
11473
11513
  }
11514
+ scheduleChanges(changes) {
11515
+ this.loop.schedule(0, changes);
11516
+ }
11474
11517
  scrollSelectionIntoView(anchor, lead, offset) {
11475
11518
  // first scroll anchor into view then scroll lead into view
11476
11519
  this.scrollCursorIntoView(anchor, offset);
@@ -11490,7 +11533,7 @@ class VirtualRenderer {
11490
11533
  top -= offset * this.container.scrollHeight;
11491
11534
  }
11492
11535
  this.scrollBar.setScrollTop(top);
11493
- this.loop.schedule({ scroll: true });
11536
+ this.scheduleChanges({ scroll: true });
11494
11537
  }
11495
11538
  else if (this.scrollBar.scrollTop + this.container.scrollHeight < top + position.height) {
11496
11539
  if (offset) {
@@ -11498,7 +11541,7 @@ class VirtualRenderer {
11498
11541
  }
11499
11542
  top += position.height - this.container.scrollHeight;
11500
11543
  this.scrollBar.setScrollTop(top);
11501
- this.loop.schedule({ scroll: true });
11544
+ this.scheduleChanges({ scroll: true });
11502
11545
  }
11503
11546
  }
11504
11547
  scrollBy(deltaY) {
@@ -11508,7 +11551,7 @@ class VirtualRenderer {
11508
11551
  const scrollTop = this.scrollBar.scrollTop + deltaY;
11509
11552
  this.scrollBar.setScrollTop(scrollTop);
11510
11553
  this.commentLayer.scrollComments(deltaY);
11511
- this.loop.schedule({ scroll: true });
11554
+ this.scheduleChanges({ scroll: true, comments: true });
11512
11555
  }
11513
11556
  // tokenDivider - used to measure if token fits (1 - should be fully fit, 2 - half of token, 3 - third part, ...) to be included
11514
11557
  screenToParagraph(x, y, tokenDivider = 1, rect) {
@@ -11534,8 +11577,9 @@ class VirtualRenderer {
11534
11577
  DomHelper.removeElement(this.scrollBar.element);
11535
11578
  this.pagesLayer.destroy();
11536
11579
  this.renderer.destroy();
11537
- this.commentLayer.destroy();
11580
+ this.commentLayer.disable();
11538
11581
  this.scrollSubscription?.unsubscribe();
11582
+ this.commentsSubscription?.unsubscribe();
11539
11583
  this.paragraphsScrolledIntoViewSubscription?.unsubscribe();
11540
11584
  }
11541
11585
  computeLayerConfig() {
@@ -11573,11 +11617,6 @@ class VirtualRenderer {
11573
11617
  this.scroller.className = 'noder-scroller';
11574
11618
  this.container.appendChild(this.scroller);
11575
11619
  }
11576
- createRenderLoop() {
11577
- this.loop = new RenderLoop(changes => this.renderChanges(changes));
11578
- this.renderer.loop = this.loop;
11579
- this.loop.schedule({ full: true });
11580
- }
11581
11620
  renderScroll(changes) {
11582
11621
  this.pagesLayer.update(this.layerConfig);
11583
11622
  this.edgesLayer.scrollEdges(this.layerConfig);
@@ -11624,8 +11663,8 @@ class VirtualRenderer {
11624
11663
  renderDragAndDropSelection() {
11625
11664
  this.renderer.renderDragAndDropSelection();
11626
11665
  }
11627
- renderComments() {
11628
- this.renderer.renderComments();
11666
+ renderCommentHighlights() {
11667
+ this.renderer.renderCommentHighlights();
11629
11668
  }
11630
11669
  }
11631
11670
 
@@ -11770,6 +11809,7 @@ class CommentRenderService {
11770
11809
  this.applicationRef = inject(ApplicationRef);
11771
11810
  this.injector = inject(Injector);
11772
11811
  this.commentRenderRequests = new Subject();
11812
+ this.selectedCommentId = null;
11773
11813
  }
11774
11814
  requestCommentsRender(sessionId, renderRequests) {
11775
11815
  const requests = [];
@@ -11803,9 +11843,17 @@ class CommentRenderService {
11803
11843
  removeCommentsFromRender(sessionId) {
11804
11844
  this.commentRenderRequests.next(new RemoveCommentsFromDom(sessionId));
11805
11845
  }
11806
- setCommentSelected(id, selected = true) {
11846
+ setSelectedComment(id) {
11847
+ if (this.selectedCommentId === id) {
11848
+ return;
11849
+ }
11850
+ if (this.selectedCommentId) {
11851
+ const oldComponentRef = this.componentInstances.find(x => x.instance.id === this.selectedCommentId);
11852
+ oldComponentRef?.instance.setSelected(false);
11853
+ }
11807
11854
  const componentRef = this.componentInstances.find(x => x.instance.id === id);
11808
- componentRef?.instance.setSelected(selected);
11855
+ componentRef?.instance.setSelected(true);
11856
+ this.selectedCommentId = id;
11809
11857
  }
11810
11858
  createComponentRef(id) {
11811
11859
  const ref = createComponent(this.componentType, {
@@ -11833,7 +11881,11 @@ class RegulatorService {
11833
11881
  this.sessions = [];
11834
11882
  this.sessionIdIncrement = 0;
11835
11883
  this.grammarEnabled = false;
11884
+ this.selectedCommentSessionId = null;
11885
+ this.selectedCommentId = null;
11886
+ this.renderLoop = new RenderLoop();
11836
11887
  this.grammarChecker = new GrammarChecker(this.grammarService);
11888
+ this.observer = this.initializeIntersectionObserver();
11837
11889
  }
11838
11890
  addMainSession(model, scalingRatio, container) {
11839
11891
  const sessionId = ++this.sessionIdIncrement;
@@ -11860,9 +11912,9 @@ class RegulatorService {
11860
11912
  const displayData = new DisplayData(model, properties, sessionId, model.pageFormats, DocumentInfo.pagesSpace, customComponents, this.customContentService, this.editorService);
11861
11913
  const scrollBar = new ScrollBar(container.nativeElement.parentElement);
11862
11914
  const mainSession = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, model, this.selection, properties, this.editorService, customComponents, 'main', scrollBar);
11863
- const virtualRenderer = new VirtualRenderer(container.nativeElement, mainSession, this.commentRenderService, scrollBar);
11915
+ this.mainRenderer = new VirtualRenderer(container.nativeElement, mainSession, this.commentRenderService, this.renderLoop, scrollBar);
11864
11916
  this.editorService.styles = DEFAULT_TOOLBAR_STYLES();
11865
- this.mainSession = new SessionModel(mainSession, virtualRenderer, sessionId, null, new MainSessionSourceModel());
11917
+ this.mainSession = new SessionModel(mainSession, this.mainRenderer, sessionId, null, new MainSessionSourceModel(), container.nativeElement);
11866
11918
  this.sessions.push(this.mainSession);
11867
11919
  this.currentSession = this.mainSession;
11868
11920
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
@@ -11870,45 +11922,48 @@ class RegulatorService {
11870
11922
  this.grammarChecker.registerSession(this.mainSession);
11871
11923
  }
11872
11924
  }
11873
- addCellSession(table, margins, component, properties) {
11925
+ addCellSession(margins, component, nativeElement) {
11874
11926
  const sessionId = ++this.sessionIdIncrement;
11875
11927
  const customComponents = { images: [], tables: [], tabs: [], customElements: [], edges: null };
11876
- const displayData = new DisplayData(component.cell, properties, sessionId, this.getPageFormats(margins, component.width), 0, customComponents, this.customContentService, this.editorService);
11928
+ const displayData = new DisplayData(component.cell, component.generalProperties, sessionId, this.getPageFormats(margins, component.width), 0, customComponents, this.customContentService, this.editorService);
11877
11929
  const sessionType = this.isWithinEdge(component.parentSessionId) ? 'cellWithinEdge' : 'cell';
11878
- const session = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, component.cell, this.selection, properties, this.editorService, customComponents, sessionType);
11930
+ const session = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, component.cell, this.selection, component.generalProperties, this.editorService, customComponents, sessionType);
11879
11931
  displayData.pagesFormat[0].contentWidth =
11880
11932
  displayData.pagesFormat[0].contentWidth === 0 ? 1 : displayData.pagesFormat[0].contentWidth;
11881
- const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session);
11882
- const source = new CellSessionSourceModel(table, component);
11883
- const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source);
11933
+ const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session, this.renderLoop);
11934
+ const source = new CellSessionSourceModel(component.table, component);
11935
+ const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source, nativeElement);
11884
11936
  this.sessions.push(newSession);
11885
11937
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
11886
11938
  newSession.renderer.updateText();
11887
11939
  if (this.grammarEnabled) {
11888
11940
  this.grammarChecker.registerSession(newSession);
11889
11941
  }
11942
+ this.observer.observe(nativeElement);
11890
11943
  return newSession;
11891
11944
  }
11892
- addEdgeSession(component) {
11945
+ addEdgeSession(component, nativeElement) {
11893
11946
  const sessionId = ++this.sessionIdIncrement;
11894
11947
  const customComponents = { images: [], tables: [], tabs: [], customElements: [], edges: null };
11895
11948
  const displayData = new DisplayData(component.model, component.generalProperties, sessionId, this.getPageFormats(component.margins, component.width), 0, customComponents, this.customContentService, this.editorService);
11896
11949
  const session = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, component.model, this.selection, component.generalProperties, this.editorService, customComponents, 'edge', null, component.type, component.model.pageType);
11897
- const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session);
11950
+ const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session, this.renderLoop);
11898
11951
  const source = new EdgeSessionSourceModel(component.model.pageType, component.type);
11899
- const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source);
11952
+ const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source, nativeElement);
11900
11953
  this.sessions.push(newSession);
11901
11954
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
11902
11955
  newSession.renderer.updateText();
11903
11956
  if (this.grammarEnabled) {
11904
11957
  this.grammarChecker.registerSession(newSession);
11905
11958
  }
11959
+ this.observer.observe(nativeElement);
11906
11960
  return newSession;
11907
11961
  }
11908
11962
  removeSession(sessionId) {
11909
11963
  const index = this.sessions.findIndex(x => x.sessionId === sessionId);
11910
11964
  this.sessions[index].session.destroy();
11911
11965
  this.sessions[index].renderer.destroy();
11966
+ this.observer.unobserve(this.sessions[index].nativeElement);
11912
11967
  this.sessions.splice(index, 1);
11913
11968
  this.grammarChecker.unregisterSession(sessionId);
11914
11969
  }
@@ -12052,9 +12107,48 @@ class RegulatorService {
12052
12107
  setCommentsVisibility(value) {
12053
12108
  for (const sessionModel of this.sessions) {
12054
12109
  sessionModel.renderer.setCommentsVisibility(value);
12055
- sessionModel.renderer.loop.schedule({ comments: true });
12110
+ sessionModel.renderer.scheduleChanges({ commentHighlights: true });
12056
12111
  }
12057
12112
  }
12113
+ setSelectedComment(commentId) {
12114
+ if (!commentId) {
12115
+ if (!this.selectedCommentSessionId) {
12116
+ return;
12117
+ }
12118
+ const sessionModel = this.getSessionModel(this.selectedCommentSessionId);
12119
+ this.mainRenderer.setSelectedComment(null);
12120
+ sessionModel.renderer.scheduleChanges({ commentHighlights: true });
12121
+ return;
12122
+ }
12123
+ this.mainRenderer.setSelectedComment(commentId);
12124
+ const newSelectedSession = this.sessions.find(x => x.session.model.comments.some(c => c.commentId === commentId));
12125
+ if (this.selectedCommentSessionId && this.selectedCommentSessionId !== newSelectedSession.sessionId) {
12126
+ const sessionModel = this.getSessionModel(this.selectedCommentSessionId);
12127
+ sessionModel.renderer.scheduleChanges({ commentHighlights: true });
12128
+ newSelectedSession.renderer.scheduleChanges({ commentHighlights: true });
12129
+ }
12130
+ else {
12131
+ newSelectedSession.renderer.scheduleChanges({ commentHighlights: true });
12132
+ }
12133
+ this.selectedCommentId = commentId;
12134
+ this.selectedCommentSessionId = newSelectedSession.sessionId;
12135
+ }
12136
+ setSelectedCommentAtCursor() {
12137
+ const comment = this.currentSession.session.getCommentAtCursor();
12138
+ this.mainRenderer.setSelectedComment(comment?.commentId);
12139
+ if (this.selectedCommentId && this.selectedCommentId !== comment?.commentId) {
12140
+ const sessionModel = this.getSessionModel(this.selectedCommentSessionId);
12141
+ sessionModel.renderer.scheduleChanges({ commentHighlights: true });
12142
+ }
12143
+ if (comment) {
12144
+ this.currentSession.renderer.scheduleChanges({ commentHighlights: true });
12145
+ this.selectedCommentId = comment.commentId;
12146
+ this.selectedCommentSessionId = this.currentSession.sessionId;
12147
+ return;
12148
+ }
12149
+ this.selectedCommentId = null;
12150
+ this.selectedCommentSessionId = null;
12151
+ }
12058
12152
  isWithinEdge(sessionId) {
12059
12153
  return !!this.getEdgeSessionId(sessionId);
12060
12154
  }
@@ -12082,12 +12176,14 @@ class RegulatorService {
12082
12176
  for (const session of this.sessions) {
12083
12177
  this.grammarChecker.registerSession(session);
12084
12178
  session.renderer.paragraphsScrolledIntoView();
12179
+ session.renderer.grammarChecksEnabled = true;
12085
12180
  }
12086
12181
  return;
12087
12182
  }
12088
12183
  for (const session of this.sessions) {
12089
12184
  this.grammarChecker.unregisterSession(session.sessionId);
12090
12185
  session.renderer.clearGrammarHighlights();
12186
+ session.renderer.grammarChecksEnabled = false;
12091
12187
  }
12092
12188
  }
12093
12189
  getEdgeSessionId(sessionId) {
@@ -12125,6 +12221,19 @@ class RegulatorService {
12125
12221
  })
12126
12222
  ];
12127
12223
  }
12224
+ initializeIntersectionObserver() {
12225
+ const options = {
12226
+ root: null,
12227
+ rootMargin: '50px',
12228
+ threshold: 0.01
12229
+ };
12230
+ return new IntersectionObserver(entries => {
12231
+ entries.forEach(entry => {
12232
+ const sessionId = +entry.target.getAttribute('data-session-id');
12233
+ this.getSessionModel(sessionId)?.renderer.setVisibility(entry.isIntersecting);
12234
+ });
12235
+ }, options);
12236
+ }
12128
12237
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RegulatorService, deps: [{ token: CustomContentService }, { token: EditorService }, { token: ComponentService }, { token: GrammarService }, { token: CommentRenderService }], target: i0.ɵɵFactoryTarget.Injectable }); }
12129
12238
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RegulatorService }); }
12130
12239
  }
@@ -12139,12 +12248,12 @@ class NoderTableCellComponent {
12139
12248
  get renderer() {
12140
12249
  return this.cellSession.renderer;
12141
12250
  }
12142
- constructor(editorService, regulatorService) {
12251
+ constructor(editorService, regulatorService, elementRef) {
12143
12252
  this.editorService = editorService;
12144
12253
  this.regulatorService = regulatorService;
12254
+ this.elementRef = elementRef;
12145
12255
  this.isHighlighted = false;
12146
12256
  this.resizerBorder = ResizerSide;
12147
- this.isVisible = false;
12148
12257
  this.pagesCountChangedHandler = (event) => {
12149
12258
  if (this._allParagraphsHeight === event.pageHeight) {
12150
12259
  return;
@@ -12153,14 +12262,9 @@ class NoderTableCellComponent {
12153
12262
  this.heightChanged(this.rowIndex, this.cellIndex, event.pageHeight);
12154
12263
  };
12155
12264
  }
12156
- ngAfterViewInit() {
12157
- this.intersectionObserver = this.initializeIntersectionObserver();
12158
- this.intersectionObserver.observe(this.container.nativeElement);
12159
- }
12160
12265
  ngOnDestroy() {
12161
12266
  this.session?.displayData.removeEventListener('pagesCountChanged', this.pagesCountChangedHandler);
12162
12267
  this.regulatorService.removeSession(this.sessionId);
12163
- this.intersectionObserver?.disconnect();
12164
12268
  }
12165
12269
  initialize() {
12166
12270
  const marginModel = new MarginModel({
@@ -12171,7 +12275,7 @@ class NoderTableCellComponent {
12171
12275
  header: 0,
12172
12276
  footer: 0
12173
12277
  });
12174
- this.cellSession = this.regulatorService.addCellSession(this.table, marginModel, this, this.generalProperties);
12278
+ this.cellSession = this.regulatorService.addCellSession(marginModel, this, this.elementRef.nativeElement);
12175
12279
  this.sessionId = this.cellSession.sessionId;
12176
12280
  this.addEventListeners();
12177
12281
  }
@@ -12192,29 +12296,13 @@ class NoderTableCellComponent {
12192
12296
  addEventListeners() {
12193
12297
  this.session.displayData.addEventListener('pagesCountChanged', this.pagesCountChangedHandler);
12194
12298
  }
12195
- initializeIntersectionObserver() {
12196
- const options = {
12197
- root: null,
12198
- rootMargin: '50px',
12199
- threshold: 0.01
12200
- };
12201
- return new IntersectionObserver(entries => {
12202
- entries.forEach(entry => {
12203
- const wasVisible = this.isVisible;
12204
- this.isVisible = entry.isIntersecting;
12205
- if (this.isVisible !== wasVisible) {
12206
- this.renderer.setVisibility(this.isVisible);
12207
- }
12208
- });
12209
- }, options);
12210
- }
12211
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderTableCellComponent, deps: [{ token: EditorService }, { token: RegulatorService }], target: i0.ɵɵFactoryTarget.Component }); }
12299
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderTableCellComponent, deps: [{ token: EditorService }, { token: RegulatorService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
12212
12300
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.5", type: NoderTableCellComponent, isStandalone: false, selector: "app-nod-table-cell", inputs: { table: "table", cell: "cell", rowIndex: "rowIndex", cellIndex: "cellIndex", columnIndex: "columnIndex", width: "width", parentSessionId: "parentSessionId", generalProperties: "generalProperties", heightChanged: "heightChanged", startResizing: "startResizing" }, host: { properties: { "class.highlighted": "this.isHighlighted", "attr.data-session-id": "this.sessionId" } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, static: true }], ngImport: i0, template: "<div\n *ngIf=\"cellIndex === 0\"\n class=\"resizer left-border\"\n (mousedown)=\"onStartResizing($event, resizerBorder.Left)\"></div>\n<div\n #container\n class=\"edit-container\"></div>\n<div class=\"highlight-container\"></div>\n<div\n class=\"resizer right-border\"\n (mousedown)=\"onStartResizing($event, resizerBorder.Right)\"></div>\n", styles: [".highlight-container{visibility:hidden;position:absolute;width:100%;height:100%;background-color:#5ea8f766;pointer-events:none;overflow:hidden}:host{display:flex;position:relative;min-height:19px;height:100%;background:transparent}:host.highlighted .highlight-container{visibility:visible}.edit-container{min-height:1px;overflow:hidden}.left-border{left:-6px}.resizer{cursor:col-resize;width:11px;height:100%;position:absolute;z-index:1}.right-border{right:-6px}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
12213
12301
  }
12214
12302
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderTableCellComponent, decorators: [{
12215
12303
  type: Component,
12216
12304
  args: [{ selector: 'app-nod-table-cell', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div\n *ngIf=\"cellIndex === 0\"\n class=\"resizer left-border\"\n (mousedown)=\"onStartResizing($event, resizerBorder.Left)\"></div>\n<div\n #container\n class=\"edit-container\"></div>\n<div class=\"highlight-container\"></div>\n<div\n class=\"resizer right-border\"\n (mousedown)=\"onStartResizing($event, resizerBorder.Right)\"></div>\n", styles: [".highlight-container{visibility:hidden;position:absolute;width:100%;height:100%;background-color:#5ea8f766;pointer-events:none;overflow:hidden}:host{display:flex;position:relative;min-height:19px;height:100%;background:transparent}:host.highlighted .highlight-container{visibility:visible}.edit-container{min-height:1px;overflow:hidden}.left-border{left:-6px}.resizer{cursor:col-resize;width:11px;height:100%;position:absolute;z-index:1}.right-border{right:-6px}\n"] }]
12217
- }], ctorParameters: () => [{ type: EditorService }, { type: RegulatorService }], propDecorators: { table: [{
12305
+ }], ctorParameters: () => [{ type: EditorService }, { type: RegulatorService }, { type: i0.ElementRef }], propDecorators: { table: [{
12218
12306
  type: Input
12219
12307
  }], cell: [{
12220
12308
  type: Input
@@ -13331,16 +13419,12 @@ class RenderingHelper {
13331
13419
  }
13332
13420
  const components = customContentService.getComponents(customComponents, fragmentStartIndex, fragmentEndIndex);
13333
13421
  for (const component of components) {
13334
- const textBeforeElement = fragmentText.substring(0, component.instance.insertIndex - fragmentStartIndex);
13422
+ const instance = component.instance;
13423
+ const textBeforeElement = fragmentText.substring(0, instance.insertIndex - fragmentStartIndex);
13335
13424
  fragmentText = fragmentText.substring(textBeforeElement.length + 1, fragmentText.length);
13336
13425
  this.renderText(fragment, textStyle, textBeforeElement, wordSpacing);
13337
13426
  renderedIndexes += textBeforeElement.length;
13338
- if (component.instance instanceof ExternalComponent && component.instance.isText) {
13339
- const rendered = this.renderExternalText(fragment, textStyle, wordSpacing, component.instance, line, renderedTokensInLine + renderedIndexes + additionalTokens, paragraphStartIndex);
13340
- renderedIndexes += rendered.renderedIndexes;
13341
- additionalTokens += rendered.additionalTokens;
13342
- }
13343
- else if (component.instance instanceof NoderTableComponent && line.customTexts?.length > 0) {
13427
+ if (instance instanceof NoderTableComponent && line.customTexts?.length > 0) {
13344
13428
  if (line.customTexts[0].start === 0) {
13345
13429
  this.renderText(fragment, textStyle, ' ', wordSpacing);
13346
13430
  additionalTokens++;
@@ -13350,6 +13434,12 @@ class RenderingHelper {
13350
13434
  renderedIndexes++;
13351
13435
  }
13352
13436
  }
13437
+ else if (instance instanceof ExternalComponent && line.customTexts?.some(x => x.index === instance.insertIndex)) {
13438
+ const tokens = renderedTokensInLine + renderedIndexes + additionalTokens;
13439
+ const rendered = this.renderExternalText(fragment, textStyle, wordSpacing, instance, line, tokens, paragraphStartIndex);
13440
+ renderedIndexes += rendered.renderedIndexes;
13441
+ additionalTokens += rendered.additionalTokens;
13442
+ }
13353
13443
  else {
13354
13444
  customContentService.componentService.attachComponent(fragment, component);
13355
13445
  renderedIndexes++;
@@ -15931,16 +16021,17 @@ class Editor {
15931
16021
  this.commentCreateRequests = this.commentCreateRequests.filter(x => x.reqId !== reqId);
15932
16022
  commentModel.commentId = commentId;
15933
16023
  sessionModel.session.addComment(commentModel);
15934
- sessionModel.renderer.setSelectedComment(commentModel.commentId);
15935
- sessionModel.renderer.loop.schedule({ comments: true });
16024
+ this.mainRenderer.setSelectedComment(commentModel.commentId);
16025
+ sessionModel.renderer.scheduleChanges({ commentHighlights: true });
15936
16026
  this.saveAttachCommentToHistory(commentModel);
15937
16027
  }
15938
16028
  onCommentRemoved(id) {
15939
16029
  const session = this.regulatorService.getCommentSessionModel(id);
15940
16030
  const comment = session.session.removeComment(id);
16031
+ session.renderer.removeComment(id);
15941
16032
  this.saveRemoveCommentToHistory(comment, session.source.getTarget());
15942
16033
  this.editorService.removeCommentData([id]);
15943
- session.renderer.loop.schedule({ comments: true });
16034
+ session.renderer.scheduleChanges({ commentHighlights: true });
15944
16035
  }
15945
16036
  onCommentTextReplace(commentId, newText) {
15946
16037
  const { session, comment } = this.regulatorService.getComment(commentId);
@@ -15973,7 +16064,7 @@ class Editor {
15973
16064
  window.removeEventListener('resize', this.rerenderResize);
15974
16065
  }
15975
16066
  rerenderMarker() {
15976
- this.renderer.loop.schedule({ marker: true });
16067
+ this.renderer.scheduleChanges({ marker: true });
15977
16068
  }
15978
16069
  onBlur() {
15979
16070
  if (!this.textInput.isFocused) {
@@ -16311,7 +16402,7 @@ class Editor {
16311
16402
  this.editorService.paragraphStyle(this.model.paragraphs[0].paragraphStyle);
16312
16403
  this.regulatorService.addMainSession(this.model, scalingRatio, this.container);
16313
16404
  }
16314
- onSelectionChange() {
16405
+ onSelectionChange(isMouseSelection = false) {
16315
16406
  this.session.applyToolbarStyles();
16316
16407
  this.renderer.updateSelection(this.selection.selectedRange);
16317
16408
  if (this.selection.isEmpty) {
@@ -16326,8 +16417,8 @@ class Editor {
16326
16417
  this.editorService.paragraphStyle(paragraphStyle, numbering);
16327
16418
  this.editorService.setPageFormat(pageFormat.pageFormatModel);
16328
16419
  this.rerenderMarker();
16329
- this.updateSelectedComment();
16330
- if (!this.selection.isEmpty && this.commentsVisible) {
16420
+ this.regulatorService.setSelectedCommentAtCursor();
16421
+ if (!this.selection.isEmpty && this.commentsVisible && !isMouseSelection) {
16331
16422
  const paragraphPos = this.session.selection.cursor;
16332
16423
  const cursor = PositionHelper.paragraphToPixel(this.session, paragraphPos.row, paragraphPos.column);
16333
16424
  const mainRect = this.mainRenderer.container.getBoundingClientRect();
@@ -16338,7 +16429,7 @@ class Editor {
16338
16429
  }
16339
16430
  }
16340
16431
  onContentChange() {
16341
- this.renderer.loop.schedule({ comments: true });
16432
+ this.renderer.scheduleChanges({ commentHighlights: true });
16342
16433
  if (this.search.term) {
16343
16434
  this.find(this.search.term);
16344
16435
  }
@@ -16442,7 +16533,7 @@ class Editor {
16442
16533
  const cursor = this.selection.cursor;
16443
16534
  this.selection.moveSelection(position);
16444
16535
  if (cursor.column !== this.selection.cursor.column || cursor.row !== this.selection.cursor.row) {
16445
- this.onSelectionChange();
16536
+ this.onSelectionChange(true);
16446
16537
  }
16447
16538
  this.scrollCursorIntoMainView();
16448
16539
  }
@@ -16543,7 +16634,7 @@ class Editor {
16543
16634
  viewOnlyModeSubscription() {
16544
16635
  return this.editorService.isViewOnly$.subscribe(() => {
16545
16636
  this.selection?.clearSelection();
16546
- this.renderer.loop.schedule({ grammar: true });
16637
+ this.renderer.scheduleChanges({ grammar: true });
16547
16638
  });
16548
16639
  }
16549
16640
  applyLeftMarginPageFormatSubscription() {
@@ -16871,15 +16962,10 @@ class Editor {
16871
16962
  ];
16872
16963
  }
16873
16964
  rerenderCommentsSubscription() {
16874
- return this.editorService.commentSizeChanged$.subscribe(() => this.mainRenderer.loop.schedule({ comments: true }));
16965
+ return this.editorService.commentSizeChanged$.subscribe(() => this.mainRenderer.scheduleChanges({ comments: true }));
16875
16966
  }
16876
16967
  selectCommentSubscription() {
16877
- return this.editorService.setCommentSelected$.subscribe(x => {
16878
- for (const session of this.regulatorService.sessions) {
16879
- session.renderer.setSelectedComment(x);
16880
- session.renderer.loop.schedule({ comments: true });
16881
- }
16882
- });
16968
+ return this.editorService.setCommentSelected$.subscribe(x => this.regulatorService.setSelectedComment(x));
16883
16969
  }
16884
16970
  removeCommentSubscription() {
16885
16971
  return this.editorService.removeComment$.subscribe(x => this.onCommentRemoved(x));
@@ -16960,16 +17046,6 @@ class Editor {
16960
17046
  this.overlayService.open(CommentPopupComponent, {}, hintX, hintY);
16961
17047
  event?.stopPropagation();
16962
17048
  }
16963
- updateSelectedComment() {
16964
- for (const session of this.regulatorService.sessions) {
16965
- if (!this.selection.range.isEmpty || session.session !== this.session) {
16966
- session.renderer.setSelectedComment(null);
16967
- continue;
16968
- }
16969
- const comment = session.session.getCommentAtCursor();
16970
- session.renderer.setSelectedComment(comment?.commentId);
16971
- }
16972
- }
16973
17049
  }
16974
17050
 
16975
17051
  const EDITOR_VERSION = '2';