-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
[FEATURE] - Styling Toolbar #1863
Comments
That's an interesting proposal. This seems like it could fit in with the virtual keyboard, though. The virtual keyboard already has a toolbar (for cut/copy/paste/undo/redo). I could see that being a "second row" toolbar (above or below the current one). And I think I would go with a JSON description of the toolbar, like for the custom keyboard layouts. It could be based on the JSON format for the keyboard layout, since those are effectively keycaps with commands attached. |
(BTW I'm in the middle of making some improvements to the VKB, in particular so it can be used as a "pop-up" keyboard, and not always at the bottom of the screen) |
Cool! Is it possible to show / hide keys based on the position of the cursor? That way the matrix buttons could only show up when relevant. I also think it would be nice to be get an indication of the current selection size / color / variant. If not, I suppose it is hackable. |
Yes, the undo/redo buttons already change their state appropriately. And cut/copy only appear where the selection is not empty. So, the state of the "style" toolbar could definitely change based on the selection or position of the caret. |
I've been reading through the keyboard logic and I think I understand a bit better how I would do this. Basically, each style attribute would be a key, and its various values would be key cap variants. I see where I would conditionally render the keys, and I also think it will be possible to modify their appearance based on the selection style. There are two features I would like to build that I am not sure how to approach: Firstly, I prefer having the variant scrim open on click for color / font size. I know I can make the key call Secondly, it would be nice to have an on-hover preview of style changes. Thoughts? |
I'll have a look, but I think you should be able to control when the scrim gets closed. That said, it would probably make sense to add a new type of panel other than the variant panel (or 'alt-keys' as it's currently called), that would pop-up on click. I can look at that. Tell me more about what you're thinking for the hover preview. Are you thinking about showing the selection with the style applied in a tooltip next to the styling button? Or something else? |
Yes I suppose that’s best. The hover preview would work like fonts in many rich text editors, where the style is temporarily applied to the selection. So the style would be applied on mouse enter, and then reverted on mouse leave. |
@arnog I'm working on this at the moment, and so far I have added methods to Is there a way for me get information from the focused mathfield? As far as I can tell, the regular toolbar is built on selection change, which is fired from within the model. But I think the stylebar should be there before any selection changes take place. |
That's great! You have probably seen and modified I'm in the process of rearchitecting the virtual keyboard so that there is only a shared virtual keyboard. This will simplify the architecture, and will also simplify usage when there are multiple mathfields on the page. It will also take care of this bug, so that Make sure you stay in sync with head. I pushed an update this morning. Also, if you'd like to push WIP updates, that would be fine by me. |
Ahh I was specifically working around the It looks like the remote keyboard passes a public |
OK, turns out it's a bit more complicated than I was hoping. In order to deal with iframes, the keyboard and the mathfield are isolated and the mathfield instance cannot be passed to |
Ah, no matter. I’ve mostly worked on the color and font styling for now (with a fun little color picker), so I haven’t yet looked into the environment manipulation features. Without having looked at the keyboard handlers, I don’t know how the logic for adding row / column work, but I will need to know when to show the buttons, and similarly know when the selection is in a matrix. For the styles, I have added a method on |
Hey @arnog, just a little check in on this after the keyboard changes. I've added a For the colors, I was thinking of adding a Also, in this new keyboard paradigm I'm thinking it should be possible to forward actions of a rich-text-editor toolbar to a math field via the keyboard. This is our use case at Perplex, and it would be nice if our users could control mathfield styles with the header toolbar. Could I for example call If so, it might be nice for the styling toolbar to be an API for integrating with broader toolbars. Last comment, re the onhover preview. I can't tell whether changes made via |
You should be able to apply formatting to a mathfield using Commands executed via |
Awesome @arnog! I wonder if the ink / paper colors should have the same base, with a shift to saturation applied where necessary. If I add an ink color to my palette as a user, I might want the "same" color in the background palette. For the undo, could I write a command to pop one item from the history? It would be incorrect in my view for a "redo" to reapply a temporary style after a |
@WildYellowfin unfortunately calculating the background/ink from a base color is... complicated. You do have to adjust the saturation, but also the lightness, although how much you do depends on the hue because the human eye is more sensitive the lightness of some hues than others, so if you do it mathematically, it will look wrong. Ah, yes, there's a |
BTW, I should add that the colors from
It is very difficult when picking a set of random colors to meet all those criteria. |
A comment here on what has been done:
|
The MathLive menu now provides options to style the selection, including color, variant, and matrix editing. |
I was planning on building this in my project, but since it might be of use to others I wanted to make a proposal here.
Font color, background color, font size, math variant. Also environments (align, gather, cases, matrix...), this would be a good place to add controls as described in #600. Something like this:

This is really for desktop, since the virtual keyboard is great on mobile.
I would approach this by having users supply DOM elements (similar to custom keyboard container) in which I insert an array of controls. These can then be styled as desired (eg. vertical flexbox).
The text was updated successfully, but these errors were encountered: