Added a WYSIWYG Editor for editing replies in Cosora.

This commit is contained in:
Azareal 2019-03-04 17:47:38 +10:00
parent 3cb5896316
commit a28b6c2690
4 changed files with 11 additions and 1 deletions

View File

@ -599,6 +599,7 @@ function mainInit(){
else source = block.innerHTML;
// TODO: Add a client template for this
block.innerHTML = "<textarea style='width: 99%;' name='edit_item'>" + source + "</textarea><br><a href='" + this.closest('a').getAttribute("href") + "'><button class='submit_edit' type='submit'>Update</button></a>";
runHook("edit_item_pre_bind");
$(".submit_edit").click(function(event){
event.preventDefault();

View File

@ -14,6 +14,7 @@ var hooks = {
"after_update_alert_list":[],
"open_edit":[],
"close_edit":[],
"edit_item_pre_bind":[],
};
var ranInitHooks = {}

View File

@ -31,7 +31,9 @@ func init() {
func ViewProfile(w http.ResponseWriter, r *http.Request, user common.User, header *common.Header) common.RouteError {
// TODO: Preload this?
header.AddSheet(header.Theme.Name + "/profile.css")
header.AddScript("profile_member.js")
if user.Loggedin {
header.AddScript("profile_member.js")
}
var err error
var replyCreatedAt time.Time

View File

@ -33,6 +33,12 @@ $(document).ready(function(){
btns: [['viewHTML'],['strong','em','del'],['link'],['insertImage'],['removeformat']],
autogrow: true,
});
addHook("edit_item_pre_bind", () => {
$('.user_content textarea').trumbowyg({
btns: btnlist,
autogrow: true,
});
});
}
// TODO: Refactor this to use `each` less