CKEDITOR.replace( \\'editor1\\' )', content: '' } }); Right now it shows error like unexpected token '<'","answerCount":3,"author":{"@type":"Person","name":"HarshOB","url":"https://gjs.market/go?url=https%3A%2F%2Fgithub.com%2FHarshOB"},"dateCreated":"2017-11-22T06:08:06Z","dateModified":"2019-09-18T00:56:18Z","acceptedAnswer":{"@type":"Answer","text":"@HarshOB https://github.com/artf/grapesjs/wiki/Components-&-JS#template-related","dateCreated":"2017-11-23T01:14:07Z","upvoteCount":2,"author":{"@type":"Person","name":"artf","url":"https://gjs.market/go?url=https%3A%2F%2Fgithub.com%2Fartf"},"url":"https://gjs.market/issues/555-add-external-script-in-script-while-creating-new-component#answer-346512990","sameAs":"https://github.com/GrapesJS/grapesjs/issues/555#issuecomment-346512990"},"suggestedAnswer":[{"@type":"Answer","text":"Move the script tag to import CKEditor on the html page and just call the script inside the block.","dateCreated":"2017-11-22T14:19:23Z","upvoteCount":0,"author":{"@type":"Person","name":"arthuralmeidap","url":"https://gjs.market/go?url=https%3A%2F%2Fgithub.com%2Farthuralmeidap"},"url":"https://gjs.market/issues/555-add-external-script-in-script-while-creating-new-component#answer-346363010","sameAs":"https://github.com/GrapesJS/grapesjs/issues/555#issuecomment-346363010"},{"@type":"Answer","text":"javascript somehow not allowing script end tag (\"\") with in string. So just change the code to be like: script: '
Issue #555✓ SolvedOpened November 22, 2017by HarshOB2 reactions

Add external script in script while creating new component

Quick answerby artf2

@HarshOB https://github.com/artf/grapesjs/wiki/Components-&-JS#template-related

Read full answer below ↓

Question

Hello @artf

How can I pass external script link while creating a component? like this way,

bm.add('test-block2', { label: 'Test block2', attributes: {class: 'fa fa-text'}, content: { script: '<script src="https://cdn.ckeditor.com/4.6.2/full/ckeditor.js"></script>CKEDITOR.replace( \'editor1\' )', content: '<textarea name="editor1"></textarea>' } });

Right now it shows error like unexpected token '<'

Answers (3)

arthuralmeidapNovember 22, 2017

Move the script tag to import CKEditor on the html page and just call the script inside the block.

rohanreddygFebruary 4, 2018

javascript somehow not allowing script end tag ("</script>") with in string. So just change the code to be like: script: '<script>alert("Hi");<' + '/script>'

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.