HTML import: Replace cheerio with jsdom to simplify contentcollector

Cheerio provides jQuery-like objects but they wrap DOM Node-like
objects that are not 100% API compatible with the DOM spec. Because of
this, contentcollector, which is used in browsers and in Node.js
during HTML import, has until now needed to support two different
APIs. This commit modifies HTML import to use jsdom instead of cheerio
and simplifies contentcollector.
This commit is contained in:
Richard Hansen 2021-01-24 01:08:08 -05:00
parent 84d6d277d7
commit c816c20bc7
6 changed files with 330 additions and 215 deletions

View file

@ -1,3 +1,22 @@
# Next Release
### Compatibility changes
* For plugin authors:
* Etherpad now uses [jsdom](https://github.com/jsdom/jsdom) instead of
[cheerio](https://cheerio.js.org/) for processing HTML imports. There are
two consequences of this change:
* `require('ep_etherpad-lite/node_modules/cheerio')` no longer works. To
fix, your plugin should directly depend on `cheerio` and do
`require('cheerio')`.
* The `node` context argument passed to the `collectContentImage` hook is
now an
[`HTMLImageElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement)
object rather than a Cheerio Node-like object, so the API is slightly
different. See
[citizenos/ep_image_upload#49](https://github.com/citizenos/ep_image_upload/pull/49)
for an example fix.
# 1.8.14
### Security fixes