From a28b6c2690337f3636aca8bf30b35916a1940605 Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 4 Mar 2019 17:47:38 +1000 Subject: [PATCH] Added a WYSIWYG Editor for editing replies in Cosora. --- public/global.js | 1 + public/init.js | 1 + routes/profile.go | 4 +++- themes/cosora/public/misc.js | 6 ++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/global.js b/public/global.js index 661f2db0..d319c212 100644 --- a/public/global.js +++ b/public/global.js @@ -599,6 +599,7 @@ function mainInit(){ else source = block.innerHTML; // TODO: Add a client template for this block.innerHTML = "
"; + runHook("edit_item_pre_bind"); $(".submit_edit").click(function(event){ event.preventDefault(); diff --git a/public/init.js b/public/init.js index 4ef98467..1c1e0d1e 100644 --- a/public/init.js +++ b/public/init.js @@ -14,6 +14,7 @@ var hooks = { "after_update_alert_list":[], "open_edit":[], "close_edit":[], + "edit_item_pre_bind":[], }; var ranInitHooks = {} diff --git a/routes/profile.go b/routes/profile.go index a59e6db6..81426580 100644 --- a/routes/profile.go +++ b/routes/profile.go @@ -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 diff --git a/themes/cosora/public/misc.js b/themes/cosora/public/misc.js index 8723bd15..750ac848 100644 --- a/themes/cosora/public/misc.js +++ b/themes/cosora/public/misc.js @@ -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