fix passing events to react

pull/1701/head^2
yann300 3 years ago
parent 77810a8684
commit 7c76377736
  1. 6
      libs/remix-ui/editor/src/lib/actions/editor.ts
  2. 2
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -17,7 +17,7 @@ export const reducerActions = (models = initialState, action: Action) => {
const readOnly = action.payload.readOnly
if (models[uri]) return models // already existing
const model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri))
model.onDidChangeContent(() => action.payload.onDidChangeContent(uri))
model.onDidChangeContent(() => action.payload.events.onDidChangeContent(uri))
models[uri] = { language, uri, readOnly, model }
return models
}
@ -66,11 +66,11 @@ export const reducerActions = (models = initialState, action: Action) => {
}
}
export const reducerListener = (plugin, dispatch, monaco) => {
export const reducerListener = (plugin, dispatch, monaco, events) => {
plugin.on('editor', 'addModel', (value, language, uri, readOnly) => {
dispatch({
type: 'ADD_MODEL',
payload: { uri, value, language, readOnly },
payload: { uri, value, language, readOnly, events },
monaco
})
})

@ -216,7 +216,7 @@ export const EditorUI = (props: EditorUIProps) => {
function handleEditorWillMount (monaco) {
monacoRef.current = monaco
reducerListener(props.plugin, dispatch, monacoRef.current)
reducerListener(props.plugin, dispatch, monacoRef.current, props.events)
// see https://microsoft.github.io/monaco-editor/playground.html#customizing-the-appearence-exposed-colors
const backgroundColor = window.getComputedStyle(document.documentElement).getPropertyValue('--light').trim()
const infoColor = window.getComputedStyle(document.documentElement).getPropertyValue('--info').trim()

Loading…
Cancel
Save