diff options
| author | Robot Odoo <xmo+roboto@odoo.com> | 2019-01-17 19:17:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-17 19:17:22 +0100 |
| commit | 22efdfbecc1e8c688000be98903a5a355d1ece8a (patch) | |
| tree | e097625171b2b67ed5f5288ced67446608b9f633 /addons/web/static/src/xml | |
| parent | f50fbc6d168f0d17fa1e932b4ecc968a92b02b65 (diff) | |
| parent | eb0ea8efbe932c140302e9f8da33a839bcd73146 (diff) | |
[IMP] web_editor,*: Refactoring the wysiwyg editor and 'html' field
_Task #1878502_
- The refactoring allows for the update of the _Summernote_ library.
- A new structure was created by transforming all the plugins in the library using the odoo inheritance system. Plugins are easier to implement with the `AbstractPlugin` to add Odoo behaviors.
- The cleanup allowed us to remove some of the code that was in `web_editor` but only used in `website` or in `mass_mailing`. Some parts are still in `web_editor` but will be moved at a later time.
- The refactoring also had to be done in order to create a set of unit tests. Each behavior can be tested, including the behaviors performed as a consequence of keyboard interactions (for instance: Enter, Tab...).
- From now on, the methods of the library (in this case _Summernote_) can no longer be called by other modules or files. Only the `wysiwyg` widgets can access it, to simplify the updating process. The `wysiwyg` object serves as an interface. A lot of tests are done, ensuring the consistency of outside behavior.
- Depending on the options the snippets will be loaded or not, the editor will be in an iframe or not... all of this is transparent from the outside.
- Regarding iframes, all controllers related to editing have been removed: the new API no longer needs them. This speeds up loading, eases testing and removes complexity for the same features.
**PUBLIC FEATURES**
There are several public methods on the `Wysiwyg` class:
- `Wysiwyg.prepare (WidgetParent)` which returns a deferred resolved when the library (xml, lazy, assets...) is loaded.
- `Wysiwyg.getRange (DOM)` returns the range (selection in the dom)
- `Wysiwyg.setRange (startNode, startOffset, endNode, endOffset)` which creates a range (selection in the dom)
- `Wysiwyg.setRangeFromNode (DOM, options)` that creates a range from an element (option available to select all, start or end)
A jQuery selector was added: `:o_editable`, which indicates whether the current element is editable. That is, if it is contained in a tag with the attribute `contentEditable = "true"` or in a tag with the class `o_editable`.
Several methods are also present:
- `focusIn`: makes a focus and places the cursor at the beginning of the element
- `focusInEnd`: makes a focus and places the cursor at the end of the element
- `selectContent`: makes a focus and selects the content
**HTML FIELD**
The HTML field can receive different options:
- `style-inline:` {boolean} transforms a class into an inline style when saving and vice versa when reading.
- `no-attachment`: {boolean} prevents the use of attachments (in media dialog)
- `cssEdit`: {xml_id} to use a template containing the css to loaded in an iframe when editing
- `cssReadonly`: {xml_id} to use a template containing the css to load into an iframe when viewing in readonly
- `snippets`: {xml_id} snippets template (can be used with or without `cssEdit`)
- `wrapper`: {template} qweb static template (containing a tag: `id = "wrapper"`) that will include the content during editing (removed on save)
**MASS MAILING**
A widget was created for `mass mailing`. There are now two fields: `body_html` and `body_arch`.
`body_arch` contains the code with the class without conversion into inline style, useful when editing and one with the inline style that is visible in readonly mode and sent by email.
Advantage: no spreading errors, able to update css/theme, able to do more changes when converting to inline style so that a maximum of mail clients have an impeccable rendering.
**REMAINING KNOW ISSUES**
These will be fixed in a subsequent commit.
- A few committed changes made during the development of this refactoring were lost in the process and should be reapplied.
- Some minor (mostly range) issues remain with Firefox.
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
closes odoo/odoo#29775
Diffstat (limited to 'addons/web/static/src/xml')
| -rw-r--r-- | addons/web/static/src/xml/colorpicker.xml | 62 | ||||
| -rw-r--r-- | addons/web/static/src/xml/report.xml | 11 |
2 files changed, 2 insertions, 71 deletions
diff --git a/addons/web/static/src/xml/colorpicker.xml b/addons/web/static/src/xml/colorpicker.xml deleted file mode 100644 index 4d85f3172a1..00000000000 --- a/addons/web/static/src/xml/colorpicker.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<templates> - <t t-name="web.colorpicker"> - <div class="o_colorpicker_widget"> - <div class="row"> - <div class="col-auto"> - <div class="o_color_pick_area d-inline-block border"> - <div class="o_picker_pointer rounded-circle"/> - </div> - <div class="o_color_slider d-inline-block ml-2 border"> - <div class="o_slider_pointer"/> - </div> - <div class="o_opacity_slider d-inline-block ml-2 border"> - <div class="o_opacity_pointer"/> - </div> - </div> - <form class="col o_color_picker_inputs"> - <div class="input-group"> - <div class="input-group-prepend o_color_preview_parent"> - <span class="input-group-text rounded-0 o_color_preview"/> - </div> - <input type="text" class="form-control o_hex_input" data-color-method="hex"/> - </div> - <div class="form-row mt-2"> - <div class="col"> - <div class="form-group"> - <label for="red">Red</label> - <input type="text" class="form-control o_red_input" data-color-method="rgb" id="red"/> - </div> - <div class="form-group"> - <label for="green">Green</label> - <input type="text" class="form-control o_green_input" data-color-method="rgb" id="green"/> - </div> - <div class="form-group"> - <label for="blue">Blue</label> - <input type="text" class="form-control o_blue_input" data-color-method="rgb" id="blue"/> - </div> - </div> - <div class="col"> - <div class="form-group"> - <label for="hue">Hue</label> - <input type="text" class="form-control o_hue_input" data-color-method="hsl" id="hue"/> - </div> - <div class="form-group"> - <label for="saturation">Saturation %</label> - <input type="text" class="form-control o_saturation_input" data-color-method="hsl" id="saturation"/> - </div> - <div class="form-group"> - <label for="lightness">Lightness %</label> - <input type="text" class="form-control o_lightness_input" data-color-method="hsl" id="lightness"/> - </div> - </div> - </div> - <div class="form-group"> - <label for="opacity">Opacity %</label> - <input type="text" class="form-control o_opacity_input" data-color-method="opacity" id="opacity"/> - </div> - </form> - </div> - </div> - </t> -</templates> diff --git a/addons/web/static/src/xml/report.xml b/addons/web/static/src/xml/report.xml index 49313e8de5a..7f08d009d53 100644 --- a/addons/web/static/src/xml/report.xml +++ b/addons/web/static/src/xml/report.xml @@ -7,15 +7,8 @@ <!-- Buttons of the Control Panel --> <t t-name="report.client_action.ControlButtons"> - <div class="o_report_no_edit_mode"> + <div class="o_report_buttons"> <button type="button" class="btn btn-primary o_report_print" title="Print">Print</button> </div> - <div class="o_edit_mode_available"> - <button type="button" class="btn btn-secondary o_report_edit" title="Edit">Edit</button> - </div> - <div class="o_report_edit_mode"> - <button type="button" class="btn btn-primary o_report_save" title="Save">Save</button> - <button type="button" class="btn btn-secondary o_report_discard" title="Discard">Discard</button> - </div> </t> -</template>
\ No newline at end of file +</template> |
