Skip to content

Commit

Permalink
[IMP] Cleaned and Improved. Working.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfcapalbo committed Sep 20, 2022
1 parent 9e119cd commit dbfc425
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 635 deletions.
25 changes: 14 additions & 11 deletions web_widget_html_markdown/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================================
Web Widget Html Markdown Unidirectional
Web Widget Html Markdown Unidirectional
========================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -14,13 +14,13 @@ Web Widget Html Markdown Unidirectional
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/14.0/web_widget_html_markdown
:target: https://github.com/OCA/web/tree/14/web_widget_html_markdown
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_widget_html_markdown
:target: https://translation.odoo-community.org/projects/web-14/web-14-web_widget_html_markdown
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/14.0
:target: https://runbot.odoo-community.org/runbot/162/14
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -31,7 +31,6 @@ Behaviour of the module and best practices
- In readonly mode, the widget renders as Html
- In editable mode, there is a switcher to choose if the source should be HTML or Markdown. If HTML, it shows the HTML edit widget. If Markdown, it shows a markdown widget. When done editing, it will save in the field as Html, no matter which widget is chosen.
- The Module converts only from markdown to html, so if i am writing HTML and then switch to markdown, i will lose all my HTML.
Therefore the module is called "unidirectional" the conversion will only be markdown-->Html.
- when switching from markdown to HTML: the markdown will always be converted and saved in html.
- if I switch again from HTML to markdown, i will lose all my html again, only the part i wrote in markdown will be preserved.
- Module provides a warning "You will lose all your current HTML if you switch to markdown"
Expand Down Expand Up @@ -61,29 +60,33 @@ Usage
Your XML form view definition should contain:

...
<field name="field_name" widget="html_markdown_unidirectional"/>
<field name="field_name" widget="html_markdown"/>
...

The widget is called unidiectional because itt is used on a Html field to edit HTML
or Markdown, but the conversion is unidirectional, ONLY from Markdown to HTML.
The widget is used on a Html field to edit HTML or Markdown,
but the conversion is unidirectional, ONLY from Markdown to HTML.

This will replace the default Html widget by the new Markdown/HTML widget and
allow the field to be edited as Markdown or HTML, depending on the user's choice.

#### Options
- default_markdown_on_new : if true when creating a new record, markdown will
be selected by default.
- only_markdown_on_new : if true when creating a new record, only markdown
will be present on radiobutton.

Known issues / Roadmap
======================

* HTML Will be lost when passing from Html to markdown


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_html_markdown%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_html_markdown%0Aversion:%2014%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -123,6 +126,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/web <https://github.com/OCA/web/tree/14.0/web_widget_html_markdown>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/14/web_widget_html_markdown>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion web_widget_html_markdown/demo/bootstrap_markdown.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="inherit_id" ref="base.view_groups_form" />
<field name="arch" type="xml">
<field name="comment" position="attributes">
<attribute name="widget">html_markdown_unidirectional</attribute>
<attribute name="widget">html_markdown</attribute>
</field>
</field>
</record>
Expand Down
1 change: 0 additions & 1 deletion web_widget_html_markdown/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Behaviour of the module and best practices
- In readonly mode, the widget renders as Html
- In editable mode, there is a switcher to choose if the source should be HTML or Markdown. If HTML, it shows the HTML edit widget. If Markdown, it shows a markdown widget. When done editing, it will save in the field as Html, no matter which widget is chosen.
- The Module converts only from markdown to html, so if i am writing HTML and then switch to markdown, i will lose all my HTML.
Therefore the module is called "unidirectional" the conversion will only be markdown-->Html.
- when switching from markdown to HTML: the markdown will always be converted and saved in html.
- if I switch again from HTML to markdown, i will lose all my html again, only the part i wrote in markdown will be preserved.
- Module provides a warning "You will lose all your current HTML if you switch to markdown"
Expand Down
6 changes: 3 additions & 3 deletions web_widget_html_markdown/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Your XML form view definition should contain:

...
<field name="field_name" widget="html_markdown_unidirectional"/>
<field name="field_name" widget="html_markdown"/>
...

The widget is called unidiectional because itt is used on a Html field to edit HTML
or Markdown, but the conversion is unidirectional, ONLY from Markdown to HTML.
The widget is used on a Html field to edit HTML or Markdown,
but the conversion is unidirectional, ONLY from Markdown to HTML.

This will replace the default Html widget by the new Markdown/HTML widget and
allow the field to be edited as Markdown or HTML, depending on the user's choice.
Expand Down
55 changes: 43 additions & 12 deletions web_widget_html_markdown/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Web Widget Html Markdown</title>
<title>Web Widget Html Markdown Unidirectional</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,23 +360,41 @@
</style>
</head>
<body>
<div class="document" id="web-widget-html-markdown">
<h1 class="title">Web Widget Html Markdown</h1>
<div class="document" id="web-widget-html-markdown-unidirectional">
<h1 class="title">Web Widget Html Markdown Unidirectional</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_widget_html_markdown"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_widget_html_markdown"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/14/web_widget_html_markdown"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-14/web-14-web_widget_html_markdown"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/14"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<div class="section" id="behaviour-of-the-module-and-best-practices">
<h1>Behaviour of the module and best practices</h1>
<ul class="simple">
<li>In readonly mode, the widget renders as Html</li>
<li>In editable mode, there is a switcher to choose if the source should be HTML or Markdown. If HTML, it shows the HTML edit widget. If Markdown, it shows a markdown widget. When done editing, it will save in the field as Html, no matter which widget is chosen.</li>
<li>In markdown mode, the markdown is saved embedded within the HTML so that it can be shown again on subsequent edits of the field and there is no loss from backconversion of Html to Markdown.</li>
<li>When switching the widget from Markdown to HTML, the Markdown source is lost.</li>
<li>When switching the widget from HTML back to Markdown, the Showdown.JS backconversion is used to generate a reasonable representation of the HTML in markdown. This is where some information loss can occur, so the user should not needlessly switch from HTML to Markdown and back - in general, choose one way to edit your field content, and stick to it.</li>
<li>In edit mode, the widget provides some feedback about potential loss of information when switching from HTML to markdown or when editing in HTML text that was edited in markdown.</li>
<li><dl class="first docutils">
<dt>The Module converts only from markdown to html, so if i am writing HTML and then switch to markdown, i will lose all my HTML.</dt>
<dd><ul class="first last">
<li>when switching from markdown to HTML: the markdown will always be converted and saved in html.</li>
<li>if I switch again from HTML to markdown, i will lose all my html again, only the part i wrote in markdown will be preserved.</li>
</ul>
</dd>
</dl>
</li>
<li>Module provides a warning “You will lose all your current HTML if you switch to markdown”</li>
<li><dl class="first docutils">
<dt>Best usages of this module:</dt>
<dd><ol class="first last arabic">
<li>As normal Html editor, only HTML</li>
<li>Write some markdown and then add some HTML. ( will cause loss of HTML if you edit markdown again)</li>
<li>Only markdown.</li>
</ol>
</dd>
</dl>
</li>
<li>RE-editing pure markdown content is LOSSLESS because we preserve the markdown content in a special tag.</li>
<li>Every switch to markdown will cause destruction of HTML. Html Can Be added after writing Markdown part but will always be deleted.</li>
</ul>
</div>
<div class="section" id="utility-of-this-module-vs-web-widget-text-markdown">
Expand All @@ -391,22 +409,35 @@ <h1>Usage</h1>
&lt;field name=”field_name” widget=”html_markdown”/&gt;
</blockquote>
<p>The widget is used on a Html field to edit HTML or Markdown,
but the conversion is unidirectional, ONLY from Markdown to HTML.</p>
<p>This will replace the default Html widget by the new Markdown/HTML widget and
allow the field to be edited as Markdown or HTML, depending on the user’s choice.</p>
<blockquote>
<dl class="docutils">
<dt>#### Options</dt>
<dd><ul class="first last simple">
<li>default_markdown_on_new : if true when creating a new record, markdown will
be selected by default.</li>
<li>only_markdown_on_new : if true when creating a new record, only markdown
will be present on radiobutton.</li>
</ul>
</dd>
</dl>
</blockquote>
</div>
<div class="section" id="known-issues-roadmap">
<h1>Known issues / Roadmap</h1>
<ul class="simple">
<li>Images Will be lost when passing from Html to markdown</li>
<li>Other information may be lost when switching from Html to markdown</li>
<li>HTML Will be lost when passing from Html to markdown</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1>Bug Tracker</h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_html_markdown%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_html_markdown%0Aversion:%2014%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -441,7 +472,7 @@ <h2>Maintainers</h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_widget_html_markdown">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/14/web_widget_html_markdown">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Loading

0 comments on commit dbfc425

Please sign in to comment.