<?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: Eeshaan Sawant</title>
    <description>The latest articles on DEV Community by Eeshaan Sawant (@sawanteeshaan).</description>
    <link>https://dev.to/sawanteeshaan</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%2F1143865%2Fb9335850-43d5-42c7-9a77-6877ad75cf53.jpeg</url>
      <title>DEV Community: Eeshaan Sawant</title>
      <link>https://dev.to/sawanteeshaan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sawanteeshaan"/>
    <language>en</language>
    <item>
      <title>Build an ONLYOFFICE macro that adds comments to every instance of a word in the Text Editor</title>
      <dc:creator>Eeshaan Sawant</dc:creator>
      <pubDate>Wed, 06 Dec 2023 19:07:10 +0000</pubDate>
      <link>https://dev.to/sawanteeshaan/build-an-onlyoffice-macro-that-adds-comments-to-every-instance-of-a-word-in-the-text-editor-4ccj</link>
      <guid>https://dev.to/sawanteeshaan/build-an-onlyoffice-macro-that-adds-comments-to-every-instance-of-a-word-in-the-text-editor-4ccj</guid>
      <description>&lt;p&gt;When working on documents, there are times when it’s essential to include a comment for a specific word that appears repeatedly throughout the text.  In this blog-post, we will show you how you can efficiently add comments to every instance of a specific word, streamlining your editing process and enhancing document clarity.&lt;/p&gt;




&lt;h2&gt;
  
  
  Building the macro
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;function addCommentToWord() {&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;addCommentToWord()&lt;/em&gt; function is designed to add comments to every occurrence of a specified word within the document.&lt;/p&gt;

&lt;p&gt;Here’s a breakdown of its key components:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const oDocument = Api.GetDocument();&lt;br&gt;
   const numberOfElements = oDocument.GetElementsCount();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, we get the current document in the &lt;em&gt;oDocument&lt;/em&gt; variable. Next, we get all the elements in the document using the &lt;em&gt;GetElementsCount()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt; &lt;code&gt;  for (&lt;br&gt;
        let elementIndex = 0;&lt;br&gt;
        elementIndex &amp;lt; numberOfElements;&lt;br&gt;
        elementIndex++&lt;br&gt;
      ) &lt;br&gt;
&lt;/code&gt;&lt;br&gt;
A &lt;em&gt;for loop&lt;/em&gt; is used here to &lt;em&gt;iterate&lt;/em&gt; through all the elements. Doing this adds a comment to the desired word in every element (paragraph) of the document.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
        const oElement = oDocument.GetElement(elementIndex);&lt;br&gt;
        const rawText = oElement.GetText();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Inside the for loop, we get each element of the document by the &lt;em&gt;GetElement&lt;/em&gt; method and passing in the &lt;em&gt;elementIndex&lt;/em&gt; . Then, we extract the plain text in the &lt;em&gt;rawText&lt;/em&gt; variable.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const targetWord = "sample word";&lt;br&gt;
    let count = 0;&lt;br&gt;
    for (let i = 0; i &amp;lt; targetWord.length; i++) {&lt;br&gt;
      count++;&lt;br&gt;
    }&lt;br&gt;
    const wordLength = count - 1;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Here, we set the word we want our comments to be on. Next, we calculate the length of the word using a &lt;em&gt;for loop&lt;/em&gt;, and store it in &lt;em&gt;wordLength&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt; const wordRegex = new RegExp("\\b" + targetWord + "\\b", "gi");&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Then, a regular expression (&lt;em&gt;wordRegex&lt;/em&gt;) is created using the target word to find all occurrences in the document.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let match;&lt;br&gt;
    while ((match = wordRegex.exec(rawText)) !== null) {&lt;br&gt;
      let matchPosition = match.index; &lt;br&gt;
      let nextMatchPosition = matchPosition + wordLength;&lt;br&gt;
      const comment = "YOUR COMMENT GOES HERE";&lt;br&gt;
      const oParagraph = oDocument.GetElement(0);&lt;br&gt;
      const range = oParagraph.GetRange(matchPosition, nextMatchPosition);&lt;br&gt;
      range.AddComment(comment, "Comment's Author Name");&lt;br&gt;
       }&lt;br&gt;
    } &lt;br&gt;
  }&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Here, inside a &lt;em&gt;while loop&lt;/em&gt;, we &lt;em&gt;iterate&lt;/em&gt; through all the instances found and stored in &lt;em&gt;wordRegex&lt;/em&gt;. &lt;br&gt;
For each match, the starting position of the word (&lt;em&gt;matchPosition&lt;/em&gt;) and the position of the next character after the word (&lt;em&gt;nextMatchPosition&lt;/em&gt;) are calculated. &lt;br&gt;
The &lt;em&gt;comment&lt;/em&gt; variable holds the comment you want to insert. The &lt;em&gt;AddComment&lt;/em&gt; method has an optional parameter which can be used to alter the author’s name. If you don’t want to use it, you can exclude the optional parameter, and just pass in the comment variable.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;addCommentToWord();&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Finally, the &lt;em&gt;addCommentToWord&lt;/em&gt; function is called.&lt;/p&gt;
&lt;h2&gt;
  
  
  The full macro code
&lt;/h2&gt;

&lt;p&gt;Here is the enitre code of the macro:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function () {
  function addCommentToWord() {
    const oDocument = Api.GetDocument();
    const numberOfElements = oDocument.GetElementsCount();

    //looping through all the elements in the document.
    for (
        let elementIndex = 0;
        elementIndex &amp;lt; numberOfElements;
        elementIndex++
      ) {
        const oElement = oDocument.GetElement(elementIndex);
        const rawText = oElement.GetText();

      // Specify the target word and the length of the word
      const targetWord = "sample word";
      let count = 0;
      for (let i = 0; i &amp;lt; targetWord.length; i++) {
        count++;
      }
      const wordLength = count - 1;

      // Find all occurrences of the target word in the document
      const wordRegex = new RegExp("\\b" + targetWord + "\\b", "gi");
      let match;
      while ((match = wordRegex.exec(rawText)) !== null) {

        let matchPosition = match.index; // returns the index where the word starts.
        let nextMatchPosition = matchPosition + wordLength; //the index where the word ends.

        // Add a comment at the position of the match
        const comment = "YOUR COMMENT GOES HERE";
        const range = oElement.GetRange(matchPosition, nextMatchPosition);
        range.AddComment(comment, "Comment's Author Name");
      }
    }
  }

  addCommentToWord();
})();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let us see how our macro performs.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/dy-QRGM7Hpo"&gt;
&lt;/iframe&gt;
&lt;br&gt;
I trust this macro made handling repetitive word comments a breeze, providing a handy tool for users dealing with the document editor in ONLYOFFICE.&lt;br&gt;
Don’t miss the chance to harness the power of the ONLYOFFICE API.  If you have any questions or innovative concepts, I encourage you to &lt;a href="https://www.onlyoffice.com/contacts.aspx?utm_source=blog&amp;amp;utm_medium=article+&amp;amp;utm_id=comment_word_macro"&gt;share them with the ONLYOFFICE Team&lt;/a&gt;. Best of luck in your exploratory endeavors!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Useful links&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.onlyoffice.com/plugin/macrosamples/?utm_source=blog&amp;amp;utm_medium=article+&amp;amp;utm_id=comment_word_macro"&gt;Macro samples&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ONLYOFFICE"&gt;ONLYOFFICE on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.onlyoffice.com/docbuilder/textdocumentapi?utm_source=blog&amp;amp;utm_medium=article+&amp;amp;utm_id=comment_word_macro"&gt;ONLYOFFICE Text Document API&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.onlyoffice.com/blog/search?s=macro&amp;amp;utm_source=blog&amp;amp;utm_medium=article+&amp;amp;utm_id=comment_word_macro"&gt;Other macros&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I am Eeshaan, a senior studying Computer Science in Pune, India. I am fond of Open-Source, Web Development, and Technical Writing. Feel free to give me a follow on my &lt;a href="https://twitter.com/sawanteeshaan"&gt;Twitter (now X)&lt;/a&gt;, if my blog was of any use to you. Cheers. 🍻&lt;/p&gt;

</description>
    </item>
    <item>
      <title>From Rookie to Remarkable: Navigating my Internship experience at ONLYOFFICE</title>
      <dc:creator>Eeshaan Sawant</dc:creator>
      <pubDate>Sun, 22 Oct 2023 15:41:16 +0000</pubDate>
      <link>https://dev.to/sawanteeshaan/from-rookie-to-remarkable-navigating-my-internship-experience-at-onlyoffice-20ga</link>
      <guid>https://dev.to/sawanteeshaan/from-rookie-to-remarkable-navigating-my-internship-experience-at-onlyoffice-20ga</guid>
      <description>&lt;p&gt;In June, I was chosen to participate in the &lt;a href="https://summer-ospp.ac.cn/"&gt;Open Source Promotion Plan (OSPP)&lt;/a&gt; with &lt;a href="//www.onlyoffice.com"&gt;ONLYOFFICE&lt;/a&gt;. Over the course of my three-month internship, I absorbed tremendous amount of knowledge and skills that have enriched my professional growth, both, as a student, and as a professional. I've already shared insights in a &lt;a href="https://dev.to/sawanteeshaan/how-i-got-into-ospp-2023-with-onlyoffice-experience-and-journey-4756"&gt;previous blog&lt;/a&gt; about getting started, choosing organizations, stipends, and more—it acts as a prequel to this one. If you haven't had a chance to read it yet, I highly recommend doing so before diving into this blog. In this blog, I will guide you through the experience as an OSPP intern at ONLYOFFICE.&lt;/p&gt;

&lt;h1&gt;
  
  
  A guide through the timeline of OSPP
&lt;/h1&gt;

&lt;p&gt;Program preparation typically kicks off in late March or early April. If you find the timeline for this year's program on &lt;a href="https://summer-ospp.ac.cn/"&gt;the official OSPP website&lt;/a&gt; confusing, don't fret. I'll do my best to quickly guide you through it and simplify the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Release
&lt;/h3&gt;

&lt;p&gt;This marks the phase when accepted projects from various open-source organizations are announced and showcased on the website following a thorough review by the OSPP committee. For those considering future program applications, it's advisable to keep checking the Project Release dates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Registration and Application
&lt;/h3&gt;

&lt;p&gt;During this period, you'll register for the program and submit your proposal (application) under your desired organization through your dashboard. This phase typically spans around 1.5 to 2 months.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application review and Internship Experience
&lt;/h3&gt;

&lt;p&gt;Following the closure of the program registration and application submission deadline, student applications undergo a thorough review process, usually done by the mentors, spanning approximately one month. If your application is selected, you will receive a notification email on the day the results are announced.&lt;br&gt;
If you are selected, Congratulations on your selection! Brace yourself for an exciting three-month journey ahead!&lt;/p&gt;

&lt;p&gt;After your selection, the process is pretty easy, and your mentor will get in touch with you for further discussions. &lt;/p&gt;

&lt;h1&gt;
  
  
  The experience at ONLYOFFICE
&lt;/h1&gt;

&lt;p&gt;The moment I glimpsed the email declaring my selection, I was surprised. More than just the joy of being chosen, what truly astonished me was the opportunity to work with ONLYOFFICE—an MNC with a global presence spanning multiple countries and regions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Onboarding
&lt;/h3&gt;

&lt;p&gt;The day after the results were announced, one of my mentor Mona Ai reached out, extending congratulations and guiding me through the onboarding process. Shortly after, we had an introductory meeting where both my mentors, Sergei and Mona, introduced themselves, and I did the same.&lt;/p&gt;

&lt;h3&gt;
  
  
  Development Phase
&lt;/h3&gt;

&lt;p&gt;After a series of initial meetings and introductions, we were all set to kick off the development phase. The best part? Everything—from meetings to development—was fully remote, allowing me to participate right from the comfort of my home. Despite my mentors residing in different time zones, they were considerate enough to choose meeting times that aligned with my local time.  We strategically established a weekly meeting cadence, convening every Monday to delve into comprehensive discussions surrounding project updates and progress.&lt;/p&gt;

&lt;p&gt;Over the course of these months, I had the invaluable opportunity to learn extensively from my mentor, Sergei Kosyrev, a seasoned technical writer at ONLYOFFICE. From minor syntax errors to significant flaws in functions, Sergei demonstrated unwavering patience in guiding me through every line of code I found challenging. At the end of the development process, the code repository was finally merged, along with huge success. &lt;/p&gt;

&lt;p&gt;After months of intensive meetings and iterative changes, the project development had, at last, reached its culmination.Sergei ultimately merged the code repository, marking a momentous success. &lt;/p&gt;

&lt;p&gt;As I am writing this blog, the project is being reviewed by my mentors and the OSPP technical Committee. The mentors, Mona and Sergei, regularly check in on my progress and well-being, creating a supportive and encouraging atmosphere throughout the entire experience.&lt;/p&gt;

&lt;p&gt;As I bring this blog to a close, I can't help but emphasize the remarkable internship journey at ONLYOFFICE—an experience that I sincerely hope will linger as a high point, contributing to the ongoing narrative of my professional growth.&lt;/p&gt;

&lt;p&gt;I wish it had never ended. 😢&lt;/p&gt;

&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I am Eeshaan, a sophomore studying Computer Science in Pune, India. I am fond of Open-Source, Web Development, and Technical Writing. Feel free to give me a follow on my &lt;a href="https://twitter.com/sawanteeshaan"&gt;Twitter (now X)&lt;/a&gt;, if my blog was of any use to you. Cheers. 🍻&lt;/p&gt;

</description>
      <category>macro</category>
      <category>spreadsheet</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How I got into OSPP 2023 with ONLYOFFICE</title>
      <dc:creator>Eeshaan Sawant</dc:creator>
      <pubDate>Tue, 22 Aug 2023 21:06:57 +0000</pubDate>
      <link>https://dev.to/sawanteeshaan/how-i-got-into-ospp-2023-with-onlyoffice-experience-and-journey-4756</link>
      <guid>https://dev.to/sawanteeshaan/how-i-got-into-ospp-2023-with-onlyoffice-experience-and-journey-4756</guid>
      <description>&lt;p&gt;In June this year, I submitted my final draft of the proposal on the OSPP site for the ONLYOFFICE Organisation, and made it in. This was my second attempt at OSPP. The first attempt was for the 2022 program last year in May, which, unfortunately, I couldn’t make in. In this Blog Post, I will take you through the Journey as an ONLYOFFICE Intern, OSPP Participant, how to apply, increase your chances, and much more. &lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;What is OSPP?&lt;/h2&gt;

&lt;p&gt;The Open-Source Promotion Plan, abbreviated OSPP, is a China based, Open – Source program, held in the Summers, between the months of May – October. Check the 2023 timeline &lt;a href="https://summer-ospp.ac.cn/help/en/timeline/"&gt;here&lt;/a&gt;. The registration process is fairly easy, and just consists of verifying your student status and the identity on the &lt;a href="https://summer-ospp.ac.cn/help/en/"&gt;OSPP website&lt;/a&gt;.&lt;br&gt;
Although OSPP is a China based program and intended for Chinese students, students from any part of the world can apply, just like me. A great example and a similar program to the OSPP is the well-known &lt;a href="https://summerofcode.withgoogle.com/"&gt;Google Summer of Code (GSOC)&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;After registering, go through all the available projects, listed by different organisations. Some organisations may have a Chinese applicant requirement (one who can communicate in Chinese), so I would recommend a project which has English as their primary or secondary language. &lt;br&gt;
The project can have either a “Basic” difficulty level, or an “Advanced” difficulty level. The amount of work you will need to do is different for both, and so is the Stipend. &lt;br&gt;
After you chose your project, you will need to work on a proposal, and submit it before the deadline.&lt;br&gt;
There can be (and most certainly will be) more than one applicant applying to a particular project, so your proposal and resume need to stand out amongst others. You can start early, get in touch with the project mentors, discuss your methodologies and even solve some “good first issues” in the respective organisation’s GitHub Repository, to increase your chances.&lt;/p&gt;

&lt;h2&gt;Organisation, Project, Mentors and the Experience&lt;/h2&gt;

&lt;p&gt;The project I had applied for was one of the two projects ONLYOFFICE had, &lt;u&gt;Creating an ONLYOFFICE Macro that inserts Baidu Search Results into the Spreadsheet&lt;/u&gt;. I put in my proposal almost an hour before the deadline, and luckily made it through. &lt;/p&gt;

&lt;h4&gt;About ONLYOFFICE&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.onlyoffice.com/"&gt;ONLYOFFICE &lt;/a&gt;is a collaborative office suite for creating, editing, and sharing documents, spreadsheets, and presentations. It offers real-time collaboration, integrates with popular platforms, emphasizes security, and can be used in the cloud or self-hosted environments. It's a versatile solution for teams and individuals seeking a comprehensive and customizable office productivity tool. Check out their GitHub &lt;a href="https://github.com/ONLYOFFICE"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As soon as the development phase began, we started researching for the required API References. After a lot of research, error logs, and questions, the first prototype of the macro code file was ready, roughly around 2 weeks into the project. If you want to know more about ONLYOFFICE Macros and how they work, you can check them out &lt;a href="https://www.onlyoffice.com/app-directory/macros"&gt;here&lt;/a&gt;.&lt;br&gt;
A huge thanks and a shoutout to my mentors Mona and Sergei, who believed in me, and kept answering my silly questions until they were cleared. &lt;br&gt;
As I am writing this blog post, we are currently working on final checks, tests, and enhancing the User Experience, and even working on a more advanced version of the Macro with added functionality.&lt;/p&gt;

&lt;p&gt;Once the Project is completed, a Blogpost on the Entire Project, its functionality, documentation, and hands-on tutorial will be published on the ONLYOFFICE website (will link it when it is out). Stay tuned for that if you want to know about the tech and concepts used for development.&lt;/p&gt;

&lt;h2&gt;About Me&lt;/h2&gt;

&lt;p&gt;I am Eeshaan, a sophomore studying Computer Science in Pune, India. I am fond of Open-Source, Web Development, and Technical Writing. Feel free to give me a follow on my &lt;a href="https://twitter.com/sawanteeshaan"&gt;Twitter&lt;/a&gt; (now X), if my blog was of any use to you. Cheers. 🍻&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>opensource</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
