Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

WYSIWYG editor

by cavac (Priest)
on Jun 11, 2021 at 08:15 UTC ( #11133765=pmdevtopic: print w/replies, xml ) Need Help??

Here is my basic plan to implement an optional WYSIWYG editor for posting. The idea is to give monks the option (default: off) of using a graphical JavaScript editor for making new posts. In my opinion, this could be especially helpful in SoPW for inexperienced users.

The idea is to use CKEditor 4 (or rather, a slightly modified version to fit Perl Monks Approved HTML tags). CKEditor 4 is ideal for this, because it just lays on top of the existing HTML textarea field and can be persuaded to update the textarea field whenever the form is posted. It also allows to edit the HTML directly ("View Source" button). Since this is an experimental feature that requires JavaScript, i propose that this overlay will only be active when all of the following conditions are true:

  1. The user has selected HTML as the prefered markup language in user settings
  2. The user has forced preview active in user settings
  3. The user has enabled the "Experimental WYSIWYG" editor in user settings

This would translate to a pseudo-code like this:

# while generating the <head> part if($usersettings[markuptype] eq 'html' && !$usersettings[disable_forced_preview] && $usersettings[graphical_content_editor]) { # external JS file also includes some form of "document.addEventLi +stener("DOMContentLoaded", function(event) {" # to initialize the editor after the browser has finished loading +everything. # This way it should not conflict with content security policy $html .= '<script type="text/javascript" src="/static/ckeditor_per +lmonks.js"></script>'; }

As this editor is completely optional and off by default, nothing should change for users, except if they go into their settings and enable it. Even if it is enabled, if the users browser has JavaScript disabled/blocked, the form would just silently and automatically fall back to the classic "edit HTML by hand" textarea. This is because the Editor doesn't replace the textarea in the HTML form, it just runs on top of it.

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2022-05-18 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?