This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 884
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New MonacoAdapter class added and plumbed into lib/firepad.js, etc. * examples/monaco.html added to demonstrate it.
- Loading branch information
1 parent
b678875
commit 251df18
Showing
7 changed files
with
422 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<!-- Firebase --> | ||
<script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script> | ||
|
||
<!-- Firepad --> | ||
<link rel="stylesheet" href="./../dist/firepad.css" /> | ||
<script src="./../dist/firepad.min.js"></script> | ||
|
||
<!-- Loader.js --> | ||
<script src="./../node_modules/monaco-editor/min/vs/loader.js"></script> | ||
|
||
<style> | ||
html { height: 100%; } | ||
body { margin: 0; height: 100%; position: relative; } | ||
/* Height / width / positioning can be customized for your use case. | ||
For demo purposes, we make firepad fill the entire browser. */ | ||
#firepad { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body onload="init()"> | ||
<div id="firepad"></div> | ||
|
||
<script> | ||
function init() { | ||
//// Initialize Firebase. | ||
//// TODO: replace with your Firebase project configuration. | ||
var config = { | ||
apiKey: "AIzaSyC_JdByNm-E1CAJUkePsr-YJZl7W77oL3g", | ||
authDomain: "firepad-tests.firebaseapp.com", | ||
databaseURL: "https://firepad-tests.firebaseio.com" | ||
}; | ||
firebase.initializeApp(config); | ||
|
||
//// Get Firebase Database reference. | ||
var firepadRef = getExampleRef(); | ||
|
||
//// Create Monaco and firepad. | ||
require.config({ paths: {'vs': './../node_modules/monaco-editor/min/vs'}}); | ||
require(['vs/editor/editor.main'], function() { | ||
editor = monaco.editor.create(document.getElementById('firepad')); | ||
Firepad.fromMonaco(firepadRef, editor); | ||
}); | ||
|
||
} | ||
|
||
// Helper to get hash from end of URL or generate a random one. | ||
function getExampleRef() { | ||
var ref = firebase.database().ref(); | ||
var hash = window.location.hash.replace(/#/g, ''); | ||
if (hash) { | ||
ref = ref.child(hash); | ||
} else { | ||
ref = ref.push(); // generate unique location. | ||
window.location = window.location + '#' + ref.key; // add it as a hash to the URL. | ||
} | ||
if (typeof console !== 'undefined') { | ||
console.log('Firebase data: ', ref.toString()); | ||
} | ||
return ref; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.