1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Copy from word, paste to wysiwyg editor and remove word tags...

Discussion in 'JavaScript' started by AmidalaX, Feb 13, 2011.

  1. #1
    Hi there,

    I have an issue with word and my WYSIWYG editor on web. When I copy something from word and paste it to my editor on web, it keeps formating but also insert lot of word tags which are not valid in html, sometimes change font on whole site, or link colors, etc...

    Is there any way in js how to clean text before paste to editor? Ty
     
    AmidalaX, Feb 13, 2011 IP
  2. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Depends on what you mean with "your"editor (you developed it or you mean just a usage of 3rd party editor). Most of the available editors support pasting from word, maybe you could try another HTML editor then. The option is called "Paste from Word" and requires special handling for Word contents, you can see an example here:
    http://tinymce.moxiecode.com/tryit/full.php

    Another example:
    http://www.asp.net/ajax/ajaxcontroltoolkit/samples/htmleditor/htmleditor.aspx or http://www.obout.com/editor_new/sample_full.aspx

    Eventually you could see what word tag cleaning logic is being used by those editors and only integrate that specific functionality into your editor.
     
    hogan_h, Feb 13, 2011 IP
  3. AmidalaX

    AmidalaX Greenhorn

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Maybe you dont understand me. When I copy something from word, paste it into editor(mostly nicedit) and then I show source I see tags like
    <meta name="Title" content="" /><meta name="Keywords" content="" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 14" /><meta name="Originator" content="Microsoft Word 14" /><link rel="File-List" href="... <!--[if gte mso 9]><xml> <o:OfficeDocumentSettings>  <o:AllowPNG/> </o:OfficeDocumentSettings></xml><![endif]--><link rel="themeData" ....
    Code (markup):
    It also copy styles, another xml, etc etc and I dont want them paste to my editor...
    I tried it in that asp.net editor you posted, its same as in nicedit, but tinymce cleaned it. How can I do this in any editor?
    EDIT: In obout.com editor I see that tags too.
     
    AmidalaX, Feb 13, 2011 IP
  4. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you using the "Paste from MS Word (with cleanup)" Button or are you just pasting text directly into editor? Because the button function *should* clean all those extra ms word tags.

    Anyways, you can't do this in "any editor" just like that. The editor itself must provide this functionality or you gotta mod it by yourself. If the obout editor isn't working that way (it should actually, if it says "cleanup" it should mean removing unnecessary tags) or nicedit, then i would go with tinymce.

    The workaround i use sometimes is to always paste whole content into notepad first to remove all formatting, and then C&P it into editors, but that could be too much work ;)
     
    hogan_h, Feb 13, 2011 IP
  5. AmidalaX

    AmidalaX Greenhorn

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Just pasting text directly(as most of users do it). This is not about me, I know how to paste it there correctly, this is about users who dont understand this (and I think they never will) and then call me "What happend? I pasted text from word and..." no matter how many times you tell them how to do it...

    I found fix for nicedit minute ago - http://www.billyswebdesign.com/blog...-wysiwyg-that-can-clean-a-paste-from-ms-word/ I havent tested it yet, hope itll work.

    P.S.: I do it same way sometimes :D
     
    AmidalaX, Feb 13, 2011 IP