2013-02-23 18 views
7

単語からテキストをwysihtml5 editorにコピーすると、テキストはフォーマットされ、追加された追加文字の点で混乱します。これは簡単に修正できますか?私が探している正しい振る舞いは、Stack Overflowのリッチテキストエディタの働きです。つまり、単語からコピーされ貼り付けられたテキストは、wordドキュメントと同じに見えます。wysihtml5:単語文書からエディターへのテキストのコピー

ありがとうございました!

更新: が貼り付けられた単語のテキストの書式で観察さの問題を解決するために、私が使用しwysihtml5-0.30_rc2.jsファイル内の行"p": {},を追加しました。この行は、defaultOptions [parserRules] [tags](see used resource)の宣言に追加されました。

はまだ、今私が貼り付けたテキスト「フォントの定義」段落の先頭に見ることができます:

<!-- /* Font Definitions */ @font-face {font-family:Arial; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; mso-hyphenate:none; font-size:11.0pt; font-family:Arial; mso-fareast-font-family:Arial; mso-bidi-font-family:Arial; color:black; mso-fareast-language:HI; mso-bidi-language:HI;} a:link, span.MsoHyperlink {mso-style-unhide:no; mso-style-parent:""; color:navy; mso-ansi-language:#00FF; mso-fareast-language:#00FF; mso-bidi-language:#00FF; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 
90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} --> 

これが唯一の私は、Firefoxを使用したときの動作、およびChromeで発生しません。どのようにこの問題を取り除くための任意のアイデア?

+0

私は同じ問題があります! – RayOnAir

+0

私も同じ問題を抱えていて、それは私を狂ってしまいます。私は本当にwysihtml5が好きです。しかし、私のユーザー、つまりWordでの書き込みが好きなユーザーは、コピーして貼り付けるときに永遠に問題が発生します。進行中の修正の検索で不運なことはありますか? – realistschuckle

答えて

1

wysihtml5には、テキスト領域に貼り付けられたすべてのテキストを解析し、parserRules設定オブジェクトで定義されているフィルタ規則を適用するパーサーが含まれています。あなたのparserRules"style": { "remove": 1 }を追加することはすべきことです。

Firefoxの問題を理解するには、テキスト領域にペーストされる生のクリップボードのHTMLコンテンツ(Word由来)を確認する必要があります。いくつかのWordテキストをコピーしてテキストエディタに貼り付けるだけでは、テキストエディタがクリップボードの内容のテキストのみの変形を要求するので役に立ちません。

Macの場合は、XCodeで自分でコンパイルする必要があるClipboardViewer toolの助けを借りて、この生のクリップボードの内容を見ることができます。目的のHTMLコンテンツはpublic.htmlまたはApple HTML pasteboard typeフィールドにある必要があります。たぶん、コンパイルする必要がない、および/または他のオペレーティングシステムで動作する他のツールが存在する可能性があります。

今、あなたは、Wordからクリップボードの内容は、実際にフォント定義ジャンクが消えた(その内容のすべてを持つ)styleタグを除去することによって、そう

<span> 
    <!-- 
     /* Font Definitions */ 
     ... 
     div.WordSection1 {page:WordSection1;} 
     ... 
    --> 
    </span> 

のようになりますことがわかります。

詳細設定オプションについては、wysihtml5’s parserRule demoをご覧ください。

1

wysihtml5.dom.getPastedHtmlを上書きして解決しました。 wysihtml5を読み込んだ後でこれを追加してください:

wysihtml5.dom.getPastedHtml = function(event) { 
    var html; 
    if (event.clipboardData) { 
    html = event.clipboardData.getData('text/plain'); 
    } 
    return html; 
}; 
関連する問題