I’m hoping some CSS wizard can point me in the right direction. I’m building a custom outliner which is going well, but I’d really like to add some of the native editor shortcuts back into a normal <$edit-text/> widget - specifically the insert link (ctrl-l). I want to add the functionality without adjusting the look. Unfortunately I think the best we can do is to instead change the look back, and thus I need to figure out the css that gets me there.
Here is a non-enhanced, simplified example that shows basic code and what I want it to look like:
So I need to remove the button, and fix the rest of the spacing. I can hide the button with something like div.tc-editor-toolbar {display:none;} but then the shortcut stops working, so that’s not an option. I saw someone say surrounding something with <template></template> would hide the button but keep it functional but for me the functionality goes away. Any ideas?
Thanks @etardiff, from a visual standpoint, your vertical-align: top; helped with a bullet alignment I was stuck on. And I finally figured out the bit of extra vertical space with li > div.tc-editor-toolbar { margin-top: 0px; } that came with the toolbar. But, with these changes the actual functionality of the ctrl-l doesn’t work anymore, same as where I was stuck before. Experimentally, because the “insert hyperlink” seems to launch at the coordinates of the button, I think the process of hiding the button itself necessarily breaks the functionality. Are you not finding that to be the case for you? Or maybe you’re only using non-popup things like bold where it wouldn’t be an issue?
That is precisely the issue. You can hide the buttons with CSS and the keyboard shortcuts will still work as long as the buttons are still there in the DOM. However, all of the popups use the buttons as anchors for their positioning and therefore will not work.
Edit: I suspect you could create a custom toolbar button that triggers a popup using <$action-popup/> and use CSS to get the correct positioning.
Thanks @Alvaro, I thought that looked promising too, but my understanding of it is that this adds drop down magic to the WHOLE edit-text box, whereas I am trying to add multiple links inline with other text. For example each of these boxes represents a note like “I need to talk to [[John Smith]] about [[Project ABC]] tomorrow”. For each of those links I’m hoping to hit the shortcut and have something like the link drop-down experience to text-insert the link. I haven’t used it though, maybe I’m wrong. I’ll dig deeper here.
Thanks @saqimtiaz. I’ll read up on the <$action-popup>. Ideally I can figure out how to skip the button by more directly calling it. In the real example that edit-text is surrounded by about a dozen <$keyboard> widgets for all sorts of stuff, but I’m pretty sure that mechanism won’t work for inline text replacement. From what I read I’m stuck with logic going inside the <$edit> widget in some way.
Another thing to keep in mind is that the core link dropdown is not able to be positioned at the caret, that is where you are typing, for that you might consider the AutoComplete plugin.
Right, so you need to use the edit-text operations and those can only be triggered from within the $edit-text widget. You should be able to create an invisible toolbar button (CSS visibility:hidden) that is triggered by a keyboard shortcut and then triggers a popup that is also defined within the $edit-text widget. The catch is going to be that it will always show up at a fixed location and not where you are typing in the editor.