Preserve white space line breaks in tinymce wysiwyg editor

I have a tinymce editor implemented in my react project installed through the package

"@tinymce/tinymce-react": "^3.12.6". 

I am trying to preserve the white space line breaks of the data which comes from external source (excel file) when being edited in the wysiwyg editor but I have not been able to do so. I have tried the options such as force_br_newlines and convert_newlines_to_brs but it does not seem to help

Scenario explanation in detail:

I have an excel file which has multiline text which gets imported to the app. The multiline text is preserved in the database and I get the text displayed in multi lines when I log it to the console. (The console does not output new line characters line n, r,etc and just white space line breaks like in the original text). But, when I edit the same data with tinymce editor, the tinymce editor puts all the data in one line.

The original text is not html text and we cannot expect the end user to type HTML tags inside the excel file such as
<p>...</p> or <br />

Example data in the excel file:

This is line one
This is line two
This is line three

Data when it gets displayed in the editor:

This is line one This is line two This is line three

I would like the editor to preserve the line breaks. Is that possible? How can it be achieved? Your help would be really appreciated. Thanks in advance.

When dynamically creating HTML elements with Javascript is it better to have the css predfined in a file, or dynamically assign the css?

So pretty what the title says.
Is it better performance/a more efficient use of memory to have the css be created with the dynamically generated HTML elements, or to have the classes predefined in a css file waiting to be called up?

I could imagine that having css sitting waiting to be used could make the css file unnecessarily big, whereas using JS to create the css could be a less efficient use of memory and proccesing power.

Would love to hear others thoughts on it 🙂

thanks,
-Boogabooga

While exporting a static array sometimes returns null

I have an array where I export it,
Sometimes this array returns me null, sometimes returns only the first element, sometimes all elements.

This is how I use

export const items= [
{
    title:"title1"
},
{
    title:"title2"
},
{
    title:"title3"
},

];

I use it in my app.js

import { items } from './data.js'

When I use it in useEffcet as I said, sometimes returns three elements some times just one element, and sometimes null. Thanks a lot

useEffet(() => {console.log(items)},[])

Map function returning whole array

const flight = () => {

return (
    <div className="tour-list-area">
      {hotelFlightPackageListTest.map((flightDetails) => {
        return <FlightHotelPackageItem key={flightDetails.outbounddate} {...flightDetails} />
      })};
    </div>

  )
  };

Inside<FlightHotelPackageItem> I am logging it like so:

const FlightHotelPackageItem = (flightDetails) => {
console.log(flightDetails)

The returned result is the entire array as though I just passed in the whole array. I imagine it’s some dumb syntax error, would appreciate someone pointing out what I’m doing wrong.

It isn’t logging anything [closed]

When I run the script it doesn’t log??
No error though, just an empty console.

Sorry if it’s easy I’m pretty new.

const config = require("./config.json");

var enabled = config.enabled;

let json = { "name": "micheal", "age": 28 };

while (enabled) {
    try {
        let jsonStringed = JSON.stringify(json);
        var currentSelection = config.string;
        let string_ea = currentSelection;
        var matchedString = jsonStringed.match(string_ea)

        let count = 0;

        matchedString.forEach(element => {
            if (element == string_ea) {
                count += 1;
            }

            if (count = 0) {
                console.log(`"${string_ea}" never occured.`);
            }

            if (count > 0) {
                console.log(`"${string_ea}" occured ${count} times.`);
            }
        })
    } catch (e) {
        console.log(e);
    }
}

more text so i can post it without adding more details asjldkasd asd as d sa da sd asdasdasdasdasdasdasd

Can you make javascript realize something like a variable or element has changed?

<script>
  let y = 0
  let x = document.querySelector("p")
  setInterval(function(){y++; x.innerHTML = y},1000)
  x.addEventListener("change",change)
  function change(){console.log("i have changed")}

</script>

the script above is kind of what i’m looking for, this has worked for a input element, but i want a this kind of solution, however i am aware it might not be possible, thank you.

SignalR intercept every incoming message (client side)

I have a question regarding SignalR on the clientside (JS). Is there a way to intercept incoming messages at the clientside? I am working on a chat application with a lot traffic on the socket. I want to be able to execute code (catch errors if any) on every incoming event. Looking at the docs i can’t find any existing solution for this. Is there anyone that knows a solution for this?

Thanks in advance. Any help would be much appreciated!

How add google font into react-stripe-elements

Hi all I have following code

I am trying to add Ralway google font into my stripe element.

I try this:

App.js

    export default function App() {
      const stripePromise = loadStripe("pk_test_FnsOZv49080ssnyO2xn0gCoS");

      const options = {
        elements: {
          fonts: [
            {
              cssSrc:
                "https://fonts.googleapis.com/css2?family=Raleway&display=swap"
            }
          ]
        }
      };
      return (
        <Elements stripe={stripePromise} options={options}>
          <div className="App">
            <PaymentForm />
          </div>
        </Elements>
      );
    }

PaymentForm .js

     const PaymentForm = () => {
      const stripe = useStripe();
      const elements = useElements();
      const stripeStyle = {
        base: {
          fontFamily: "Raleway",
          fontSize: "16px"
        },
        "::placeholder": {
          color: "green"
        }
      };
      return (
        <div>
          <CardNumberElement
            options={{
          style: stripeStyle
            }}
          />

          <CardExpiryElement options={{ style: stripeStyle }} />

          <CardCvcElement options={{ style: stripeStyle }} />
        </div>
      );
    };

But nothing has happened. Please help me figure out how should I change my code.

I looked into following questions ( 1, 2, 3 ) regarding to fonts for react-stripe-elements but no one of them didn’t helped me to resolve my problem.

change the position of object in array inside other object

in given data every ingredient have its substitute option while I can
select any substitute option for example if I want to change masala
with its substitute output will change the position of substitute with
it’s option and output should be given below

i want to replace masala with normal masala

  • i have to create a function who replace ingredient with it’s substitute and interchange the position of both *

input

const oData = [
    { CurryName: 'Chiken', id: 0 },
    {
      ingredients: [
        {
          id: 1,
          name: 'onion',
          property: { color: 'yellow', Quantity: 'half KG', price: 120 },
          subOption: [
            {
              id: 11,
              name: 'redOnion',
              property: { color: 'red', Quantity: '1 KG', price: 120 },
            },
            {
              id: 12,
              name: 'whiteOnion',
              property: { color: 'white', Quantity: '2 KG', price: 120 },
            },
          ],
        },
        {
          id: 2,
          name: 'oil',
          property: { color: 'green', Quantity: 'half LT', price: 120 },
          subOption: [
            {
              id: 21,
              name: 'yellowOil',
              property: { color: 'yellow', Quantity: '1 LT', price: 120 },
            },
            {
              id: 22,
              name: 'olivoOil',
              property: { color: 'golden', Quantity: '2 LT', price: 120 },
            },
            {
              id: 22,
              name: 'CastrolOil',
              property: { color: 'silk', Quantity: '2 LT', price: 170 },
            },
          ],
        },
        {
          id: 3,
          name: 'masala',
          property: { color: 'gray', Quantity: '1Tspoon', price: 30 },
          subOption: [
            {
              id: 31,
              name: 'garamMasala',
              property: { color: 'Garam', Quantity: '2Tspoon', price: 30 },
            },
            {
              id: 32,
              name: 'chikenMasala',
              property: { color: 'green', Quantity: ' 3Tspoon', price: 30 },
            },
            {
              id: 33,
              name: 'normalMasala',
              property: { color: 'red', Quantity: '5Tspoon', price: 30 },
            },
          ],
        },
      ],
    },
  ];
  
  // in given data every ingredient have it's substitute option while i can select any supstitute option for example if i  want to change masala with its substitute output will change the position of substitue with it's option and output should be given below
  //i want to replace masala with normal masala
  const output = [
    { CurryName: 'Chiken', id: 0 },
    {
      ingredients: [
        {
          id: 1,
          name: 'onion',
          property: { color: 'yellow', Quantity: 'half KG', price: 120 },
          subOption: [
            {
              id: 11,
              name: 'redOnion',
              property: { color: 'red', Quantity: '1 KG', price: 120 },
            },
            {
              id: 12,
              name: 'whiteOnion',
              property: { color: 'white', Quantity: '2 KG', price: 120 },
            },
          ],
        },
        {
          id: 2,
          name: 'oil',
          property: { color: 'green', Quantity: 'half LT', price: 120 },
          subOption: [
            {
              id: 21,
              name: 'yellowOil',
              property: { color: 'yellow', Quantity: '1 LT', price: 120 },
            },
            {
              id: 22,
              name: 'olivoOil',
              property: { color: 'golden', Quantity: '2 LT', price: 120 },
            },
            {
              id: 22,
              name: 'CastrolOil',
              property: { color: 'silk', Quantity: '2 LT', price: 170 },
            },
          ],
        },
        {
         
              id: 33,
              name: 'normalMasala',
              property: { color: 'red', Quantity: '5Tspoon', price: 30 },
           
         
          subOption: [
            {
              id: 31,
              name: 'garamMasala',
              property: { color: 'Garam', Quantity: '2Tspoon', price: 30 },
            },
            {
              id: 32,
              name: 'chikenMasala',
              property: { color: 'green', Quantity: ' 3Tspoon', price: 30 },
            },
            {
              id: 3,
              name: 'masala',
              property: { color: 'gray', Quantity: '1Tspoon', price: 30 },
             }
          ],
        },
      ],
    },
  ];
  
  console.log(output)

How to store objects created in a loop inside array defined outside of loop in Javascript

I have the following for loop in which this_block gets created and then filled in:

for (i = learning_trial_idx.length - 1; i >= 0; i--) {

  target = Math.floor(Math.random())

  these_trials = learning_trial_idx.filter(x => x.from != target)

  this_block = [];

  for (let i = 0; i < these_trials.length; i++) {
      this_block.push(these_trials[i])
  }

  this_block = this_block.filter(function (a) {
    var key = a.to + '|' + a.from;
    if (!this[key]) {
        this[key] = true;
        return true;
      }
    }, Object.create(null));
}

How can I go about storing this_block each time into something like const all_blocks = {}, which is defined outside of the for loop?

Insert php works but the data is not save in database

I want to insert data into database with ajax and I got message in console that it does work also no errors but the data is not inserting into database.

Php code:

<?php 

include 'connection.php';


if($_POST['action'] == 'rating')
{
    echo "work";

    $user_name = $_POST['user_name'];
    $rating_index = $_POST['rating_index'];
    $user_review = $_POST['user_review'];

    $stmt = $conn->prepare("INSERT INTO review_table
    (review_id, user_name, user_rating, user_review, datetime) 
    VALUES (NULL, ?, ?, ?, NOW())");
    $stmt->bind_param('sis',  $user_name,  $user_rating, $user_review);
    $stmt->execute();
}
?>

and like I said I have echo “work” printed in console so it is connecting with ajax and also I checked if variable are set correctly and they are.

ajax code:

 $.ajax({
                                url:"rating-data.php",
                                method:"POST",
                                data: {
                                    action:'rating',
                                    rating_index: rating_index,
                                    user_name: user_name,
                                    user_review : user_review
                                },
                                success:function(data)
                                {
                                    $('#review_modal').modal('hide');
                                    // load_rating_data();
                                    console.log(data);
                                }
                            })

Motorcycle Clothing | Leather Clothing

Getting a motorcycle Clothing, needs massive passion which comes with great exhilaration. But, there is one more important factor to discuss is that the danger of an accident, because that’s where motorcycle clothing enters the scene. To be a biker means touching the limits of speed, even if it means risking. Unlike a car driver, motorcycles do not have a cabin to protect the rider in case of an accident, so a need for protective motorcycle clothing was born. At Leather Collection, with collaboration with Moto Speeds, we make motorcycle racing suits laced with CE approved armour, high-quality leather with maximum resistance against cuts, abrasions, and impact to save you in case of an unfortunate event.
enter image description here

How to get data from recharts graph using selenium?

Goal Of the task

The task requires me to scrape the data from this site. If you will scroll down you will see a graph that displays data only when the mouse hovers over it. Here is a screenshot.
I want to get the data displayed using selenium. One obvious choice is using ActionChains, but I can’t use ActionChains in this case, cause It doesn’t work when the browser is minimized. I want a solution which uses Javascript or any other means to somehow fetch the data and not use ActionChains.

Some Insights and Progress made by me

The site is sending a POST request to its GraphQl server and getting a response.
I am not much familiar with JS or with React. But doing some research I found out that the site uses Recharts library to display the data. I also found out this react script named PriceHistoryGraph.react.tsx in the source. I can see that It detects the mouse hover using OnMouseMove and OnMouseLeave events. I have also looked at a lot of StackOverflow posts but none seems to help, for example this.
I then tried to look for some way to get the data where the chrome has stored it as the script uses these imports, but I can’t find any way or see if it is possible.
If I were able to simulate the mouse movements as required by recharts so that the bubble appears then I can use XPath to extract the data.
Here are the imports the script is using to work on the data.

import {
  PriceHistoryGraph_data,
  PriceHistoryGraph_data$key,
} from "lib/graphql/__generated__/PriceHistoryGraph_data.graphql"

Final Questions

  1. Is there a way to simulate the “mouse move” behavior using Javascript to trigger the bubble that appears on the graph, then I can just use XPath and get the data?
  2. Is there a workaround way to extract the data easily? (Can’t use selenium wire to intercept the GraphQL requests as I am using a modified Selenium web driver, Github here)