I create paragraph in tiptap 2, how to add a class to this paragraph

below is my tiptap code which creates paragraph

<script>
this.editor.commands.insertContent({
                        type: 'paragraph',
                        HTMLAttributes: {
                            class: 'created-paragraph',
                        },
                        content: [{ type: 'text', text }],
                    });
</script>

i created a paragraph like this, but “HTMLAttributes” is not working, how to add a class in other way? i cant figure it out 🙁

i hope guys u can help me

Pass C# float array to Javascript in CefSharp

I am developing in a WPF project and am using CefSharp.wpf to connect to my html/javascript script. The script is locally on my pc.
Currently, I have to convert my C# float array to a string, which takes a long time (192ms).
It takes this long because the array has a length of over 200000.
The main problem is that this Array has to be sent 30 times per Second, with different values each time.

My Idea was to send the pointer to the array location to the website so it can always get the newest version directly, but I have not found a solution yet.
Does anyone have an Idea how I can achieve this?

some time showing device found in camera and mic api permission uisng javascript

function allowCameraPermission(user,supplierTeam){
     try {
    navigator.mediaDevices.getUserMedia({ video: true, audio: true })
      .then(function (stream) {
        saveUserPermissionData(true, true, user ,supplierTeam);
      })
      .catch(function (error) {
        $('.loadingspinnerparent').hide();
        handleNoDeviceFound(user, supplierTeam);
      $(".notification-permisssion-white").text("Please allow permission for camera and microphone");
        saveUserPermissionData(false, false, user ,supplierTeam);
      })
     } catch (error) {
    console.log(error)
    }

some time showing device not found error in catch function
please help me if any one know about this

i dont want to show device not found and please resolve this

if permission already allow for both camera and mic still showing

how to load outside application libraries into current application in cloud foundry bussiness application studio?

in my application i am using reuse libraries(fiori apps library) in neo environment(web ide). But i am planning to migrate my application in cloud foundry. so i am unable to load the libraries. In neo i am define the libraries in neo-app.json with type app name and loaded libraries same in component.js. By the way there is no index file and component files for reuse libraries in web ide. So how can i proceed/migrating here.

in my application i am using reuse libraries(fiori apps library) in neo environment(web ide). But i am planning to migrate my application in cloud foundry. so i am unable to load the libraries. In neo i am define the libraries in neo-app.json with type app name and loaded libraries same in component.js. By the way there is no index file and component files for reuse libraries in web ide. So how can i proceed

How to use linq in microsoft.clearscript.v8

I am using microsoft.clearscript.v8 in ASP.Net Core MVC. This code is in my Home controller:

public async Task<IActionResult> Index()
{
    using (var engine1 = new V8ScriptEngine())
    {
        engine1.AddHostType(typeof(JavaScriptExtensions));
        engine1.DocumentSettings.AccessFlags = DocumentAccessFlags.EnableFileLoading;
        string scriptPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "js", "NewScript.js");
        string scriptContent = System.IO.File.ReadAllText(scriptPath);
        engine1.Execute(scriptContent);
        dynamic data = engine1.Evaluate("NewLinq();");
        return View();
    }
}

This code is in NewScript.js

function NewLinq() {
  const rawData = [
    { "id": 1, "name": "John", "age": 25 },
    { "id": 2, "name": "Jane", "age": 30 }      
  ];

  var result = rawData.filter(person => person.age > 25);  
  return result;
}

The code returns an error:

UnderlyingSystemType = ‘((Microsoft.ClearScript.ScriptItem)data).UnderlyingSystemType’ threw an exception of type ‘System.NotImplementedException’

How to get output and use linq?

after installing vite for react npm run dev not working

after successfully installing react js with vite
after using npm i
when i write npm run dev
it show this error
npm run dev

> [email protected] dev
> vite

E:nasheednaldonode_modulesrollupdistnative.js:64
                throw new Error(
                      ^

Error: Cannot find module @rollup/rollup-win32-ia32-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at requireWithFriendlyError (E:nasheednaldonode_modulesrollupdistnative.js:64:9)
    at Object.<anonymous> (E:nasheednaldonode_modulesrollupdistnative.js:73:48)
    ... 2 lines matching cause stack trace ...
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at cjsLoader (node:internal/modules/esm/translators:284:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:234:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) {
  [cause]: Error: The specified module could not be found.
  \?E:nasheednaldonode_modules@rolluprollup-win32-ia32-msvcrollup.win32-ia32-msvc.node
      at Module._extensions..node (node:internal/modules/cjs/loader:1327:18)
      at Module.load (node:internal/modules/cjs/loader:1091:32)
      at Module._load (node:internal/modules/cjs/loader:938:12)
      at Module.require (node:internal/modules/cjs/loader:1115:19)
      at require (node:internal/modules/helpers:130:18)
      at requireWithFriendlyError (E:nasheednaldonode_modulesrollupdistnative.js:62:10)
      at Object.<anonymous> (E:nasheednaldonode_modulesrollupdistnative.js:73:48)
      at Module._compile (node:internal/modules/cjs/loader:1241:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
      at Module.load (node:internal/modules/cjs/loader:1091:32) {
    code: 'ERR_DLOPEN_FAILED'
  }
}

Node.js v20.9.0

now i tried to reinstall it but it kept happening everytime.

In linux distro debian getting an error while trying to install : npm install nodemon [closed]

my input in terminal npm install nodemon --save-dev and also tried sudo npm install nodemon --save-dev

npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ../nodemon/bin/nodemon.js
npm ERR! dest /media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, symlink '../nodemon/bin/nodemon.js' -> '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'
npm ERR!  [Error: EPERM: operation not permitted, symlink '../nodemon/bin/nodemon.js' -> '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../nodemon/bin/nodemon.js',
npm ERR!   dest: '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/ghost/.npm/_logs/2023-11-28T08_34_57_994Z-debug-0.log
Waiting for the debugger to disconnect...
ghost@ghost:/media/ghost/T7 Shield/Builds/server$ npm install nodemon
Debugger listening on ws://127.0.0.1:33217/d375f3c9-3cad-450f-8502-1a5c4eb81128
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ../nodemon/bin/nodemon.js
npm ERR! dest /media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, symlink '../nodemon/bin/nodemon.js' -> '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'
npm ERR!  [Error: EPERM: operation not permitted, symlink '../nodemon/bin/nodemon.js' -> '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../nodemon/bin/nodemon.js',
npm ERR!   dest: '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/ghost/.npm/_logs/2023-11-28T08_35_29_947Z-debug-0.log
Waiting for the debugger to disconnect...
ghost@ghost:/media/ghost/T7 Shield/Builds/server$ ls
index.html  package.json  run.js
ghost@ghost:/media/ghost/T7 Shield/Builds/server$ npm install nodemon --save-dev
Debugger listening on ws://127.0.0.1:44093/78d10902-9d75-4818-a992-04461a67f15e
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ../nodemon/bin/nodemon.js
npm ERR! dest /media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, symlink '../nodemon/bin/nodemon.js' -> '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'
npm ERR!  [Error: EPERM: operation not permitted, symlink '../nodemon/bin/nodemon.js' -> '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../nodemon/bin/nodemon.js',
npm ERR!   dest: '/media/ghost/T7 Shield/Builds/server/node_modules/.bin/nodemon'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/ghost/.npm/_logs/2023-11-28T08_44_59_836Z-debug-0.log
Waiting for the debugger to disconnect...

Condition operator, doesn’t react on condition changes, I guess

I have a React component representing a form with inputs (Text, Number, Date). The date input has a default value – today. I use this component for two functions: creating an object and editing an object. In the first case, all inputs are empty by default, except for the date input, which is set to today. In the second case, the inputs receive default values from optional props (values) that are passed to the component from the parent component’s state. The component is rendered on the page in two instances, one with values passed and one without. Since the presence of values is optional, I included a conditional operator in the default values of each input. In the case of the date input, it looks like this:

defaultValue={inputValues?.date ? inputValues.date : today}

In other cases, an empty string '' is used instead of today.

I expected that when the state changes, the component would re-render and insert the values into the default inputs. In practice, this only happens with inputs that are initially empty, while the date input always has the value today.

Through the console, I see that when the component is rendered, inputValue = undefined (useState is set with empty brackets, so it’s not a surprise), so initially I assumed that the values do not appear by the time of rendering. However, when the edit button is clicked, the correct values are displayed in the console. In my understanding, at this point, the component should re-render and insert the values according to the expression {inputValues?.date ? inputValues.date : today}. However, in fact, the value of the date picker is today, and the value of all other inputs is values. If you replace today with an '' in the expression, then when the edit function is called, the value of the date picker in the edit form is inputValues.date, but the default value in the creation form is now empty, because today is not set in this case.

This behavior is not exclusive to the date picker; any other input behaves in the same way if you replace '' with any value in the expression. I would be very glad if you could explain this behavior and how to fix it.

Here is a test example:”

function App() {
    const [values, setValues] = React.useState();
    const change = () => setValues({ name: 'name', date: '2023-11-28' });
    return (
        <Child values={values} change={change} />
    );
}

function Child({ values, change }) {
    console.log(values);
    return (
        <div className="container">
            <button type="button" onClick={change} >clickMe</button>
            <input type="text" defaultValue={values?.name ? values.name : ''} />
            <input type="date" defaultValue={values?.date ? values.date : '2023-11-20'} />
        </div>
    );
}

const domContainer = document.querySelector('#like_button_container');
const root = ReactDOM.createRoot(domContainer);
root.render(<App />);

rendering artefacts on small objects

I am currently rendering a texture on a cylinder in threeJS.

In most cases it works fine, but I’ve noticed that when the radius of the cylinder shrinks to low values (in the case of the image attached: 0.0012561892224928503) I am getting weird artefacts

Is this something that is common in ThreeJS and has some known workarounds for?
I’ve tried setting logarithmic depthbuffer but that didn’t work.

I assume it to be a rounding error somehwere that causes the artifacts, but to my knowledge the default for the renderer precision is highp so not much to change there

artefacts

Can you plot within a for loop in Javascript?

When I try the below my plot is empty, is the below possible? With the blow code my plot is empty.

for (let t in test) {
            let test3 = test[t]
            const { country, deforestation_mean, fair_wages_mean, 
overall_mean, overconsumption_mean, sustainable_sourcing_mean } = test3
            

            let trace1 = [
                {
                    x: country,
                    y: deforestation_mean,
                    type: 'bar',
                },
            ];
            let trace1Layout = {
                title: 'Sustainability Metric: ' + selectedMetric.replace(/_/g, ' '),
                //margin: { t: 100 },
                hovermode: 'closest',
                xaxis: { title: 'Countries' },
                //margin: { t: 100 },
            };
            Plotly.newPlot('plot1', trace1, trace1Layout);
            console.log(country)

        }

I tried the below, and can successfully plot:

switch (selectedMetric) {
            case 'overall_mean':
                y = data.map((d) => d.overall_mean);
                break;
            case 'sustainable_sourcing_mean':
                y = data.map((d) => d.sustainable_sourcing_mean);
                break;
            case 'overconsumption_mean':
                y = data.map((d) => d.overconsumption_mean);
                break;
            case 'deforestation_mean':
                y = data.map((d) => d.deforestation_mean);
                break;
            case 'fair_wages_mean':
                y = data.map((d) => d.fair_wages_mean);
                break;
            default:
                y = data.map((d) => d.overall_mean); // Default to overall mean
        }

However I want to be able to plot off of different metrics.

Swap AxisX and AxisY using Lightningchart library

I’m using lightningchart library and would like to create a ChartXY with an AreaSeries attach to it. To do so I write this code using React and TypeScript :

import { useEffect, useRef } from 'react';

import {
    lightningChart,
    ChartXY,
    Dashboard,
    emptyFill,
    AreaSeries,
    AreaSeriesTypes
} from "@arction/lcjs";

import './ChartTest.scss';


const ChartTest = () => {
    const chartRef = useRef(null);
    
    const dashboard = useRef<Dashboard|null>(null);
    const scallingChart2 = useRef<ChartXY|null>(null);
    const scallingChart2Serie = useRef<AreaSeries|null>(null);

    const initializeDashboard = (container:HTMLDivElement) => {
        const dashboard = lightningChart()
            .Dashboard({
                numberOfColumns: 1,
                numberOfRows: 1,
                container: container
            })
            .setRowHeight(0, 3)
            .setRowHeight(1, 1)
            .setColumnWidth(0,12)
            .setColumnWidth(1,1);

        return dashboard;
    }

    const initializeScallingChart = (dashboard:Dashboard) => {
        const chart = dashboard.createChartXY({
            columnIndex: 0,
            rowIndex: 0
        })
        .setTitleFillStyle(emptyFill)
        .setTitleMargin({ top: 0, bottom: 0 })
        .setPadding(0)

        return chart;
    }

    const renderScalingChart = (chart:ChartXY) => {
        const series = chart
            .addAreaSeries({
                type: AreaSeriesTypes.Bipolar,
            })

        for (let i=0; i<100; i++) {
            series.add({ y: Math.floor(Math.random() * 20) - 10, x: i })
        }

        return series;
    }

    useEffect(() => {
        if (chartRef.current) {
            dashboard.current = initializeDashboard(chartRef.current);

            scallingChart2.current = initializeScallingChart(dashboard.current);

            scallingChart2Serie.current = renderScalingChart(scallingChart2.current);
        }
        
        return () => {
            if (dashboard.current) {
                dashboard.current.dispose();
            }
        }
    }, []);


    return (
        <div className='chart-test' ref={chartRef} ></div>
    );
}

export default ChartTest;

This part work well and give me this result:
enter image description here

But from there I wanna rotate the chart 90deg to put it verticaly. So when I add points to the AreaSerie I change the x and y :

for (let i=0; i<100; i++) {
    series.add({ y: Math.floor(Math.random() * 20) - 10, x: i })
}

But got this result :
enter image description here

It’s normal because I didn’t tell Lightningchart to draw under the y axis instead of the x axis. However I don’t see any option to do so. I try to swap the x and y axis on creation of my AreaSerie but got nothing:

const series = chart
    .addAreaSeries({
        type: AreaSeriesTypes.Bipolar,
        yAxis: chart.addAxisX(),
        xAxis: chart.addAxisY()
    })

I also check the different options for createChartXY and thought I was near the solution with the defaultAxisY axis option. But It’s only possible to set the axis to the oposite of the chart and not swaping with the other axis.

Any other idea is welcome.

ajax await async:false Difference

First of all, I am not good at English, so please understand if my writing is weird.

We found two ways when converting from ajax asynchronous calls to synchronization.

  1. async: false
  2. await

It shows the same result, but I would like to know the difference between these two modes of operation.

function callAjax(url) {
    $.ajax({
        url: url,
        type: "POST",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: JSON.stringify(data),
        caches: false,
        async: false,
        success: function(response) {
            console.log(response);
        },
        failed: function(e) {
            ajaxFail(e);
        }
    });
}
async function ca(url) {


    await $.ajax({
        url: url,
        type: "POST",
        contentType: "application/json; charset=utf-8",
        caches: false,
        success: function(response) {
            console.log(response);
        },
        failed: function(e) {
            ajaxFail(e);
        }
    });
}

I don’t know how to directly identify the fundamental part. I don’t even know if I wrote English properly. I’m sorry.

Display a short version of long string on a div in React TS

I am working on a React component that receives a long string and a numerical variable as props. The component’s objective is to display a trimmed version of the string, based on the specified number variable. Additionally, it should include “show more” and “show less” buttons.

Despite attempting various approaches, none have proven successful. The original single-line string becomes multi-lined when placed within a div with defined width and height. My primary challenge arises when using the “useRef” hook to access textRef.current.innerHTML, which returns the original string without ‘n’ characters.

Do you have any suggestions on how to address this issue?

React Redux: Inconsistent Value of Variable Inside and Outside Function in Custom Hook

I am encountering an issue in a custom React hook that uses Redux. The problem is related to the inconsistency of a variable’s value inside and outside a function within the same hook. Here’s the simplified code:

import { useAppSelector } from "Redux/helpers";
import { selectAgentState } from "Redux/slices/agentSlice";

const useRemoveRoomNotif = () => {
  const notifications = useAppSelector((state) => selectAgentState(state).notifications);
  console.log("Outside function:", notifications);

  const removeNotif = (rid: string, markNotificationsAsRead) => {
    console.log("Inside function:", notifications);
    const ntf = notifications.filter((notif) => notif.roomID === rid && !notif.isRead);
    if (ntf.length !== 0) markNotificationsAsRead(ntf);
  };

  return { removeNotif };
};

export default useRemoveRoomNotif;

he issue is that the notifications value inside the removeNotif function is different from the value outside the function. I assumed that since it’s the same variable, the values should be the same.

I attempted a workaround using useState, useEffect, and useRef to ensure the correct value is used inside the function:

const useRemoveRoomNotif = () => {
  const notifications = useAppSelector((state) => selectAgentState(state).notifications);
  const [update, setUpdate] = useState(false);
  const [id, seId] = useState("");
  const markAsReadRef = useRef<(notifications: INotification[]) => void>();

  useEffect(() => {
    if (!update) return;
    const ntf = notifications.filter((notif) => notif.roomID === id && !notif.isRead);
    if (ntf.length !== 0 && markAsReadRef.current) {
      markAsReadRef.current(ntf);
    }
    setUpdate(false);
  }, [notifications, markAsReadRef, id, update, setUpdate]);

  const removeNotif = useCallback(
    (rid: string, markNotificationsAsRead: (notifications: INotification[]) => void) => {
      seId(rid);
      markAsReadRef.current = markNotificationsAsRead;
      setUpdate(true);
    },
    [notifications, seId, markAsReadRef]
  );

  return { removeNotif };
};

export default useRemoveRoomNotif;

Can someone please help me understand why the initial implementation is not working as expected and if the workaround is necessary? Any insights or suggestions for improvement would be greatly appreciated. Thank you!

How can I add the last paragraph with the basic code

I’m trying of making the lyrics of 99 Bottles of Beer by coding by this

var beer = 99;
while (beer >= 0) {
    var words = "bottles";
    if (beer === 1) {
        words = "bottle";
    }
    console.log(beer + " " + words + " of beer on the wall, " + beer + " " + words + " of beer.Take one down and pass it around, ");
    beer--;
    if (beer === 1) {
        words = "bottle";
    }
    if (beer === 0) {
        beer = "no more";
    }
    console.log(beer + " " + words + " of beer on the wall.");
}

This is what I’ve got on the last line>>

1 bottle of beer on the wall, 1 bottle of beer.Take one down and pass it around,
no more bottle of beer on the wall.

How can i put another line said(With the N capital letter)>>

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.