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/note/data/note_demo.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/note/data/note_demo.xml')
| -rw-r--r-- | addons/note/data/note_demo.xml | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/addons/note/data/note_demo.xml b/addons/note/data/note_demo.xml index c02acf96ef2..6baf90f6f33 100644 --- a/addons/note/data/note_demo.xml +++ b/addons/note/data/note_demo.xml @@ -3,69 +3,67 @@ <data noupdate="1"> <record id="note_1" model="note.note"> <field name="name">Customer report #349872</field> - <field name="memo"><![CDATA[<b>Customer report #349872</b> - <br/><br/>* Calendar app in Home - <br/>* The calendar module should create a menu in Home, like described above. - <br/>* This module should become a main application (in the first screen at installation) - <br/>* We should use the term Calendar, not Meeting. - ]]> + <field name="memo"><![CDATA[<p><b>Customer report #349872</b></p> + <p><br/></p> + <p>* Calendar app in Home</p> + <p>* The calendar module should create a menu in Home, like described above.</p> + <p>* This module should become a main application (in the first screen at installation)</p> + <p>* We should use the term Calendar, not Meeting.</p>]]> </field> <field name="user_id" ref="base.user_demo"/> <field name="color">2</field> </record> <record id="note_2" model="note.note"> - <field name="memo"><![CDATA[<b>Call Raoulette</b> - <br/><br/>* Followed by the telephone conversation and mail about D.544.3 - ]]> + <field name="memo"><![CDATA[<p><b>Call Raoulette</b></p> + <p><br/></p> + <p>* Followed by the telephone conversation and mail about D.544.3</p>]]> </field> <field name="user_id" ref="base.user_demo"/> </record> <record id="note_4" model="note.note"> - <field name="memo"><![CDATA[<b>Project N.947.5</b> - <br/><br/>]]> + <field name="memo"><![CDATA[<p><b>Project N.947.5</b></p>]]> </field> <field name="stage_id" ref="note_stage_02"/> <field name="user_id" ref="base.user_admin"/> </record> <record id="note_5" model="note.note"> - <field name="memo"><![CDATA[<b>Shop for family dinner</b> - <br/>* stuffed turkey - <br/>* wine - ]]> + <field name="memo"><![CDATA[<p><b>Shop for family dinner</b></p> + <p>* stuffed turkey</p> + <p>* wine</p>]]> </field> <field name="user_id" ref="base.user_demo"/> </record> <record id="note_6" model="note.note"> - <field name="memo"><![CDATA[<b>Idea to develop</b> - <br/><br/>* Create a module note_pad - it transforms the html editable memo text field into widget='pad', similar to project_pad depends on 'memo' and 'pad' modules - ]]> + <field name="memo"><![CDATA[<p><b>Idea to develop</b></p> + <p><br/></p> + <p>* Create a module note_pad + it transforms the html editable memo text field into widget='pad', similar to project_pad depends on 'memo' and 'pad' modules</p>]]> </field> <field name="stage_id" ref="note_stage_02"/> <field name="user_id" ref="base.user_admin"/> </record> <record id="note_8" model="note.note"> - <field name="memo"><![CDATA[<b>New computer specs</b> - <br/><br/>* Motherboard + <field name="memo"><![CDATA[<p><b>New computer specs</b></p> + <p><br/></p> + <p>* Motherboard according to processor - <br/>* Processor + </p><p>* Processor need to decide - <br/>* Graphic card + </p><p>* Graphic card with great performance for games ! - <br/>* Hard drive + </p><p>* Hard drive big, for lot of internet backups - <br/>* Tower + </p><p>* Tower silent, better when watching films - <br/>* Blueray drive ? + </p><p>* Blueray drive ? is it interesting yet ? - <br/>* Screen - a big one, full of pixels, of course ! - ]]> + </p><p>* Screen + a big one, full of pixels, of course !</p>]]> </field> <field name="stage_id" ref="note_stage_03"/> <field name="color">3</field> @@ -73,19 +71,19 @@ </record> <record id="note_9" model="note.note"> - <field name="memo"><![CDATA[<b>Read those books</b> - <br/><br/>* Odoo: a modern approach to integrated business management - <br/>* Odoo for Retail and Industrial Management - ]]> + <field name="memo"><![CDATA[<p><b>Read those books</b></p> + <p><br/></p> + <p>* Odoo: a modern approach to integrated business management</p> + <p>* Odoo for Retail and Industrial Management</p>]]> </field> <field name="user_id" ref="base.user_demo"/> </record> <record id="note_12" model="note.note"> - <field name="memo"><![CDATA[<b>Read some documentation about Odoo before diving into the code</b> - <br/><br/>* Odoo: a modern approach to integrated business management - <br/>* Odoo for Retail and Industrial Management - ]]> + <field name="memo"><![CDATA[<p><b>Read some documentation about Odoo before diving into the code</b></p> + <p><br/></p> + <p>* Odoo: a modern approach to integrated business management</p> + <p>* Odoo for Retail and Industrial Management</p>]]> </field> <field name="color">7</field> <field name="stage_ids" eval="['note_stage_03']"/> |
