uiwjs / uiwjs/react-codemirror

React codemirror merge doesn't work in shadow dom

Open
#734 1 comment 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 think the styles are injected in the main document, not in the shadow dom. Below is the code i am using

import CodeMirrorMerge from "react-codemirror-merge";
import { EditorView } from "@codemirror/view";
import { EditorState } from "@codemirror/state";
import React from "react";
import { javascript } from "@codemirror/lang-javascript";

const Original = CodeMirrorMerge.Original;
const Modified = CodeMirrorMerge.Modified;

interface ShowDiffProps {
  original: string;
  modified: string;
}

const ShowDiff: React.FC<ShowDiffProps> = ({ original, modified }) => {
  return (
    <CodeMirrorMerge orientation="b-a" theme={"light"}>
      <Original value={original} extensions={[javascript({ jsx: true })]} />
      <Modified
        value={modified}
        extensions={[
          EditorView.editable.of(false),
          EditorState.readOnly.of(true),
          javascript({
            jsx: true,
          }),
        ]}
      />
    </CodeMirrorMerge>
  );
};

export default ShowDiff;

I think, we will have to expose the root prop from the codemirror-merge's MergeView

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 provided ShowDiff reproduction and inspect react-codemirror-merge's MergeView, focusing on where its styles are injected and how a root prop could be exposed. Done means the CodeMirror Merge styles are available inside the consuming shadow DOM without breaking the existing React usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.