4 Replies Latest reply on Jun 28, 2013 7:06 PM by Sham HC

    RTE not working in chrome and mozilla

    Veena_07 Level 3

      Hi

       

          I have an urgent issue.. My RTE is not working in chrome and mozilla.. It is showing up in my dialog; but when i enter data and submit it is not storing in CRX. Also non of the plugins is active

       

      Any help weill be appreciable

       

       

      Thanks

       

      Veena

        • 1. Re: RTE not working in chrome and mozilla
          Sham HC Level 7

          ANy javascript error in console?

          • 2. Re: RTE not working in chrome and mozilla
            Veena_07 Level 3

            Hi Sham

             

                 After lot of debug i found out the following issues

             

            • In RTE if we put styles plugin only this issue is happening
            • The issue happens because the RTE is getting disabled because of the following in RichText.js

             

             

            if (CQ.Ext.isIE) {

                        var editorSheet = this.doc.createStyleSheet();

                        for (cssIndex = 0; cssIndex < cssCnt; cssIndex++) {

                            styleToAdd = cssToAdd[cssIndex];

                            for (sheetIndex = 0; sheetIndex < styleSheetCnt; sheetIndex++) {

                                styleToCheck = styleSheets[sheetIndex];

                                rules = styleToCheck.rules;

                                ruleCnt = rules.length;

                                ruleToCopy = null;

                                for (ruleIndex = 0; ruleIndex < ruleCnt; ruleIndex++) {

                                    ruleToProcess = rules[ruleIndex];

                                    ruleText = ruleToProcess.selectorText;

                                    if (ruleText == "." + styleToAdd) {

                                        editorSheet.addRule(

                                                "." + ruleText, ruleToProcess.style.cssText);

                                        break;

                                    }

                                }

                            }

                        }

                    } else {

                        var styleDef = this.doc.createElement("style");

                        styleDef.type = 'text/css';

                        var cssText = "";

                        for (cssIndex = 0; cssIndex < cssCnt; cssIndex++) {

                            styleToAdd = cssToAdd[cssIndex];

                            for (sheetIndex = 0; sheetIndex < styleSheetCnt; sheetIndex++) {

                                styleToCheck = styleSheets[sheetIndex];

                                rules = styleToCheck.cssRules;

                               ruleCnt = rules.length;

                                ruleToCopy = null;

                                for (ruleIndex = 0; ruleIndex < ruleCnt; ruleIndex++) {

                                    ruleToProcess = rules[ruleIndex];

                                    if (ruleToProcess.type) {

                                        if (ruleToProcess.type == CSSRule.STYLE_RULE) {

                                            ruleText = ruleToProcess.selectorText;

                                            if (ruleText == ("." + styleToAdd)) {

                                                ruleToCopy = ruleToProcess;

                                                break;

                                            }

                                        }

                                    }

                                }

                                if (ruleToCopy) {

                                    cssText += ruleToCopy.cssText;

                                    break;

                                }

                            }

                        }

                        styleDef.appendChild(this.doc.createTextNode(cssText));

                        headEl.appendChild(styleDef);

                    }

             

             

            The above lines are from 650-701 in RichText.js of CQ5.4 . They have handled the code for IE seperately from lines 650-670

             

            The error is happening in line number 679 ; Where the ruleCnt is returning null for some sheetIndex and so the code is breaking and the RTE is disabled.

             

            If i add the following line of code

             

            if(ruleCnt == null){

            continue;

            }

             

            just after line 679 . This issue seems fixed. But i think it is not the proper way to fix it and it is only a temporary fix. I dont know if it is a CQ issue.

             

            Does any one have any solution for this.

             

            To replicate the scenario

             

            • Create a rtePlugin in ur richtext widget
            • add a styles dropdown with styles in it
            • run this in chrome or any other browser except IE

             

             

            If you have a proper solution please let me know

             

             

            Thanks

             

            Veena

            • 3. Re: RTE not working in chrome and mozilla
              Veena_07 Level 3

              Hi

               

                   The above issue happens only in the template I am using. It is working fine for geometrixx ..


                  The issue happens because as I am including <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Droid+Sans:400,700' rel='stylesheet' type='text/css' />  in my head.jsp. When it is accessed in the else part of the above method; the line

               

              styleToCheck = styleSheets[sheetIndex];

              rules = styleToCheck.cssRules;

               

                 returns me null. Since for chrome the fonts stylesheet from google is giving null for rules.

               

               

              Need Help in solving out this

               

              Thanks

               

              Veena

              • 4. Re: RTE not working in chrome and mozilla
                Sham HC Level 7

                For now modified rte [1] to skip style sheet seems to resolved the issue.  Request has been placed to support external css though i am not sure of exact status. File daycare for further help.

                 

                [1]

                 

                try{

                rules = styleToCheck.cssRules;

                ruleCnt = rules.length;

                }

                catch(err){

                ruleCnt=0;

                }