Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#77 Re: User Discussion & Help » Capturing Key Events in Xinha » 2008-02-04 15:18:30

ray

It is indeed the editor (technically an iframe) you have to add the listener to. You can do this either from "outside" like so

        //add this in your init function AFTER Xinha.startEditors()
      var editor = Xinha.getEditor('myTextArea'); //please update to the latest version to have this utility function
    editor.whenDocReady (function() {Xinha._addEvent(editor._doc,"keydown", keyHandler)}); // you have to wait until every thing is initialized
    
    function keyHandler (event) {
        event = (event) ? event : window.event; // care for IE
        var key = String.fromCharCode(event.keyCode);
        alert (key);
                // if you for some reason don't want the keypress to be executed, use this; otherwise just return true at the end of your function 
        Xinha._stopEvent(event);
        return false;
    }

or you can create a custom plugin, which is what I would prefer. It is as easy as putting this code in a file plugins/MyCustomPlugin/my-custom-plugin.js

MyCustomPlugin._pluginInfo = {
  name          : "MyCustomPlugin"
}
function MyCustomPlugin(editor)
{
    this.editor = editor;
}

MyCustomPlugin.prototype.onKeyPress = function ( event )
{  // here you don't have to care about getting the event right
   var key = this.editor.getKey(event); 
   alert(key);
   // once again you can stop the event 
   Xinha._stopEvent(event);
   // return true here to to stop the event to be dispatched to other plugins, too
   return true;
}

Available API function: http://xinha.raimundmeyer.de/JSdoc/Xinha/

#78 Re: User Discussion & Help » Safari ? » 2008-02-04 14:16:50

ray

You should at least replace XinhaCore.js, Xinha.css and the whole modules folder

#79 Re: User Discussion & Help » Safari ? » 2008-02-02 14:39:34

ray

Just comittet a version with  a first try of Safari 3 support. you can check it out here http://releases.xinha.gogo.co.nz/Xinha_0.95_RC2.tar.bz2

Please let me know everything that doesn't work right. Unfortunately I have only Windows to test

#80 Re: User Discussion & Help » PHP File Editing: Source = Plain Text and Design = Parsed HTML? » 2008-01-22 17:30:03

ray

Possibly could be done similar to the PreserveScripts plugin (currently only in nightly), involving XMLHttpRequest and eval'ing the content on the server.

#81 Re: User Discussion & Help » Safari Error Message » 2007-12-12 18:55:38

ray

Stand by, Safari support is coming soon smile

#82 Re: User Discussion & Help » Front of URL disappears! » 2007-12-12 18:45:15

ray

Is the page located on http://joint.dudley.nhs.uk? If so, this is wanted, but should be possible to be switched off with

     xinha_config.stripBaseHref = false;

#83 Re: User Discussion & Help » <> </> appearance » 2007-12-12 18:15:00

ray
Chuck wrote:

In the meantime, I'll try to isolate the html snippet that's causing the issue and post a ticket about it on trac.

Please do that, because actually I can't imagine how this can happen

#84 Re: User Discussion & Help » Upgrading from Htmlarea 3 » 2007-12-12 18:12:12

ray

The latest version is  of course wink the least buggy available!
Unfortunately not all plugins are so up-to-date, but that's only natural in an heterogeneous, plugin based system. Creating tickets is a good way to help.  Thanks smile

#85 Re: User Discussion & Help » deactivate shortcuts » 2007-12-12 17:59:24

ray

At the moment there's no simple way to do that.

If you know some JavaScript you could do it by overwriting Xinha.prototype._shortCuts. This is the original function for a start. You can edit it to fit your needs and load the edited code at some point after XinhaCore.js

Xinha.prototype._shortCuts = function (ev)
{
  var key = this.getKey(ev).toLowerCase();
  var cmd = null;
  var value = null;
  switch (key)
  {
    // simple key commands follow

    case 'b': cmd = "bold"; break;
    case 'i': cmd = "italic"; break;
    case 'u': cmd = "underline"; break;
    case 's': cmd = "strikethrough"; break;
    case 'l': cmd = "justifyleft"; break;
    case 'e': cmd = "justifycenter"; break;
    case 'r': cmd = "justifyright"; break;
    case 'j': cmd = "justifyfull"; break;
    case 'z': cmd = "undo"; break;
    case 'y': cmd = "redo"; break;
    case 'v': cmd = "paste"; break;
    case 'n':
    cmd = "formatblock";
    value = "p";
    break;

    case '0': cmd = "killword"; break;

    // headings
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    cmd = "formatblock";
    value = "h" + key;
    break;
  }
  if ( cmd )
  {
    // execute simple command
    this.execCommand(cmd, false, value);
    Xinha._stopEvent(ev);
  }
};

Be aware, though, that this -- like any "hack" -- after an update could stop working and in any case hinders any improvements made in this function (which are actually likely to  happen some time in the future, as the shortcut handling definitively is too unflexible)

#86 Re: User Discussion & Help » Span vs. Font Depreceated Font Tags » 2007-12-12 17:44:26

ray

This is done by the browser, which you may notice if you use Firefox instead of Internet Explorer. It may be possible to implement such behaviour, but it hasn't been done yet. You may want to post this as an Enhancement in the tickets

#87 Re: User Discussion & Help » Can I load/edit/save online documnets with Xinha? » 2007-12-12 17:37:33

ray

1) Yes, of course. That's exactly what it does
2-5) No. Xinha or any similar online editor do nothing expect provide a means to edit. Any saving or user management etc. is to be done by a CMS.

#88 Re: User Discussion & Help » Does Xinha have to be used in a CMS » 2007-12-12 17:35:53

ray

That's just two different things. Xinha or any similar online editor do nothing expect provide a means to edit. Any saving or user management etc. is to be done by a CMS.

#89 Re: User Discussion & Help » Execute Xinha command from other HTML elements » 2007-11-28 12:06:45

ray

Yes of course you are right as long as you don't want to use plugins

#90 Re: User Discussion & Help » Clicking on "Toggle HTML Source" should not disable all the buttons » 2007-11-28 12:04:08

ray

Hi, the buttons that are disabled in HTML mode are disabled, because they only work in WYSIWIG mode. There is no sense in enabling them when they do nothing and possibly only throw errors

#91 Re: User Discussion & Help » Xinha and zencart » 2007-11-26 20:10:50

ray

That's a pretty frequent source for syntax errors

#92 Re: User Discussion & Help » skins not working in IE » 2007-11-26 20:02:05

ray

try

_editor_skin = "silva";

As to why it doesn't work on your server: not beeing clairvoyant it's hard to guess (if you give a URL, it should be most probably sorted out, but otherwise most probably not)

#93 Re: User Discussion & Help » Xinha and zencart » 2007-11-26 19:54:54

ray

Well from here on the thing starts to get a general JavaScript question, as opposed to a Xinha one. But here we go

if (!xinha_editors) // the init function may be executed several times during plugin loading, but we want to define the array only once
{
  xinhas_editors = []; //new Array
  var allTextareas = document.getElementsByTagName('textarea');
  for (var i=0;i<allTextareas.length;i++) // iterate through the array
  {
    if (allTextareas[i].id != 'exclude') // check whatever condition you need to exclude your textarea
    {
      xinhas_editors.push(allTextareas[i]); // add the others to the array
    }
  }
}

#94 Re: User Discussion & Help » How to change default font (Times New Roman) to something else » 2007-11-26 19:36:52

ray

There's nothing you have to do in this case. The font always starts without an inline font. See here if you neither want to show the font select box

#95 Re: User Discussion & Help » Execute Xinha command from other HTML elements » 2007-11-26 19:28:31

ray
var editor = xinha_editors.idOfYourTextarea; //first, you must get a reference to the object that represents the editor you want to perform commands on

Replace idOfYourTextarea with the according id of your textarea. This assumes that you use the xinha_editors array, as show in the NewbieGuide

var toolbar = editor._toolbarObjects;  // this object contains all the button objects, referenced by a rather arbitrary id
 
toolbar.bold.cmd(); // call the actual button command;  obviously you need the id of the button

Get Firebug and click yourself through the DOM to access the id's of the buttons, and get an overview what's going on inside all these objects

Have fun smile

#96 Re: User Discussion & Help » Setting up Xinha » 2007-11-26 18:51:18

ray

Just a little oversight in your plugins array: you have getHtml where it should be GetHtml (which is the name of the folder in the plugins folder)

#97 Re: User Discussion & Help » Setting up Xinha » 2007-11-24 16:41:09

ray

You have your _editor_url set to "/xinha/XinhaCore/, but indeed your files reside in "/testroot/xinha/". Additionally you have a syntax error (missing ; between definitions of _editor_url and _editor_lang).

So correctly the respective lines should be like

<script type="text/javascript">_editor_url="/testroot/xinha/";
_editor_lang="en";
</script>
<script type="text/javascript" src="/testroot/xinha/XinhaCore.js"></script>
<script type="text/javascript" src="/testroot/xinha/my_config.js"></script>

Another thing: You might want to read this text on using tags inside a textarea

#98 Re: User Discussion & Help » xinha problem with wrong width » 2007-11-18 18:49:01

ray

Do you use a custom toolbar, and may be you have neither "separator" nor "linebreak" tags in it. That causes the toolbar to be one line that causes the table to grow to the length of the toolbar cell. If this is not the case, could you provide a link to a page where one can have a look at the problem? I'd like to help to sort this out, but I cannot reproduce it.

#99 Re: User Discussion & Help » Xinha and zencart » 2007-11-18 18:21:27

ray

Hi, I jaust had the chance to have another look at your problem and found that it's really there's a problem converting all textareas with the described method. I fixed the code accordingly

Now, the way to convert all textareas in a document is to put

  xinha_editors = xinha_editors ? xinha_editors : document.getElementsByTagName('textarea');

in your config as Step 1

For this to work at the moment you have to change the code of XinhaCore.js. Open the the file, locate the function Xinha.makeEditors and replace it by the following code (or simply put it at the end of the file, doesn't actually matter)

Xinha.makeEditors = function(editor_names, default_config, plugin_names)
{
  if ( !Xinha.isSupportedBrowser ) return;
  
  if ( typeof default_config == 'function' )
  {
    default_config = default_config();
  }

  var editors = {};
  var textarea;
  for ( var x = 0; x < editor_names.length; x++ )
  {
    if ( typeof editor_names[x] == 'string' ) // the regular case, an id of a textarea
    {
      textarea = Xinha.getElementById('textarea', editor_names[x] );
      if (!textarea) // the id may be specified for a textarea that is maybe on another page; we simply skip it and go on
      {
        editor_names[x] = null;
        continue;
      }
    }
     // make it possible to pass a reference instead of an id, for example from  document.getElementsByTagName('textarea')
    else if ( typeof editor_names[x] == 'object' && editor_names[x].tagName && editor_names[x].tagName.toLowerCase() == 'textarea' )
    {
      textarea =  editor_names[x];
      if ( !textarea.id ) // we'd like to have the textarea have an id
      {
        textarea.id = 'xinha_id_' + x;
      } 
    }
    var editor = new Xinha(textarea, Xinha.cloneObject(default_config));
    editor.registerPlugins(plugin_names);
    editors[textarea.id] = editor;
  }
  return editors;
};

#100 Re: User Discussion & Help » How to simply enable and disable the text in the editor » 2007-11-16 13:45:34

ray

Im sorry this is not so easily doable as you might think

Board footer

Powered by FluxBB