skip to Main Content

Trying to add my JS code to custom block in Drupal 9.5.3 with CKEditor 5. But JS code is not running there.

custom block

I tried adding code using code button in tool bar of CKEditor. But doesn’t working.

In the older version of Drupal 8 I used to write the JS script in the custom blocks itself.

So, How can I add my JS scripts in editor itself?

2

Answers


  1. Pasting the source into the main WYSIWYG window of CKEditor escapes some of the characters in the script tag, causing it not to run. You need to first click on the "Source" option on the CKEditor toolbar (the right-most option in your screenshot), then paste your Javascript in there. I just tested pasting in some Javascript on a fresh install of Drupal 9.5.3 with CKEditor 5 on simplytest.me and it worked for me.

    Login or Signup to reply.
  2. Here i tried my script without selecting option which is shown in your given image just clicking on source added js script enter image description here

    set text editor as full html this worked for me

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search