I am trying to extend TagOnEnterHandler Plugin to also generate a unique id for each paragraph inserted on pressing enter. Below is some modification I did to this library. But what it does is that it only generates a unique id for the first paragraph tag and pressing enter after that simple copies the same id. It appears to me that the enter handler is splitting the current paragraph into two and shifting the focus to the newly created paragraph tag. Can any one provide me with a solution
goog.editor.plugins.TagOnEnterHandler.prototype.getNonCollapsingBlankHtml =
function() {
if (this.tag == goog.dom.TagName.P) {
return '<p id="'+this.getId()+'"><br /></p>';
} else if (this.tag == goog.dom.TagName.DIV) {
return '<div id="'+this.getId()+'"><br></div>';
}
return '<br>';
};
/**
* Generated Unique Identifiers.
* @type {Object.<number>}
*/
goog.editor.plugins.TagOnEnterHandler.prototype.blockId = {};
/**
* Generates a unique identifier
* @return {string} The unique identifier
*/
goog.editor.plugins.TagOnEnterHandler.prototype.getId = function(){
var uid;
do{
uid = Math.round(65535 * Math.random()).toString(16);
uid = Array(4 - uid.length + 1).join("0") + uid;
}while(this.blockId[uid]);
this.blockId[uid] = 1;
return uid;
};