Page 1 of 1

WYSIWYG Java editor

PostPosted: Wed Jan 19, 2011 12:47 am
by smartmedia
Hi..

I want to use an WYSIWYG Java editor and save the result in a variable and afterworlds to a field in database.

For that reason i have found http://www.nicedit.com/index.php
What i want is: To use a web object, edit in editor and then, when hit an NB button to get in variable and save the text in database.

If somebody could help i will appreciate it.

Thanks

PostPosted: Wed Jan 19, 2011 7:09 am
by Gaev
smartmedia:

1) Were you planning on deploying this from a local (e.g. c: drive) environment ... or call a web page (e.g. .php on your server) ... inside a Web Browser object in both cases.

I had looked into a similar thing with another such facility years ago ... and ran into difficulties because it was designed only to be deployed from the web ... so the first thing I would do is make sure that you can load a local html page containing this facility into the Web Browser object ... and that the UI works as expected.

2) Instead of a NeoBook Button to trigger the extraction of the associated html code, it might be better to examine the Javascript function that is called when the facility's Save Button is invoked ... and modify it to ...

a) Copy the code to a NeoBook variable.

b) Trigger a NeoBook SubRoutine ... that would then do what ever is needed to save it.


3) Somewhat more difficult will be the reverse process ... i.e. extracting previously stored code and injecting it into the facility.


However, looks like the developer of NiceEdit could be persuaded ($Donation$) to perhaps assist in either advice or modifications to the API so it could be deployed in the NeoBook ecosystem ... if this could be a generic facility, perhaps others here might be interested in a joint effort.

PostPosted: Wed Jan 19, 2011 8:46 am
by smartmedia
Hi..

Thanks Gaev for your answer.
I did some research and tried to play with it. According to API (http://wiki.nicedit.com/w/page/521/Javascript-API) [nicInstance].setContent(HTML) fills the text area with any text you enter. That did worked using the demo page demo02.html like this:
Code: Select all
BrowserExecScript "WebBrowser1" "nicEditors.findEditor('area1').setContent('<strong>Some HTML</strong> here');" "JScript"

Also i was able to send text from a text entry from NB.
Code: Select all
BrowserExecScript "WebBrowser1" "nicEditors.findEditor('area1').setContent('[TextEntry1]');" "JScript"

Weird stuff happen when i tried to get from the WYSIWYG area. According to API [nicInstance].getContent() get the contains of textarea, which is true using that:
Code: Select all
BrowserExecScript "WebBrowser1" "var ReturnedCode = nicEditors.findEditor('area1').getContent();|document.write(ReturnedCode);" "JScript"

Now in order to get back to NB the contains of variable ReturnedCode i have used:
Code: Select all
BrowserExecScript "WebBrowser1" "window.external.nbSetVar( '[ReturnedCode]', ReturnedCode );" "JScript"

I didn't get any result. So i think that perhaps i must declare my Variable in NB before i request to filled. So i did an empty setvar. One more time, nothing happend. Then i tried that:
Code: Select all
SetVar "[ReturnedCode]" "null"

when i run the code, a new variable called null was created and was filled with the contains of textarea from Javascript editor.
This is a bug i believe and must be corrected as soon as possible..
So now in order to get from the WYSIWYG editor i must use setvar and fill the variable with the name of variable i want to use...
xxmm Very weird stuff don't you think....???? lol...

PostPosted: Wed Jan 19, 2011 11:58 am
by Neosoft Support
If you can send me a sample pub, I will take a look at it.

PostPosted: Thu Jan 20, 2011 12:10 pm
by Neosoft Support
Thanks for sending the sample pub.

The solution to the problem is to remove the square brackets "[ ]" from the variable name passed to the BrowserExecScript action. For example:

BrowserExecScript "WebBrowser1" "var ReturnedCode = nicEditors.findEditor('area1').getContent();|window.external.nbSetVar( 'ReturnedCode', ReturnedCode );" "JScript"

Before sending the JavaScript code to the browser for processing it scans the script for variable names and replaces them with the content contained within the variable. Since you want to set a variable from within JavaScript, you must leave off the square brackets. If you do that it will correctly set the variable in NeoBook.

Re: WYSIWYG Java editor

PostPosted: Fri Feb 25, 2011 9:01 am
by dpayer
smartmedia wrote:Hi..

I want to use an WYSIWYG Java editor and save the result in a variable and afterworlds to a field in database.

For that reason i have found http://www.nicedit.com/index.php
What i want is: To use a web object, edit in editor and then, when hit an NB button to get in variable and save the text in database.

If somebody could help i will appreciate it.

Thanks


I have also been thinking about this one. Remember that you can always parse the html within the web object and only use the area between <textarea> </textarea> that is used. Save that as your variable and then when you want to load it, load the html into that variable and recreate the html that you will then insert into the web object.

David P

Possible demo program

PostPosted: Fri Feb 25, 2011 11:23 am
by eddy current
I am also interested in this subject. Unfortunately, I currently lack the necessary programming skills to incorporate TinyMCE into my projects. The way I learn, however, is by deconstructing others' examples. It would be wonderful to see some implementations of this topic in the "Examples" directory or for download. Unless, of course, it is seen as proprietary knowledge and then I understand the desire to keep it private.

-- Glen