-
Notifications
You must be signed in to change notification settings - Fork 841
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
fix: Markdown editor unregister tooltip plugin #4383
Conversation
Issue number 4239 Ability to unregister the tooltip plugin added Updated the editor example doc to show how to use it
💚 CLA has been signed |
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Hi @K-Kumar-01, thanks for contributing to EUI! Can you please sign the Contributor agreement using the email associated with your GitHub account? |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4383/ |
In the Title field, I have put my name for now, as I didn't know what to put there. |
Thanks for the PR! I think we need to broaden the change to account for other (future) plugins, and not be specific to the tooltip UI. If you look at src/components/markdown_editor/plugins/markdown_default_plugins.tsx there are two existing functions providing plugin arrays: @timroes this would be a breaking change, which is okay, but I think we could get by with a deprecation here by adding a flag to the return uiPlugins array which the editor could check for - if it's missing, it could continue injecting the tooltip button. Thoughts?
|
@chandlerprall |
@timroes |
A lot of us are now on holiday through the end of the year, and those remaining will start taking time this week. Since Tim's not here, let's go with my proposed setup to avoid a breaking change and see how that feels. 😁 |
@chandlerprall
Can you please explain what the above sentence means. I am unable to understand what we have to do here. |
Sure thing! Right now, EuiMarkdownEditor receives an array of UI plugins https://github.com/elastic/eui/blob/master/src/components/markdown_editor/markdown_editor.tsx#L158 It then mixes that array with the internally-defined tooltip plugin https://github.com/elastic/eui/blob/master/src/components/markdown_editor/markdown_editor.tsx#L179 This prevents an application from removing the tooltip's toolbar UI, even if the tooltip processing has been disabled. The
Let me know if that's still not clear! |
@chandlerprall
Still not able to comprehend this part |
The part that's confusing here is to avoid making this a backwards-compatible change. For example, right now if I provide my own uiPlugins array the component also injects Something like,
This allows existing implementations to continue working, while allowing new implementations to call |
@chandlerprall I unfortunately also had a couple of issues understanding the desired solution, so let me make sure that I understand it: I am not really seeing how the proposed solution would prevent a breaking change? In the code you outlined above when a user passes in a custom array to E.g. a user had the following code: <EuiMarkdownEditor uiPlugins={[myFancyEmojiPlugin]} /> Before that they would get the fancy emoji plugin AND the the tooltip plugin, after that change they would only get the emoji plugin? I am sorry for all the clarification, but could you potentially outline the consuming code, that you want to prevent breaking by that solution? (Btw I am not against a breaking change at all, just trying to understand the solution.) |
Other way around, it'll detect |
Meaning, if youa ctually want to get rid of it, you'll need to do something like the following? const plugins = getDefaultEuiMarkdownUiPlugins();
plugins.splice(0, plugins.length);
plugins.push(yourPlugin);
<EuiMarkdownEditor uiPlugins={plugins} /> |
Correct. We'd mark the old functionality (injecting the tooltip) as deprecated and console.warn when it happens, but gives us room to make the change without being breaking. |
@chandlerprall @timroes |
@chandlerprall
VS Code is showing some quick fixed though it changes the typescript lib file |
Let's tell TS to ignore the problem both where you set it on the array and then check for it later (which I assume will give the same error)
|
Added the ability to unregsiter inbuilt UI plugins Addresses issue 4239 Signed-off-by: k-kumar-01 <[email protected]>
Signed-off-by: k-kumar-01 <[email protected]>
@chandlerprall |
Tested, and it is working as expected. Thanks! Couple of items left:
|
Default UI Plugins initialized Warning added on injecting tooltip plugin Signed-off-by: k-kumar-01 <[email protected]>
@chandlerprall
I have added a PR making the above changes. Let me know if there are any changes required. :) |
Changes look good, I pushed an entry CHANGELOG.md & an update to the markdown plugin example page to use the new method. Will merge this after CI passes - jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4383/ |
looks like a flaky test run, jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4383/ |
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.
Sorry for the delay in merging @K-Kumar-01 , everything looks good; thanks for making these changes!
Issue number #4239
Ability to unregister the tooltip plugin added
Updated the editor example doc (mardowm_editor_example.js) to show how to use it
Summary
Provide a detailed summary of your PR. Explain how you arrived at your solution. If it includes changes to UI elements include a screenshot or gif.
Checklist
- [ ] Props have proper autodocsAddedUpdated documentation- [ ] Checked Code Sandbox works for the any docs examples- [ ] Added or updated jest tests- [ ] Checked for accessibility including keyboard-only and screenreader modes