0

Is it possible to copy content from a Microsoft Word document into Drupal and use the name of paragraph styles used in word as class names in the HTML?

I am using:

  • Drupal 7.34
  • CKEditor 7.x-1.15+1-dev

If I drag-and-drop content from Word into CKEditor the paragraph styles are used as class names which is good, but unwanted XML comes over from Word too. Example:

<h3><span lang="EN-AU">Prefixes<o:p></o:p></span></h3>

<p class="NormalBeforeBullet"><span lang="EN-AU">A paragraph here with the normal paragraph style to test that class comes along:<o:p></o:p></span></p>

<p class="Bullet" style="margin-left:0cm;text-indent:0cm;mso-list:l0 level1 lfo1"><!--[if !supportLists]--><span lang="EN-AU"><span style="mso-list:Ignore">•<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><!--[endif]--><span lang="EN-AU">These are my own bullets<o:p></o:p></span></p>

<p class="Bullet" style="margin-left:0cm;text-indent:0cm;mso-list:l0 level1 lfo1"><!--[if !supportLists]--><span lang="EN-AU"><span style="mso-list:Ignore">•<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><!--[endif]--><span lang="EN-AU">To test if the HTML<o:p></o:p></span></p>

<p><!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Version>15.0</o:Version>
 </o:DocumentProperties>
</xml>.... a lot more xml code follows....

If I copy and paste the same content from Word into CKEditor, I get better HTML but no class attributes. Example:

<h3>Prefixes</h3>

<p>A paragraph here with the normal paragraph style to test that class comes along:</p>

<ul>
    <li>These are my own bullets</li>
    <li>To test if the HTML</li>
    <li>Is created correctly</li>
</ul>

CKEditor config options I've tried include

  • Disabling Advanced Content Filter with config.allowedContent = true;
  • Adding allowed content filter with config.extraAllowedContent = 'p(mso*,Normal)';
  • Disabling additional paste filter with config.pasteFilter = null;

None of these options have resulted in clean HTML with paragraph styles as class names.

  • Take Drupal out of the equation. Have you established whether this is even possible with CKEditor? – J. Reynolds Mar 3 '16 at 5:35
  • I have not read any references to this functionality specifically in the CKEditor docs, but the fact that paragraph styes come across as class names when I drag and drop content leads me to think it is possible. – Andrew Mar 4 '16 at 6:52
1

CKEditor Editor will not work the same way as Word so when you copy and paste some document to CKEditor. CKEditor will change the setting based on it own setting

  • I know CKEditor and Word do not work the same. I'm looking for suggestions about CKEditor settings which will use the paragraph style name from Word as the class name on the HTML elements in the editor. Thanks for you suggestion. – Andrew Mar 3 '16 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.