@talrace/ngx-noder 19.0.62 → 19.0.63
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.
|
@@ -15521,43 +15521,73 @@ class Editor {
|
|
|
15521
15521
|
this.onContentChange();
|
|
15522
15522
|
}
|
|
15523
15523
|
insertImage(imageData) {
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15524
|
+
if (!this.selection.isEmpty && !this.selection.isFocused) {
|
|
15525
|
+
const startIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, this.selection.range.start);
|
|
15526
|
+
const pageFormat = this.session.displayData.getPageFormatAtPosition(startIndex);
|
|
15527
|
+
const adjustedImage = ImageHelper.getImageWithAllowedSize(imageData, pageFormat.contentWidth);
|
|
15528
|
+
const insertImage = new InsertImageModel({ insertIndex: startIndex, imageData: adjustedImage });
|
|
15529
15529
|
this.replaceBy(new ReplaceModel({ insertImage }));
|
|
15530
15530
|
return;
|
|
15531
15531
|
}
|
|
15532
|
+
const startPoint = this.selection.isFocused
|
|
15533
|
+
? new CursorParagraph(this.selection.cursor.row, this.selection.cursor.column + 1)
|
|
15534
|
+
: this.selection.cursor;
|
|
15535
|
+
const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, startPoint);
|
|
15536
|
+
const pageFormat = this.session.displayData.getPageFormatAtPosition(insertIndex);
|
|
15537
|
+
const adjustedImage = ImageHelper.getImageWithAllowedSize(imageData, pageFormat.contentWidth);
|
|
15538
|
+
const insertImage = new InsertImageModel({ insertIndex, imageData: adjustedImage });
|
|
15532
15539
|
this.saveInsertImageToHistory(insertImage);
|
|
15533
|
-
const endPoint = this.session.insertImage(
|
|
15534
|
-
let lastRow =
|
|
15535
|
-
this.renderer.updateLines(
|
|
15540
|
+
const endPoint = this.session.insertImage(startPoint, adjustedImage);
|
|
15541
|
+
let lastRow = startPoint.row === endPoint.row ? endPoint.row : Infinity;
|
|
15542
|
+
this.renderer.updateLines(startPoint.row, lastRow);
|
|
15536
15543
|
this.renderer.updateCursor();
|
|
15537
15544
|
this.rerenderMarker();
|
|
15538
15545
|
this.onContentChange();
|
|
15539
15546
|
}
|
|
15540
15547
|
insertLink(linkDataModel) {
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15548
|
+
if (!this.selection.isEmpty && !this.selection.isFocused) {
|
|
15549
|
+
const startIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, this.selection.range.start);
|
|
15550
|
+
const insertLink = new InsertLinkModel({ insertIndex: startIndex, linkDataModel });
|
|
15544
15551
|
this.replaceBy(new ReplaceModel({ insertLink }));
|
|
15545
15552
|
return;
|
|
15546
15553
|
}
|
|
15554
|
+
const startPoint = this.selection.isFocused
|
|
15555
|
+
? new CursorParagraph(this.selection.cursor.row, this.selection.cursor.column + 1)
|
|
15556
|
+
: this.selection.cursor;
|
|
15557
|
+
const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, startPoint);
|
|
15558
|
+
const insertLink = new InsertLinkModel({ insertIndex, linkDataModel });
|
|
15547
15559
|
this.saveInsertLinkToHistory(insertLink);
|
|
15548
|
-
this.session.insertLink(
|
|
15560
|
+
this.session.insertLink(startPoint, linkDataModel);
|
|
15549
15561
|
this.renderer.updateCursor();
|
|
15550
15562
|
this.rerenderMarker();
|
|
15551
15563
|
this.onContentChange();
|
|
15552
15564
|
}
|
|
15553
15565
|
insertTable(tableData) {
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15566
|
+
if (!this.selection.isEmpty && !this.selection.isFocused) {
|
|
15567
|
+
const start = this.selection.range.start;
|
|
15568
|
+
const end = this.selection.range.end;
|
|
15569
|
+
const startIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, start);
|
|
15570
|
+
const endIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, end);
|
|
15571
|
+
const isNumbering = !!this.session.displayData.paragraphs[start.row].paragraphSettings.numberingData.numberingId;
|
|
15572
|
+
const noParagraphLeft = startIndex !== 0 && !this.session.model.paragraphs.find(x => x.insertIndex === startIndex - 1);
|
|
15573
|
+
const noParagraphRight = !this.session.model.paragraphs.find(x => x.insertIndex === endIndex);
|
|
15574
|
+
const insertTable = new InsertTableModel({
|
|
15575
|
+
insertIndex: startIndex,
|
|
15576
|
+
rowsCount: tableData.rows,
|
|
15577
|
+
columnsCount: tableData.columns,
|
|
15578
|
+
insertParagraphBefore: isNumbering || noParagraphLeft,
|
|
15579
|
+
insertParagraphAfter: isNumbering || noParagraphRight
|
|
15580
|
+
});
|
|
15581
|
+
this.replaceBy(new ReplaceModel({ insertTable }));
|
|
15582
|
+
return;
|
|
15583
|
+
}
|
|
15584
|
+
const startPoint = this.selection.isFocused
|
|
15585
|
+
? new CursorParagraph(this.selection.cursor.row, this.selection.cursor.column + 1)
|
|
15586
|
+
: this.selection.cursor;
|
|
15587
|
+
const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, startPoint);
|
|
15588
|
+
const isNumbering = !!this.session.displayData.paragraphs[startPoint.row].paragraphSettings.numberingData.numberingId;
|
|
15559
15589
|
const noParagraphLeft = insertIndex !== 0 && !this.session.model.paragraphs.find(x => x.insertIndex === insertIndex - 1);
|
|
15560
|
-
const noParagraphRight = !this.session.model.paragraphs.find(x => x.insertIndex ===
|
|
15590
|
+
const noParagraphRight = !this.session.model.paragraphs.find(x => x.insertIndex === insertIndex);
|
|
15561
15591
|
const insertTable = new InsertTableModel({
|
|
15562
15592
|
insertIndex,
|
|
15563
15593
|
rowsCount: tableData.rows,
|
|
@@ -15565,14 +15595,10 @@ class Editor {
|
|
|
15565
15595
|
insertParagraphBefore: isNumbering || noParagraphLeft,
|
|
15566
15596
|
insertParagraphAfter: isNumbering || noParagraphRight
|
|
15567
15597
|
});
|
|
15568
|
-
if (!this.selection.isEmpty) {
|
|
15569
|
-
this.replaceBy(new ReplaceModel({ insertTable }));
|
|
15570
|
-
return;
|
|
15571
|
-
}
|
|
15572
15598
|
this.saveInsertTableToHistory(insertTable);
|
|
15573
|
-
const endPoint = this.session.insertTable(
|
|
15574
|
-
let lastRow =
|
|
15575
|
-
this.renderer.updateLines(
|
|
15599
|
+
const endPoint = this.session.insertTable(startPoint, insertTable);
|
|
15600
|
+
let lastRow = startPoint.row === endPoint.row ? endPoint.row : Infinity;
|
|
15601
|
+
this.renderer.updateLines(startPoint.row, lastRow);
|
|
15576
15602
|
this.renderer.updateCursor();
|
|
15577
15603
|
this.onContentChange();
|
|
15578
15604
|
this.rerenderMarker();
|
|
@@ -16237,17 +16263,28 @@ class Editor {
|
|
|
16237
16263
|
this.commandsService.createCommand(SaveCommandsHelper.getApplyDocumentPageFormatCommand(redo, this.targets));
|
|
16238
16264
|
}
|
|
16239
16265
|
createCustomElement(data) {
|
|
16240
|
-
|
|
16241
|
-
|
|
16242
|
-
|
|
16266
|
+
if (!this.selection.isEmpty && !this.selection.isFocused) {
|
|
16267
|
+
const startIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, this.selection.range.start);
|
|
16268
|
+
const insertElement = new InsertElementModel({ element: new ElementModel({ ...data, insertIndex: startIndex }) });
|
|
16243
16269
|
this.replaceBy(new ReplaceModel({ insertElement }));
|
|
16270
|
+
this.focusCustomElement(startIndex).catch(() => {
|
|
16271
|
+
// continue regardless error
|
|
16272
|
+
});
|
|
16244
16273
|
return;
|
|
16245
16274
|
}
|
|
16275
|
+
const startPoint = this.selection.isFocused
|
|
16276
|
+
? new CursorParagraph(this.selection.cursor.row, this.selection.cursor.column + 1)
|
|
16277
|
+
: this.selection.cursor;
|
|
16278
|
+
const insertIndex = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, startPoint);
|
|
16279
|
+
const insertElement = new InsertElementModel({ element: new ElementModel({ ...data, insertIndex }) });
|
|
16246
16280
|
this.saveInsertElementToHistory(insertElement);
|
|
16247
|
-
const endPoint = this.session.insertElement(
|
|
16248
|
-
this.onDocumentChange(new Range(
|
|
16281
|
+
const endPoint = this.session.insertElement(startPoint, data);
|
|
16282
|
+
this.onDocumentChange(new Range(startPoint, endPoint));
|
|
16249
16283
|
this.onSelectionChange();
|
|
16250
16284
|
this.onContentChange();
|
|
16285
|
+
this.focusCustomElement(insertIndex).catch(() => {
|
|
16286
|
+
// continue regardless error
|
|
16287
|
+
});
|
|
16251
16288
|
}
|
|
16252
16289
|
replaceByCustomElement(textKey, model) {
|
|
16253
16290
|
const index = ContentHelper.paragraphPositionToDocumentIndex(this.session.displayData.paragraphs, this.selection.cursor);
|
|
@@ -16717,16 +16754,10 @@ class Editor {
|
|
|
16717
16754
|
});
|
|
16718
16755
|
this.editorService.lockSidenav(true);
|
|
16719
16756
|
this.insertContent(insertIndex, nextElementContents);
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
const position = this.session.displayData.indexToPosition(component.instance.insertIndex, 0);
|
|
16725
|
-
this.selection.focus(component, position);
|
|
16726
|
-
this.onSelectionChange();
|
|
16727
|
-
this.scrollCursorIntoMainView();
|
|
16728
|
-
}
|
|
16729
|
-
this.editorService.lockSidenav(false);
|
|
16757
|
+
this.focusCustomElement(insertIndex + 1)
|
|
16758
|
+
.then(() => this.editorService.lockSidenav(false))
|
|
16759
|
+
.catch(() => {
|
|
16760
|
+
// continue regardless error
|
|
16730
16761
|
});
|
|
16731
16762
|
}
|
|
16732
16763
|
insertContent(insertIndex, contents) {
|
|
@@ -17495,6 +17526,21 @@ class Editor {
|
|
|
17495
17526
|
this.overlayService.open(CommentPopupComponent, {}, hintX, hintY);
|
|
17496
17527
|
event?.stopPropagation();
|
|
17497
17528
|
}
|
|
17529
|
+
focusCustomElement(insertIndex) {
|
|
17530
|
+
return new Promise(resolve => {
|
|
17531
|
+
setTimeout(() => {
|
|
17532
|
+
// Need to skip micro tasks for a render element before focus
|
|
17533
|
+
const component = this.session.customComponents.customElements.find(x => x.instance.content.insertIndex === insertIndex);
|
|
17534
|
+
if (component) {
|
|
17535
|
+
const position = this.session.displayData.indexToPosition(component.instance.insertIndex, 0);
|
|
17536
|
+
this.selection.focus(component, position);
|
|
17537
|
+
this.onSelectionChange();
|
|
17538
|
+
this.scrollCursorIntoMainView();
|
|
17539
|
+
}
|
|
17540
|
+
resolve();
|
|
17541
|
+
});
|
|
17542
|
+
});
|
|
17543
|
+
}
|
|
17498
17544
|
}
|
|
17499
17545
|
|
|
17500
17546
|
const EDITOR_VERSION = '2';
|