<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arnaud F.</title>
    <description>The latest articles on DEV Community by Arnaud F. (@arnaudfl).</description>
    <link>https://dev.to/arnaudfl</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1113129%2F96887694-fa84-48c1-abfb-db7f040d555a.jpeg</url>
      <title>DEV Community: Arnaud F.</title>
      <link>https://dev.to/arnaudfl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arnaudfl"/>
    <language>en</language>
    <item>
      <title>Integrating React QuillJs with React Hook Form</title>
      <dc:creator>Arnaud F.</dc:creator>
      <pubDate>Fri, 14 Jun 2024 13:10:29 +0000</pubDate>
      <link>https://dev.to/arnaudfl/integrating-react-quilljs-with-react-hook-form-2ghj</link>
      <guid>https://dev.to/arnaudfl/integrating-react-quilljs-with-react-hook-form-2ghj</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quilljs&lt;/strong&gt; is a free, open-source library that lets developers easily add rich text editing capabilities to their web applications. It provides a familiar WYSIWYG (What You See Is What You Get) editing experience, similar to popular word processors, allowing users to format text, add images, and create interactive content.  It's also known for being customizable, so developers can tailor it to their specific needs.&lt;/p&gt;

&lt;p&gt;While &lt;strong&gt;React Quill&lt;/strong&gt; was once a popular option for adding rich text editing to React applications, there are a couple reasons why it might not be the most relevant choice these days:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Out of Date:&lt;/strong&gt; React Quill hasn't had major updates in over two years. This raises concerns about compatibility with newer React versions and security risks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quill v2 Issues:&lt;/strong&gt; There's a new version of Quill (v2), but React Quill doesn't seem to work with it smoothly, potentially causing problems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outdated Techniques:&lt;/strong&gt; React Quill might use older methods for handling the web page structure (DOM manipulation) that aren't ideal for modern React development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's a new React library called &lt;strong&gt;React Quilljs&lt;/strong&gt; that's actively maintained and integrates well with React projects.&lt;/p&gt;

&lt;p&gt;I'll show you how to use React Quilljs with React Hook Form in a TypeScript project. While it might not be the ultimate solution, it works!&lt;/p&gt;

&lt;h2&gt;
  
  
  Install dependencies
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;react-quilljs quill
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; @types/quill
npm &lt;span class="nb"&gt;install &lt;/span&gt;react-hook-form
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For other configuration options, check out the &lt;a href="https://github.com/gtgalone/react-quilljs" rel="noopener noreferrer"&gt;react-quilljs documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;First, create a file named &lt;code&gt;App.tsx&lt;/code&gt; in the root directory. This file will be used to render the editor. Be caution when using this file like this, because it will not work without the &lt;code&gt;Layout.tsx&lt;/code&gt; component (see the project on GitHub)&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Then, create a file named &lt;code&gt;Editor.tsx&lt;/code&gt; in the &lt;code&gt;components&lt;/code&gt; directory. This file will be used to render the editor.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You can view results on &lt;a href="https://codesandbox.io/p/sandbox/react-hook-form-quilljs-d5lx6f" rel="noopener noreferrer"&gt;CodeSandbox&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fupn48d4fy0olsgkpukvt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fupn48d4fy0olsgkpukvt.PNG" alt="codesandbox" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project is hosted on &lt;a href="https://github.com/arnaudfl/react-hook-form-quilljs" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Thank you
&lt;/h2&gt;

&lt;p&gt;Life's too short for boring endings.&lt;/p&gt;

</description>
      <category>react</category>
      <category>quilljs</category>
      <category>typescript</category>
      <category>reacthookform</category>
    </item>
    <item>
      <title>🌲Svelte + 🍃Leaflet + 📍 Clusters</title>
      <dc:creator>Arnaud F.</dc:creator>
      <pubDate>Mon, 25 Sep 2023 05:37:49 +0000</pubDate>
      <link>https://dev.to/arnaudfl/svelte-leaflet-clusters-1fgb</link>
      <guid>https://dev.to/arnaudfl/svelte-leaflet-clusters-1fgb</guid>
      <description>&lt;p&gt;For a personal project, I had to use &lt;a href="https://leafletjs.com/" rel="noopener noreferrer"&gt;Leaflet&lt;/a&gt; with &lt;a href="https://svelte.dev/" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;, and I faced some problems during development.&lt;/p&gt;

&lt;p&gt;In this article, I will list each point that required finding a solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating Leaflet into a SvelteKit project
&lt;/h2&gt;

&lt;p&gt;I highly recommend that you read the article &lt;a href="https://dev.to/khromov/using-leaflet-with-sveltekit-3jn1"&gt;Using Leaflet with SvelteKit&lt;/a&gt; written by &lt;a href="https://dev.to/khromov"&gt;Stanislav Khromov&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;He explains an effective way to add &lt;strong&gt;Leaflet&lt;/strong&gt; to a project made with SvelteKit. It was my starting point in my project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Leaflet.markercluster plugin
&lt;/h2&gt;

&lt;p&gt;You can retrieve this plugin from its official repo on Github : &lt;a href="https://github.com/Leaflet/Leaflet.markercluster" rel="noopener noreferrer"&gt;Leaflet.markercluster&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I used npm to add it to my project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;leaflet.markercluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, it needs to be integrated into the code of the file &lt;code&gt;LeafletMap.svelte&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;onMount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;leaflet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;leaflet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MarkerClusterGroup&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;leaflet.markercluster&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, we can declare the variable lower in the file, and add each marker to the &lt;code&gt;markers&lt;/code&gt; element. Finally, add all the markers to the map.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// L.MarkerClusterGroup extends L.FeatureGroup&lt;/span&gt;
&lt;span class="c1"&gt;// by clustering the markers contained within&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;markers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MarkerClusterGroup&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// create feature group&lt;/span&gt;
&lt;span class="c1"&gt;// for each marker, add it to markers&lt;/span&gt;
&lt;span class="nx"&gt;markers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;marker&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Add all markers to map&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;markers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, don’t forget to add the CSS style.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s2"&gt;'leaflet.markercluster/dist/MarkerCluster.Default.css'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bug of icons in production environment
&lt;/h2&gt;

&lt;p&gt;The Leaflet framework can give an error once the project is deployed, the path to the icon causes a 404 (not found) error. To remedy this, one of the solutions is to manually define the icon with an image available in the project’s &lt;code&gt;assets&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;iconRetinaUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./images/leaflet/marker-icon-2x.png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;iconUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./images/leaflet/marker-icon.png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shadowUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./images/leaflet/marker-shadow.png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;iconDefault&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;leaflet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;iconRetinaUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;iconUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;shadowUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;iconSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;iconAnchor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;popupAnchor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;tooltipAnchor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;shadowSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, you need to use the &lt;code&gt;iconDefault&lt;/code&gt; variable in the marker definition, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;leaflet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;marker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;coords&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;iconDefault&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using the &lt;code&gt;iconDefault&lt;/code&gt; variable in the marker definition, you can ensure that all markers use the same default icon.&lt;/p&gt;

&lt;p&gt;Et voilà 🎉&lt;/p&gt;

&lt;p&gt;These are the only errors I had to correct during my development, I hope this article will be useful to you.&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>leaflet</category>
      <category>javascript</category>
      <category>sveltekit</category>
    </item>
  </channel>
</rss>
