@talrace/ngx-noder 19.0.68 → 19.0.70
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.
- package/fesm2022/talrace-ngx-noder.mjs +138 -186
- package/fesm2022/talrace-ngx-noder.mjs.map +1 -1
- package/lib/editor/components/table/components/table-cell.component.d.ts +1 -1
- package/lib/editor/components/table/components/table.component.d.ts +10 -5
- package/lib/editor/components/table/selection/table-selection.d.ts +2 -2
- package/lib/editor/content/display-data/display-data.d.ts +2 -7
- package/lib/editor/content/display-data/display-token.model.d.ts +0 -1
- package/lib/editor/content/helpers/display-token.helper.d.ts +1 -1
- package/lib/editor/execution/editor.d.ts +0 -1
- package/lib/editor/execution/regulator.service.d.ts +2 -0
- package/lib/editor/gadgets/font-metrics/font-metric-size.interface.d.ts +0 -1
- package/lib/editor/gadgets/font-metrics/font-metric.d.ts +8 -0
- package/lib/editor/gadgets/font-metrics/font-metrics.helper.d.ts +4 -11
- package/lib/editor/interaction/editor.service.d.ts +5 -2
- package/package.json +1 -1
|
@@ -489,6 +489,15 @@ class FormatStyleHelper {
|
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
+
class FontMetric {
|
|
493
|
+
constructor(width, ascent, descent) {
|
|
494
|
+
this.width = width;
|
|
495
|
+
this.ascent = ascent;
|
|
496
|
+
this.descent = descent;
|
|
497
|
+
this.height = ascent + descent;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
492
501
|
class FontMetrics {
|
|
493
502
|
static { this.storageKey = 'metrics'; }
|
|
494
503
|
static { this.versionKey = 'editorVersion'; }
|
|
@@ -515,7 +524,7 @@ class FontMetrics {
|
|
|
515
524
|
this.fontStringMap[contentStyle] = identifier;
|
|
516
525
|
}
|
|
517
526
|
this.metrics[identifier] ??= {};
|
|
518
|
-
if (!this.metrics[identifier][ch]
|
|
527
|
+
if (!this.metrics[identifier][ch]) {
|
|
519
528
|
this.metrics[identifier][ch] = this.calculateCanvas(ch, contentStyle);
|
|
520
529
|
localStorage.setItem(this.storageKey, JSON.stringify(this.metrics));
|
|
521
530
|
}
|
|
@@ -523,53 +532,10 @@ class FontMetrics {
|
|
|
523
532
|
}
|
|
524
533
|
static calculateCanvas(ch, contentStyle) {
|
|
525
534
|
this.canvasNode ||= document.createElement('canvas');
|
|
526
|
-
const fontBaseLine = this.fontBaseline(contentStyle, ch);
|
|
527
535
|
const context = this.canvasNode.getContext('2d');
|
|
528
536
|
context.font = contentStyle;
|
|
529
|
-
const
|
|
530
|
-
return
|
|
531
|
-
width: textMetrics.width,
|
|
532
|
-
height: textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent,
|
|
533
|
-
font: fontBaseLine.font,
|
|
534
|
-
ascent: textMetrics.fontBoundingBoxAscent,
|
|
535
|
-
descent: textMetrics.fontBoundingBoxDescent
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
static fontBaseline(contentStyle, text) {
|
|
539
|
-
const container = document.body;
|
|
540
|
-
this.measureDiv ||= document.createElement('div');
|
|
541
|
-
this.strut ||= document.createElement('span');
|
|
542
|
-
if (text === ' ') {
|
|
543
|
-
text = 'X';
|
|
544
|
-
}
|
|
545
|
-
this.measureDiv.style.font = contentStyle;
|
|
546
|
-
this.measureDiv.style.lineHeight = '1';
|
|
547
|
-
this.measureDiv.style.position = 'absolute';
|
|
548
|
-
this.measureDiv.style.visibility = 'hidden';
|
|
549
|
-
this.measureDiv.style.margin = '0';
|
|
550
|
-
this.measureDiv.style.padding = '0';
|
|
551
|
-
this.measureDiv.innerHTML = text;
|
|
552
|
-
this.strut.style.fontSize = '0';
|
|
553
|
-
this.strut.style.verticalAlign = 'baseline';
|
|
554
|
-
this.strut.style.padding = '0 10px';
|
|
555
|
-
this.measureDiv.classList.add('font-baseline');
|
|
556
|
-
this.measureDiv.appendChild(this.strut);
|
|
557
|
-
container.appendChild(this.measureDiv);
|
|
558
|
-
const computedStyle = window.getComputedStyle(this.measureDiv);
|
|
559
|
-
const fontSize = parseFloat(computedStyle.fontSize);
|
|
560
|
-
const baselineHeight = fontSize - this.strut.offsetTop;
|
|
561
|
-
const strutHeight = this.measureDiv.offsetHeight;
|
|
562
|
-
const lineHeight = parseFloat(computedStyle.lineHeight) || this.measureDiv.offsetHeight;
|
|
563
|
-
this.measureDiv.parentNode.removeChild(this.measureDiv);
|
|
564
|
-
this.measureDiv.innerHTML = '';
|
|
565
|
-
this.strut.innerHTML = '';
|
|
566
|
-
return {
|
|
567
|
-
baseline: baselineHeight,
|
|
568
|
-
content: strutHeight,
|
|
569
|
-
font: fontSize,
|
|
570
|
-
line: lineHeight,
|
|
571
|
-
multiplier: fontSize / baselineHeight
|
|
572
|
-
};
|
|
537
|
+
const metric = context.measureText(ch);
|
|
538
|
+
return new FontMetric(metric.width, metric.fontBoundingBoxAscent, metric.fontBoundingBoxDescent);
|
|
573
539
|
}
|
|
574
540
|
}
|
|
575
541
|
|
|
@@ -1154,8 +1120,8 @@ class EditorService {
|
|
|
1154
1120
|
changeImageStyle(value) {
|
|
1155
1121
|
this._changeImageStyle$.next(value);
|
|
1156
1122
|
}
|
|
1157
|
-
rerender(index
|
|
1158
|
-
this._rerender$.next(index);
|
|
1123
|
+
rerender(index, sessionId) {
|
|
1124
|
+
this._rerender$.next({ index, sessionId });
|
|
1159
1125
|
}
|
|
1160
1126
|
createCustomComponent(model) {
|
|
1161
1127
|
this._createCustomComponent$.next(model);
|
|
@@ -1418,7 +1384,7 @@ class BaseNoderComponent extends DestroyComponent {
|
|
|
1418
1384
|
return [];
|
|
1419
1385
|
}
|
|
1420
1386
|
rerender() {
|
|
1421
|
-
this.editorService.rerender(this.insertIndex);
|
|
1387
|
+
this.editorService.rerender(this.insertIndex, this.sessionId);
|
|
1422
1388
|
}
|
|
1423
1389
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: BaseNoderComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1424
1390
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: BaseNoderComponent, isStandalone: true, inputs: { content: "content", sessionId: "sessionId", contentWidth: "contentWidth", generalProperties: "generalProperties" }, host: { properties: { "class.focused": "this.focused", "attr.data-session-id": "this.sessionId", "attr.data-insert-index": "this.insertIndex" } }, usesInheritance: true, ngImport: i0 }); }
|
|
@@ -7456,15 +7422,14 @@ class DisplayTokenHelper {
|
|
|
7456
7422
|
}
|
|
7457
7423
|
return result;
|
|
7458
7424
|
}
|
|
7459
|
-
return [this.getComponentToken(component,
|
|
7425
|
+
return [this.getComponentToken(component, index)];
|
|
7460
7426
|
}
|
|
7461
|
-
static getComponentToken(component,
|
|
7427
|
+
static getComponentToken(component, index) {
|
|
7462
7428
|
const ascent = component.instance.ascent() ?? 0;
|
|
7463
7429
|
const descent = component.instance.descent() ?? 0;
|
|
7464
7430
|
return new DisplayToken({
|
|
7465
7431
|
width: component.instance.width(),
|
|
7466
7432
|
height: ascent + descent,
|
|
7467
|
-
font: FontMetrics.measureCharSize('0', fontString).font,
|
|
7468
7433
|
ascent,
|
|
7469
7434
|
descent,
|
|
7470
7435
|
displayValue: this.getComponentDisplayValue(component.instance),
|
|
@@ -7472,7 +7437,7 @@ class DisplayTokenHelper {
|
|
|
7472
7437
|
});
|
|
7473
7438
|
}
|
|
7474
7439
|
static getTableTokens(component, fontString, index, withNumbering) {
|
|
7475
|
-
const tableToken = this.getComponentToken(component,
|
|
7440
|
+
const tableToken = this.getComponentToken(component, index);
|
|
7476
7441
|
if (!withNumbering) {
|
|
7477
7442
|
return [tableToken];
|
|
7478
7443
|
}
|
|
@@ -8257,9 +8222,6 @@ class DisplayData extends EventEmitting {
|
|
|
8257
8222
|
getParagraphContent(index) {
|
|
8258
8223
|
return this.paragraphs[index]?.content || '';
|
|
8259
8224
|
}
|
|
8260
|
-
getAllParagraphsContent() {
|
|
8261
|
-
return this.paragraphs.map(x => x.content);
|
|
8262
|
-
}
|
|
8263
8225
|
getParagraphSettings(index) {
|
|
8264
8226
|
return this.paragraphs[index]?.paragraphSettings || null;
|
|
8265
8227
|
}
|
|
@@ -8278,48 +8240,18 @@ class DisplayData extends EventEmitting {
|
|
|
8278
8240
|
getTextRange(range) {
|
|
8279
8241
|
return this.getParagraphsContentForRange(range).join(NEW_LINE_MARKUP);
|
|
8280
8242
|
}
|
|
8281
|
-
positionToIndex(position
|
|
8282
|
-
|
|
8283
|
-
const endRow = Math.min(position.row, this.paragraphs.length);
|
|
8284
|
-
for (let i = startRow || 0; i < endRow; i++) {
|
|
8285
|
-
index += this.paragraphs[i].content.length + 1;
|
|
8286
|
-
}
|
|
8287
|
-
return index + position.column;
|
|
8243
|
+
positionToIndex(position) {
|
|
8244
|
+
return this.paragraphs[position.row].startIndex + position.column;
|
|
8288
8245
|
}
|
|
8289
|
-
indexToPosition(positionIndex
|
|
8290
|
-
const
|
|
8291
|
-
|
|
8292
|
-
positionIndex -= this.paragraphs[lineIndex].content.length + newlineLength;
|
|
8293
|
-
if (positionIndex < 0) {
|
|
8294
|
-
const column = positionIndex + this.paragraphs[lineIndex].content.length + newlineLength;
|
|
8295
|
-
return new CursorParagraph(lineIndex, column);
|
|
8296
|
-
}
|
|
8297
|
-
}
|
|
8298
|
-
const column = positionIndex + this.paragraphs[this.paragraphs.length - 1].content.length + newlineLength;
|
|
8299
|
-
return new CursorParagraph(this.paragraphs.length - 1, column);
|
|
8246
|
+
indexToPosition(positionIndex) {
|
|
8247
|
+
const paragraph = this.paragraphs.findLastIndex(x => x.startIndex <= positionIndex);
|
|
8248
|
+
return new CursorParagraph(paragraph, positionIndex - this.paragraphs[paragraph].startIndex);
|
|
8300
8249
|
}
|
|
8301
8250
|
indexesToRange(startIndex, endIndex) {
|
|
8302
|
-
const startPoint = this.indexToPosition(startIndex
|
|
8303
|
-
const endPoint = this.indexToPosition(endIndex
|
|
8251
|
+
const startPoint = this.indexToPosition(startIndex);
|
|
8252
|
+
const endPoint = this.indexToPosition(endIndex);
|
|
8304
8253
|
return new Range(startPoint, endPoint);
|
|
8305
8254
|
}
|
|
8306
|
-
getSelectedParagraphsByRange(range) {
|
|
8307
|
-
const newlineLength = NEW_LINE_MARKUP.length;
|
|
8308
|
-
let start = 0;
|
|
8309
|
-
let end = 0;
|
|
8310
|
-
let i;
|
|
8311
|
-
const row = Math.min(range.end.row, this.paragraphs.length - 1);
|
|
8312
|
-
for (i = 0; i < row; i++) {
|
|
8313
|
-
if (i < range.start.row) {
|
|
8314
|
-
start += this.paragraphs[i].content.length + newlineLength;
|
|
8315
|
-
}
|
|
8316
|
-
end += this.paragraphs[i].content.length + newlineLength;
|
|
8317
|
-
}
|
|
8318
|
-
if (i < this.paragraphs.length) {
|
|
8319
|
-
end += this.paragraphs[i].content.length;
|
|
8320
|
-
}
|
|
8321
|
-
return { start, end };
|
|
8322
|
-
}
|
|
8323
8255
|
getPositionAfterBreak(position, breakType) {
|
|
8324
8256
|
if (breakType === BreakTypes.TextWrapping) {
|
|
8325
8257
|
return position;
|
|
@@ -9833,7 +9765,7 @@ class EditSession {
|
|
|
9833
9765
|
const imageComponentRef = this.customComponents.images.find(x => x.instance.insertIndex === applyImage.insertIndex);
|
|
9834
9766
|
imageComponentRef.instance.resize({ width: applyImage.width, height: applyImage.height });
|
|
9835
9767
|
OperationsHelper.applyImageStyle(this.model, applyImage);
|
|
9836
|
-
const start = this.displayData.indexToPosition(applyImage.insertIndex
|
|
9768
|
+
const start = this.displayData.indexToPosition(applyImage.insertIndex);
|
|
9837
9769
|
this.displayData.updateNextLineIndexes(start.row, this.displayData.paragraphs.length - 1);
|
|
9838
9770
|
}
|
|
9839
9771
|
restoreTextStyles(formats, linkFormats) {
|
|
@@ -10044,8 +9976,8 @@ class EditSession {
|
|
|
10044
9976
|
}
|
|
10045
9977
|
removeMoveRange(moveModel) {
|
|
10046
9978
|
const endIndex = moveModel.sourceStartIndex + moveModel.sourceCount - 1;
|
|
10047
|
-
const startPosition = this.displayData.indexToPosition(moveModel.sourceStartIndex
|
|
10048
|
-
const endPosition = this.displayData.indexToPosition(endIndex + 1
|
|
9979
|
+
const startPosition = this.displayData.indexToPosition(moveModel.sourceStartIndex);
|
|
9980
|
+
const endPosition = this.displayData.indexToPosition(endIndex + 1);
|
|
10049
9981
|
const sourceRange = new Range(startPosition, endPosition);
|
|
10050
9982
|
this.displayData.removeRange(sourceRange);
|
|
10051
9983
|
CustomComponentHelper.applyRemovingComponents(this.customComponents.tables, moveModel.sourceStartIndex, endIndex);
|
|
@@ -10070,8 +10002,8 @@ class EditSession {
|
|
|
10070
10002
|
this.displayData.updateNextLineIndexes(startPosition.row, endPosition.row);
|
|
10071
10003
|
this.selection.placeCursor(endPosition);
|
|
10072
10004
|
this.applyToolbarStyles();
|
|
10073
|
-
const newStartPosition = this.displayData.indexToPosition(moveIndex
|
|
10074
|
-
const newEndPosition = this.displayData.indexToPosition(moveIndex + moveModel.sourceCount
|
|
10005
|
+
const newStartPosition = this.displayData.indexToPosition(moveIndex);
|
|
10006
|
+
const newEndPosition = this.displayData.indexToPosition(moveIndex + moveModel.sourceCount);
|
|
10075
10007
|
return new Range(newStartPosition, newEndPosition);
|
|
10076
10008
|
}
|
|
10077
10009
|
isPositionInRange(position, range) {
|
|
@@ -12619,7 +12551,7 @@ class RegulatorService {
|
|
|
12619
12551
|
});
|
|
12620
12552
|
}
|
|
12621
12553
|
getSessionModel(sessionId) {
|
|
12622
|
-
return this.sessions.find(x => x.sessionId === sessionId);
|
|
12554
|
+
return this.currentSession.sessionId === sessionId ? this.currentSession : this.sessions.find(x => x.sessionId === sessionId);
|
|
12623
12555
|
}
|
|
12624
12556
|
getSession(sessionId) {
|
|
12625
12557
|
return this.getSessionModel(sessionId).session;
|
|
@@ -12634,6 +12566,22 @@ class RegulatorService {
|
|
|
12634
12566
|
});
|
|
12635
12567
|
this.sessions = [];
|
|
12636
12568
|
}
|
|
12569
|
+
getIndexWithinMainSession() {
|
|
12570
|
+
if (this.currentSession.session.isEdgeOrWithinEdge()) {
|
|
12571
|
+
return 0; // currently there is no mechanism to track pages and get position according valid page for edge
|
|
12572
|
+
}
|
|
12573
|
+
let session = this.currentSession;
|
|
12574
|
+
while (session.parentSessionId) {
|
|
12575
|
+
const parent = this.sessions.find(x => x.sessionId === session.parentSessionId);
|
|
12576
|
+
if (parent.parentSessionId) {
|
|
12577
|
+
session = parent;
|
|
12578
|
+
}
|
|
12579
|
+
else {
|
|
12580
|
+
break;
|
|
12581
|
+
}
|
|
12582
|
+
}
|
|
12583
|
+
return session.source.table.insertIndex;
|
|
12584
|
+
}
|
|
12637
12585
|
getCurrentSessionTargets() {
|
|
12638
12586
|
return this.getTargets(this.currentSession);
|
|
12639
12587
|
}
|
|
@@ -12752,6 +12700,9 @@ class RegulatorService {
|
|
|
12752
12700
|
}
|
|
12753
12701
|
});
|
|
12754
12702
|
}
|
|
12703
|
+
rerender(index, sessionId) {
|
|
12704
|
+
this.getSession(sessionId).rerender(index);
|
|
12705
|
+
}
|
|
12755
12706
|
toggleGrammarChecks(value) {
|
|
12756
12707
|
this.grammarEnabled = value;
|
|
12757
12708
|
if (this.grammarEnabled) {
|
|
@@ -12828,7 +12779,7 @@ class NoderTableCellComponent {
|
|
|
12828
12779
|
return;
|
|
12829
12780
|
}
|
|
12830
12781
|
this._allParagraphsHeight = event.pageHeight;
|
|
12831
|
-
this.heightChanged(this.rowIndex, this.
|
|
12782
|
+
this.heightChanged(this.rowIndex, this.columnIndex, event.pageHeight);
|
|
12832
12783
|
};
|
|
12833
12784
|
}
|
|
12834
12785
|
ngOnDestroy() {
|
|
@@ -13043,16 +12994,16 @@ class TableOverlayMenuComponent {
|
|
|
13043
12994
|
const insertRowsBelowMessage = this.selectedRowsCount > 1
|
|
13044
12995
|
? this.translateService.instant('NODER.COMPLEX_LABEL.INSERT_ROWS_BELOW', { count: this.selectedRowsCount })
|
|
13045
12996
|
: this.translateService.instant('NODER.LABEL.INSERT_ROW_BELOW');
|
|
13046
|
-
const insertColumnsLeftMessage = this.
|
|
12997
|
+
const insertColumnsLeftMessage = this.selectedColumnsCount > 1
|
|
13047
12998
|
? this.translateService.instant('NODER.COMPLEX_LABEL.INSERT_COLUMNS_TO_THE_LEFT', { count: this.selectedColumnsCount })
|
|
13048
12999
|
: this.translateService.instant('NODER.LABEL.INSERT_COLUMN_TO_THE_LEFT');
|
|
13049
|
-
const insertColumnsRightMessage = this.
|
|
13000
|
+
const insertColumnsRightMessage = this.selectedColumnsCount > 1
|
|
13050
13001
|
? this.translateService.instant('NODER.COMPLEX_LABEL.INSERT_COLUMNS_TO_THE_RIGHT', { count: this.selectedColumnsCount })
|
|
13051
13002
|
: this.translateService.instant('NODER.LABEL.INSERT_COLUMN_TO_THE_RIGHT');
|
|
13052
13003
|
const removeRowsMessage = this.selectedRowsCount > 1
|
|
13053
13004
|
? this.translateService.instant('NODER.COMPLEX_LABEL.REMOVE_ROWS', { count: this.selectedRowsCount })
|
|
13054
13005
|
: this.translateService.instant('NODER.LABEL.REMOVE_ROW');
|
|
13055
|
-
const removeColumnsMessage = this.
|
|
13006
|
+
const removeColumnsMessage = this.selectedColumnsCount > 1
|
|
13056
13007
|
? this.translateService.instant('NODER.COMPLEX_LABEL.REMOVE_COLUMNS', { count: this.selectedColumnsCount })
|
|
13057
13008
|
: this.translateService.instant('NODER.LABEL.REMOVE_COLUMN');
|
|
13058
13009
|
const removeTableMessage = this.translateService.instant('NODER.LABEL.REMOVE_TABLE');
|
|
@@ -13222,7 +13173,8 @@ class TableSelection {
|
|
|
13222
13173
|
return;
|
|
13223
13174
|
}
|
|
13224
13175
|
const position = this.regulatorService.currentSession.renderer.screenToParagraph(event.clientX, event.clientY);
|
|
13225
|
-
if (!this.session.selection.isEmpty &&
|
|
13176
|
+
if (!this.session.selection.isEmpty &&
|
|
13177
|
+
this.regulatorService.currentSession.session.isPositionInRange(position, this.session.selection.selectedRange)) {
|
|
13226
13178
|
return;
|
|
13227
13179
|
}
|
|
13228
13180
|
this.overlayService.close();
|
|
@@ -13476,15 +13428,17 @@ class TableSelection {
|
|
|
13476
13428
|
}
|
|
13477
13429
|
getTargetsForMenuOverlay(selectionRange) {
|
|
13478
13430
|
return new SelectionRangeModel({
|
|
13479
|
-
startIndex: this.getTargetRowStartIndex(selectionRange.rowIndexes.startIndex),
|
|
13480
|
-
endIndex: this.getTargetRowEndIndex(selectionRange.rowIndexes.endIndex)
|
|
13431
|
+
startIndex: this.getTargetRowStartIndex(selectionRange.rowIndexes.startIndex, selectionRange.cellIndexes.startIndex, selectionRange.cellIndexes.endIndex),
|
|
13432
|
+
endIndex: this.getTargetRowEndIndex(selectionRange.rowIndexes.endIndex, selectionRange.cellIndexes.startIndex, selectionRange.cellIndexes.endIndex)
|
|
13481
13433
|
}, {
|
|
13482
13434
|
startIndex: this.getTargetColumnStartIndex(selectionRange.rowIndexes.startIndex, selectionRange.rowIndexes.endIndex, selectionRange.cellIndexes.startIndex),
|
|
13483
13435
|
endIndex: this.getTargetColumnEndIndex(selectionRange.rowIndexes.startIndex, selectionRange.rowIndexes.endIndex, selectionRange.cellIndexes.endIndex)
|
|
13484
13436
|
});
|
|
13485
13437
|
}
|
|
13486
|
-
getTargetRowStartIndex(startIndex) {
|
|
13487
|
-
const mergedRowCells = this.rowMatrix[startIndex].cells
|
|
13438
|
+
getTargetRowStartIndex(startIndex, cellStartIndex, cellEndIndex) {
|
|
13439
|
+
const mergedRowCells = this.rowMatrix[startIndex].cells
|
|
13440
|
+
.slice(cellStartIndex, cellEndIndex + 1)
|
|
13441
|
+
.filter(x => x.cell.rowSpan > 1 && x.componentRef.instance.cell.verticalMerge);
|
|
13488
13442
|
if (!mergedRowCells.length) {
|
|
13489
13443
|
return startIndex;
|
|
13490
13444
|
}
|
|
@@ -13499,8 +13453,10 @@ class TableSelection {
|
|
|
13499
13453
|
}
|
|
13500
13454
|
return index + 1;
|
|
13501
13455
|
}
|
|
13502
|
-
getTargetRowEndIndex(endIndex) {
|
|
13503
|
-
const mergedRowCells = this.rowMatrix[endIndex].cells
|
|
13456
|
+
getTargetRowEndIndex(endIndex, cellStartIndex, cellEndIndex) {
|
|
13457
|
+
const mergedRowCells = this.rowMatrix[endIndex].cells
|
|
13458
|
+
.slice(cellStartIndex, cellEndIndex + 1)
|
|
13459
|
+
.filter(x => x.cell.rowSpan > 1 && x.componentRef.instance.cell.verticalMerge);
|
|
13504
13460
|
if (!mergedRowCells.length) {
|
|
13505
13461
|
return endIndex + 1;
|
|
13506
13462
|
}
|
|
@@ -13568,36 +13524,32 @@ class NoderTableComponent extends BaseNoderComponent {
|
|
|
13568
13524
|
this.regulatorService = regulatorService;
|
|
13569
13525
|
this.rowMatrix = [];
|
|
13570
13526
|
this.splits = [];
|
|
13571
|
-
this.minRowHeight =
|
|
13527
|
+
this.minRowHeight = 18;
|
|
13572
13528
|
this.borderSize = 1;
|
|
13573
13529
|
this.RESIZE_MIN_OFFSET = 5;
|
|
13574
13530
|
this.startResizing = (cellResizerParameters) => {
|
|
13575
|
-
const splitRowIndex = this.getSplitRowIndex(cellResizerParameters.rowIndex);
|
|
13576
13531
|
const availableTableSpace = this.getAvailableTableSpace();
|
|
13577
|
-
this.resizer.resizerHeight = this.getRowsHeightBetweenSplits(
|
|
13578
|
-
this.resizer.startY = this.getRowsHeightBefore(
|
|
13579
|
-
this.resizer.splitRowIndex =
|
|
13532
|
+
this.resizer.resizerHeight = this.getRowsHeightBetweenSplits(cellResizerParameters.rowIndex);
|
|
13533
|
+
this.resizer.startY = this.getRowsHeightBefore(cellResizerParameters.rowIndex);
|
|
13534
|
+
this.resizer.splitRowIndex = cellResizerParameters.rowIndex;
|
|
13580
13535
|
this.resizer.tableInsertIndex = this.insertIndex;
|
|
13581
13536
|
this.resizer.onStartResizing(cellResizerParameters, availableTableSpace);
|
|
13582
13537
|
};
|
|
13583
|
-
this.cellHeightChanged = (rowIndex,
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
(maxCellContentHeigh < currentHeight && (!tableRow.height || tableRow.height <= maxCellContentHeigh))) {
|
|
13596
|
-
row.style.height = `${maxCellContentHeigh}px`;
|
|
13597
|
-
this.rowMatrix[rowIndex].height = maxCellContentHeigh;
|
|
13598
|
-
this.setTableHeight();
|
|
13599
|
-
this.editorService.changedTableSize(this.insertIndex, this.sessionId);
|
|
13538
|
+
this.cellHeightChanged = (rowIndex, columnIndex, height) => {
|
|
13539
|
+
height = height < this.minRowHeight ? this.minRowHeight : height;
|
|
13540
|
+
let index = rowIndex;
|
|
13541
|
+
do {
|
|
13542
|
+
for (let i = columnIndex; this.rowMatrix[index].cells[columnIndex].cell === this.rowMatrix[index].cells[i]?.cell; i++) {
|
|
13543
|
+
this.rowMatrix[index].cells[i].cellContentHeight = height;
|
|
13544
|
+
}
|
|
13545
|
+
index++;
|
|
13546
|
+
} while (this.rowMatrix[index - 1].cells[columnIndex].cell === this.rowMatrix[index]?.cells[columnIndex].cell);
|
|
13547
|
+
let isAdjustable = true;
|
|
13548
|
+
for (let i = rowIndex; isAdjustable && i < this.table.rows.length; i++) {
|
|
13549
|
+
isAdjustable = this.fillTableRow(i);
|
|
13600
13550
|
}
|
|
13551
|
+
this.setTableHeight();
|
|
13552
|
+
this.editorService.changedTableSize(this.insertIndex, this.sessionId);
|
|
13601
13553
|
};
|
|
13602
13554
|
}
|
|
13603
13555
|
ngOnDestroy() {
|
|
@@ -13667,7 +13619,9 @@ class NoderTableComponent extends BaseNoderComponent {
|
|
|
13667
13619
|
this.insertCells(targetRowIndex, this.table.rows[targetRowIndex].cells.length, 0);
|
|
13668
13620
|
rowIndex++;
|
|
13669
13621
|
}
|
|
13670
|
-
this.
|
|
13622
|
+
for (let i = 0; i < this.table.rows.length; i++) {
|
|
13623
|
+
this.fillTableRow(i);
|
|
13624
|
+
}
|
|
13671
13625
|
}
|
|
13672
13626
|
insertCells(rowIndex, cellsCount, targetIndex) {
|
|
13673
13627
|
let modelTargetIndex = this.getModelTargetIndex(rowIndex, targetIndex);
|
|
@@ -13750,49 +13704,56 @@ class NoderTableComponent extends BaseNoderComponent {
|
|
|
13750
13704
|
}
|
|
13751
13705
|
this.tableEl.insertAdjacentElement('afterbegin', colgroup);
|
|
13752
13706
|
}
|
|
13753
|
-
fillTableRow() {
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
break;
|
|
13774
|
-
}
|
|
13707
|
+
fillTableRow(rowIndex) {
|
|
13708
|
+
switch (this.table.rows[rowIndex].hRule) {
|
|
13709
|
+
case HRule.AtLeast: {
|
|
13710
|
+
const { rowHeight, hasMerges } = this.getRowHeight(rowIndex);
|
|
13711
|
+
this.tableEl.rows[rowIndex].style.minHeight = `${this.table.rows[rowIndex].height}px`;
|
|
13712
|
+
this.tableEl.rows[rowIndex].style.height = `${rowHeight}px`;
|
|
13713
|
+
this.rowMatrix[rowIndex].height = rowHeight;
|
|
13714
|
+
return hasMerges;
|
|
13715
|
+
}
|
|
13716
|
+
case HRule.Exact:
|
|
13717
|
+
this.tableEl.rows[rowIndex].style.height = `${this.table.rows[rowIndex].height}px`;
|
|
13718
|
+
this.rowMatrix[rowIndex].height = this.table.rows[rowIndex].height;
|
|
13719
|
+
return false;
|
|
13720
|
+
default: {
|
|
13721
|
+
const { rowHeight, hasMerges } = this.getRowHeight(rowIndex);
|
|
13722
|
+
const minRowHeight = this.table.rows[rowIndex].height ?? this.minRowHeight;
|
|
13723
|
+
const resultHeight = minRowHeight > rowHeight ? minRowHeight : rowHeight;
|
|
13724
|
+
this.tableEl.rows[rowIndex].style.height = `${resultHeight}px`;
|
|
13725
|
+
this.rowMatrix[rowIndex].height = resultHeight;
|
|
13726
|
+
return hasMerges;
|
|
13775
13727
|
}
|
|
13776
13728
|
}
|
|
13777
13729
|
}
|
|
13778
13730
|
getRowHeight(rowIndex) {
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
currentHeight -= this.rowMatrix[i].height;
|
|
13787
|
-
i--;
|
|
13788
|
-
}
|
|
13789
|
-
return currentHeight;
|
|
13790
|
-
}
|
|
13791
|
-
return 0;
|
|
13731
|
+
let rowHeight = 0;
|
|
13732
|
+
let hasMerges = false;
|
|
13733
|
+
this.rowMatrix[rowIndex].cells.forEach((x, index) => {
|
|
13734
|
+
const { height, isMerged } = this.getCellHeight(rowIndex, index, x);
|
|
13735
|
+
hasMerges = hasMerges || isMerged;
|
|
13736
|
+
if (rowHeight < height) {
|
|
13737
|
+
rowHeight = height;
|
|
13792
13738
|
}
|
|
13793
|
-
return x.cellContentHeight;
|
|
13794
13739
|
});
|
|
13795
|
-
return
|
|
13740
|
+
return { rowHeight, hasMerges };
|
|
13741
|
+
}
|
|
13742
|
+
getCellHeight(rowIndex, cellIndex, cell) {
|
|
13743
|
+
if (cell.componentRef.instance.cell.verticalMerge === VerticalMerge.Restart) {
|
|
13744
|
+
const isLastVerticalMergedCell = cell.cell !== this.rowMatrix[rowIndex + 1]?.cells[cellIndex].cell;
|
|
13745
|
+
if (isLastVerticalMergedCell) {
|
|
13746
|
+
let i = rowIndex - 1;
|
|
13747
|
+
let currentHeight = cell.cellContentHeight;
|
|
13748
|
+
while (cell.cell === this.rowMatrix[i]?.cells[cellIndex].cell) {
|
|
13749
|
+
currentHeight -= this.rowMatrix[i].height;
|
|
13750
|
+
i--;
|
|
13751
|
+
}
|
|
13752
|
+
return { height: currentHeight, isMerged: false };
|
|
13753
|
+
}
|
|
13754
|
+
return { height: 0, isMerged: true };
|
|
13755
|
+
}
|
|
13756
|
+
return { height: cell.cellContentHeight, isMerged: false };
|
|
13796
13757
|
}
|
|
13797
13758
|
fillTableCells() {
|
|
13798
13759
|
for (let i = 0; i < this.rowMatrix.length; i++) {
|
|
@@ -13901,12 +13862,6 @@ class NoderTableComponent extends BaseNoderComponent {
|
|
|
13901
13862
|
getTableWidth() {
|
|
13902
13863
|
return this.table.columns.reduce((prev, next) => prev + next.width + this.borderSize, 1);
|
|
13903
13864
|
}
|
|
13904
|
-
getSplitRowIndex(rowIndex) {
|
|
13905
|
-
return this.getIndexIncludingSplitRows(this.rowMatrix[rowIndex].row);
|
|
13906
|
-
}
|
|
13907
|
-
getIndexIncludingSplitRows(row) {
|
|
13908
|
-
return Array.from(this.tableEl.rows).indexOf(row);
|
|
13909
|
-
}
|
|
13910
13865
|
getRowsHeightBefore(rowIndex) {
|
|
13911
13866
|
let index = 0;
|
|
13912
13867
|
for (const element of this.splits) {
|
|
@@ -15629,7 +15584,6 @@ class Editor {
|
|
|
15629
15584
|
this.subscriptions = [];
|
|
15630
15585
|
this.commentCreateRequests = [];
|
|
15631
15586
|
this.emojiRegex = /\p{Extended_Pictographic}(?:\p{Emoji_Modifier}|\u{200D}\p{Extended_Pictographic})*/gu;
|
|
15632
|
-
this.isRerenderSubscriptionOpen = true;
|
|
15633
15587
|
this.rerenderResize = () => {
|
|
15634
15588
|
this.mainRenderer.onResize(true);
|
|
15635
15589
|
};
|
|
@@ -17075,7 +17029,7 @@ class Editor {
|
|
|
17075
17029
|
});
|
|
17076
17030
|
this.insertContent(insertIndex, nextElementContents);
|
|
17077
17031
|
const component = this.session.customComponents.customElements.find(x => x.instance.content.insertIndex === insertIndex + 1);
|
|
17078
|
-
const position = this.session.displayData.indexToPosition(component.instance.insertIndex
|
|
17032
|
+
const position = this.session.displayData.indexToPosition(component.instance.insertIndex);
|
|
17079
17033
|
this.selection.focus(component, position);
|
|
17080
17034
|
this.onSelectionChange();
|
|
17081
17035
|
}
|
|
@@ -17199,11 +17153,13 @@ class Editor {
|
|
|
17199
17153
|
}
|
|
17200
17154
|
this.regulatorService.updateCursorPosition();
|
|
17201
17155
|
this.editorService.setHasSelection(!this.selection.isEmpty);
|
|
17202
|
-
const position = this.mainSession.displayData.positionToIndex(this.selection.selectedRange.start);
|
|
17203
|
-
const pageFormat = this.mainSession.displayData.getPageFormatAtPosition(position);
|
|
17204
17156
|
const paragraphStyle = this.session.model.paragraphs[this.selection.selectedRange.start.row].paragraphStyle;
|
|
17205
17157
|
const numbering = this.session.generalProperties.numberings.find(x => x.numberingId === paragraphStyle.numberingId) ?? null;
|
|
17206
17158
|
this.editorService.paragraphStyle(paragraphStyle, numbering);
|
|
17159
|
+
const position = this.session === this.mainSession
|
|
17160
|
+
? this.mainSession.displayData.positionToIndex(this.selection.selectedRange.start)
|
|
17161
|
+
: this.regulatorService.getIndexWithinMainSession();
|
|
17162
|
+
const pageFormat = this.mainSession.displayData.getPageFormatAtPosition(position);
|
|
17207
17163
|
this.editorService.setPageFormat(pageFormat.pageFormatModel);
|
|
17208
17164
|
this.rerenderMarker();
|
|
17209
17165
|
this.regulatorService.setSelectedCommentAtCursor();
|
|
@@ -17250,7 +17206,7 @@ class Editor {
|
|
|
17250
17206
|
if (!component) {
|
|
17251
17207
|
return;
|
|
17252
17208
|
}
|
|
17253
|
-
const position = this.session.displayData.indexToPosition(index
|
|
17209
|
+
const position = this.session.displayData.indexToPosition(index);
|
|
17254
17210
|
this.selection.focus(component, position);
|
|
17255
17211
|
this.renderer.hideCursor();
|
|
17256
17212
|
this.onSelectionChange();
|
|
@@ -17532,9 +17488,7 @@ class Editor {
|
|
|
17532
17488
|
return this.editorService.setImageStyle$.subscribe(image => this.applyImageStyles(image));
|
|
17533
17489
|
}
|
|
17534
17490
|
rerenderSubscription() {
|
|
17535
|
-
return this.editorService.rerender$.
|
|
17536
|
-
this.session.rerender(index);
|
|
17537
|
-
});
|
|
17491
|
+
return this.editorService.rerender$.subscribe(x => this.regulatorService.rerender(x.index, x.sessionId));
|
|
17538
17492
|
}
|
|
17539
17493
|
createCustomComponentSubscription() {
|
|
17540
17494
|
return this.editorService.createCustomComponent$.subscribe(model => {
|
|
@@ -17834,9 +17788,7 @@ class Editor {
|
|
|
17834
17788
|
this.changeCellsWidth(table.rows, scalingRatio);
|
|
17835
17789
|
});
|
|
17836
17790
|
this.selection.navigateFileStart();
|
|
17837
|
-
this.isRerenderSubscriptionOpen = false;
|
|
17838
17791
|
this.regulatorService.addMainSession(this.model, scalingRatio, this.container);
|
|
17839
|
-
this.isRerenderSubscriptionOpen = true;
|
|
17840
17792
|
this.textInput = new TextInput(this.mainRenderer.container);
|
|
17841
17793
|
this.mainRenderer.textarea = this.textInput.input;
|
|
17842
17794
|
this.touchHandler.destroy();
|