devexpress-richedit 24.1.11 → 24.1.12-build-25107-0103
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/bin/gulpfile.js +1 -1
- package/bin/index-custom.js +1 -1
- package/bin/localization-builder.js +1 -1
- package/bin/nspell-index.js +1 -1
- package/bin/nspell.webpack.config.js +1 -1
- package/bin/webpack-externals.js +1 -1
- package/bin/webpack.config.js +1 -1
- package/dist/dx.richedit.d.ts +1 -1
- package/dist/dx.richedit.js +210 -125
- package/dist/dx.richedit.min.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/client/bars/ribbon.d.ts +1 -0
- package/lib/client/bars/ribbon.js +3 -1
- package/lib/client/public/rich-edit.js +2 -2
- package/lib/client/utils/focus-helper.d.ts +4 -0
- package/lib/client/utils/focus-helper.js +36 -0
- package/lib/common/canvas/canvas-manager.js +10 -4
- package/lib/common/canvas/renderes/common/document-renderer.js +10 -12
- package/lib/common/commands/layout/apply-style-command.d.ts +12 -7
- package/lib/common/commands/layout/apply-style-command.js +44 -36
- package/lib/common/commands/toc/set-paragraph-level-command.d.ts +2 -0
- package/lib/common/commands/toc/set-paragraph-level-command.js +13 -7
- package/lib/common/input-controller.d.ts +5 -5
- package/lib/common/input-controller.js +12 -12
- package/lib/common/layout/main-structures/layout-row.d.ts +2 -1
- package/lib/common/layout/main-structures/layout-row.js +3 -1
- package/lib/common/layout-formatter/row/result.js +2 -1
- package/lib/common/layout-formatter/row/tab-info.js +4 -2
- package/lib/common/model/paragraph/paragraph-style.js +1 -1
- package/lib/common/mouse-handler/mouse-handler/mouse-handler-default-state.d.ts +1 -1
- package/lib/common/mouse-handler/mouse-handler/mouse-handler-default-state.js +22 -25
- package/lib/common/rich-edit-core.js +2 -2
- package/lib/common/utils/size-utils.d.ts +14 -7
- package/lib/common/utils/size-utils.js +43 -18
- package/package.json +3 -3
package/index.d.ts
CHANGED
package/index.js
CHANGED
@@ -13,6 +13,7 @@ export declare class ClientRibbonBar extends RibbonBarBase implements IRibbonBar
|
|
13
13
|
private _toolbarItemsCache;
|
14
14
|
private ownerElement;
|
15
15
|
private activeItem;
|
16
|
+
private focusHandler;
|
16
17
|
constructor(ownerControl: IControlOwner, ownerElement: HTMLElement, apiRibbon: ApiRibbon, fonts: FontsSettings);
|
17
18
|
protected updateContextItem(_commandKey: RichEditClientCommand): void;
|
18
19
|
onCanvasMouseDown(): void;
|
@@ -6,6 +6,7 @@ import { ListUtils } from '@devexpress/utils/lib/utils/list';
|
|
6
6
|
import { StringMapUtils } from '@devexpress/utils/lib/utils/map/string';
|
7
7
|
import { createInnerTab } from '../public/ribbon/creator';
|
8
8
|
import { SizeUtils } from '../../common/utils/size-utils';
|
9
|
+
import { FocusHelper } from '../utils/focus-helper';
|
9
10
|
export class ClientRibbonBar extends RibbonBarBase {
|
10
11
|
constructor(ownerControl, ownerElement, apiRibbon, fonts) {
|
11
12
|
var _a;
|
@@ -14,6 +15,7 @@ export class ClientRibbonBar extends RibbonBarBase {
|
|
14
15
|
this.ownerElement = ownerElement;
|
15
16
|
this.init(apiRibbon, fonts);
|
16
17
|
this.createControl((_a = apiRibbon.activeTabIndex) !== null && _a !== void 0 ? _a : 1);
|
18
|
+
this.focusHandler = FocusHelper.preventFocusOnClick(this.ribbon.element);
|
17
19
|
}
|
18
20
|
updateContextItem(_commandKey) {
|
19
21
|
}
|
@@ -39,13 +41,13 @@ export class ClientRibbonBar extends RibbonBarBase {
|
|
39
41
|
}
|
40
42
|
dispose() {
|
41
43
|
this.ribbon.dispose();
|
44
|
+
this.focusHandler.dispose();
|
42
45
|
}
|
43
46
|
checkActivateHeaderFooter(_selection) {
|
44
47
|
return false;
|
45
48
|
}
|
46
49
|
createControl(activeTabIndex) {
|
47
50
|
const element = document.createElement('div');
|
48
|
-
element.tabIndex = 0;
|
49
51
|
const firstChild = this.ownerElement.firstChild;
|
50
52
|
if (firstChild)
|
51
53
|
this.ownerElement.insertBefore(element, firstChild);
|
@@ -158,11 +158,11 @@ class RichEditPublic {
|
|
158
158
|
command.execute(true, type);
|
159
159
|
}
|
160
160
|
get readOnly() {
|
161
|
-
return this._native.core.readOnly
|
161
|
+
return this._native.core.readOnly === ReadOnlyMode.Persistent;
|
162
162
|
}
|
163
163
|
set readOnly(value) {
|
164
164
|
if (this.readOnly != value) {
|
165
|
-
this._native.core.
|
165
|
+
this._native.core.setPersistentReadOnly(value);
|
166
166
|
this._native.core.barHolder.updateItemsState();
|
167
167
|
this._native.core.horizontalRulerControl.update();
|
168
168
|
this._native.core.beginUpdate();
|
@@ -0,0 +1,36 @@
|
|
1
|
+
export class FocusHelper {
|
2
|
+
static preventFocusOnClick(element) {
|
3
|
+
return new FocusBlocker(element);
|
4
|
+
}
|
5
|
+
}
|
6
|
+
class FocusBlocker {
|
7
|
+
constructor(target) {
|
8
|
+
this.target = target;
|
9
|
+
this.onPointerDownBinded = this.onPointerDown.bind(this);
|
10
|
+
this.addEventListeners(target);
|
11
|
+
}
|
12
|
+
addEventListeners(element) {
|
13
|
+
element.addEventListener("pointerdown", this.onPointerDownBinded);
|
14
|
+
}
|
15
|
+
removeEventListeners(element) {
|
16
|
+
element.removeEventListener("pointerdown", this.onPointerDownBinded);
|
17
|
+
}
|
18
|
+
onPointerDown(event) {
|
19
|
+
for (const element of event.composedPath()) {
|
20
|
+
if (!(element instanceof HTMLElement))
|
21
|
+
continue;
|
22
|
+
if (element === this.target) {
|
23
|
+
event.preventDefault();
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
if (!this.target.contains(element) || element.tabIndex > -1)
|
27
|
+
break;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
dispose() {
|
31
|
+
if (this.target) {
|
32
|
+
this.removeEventListeners(this.target);
|
33
|
+
this.target = null;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
@@ -318,17 +318,23 @@ export class CanvasManager extends BatchUpdatableObject {
|
|
318
318
|
onScrollIntervalTick() {
|
319
319
|
const evtX = this.lastMousePosition.x;
|
320
320
|
const evtY = this.lastMousePosition.y;
|
321
|
-
const inHorizontalArea = evtX >= this.canvasPosition.x && evtX <= this.canvasPosition.x + this.sizes.getVisibleAreaWidth(
|
322
|
-
const inVerticalArea = evtY >= this.canvasPosition.y && evtY <= this.canvasPosition.y + this.sizes.getVisibleAreaHeight(
|
321
|
+
const inHorizontalArea = evtX >= this.canvasPosition.x && evtX <= this.canvasPosition.x + this.sizes.getVisibleAreaWidth(false);
|
322
|
+
const inVerticalArea = evtY >= this.canvasPosition.y && evtY <= this.canvasPosition.y + this.sizes.getVisibleAreaHeight(false);
|
323
323
|
if (!inHorizontalArea && !inVerticalArea)
|
324
324
|
return;
|
325
|
+
const yOffsetWithoutScrollbar = this.canvasPosition.y + this.sizes.getVisibleAreaHeight(false) - evtY;
|
326
|
+
const yOffsetWithScrollbar = this.canvasPosition.y + this.sizes.getVisibleAreaHeight(true) - evtY;
|
327
|
+
const outsideHorizontalScrollbar = yOffsetWithoutScrollbar > 0 || yOffsetWithScrollbar < 0;
|
325
328
|
if (inHorizontalArea && evtY - this.canvasPosition.y <= AUTOSCROLL_AREA_SIZE)
|
326
329
|
this.viewManager.canvas.scrollTop -= AUTOSCROLL_STEP;
|
327
|
-
else if (inHorizontalArea &&
|
330
|
+
else if (inHorizontalArea && yOffsetWithoutScrollbar <= AUTOSCROLL_AREA_SIZE && outsideHorizontalScrollbar)
|
328
331
|
this.viewManager.canvas.scrollTop += AUTOSCROLL_STEP;
|
332
|
+
const xOffsetWithoutScrollbar = this.canvasPosition.x + this.sizes.getVisibleAreaWidth(false) - evtX;
|
333
|
+
const xOffsetWithScrollbar = this.canvasPosition.x + this.sizes.getVisibleAreaWidth(true) - evtX;
|
334
|
+
const outsideVerticalScrollbar = xOffsetWithoutScrollbar > 0 || xOffsetWithScrollbar < 0;
|
329
335
|
if (inVerticalArea && evtX - this.canvasPosition.x <= AUTOSCROLL_AREA_SIZE)
|
330
336
|
this.viewManager.canvas.scrollLeft -= AUTOSCROLL_STEP;
|
331
|
-
else if (inVerticalArea &&
|
337
|
+
else if (inVerticalArea && xOffsetWithoutScrollbar <= AUTOSCROLL_AREA_SIZE && outsideVerticalScrollbar)
|
332
338
|
this.viewManager.canvas.scrollLeft += AUTOSCROLL_STEP;
|
333
339
|
}
|
334
340
|
static getCursorClassName(pointer) {
|
@@ -77,18 +77,16 @@ export class SimpleViewCanvasSizeManager {
|
|
77
77
|
this.sizeUpdated = true;
|
78
78
|
}
|
79
79
|
changeSizeCore() {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
this.control.selection.
|
87
|
-
.setModelPosition(this.control.selection.lastSelectedInterval.start).useStdRelativePosition().useStdOffset());
|
88
|
-
}
|
89
|
-
this.control.owner.adjustControl();
|
90
|
-
this.control.horizontalRulerControl.update();
|
80
|
+
ListUtils.forEach(this.control.viewManager.cache, (_val) => this.control.viewManager.renderer.removePage(1), 1);
|
81
|
+
this.control.viewManager.ensureFirstPageIsRendered();
|
82
|
+
this.control.innerClientProperties.viewsSettings.widthOfPage = this.canvasManager.getCanvasWidth();
|
83
|
+
if (this.control.layoutFormatterManager) {
|
84
|
+
this.control.layoutFormatterManager.invalidator.onChangedAllLayout();
|
85
|
+
this.control.selection.scrollManager.setScroll(new ScrollState().byModelPosition(this.control.selection)
|
86
|
+
.setModelPosition(this.control.selection.lastSelectedInterval.start).useStdRelativePosition().useStdOffset());
|
91
87
|
}
|
88
|
+
this.control.owner.adjustControl();
|
89
|
+
this.control.horizontalRulerControl.update();
|
92
90
|
}
|
93
91
|
}
|
94
92
|
export class DocumentRenderer {
|
@@ -272,7 +270,7 @@ export class DocumentRenderer {
|
|
272
270
|
}
|
273
271
|
}
|
274
272
|
updatePageSize(page, pageElement) {
|
275
|
-
if (pageElement.offsetHeight != page.height || pageElement.offsetWidth != page.width)
|
273
|
+
if (pageElement.offsetHeight != Math.round(page.height) || pageElement.offsetWidth != Math.round(page.width))
|
276
274
|
DomUtils.setStyleSize(pageElement.style, page);
|
277
275
|
}
|
278
276
|
updatePageClasses(pageElement) {
|
@@ -1,18 +1,23 @@
|
|
1
1
|
import { CharacterStyle } from '../../model/character/character-style';
|
2
2
|
import { ParagraphStyle } from '../../model/paragraph/paragraph-style';
|
3
|
-
import {
|
3
|
+
import { SubDocumentInterval } from '../../model/sub-document';
|
4
4
|
import { FixedInterval } from '@devexpress/utils/lib/intervals/fixed';
|
5
5
|
import { CommandBase, CommandSimpleOptions } from '../command-base';
|
6
6
|
import { ApplyStyleCommandState } from '../command-states';
|
7
|
+
export interface IApplyStyleCommandParams {
|
8
|
+
styleName: string;
|
9
|
+
keepDirectFormatting?: boolean;
|
10
|
+
}
|
7
11
|
export declare class ApplyStyleCommand extends CommandBase<ApplyStyleCommandState> {
|
8
12
|
getState(): ApplyStyleCommandState;
|
9
13
|
private getStyleName;
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
DEPRECATEDConvertOptionsParameter(parameter: string | IApplyStyleCommandParams): IApplyStyleCommandParams;
|
15
|
+
executeCore(state: ApplyStyleCommandState, options: CommandSimpleOptions<IApplyStyleCommandParams>): boolean;
|
16
|
+
applyCharacterStyle(subDocumentInterval: SubDocumentInterval, style: CharacterStyle, isPresetStyle: boolean): void;
|
17
|
+
applyParagraphStyle(subDocumentInterval: SubDocumentInterval, style: ParagraphStyle, isPresetStyle: boolean, keepDirectFormatting?: boolean): void;
|
18
|
+
applyParagraphLinkedStyle(subDocumentInterval: SubDocumentInterval, style: ParagraphStyle, isPresetStyle: boolean): void;
|
19
|
+
private addLinkedCharacterStyle;
|
20
|
+
calculateAffectedParagraphCount(subDocumentInterval: SubDocumentInterval): number;
|
16
21
|
isEnabled(): boolean;
|
17
22
|
protected canModify(): boolean;
|
18
23
|
protected getIntervalsForModifying(): FixedInterval[];
|
@@ -9,7 +9,6 @@ import { ControlOptions } from '../../model/options/control';
|
|
9
9
|
import { RichUtils } from '../../model/rich-utils';
|
10
10
|
import { StylesManager } from '../../model/styles-manager';
|
11
11
|
import { SubDocumentInterval } from '../../model/sub-document';
|
12
|
-
import { FixedInterval } from '@devexpress/utils/lib/intervals/fixed';
|
13
12
|
import { SearchUtils } from '@devexpress/utils/lib/utils/search';
|
14
13
|
import { CommandBase } from '../command-base';
|
15
14
|
import { StringUtils } from '@devexpress/utils/lib/utils/string';
|
@@ -50,16 +49,19 @@ export class ApplyStyleCommand extends CommandBase {
|
|
50
49
|
getStyleName(style) {
|
51
50
|
return style.styleName;
|
52
51
|
}
|
52
|
+
DEPRECATEDConvertOptionsParameter(parameter) {
|
53
|
+
return typeof parameter === 'string' ? { styleName: parameter } : parameter;
|
54
|
+
}
|
53
55
|
executeCore(state, options) {
|
54
56
|
const parameter = options.param;
|
55
|
-
if (StringUtils.isNullOrEmpty(parameter))
|
57
|
+
if (StringUtils.isNullOrEmpty(parameter.styleName))
|
56
58
|
return false;
|
57
|
-
|
59
|
+
const subDocumentInterval = new SubDocumentInterval(options.subDocument, state.interval.clone());
|
58
60
|
let executed = true;
|
59
61
|
let isPresetStyle = false;
|
60
62
|
this.history.beginTransaction();
|
61
|
-
if (StylesManager.isParagraphStyle(parameter) && state.paragraphStyleChangeEnabled) {
|
62
|
-
const styleName = StylesManager.getStyleNameWithoutPrefix(parameter);
|
63
|
+
if (StylesManager.isParagraphStyle(parameter.styleName) && state.paragraphStyleChangeEnabled) {
|
64
|
+
const styleName = StylesManager.getStyleNameWithoutPrefix(parameter.styleName);
|
63
65
|
let paragraphStyle = this.control.modelManager.model.getParagraphStyleByName(styleName);
|
64
66
|
if (!paragraphStyle) {
|
65
67
|
const presetStyle = StylesManager.getPresetParagraphStyleByName(styleName);
|
@@ -68,12 +70,12 @@ export class ApplyStyleCommand extends CommandBase {
|
|
68
70
|
paragraphStyle = StylesManager.getPresetParagraphStyleByName(styleName).clone();
|
69
71
|
isPresetStyle = true;
|
70
72
|
}
|
71
|
-
this.applyParagraphStyle(
|
73
|
+
this.applyParagraphStyle(subDocumentInterval, paragraphStyle, isPresetStyle, parameter.keepDirectFormatting);
|
72
74
|
}
|
73
|
-
else if (!StylesManager.isParagraphStyle(parameter) && state.characterStyleChangeEnabled) {
|
74
|
-
const styleName = StylesManager.getStyleNameWithoutPrefix(parameter);
|
75
|
-
if (interval.length == 0)
|
76
|
-
interval = options.subDocument.getWholeWordInterval(interval.start);
|
75
|
+
else if (!StylesManager.isParagraphStyle(parameter.styleName) && state.characterStyleChangeEnabled) {
|
76
|
+
const styleName = StylesManager.getStyleNameWithoutPrefix(parameter.styleName);
|
77
|
+
if (subDocumentInterval.interval.length == 0)
|
78
|
+
subDocumentInterval.interval = options.subDocument.getWholeWordInterval(subDocumentInterval.interval.start);
|
77
79
|
let characterStyle = this.control.modelManager.model.getCharacterStyleByName(styleName);
|
78
80
|
if (!characterStyle) {
|
79
81
|
const presetStyle = StylesManager.getPresetCharacterStyleByName(styleName);
|
@@ -82,9 +84,9 @@ export class ApplyStyleCommand extends CommandBase {
|
|
82
84
|
characterStyle = presetStyle.clone();
|
83
85
|
isPresetStyle = true;
|
84
86
|
}
|
85
|
-
if (interval.length == 0) {
|
87
|
+
if (subDocumentInterval.interval.length == 0) {
|
86
88
|
if (isPresetStyle) {
|
87
|
-
|
89
|
+
const fontInfo = characterStyle.maskedCharacterProperties.fontInfo;
|
88
90
|
if (fontInfo && fontInfo.measurer === undefined)
|
89
91
|
characterStyle.maskedCharacterProperties.fontInfo = this.control.modelManager.model.cache.fontInfoCache.getItemByName(fontInfo.name);
|
90
92
|
}
|
@@ -92,50 +94,56 @@ export class ApplyStyleCommand extends CommandBase {
|
|
92
94
|
executed = false;
|
93
95
|
}
|
94
96
|
else
|
95
|
-
this.applyCharacterStyle(
|
97
|
+
this.applyCharacterStyle(subDocumentInterval, characterStyle, isPresetStyle);
|
96
98
|
}
|
97
99
|
this.history.endTransaction();
|
98
100
|
return executed;
|
99
101
|
}
|
100
|
-
applyCharacterStyle(
|
102
|
+
applyCharacterStyle(subDocumentInterval, style, isPresetStyle) {
|
101
103
|
if (ControlOptions.isEnabled(this.control.modelManager.richOptions.control.characterStyle)) {
|
102
|
-
|
104
|
+
const characterStyle = isPresetStyle ? this.control.modelManager.model.stylesManager.addCharacterStyle(style) : style;
|
105
|
+
this.modelManipulator.style.applyCharacterStyle(subDocumentInterval, characterStyle, false);
|
103
106
|
}
|
104
107
|
}
|
105
|
-
applyParagraphStyle(
|
106
|
-
|
108
|
+
applyParagraphStyle(subDocumentInterval, style, isPresetStyle, keepDirectFormatting = false) {
|
109
|
+
const count = this.calculateAffectedParagraphCount(subDocumentInterval);
|
107
110
|
if (count > 0 && ControlOptions.isEnabled(this.control.modelManager.richOptions.control.paragraphStyle)) {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
this.history.addAndRedo(new
|
111
|
+
const { interval, subDocument } = subDocumentInterval;
|
112
|
+
const paragraphs = subDocument.paragraphs;
|
113
|
+
const paragraphIndex = SearchUtils.normedInterpolationIndexOf(paragraphs, p => p.startLogPosition.value, interval.start);
|
114
|
+
for (let i = 0; i < count; i++) {
|
115
|
+
const paragraph = paragraphs[paragraphIndex + i];
|
116
|
+
const modelManipulator = this.modelManipulator;
|
117
|
+
const paragraphSubDocumentInterval = new SubDocumentInterval(subDocument, paragraph.interval);
|
118
|
+
style = isPresetStyle ? modelManipulator.model.stylesManager.addParagraphStyle(style) : style;
|
119
|
+
this.history.addAndRedo(new ApplyParagraphStyleHistoryItem(modelManipulator, paragraphSubDocumentInterval, style));
|
120
|
+
this.history.addAndRedo(new ParagraphUseValueHistoryItem(modelManipulator, paragraphSubDocumentInterval, 0));
|
121
|
+
if (!keepDirectFormatting)
|
122
|
+
this.history.addAndRedo(new FontUseValueHistoryItem(modelManipulator, paragraphSubDocumentInterval, 0));
|
123
|
+
this.history.addAndRedo(new AddParagraphToListHistoryItem(modelManipulator, subDocument, paragraphIndex, NumberingList.NumberingListNotSettedIndex, -1));
|
117
124
|
}
|
118
125
|
}
|
119
126
|
else
|
120
|
-
this.applyParagraphLinkedStyle(
|
127
|
+
this.applyParagraphLinkedStyle(subDocumentInterval, style, isPresetStyle);
|
121
128
|
}
|
122
|
-
applyParagraphLinkedStyle(
|
129
|
+
applyParagraphLinkedStyle(subDocumentInterval, style, isPresetStyle) {
|
123
130
|
if (ControlOptions.isEnabled(this.control.modelManager.richOptions.control.characterStyle)) {
|
124
131
|
if (!style.linkedStyle)
|
125
|
-
this.
|
126
|
-
this.applyCharacterStyle(
|
132
|
+
this.addLinkedCharacterStyle(style);
|
133
|
+
this.applyCharacterStyle(subDocumentInterval, style.linkedStyle, isPresetStyle);
|
127
134
|
}
|
128
135
|
}
|
129
|
-
|
130
|
-
|
136
|
+
addLinkedCharacterStyle(paragraphStyle) {
|
137
|
+
const style = new CharacterStyle(paragraphStyle.styleName + " Char", paragraphStyle.localizedName + " Char", false, false, false, false, paragraphStyle.maskedCharacterProperties);
|
131
138
|
this.history.addAndRedo(new CreateStyleLinkHistoryItem(this.modelManipulator, style, paragraphStyle));
|
132
139
|
}
|
133
|
-
calculateAffectedParagraphCount(
|
134
|
-
|
140
|
+
calculateAffectedParagraphCount(subDocumentInterval) {
|
141
|
+
const { interval, subDocument } = subDocumentInterval;
|
142
|
+
const paragraphs = subDocument.getParagraphsByInterval(interval);
|
135
143
|
if (paragraphs.length > 1)
|
136
144
|
return paragraphs.length;
|
137
|
-
|
138
|
-
|
145
|
+
const paragraph = paragraphs[0];
|
146
|
+
const lastParagraphCharSelected = interval.length >= paragraph.length - 1;
|
139
147
|
if (interval.start === paragraph.startLogPosition.value && lastParagraphCharSelected || interval.length === 0)
|
140
148
|
return 1;
|
141
149
|
return 0;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { CommandBase, CommandSimpleOptions } from '../command-base';
|
2
2
|
import { SimpleCommandState } from '../command-states';
|
3
3
|
export declare abstract class SetParagraphLevelCommandBase extends CommandBase<SimpleCommandState> {
|
4
|
+
private get commandManager();
|
5
|
+
private get modelManager();
|
4
6
|
isEnabled(): boolean;
|
5
7
|
getState(): SimpleCommandState;
|
6
8
|
executeCore(_state: SimpleCommandState, options: CommandSimpleOptions<number>): boolean;
|
@@ -5,24 +5,30 @@ import { RichEditClientCommand } from '../client-command';
|
|
5
5
|
import { CommandBase, CommandSimpleOptions } from '../command-base';
|
6
6
|
import { SimpleCommandState } from '../command-states';
|
7
7
|
export class SetParagraphLevelCommandBase extends CommandBase {
|
8
|
+
get commandManager() { return this.control.commandManager; }
|
9
|
+
get modelManager() { return this.control.modelManager; }
|
8
10
|
isEnabled() {
|
9
|
-
return super.isEnabled() && ControlOptions.isEnabled(this.
|
11
|
+
return super.isEnabled() && ControlOptions.isEnabled(this.modelManager.richOptions.control.paragraphFormatting);
|
10
12
|
}
|
11
13
|
getState() {
|
12
14
|
const state = new SimpleCommandState(this.isEnabled());
|
13
|
-
state.value = this.
|
15
|
+
state.value = this.commandManager.getCommand(RichEditClientCommand.ChangeHeadingLevel).getState().value == this.getLevel(null);
|
14
16
|
return state;
|
15
17
|
}
|
16
18
|
executeCore(_state, options) {
|
17
19
|
const level = this.getLevel(options.param);
|
18
20
|
const styleName = level > 0 ? `${ParagraphStyle.headingStyleName} ${level}` : ParagraphStyle.normalStyleName;
|
19
|
-
let paragraphStyle = this.
|
21
|
+
let paragraphStyle = this.modelManager.model.getParagraphStyleByName(styleName);
|
20
22
|
if (!paragraphStyle)
|
21
23
|
paragraphStyle = StylesManager.getPresetParagraphStyleByName(styleName);
|
22
|
-
if (paragraphStyle)
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
if (paragraphStyle) {
|
25
|
+
const commandOptions = new CommandSimpleOptions(this.control, { styleName: StylesManager.paragraphPrefix + styleName, keepDirectFormatting: true });
|
26
|
+
this.commandManager.getCommand(RichEditClientCommand.ChangeStyle).execute(this.commandManager.isPublicApiCall, commandOptions);
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
const commandOptions = new CommandSimpleOptions(this.control, level);
|
30
|
+
this.commandManager.getCommand(RichEditClientCommand.ChangeHeadingLevel).execute(this.commandManager.isPublicApiCall, commandOptions);
|
31
|
+
}
|
26
32
|
return true;
|
27
33
|
}
|
28
34
|
getRelatedCommands() {
|
@@ -17,7 +17,7 @@ export declare abstract class InputEditorBase<TInpElement extends HTMLElement> {
|
|
17
17
|
previousText: string;
|
18
18
|
canInsertTextOnInputEvent: boolean;
|
19
19
|
needProcessShortcut: boolean;
|
20
|
-
|
20
|
+
editableStateInitialized: boolean;
|
21
21
|
prevKeyCode: number;
|
22
22
|
IMEState: IMEState;
|
23
23
|
private inputWithAlt;
|
@@ -31,8 +31,8 @@ export declare abstract class InputEditorBase<TInpElement extends HTMLElement> {
|
|
31
31
|
constructor(control: IRichEditControl, eventManager: IEventManager, parent: HTMLElement);
|
32
32
|
dispose(): void;
|
33
33
|
initialize(): void;
|
34
|
-
|
35
|
-
|
34
|
+
initializeEditableState(): void;
|
35
|
+
initializeEditableStateCore(): void;
|
36
36
|
initEvents(): void;
|
37
37
|
createHierarchy(parent: HTMLElement): void;
|
38
38
|
createHierarchyCore(): void;
|
@@ -78,7 +78,7 @@ export declare class DivInputEditor extends InputEditorBase<HTMLElement> {
|
|
78
78
|
private onTextInputTimerId;
|
79
79
|
constructor(control: IRichEditControl, eventManager: IEventManager, parent: HTMLElement);
|
80
80
|
dispose(): void;
|
81
|
-
|
81
|
+
initializeEditableStateCore(): void;
|
82
82
|
setPosition(left: number, top: number): void;
|
83
83
|
createInputElement(): HTMLElement;
|
84
84
|
initEvents(): void;
|
@@ -114,7 +114,7 @@ export declare class IFrameInputEditor extends InputEditorBase<HTMLIFrameElement
|
|
114
114
|
constructor(control: IRichEditControl, eventManager: IEventManager, parent: HTMLElement);
|
115
115
|
dispose(): void;
|
116
116
|
createHierarchyCore(): void;
|
117
|
-
|
117
|
+
initializeEditableStateCore(): void;
|
118
118
|
createInputElement(): HTMLIFrameElement;
|
119
119
|
initEvents(): void;
|
120
120
|
private isModifyEnabled;
|
@@ -51,17 +51,17 @@ export class InputEditorBase {
|
|
51
51
|
clearTimeout(this.onKeyUpTimerId);
|
52
52
|
}
|
53
53
|
initialize() {
|
54
|
-
this.
|
54
|
+
this.initializeEditableState();
|
55
55
|
this.initEvents();
|
56
56
|
this.prevKeyCode = EMPTY_KEYCODE;
|
57
57
|
}
|
58
|
-
|
59
|
-
if (
|
60
|
-
this.
|
61
|
-
this.
|
58
|
+
initializeEditableState() {
|
59
|
+
if (!this.editableStateInitialized) {
|
60
|
+
this.editableStateInitialized = true;
|
61
|
+
this.initializeEditableStateCore();
|
62
62
|
}
|
63
63
|
}
|
64
|
-
|
64
|
+
initializeEditableStateCore() {
|
65
65
|
}
|
66
66
|
initEvents() {
|
67
67
|
this.evtHandlersHolder.addListener(this.getEditableDocument(), "keydown", this.onKeyDown.bind(this));
|
@@ -281,8 +281,8 @@ export class DivInputEditor extends InputEditorBase {
|
|
281
281
|
clearTimeout(this.composEndTimerId);
|
282
282
|
clearTimeout(this.onTextInputTimerId);
|
283
283
|
}
|
284
|
-
|
285
|
-
this.inputElement.contentEditable =
|
284
|
+
initializeEditableStateCore() {
|
285
|
+
this.inputElement.contentEditable = String(!this.control.isReadOnlyPersistent);
|
286
286
|
this.clearInputElement();
|
287
287
|
}
|
288
288
|
setPosition(left, top) {
|
@@ -530,11 +530,11 @@ export class IFrameInputEditor extends InputEditorBase {
|
|
530
530
|
body.style.margin = "0px";
|
531
531
|
body.style.overflow = "hidden";
|
532
532
|
}
|
533
|
-
|
533
|
+
initializeEditableStateCore() {
|
534
534
|
if (Browser.WebKitFamily)
|
535
|
-
this.editableDocument.body.setAttribute("contenteditable",
|
535
|
+
this.editableDocument.body.setAttribute("contenteditable", String(!this.control.isReadOnlyPersistent));
|
536
536
|
else
|
537
|
-
this.editableDocument.designMode = "on";
|
537
|
+
this.editableDocument.designMode = this.control.isReadOnlyPersistent ? "off" : "on";
|
538
538
|
}
|
539
539
|
createInputElement() {
|
540
540
|
const element = document.createElement("IFRAME");
|
@@ -673,7 +673,7 @@ export class IFrameInputEditor extends InputEditorBase {
|
|
673
673
|
recreateIfNeeded() {
|
674
674
|
const iframeDocument = this.inputElement.contentDocument || this.inputElement.contentWindow.document;
|
675
675
|
if (!iframeDocument.body.hasAttribute("loaded")) {
|
676
|
-
this.
|
676
|
+
this.editableStateInitialized = false;
|
677
677
|
this.createHierarchyCore();
|
678
678
|
this.initialize();
|
679
679
|
}
|
@@ -13,7 +13,8 @@ export declare enum LayoutRowStateFlags {
|
|
13
13
|
SectionEnd = 8,
|
14
14
|
DocumentEnd = 16,
|
15
15
|
CellTableEnd = 64,
|
16
|
-
PageBreakBefore = 128
|
16
|
+
PageBreakBefore = 128,
|
17
|
+
InfinityWidth = 256
|
17
18
|
}
|
18
19
|
export declare class LayoutRow extends Rectangle {
|
19
20
|
boxes: LayoutBox[];
|
@@ -2,6 +2,7 @@ import { Flag } from '@devexpress/utils/lib/class/flag';
|
|
2
2
|
import { UnitConverter } from '@devexpress/utils/lib/class/unit-converter';
|
3
3
|
import { Rectangle } from '@devexpress/utils/lib/geometry/rectangle';
|
4
4
|
import { ListUtils } from '@devexpress/utils/lib/utils/list';
|
5
|
+
import { LayoutBoxType } from './layout-boxes/layout-box';
|
5
6
|
export var LayoutRowStateFlags;
|
6
7
|
(function (LayoutRowStateFlags) {
|
7
8
|
LayoutRowStateFlags[LayoutRowStateFlags["NormallyEnd"] = 0] = "NormallyEnd";
|
@@ -12,6 +13,7 @@ export var LayoutRowStateFlags;
|
|
12
13
|
LayoutRowStateFlags[LayoutRowStateFlags["DocumentEnd"] = 16] = "DocumentEnd";
|
13
14
|
LayoutRowStateFlags[LayoutRowStateFlags["CellTableEnd"] = 64] = "CellTableEnd";
|
14
15
|
LayoutRowStateFlags[LayoutRowStateFlags["PageBreakBefore"] = 128] = "PageBreakBefore";
|
16
|
+
LayoutRowStateFlags[LayoutRowStateFlags["InfinityWidth"] = 256] = "InfinityWidth";
|
15
17
|
})(LayoutRowStateFlags || (LayoutRowStateFlags = {}));
|
16
18
|
export class LayoutRow extends Rectangle {
|
17
19
|
constructor(minY = Number.MAX_SAFE_INTEGER) {
|
@@ -127,7 +129,7 @@ export class LayoutRow extends Rectangle {
|
|
127
129
|
return lastBoxIndexWhatCanStrikeoutAndUnderline;
|
128
130
|
}
|
129
131
|
containsSpacesOnly() {
|
130
|
-
return this.boxes.length > 0 && ListUtils.allOf(this.boxes, val => val.isWhitespace());
|
132
|
+
return this.boxes.length > 0 && ListUtils.allOf(this.boxes, val => val.isWhitespace() || val.getType() === LayoutBoxType.ParagraphMark);
|
131
133
|
}
|
132
134
|
}
|
133
135
|
export class LayoutRowWithIndex extends LayoutRow {
|
@@ -42,7 +42,8 @@ export class RowFormatterResult {
|
|
42
42
|
return;
|
43
43
|
this.rowFormatter.tabInfo.shiftBoxesAfterLastTab();
|
44
44
|
const dontJustifyLinesEndingInSoftLineBreak = this.rowFormatter.manager.model.compatibilitySettings.dontJustifyLinesEndingInSoftLineBreak;
|
45
|
-
|
45
|
+
if (!this.row.flags.get(LayoutRowStateFlags.InfinityWidth))
|
46
|
+
BoxAligner.align(this.row, this.rowFormatter.paragraphProps.alignment, currLogicRowEndPos, this.rowBoxIndexStart, dontJustifyLinesEndingInSoftLineBreak);
|
46
47
|
this.rowBoxIndexStart = this.row.boxes.length;
|
47
48
|
}
|
48
49
|
deleteSomeAnchorObjects(index, posToRestart) {
|
@@ -7,6 +7,7 @@ import { SearchUtils } from '@devexpress/utils/lib/utils/search';
|
|
7
7
|
import { StringUtils } from '@devexpress/utils/lib/utils/string';
|
8
8
|
import { LayoutBoxType } from '../../layout/main-structures/layout-boxes/layout-box';
|
9
9
|
import { TabLeaderType } from '../../layout/main-structures/layout-boxes/layout-tab-space-box';
|
10
|
+
import { LayoutRowStateFlags } from '../../layout/main-structures/layout-row';
|
10
11
|
import { TabAlign } from '../../model/paragraph/paragraph';
|
11
12
|
import { ParagraphFirstLineIndent } from '../../model/paragraph/paragraph-properties';
|
12
13
|
import { TabInfo } from '../../model/paragraph/paragraph-style';
|
@@ -84,10 +85,11 @@ export class RowTabInfo {
|
|
84
85
|
const lastInterval = ListUtils.last(this.rowFormatter.rowSizesManager.rowFormattingInfo.intervals);
|
85
86
|
if (tabXPosRelativePage > lastInterval.end) {
|
86
87
|
if (lastInterval.end < this.rowFormatter.paragraphHorizontalBounds.end) {
|
87
|
-
if (this.rowFormatter.manager.model.compatibilitySettings.compatibilityMode < CompatibilityMode.Word2013) {
|
88
|
+
if (this.rowFormatter.manager.model.compatibilitySettings.compatibilityMode < CompatibilityMode.Word2013 && tabPosition !== null) {
|
89
|
+
this.currInterval.avaliableWidth = Number.MAX_SAFE_INTEGER - this.currInterval.busyWidth;
|
88
90
|
this.currInterval.length = Number.MAX_SAFE_INTEGER;
|
89
|
-
this.currInterval.avaliableWidth = Number.MAX_SAFE_INTEGER;
|
90
91
|
this.row.width = Number.MAX_SAFE_INTEGER;
|
92
|
+
this.row.flags.set(LayoutRowStateFlags.InfinityWidth, true);
|
91
93
|
return this.addTabBox();
|
92
94
|
}
|
93
95
|
else if (tabBox.right < this.rowFormatter.paragraphHorizontalBounds.end) {
|
@@ -61,7 +61,7 @@ export class ParagraphStyle extends StyleBase {
|
|
61
61
|
}
|
62
62
|
}
|
63
63
|
ParagraphStyle.normalStyleName = "Normal";
|
64
|
-
ParagraphStyle.headingStyleName = "
|
64
|
+
ParagraphStyle.headingStyleName = "Heading";
|
65
65
|
ParagraphStyle.tocStyleName = "toc";
|
66
66
|
export class TabProperties {
|
67
67
|
constructor() {
|
@@ -32,7 +32,7 @@ export declare class MouseHandlerDefaultState extends MouseHandlerStateBase {
|
|
32
32
|
private shouldBeginDragExistingSelection;
|
33
33
|
private selectImage;
|
34
34
|
private beginDragExistingSelection;
|
35
|
-
selectFloatingObject(box: LayoutAnchoredObjectBox):
|
35
|
+
selectFloatingObject(box: LayoutAnchoredObjectBox): boolean;
|
36
36
|
}
|
37
37
|
export declare class MouseHandlerHelper {
|
38
38
|
static selectParentsTextBox(control: IRichEditControl): void;
|