|
@@ -1009,6 +1009,44 @@ function getCode() {
|
|
|
|
|
|
|
|
|
|
|
|
+== Hover provider example
|
|
|
+=======================JS
|
|
|
+var quoteOfTheDay = new monaco.Promise(function(c,e) {
|
|
|
+ window.parseResponse = function(rawQOD) {
|
|
|
+ c(rawQOD.data.contents.quotes[0].quote);
|
|
|
+ }
|
|
|
+ var script = document.createElement('script');
|
|
|
+ script.src='http://quotes.rest/qod.js';
|
|
|
+ document.head.appendChild(script);
|
|
|
+});
|
|
|
+
|
|
|
+monaco.languages.register({ id: 'mySpecialLanguage' });
|
|
|
+
|
|
|
+monaco.languages.registerHoverProvider('mySpecialLanguage', {
|
|
|
+ provideHover: function(model, position) {
|
|
|
+ return quoteOfTheDay.then(function(quoteText) {
|
|
|
+ return {
|
|
|
+ range: new monaco.Range(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
|
|
|
+ contents: ['**' + quoteText + '**']
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+monaco.editor.create(document.getElementById("container"), {
|
|
|
+ value: '\n\nHover over this text',
|
|
|
+ language: 'mySpecialLanguage'
|
|
|
+});
|
|
|
+
|
|
|
+=======================HTML
|
|
|
+<div id="container" style="height:100%;"></div>
|
|
|
+
|
|
|
+=======================CSS
|
|
|
+
|
|
|
+=======================END
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
== Configure JavaScript defaults
|
|
|
=======================JS
|