Skip to content

Commit

Permalink
fix: support updating diff markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Dec 10, 2023
1 parent 72ca749 commit 32b984c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/examples/diff-source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ export function GetMarkdownInSourceMode() {
</div>
)
}

export function ChangeDiffMakrkdown() {
const ref = useRef<MDXEditorMethods>(null)
const [diffMarkdown, setDiffMarkdown] = React.useState('foo')
return (
<div className="App">
<button onClick={() => setDiffMarkdown('bar')}>Change Diff Markdown</button>
<MDXEditor
ref={ref}
onChange={(md) => console.log('change', md)}
markdown="Hello world"
plugins={[diffSourcePlugin({ viewMode: 'diff', diffMarkdown })]}
/>
<button onClick={() => console.log(ref.current?.getMarkdown())}>Get Markdown</button>
</div>
)
}
3 changes: 3 additions & 0 deletions src/plugins/diff-source/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export const [
] = realmPlugin({
id: 'diff-source',
systemSpec: diffSourceSystem,
applyParamsToSystem: (r, params?: DiffSourcePluginParams) => {
r.pubKey('diffMarkdown', params?.diffMarkdown || '')
},

init(r, params?: DiffSourcePluginParams) {
r.pubKey('diffMarkdown', params?.diffMarkdown || '')
Expand Down

0 comments on commit 32b984c

Please sign in to comment.