@talrace/ngx-noder 19.0.49 → 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.
@@ -6890,41 +6890,33 @@ class DisplayTokenHelper {
6890
6890
  for (let i = 0; i < text.length; i++) {
6891
6891
  result.push(this.getSymbolToken(text[i], fontString, index));
6892
6892
  result[i].customIndex = i;
6893
+ result[i].customText = text;
6893
6894
  }
6894
- return result.length ? result : [this.getSymbolToken(' ', fontString, index)];
6895
+ return result;
6895
6896
  }
6896
- const ascent = component.instance.ascent() ?? 0;
6897
- const descent = component.instance.descent() ?? 0;
6898
- return [
6899
- new DisplayToken({
6900
- width: component.instance.width(),
6901
- height: ascent + descent,
6902
- font: FontMetrics.measureCharSize('0', fontString).font,
6903
- ascent,
6904
- descent,
6905
- displayValue: this.getComponentDisplayValue(component.instance),
6906
- index
6907
- })
6908
- ];
6897
+ return [this.getComponentToken(component, fontString, index)];
6909
6898
  }
6910
- static getTableTokens(component, fontString, index, withNumbering) {
6911
- if (!withNumbering) {
6912
- return this.getComponentTokens(component, fontString, index);
6913
- }
6914
- const spaceToken = this.getSymbolToken(' ', fontString, index);
6915
- spaceToken.customIndex = 0;
6899
+ static getComponentToken(component, fontString, index) {
6916
6900
  const ascent = component.instance.ascent() ?? 0;
6917
6901
  const descent = component.instance.descent() ?? 0;
6918
- const tableToken = new DisplayToken({
6902
+ return new DisplayToken({
6919
6903
  width: component.instance.width(),
6920
6904
  height: ascent + descent,
6921
6905
  font: FontMetrics.measureCharSize('0', fontString).font,
6922
6906
  ascent,
6923
6907
  descent,
6924
- displayValue: DisplayValue.table,
6925
- index,
6926
- customIndex: 1
6908
+ displayValue: this.getComponentDisplayValue(component.instance),
6909
+ index
6927
6910
  });
6911
+ }
6912
+ static getTableTokens(component, fontString, index, withNumbering) {
6913
+ const tableToken = this.getComponentToken(component, fontString, index);
6914
+ if (!withNumbering) {
6915
+ return [tableToken];
6916
+ }
6917
+ const spaceToken = this.getSymbolToken(' ', fontString, index);
6918
+ spaceToken.customIndex = 0;
6919
+ tableToken.customIndex = 1;
6928
6920
  return [spaceToken, tableToken];
6929
6921
  }
6930
6922
  static getBreakDisplayValue(breakType) {
@@ -7146,7 +7138,8 @@ class LineInfoHelper {
7146
7138
  line.customTexts.push({
7147
7139
  index: indexInParagraph,
7148
7140
  start: token.customIndex,
7149
- end: token.customIndex + 1
7141
+ end: token.customIndex + 1,
7142
+ text: token.customText
7150
7143
  });
7151
7144
  }
7152
7145
  }
@@ -8368,14 +8361,14 @@ class NoderEdgeComponent extends DestroyComponent {
8368
8361
  // todo need make in diff Task for get correct contentHeight
8369
8362
  return this.session.displayData.pagesFormat[0].defaultVerticalData.contentHeight;
8370
8363
  }
8371
- constructor(regulatorService, editorService, translateService, cdr) {
8364
+ constructor(regulatorService, editorService, translateService, cdr, elementRef) {
8372
8365
  super();
8373
8366
  this.regulatorService = regulatorService;
8374
8367
  this.editorService = editorService;
8375
8368
  this.translateService = translateService;
8376
8369
  this.cdr = cdr;
8370
+ this.elementRef = elementRef;
8377
8371
  this.initialized = false;
8378
- this.isVisible = false;
8379
8372
  this.pagesCountChangedHandler = (event) => {
8380
8373
  if (this._height === event.pageHeight) {
8381
8374
  return;
@@ -8388,11 +8381,10 @@ class NoderEdgeComponent extends DestroyComponent {
8388
8381
  ngOnDestroy() {
8389
8382
  this.session?.displayData.removeEventListener('pagesCountChanged', this.pagesCountChangedHandler);
8390
8383
  this.regulatorService.removeSession(this.sessionId);
8391
- this.intersectionObserver?.disconnect();
8392
8384
  super.ngOnDestroy();
8393
8385
  }
8394
8386
  initialize() {
8395
- this.edgeSession = this.regulatorService.addEdgeSession(this);
8387
+ this.edgeSession = this.regulatorService.addEdgeSession(this, this.elementRef.nativeElement);
8396
8388
  this.sessionId = this.edgeSession.sessionId;
8397
8389
  this.container.nativeElement.parentElement.setAttribute('data-session-id', `${this.sessionId}`);
8398
8390
  DomHelper.setStyle(this.container.nativeElement.style, 'overflow', 'hidden');
@@ -8407,8 +8399,6 @@ class NoderEdgeComponent extends DestroyComponent {
8407
8399
  this.edgeNameByType = this.getEdgeNameByType();
8408
8400
  this.cdr.detectChanges();
8409
8401
  });
8410
- this.intersectionObserver = this.initializeIntersectionObserver();
8411
- this.intersectionObserver.observe(this.container.nativeElement);
8412
8402
  }
8413
8403
  enterEditMode() {
8414
8404
  DomHelper.addCssClass(this.container.nativeElement, this.editModeClass);
@@ -8451,29 +8441,13 @@ class NoderEdgeComponent extends DestroyComponent {
8451
8441
  const height = this.contentHeight > maxHeight ? maxHeight : this.contentHeight;
8452
8442
  DomHelper.setStyle(this.typeContainer.nativeElement.style, this.typeContainerPosition, `${height}px`);
8453
8443
  }
8454
- initializeIntersectionObserver() {
8455
- const options = {
8456
- root: null,
8457
- rootMargin: '50px',
8458
- threshold: 0.01
8459
- };
8460
- return new IntersectionObserver(entries => {
8461
- entries.forEach(entry => {
8462
- const wasVisible = this.isVisible;
8463
- this.isVisible = entry.isIntersecting;
8464
- if (this.isVisible !== wasVisible) {
8465
- this.renderer.setVisibility(this.isVisible);
8466
- }
8467
- });
8468
- }, options);
8469
- }
8470
- 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 }); }
8471
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 }); }
8472
8446
  }
8473
8447
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderEdgeComponent, decorators: [{
8474
8448
  type: Component,
8475
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"] }]
8476
- }], 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: [{
8477
8451
  type: Input
8478
8452
  }], generalProperties: [{
8479
8453
  type: Input
@@ -9982,7 +9956,6 @@ class CommentHighlightLayer extends HighlightLayer {
9982
9956
  const comments = this.session.model.comments;
9983
9957
  if (!config?.isVisible || !comments?.length || !this.enabled) {
9984
9958
  this.element.innerHTML = '';
9985
- this.commentService.removeCommentsFromRender(this.session.sessionId);
9986
9959
  return;
9987
9960
  }
9988
9961
  this.config = config;
@@ -10013,6 +9986,12 @@ class CommentHighlightLayer extends HighlightLayer {
10013
9986
  }
10014
9987
  }
10015
9988
  }
9989
+ removeSessionComments() {
9990
+ this.commentService.removeCommentsFromRender(this.session.sessionId);
9991
+ }
9992
+ removeComment(id) {
9993
+ this.commentService.removeCommentFromRender(this.session.sessionId, id);
9994
+ }
10016
9995
  setSelectedComment(id) {
10017
9996
  if (this.selectedCommentId) {
10018
9997
  this.commentService.setCommentSelected(this.selectedCommentId, false);
@@ -10022,6 +10001,9 @@ class CommentHighlightLayer extends HighlightLayer {
10022
10001
  this.commentService.setCommentSelected(id);
10023
10002
  }
10024
10003
  }
10004
+ clearSessionComments() {
10005
+ this.commentService.removeCommentsFromRender(this.session.sessionId);
10006
+ }
10025
10007
  requestCommentRender(highlight, id) {
10026
10008
  const element = Array.isArray(highlight) ? highlight[0] : highlight;
10027
10009
  const rect = element.getBoundingClientRect();
@@ -10183,6 +10165,7 @@ class RenderChangesModel {
10183
10165
  this.selection ||
10184
10166
  this.search ||
10185
10167
  this.grammar ||
10168
+ this.commentHighlights ||
10186
10169
  this.comments ||
10187
10170
  this.scroll ||
10188
10171
  this.size ||
@@ -10198,6 +10181,7 @@ class RenderChangesModel {
10198
10181
  this.selection = false;
10199
10182
  this.search = false;
10200
10183
  this.grammar = false;
10184
+ this.commentHighlights = false;
10201
10185
  this.comments = false;
10202
10186
  this.scroll = false;
10203
10187
  this.size = false;
@@ -10686,7 +10670,7 @@ class Renderer extends EventEmitting {
10686
10670
  changes.scroll ||
10687
10671
  changes.search ||
10688
10672
  changes.grammar ||
10689
- changes.comments ||
10673
+ changes.commentHighlights ||
10690
10674
  changes.visibilityChanged) {
10691
10675
  changes.apply(this.computeLayerConfig());
10692
10676
  DomHelper.translate(this.content, 0, -this.layerConfig.offset);
@@ -10713,8 +10697,8 @@ class Renderer extends EventEmitting {
10713
10697
  if (changes.grammar) {
10714
10698
  this.renderGrammarHighlights();
10715
10699
  }
10716
- if (changes.comments) {
10717
- this.renderComments();
10700
+ if (changes.commentHighlights) {
10701
+ this.renderCommentHighlights();
10718
10702
  }
10719
10703
  if (changes.dragAndDrop) {
10720
10704
  this.renderDragAndDropSelection();
@@ -10722,7 +10706,7 @@ class Renderer extends EventEmitting {
10722
10706
  if (changes.visibilityChanged) {
10723
10707
  this.renderSearchHighlights();
10724
10708
  this.renderGrammarHighlights();
10725
- this.renderComments();
10709
+ this.renderCommentHighlights();
10726
10710
  this.visibilitySubject.next(this.isVisible);
10727
10711
  }
10728
10712
  this.session.onRendered();
@@ -10820,6 +10804,9 @@ class Renderer extends EventEmitting {
10820
10804
  setVisibility(isVisible) {
10821
10805
  if (this.isVisible !== isVisible) {
10822
10806
  this.isVisible = isVisible;
10807
+ if (!isVisible) {
10808
+ this.commentsLayer.clearSessionComments();
10809
+ }
10823
10810
  this.loop.schedule({ visibilityChanged: true });
10824
10811
  }
10825
10812
  }
@@ -10890,13 +10877,22 @@ class Renderer extends EventEmitting {
10890
10877
  renderGrammarHighlights() {
10891
10878
  this.grammarHighlightLayer.update(this.layerConfig);
10892
10879
  }
10893
- renderComments() {
10880
+ renderCommentHighlights() {
10894
10881
  this.commentsLayer.update(this.layerConfig);
10895
10882
  }
10896
10883
  setSelectedComment(comment) {
10897
10884
  this.commentsLayer.setSelectedComment(comment);
10898
10885
  }
10886
+ removeComment(id) {
10887
+ this.commentsLayer.removeComment(id);
10888
+ }
10889
+ clearComments() {
10890
+ this.commentsLayer.removeSessionComments();
10891
+ }
10899
10892
  setCommentsVisibility(value) {
10893
+ if (!value) {
10894
+ this.commentsLayer.clearSessionComments();
10895
+ }
10900
10896
  this.commentsLayer.enabled = value;
10901
10897
  }
10902
10898
  renderDragAndDropSelection() {
@@ -11016,12 +11012,13 @@ class ScrollBar {
11016
11012
  }
11017
11013
 
11018
11014
  class SessionModel {
11019
- constructor(session, renderer, sessionId, parentSessionId, source) {
11015
+ constructor(session, renderer, sessionId, parentSessionId, source, nativeElement) {
11020
11016
  this.session = session;
11021
11017
  this.renderer = renderer;
11022
11018
  this.sessionId = sessionId;
11023
11019
  this.parentSessionId = parentSessionId;
11024
11020
  this.source = source;
11021
+ this.nativeElement = nativeElement;
11025
11022
  }
11026
11023
  }
11027
11024
 
@@ -11046,19 +11043,16 @@ class RenderComments {
11046
11043
  }
11047
11044
 
11048
11045
  class CommentLayer {
11049
- constructor(parentEl, commentService) {
11046
+ constructor(parentEl) {
11050
11047
  this.commentPadding = 8;
11051
11048
  this.rendersBySession = new Map();
11052
11049
  this.element = document.createElement('div');
11053
11050
  this.element.className = `noder-comments-layer`;
11054
11051
  parentEl.appendChild(this.element);
11055
- this.commentSubscription = commentService.commentRenderRequests$.subscribe(x => {
11056
- this.applyChanges(x);
11057
- this.renderComments();
11058
- });
11059
11052
  }
11060
- destroy() {
11061
- this.commentSubscription.unsubscribe();
11053
+ disable() {
11054
+ this.rendersBySession.clear();
11055
+ this.renderComments();
11062
11056
  }
11063
11057
  scrollComments(offsetY) {
11064
11058
  for (const [sessionId, comments] of this.rendersBySession) {
@@ -11101,7 +11095,7 @@ class CommentLayer {
11101
11095
  }
11102
11096
  return;
11103
11097
  }
11104
- let lastCommentBounds = { from: 0, to: 0 };
11098
+ let lastCommentBounds = { from: -Infinity, to: -Infinity };
11105
11099
  for (let i = selectedIndex + 1; i < sortedComments.length; i++) {
11106
11100
  const comment = sortedComments[i];
11107
11101
  let top = comment.highlightTop - topOffset;
@@ -11284,6 +11278,7 @@ class VirtualRenderer {
11284
11278
  return this.renderer.paragraphsAppeared.asObservable();
11285
11279
  }
11286
11280
  constructor(parentContainer, mainSession, commentService, scrollBar) {
11281
+ this.commentService = commentService;
11287
11282
  this.scrollBar = scrollBar;
11288
11283
  this.changes = new RenderChangesModel();
11289
11284
  this.size = {
@@ -11299,10 +11294,10 @@ class VirtualRenderer {
11299
11294
  this.renderer = new Renderer(parentContainer, commentService, mainSession);
11300
11295
  this.pagesLayer = new PagesLayer(this.renderer.content, mainSession);
11301
11296
  this.edgesLayer = new EdgesLayer(this.renderer.content, mainSession);
11302
- this.commentLayer = new CommentLayer(this.renderer.content, commentService);
11297
+ this.commentLayer = new CommentLayer(this.renderer.content);
11303
11298
  this.scrollSubscription = this.scrollBar.scrolled$.subscribe(x => {
11304
- this.loop.schedule({ scroll: true });
11305
11299
  this.commentLayer.scrollComments(x);
11300
+ this.loop.schedule({ scroll: true, comments: true });
11306
11301
  });
11307
11302
  this.createRenderLoop();
11308
11303
  this.paragraphsScrolledIntoViewSubscription = this.paragraphsScrolledIntoViewSubject
@@ -11350,7 +11345,7 @@ class VirtualRenderer {
11350
11345
  }
11351
11346
  if (changes.cursor) {
11352
11347
  this.renderCursor();
11353
- this.renderComments();
11348
+ this.renderCommentHighlights();
11354
11349
  }
11355
11350
  if (changes.marker || changes.selection) {
11356
11351
  this.renderSelection();
@@ -11361,8 +11356,11 @@ class VirtualRenderer {
11361
11356
  if (changes.grammar) {
11362
11357
  this.renderGrammarHighlights();
11363
11358
  }
11359
+ if (changes.commentHighlights) {
11360
+ this.renderCommentHighlights();
11361
+ }
11364
11362
  if (changes.comments) {
11365
- this.renderComments();
11363
+ this.commentLayer.renderComments();
11366
11364
  }
11367
11365
  if (changes.dragAndDrop) {
11368
11366
  this.renderDragAndDropSelection();
@@ -11417,8 +11415,24 @@ class VirtualRenderer {
11417
11415
  this.renderer.setSelectedComment(commentId);
11418
11416
  }
11419
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
+ }
11420
11428
  this.renderer.setCommentsVisibility(value);
11421
11429
  }
11430
+ removeComment(id) {
11431
+ this.renderer.removeComment(id);
11432
+ }
11433
+ clearComments() {
11434
+ this.renderer.clearComments();
11435
+ }
11422
11436
  moveTextAreaToCursor() {
11423
11437
  if (!this.textarea) {
11424
11438
  return;
@@ -11515,7 +11529,7 @@ class VirtualRenderer {
11515
11529
  const scrollTop = this.scrollBar.scrollTop + deltaY;
11516
11530
  this.scrollBar.setScrollTop(scrollTop);
11517
11531
  this.commentLayer.scrollComments(deltaY);
11518
- this.loop.schedule({ scroll: true });
11532
+ this.loop.schedule({ scroll: true, comments: true });
11519
11533
  }
11520
11534
  // tokenDivider - used to measure if token fits (1 - should be fully fit, 2 - half of token, 3 - third part, ...) to be included
11521
11535
  screenToParagraph(x, y, tokenDivider = 1, rect) {
@@ -11541,8 +11555,9 @@ class VirtualRenderer {
11541
11555
  DomHelper.removeElement(this.scrollBar.element);
11542
11556
  this.pagesLayer.destroy();
11543
11557
  this.renderer.destroy();
11544
- this.commentLayer.destroy();
11558
+ this.commentLayer.disable();
11545
11559
  this.scrollSubscription?.unsubscribe();
11560
+ this.commentsSubscription?.unsubscribe();
11546
11561
  this.paragraphsScrolledIntoViewSubscription?.unsubscribe();
11547
11562
  }
11548
11563
  computeLayerConfig() {
@@ -11631,8 +11646,8 @@ class VirtualRenderer {
11631
11646
  renderDragAndDropSelection() {
11632
11647
  this.renderer.renderDragAndDropSelection();
11633
11648
  }
11634
- renderComments() {
11635
- this.renderer.renderComments();
11649
+ renderCommentHighlights() {
11650
+ this.renderer.renderCommentHighlights();
11636
11651
  }
11637
11652
  }
11638
11653
 
@@ -11840,7 +11855,10 @@ class RegulatorService {
11840
11855
  this.sessions = [];
11841
11856
  this.sessionIdIncrement = 0;
11842
11857
  this.grammarEnabled = false;
11858
+ this.selectedCommentSessionId = null;
11859
+ this.selectedCommentId = null;
11843
11860
  this.grammarChecker = new GrammarChecker(this.grammarService);
11861
+ this.observer = this.initializeIntersectionObserver();
11844
11862
  }
11845
11863
  addMainSession(model, scalingRatio, container) {
11846
11864
  const sessionId = ++this.sessionIdIncrement;
@@ -11869,7 +11887,7 @@ class RegulatorService {
11869
11887
  const mainSession = new EditSession(displayData, sessionId, this.customContentService, this.commentRenderService, model, this.selection, properties, this.editorService, customComponents, 'main', scrollBar);
11870
11888
  const virtualRenderer = new VirtualRenderer(container.nativeElement, mainSession, this.commentRenderService, scrollBar);
11871
11889
  this.editorService.styles = DEFAULT_TOOLBAR_STYLES();
11872
- this.mainSession = new SessionModel(mainSession, virtualRenderer, sessionId, null, new MainSessionSourceModel());
11890
+ this.mainSession = new SessionModel(mainSession, virtualRenderer, sessionId, null, new MainSessionSourceModel(), container.nativeElement);
11873
11891
  this.sessions.push(this.mainSession);
11874
11892
  this.currentSession = this.mainSession;
11875
11893
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
@@ -11877,45 +11895,48 @@ class RegulatorService {
11877
11895
  this.grammarChecker.registerSession(this.mainSession);
11878
11896
  }
11879
11897
  }
11880
- addCellSession(table, margins, component, properties) {
11898
+ addCellSession(margins, component, nativeElement) {
11881
11899
  const sessionId = ++this.sessionIdIncrement;
11882
11900
  const customComponents = { images: [], tables: [], tabs: [], customElements: [], edges: null };
11883
- 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);
11884
11902
  const sessionType = this.isWithinEdge(component.parentSessionId) ? 'cellWithinEdge' : 'cell';
11885
- 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);
11886
11904
  displayData.pagesFormat[0].contentWidth =
11887
11905
  displayData.pagesFormat[0].contentWidth === 0 ? 1 : displayData.pagesFormat[0].contentWidth;
11888
11906
  const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session);
11889
- const source = new CellSessionSourceModel(table, component);
11890
- 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);
11891
11909
  this.sessions.push(newSession);
11892
11910
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
11893
11911
  newSession.renderer.updateText();
11894
11912
  if (this.grammarEnabled) {
11895
11913
  this.grammarChecker.registerSession(newSession);
11896
11914
  }
11915
+ this.observer.observe(nativeElement);
11897
11916
  return newSession;
11898
11917
  }
11899
- addEdgeSession(component) {
11918
+ addEdgeSession(component, nativeElement) {
11900
11919
  const sessionId = ++this.sessionIdIncrement;
11901
11920
  const customComponents = { images: [], tables: [], tabs: [], customElements: [], edges: null };
11902
11921
  const displayData = new DisplayData(component.model, component.generalProperties, sessionId, this.getPageFormats(component.margins, component.width), 0, customComponents, this.customContentService, this.editorService);
11903
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);
11904
11923
  const renderer = new Renderer(component.container.nativeElement, this.commentRenderService, session);
11905
11924
  const source = new EdgeSessionSourceModel(component.model.pageType, component.type);
11906
- const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source);
11925
+ const newSession = new SessionModel(session, renderer, sessionId, component.parentSessionId, source, nativeElement);
11907
11926
  this.sessions.push(newSession);
11908
11927
  displayData.updateNextLineIndexes(0, displayData.paragraphs.length - 1);
11909
11928
  newSession.renderer.updateText();
11910
11929
  if (this.grammarEnabled) {
11911
11930
  this.grammarChecker.registerSession(newSession);
11912
11931
  }
11932
+ this.observer.observe(nativeElement);
11913
11933
  return newSession;
11914
11934
  }
11915
11935
  removeSession(sessionId) {
11916
11936
  const index = this.sessions.findIndex(x => x.sessionId === sessionId);
11917
11937
  this.sessions[index].session.destroy();
11918
11938
  this.sessions[index].renderer.destroy();
11939
+ this.observer.unobserve(this.sessions[index].nativeElement);
11919
11940
  this.sessions.splice(index, 1);
11920
11941
  this.grammarChecker.unregisterSession(sessionId);
11921
11942
  }
@@ -12059,7 +12080,44 @@ class RegulatorService {
12059
12080
  setCommentsVisibility(value) {
12060
12081
  for (const sessionModel of this.sessions) {
12061
12082
  sessionModel.renderer.setCommentsVisibility(value);
12062
- 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;
12063
12121
  }
12064
12122
  }
12065
12123
  isWithinEdge(sessionId) {
@@ -12132,6 +12190,19 @@ class RegulatorService {
12132
12190
  })
12133
12191
  ];
12134
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
+ }
12135
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 }); }
12136
12207
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RegulatorService }); }
12137
12208
  }
@@ -12146,12 +12217,12 @@ class NoderTableCellComponent {
12146
12217
  get renderer() {
12147
12218
  return this.cellSession.renderer;
12148
12219
  }
12149
- constructor(editorService, regulatorService) {
12220
+ constructor(editorService, regulatorService, elementRef) {
12150
12221
  this.editorService = editorService;
12151
12222
  this.regulatorService = regulatorService;
12223
+ this.elementRef = elementRef;
12152
12224
  this.isHighlighted = false;
12153
12225
  this.resizerBorder = ResizerSide;
12154
- this.isVisible = false;
12155
12226
  this.pagesCountChangedHandler = (event) => {
12156
12227
  if (this._allParagraphsHeight === event.pageHeight) {
12157
12228
  return;
@@ -12160,14 +12231,9 @@ class NoderTableCellComponent {
12160
12231
  this.heightChanged(this.rowIndex, this.cellIndex, event.pageHeight);
12161
12232
  };
12162
12233
  }
12163
- ngAfterViewInit() {
12164
- this.intersectionObserver = this.initializeIntersectionObserver();
12165
- this.intersectionObserver.observe(this.container.nativeElement);
12166
- }
12167
12234
  ngOnDestroy() {
12168
12235
  this.session?.displayData.removeEventListener('pagesCountChanged', this.pagesCountChangedHandler);
12169
12236
  this.regulatorService.removeSession(this.sessionId);
12170
- this.intersectionObserver?.disconnect();
12171
12237
  }
12172
12238
  initialize() {
12173
12239
  const marginModel = new MarginModel({
@@ -12178,7 +12244,7 @@ class NoderTableCellComponent {
12178
12244
  header: 0,
12179
12245
  footer: 0
12180
12246
  });
12181
- this.cellSession = this.regulatorService.addCellSession(this.table, marginModel, this, this.generalProperties);
12247
+ this.cellSession = this.regulatorService.addCellSession(marginModel, this, this.elementRef.nativeElement);
12182
12248
  this.sessionId = this.cellSession.sessionId;
12183
12249
  this.addEventListeners();
12184
12250
  }
@@ -12199,29 +12265,13 @@ class NoderTableCellComponent {
12199
12265
  addEventListeners() {
12200
12266
  this.session.displayData.addEventListener('pagesCountChanged', this.pagesCountChangedHandler);
12201
12267
  }
12202
- initializeIntersectionObserver() {
12203
- const options = {
12204
- root: null,
12205
- rootMargin: '50px',
12206
- threshold: 0.01
12207
- };
12208
- return new IntersectionObserver(entries => {
12209
- entries.forEach(entry => {
12210
- const wasVisible = this.isVisible;
12211
- this.isVisible = entry.isIntersecting;
12212
- if (this.isVisible !== wasVisible) {
12213
- this.renderer.setVisibility(this.isVisible);
12214
- }
12215
- });
12216
- }, options);
12217
- }
12218
- 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 }); }
12219
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 }); }
12220
12270
  }
12221
12271
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NoderTableCellComponent, decorators: [{
12222
12272
  type: Component,
12223
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"] }]
12224
- }], ctorParameters: () => [{ type: EditorService }, { type: RegulatorService }], propDecorators: { table: [{
12274
+ }], ctorParameters: () => [{ type: EditorService }, { type: RegulatorService }, { type: i0.ElementRef }], propDecorators: { table: [{
12225
12275
  type: Input
12226
12276
  }], cell: [{
12227
12277
  type: Input
@@ -13338,16 +13388,12 @@ class RenderingHelper {
13338
13388
  }
13339
13389
  const components = customContentService.getComponents(customComponents, fragmentStartIndex, fragmentEndIndex);
13340
13390
  for (const component of components) {
13341
- const textBeforeElement = fragmentText.substring(0, component.instance.insertIndex - fragmentStartIndex);
13391
+ const instance = component.instance;
13392
+ const textBeforeElement = fragmentText.substring(0, instance.insertIndex - fragmentStartIndex);
13342
13393
  fragmentText = fragmentText.substring(textBeforeElement.length + 1, fragmentText.length);
13343
13394
  this.renderText(fragment, textStyle, textBeforeElement, wordSpacing);
13344
13395
  renderedIndexes += textBeforeElement.length;
13345
- if (component.instance instanceof ExternalComponent && component.instance.isText) {
13346
- const rendered = this.renderExternalText(fragment, textStyle, wordSpacing, component.instance, line, renderedTokensInLine + renderedIndexes + additionalTokens, paragraphStartIndex);
13347
- renderedIndexes += rendered.renderedIndexes;
13348
- additionalTokens += rendered.additionalTokens;
13349
- }
13350
- else if (component.instance instanceof NoderTableComponent && line.customTexts?.length > 0) {
13396
+ if (instance instanceof NoderTableComponent && line.customTexts?.length > 0) {
13351
13397
  if (line.customTexts[0].start === 0) {
13352
13398
  this.renderText(fragment, textStyle, ' ', wordSpacing);
13353
13399
  additionalTokens++;
@@ -13357,6 +13403,12 @@ class RenderingHelper {
13357
13403
  renderedIndexes++;
13358
13404
  }
13359
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
+ }
13360
13412
  else {
13361
13413
  customContentService.componentService.attachComponent(fragment, component);
13362
13414
  renderedIndexes++;
@@ -13377,10 +13429,8 @@ class RenderingHelper {
13377
13429
  { name: 'data-session-id', value: `${instance.sessionId}` },
13378
13430
  { name: 'data-insert-index', value: `${instance.insertIndex}` }
13379
13431
  ];
13380
- let text = instance.getText();
13381
- text = !text.length ? ' ' : text;
13382
13432
  const customText = line.customTexts.find(x => x.index === instance.insertIndex - paragraphStartIndex);
13383
- const customTextFragment = text.substring(customText.start, customText.end);
13433
+ const customTextFragment = customText.text.substring(customText.start, customText.end);
13384
13434
  if (!line.wordSpacing) {
13385
13435
  this.renderText(fragment, textStyle, customTextFragment, wordSpacing, classes, attributes, style);
13386
13436
  additionalTokens += customTextFragment.length;
@@ -13402,7 +13452,7 @@ class RenderingHelper {
13402
13452
  additionalTokens += rightText.length;
13403
13453
  }
13404
13454
  }
13405
- if (text.length === customText.end) {
13455
+ if (customText.text.length === customText.end) {
13406
13456
  renderedIndexes++;
13407
13457
  additionalTokens--;
13408
13458
  }
@@ -15941,15 +15991,16 @@ class Editor {
15941
15991
  commentModel.commentId = commentId;
15942
15992
  sessionModel.session.addComment(commentModel);
15943
15993
  sessionModel.renderer.setSelectedComment(commentModel.commentId);
15944
- sessionModel.renderer.loop.schedule({ comments: true });
15994
+ sessionModel.renderer.loop.schedule({ commentHighlights: true });
15945
15995
  this.saveAttachCommentToHistory(commentModel);
15946
15996
  }
15947
15997
  onCommentRemoved(id) {
15948
15998
  const session = this.regulatorService.getCommentSessionModel(id);
15949
15999
  const comment = session.session.removeComment(id);
16000
+ session.renderer.removeComment(id);
15950
16001
  this.saveRemoveCommentToHistory(comment, session.source.getTarget());
15951
16002
  this.editorService.removeCommentData([id]);
15952
- session.renderer.loop.schedule({ comments: true });
16003
+ session.renderer.loop.schedule({ commentHighlights: true });
15953
16004
  }
15954
16005
  onCommentTextReplace(commentId, newText) {
15955
16006
  const { session, comment } = this.regulatorService.getComment(commentId);
@@ -16335,7 +16386,7 @@ class Editor {
16335
16386
  this.editorService.paragraphStyle(paragraphStyle, numbering);
16336
16387
  this.editorService.setPageFormat(pageFormat.pageFormatModel);
16337
16388
  this.rerenderMarker();
16338
- this.updateSelectedComment();
16389
+ this.regulatorService.setSelectedCommentAtCursor();
16339
16390
  if (!this.selection.isEmpty && this.commentsVisible) {
16340
16391
  const paragraphPos = this.session.selection.cursor;
16341
16392
  const cursor = PositionHelper.paragraphToPixel(this.session, paragraphPos.row, paragraphPos.column);
@@ -16347,7 +16398,7 @@ class Editor {
16347
16398
  }
16348
16399
  }
16349
16400
  onContentChange() {
16350
- this.renderer.loop.schedule({ comments: true });
16401
+ this.renderer.loop.schedule({ commentHighlights: true });
16351
16402
  if (this.search.term) {
16352
16403
  this.find(this.search.term);
16353
16404
  }
@@ -16883,12 +16934,7 @@ class Editor {
16883
16934
  return this.editorService.commentSizeChanged$.subscribe(() => this.mainRenderer.loop.schedule({ comments: true }));
16884
16935
  }
16885
16936
  selectCommentSubscription() {
16886
- return this.editorService.setCommentSelected$.subscribe(x => {
16887
- for (const session of this.regulatorService.sessions) {
16888
- session.renderer.setSelectedComment(x);
16889
- session.renderer.loop.schedule({ comments: true });
16890
- }
16891
- });
16937
+ return this.editorService.setCommentSelected$.subscribe(x => this.regulatorService.setSelectedComment(x));
16892
16938
  }
16893
16939
  removeCommentSubscription() {
16894
16940
  return this.editorService.removeComment$.subscribe(x => this.onCommentRemoved(x));
@@ -16969,16 +17015,6 @@ class Editor {
16969
17015
  this.overlayService.open(CommentPopupComponent, {}, hintX, hintY);
16970
17016
  event?.stopPropagation();
16971
17017
  }
16972
- updateSelectedComment() {
16973
- for (const session of this.regulatorService.sessions) {
16974
- if (!this.selection.range.isEmpty || session.session !== this.session) {
16975
- session.renderer.setSelectedComment(null);
16976
- continue;
16977
- }
16978
- const comment = session.session.getCommentAtCursor();
16979
- session.renderer.setSelectedComment(comment?.commentId);
16980
- }
16981
- }
16982
17018
  }
16983
17019
 
16984
17020
  const EDITOR_VERSION = '2';