Skip to Content
Menú
This question has been flagged
2 Respostes
2861 Vistes

Hi all

Can anyone tell me why, after migrating from version 16 to version 17, it is no longer possible to import Wysiwyg in the usual way?


In my module i use

import { Wysiwyg } from "@web_editor/js/wysiwyg/wysiwyg";

I need this to add new commands to powerbox

But this results in an error:


The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle:

@web_editor/js/wysiwyg/wysiwyg


At the same time, 

import fonts from '@web_editor/js/wysiwyg/fonts';

in the same file, does not lead to errors.


__manifest__ contains dependencies:

'depends': ['base', 'mail', 'web_editor']


I tried to do this on a completely empty module to avoid possible conflicts, but the error was the same. What could be wrong?

Avatar
Descartar
Autor Best Answer

The problem was in the order in which the assets were loaded.

In version 17, it is important that wysiwyg is loaded in a separate assets group:

web.assets_backend:
        'web.assets_backend': [
            'my_module/static/src/scss/**',
            'my_module/static/src/xml/**'
        ],
        'web_editor.backend_assets_wysiwyg': [
            'my_module/static/src/js/wysiwyg.js',
        ],
Avatar
Descartar

Hi I'm trying to do something very similar in Odoo 18.0 upgrading from Odoo 17.0. Have you had any issues with this?

I have this in my manifest:
web.assets_backend:
'web.assets_backend': [
'my_module/static/src/scss/**',
'my_module/static/src/xml/**'
],
'web_editor.backend_assets_wysiwyg': [
'my_module/static/src/js/wysiwyg.js',
],

And this is my wysiwyg.js file:

/** @odoo-module **/
import { Wysiwyg } from '@web_editor/js/wysiwyg/wysiwyg';
import { patch } from '@web/core/utils/patch';
import { _t } from '@web/core/l10n/translation';
import {parseHTML} from '@web_editor/js/editor/odoo-editor/src/utils/utils'

patch(Wysiwyg.prototype, {
_getPowerboxOptions() {
const options = super._getPowerboxOptions();
const wysiwyg = this

options.commands.push({
category: _t('Widgets'),
name: _t('10 Stars'),
priority: 5,
description: _t('Insert a rating over 10 stars'),
fontawesome: 'fa-star',
callback: function () {
let html = '\u200B<span contenteditable="false" class="o_stars o_ten_stars">';
html += Array(10).fill().map(() => '<i class="fa fa-star-o"></i>').join('');
html += '</span>\u200B';
wysiwyg.odooEditor.execCommand('insert', parseHTML(window.document, html));
},
});
return options;
},
});

It works perfectly in Odoo 17.0, but in Odoo 18.0 the modules aren't even loading at all. I can't even see console logs. I've tried it on other browsers, other computers, clearing cache, regenerating assets, restarting odoo http. Can't seem to get anything to load using the web_editor.backend_assets_wysiwyg bundle

Best Answer

Hi Vertec LLC - did you resolve this - have the same issue.


Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de juny 24
2715
0
de nov. 24
1038
0
de març 24
1491
3
de jul. 25
1935
4
de maig 25
2462