Alpha Video Training
Results 1 to 10 of 10

Thread: Can the HTML editor be limited in it's editing feature set?

  1. #1
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    424

    Default Can the HTML editor be limited in it's editing feature set?

    In general the HTML editor serves it's purpose. However sometimes, "WE" the developers would not like our end users to be able to use all of the features that the HTML editor provides us. For example, while I'd like my users to be able to change fonts and color etc. I would NOT like them to be able to alter the source (ie. html) of the memo field. The default seems to allow the user to do this and I would like to turn it off. Allowing them to manually insert or edit the source seems very dangerous to me, especially if they know what they doing (ie. hack).

    So: Can the HTML editor be limited in it's editing feature set?

  2. #2
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Plug - if you use my Alpha-CKEditor Integration, you can do any customization you want. CKEditor is the editor used right here in this forum. See the demo here: http://ialpha5.com/CKEditor/

    Click Custom Editor Styles to see example configs.

    Note, the www.ckeditor.com is on version 4. My Integration is on version 3; working on the upgrade.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    "Certified" Alphaholic kingcarol's Avatar
    Real Name
    Carol King
    Join Date
    Jun 2010
    Posts
    1,512

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Allowing them to manually insert or edit the source seems very dangerous to me, especially if they know what they doing (ie. hack)
    I was worried about the same thing and ended up using an Xbasic function (removeScriptTags) that Selwyn wrote to remove script tags. For example, on one of my grids I have a field named BUYER_NOTES that uses the HTML editor. In the server side event CanUpdateRecord, I call the Xbasic function like this:
    Code:
    dataSubmitted.BUYER_NOTES = removeScriptTags(dataSubmitted.BUYER_NOTES)
    Here is the Xbasic removeScriptTags function that Selwyn wrote:
    Code:
    function removeScriptTags as c (html as c )
    'PURPOSE - To remove javascript from HTML.  In case users try to inject javascript there.
    'WRITTEN BY:  Selwyn Rabins
    
    'debug(1)	
    dim count as n 
    count = occursi("<SCRIPT",html) 
    dim i as n 
    dim search as c 
    for i = 1 to count 
     search = extract_string(html,"<SCRIPT","</SCRIPT>",1,.t.)
     html = stritran(html,search,"")
    next i 
    
    count = occursi("&lt;SCRIPT",html) 
    for i = 1 to count 
    	search = extract_string(html,"&lt;SCRIPT","&lt;/SCRIPT&gt;",1,.t.)
    	html = stritran(html,search,"")
    next i 
    
    removeScriptTags = html
    
    end function
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

  4. #4
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    424

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Quote Originally Posted by Steve Wood View Post
    Plug - if you use my Alpha-CKEditor Integration, you can do any customization you want. CKEditor is the editor used right here in this forum. See the demo here: http://ialpha5.com/CKEditor/

    Click Custom Editor Styles to see example configs.

    Note, the www.ckeditor.com is on version 4. My Integration is on version 3; working on the upgrade.
    Steve,

    I read with interest your post in reference to my concerns. I was wondering if your CKEditor allowed you to configure features on an "item by item" bases or was it more "group wise".

    Also, I try like "heck" to stay away from those tiny tiny icons we've been innodated with in recent years. I don't need LARGE icons but something bigger than what was seen during my review is desired. Question! Can the icons for features be replaced by me?


    Carol,

    Thanks for the heads up on that function written by Selwyn. I have in the past written something similar but I didn't know where the best place to call it. Your reply exposed CanUpdateRecord for me. That was good information.

    Tom W.

  5. #5
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: Can the HTML editor be limited in it's editing feature set?

    I was wondering if your CKEditor allowed you to configure features on an "item by item" bases or was it more "group wise". Can the icons for features be replaced by me?
    You can configure in/out each feature (icon) one-by-one. I do not see any larger icon sets available. There are several "skins" with different user interface design. You would need a "skin" that had larger icons. The complete set of icons, whether used or not, are all in a single jpg file.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  6. #6
    "Certified" Alphaholic TheSmitchell's Avatar
    Real Name
    Sarah
    Join Date
    Apr 2012
    Posts
    1,309

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Quote Originally Posted by Fulltimer View Post
    So: Can the HTML editor be limited in it's editing feature set?
    Of course. Just not with Alpha.

    Code:
    var htmlFoo = function ()
    {
        jQuery('[id$="FIELD_NAME.TOOLBAR"]>[title="Toggle Code"]').remove();
    }
    Quote Originally Posted by Fulltimer View Post
    Allowing them to manually insert or edit the source seems very dangerous to me, especially if they know what they doing (ie. hack).
    This does not prevent someone from inserting scripts. If you really want to prevent scripts, then you'll need to preprocess the data as Carol suggests before saving/previewing it and strip out all the script tags. Someone who, as you put it, knows what they're doing probably has the know-how to use a tool such as FireBug to insert the scripting code --- completely bypassing your interface. The upshot is that the "script" code will only affect the person who is trying to insert it, so an xbasic function to strip that stuff out is more than sufficient.

    Also, "afterDetailViewNewRecord" for New Record in a Detail View is strange sauce. I recommend setTimeout(htmlFoo, 200) in that case.
    ---
    Sarah

  7. #7
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    424

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Quote Originally Posted by TheSmitchell View Post

    Also, "afterDetailViewNewRecord" for New Record in a Detail View is strange sauce. I recommend setTimeout(htmlFoo, 200) in that case.
    ---
    Sarah
    Sarah,

    Thanks for your comments. I do however have a question. I am not clear on your quoted reference listed above. I don't recall ever seeing "afterDetailViewNewRecord" but more importantly, what purpose is the Timeout trying to accomplish. Could you clarify your response a bit please?

    Tom W.

  8. #8
    "Certified" Alphaholic TheSmitchell's Avatar
    Real Name
    Sarah
    Join Date
    Apr 2012
    Posts
    1,309

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Quote Originally Posted by Fulltimer View Post
    Sarah,

    Thanks for your comments. I do however have a question. I am not clear on your quoted reference listed above. I don't recall ever seeing "afterDetailViewNewRecord" but more importantly, what purpose is the Timeout trying to accomplish. Could you clarify your response a bit please?

    Tom W.
    afterDetailViewNewRecord is a client-side event in grids.

    setTimeout waits a number of milliseconds before calling a function: setTimeout(function, number_of_milliseconds). Waiting because the toolbar doesn't exist just yet when you try to remove controls in afterDetailViewNewRecord.

    Do not use the parameter version of setTimeout. It is not supported by IE 9 or older.

  9. #9
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    424

    Default Re: Can the HTML editor be limited in it's editing feature set?

    Quote Originally Posted by TheSmitchell View Post
    afterDetailViewNewRecord is a client-side event in grids.

    setTimeout waits a number of milliseconds before calling a function: setTimeout(function, number_of_milliseconds). Waiting because the toolbar doesn't exist just yet when you try to remove controls in afterDetailViewNewRecord.

    Do not use the parameter version of setTimeout. It is not supported by IE 9 or older.
    Sarah,

    setTimeout(function, number_of_milliseconds) does not work for me in the same way it must apparently work for you. I created a simple function with alert() as the only command within that function. My alert msg displays as expected but it does not honor the wait period. I have tried 300, 3000, 30000 as the number of milli seconds to wait. The function and therefore my msg appear immediately after clicking my test button.

    I am using Firefox to run my app. Seems like something is missing because I see nothing that will accept the number_of_milliseconds as a ligitimate parameter. I don't know if you were simply noting the snippet from memory or if what you provided should have been "real, workable code". Strangely I get no error but I get "no wait".

    Tom W.

  10. #10
    "Certified" Alphaholic TheSmitchell's Avatar
    Real Name
    Sarah
    Join Date
    Apr 2012
    Posts
    1,309

    Default Re: Can the HTML editor be limited in it's editing feature set?

    what's your source code?

    Edit:
    Example -
    EG:

    In Client-Side event (such as afterDetailViewOpen):
    Code:
    setTimeout(htmlFoo, 1000);
    In Code > Javascript Functions:
    Code:
    var htmlFoo = function ()
    {
        alert("Deleting");
        jQuery('[id$="FIELD_NAME.TOOLBAR"]>[title="Toggle Code"]').remove();
    }
    Last edited by TheSmitchell; 03-27-2013 at 05:41 PM.

Similar Threads

  1. HTML Editing in a memo field
    By lgrupido in forum Application Server Version 10 - Web/Browser Applications
    Replies: 3
    Last Post: 09-09-2010, 04:43 PM
  2. Using HTML editor for simple HTML
    By Mr GreenJeans in forum Alpha Five Version 9 - Desktop Applications
    Replies: 11
    Last Post: 06-25-2010, 05:55 PM
  3. Using HTML editor for simple HTML
    By Mr GreenJeans in forum Application Server Version 9 - Web/Browser Applications
    Replies: 0
    Last Post: 06-23-2010, 02:26 PM
  4. Editing Html field trough a grid
    By mmaisterrena in forum Application Server Version 9 - Web/Browser Applications
    Replies: 15
    Last Post: 04-21-2008, 04:30 PM
  5. Editing html code from a .a5wcmp file
    By Andy Gill in forum Alpha Five Version 6
    Replies: 2
    Last Post: 03-28-2005, 06:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •