@talrace/ngx-noder 19.0.58 → 19.0.60
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) {
|
|
@@ -8178,8 +8185,8 @@ class DisplayData extends EventEmitting {
|
|
|
8178
8185
|
paragraphSettings.calculateDistanceFromTop(pageHeight, this.pagesSpace, pageVerticalData.marginTop, prevFormatsData);
|
|
8179
8186
|
}
|
|
8180
8187
|
this.pagesFormat.forEach((x, i) => {
|
|
8181
|
-
const
|
|
8182
|
-
x.updateData(
|
|
8188
|
+
const paragraphs = this.getPageFormatParagraphs(i);
|
|
8189
|
+
x.updateData(this.getPhysicalHeight(paragraphs));
|
|
8183
8190
|
});
|
|
8184
8191
|
this.allPagesHeight = 0;
|
|
8185
8192
|
this.pagesFormat.forEach((x, i) => {
|
|
@@ -8200,7 +8207,7 @@ class DisplayData extends EventEmitting {
|
|
|
8200
8207
|
});
|
|
8201
8208
|
}
|
|
8202
8209
|
getAllParagraphsHeight() {
|
|
8203
|
-
return this.
|
|
8210
|
+
return this.getPhysicalHeight(this.paragraphs);
|
|
8204
8211
|
}
|
|
8205
8212
|
destroy() {
|
|
8206
8213
|
this.removeAllListeners('pagesCountChanged');
|
|
@@ -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);
|
|
@@ -8638,6 +8646,15 @@ class DisplayData extends EventEmitting {
|
|
|
8638
8646
|
paragraph.paragraphSettings.startInsertIndex = paragraph.startIndex;
|
|
8639
8647
|
}
|
|
8640
8648
|
}
|
|
8649
|
+
getPhysicalHeight(paragraphs) {
|
|
8650
|
+
const bounds = paragraphs
|
|
8651
|
+
.flatMap(x => x.paragraphSettings?.textLinesInfo || [])
|
|
8652
|
+
.reduce((acc, line) => ({
|
|
8653
|
+
cursorY: acc.cursorY + line.offsetBefore + line.height + line.offsetAfter + (line.endPageOffset || 0),
|
|
8654
|
+
maxBottom: Math.max(acc.maxBottom, acc.cursorY + line.offsetBefore + line.height)
|
|
8655
|
+
}), { cursorY: 0, maxBottom: 0 });
|
|
8656
|
+
return Math.max(bounds.cursorY, bounds.maxBottom);
|
|
8657
|
+
}
|
|
8641
8658
|
}
|
|
8642
8659
|
|
|
8643
8660
|
class NoderEdgeComponent extends DestroyComponent {
|
|
@@ -15284,7 +15301,7 @@ class Editor {
|
|
|
15284
15301
|
this.session.applyToolbarStyles();
|
|
15285
15302
|
this.onSetCommentsVisibility(!!this.model.comments.length);
|
|
15286
15303
|
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());
|
|
15304
|
+
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
15305
|
}
|
|
15289
15306
|
destroy() {
|
|
15290
15307
|
this.subscriptions.forEach(s => s?.unsubscribe());
|
|
@@ -16659,6 +16676,36 @@ class Editor {
|
|
|
16659
16676
|
this.onSelectionChange();
|
|
16660
16677
|
this.onContentChange();
|
|
16661
16678
|
}
|
|
16679
|
+
insertNextElement(element) {
|
|
16680
|
+
const selectionRange = this.selection.selectedRange;
|
|
16681
|
+
const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, selectionRange.end) + 1;
|
|
16682
|
+
const currentFormat = structuredClone(FormatStyleHelper.getFormatAtIndex(this.session.model.formats, insertIndex));
|
|
16683
|
+
currentFormat.startIndex = 0;
|
|
16684
|
+
currentFormat.endIndex = 1;
|
|
16685
|
+
const nextElementContents = new ContentsModel({
|
|
16686
|
+
content: ` ${CUSTOM_ELEMENT_MARKER}`,
|
|
16687
|
+
paragraphs: [],
|
|
16688
|
+
elements: [new ElementModel({ guid: element.guid, type: element.type, id: element.id, insertIndex: 1 })],
|
|
16689
|
+
formats: [currentFormat],
|
|
16690
|
+
breaks: [],
|
|
16691
|
+
images: [],
|
|
16692
|
+
tables: [],
|
|
16693
|
+
tabs: [],
|
|
16694
|
+
links: [],
|
|
16695
|
+
comments: []
|
|
16696
|
+
});
|
|
16697
|
+
this.insertContent(insertIndex, nextElementContents);
|
|
16698
|
+
setTimeout(() => {
|
|
16699
|
+
// Need to skip micro tasks for a render element before focus
|
|
16700
|
+
const component = this.session.customComponents.customElements.find(x => x.instance.content.insertIndex === insertIndex + 1);
|
|
16701
|
+
if (component) {
|
|
16702
|
+
const position = this.session.displayData.indexToPosition(component.instance.insertIndex, 0);
|
|
16703
|
+
this.selection.focus(component, position);
|
|
16704
|
+
this.onSelectionChange();
|
|
16705
|
+
this.scrollCursorIntoMainView();
|
|
16706
|
+
}
|
|
16707
|
+
});
|
|
16708
|
+
}
|
|
16662
16709
|
insertContent(insertIndex, contents) {
|
|
16663
16710
|
const insertContents = new InsertContentsModel({ insertIndex, contents });
|
|
16664
16711
|
this.saveInsertContentsToHistory(insertContents);
|
|
@@ -16872,7 +16919,7 @@ class Editor {
|
|
|
16872
16919
|
const beforeTable = ContentHelper.documentIndexToParagraphIndex(this.session.displayData.paragraphs, insertIndex);
|
|
16873
16920
|
this.selection.placeCursor(beforeTable);
|
|
16874
16921
|
this.history.pushRemoveTableRows(insertIndex, startIndex, endIndex);
|
|
16875
|
-
this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableRowsCommand(startIndex, endIndex,
|
|
16922
|
+
this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableRowsCommand(insertIndex, startIndex, endIndex, this.targets));
|
|
16876
16923
|
this.session.removeTableRows(insertIndex, startIndex, endIndex);
|
|
16877
16924
|
this.changedTableSize(insertIndex, sessionId);
|
|
16878
16925
|
this.onContentChange();
|
|
@@ -16882,7 +16929,7 @@ class Editor {
|
|
|
16882
16929
|
const beforeTable = ContentHelper.documentIndexToParagraphIndex(this.session.displayData.paragraphs, insertIndex);
|
|
16883
16930
|
this.selection.placeCursor(beforeTable);
|
|
16884
16931
|
this.history.pushRemoveTableColumns(insertIndex, startIndex, endIndex);
|
|
16885
|
-
this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableColumnsCommand(startIndex, endIndex,
|
|
16932
|
+
this.commandsService.createCommand(SaveCommandsHelper.getRemoveTableColumnsCommand(insertIndex, startIndex, endIndex, this.targets));
|
|
16886
16933
|
this.session.removeTableColumns(insertIndex, startIndex, endIndex);
|
|
16887
16934
|
this.changedTableSize(insertIndex, sessionId);
|
|
16888
16935
|
this.onContentChange();
|
|
@@ -17285,6 +17332,11 @@ class Editor {
|
|
|
17285
17332
|
this.scrollCursorIntoMainView();
|
|
17286
17333
|
}
|
|
17287
17334
|
}
|
|
17335
|
+
insertNextElementSubscription() {
|
|
17336
|
+
return this.editorService.insertNextElement$.subscribe(element => {
|
|
17337
|
+
this.insertNextElement(element);
|
|
17338
|
+
});
|
|
17339
|
+
}
|
|
17288
17340
|
insertContentsSubscription() {
|
|
17289
17341
|
return this.editorService.insertContents$.subscribe(contents => {
|
|
17290
17342
|
const start = this.selection.range.start;
|