Issue #567✓ SolvedOpened November 24, 2017by NorthstarTech4 reactions

A component that inserts editable HTML

快速解答by ryandeba2

Hi @NorthstarTech, I just created a plugin (very early, could use some more work) that you may find helpful: https://github.com/ryandeba/grapesjs-html-block. You should just be able to include that file in your project and include the plugin in your grapesjs init config: grapesjs.init({ ..., plugins: ['html-block'] })...

Read full answer below ↓

Question

Would it be possible to create a block that allowed the user to write in responsive HTML either directly on to the template or on the side in the style/layout manager?

Answers (3)

👍 Most helpfulryandebaNovember 24, 2017

Hi @NorthstarTech,

I just created a plugin (very early, could use some more work) that you may find helpful: https://github.com/ryandeba/grapesjs-html-block.

You should just be able to include that file in your project and include the plugin in your grapesjs init config: grapesjs.init({ ..., plugins: ['html-block'] })

After doing that, you should see a new "HTML Code" block. Drag and drop it somewhere, select the element, and you should see a "code" button in the toolbar. Click the code button and you should get a modal that lets you edit the HTML content.

Let me know if you run into any issues.

ryandebaFebruary 14, 2018

@chiqui3d Change the isComponent function to this to prevent the initial internal html from getting parsed by grapesjs into components:

isComponent: function(el) {
	if (el.hasAttribute && el.hasAttribute("data-html-code")) {
		return {
			type: 'html-code',
			content: el.innerHTML,
			components: []
		};
	}
}

The other code I posted should prevent grapesjs from parsing the html after editing through the modal. The key to both is that you need to set the internal html into the content property instead of components.

ryandebaNovember 28, 2017

I believe this issue has been resolved and could be closed based on the first comment here: https://github.com/ryandeba/grapesjs-html-block/issues/1. @NorthstarTech could you confirm or reply with additional details if you want to keep this issue open?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.