@talrace/ngx-noder 19.0.57 → 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) {
|
|
@@ -7166,6 +7173,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
|
|
|
7166
7173
|
}] });
|
|
7167
7174
|
|
|
7168
7175
|
class DisplayTokenHelper {
|
|
7176
|
+
static { this.SPACE_NORMALIZER_REGEX = /[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/; }
|
|
7169
7177
|
static getParagraphToken(paragraphSymbolStyle, index) {
|
|
7170
7178
|
const size = FontMetrics.measureCharSize('0', ContentStyleHelper.getFontStylesString(paragraphSymbolStyle));
|
|
7171
7179
|
return new DisplayToken({ ...size, displayValue: DisplayValue.paragraph, index });
|
|
@@ -7178,9 +7186,10 @@ class DisplayTokenHelper {
|
|
|
7178
7186
|
});
|
|
7179
7187
|
}
|
|
7180
7188
|
static getSymbolToken(symbol, fontString, index) {
|
|
7189
|
+
const normalizedSymbol = this.SPACE_NORMALIZER_REGEX.test(symbol) ? ' ' : symbol;
|
|
7181
7190
|
return new DisplayToken({
|
|
7182
|
-
...FontMetrics.measureCharSize(
|
|
7183
|
-
displayValue: this.getSymbolDisplayValue(
|
|
7191
|
+
...FontMetrics.measureCharSize(normalizedSymbol, fontString),
|
|
7192
|
+
displayValue: this.getSymbolDisplayValue(normalizedSymbol),
|
|
7184
7193
|
index
|
|
7185
7194
|
});
|
|
7186
7195
|
}
|
|
@@ -8380,12 +8389,13 @@ class DisplayData extends EventEmitting {
|
|
|
8380
8389
|
for (let i = 0; i < content.length; i++) {
|
|
8381
8390
|
const breakType = BreakHelper.getBreakType(this.model.breaks, content[i], contentIndex);
|
|
8382
8391
|
const customComponent = breakType === null ? this.getOrGenerateComponent(contentIndex, content[i]) : null;
|
|
8383
|
-
let newTokens = breakType !== null
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
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)];
|
|
8389
8399
|
contentIndex++;
|
|
8390
8400
|
if (contentIndex > format.endIndex) {
|
|
8391
8401
|
format = FormatStyleHelper.getFormatAtIndex(this.model.formats, contentIndex);
|
|
@@ -15282,7 +15292,7 @@ class Editor {
|
|
|
15282
15292
|
this.session.applyToolbarStyles();
|
|
15283
15293
|
this.onSetCommentsVisibility(!!this.model.comments.length);
|
|
15284
15294
|
this.search = new Search(editorService);
|
|
15285
|
-
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());
|
|
15286
15296
|
}
|
|
15287
15297
|
destroy() {
|
|
15288
15298
|
this.subscriptions.forEach(s => s?.unsubscribe());
|
|
@@ -16657,6 +16667,36 @@ class Editor {
|
|
|
16657
16667
|
this.onSelectionChange();
|
|
16658
16668
|
this.onContentChange();
|
|
16659
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
|
+
}
|
|
16660
16700
|
insertContent(insertIndex, contents) {
|
|
16661
16701
|
const insertContents = new InsertContentsModel({ insertIndex, contents });
|
|
16662
16702
|
this.saveInsertContentsToHistory(insertContents);
|
|
@@ -17283,6 +17323,11 @@ class Editor {
|
|
|
17283
17323
|
this.scrollCursorIntoMainView();
|
|
17284
17324
|
}
|
|
17285
17325
|
}
|
|
17326
|
+
insertNextElementSubscription() {
|
|
17327
|
+
return this.editorService.insertNextElement$.subscribe(element => {
|
|
17328
|
+
this.insertNextElement(element);
|
|
17329
|
+
});
|
|
17330
|
+
}
|
|
17286
17331
|
insertContentsSubscription() {
|
|
17287
17332
|
return this.editorService.insertContents$.subscribe(contents => {
|
|
17288
17333
|
const start = this.selection.range.start;
|