On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Quote from: Gildas at Nov 13, 2006, 01:01 PM

    Prototypify.js has been removed in Rev. 2001 huh So, at this stage the current version of the Plugin doesn’t work anymore sad Thus you will find hereafter a slightly modified version of the pluggin ;-) With a little hack inspired from prototypify, this version now support the Prototype.js inclusion.

    Prototypify was removed from the code for the 0.9.5 release candidates because it’s a adhoc hack to getting around problems with using legacy code with Prototype. The reason for the introduction of Prototype was to find a quick and dirty solution to remove the legacy WebFX code. The problem is that using Prototype can cause some code to go nuts if you aren’t careful. One of the main problems I ran into is the use of associative arrays...Prototype doesn’t like them! I found a workaround simply by implementing any associative arrays as objects instead. Plus, we’re moving in a direction where we’ll likely be doing away with Prototype in favor of MooTools, which will support the more useful functions of Prototype and then some. We’re working on getting MooTools compatible scripts into the manager right now. Should have something in the RC’s soon. smiley

    Jeff
      Jeff Whitfield

      "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
    • Quote from: Gildas at Nov 13, 2006, 08:37 PM

      @sD

      I am on a testing server with WAMP5 (http://www.wampserver.com). Sorry wink Like Pixelchutes my MODx directory wasn’t at the root and the redirect was incorrect. But nevertheless the installation of Ressource Wizard succeed. After this fisrt step I try to install the EditArea package. At this stage I had a problem with the "resource_pkgmime". On WAMP5 I have to change the test from "application/zip" to "application/x-zip-compressed". With this correction, all work fine wink This "install test" helped me to detect & correct an error in the plugin (@see http://modxcms.com/forums/index.php/topic,8285.msg63030.html#msg63030)...

      NB : - The notes.txt is incomplete and due to CR problem unreadable (@see attachement).
      - For the next version I will try to make a clean distribution of EditArea JS code...


      Yeah, I need to find a better way to redirect to the manager. As far as the mime-type, a user named Jesster444 found a great workaround for that part of the code, I will be releasing an offical fix this week, with some other minor updates. If one of you great folks has any time to do a quick readme.html that I can use instead of note.txt (which displays horribly!), I could also include that in the package. oh oh oh... and I will change the name to EditArea from "Edit Area". is that correct?

      let me know if I need to add anything else to the package.

      -sD-
      Dr. Scotty Delicious, Scientist.
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
      • Quote from: Bravado at Nov 14, 2006, 03:30 AM

        Plus, we’re moving in a direction where we’ll likely be doing away with Prototype in favor of MooTools, which will support the more useful functions of Prototype and then some. We’re working on getting MooTools compatible scripts into the manager right now. Should have something in the RC’s soon. smiley
        Switching from Prototype to Mootools will not change anything in this case... Indeed, like Prototype, Mootols add some utility functions to the native javascript Array, consequently JS scripts using Arrays as associative arrays doesn’t work sad But, while waiting for a new version of EditArea from C.Dolivet, my little hack will still work wink
          Ackwa - Web Design & Development agency | Tours - France | Follow me on Twitter...
        • Quote from: "C.Dolivet"
          The last version of EditArea (0.6.2) is now compatible with javascript libraries like "prototype" (1.5) and "mootools" (release 83)
          So I’ve updated the plugin and at this occasion I’ve added the ability to save the current position of the cursor for "Continue Editing" smart use ;-) This version need at least MODx 0.9.5 rev. 2000.

          <?php
          /**
           * @name       EditArea Plugin
           * @purpose    Replaces standard textarea with EditArea (c) C.Dolivet
           * @status     Experimental 
           * @version    0.1.6 Beta - 21/11/06
           * @depend     MODx 0.9.5 Rev.2000+   
           *
           * @author     Gildas       <modx@ackwa.fr>
           *             Pixelchutes  <http://www.pixelchutes.com>
           *               
           * @copyright  Copyright (c) 2006 Krismas.net
           * @license    GNU General Public License 2.0
           *
           * @see        http://www.cdolivet.net/editarea
           *
           * @history    [Gildas      - 0.1.1 - 26/10/06] Create from CodePress plugin based on an original idea of pixelchutes
           *             [Gildas      - 0.1.1 - 26/10/06] Change edit_area location from /manager/media to /assets/plugins
           *             [Gildas      - 0.1.1 - 26/10/06] Change default font size to a smaller one : 9pt
           *             [Gildas      - 0.1.1 - 26/10/06] Update Traces and correct invalid test ;-) 
           *             [Gildas      - 0.1.2 - 27/10/06] Change algorithm for New Documents and Links support
           *             [Gildas      - 0.1.2 - 27/10/06] Support for BottomButtonBar is native. Thanks to EditArea ;-)
           *             [Gildas      - 0.1.2 - 27/10/06] Add an handler for changeRTE()
           *             [Pixelchutes - 0.1.3 - 02/11/06] Update editAreaLoader.init
           *             [Gildas      - 0.1.3 - 08/11/06] Tested with EditArea 0.6.1 (2006-11-03) - OK
           *             [Gildas      - 0.1.3 - 08/11/06] Add installation steps
           *             [Gildas      - 0.1.3 - 08/11/06] Add support for EditArea Debug mode (cf. $debug)
           *             [Gildas      - 0.1.4 - 13/11/06] Add a little hack to support Prototype.js (Thanks to prototypify.js)
           *             [Gildas      - 0.1.4 - 13/11/06] Remove reference to document.mutate in onChangeEditArea()
           *             [Gildas      - 0.1.4 - 16/11/06] Make some tests after Prototype.js was replaced by Mootools (Rev 2017)
           *             [Gildas      - 0.1.5 - 20/11/06] Tested with EditArea 0.6.2 (2006-11-20) - OK
           *             [Gildas      - 0.1.5 - 20/11/06] EditArea is now compatible with "Prototype" (1.5) and "Mootools" (release 83)
           *             [Gildas      - 0.1.6 - 21/11/06] Add the ability to save position. Helpful for "Continue Editing"
           *
           * @Todo       X Suggest some improvements to C.Dolivet
           *             - Change Cookie management ie Serialization & Domain
           *             - Change save/restorePosition calling methods
           *             - Add some configuration parameters : Font size, Debug mode...
           *             - Create a "Resource Wizard" package
           *             - Add support to EditArea on the Frontend within QuickEdit
           *             - Save current position for "Continue editing"   
           *             - Add support to CodePress with the same plugin code !? 
           *              
           * @notes      - If scriptaculous/prototype.js is loaded EditArea stop working... Indeed Prototype was interfering with the associative 
           *               arrays of certain scripts. The solution is to load BEFORE prototype.js, prototypify.js. This has been done in MODx  
           *               Rev. 1934 for Snippets, Plugins and Modules but not for Documents, Templates and Chunks !? There is no problem to add
           *               prototypify.js for Templates, but for Chunks and Documents, a JS error appear when switching from RTE do EditArea !!!  
           *  
           * @install    - Download EditArea from http://prdownloads.sourceforge.net/editarea/edit_area_0_6_0_1.zip?download
           *             - After you've unzipped the archive, you should see the edit_area_0_6_0_1 folder with 3 sub-folders: docs, edit_area, exemples
           *             - Upload only the edit_area folder into the /assets/plugins/ folder.
           *             - Copy and paste de plugin code (without the begin/end PHP tags)
           *             - Select on or more events in this list :
           *
           *                  OnTempFormRender   (Template editor - html highlighting)
           *                  OnChunkFormRender  (Chunk    editor - html highlighting)
           *                  OnDocFormRender    (Document editor - html highlighting)
           *                  OnSnipFormRender   (Snippet  editor - php  highlighting)
           *                  OnPluginFormRender (Plugin   editor - php  highlighting)
           *                  OnModFormRender    (Module   editor - php  highlighting)
           */
          global $content;
          
          /*
           * $debug : In debug mode EditArea plugin don't use EditArea ;-)
           */
          $debug = false;
          
          /*
           * Collect current MODx Event & Initialize some data
           */
          $evt   = &$modx->Event;
          $code  = '';
          $ta    = 'post';
          $oname = $content['name'];
          $lang  = strtolower(substr($modx->config['manager_language'], 0, 2));
          $eadbg = ($debug ? 'true' : 'false');
          $otype = substr($evt->name, 2, 1);
          
          /*
           * This plugin is only valid in "text" mode. So check for the current Editor 
           */
          $prte  = (isset($_POST['which_editor']) ? $_POST['which_editor'] : '');
          $srte  = ($modx->config['use_editor'] ? $modx->config['which_editor'] : 'none');
          
          /*
           * Check Event to define language
           */
          switch ($evt->name) {
              case 'OnTempFormRender'  :
                  $oname = $content['templatename'];
              case 'OnChunkFormRender' :
                  $rte   = ($prte ? $prte : 'none');
                  $code  = 'html';
                  break;
              case 'OnDocFormRender'   :
                  $ta    = 'ta';
                  $oname = $content['pagetitle'];
                  $rte   = ($prte ? $prte : ($content['id'] ? ($content['richtext'] ? $srte : 'none') : $srte));
                  $code  = (('reference' == $content['type']) ? '' : 'html');
                  break;
              case 'OnSnipFormRender'  :
              case 'OnPluginFormRender':
              case 'OnModFormRender'   :
                  $rte   = ($prte ? $prte : 'none');
                  $code  = 'php';
                  break;
          }
          
          /*
           * Compute Object key
           */
          $okey = $otype.'-'.$oname;
          
          /*
           * Add some Trace for Debug purpose... 
           */
          if ($lang) {
              /* 
               * Some Traces
               */
              $evt->output('<!--  EditArea Plugin Debug for : '.$evt->name.' in '.$oname.' ['.$okey.']['.$code.']['.$lang.'] RichText ['.$rte.'|'.$prte.'|'.$srte.'] ');
              $evt->output('Settings Use Editor ['.$modx->config['use_editor'].'] Which Editor ['.$modx->config['which_editor'].'] ');
              $evt->output('Doc. ID ['.$content['id'].'] Doc. Type ['.$content['type'].'] RichText ['.$content['richtext'].'] -->');
          }
          
          /*
           * Create JS code if needed
           */
          if (('none' == $rte) && $code && !($debug && ('editarea' == strtolower($oname)))) {
              /*
               * Now create the JS code to add at the end of the current page
               */
              $output = <<< HEREDOC
          
              <!-- EditArea Plugin -->
              <script type="text/javascript">
                  /*
                   * Add EditArea specific action to the standard "Change RTE Process"
                   */
                  function EAonChangeRTE () {
                      ta.value = editAreaLoader.getValue('myeditarea'); 
                      changeRTE();
                  }
          
                  /*
                   * Call when the onchange event of the textarea will be triggered
                   */
                  function EAonChange (id) {savePosition(id);}
          
                  /*
                   * Save/Restore position (Need Mootools API)
                   */
                  function savePosition (id) {
                      var sr = editAreaLoader.getSelectionRange(id)
                      Cookie.set('$okey', sr.start, 1);
                  }
                  function restorePosition (id) {
                      var start = (Cookie.get('$okey') ? Cookie.get('$okey') : 0);
                      editAreaLoader.setSelectionRange(id, start, start);
                  }
          
                  /* 
                   * Locate the textarea named "post" or "ta"
                   */
                  var ta = document.getElementsByName('$ta')[0];
                 
                  /* 
                   * If we have found a valid textarea then change it to an EditArea one...
                   *
                   * EditArea is able to save modified textarea content without
                   * any modification on "Button1" ;-)
                   */
                  if (ta && ('textarea' == ta.type)) {
                      /* 
                       * Add an ID to the textarea
                       * modify "on save" actions
                       */
                      ta.id = 'myeditarea'; 
          
                      /* 
                       * Modify the "OnChange" action on "which_editor" select
                       */
                      if (document.getElementById('which_editor')) {
                          document.getElementById('which_editor').onchange = EAonChangeRTE;
                      }
                  }
                  else {
                      ta = null;
                  }
              </script>
              <script language="javascript" type="text/javascript" src="../assets/plugins/edit_area/edit_area_full.js"></script>
              <script language="javascript" type="text/javascript">
                  /*
                   * Some params (IF CHANGED) will (currently) bomb in MODx! Trying to save after a bomb erases your content! :( This params are :
                   *          
                   * allow_toggle : Allows toggling between normal textarea and syntax highlighting (editarea). Toggling (more than once) bombs in MODx
                   * allow_resize : Should allow you to resize your container, but container disappears and saving has nothing to reference, thus overwrites leaving it empty.
                   * display      : When set to "later" delays automatic syntax highlighting, waiting for the user to toggle the editor. See "allow_toggle" below:
                   */
                  if (ta) {
                      editAreaLoader.init({
                          id: 'myeditarea'                // textarea id
                          ,syntax: '$code'                // Code-syntax to be highlighted (NOTE: For the 'CHUNK' section, syntax: "html" may be more appropriate)
                          ,start_highlight: true          // Display highlight-mode on start-up
                          ,language: '$lang'              // Language support
                          ,font_size: 9                   // Code font size
                          ,debug:$eadbg                   // Debug mode
                          ,allow_toggle: false            // Allow toggling on/off [For MODx, set to false!]
                          ,allow_resize: 'no'             // Allow resizing [For MODx, set to NO!]
                          ,change_callback: 'EAonChange'  // Call when the onchange event of the textarea will be triggered
                      });
                      window.setTimeout('restorePosition(ta.id)', 500);
                  }
              </script>
              <!-- /EditArea Plugin -->
          HEREDOC;
              
              /*
               * Output JS code
               */
              $evt->output($output);
          }
          ?>
            Ackwa - Web Design & Development agency | Tours - France | Follow me on Twitter...
          • Quote from: Gildas at Nov 21, 2006, 08:40 PM

            Quote from: "C.Dolivet"
            The last version of EditArea (0.6.2) is now compatible with javascript libraries like "prototype" (1.5) and "mootools" (release 83)
            So I’ve updated the plugin and at this occasion I’ve added the ability to save the current position of the cursor for "Continue Editing" smart use ;-)

            Awesome!

            Testing immediately!

            Don’t forget about the events that should be ticked for the plugin:

            OnTempFormRender (template editor - html highlighting)
            OnChunkFormRender (chunk editor - html highlighting)
            OnDocFormRender (Document editor if you are not using an RTE - html highlighting)
            OnSnipFormRender (Snippet editor - php highlighting)
            OnPluginFormRender (plugin editor - php highlighting)
            OnModFormRender (module editor - php highlighting)

            NOTE:
            All-- Don’t forget to download the new EditArea... same as before, simply upload the edit_area folder within the archive!


            UPDATE!

            I personally recommend enabling EditArea toggling, as I have seen the editor shrink if you interact with the tabs too quickly before loading (very seldom)

            allow_toggle: true            // Allow toggling on/off ... can re-render the editor, too, if needed MODx, set to false!



            Also, if you’d like to make the default text editor size greater than 370px high, add the following code after ta.id = ’myeditarea’; in the plugin/JS code:

                        ta.style.height = '800px'; // Enter desired default height in pixels
            
              Mike Reid - www.pixelchutes.com
              MODx Ambassador / Contributor
              [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
              ________________________________
              Where every pixel matters.
            • Great news!

              With version 0.6.2, it appears to be much more friendly, especially within MODx!

              The following params that were previously forced to false (for MODx) no longer need to be!


              ,allow_toggle: false // Allow toggling on/off ----> [For MODx, can now be false or true]
              ,allow_resize: ’no’ // Allow resizing ----> [For MODx, can now be no or yes, though was not able to resize in Win FF2.0]

              Toggling of the EditArea is now handled just as expected, which means we can pre-package EditArea w/ MODx 0.9.5 smiley ...keeping everything disabled by default, if needed. A user could then have syntax highlighting by default, by choice (toggling it on) or not at all (delete the pre-packaged plugin!)

              If you take this very thread’s current Poll results into account:

              Question: Should MODx come pre-packaged with inline syntax highlighting as described below? (25 voters as of 11/21/06 2:48 PM MST)

              76% of the involved community feels it should come pre-packaged.

              64% - Absolutely! Just what MODx needs, plus EditArea offers multi-lingual support!
              12% - Of course. Removes risk of modding core files, plus less work for me.

              24% of the involved community feels it should be manually added.

              24% - No. MODx was built to be extensible. If you want it, add it yourself.

              NOTE:
              While resizing still does not seem to work in MODx, at least it does not disappear/crash. It probably is not a bad idea to leave the resize disabled for the time being. Gildas, possibly you/C.Dolivet can determine why it doesn’t seem to work in MODx as one might expect.
                Mike Reid - www.pixelchutes.com
                MODx Ambassador / Contributor
                [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                ________________________________
                Where every pixel matters.
              • In my point of view "Resizing" has no interest. Regarding "Toggling", I will add this as a parameter in a future release...
                  Ackwa - Web Design & Development agency | Tours - France | Follow me on Twitter...
                • The last version of EditArea (0.6.2) is now compatible with javascript libraries like "prototype" (1.5) and "mootools" (release 83)So I’ve updated the plugin and at this occasion I’ve added the ability to save the current position of the cursor for "Continue Editing" smart use ;-)


                  I am getting a JS error in IE 6.0 ...Cookie is undefined
                    Mike Reid - www.pixelchutes.com
                    MODx Ambassador / Contributor
                    [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                    ________________________________
                    Where every pixel matters.
                  • In this version the Cookies are managed by Mootools so you need to upgrade your version to at least 0.9.5 Rev. 2000. Mootools Cookies extension is very limited sad I will change this "bad choice" in a future release.
                      Ackwa - Web Design & Development agency | Tours - France | Follow me on Twitter...
                    • Quote from: pixelchutes at Nov 21, 2006, 09:49 PM

                      76% of the community feels it should come pre-packaged.

                      This is meaningless. MODx is not a democracy and if it was, 25 people who visited a thread called "Syntax Highlighting for snippet, plugin, module and chunk editing using EditArea" and placed a vote would not constitute a quorum.

                      I’ve not voted, but my vote would be with the "If you want it, add it yourself." crowd.

                      I can’t see it being pre-packaged before it’s stable. I should point out that there’s talk of multiple packages in the future, so there could easily be a "MODx with EditArea" amongst the versions.

                      Is it stable yet?
                        No, I don&#39;t know what OpenGeek&#39;s saying half the time either.
                        MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
                        Forum: Where to post threads about add-ons | Forum Rules
                        Like MODx? donate (and/or share your resources)
                        Like me? See my Amazon wishlist
                        MODx "Most Promising CMS" - so appropriate!