Skip to content

Commit

Permalink
editor in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
williamngan committed Aug 1, 2018
1 parent 039c7c4 commit df2abfa
Show file tree
Hide file tree
Showing 25 changed files with 11,460 additions and 1 deletion.
17 changes: 17 additions & 0 deletions demo/edit/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
body {
padding: 0; margin: 0;
}

iframe {
display: block;
border: none;
border-right: 1px solid #9ab;
width: 50vw;
height: 100vh;
}

#editor {
position: absolute;
top: 50px; right: 20px; left: 51%; bottom: 50px;
border: 1px solid #f1f3f7;
}
20 changes: 20 additions & 0 deletions demo/edit/frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<script type="text/javascript" src="../../dist/pts.min.js"></script>
</head>
<body>
<h1 id="test">Hello</h1>
<div id="pt"></div>

<script type="text/javascript">
function test( txt ) {
var sc = document.createElement("script");
sc.type = "text/javascript";
// sc.innerHTML = "document.querySelector('#test').textContent = ('"+txt+"')";
sc.innerHTML = txt;
document.body.appendChild( sc );
}
</script>

</body>
</html>
16 changes: 16 additions & 0 deletions demo/edit/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<script type="text/javascript" src="./js/vue.js"></script>
<link rel="stylesheet" href="./css/style.css" type="text/css" />
</head>
<body>

<iframe id="demo" title="demo" allow-scripts="true" src="./frame.html"></iframe>

<div id="editor"></div>

<script type="text/javascript" src="./js/edit.js"></script>
<script src="./vs/loader.js"></script>

</body>
</html>
42 changes: 42 additions & 0 deletions demo/edit/js/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@


document.getElementById('demo').onload = function(evt) {

if (window.frames.length > 0) {
// console.log( frames[0].document )
frames[0].document.body.style.background = "red"
frames[0].test('Pts.namespace( this ); var space = new CanvasSpace("#pt").setup({bgcolor: "#fe3"}); var form = space.getForm(); space.add( function(time) { form.point( space.pointer, 3); } ); space.bindMouse().bindTouch().play();');
}
}


var ptsdef = "";

var client = new XMLHttpRequest();
client.open('GET', '../../dist/pts.d.ts');
client.onload = function() {
console.log( client.responseText );
ptsdef = (client.responseText);
vscode();
}
client.send();

function vscode() {
require.config({ paths: { 'vs': './vs' }});
require(['vs/editor/editor.main'], function() {

monaco.languages.typescript.javascriptDefaults.addExtraLib(
ptsdef
);

window.editor = monaco.editor.create(document.getElementById('editor'), {
value: "loading...",
language: 'javascript',
theme: "vs-dark",
minimap: {
enabled: false
}
});

});
}
Loading

0 comments on commit df2abfa

Please sign in to comment.