Results 1 to 7 of 7

Thread: Coloring a string/line of text in a text

  1. #1

    Default Coloring a string/line of text in a text

    Hello Community,

    The program i am currently working on requires me to load a XML File,display it in a container/textarea, let it be validated and mark(color the font background red for example) the spots,where validation failed.(given to me as an XPath expression)

    The problem is, i couldnt find an ExtJS internal way of coloring a specific part of some kind of text
    and the workaround i thought of, using HTML/CSS for styling, doesnt really work either,
    since if i display it in a container which interpretes tags it also tries to interprete the tags in the XMLFile,
    which i dont want.

    I would very much appreciate any suggestions on how to solve this problem.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Can you remove the tags ( Ext.stripTags / Ext.stripScripts )?

    If you are unable to use our Ext.form.htmlEditor, tags, or color it with CSS like shown here:
    http://jsfiddle.net/HR5N8/

    Then I am not sure how you would achieve this.

  3. #3
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    You might want to look at something like code mirror:

    http://codemirror.net/demo/preview.html
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You might want to look at something like code mirror:
    On that note .. there is:
    https://github.com/ateodorescu/mzExt

    Or an alternative for AceEditor
    https://github.com/harrydeluxe/extjs-ux

  5. #5

    Default

    First of all, thank you all for taking the time trying to help me.

    sadly none of your suggestions are really what im looking for.

    stripping the tags is not a possibility, as they are the subject of validation
    and therefore have to be displayed, and why styling with HTML/CSS doesnt work i already stated above;
    I need to keep the xml file as plain text as given to me, just coloring the validation errors.

    HTML Editors be it the extjs one, or codemirror etc would confuse the User unnessecarily,
    as it is just for display, and the text should not be editable.

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    Oh, you just want to highlight it and it's static? Even easier (this is the first one I pulled from google, there's probably way more):

    http://alexgorbatchev.com/SyntaxHigh...ushes/xml.html
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  7. #7

    Default

    well, static is not quite right, as i have to dynamically accept and display any xml file the user uploads,
    but the syntaxhighlighter might be something i can work with regardless, ill have a look into it.

Posting Permissions

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