~clinton-collins/familyproject/trunk

« back to all changes in this revision

Viewing changes to ZendFramework/externals/dojo/dijit/Editor.js

  • Committer: Clinton Collins
  • Date: 2009-06-26 19:54:58 UTC
  • Revision ID: clinton.collins@gmail.com-20090626195458-5ebba0qcvo15xlpy
Initial Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dojo.provide("dijit.Editor");
 
2
dojo.require("dijit._editor.RichText");
 
3
dojo.require("dijit.Toolbar");
 
4
dojo.require("dijit.ToolbarSeparator");
 
5
dojo.require("dijit._editor._Plugin");
 
6
dojo.require("dijit._editor.plugins.EnterKeyHandling");
 
7
dojo.require("dijit._editor.range");
 
8
dojo.require("dijit._Container");
 
9
dojo.require("dojo.i18n");
 
10
dojo.requireLocalization("dijit._editor", "commands");
 
11
 
 
12
dojo.declare(
 
13
        "dijit.Editor",
 
14
        dijit._editor.RichText,
 
15
        {
 
16
                // summary:
 
17
                //              A rich text Editing widget
 
18
                //
 
19
                // description:
 
20
                //              This widget provides basic WYSIWYG editing features, based on the browser's
 
21
                //              underlying rich text editing capability, accompanied by a toolbar (dijit.Toolbar).
 
22
                //              A plugin model is available to extend the editor's capabilities as well as the
 
23
                //              the options available in the toolbar.  Content generation may vary across
 
24
                //              browsers, and clipboard operations may have different results, to name
 
25
                //              a few limitations.  Note: this widget should not be used with the HTML
 
26
                //              <TEXTAREA> tag -- see dijit._editor.RichText for details.
 
27
 
 
28
                // plugins: String[]
 
29
                //              A list of plugin names (as strings) or instances (as objects)
 
30
                //              for this widget.
 
31
                plugins: null,
 
32
 
 
33
                // extraPlugins: String[]
 
34
                //              A list of extra plugin names which will be appended to plugins array
 
35
                extraPlugins: null,
 
36
 
 
37
                constructor: function(){
 
38
                        // summary:
 
39
                        //              Runs on widget initialization to setup arrays etc.
 
40
                        // tags:
 
41
                        //              private
 
42
 
 
43
                        if(!dojo.isArray(this.plugins)){
 
44
                                this.plugins=["undo","redo","|","cut","copy","paste","|","bold","italic","underline","strikethrough","|",
 
45
                                "insertOrderedList","insertUnorderedList","indent","outdent","|","justifyLeft","justifyRight","justifyCenter","justifyFull",
 
46
                                "dijit._editor.plugins.EnterKeyHandling" /*, "createLink"*/];
 
47
                        }
 
48
 
 
49
                        this._plugins=[];
 
50
                        this._editInterval = this.editActionInterval * 1000;
 
51
 
 
52
                        //IE will always lose focus when other element gets focus, while for FF and safari,
 
53
                        //when no iframe is used, focus will be lost whenever another element gets focus.
 
54
                        //For IE, we can connect to onBeforeDeactivate, which will be called right before
 
55
                        //the focus is lost, so we can obtain the selected range. For other browsers,
 
56
                        //no equivelent of onBeforeDeactivate, so we need to do two things to make sure 
 
57
                        //selection is properly saved before focus is lost: 1) when user clicks another 
 
58
                        //element in the page, in which case we listen to mousedown on the entire page and
 
59
                        //see whether user clicks out of a focus editor, if so, save selection (focus will
 
60
                        //only lost after onmousedown event is fired, so we can obtain correct caret pos.)
 
61
                        //2) when user tabs away from the editor, which is handled in onKeyDown below.
 
62
                        if(dojo.isIE){
 
63
                                this.events.push("onBeforeDeactivate");
 
64
                        }
 
65
                },
 
66
 
 
67
                postCreate: function(){
 
68
                        //for custom undo/redo
 
69
                        if(this.customUndo){
 
70
                                dojo['require']("dijit._editor.range");
 
71
                                this._steps=this._steps.slice(0);
 
72
                                this._undoedSteps=this._undoedSteps.slice(0);
 
73
//                              this.addKeyHandler('z',this.KEY_CTRL,this.undo);
 
74
//                              this.addKeyHandler('y',this.KEY_CTRL,this.redo);
 
75
                        }
 
76
                        if(dojo.isArray(this.extraPlugins)){
 
77
                                this.plugins=this.plugins.concat(this.extraPlugins);
 
78
                        }
 
79
 
 
80
//                      try{
 
81
                        this.inherited(arguments);
 
82
//                      dijit.Editor.superclass.postCreate.apply(this, arguments);
 
83
 
 
84
                        this.commands = dojo.i18n.getLocalization("dijit._editor", "commands", this.lang);
 
85
 
 
86
                        if(!this.toolbar){
 
87
                                // if we haven't been assigned a toolbar, create one
 
88
                                this.toolbar = new dijit.Toolbar({});
 
89
                                dojo.place(this.toolbar.domNode, this.editingArea, "before");
 
90
                        }
 
91
 
 
92
                        dojo.forEach(this.plugins, this.addPlugin, this);
 
93
                        this.onNormalizedDisplayChanged(); //update toolbar button status
 
94
//                      }catch(e){ console.debug(e); }
 
95
 
 
96
                        this.toolbar.startup();
 
97
                },
 
98
                destroy: function(){
 
99
                        dojo.forEach(this._plugins, function(p){
 
100
                                if(p && p.destroy){
 
101
                                        p.destroy();
 
102
                                }
 
103
                        });
 
104
                        this._plugins=[];
 
105
                        this.toolbar.destroyRecursive();
 
106
                        delete this.toolbar;
 
107
                        this.inherited(arguments);
 
108
                },
 
109
                addPlugin: function(/*String||Object*/plugin, /*Integer?*/index){
 
110
                        // summary:
 
111
                        //              takes a plugin name as a string or a plugin instance and
 
112
                        //              adds it to the toolbar and associates it with this editor
 
113
                        //              instance. The resulting plugin is added to the Editor's
 
114
                        //              plugins array. If index is passed, it's placed in the plugins
 
115
                        //              array at that index. No big magic, but a nice helper for
 
116
                        //              passing in plugin names via markup.
 
117
                        //
 
118
                        // plugin: String, args object or plugin instance
 
119
                        //
 
120
                        // args:
 
121
                        //              This object will be passed to the plugin constructor
 
122
                        //
 
123
                        // index: Integer
 
124
                        //              Used when creating an instance from
 
125
                        //              something already in this.plugins. Ensures that the new
 
126
                        //              instance is assigned to this.plugins at that index.
 
127
                        var args=dojo.isString(plugin)?{name:plugin}:plugin;
 
128
                        if(!args.setEditor){
 
129
                                var o={"args":args,"plugin":null,"editor":this};
 
130
                                dojo.publish(dijit._scopeName + ".Editor.getPlugin",[o]);
 
131
                                if(!o.plugin){
 
132
                                        var pc = dojo.getObject(args.name);
 
133
                                        if(pc){
 
134
                                                o.plugin=new pc(args);
 
135
                                        }
 
136
                                }
 
137
                                if(!o.plugin){
 
138
                                        console.warn('Cannot find plugin',plugin);
 
139
                                        return;
 
140
                                }
 
141
                                plugin=o.plugin;
 
142
                        }
 
143
                        if(arguments.length > 1){
 
144
                                this._plugins[index] = plugin;
 
145
                        }else{
 
146
                                this._plugins.push(plugin);
 
147
                        }
 
148
                        plugin.setEditor(this);
 
149
                        if(dojo.isFunction(plugin.setToolbar)){
 
150
                                plugin.setToolbar(this.toolbar);
 
151
                        }
 
152
                },
 
153
                //the following 3 functions are required to make the editor play nice under a layout widget, see #4070
 
154
                startup: function(){
 
155
                        // summary:
 
156
                        //              Exists to make Editor work as a child of a layout widget.
 
157
                        //              Developers don't need to call this method.
 
158
                        // tags:
 
159
                        //              protected
 
160
                        //console.log('startup',arguments);
 
161
                },
 
162
                resize: function(size){
 
163
                        // summary:
 
164
                        //              Resize the editor to the specified size, see `dijit.layout._LayoutWidget.resize`
 
165
                        dijit.layout._LayoutWidget.prototype.resize.apply(this,arguments);
 
166
                },
 
167
                layout: function(){
 
168
                        // summary:
 
169
                        //              Called from `dijit.layout._LayoutWidget.resize`.  This shouldn't be called directly
 
170
                        // tags:
 
171
                        //              protected
 
172
                        this.editingArea.style.height=(this._contentBox.h - dojo.marginBox(this.toolbar.domNode).h)+"px";
 
173
                        if(this.iframe){
 
174
                                this.iframe.style.height="100%";
 
175
                        }
 
176
                        this._layoutMode = true;
 
177
                },
 
178
                _onIEMouseDown: function(/*Event*/ e){
 
179
                        // summary:
 
180
                        //              IE only to prevent 2 clicks to focus
 
181
                        // tags:
 
182
                        //              private
 
183
                        delete this._savedSelection; // new mouse position overrides old selection
 
184
                        if(e.target.tagName == "BODY"){
 
185
                                setTimeout(dojo.hitch(this, "placeCursorAtEnd"), 0);
 
186
                        }
 
187
                        this.inherited(arguments);
 
188
                },
 
189
                onBeforeDeactivate: function(e){
 
190
                        // summary:
 
191
                        //              Called on IE right before focus is lost.   Saves the selected range.
 
192
                        // tags:
 
193
                        //              private
 
194
                        if(this.customUndo){
 
195
                                this.endEditing(true);
 
196
                        }
 
197
                        //in IE, the selection will be lost when other elements get focus,
 
198
                        //let's save focus before the editor is deactivated
 
199
                        this._saveSelection();
 
200
                //console.log('onBeforeDeactivate',this);
 
201
                },
 
202
 
 
203
                /* beginning of custom undo/redo support */
 
204
 
 
205
                // customUndo: Boolean
 
206
                //              Whether we shall use custom undo/redo support instead of the native
 
207
                //              browser support. By default, we only enable customUndo for IE, as it
 
208
                //              has broken native undo/redo support. Note: the implementation does
 
209
                //              support other browsers which have W3C DOM2 Range API implemented.
 
210
                customUndo: dojo.isIE,
 
211
 
 
212
                // editActionInterval: Integer
 
213
                //              When using customUndo, not every keystroke will be saved as a step.
 
214
                //              Instead typing (including delete) will be grouped together: after
 
215
                //              a user stops typing for editActionInterval seconds, a step will be
 
216
                //              saved; if a user resume typing within editActionInterval seconds,
 
217
                //              the timeout will be restarted. By default, editActionInterval is 3
 
218
                //              seconds.
 
219
                editActionInterval: 3,
 
220
 
 
221
                beginEditing: function(cmd){
 
222
                        // summary:
 
223
                        //              Called to note that the user has started typing alphanumeric characters, if it's not already noted.
 
224
                        //              Deals with saving undo; see editActionInterval parameter.
 
225
                        // tags:
 
226
                        //              private
 
227
                        if(!this._inEditing){
 
228
                                this._inEditing=true;
 
229
                                this._beginEditing(cmd);
 
230
                        }
 
231
                        if(this.editActionInterval>0){
 
232
                                if(this._editTimer){
 
233
                                        clearTimeout(this._editTimer);
 
234
                                }
 
235
                                this._editTimer = setTimeout(dojo.hitch(this, this.endEditing), this._editInterval);
 
236
                        }
 
237
                },
 
238
                _steps:[],
 
239
                _undoedSteps:[],
 
240
                execCommand: function(cmd){
 
241
                        // summary:
 
242
                        //              Main handler for executing any commands to the editor, like paste, bold, etc.
 
243
                        //      Called by plugins, but not meant to be called by end users.
 
244
                        // tags:
 
245
                        //              protected
 
246
                        if(this.customUndo && (cmd=='undo' || cmd=='redo')){
 
247
                                return this[cmd]();
 
248
                        }else{
 
249
                                if(this.customUndo){
 
250
                                        this.endEditing();
 
251
                                        this._beginEditing();
 
252
                                }
 
253
                                try{
 
254
                                        var r = this.inherited('execCommand', arguments);
 
255
                    if(dojo.isWebKit && cmd=='paste' && !r){ //see #4598: safari does not support invoking paste from js
 
256
                                                throw { code: 1011 }; // throw an object like Mozilla's error
 
257
                    }
 
258
                                }catch(e){
 
259
                                        //TODO: when else might we get an exception?  Do we need the Mozilla test below?
 
260
                                        if(e.code == 1011 /* Mozilla: service denied */ && /copy|cut|paste/.test(cmd)){
 
261
                                                // Warn user of platform limitation.  Cannot programmatically access clipboard. See ticket #4136
 
262
                                                var sub = dojo.string.substitute,
 
263
                                                        accel = {cut:'X', copy:'C', paste:'V'},
 
264
                                                        isMac = navigator.userAgent.indexOf("Macintosh") != -1;
 
265
                                                alert(sub(this.commands.systemShortcut,
 
266
                                                        [this.commands[cmd], sub(this.commands[isMac ? 'appleKey' : 'ctrlKey'], [accel[cmd]])]));
 
267
                                        }
 
268
                                        r = false;
 
269
                                }
 
270
                                if(this.customUndo){
 
271
                                        this._endEditing();
 
272
                                }
 
273
                                return r;
 
274
                        }
 
275
                },
 
276
                queryCommandEnabled: function(cmd){
 
277
                        // summary:
 
278
                        //              Returns true if specified editor command is enabled.
 
279
                        //      Used by the plugins to know when to highlight/not highlight buttons.
 
280
                        // tags:
 
281
                        //              protected
 
282
                        if(this.customUndo && (cmd=='undo' || cmd=='redo')){
 
283
                                return cmd=='undo'?(this._steps.length>1):(this._undoedSteps.length>0);
 
284
                        }else{
 
285
                                return this.inherited('queryCommandEnabled',arguments);
 
286
                        }
 
287
                },
 
288
 
 
289
                focus: function(){
 
290
                        // summary:
 
291
                        //              Set focus inside the editor
 
292
                        var restore=0;
 
293
                        //console.log('focus',dijit._curFocus==this.editNode)
 
294
                        if(this._savedSelection && dojo.isIE){
 
295
                                restore = dijit._curFocus!=this.editNode;
 
296
                        }
 
297
                    this.inherited(arguments);
 
298
                    if(restore){
 
299
                        this._restoreSelection();
 
300
                    }
 
301
                },
 
302
                _moveToBookmark: function(b){
 
303
                        // summary:
 
304
                        //              Selects the text specified in bookmark b
 
305
                        // tags:
 
306
                        //              private
 
307
                        var bookmark=b;
 
308
                        if(dojo.isIE){
 
309
                                if(dojo.isArray(b)){//IE CONTROL
 
310
                                        bookmark=[];
 
311
                                        dojo.forEach(b,function(n){
 
312
                                                bookmark.push(dijit.range.getNode(n,this.editNode));
 
313
                                        },this);
 
314
                                }
 
315
                        }else{//w3c range
 
316
                                var r=dijit.range.create();
 
317
                                r.setStart(dijit.range.getNode(b.startContainer,this.editNode),b.startOffset);
 
318
                                r.setEnd(dijit.range.getNode(b.endContainer,this.editNode),b.endOffset);
 
319
                                bookmark=r;
 
320
                        }
 
321
                        dojo.withGlobal(this.window,'moveToBookmark',dijit,[bookmark]);
 
322
                },
 
323
                _changeToStep: function(from, to){
 
324
                        // summary:
 
325
                        //              Reverts editor to "to" setting, from the undo stack.
 
326
                        // tags:
 
327
                        //              private
 
328
                        this.setValue(to.text);
 
329
                        var b=to.bookmark;
 
330
                        if(!b){ return; }
 
331
                        this._moveToBookmark(b);
 
332
                },
 
333
                undo: function(){
 
334
                        // summary:
 
335
                        //              Handler for editor undo (ex: ctrl-z) operation
 
336
                        // tags:
 
337
                        //              private
 
338
//                      console.log('undo');
 
339
                        this.endEditing(true);
 
340
                        var s=this._steps.pop();
 
341
                        if(this._steps.length>0){
 
342
                                this.focus();
 
343
                                this._changeToStep(s,this._steps[this._steps.length-1]);
 
344
                                this._undoedSteps.push(s);
 
345
                                this.onDisplayChanged();
 
346
                                return true;
 
347
                        }
 
348
                        return false;
 
349
                },
 
350
                redo: function(){
 
351
                        // summary:
 
352
                        //              Handler for editor redo (ex: ctrl-y) operation
 
353
                        // tags:
 
354
                        //              private
 
355
 
 
356
//                      console.log('redo');
 
357
                        this.endEditing(true);
 
358
                        var s=this._undoedSteps.pop();
 
359
                        if(s && this._steps.length>0){
 
360
                                this.focus();
 
361
                                this._changeToStep(this._steps[this._steps.length-1],s);
 
362
                                this._steps.push(s);
 
363
                                this.onDisplayChanged();
 
364
                                return true;
 
365
                        }
 
366
                        return false;
 
367
                },
 
368
                endEditing: function(ignore_caret){
 
369
                        // summary:
 
370
                        //              Called to note that the user has stopped typing alphanumeric characters, if it's not already noted.
 
371
                        //              Deals with saving undo; see editActionInterval parameter.
 
372
                        // tags:
 
373
                        //              private
 
374
                        if(this._editTimer){
 
375
                                clearTimeout(this._editTimer);
 
376
                        }
 
377
                        if(this._inEditing){
 
378
                                this._endEditing(ignore_caret);
 
379
                                this._inEditing=false;
 
380
                        }
 
381
                },
 
382
                _getBookmark: function(){
 
383
                        // summary:
 
384
                        //              Get the currently selected text
 
385
                        // tags:
 
386
                        //              protected
 
387
                        var b=dojo.withGlobal(this.window,dijit.getBookmark);
 
388
                        var tmp=[];
 
389
                        if(dojo.isIE){
 
390
                                if(dojo.isArray(b)){//CONTROL
 
391
                                        dojo.forEach(b,function(n){
 
392
                                                tmp.push(dijit.range.getIndex(n,this.editNode).o);
 
393
                                        },this);
 
394
                                        b=tmp;
 
395
                                }
 
396
                        }else{//w3c range
 
397
                                tmp=dijit.range.getIndex(b.startContainer,this.editNode).o;
 
398
                                b={startContainer:tmp,
 
399
                                        startOffset:b.startOffset,
 
400
                                        endContainer:b.endContainer===b.startContainer?tmp:dijit.range.getIndex(b.endContainer,this.editNode).o,
 
401
                                        endOffset:b.endOffset};
 
402
                        }
 
403
                        return b;
 
404
                },
 
405
                _beginEditing: function(cmd){
 
406
                        // summary:
 
407
                        //              Called when the user starts typing alphanumeric characters.
 
408
                        //              Deals with saving undo; see editActionInterval parameter.
 
409
                        // tags:
 
410
                        //              private
 
411
                        if(this._steps.length===0){
 
412
                                this._steps.push({'text':this.savedContent,'bookmark':this._getBookmark()});
 
413
                        }
 
414
                },
 
415
                _endEditing: function(ignore_caret){
 
416
                        // summary:
 
417
                        //              Called when the user stops typing alphanumeric characters.
 
418
                        //              Deals with saving undo; see editActionInterval parameter.
 
419
                        // tags:
 
420
                        //              private
 
421
                        var v=this.getValue(true);
 
422
 
 
423
                        this._undoedSteps=[];//clear undoed steps
 
424
                        this._steps.push({text: v, bookmark: this._getBookmark()});
 
425
                },
 
426
                onKeyDown: function(e){
 
427
                        // summary:
 
428
                        //              Handler for onkeydown event.
 
429
                        // tags:
 
430
                        //              private
 
431
 
 
432
                        //We need to save selection if the user TAB away from this editor
 
433
                        //no need to call _saveSelection for IE, as that will be taken care of in onBeforeDeactivate
 
434
                        if(!dojo.isIE && !this.iframe && e.keyCode==dojo.keys.TAB && !this.tabIndent){
 
435
                                this._saveSelection();
 
436
                        }
 
437
                        if(!this.customUndo){
 
438
                                this.inherited(arguments);
 
439
                                return;
 
440
                        }
 
441
                        var k = e.keyCode, ks = dojo.keys;
 
442
                        if(e.ctrlKey && !e.altKey){//undo and redo only if the special right Alt + z/y are not pressed #5892
 
443
                                if(k == 90 || k == 122){ //z
 
444
                                        dojo.stopEvent(e);
 
445
                                        this.undo();
 
446
                                        return;
 
447
                                }else if(k == 89 || k == 121){ //y
 
448
                                        dojo.stopEvent(e);
 
449
                                        this.redo();
 
450
                                        return;
 
451
                                }
 
452
                        }
 
453
                        this.inherited(arguments);
 
454
 
 
455
                        switch(k){
 
456
                                        case ks.ENTER:
 
457
                                        case ks.BACKSPACE:
 
458
                                        case ks.DELETE:
 
459
                                                this.beginEditing();
 
460
                                                break;
 
461
                                        case 88: //x
 
462
                                        case 86: //v
 
463
                                                if(e.ctrlKey && !e.altKey && !e.metaKey){
 
464
                                                        this.endEditing();//end current typing step if any
 
465
                                                        if(e.keyCode == 88){
 
466
                                                                this.beginEditing('cut');
 
467
                                                                //use timeout to trigger after the cut is complete
 
468
                                                                setTimeout(dojo.hitch(this, this.endEditing), 1);
 
469
                                                        }else{
 
470
                                                                this.beginEditing('paste');
 
471
                                                                //use timeout to trigger after the paste is complete
 
472
                                                                setTimeout(dojo.hitch(this, this.endEditing), 1);
 
473
                                                        }
 
474
                                                        break;
 
475
                                                }
 
476
                                                //pass through
 
477
                                        default:
 
478
                                                if(!e.ctrlKey && !e.altKey && !e.metaKey && (e.keyCode<dojo.keys.F1 || e.keyCode>dojo.keys.F15)){
 
479
                                                        this.beginEditing();
 
480
                                                        break;
 
481
                                                }
 
482
                                                //pass through
 
483
                                        case ks.ALT:
 
484
                                                this.endEditing();
 
485
                                                break;
 
486
                                        case ks.UP_ARROW:
 
487
                                        case ks.DOWN_ARROW:
 
488
                                        case ks.LEFT_ARROW:
 
489
                                        case ks.RIGHT_ARROW:
 
490
                                        case ks.HOME:
 
491
                                        case ks.END:
 
492
                                        case ks.PAGE_UP:
 
493
                                        case ks.PAGE_DOWN:
 
494
                                                this.endEditing(true);
 
495
                                                break;
 
496
                                        //maybe ctrl+backspace/delete, so don't endEditing when ctrl is pressed
 
497
                                        case ks.CTRL:
 
498
                                        case ks.SHIFT:
 
499
                                        case ks.TAB:
 
500
                                                break;
 
501
                                }
 
502
                },
 
503
                _onBlur: function(){
 
504
                        // summary:
 
505
                        //              Called from focus manager when focus has moved away from this editor
 
506
                        // tags:
 
507
                        //              protected
 
508
 
 
509
                        //this._saveSelection();
 
510
                        this.inherited('_onBlur',arguments);
 
511
                        this.endEditing(true);
 
512
                },
 
513
                _saveSelection: function(){
 
514
                        // summary:
 
515
                        //              Save the currently selected text in _savedSelection attribute
 
516
                        // tags:
 
517
                        //              private
 
518
                        this._savedSelection=this._getBookmark();
 
519
                        //console.log('save selection',this._savedSelection,this);
 
520
                },
 
521
                _restoreSelection: function(){
 
522
                        // summary:
 
523
                        //              Re-select the text specified in _savedSelection attribute;
 
524
                        //              see _saveSelection().
 
525
                        // tags:
 
526
                        //              private
 
527
                        if(this._savedSelection){
 
528
                                //only restore the selection if the current range is collapsed
 
529
                        //if not collapsed, then it means the editor does not lose 
 
530
                        //selection and there is no need to restore it
 
531
                        //if(dojo.withGlobal(this.window,'isCollapsed',dijit)){
 
532
                                //console.log('_restoreSelection true')
 
533
                                        this._moveToBookmark(this._savedSelection);
 
534
                                //}
 
535
                                delete this._savedSelection;
 
536
                        }
 
537
                },
 
538
                _onFocus: function(){
 
539
                        // summary:
 
540
                        //              Called from focus manager when focus has moved into this editor
 
541
                        // tags:
 
542
                        //              protected
 
543
 
 
544
                        //console.log('_onFocus');
 
545
                        setTimeout(dojo.hitch(this, "_restoreSelection"), 0); // needs input caret first
 
546
                        this.inherited(arguments);
 
547
                },
 
548
 
 
549
                onClick: function(){
 
550
                        // summary:
 
551
                        //              Handler for when editor is clicked
 
552
                        // tags:
 
553
                        //              protected
 
554
                        this.endEditing(true);
 
555
                        this.inherited(arguments);
 
556
                }
 
557
                /* end of custom undo/redo support */
 
558
        }
 
559
);
 
560
 
 
561
// Register the "default plugins", ie, the built-in editor commands
 
562
dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
 
563
        if(o.plugin){ return; }
 
564
        var args = o.args, p;
 
565
        var _p = dijit._editor._Plugin;
 
566
        var name = args.name;
 
567
        switch(name){
 
568
                case "undo": case "redo": case "cut": case "copy": case "paste": case "insertOrderedList":
 
569
                case "insertUnorderedList": case "indent": case "outdent": case "justifyCenter":
 
570
                case "justifyFull": case "justifyLeft": case "justifyRight": case "delete":
 
571
                case "selectAll": case "removeFormat": case "unlink":
 
572
                case "insertHorizontalRule":
 
573
                        p = new _p({ command: name });
 
574
                        break;
 
575
 
 
576
                case "bold": case "italic": case "underline": case "strikethrough":
 
577
                case "subscript": case "superscript":
 
578
                        p = new _p({ buttonClass: dijit.form.ToggleButton, command: name });
 
579
                        break;
 
580
                case "|":
 
581
                        p = new _p({ button: new dijit.ToolbarSeparator() });
 
582
        }
 
583
//      console.log('name',name,p);
 
584
        o.plugin=p;
 
585
});
 
 
b'\\ No newline at end of file'