@talrace/ngx-noder 19.0.58 → 19.0.59
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.
|
@@ -720,6 +720,7 @@ class EditorService {
|
|
|
720
720
|
this._setCommentsVisibility$ = new Subject();
|
|
721
721
|
this._getCommentText$ = new Subject();
|
|
722
722
|
this._replaceCommentText$ = new Subject();
|
|
723
|
+
this._insertNextElement$ = new Subject();
|
|
723
724
|
this._requestContentsInsertion$ = new Subject();
|
|
724
725
|
this._insertContents$ = new Subject();
|
|
725
726
|
this._startNewList$ = new Subject();
|
|
@@ -1030,6 +1031,9 @@ class EditorService {
|
|
|
1030
1031
|
get replaceCommentText$() {
|
|
1031
1032
|
return this._replaceCommentText$.asObservable();
|
|
1032
1033
|
}
|
|
1034
|
+
get insertNextElement$() {
|
|
1035
|
+
return this._insertNextElement$.asObservable();
|
|
1036
|
+
}
|
|
1033
1037
|
get requestContentsInsertion$() {
|
|
1034
1038
|
return this._requestContentsInsertion$.asObservable();
|
|
1035
1039
|
}
|
|
@@ -1045,6 +1049,9 @@ class EditorService {
|
|
|
1045
1049
|
get setNumberingValue$() {
|
|
1046
1050
|
return this._setNumberingValue$.asObservable();
|
|
1047
1051
|
}
|
|
1052
|
+
insertNextElement(data) {
|
|
1053
|
+
this._insertNextElement$.next(data);
|
|
1054
|
+
}
|
|
1048
1055
|
requestContentsInsertion(contents, from) {
|
|
1049
1056
|
this._requestContentsInsertion$.next({ contents, from });
|
|
1050
1057
|
}
|
|
@@ -2086,6 +2093,14 @@ class ContentHelper {
|
|
|
2086
2093
|
}
|
|
2087
2094
|
}
|
|
2088
2095
|
|
|
2096
|
+
class ContentsModel {
|
|
2097
|
+
constructor(fields) {
|
|
2098
|
+
if (fields) {
|
|
2099
|
+
Object.assign(this, fields);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2089
2104
|
class BreakModel {
|
|
2090
2105
|
constructor(fields) {
|
|
2091
2106
|
if (fields) {
|
|
@@ -2112,14 +2127,6 @@ class ContentOperationsHelper {
|
|
|
2112
2127
|
}
|
|
2113
2128
|
}
|
|
2114
2129
|
|
|
2115
|
-
class ContentsModel {
|
|
2116
|
-
constructor(fields) {
|
|
2117
|
-
if (fields) {
|
|
2118
|
-
Object.assign(this, fields);
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
2130
|
class ElementModel {
|
|
2124
2131
|
constructor(fields) {
|
|
2125
2132
|
if (fields) {
|
|
@@ -8382,12 +8389,13 @@ class DisplayData extends EventEmitting {
|
|
|
8382
8389
|
for (let i = 0; i < content.length; i++) {
|
|
8383
8390
|
const breakType = BreakHelper.getBreakType(this.model.breaks, content[i], contentIndex);
|
|
8384
8391
|
const customComponent = breakType === null ? this.getOrGenerateComponent(contentIndex, content[i]) : null;
|
|
8385
|
-
let newTokens = breakType !== null
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8392
|
+
let newTokens = breakType !== null
|
|
8393
|
+
? [DisplayTokenHelper.getBreakToken(content[i], fontString, breakType, contentIndex)]
|
|
8394
|
+
: customComponent !== null
|
|
8395
|
+
? customComponent.instance instanceof NoderTableComponent
|
|
8396
|
+
? DisplayTokenHelper.getTableTokens(customComponent, fontString, contentIndex, withNumbering)
|
|
8397
|
+
: DisplayTokenHelper.getComponentTokens(customComponent, fontString, contentIndex)
|
|
8398
|
+
: [DisplayTokenHelper.getSymbolToken(content[i], fontString, contentIndex)];
|
|
8391
8399
|
contentIndex++;
|
|
8392
8400
|
if (contentIndex > format.endIndex) {
|
|
8393
8401
|
format = FormatStyleHelper.getFormatAtIndex(this.model.formats, contentIndex);
|
|
@@ -15284,7 +15292,7 @@ class Editor {
|
|
|
15284
15292
|
this.session.applyToolbarStyles();
|
|
15285
15293
|
this.onSetCommentsVisibility(!!this.model.comments.length);
|
|
15286
15294
|
this.search = new Search(editorService);
|
|
15287
|
-
this.subscriptions.push(this.changedEdgeSizeSubscription(), this.changedEdgeSubscription(), this.changedTableSizeSubscription(), this.copySelectedSubscription(), this.createCustomComponentSubscription(), this.replaceByCustomComponentSubscription(), this.cutSelectedSubscription(), this.disableSelectionSubscription(), this.endMousePressSubscription(), this.imageLoadedSubscription(), this.insertBreakSubscription(), this.insertImageSubscription(), this.insertLinkSubscription(), this.insertTableColumnsSubscription(), this.insertTableRowsSubscription(), this.insertTableSubscription(), this.updateTableBorderStyleSubscription(), this.updateTableBorderWidthSubscription(), this.updateTableBordersSubscription(), this.selectSpacingSubscription(), this.selectBeforeSubscription(), this.selectAfterSubscription(), this.insertTextSubscription(), this.pasteFromClipboardSubscription(), this.printSubscription(), this.redoSubscription(), this.removeLeftSubscription(), this.removeNumberingsSubscription(), this.removeRightSubscription(), this.removeSelectedSubscription(), this.removeTableColumnsSubscription(), this.removeTableRowsSubscription(), this.removeTableSubscription(), this.rerenderSubscription(), this.resizeTableColumnsSubscription(), ...this.searchOptionSubscriptions(), ...this.replaceSubscription(), this.grammarReplaceSubscription(), this.ignoreGrammarErrorSubscription(), this.toggleGrammarChecksSubscription(), this.selectAllSubscription(), this.setImageStyleSubscription(), this.setNumberingTemplateTypeSubscription(), this.setParagraphStylesSubscription(), this.setTextStylesSubscription(), this.undoSubscription(), this.updateEdgeSubscription(), this.viewOnlyModeSubscription(), this.applyPageFormatSubscription(), this.applyRightMarginPageFormatSubscription(), this.applyLeftMarginPageFormatSubscription(), this.insertPageFormatSubscription(), this.applyDocumentPageFormatSubscription(), this.dragMoveSubscription(), this.dragDropSubscription(), this.applyFirstLinePositionSubscription(), this.applyRightIndentParagraphSubscription(), this.applyLeftIndentParagraphSubscription(), this.applyTabSettingsSubscription(), this.commandCreatedForEdges(), ...this.commentCreationSubscriptions(), this.removeCommentSubscription(), this.rerenderCommentsSubscription(), this.selectCommentSubscription(), this.setComentsVisibilitySubscription(), this.getCommentTextSubscription(), this.replaceCommentTextSubscription(), this.startNewListSubscription(), this.continueNumberingSubscription(), this.setNumberingValueSubscription(), this.insertContentsSubscription());
|
|
15295
|
+
this.subscriptions.push(this.changedEdgeSizeSubscription(), this.changedEdgeSubscription(), this.changedTableSizeSubscription(), this.copySelectedSubscription(), this.createCustomComponentSubscription(), this.replaceByCustomComponentSubscription(), this.cutSelectedSubscription(), this.disableSelectionSubscription(), this.endMousePressSubscription(), this.imageLoadedSubscription(), this.insertBreakSubscription(), this.insertImageSubscription(), this.insertLinkSubscription(), this.insertTableColumnsSubscription(), this.insertTableRowsSubscription(), this.insertTableSubscription(), this.updateTableBorderStyleSubscription(), this.updateTableBorderWidthSubscription(), this.updateTableBordersSubscription(), this.selectSpacingSubscription(), this.selectBeforeSubscription(), this.selectAfterSubscription(), this.insertTextSubscription(), this.pasteFromClipboardSubscription(), this.printSubscription(), this.redoSubscription(), this.removeLeftSubscription(), this.removeNumberingsSubscription(), this.removeRightSubscription(), this.removeSelectedSubscription(), this.removeTableColumnsSubscription(), this.removeTableRowsSubscription(), this.removeTableSubscription(), this.rerenderSubscription(), this.resizeTableColumnsSubscription(), ...this.searchOptionSubscriptions(), ...this.replaceSubscription(), this.grammarReplaceSubscription(), this.ignoreGrammarErrorSubscription(), this.toggleGrammarChecksSubscription(), this.selectAllSubscription(), this.setImageStyleSubscription(), this.setNumberingTemplateTypeSubscription(), this.setParagraphStylesSubscription(), this.setTextStylesSubscription(), this.undoSubscription(), this.updateEdgeSubscription(), this.viewOnlyModeSubscription(), this.applyPageFormatSubscription(), this.applyRightMarginPageFormatSubscription(), this.applyLeftMarginPageFormatSubscription(), this.insertPageFormatSubscription(), this.applyDocumentPageFormatSubscription(), this.dragMoveSubscription(), this.dragDropSubscription(), this.applyFirstLinePositionSubscription(), this.applyRightIndentParagraphSubscription(), this.applyLeftIndentParagraphSubscription(), this.applyTabSettingsSubscription(), this.commandCreatedForEdges(), ...this.commentCreationSubscriptions(), this.removeCommentSubscription(), this.rerenderCommentsSubscription(), this.selectCommentSubscription(), this.setComentsVisibilitySubscription(), this.getCommentTextSubscription(), this.replaceCommentTextSubscription(), this.startNewListSubscription(), this.continueNumberingSubscription(), this.setNumberingValueSubscription(), this.insertContentsSubscription(), this.insertNextElementSubscription());
|
|
15288
15296
|
}
|
|
15289
15297
|
destroy() {
|
|
15290
15298
|
this.subscriptions.forEach(s => s?.unsubscribe());
|
|
@@ -16659,6 +16667,36 @@ class Editor {
|
|
|
16659
16667
|
this.onSelectionChange();
|
|
16660
16668
|
this.onContentChange();
|
|
16661
16669
|
}
|
|
16670
|
+
insertNextElement(element) {
|
|
16671
|
+
const selectionRange = this.selection.selectedRange;
|
|
16672
|
+
const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, selectionRange.end) + 1;
|
|
16673
|
+
const currentFormat = structuredClone(FormatStyleHelper.getFormatAtIndex(this.session.model.formats, insertIndex));
|
|
16674
|
+
currentFormat.startIndex = 0;
|
|
16675
|
+
currentFormat.endIndex = 1;
|
|
16676
|
+
const nextElementContents = new ContentsModel({
|
|
16677
|
+
content: ` ${CUSTOM_ELEMENT_MARKER}`,
|
|
16678
|
+
paragraphs: [],
|
|
16679
|
+
elements: [new ElementModel({ guid: element.guid, type: element.type, id: element.id, insertIndex: 1 })],
|
|
16680
|
+
formats: [currentFormat],
|
|
16681
|
+
breaks: [],
|
|
16682
|
+
images: [],
|
|
16683
|
+
tables: [],
|
|
16684
|
+
tabs: [],
|
|
16685
|
+
links: [],
|
|
16686
|
+
comments: []
|
|
16687
|
+
});
|
|
16688
|
+
this.insertContent(insertIndex, nextElementContents);
|
|
16689
|
+
setTimeout(() => {
|
|
16690
|
+
// Need to skip micro tasks for a render element before focus
|
|
16691
|
+
const component = this.session.customComponents.customElements.find(x => x.instance.content.insertIndex === insertIndex + 1);
|
|
16692
|
+
if (component) {
|
|
16693
|
+
const position = this.session.displayData.indexToPosition(component.instance.insertIndex, 0);
|
|
16694
|
+
this.selection.focus(component, position);
|
|
16695
|
+
this.onSelectionChange();
|
|
16696
|
+
this.scrollCursorIntoMainView();
|
|
16697
|
+
}
|
|
16698
|
+
});
|
|
16699
|
+
}
|
|
16662
16700
|
insertContent(insertIndex, contents) {
|
|
16663
16701
|
const insertContents = new InsertContentsModel({ insertIndex, contents });
|
|
16664
16702
|
this.saveInsertContentsToHistory(insertContents);
|
|
@@ -17285,6 +17323,11 @@ class Editor {
|
|
|
17285
17323
|
this.scrollCursorIntoMainView();
|
|
17286
17324
|
}
|
|
17287
17325
|
}
|
|
17326
|
+
insertNextElementSubscription() {
|
|
17327
|
+
return this.editorService.insertNextElement$.subscribe(element => {
|
|
17328
|
+
this.insertNextElement(element);
|
|
17329
|
+
});
|
|
17330
|
+
}
|
|
17288
17331
|
insertContentsSubscription() {
|
|
17289
17332
|
return this.editorService.insertContents$.subscribe(contents => {
|
|
17290
17333
|
const start = this.selection.range.start;
|