prosemirror-mentions icon indicating copy to clipboard operation
prosemirror-mentions copied to clipboard

React element suggestions

Open doublejosh opened this issue 4 years ago • 2 comments

What is required to return a React element for suggestions? I can't get anything to appear. Is this against ProseMirror norms for decorations perhaps?

Why?

  • Avoid DOM creation
  • Stay within React
  • Avoid class names

doublejosh avatar Jul 09 '20 23:07 doublejosh

Partial workaround... Still creates DOM and uses named classes.

const SuggestionList = ({ items }) => (
  <div className="suggestion-item-list">
    {items && items.map(i => 
      <div className="suggestion-item">{i.name}</div>
    )}
  </div>
)

const getSuggestionsHTML = (items, type) => {
  if (type === 'mention') {
    return ReactDOMServer.renderToString(<SuggestionList items={items} />)
  }
}

doublejosh avatar Jul 10 '20 01:07 doublejosh

The dropdown was written without respecting any VDOM abstractions, so this might not be a trivial job. Like you've mentioned ReactDOMServer.renderToString() should do the trick, only drawback being no support for React-style event handlers.

We'd have to fork this project for react support, that implements the dropdown behavior with React.

joelewis avatar Jul 23 '20 12:07 joelewis