@talrace/ngx-noder 0.0.11 → 0.0.12
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/esm2022/lib/apart-components/editor-toolbar/components/buttons/font/font.component.mjs +2 -2
- package/esm2022/lib/editor/execution/edit.session.mjs +3 -3
- package/esm2022/lib/editor/execution/editor.mjs +12 -12
- package/esm2022/lib/editor/gadgets/history/operation-history.mjs +17 -18
- package/esm2022/lib/editor/operations/helpers/content-operations.helper.mjs +4 -4
- package/esm2022/lib/editor/operations/operations-helper.helper.mjs +7 -6
- package/esm2022/lib/editor/operations/save-commands.helper.mjs +4 -4
- package/esm2022/lib/models/generated/delete.model.mjs +1 -1
- package/esm2022/lib/models/generated/link-data.model.mjs +1 -1
- package/esm2022/lib/models/generated/link.model.mjs +1 -1
- package/fesm2022/talrace-ngx-noder.mjs +41 -42
- package/fesm2022/talrace-ngx-noder.mjs.map +1 -1
- package/lib/editor/execution/editor.d.ts +1 -1
- package/lib/editor/gadgets/history/operation-history.d.ts +2 -2
- package/lib/editor/operations/helpers/content-operations.helper.d.ts +1 -1
- package/lib/editor/operations/operations-helper.helper.d.ts +1 -1
- package/lib/editor/operations/save-commands.helper.d.ts +1 -1
- package/lib/models/generated/delete.model.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1629,10 +1629,10 @@ class OperationHistory {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
pushInsertText(insertIndex, text) {
|
|
1631
1631
|
const redoStep = new InsertTextModel({ insertIndex, text });
|
|
1632
|
-
const undoStep = new DeleteModel({ startIndex: insertIndex,
|
|
1632
|
+
const undoStep = new DeleteModel({ startIndex: insertIndex, count: text.length });
|
|
1633
1633
|
this.addToHistory(undoStep, redoStep);
|
|
1634
1634
|
}
|
|
1635
|
-
pushInsertParagraph(model, paragraphs) {
|
|
1635
|
+
pushInsertParagraph(content, model, paragraphs) {
|
|
1636
1636
|
const currentParagraph = paragraphs
|
|
1637
1637
|
.slice()
|
|
1638
1638
|
.sort((a, b) => a.insertIndex - b.insertIndex)
|
|
@@ -1642,52 +1642,50 @@ class OperationHistory {
|
|
|
1642
1642
|
.sort((a, b) => b.insertIndex - a.insertIndex)
|
|
1643
1643
|
.find(x => x.insertIndex < currentParagraph.insertIndex);
|
|
1644
1644
|
let startIndex = model.insertIndex;
|
|
1645
|
-
let
|
|
1645
|
+
let count = content.length;
|
|
1646
1646
|
if (model.insertIndex === 0 || previousParagraph?.insertIndex === model.insertIndex - 1) {
|
|
1647
|
-
|
|
1647
|
+
count++;
|
|
1648
1648
|
}
|
|
1649
1649
|
else if (currentParagraph.insertIndex === model.insertIndex) {
|
|
1650
1650
|
startIndex++;
|
|
1651
|
-
endIndex++;
|
|
1652
1651
|
}
|
|
1653
1652
|
else {
|
|
1654
|
-
|
|
1653
|
+
count = count + 2;
|
|
1655
1654
|
}
|
|
1656
|
-
|
|
1657
|
-
const undoStep = new DeleteModel({ startIndex, endIndex });
|
|
1655
|
+
const undoStep = new DeleteModel({ startIndex, count });
|
|
1658
1656
|
this.addToHistory(undoStep, model);
|
|
1659
1657
|
}
|
|
1660
1658
|
pushInsertElement(model) {
|
|
1661
|
-
const undoStep = new DeleteModel({ startIndex: model.element.insertIndex,
|
|
1659
|
+
const undoStep = new DeleteModel({ startIndex: model.element.insertIndex, count: CUSTOM_ELEMENT_MARKER.length });
|
|
1662
1660
|
this.addToHistory(undoStep, model);
|
|
1663
1661
|
}
|
|
1664
|
-
pushInsertBreak(model,
|
|
1665
|
-
const undoStep = new DeleteModel({ startIndex: model.insertIndex,
|
|
1662
|
+
pushInsertBreak(model, count) {
|
|
1663
|
+
const undoStep = new DeleteModel({ startIndex: model.insertIndex, count });
|
|
1666
1664
|
this.addToHistory(undoStep, model);
|
|
1667
1665
|
}
|
|
1668
1666
|
pushInsertTab(model) {
|
|
1669
|
-
const undoStep = new DeleteModel({ startIndex: model.insertIndex,
|
|
1667
|
+
const undoStep = new DeleteModel({ startIndex: model.insertIndex, count: CUSTOM_ELEMENT_MARKER.length });
|
|
1670
1668
|
this.addToHistory(undoStep, model);
|
|
1671
1669
|
}
|
|
1672
1670
|
pushInsertImage(model) {
|
|
1673
|
-
const undoStep = new DeleteModel({ startIndex: model.insertIndex,
|
|
1671
|
+
const undoStep = new DeleteModel({ startIndex: model.insertIndex, count: CUSTOM_ELEMENT_MARKER.length });
|
|
1674
1672
|
this.addToHistory(undoStep, model);
|
|
1675
1673
|
}
|
|
1676
1674
|
pushInsertLink(model) {
|
|
1677
|
-
const undoStep = new DeleteModel({ startIndex: model.insertIndex,
|
|
1675
|
+
const undoStep = new DeleteModel({ startIndex: model.insertIndex, count: model.linkDataModel.text.length });
|
|
1678
1676
|
this.addToHistory(undoStep, model);
|
|
1679
1677
|
}
|
|
1680
1678
|
pushInsertTable(model) {
|
|
1681
|
-
const undoStep = new DeleteModel({ startIndex: model.insertIndex,
|
|
1679
|
+
const undoStep = new DeleteModel({ startIndex: model.insertIndex, count: model.content.length });
|
|
1682
1680
|
this.addToHistory(undoStep, model);
|
|
1683
1681
|
}
|
|
1684
1682
|
pushInsertStyledText(insertIndex, text, style) {
|
|
1685
1683
|
const redoStep = new InsertStyledTextModel({ insertIndex, text, textStyle: style });
|
|
1686
|
-
const undoStep = new DeleteModel({ startIndex: insertIndex,
|
|
1684
|
+
const undoStep = new DeleteModel({ startIndex: insertIndex, count: text.length });
|
|
1687
1685
|
this.addToHistory(undoStep, redoStep);
|
|
1688
1686
|
}
|
|
1689
1687
|
pushDelete(model) {
|
|
1690
|
-
const redoStep = new DeleteModel({ startIndex: model.startIndex,
|
|
1688
|
+
const redoStep = new DeleteModel({ startIndex: model.startIndex, count: model.text.length });
|
|
1691
1689
|
this.addToHistory(model, redoStep);
|
|
1692
1690
|
}
|
|
1693
1691
|
pushApplyTextStyle(startIndex, endIndex, style, formats) {
|
|
@@ -3236,7 +3234,7 @@ class SaveCommandsHelper {
|
|
|
3236
3234
|
return new CommandModel({ commandType: CommandType.RemoveNumberings, removeNumberings, targets });
|
|
3237
3235
|
}
|
|
3238
3236
|
static getRestoreNumberingsCommand(restoreNumberings, targets) {
|
|
3239
|
-
return new CommandModel({ commandType: CommandType.
|
|
3237
|
+
return new CommandModel({ commandType: CommandType.RestoreNumberings, restoreNumberings, targets });
|
|
3240
3238
|
}
|
|
3241
3239
|
static getApplyImageStyleCommand(height, width, insertIndex, targets) {
|
|
3242
3240
|
const applyImageStyle = new ApplyImageStyleModel({ height, width, insertIndex });
|
|
@@ -3250,8 +3248,8 @@ class SaveCommandsHelper {
|
|
|
3250
3248
|
const applyTextStyle = new ApplyTextStyleModel({ startIndex, endIndex, textStyle });
|
|
3251
3249
|
return new CommandModel({ commandType: CommandType.ApplyTextStyle, applyTextStyle, targets });
|
|
3252
3250
|
}
|
|
3253
|
-
static getDeleteCommand(startIndex,
|
|
3254
|
-
const deleteModel = new DeleteModel({ startIndex,
|
|
3251
|
+
static getDeleteCommand(startIndex, count, targets) {
|
|
3252
|
+
const deleteModel = new DeleteModel({ startIndex, count });
|
|
3255
3253
|
return new CommandModel({ commandType: CommandType.Delete, delete: deleteModel, targets });
|
|
3256
3254
|
}
|
|
3257
3255
|
static getInsertTextCommand(text, insertIndex, targets) {
|
|
@@ -4161,7 +4159,7 @@ class Editor {
|
|
|
4161
4159
|
this.replaceBy(new ReplaceModel({ insertParagraph }));
|
|
4162
4160
|
return;
|
|
4163
4161
|
}
|
|
4164
|
-
this.saveInsertParagraphToHistory(insertParagraph);
|
|
4162
|
+
this.saveInsertParagraphToHistory(insertTable.content, insertParagraph);
|
|
4165
4163
|
const endPoint = this.session.insertParagraph(this.selection.cursor, insertParagraph);
|
|
4166
4164
|
let lastRow = this.selection.cursor.row === endPoint.row ? endPoint.row : Infinity;
|
|
4167
4165
|
this.renderer.updateLines(this.selection.cursor.row, lastRow);
|
|
@@ -4182,7 +4180,7 @@ class Editor {
|
|
|
4182
4180
|
}
|
|
4183
4181
|
replaceBy(model) {
|
|
4184
4182
|
const partIndexes = ContentHelper.getSelectedPartDocumentIndexes(this.session.displayData.paragraphs, this.selection.range);
|
|
4185
|
-
model.delete = new DeleteModel({ startIndex: partIndexes.startIndex,
|
|
4183
|
+
model.delete = new DeleteModel({ startIndex: partIndexes.startIndex, count: partIndexes.endIndex - partIndexes.startIndex + 1 });
|
|
4186
4184
|
this.saveReplaceToHistory(this.selection.range, model);
|
|
4187
4185
|
this.removeCustomElementsData();
|
|
4188
4186
|
const endPosition = this.session.replace(model);
|
|
@@ -4383,8 +4381,8 @@ class Editor {
|
|
|
4383
4381
|
command = SaveCommandsHelper.getInsertParagraphCommand(operation, this.targets);
|
|
4384
4382
|
}
|
|
4385
4383
|
else if (operation instanceof DeleteModel) {
|
|
4386
|
-
this.session.removeByDocumentIndexes(operation.startIndex, operation.
|
|
4387
|
-
command = SaveCommandsHelper.getDeleteCommand(operation.startIndex, operation.
|
|
4384
|
+
this.session.removeByDocumentIndexes(operation.startIndex, operation.startIndex + operation.count);
|
|
4385
|
+
command = SaveCommandsHelper.getDeleteCommand(operation.startIndex, operation.count, this.targets);
|
|
4388
4386
|
}
|
|
4389
4387
|
else if (operation instanceof InsertStyledTextModel) {
|
|
4390
4388
|
this.session.insertTextByDocumentIndex(operation.insertIndex, operation.text, new TextStyleModel(operation.textStyle));
|
|
@@ -4506,18 +4504,18 @@ class Editor {
|
|
|
4506
4504
|
}
|
|
4507
4505
|
saveRemoveToHistory(range) {
|
|
4508
4506
|
const restoreModel = this.createRestoreFromSlice(range.start.row, range.start.column, range.end.row, range.end.column);
|
|
4509
|
-
const
|
|
4507
|
+
const count = restoreModel.endIndex - restoreModel.startIndex + 1;
|
|
4510
4508
|
restoreModel.endIndex = restoreModel.startIndex; // this is to restore in position without deleting/replacing anything in range
|
|
4511
4509
|
this.history.pushDelete(restoreModel);
|
|
4512
|
-
this.commandsService.createCommand(SaveCommandsHelper.getDeleteCommand(restoreModel.startIndex,
|
|
4510
|
+
this.commandsService.createCommand(SaveCommandsHelper.getDeleteCommand(restoreModel.startIndex, count, this.targets));
|
|
4513
4511
|
}
|
|
4514
4512
|
saveInsertTextToHistory(paragraph, indexInParagraph, text) {
|
|
4515
4513
|
const index = ContentHelper.paragraphToDocumentIndex(this.session.displayData.paragraphs, paragraph, indexInParagraph);
|
|
4516
4514
|
this.history.pushInsertText(index, text);
|
|
4517
4515
|
this.commandsService.createCommand(SaveCommandsHelper.getInsertTextCommand(text, index, this.targets));
|
|
4518
4516
|
}
|
|
4519
|
-
saveInsertParagraphToHistory(model) {
|
|
4520
|
-
this.history.pushInsertParagraph(model, this.session.model.paragraphs);
|
|
4517
|
+
saveInsertParagraphToHistory(content, model) {
|
|
4518
|
+
this.history.pushInsertParagraph(content, model, this.session.model.paragraphs);
|
|
4521
4519
|
this.commandsService.createCommand(SaveCommandsHelper.getInsertParagraphCommand(model, this.targets));
|
|
4522
4520
|
}
|
|
4523
4521
|
saveInsertStyledTextToHistory(paragraph, indexInParagraph, text, style) {
|
|
@@ -4533,8 +4531,8 @@ class Editor {
|
|
|
4533
4531
|
model.isOnNewParagraph =
|
|
4534
4532
|
model.breakType === BreakTypes.Page &&
|
|
4535
4533
|
BreakHelper.getBreakType(this.session.model, CUSTOM_ELEMENT_MARKER, model.insertIndex - 1) !== BreakTypes.Page;
|
|
4536
|
-
const
|
|
4537
|
-
this.history.pushInsertBreak(model,
|
|
4534
|
+
const count = model.isOnNewParagraph ? NEW_LINE_MARKUP.length + 1 : 1;
|
|
4535
|
+
this.history.pushInsertBreak(model, count);
|
|
4538
4536
|
this.commandsService.createCommand(SaveCommandsHelper.getInsertBreakCommand(model, this.targets));
|
|
4539
4537
|
}
|
|
4540
4538
|
saveInsertTabToHistory(model) {
|
|
@@ -4604,7 +4602,7 @@ class Editor {
|
|
|
4604
4602
|
const paragraphs = IndexedElementHelper.sliceSection(this.session.model.paragraphs, startIndex, endIndex).map(x => new ParagraphModel(x));
|
|
4605
4603
|
const images = IndexedElementHelper.sliceSection(this.session.model.images, startIndex, endIndex).map(x => new ImageModel(x));
|
|
4606
4604
|
const tables = IndexedElementHelper.sliceSection(this.session.model.tables, startIndex, endIndex).map(x => new TableModel(x));
|
|
4607
|
-
const elements = IndexedElementHelper.sliceSection(this.session.model.elements, startIndex, endIndex).map(x => new ElementModel({ ...x, guid: '' }));
|
|
4605
|
+
const elements = IndexedElementHelper.sliceSection(this.session.model.elements, startIndex, endIndex).map(x => new ElementModel({ ...x, id: 0, guid: '' }));
|
|
4608
4606
|
const breaks = IndexedElementHelper.sliceSection(this.session.model.breaks, startIndex, endIndex).map(x => new BreakModel(x));
|
|
4609
4607
|
const tabs = IndexedElementHelper.sliceSection(this.session.model.tabs, startIndex, endIndex).map(x => new TabModel(x));
|
|
4610
4608
|
const links = LinkHelper.sliceSection(this.session.model.links, startIndex, endIndex).map(x => new LinkModel(x));
|
|
@@ -8614,8 +8612,8 @@ class CellModel {
|
|
|
8614
8612
|
}
|
|
8615
8613
|
|
|
8616
8614
|
class ContentOperationsHelper {
|
|
8617
|
-
static removeContent(content, startIndex,
|
|
8618
|
-
return `${content.slice(0, startIndex)}${content.slice(
|
|
8615
|
+
static removeContent(content, startIndex, count) {
|
|
8616
|
+
return `${content.slice(0, startIndex)}${content.slice(startIndex + count, content.length)}`;
|
|
8619
8617
|
}
|
|
8620
8618
|
static insertContent(content, text, index) {
|
|
8621
8619
|
const before = content.slice(0, index);
|
|
@@ -8623,7 +8621,7 @@ class ContentOperationsHelper {
|
|
|
8623
8621
|
return `${before}${text}${after}`;
|
|
8624
8622
|
}
|
|
8625
8623
|
static replaceContent(content, startIndex, endIndex, text) {
|
|
8626
|
-
const reduced = this.removeContent(content, startIndex, endIndex);
|
|
8624
|
+
const reduced = this.removeContent(content, startIndex, endIndex - startIndex + 1);
|
|
8627
8625
|
return this.insertContent(reduced, text, startIndex);
|
|
8628
8626
|
}
|
|
8629
8627
|
}
|
|
@@ -9411,7 +9409,7 @@ class OperationsHelper {
|
|
|
9411
9409
|
this.deleteRestore(contents, command.restore);
|
|
9412
9410
|
break;
|
|
9413
9411
|
case CommandType.Delete:
|
|
9414
|
-
this.delete(contents, command.delete.startIndex, command.delete.
|
|
9412
|
+
this.delete(contents, command.delete.startIndex, command.delete.count);
|
|
9415
9413
|
break;
|
|
9416
9414
|
case CommandType.ReplaceByText: {
|
|
9417
9415
|
const model = command.replaceByText;
|
|
@@ -9699,7 +9697,7 @@ class OperationsHelper {
|
|
|
9699
9697
|
}
|
|
9700
9698
|
static deleteRestore(document, model) {
|
|
9701
9699
|
if (model.startIndex !== model.endIndex) {
|
|
9702
|
-
this.delete(document, model.startIndex, model.endIndex);
|
|
9700
|
+
this.delete(document, model.startIndex, model.endIndex - model.startIndex + 1);
|
|
9703
9701
|
}
|
|
9704
9702
|
this.restore(document, model);
|
|
9705
9703
|
}
|
|
@@ -9715,9 +9713,10 @@ class OperationsHelper {
|
|
|
9715
9713
|
IndexedElementOperationsHelper.restore(document.tabs, model.startIndex, model.text.length, model.tabs);
|
|
9716
9714
|
LinkOperationsHelper.restore(document.links, model.startIndex, model.text.length, model.links);
|
|
9717
9715
|
}
|
|
9718
|
-
static delete(document, startIndex,
|
|
9719
|
-
document.content = ContentOperationsHelper.removeContent(document.content, startIndex,
|
|
9716
|
+
static delete(document, startIndex, count) {
|
|
9717
|
+
document.content = ContentOperationsHelper.removeContent(document.content, startIndex, count);
|
|
9720
9718
|
document.contentLength = document.content.length;
|
|
9719
|
+
const endIndex = startIndex + count - 1;
|
|
9721
9720
|
FormatOperationsHelper.removeContent(document.formats, startIndex, endIndex);
|
|
9722
9721
|
IndexedElementOperationsHelper.removeContent(document.paragraphs, startIndex, endIndex);
|
|
9723
9722
|
IndexedElementOperationsHelper.removeContent(document.images, startIndex, endIndex);
|
|
@@ -9740,7 +9739,7 @@ class OperationsHelper {
|
|
|
9740
9739
|
LinkOperationsHelper.replaceContent(document.links, startIndex, endIndex, text.length);
|
|
9741
9740
|
}
|
|
9742
9741
|
static replace(document, model, contentWidth) {
|
|
9743
|
-
this.delete(document, model.delete.startIndex, model.delete.
|
|
9742
|
+
this.delete(document, model.delete.startIndex, model.delete.count);
|
|
9744
9743
|
if (model.insertText) {
|
|
9745
9744
|
this.insertText(document, model.insertText.text, model.insertText.insertIndex);
|
|
9746
9745
|
}
|
|
@@ -10079,7 +10078,7 @@ class EditSession {
|
|
|
10079
10078
|
CustomComponentHelper.applyRemovingComponents(this.customComponents.images, partIndexes.startIndex, partIndexes.endIndex);
|
|
10080
10079
|
CustomComponentHelper.applyRemovingComponents(this.customComponents.customElements, partIndexes.startIndex, partIndexes.endIndex);
|
|
10081
10080
|
CustomComponentHelper.applyRemovingComponents(this.customComponents.tabs, partIndexes.startIndex, partIndexes.endIndex);
|
|
10082
|
-
OperationsHelper.delete(this.model, partIndexes.startIndex, partIndexes.endIndex);
|
|
10081
|
+
OperationsHelper.delete(this.model, partIndexes.startIndex, partIndexes.endIndex - partIndexes.startIndex + 1);
|
|
10083
10082
|
this.selection.placeCursor(range.start);
|
|
10084
10083
|
this.displayData.resetAllNumberingInfo(range.start.row);
|
|
10085
10084
|
this.displayData.updateNextLineIndexes(range.start.row, range.start.row);
|
|
@@ -10089,7 +10088,7 @@ class EditSession {
|
|
|
10089
10088
|
this.applyToolbarStyles();
|
|
10090
10089
|
}
|
|
10091
10090
|
replace(model) {
|
|
10092
|
-
this.removeByDocumentIndexes(model.delete.startIndex, model.delete.
|
|
10091
|
+
this.removeByDocumentIndexes(model.delete.startIndex, model.delete.startIndex + model.delete.count);
|
|
10093
10092
|
let endPoint;
|
|
10094
10093
|
if (model.insertText) {
|
|
10095
10094
|
endPoint = this.insertTextByDocumentIndex(model.insertText.insertIndex, model.insertText.text);
|
|
@@ -13627,7 +13626,7 @@ class FontComponent {
|
|
|
13627
13626
|
constructor() {
|
|
13628
13627
|
this.isDisabled = false;
|
|
13629
13628
|
this.selectFont = new EventEmitter();
|
|
13630
|
-
this.fonts = [
|
|
13629
|
+
this.fonts = ['Arial', DEFAULT_FONT_FAMILY, 'Times New Roman', 'Verdana'];
|
|
13631
13630
|
this.font = DEFAULT_FONT_FAMILY;
|
|
13632
13631
|
}
|
|
13633
13632
|
set styles(value) {
|