diff --git a/samples/react-image-editor/README.md b/samples/react-image-editor/README.md index 0c13c3dab2..f6e4b85a53 100644 --- a/samples/react-image-editor/README.md +++ b/samples/react-image-editor/README.md @@ -66,6 +66,7 @@ References to office-ui-fabric-react version 5.x because of SharePoint 2019 Supp ## Contributors * [Peter Paul Kirschner](https://github.com/petkir) +* [Ishai Sagi] (http://github.com/ishaisagi-hns) Thanks to [celum](https://www.celum.com/) and [cubido](https://www.cubido.at/) to allow to share this code. @@ -73,6 +74,7 @@ Thanks to [celum](https://www.celum.com/) and [cubido](https://www.cubido.at/) t Version|Date|Comments -------|----|-------- +1.1.0.0|Sep 09, 2024|Added properties and accessibility 1.0.0.0|Mar 17, 2021|Initial release ## Minimal Path to Awesome diff --git a/samples/react-image-editor/src/components/ImageManipulation/ImageManipulation.tsx b/samples/react-image-editor/src/components/ImageManipulation/ImageManipulation.tsx index 56093470dc..dd3a35d96b 100644 --- a/samples/react-image-editor/src/components/ImageManipulation/ImageManipulation.tsx +++ b/samples/react-image-editor/src/components/ImageManipulation/ImageManipulation.tsx @@ -59,11 +59,14 @@ export interface IImageManipulationProps { editMode?: (mode: boolean) => void; configSettings: IImageManipulationConfig; displayMode: DisplayMode; + altText: string; } export interface IImageManipulationState { settingPanel: SettingPanelType; redosettings: IImageManipulationSettings[]; + lockAspectCrop: boolean; + lockAspectResize: boolean; } export class ImageManipulation extends React.Component { @@ -81,7 +84,9 @@ export class ImageManipulation extends React.Component { this.applySettings(); @@ -305,7 +311,7 @@ export class ImageManipulation extends React.Component - + Your browser does not support displaying canvas elements. {this.state.settingPanel === SettingPanelType.Crop && (this.getCropGrid())} {this.state.settingPanel === SettingPanelType.Resize && (this.getResizeGrid())} @@ -600,17 +606,20 @@ export class ImageManipulation extends React.Component { - if (isNaN(crop.aspect)) { - this.setCrop(undefined, undefined, undefined, undefined, this.getAspect()); - } else { - this.setCrop(undefined, undefined, undefined, undefined, undefined); - } - + checked={this.state.lockAspectCrop} + onChange={(e, checked) => { + // Toggle the lockAspect state when checkbox is checked/unchecked + this.setState({ lockAspectCrop: checked }, () => { + // Call the setCrop function with appropriate arguments based on the new state + if (this.state.lockAspectCrop) { + this.setCrop(undefined, undefined, undefined, undefined, this.getAspect()); + } else { + this.setCrop(undefined, undefined, undefined, undefined, undefined); + } + }); }} - /> + { - if (isNaN(resize.aspect)) { - this.setResize(undefined, undefined, this.getAspect()); - } else { - this.setResize(undefined, undefined, undefined); - } + this.setState({ lockAspectResize: !this.state.lockAspectResize }, () => { + if (isNaN(resize.aspect)) { + this.setResize(undefined, undefined, this.getAspect()); + } else { + this.setResize(undefined, undefined, undefined); + } + }) + }} diff --git a/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.manifest.json b/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.manifest.json index 768987eae2..fecbedf0e9 100644 --- a/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.manifest.json +++ b/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.manifest.json @@ -12,12 +12,13 @@ "preconfiguredEntries": [{ "groupId": "5c03119e-3074-46fd-976b-c60198311f70", "group": { "default": "Other" }, - "title": { "default": "react-image-editor" }, - "description": { "default": "react-image-editor description" }, + "title": { "default": "Advanced Image Editor" }, + "description": { "default": "Add an image to the page, resize and edit the image." }, "officeFabricIconFontName": "Page", "properties": { - "title": "react-image-editor Sample", - "showTitle":true, + "title": "Advanced Image Editor", + "showTitle":false, + "showEditIcon":false, "settings":[], "url":"" } diff --git a/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.ts b/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.ts index 89971ca2e5..955d14a554 100644 --- a/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.ts +++ b/samples/react-image-editor/src/webparts/reactImageEditor/ReactImageEditorWebPart.ts @@ -4,6 +4,8 @@ import { Version } from '@microsoft/sp-core-library'; import { BaseClientSideWebPart, IPropertyPaneConfiguration, + PropertyPaneLabel, + PropertyPaneTextField, PropertyPaneToggle } from '@microsoft/sp-webpart-base'; @@ -28,6 +30,10 @@ export default class ReactImageEditorWebPart extends BaseClientSideWebPart { this.properties.title = value; }, updateUrlProperty: (value: string) => { @@ -67,9 +73,16 @@ export default class ReactImageEditorWebPart extends BaseClientSideWebPart void; updateUrlProperty: (value: string) => void; updateManipulationSettingsProperty: (value: IImageManipulationSettings[]) => void; + } export interface IReactImageEditorState { @@ -46,14 +49,16 @@ export default class ReactImageEditor extends React.Component - - {(isFilePickerOpen || isConfigured) && Environment.type !== EnvironmentType.Local && + {this.props.showTitle && + + } + {(isFilePickerOpen || (isConfigured && this.props.displayMode === DisplayMode.Edit)) && Environment.type !== EnvironmentType.Local && { this.setState({ isFilePickerOpen: false }, () => this._onUrlChanged(filePickerResult.fileAbsoluteUrl)); }} @@ -65,6 +70,7 @@ export default class ReactImageEditor extends React.Component} {!isConfigured ? () : ( - + )} @@ -95,7 +101,7 @@ export default class ReactImageEditor extends React.Component