import { override } from '@microsoft/decorators' ; import { Log } from '@microsoft/sp-core-library' ; import * as pnp from 'sp-pnp-js' ; import { BaseApplicationCustomizer , PlaceholderName , PlaceholderContent } from '@microsoft/sp-application-base' ; import { PlaceholderItems , IPlaceholderItem } from './PlaceholderItems' ; import * as strings from 'PlaceholdersExtensionApplicationCustomizerStrings' ; const LOG_SOURCE = 'PlaceholdersExtensionApplicationCustomizer' ; /**
 * If your command set uses the ClientSideComponentProperties JSON input,
 * it will be deserialized into the BaseExtension.properties object.
 * You can define an interface to describe it.
 */ export interface IPlaceholdersExtensionApplicationCustomizerProperties { } /** A Custom Action which can be run during execution of a Client Side Application */ export default class PlaceholdersExtensionApplicationCustomizer extends BaseApplicationCustomizer < IPlaceholdersExtensionApplicationCustomizerProperties > { @ override public onInit ( ) { Log . info ( LOG_SOURCE , `Initialized ${ strings . Title }` ) ; pnp . setup ( { spfxContext : this . context } ) ; try { let pagePlaceHolders = this . context . placeholderProvider . placeholderNames ; PlaceholderItems . GetItems ( this . context . pageContext . web . id . toString ( ) ) . then ( ( data ) => { data . forEach ( ( element ) => { let index = pagePlaceHolders . indexOf ( PlaceholderName [ element . Title ] ) ; if ( index !== - 1 ) { let currentPlaceholder = this . context . placeholderProvider . tryCreateContent ( PlaceholderName [ element . Title ] ) ; currentPlaceholder . domElement . innerHTML = element . SPFxContent ; } } ) ; } ) ; } finally { } return Promise . resolve < void > ( ) ; } }