PowerPoint.SensitivityLabel class
Nota
Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.
Representa la etiqueta de confidencialidad de la presentación.
- Extends
Propiedades
| context | El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office. |
Métodos
| get |
Obtiene la información de etiqueta actual que existe en la presentación para el usuario. Si no hay ninguna etiqueta de confidencialidad en la presentación actual, se devuelve un objeto con una |
| toJSON() | Reemplaza el método JavaScript |
| try |
Intenta actualizar a la etiqueta de confidencialidad proporcionada en la presentación para el usuario. Para las etiquetas habilitadas para ABAC, pase las selecciones de atributo deseadas a través de |
Detalles de las propiedades
context
Nota
Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.
El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office.
context: RequestContext;
Valor de propiedad
Detalles del método
getCurrentOrNullObject()
Nota
Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.
Obtiene la información de etiqueta actual que existe en la presentación para el usuario. Si no hay ninguna etiqueta de confidencialidad en la presentación actual, se devuelve un objeto con una isNullObject propiedad establecida true . Para obtener más información, vea los métodos y propiedades *OrNullObject.
getCurrentOrNullObject(): PowerPoint.SensitivityLabelDetails;
Devoluciones
El objeto actual SensitivityLabelDetails .
Comentarios
Conjunto de API: PowerPointApi BETA (SOLO VERSIÓN PRELIMINAR)
Ejemplos
// 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) => {
// Get the sensitivity label currently applied to the presentation.
const presentation: PowerPoint.Presentation = context.presentation;
const presentationLabel: PowerPoint.SensitivityLabel = presentation.sensitivityLabel;
const currentLabel: PowerPoint.SensitivityLabelDetails = presentationLabel.getCurrentOrNullObject();
// Load the properties of the label currently applied to the presentation.
currentLabel.load(
"color,id,isAbacAttributesRequired,isAbacEnabled,isEnabled,name,order,protectionType,siteId,tooltip"
);
await context.sync();
if (currentLabel.isNullObject) {
console.log("The presentation doesn't have a sensitivity label.");
return;
}
// Get ABAC values when enabled for the label.
let abacAttributeValues: PowerPoint.SensitivityLabelAbacAttributeValue[] = [];
if (currentLabel.isAbacEnabled) {
currentLabel.load("abacAttributeValues");
await context.sync();
abacAttributeValues = currentLabel.abacAttributeValues;
}
// Display the loaded properties of the current label.
const attributeValues = abacAttributeValues.length
? abacAttributeValues
.map(
(attributeValue: PowerPoint.SensitivityLabelAbacAttributeValue) =>
`${attributeValue.displayName} (ID: ${attributeValue.id}, order: ${attributeValue.displayOrder}, active: ${attributeValue.isActive ? "Yes" : "No"})`
)
.join(", ")
: "None";
let protectionDescription: string;
switch (currentLabel.protectionType) {
case PowerPoint.SensitivityLabelProtectionType.adminDefined:
protectionDescription = "Defined by an administrator";
break;
case PowerPoint.SensitivityLabelProtectionType.userDefined:
protectionDescription = "Defined by the user";
break;
case PowerPoint.SensitivityLabelProtectionType.noProtection:
protectionDescription = "No protection";
break;
default:
protectionDescription = `Unknown (${currentLabel.protectionType})`;
break;
}
console.log(
`Current presentation sensitivity label:\n\n${currentLabel.name}\n` +
` ID: ${currentLabel.id}\n` +
` Site ID: ${currentLabel.siteId}\n` +
` Tooltip: ${currentLabel.tooltip}\n` +
` Color: ${currentLabel.color}\n` +
` Enabled: ${currentLabel.isEnabled ? "Yes" : "No"}\n` +
` Display order: ${currentLabel.order}\n` +
` ABAC enabled: ${currentLabel.isAbacEnabled ? "Yes" : "No"}\n` +
` ABAC attributes required: ${currentLabel.isAbacAttributesRequired ? "Yes" : "No"}\n` +
` ABAC attribute values: ${attributeValues}\n` +
` Protection type: ${protectionDescription}`
);
});
toJSON()
Nota
Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.
Reemplaza el método JavaScript toJSON() para proporcionar una salida más útil cuando se pasa un objeto API a JSON.stringify(). (JSON.stringify, a su vez, llama al toJSON método del objeto que se le pasa). Mientras que el objeto original PowerPoint.SensitivityLabel es un objeto API, el toJSON método devuelve un objeto JavaScript simple (escrito como PowerPoint.Interfaces.SensitivityLabelData) que contiene copias superficiales de cualquier propiedad secundaria cargada del objeto original.
toJSON(): {
[key: string]: string;
};
Devoluciones
{ [key: string]: string; }
tryToUpdate(labelId, options)
Nota
Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.
Intenta actualizar a la etiqueta de confidencialidad proporcionada en la presentación para el usuario. Para las etiquetas habilitadas para ABAC, pase las selecciones de atributo deseadas a través de options.abacAttributes.
tryToUpdate(labelId: string, options?: PowerPoint.SensitivityLabelTryUpdateOptions): OfficeExtension.ClientResult<PowerPoint.SensitivityLabelUpdateResult>;
Parámetros
- labelId
-
string
El identificador de la etiqueta que se va a aplicar.
Opcional. Entradas adicionales que influyen en la actualización, como las selecciones de atributos ABAC para etiquetas habilitadas para ABAC.
Devoluciones
El SensitivityLabelUpdateResult objeto.
Comentarios
Conjunto de API: PowerPointApi BETA (SOLO VERSIÓN PRELIMINAR)
Ejemplos
// 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) => {
// Apply the selected sensitivity label to the presentation.
const labelId = (document.getElementById("label-id") as HTMLSelectElement).value;
if (!labelId) {
console.warn("Get the available labels, and then select a label to apply.");
return;
}
const presentation: PowerPoint.Presentation = context.presentation;
const presentationLabel: PowerPoint.SensitivityLabel = presentation.sensitivityLabel;
const updateResult: OfficeExtension.ClientResult<PowerPoint.SensitivityLabelUpdateResult> =
presentationLabel.tryToUpdate(labelId);
await context.sync();
if (updateResult.value.status === PowerPoint.SensitivityLabelUpdateStatus.success) {
console.log("Applied the sensitivity label to the presentation.");
} else {
console.error(`The sensitivity label wasn't applied. Status: ${updateResult.value.status}`);
}
});