editor-lists.js revision aa2ac226ad6e45232f8416eecc99d2165ce74d03
8346e283ad797ef549be70335d3961f4324901baRyan Grove * Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
8346e283ad797ef549be70335d3961f4324901baRyan Grove * @module editor
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @submodule editor-lists
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @class Plugin.EditorLists
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @constructor
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @extends Base
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney var EditorLists = function() {
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney EditorLists.superclass.constructor.apply(this, arguments);
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney }, LI = 'li', OL = 'ol', UL = 'ul', HOST = 'host';
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @method _onNodeChange
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @param {Event} e The Event facade passed from the host.
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney var inst = this.get(HOST).getInstance(), sel, li,
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney newLi, newList, sTab, par, moved = false, tag, focusEnd = false;
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney if (e.changedNode.test(LI + ', ' + LI + ' *')) {
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney newLi = inst.Node.create('<' + LI + '>' + EditorLists.NON + '</' + LI + '>');
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney sel.selectNode(newLi.get('firstChild'), true, false);
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney if (e.changedNode.test(LI + ', ' + LI + ' *')) {
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney //li.setStyle('border', '1px solid red');
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney newList = inst.Node.create('<' + tag + '></' + tag + '>');
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney //Selection here..
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney (new inst.Selection()).selectNode(li, true, focusEnd);
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * The non element placeholder, used for positioning the cursor and filling empty items
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @property REMOVE
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * The selector query to get all non elements
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @property NONSEL
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * The items to removed from a list when a list item is moved, currently removes BR nodes
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @property REMOVE
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * editorLists
8ff167b366d7ee96cfc801bb01cd93e3ce573cbfMatt Sweeney * @property NAME
ATTRS: {
host: {
value: false
* Override for the insertunorderedlist method from the <a href="Plugin.EditorLists.html">EditorLists</a> plugin.
* Override for the insertorderedlist method from the <a href="Plugin.EditorLists.html">EditorLists</a> plugin.