Trumbowyg icon indicating copy to clipboard operation
Trumbowyg copied to clipboard

Insert html, java, python, etc code with format like an IDE

Open manueltechlabs opened this issue 1 year ago • 4 comments

I would like to insert html, java, python, etc code with format like an IDE to explain code for example. like this:

If we are building plain HTML Jquery web ui, then we can integrate the CDN as below:

<head> 
<title>Your Web Page</title>
 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/ui/trumbowyg.min.css">
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/trumbowyg.min.js"></script>
</head>

We can take the js and css files of the jquery rich text editor from github and add it our project.

Description

this id my base code:

<!DOCTYPE html>
<html lang="en">

<head>    
    <title>Document</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/ui/trumbowyg.min.css">
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/trumbowyg.min.js"></script>
</head>
<script>
    $(document).ready(function() {
        $('#default-editor').trumbowyg();
        $('#reset-default-editor').click(function () {
         $('#default-editor').trumbowyg('empty');
         });
   });
        
</script> 


<body>
    <textarea id="default-editor"></textarea>
    <div id="default-editor"></div>
    <button id="reset-default-editor">Reset</button>

</body>
<footer>
    <!-- Import jQuery -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/vendor/jquery-3.3.1.min.js"><\/script>')</script>

    <!-- Import Trumbowyg -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.27.3/trumbowyg.min.js"></script>
</footer>
<script>
    $('#editor').trumbowyg();
</script>

</html>

How to reproduce?

manueltechlabs avatar Jun 05 '24 03:06 manueltechlabs

So you would like to have a Code Editor inside Trumbowyg, aka inside the WYSIWYG?

Alex-D avatar Jan 29 '25 23:01 Alex-D

Sorry, I didn't know how to explain what I wanted, I am using the library prism for what I needed—present Java code in a format similar to what you see in an IDE. thanks.

manueltechlabs avatar Feb 01 '25 14:02 manueltechlabs

Did you give the highlight plugin a try?

Alex-D avatar Feb 02 '25 11:02 Alex-D

I tried several Wisiwig libraries and ended up implementing Summernote for Wisiwig, which was easy to implement with less effort. I copied the code examples and it just worked, I didn't have the same experience with other plugins. I might give Trumbowig a go in my next project as I like it.

manueltechlabs avatar Feb 03 '25 22:02 manueltechlabs