Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
2912 Zobrazení

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit

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

Nejlepší odpověď

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


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
čvn 24
2766
0
lis 24
1117
0
bře 24
1528
3
čvc 25
1978
4
kvě 25
2535