1. #1
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    227
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Default HTMLEditor: convert HTML to text and vice versa

    HTMLEditor: convert HTML to text and vice versa


    I've got an HTMLEditor and I need:
    1. to save data in text format by setValue() function (without tags HTML and the tag <br> must be converted in #13)

    2. read the text data by getValue() function and transform the text in HTML

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can use RegExp to replace tags.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi nicolabaldo,
    you can use regex to replace the html tag like this.

    Ext.util.Format.stripTags(yourhtmleditor.ed.getContent({format: 'raw' }).replace(/<\/?p+>/gi, ' '))

    It will remove all html tag and also replace <p> tag with space.
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  4. #4
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    227
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Default


    Ok thanks!

Thread Participants: 2