Word.ContentControlOptions interface
Especifica las opciones que definen qué controles de contenido se devuelven.
Comentarios
[ Conjunto de API: WordApi 1.5 ]
Ejemplos
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-checkbox-content-control.yaml
// Toggles the isChecked property of the first checkbox content control found in the selection.
await Word.run(async (context) => {
const selectedRange: Word.Range = context.document.getSelection();
let selectedContentControl = selectedRange
.getContentControls({
types: [Word.ContentControlType.checkBox]
})
.getFirstOrNullObject();
selectedContentControl.load("id,checkboxContentControl/isChecked");
await context.sync();
if (selectedContentControl.isNullObject) {
const parentContentControl: Word.ContentControl = selectedRange.parentContentControl;
parentContentControl.load("id,type,checkboxContentControl/isChecked");
await context.sync();
if (parentContentControl.isNullObject || parentContentControl.type !== Word.ContentControlType.checkBox) {
console.warn("No checkbox content control is currently selected.");
return;
} else {
selectedContentControl = parentContentControl;
}
}
const isCheckedBefore = selectedContentControl.checkboxContentControl.isChecked;
console.log("isChecked state before:", `id: ${selectedContentControl.id} ... isChecked: ${isCheckedBefore}`);
selectedContentControl.checkboxContentControl.isChecked = !isCheckedBefore;
selectedContentControl.load("id,checkboxContentControl/isChecked");
await context.sync();
console.log(
"isChecked state after:",
`id: ${selectedContentControl.id} ... isChecked: ${selectedContentControl.checkboxContentControl.isChecked}`
);
});
Propiedades
types | Una matriz de tipos de control de contenido, item debe ser "RichText", "PlainText", "CheckBox", "DropDownList" o "ComboBox". |
Detalles de las propiedades
types
Una matriz de tipos de control de contenido, item debe ser "RichText", "PlainText", "CheckBox", "DropDownList" o "ComboBox".
types: Word.ContentControlType[];
Valor de propiedad
Comentarios
[ Conjunto de API: WordApi 1.5 ]
Nota: Se agregó compatibilidad con "PlainText" en WordApi 1.5. Se agregó compatibilidad con "CheckBox" en WordApi 1.7. La compatibilidad con "DropDownList" y "ComboBox" se agregó en WordApi 1.9.