-
Notifications
You must be signed in to change notification settings - Fork 5
sp webpart base.iwebpartpropertiesmetadata
Home > @microsoft/sp-webpart-base > IWebPartPropertiesMetadata
This structure is used to define metadata for web part properties as a map of string to IWebPartPropertyMetadata
Signature:
interface IWebPartPropertiesMetadata
The key should be a JSON path to the property in web part properties. The JSON path supports the following operators:
-
Dot
.
for selecting object members, for exampleperson.name
-
Brackets
[]
for selecting array items, for exampleperson.photoURLs[0]
-
Bracketed asterisk
[*]
for array elements wildcard, for exampleperson.websites[*]
.
You can make combinations of these operators, for example person.websites[*].url
Important Note: Only one wildcard per path is supported.
Example: Let's assume we have a web part with properties that have the following schema:
{
title: string;
person: {
name: string;
bio: string;
photoURLs: string[];
websites: { title: string; url: string; }[]
}
}
We can define the metadata for the desired properties as following:
{
'person.bio': { isRichContent: true },
'person.photoURLs[*]': { isImageSource: true },
'person.websites[*].url': { isLink: true }
}
This will make SharePoint servers aware of the content of your properties and run services such as search indexing, link fix-up, etc on the data. In case any of the values needs to update by these services, e.g link fix-up, the web part property bag is automatically updated.