Wednesday, 21 September 2022

Odoo: how to replace standard discuss textarea by froala editor?

I want to extend the message field to do from this to this

enter image description hereenter image description here

in file addons\mail\static\src\components\composer_text_input\composer_text_input.xml there is a template with current textarea:

<t t-name="mail.ComposerTextInput" owl="1">
    <div class="o_ComposerTextInput">
        <t t-if="composerView">
            <t t-if="composerView.hasSuggestions">
                <ComposerSuggestionList
                    composerViewLocalId="props.composerViewLocalId"
                    isBelow="props.hasMentionSuggestionsBelowPosition"
                />
            </t>
            <textarea class="o_ComposerTextInput_textarea o_ComposerTextInput_textareaStyle" t-att-class="{ 'o-composer-is-compact': props.isCompact }" t-esc="composerView.composer.textInputContent" t-att-placeholder="textareaPlaceholder" t-on-click="_onClickTextarea" t-on-focusin="_onFocusinTextarea" t-on-focusout="_onFocusoutTextarea" t-on-keydown="_onKeydownTextarea" t-on-keyup="_onKeyupTextarea" t-on-input="_onInputTextarea" t-ref="textarea"/>
            <!--
                 This is an invisible textarea used to compute the composer
                 height based on the text content. We need it to downsize
                 the textarea properly without flicker.
            -->
            <textarea class="o_ComposerTextInput_mirroredTextarea o_ComposerTextInput_textareaStyle" t-att-class="{ 'o-composer-is-compact': props.isCompact }" t-esc="composerView.composer.textInputContent" t-ref="mirroredTextarea" disabled="1"/>
        </t>
    </div>
</t>

here is an example how it works in pure HTML file (2 files are placed in the same directory as a *.html file):

<html>
    <head>
        <link href="froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
        <textarea id="example"></textarea>
        <script type="text/javascript" src="froala_editor.pkgd.min.js"></script>
        <script type="text/javascript" >
            var editor = new FroalaEditor('#example');
        </script>
    </body>
</html>

problem is that when I insert that code, piece like that:

<link href="froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="froala_editor.pkgd.min.js"></script>

odoo can't find it, line with styles also doesn't work. i tried also to paste code from froala_editor.pkgd.min.js in tag. In pure HTML it works, in odoo .xml not.

What I`m doing wrong?



from Odoo: how to replace standard discuss textarea by froala editor?

No comments:

Post a Comment