-
Notifications
You must be signed in to change notification settings - Fork 2k
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
WIP: Add "insert items" menu item to editor #5071
Conversation
.mce-container.mce-menu .mce-container-body .mce-wpcom-insert-menu__menu-item { | ||
margin-left: -6px; | ||
|
||
& svg { |
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.
Could we use classes to target these?
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.
Also, prefixing descendent selector with &
is redundant and can be removed safely.
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 @mtias and @aduth. This is still very much a work-in-progress. I have rearranged the CSS to make better use of classes for specifying the styles, but I'm still pretty troubled by the strange .mce
classes.
I'm new to TinyMCE work and had trouble getting enough specificity to overwrite the TinyMCE-provided styles. Any help to clean this up would be much-appreciated!
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.
Yes, it'd be nice to replace the whole toolbar with our components and scope at some point.
We should feature flag this plugin until it's fully implemented. |
Will do soon @aduth but not yet. I think this is going to involve some bigger changes and I think that I would prefer for now to get a little further along before thinking of merging. In other words, I want to see how far this reaches before I send out twenty different |
@drw158 if you can take a look at this I would appreciate the CSS review. I have diverged from the example in the picture above by turning the color of the menu items blue when hovered instead of changing the background color to blue. This is what the format selector to the immediate right of the control does, so I chose it for consistency. Styling questions
|
072c3ca
to
a660563
Compare
The "add media" dialog appears after clicking on the "add media" icon in the TinyMCE toolbar. Previously, this occurred as a direct result of the `onclick` handler in `editor.addButton()`. Because this meant that adding media was dependent on clicking the button, it prevented being able to do so in other ways, such as is the goal in #5071 This patch moves the code to cause the media dialog to appear into a new command, which the button then calls when it's clicked.
Thanks @drw158 - I will change it back to the plan. The only reason I diverged was because in practice it felt confusing the way it did one thing if you click on the icon and another thing if you click on the chevron. Some of our justification for doing it this was (based on the behavior of other apps) was actually reported incorrectly in the earlier discussions too. |
I'll probably leave this as-is for now because of the TinyMCE wrangling. We should be able to supply the appropriate styling to do what we need visually. |
I'm very open for help here and think it's ugly as-is, but I was really struggling to get a higher specificity than the styles from TinyMCE that were overwriting my changes. |
@drw158 I switched back to the split button, and I am sorry to say that I broke your lovely box-padding fix around the chevron. Would you be willing to take another look at it? |
This may prove to be problematic, but should come up in testing. It's possible users won't even notice that you can click on the chevron to get the dropdown menu. |
Create TinyMCE command for adding media The "add media" dialog appears after clicking on the "add media" icon in the TinyMCE toolbar. Previously, this occurred as a direct result of the `onclick` handler in `editor.addButton()`. Because this meant that adding media was dependent on clicking the button, it prevented being able to do so in other ways, such as is the goal in #5071 This patch moves the code to cause the media dialog to appear into a new command, which the button then calls when it's clicked.
f095f0e
to
506668d
Compare
@drw158 I don't want to rain on your parade, but I noticed that when I hover over the label for one of the items in that dropdown menu, the icon doesn't highlight. The same is true if I hover over the icon, where the label doesn't highlight. |
Np, I just pushed a fix. |
I'm concerned about:
But, I don't think this small of a change really warrants a Horizon test. Can we deploy on wpcalypso first? We can feedback internally. |
061e03b
to
4243e3a
Compare
@drw158 and @aduth I have hidden this behind a config flag, but the code actually still loads on every request. Personally I don't feel much hesitation to do this since I haven't found any bugs or errors the code produces, but if you think it's worth it we can hide it all. Each step towards preventing it from loading at all in the production environment simply requires more and more |
{ | ||
name: 'insert_media_item', | ||
icon: 'add-image', | ||
item: <GridiconButton icon="image-multiple" label={ 'Add Media' } />, |
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.
These labels should be translated?
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.
Did the large icon get fixed? |
I don't see any changes that would indicate that it has been, but I haven't spun up the branch to verify. |
haha, whoops I didn't test it and had assumed you got it @drw158 |
Adds a basic shell for a new split button in TinyMCE, meant to be pluggable to display a variety of menu options to insert embeds/widgets.
This patch changes the behavior of the insert menu dropdown, whereas previously we had a separate add media button and then the insert button, which always opened the drop-down. Now, we have a single button that will add media on a direct click and only open the drop-down when the chevron is clicked.
Add translation to strings
Changing color of caret on hover
Props to @aduth for the suggestions
c1ec490
to
adaa14b
Compare
Fix of #5071 - was missing a config flag check Adds an "insert item" menu bar to the editor toolbar to allow inserting various types of media or embeds into a post, similar to how the insert menus in other mainstream applications (such as Pages, Sketch, etc…) work. This patch removes the contact form button and the media button and combines those into the new insert menu. The insert menu button has two behaviors: a default click on the button inserts a media item; a click on the chevron opens the drop-down menu to select one of many possible items to insert. Props to all who helped review and edit and design this feature: @aduth @drw158 @folletto @mtias @rralian
Part of #5070
Adds an "insert item" menu bar to the editor toolbar to allow inserting various types of media or embeds into a post, similar to how the insert menus in mainstream applications work.
This PR's goal is to add in the empty shell on the editor toolbar which will make it easy to add other modules or embeds.
Testing
Questions
The toolbar button initialization and runtime code is tightly coupled to TinyMCE's API. This is making it hard to abstract the buttons and actions; for example, it's not possible to simply add the existing media plugin into the new dropdown menu. Our options are to refactor the existing TinyMCE plugins or to provide an adapter interface to mock the TinyMCE API and pass through the appropriate calls to the actual TinyMCE. None of this feels like the "right way to do it" so if anyone can offer some wisdom that would help us keep the code clean.As long as the other plugins create a new TinyMCE command, we can use that command in the insert menu without having to rewire anything else.cc: @dan @aduth @drw158 @rodrigoi