-
Notifications
You must be signed in to change notification settings - Fork 167
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
[FHL] Part 2 - Image Selection - Image Selection Plugin #1286
Conversation
*/ | ||
export default class ImageSelection implements EditorPlugin { | ||
private editor: IEditor | null = null; | ||
private image: HTMLImageElement | null = 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.
do we need to cache the image here? Can we get it (its id) using getSelectionRangeEx()?
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 saving the image, I'm saving only the id.
@@ -21,3 +30,38 @@ export const selectImage: SelectImage = (image: HTMLImageElement | null) => { | |||
|
|||
return null; | |||
}; | |||
|
|||
const select = (core: EditorCore, image: HTMLImageElement) => { |
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.
Is there any duplicated code with table selection? we can move them out into dom package under style folder
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 added this duplicated code as function under utils folder of the core, it add styles, but only for selection and it uses editor core object.
|
||
el.id = idPrefix + cont; | ||
} else { | ||
const elements = doc.querySelectorAll(`#${el.id}`); |
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 know this is moved from table selection, but let's refine it. It may not be a good idea to call the function recursively. So we can do:
if (has id) {
if (id is not unique) {
remove id;
}
}
if (not have id) {
apply an id
}
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 fixed and changed the name to addUniqueId, since the function is responsible to add the id and not only ensure that is unique.
….com/microsoft/roosterjs into fhl/juliaroldi/imageSelection-plugin
Add Image Selection Plugin, this plugin is responsible for detect if a click was made above an image. If an image is selected, the selecImage core api will be triggered and will add border to the selected image.