pagery-edition 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagery-edition",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Composants d'édition en ligne pour les sites clients Pagery",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -240,11 +240,12 @@ export function TexteEditable({
240
240
  const sauvegarder = useCallback(async () => {
241
241
  if (!refElement.current) return;
242
242
  const el = refElement.current;
243
- // Extraire le texte brut (sans HTML)
244
- const nouveauTexte = (el.textContent || "").replace(/\s+/g, " ").trim();
243
+ // Extraire le texte brut (sans HTML, normaliser espaces et retours a la ligne)
244
+ const nouveauTexte = (el.textContent || "").replace(/[\n\r]+/g, " ").replace(/\s+/g, " ").trim();
245
+ const texteOriginalNormalise = texteOriginal.current.replace(/\s+/g, " ").trim();
245
246
  el.contentEditable = "false";
246
247
  setEnEdition(false);
247
- if (nouveauTexte !== texteOriginal.current) {
248
+ if (nouveauTexte !== texteOriginalNormalise) {
248
249
  await modifierTexte(cle, nouveauTexte);
249
250
  }
250
251
  }, [cle, modifierTexte]);
@@ -301,9 +302,9 @@ export function TexteEditable({
301
302
  }}
302
303
  onKeyDown={gererTouche}
303
304
  suppressContentEditableWarning
304
- {...(!enEdition && doitRendreHtml ? { dangerouslySetInnerHTML: { __html: htmlRendu } } : {})}
305
+ {...(doitRendreHtml ? { dangerouslySetInnerHTML: { __html: htmlRendu } } : {})}
305
306
  >
306
- {!enEdition && doitRendreHtml ? undefined : texte}
307
+ {doitRendreHtml ? undefined : texte}
307
308
  </Balise>
308
309
  {enEdition && monte && (
309
310
  <BarreOutils