-
Notifications
You must be signed in to change notification settings - Fork 58
Added click listener to get current applied format. #30
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
base: master
Are you sure you want to change the base?
Added click listener to get current applied format. #30
Conversation
We already have custom delegate method where we can send custom handle and this method will be decieder for us to check already applied format and we can play with selected and unselected method
- We have content change delegate method and we can now manually call the click event if any content change and we can get the all latest format.
i.e. editor.runJS("document.querySelector('body').click();")
- This will also take care if user click anywhere in DIV.
Andrew-Chen-Wang
left a comment
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.
thanks for this, but this seems a bit jacky and not robust for the future in terms of deprecated methods and method of updating ourselves.
| // You can replace this code with any action you want to perform when a click happens. | ||
| var items = []; | ||
|
|
||
| if (document.queryCommandState('bold')) { |
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.
this is very repetitive. Query command state is also deprecated and may not work if you load in HTML with certain formats already applied
| const allAppliedFormat = items.toString() | ||
| RE.callback(allAppliedFormat) |
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.
this isn't ideal. A parsable list would be better or performing the callback one at a time since you're not getting the formats in the order of encapsulation
Problem: Issue Link
Soluation: We have added the click listener which will send all applied format for current tag.
PFA:
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-08-31.at.16.16.39.mp4
This enhancement is particularly beneficial, as it introduces an event that empowers users to effortlessly retrieve an array of applied formats. By capturing content changes through our delegate method and manually invoking the click event, users gain streamlined access to a comprehensive array of string-based formats that have been applied
Example Code: