site

A custom static site generator written in C.
git clone https://unitehenry.com/git/site.git
Log | Files | Refs | README

striven-editor.md (5898B)


      1 ---
      2 title: Striven Editor
      3 description: At Striven, I led the research and development of a lightweight, in-house WYSIWYG editor to replace the heavy Kendo UI component.
      4 ---
      5 
      6 # Striven Editor
      7 
      8 2019-10-27
      9 
     10 ## Introduction
     11 
     12 At Striven, we were looking for potential editors that would be suitable for our client side customer portal revamp. In the past, we have always used the [Kendo UI](https://www.telerik.com/kendo-ui) editor. We were dynamically loading these components into our pages, but even then the editor was shipping over 1MB of scripts over the network.
     13 
     14 One of the key features of this portal was its lightweight optimization. When you look at the Kendo UI minified script over the network, you'll notice a whoping 1.3MB are being shipped to the browser. With the editor component alone making up nearly 1MB of that script.
     15 
     16 !["Kendo UI Script Size"](/images/0bcda974-b314-4aaf-b3ac-cc59534b5748.png)
     17 
     18 An editor was a fundamental component of this customer portal, so we wanted to provide a more optimal solution to our users. I was tasked with the research of finding a lighter editor with just as much, or as much as we needed, functionality.
     19 
     20 These were some notable candidates:
     21 
     22 *   [Quill](https://quilljs.com/)
     23 *   [Froala](https://froala.com/wysiwyg-editor/)
     24 *   [TineMCE](https://www.tiny.cloud/features)
     25 
     26 ## Quill
     27 
     28 Quill would be great; its open source, inline, and used by top companies. My experience when trying to integrate with the editor involved the developer push for the adoption of the editor's [delta](https://quilljs.com/docs/delta/) api.
     29 
     30 My advice to anyone trying to include this control in their project is that you'll have a much easier time designing your system with the concept of delta in mind than trying to bring the concept of the quill editor and its delta api into an existing system.
     31 
     32 ## Froala and TinyMCE
     33 
     34 So these editors are obviously top tier editors, but usually have some licensing and enterprise support costs that we weren't ready to explore just yet. I never tried to demo or pitch it to my team, but I still think these were candidates worth considering when all else failed.
     35 
     36 ## Undertaking a Custom Built Editor
     37 
     38 After working on implementing the ability to mention users in posts and exploring all these different editor solutions, I formed an understanding of the underlying concepts that went into the inner workings of a WYSIWYG editor. My manager was convinced that I was capable of taking on the project of building a tailored editor for Striven, as it would be worth the time and investment to work on this component in house.
     39 
     40 We decided to work on the component in phases.
     41 
     42 What did we need out of the initial phase of the control?
     43 
     44 *   Simple Editing Functions (bold, italic, underline, unordered lists)
     45 *   File Attachments and Link Insertions
     46 *   Mention Support
     47 
     48 With these functionalities in pipeline, editor phase one development was underway. But I decided that I wasn't going to do it alone.
     49 
     50 ## The Benefits of Open Source
     51 
     52 With permission from my manager, I decided that open sourcing this control would have the following benefits:
     53 
     54 *   Faster development
     55 *   Development guidance from the community on building an editor
     56 *   Product brand awareness
     57 *   Component development independent from the internal system
     58 
     59 The idea was a success\*, as I could gain input from the open source community and work on the component without having to rely on the internal structure of our client side ecosystem. I also learned a lot as a project maintainer and was really proud of the overall traction that the editor had received in early development.
     60 
     61 !["editor github page"](/images/963fcb0b-63ed-44bc-8fcb-a79882ee237d.png)
     62 
     63 \*Even though 13 contributors isn't a terribly significant amount, I still take pride in it 😅
     64 
     65 ## What I Learned From This Project
     66 
     67 !["editor open source demo"](/images/d03e30dd-b964-4199-b2b6-f56168b44b06.png)
     68 
     69 I've been actively maintaining this [code base](https://github.com/striven-erp/striven-editor) for about a year now and if I could given some wisdom to the young software engineer that does it next, this would be the advice I would give:
     70 
     71 Avoid [document.execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand)
     72 
     73 *   It's old, buggy, and just a pain of an API to use
     74 *   It's one of those Internet Explorer that still lives to see modern web development
     75 
     76 Start with an engine or library
     77 
     78 *   I've explored ways I would've redesigned this component on the [trix](https://github.com/basecamp/trix) engine
     79 *   I've considered how nice it would've been to use [`contenteditable`](https://getcontenttools.com/api/content-edit) libraries
     80 
     81 Understand the [Range](https://developer.mozilla.org/en-US/docs/Web/API/Range) API
     82 
     83 *   Although I don't see this system going anywhere in future iterations of the browser, I still believe it to be mediocre
     84 *   Learning how to use the Range API and [`window.getSelection()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection) will make your life much easier
     85 *   Try exploring libraries like [rangy](https://github.com/timdown/rangy)
     86 
     87 ## Final Thoughts
     88 
     89 When I reflect on the development of this project, my goal was always to accomplish two things:
     90 
     91 *   Allow developers to contribute, collaborate, and learn open source with a smaller scale project
     92 *   It's an editor for Striven, not for anything else (but feel free to use it)
     93 
     94 It's satisfying to have the ability of opening an issue and letting someone contribute to this [project](https://github.com/striven-erp/striven-editor). I also enjoy the ability to work on this component in an independent environment from Striven. It lets me flex my ES6 muscles and have all the luxuries of hot reloading, webpack loaders, and working in Vue.
     95 
     96 There are definitely things that I would've done differently, but at the end of the day it does what Striven needs.