How to use the Word JS API to search for text with tracked changes enabled

I have a Microsoft Word document with tracked changes enabled, which I am trying to search for a string of text. I want to search for what the text would be if tracked changes were accepted. I do this using the Office JS API:

await Word.run(async (context) => {
  const searchString = "This is text with tracked changes accepted.";

  const searchRange =
    context.document.body.search(searchString, {
      ignoreSpace: true,
      matchCase: true,
      ignorePunct: false,
      matchWildcards: false,
    });

  searchRange.select();
})

This is what the text looks like in the Word document

However, this code does not find the range because the word “the” is still in the Word document text even though it has been deleted with tracked changes turned on. The search bar within the Microsoft Word app also does not find it.

I am wondering how I could find this text without modifying the document in any way (for example, by accepting tracked changes). It would be nice if there was a workaround where I could accomplish something like the ignoreSpace search option, but instead for ignoring tracked changes.

Cheking list using google sheet, and google app scrips

Hey I don’t know how to code. I don’t know java script. And I started doing it using chatGpt. I was doing things with sheet google. But it was limited. Sheet doesnt allow to use pop without create web app. So I tried to create one. Sorry for my english i’m french.

I have a file named “Fichier Accord” which contains my database with columns A, B, C, D, E, F, representing the following information: Last Name, First Name, Phone Number, Address, Date, and Need. This database is located in the “Parameter” sheet.

I have another file called “Base de donnée” where I have used a VLOOKUP(importrange) formula in the “Exercise 1” sheet:

=VLOOKUP(A5, IMPORTRANGE(“Drive_link ‘Fichier Accord'”, “Parameter!A1:A25”), IMPORTRANGE(“Drive_link ‘Fichier Accord'”, “Parameter!A1:F25”), 2)

This formula allows me to display the desired data from the Parameter sheet when I modify cell A5. In other words, when I search for a name (in column A), it displays all the information on one row (row 5).

Now, I would like that when I modify cell A6 in the “Exercise 1” sheet, it shows pop-up windows:

  1. If the user exists, it displays a window with their information.
  2. If the user doesn’t exist, it shows a pop-up window allowing me to enter the user’s information: Last Name, First Name, Phone Number, Date, Address, and Need. It then saves this information in the “Fichier Accord” file, in the “Parameter” sheet, just below the last entered user. The pop-up window closes after successfully saving the user, displaying a message saying “User successfully saved.” When the user is found, there is an “OK” button to close the pop-up window.

Please note that the formulas and references provided are based on the information you provided in French. If you need further assistance or clarifications, feel free to ask.

I write my htlm code and my script code. I think I modify the code many times. I tried to know what the function are for. But i think I need someone to explain me what I did wrong so that I can learn from something I like.

Here my code.

function onEdit(e) {
if (e && e.range && e.range.getA1Notation() === "Exercice 1'!A6") {
var activeCell = e.range;
var searchValue = activeCell.getValue();

        Logger.log("Search value: " + searchValue);
    
        showSearchUserDialog(searchValue);
    }

}

function showSearchUserDialog(searchValue) {
var htmlOutput = HtmlService.createHtmlOutputFromFile('recherche_utilisateur');
SpreadsheetApp.getUi().showModalDialog(htmlOutput, "Recherche utilisateur");

    var searchUserScript = "onSearchUser('" + searchValue + "');";
    var scriptTag = "<script>" + searchUserScript + "</script>";
    htmlOutput.append(scriptTag);

}

function onSearchUser(searchValue) {
var dataFile = SpreadsheetApp.openById("ID_Fichier Accord");
var dataSheet = dataFile.getSheetByName("Parameter");

    var searchRange = dataSheet.getRange("A:A");
    var searchResult = searchRange.createTextFinder(searchValue).findAll();
    
    Logger.log("Search result length: " + searchResult.length);
    
    if (searchResult.length > 0) {
        var rowData = searchResult[0].getRow();
        var infoA = dataSheet.getRange("A" + rowData).getValue();
        var infoB = dataSheet.getRange("B" + rowData).getValue();
        var infoC = dataSheet.getRange("C" + rowData).getValue();
        var infoD = dataSheet.getRange("D" + rowData).getValue();
        var infoE = dataSheet.getRange("E" + rowData).getValue();
        var infoF = dataSheet.getRange("F" + rowData).getValue();
    
        var message = "Nom: " + infoA + "n" +
            "Prénom: " + infoB + "n" +
            "Numéro de téléphone: " + infoC + "n" +
            "Adresse: " + infoD + "n" +
            "Date: " + infoE + "n" +
            "Besoin: " + infoF;
    
        SpreadsheetApp.getUi().alert("Informations Utilisateur", message, SpreadsheetApp.getUi().ButtonSet.OK);
    
        var htmlOutput = HtmlService.createHtmlOutput('<h2>Informations Utilisateur</h2><p>Nom: ' + infoA + '</p><p>Prénom: ' + infoB + '</p><p>Numéro de téléphone: ' + infoC + '</p><p>Adresse: ' + infoD + '</p><p>Date: ' + infoE + '</p><p>Besoin: ' + infoF + '</p>');
        SpreadsheetApp.getUi().showModalDialog(htmlOutput, "Informations Utilisateur");
    } else {
        var htmlOutput = HtmlService.createHtmlOutputFromFile("form.html");
        SpreadsheetApp.getUi().showModalDialog(htmlOutput, "Nouvel utilisateur");
    }

}

function saveUserInfo(data) {
var file = SpreadsheetApp.openById("Id_Fichier Accord");
var parameterSheet = file.getSheetByName("Parameter");

    var lastRow = parameterSheet.getLastRow() + 1;
    
    parameterSheet.getRange("A" + lastRow).setValue(data.nom);
    parameterSheet.getRange("B" + lastRow).setValue(data.prenom);
    parameterSheet.getRange("C" + lastRow).setValue(data.telephone);
    parameterSheet.getRange("D" + lastRow).setValue(data.adresse);
    parameterSheet.getRange("E" + lastRow).setValue(data.date);
    parameterSheet.getRange("F" + lastRow).setValue(data.besoin);
    
    Logger.log("User information saved: " + JSON.stringify(data));
    
    var template = HtmlService.createTemplateFromFile('informations_utilisateur');
    template.infoA = data.nom;
    template.infoB = data.prenom;
    template.infoC = data.telephone;
    template.infoD = data.adresse;
    template.infoE = data.date;
    template.infoF = data.besoin;
    var htmlOutput = template.evaluate();
    
    SpreadsheetApp.getUi().showModalDialog(htmlOutput, "Informations utilisateur enregistrées avec succès!");
    SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("A6").clearContent(); // Réinitialiser la cellule de recherche

}

function doGet() {
var htmlOutput = HtmlService.createHtmlOutputFromFile('recherche_utilisateur');
return htmlOutput;
}

<!-- informations_utilisateur.html -->
<!DOCTYPE html>
<html>
    <head>
        <base target="_top">
        <style>
            /* Ajoutez ici votre style CSS personnalisé pour la fenêtre modale */
        </style>
    </head>
    <body>
        <h2>Informations Utilisateur</h2>
        <p>Nom: <?!= infoA ?></p>
        <p>Prénom: <?!= infoB ?></p>
        <p>Numéro de téléphone: <?!= infoC ?></p>
        <p>Adresse: <?!= infoD ?></p>
        <p>Date: <?!= infoE ?></p>
        <p>Besoin: <?!= infoF ?></p>
    </body>
</html>

<!-- nouvel_utilisateur.html -->
<!DOCTYPE html>
<html>
    <head>
        <base target="_top">
        <style>
            /* Ajoutez ici votre style CSS personnalisé pour la fenêtre modale */
        </style>
    </head>
    <body>
        <h2>Nouvel utilisateur</h2>
        <form id="userForm">
            <label for="nom">Nom:</label>
            <input type="text" id="nom" name="nom" required><br>

            <label for="prenom">Prénom:</label>
            <input type="text" id="prenom" name="prenom" required><br>

            <label for="telephone">Numéro de téléphone:</label>
            <input type="text" id="telephone" name="telephone" required><br>

            <label for="adresse">Adresse:</label>
            <input type="text" id="adresse" name="adresse" required><br>

            <label for="date">Date:</label>
            <input type="text" id="date" name="date" required><br>

            <label for="besoin">Besoin:</label>
            <input type="text" id="besoin" name="besoin" required><br>

            <input type="button" value="Enregistrer" onclick="saveUserInfo()">
        </form>

        <script>
            function saveUserInfo() {
                var nom = document.getElementById('nom').value;
                var prenom = document.getElementById('prenom').value;
                var telephone = document.getElementById('telephone').value;
                var adresse = document.getElementById('adresse').value;
                var date = document.getElementById('date').value;
                var besoin = document.getElementById('besoin').value;

                google.script.run.saveUserInfo({ nom: nom, prenom: prenom, telephone: telephone, adresse: adresse, date: date, besoin: besoin });
            }
        </script>
    </body>
</html>


<!-- informations_utilisateur.html -->

<!DOCTYPE html>
<html>
    <head>
        <base target="_top">
        <style>
            /* Ajoutez ici votre style CSS personnalisé pour la fenêtre modale */
        </style>
    </head>
    <body>
        <h2>Informations Utilisateur</h2>
        <p>Nom: <?!= infoA ?></p>
        <p>Prénom: <?!= infoB ?></p>
        <p>Numéro de téléphone: <?!= infoC ?></p>
        <p>Adresse: <?!= infoD ?></p>
        <p>Date: <?!= infoE ?></p>
        <p>Besoin: <?!= infoF ?></p>
    </body>
</html>

prevent malicious post request from console tab which can change data in database

I stored jwt token in a cookie with http only option. But what if the user sends a post request from console which includes the token automatically and can change the data in the database.

lets say a game after game over sends stats to server, these stats can be seen in the network tab.
what if user modifies this data and sends a post request. How can we prevent this. Even using http only to hide the token but it will be included automatically in every request.

TailwindCSS default colours is not being recognised in my project

I have added custom colors to my TailwindCSS project, however, when I try and use a built-in color such as text-blue-200 it is not recognized within the HTML file.

Any idea what this could be?

Here is my tailwindconfig file

module.exports = {
  content: ['./public/**/*.{html, js}'],
  theme: {
    colors: {
      transparent: 'transparent',
      current: 'currentColor',
      'golden': '#cdaa60',
      'light-brown': '#6b5635',
      'dark-brown': '#433627',
      'light-green': '#848468',
      'dark': '#141115',
      'light': '#fff',
      'black': '#000',
      'error': '#ff6961'
    },
    fontFamily: {
      redressed: ['Prata', 'serif']
    }
  },
  plugins: [],
}

Slideshow/ Carousel Indicators

I was trying hard not to come on here and bother you guys but i just can’t figure out to incorporate these little slide-indicators into my code. I’ve gone through too many tutorials and can’t figure it out. I’m sure it’s something simple. Please enlighten me! Appreciate it!

HTML


 <!---- Slide Show ---->
            <div class="slide-container" id="myslideshow" data-ride="carousel">
                <!--- Slide Wrapper--->
                <div class="image-slideshow" id="myslideshow" data-ride="carousel">
                    <div class="slide-text">LAS VEGAS<br> WALK | EXPERIENCE</div>
                    <div class="image fade">
                        <img src="Images/eiffel_overlook_3-1.26.jpg" alt="Bachelorette Party at the Ghost Donkey Hidden Tequila Bar">
                    </div>        
                    <div class="image fade">
                        <img src="Images/ghost_donkey_bechelorette_3-1.26.jpg" alt="Tour Stop Hidden Gem- Secluded View of Eiffel Tower">
                    </div>        
                    <div class="image fade">
                        <img src="Images/love_sign_atrium_view_3-1.26.jpeg" alt="Laura Kimptons Love Sign at Palazzo Las Vegas">
                    </div>
                    <div class="image fade">
                        <img src="Images/big_group_mex_2_3-1.26.jpeg" alt="Big Group Mexicans with Vegas Street Performers">
                    </div>        
                    <div class="image fade">
                        <img src="Images/birdbar_group_1_3-1.26.jpg" alt="Tour group at Bird Bar Flamingo Las Vegas">
                    </div>        
                    <div class="image fade">
                        <img src="Images/waldorf_view_3-1.26.jpg" alt="View of the Strip from the Skybar at Waldorf Astoria">
                    </div>
                    <div class="image fade">
                        <img src="Images/venetian_stmarks_high_view_3-1.26.jpeg" alt="St. Mark's Square and gondolas at the Venetian Las Vegas">
                    </div>
                </div>
                <script src="main.js"></script>
            </div>

Javascript

<!----- Javascript Slideshow ----->   
     <script>
        let index = 0;
        displayImages();
        function displayImages()
         {
            let i;
            const images = document.getElementsByClassName("image");
            for (i = 0; i < images.length; i++)
            {
                images[i].style.display = "none";
            }
            index++;
            if (index > images.length)
            {
                index = 1;
            }
            images[index-1].style.display = "block";
            setTimeout(displayImages, 4000); 
        }
    </script>

CSS

/*---- Slide Show ----*/

.slide-container
{
    margin-top: 30px;
    margin-bottom: 30px;
    width: 100%;
}
.image-slideshow 
{
    width: 100%;
    position:relative;
    margin: auto;
}
.image-slideshow img
{
    width: 100%;
}
.fade 
{
    animation-name: fade;
    animation-duration: 5s;
}
@keyframes fade 
{
    from {opacity: .5}
    to {opacity: 1}
}
.slide-text
{
    
    font-size: 50px;
    font-family: 'Oswald', sans-serif;
    font-weight: 500;
    line-height: 1.2;
    position: absolute;
    top: 40%;
    left: 5%;
    z-index: 3;
    color: #fff;
    margin: 0;
}

Looking to add dots or dashes, whatever, on the bottom of the slides (on the slides, not under) so guests can flip through the slides. At the same time, I also want to keep it on an automatic slide (which right now it runs automatically). Thanks again.

Is it possible to called fetch data from a server function in “use client” client side NextJS 14 runtime

I am wondering about the various data fetching mechanism given by the NextJS. In my application I have a server side function called fetchAHistory() and it is fetching history document data from the MongoDB database.

"use server";
import History from "@/models/History";
import { connectToDB } from "@/util/database/database";

export const fetchAHistory = async (cid: string) => {
  console.log(cid);

  try {
    const results = await History.find({ id: cid }, { msgs: 1 });
    console.log(results[0].msgs);

    return results[0].msgs;
  } catch (error) {
    console.log(error);
  }
};

From the documents I referred about server-side data fetching my understand about this kind of server function was, these functions only able to call in server side. And render the fetch data as a server component to the client I need to pass the server component as a children to client component. However, in my scenario I was able to call and execute fetchAHistory() in use client client-side environment and fetch history data successfully without any issues. And fetchAHistory() was executed on the server side I was able to verify it by console.log(results[0].msgs) seeing the fetching results in the vs code terminal.

"use client";
import clsx from "clsx";
import { v4 as uuidv4 } from "uuid";
import React, { ChangeEvent, useEffect, useState } from "react";
import { useChat } from "ai/react";
import { useSearchParams } from "next/navigation";
import { Avatar } from "../ui/avatar";
import { AvatarFallback, AvatarImage } from "@radix-ui/react-avatar";
import { Button } from "../ui/button";
import { useSession } from "next-auth/react";
import { fetchAHistory } from "@/lib/data";

const Chat = () => {
  const searchParams = useSearchParams();
  const cid = searchParams.get("cid");

  const [id, setID] = useState(uuidv4);
  const image = "";

  const {
    messages,
    input,
    handleInputChange,
    handleSubmit,
    stop,
    isLoading,
    setMessages,
  } = useChat({
    body: {
      id,
    },
  });

  useEffect(() => {
    (async () => {
      if (cid) {
        const results = await fetchAHistory(cid);
        setMessages(results);
      } else if (!cid) {
        setMessages([]);
      }
    })();
  }, [cid]);

  return (
    <div className="flex flex-col h-full">
      <div className="overflow-y-auto">
        <div>
          {messages.map((m) => (
            <div
              className={clsx("p-8 flex justify-start", {
                "bg-gray-200 text-gray-800": m.role === "user",
                "bg-gray-100 text-gray-800": m.role !== "user",
              })}
              key={m.id}
            >
              <div className="max-w-[1024px] flex gap-4">
                <Avatar>
                  <AvatarImage
                    src={
                      m.role === "user"
                        ? image
                        : "https://github.com/shadcn.png"
                    }
                    alt="user"
                  />
                  <AvatarFallback>IA</AvatarFallback>
                </Avatar>
                <div className="mt-2">
                  {isLoading && m.role !== "user" ? "Loading" : m.content}
                </div>
              </div>
            </div>
          ))}
        </div>
      </div>

      <div className="mt-auto flex">
        {/* <ChatInput /> */}
        <form className="w-full flex gap-2 m-4" onSubmit={handleSubmit}>
          <input
            className="rounded border w-full border-gray-300 p-2 shadow-xl"
            value={input}
            onChange={handleInputChange}
          />
          <Button onClick={stop}>Stop</Button>
          <Button type="submit">Send</Button>
        </form>
      </div>
    </div>
  );
};
export default Chat;

Even though I have seen calling server functions in server side I didn’t know I can execute server functions this way in client side.

  1. First I like to know, is this is a recommended data fetching method in
    NextJS?
  2. And what’s are the advantage and disadvantages using server functions to fetch data compared to using API routes provided by NextJS?
  3. (Additional) What’s the real difference between 'use server' and import 'server-only'.

(updated)
I also came across this [https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#keeping-server-only-code-out-of-the-client-environment][1] next JS documentation about keeping server only code out of client side. But since the fetchAHistory() function doesn’t use any private keys and all the database operations still execute in server side is there a security risk still there when execution fetchAHistory() in client sid

Multiple individual data cannot be sent on mediaDevices.getDisplayMedia

console.log("Starting recording ...")
    audioChunks = []
    recorder.addEventListener('dataavailable', evt => {
        
        if(evt.data.size > 0  && close_record === 1) {
            

            audioChunks.push(evt.data);

            // Giữ lại chỉ 10 audio chunk mới nhất
            // if (audioChunks.length > 10) {
            //     audioChunks = audioChunks.slice(-10);
            // }
            blob = new Blob(audioChunks, { type: 'video/webm'  });
 
            async function makepredict(){
                let response = await fetch(`http://127.0.0.1:8000/api/audio/`, {
                     method: 'POST',
                     mode: 'cors',
                     body: blob
                 });
                 let result = response.json();
                 return result;
             };
            makepredict().then( function(result) {
                if (result['translate'] !== "oke"){
                    console.log(result)
                }else{
                    console.log(audioChunks.length)
                }
                

            });
        }
    })
    recorder.start(300)

When I use audioChunks with unlimited data, no error occurs, but when I limit it to only taking the last 10 data chunks, an error occurs.

if (audioChunks.length > 10) {
           audioChunks = audioChunks.slice(-10);
       } 

I cannot play the video received from the server when limited to the last 10 data chunks

I have tried many ways but still cannot fix the error. Please support me. Thank you very much

How am i supposed to add a task in Todolist App [closed]

I was trying to create a Todolist App and I am at the very beginning of this project and I am having a problem with the adding tasks to the Todolist App.

const submit = document.getElementById("submit");
const addTodo = document.getElementById("add-todo");

submit.onclick = addingTodo;

function addingTodo() {
    const addTodoText = addTodo.value;

    if (addTodo.trim() !== "") {
        const todoItem = document.createElement("li");
        todoItem.textContent = addTodoText;

        todos.innerHTML(todoItem);

    } else {
        alert("please enter a task.");
    }

}

document.getElementById('submit').addEventListener('click', addingTodo);

R Shiny export buttons that export from another column

I have a table that has NA values in certain columns. In a Shiny app, I would like export buttons below each column that report values from another column that correspond to NA in the selected column.

Code for simple data frame:

data <- data.frame(
  ID = c(1, 2, 3, 4, 5),
  Name = c("John", "Jane", "Alice", NA, "Bob"), 
  Age = c(25, NA, 30, 35, NA), 
  Score = c(80, 90, NA, 75, 85))

I would like to show this table, and below each column (except ID), I would like a button to export a CSV that contains all ID that correspond to NA in the selected column.

I have tried multiple iterations of JS code to no avail as well as some DT code. I can’t the buttons to go to the bottom or to export ONLY the IDs corresponding to NA

observe({ 
     buttons <- lapply(names(data), 
          function(col_name) { 
               if (col_name %in% c("Name", "Age")) { 
                    actionButton( 
                         inputId = paste0("export_", col_name), 
                                   label = paste("Export IDs where NA in", col_name) 
                 ) 
              } else { 
                  actionButton( 
                         inputId = paste0("export_", col_name), 
                                   label = paste("Export", col_name) 
                         ) 
                   } 
              }) 
     insertUI( 
        selector = "#table_wrapper .dataTables_wrapper .dataTables_scrollFoot .dataTables_scrollFootInner table tfoot", 
        where = "afterEnd", 
        ui = tags$tr( 
            lapply(buttons, function(btn) tags$td(btn)) 
        ) 
     ) 
}) 
observeEvent(input$table_cell_clicked, { 
     info <- input$table_cell_clicked 
     if (info$value == "Export") { 
           col_name <- gsub("export_", "", info$target) 
           selected_data <- data[[col_name]] filename <- paste("export_", col_name, ".txt", sep="")          
           write.table(selected_data, file = filename, row.names = FALSE, na = "") 
} 

To do I call Vue app.mount(‘#myAppID’) a second time if the div with that ID is removed from the DOM and added back later?

I have one Vue component (a compiled single .js file) that is a header, and another Vue app that contains a lot of pages. If I load in the second (compiled) vue app.js file, AND the DOM element with the expected ID is present, then it loads fine at first. But, if I change pages with a router, and that DOM becomes unloaded, then when I switch back to that initial page, the Vue Header app doesn’t load, the stays empty.

Same thing happens if I try to load that script first, and the DOM element with the expected ID isn’t present, it won’t load then, and it won’t load later.

So, here is what the code block looks like with the Vue header. This works, once but not a second time. I think in part because the script is already added to the document so calling it again would add a duplicate. So ideally, I would just load it once, but be able to re-initialize or re-mount it again when needed.

<template>
  <div id="vue-header"></div>
</template>

<script>
  export default {
    mounted() {
      console.log("Vue header mounted event")
      let testScript = document.createElement('script')
      testScript.setAttribute('src', 'https://site****URL.com/Vue/vue-header.js')
      document.head.appendChild(testScript)
    }
  }
</script>

Within the vue-header.js in main.ts I have the standard stuff, but the important part to know is that it targets that id #vue-header

import App from './App.vue'

const app = createApp(App);

app.mount('#vue-header');

So, is there any simple way to re-initialize that app once it gets unloaded? I am not sure how (or if it is possible) to reference and target the imported block of script to call the app.mount for it a second time.

Uploading the NextJs app and building it produces strange issues

I am building a nextjs web and this is my first time building in NextJs. The web is working fine on the localhost but it doesn’t work when I run the npm run build command or if I try to upload to some hosting service like Vercel or Firebase hosting.
It gives me strange errors. I am posting some error description below.

ReferenceError: Cannot access 'rL' before initialization
    at 52209 (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/.next/server/app/dashboard/page.js:504:18)
    at t (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/.next/server/webpack-runtime.js:1:143)
    at F (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:91937)
    at /Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94352
    at W._fromJSON (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94790)
    at JSON.parse (<anonymous>)
    at N (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:91658)
    at t (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:98043)

Error occurred prerendering page "/dashboard". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: Cannot access 'rL' before initialization
    at 52209 (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/.next/server/app/dashboard/page.js:504:18)
    at t (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/.next/server/webpack-runtime.js:1:143)
    at F (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:91937)
    at /Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94352
    at W._fromJSON (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94790)
    at JSON.parse (<anonymous>)
    at N (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:91658)
    at t (/Users/salmanmajid/Desktop/React/NewPromptSavvy/promptsavvy/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:98043)

I am attaching the whole source code.
I am not sure where I can resolve this issue. It is something that next is adding after I run the npm run build command

Trying to upload the project to vercel. Before I do that, I run the npm run build command and I get the error described in the question.

Point my mochawesome report to external domain

Good afternoon!

I have the following situation:

Automation in Cypress and report generated using the mochawesome lib.

I need to add this report to an external URL/domain.

I searched and found the http-server lib. However, it is localhost only.

Could anyone help me?

The objective is to add the report from the directory (mochawesome-report) to an already created external domain.

Thanks in advance.

How to save data from CKEditor via Django Rest Framework using javascript (vanilla)

Im writing an application that has a function for adding a document. For this reason i needed some rich text editor for formatting the documents.

so here is my views.py for rendering my html:

def add_document_view(request):
    if request.user.is_authenticated:
        categories = Category.objects.all()
        languages = get_language_choices()
        context = {"allCategories":categories, "form":PostForm, "languages":languages}
        return render(request, "documents/add-document.html", context)
    return JsonResponse({"status":"500 Auth Error"})

add-document.html

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Add Document</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
    <div class="container mt-5">
        <h1>Add Document</h1>
        <hr>
        <form method="POST" action="#">
            {% csrf_token %}
            <div class="form-group">
                <label for="title">Header:</label>
                <input type="text" class="form-control" id="header" name="header" placeholder="Enter document header" required>
            </div>
            <div class="form-group">
                <label for="category">Category:</label>
                <select class="form-control" id="category" name="category" required>
                    <option value="" disabled selected>Select category</option>
                    {% for category in allCategories %}
                    <option value="{{ category.id }}">{{ category.title }}</option>
                    {% endfor %}
                </select>
            </div>
            
            
            <div class="form-group">
                {{form.media}}  
                {{form.as_p}}
            </div>
            <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>

    <script src="https://cdn.ckeditor.com/ckeditor5/38.0.0/classic/ckeditor.js" defer></script>
    
</body>
</html>

models.py


from django.db import models
from ckeditor.fields import RichTextField
from simple_history.models import HistoricalRecords
from .utils import get_language_choices

class Category(models.Model):
    title = models.CharField(max_length = 64, unique = True)

    def __str__(self):
        return self.title


class Document(models.Model):

    class DocumentStatus(models.TextChoices):
        ACTIVE = 'active', 'Active'
        ARCHIVED = 'archived', 'Archived'

    header = models.CharField(max_length = 32)
    body = RichTextField()
    category = models.ForeignKey(Category, on_delete = models.CASCADE)
    timestamp = models.DateTimeField(auto_now_add = True)
    status = models.CharField(max_length = 10, choices = DocumentStatus.choices, default = DocumentStatus.ACTIVE)
    history = HistoricalRecords()

    def __str__(self):
        return self.header

forms.py for CKEditor form:

from django import forms
from ckeditor.widgets import CKEditorWidget
from .models import Document

class PostForm(forms.Form):
    body = forms.CharField(widget = CKEditorWidget())
    class Meta:
        model = Document
        fields = ('body',)

script to fetch my API:

document.addEventListener("DOMContentLoaded", ()=>{
    const richTextContent = CKEDITOR.instances[0].getData(); 
    // How do i get the content and sanitize it in order to pass it to my API
    // with url "/api/" POST request

})

So the main question is How do i get the content from ckeditor form so i could send it to my API?