mdx-editor / editor

A rich text editor React component for markdown
https://mdxeditor.dev
MIT License
1.75k stars 139 forks source link

Add readOnlyDiff parameter to diffSourcePlugin #374

Closed StanlieK closed 6 months ago

StanlieK commented 6 months ago

This PR will add read-only functionality to diff mode.

You can enable the read-only mode for the diff viewer in two ways:

  1. Use the readOnly flag on the MDXEditor - this makes the entire editor read-only, including both the source and rich-text modes.
  2. Use the readOnlyDiff flag on the diffSourcePlugin - this makes only the diff mode read-only.

For example, the code below will display the differences but prevent code editing in diff view:

<MDXEditor
  markdown={'hello world'}
  plugins={[
    diffSourcePlugin({
      diffMarkdown: 'An older version',
      viewMode: 'diff',
      readOnlyDiff: true
    })
  ]}
/>

And this code will prevent any code changes in any mode:

<MDXEditor
  markdown={'hello world'}
  readOnly={true}
  plugins={[
    diffSourcePlugin({
      diffMarkdown: 'An older version',
      viewMode: 'diff'
    })
  ]}
/>
github-actions[bot] commented 6 months ago

:tada: This PR is included in version 2.11.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: