How to create a WYSIWYG editor in PHP

I am trying to create a WYSIWYG editor in PHP. So far I got this (I'm new by the way):

HTML:

   <form action="" method="POST">
        <select name="fontSize" onchange="this.form.submit();">
            <option>Font Size</option>
            <option value="14px">14px</option>
            <option value="24px">24px</option>
            <option value="34px">34px</option>
        </select>
    </form>

    <form action="" method="POST">
        <textarea name="bodyText" style="width:500px;height:200px;font-size:<?php echo $fontSize; ?>"></textarea>
    </form>

PHP:

<?php

$fontSize = $_POST['fontSize'];

switch($fontSize)
{
    case "14px":
    $fontSize = "14px";
    break;

    case "24px":
    $fontSize = "24px";
    break;

    case "34px":
    $fontSize = "34px";
    break;

    default:
    $fontSize = "12px";
}

?>

The problem is that when I select a new font size from the drop-down menu, the font size for the entire text area changes, instead I want to be able to select a specific word or letter and only have the font size of this change and not the entire text area. How to do it?

+3
source share
3 answers

(), , , . , . , , .

, . , . .

- JS WYSIWYG, .. ( ).

, , .. , . , , , . JS.

JS. , . , , .

. .

+5

, DRY ( ) Javascript WYSIWYG, http://tinymce.moxiecode.com/.

, , .

Bye

0

, TinyMCE . http://tinymce.moxiecode.com/examples/full.php, , . .

, , , , , . FileManager ImageManager , , .

0

Source: https://habr.com/ru/post/1731302/


All Articles