diff --git a/samples/react-image-editor/src/webparts/reactImageEditor/components/ReactImageEditor.tsx b/samples/react-image-editor/src/webparts/reactImageEditor/components/ReactImageEditor.tsx new file mode 100644 index 000000000..4558082cd --- /dev/null +++ b/samples/react-image-editor/src/webparts/reactImageEditor/components/ReactImageEditor.tsx @@ -0,0 +1,81 @@ +import * as React from 'react'; +import styles from './ReactImageEditor.module.scss'; + +import { WebPartTitle } from "@pnp/spfx-controls-react/lib/WebPartTitle"; +import { DisplayMode } from '@microsoft/sp-core-library'; +import { Placeholder } from "@pnp/spfx-controls-react/lib/Placeholder"; +import { WebPartContext } from '@microsoft/sp-webpart-base'; +import { FilePicker, IFilePickerResult } from '@pnp/spfx-controls-react/lib/FilePicker'; + +import { ImageManipulation, IImageManipulationSettings } from 'react-image-manipulation-spfx' + + +export interface IReactImageEditorProps extends IReactImageEditorBaseProps { + displayMode: DisplayMode; + context: WebPartContext; + + updateTitleProperty: (value: string) => void; + updateUrlProperty: (value: string) => void; + updateManipulationSettingsProperty: (value: IImageManipulationSettings[]) => void; +} +export interface IReactImageEditorBaseProps { + showTitle: boolean; + title: string; + url?: string + settings?: IImageManipulationSettings[]; + +} +export interface IReactImageEditorState { + filepickerOpen: boolean +} + +export default class ReactImageEditor extends React.Component { + constructor(props: IReactImageEditorProps) { + super(props); + this.state = { + filepickerOpen: true + } + } + public render(): React.ReactElement { + const { url, settings } = this.props; + const isConfigured = url && url.length > 0; + const isFilePickerOpen = this.state.filepickerOpen + return ( + +
+ + {isConfigured ? () : + ()} + {isFilePickerOpen} + { this.props.updateUrlProperty(filePickerResult.fileAbsoluteUrl) }} + onCancel={() => { this.props.updateUrlProperty('') }} + onChanged={(filePickerResult: IFilePickerResult) => { this.props.updateUrlProperty(filePickerResult.fileAbsoluteUrl) }} + context={this.props.context} + /> +
+ ); + } + + private _onConfigure = () => { + // Context of the web part + this.props.context.propertyPane.open(); + } +}