[REF] web_editor: lazyload html2canvas

Before this commit, the html2canvas library was loaded in the
assets_common bundle, which is in turn loaded by pretty much all odoo
users.

Since it is a big library, and it is only used in two different cases,
it makes sense to lazy load it.  The call in convert_inline.js has been
adapted.  It is however also added to the point of sale bundle, and
could probably be lazy loaded as well.

closes odoo/odoo#102490

X-original-commit: 3d94b0212d2b7f4d412a578055de42e3f88058eb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
Géry Debongnie
2022-10-06 19:58:59 +02:00
parent e58f098d1a
commit dcf6f8ef3c
2 changed files with 3 additions and 1 deletions
-1
View File
@@ -30,7 +30,6 @@ Odoo Web Editor widget.
'web_editor/static/lib/jQuery.transfo.js',
'web/static/lib/nearest/jquery.nearest.js',
'web_editor/static/lib/webgl-image-filter/webgl-image-filter.js',
'web_editor/static/lib/html2canvas.js', # needed for convert_inline.js
'web_editor/static/lib/DOMPurify.js',
# odoo-editor
@@ -2,6 +2,8 @@
'use strict';
import { isBlock, rgbToHex } from '../editor/odoo-editor/src/utils/utils';
import { loadJS } from '@web/core/assets';
/* global html2canvas */
//--------------------------------------------------------------------------
@@ -631,6 +633,7 @@ async function toInline($editable, cssRules, $iframe) {
* @param {Element} editable
*/
async function flattenBackgroundImages(editable) {
await loadJS('/web_editor/static/lib/html2canvas.js');
for (const backgroundImage of editable.querySelectorAll('*[style*=background-image]')) {
if (backgroundImage.parentElement) { // If the image was nested, we removed it already.
const canvas = await html2canvas(backgroundImage);