diff --git a/src/dom.js b/src/dom.js index c1d4eb2f..859fe396 100644 --- a/src/dom.js +++ b/src/dom.js @@ -3,6 +3,7 @@ dom = {}; dom.DOM_VK_DELETE = 8; + dom.DOM_VK_DELETE_KEY = 46; dom.DOM_VK_LEFT = 37; dom.DOM_VK_UP = 38; dom.DOM_VK_RIGHT = 39; diff --git a/src/ice.js b/src/ice.js index e22be15b..305e5f13 100644 --- a/src/ice.js +++ b/src/ice.js @@ -10,6 +10,19 @@ userNameAttribute: 'data-username', timeAttribute: 'data-time', + // date format for changes popup title attribute + titleDateFormat: 'm/d/Y h:ia', + + // setting this to true means that the dummy white space character that is inserted by ice + // is selected before the event bubbles up to the final handler. + // Issue in Chrome with tinyMCE: + // When the event bubbles up to tinyMCE, the selection gets removed which leaves + // the "insert" element empty. If the insert element is + // a non block element (like span or a custom element like insert), Chrome will delete it as soon + // as it is empty and before the content text can be inserted into the element. So ensure this variable + // is set to false for ice to work correctly. (TinyMCE removes the dummy whitespace character anyway) + selectDummyCharacter: false, + // Prepended to `changeType.alias` for classname uniqueness, if needed attrValuePrefix: '', @@ -912,6 +925,11 @@ range.insertNode(node); range.setEnd(node, 1); + /* + Always collapse the range if selectDummyCharacter is false, otherwise select it. + See comment where selectDummyCharacter is defined + */ + if (self.selectDummyCharacter) { if (insertingDummy) { // Create a selection of the dummy character we inserted // which will be removed after it bubbles up to the final handler. @@ -919,6 +937,9 @@ } else { range.collapse(); } + } else { + range.collapse(); + } this.selection.addRange(range); }, @@ -1464,8 +1485,7 @@ preventDefault = this.deleteContents(); this.pluginsManager.fireKeyPressed(e); break; - case 46: - // Key 46 is the DELETE key. + case ice.dom.DOM_VK_DELETE_KEY: preventDefault = this.deleteContents(true); this.pluginsManager.fireKeyPressed(e); break; diff --git a/src/plugins/IceAddTitlePlugin/IceAddTitlePlugin.js b/src/plugins/IceAddTitlePlugin/IceAddTitlePlugin.js index 94955a8e..887d52ec 100644 --- a/src/plugins/IceAddTitlePlugin/IceAddTitlePlugin.js +++ b/src/plugins/IceAddTitlePlugin/IceAddTitlePlugin.js @@ -9,7 +9,7 @@ IceAddTitlePlugin = function(ice_instance) { IceAddTitlePlugin.prototype = { nodeCreated: function(node, option) { node.setAttribute('title', (option.action || 'Modified') + ' by ' + node.getAttribute(this._ice.userNameAttribute) - + ' - ' + ice.dom.date('m/d/Y h:ia', parseInt(node.getAttribute(this._ice.timeAttribute)))); + + ' - ' + ice.dom.date(this._ice.titleDateFormat, parseInt(node.getAttribute(this._ice.timeAttribute)))); } };