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.

Import raw HTML on init

See original GitHub issue

Hi,

is it possible to import custom HTML into EditorJS on initialization?

For example - I have already existing HTML page, for which I need some WYSIWYG functionality.

Currently when I do:

<div id="page-content">
   <p>Hello</p>
   <p>World</p>
</div>

var editor = new EditorJS({
	holder : 'page-content'
});

then existing content of element “page-content” is ignored, and editor is just appended at the end (e.g. page bottom). Creates new empty space rather than importing two existing <p> nodes - Hello and World.

So it seems that EditosJS can only load supplied data of JSON blocks on initialization and cannot load any custom HTML contents. Is that correct or did I miss something … ?

I also looked over plugins - could not find any plugin for importing/parsing/loading supplied HTML.

Thank you.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:18

github_iconTop GitHub Comments

2reactions
entoneecommented, Mar 30, 2021

@entonee we’re using that solution in production, so it’s working for all our customers. Maybe you have an issue with your HTML, or don’t have the necessary EditorJS blocks installed.

Thank you. i found a way. i get error with await ( i`m not using react - may be thats why)

but i added it to onReady and everything works like a charm

onReady: () => { editor.blocks.renderFromHTML(“<?=trim(preg_replace('/\s\s+/', ' ', addslashes($rw['body'])))?>”) }

but have an issue with images - i get an error ( Image Tool: uploading failed because of incorrect response: {“url”:“http://myimageurl”} )

cant figure out what is correct responce - trying send just http://myimageurl - same thing. google not helped yet.

2reactions
tkrevhcommented, Jan 27, 2021

@lubosdz I found the way!

await editor.isReady
editor.blocks.renderFromHTML(existingHtml)
Read more comments on GitHub >

github_iconTop Results From Across the Web

TinyMCE insert raw html into active editor - Stack Overflow
Using WindowManager for TinyMCE I open a window and it writes back raw HTML. But its truncating my links for my images.
Read more >
Render Raw HTML In Your Vue Apps - DigitalOcean
Perhaps, for some reason you need to render raw HTML in your Vue components. Never fear: v-html is here.
Read more >
html-loader - webpack
Export into HTML files ... A very common scenario is exporting the HTML into their own .html file, to serve them directly instead...
Read more >
Raw HTML object
From the "Objects" toolbar item, select "Raw HTML." · Enter your HTML into the editor that appears. · To see the HTML in...
Read more >
How to get content from the editor and set content | TinyMCE
How to set content on initialization; How to get the content without any HTML tags; Why isn't the getContent working? This article also...
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