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.

Using Block.ATOMIC is broken

See original GitHub issue

I’m using the following Workflow.

1.- User click on the plus icon. 2.- Sub menus appear and user can select video 3.- When user click video other form appears where user can paste url. 4.- when user submit url i call addNewVideoToEditor.

I have the same workflow for images, and this is how the addNewImageToEditor looks.

  addNewImageToEditor(src) {
    const { getEditorState, setEditorState } = this;

    setEditorState(addNewBlock(
      getEditorState(),
      Block.IMAGE, { src },
    ));
  }

So for video i’m doing.

  addNewVideoToEditor(url) {
    const { getEditorState, setEditorState } = this;

    setEditorState(addNewBlock(
      getEditorState(),
      Block.ATOMIC, { url }, // try with src already too.
    ));
  }

Now, this work for images great, and i’m inserting any kind of images, but for atomic i got.

Uncaught TypeError: props.getEditorState is not a function.

and i can see that came from this line.

https://github.com/brijeshb42/medium-draft/blob/master/src/components/blocks/atomic.js#L7

The only difference i can see is that ImageBlock access getEditorState from blockProps.getEditorState and AtomicBlock is accessing it directly from props.getEditorState

eve thought the implementation on.

https://github.com/brijeshb42/medium-draft/blob/master/src/components/customrenderer.js

is the same.

I’m missing something here?, i try to implement the example from your the example.js but i got the same error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Ethaancommented, Jan 15, 2019

This is how its looking if i do.

const rawContentState = convertToRaw(content.getCurrentContent());

screen shot 2019-01-15 at 2 17 32 pm

Even using a third party library.

import { convertToRaw } from 'draft-js';
import draftToHtml from 'draftjs-to-html';

const rawContentState = convertToRaw(content.getCurrentContent());
const htmlContent = draftToHtml(rawContentState);
console.log(htmlContent);

i got nothing

2reactions
brijeshb42commented, Oct 19, 2018

Assuming you are using importer/exporter from medium-draft Have you customized your exporter/importer in any way? I just verified this on the demo page and exporting then importing was working fine. You can verify this yourself if you have react devtools in chrome installed. Go to the React tab in chrome devtools, select <App>, go back to console and then run this, (make sure there is only image block and maybe some text block in the content. delete other blocks and text) -

MediumDraftImporter.default($r.exporter($r.state.editorState.getCurrentContent())).toJS()

It should have type atomic:image in the blockMap of the result

Read more comments on GitHub >

github_iconTop Results From Across the Web

TransactionManagementError "You can't execute queries until ...
TransactionManagementError "You can't execute queries until the end of the 'atomic' block" while using signals, but only during Unit Testing · From the...
Read more >
[Atomic Blocks] Support - WordPress.org
issues adding analytics tags to atomic blocks. Started by: mikevolmar ... Comment link is broken ... php notice in wp-admin with WP 5.3.0...
Read more >
Answered: A block of carbon is broken down into… - Bartleby
Solution for A block of carbon is broken down into small pieces. Each piece of carbon is a different kind of atom Select...
Read more >
The periodic table is broken down into rows and blocks such ...
The periodic table is broken down into rows and blocks such as the s, p, d and f blocks. Each block has different...
Read more >
What's wrong with atomic design? - LinkedIn
An atom is the smallest building block and combines with other atoms to form molecules. A button is considered to be an atom...
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