|
|
@ -5,14 +5,14 @@ export interface Action { |
|
|
|
type: string; |
|
|
|
type: string; |
|
|
|
payload: Record<string, any> |
|
|
|
payload: Record<string, any> |
|
|
|
monaco: any, |
|
|
|
monaco: any, |
|
|
|
editor: any |
|
|
|
editors: any[] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const initialState = {} |
|
|
|
export const initialState = {} |
|
|
|
|
|
|
|
|
|
|
|
export const reducerActions = (models = initialState, action: Action) => { |
|
|
|
export const reducerActions = (models = initialState, action: Action) => { |
|
|
|
const monaco = action.monaco |
|
|
|
const monaco = action.monaco |
|
|
|
const editors = action.editor as any[] |
|
|
|
const editors = action.editors as any[] |
|
|
|
switch (action.type) { |
|
|
|
switch (action.type) { |
|
|
|
case 'ADD_MODEL': { |
|
|
|
case 'ADD_MODEL': { |
|
|
|
if (!editors) return models |
|
|
|
if (!editors) return models |
|
|
@ -23,6 +23,7 @@ export const reducerActions = (models = initialState, action: Action) => { |
|
|
|
if (models[uri]) return models // already existing
|
|
|
|
if (models[uri]) return models // already existing
|
|
|
|
models[uri] = { language, uri, readOnly } |
|
|
|
models[uri] = { language, uri, readOnly } |
|
|
|
let model |
|
|
|
let model |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri)) |
|
|
|
model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri)) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|