Repository navigation
wordpaste: cleaning Microsoft Word / Google Docs paste before $generateNodesFromDOM, with equations as LaTeX #9306
smrifat1411
started this conversation in
Show and tell
Replies: 2 comments 2 replies
|
#9312 should make this a bit easier to hook in |
0 replies
|
That's much cleaner than overriding PASTE_COMMAND. If I'm reading the PR right, the whole hook becomes: configExtension(ClipboardImportExtension, {
$importMimeType: {
'text/html': [(html, _selection, $next) => $next(transformPastedHTML(html))],
},
})with ClipboardDOMImportExtension in dependencies to do the actual import. One question before I put this in the README: does this handler sit above the ClipboardDOMImportExtension one simply because it's registered later in dependencies, or should the order be made explicit? I'll update the Lexical example once #9312 lands. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Sharing a small library I use with Lexical: wordpaste takes the clipboard
text/htmlfrom Microsoft Word, LibreOffice Writer, Google Docs, Outlook or Excel and returns clean HTML. Real nested lists with numbering instead of "1." frozen in the text, tables and alignment kept, colours and fonts dropped, and Word's OMML equations turned into LaTeX in adata-latexattribute.With Lexical it sits in a
PASTE_COMMANDhandler before$generateNodesFromDOM; the example page shows the ten lines: https://smrifat1411.github.io/wordpaste/examples/lexical.html4.3 kB gzipped, zero dependencies, MIT: https://github.com/smrifat1411/wordpaste
Lexical already has its own experimental Word list import, so if you use that, the part you'd get from wordpaste is the rest: Google Docs' bold wrapper, Outlook, LibreOffice, and the equations.
All reactions