mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 13:55:41 +01:00
2 lines
No EOL
3 KiB
JavaScript
2 lines
No EOL
3 KiB
JavaScript
"use strict";(self.webpackChunkmy_application=self.webpackChunkmy_application||[]).push([[2694],{2694:(t,n,e)=>{e.r(n),e.d(n,{default:()=>o});const o='var jsCode = [\n\t\'"use strict";\',\n\t"function Person(age) {",\n\t"\tif (age) {",\n\t"\t\tthis.age = age;",\n\t"\t}",\n\t"}",\n\t"Person.prototype.getAge = function () {",\n\t"\treturn this.age;",\n\t"};",\n].join("\\n");\n\nvar editor = monaco.editor.create(document.getElementById("container"), {\n\tvalue: jsCode,\n\tlanguage: "javascript",\n\tglyphMargin: true,\n\tcontextmenu: false,\n});\n\nvar decorations = editor.createDecorationsCollection([\n\t{\n\t\trange: new monaco.Range(3, 1, 3, 1),\n\t\toptions: {\n\t\t\tisWholeLine: true,\n\t\t\tclassName: "myContentClass",\n\t\t\tglyphMarginClassName: "myGlyphMarginClass",\n\t\t},\n\t},\n]);\n\n// Add a zone to make hit testing more interesting\nvar viewZoneId = null;\neditor.changeViewZones(function (changeAccessor) {\n\tvar domNode = document.createElement("div");\n\tdomNode.style.background = "lightgreen";\n\tviewZoneId = changeAccessor.addZone({\n\t\tafterLineNumber: 3,\n\t\theightInLines: 3,\n\t\tdomNode: domNode,\n\t});\n});\n\n// Add a content widget (scrolls inline with text)\nvar contentWidget = {\n\tdomNode: (function () {\n\t\tvar domNode = document.createElement("div");\n\t\tdomNode.innerHTML = "My content widget";\n\t\tdomNode.style.background = "grey";\n\t\treturn domNode;\n\t})(),\n\tgetId: function () {\n\t\treturn "my.content.widget";\n\t},\n\tgetDomNode: function () {\n\t\treturn this.domNode;\n\t},\n\tgetPosition: function () {\n\t\treturn {\n\t\t\tposition: {\n\t\t\t\tlineNumber: 7,\n\t\t\t\tcolumn: 8,\n\t\t\t},\n\t\t\tpreference: [\n\t\t\t\tmonaco.editor.ContentWidgetPositionPreference.ABOVE,\n\t\t\t\tmonaco.editor.ContentWidgetPositionPreference.BELOW,\n\t\t\t],\n\t\t};\n\t},\n};\neditor.addContentWidget(contentWidget);\n\n// Add an overlay widget\nvar overlayWidget = {\n\tdomNode: (function () {\n\t\tvar domNode = document.createElement("div");\n\t\tdomNode.innerHTML = "My overlay widget";\n\t\tdomNode.style.background = "grey";\n\t\tdomNode.style.right = "30px";\n\t\tdomNode.style.top = "50px";\n\t\treturn domNode;\n\t})(),\n\tgetId: function () {\n\t\treturn "my.overlay.widget";\n\t},\n\tgetDomNode: function () {\n\t\treturn this.domNode;\n\t},\n\tgetPosition: function () {\n\t\treturn null;\n\t},\n};\neditor.addOverlayWidget(overlayWidget);\n\nvar output = document.getElementById("output");\nfunction showEvent(str) {\n\twhile (output.childNodes.length > 6) {\n\t\toutput.removeChild(output.firstChild.nextSibling.nextSibling);\n\t}\n\toutput.appendChild(document.createTextNode(str));\n\toutput.appendChild(document.createElement("br"));\n}\n\neditor.onMouseMove(function (e) {\n\tshowEvent("mousemove - " + e.target.toString());\n});\neditor.onMouseDown(function (e) {\n\tshowEvent("mousedown - " + e.target.toString());\n});\neditor.onContextMenu(function (e) {\n\tshowEvent("contextmenu - " + e.target.toString());\n});\neditor.onMouseLeave(function (e) {\n\tshowEvent("mouseleave");\n});\n'}}]);
|
|
//# sourceMappingURL=2694.js.map
|