-
Notifications
You must be signed in to change notification settings - Fork 27
Employeur : ajouter un éditeur de texte markdown sur les grands champs de saisie #4834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
082eed3 to
b46b733
Compare
|
🥁 La recette jetable est prête ! 👉 Je veux tester cette PR ! |
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: pypi/pytest-randomly@3.15.0, pypi/pytest-subtests@0.13.1, pypi/pytest-xdist@3.6.1, pypi/python-crontab@3.2.0, pypi/regex@2024.9.11 |
1efa213 to
066e757
Compare
EwenKorr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour la relecture : je mets en évidence les différences par rapport à #4816
| from dotenv import load_dotenv | ||
|
|
||
| from itou.utils.enums import ItouEnvironment | ||
| from itou.utils.urls import markdown_url_set_protocol, markdown_url_set_target_blank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ajouté ces callbacks pour mieux gérer les liens en markdown
| MARKDOWNIFY = { | ||
| "default": { | ||
| "WHITELIST_TAGS": ["a", "p", "ul", "ol", "li", "em", "strong", "br"], | ||
| "MARKDOWN_EXTENSIONS": ["nl2br", "sane_lists"], | ||
| "LINKIFY_TEXT": { | ||
| "PARSE_URLS": True, | ||
| "CALLBACKS": [markdown_url_set_target_blank, markdown_url_set_protocol], | ||
| "PARSE_EMAIL": True, | ||
| }, | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nouvelle config de markdownify
| const easyMDE = new EasyMDE({ | ||
| element: textarea, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quelques modifs sur ce fichier : les classes principalement, pour avoir des icônes plus grandes
| def markdown_url_set_target_blank(attrs, new=False): | ||
| attrs[(None, "target")] = "_blank" | ||
| attrs[(None, "rel")] = "noopener" | ||
| attrs[(None, "aria-label")] = "Ouverture dans un nouvel onglet" | ||
| return attrs | ||
|
|
||
|
|
||
| def markdown_url_set_protocol(attrs, new=False): | ||
| if href := attrs.get((None, "href")): | ||
| if not (href.startswith("http") or href.startswith("mailto")): | ||
| attrs[(None, "href")] = "https://" + href | ||
| return attrs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nouveau :
- pour ouvrir les liens dans un autre onglet
- pour ajouter https:// aux liens qui n'auraient pas de protocole
39e9d87 to
d559c46
Compare
We changed the following fields: - companies: description, provided_support - job descriptions: description, profile_description - prescribers: description Two packages were added: - `django-easymde`: add the JS and CSS needed in the forms) note: as of version 1.0.4, the plugin can only have static configuration, so we cannot properly configure it in `base.py` Hence, a (temporary?) `easymde_config.js` has to be loaded. https://github.com/WPI-LNL/django-easymde/blob/main/README.md#easymde-options - `django-markdownify`: render only a chosen subset of HTML tags
d559c46 to
b19244e
Compare
PR initiale : #4816
PR de revert : #4833
🤔 Pourquoi ?
Inciter les utilisateurs à renseigner plus d’infos dans leurs descriptions de fiche structure et fiche de poste.
On a observé de très bons résultats sur le marché depuis qu’ils l’ont fait.
🍰 Comment ?
utiliser
django-easymde, qui importeEasyMDE(js et css) dans les formulaires, via{{ form.media }}.Malheureusement la version actuelle du
django-easymdene permet pas de configuration "dynamique" (mentionner une fonction JS, commetoggleBoldpar exemple), donc on doit configurer l'éditeur avec un fichier JS (itou/static/js/easymde_config.js) pour le moment. On enregistre en base de données un texte au format markdown.django-markdownify: pour convertir le markdown enregistré en HTML. On préfèremarkdownifyàmarkdownici pour pouvoir choisir un sous-ensemble de balises HTML dans le rendu (<em>,<bold>,<a>…).Les tests vérifient qu'on traduit les balises désirées, et qu'on ne traduit pas les autres balises.
On ne teste pas le bon chargement de l'éditeur EasyMDE (ça ferait partie de tests fronts ?).
Nouveautés avec cette nouvelle PR :
br) en HTML.[test](www.test.com)=> on rajoutehttps://)🚨 À vérifier
🏝️ Comment tester + captures d'écran
En tant qu'employeur
Se connecter en tant qu'employeur et créer une nouvelle structure

Aller voir la fiche publique

Modifier les informations

Prévisualiser

En tant que prescripteur
Se connecter en tant qu'Orienteur (prescripteur non habilité) et "Modifier cette organisation"

Cas particulier pour France Travail (se connecter en tant que Prescripteur habilité), les champs sont en lecture seule :
