This exists now, if it’s still useful: wordpaste — GitHub - smrifat1411/wordpaste: Clean Microsoft Word clipboard HTML on paste and keep the equations editable. OMML and MathML to LaTeX. 3.6 kB, zero dependencies, works with Tiptap, ProseMirror, Lexical or plain contenteditable. · GitHub
It is the generic converter described up-thread rather than a ProseMirror plugin: MIT, no dependencies, plain DOMParser, one function, string in and string out. Nothing in it knows what editor you use.
import { transformPastedHTML } from 'wordpaste';
new Plugin({
props: { transformPastedHTML: (html) => transformPastedHTML(html) },
});
The three list observations in this thread are exactly what it implements, so to confirm they hold up: the MsoListParagraphCxSp{First,Middle,Last} classes are reliable enough to bound a run, mso-list:lN levelM gives list identity and nesting depth, and the <![if !supportLists]> block has to be unwrapped rather than dropped — it is the only record of how the list was numbered. It rebuilds <ul>/<ol> from those with nesting, the original 1. a. i. sequence, and start when a list doesn’t begin at 1.
One correction to the “throw unknown stuff out” approach: for lists that is worse than doing nothing. Strip the styling and the literal 1. and 2. stay frozen in the paragraph text, so the numbering is permanently wrong the moment anyone reorders or inserts an item. The markers have to be read before they are discarded, which means it has to happen before the schema filter, not after.
On testing without Word to hand — that was the blocker in the last reply here. The fixtures are real Word-shaped clipboard HTML with genuine mso- attributes and <m:oMath> markup, so they are reusable whatever you build: wordpaste/test at main · smrifat1411/wordpaste · GitHub
There is one thing it does that CKEditor’s paste-from-office doesn’t. Word puts an equation on the clipboard twice — as a rasterised screenshot and as the real OMML markup. Everyone takes the picture, so the maths is never editable again. wordpaste reads the OMML (and LibreOffice’s MathML) and converts it to LaTeX. That was the actual reason I wrote it.
Honest limits: it is not a sanitiser — <script>, inline handlers and javascript: URLs pass straight through. Inside ProseMirror the schema drops them, so that is fine here, but sanitise if you innerHTML the output yourself. Google Docs equations are already images on the clipboard, so nobody can recover those.
Playground with real Word samples, if you want to throw your own document at it before trusting it: wordpaste playground — paste from Word into a real editor