@talrace/ngx-noder 19.0.48 → 19.0.50

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.
@@ -5529,7 +5529,7 @@ class TargetOperationsHelper {
5529
5529
  static getContents(document, targets) {
5530
5530
  let result = document;
5531
5531
  for (const target of targets) {
5532
- result = this.getTargetContents(document, target, document);
5532
+ result = this.getTargetContents(result, target, document);
5533
5533
  }
5534
5534
  return result;
5535
5535
  }
@@ -6876,17 +6876,11 @@ class DisplayTokenHelper {
6876
6876
  });
6877
6877
  }
6878
6878
  static getSymbolToken(symbol, fontString, index) {
6879
- const result = new DisplayToken({
6879
+ return new DisplayToken({
6880
6880
  ...FontMetrics.measureCharSize(symbol, fontString),
6881
6881
  displayValue: this.getSymbolDisplayValue(symbol),
6882
6882
  index
6883
6883
  });
6884
- if (result.isSpace) {
6885
- result.ascent = 0;
6886
- result.descent = 0;
6887
- result.height = 0;
6888
- }
6889
- return result;
6890
6884
  }
6891
6885
  static getComponentTokens(component, fontString, index) {
6892
6886
  if (component.instance instanceof ExternalComponent && component.instance.isText) {
@@ -6896,41 +6890,33 @@ class DisplayTokenHelper {
6896
6890
  for (let i = 0; i < text.length; i++) {
6897
6891
  result.push(this.getSymbolToken(text[i], fontString, index));
6898
6892
  result[i].customIndex = i;
6893
+ result[i].customText = text;
6899
6894
  }
6900
- return result.length ? result : [this.getSymbolToken(' ', fontString, index)];
6895
+ return result;
6901
6896
  }
6902
- const ascent = component.instance.ascent() ?? 0;
6903
- const descent = component.instance.descent() ?? 0;
6904
- return [
6905
- new DisplayToken({
6906
- width: component.instance.width(),
6907
- height: ascent + descent,
6908
- font: FontMetrics.measureCharSize('0', fontString).font,
6909
- ascent,
6910
- descent,
6911
- displayValue: this.getComponentDisplayValue(component.instance),
6912
- index
6913
- })
6914
- ];
6897
+ return [this.getComponentToken(component, fontString, index)];
6915
6898
  }
6916
- static getTableTokens(component, fontString, index, withNumbering) {
6917
- if (!withNumbering) {
6918
- return this.getComponentTokens(component, fontString, index);
6919
- }
6920
- const spaceToken = this.getSymbolToken(' ', fontString, index);
6921
- spaceToken.customIndex = 0;
6899
+ static getComponentToken(component, fontString, index) {
6922
6900
  const ascent = component.instance.ascent() ?? 0;
6923
6901
  const descent = component.instance.descent() ?? 0;
6924
- const tableToken = new DisplayToken({
6902
+ return new DisplayToken({
6925
6903
  width: component.instance.width(),
6926
6904
  height: ascent + descent,
6927
6905
  font: FontMetrics.measureCharSize('0', fontString).font,
6928
6906
  ascent,
6929
6907
  descent,
6930
- displayValue: DisplayValue.table,
6931
- index,
6932
- customIndex: 1
6908
+ displayValue: this.getComponentDisplayValue(component.instance),
6909
+ index
6933
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;
6934
6920
  return [spaceToken, tableToken];
6935
6921
  }
6936
6922
  static getBreakDisplayValue(breakType) {
@@ -7083,6 +7069,7 @@ class LineInfoHelper {
7083
7069
  let maxAscent = 0;
7084
7070
  let maxDescent = 0;
7085
7071
  let i = 0;
7072
+ const length = tokens[tokens.length - 1].isParagraph && tokens.length > 1 ? tokens.length - 1 : tokens.length;
7086
7073
  do {
7087
7074
  if (maxAscent < tokens[i].ascent) {
7088
7075
  maxAscent = tokens[i].ascent;
@@ -7092,10 +7079,7 @@ class LineInfoHelper {
7092
7079
  }
7093
7080
  line.width += tokens[i].width;
7094
7081
  i++;
7095
- } while (i < tokens.length);
7096
- if (tokens.length > 1 && tokens[tokens.length - 1].isParagraph) {
7097
- line.width -= tokens[tokens.length - 1].width;
7098
- }
7082
+ } while (i < length);
7099
7083
  line.height = maxAscent + maxDescent;
7100
7084
  line.ascent = maxAscent;
7101
7085
  if (line.height === 0) {
@@ -7154,7 +7138,8 @@ class LineInfoHelper {
7154
7138
  line.customTexts.push({
7155
7139
  index: indexInParagraph,
7156
7140
  start: token.customIndex,
7157
- end: token.customIndex + 1
7141
+ end: token.customIndex + 1,
7142
+ text: token.customText
7158
7143
  });
7159
7144
  }
7160
7145
  }
@@ -13351,7 +13336,7 @@ class RenderingHelper {
13351
13336
  this.renderText(fragment, textStyle, textBeforeElement, wordSpacing);
13352
13337
  renderedIndexes += textBeforeElement.length;
13353
13338
  if (component.instance instanceof ExternalComponent && component.instance.isText) {
13354
- const rendered = this.renderExternalText(fragment, textStyle, wordSpacing, component.instance, line, renderedTokensInLine, paragraphStartIndex);
13339
+ const rendered = this.renderExternalText(fragment, textStyle, wordSpacing, component.instance, line, renderedTokensInLine + renderedIndexes + additionalTokens, paragraphStartIndex);
13355
13340
  renderedIndexes += rendered.renderedIndexes;
13356
13341
  additionalTokens += rendered.additionalTokens;
13357
13342
  }
@@ -13385,10 +13370,8 @@ class RenderingHelper {
13385
13370
  { name: 'data-session-id', value: `${instance.sessionId}` },
13386
13371
  { name: 'data-insert-index', value: `${instance.insertIndex}` }
13387
13372
  ];
13388
- let text = instance.getText();
13389
- text = !text.length ? ' ' : text;
13390
13373
  const customText = line.customTexts.find(x => x.index === instance.insertIndex - paragraphStartIndex);
13391
- const customTextFragment = text.substring(customText.start, customText.end);
13374
+ const customTextFragment = customText.text.substring(customText.start, customText.end);
13392
13375
  if (!line.wordSpacing) {
13393
13376
  this.renderText(fragment, textStyle, customTextFragment, wordSpacing, classes, attributes, style);
13394
13377
  additionalTokens += customTextFragment.length;
@@ -13410,7 +13393,7 @@ class RenderingHelper {
13410
13393
  additionalTokens += rightText.length;
13411
13394
  }
13412
13395
  }
13413
- if (text.length === customText.end) {
13396
+ if (customText.text.length === customText.end) {
13414
13397
  renderedIndexes++;
13415
13398
  additionalTokens--;
13416
13399
  }