Users paste a lot from Word and Excel. Jodit HTML Editor cleans up all unnecessary code and makes HTML just beautiful.
This plugin provides enhanced functionality for pasting content from Microsoft Word and Excel, ensuring clean and properly formatted HTML output.
boolean
false
Enables or disables the paste from Word processing functionality. By default, this feature is disabled and needs to be explicitly enabled.
CopyJodit.make('#editor', { pasteFromWord: { enable: true } });
boolean
false
When enabled, this option converts all units (cm, pt, etc.) to pixels in the pasted content.
CopyJodit.make('#editor', { pasteFromWord: { enable: true, convertUnitsToPixel: true } });
string[]
A list of CSS style properties that will be preserved when pasting from Word. All other style properties will be removed.
Default value:
Copy[ 'background', 'background-color', 'border', 'border-.*', 'color', 'float', 'font-family', 'font-size', 'font-style', 'font-weight', 'height', 'line-height', 'list-style-type', 'margin', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'padding', 'text-align', 'text-justify', 'text-decoration', 'text-indent', 'vertical-align', 'width' ]
You can customize this list to allow only specific style properties:
CopyJodit.make('#editor', { pasteFromWord: { enable: true, allowedStyleProps: [ 'color', 'font-weight', 'text-align' ] } });
CopyJodit.make('#editor', { pasteFromWord: { enable: true, convertUnitsToPixel: true } });
CopyJodit.make('#editor', { pasteFromWord: { enable: true, convertUnitsToPixel: true, allowedStyleProps: [ 'background-color', 'color', 'font-family', 'font-size', 'font-weight', 'text-align', 'text-decoration' ] } });
To completely disable the plugin:
CopyJodit.make('#editor', { disablePlugins: ['pasteFromWordPro'] });
The plugin works in combination with the following core Jodit options:
boolean
true
When enabled, Jodit will show a dialog asking how to paste content from Word.
number
Jodit.INSERT_AS_HTML
Determines the default action when pasting content.
Example of integration with core options:
CopyJodit.make('#editor', { askBeforePasteFromWord: false, pasteFromWord: { enable: true, convertUnitsToPixel: true }, beautifyHTML: false, defaultActionOnPaste: Jodit.INSERT_AS_HTML });
In order for the counters to work correctly with nested lists (e.g., 1, 1.1, 1.2), you must include the following CSS in your stylesheet:
Copyul ol[data-list-style-type='decimal'], ol ol[data-list-style-type='decimal'] { counter-reset: item; } ol ol[data-list-style-type='decimal'] > li, ul ol[data-list-style-type='decimal'] > li { display: block; } ol ol[data-list-style-type='decimal'] > li:before, ul ol[data-list-style-type='decimal'] > li:before { content: counters(item, '.') '. '; counter-increment: item; }
This CSS ensures that nested lists are properly formatted with hierarchical numbering.
convertUnitsToPixel
is enabled, all units (cm, pt, etc.) are converted to pixelsThis process ensures that content pasted from Word is clean, consistent, and properly formatted according to your specifications.