dojo / dojo.io

Dojo - source for the dojo.io website
Other
17 stars 43 forks source link

Consider using monaco-editor for tutorials #45

Closed kitsonk closed 7 years ago

kitsonk commented 7 years ago

Discussion

As far as I am aware, the solutions we have for web editors for tutorials have fairly challenging limitations.

I have done a really simple POC to see how difficult it is to get the monaco-editor to work in dojo.io. Here is the output of that simple POC:

monacoexample

The code for that is as follows:

---
title: Monaco Example Tutorial
layout: tutorial
overview: An example of the `monaco-editor` as a tutorial
---

# Monaco Example Tutorial

Let's see how this goes...

<div id="container" style="height: 800px; border:1px solid grey;"></div>

<script type="text/javascript" src="/editor/monaco-editor/min/vs/loader.js"></script>
<script>
    require.config({ paths: { 'vs': '/editor/monaco-editor/min/vs' }});

    window.MonacoEnvironment = {
        getWorkerUrl: function (workerId, label) {
            return 'monaco-editor-worker-loader-proxy.js';
        }
    };

    require([ 'vs/editor/editor.main' ], function () {
        monaco.editor.create(document.getElementById('container'), {
            value: [
                'function x() {',
                '\tconsole.log("Hello world!");',
                '}'
            ].join('\n'),
            language: 'typescript'
        });
    });
</script>

And to the deployment I had to run the following:

grunt generate && rm -rf _dist/editor && cp -r site/editor _dist/editor

Path forward

If we were to create a package (e.g. @dojo/web-editor) we could inject additional opinionated way of editing/running additional Dojo 2 application on the web. Here are the high level functionality tasks I would see us needing to do:

The Future

Additional functionality that we would want but would be delivered in the future:

devpaul commented 7 years ago

We've discussed this in meetings and decided to move forward on a POC. I'm considering this closed by #71