source: trunk/examples/XinhaConfig.js @ 999

Last change on this file since 999 was 999, checked in by ray, 11 years ago

#1195 Allow to specify an external url to load a plugin from

File size: 4.5 KB
Line 
1xinha_editors = null;
2xinha_init    = null;
3xinha_config  = null;
4xinha_plugins = null;
5
6// This contains the names of textareas we will make into Xinha editors
7xinha_init = xinha_init ? xinha_init : function()
8{
9   /** STEP 1 ***************************************************************
10   * First, specify the textareas that shall be turned into Xinhas.
11   * For each one add the respective id to the xinha_editors array.
12   * I you want add more than on textarea, keep in mind that these
13   * values are comma seperated BUT there is no comma after the last value.
14   * If you are going to use this configuration on several pages with different
15   * textarea ids, you can add them all. The ones that are not found on the
16   * current page will just be skipped.
17   ************************************************************************/
18
19  xinha_editors = xinha_editors ? xinha_editors :
20  [
21    'myTextArea', 'anotherOne'
22  ];
23 
24  /** STEP 2 ***************************************************************
25   * Now, what are the plugins you will be using in the editors on this
26   * page.  List all the plugins you will need, even if not all the editors
27   * will use all the plugins.
28   *
29   * The list of plugins below is a good starting point, but if you prefer
30   * a simpler editor to start with then you can use the following
31   *
32   * xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
33   *
34   * which will load no extra plugins at all.
35   ************************************************************************/
36
37  xinha_plugins = xinha_plugins ? xinha_plugins :
38  [
39   'CharacterMap',
40   'ContextMenu',
41   { plugin: 'SmartReplace',url: '/xff3/xSmartReplace/smart-replace.js' },
42   //'SmartReplace',
43   'Stylist',
44   'Linker',
45   'SuperClean',
46   'TableOperations',
47   'SetId',
48   'FullScreen'
49  ];
50 
51         // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
52         if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
53
54
55  /** STEP 3 ***************************************************************
56   * We create a default configuration to be used by all the editors.
57   * If you wish to configure some of the editors differently this will be
58   * done in step 5.
59   *
60   * If you want to modify the default config you might do something like this.
61   *
62   *   xinha_config = new Xinha.Config();
63   *   xinha_config.width  = '640px';
64   *   xinha_config.height = '420px';
65   *
66   *************************************************************************/
67
68   xinha_config = xinha_config ? xinha_config() : new Xinha.Config();
69       
70   // To adjust the styling inside the editor, we can load an external stylesheet like this
71   // NOTE : YOU MUST GIVE AN ABSOLUTE URL
72 
73   xinha_config.pageStyleSheets = [ _editor_url + "examples/full_example.css" ];
74
75  /** STEP 4 ***************************************************************
76   * We first create editors for the textareas.
77   *
78   * You can do this in two ways, either
79   *
80   *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
81   *
82   * if you want all the editor objects to use the same set of plugins, OR;
83   *
84   *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
85   *   xinha_editors.myTextArea.registerPlugins(['Stylist']);
86   *   xinha_editors.anotherOne.registerPlugins(['CSS','SuperClean']);
87   *
88   * if you want to use a different set of plugins for one or more of the
89   * editors.
90   ************************************************************************/
91
92  xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
93
94  /** STEP 5 ***************************************************************
95   * If you want to change the configuration variables of any of the
96   * editors,  this is the place to do that, for example you might want to
97   * change the width and height of one of the editors, like this...
98   *
99   *   xinha_editors.myTextArea.config.width  = '640px';
100   *   xinha_editors.myTextArea.config.height = '480px';
101   *
102   ************************************************************************/
103
104
105  /** STEP 6 ***************************************************************
106   * Finally we "start" the editors, this turns the textareas into
107   * Xinha editors.
108   ************************************************************************/
109
110  Xinha.startEditors(xinha_editors);
111}
112
113Xinha.addOnloadHandler(xinha_init); // this executes the xinha_init function on page load
114                                     // and does not interfere with window.onload properties set by other scripts
115
Note: See TracBrowser for help on using the repository browser.