-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feat: [Regions] contenteditable
content
#3453
Conversation
src/plugins/regions.ts
Outdated
@@ -1,3 +1,4 @@ | |||
0 |
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.
Nani?
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.
Oh no! That's embarrasing :D
src/plugins/regions.ts
Outdated
if (this.contentEditable && this.content) { | ||
this.content.addEventListener('click', (e) => this.onContentClick(e)) | ||
} | ||
if (this.contentEditable && this.content) { | ||
this.content.addEventListener('blur', (e) => this.onContentBlur(e)) | ||
} |
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.
if (this.contentEditable && this.content) { | |
this.content.addEventListener('click', (e) => this.onContentClick(e)) | |
} | |
if (this.contentEditable && this.content) { | |
this.content.addEventListener('blur', (e) => this.onContentBlur(e)) | |
} | |
if (this.contentEditable && this.content) { | |
this.content.addEventListener('click', (e) => this.onContentClick(e)) | |
this.content.addEventListener('blur', (e) => this.onContentBlur(e)) | |
} |
Looks good to me overall, left a couple of comments. As an alternative to the |
private onContentClick(event: MouseEvent) { | ||
event.stopPropagation() | ||
const contentContainer = event.target as HTMLDivElement | ||
contentContainer.focus() |
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.
Why is this necessary btw? Isn't focusing the default action on click on editable elements?
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.
True, but with the region container having an event listener for clicks, this (focus on text content) does not happen. The event is immediately propagated to its parent. This function is in hopes that we can step in and handle the content property before propagating the event further. In the latest commit, I have made changes to emit the region-clicked
event:
private onContentClick(event: MouseEvent) {
event.stopPropagation()
const contentContainer = event.target as HTMLDivElement
contentContainer.focus()
this.emit('click', event)
}
Thanks for the reviews. I have updated my PR with changes from the main repo along with the suggestions in your notes. One thing that I am still thinking of is the fact that clicking on a text content and clicking away would trigger a |
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.
Thank you!
Short description
Resolves #3404
Implementation details
Added a
contenteditable
property to thecontent
generated by theRegions
plugin. This property isfalse
by default.How to test it
Create a new region and tap/click on the text content of the region.
Screenshots
Checklist