Commit 7c763777 authored by yann300's avatar yann300

fix passing events to react

parent 77810a86
...@@ -17,7 +17,7 @@ export const reducerActions = (models = initialState, action: Action) => { ...@@ -17,7 +17,7 @@ export const reducerActions = (models = initialState, action: Action) => {
const readOnly = action.payload.readOnly const readOnly = action.payload.readOnly
if (models[uri]) return models // already existing if (models[uri]) return models // already existing
const model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri)) 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 } models[uri] = { language, uri, readOnly, model }
return models return models
} }
...@@ -66,11 +66,11 @@ export const reducerActions = (models = initialState, action: Action) => { ...@@ -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) => { plugin.on('editor', 'addModel', (value, language, uri, readOnly) => {
dispatch({ dispatch({
type: 'ADD_MODEL', type: 'ADD_MODEL',
payload: { uri, value, language, readOnly }, payload: { uri, value, language, readOnly, events },
monaco monaco
}) })
}) })
......
...@@ -216,7 +216,7 @@ export const EditorUI = (props: EditorUIProps) => { ...@@ -216,7 +216,7 @@ export const EditorUI = (props: EditorUIProps) => {
function handleEditorWillMount (monaco) { function handleEditorWillMount (monaco) {
monacoRef.current = 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 // see https://microsoft.github.io/monaco-editor/playground.html#customizing-the-appearence-exposed-colors
const backgroundColor = window.getComputedStyle(document.documentElement).getPropertyValue('--light').trim() const backgroundColor = window.getComputedStyle(document.documentElement).getPropertyValue('--light').trim()
const infoColor = window.getComputedStyle(document.documentElement).getPropertyValue('--info').trim() const infoColor = window.getComputedStyle(document.documentElement).getPropertyValue('--info').trim()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment