1
votes

The rich text editor in AEM 6 has a source code editor, which renders the html code if copy pasted in it. Am stuck with the JS part. how to make the script tag work in it?

If i add

<script>
      $(document).ready(function(){ //alert("1"); });
</script>

then it converts it to:

<p>$(document).ready(function(){ //alert(&quot;1&quot;);</p>

when viewed in the page source.

and " $(document).ready(function(){ //alert("1"); });" is rendered on the page as it is.

1
What do you mean by stuck ? what happens when you add script tags in them ? you get javascript errors on your debugger console ?yash ahuja
it automatically removes the <script> tags once you reclick the source editor to view your preview.Shine

1 Answers

1
votes

You'll have to overlay two files by creating corresponding structure in /apps:

  • /libs/cq/ui/rte/core/WhitespaceProcessor.js
  • /libs/cq/ui/widgets/source/widgets/form/rte/WhitespaceProcessor.js

and modify DEFAULT_REMOVAL_RULES array at the bottom of each file - there is a list of tags which RTE widget removes from the HTML source code.