monkeyide v1.1.3
monkeyide
monkeyide is a small lightweight multi-tab IDE written based on CodeMirror.
Importing
To import monkeyide, run:
npm install codemirror monkeyideNow add the following into your HTML:
<script src="node_modules/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="node_modules/codemirror/lib/codemirror.css" />
<script src="node_modules/monkeyide/index.js"></script>
<link rel="stylesheet" href="node_modules/monkeyide/style.css" />monkeyide is now fully imported! If you would like to import syntax highlighting, go to https://codemirror.net/mode/, from the documentation for more information on that. Here is a link with an index of themes: https://codemirror.net/theme/. Just import a theme as: node_modules/codemirror/theme/*.css. Replace * with the theme name. For more information on CodeMirror, go to their main website. They have multiple other addons, themes, and modes.
Using
The monkeyide controls the ide object, which contains everything that you need to do when controlling the IDE programmatically:
Strings
The following are some plain strings in the ide object:
nameThe name is simply =>"monkeyide"versionThis is simply the current version ofmonkeyidelicenseThis is a string that contains =>"MIT"
Elements
buttonsBarThis element contains all of the buttons that allow the user to navigate through the code editortabsElementsThis contains the container for all of the tabs inside the code editor.
Lists
filesThis is the one list inside theideobject that contains objects. These objects are in the format:
{
mirror: CodeMirror,
name: String,
configuration: Object
}The mirror key contains the CodeMirror for that tab. The name key contains a string for the specified string that the tab should be called. The configuration key contains an object for the configuration which was specified inside the call.
Integers
currentTabThis integer contains the current tab opened.totalTabsThis is the total amount of tabs. It can also be obtained by examining thefileslist's length.limitThe limit for the number of tabs that can be opened at once. Defaults to"infinity". Will only be accepted if it is atypeofnumber
Functions
createTabThis function allows you to create a new tab for the IDE. It accepts two arguments: a string and an object. The string is the name of the tab. The object is the configuration passed intoCodeMirror.openTabThis function takes one argument, a number. That number is the index of the tab that will be opened.removeElementUsed for internal purposes to manipulate arrays.getCodeByTabA function to get the code of the tabID specified.getTabsThis returns theide.fileslist.getTabReturns the given index on theide.fileslist.removeTabRemove the tab at the specified index.removeAllRemoves all of the tabs.renameTabRenames a tab.packPacks up the given list. You can runide.pack(ide.files)to pack up everything now.largeMass create files. Takes in an object in the form:{ "name": "NAME", "configuration": { "key": "value", "value": "CODEHERE", "etc": "etc" } }
Testing
To test this program locally, run:
npm run testNow you can view the tests at http://localhost:1567/.
Contributing
Contributions are welcome!