Commit 177fb686 authored by gxkai's avatar gxkai

fix: 暂时移除高亮

parent 1844a594
...@@ -51,12 +51,12 @@ class ContextualListener extends Plugin { ...@@ -51,12 +51,12 @@ class ContextualListener extends Plugin {
} }
this._buildIndex(data, source) this._buildIndex(data, source)
}) })
// todo
setInterval(() => { // setInterval(() => {
if (this._deps.compilersArtefacts.__last && this._deps.compilersArtefacts.__last.languageversion.indexOf('soljson') === 0) { // if (this._deps.compilersArtefacts.__last && this._deps.compilersArtefacts.__last.languageversion.indexOf('soljson') === 0) {
this._highlightItems(this.editor.getCursorPosition(), this._deps.compilersArtefacts.__last, this._deps.config.get('currentFile')) // this._highlightItems(this.editor.getCursorPosition(), this._deps.compilersArtefacts.__last, this._deps.config.get('currentFile'))
} // }
}, 1000) // }, 1000)
} }
getActiveHighlights () { getActiveHighlights () {
......
...@@ -5,11 +5,11 @@ import './remix-ui-editor.css' ...@@ -5,11 +5,11 @@ import './remix-ui-editor.css'
/// ///
import AceEditor from 'react-ace' import AceEditor from 'react-ace'
import "ace-builds/src-min-noconflict/ext-language_tools"; import 'ace-builds/src-min-noconflict/ext-language_tools'
import 'ace-builds/webpack-resolver' import 'ace-builds/webpack-resolver'
// Custom mode and theme import // Custom mode and theme import
import 'ace-mode-solidity/build/remix-ide/mode-solidity' import 'ace-mode-solidity/build/remix-ide/mode-solidity'
import './utils/theme-solidity'; import './utils/theme-solidity'
import { Ace } from 'ace-builds' import { Ace } from 'ace-builds'
import * as AceBuilds from 'ace-builds' import * as AceBuilds from 'ace-builds'
type cursorPosition = { type cursorPosition = {
...@@ -71,7 +71,7 @@ export interface EditorUIProps { ...@@ -71,7 +71,7 @@ export interface EditorUIProps {
findMatches: (uri: string, value: string) => any findMatches: (uri: string, value: string) => any
getFontSize: () => number, getFontSize: () => number,
getValue: (uri: string) => string getValue: (uri: string) => string
getCursorPosition: () => cursorPosition getCursorPosition: () => number
} }
} }
...@@ -142,28 +142,32 @@ export const EditorUI = (props: EditorUIProps) => { ...@@ -142,28 +142,32 @@ export const EditorUI = (props: EditorUIProps) => {
} }
} }
// todo cursor position // todo cursor position
// props.editorAPI.getCursorPosition = () => { props.editorAPI.getCursorPosition = () => {
// if (!aceRef.current) return if (!aceRef.current) return
// const model = editorModelsState[currentFileRef.current]?.model const model = editorModelsState[currentFileRef.current]?.model
// if (model) { const point = editorRef.current.getCursorPosition()
// const point = model.getCursorPosition() const offset = model.getDocument().positionToIndex(
point,
0
)
return offset
// return { // return {
// startColumn: point.column, // startColumn: point.column,
// startLineNumber: point.row, // startLineNumber: point.row,
// endColumn: point.column, // endColumn: point.column + offset,
// endLineNumber: point.row, // endLineNumber: point.row
// }
// }
// } // }
}
props.editorAPI.getFontSize = () => { props.editorAPI.getFontSize = () => {
if (!editorRef.current) return if (!editorRef.current) return
return Number(editorRef.current.getFontSize()) return Number(editorRef.current.getFontSize())
} }
function onLoad(editor: Ace.Editor) { function onLoad (editor: Ace.Editor) {
editorRef.current = editor editorRef.current = editor
reducerListener(props.plugin, dispatch, aceRef.current, editorRef.current, props.events) reducerListener(props.plugin, dispatch, aceRef.current, editorRef.current, props.events)
setTimeout(()=> { setTimeout(() => {
props.events.onEditorMounted() props.events.onEditorMounted()
}, 1000) }, 1000)
// @ts-ignore // @ts-ignore
...@@ -171,33 +175,33 @@ export const EditorUI = (props: EditorUIProps) => { ...@@ -171,33 +175,33 @@ export const EditorUI = (props: EditorUIProps) => {
const row = e.getDocumentPosition().row const row = e.getDocumentPosition().row
const target = e.domEvent.target const target = e.domEvent.target
if (target.className.indexOf("ace_gutter-cell") == -1){ if (target.className.indexOf('ace_gutter-cell') == -1) {
return; return
} }
if (!editor.isFocused()){ if (!editor.isFocused()) {
return; return
} }
if (e.clientX > 25 + target.getBoundingClientRect().left){ if (e.clientX > 25 + target.getBoundingClientRect().left) {
return; return
} }
// If there's a breakpoint already defined, it should be removed, offering the toggle feature // If there's a breakpoint already defined, it should be removed, offering the toggle feature
const breakpoints = e.editor.session.getBreakpoints() const breakpoints = e.editor.session.getBreakpoints()
const currentFile = currentFileRef.current const currentFile = currentFileRef.current
if(breakpoints[row] === undefined){ if (breakpoints[row] === undefined) {
props.events.onBreakPointAdded(currentFile, row) props.events.onBreakPointAdded(currentFile, row)
e.editor.session.setBreakpoint(row, 'ace_breakpoint'); e.editor.session.setBreakpoint(row, 'ace_breakpoint')
}else{ } else {
props.events.onBreakPointCleared(currentFile, row) props.events.onBreakPointCleared(currentFile, row)
e.editor.session.clearBreakpoint(row); e.editor.session.clearBreakpoint(row)
} }
e.stop(); e.stop()
}) })
} }
function onBeforeunload(ace: typeof AceBuilds) { function onBeforeunload (ace: typeof AceBuilds) {
aceRef.current = ace aceRef.current = ace
} }
...@@ -211,7 +215,7 @@ export const EditorUI = (props: EditorUIProps) => { ...@@ -211,7 +215,7 @@ export const EditorUI = (props: EditorUIProps) => {
enableLiveAutocompletion enableLiveAutocompletion
enableSnippets enableSnippets
editorProps={{ $blockScrolling: true }} editorProps={{ $blockScrolling: true }}
style={{lineHeight: 1.75, height: '100%', width: '100%'}} style={{ lineHeight: 1.75, height: '100%', width: '100%' }}
onLoad={onLoad} onLoad={onLoad}
onBeforeLoad={onBeforeunload} onBeforeLoad={onBeforeunload}
showGutter showGutter
......
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