Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Javascript Functions</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Javascript Functions</h1>
</div>
<div class="content">
<p>This is for advanced users, TinyMCE has a global instance with some public functions that can be called from the page.</p>
<h3>tinyMCE.triggerSave([skip_cleanup], [skip_callback]);</h3>
<p>
Makes a cleanup and moves the contents from the editor to the form field. This method is automaticly called by tinyMCE by adding a trigger on the forms submit method.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>[skip_cleanup]</td>
<td>Disables the cleanup process of trigger save. Defaults to false. (Optional)</td>
</tr>
<tr>
<td>[skip_callback]</td>
<td>Disables the execution of the <a href="option_save_callback.html">save_callback</a> function. Defaults to false. (Optional)</td>
</tr>
</tbody>
</table>
skip_callback
</p>
<p>
Returns: Nothing
</p>
<div class="separator"></div>
<h3>tinyMCE.updateContent(form_element_name);</h3>
<p>
Moves the contents from the form element to the editor, this does the opposite of triggerSave(). This method can be used when you want to change the contents of the editor dynamicly.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>form_element_name</td>
<td>The name of the form element to get contents from.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: Nothing
</p>
<div class="separator"></div>
<h3>tinyMCE.execInstanceCommand(editor_id, command, [user_interface], [value]);</h3>
<p>
This method executes a command by name on the editor instance specified by the editor_id parameter.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>editor_id</td>
<td>ID of editor instance or element id/name of the replaced element.</td>
</tr>
<tr>
<td>command</td>
<td>Command to execute check the execCommand function for details.</td>
</tr>
<tr>
<td>[user_interface]</td>
<td>Is a user interface to be used or not.</td>
</tr>
<tr>
<td>[value]</td>
<td>Value to pass with command for example a URL..</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: Nothing
</p>
<div class="separator"></div>
<h3>tinyMCE.execCommand(command, [user_interface], [value]);</h3>
<p>
This method executes a command by name on the selected editor instance.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>command</td>
<td>Command to execute for example "Bold" or "Italic". These are defined by Mozilla <a href="http://www.mozilla.org/editor/midas-spec.html">Midas specification</a> or <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/commandids.asp">Microsoft specification</a>. But there are a some TinyMCE specific commands many other commands are available within plugins and themes.<br /><br />
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td>mceLink</td>
<td>Opens the insert link dialog and inserts a link.</td>
</tr>
<tr>
<td>mceImage</td>
<td>Opens the insert image dialog and inserts a image.</td>
</tr>
<tr>
<td>mceCleanup</td>
<td>Removed unwanted elements and attributes from the HTML code.</td>
</tr>
<tr>
<td>mceHelp</td>
<td>Opens the manual pages.</td>
</tr>
<tr>
<td>mceAddControl</td>
<td>Adds a editor control to the element id/name specified as value.</td>
</tr>
<tr>
<td>mceRemoveControl</td>
<td>Removes a specific control by editor_id name. The value is the editor_id to remove, editor ids are in the following format: "mce_editor_<index>". DOM element ids and form element names can allso be used.</td>
</tr>
<tr>
<td>mceFocus</td>
<td>Focuses the editor by the id placed in value. Editor id's are in the format "mce_editor_<index>". DOM element ids and form element names can allso be used.</td>
</tr>
<tr>
<td>mceSetCSSClass</td>
<td>Sets the CSS class attribute or creates a new span of the selection. The value is the css class name to assign to selected element or new span element.</td>
</tr>
<tr>
<td>mceInsertContent</td>
<td>Inserts contents of value parameter to current cursor position.</td>
</tr>
<tr>
<td>mceReplaceContent</td>
<td>Replaces the current selection with the HTML code in value. The {$selection} variable gets replaced with the currently selected text contents.</td>
</tr>
<tr>
<td>mceSetAttribute</td>
<td>Sets a attribute of the currenly selected element. The value of this command should be a name/value array with the following parameters.<br /><br />
name - Attribute name to set.<br />
value - Attrbute value to set.<br />
[targets] - Target elements to add attribute on. Default: p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address.<br /><br />
Example of usage:<br />
tinyMCE.execCommand('mceSetAttribute',false,{name:'align',value:'right'});<br />
</td>
</tr>
<tr>
<td>mceToggleVisualAid</td>
<td>Toggles visual aid/guidelines mode on/off.</td>
</tr>
<tr>
<td>mceAnchor</td>
<td>Inserts a named anchor element, the value is the name of the anchor.</td>
</tr>
<tr>
<td>mceResetDesignMode</td>
<td>Resets the designMode state of all editor instances, this command is useful on Firefox if the editor is placed in tabs or shown/hidden with style.display="none/block". Call this command after the editor displayed again.</td>
</tr>
<tr>
<td>mceSelectNode</td>
<td>Selects the node/element passed as value. This command will also scroll to the elements location within the editor.</td>
</tr>
<tr>
<td>mceSelectNodeDepth</td>
<td>Selects the node/element by depth relative from the current node. So a value of 0 will select the currently focused node. This command will also scroll to the elements location within the editor.</td>
</tr>
<tr>
<td>mceRemoveNode</td>
<td>Removes the specified node and places the contents of the node in the same location. Specify the node reference to remove in the value parameter or null if the currently selected node is to be removed.</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>[user_interface]</td>
<td>Tells if the command is to display a user interface or not. True/False option.</td>
</tr>
<tr>
<td>[value]</td>
<td>Value to pass for the command for example to insertLink it's the URL of the link.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: Nothing
</p>
<p>
Example:
</p>
<p>
<div class="example">
<pre>
<a href="javascript:tinymce.execCommand('Bold');">[Do bold]</a>
</pre>
</div>
</p>
<div class="separator"></div>
<h3><span class="marked">(Deprecated)</span> tinyMCE.insertLink(href, target);</h3>
<p>This method is deprecated and removed as of 2.0.3. Use tinyMCE.execCommand('mceInsertContent',false,'custom html'); instead and tinyMCE.getInstanceById('<inst>').selection.getFocusElement() to retrive/update the selected element.</p>
<p>But if you realy need the old function it's marked internal but is available in the advanced theme and you can call it by using tinyMCE.themes['advanced']._insertLink(href, target);. But the recommended way is to modify your code to use the logic above.</p>
<p>This method inserts a link a the cursor position of the selected editor instance or updates the selected link with new data. This method should be called upon "ok" in the insertLink popup when you create custom themes.
</p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>href</td>
<td>HREF/URL of the link.</td>
</tr>
<tr>
<td>target</td>
<td>Target of the link.</td>
</tr>
</tbody>
</table>
<p>
Returns: Nothing
</p>
<div class="separator"></div>
<h3><span class="marked">(Deprecated)</span> tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout);</h4>
<p>This method is deprecated and removed as of 2.0.3. Use tinyMCE.execCommand('mceInsertContent',false,'custom html'); instead or if you realy need the old function it's marked internal but is available in the advanced theme and you can call it by using tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout);. But the recommended way is to modify your code to use the logic above.</p>
<p>
This method inserts a image a the cursor position of the selected editor instance or updates the selected image with new data. This method should be called upon "ok" in the insertImage popup when you create custom themes.
</p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>src</td>
<td>Image src url.</td>
</tr>
<tr>
<td>alt</td>
<td>Alternative text of img element.</td>
</tr>
<tr>
<td>border</td>
<td>Border of image element.</td>
</tr>
<tr>
<td>hspace</td>
<td>Horizontal spacing of image element.</td>
</tr>
<tr>
<td>vspace</td>
<td>Vertical spacing of image element.</td>
</tr>
<tr>
<td>width</td>
<td>Width of image element.</td>
</tr>
<tr>
<td>height</td>
<td>Height of image element.</td>
</tr>
<tr>
<td>align</td>
<td>Alignment of image element.</td>
</tr>
<tr>
<td>title</td>
<td>Link title of image element.</td>
</tr>
<tr>
<td>onmouseover</td>
<td>On mouse over event handler of image element.</td>
</tr>
<tr>
<td>onmouseout</td>
<td>On mouse out event handler of image element.</td>
</tr>
</tbody>
</table>
<p>
Returns: Nothing
</p>
<div class="separator"></div>
<h3>tinyMCE.triggerNodeChange();</h3>
<p>This method is to be called when external changes is made to the editor. This method will then call the "handleNodeChangeCallback" callback in the theme.
</p>
<p>
Parameters:
</p>
<p>
None
</p>
<p>
Returns: Nothing
</p>
<div class="separator"></div>
<h3>tinyMCE.getContent();</h3>
<p>
This method returns the HTML contents of the currently selected editor or null if no editor was selected.
</p>
<p>
Parameters:
</p>
<p>
None
</p>
<p>
Returns: HTML contents of the currently selected editor or null.
</p>
<div class="separator"></div>
<h3>Syntax: tinyMCE.setContent(html);</h3>
<p>This method sets the HTML contents of the currently selected editor.</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>html</td>
<td>HTML Source code to set.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: None.
</p>
<div class="separator"></div>
<h3>tinyMCE.getInstanceById(editor_id);</h3>
<p>
This method returns a editor instance by editor id.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>editor_id</td>
<td>Editor instance to retrive.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: TinyMCE Editor instance (TinyMCE_Control).
</p>
<div class="separator"></div>
<h3>tinyMCE.importThemeLanguagePack([theme]);</h3>
<p>
This method imports/loads theme specific language packs. This may be called from custom themes.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>[theme]</td>
<td>Name of the current theme. This is a optional parameter it defaults to the global "theme" setting. This parameter is useful within theme plugins.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: None.
</p>
<div class="separator"></div>
<h3>tinyMCE.importPluginLanguagePack(plugin, valid_languages);</h3>
<p>
This method imports/loads plugin specific language packs. This may be called from custom plugins.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>plugin</td>
<td>Name of the current plugin.</td>
</tr>
<tr>
<td>valid_languages</td>
<td>Comma separated list of supported languagepacks.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: None.
</p>
<div class="separator"></div>
<h3>tinyMCE.applyTemplate(html);</h3>
<p>
This method replaces settings and lang variables in the theme.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>html</td>
<td>HTML code to apply theme variable substitution on.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: New converted, HTML code.
</p>
<div class="separator"></div>
<h3>tinyMCE.openWindow(template, [args]);</h3>
<p>This method opens a new window by the template data assigned, it will get the width, height and html data from template parameters. The args array contains variable names to be substituted.</p>
<p>
There are some custom window arguments:
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>mce_replacevariables</td>
<td>Enables/Disables the language/variable replacement of the document HTML. Enabled by default.</td>
</tr>
<tr>
<td>mce_windowresize</td>
<td>Enables/Disables the auto resize feature of popupwindows. Enabled by default.</td>
</tr>
</tbody>
</table>
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>template</td>
<td>Name/Value array with width, height, html and file keys in it.</td>
</tr>
<tr>
<td>[args]</td>
<td>Name/Value array with variable names to replace. Variables in the template file key value (URL) gets replaced with the argument list.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: None.
</p>
<div class="separator"></div>
<h3>tinyMCE.getWindowArg(name, [default_value]);</h3>
<p>
This method returns a window argument defined by name. This function is to be used in theme popup windows to retrive dialog parameters.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>Name of window argument to get.</td>
</tr>
<tr>
<td>[default_value]</td>
<td>Default value to be returned if window argument is missing.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: Window argument value.
</p>
<div class="separator"></div>
<h3>tinyMCE.setWindowArg(name, value);</h3>
<p>This method sets a window argument by name. This can for example be useful if plugin are to call other plugins.</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>Name of window argument to set.</td>
</tr>
<tr>
<td>value</td>
<td>Value to set in window argument.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: Window argument value.
</p>
<div class="separator"></div>
<h3>tinyMCE.getParam(name, [default_value], [strip_whitespace]);</h3>
<p>This method returns a TinyMCE configuration parameter.</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters:</td>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>Name of window argument to get.</td>
</tr>
<tr>
<td>[default_value]</td>
<td>Default value to be returned if window argument is missing.</td>
</tr>
<tr>
<td>[strip_whitespace]</td>
<td>If true all whitespace will be removed from return value, default: false.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: TinyMCE configuration parameter.
</p>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright © 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>