@talrace/ngx-noder 19.0.50 → 19.0.51

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
@@ -9975,7 +9956,6 @@ class CommentHighlightLayer extends HighlightLayer {
9975
9956
  const comments = this.session.model.comments;
9976
9957
  if (!config?.isVisible || !comments?.length || !this.enabled) {
9977
9958
  this.element.innerHTML = '';
9978
- this.commentService.removeCommentsFromRender(this.session.sessionId);
9979
9959
  return;
9980
9960
  }
9981
9961
  this.config = config;
@@ -10006,6 +9986,12 @@ class CommentHighlightLayer extends HighlightLayer {
10006
9986
  }
10007
9987
  }
10008
9988
  }
9989
+ removeSessionComments() {
9990
+ this.commentService.removeCommentsFromRender(this.session.sessionId);
9991
+ }
9992
+ removeComment(id) {
9993
+ this.commentService.removeCommentFromRender(this.session.sessionId, id);
9994
+ }
10009
9995
  setSelectedComment(id) {
10010
9996
  if (this.selectedCommentId) {
10011
9997
  this.commentService.setCommentSelected(this.selectedCommentId, false);
@@ -10015,6 +10001,9 @@ class CommentHighlightLayer extends HighlightLayer {
10015
10001
  this.commentService.setCommentSelected(id);
10016
10002
  }
10017
10003
  }
10004
+ clearSessionComments() {
10005
+ this.commentService.removeCommentsFromRender(this.session.sessionId);
10006
+ }
10018
10007
  requestCommentRender(highlight, id) {
10019
10008
  const element = Array.isArray(highlight) ? highlight[0] : highlight;
10020
10009
  const rect = element.getBoundingClientRect();
@@ -10176,6 +10165,7 @@ class RenderChangesModel {
10176
10165
  this.selection ||
10177
10166
  this.search ||
10178
10167
  this.grammar ||
10168
+ this.commentHighlights ||
10179
10169
  this.comments ||
10180
10170
  this.scroll ||
10181
10171
  this.size ||
@@ -10191,6 +10181,7 @@ class RenderChangesModel {
10191
10181
  this.selection = false;
10192
10182
  this.search = false;
10193
10183
  this.grammar = false;
10184
+ this.commentHighlights = false;
10194
10185
  this.comments = false;
10195
10186
  this.scroll = false;
10196
10187
  this.size = false;
@@ -10679,7 +10670,7 @@ class Renderer extends EventEmitting {
10679
10670
  changes.scroll ||
10680
10671
  changes.search ||
10681
10672
  changes.grammar ||
10682
- changes.comments ||
10673
+ changes.commentHighlights ||
10683
10674
  changes.visibilityChanged) {
10684
10675
  changes.apply(this.computeLayerConfig());
10685
10676
  DomHelper.translate(this.content, 0, -this.layerConfig.offset);
@@ -10706,8 +10697,8 @@ class Renderer extends EventEmitting {
10706
10697
  if (changes.grammar) {
10707
10698
  this.renderGrammarHighlights();
10708
10699
  }
10709
- if (changes.comments) {
10710
- this.renderComments();
10700
+ if (changes.commentHighlights) {
10701
+ this.renderCommentHighlights();
10711
10702
  }
10712
10703
  if (changes.dragAndDrop) {
10713
10704
  this.renderDragAndDropSelection();
@@ -10715,7 +10706,7 @@ class Renderer extends EventEmitting {
10715
10706
  if (changes.visibilityChanged) {
10716
10707
  this.renderSearchHighlights();
10717
10708
  this.renderGrammarHighlights();
10718
- this.renderComments();
10709
+ this.renderCommentHighlights();
10719
10710
  this.visibilitySubject.next(this.isVisible);
10720
10711
  }
10721
10712
  this.session.onRendered();
@@ -10813,6 +10804,9 @@ class Renderer extends EventEmitting {
10813
10804
  setVisibility(isVisible) {
10814
10805
  if (this.isVisible !== isVisible) {
10815
10806
  this.isVisible = isVisible;
10807
+ if (!isVisible) {
10808
+ this.commentsLayer.clearSessionComments();
10809
+ }
10816
10810
  this.loop.schedule({ visibilityChanged: true });
10817
10811
  }
10818
10812
  }
@@ -10883,13 +10877,22 @@ class Renderer extends EventEmitting {
10883
10877
  renderGrammarHighlights() {
10884
10878
  this.grammarHighlightLayer.update(this.layerConfig);
10885
10879
  }
10886
- renderComments() {
10880
+ renderCommentHighlights() {
10887
10881
  this.commentsLayer.update(this.layerConfig);
10888
10882
  }
10889
10883
  setSelectedComment(comment) {
10890
10884
  this.commentsLayer.setSelectedComment(comment);
10891
10885
  }
10886
+ removeComment(id) {
10887
+ this.commentsLayer.removeComment(id);
10888
+ }
10889
+ clearComments() {
10890
+ this.commentsLayer.removeSessionComments();
10891
+ }
10892
10892
  setCommentsVisibility(value) {
10893
+ if (!value) {
10894
+ this.commentsLayer.clearSessionComments();
10895
+ }
10893
10896
  this.commentsLayer.enabled = value;
10894
10897
  }
10895
10898
  renderDragAndDropSelection() {
@@ -11009,12 +11012,13 @@ class ScrollBar {
11009
11012
  }
11010
11013
 
11011
11014
  class SessionModel {
11012
- constructor(session, renderer, sessionId, parentSessionId, source) {
11015
+ constructor(session, renderer, sessionId, parentSessionId, source, nativeElement) {
11013
11016
  this.session = session;
11014
11017
  this.renderer = renderer;
11015
11018
  this.sessionId = sessionId;
11016
11019
  this.parentSessionId = parentSessionId;
11017
11020
  this.source = source;
11021
+ this.nativeElement = nativeElement;
11018
11022
  }
11019
11023
  }
11020
11024
 
@@ -11039,19 +11043,16 @@ class RenderComments {
11039
11043
  }
11040
11044
 
11041
11045
  class CommentLayer {
11042
- constructor(parentEl, commentService) {
11046
+ constructor(parentEl) {
11043
11047
  this.commentPadding = 8;
11044
11048
  this.rendersBySession = new Map();
11045
11049
  this.element = document.createElement('div');
11046
11050
  this.element.className = `noder-comments-layer`;
11047
11051
  parentEl.appendChild(this.element);
11048
- this.commentSubscription = commentService.commentRenderRequests$.subscribe(x => {
11049
- this.applyChanges(x);
11050
- this.renderComments();
11051
- });
11052
11052
  }
11053
- destroy() {
11054
- this.commentSubscription.unsubscribe();
11053
+ disable() {
11054
+ this.rendersBySession.clear();
11055
+ this.renderComments();
11055
11056
  }
11056
11057
  scrollComments(offsetY) {
11057
11058
  for (const [sessionId, comments] of this.rendersBySession) {
@@ -11094,7 +11095,7 @@ class CommentLayer {
11094
11095
  }
11095
11096
  return;
11096
11097
  }
11097
- let lastCommentBounds = { from: 0, to: 0 };
11098
+ let lastCommentBounds = { from: -Infinity, to: -Infinity };
11098
11099
  for (let i = selectedIndex + 1; i < sortedComments.length; i++) {
11099
11100
  const comment = sortedComments[i];
11100
11101
  let top = comment.highlightTop - topOffset;
@@ -11277,6 +11278,7 @@ class VirtualRenderer {
11277
11278
  return this.renderer.paragraphsAppeared.asObservable();
11278
11279
  }
11279
11280
  constructor(parentContainer, mainSession, commentService, scrollBar) {
11281
+ this.commentService = commentService;
11280
11282
  this.scrollBar = scrollBar;
11281
11283
  this.changes = new RenderChangesModel();
11282
11284
  this.size = {
@@ -11292,10 +11294,10 @@ class VirtualRenderer {
11292
11294
  this.renderer = new Renderer(parentContainer, commentService, mainSession);
11293
11295
  this.pagesLayer = new PagesLayer(this.renderer.content, mainSession);
11294
11296
  this.edgesLayer = new EdgesLayer(this.renderer.content, mainSession);
11295
- this.commentLayer = new CommentLayer(this.renderer.content, commentService);
11297
+ this.commentLayer = new CommentLayer(this.renderer.content);
11296
11298
  this.scrollSubscription = this.scrollBar.scrolled$.subscribe(x => {
11297
- this.loop.schedule({ scroll: true });
11298
11299
  this.commentLayer.scrollComments(x);
11300
+ this.loop.schedule({ scroll: true, comments: true });
11299
11301
  });
11300
11302
  this.createRenderLoop();
11301
11303
  this.paragraphsScrolledIntoViewSubscription = this.paragraphsScrolledIntoViewSubject
@@ -11343,7 +11345,7 @@ class VirtualRenderer {
11343
11345
  }
11344
11346
  if (changes.cursor) {
11345
11347
  this.renderCursor();
11346
- this.renderComments();
11348
+ this.renderCommentHighlights();
11347
11349
  }
11348
11350
  if (changes.marker || changes.selection) {
11349
11351
  this.renderSelection();
@@ -11354,8 +11356,11 @@ class VirtualRenderer {
11354
11356
  if (changes.grammar) {
11355
11357
  this.renderGrammarHighlights();
11356
11358
  }
11359
+ if (changes.commentHighlights) {
11360
+ this.renderCommentHighlights();
11361
+ }
11357
11362
  if (changes.comments) {
11358
- this.renderComments();
11363
+ this.commentLayer.renderComments();
11359
11364
  }
11360
11365
  if (changes.dragAndDrop) {
11361
11366
  this.renderDragAndDropSelection();
@@ -11410,8 +11415,24 @@ class VirtualRenderer {
11410
11415
  this.renderer.setSelectedComment(commentId);
11411
11416
  }
11412
11417
  setCommentsVisibility(value) {
11418
+ if (value && !this.commentsSubscription) {
11419
+ this.commentsSubscription = this.commentService.commentRenderRequests$.subscribe(x => {
11420
+ this.commentLayer.applyChanges(x);
11421
+ this.loop.schedule({ comments: true });
11422
+ });
11423
+ }
11424
+ else {
11425
+ this.commentsSubscription?.unsubscribe();
11426
+ this.commentsSubscription = null;
11427
+ }
11413
11428
  this.renderer.setCommentsVisibility(value);
11414
11429
  }
11430
+ removeComment(id) {
11431
+ this.renderer.removeComment(id);
11432
+ }
11433
+ clearComments() {
11434
+ this.renderer.clearComments();
11435
+ }
11415
11436
  moveTextAreaToCursor() {
11416
11437
  if (!this.textarea) {
11417
11438
  return;
@@ -11508,7 +11529,7 @@ class VirtualRenderer {
11508
11529
  const scrollTop = this.scrollBar.scrollTop + deltaY;
11509
11530
  this.scrollBar.setScrollTop(scrollTop);
11510
11531
  this.commentLayer.scrollComments(deltaY);
11511
- this.loop.schedule({ scroll: true });
11532
+ this.loop.schedule({ scroll: true, comments: true });
11512
11533
  }
11513
11534
  // tokenDivider - used to measure if token fits (1 - should be fully fit, 2 - half of token, 3 - third part, ...) to be included
11514
11535
  screenToParagraph(x, y, tokenDivider = 1, rect) {
@@ -11534,8 +11555,9 @@ class VirtualRenderer {
11534
11555
  DomHelper.removeElement(this.scrollBar.element);
11535
11556
  this.pagesLayer.destroy();
11536
11557
  this.renderer.destroy();
11537
- this.commentLayer.destroy();
11558
+ this.commentLayer.disable();
11538
11559
  this.scrollSubscription?.unsubscribe();
11560
+ this.commentsSubscription?.unsubscribe();
11539
11561
  this.paragraphsScrolledIntoViewSubscription?.unsubscribe();
11540
11562
  }
11541
11563
  computeLayerConfig() {
@@ -11624,8 +11646,8 @@ class VirtualRenderer {
11624
11646
  renderDragAndDropSelection() {
11625
11647
  this.renderer.renderDragAndDropSelection();
11626
11648
  }
11627
- renderComments() {
11628
- this.renderer.renderComments();
11649
+ renderCommentHighlights() {
11650
+ this.renderer.renderCommentHighlights();
11629
11651
  }
11630
11652
  }
11631
11653
 
@@ -11833,7 +11855,10 @@ class RegulatorService {
11833
11855
  this.sessions = [];
11834
11856
  this.sessionIdIncrement = 0;
11835
11857
  this.grammarEnabled = false;
11858
+ this.selectedCommentSessionId = null;
11859
+ this.selectedCommentId = null;
11836
11860
  this.grammarChecker = new GrammarChecker(this.grammarService);
11861
+ this.observer = this.initializeIntersectionObserver();
11837
11862
  }
11838
11863
  addMainSession(model, scalingRatio, container) {
11839
11864
  const sessionId = ++this.sessionIdIncrement;
@@ -11862,7 +11887,7 @@ class RegulatorService {
11862
11887
  const mainSession = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, model, this.selection, properties, this.editorService, customComponents, 'main', scrollBar);
11863
11888
  const virtualRenderer = new VirtualRenderer(container.nativeElement, mainSession, this.commentRenderService, scrollBar);
11864
11889
  this.editorService.styles = DEFAULT_TOOLBAR_STYLES();
11865
- this.mainSession = new SessionModel(mainSession, virtualRenderer, sessionId, null, new MainSessionSourceModel());
11890
+ this.mainSession = new SessionModel(mainSession, virtualRenderer, sessionId, null, new MainSessionSourceModel(), container.nativeElement);
11866
11891
  this.sessions.push(this.mainSession);
11867
11892
  this.currentSession = this.mainSession;
11868
11893
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
@@ -11870,45 +11895,48 @@ class RegulatorService {
11870
11895
  this.grammarChecker.registerSession(this.mainSession);
11871
11896
  }
11872
11897
  }
11873
- addCellSession(table, margins, component, properties) {
11898
+ addCellSession(margins, component, nativeElement) {
11874
11899
  const sessionId = ++this.sessionIdIncrement;
11875
11900
  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);
11901
+ const displayData = new DisplayData(component.cell, component.generalProperties, sessionId, this.getPageFormats(margins, component.width), 0, customComponents, this.customContentService, this.editorService);
11877
11902
  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);
11903
+ const session = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, component.cell, this.selection, component.generalProperties, this.editorService, customComponents, sessionType);
11879
11904
  displayData.pagesFormat[0].contentWidth =
11880
11905
  displayData.pagesFormat[0].contentWidth === 0 ? 1 : displayData.pagesFormat[0].contentWidth;
11881
11906
  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);
11907
+ const source = new CellSessionSourceModel(component.table, component);
11908
+ const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source, nativeElement);
11884
11909
  this.sessions.push(newSession);
11885
11910
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
11886
11911
  newSession.renderer.updateText();
11887
11912
  if (this.grammarEnabled) {
11888
11913
  this.grammarChecker.registerSession(newSession);
11889
11914
  }
11915
+ this.observer.observe(nativeElement);
11890
11916
  return newSession;
11891
11917
  }
11892
- addEdgeSession(component) {
11918
+ addEdgeSession(component, nativeElement) {
11893
11919
  const sessionId = ++this.sessionIdIncrement;
11894
11920
  const customComponents = { images: [], tables: [], tabs: [], customElements: [], edges: null };
11895
11921
  const displayData = new DisplayData(component.model, component.generalProperties, sessionId, this.getPageFormats(component.margins, component.width), 0, customComponents, this.customContentService, this.editorService);
11896
11922
  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
11923
  const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session);
11898
11924
  const source = new EdgeSessionSourceModel(component.model.pageType, component.type);
11899
- const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source);
11925
+ const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source, nativeElement);
11900
11926
  this.sessions.push(newSession);
11901
11927
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
11902
11928
  newSession.renderer.updateText();
11903
11929
  if (this.grammarEnabled) {
11904
11930
  this.grammarChecker.registerSession(newSession);
11905
11931
  }
11932
+ this.observer.observe(nativeElement);
11906
11933
  return newSession;
11907
11934
  }
11908
11935
  removeSession(sessionId) {
11909
11936
  const index = this.sessions.findIndex(x => x.sessionId === sessionId);
11910
11937
  this.sessions[index].session.destroy();
11911
11938
  this.sessions[index].renderer.destroy();
11939
+ this.observer.unobserve(this.sessions[index].nativeElement);
11912
11940
  this.sessions.splice(index, 1);
11913
11941
  this.grammarChecker.unregisterSession(sessionId);
11914
11942
  }
@@ -12052,7 +12080,44 @@ class RegulatorService {
12052
12080
  setCommentsVisibility(value) {
12053
12081
  for (const sessionModel of this.sessions) {
12054
12082
  sessionModel.renderer.setCommentsVisibility(value);
12055
- sessionModel.renderer.loop.schedule({ comments: true });
12083
+ sessionModel.renderer.loop.schedule({ commentHighlights: true });
12084
+ }
12085
+ }
12086
+ setSelectedComment(commentId) {
12087
+ if (!commentId) {
12088
+ if (!this.selectedCommentSessionId) {
12089
+ return;
12090
+ }
12091
+ const sessionModel = this.getSessionModel(this.selectedCommentSessionId);
12092
+ sessionModel.renderer.setSelectedComment(null);
12093
+ sessionModel.renderer.loop.schedule({ commentHighlights: true });
12094
+ return;
12095
+ }
12096
+ const newSelectedSession = this.sessions.find(x => x.session.model.comments.some(c => c.commentId === commentId));
12097
+ if (this.selectedCommentSessionId && this.selectedCommentSessionId !== newSelectedSession.sessionId) {
12098
+ const sessionModel = this.getSessionModel(this.selectedCommentSessionId);
12099
+ sessionModel.renderer.setSelectedComment(null);
12100
+ sessionModel.renderer.loop.schedule({ commentHighlights: true });
12101
+ }
12102
+ else {
12103
+ newSelectedSession.renderer.setSelectedComment(commentId);
12104
+ newSelectedSession.renderer.loop.schedule({ commentHighlights: true });
12105
+ }
12106
+ this.selectedCommentId = commentId;
12107
+ this.selectedCommentSessionId = newSelectedSession.sessionId;
12108
+ }
12109
+ setSelectedCommentAtCursor() {
12110
+ const comment = this.currentSession.session.getCommentAtCursor();
12111
+ if (this.selectedCommentId && this.selectedCommentId !== comment?.commentId) {
12112
+ const sessionModel = this.getSessionModel(this.selectedCommentSessionId);
12113
+ sessionModel.renderer.setSelectedComment(null);
12114
+ sessionModel.renderer.loop.schedule({ commentHighlights: true });
12115
+ }
12116
+ if (comment) {
12117
+ this.currentSession.renderer.setSelectedComment(comment.commentId);
12118
+ this.currentSession.renderer.loop.schedule({ commentHighlights: true });
12119
+ this.selectedCommentId = comment.commentId;
12120
+ this.selectedCommentSessionId = this.currentSession.sessionId;
12056
12121
  }
12057
12122
  }
12058
12123
  isWithinEdge(sessionId) {
@@ -12125,6 +12190,19 @@ class RegulatorService {
12125
12190
  })
12126
12191
  ];
12127
12192
  }
12193
+ initializeIntersectionObserver() {
12194
+ const options = {
12195
+ root: null,
12196
+ rootMargin: '50px',
12197
+ threshold: 0.01
12198
+ };
12199
+ return new IntersectionObserver(entries => {
12200
+ entries.forEach(entry => {
12201
+ const sessionId = +entry.target.getAttribute('data-session-id');
12202
+ this.getSessionModel(sessionId)?.renderer.setVisibility(entry.isIntersecting);
12203
+ });
12204
+ }, options);
12205
+ }
12128
12206
  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
12207
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RegulatorService }); }
12130
12208
  }
@@ -12139,12 +12217,12 @@ class NoderTableCellComponent {
12139
12217
  get renderer() {
12140
12218
  return this.cellSession.renderer;
12141
12219
  }
12142
- constructor(editorService, regulatorService) {
12220
+ constructor(editorService, regulatorService, elementRef) {
12143
12221
  this.editorService = editorService;
12144
12222
  this.regulatorService = regulatorService;
12223
+ this.elementRef = elementRef;
12145
12224
  this.isHighlighted = false;
12146
12225
  this.resizerBorder = ResizerSide;
12147
- this.isVisible = false;
12148
12226
  this.pagesCountChangedHandler = (event) => {
12149
12227
  if (this._allParagraphsHeight === event.pageHeight) {
12150
12228
  return;
@@ -12153,14 +12231,9 @@ class NoderTableCellComponent {
12153
12231
  this.heightChanged(this.rowIndex, this.cellIndex, event.pageHeight);
12154
12232
  };
12155
12233
  }
12156
- ngAfterViewInit() {
12157
- this.intersectionObserver = this.initializeIntersectionObserver();
12158
- this.intersectionObserver.observe(this.container.nativeElement);
12159
- }
12160
12234
  ngOnDestroy() {
12161
12235
  this.session?.displayData.removeEventListener('pagesCountChanged', this.pagesCountChangedHandler);
12162
12236
  this.regulatorService.removeSession(this.sessionId);
12163
- this.intersectionObserver?.disconnect();
12164
12237
  }
12165
12238
  initialize() {
12166
12239
  const marginModel = new MarginModel({
@@ -12171,7 +12244,7 @@ class NoderTableCellComponent {
12171
12244
  header: 0,
12172
12245
  footer: 0
12173
12246
  });
12174
- this.cellSession = this.regulatorService.addCellSession(this.table, marginModel, this, this.generalProperties);
12247
+ this.cellSession = this.regulatorService.addCellSession(marginModel, this, this.elementRef.nativeElement);
12175
12248
  this.sessionId = this.cellSession.sessionId;
12176
12249
  this.addEventListeners();
12177
12250
  }
@@ -12192,29 +12265,13 @@ class NoderTableCellComponent {
12192
12265
  addEventListeners() {
12193
12266
  this.session.displayData.addEventListener('pagesCountChanged', this.pagesCountChangedHandler);
12194
12267
  }
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 }); }
12268
+ 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
12269
  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
12270
  }
12214
12271
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderTableCellComponent, decorators: [{
12215
12272
  type: Component,
12216
12273
  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: [{
12274
+ }], ctorParameters: () => [{ type: EditorService }, { type: RegulatorService }, { type: i0.ElementRef }], propDecorators: { table: [{
12218
12275
  type: Input
12219
12276
  }], cell: [{
12220
12277
  type: Input
@@ -13331,16 +13388,12 @@ class RenderingHelper {
13331
13388
  }
13332
13389
  const components = customContentService.getComponents(customComponents, fragmentStartIndex, fragmentEndIndex);
13333
13390
  for (const component of components) {
13334
- const textBeforeElement = fragmentText.substring(0, component.instance.insertIndex - fragmentStartIndex);
13391
+ const instance = component.instance;
13392
+ const textBeforeElement = fragmentText.substring(0, instance.insertIndex - fragmentStartIndex);
13335
13393
  fragmentText = fragmentText.substring(textBeforeElement.length + 1, fragmentText.length);
13336
13394
  this.renderText(fragment, textStyle, textBeforeElement, wordSpacing);
13337
13395
  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) {
13396
+ if (instance instanceof NoderTableComponent && line.customTexts?.length > 0) {
13344
13397
  if (line.customTexts[0].start === 0) {
13345
13398
  this.renderText(fragment, textStyle, ' ', wordSpacing);
13346
13399
  additionalTokens++;
@@ -13350,6 +13403,12 @@ class RenderingHelper {
13350
13403
  renderedIndexes++;
13351
13404
  }
13352
13405
  }
13406
+ else if (instance instanceof ExternalComponent && line.customTexts?.some(x => x.index === instance.insertIndex)) {
13407
+ const tokens = renderedTokensInLine + renderedIndexes + additionalTokens;
13408
+ const rendered = this.renderExternalText(fragment, textStyle, wordSpacing, instance, line, tokens, paragraphStartIndex);
13409
+ renderedIndexes += rendered.renderedIndexes;
13410
+ additionalTokens += rendered.additionalTokens;
13411
+ }
13353
13412
  else {
13354
13413
  customContentService.componentService.attachComponent(fragment, component);
13355
13414
  renderedIndexes++;
@@ -15932,15 +15991,16 @@ class Editor {
15932
15991
  commentModel.commentId = commentId;
15933
15992
  sessionModel.session.addComment(commentModel);
15934
15993
  sessionModel.renderer.setSelectedComment(commentModel.commentId);
15935
- sessionModel.renderer.loop.schedule({ comments: true });
15994
+ sessionModel.renderer.loop.schedule({ commentHighlights: true });
15936
15995
  this.saveAttachCommentToHistory(commentModel);
15937
15996
  }
15938
15997
  onCommentRemoved(id) {
15939
15998
  const session = this.regulatorService.getCommentSessionModel(id);
15940
15999
  const comment = session.session.removeComment(id);
16000
+ session.renderer.removeComment(id);
15941
16001
  this.saveRemoveCommentToHistory(comment, session.source.getTarget());
15942
16002
  this.editorService.removeCommentData([id]);
15943
- session.renderer.loop.schedule({ comments: true });
16003
+ session.renderer.loop.schedule({ commentHighlights: true });
15944
16004
  }
15945
16005
  onCommentTextReplace(commentId, newText) {
15946
16006
  const { session, comment } = this.regulatorService.getComment(commentId);
@@ -16326,7 +16386,7 @@ class Editor {
16326
16386
  this.editorService.paragraphStyle(paragraphStyle, numbering);
16327
16387
  this.editorService.setPageFormat(pageFormat.pageFormatModel);
16328
16388
  this.rerenderMarker();
16329
- this.updateSelectedComment();
16389
+ this.regulatorService.setSelectedCommentAtCursor();
16330
16390
  if (!this.selection.isEmpty && this.commentsVisible) {
16331
16391
  const paragraphPos = this.session.selection.cursor;
16332
16392
  const cursor = PositionHelper.paragraphToPixel(this.session, paragraphPos.row, paragraphPos.column);
@@ -16338,7 +16398,7 @@ class Editor {
16338
16398
  }
16339
16399
  }
16340
16400
  onContentChange() {
16341
- this.renderer.loop.schedule({ comments: true });
16401
+ this.renderer.loop.schedule({ commentHighlights: true });
16342
16402
  if (this.search.term) {
16343
16403
  this.find(this.search.term);
16344
16404
  }
@@ -16874,12 +16934,7 @@ class Editor {
16874
16934
  return this.editorService.commentSizeChanged$.subscribe(() => this.mainRenderer.loop.schedule({ comments: true }));
16875
16935
  }
16876
16936
  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
- });
16937
+ return this.editorService.setCommentSelected$.subscribe(x => this.regulatorService.setSelectedComment(x));
16883
16938
  }
16884
16939
  removeCommentSubscription() {
16885
16940
  return this.editorService.removeComment$.subscribe(x => this.onCommentRemoved(x));
@@ -16960,16 +17015,6 @@ class Editor {
16960
17015
  this.overlayService.open(CommentPopupComponent, {}, hintX, hintY);
16961
17016
  event?.stopPropagation();
16962
17017
  }
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
17018
  }
16974
17019
 
16975
17020
  const EDITOR_VERSION = '2';