improve frontend of emacs, ckeditor, tinymce, nicedit, meta and env functions

Improves in emacs:
- use htmx to send content to the controller
- show txt and formatted_txt content in the second panel
- show two tabs if "tabs" winix parameter is used
- add an option to show either one or two panels
- correctly resize the editor window (F11) when two panels are shown

Improves in ckeditor:
- use htmx to send content to the controller
- do not check automatically for ckeditor update

Improves in tinymce/nicedit/meta/env:
- use htmx to send content to the controller

while here:
- change PascalCase to snake_case in meta/env controllers
- update CodeMirror editor to 5.65.16
- udpate Showdown (markdown to html converter) to 2.1.0
This commit is contained in:
2024-07-20 15:13:27 +02:00
parent 89b37db48e
commit e63838faeb
27 changed files with 1075 additions and 496 deletions

View File

@@ -37,14 +37,10 @@
#include "functions.h"
namespace Winix
namespace Winix::Fun
{
namespace Fun
{
Emacs::Emacs()
{
fun.url = L"emacs";
@@ -128,13 +124,30 @@ return WINIX_NOTIFY_CODE_ADD;
}
// IMPROVEME
// make some kind of utils and put this method there
// because this method is used from ckeditor and other editors too
void Emacs::push_url_to_current_function(const wchar_t * local_url)
{
if( cur->request->is_htmx_request )
{
pt::WTextStream url;
if( cur->request->IsParam(L"tabs") )
prepare_current_function(L"/tabs", url);
else
prepare_current_function(nullptr, url);
cur->request->out_headers.add(Header::hx_push_url, url);
}
}
/*
* this make_post() is used from Ckeditor, Tinymce and Nicedit as well
*/
void Emacs::make_post()
{
bool status = false;
bool adding = !cur->request->is_item;
std::wstring old_url;
if( !adding )
old_url = cur->request->item.url;
@@ -163,38 +176,29 @@ void Emacs::make_post()
}
cur->request->status = status ? WINIX_ERR_OK : WINIX_ERR_PERMISSION_DENIED;
answer.add(L"status", status);
if( status )
{
if( adding )
{
system->RedirectToLastFunction(nullptr, false);
answer.add(L"redirect_to", cur->request->redirect_to);
if( cur->request->container_type != Request::ContainerType::container_raw )
{
cur->request->redirect_to.clear();
}
}
functions->CheckSpecialFile(cur->request->item);
bool was_url_changed = (adding || cur->request->item.url != old_url);
redirect_if_needed(was_url_changed);
}
cur->request->models.Add(L"answer", answer);
if( adding )
{
// App::AddDefaultModels() is called before make_post() and didn't see the item yet
cur->request->models.Add(L"item", cur->request->item);
}
}
void Emacs::clear()
{
answer.clear();
}
} // namespace
} // namespace Winix