Trying to add my JS code to custom block in Drupal 9.5.3 with CKEditor 5. But JS code is not running there.
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
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.
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