Jump to content
UBot Underground

Can I Add Wysiwyg Editor In Ui Block Text?


Recommended Posts

What type of file is the editor that you want to embed? Maybe you could upload it to a website of yours then use an <iframe> that doesn't have scrolling to embed it.

Link to post
Share on other sites

You can add a WYSIWYG Editor to the ui html panel, but I have not been able to find a way to set it's content to a variable so it's no use.

 

If you want to use the browser for your ui then you can do it that way by scraping the content to a variable. Otherwise one of pash's plugins has a WYSIWYG Editor. This one I think: http://www.ubotstudio.com/forum/index.php?/topic/16146-sell-plugin-advanced-dialog/

 

Cheers.

  • Like 1
Link to post
Share on other sites

I've noticed that you struggle here so I decided to publish a snippet that I use (using TinyMCE WYSIWYG Editor): 

http://ubotdev.com/snippet-tinymce-wysiwyg-editor-implementation

 

 

Hope you like it. ;)

ui html panel("<textarea style=\"height:250px;\" class=\"wysiwyg\" id=\"wysiwyg\" variable=\"#TINYMCE Content Set\" fillwith=\"value\" onchange=\"tinymce.get(\'wysiwyg\').setContent(this.value);\"></textarea>
<script src=\"http://tinymce.cachefly.net/4.1/tinymce.min.js\"></script>
<script>
    //name of UBot variable that will hold TinyMCE content
    var variableName = \'#TINYMCE Content\';    
    
    tinymce.init(\{
        selector:\'textarea.wysiwyg\',
        menubar: true,
        toolbar_items_size: \'medium\',
        toolbar1: \"newdocument | undo redo | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent blockquote | bullist numlist | link unlink anchor | image media | code | insertdatetime preview | forecolor backcolor | hr removeformat | subscript superscript | charmap emoticons | cut copy paste | searchreplace | print fullscreen \",
        
        plugins: [
            \"link image lists charmap print preview hr anchor\",
            \"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking\",
            \"table contextmenu emoticons textcolor paste textcolor colorpicker textpattern\"
        ],          

        setup : function(editor) \{
            editor.on(\"change\", function(editor, e) \{
                updateUBotVariable(variableName);
            \});
            
            editor.on(\"keyup\", function(editor, e) \{
                updateUBotVariable(variableName);
            \});
            
            //updates UBot variable when \"File->New Document\" is clicked
            editor.on(\"init\", function(editor, e) \{
                updateUBotVariable(variableName);
            \});
            
            editor.on(\"undo\", function(editor, e) \{
                updateUBotVariable(variableName);
            \});
            
            editor.on(\"redo\", function(editor, e) \{
                updateUBotVariable(variableName);
            \});
            
            //updates UBot variable when text color is changed
            editor.on(\"nodeChange\", function(editor, e) \{
                updateUBotVariable(variableName);
            \});
        \}
    \});            
</script>
<script>
    function updateUBotVariable(variable)\{
        ubot.settingChanged(variable, tinyMCE.activeEditor.getContent());
    \}
</script>", 400)
define TINYMCE CONTENT SET(#DEF Content) {
    set(#TINYMCE Content Set, "", "Global")
    wait(0.1)
    set(#TINYMCE Content Set, #DEF Content, "Global")
    set(#TINYMCE Content, #DEF Content, "Global")
}

  • Like 3
Link to post
Share on other sites

Hi UBotDev many thanks for it, but I still have one question how we add more function in the editor like:

 

http://oregonstate.edu/cws/training/sites/default/files/book/drupal-deep-dive/tiny-mce-wysiwyg/00-overview/01-tinymce-text-editor.png

 

Thanks so much bro I wait your answer :D

Link to post
Share on other sites

Hi UBotDev many thanks for it, but I still have one question how we add more function in the editor like:

 

I don't think that you showed the screenshot of TinyMCE...but while the snippet I use used TinyMCE, you are limited to that one. You can still modify it a bit to fit your needs, check the options on their page: http://www.tinymce.com/

 

If you don't like TinyMCE, the snippet should give you an idea about how to implement other WYSIWYG editors...

 

Hope that helps.

  • Like 1
Link to post
Share on other sites

Thanks UBotDev for the sample code. It'll come in handy some day.

As for a more full featured example of loading TinyMCE I've used your code and loaded some more "bells and whistles" for those who need it. 

ui html panel("<textarea style=\"height:250px;\" class=\"wysiwyg\" id=\"wysiwyg\" variable=\"#TINYMCE Content Set\" fillwith=\"value\" onchange=\"tinymce.get(\'wysiwyg\').setContent(this.value);\"></textarea>
<script src=\"http://tinymce.cachefly.net/4.1/tinymce.min.js\"></script>
<script>
        tinymce.init(\{
			selector:\'textarea.wysiwyg\',
	        plugins: [
	                \"advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker\",
	                \"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking\",
	                \"table contextmenu directionality emoticons template textcolor paste fullpage textcolor colorpicker textpattern\"
	        ],
	
	        toolbar1: \"newdocument | styleselect formatselect fontselect fontsizeselect | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | insertdatetime preview | forecolor backcolor | table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | visualchars visualblocks nonbreaking\",
	
	        menubar: false,
	        toolbar_items_size: \'medium\',

			setup : function(editor) \{
				editor.on(\"change\", function(editor, e) \{
					ubot.settingChanged(\'#TINYMCE Content\', tinyMCE.activeEditor.getContent());
				\});
				
				editor.on(\"keyup\", function(editor, e) \{
					ubot.settingChanged(\'#TINYMCE Content\', tinyMCE.activeEditor.getContent());
				\});
			\}
		\});
	
</script>",400)
define TINYMCE CONTENT SET(#DEF Content) {
    set(#TINYMCE Content Set,"","Global")
    wait(0.1)
    set(#TINYMCE Content Set,#DEF Content,"Global")
    set(#TINYMCE Content,#DEF Content,"Global")
}

post-12789-0-32644300-1421700887_thumb.png

  • Like 2
Link to post
Share on other sites

Hi, Thanks so much for Ubot dev and dyvel,

 

I already try and it's work but I still have one question (hope last question :) ) how to remove:

 

<!DOCTYPE html>
<html>
<head>
</head>
<body>

 

in blog editor after insert?

 

Thanks

Link to post
Share on other sites

I already replied in private, but for others, just remove the plugin fullpage from the code. Here's a cleaned up version that I prefer. 

ui html panel("<textarea style=\"height:250px;\" class=\"wysiwyg\" id=\"wysiwyg\" variable=\"#TINYMCE Content Set\" fillwith=\"value\" onchange=\"tinymce.get(\'wysiwyg\').setContent(this.value);\"></textarea>
<script src=\"http://tinymce.cachefly.net/4.1/tinymce.min.js\"></script>
<script>
        tinymce.init(\{
			selector:\'textarea.wysiwyg\',
	        plugins: [
	                \"link image lists charmap print preview hr anchor\",
	                \"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking\",
	                \"table contextmenu emoticons textcolor paste textcolor colorpicker textpattern\"
	        ],
	
	        toolbar1: \"newdocument | undo redo | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent blockquote | bullist numlist | link unlink anchor | image media | code | insertdatetime preview | forecolor backcolor | hr removeformat | subscript superscript | charmap emoticons | cut copy paste | searchreplace | print fullscreen \",
	
	        menubar: true,
	        toolbar_items_size: \'medium\',

			setup : function(editor) \{
				editor.on(\"change\", function(editor, e) \{
					ubot.settingChanged(\'#TINYMCE Content\', tinyMCE.activeEditor.getContent());
				\});
				
				editor.on(\"keyup\", function(editor, e) \{
					ubot.settingChanged(\'#TINYMCE Content\', tinyMCE.activeEditor.getContent());
				\});
			\}
		\});
	
</script>",400)
define TINYMCE CONTENT SET(#DEF Content) {
    set(#TINYMCE Content Set,"","Global")
    wait(0.1)
    set(#TINYMCE Content Set,#DEF Content,"Global")
    set(#TINYMCE Content,#DEF Content,"Global")
}

  • Like 3
Link to post
Share on other sites

how are you doing with getting the contents out of the html panel? If you found a way please share :)

 

Hey Edward, if you only tried the code dyvel supplied like I did then yeh, it won't work on it's own. So I went to the link UBotDev supplied, and you need to add this bit after : </script>",400)

TINYMCE CONTENT SET("<p>test <b>bold</b></p>")

then open your debugger, run the bot, then type something into the editor.

 

This is brilliant UBotDev, thanks for sharing. And thanks dyvel for sharing the code with the "bells and whistles".

 

Cheers.

  • Like 1
Link to post
Share on other sites

jbsgroup....great to see you got it working!

 

Thanks dyvel for showing an example of how to customize TinyMCE (was a bit short on time so I didn't post it last time). I hope you don't mind if I update my code with the javascript you've added and update the post above.

Link to post
Share on other sites

Not at all UBotDev - after all, without your first post, I wouldn't been able to do what I did... And that's the whole point of this forum - helping each other :) 

Link to post
Share on other sites

 

No I don't - I create my own UI from scratch, but I'm also using bootstrap framework. 

Link to post
Share on other sites

For Dyvel and all member

 

Any method to run the compiled ubot (the .exe file) without open browser.

 

E.g

 

I have 3 tabs (tab a, tab b and tab c) but I don't need browser open in tab a so I can fill it with UI command only, when I need to run bot I just click tab b or tab c.

 

did you done it?

Link to post
Share on other sites

MORE TINYMCE FEATURES BUGFIX + CELANUP:

I've got some time today so I've updated the snippet to support more TinyMCE features (thanks to dyvel for providing that part).

The code that he shared has some small bugs (UBot variable was not updated when user clicked "New Document", "Undo" and"Redo"), that's why make sure to check the updated code in my initial response or on my blog: http://ubotdev.com/snippet-tinymce-wysiwyg-editor-implementation

 

I've tested most of the buttons/menu items and I think it works OK now; if you find any problems let me know.

 

P.S.: jbsgroup...you are getting a bit off-topic here...maybe open a new thread for that?

  • Like 1
Link to post
Share on other sites

TINYMCE CONTENT SET("<p>test <b>bold</b></p>")

 

How is that? here is the docs for tinymce

 

http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent

 

 

// Sets the HTML contents of the activeEditor editor

 

tinyMCE.activeEditor.setContent('<span>some</span> html');

// Sets the raw contents of the activeEditor editor

tinyMCE.activeEditor.setContent('<span>some</span> html', {format : 'raw'});

// Sets the content of a specific editor (my_editor in this example)

tinyMCE.get('my_editor').setContent(data);

// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added

tinyMCE.activeEditor.setContent('some html', {format : 'bbcode'});

 

 

So where did this code come from?

 

TINYMCE CONTENT SET("<p>test <b>bold</b></p>") :)

 

--------------------------------------------------------------------------

 

Im actually working on something similar with codemirror. Would like to incorporate it into ubot as well.

 

:)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...