From c07624ccf3960168ad9f68d38ecb27638b48f8a8 Mon Sep 17 00:00:00 2001 From: Haowen Chen Date: Wed, 16 Nov 2022 13:30:23 +0800 Subject: [PATCH] Disable the logic in ImageEdit plugin to set image editing when users click images (#1405) * Update * Update * update Co-authored-by: Jiuqing Song --- .../lib/plugins/ImageEdit/ImageEdit.ts | 6 ++---- .../lib/interface/ImageEditOptions.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts b/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts index 0eadb6571f9..9d2e88e2d99 100644 --- a/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts +++ b/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts @@ -63,6 +63,7 @@ const DefaultOptions: Required = { disableCrop: false, disableRotate: false, disableSideResize: false, + onSelectState: ImageEditOperation.ResizeAndRotate, }; /** @@ -185,10 +186,7 @@ export default class ImageEdit implements EditorPlugin { e.selectionRangeEx && e.selectionRangeEx.type === SelectionRangeTypes.ImageSelection ) { - this.setEditingImage( - e.selectionRangeEx.image, - ImageEditOperation.ResizeAndRotate - ); + this.setEditingImage(e.selectionRangeEx.image, this.options.onSelectState); } break; case PluginEventType.MouseDown: diff --git a/packages/roosterjs-editor-types/lib/interface/ImageEditOptions.ts b/packages/roosterjs-editor-types/lib/interface/ImageEditOptions.ts index 756c8c10300..bc1dbb037ec 100644 --- a/packages/roosterjs-editor-types/lib/interface/ImageEditOptions.ts +++ b/packages/roosterjs-editor-types/lib/interface/ImageEditOptions.ts @@ -1,4 +1,6 @@ import ModeIndependentColor from './ModeIndependentColor'; +import { ImageEditOperation } from '../enum/ImageEditOperation'; +import type { CompatibleImageEditOperation } from '../compatibleEnum/ImageEditOperation'; /** * Options for ImageEdit plugin @@ -63,4 +65,10 @@ export default interface ImageEditOptions { * Whether image crop is disabled. @default false */ disableCrop?: boolean; + + /** + * Which operations will be executed when image is selected + * @default ImageEditOperation.ResizeAndRotate + */ + onSelectState?: ImageEditOperation | CompatibleImageEditOperation; }