question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for blockRenderMap

See original GitHub issue

Just wanted to bring this up for discussion as I started working on new plugin. draft-js has recently added support for passing a custom Map through a blockRenderMap prop but its support in the plugin system is as-yet unresolved.

The main to think about here with regard to the plugin system is: how do you reconcile things if multiple plugins provide a blockRenderMap?

For example, the plugin I’m working on at the moment overrides the entire block map to ensure that only one type of block is allowed. If the plugin editor merges blockRenderMaps then that use case would fail. Could you provide a way for individual plugins to specify some sort of priority and/or merge/replace property?

Note that the draft-js-plugins-editor currently supports a single blockRenderMap being passed to it, in that it simply passes that onto the standard draft-js <Editor>. Is that actually enough? In which case, good work team 😄

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davidbyttowcommented, Jun 1, 2016

FWIW, I have a working prototype on my own editor with code like this:

_resolveBlockRenderMap() {
  return this._plugins
      .filter((plug) => plug.blockRenderMap !== undefined)
      .map((plug) => plug.blockRenderMap)
      .reduce((map, type) => {
        return map.merge(type);
      }, DefaultDraftBlockRenderMap);
}

In this implementation, the plugins can return either a Map() or a JS object.

0reactions
stale[bot]commented, Sep 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Block Rendering - Draft.js
The block rendering is used to define supported block types and their ... type by matching the Draft block render map with the...
Read more >
DraftJs creating simplest possible custom block - Stack Overflow
I implemented sth like that: const blockRenderMap = Immutable.Map({ 'backgroundColor': { element: 'section', wrapper: <div>{this.props.children} ...
Read more >
Support advanced customisations to block rendering #169
Support for wrapper blocks should be straightforward. Add it to the getBlockRenderMap : draftail/lib/api/behavior.js.
Read more >
draft-js-single-line-plugin | Yarn - Package Manager
This plugin adds support restricting Facebook's Draft.js editor to a single line of content. It will condense any blocks into a single block, ......
Read more >
How to solve Draft.js convertFromHTML combining adjacent ...
I solved this by adding a custom DraftBlockRenderMap element for paragraph ... convertFromHTML(html, getSafeBodyFromHTML, blockRenderMap);.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found