-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop editing when content changed #2931
Conversation
@@ -279,6 +283,11 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin { | |||
} | |||
} | |||
|
|||
private beforeSetContentHandler(editor: IEditor, newContent: string) { | |||
newContent.replace(IMAGE_EDIT_DATASET, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this can work since you didn't use the return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of changing the source HTML, I prefer to do it in DOM tree, when handling ContentChangedEvent and check change source is setContent
@@ -279,6 +283,11 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin { | |||
} | |||
} | |||
|
|||
private beforeSetContentHandler(editor: IEditor, newContent: string) { | |||
newContent.replace(IMAGE_EDIT_DATASET, ''); | |||
editor?.setEditorStyle(IMAGE_EDIT_CLASS_CARET, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"beforeSetContent" is a legacy event from v8. Since there is no API "setContent" in v9, I prefer not use this event. Can we do this in ContentChangedEvent? We just need to make sure do not reset cursor style if images is still selected.
Actually we should do that in SelectionPlugin since this problem can still exist if ImageEditPlugin is not added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just testing in OWA right now and remove the dataset in new content worked, but the remove caret styled persisted, I'm testing using ContentChangedEvent right now. I think we should remove the caret style in ImageEdit, since we add this style when we add the image edit wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the style set from core API setDOMSelection?
roosterjs/packages/roosterjs-content-model-core/lib/coreApi/setDOMSelection/setDOMSelection.ts
Line 61 in 11c9e3e
core.api.setEditorStyle( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add the style here
editor.setEditorStyle(IMAGE_EDIT_CLASS_CARET, caret-color: transparent;
);
…ft/roosterjs into u/juliaroldi/undo-images
Before setting new content into the editor, check if it has the
'data-is-editing="true"'
dataset and remove it. Also stop editing the image when the content changed.