1
0

creating-the-diffeditor-navigating-a-diff.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE html>
  2. <!-- THIS IS A GENERATED FILE VIA gulp generate-test-samples -->
  3. <html>
  4. <head>
  5. <base href="..">
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  7. </head>
  8. <body>
  9. <style>
  10. /*----------------------------------------SAMPLE CSS START*/
  11. /*----------------------------------------SAMPLE CSS END*/
  12. </style>
  13. <a class="loading-opts" href="playground.generated/index.html">[&lt;&lt; BACK]</a> <br/>
  14. THIS IS A GENERATED FILE VIA gulp generate-test-samples
  15. <div id="bar" style="margin-bottom: 6px;"></div>
  16. <div style="clear:both"></div>
  17. <div id="outer-container" style="width:800px;height:450px;border: 1px solid grey">
  18. <!-- ----------------------------------------SAMPLE HTML START-->
  19. <div id="container" style="height:100%;"></div>
  20. <!-- ----------------------------------------SAMPLE HTML END-->
  21. </div>
  22. <div style="clear:both"></div>
  23. <script src="../metadata.js"></script>
  24. <script src="dev-setup.js"></script>
  25. <script>
  26. loadEditor(function() {
  27. /*----------------------------------------SAMPLE JS START*/
  28. // The diff editor offers a navigator to jump between changes. Once the diff is computed the <em>next()</em> and <em>previous()</em> method allow navigation. By default setting the selection in the editor manually resets the navigation state.
  29. var originalModel = monaco.editor.createModel("just some text\n\nHello World\n\nSome more text", "text/plain");
  30. var modifiedModel = monaco.editor.createModel("just some Text\n\nHello World\n\nSome more changes", "text/plain");
  31. var diffEditor = monaco.editor.createDiffEditor(document.getElementById("container"));
  32. diffEditor.setModel({
  33. original: originalModel,
  34. modified: modifiedModel
  35. });
  36. var navi = monaco.editor.createDiffNavigator(diffEditor, {
  37. followsCaret: true, // resets the navigator state when the user selects something in the editor
  38. ignoreCharChanges: true // jump from line to line
  39. });
  40. window.setInterval(function() {
  41. navi.next();
  42. }, 2000);
  43. /*----------------------------------------SAMPLE JS END*/
  44. });
  45. </script>
  46. </body>
  47. </html>