From 03fcfe4709a3001c77fea50501101dcf93070b64 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 14 Feb 2022 20:25:53 +0100 Subject: [PATCH] editor --- apps/remix-ide/src/app/editor/editor.js | 56 ++++++++++++++++++------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index 3416af663c..2e2de4b8cc 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -4,6 +4,7 @@ import ReactDOM from 'react-dom' import { EditorUI } from '@remix-ui/editor' // eslint-disable-line import { Plugin } from '@remixproject/engine' import * as packageJson from '../../../../../package.json' +import { ViewPluginUI } from '../plugins/ViewPluginUI' const EventManager = require('../../lib/events') @@ -62,15 +63,39 @@ class Editor extends Plugin { // to be implemented by the react component this.api = {} this.dispatch = null + this.ref = null } setDispatch (dispatch) { this.dispatch = dispatch - this.renderComponent() + + this.ref.currentContent = () => this.currentContent() // used by e2e test + this.ref.setCurrentContent = (value) => { + if (this.sessions[this.currentFile]) { + this.sessions[this.currentFile].setValue(value) + this._onChange(this.currentFile) + } + } + this.ref.gotoLine = (line, column) => this.gotoLine(line, column || 0) + this.ref.getCursorPosition = () => this.getCursorPosition() + } + + updateComponent(state) { + console.log(state) + return } render () { - if (this.el) return this.el + +/* if (this.el) return this.el this.el = document.createElement('div') this.el.setAttribute('id', 'editorView') @@ -82,22 +107,23 @@ class Editor extends Plugin { } } this.el.gotoLine = (line, column) => this.gotoLine(line, column || 0) - this.el.getCursorPosition = () => this.getCursorPosition() - return this.el + this.el.getCursorPosition = () => this.getCursorPosition() */ + + return
{ this.ref = element}} id='editorView'> + +
} renderComponent () { - ReactDOM.render( - - , this.el) + this.dispatch({ + api: this.api, + currentThemeType: this.currentThemeType, + currentFile: this.currentFile, + sourceAnnotationsPerFile: this.sourceAnnotationsPerFile, + markerPerFile: this.markerPerFile, + events: this.events, + plugin: this + }) } triggerEvent (name, params) {