Giter Club home page Giter Club logo

Comments (2)

pratham15541 avatar pratham15541 commented on June 20, 2024

i find solution by using module css instead of styled component

/* Editor.module.css */

.editor {
  width: 96.5vw !important;
  margin: 0 auto !important;
}

.editor, 
.editor * {
  font-family: consolas !important;
  line-height: 1 !important;
}

@media (max-width: 600px) {
  .editor {
    width: 100%;
  }
}

and my react code

import React, { useState, useEffect, useRef } from "react";
import { useSelector, useDispatch } from "react-redux";
import { setCodeForStore } from "../../../store/slices/codeSlice";
import { styled } from "@mui/system";

import AceEditor from "react-ace";
// import "ace-builds/src-noconflict/ace";
import * as modes from "../../../constants/language";
import * as themes from "../../../constants/themes";
import * as snippets from "../../../constants/snippets";
import * as workers from "../../../constants/workers";
import * as ext from "../../../constants/ext";
import * as keybindings from "../../../constants/keybinding";

import styles from "../../../assets/css/Editor.module.css";

const CodeEditor = () => {
  const selectedTheme = useSelector(
    (state) => state.themeSelector.selectedTheme
  );
  // console.log(selectedTheme);
  const selectedLanguage = useSelector(
    (state) => state.languageSelector.langSelected
  );

  const dispatch = useDispatch();

  const [code, setCode] = useState('console.log("Hello World")');

  const handleCodeChange = (newCode) => {
    try {
      console.log(newCode);
      // Perform any necessary operations on 'newCode'
      setCode(newCode); // Update the 'code' state with the new value
    } catch (error) {
      console.log(error);
    }
  };

  return (
    <>
      <AceEditor
        placeholder="Placeholder Text"
        mode={selectedLanguage}
        style={{
          marginTop: "-9px",
          height: "87.5vh",
          width: "100%",
          fontFamily: "consolas !important",
          lineHeight: "1 !important",
        }}
        theme={selectedTheme}
        className={styles.editor}
        name="blah2"
        fontSize={16}
        showPrintMargin={false}
        wrapEnabled={true}
        showGutter={true}
        highlightActiveLine={true}
        value={code}
        onChange={handleCodeChange}
        setOptions={{
          enableBasicAutocompletion: true,
          enableLiveAutocompletion: true,
          enableSnippets: true,
          showLineNumbers: true,
          tabSize: 2,
        }}
      />
    </>
  );
};

export default CodeEditor;

from react-ace.

pratham15541 avatar pratham15541 commented on June 20, 2024

this is finally closing my issue by solving self 😁😂🤣

from react-ace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.