@talrace/ngx-noder 19.0.27 → 19.0.28

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.
@@ -596,6 +596,7 @@ class EditorService {
596
596
  this._insertText$ = new Subject();
597
597
  this._removeLeft$ = new Subject();
598
598
  this._removeCustomElementsData$ = new Subject();
599
+ this._restoreCustomElementsData$ = new Subject();
599
600
  this._currentPage$ = new BehaviorSubject(1);
600
601
  this._lastPageNumber$ = new BehaviorSubject(1);
601
602
  this._applyDocumentPageFormat$ = new Subject();
@@ -811,10 +812,16 @@ class EditorService {
811
812
  get removeLeft$() {
812
813
  return this._removeLeft$.asObservable();
813
814
  }
814
- // Will be used by Project which use Library. To manage the delete of the external custom elements associated with the local custom elements
815
+ // Will be used by Project which use Library. To manage the delete of the external custom elements associated with the local custom elements.
816
+ // Should not delete entities but hide them instead. Because of possible synchronous restore
815
817
  get removeCustomElementsData$() {
816
818
  return this._removeCustomElementsData$.asObservable();
817
819
  }
820
+ // Will be used by Project which use Library. To manage the restore of the external custom elements associated with the local custom elements.
821
+ // Should not create entities but unhide them instead. Because its synchronous
822
+ get restoreCustomElementsData$() {
823
+ return this._restoreCustomElementsData$.asObservable();
824
+ }
818
825
  get currentPage() {
819
826
  return this._currentPage$.value;
820
827
  }
@@ -1065,6 +1072,9 @@ class EditorService {
1065
1072
  removeCustomElementsData(elements) {
1066
1073
  this._removeCustomElementsData$.next(elements);
1067
1074
  }
1075
+ restoreCustomElementsData(elements) {
1076
+ this._restoreCustomElementsData$.next(elements);
1077
+ }
1068
1078
  setNewSearchTerm(term) {
1069
1079
  this._searchTerm$.next(term);
1070
1080
  }
@@ -2660,7 +2670,7 @@ class ContentsOperationsHelper {
2660
2670
  const paragraphs = IndexedElementHelper.sliceSection(contents.paragraphs, startIndex, endIndex).map(x => new ParagraphModel(x));
2661
2671
  const images = IndexedElementHelper.sliceSection(contents.images, startIndex, endIndex).map(x => new ImageModel(x));
2662
2672
  const tables = IndexedElementHelper.sliceSection(contents.tables, startIndex, endIndex).map(x => new TableModel(x));
2663
- const elements = IndexedElementHelper.sliceSection(contents.elements, startIndex, endIndex).map(x => new ElementModel({ ...x, id: 0, guid: '' }));
2673
+ const elements = IndexedElementHelper.sliceSection(contents.elements, startIndex, endIndex).map(x => new ElementModel(x));
2664
2674
  const breaks = IndexedElementHelper.sliceSection(contents.breaks, startIndex, endIndex).map(x => new BreakModel(x));
2665
2675
  const tabs = IndexedElementHelper.sliceSection(contents.tabs, startIndex, endIndex).map(x => new TabModel(x));
2666
2676
  const links = LinkHelper.sliceSection(contents.links, startIndex, endIndex).map(x => new LinkModel(x));
@@ -8745,8 +8755,10 @@ class Editor {
8745
8755
  command = SaveCommandsHelper.getInsertStyledTextCommand(text, insertIndex, textStyle, this.targets);
8746
8756
  }
8747
8757
  else if (operation instanceof RestoreModel) {
8748
- this.session.restore(structuredClone(operation));
8749
- command = SaveCommandsHelper.getRestoreCommand(structuredClone(operation), this.targets);
8758
+ const deepCopy = structuredClone(operation);
8759
+ this.editorService.restoreCustomElementsData(deepCopy.elements);
8760
+ this.session.restore(deepCopy);
8761
+ command = SaveCommandsHelper.getRestoreCommand(deepCopy, this.targets);
8750
8762
  }
8751
8763
  else if (operation instanceof ApplyTextStyleModel) {
8752
8764
  this.session.applyTextStyle(operation.startIndex, operation.endIndex, new TextStyleModel(operation.textStyle));
@@ -8858,8 +8870,10 @@ class Editor {
8858
8870
  command = SaveCommandsHelper.getRemoveWithParagraphCommand(operation, this.targets);
8859
8871
  }
8860
8872
  else if (operation instanceof RestoreWithParagraphModel) {
8861
- this.session.restoreWithParagraph(operation);
8862
- command = SaveCommandsHelper.getRestoreWithParagraphCommand(operation, this.targets);
8873
+ const deepCopy = structuredClone(operation);
8874
+ this.editorService.restoreCustomElementsData(deepCopy.restore.elements);
8875
+ this.session.restoreWithParagraph(deepCopy);
8876
+ command = SaveCommandsHelper.getRestoreWithParagraphCommand(deepCopy, this.targets);
8863
8877
  }
8864
8878
  else if (operation instanceof MoveRangeModel) {
8865
8879
  this.moveRange(operation);
@@ -8891,8 +8905,10 @@ class Editor {
8891
8905
  this.recreateMainSession();
8892
8906
  }
8893
8907
  else if (operation instanceof ReplaceByRestoreModel) {
8894
- this.session.replaceByRestore(structuredClone(operation));
8895
- command = SaveCommandsHelper.getReplaceByRestoreCommand(structuredClone(operation), this.targets);
8908
+ const deepCopy = structuredClone(operation);
8909
+ this.editorService.restoreCustomElementsData(deepCopy.restore.elements);
8910
+ this.session.replaceByRestore(structuredClone(deepCopy));
8911
+ command = SaveCommandsHelper.getReplaceByRestoreCommand(structuredClone(deepCopy), this.targets);
8896
8912
  }
8897
8913
  else if (operation instanceof ApplyParagraphsModel) {
8898
8914
  const deepCopy = structuredClone(operation);