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
e.changedEvent.halt();
42
sTab = e.changedEvent.shiftKey;
43
par = li.ancestor(OL + ',' + UL);
46
if (par.get('tagName').toLowerCase() === OL) {
54
if (li.ancestor(LI)) {
55
li.ancestor(LI).insert(li, 'after');
60
//li.setStyle('border', '1px solid red');
61
if (li.previous(LI)) {
62
newList = inst.Node.create('<' + tag + '></' + tag + '>');
63
li.previous(LI).append(newList);
73
li.all(EditorLists.REMOVE).remove();
75
li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
78
(new inst.EditorSelection()).selectNode(li, true, focusEnd);
82
initializer: function() {
83
this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
87
* The non element placeholder, used for positioning the cursor and filling empty items
91
NON: '<span class="yui-non"> </span>',
93
* The selector query to get all non elements
97
NON_SEL: 'span.yui-non',
99
* The items to removed from a list when a list item is moved, currently removes BR nodes
123
Y.namespace('Plugin');
125
Y.Plugin.EditorLists = EditorLists;
129
}, '3.10.3', {"requires": ["editor-base"]});