@@ -319,6 +319,14 @@ export class Editor {
319
319
* @private
320
320
*/
321
321
public isFieldOperation: boolean = false;
322
+ /**
323
+ * @private
324
+ */
325
+ public decreasedIndent: boolean = false;
326
+ /**
327
+ * @private
328
+ */
329
+ public increasedIndent: boolean = false;
322
330
/**
323
331
* @private
324
332
* @returns {boolean} - Returns the restrict formatting
@@ -2727,37 +2735,50 @@ export class Editor {
2727
2735
}
2728
2736
}
2729
2737
private applyRichText(value?: string, title?: string, tag?: string, lock?: boolean, lockContents?: boolean): void {
2730
- let positionStart: TextPosition = this.selection.isForward ? this.selection.start.clone() : this.selection.end.clone();
2731
- let positionEnd: TextPosition = this.selection.isForward ? this.selection.end.clone() : this.selection.start.clone();
2732
- if (this.selection.isParagraphMarkSelected()) {
2733
- positionEnd.offset -= 1;
2734
- }
2735
- if (positionStart.paragraph !== positionEnd.paragraph) {
2736
- if (!positionStart.isAtParagraphStart) {
2737
- positionEnd.setPositionParagraph(positionStart.paragraph.lastChild as LineWidget, (positionStart.paragraph.lastChild as LineWidget).getEndOffset());
2738
- } else if (positionStart.isAtParagraphStart && !positionEnd.isAtParagraphEnd) {
2739
- let previousParagraph: ParagraphWidget;
2740
- if (positionEnd.paragraph.previousRenderedWidget instanceof TableWidget) {
2741
- previousParagraph = this.selection.getLastBlockInLastCell(positionEnd.paragraph.previousRenderedWidget) as ParagraphWidget;
2742
- } else {
2743
- previousParagraph = positionEnd.paragraph.previousRenderedWidget as ParagraphWidget;
2738
+ let positionStart: TextPosition;
2739
+ let positionEnd: TextPosition;
2740
+ let isInline: boolean = true;
2741
+ if (!isNullOrUndefined(this.selection.currentContentControl) && this.selection.currentContentControl.contentControlProperties.hasPlaceHolderText) {
2742
+ if (this.editorHistory) {
2743
+ this.initComplexHistory('InsertContentControl');
2744
+ }
2745
+ this.delete();
2746
+ this.selection.selectContentControlInternal(this.selection.currentContentControl);
2747
+ positionStart = this.selection.isForward ? this.selection.start.clone() : this.selection.end.clone();
2748
+ positionEnd = this.selection.isForward ? this.selection.end.clone() : this.selection.start.clone();
2749
+ isInline = this.selection.currentContentControl.contentControlWidgetType === 'Block' ? false : true;
2750
+ } else {
2751
+ positionStart = this.selection.isForward ? this.selection.start.clone() : this.selection.end.clone();
2752
+ positionEnd = this.selection.isForward ? this.selection.end.clone() : this.selection.start.clone();
2753
+ if (this.selection.isParagraphMarkSelected()) {
2754
+ positionEnd.offset -= 1;
2755
+ }
2756
+ if (positionStart.paragraph !== positionEnd.paragraph) {
2757
+ if (!positionStart.isAtParagraphStart) {
2758
+ positionEnd.setPositionParagraph(positionStart.paragraph.lastChild as LineWidget, (positionStart.paragraph.lastChild as LineWidget).getEndOffset());
2759
+ } else if (positionStart.isAtParagraphStart && !positionEnd.isAtParagraphEnd) {
2760
+ let previousParagraph: ParagraphWidget;
2761
+ if (positionEnd.paragraph.previousRenderedWidget instanceof TableWidget) {
2762
+ previousParagraph = this.selection.getLastBlockInLastCell(positionEnd.paragraph.previousRenderedWidget) as ParagraphWidget;
2763
+ } else {
2764
+ previousParagraph = positionEnd.paragraph.previousRenderedWidget as ParagraphWidget;
2765
+ }
2766
+ positionEnd.setPositionParagraph(previousParagraph.lastChild as LineWidget, (previousParagraph.lastChild as LineWidget).getEndOffset());
2744
2767
}
2745
- positionEnd.setPositionParagraph(previousParagraph.lastChild as LineWidget, (previousParagraph.lastChild as LineWidget).getEndOffset());
2746
2768
}
2747
- }
2748
- let isInline: boolean = true;
2749
- if (positionStart.isAtParagraphStart && positionEnd.isAtParagraphEnd) {
2750
- isInline = false;
2751
- }
2752
- this.updateContentControlPosition(positionStart, positionEnd);
2753
- if (this.editorHistory) {
2754
- this.initComplexHistory('InsertContentControl');
2769
+ this.updateContentControlPosition(positionStart, positionEnd);
2770
+ if (positionStart.isAtParagraphStart && positionEnd.isAtParagraphEnd) {
2771
+ isInline = false;
2772
+ }
2773
+ if (this.editorHistory) {
2774
+ this.initComplexHistory('InsertContentControl');
2775
+ }
2755
2776
}
2756
2777
const blockStartContentControl: ContentControl = new ContentControl(isInline ? 'Inline' : 'Block');
2757
2778
const blockEndContentControl: ContentControl = new ContentControl(isInline ? 'Inline' : 'Block');
2758
2779
let properties: ContentControlProperties = new ContentControlProperties(isInline ? 'Inline' : 'Block');
2759
2780
properties.color = "#00000000";
2760
- positionStart.isAtSamePosition(positionEnd) ? properties.hasPlaceHolderText = true : properties.hasPlaceHolderText = false;
2781
+ properties.hasPlaceHolderText = positionStart.isAtSamePosition(positionEnd) ? true : false;
2761
2782
properties.isTemporary = false;
2762
2783
properties.lockContentControl = !isNullOrUndefined(lock) ? !lock : false;
2763
2784
properties.lockContents = !isNullOrUndefined(lockContents) ? !lockContents : false;
@@ -7238,6 +7259,9 @@ export class Editor {
7238
7259
if (lineWidget.children[k].characterFormat.fontColor !== insertFormat.fontColor) {
7239
7260
lineWidget.children[k].characterFormat.fontColor = insertFormat.fontColor;
7240
7261
}
7262
+ if (lineWidget.children[k].characterFormat.highlightColor !== insertFormat.highlightColor) {
7263
+ lineWidget.children[k].characterFormat.highlightColor = insertFormat.highlightColor;
7264
+ }
7241
7265
if (lineWidget.children[k].characterFormat.fontSize !== insertFormat.fontSize) {
7242
7266
lineWidget.children[k].characterFormat.fontSize = insertFormat.fontSize;
7243
7267
lineWidget.children[k].characterFormat.fontSizeBidi = insertFormat.fontSizeBidi;
@@ -11215,7 +11239,9 @@ export class Editor {
11215
11239
*/
11216
11240
public increaseIndent(): void {
11217
11241
if (!this.owner.isReadOnlyMode || this.selection.isInlineFormFillMode()) {
11242
+ this.increasedIndent = true;
11218
11243
this.onApplyParagraphFormat('leftIndent', this.documentHelper.defaultTabWidth, true, false);
11244
+ this.increasedIndent = false;
11219
11245
}
11220
11246
}
11221
11247
/**
@@ -11225,7 +11251,9 @@ export class Editor {
11225
11251
*/
11226
11252
public decreaseIndent(): void {
11227
11253
if (!this.owner.isReadOnlyMode || this.selection.isInlineFormFillMode()) {
11254
+ this.decreasedIndent = true;
11228
11255
this.onApplyParagraphFormat('leftIndent', -this.documentHelper.defaultTabWidth, true, false);
11256
+ this.decreasedIndent = false;
11229
11257
}
11230
11258
}
11231
11259
/**
@@ -13103,15 +13131,21 @@ export class Editor {
13103
13131
// Increment or Decrement list level for Multilevel lists.
13104
13132
let documentHelper: DocumentHelper = this.documentHelper;
13105
13133
let listFormat: WListFormat = this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat;
13106
- let paragraphFormat: WParagraphFormat = this.documentHelper.selection.start.paragraph.paragraphFormat;
13134
+ let paragraphFormat: WParagraphFormat = undefined;
13135
+ if (!this.documentHelper.selection.isForward) {
13136
+ paragraphFormat = documentHelper.selection.end.paragraph.paragraphFormat;
13137
+ } else {
13138
+ paragraphFormat = documentHelper.selection.start.paragraph.paragraphFormat;
13139
+ }
13107
13140
let list: WList = documentHelper.getListById(paragraphFormat.listFormat.listId);
13108
13141
let listLevel: WListLevel = documentHelper.layout.getListLevel(list, paragraphFormat.listFormat.listLevelNumber);
13142
+ const paraListLevelNumber: number = paragraphFormat.listFormat.listLevelNumber;
13109
13143
let levelNumber: number;
13110
13144
if (increaseLevel) {
13111
- levelNumber = paragraphFormat.listFormat.listLevelNumber + 1;
13145
+ levelNumber = paraListLevelNumber === 8 ? paraListLevelNumber : paraListLevelNumber + 1;
13112
13146
}
13113
13147
else {
13114
- levelNumber = paragraphFormat.listFormat.listLevelNumber - 1;
13148
+ levelNumber = paraListLevelNumber === 0 ? paraListLevelNumber : paraListLevelNumber - 1;
13115
13149
}
13116
13150
let nextListLevel: WListLevel = documentHelper.layout.getListLevel(list, levelNumber);
13117
13151
if (!isNullOrUndefined(nextListLevel)) {
@@ -13824,8 +13858,17 @@ export class Editor {
13824
13858
block = this.documentHelper.selection.getNextRenderedBlock(block);
13825
13859
if (!isNullOrUndefined(block)) { //Goto the next block.
13826
13860
if (block instanceof ParagraphWidget) {
13827
- if (property === 'listFormat' && value instanceof WListFormat && block.paragraphFormat.listFormat.hasValue("listLevelNumber") && value["listLevelNumber"] < block.paragraphFormat.listFormat.listLevelNumber) {
13828
- value["listLevelNumber"] = block.paragraphFormat.listFormat.listLevelNumber;
13861
+ if (value instanceof WListFormat && block.paragraphFormat.listFormat.hasValue("listLevelNumber")) {
13862
+ const paraListLevelNumber: number = block.paragraphFormat.listFormat.listLevelNumber;
13863
+ if (property === 'listFormat' && value["listLevelNumber"] < paraListLevelNumber && !this.increasedIndent && !this.decreasedIndent) {
13864
+ value["listLevelNumber"] = paraListLevelNumber;
13865
+ }
13866
+ if (this.increasedIndent && value["listLevelNumber"] - 1 !== paraListLevelNumber) {
13867
+ value["listLevelNumber"] = paraListLevelNumber === 8 ? paraListLevelNumber : paraListLevelNumber + 1;
13868
+ }
13869
+ if (this.decreasedIndent && value["listLevelNumber"] + 1 !== paraListLevelNumber) {
13870
+ value["listLevelNumber"] = paraListLevelNumber === 0 ? paraListLevelNumber : paraListLevelNumber - 1;
13871
+ }
13829
13872
}
13830
13873
this.applyParaFormat(block, start, end, property, value, update);
13831
13874
} else {
@@ -17960,25 +18003,32 @@ export class Editor {
17960
18003
let levelNumber: number = -1;
17961
18004
let initialListLevel: WListLevel = undefined;
17962
18005
let isSameList: boolean = false;
17963
- if (currentParagraph.paragraphFormat.listFormat.listId !== -1 && !isNullOrUndefined(currentParagraph.paragraphFormat.listFormat.listLevel)) {
18006
+ let isRestartList: boolean = false;
18007
+ if (!isNullOrUndefined(list) && start.paragraph.paragraphFormat.listFormat.listId === -1
18008
+ && currentParagraph.paragraphFormat.listFormat.listId !== -1 && currentParagraph.paragraphFormat.listFormat.listLevelNumber > 0
18009
+ && currentParagraph.paragraphFormat.listFormat.listLevel.listLevelPattern !== listLevelPattern) {
18010
+ isRestartList = true;
18011
+ list = undefined;
18012
+ }
18013
+ if (!isRestartList && currentParagraph.paragraphFormat.listFormat.listId !== -1 && !isNullOrUndefined(currentParagraph.paragraphFormat.listFormat.listLevel)) {
17964
18014
const listFormat: WListFormat = currentParagraph.paragraphFormat.listFormat;
17965
18015
this.listFormatInfo = {
17966
18016
listNumberFormat: listFormat.listLevel.numberFormat,
17967
18017
listLevelPattern: listFormat.listLevel.listLevelPattern,
17968
18018
listCharacterFormat: listFormat.listLevel.characterFormat.hasValue('fontFamily') ? listFormat.listLevel.characterFormat.fontFamily : undefined,
17969
18019
listId: listFormat.listId
17970
18020
};
17971
- if (isNullOrUndefined(currentParagraph.previousWidget) && currentParagraph.paragraphFormat. listFormat.listLevelNumber > 0) {
17972
- this.listFormatInfo.listLevelNumber = this.listLevelNumber = this.documentHelper.selection. start.paragraph.paragraphFormat.listFormat.listLevelNumber;
18021
+ if (isNullOrUndefined(currentParagraph.previousWidget) && listFormat.listLevelNumber > 0) {
18022
+ this.listFormatInfo.listLevelNumber = this.listLevelNumber = start.paragraph.paragraphFormat.listFormat.listLevelNumber;
17973
18023
}
17974
18024
else {
17975
18025
this.listFormatInfo.listLevelNumber = this.listLevelNumber = listFormat.listLevelNumber;
17976
18026
}
17977
18027
}
17978
18028
if (!isNullOrUndefined(list)) {
17979
- if (isNullOrUndefined(currentParagraph.previousWidget) && currentParagraph.paragraphFormat.listFormat.listLevelNumber > 0)
18029
+ if (isNullOrUndefined(currentParagraph.previousWidget) && currentParagraph.paragraphFormat.listFormat.listLevelNumber > 0)
17980
18030
{
17981
- levelNumber = this.documentHelper.selection. start.paragraph.paragraphFormat.listFormat.listLevelNumber;
18031
+ levelNumber = start.paragraph.paragraphFormat.listFormat.listLevelNumber;
17982
18032
}
17983
18033
else
17984
18034
{
@@ -23909,6 +23959,7 @@ export class Editor {
23909
23959
}
23910
23960
this.owner.isShiftingEnabled = true;
23911
23961
this.insertElements([editEnd], [editStart]);
23962
+ editStart.editRangeEnd.line = editEnd.line;
23912
23963
if (this.editorHistory) {
23913
23964
this.editorHistory.updateComplexHistoryInternal();
23914
23965
}
0 commit comments