Displaying custom tooltipmenu on the empty line


this is follow up to Detect if caret is on an empty line

Idea is to display an “Insert Media” button when the line is empty (keen to medium.com). I can see that this reaction is already implemented in the tooltipmenu demo, but I’m not sure how to

  • display “Insert media” button instead of toolbar
  • display custom toolbar after user click on “Insert media” button. Particularly: should I somehow customize it or make my own basing on ProseMirror API ?

Thank you

You can get the code needed to react to the cursor being on an empty line from the tooltip menu, as you noticed. Showing a widget and having that react to user input can be done with generic browser programming techniques, overlaying some nodes on the editor. There is (apart from the tooltip module) no ProseMirror-specific way to do that.

cool! I just wanted to check if there are any serious roadblocks on the way before throwing away our current WIP editor. Thank you, your support is insane.

I like your idea of showing a small button rather than whole tooltip especially when typing multiple paragraphs. Any idea how to do the same when inserting inline elements?