2
YUI 3.10.3 (build 2fb5187)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('editor-lists', function (Y, NAME) {
12
* Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support.
13
* Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a>
14
* and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
15
* @class Plugin.EditorLists
19
* @submodule editor-lists
22
var EditorLists = function() {
23
EditorLists.superclass.constructor.apply(this, arguments);
24
}, LI = 'li', OL = 'ol', UL = 'ul', HOST = 'host';
26
Y.extend(EditorLists, Y.Base, {
28
* Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
30
* @method _onNodeChange
31
* @param {Event} e The Event facade passed from the host.
33
_onNodeChange: function(e) {
34
var inst = this.get(HOST).getInstance(), li,
35
newList, sTab, par, moved = false, tag, focusEnd = false;
37
if (e.changedType === 'tab') {
38
if (e.changedNode.test(LI + ', ' + LI + ' *')) {
39
Y.log('Overriding TAB to move lists around', 'info', 'editorLists');
40
e.changedEvent.halt();
43
sTab = e.changedEvent.shiftKey;
44
par = li.ancestor(OL + ',' + UL);
47
if (par.get('tagName').toLowerCase() === OL) {
50
Y.log('ShiftKey: ' + sTab, 'info', 'editorLists');
56
if (li.ancestor(LI)) {
57
Y.log('Shifting list up one level', 'info', 'editorLists');
58
li.ancestor(LI).insert(li, 'after');
63
//li.setStyle('border', '1px solid red');
64
if (li.previous(LI)) {
65
Y.log('Shifting list down one level', 'info', 'editorLists');
66
newList = inst.Node.create('<' + tag + '></' + tag + '>');
67
li.previous(LI).append(newList);
77
li.all(EditorLists.REMOVE).remove();
79
li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
82
Y.log('Selecting the new node', 'info', 'editorLists');
83
(new inst.EditorSelection()).selectNode(li, true, focusEnd);
87
initializer: function() {
88
this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
92
* The non element placeholder, used for positioning the cursor and filling empty items
96
NON: '<span class="yui-non"> </span>',
98
* The selector query to get all non elements
102
NON_SEL: 'span.yui-non',
104
* The items to removed from a list when a list item is moved, currently removes BR nodes
128
Y.namespace('Plugin');
130
Y.Plugin.EditorLists = EditorLists;
134
}, '3.10.3', {"requires": ["editor-base"]});