PowerPoint.SensitivityLabelsCatalog class
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
提供方法来检查 PowerPoint 中敏感度标签目录的状态,并在启用目录的情况下检索所有可用的敏感度标签。
属性
| context | 与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。 |
| get |
获取 PowerPoint 中敏感度标签的主机功能。 |
| get |
方法
| get |
获取当前用户可用的基于属性 (ABAC) 属性的访问控制。 |
| get |
获取当前用户可用的敏感度标签。 |
| load(options) | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| new |
创建对象的新 |
| toJSON() | 覆盖 JavaScript |
属性详细信息
context
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。
context: RequestContext;
属性值
getLabelingCapabilities
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取 PowerPoint 中敏感度标签的主机功能。
readonly getLabelingCapabilities: PowerPoint.LabelingCapability[];
属性值
注解
getLabelingCapability
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
readonly getLabelingCapability: PowerPoint.LabelingCapability | "NoLicense" | "LabelingDisabled" | "LabelingPolicyNotFound" | "LabelingEnabled" | "AttributeBasedAccessControlEnabled";
属性值
PowerPoint.LabelingCapability | "NoLicense" | "LabelingDisabled" | "LabelingPolicyNotFound" | "LabelingEnabled" | "AttributeBasedAccessControlEnabled"
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/preview-apis/manage-sensitivity-labels.yaml
await PowerPoint.run(async (context) => {
// Check whether sensitivity labeling is available for the current user.
const labelCatalog: PowerPoint.SensitivityLabelsCatalog = context.sensitivityLabelsCatalog;
if (!labelCatalog) {
console.warn("The sensitivity label catalog isn't available.");
return;
}
labelCatalog.load("getLabelingCapability");
await context.sync();
switch (labelCatalog.getLabelingCapability) {
case PowerPoint.LabelingCapability.labelingEnabled:
console.log("Sensitivity labeling is enabled.");
break;
case PowerPoint.LabelingCapability.labelingDisabled:
console.log("Sensitivity labeling is disabled.");
break;
case PowerPoint.LabelingCapability.labelingPolicyNotFound:
console.log("No sensitivity labeling policy was found.");
break;
case PowerPoint.LabelingCapability.noLicense:
console.log("The current user doesn't have a valid sensitivity labeling license.");
break;
default:
console.log(`Unknown labeling capability: ${labelCatalog.getLabelingCapability}`);
break;
}
});
方法详细信息
getAttributes()
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取当前用户可用的基于属性 (ABAC) 属性的访问控制。
getAttributes(): OfficeExtension.ClientResult<PowerPoint.SensitivityLabelAbacAttribute[]>;
返回
注解
API 集:PowerPointApi BETA (仅预览版)
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/preview-apis/manage-sensitivity-labels.yaml
// Get available ABAC attributes and describe the kind of value each attribute accepts.
const container = document.getElementById("abac-attributes");
while (container.firstChild) {
container.removeChild(container.firstChild);
}
await PowerPoint.run(async (context) => {
const labelCatalog: PowerPoint.SensitivityLabelsCatalog = context.sensitivityLabelsCatalog;
if (!labelCatalog) {
console.warn("The sensitivity label catalog isn't available.");
return;
}
labelCatalog.load("getLabelingCapabilities");
await context.sync();
const capabilities: PowerPoint.LabelingCapability[] = labelCatalog.getLabelingCapabilities;
if (capabilities.indexOf(PowerPoint.LabelingCapability.attributeBasedAccessControlEnabled) === -1) {
console.warn("ABAC attributes aren't enabled or available for the current user.");
return;
}
const catalogAttributes: OfficeExtension.ClientResult<PowerPoint.SensitivityLabelAbacAttribute[]> =
labelCatalog.getAttributes();
await context.sync();
if (catalogAttributes.value.length === 0) {
console.log("No ABAC attributes are available in the sensitivity label catalog.");
return;
}
console.log("Available ABAC attributes:");
catalogAttributes.value.forEach((attribute: PowerPoint.SensitivityLabelAbacAttribute) => {
let dataTypeDescription: string;
switch (attribute.dataType) {
case PowerPoint.SensitivityLabelAbacAttributeDataType.booleanValue:
dataTypeDescription = "Boolean";
break;
case PowerPoint.SensitivityLabelAbacAttributeDataType.dateValue:
dataTypeDescription = "Date";
break;
case PowerPoint.SensitivityLabelAbacAttributeDataType.numberValue:
dataTypeDescription = "Number";
break;
case PowerPoint.SensitivityLabelAbacAttributeDataType.stringValue:
dataTypeDescription = "String";
break;
case PowerPoint.SensitivityLabelAbacAttributeDataType.unknown:
dataTypeDescription = "Unknown";
break;
default:
dataTypeDescription = `Unrecognized (${attribute.dataType})`;
break;
}
console.log(`ABAC attribute: ${attribute.displayName}`, {
dataType: attribute.dataType,
dataTypeDescription,
displayOrder: attribute.displayOrder,
isActive: attribute.isActive,
isMultiValued: attribute.isMultiValued,
values: attribute.values.map((attributeValue: PowerPoint.SensitivityLabelAbacAttributeValue) => ({
displayName: attributeValue.displayName,
displayOrder: attributeValue.displayOrder,
id: attributeValue.id,
isActive: attributeValue.isActive
}))
});
});
addAttributeOptions(catalogAttributes.value);
});
getLabels()
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取当前用户可用的敏感度标签。
getLabels(): PowerPoint.SensitivityLabelDetailsCollection;
返回
当前对象。
注解
API 集:PowerPointApi BETA (仅预览版)
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/preview-apis/manage-sensitivity-labels.yaml
await PowerPoint.run(async (context) => {
const labelSelect = document.getElementById("label-id") as HTMLSelectElement;
labelSelect.options.length = 0;
const placeholder = document.createElement("option");
placeholder.textContent = "Select a label";
placeholder.value = "";
labelSelect.add(placeholder);
// Get the sensitivity labels that the organization published for the current user.
const labelCatalog: PowerPoint.SensitivityLabelsCatalog = context.sensitivityLabelsCatalog;
if (!labelCatalog) {
console.warn("The sensitivity label catalog isn't available.");
return;
}
const availableLabels: PowerPoint.SensitivityLabelDetailsCollection = labelCatalog.getLabels();
// Load the properties and sublabels for every label in the catalog.
availableLabels.load(
"items/color,items/id,items/isAbacAttributesRequired,items/isAbacEnabled,items/isEnabled," +
"items/name,items/order,items/protectionType,items/siteId,items/tooltip," +
"items/children/items/id,items/children/items/name,items/children/items/isEnabled"
);
await context.sync();
if (availableLabels.items.length === 0) {
console.log("No sensitivity labels are available for the current user.");
return;
}
// Display the loaded properties for each available label.
console.log("Available sensitivity labels:");
availableLabels.items.forEach((labelDetails: PowerPoint.SensitivityLabelDetails) => {
const childLabels = labelDetails.children && labelDetails.children.items.length
? labelDetails.children.items
.map((childLabel: PowerPoint.SensitivityLabelDetails) => `${childLabel.name} (${childLabel.id})`)
.join(", ")
: "None";
console.log(
`\n${labelDetails.name}\n` +
` ID: ${labelDetails.id}\n` +
` Site ID: ${labelDetails.siteId}\n` +
` Tooltip: ${labelDetails.tooltip}\n` +
` Color: ${labelDetails.color}\n` +
` Enabled: ${labelDetails.isEnabled ? "Yes" : "No"}\n` +
` Display order: ${labelDetails.order}\n` +
` ABAC enabled: ${labelDetails.isAbacEnabled ? "Yes" : "No"}\n` +
` ABAC attributes required: ${labelDetails.isAbacAttributesRequired ? "Yes" : "No"}\n` +
` Sublabels: ${childLabels}\n` +
` Protection type: ${labelDetails.protectionType}`
);
});
addLabelOptions(availableLabels);
});
load(options)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(options?: PowerPoint.Interfaces.SensitivityLabelsCatalogLoadOptions): PowerPoint.SensitivityLabelsCatalog;
参数
为要加载的对象属性提供选项。
返回
load(propertyNames)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNames?: string | string[]): PowerPoint.SensitivityLabelsCatalog;
参数
- propertyNames
-
string | string[]
指定要加载的属性的逗号分隔的字符串或字符串数组。
返回
load(propertyNamesAndPaths)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.SensitivityLabelsCatalog;
参数
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select 是指定要加载的属性的逗号分隔字符串,以及 propertyNamesAndPaths.expand 指定要加载的导航属性的逗号分隔字符串。
返回
newObject(context)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
创建对象的新 PowerPoint.SensitivityLabelsCatalog 实例。
static newObject(context: OfficeExtension.ClientRequestContext): PowerPoint.SensitivityLabelsCatalog;
参数
返回
toJSON()
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 PowerPoint.SensitivityLabelsCatalog 对象是 API 对象, toJSON 但该方法返回一个纯 JavaScript 对象, (类型化为 PowerPoint.Interfaces.SensitivityLabelsCatalogData) ,其中包含从原始对象加载的任何子属性的浅层副本。
toJSON(): PowerPoint.Interfaces.SensitivityLabelsCatalogData;