uiwjs / uiwjs/react-codemirror

How to use codemirrormerge on json data?.

Open
#559 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

I am working in a project requirement where i need to compare the config files from different deployment environment. I was searching for a difference editor and finalised with codemirror. My data to handle is in json format. When i load it in codemirror merge, my screen is blank with no error indication. I do not know where should i indicate the lang support. Any help here would be gr8.

import React, {useState} from 'react';
import './mergeView.css';
import CodeMirrorMerge from 'react-codemirror-merge';
import { EditorView } from 'codemirror';
import { EditorState } from '@codemirror/state';
import { githubLight, githubDark } from '@uiw/codemirror-theme-github';
import { StreamLanguage } from '@codemirror/language';
import {javascript} from '@codemirror/lang-javascript';


const Original = CodeMirrorMerge.Original;
const Modified = CodeMirrorMerge.Modified;
const original_doc = `{one: to, three: four}`;
const modified_doc = `{One: Two, Three: Four}`;

export const Example = () => {
  const [theme, setTheme] = useState('light');
  return (
    <>
    <CodeMirrorMerge theme={theme === 'light' ? githubLight : githubDark} orientation="b-a">
      <Original value={original_doc} />
      <Modified
        value={modified_doc}
        extensions={[EditorView.editable.of(false), EditorState.readOnly.of(true)]}
      />
    </CodeMirrorMerge>
    <button className="theme-btn" onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}> Change Theme </button>
    </>
  );
};

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported JSX entry point and the CodeMirrorMerge, Original, Modified, EditorView, and EditorState imports shown in the issue. Check how the merge components handle the supplied JSON data and language-related extensions; the issue is done when a JSON comparison renders instead of a blank screen.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.