跳到主要内容

GetSelectedContent

以指定格式返回所选内容。

语法

expression.GetSelectedContent(prop);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
prop必需object返回内容的属性。
prop.type可选"text" | "html""text"返回内容的格式类型(text 或 HTML)。

返回值

string

示例

const prepareShape = function () {
const doc = Api.GetDocument();

const text = 'Text string to select from.';
const paragraph = doc.GetElement(0);
paragraph.AddText(text);

const range = paragraph.GetRange(6, 12);
range.Select();
};

Asc.plugin.callCommand(prepareShape);
Asc.plugin.executeMethod('GetSelectedContent', [], console.log);