Search code examples
2sxc

2sxc allowing Javascript on wysiwyg editor


We want to move away from DNN html/text and replace with with 2sxc-Content. But in some pages, it require to have javascript injected into the content. Exp case: tracking user when clicking the Link on content.

TinyMCE had option for allowing Javascript: tinymce.init({ ..... extended_valid_elements : "script[language|type|src]" });

But we cannot found any information on 2sxc-documentation for configure it, we need it to allowing insert Javascript to wysiwyg.

Right now, we change the Input Type from wysiwyg editor into string/text, and it doesn't look nice for user.


Solution

  • I believe I know what you're trying to do but it's quite dangerous (XSS, etc.), so let me suggest some alternatives:

    1. Use the Snippet App to just inject JS Snippets where needed
    2. Create a convention placeholder like ENABLETRACKING and make your razor-code replace this when rendering the HTML.

    I highly suggest you use the snippet app - see https://2sxc.org/apps/app/snippet-inject-v3-hybrid-for-dnn-and-oqtane