diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bedc50c4297..988051bfe92c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,6 +27,11 @@ repos: entry: found forbidden files; remove them language: fail files: "\\.rej$" + - id: en-po-files + name: en.po files cannot exist + entry: found a en.po file + language: fail + files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools rev: ab1d7f6 hooks: @@ -96,7 +101,7 @@ repos: - id: pyupgrade args: ["--keep-percent-format"] - repo: https://github.com/PyCQA/isort - rev: 5.5.1 + rev: 5.12.0 hooks: - id: isort name: isort except __init__.py @@ -104,7 +109,7 @@ repos: - --settings=. exclude: /__init__\.py$ - repo: https://github.com/acsone/setuptools-odoo - rev: 2.6.0 + rev: 3.1.8 hooks: - id: setuptools-odoo-make-default - id: setuptools-odoo-get-requirements @@ -113,25 +118,21 @@ repos: - requirements.txt - --header - "# generated from manifests external_dependencies" - - repo: https://gitlab.com/PyCQA/flake8 + - repo: https://github.com/PyCQA/flake8 rev: 3.8.3 hooks: - id: flake8 name: flake8 additional_dependencies: ["flake8-bugbear==20.1.4"] - - repo: https://github.com/PyCQA/pylint - rev: v2.11.1 + - repo: https://github.com/OCA/pylint-odoo + rev: 7.0.2 hooks: - - id: pylint + - id: pylint_odoo name: pylint with optional checks args: - --rcfile=.pylintrc - --exit-zero verbose: true - additional_dependencies: &pylint_deps - - pylint-odoo==5.0.5 - - id: pylint - name: pylint with mandatory checks + - id: pylint_odoo args: - --rcfile=.pylintrc-mandatory - additional_dependencies: *pylint_deps diff --git a/web_widget_html_markdown/doc/tech_design.md b/web_widget_html_markdown/doc/tech_design.md new file mode 100644 index 000000000000..d97731db2ce9 --- /dev/null +++ b/web_widget_html_markdown/doc/tech_design.md @@ -0,0 +1,47 @@ +# Technical design of the markdown for html fields widget + +When this widget is linked to an html field, the user will be able to switch between an +html editor and a markdown editor for the fields content. The display of the field, and +the contents stored will always be html. + +Actually when editing in markdown, this markdown will also be stored in html, but then +as a hidden code section. In this way using the widget does not need any new database +element. + +To convert from markdown to html, the marked library is used: [marked]: +https://github.com/markedjs/marked + +To convert from html to markdown the turndown library is used: [turndown]: +https://github.com/mixmark-io/turndown + +## Events + +1. Starting the editor + +When a field is going to be edited, we have to show either the html editor or the +markdown editor. For existing records, we just look at the presence or absence of stored +markdown code. For new records we will look at the field options. + +2. Switching to markdown + +- Take the html value and convert it to markdown; +- Create the markdown hidden paragraph, and add it to the html; +- Activate the markdown editor; +- Change to info in the control area to show markdown is being used. + +3. Switching to html + +- Take the markdown content and convert it to html; +- Remove the hidden markdown paragraph; +- Activate the html editor; +- Change to info in the control area to show html is being used. + +4. Saving the form: commiting the changes + +If html is being used, nothing special needs to be done. + +If markdown is being used: + +- Convert the markdown value to html; +- Add the hidden paragraph with the markdown content; +- Replace the html contents with the html genererated, including the hidden paragraph. diff --git a/web_widget_html_markdown/readme/CONTRIBUTORS.rst b/web_widget_html_markdown/readme/CONTRIBUTORS.rst index e74d0af8ea9a..9cdcbc1d323f 100644 --- a/web_widget_html_markdown/readme/CONTRIBUTORS.rst +++ b/web_widget_html_markdown/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Tom Blauwendraat * Kevin Kamau * Giovanni Francesco Capalbo +* Ronald Portier diff --git a/web_widget_html_markdown/readme/DESCRIPTION.rst b/web_widget_html_markdown/readme/DESCRIPTION.rst index 6d0a0307a0cd..000e4074906c 100644 --- a/web_widget_html_markdown/readme/DESCRIPTION.rst +++ b/web_widget_html_markdown/readme/DESCRIPTION.rst @@ -1,11 +1,17 @@ Behaviour of the module and best practices ========================================== -This module implements a Markdown editor on Html fields, in contrast to web_widget_text_markdown, which implements it on Text fields. In readonly mode, the widget displays HTML, but when editing, the widget offers you an option to edit in Markdown or in HTML. If you edit markdown, it will save as the rendered HTML, but with the source Markdown embedded inside a