pull/2677/head
filip mertens 3 years ago
parent 1d8f36dcb3
commit 5523be0f89
  1. 35
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -4,6 +4,7 @@ import Editor, { loader } from '@monaco-editor/react'
import { reducerActions, reducerListener, initialState } from './actions/editor' import { reducerActions, reducerListener, initialState } from './actions/editor'
import { language, conf } from './syntax' import { language, conf } from './syntax'
import { cairoLang, cairoConf } from './cairoSyntax' import { cairoLang, cairoConf } from './cairoSyntax'
import { IMarkdownString } from 'monaco-editor'
import './remix-ui-editor.css' import './remix-ui-editor.css'
import { loadTypes } from './web-types' import { loadTypes } from './web-types'
@ -39,6 +40,25 @@ type sourceMarker = {
hide: boolean hide: boolean
} }
export type lineText = {
position: {
start: {
line: number
column: number
},
end: {
line: number
column: number
}
},
from?: string // plugin name
content: string
className: string
afterContentClassName: string
hide: boolean,
hoverMessage: IMarkdownString | IMarkdownString[]
}
loader.config({ paths: { vs: 'assets/js/monaco-editor/dev/vs' } }) loader.config({ paths: { vs: 'assets/js/monaco-editor/dev/vs' } })
export type DecorationsReturn = { export type DecorationsReturn = {
@ -259,7 +279,7 @@ export const EditorUI = (props: EditorUIProps) => {
} }
}, [props.currentFile]) }, [props.currentFile])
const convertToMonacoDecoration = (decoration: sourceAnnotation | sourceMarker, typeOfDecoration: string) => { const convertToMonacoDecoration = (decoration: lineText | sourceAnnotation | sourceMarker, typeOfDecoration: string) => {
if (typeOfDecoration === 'sourceAnnotationsPerFile') { if (typeOfDecoration === 'sourceAnnotationsPerFile') {
decoration = decoration as sourceAnnotation decoration = decoration as sourceAnnotation
return { return {
@ -289,6 +309,19 @@ export const EditorUI = (props: EditorUIProps) => {
} }
} }
} }
if (typeOfDecoration === 'lineTextPerFile') {
const lineTextDecoration = decoration as lineText
return {
type: typeOfDecoration,
range: new monacoRef.current.Range(lineTextDecoration.position.start.line + 1, lineTextDecoration.position.start.column + 1, lineTextDecoration.position.start.line + 1, 1024),
options: {
after: { content: ` ${lineTextDecoration.content}`, inlineClassName: `${lineTextDecoration.className}` },
afterContentClassName: `${lineTextDecoration.afterContentClassName}`,
hoverMessage : lineTextDecoration.hoverMessage
},
}
}
} }
props.editorAPI.clearDecorationsByPlugin = (filePath: string, plugin: string, typeOfDecoration: string, registeredDecorations: any, currentDecorations: any) => { props.editorAPI.clearDecorationsByPlugin = (filePath: string, plugin: string, typeOfDecoration: string, registeredDecorations: any, currentDecorations: any) => {

Loading…
Cancel
Save