跳到主要内容

GetSelectedText

Returns the selected text from the document.

Syntax

expression.GetSelectedText(prop, prop.NewLine, prop.NewLineParagraph, prop.Numbering, prop.Math, prop.TableCellSeparator, prop.TableRowSeparator, prop.ParaSeparator, prop.TabSymbol, prop.NewLineSeparator);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
propRequiredobjectThe resulting string display properties.
prop.NewLineRequiredbooleanDefines if the resulting string will include line boundaries or not (they will be replaced with '\r').
prop.NewLineParagraphRequiredbooleanDefines if the resulting string will include paragraph line boundaries or not.
prop.NumberingRequiredbooleanDefines if the resulting string will include numbering or not.
prop.MathRequiredbooleanDefines if the resulting string will include mathematical expressions or not.
prop.TableCellSeparatorRequiredstringDefines how the table cell separator will be specified in the resulting string.
prop.TableRowSeparatorRequiredstringDefines how the table row separator will be specified in the resulting string.
prop.ParaSeparatorRequiredstringDefines how the paragraph separator will be specified in the resulting string.
prop.TabSymbolRequiredstringDefines how the tab will be specified in the resulting string.
prop.NewLineSeparatorRequiredstringDefines how the line separator will be specified in the resulting string (this property has the priority over NewLine).

Returns

string

Example

function CorrectText () {
switch (window.Asc.plugin.info.editorType) {
case 'word':
case 'slide': {
window.Asc.plugin.executeMethod ("GetSelectedText", [{"Numbering": false, "Math": false, "TableCellSeparator": '\n', "ParaSeparator": '\n', "TabSymbol": String.fromCharCode(9)}], function (data) {
sText = data;
ExecTypograf (sText);
});
break;
}
case 'cell': {
window.Asc.plugin.executeMethod ("GetSelectedText", [{"Numbering": false, "Math": false, "TableCellSeparator": '\n', "ParaSeparator": '\n', "TabSymbol": String.fromCharCode(9)}], function (data) {
if (data == '') {
sText = sText.replace (/\t/g, '\n');
ExecTypograf (sText);
}
else {
sText = data;
ExecTypograf (sText);
}
});
break;
}
}
}