UNPKG

@syncfusion/ej2-documenteditor

Version:

Feature-rich document editor control with built-in support for context menu, options pane and dialogs.

1,498 lines 139 kB
import { FontScriptType } from '../../base/types'; import { WShading } from '../format/index'; import { HelperMethods } from '../index'; import { isNullOrUndefined } from '@syncfusion/ej2-base'; import { TableCellWidget } from '../viewer/page'; import { WList } from '../list/list'; import { WAbstractList } from '../list/abstract-list'; import { WListLevel } from '../list/list-level'; /* eslint-disable */ /** * Selection character format implementation */ var SelectionCharacterFormat = /** @class */ (function () { /** * @param selection * @private */ function SelectionCharacterFormat(selection) { this.boldIn = undefined; this.italicIn = undefined; this.underlineIn = undefined; this.strikeThroughIn = undefined; this.baselineAlignmentIn = undefined; this.highlightColorIn = undefined; this.fontSizeIn = 0; this.scriptType = FontScriptType.English; this.fontColorIn = undefined; this.allCapsIn = undefined; /** * @private */ this.boldBidi = undefined; /** * @private */ this.italicBidi = undefined; /** * @private */ this.complexScript = undefined; /** * @private */ this.fontSizeBidi = 0; /** * @private */ this.bidi = undefined; /** * @private */ this.bdo = undefined; this.selection = selection; } Object.defineProperty(SelectionCharacterFormat.prototype, "fontSize", { /** * Gets the font size of selected contents. * * @aspType int */ get: function () { return this.fontSizeIn; }, /** * Sets the font size of selected contents. * * @aspType int */ set: function (value) { if (value === this.fontSizeIn) { return; } this.fontSizeIn = value; this.notifyPropertyChanged('fontSize'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "renderedFontFamily", { get: function () { return this.renderedFontFamilyIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "fontFamily", { /** * Gets or sets the font family of selected contents. * * @aspType string */ get: function () { return this.fontFamilyIn; }, /** * Sets the font family of selected contents. * * @aspType string */ set: function (value) { if (value === this.fontFamilyIn) { return; } this.fontFamilyIn = this.renderedFontFamilyIn = value; this.notifyPropertyChanged('fontFamily'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "fontColor", { /** * Gets or sets the font color of selected contents. * * @aspType string */ get: function () { return this.fontColorIn; }, /** * Sets the font color of selected contents. * * @aspType string */ set: function (value) { if (value === this.fontColorIn) { return; } this.fontColorIn = value; this.notifyPropertyChanged('fontColor'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "bold", { /** * Gets or sets the bold formatting of selected contents. * * @aspType bool */ get: function () { return this.boldIn; }, /** * Sets the bold formatting of selected contents. * * @aspType bool */ set: function (value) { if (value === this.boldIn) { return; } this.boldIn = value; this.notifyPropertyChanged('bold'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "italic", { /** * Gets or sets the italic formatting of selected contents. * * @aspType bool */ get: function () { return this.italicIn; }, /** * Sets the italic formatting of selected contents. * * @aspType bool */ set: function (value) { if (value === this.italic) { return; } this.italicIn = value; this.notifyPropertyChanged('italic'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "strikethrough", { /** * Gets or sets the strikethrough property of selected contents. */ get: function () { return this.strikeThroughIn; }, /** * Sets the strikethrough property of selected contents. */ set: function (value) { if (value === this.strikeThroughIn) { return; } this.strikeThroughIn = value; this.notifyPropertyChanged('strikethrough'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "baselineAlignment", { /** * Gets or sets the baseline alignment property of selected contents. */ get: function () { return this.baselineAlignmentIn; }, /** * Sets the baseline alignment property of selected contents. */ set: function (value) { if (value === this.baselineAlignmentIn) { return; } this.baselineAlignmentIn = value; this.notifyPropertyChanged('baselineAlignment'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "underline", { /** * Gets or sets the underline style of selected contents. */ get: function () { return this.underlineIn; }, /** * Sets the underline style of selected contents. */ set: function (value) { if (value === this.underlineIn) { return; } this.underlineIn = value; this.notifyPropertyChanged('underline'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "highlightColor", { /** * Gets or sets the highlight color of selected contents. */ get: function () { return this.highlightColorIn; }, /** * Sets the highlight color of selected contents. */ set: function (value) { if (value === this.highlightColorIn && value !== "NoColor") { return; } this.highlightColorIn = value; this.notifyPropertyChanged('highlightColor'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionCharacterFormat.prototype, "allCaps", { /** * Gets or sets the allCaps formatting of selected contents. * * @aspType bool */ get: function () { return this.allCapsIn; }, /** * Sets the allCaps formatting of selected contents. * * @aspType bool */ set: function (value) { if (value === this.allCapsIn) { return; } this.allCapsIn = value; this.notifyPropertyChanged('allCaps'); }, enumerable: true, configurable: true }); SelectionCharacterFormat.prototype.getPropertyValue = function (property) { switch (property) { case 'bold': return this.bold; case 'italic': return this.italic; case 'fontSize': if (this.fontSize >= 1) { return this.fontSize; } return undefined; case 'fontFamily': return this.fontFamily; case 'strikethrough': return this.strikethrough; case 'baselineAlignment': return this.baselineAlignment; case 'highlightColor': return this.highlightColor; case 'underline': return this.underline; case 'fontColor': return this.fontColor; case 'allCaps': return this.allCaps; default: return undefined; } }; /** * Notifies whenever property gets changed. * * @param {string} propertyName */ SelectionCharacterFormat.prototype.notifyPropertyChanged = function (propertyName) { if (!isNullOrUndefined(this.selection) && !this.selection.isRetrieveFormatting && (this.selection.isCleared || (this.selection.owner.isReadOnlyMode && !this.selection.isInlineFormFillMode()) || !this.selection.owner.isDocumentLoaded || this.selection.owner.isPastingContent)) { return; } if (!isNullOrUndefined(this.selection) && !isNullOrUndefined(this.selection.start) && !this.selection.isRetrieveFormatting) { var propertyValue = this.getPropertyValue(propertyName); if (!isNullOrUndefined(propertyValue)) { this.selection.owner.editorModule.onApplyCharacterFormat(propertyName, propertyValue); } } }; /** * Copies the source format. * * @param {WCharacterFormat} format * @returns {void} * @private */ SelectionCharacterFormat.prototype.copyFormat = function (format, renderFontFamily) { this.styleName = !isNullOrUndefined(format.baseCharStyle) ? format.baseCharStyle.name : 'Default Paragraph Font'; this.fontSize = format.fontSize; this.fontFamily = format.fontFamily; this.renderedFontFamilyIn = renderFontFamily; this.bold = format.bold; this.italic = format.italic; this.baselineAlignment = format.baselineAlignment; this.underline = format.underline; this.fontColor = format.fontColor; this.highlightColor = format.highlightColor; this.strikethrough = format.strikethrough; this.bidi = format.bidi; this.bdo = format.bdo; this.boldBidi = format.boldBidi; this.italicBidi = format.italicBidi; this.fontFamilyBidi = format.fontFamilyBidi; this.fontSizeBidi = format.fontSizeBidi; this.allCaps = format.allCaps; this.complexScript = format.complexScript; }; /** * Combines the format. * * @param {WCharacterFormat} format * @private */ SelectionCharacterFormat.prototype.combineFormat = function (format, renderFontFamily) { if (!isNullOrUndefined(this.bold) && this.bold !== format.bold) { this.bold = undefined; } if (!isNullOrUndefined(this.italic) && this.italic !== format.italic) { this.italic = undefined; } if (this.fontSize !== 0 && this.fontSize !== format.fontSize) { this.fontSize = 0; } if (!isNullOrUndefined(this.renderedFontFamily) && this.renderedFontFamily !== renderFontFamily) { this.renderedFontFamilyIn = undefined; } if (!isNullOrUndefined(this.fontFamily) && this.fontFamily !== format.fontFamily) { this.fontFamily = undefined; } if (!isNullOrUndefined(this.highlightColor) && this.highlightColor !== format.highlightColor) { this.highlightColor = undefined; } if (!isNullOrUndefined(this.baselineAlignment) && this.baselineAlignment !== format.baselineAlignment) { this.baselineAlignment = undefined; } if (!isNullOrUndefined(this.fontColor) && (this.fontColor !== format.fontColor)) { this.fontColor = undefined; } if (!isNullOrUndefined(this.underline) && this.underline !== format.underline) { this.underline = undefined; } if (!isNullOrUndefined(this.strikethrough) && this.strikethrough !== format.strikethrough) { this.strikethrough = undefined; } if (!isNullOrUndefined(this.boldBidi) && this.boldBidi !== format.boldBidi) { this.boldBidi = undefined; } if (!isNullOrUndefined(this.italicBidi) && this.italicBidi !== format.italicBidi) { this.italicBidi = undefined; } if (this.fontSizeBidi !== 0 && this.fontSizeBidi !== format.fontSizeBidi) { this.fontSizeBidi = 0; } if (!isNullOrUndefined(this.fontFamilyBidi) && this.fontFamilyBidi !== format.fontFamilyBidi) { this.fontFamilyBidi = undefined; } if (!isNullOrUndefined(this.bidi) && this.bidi !== format.bidi) { this.bidi = undefined; } if (!isNullOrUndefined(this.bdo) && this.bdo !== format.bdo) { this.bdo = undefined; } if (!isNullOrUndefined(this.allCaps) && this.allCaps !== format.allCaps) { this.allCaps = undefined; } if (!isNullOrUndefined(this.complexScript) && this.complexScript !== format.complexScript) { this.complexScript = undefined; } }; /** * @private */ SelectionCharacterFormat.prototype.canRetrieveNextCharacterFormat = function () { if (isNullOrUndefined(this.bold) && isNullOrUndefined(this.italic) && this.fontSize === 0 && isNullOrUndefined(this.fontFamily) && isNullOrUndefined(this.highlightColor) && isNullOrUndefined(this.baselineAlignment) && isNullOrUndefined(this.fontColor) && isNullOrUndefined(this.underline) && isNullOrUndefined(this.strikethrough) && isNullOrUndefined(this.boldBidi) && isNullOrUndefined(this.italicBidi) && this.fontSizeBidi === 0 && isNullOrUndefined(this.fontFamilyBidi) && isNullOrUndefined(this.bdo) && isNullOrUndefined(this.allCaps)) { return false; } return true; }; /** * Clones the format. * * @param {SelectionCharacterFormat} selectionCharacterFormat * @returns {void} * @private */ SelectionCharacterFormat.prototype.cloneFormat = function (selectionCharacterFormat) { this.bold = selectionCharacterFormat.bold; this.italic = selectionCharacterFormat.italic; this.underline = selectionCharacterFormat.underline; this.strikethrough = selectionCharacterFormat.strikethrough; this.baselineAlignment = selectionCharacterFormat.baselineAlignment; this.highlightColor = selectionCharacterFormat.highlightColor; this.fontSize = selectionCharacterFormat.fontSize; this.fontFamily = selectionCharacterFormat.fontFamily; this.fontColor = selectionCharacterFormat.fontColor; this.styleName = selectionCharacterFormat.styleName; this.bidi = selectionCharacterFormat.bidi; this.bdo = selectionCharacterFormat.bdo; this.boldBidi = selectionCharacterFormat.boldBidi; this.italicBidi = selectionCharacterFormat.italicBidi; this.fontSizeBidi = selectionCharacterFormat.fontSizeBidi; this.fontFamilyBidi = selectionCharacterFormat.fontFamilyBidi; this.allCaps = selectionCharacterFormat.allCaps; this.complexScript = selectionCharacterFormat.complexScript; }; /** * Checks whether current format is equal to the source format or not. * * @param {SelectionCharacterFormat} format * @returns boolean * @private */ SelectionCharacterFormat.prototype.isEqualFormat = function (format) { return (this.fontSize === format.fontSize && this.strikethrough === format.strikethrough && this.bold === format.bold && this.fontFamily === format.fontFamily && this.underline === format.underline && this.highlightColor === format.highlightColor && this.italic === format.italic && this.baselineAlignment === format.baselineAlignment && this.fontColor === format.fontColor && this.allCaps === format.allCaps); }; /** * Clears the format. * * @returns {void} * @private */ SelectionCharacterFormat.prototype.clearFormat = function () { this.fontSizeIn = 0; this.boldIn = undefined; this.italicIn = undefined; this.fontFamilyIn = undefined; this.fontColorIn = undefined; this.underlineIn = undefined; this.strikeThroughIn = undefined; this.highlightColorIn = undefined; this.baselineAlignmentIn = undefined; this.styleName = undefined; this.bidi = undefined; this.bdo = undefined; this.boldBidi = undefined; this.italicBidi = undefined; this.fontFamilyBidi = undefined; this.fontSizeBidi = undefined; this.allCapsIn = undefined; this.complexScript = undefined; }; /** * Destroys the maintained resources. * * @returns {void} * @private */ SelectionCharacterFormat.prototype.destroy = function () { this.fontSizeIn = undefined; this.boldIn = undefined; this.italicIn = undefined; this.fontFamilyIn = undefined; this.fontColorIn = undefined; this.underlineIn = undefined; this.strikeThroughIn = undefined; this.baselineAlignmentIn = undefined; this.highlightColorIn = undefined; this.selection = undefined; this.styleName = undefined; this.bidi = undefined; this.bdo = undefined; this.boldBidi = undefined; this.italicBidi = undefined; this.fontFamilyBidi = undefined; this.fontSizeBidi = undefined; this.allCapsIn = undefined; this.complexScript = undefined; }; return SelectionCharacterFormat; }()); export { SelectionCharacterFormat }; /** * Selection Border implementation */ var SelectionBorder = /** @class */ (function () { /** * @param SelectionBorders * @private */ function SelectionBorder(selection, borderType, node) { this.colorIn = undefined; this.lineStyleIn = undefined; this.lineWidthIn = undefined; this.shadowIn = undefined; this.spaceIn = undefined; this.borderType = borderType; this.ownerBase = node; this.selection = selection; } Object.defineProperty(SelectionBorder.prototype, "color", { /** * Gets or sets the color for selected paragraph borders. * * @default undefined * @aspType string */ get: function () { return this.colorIn; }, /** * Sets the color for selected paragraph borders. * * @default undefined * @aspType string */ set: function (value) { if (value === this.colorIn) { return; } this.colorIn = value; this.notifyPropertyChanged("color"); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorder.prototype, "lineStyle", { /** * Gets or sets the lineStyle for selected paragraph borders. * * @default undefined * @aspType LineStyle */ get: function () { return this.lineStyleIn; }, /** * Sets the lineStyle for selected paragraph borders. * * @default undefined * @aspType LineStyle */ set: function (value) { if (value === this.lineStyleIn) { return; } this.lineStyleIn = value; this.notifyPropertyChanged("lineStyle"); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorder.prototype, "lineWidth", { /** * Gets or sets the lineWidth for selected paragraph borders. * * @default undefined * @aspType number */ get: function () { return this.lineWidthIn; }, /** * Sets the lineWidth for selected paragraphs borders. * * @default undefined * @aspType number */ set: function (value) { if (value === this.lineWidthIn) { return; } this.lineWidthIn = value; this.notifyPropertyChanged("lineWidth"); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorder.prototype, "shadow", { /** * Gets or sets the shadow for selected paragraph borders. * * @default undefined * @aspType boolean */ get: function () { return this.shadowIn; }, /** * Sets the shadow for selected paragraphs borders. * * @default undefined * @aspType boolean */ set: function (value) { if (value === this.shadowIn) { return; } this.shadowIn = value; this.notifyPropertyChanged("shadow"); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorder.prototype, "space", { /** * Gets or sets the space for selected paragraphs borders. * * @default undefined * @aspType number */ get: function () { return this.spaceIn; }, /** * Sets the space for selected paragraphs borders. * * @default undefined * @aspType number */ set: function (value) { if (value === this.spaceIn) { return; } this.spaceIn = value; this.notifyPropertyChanged('space'); }, enumerable: true, configurable: true }); /** *Copies the format. * * @param {WBorder} border * @returns {void} * @private */ SelectionBorder.prototype.copyFormat = function (border) { this.color = border.color; this.lineStyle = border.lineStyle; this.lineWidth = border.lineWidth; this.shadow = border.shadow; this.space = border.space; }; /** * Combines the format. * * @param {WBorder} border * @returns {void} * @private */ SelectionBorder.prototype.combineFormat = function (border) { if (!isNullOrUndefined(this.color) && this.color !== border.color) { this.color = undefined; } if (!isNullOrUndefined(this.lineStyle) && this.lineStyle !== border.lineStyle) { this.lineStyle = undefined; } if (!isNullOrUndefined(this.lineWidth) && this.lineWidth !== border.lineWidth) { this.lineWidth = undefined; } if (!isNullOrUndefined(this.shadow) && this.shadow !== border.shadow) { this.shadow = undefined; } if (!isNullOrUndefined(this.space) && this.space !== border.space) { this.space = undefined; } }; SelectionBorder.prototype.getPropertyValue = function (property) { switch (property) { case 'color': return this.color; case 'lineStyle': return this.lineStyle; case 'lineWidth': return this.lineWidth; case 'space': return this.space; case 'shadow': return this.shadow; } return undefined; }; /** * Notifies whenever the property gets changed. * @param {string} propertyName * @returns {void} */ SelectionBorder.prototype.notifyPropertyChanged = function (propertyName) { if (!isNullOrUndefined(this.selection) && !this.selection.isRetrieveFormatting && ((this.selection.owner.isReadOnlyMode && !this.selection.isInlineFormFillMode()) || !this.selection.owner.isDocumentLoaded)) { return; } if (!isNullOrUndefined(this.selection) && !isNullOrUndefined(this.selection.start) && !this.selection.isRetrieveFormatting) { var editor = this.selection.owner.editorModule; var propertyValue = this.getPropertyValue(propertyName); if (!isNullOrUndefined(propertyValue)) { editor.applyParagraphBorders(propertyName, this.borderType, propertyValue); } } }; /** * Destroys the managed resources. * * @returns {void} * @private */ SelectionBorder.prototype.destroy = function () { if (!isNullOrUndefined(this.colorIn)) { this.colorIn = undefined; } if (!isNullOrUndefined(this.lineStyleIn)) { this.lineStyleIn = undefined; } if (!isNullOrUndefined(this.lineWidthIn)) { this.lineWidthIn = undefined; } if (!isNullOrUndefined(this.spaceIn)) { this.spaceIn = undefined; } if (!isNullOrUndefined(this.shadowIn)) { this.shadowIn = undefined; } }; return SelectionBorder; }()); export { SelectionBorder }; /** * Selection Borders implementation */ var SelectionBorders = /** @class */ (function () { /** * @param Object * @private */ function SelectionBorders(selection, node) { this.ownerBase = undefined; this.ownerBase = node; this.selection = selection; this.topIn = new SelectionBorder(this.selection, 'topBorder', this); this.bottomIn = new SelectionBorder(this.selection, 'bottomBorder', this); this.rightIn = new SelectionBorder(this.selection, 'rightBorder', this); this.leftIn = new SelectionBorder(this.selection, 'leftBorder', this); this.horizontalIn = new SelectionBorder(this.selection, 'horizontalBorder', this); this.verticalIn = new SelectionBorder(this.selection, 'verticalBorder', this); } Object.defineProperty(SelectionBorders.prototype, "top", { /** * Gets the top Border for selected paragraphs. * * @default undefined * @aspType SelectionBorder */ get: function () { return this.topIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorders.prototype, "bottom", { /** * Gets the bottom Border for selected paragraphs. * * @default undefined * @aspType SelectionBorder */ get: function () { return this.bottomIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorders.prototype, "left", { /** * Gets the left Border for selected paragraphs. * * @default undefined * @aspType SelectionBorder */ get: function () { return this.leftIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorders.prototype, "right", { /** * Gets the right Border for selected paragraphs. * * @default undefined * @aspType SelectionBorder */ get: function () { return this.rightIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorders.prototype, "horizontal", { /** * Gets the horizontal Border for selected paragraphs. * * @default undefined * @aspType SelectionBorder */ get: function () { return this.horizontalIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionBorders.prototype, "vertical", { /** * Gets the vertical Border for selected paragraphs. * * @default undefined * @aspType SelectionBorder */ get: function () { return this.verticalIn; }, enumerable: true, configurable: true }); /** * Copies the format. * * @param {WBorders} borders * @returns {void} * @private */ SelectionBorders.prototype.copyFormat = function (borders) { this.top.copyFormat(borders.top); this.bottom.copyFormat(borders.bottom); this.left.copyFormat(borders.left); this.right.copyFormat(borders.right); this.horizontal.copyFormat(borders.horizontal); this.vertical.copyFormat(borders.vertical); }; /** * Combines the format. * * @param {WBorders} borders * @private */ SelectionBorders.prototype.combineFormat = function (borders) { this.top.combineFormat(borders.top); this.bottom.combineFormat(borders.bottom); this.left.combineFormat(borders.left); this.right.combineFormat(borders.right); this.vertical.combineFormat(borders.vertical); this.horizontal.combineFormat(borders.horizontal); }; /** * Destroys the managed resources. * * @returns {void} * @private */ SelectionBorders.prototype.destroy = function () { if (!isNullOrUndefined(this.topIn)) { this.topIn.destroy(); this.topIn = undefined; } if (!isNullOrUndefined(this.topIn)) { this.bottomIn.destroy(); this.bottomIn = undefined; } if (!isNullOrUndefined(this.leftIn)) { this.leftIn.destroy(); this.leftIn = undefined; } if (!isNullOrUndefined(this.rightIn)) { this.rightIn.destroy(); this.rightIn = undefined; } if (!isNullOrUndefined(this.horizontalIn)) { this.horizontalIn.destroy(); this.horizontalIn = undefined; } if (!isNullOrUndefined(this.verticalIn)) { this.verticalIn.destroy(); this.verticalIn = undefined; } }; return SelectionBorders; }()); export { SelectionBorders }; /** * Selection paragraph format implementation */ var SelectionParagraphFormat = /** @class */ (function () { /** * @param selection * @param documentHelper * @private */ function SelectionParagraphFormat(selection, documentHelper) { // Declaring the character format properties. this.leftIndentIn = 0; this.rightIndentIn = 0; this.beforeSpacingIn = 0; this.afterSpacingIn = 0; this.spaceAfterAutoIn = undefined; this.spaceBeforeAutoIn = undefined; this.textAlignmentIn = undefined; this.outlineLevelIn = undefined; this.firstLineIndentIn = 0; this.lineSpacingIn = 1; this.lineSpacingTypeIn = undefined; this.bidiIn = undefined; this.keepWithNextIn = undefined; this.keepLinesTogetherIn = undefined; this.widowControlIn = undefined; this.contextualSpacingIn = undefined; this.listLevelNumberIn = -1; this.selection = selection; this.documentHelper = documentHelper; this.bordersIn = new SelectionBorders(this.selection, this); } Object.defineProperty(SelectionParagraphFormat.prototype, "borders", { /** * Gets the borders for selected paragraphs. * * @default undefined * @aspType SelectionBorders */ get: function () { return this.bordersIn; }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "leftIndent", { /** * Gets or Sets the left indent for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.leftIndentIn; }, /** * Sets the left indent for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.leftIndentIn) { return; } this.leftIndentIn = value; this.notifyPropertyChanged('leftIndent'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "rightIndent", { /** * Gets or Sets the right indent for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.rightIndentIn; }, /** * Sets the right indent for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.rightIndentIn) { return; } this.rightIndentIn = value; this.notifyPropertyChanged('rightIndent'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "firstLineIndent", { /** * Gets or Sets the first line indent for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.firstLineIndentIn; }, /** * Sets the first line indent for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.firstLineIndentIn) { return; } this.firstLineIndentIn = value; this.notifyPropertyChanged('firstLineIndent'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "textAlignment", { /** * Gets or Sets the text alignment for selected paragraphs. * * @default undefined */ get: function () { return this.textAlignmentIn; }, /** * Sets the text alignment for selected paragraphs. * * @default undefined */ set: function (value) { if (value === this.textAlignmentIn) { return; } this.textAlignmentIn = value; this.notifyPropertyChanged('textAlignment'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "outlineLevel", { /** * Gets or Sets the outline level for selected paragraphs. * * @default undefined */ get: function () { return this.outlineLevelIn; }, /** * Sets the outline level for selected paragraphs. * * @default undefined */ set: function (value) { if (value === this.outlineLevelIn) { return; } this.outlineLevelIn = value; this.notifyPropertyChanged('outlineLevel'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "afterSpacing", { /** * Sets the after spacing for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.afterSpacingIn; }, /** * Gets or Sets the after spacing for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.afterSpacingIn) { return; } this.afterSpacingIn = value; this.notifyPropertyChanged('afterSpacing'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "beforeSpacing", { /** * Gets or Sets the before spacing for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.beforeSpacingIn; }, /** * Sets the before spacing for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.beforeSpacingIn) { return; } this.beforeSpacingIn = value; this.notifyPropertyChanged('beforeSpacing'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "spaceAfterAuto", { /** * Gets or Sets the space after auto for selected paragraphs. * * @default false * @aspType bool */ get: function () { return this.spaceAfterAutoIn; }, /** * Sets the space after auto for selected paragraphs. * * @aspType bool * @blazorType bool */ set: function (value) { if (value === this.spaceAfterAutoIn) { return; } this.spaceAfterAutoIn = value; this.notifyPropertyChanged('spaceAfterAuto'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "spaceBeforeAuto", { /** * Gets or Sets the space before auto for selected paragraphs. * * @default false * @aspType bool */ get: function () { return this.spaceBeforeAutoIn; }, /** * Sets the space before auto for selected paragraphs. * * @aspType bool * @blazorType bool */ set: function (value) { if (value === this.spaceBeforeAutoIn) { return; } this.spaceBeforeAutoIn = value; this.notifyPropertyChanged('spaceBeforeAuto'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "lineSpacing", { /** * Gets or Sets the line spacing for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.lineSpacingIn; }, /** * Sets the line spacing for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.lineSpacingIn) { return; } this.lineSpacingIn = value; this.notifyPropertyChanged('lineSpacing'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "lineSpacingType", { /** * Gets or Sets the line spacing type for selected paragraphs. * * @default undefined */ get: function () { return this.lineSpacingTypeIn; }, /** * Gets or Sets the line spacing type for selected paragraphs. * * @default undefined */ set: function (value) { if (value === this.lineSpacingTypeIn) { return; } this.lineSpacingTypeIn = value; this.notifyPropertyChanged('lineSpacingType'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "listLevelNumber", { /** * Sets the list level number for selected paragraphs. * * @default undefined * @aspType int */ get: function () { return this.listLevelNumberIn; }, /** * Gets or Sets the list level number for selected paragraphs. * * @default undefined * @aspType int */ set: function (value) { if (value === this.listLevelNumberIn) { return; } this.listLevelNumberIn = value; this.notifyPropertyChanged('listLevelNumber'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "bidi", { /** * Gets or Sets the bidirectional property for selected paragraphs * * @aspType bool */ get: function () { return this.bidiIn; }, /** * Sets the bidirectional property for selected paragraphs * * @aspType bool */ set: function (value) { this.bidiIn = value; this.notifyPropertyChanged('bidi'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "keepWithNext", { /** * Gets or sets a value indicating whether the specified paragraph remains on the same page as the paragraph that follows it while paginating the document. * * @default false * @aspType bool * @returns {boolean} - `true` if the specified paragraph remains on the same page as the paragraph that follows it; otherwise, `false`. */ get: function () { return this.keepWithNextIn; }, /** * Sets a value indicating whether the specified paragraph remains on the same page as the paragraph that follows it while paginating the document. * * @aspType bool * @blazorType bool */ set: function (value) { this.keepWithNextIn = value; this.notifyPropertyChanged('keepWithNext'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "keepLinesTogether", { /** * Gets or sets a value indicating whether all lines in the specified paragraphs remain on the same page while paginating the document. * * @default false * @aspType bool * @returns {boolean} - `true` if all lines in the specified paragraphs remain on the same page; otherwise, `false`. */ get: function () { return this.keepLinesTogetherIn; }, /** * Sets a value indicating whether all lines in the specified paragraphs remain on the same page while paginating the document. * * @aspType bool * @blazorType bool */ set: function (value) { this.keepLinesTogetherIn = value; this.notifyPropertyChanged('keepLinesTogether'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "widowControl", { /** * Gets or sets a value indicating whether the first and last lines of the paragraph are to remain on the same page as the rest of the paragraph when paginating the document. * * @default true * @aspType bool * @returns {boolean} - `true` if the first and last lines of the paragraph are to remain on the same page; otherwise, `false`. */ get: function () { return this.widowControlIn; }, /** * Sets a value indicating whether the first and last lines of the paragraph are to remain on the same page as the rest of the paragraph when paginating the document. * * @default true * @aspType bool */ set: function (value) { this.widowControlIn = value; this.notifyPropertyChanged('widowControl'); }, enumerable: true, configurable: true }); Object.defineProperty(SelectionParagraphFormat.prototype, "contextualSpacing", { /** * Gets or sets a value indicating whether to add space between the paragraphs of same style. * * @aspType bool */ get: function () { return this.contextualSpacingIn; }, /** * Sets a value indicating whether to add space between the paragraphs of same style. * * @aspType bool */ set: function (value) { this.contextualSpacingIn = value; this.notifyPropertyChanged('contextualSpacing'); }, enumerable: true, configurable: true }); SelectionParagraphFormat.prototype.validateLineSpacing = function () { if (this.lineSpacingType !== 'Multiple' && this.lineSpacingIn < 12) { return true; } return false; }; Object.defineProperty(SelectionParagraphFormat.prototype, "listText", { /** * Gets the list text for selected paragraphs. * * @aspType string */ get: function () { var listFormat = undefined; var list = this.documentHelper.getListById(this.listId); if (list instanceof WList && this.listLevelNumberIn > -1 && this.listLevelNumberIn < 9) { var listLevel = list.getListLevel(this.listLevelNumber); if (listLevel instanceof WListLevel) { if (listLevel.listLevelPattern === 'Bullet') { listFormat = listLevel.numberFormat; } else { listFormat = listLevel.numberFormat; for (var i = 0; i < 9; i++) { var levelPattern = '%' + (i + 1); if (listFormat.indexOf(levelPattern) > -1) { var level = i === this.listLevelNumberIn ? listLevel : list.getListLevel(i); var listTextElement = this.selection.getListTextElementBox(this.selection.start.paragraph); var listText = listTextElement ? listTextElement.text : ''; listFormat = listText; } } } } } return listFormat; }, enumerable: true, configurable: true }); SelectionParagraphFormat.prototype.getPropertyValue = function (property) { switch (property) { case 'leftIndent': return this.leftIndent; case 'rightIndent': return this.rightIndent; case 'firstLineIndent': return this.firstLineIndent; case 'beforeSpacing': return this.beforeSpacing; case 'afterSpacing': return this.afterSpacing; case 'spaceAfterAuto': return this.spaceAfterAuto; case 'spaceBeforeAuto': return this.spaceBeforeAuto; case 'textAlignment': return this.textAlignment; case 'lineSpacing': return this.lineSpacing; case 'lineSpacingType': return this.lineSpacingType; case 'bidi': return this.bidi; case 'contextualSpacing': return this.contextualSpacing; case 'keepWithNext': return this.keepWithNext; case 'keepLinesTogether': return this.keepLinesTogether; case 'widowControl': return this.widowControl; case 'outlineLevel': return this.outlineLevel; default: return undefined; } }; /** * Notifies whenever the property gets changed. * * @param {string} propertyName */ SelectionParagraphFormat.prototype.notifyPropertyChanged = function (propertyName) { if (!isNullOrUndefined(this.selection) && !this.selection.isRetrieveFormatting && ((this.selection.owner.isReadOnlyMode && !this.selection.isInlineFormFillMode()) || !this.selection.owner.isDocumentLoaded)) { return; } if (!isNullOrUndefined(this.selection) && !isNullOrUndefined(this.selection.start) && !this.selection.isRetrieveFormatting) { var editorModule = this.selection.owner.editorModule; if (propertyName === 'lineSpacing' || propertyName === 'lineSpacingType') { var editorHistory = this.selection.owner.editorHistoryModule; if (!(editorHistory && (editorHi