1
/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
2
YUI.add('editor-lists', function (Y, NAME) {
6
* Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support.
7
* Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a>
8
* and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
9
* @class Plugin.EditorLists
13
* @submodule editor-lists
16
var EditorLists = function() {
17
EditorLists.superclass.constructor.apply(this, arguments);
18
}, LI = 'li', OL = 'ol', UL = 'ul', HOST = 'host';
20
Y.extend(EditorLists, Y.Base, {
22
* Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
24
* @method _onNodeChange
25
* @param {Event} e The Event facade passed from the host.
27
_onNodeChange: function(e) {
28
var inst = this.get(HOST).getInstance(), li,
29
newList, sTab, par, moved = false, tag, focusEnd = false;
31
if (e.changedType === 'tab') {
32
if (e.changedNode.test(LI + ', ' + LI + ' *')) {
33
e.changedEvent.halt();
36
sTab = e.changedEvent.shiftKey;
37
par = li.ancestor(OL + ',' + UL);
40
if (par.get('tagName').toLowerCase() === OL) {
48
if (li.ancestor(LI)) {
49
li.ancestor(LI).insert(li, 'after');
54
//li.setStyle('border', '1px solid red');
55
if (li.previous(LI)) {
56
newList = inst.Node.create('<' + tag + '></' + tag + '>');
57
li.previous(LI).append(newList);
67
li.all(EditorLists.REMOVE).remove();
69
li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
72
(new inst.EditorSelection()).selectNode(li, true, focusEnd);
76
initializer: function() {
77
this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
81
* The non element placeholder, used for positioning the cursor and filling empty items
85
NON: '<span class="yui-non"> </span>',
87
* The selector query to get all non elements
91
NON_SEL: 'span.yui-non',
93
* The items to removed from a list when a list item is moved, currently removes BR nodes
117
Y.namespace('Plugin');
119
Y.Plugin.EditorLists = EditorLists;
123
}, '3.9.1', {"requires": ["editor-base"]});