Menu

My CSS in DropDown Menu ??

2003-06-23
2003-11-11
  • Alessandro Panzani

    Hi everybody,

    I'd like to add the classes of my CSS to the style menu of the editor...

    How can i do???

    Thanks.

     
    • Boštjan Žokš

      Boštjan Žokš - 2003-10-09

      This is probably not relevant to you anymore, but for others looking the same info (as I were):

      in .htm where you include editor (<object id="richedit"...), you also have something like

      <script language="JavaScript" event="onload" for="window">
      theForm.richedit.options = "history=yes;source=yes";
      theForm.richedit.styleData = document.styleSheets;

      Add this:
      theForm.richedit.styleData = document.styleSheets;

      that's it. Now all stylesheets you have specified/linked/imported in this .htm are available in editors Style dropdown.

       
    • paul armstrong

      paul armstrong - 2003-10-21

      Hi,

      I can't seem to get this functionality to work. The editor is currently embedded in a "CMS" but we only want users to be able to apply styles that we explicitly define - not Heading 1, Heading 2 etc. Removing unwanted styles is simple enough but I cannot get the ditor to pick up my custom styles

      In richedit.html I've included a link to "my.css".

      The following script code is present by default in richedit.html:

      <script language="JavaScript">
      // This defines the scriptlets public interface.  See rte_interface.js for
      // the actual interface definition.
      var public_description =  new RichEditor();
      // Initialise the editor as soon as the window is loaded.
      window.attachEvent("onload", initEditor);
      // Initialise the tEdit var
      var tEdit = null;
      //javascript:void( window.open("http://dsubramanian/portal/beanutils/htmleditor/jsdebug.html",
        //    "Debugger", "width=400,height=300,status=1,scrollbars=1,resizable=1" ) );

      </script>

      I've tried just adding:

      public_description.styleData = document.styleSheets;

      but this results in no styles at all appearing in the drop down box.

      I'm assuming I'm missing a trick somewhere. From previous posts on this issue it looks like people have successfully done this. Could anyone post exactly what they did to get this to work ?

      Any pointers would be much appreciated.

       
    • Mark Wiltshire

      Mark Wiltshire - 2003-11-07

      I am also having a problem with this.

      From Richtext-0.2.3-editor.zip

      Only addition was to add the following to starting html to get inclusive styles in dropdown.

         document.content.richtext1.styleData=document.styleSheets;

      where richtext1 is my richedit.html object

      Now get all my styles in dropdown, but these are repeated multiple times ???

      Anyone else seen this ??

       
      • Boštjan Žokš

        Boštjan Žokš - 2003-11-07

        Yes, I had same problems with latest CVS version. I tried to fix them, but succeeded only partly.

        Problem is in the fact, that function for adding those styles to dropdown gets called twice.

        My partial solution is to completely ignore built-in styles (H1,...). This way only styles YOU define in .css gets shown in dropdown. But of course you can add H1,... to this .css and get everyhing you need back.

        In file rte_interface.js find function
        function put_styleData(passedValue) {....

        and near bottom of this function code looks like this:

        // Otherwise, assume it's a tag and select the existing tag entry
                    // in the style list.
                    else {
                        for (var k = 0; k < this.styleList.length; k++) {
                            if (this.styleList[k][0] == a) {
                                this.styleList[k][2] = 1;
                                break;
                            }
                        }
                    }

        Comment FOR sentence out, so it will look like this:

        // Otherwise, assume it's a tag and select the existing tag entry
                    // in the style list.
                    else {
                        /*
                        for (var k = 0; k < this.styleList.length; k++) {
                            if (this.styleList[k][0] == a) {
                                this.styleList[k][2] = 1;
                                break;
                            }
                        }
                        */
                    }

        Works for me.

         
        • Austin David France

          Sounds like we need an option to disable adding of internal styles

           
    • Mark Wiltshire

      Mark Wiltshire - 2003-11-11

      I have now fixed the multiple styles by commenting out the following in rte.js

      orig ....

      function initEditor()
      {
          // Apply style data if supplied
          if (!public_description.styleData) {
              public_description.put_styleData(null);
          }

      new ....

      function initEditor()
      {
          // Apply style data if supplied
          if (!public_description.styleData) {
              //public_description.put_styleData(null);
          }

      ...

      Since put_styleData is also called in rte_interface.js RichEditor function.

      I now just have a small problem, when trying to increase the width of the style dropdown ??

      Can Anyone help ??

      Ta

      Mark

       

Log in to post a comment.