Skip to content

Commit

Permalink
Fix first line HTML tags
Browse files Browse the repository at this point in the history
  • Loading branch information
webfashionist committed Sep 11, 2017
1 parent 16bcb10 commit 8100da4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/jquery.richtext.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@
$editor.children(".richText-editor, .richText-initial").css({'min-height' : height + 'px', 'height' : height + 'px'});
}


// add custom class
if(settings.class) {
$editor.addClass(settings.class);
Expand All @@ -442,11 +441,14 @@
$editor.attr("id", settings.id);
}

// fix the first line
fixFirstLine();

// save history
history.push($editor.find("textarea").val());
};

// initialize editor
init();


Expand Down Expand Up @@ -491,6 +493,7 @@
tabifyEditableTable(window, e);
return false;
}
fixFirstLine();
updateTextarea();
doSave();
});
Expand Down Expand Up @@ -1398,6 +1401,21 @@
return false;
}


/**
* Fix the first line as by default the first line has no tag container
*/
function fixFirstLine() {
if($editor && !$editor.find(".richText-editor").html()) {
if(settings.useParagraph !== false) {
$editor.find(".richText-editor").html('<p><br></p>');
} else {
$editor.find(".richText-editor").html('<div><br></div>');
}
updateTextarea();
}
}

return $(this);
};

Expand Down
Loading

0 comments on commit 8100da4

Please sign in to comment.