core icon indicating copy to clipboard operation
core copied to clipboard

Support WYSIWYG text editor

Open suntong opened this issue 1 year ago • 1 comments

Describe the feature

Can tinymce be supported so as it goes smoothly with cogentcore forms?

See

  • https://www.tiny.cloud/docs/tinymce/latest/npm-projects/#initialize-tinymce-as-part-of-a-web-form
  • https://www.tiny.cloud/blog/source-code-editing/

Basically the web page source should looks something like this:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script src="/path/or/uri/to/tinymce.min.js" referrerpolicy="origin"></script>
    <script>
      tinymce.init({
        selector: '#mytextarea',
        plugins: 'powerpaste casechange searchreplace autolink directionality visualblocks visualchars image link media mediaembed codesample table charmap pagebreak nonbreaking anchor tableofcontents insertdatetime advlist lists checklist wordcount tinymcespellchecker editimage help formatpainter permanentpen charmap linkchecker emoticons advtable export autosave',
        toolbar: 'undo redo print spellcheckdialog formatpainter | blocks fontfamily fontsize | bold italic underline forecolor backcolor | link image | alignleft aligncenter alignright alignjustify',
        license_key: 'gpl|<your-license-key>'
      });
    </script>
  </head>

  <body>
    <h1>TinyMCE Quick Start Guide</h1>
    <form method="post">
      <textarea id="mytextarea">Hello, World!</textarea>
    </form>
  </body>
</html>

I guess the answer would be "yes", but I'd appreciate a more hands-on example. thanks!

Relevant code

No response

suntong avatar Sep 02 '24 04:09 suntong

Unfortunately, the way Cogent Core is structured, it is not compatible with other JS libraries that control widgets such as tinymce. However, we could add similar functionality to Cogent Core itself at some point.

kkoreilly avatar Sep 02 '24 17:09 kkoreilly