@talrace/ngx-noder 0.0.35 → 0.0.37

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.
@@ -1809,6 +1809,14 @@ var NumberingTemplateType;
1809
1809
  NumberingTemplateType[NumberingTemplateType["NumberList6"] = 11] = "NumberList6";
1810
1810
  })(NumberingTemplateType || (NumberingTemplateType = {}));
1811
1811
 
1812
+ /*
1813
+ * This file is the source of truth for numbering templates.
1814
+ * Its contents are manually duplicated in the C# project
1815
+ * in the `NumberingTemplates.cs` class.
1816
+ *
1817
+ * If you make changes here, you MUST sync them in the back-end!
1818
+ * !!!
1819
+ */
1812
1820
  const NumberingTemplates = [
1813
1821
  {
1814
1822
  templateType: NumberingTemplateType.NumberList1,
@@ -3694,7 +3702,7 @@ class RenderingHelper {
3694
3702
  }
3695
3703
  else {
3696
3704
  const paddingLeft = textFragment.startsWith(' ') && lineInfo.wordSpacing ? lineInfo.wordSpacing : null;
3697
- this.renderText(fragment, formatExt, textFragment, paddingLeft);
3705
+ this.renderText(fragment, formatExt, textFragmentWithoutBreaks, paddingLeft);
3698
3706
  }
3699
3707
  return textFragment.length;
3700
3708
  }
@@ -5261,7 +5269,7 @@ class Selection {
5261
5269
  }
5262
5270
  selectAll(model) {
5263
5271
  const last = model.paragraphs.length - 1;
5264
- const length = last > 0 ? model.contentLength - model.paragraphs[last - 1].insertIndex - 1 : model.contentLength;
5272
+ const length = last > 0 ? model.content.length - model.paragraphs[last - 1].insertIndex - 1 : model.content.length;
5265
5273
  this.placeSelection(new CursorParagraph(0, 0), new CursorParagraph(last, length));
5266
5274
  }
5267
5275
  selectUp(session) {
@@ -5915,7 +5923,7 @@ class Editor {
5915
5923
  }
5916
5924
  setTextStyle(textStyle) {
5917
5925
  const index = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, this.selection.cursor);
5918
- const isParagraph = this.session.model.contentLength === index || this.session.model.content[index] === NEW_LINE_MARKUP;
5926
+ const isParagraph = this.session.model.content.length === index || this.session.model.content[index] === NEW_LINE_MARKUP;
5919
5927
  if (isParagraph) {
5920
5928
  this.saveApplyTextStyleToHistory(index, index, textStyle);
5921
5929
  this.session.applyTextStyle(index, index, textStyle);
@@ -10516,7 +10524,6 @@ class EdgesOperationsHelper {
10516
10524
  pageType,
10517
10525
  breaks: [],
10518
10526
  content: '',
10519
- contentLength: 0,
10520
10527
  elements: [],
10521
10528
  formats: [new FormatModel({ startIndex: 0, endIndex: 0, textStyle: DEFAULT_TEXT_STYLE })],
10522
10529
  images: [],
@@ -10962,7 +10969,6 @@ class TableOperationsHelper {
10962
10969
  const cell = new CellModel({
10963
10970
  breaks: [],
10964
10971
  content: '',
10965
- contentLength: 0,
10966
10972
  elements: [],
10967
10973
  formats: [new FormatModel({ startIndex: 0, endIndex: 0, textStyle: DEFAULT_TEXT_STYLE })],
10968
10974
  images: [],
@@ -11065,7 +11071,6 @@ class TableOperationsHelper {
11065
11071
  ...matrix[inheritIndex].cells[i],
11066
11072
  breaks: [],
11067
11073
  content: '',
11068
- contentLength: 0,
11069
11074
  elements: [],
11070
11075
  images: [],
11071
11076
  formats: [
@@ -11102,7 +11107,6 @@ class TableOperationsHelper {
11102
11107
  ...x,
11103
11108
  breaks: [],
11104
11109
  content: '',
11105
- contentLength: 0,
11106
11110
  elements: [],
11107
11111
  formats: [new FormatModel({ startIndex: 0, endIndex: 0, textStyle: new TextStyleModel(x.formats[0].textStyle) })],
11108
11112
  images: [],
@@ -11155,7 +11159,6 @@ class TableOperationsHelper {
11155
11159
  ...row.cells[inheritIndex],
11156
11160
  breaks: [],
11157
11161
  content: '',
11158
- contentLength: 0,
11159
11162
  elements: [],
11160
11163
  formats: [new FormatModel({ startIndex: 0, endIndex: 0, textStyle: row.cells[inheritIndex].formats[0].textStyle })],
11161
11164
  horizontalMerge: null,
@@ -11239,7 +11242,6 @@ class TableOperationsHelper {
11239
11242
  matrix[rowIndex].cells[cellIndex].breaks = removedCell.breaks;
11240
11243
  matrix[rowIndex].cells[cellIndex].columnSections = removedCell.columnSections;
11241
11244
  matrix[rowIndex].cells[cellIndex].content = removedCell.content;
11242
- matrix[rowIndex].cells[cellIndex].contentLength = removedCell.contentLength;
11243
11245
  matrix[rowIndex].cells[cellIndex].elements = removedCell.elements;
11244
11246
  matrix[rowIndex].cells[cellIndex].formats = removedCell.formats;
11245
11247
  matrix[rowIndex].cells[cellIndex].horizontalMerge = removedCell.horizontalMerge;
@@ -11299,8 +11301,8 @@ class TableOperationsHelper {
11299
11301
  static calculateCellsWidth(table) {
11300
11302
  table.rows.forEach(row => {
11301
11303
  let columnIndex = 0;
11302
- for (let i = 0; i < row.cells.length; i++) {
11303
- let cell = row.cells[i];
11304
+ for (const element of row.cells) {
11305
+ let cell = element;
11304
11306
  if (cell.horizontalMerge) {
11305
11307
  let width = table.columns[columnIndex].width;
11306
11308
  for (let j = 1; j < cell.horizontalMerge; j++) {
@@ -11593,7 +11595,6 @@ class OperationsHelper {
11593
11595
  }
11594
11596
  static insertText(document, text, index) {
11595
11597
  document.content = ContentOperationsHelper.insertContent(document.content, text, index);
11596
- document.contentLength = document.content.length;
11597
11598
  FormatOperationsHelper.insertContent(document.formats, index, text.length);
11598
11599
  ParagraphOperationsHelper.insertContent(document.paragraphs, text, index);
11599
11600
  IndexedElementOperationsHelper.insertContent(document.images, index, text.length);
@@ -11607,7 +11608,6 @@ class OperationsHelper {
11607
11608
  const createdParagraphs = ParagraphOperationsHelper.insertParagraphsFromModel(document.paragraphs, index);
11608
11609
  const text = createdParagraphs.map(() => NEW_LINE_MARKUP).join('');
11609
11610
  document.content = ContentOperationsHelper.insertContent(document.content, text, index);
11610
- document.contentLength = document.content.length;
11611
11611
  FormatOperationsHelper.insertContent(document.formats, index, text.length);
11612
11612
  IndexedElementOperationsHelper.insertContent(document.images, index, text.length);
11613
11613
  IndexedElementOperationsHelper.insertContent(document.tables, index, text.length);
@@ -11635,7 +11635,6 @@ class OperationsHelper {
11635
11635
  }
11636
11636
  static insertElement(document, element) {
11637
11637
  document.content = ContentOperationsHelper.insertContent(document.content, CUSTOM_ELEMENT_MARKER, element.element.insertIndex);
11638
- document.contentLength = document.content.length;
11639
11638
  FormatOperationsHelper.insertContent(document.formats, element.element.insertIndex, 1);
11640
11639
  IndexedElementOperationsHelper.insertContent(document.paragraphs, element.element.insertIndex, 1);
11641
11640
  IndexedElementOperationsHelper.insertContent(document.images, element.element.insertIndex, 1);
@@ -11647,7 +11646,6 @@ class OperationsHelper {
11647
11646
  }
11648
11647
  static insertBreak(document, text, index, breakType) {
11649
11648
  document.content = ContentOperationsHelper.insertContent(document.content, text, index);
11650
- document.contentLength = document.content.length;
11651
11649
  FormatOperationsHelper.insertContent(document.formats, index, text.length);
11652
11650
  ParagraphOperationsHelper.insertContent(document.paragraphs, text, index);
11653
11651
  IndexedElementOperationsHelper.insertContent(document.images, index, text.length);
@@ -11659,7 +11657,6 @@ class OperationsHelper {
11659
11657
  }
11660
11658
  static insertTab(document, index) {
11661
11659
  document.content = ContentOperationsHelper.insertContent(document.content, CUSTOM_ELEMENT_MARKER, index);
11662
- document.contentLength = document.content.length;
11663
11660
  FormatOperationsHelper.insertContent(document.formats, index, 1);
11664
11661
  IndexedElementOperationsHelper.insertContent(document.paragraphs, index, 1);
11665
11662
  IndexedElementOperationsHelper.insertContent(document.images, index, 1);
@@ -11671,7 +11668,6 @@ class OperationsHelper {
11671
11668
  }
11672
11669
  static insertLink(document, text, link, index) {
11673
11670
  document.content = ContentOperationsHelper.insertContent(document.content, text, index);
11674
- document.contentLength = document.content.length;
11675
11671
  FormatOperationsHelper.insertContent(document.formats, index, text.length);
11676
11672
  ParagraphOperationsHelper.insertContent(document.paragraphs, text, index);
11677
11673
  IndexedElementOperationsHelper.insertContent(document.images, index, text.length);
@@ -11710,7 +11706,6 @@ class OperationsHelper {
11710
11706
  }
11711
11707
  static insertImage(document, index, imageData) {
11712
11708
  document.content = ContentOperationsHelper.insertContent(document.content, CUSTOM_ELEMENT_MARKER, index);
11713
- document.contentLength = document.content.length;
11714
11709
  FormatOperationsHelper.insertContent(document.formats, index, 1);
11715
11710
  IndexedElementOperationsHelper.insertContent(document.paragraphs, index, 1);
11716
11711
  IndexedElementOperationsHelper.insertContent(document.tables, index, 1);
@@ -11722,7 +11717,6 @@ class OperationsHelper {
11722
11717
  }
11723
11718
  static insertTable(document, index, tableModel, contentWidth) {
11724
11719
  document.content = ContentOperationsHelper.insertContent(document.content, tableModel.content, index);
11725
- document.contentLength = document.content.length;
11726
11720
  FormatOperationsHelper.insertContent(document.formats, index, tableModel.content.length);
11727
11721
  ParagraphOperationsHelper.insertContent(document.paragraphs, tableModel.content, index);
11728
11722
  IndexedElementOperationsHelper.insertContent(document.images, index, tableModel.content.length);
@@ -11734,7 +11728,6 @@ class OperationsHelper {
11734
11728
  }
11735
11729
  static insertStyledText(document, text, index, style) {
11736
11730
  document.content = ContentOperationsHelper.insertContent(document.content, text, index);
11737
- document.contentLength = document.content.length;
11738
11731
  FormatOperationsHelper.insertStyledContent(document.formats, index, text.length, style);
11739
11732
  ParagraphOperationsHelper.insertContent(document.paragraphs, text, index);
11740
11733
  IndexedElementOperationsHelper.insertContent(document.images, index, text.length);
@@ -11752,7 +11745,6 @@ class OperationsHelper {
11752
11745
  }
11753
11746
  static restore(document, model) {
11754
11747
  document.content = ContentOperationsHelper.insertContent(document.content, model.text, model.startIndex);
11755
- document.contentLength = document.content.length;
11756
11748
  FormatOperationsHelper.restore(document.formats, model.startIndex, model.text.length, model.formats);
11757
11749
  IndexedElementOperationsHelper.restore(document.paragraphs, model.startIndex, model.text.length, model.paragraphs);
11758
11750
  IndexedElementOperationsHelper.restore(document.images, model.startIndex, model.text.length, model.images);
@@ -11764,7 +11756,6 @@ class OperationsHelper {
11764
11756
  }
11765
11757
  static delete(document, startIndex, count) {
11766
11758
  document.content = ContentOperationsHelper.removeContent(document.content, startIndex, count);
11767
- document.contentLength = document.content.length;
11768
11759
  const endIndex = startIndex + count - 1;
11769
11760
  FormatOperationsHelper.removeContent(document.formats, startIndex, endIndex);
11770
11761
  IndexedElementOperationsHelper.removeContent(document.paragraphs, startIndex, endIndex);
@@ -11777,7 +11768,6 @@ class OperationsHelper {
11777
11768
  }
11778
11769
  static replaceText(document, startIndex, endIndex, text) {
11779
11770
  document.content = ContentOperationsHelper.replaceContent(document.content, startIndex, endIndex, text);
11780
- document.contentLength = document.content.length;
11781
11771
  FormatOperationsHelper.replaceContent(document.formats, startIndex, endIndex, text.length);
11782
11772
  ParagraphOperationsHelper.replace(document.paragraphs, text, startIndex, endIndex);
11783
11773
  IndexedElementOperationsHelper.replaceContent(document.images, startIndex, endIndex, text.length);
@@ -12061,6 +12051,7 @@ class EditSession {
12061
12051
  const endParagraph = ContentHelper.documentIndexToParagraphIndex(this.displayData.paragraphs, endIndex).row;
12062
12052
  OperationsHelper.applyTextStyle(this.model, startIndex, endIndex, textStyle);
12063
12053
  this.provideTextStyle(startIndex, endIndex);
12054
+ this.displayData.resetAllNumberingInfo(startParagraph);
12064
12055
  this.displayData.updateNextLineIndexes(startParagraph, endParagraph);
12065
12056
  this.setTextStyle(textStyle);
12066
12057
  }
@@ -12068,6 +12059,7 @@ class EditSession {
12068
12059
  const startParagraph = ContentHelper.documentIndexToParagraphIndex(this.displayData.paragraphs, startIndex).row;
12069
12060
  const endParagraph = ContentHelper.documentIndexToParagraphIndex(this.displayData.paragraphs, endIndex).row;
12070
12061
  OperationsHelper.applyParagraphStyle(this.model, startIndex, endIndex, paragraphStyle);
12062
+ this.displayData.resetAllNumberingInfo(startParagraph);
12071
12063
  this.displayData.updateNextLineIndexes(startParagraph, endParagraph);
12072
12064
  this.applyToolbarStyles();
12073
12065
  }
@@ -12121,6 +12113,7 @@ class EditSession {
12121
12113
  imageComponentRef.instance.resize({ width: applyImage.width, height: applyImage.height });
12122
12114
  OperationsHelper.applyImageStyle(this.model, applyImage);
12123
12115
  const start = this.displayData.indexToPosition(applyImage.insertIndex, 0);
12116
+ this.displayData.resetAllNumberingInfo(start.row);
12124
12117
  this.displayData.updateNextLineIndexes(start.row, this.displayData.paragraphs.length - 1);
12125
12118
  }
12126
12119
  restoreTextStyles(formats, linkFormats) {
@@ -12130,6 +12123,7 @@ class EditSession {
12130
12123
  const endPosition = ContentHelper.documentIndexToParagraphWithOffset(this.displayData.paragraphs, endIndex);
12131
12124
  OperationsHelper.restoreTextStyles(this.model, formats, linkFormats);
12132
12125
  this.provideTextStyle(startIndex, endIndex);
12126
+ this.displayData.resetAllNumberingInfo(startParagraph);
12133
12127
  this.displayData.updateNextLineIndexes(startParagraph, endPosition.row);
12134
12128
  this.selection.placeCursor(endPosition);
12135
12129
  this.applyToolbarStyles();
@@ -12303,6 +12297,7 @@ class EditSession {
12303
12297
  const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.displayData.paragraphs, position);
12304
12298
  const text = OperationsHelper.insertParagraph(this.model, insertIndex, paragraphModel, this.displayData.contentWidth);
12305
12299
  const endPosition = this.displayData.insertText(position, text);
12300
+ this.displayData.resetAllNumberingInfo(position.row);
12306
12301
  this.displayData.updateNextLineIndexes(position.row, endPosition.row);
12307
12302
  if (endPosition.row - position.row) {
12308
12303
  this.displayData.updateNumberingsDataOnChange(endPosition.row);
@@ -12311,6 +12306,7 @@ class EditSession {
12311
12306
  if (paragraphModel.insertText) {
12312
12307
  const paragraphPosition = ContentHelper.documentIndexToParagraphIndex(this.displayData.paragraphs, paragraphModel.insertText.insertIndex);
12313
12308
  endPoint = this.displayData.insertText(paragraphPosition, text);
12309
+ this.displayData.resetAllNumberingInfo(paragraphPosition.row);
12314
12310
  this.displayData.updateNextLineIndexes(paragraphPosition.row, endPoint.row);
12315
12311
  if (endPoint.row - paragraphPosition.row) {
12316
12312
  this.displayData.updateNumberingsDataOnChange(endPoint.row);
@@ -12323,6 +12319,7 @@ class EditSession {
12323
12319
  const model = this.model.images.find(x => x.insertIndex === imageInsertIndex);
12324
12320
  this.addComponent(this.customComponents.images, model, NoderImageComponent);
12325
12321
  endPoint = this.displayData.insertText(paragraphPosition, CUSTOM_ELEMENT_MARKER);
12322
+ this.displayData.resetAllNumberingInfo(paragraphPosition.row);
12326
12323
  this.displayData.updateNextLineIndexes(paragraphPosition.row, paragraphPosition.row);
12327
12324
  this.selection.placeCursor(endPoint);
12328
12325
  }
@@ -12331,6 +12328,7 @@ class EditSession {
12331
12328
  const model = this.model.tables.find(x => x.insertIndex === paragraphModel.insertTable.insertTableIndex);
12332
12329
  this.addComponent(this.customComponents.tables, model, NoderTableComponent);
12333
12330
  endPoint = this.displayData.insertText(paragraphPosition, paragraphModel.insertTable.content);
12331
+ this.displayData.resetAllNumberingInfo(paragraphPosition.row);
12334
12332
  this.displayData.updateNextLineIndexes(paragraphPosition.row, endPoint.row);
12335
12333
  if (endPoint.row - paragraphPosition.row) {
12336
12334
  this.displayData.updateNumberingsDataOnChange(endPoint.row);
@@ -15680,7 +15678,6 @@ class RevisionHelper {
15680
15678
  const pageMargin = new MarginModel();
15681
15679
  return new DocxModel({
15682
15680
  content: '',
15683
- contentLength: 0,
15684
15681
  headings: DEFAULT_HEADINGS,
15685
15682
  pageHeight: DocumentInfo.height,
15686
15683
  pageWidth: DocumentInfo.width,