Showing preview only (2,206K chars total). Download the full file or copy to clipboard to get everything.
Repository: sparksuite/simplemde-markdown-editor
Branch: master
Commit: 6abda7ab68cc
Files: 15
Total size: 2.1 MB
Directory structure:
gitextract_bzego8h5/
├── .eslintrc
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── bower.json
├── debug/
│ ├── simplemde.css
│ ├── simplemde.debug.js
│ └── simplemde.js
├── gulpfile.js
├── package.json
└── src/
├── css/
│ └── simplemde.css
└── js/
├── codemirror/
│ └── tablist.js
└── simplemde.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc
================================================
{
"rules": {
"indent": [
2,
"tab"
],
"strict": 0,
"no-console": 0,
"quotes": [
2,
"double"
],
"semi": [
2,
"always"
]
},
"env": {
"browser": true,
"node":true
},
"extends": "eslint:recommended"
}
================================================
FILE: .gitignore
================================================
localtesting/
node_modules/
bower_components/
#For IDE
*.iml
*.ipr
*.iws
.idea/
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- '6'
- '5'
- '4'
- '0.12'
before_script:
- npm install -g gulp
script: gulp
deploy:
provider: npm
email: support@nextstepwebs.com
api_key:
secure: nADZupyOhJAhTQgr5uOIydbDEjCTAj+3nGHW7ZBJUrVJcb0uR4pg8ngmwrUpvaCeNXgKPG9Uag75/mPcBre9ly2cigBIG9LHlxImlF8qi1jRJykcNRmBb9N2MJJj+zdAMwLaF5Ns+f2v3zt97qxovbEzunhXGcZeCaxc6y40nDM8OTyo0PESNBjQYqaNblt2gO2KHysrwFL8i4kCCKLa+HOBLu2iqgk/fYVqTmfhEeOiiwQ4lIXJeyPyzgb3OPhKCMV1FI5H0T48fRD0MPczt8ds3Daj1OjCbIZurQ7s1dcKwz1g6TKATN59HcMsSarW4lImrEeYmfQxz2F5NjKDRhnith5V0W2IssrkpDG9teTFQ20eQdl5cpnlGjgBvsjb8GhPLR44GvefyJL4+kJGI3O1KVq3/7wbmu/IXrvhtKHEQSdGL2PTqW8QxKasAoUCnk3LGZKN12g8bg0xDg2tvoCUk5Z3asHLRdCJpDbBq1h8QfZ4HV5VLYjr84xduOUZbEUtfMVAixPpJ4h1E3OXJ1wil97BlHjxOZ8JkkxJg5lgSUZ/O/QWwJokEAYXR9c+ouMoVokChAyleV77cRZ5qLn9zbnUxZtnKX8w0IUKeu95/z8QgiaRcERKVCpZvceo8Qw0Y+JoiEtno7Zg/nsrZGxsS6K/V3yg1QQmT3bjDHQ=
on:
tags: true
repo: NextStepWebs/simplemde-markdown-editor
branch: production
================================================
FILE: CONTRIBUTING.md
================================================
### Overview
First of all, thanks for your interest in helping make SimpleMDE even better. Contributions help resolve rare bugs, accomplish neat new features, polish the code, and improve the documentation.
### Guidelines for contributing
- The *most important* guideline for contributing is to compare against the `development` branch when creating a pull request. This allows time to test and modify code changes before merging them into the stable master branch with the next release.
- Travis CI is configured to build and verify all PRs. If your PR causes the build to fail, please add an additional commit that resolves any problems.
- If you really want to earn some brownie points, create a JSFiddle that demonstrates your code changes. Seriously, this helps immensely and allows one or multiple people to easily provide feedback on the great work you've done.
- When creating the JSFiddle, keep in mind that you can use http://rawgit.com for your files.
- Do your best to fully test your changes. Anticipate edge-case behavior.
- Try to keep your codebase that you're making changes to as up-to-date as possible with the origin. SimpleMDE creates new releases frequently, so it's easy to fall behind if you've been working on something new for a while.
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 Next Step Webs, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# SimpleMDE - Markdown Editor
A drop-in JavaScript textarea replacement for writing beautiful and understandable Markdown. The WYSIWYG-esque editor allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts. In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc. SimpleMDE is one of the first editors to feature both built-in autosaving and spell checking.
[**Demo**](https://simplemde.com)
[](https://simplemde.com)
## Why not a WYSIWYG editor or pure Markdown?
WYSIWYG editors that produce HTML are often complex and buggy. Markdown solves this problem in many ways, plus Markdown can be rendered natively on more platforms than HTML. However, Markdown is not a syntax that an average user will be familiar with, nor is it visually clear while editing. In otherwords, for an unfamiliar user, the syntax they write will make little sense until they click the preview button. SimpleMDE has been designed to bridge this gap for non-technical users who are less familiar with or just learning Markdown syntax.
## Install
Via [npm](https://www.npmjs.com/package/simplemde).
```
npm install simplemde --save
```
Via [bower](https://www.bower.io).
```
bower install simplemde --save
```
Via [jsDelivr](https://www.jsdelivr.com/#!simplemde). *Please note, jsDelivr may take a few days to update to the latest release.*
```HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
```
## Quick start
After installing, load SimpleMDE on the first textarea on a page
```HTML
<script>
var simplemde = new SimpleMDE();
</script>
```
#### Using a specific textarea
Pure JavaScript method
```HTML
<script>
var simplemde = new SimpleMDE({ element: document.getElementById("MyID") });
</script>
```
jQuery method
```HTML
<script>
var simplemde = new SimpleMDE({ element: $("#MyID")[0] });
</script>
```
## Get/set the content
```JavaScript
simplemde.value();
```
```JavaScript
simplemde.value("This text will appear in the editor");
```
## Configuration
- **autoDownloadFontAwesome**: If set to `true`, force downloads Font Awesome (used for icons). If set to `false`, prevents downloading. Defaults to `undefined`, which will intelligently check whether Font Awesome has already been included, then download accordingly.
- **autofocus**: If set to `true`, autofocuses the editor. Defaults to `false`.
- **autosave**: *Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted.*
- **enabled**: If set to `true`, autosave the text. Defaults to `false`.
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
- **uniqueId**: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website.
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
- **bold** Can be set to `**` or `__`. Defaults to `**`.
- **code** Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
- **italic** Can be set to `*` or `_`. Defaults to `*`.
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`.
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
- **initialValue**: If set, will customize the initial value of the editor.
- **insertTexts**: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: `["[", "](http://)"]`.
- horizontalRule
- image
- link
- table
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
- **placeholder**: Custom placeholder that should be displayed
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
- **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
- Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
- **tabSize**: If set, customize the tab size. Defaults to `2`.
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
```JavaScript
// Most options demonstrate the non-default behavior
var simplemde = new SimpleMDE({
autofocus: true,
autosave: {
enabled: true,
uniqueId: "MyUniqueID",
delay: 1000,
},
blockStyles: {
bold: "__",
italic: "_"
},
element: document.getElementById("MyID"),
forceSync: true,
hideIcons: ["guide", "heading"],
indentWithTabs: false,
initialValue: "Hello world!",
insertTexts: {
horizontalRule: ["", "\n\n-----\n\n"],
image: [""],
link: ["[", "](http://)"],
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
},
lineWrapping: false,
parsingConfig: {
allowAtxHeaderWithoutSpace: true,
strikethrough: false,
underscoresBreakWords: true,
},
placeholder: "Type here...",
previewRender: function(plainText) {
return customMarkdownParser(plainText); // Returns HTML from a custom parser
},
previewRender: function(plainText, preview) { // Async method
setTimeout(function(){
preview.innerHTML = customMarkdownParser(plainText);
}, 250);
return "Loading...";
},
promptURLs: true,
renderingConfig: {
singleLineBreaks: false,
codeSyntaxHighlighting: true,
},
shortcuts: {
drawTable: "Cmd-Alt-T"
},
showIcons: ["code", "table"],
spellChecker: false,
status: false,
status: ["autosave", "lines", "words", "cursor"], // Optional usage
status: ["autosave", "lines", "words", "cursor", {
className: "keystrokes",
defaultValue: function(el) {
this.keystrokes = 0;
el.innerHTML = "0 Keystrokes";
},
onUpdate: function(el) {
el.innerHTML = ++this.keystrokes + " Keystrokes";
}
}], // Another optional usage, with a custom status bar item that counts keystrokes
styleSelectedText: false,
tabSize: 4,
toolbar: false,
toolbarTips: false,
});
```
#### Toolbar icons
Below are the built-in toolbar icons (only some of which are enabled by default), which can be reorganized however you like. "Name" is the name of the icon, referenced in the JS. "Action" is either a function or a URL to open. "Class" is the class given to the icon. "Tooltip" is the small tooltip that appears via the `title=""` attribute. Note that shortcut hints are added automatically and reflect the specified action if it has a keybind assigned to it (i.e. with the value of `action` set to `bold` and that of `tooltip` set to `Bold`, the final text the user will see would be "Bold (Ctrl-B)").
Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
Name | Action | Tooltip<br>Class
:--- | :----- | :--------------
bold | toggleBold | Bold<br>fa fa-bold
italic | toggleItalic | Italic<br>fa fa-italic
strikethrough | toggleStrikethrough | Strikethrough<br>fa fa-strikethrough
heading | toggleHeadingSmaller | Heading<br>fa fa-header
heading-smaller | toggleHeadingSmaller | Smaller Heading<br>fa fa-header
heading-bigger | toggleHeadingBigger | Bigger Heading<br>fa fa-lg fa-header
heading-1 | toggleHeading1 | Big Heading<br>fa fa-header fa-header-x fa-header-1
heading-2 | toggleHeading2 | Medium Heading<br>fa fa-header fa-header-x fa-header-2
heading-3 | toggleHeading3 | Small Heading<br>fa fa-header fa-header-x fa-header-3
code | toggleCodeBlock | Code<br>fa fa-code
quote | toggleBlockquote | Quote<br>fa fa-quote-left
unordered-list | toggleUnorderedList | Generic List<br>fa fa-list-ul
ordered-list | toggleOrderedList | Numbered List<br>fa fa-list-ol
clean-block | cleanBlock | Clean block<br>fa fa-eraser fa-clean-block
link | drawLink | Create Link<br>fa fa-link
image | drawImage | Insert Image<br>fa fa-picture-o
table | drawTable | Insert Table<br>fa fa-table
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
preview | togglePreview | Toggle Preview<br>fa fa-eye no-disable
side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disable no-mobile
fullscreen | toggleFullScreen | Toggle Fullscreen<br>fa fa-arrows-alt no-disable no-mobile
guide | [This link](https://simplemde.com/markdown-guide) | Markdown Guide<br>fa fa-question-circle
Customize the toolbar using the `toolbar` option like:
```JavaScript
// Customize only the order of existing buttons
var simplemde = new SimpleMDE({
toolbar: ["bold", "italic", "heading", "|", "quote"],
});
// Customize all information and/or add your own icons
var simplemde = new SimpleMDE({
toolbar: [{
name: "bold",
action: SimpleMDE.toggleBold,
className: "fa fa-bold",
title: "Bold",
},
{
name: "custom",
action: function customFunction(editor){
// Add your own code
},
className: "fa fa-star",
title: "Custom Button",
},
"|", // Separator
...
],
});
```
#### Keyboard shortcuts
SimpleMDE comes with an array of predefined keyboard shortcuts, but they can be altered with a configuration option. The list of default ones is as follows:
Shortcut | Action
:------- | :-----
*Cmd-'* | "toggleBlockquote"
*Cmd-B* | "toggleBold"
*Cmd-E* | "cleanBlock"
*Cmd-H* | "toggleHeadingSmaller"
*Cmd-I* | "toggleItalic"
*Cmd-K* | "drawLink"
*Cmd-L* | "toggleUnorderedList"
*Cmd-P* | "togglePreview"
*Cmd-Alt-C* | "toggleCodeBlock"
*Cmd-Alt-I* | "drawImage"
*Cmd-Alt-L* | "toggleOrderedList"
*Shift-Cmd-H* | "toggleHeadingBigger"
*F9* | "toggleSideBySide"
*F11* | "toggleFullScreen"
Here is how you can change a few, while leaving others untouched:
```JavaScript
var simplemde = new SimpleMDE({
shortcuts: {
"toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList
"toggleCodeBlock": null, // unbind Ctrl-Alt-C
"drawTable": "Cmd-Alt-T" // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut
}
});
```
Shortcuts are automatically converted between platforms. If you define a shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely, a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users.
The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons).
#### Height
To change the minimum height (before it starts auto-growing):
```CSS
.CodeMirror, .CodeMirror-scroll {
min-height: 200px;
}
```
Or, you can keep the height static:
```CSS
.CodeMirror {
height: 300px;
}
```
## Event handling
You can catch the following list of events: https://codemirror.net/doc/manual.html#events
```JavaScript
var simplemde = new SimpleMDE();
simplemde.codemirror.on("change", function(){
console.log(simplemde.value());
});
```
## Removing SimpleMDE from textarea
You can revert to the initial textarea by calling the `toTextArea` method. Note that this clears up the autosave (if enabled) associated with it. The textarea will retain any text from the destroyed SimpleMDE instance.
```JavaScript
var simplemde = new SimpleMDE();
...
simplemde.toTextArea();
simplemde = null;
```
## Useful methods
The following self-explanatory methods may be of use while developing with SimpleMDE.
```js
var simplemde = new SimpleMDE();
simplemde.isPreviewActive(); // returns boolean
simplemde.isSideBySideActive(); // returns boolean
simplemde.isFullscreenActive(); // returns boolean
simplemde.clearAutosavedValue(); // no returned value
```
## How it works
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io).
CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GFM.
================================================
FILE: bower.json
================================================
{
"name": "simplemde",
"version": "1.11.2",
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
"authors": [
"Wes Cossick <https://wescossick.com>"
],
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor.",
"main": ["src/js/simplemde.js", "src/css/simplemde.css"],
"keywords": [
"embeddable",
"markdown",
"editor",
"javascript",
"wysiwyg"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components"
]
}
================================================
FILE: debug/simplemde.css
================================================
/**
* simplemde v1.11.2
* Copyright Next Step Webs, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
* @license MIT
*/
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-ruler {
border-left: 1px solid #ccc;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3 {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px;
/* Hack to make IE7 behave */
*zoom:1;
*display:inline;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
overflow: auto;
}
.CodeMirror-widget {}
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor { position: absolute; }
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
.CodeMirror span { *vertical-align: text-bottom; }
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }
.CodeMirror {
height: auto;
min-height: 300px;
border: 1px solid #ddd;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
padding: 10px;
font: inherit;
z-index: 1;
}
.CodeMirror-scroll {
min-height: 300px
}
.CodeMirror-fullscreen {
background: #fff;
position: fixed !important;
top: 50px;
left: 0;
right: 0;
bottom: 0;
height: auto;
z-index: 9;
}
.CodeMirror-sided {
width: 50% !important;
}
.editor-toolbar {
position: relative;
opacity: .6;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
padding: 0 10px;
border-top: 1px solid #bbb;
border-left: 1px solid #bbb;
border-right: 1px solid #bbb;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.editor-toolbar:after,
.editor-toolbar:before {
display: block;
content: ' ';
height: 1px;
}
.editor-toolbar:before {
margin-bottom: 8px
}
.editor-toolbar:after {
margin-top: 8px
}
.editor-toolbar:hover,
.editor-wrapper input.title:focus,
.editor-wrapper input.title:hover {
opacity: .8
}
.editor-toolbar.fullscreen {
width: 100%;
height: 50px;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
padding-top: 10px;
padding-bottom: 10px;
box-sizing: border-box;
background: #fff;
border: 0;
position: fixed;
top: 0;
left: 0;
opacity: 1;
z-index: 9;
}
.editor-toolbar.fullscreen::before {
width: 20px;
height: 50px;
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
}
.editor-toolbar.fullscreen::after {
width: 20px;
height: 50px;
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
position: fixed;
top: 0;
right: 0;
margin: 0;
padding: 0;
}
.editor-toolbar a {
display: inline-block;
text-align: center;
text-decoration: none!important;
color: #2c3e50!important;
width: 30px;
height: 30px;
margin: 0;
border: 1px solid transparent;
border-radius: 3px;
cursor: pointer;
}
.editor-toolbar a.active,
.editor-toolbar a:hover {
background: #fcfcfc;
border-color: #95a5a6;
}
.editor-toolbar a:before {
line-height: 30px
}
.editor-toolbar i.separator {
display: inline-block;
width: 0;
border-left: 1px solid #d9d9d9;
border-right: 1px solid #fff;
color: transparent;
text-indent: -10px;
margin: 0 6px;
}
.editor-toolbar a.fa-header-x:after {
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 65%;
vertical-align: text-bottom;
position: relative;
top: 2px;
}
.editor-toolbar a.fa-header-1:after {
content: "1";
}
.editor-toolbar a.fa-header-2:after {
content: "2";
}
.editor-toolbar a.fa-header-3:after {
content: "3";
}
.editor-toolbar a.fa-header-bigger:after {
content: "▲";
}
.editor-toolbar a.fa-header-smaller:after {
content: "▼";
}
.editor-toolbar.disabled-for-preview a:not(.no-disable) {
pointer-events: none;
background: #fff;
border-color: transparent;
text-shadow: inherit;
}
@media only screen and (max-width: 700px) {
.editor-toolbar a.no-mobile {
display: none;
}
}
.editor-statusbar {
padding: 8px 10px;
font-size: 12px;
color: #959694;
text-align: right;
}
.editor-statusbar span {
display: inline-block;
min-width: 4em;
margin-left: 1em;
}
.editor-statusbar .lines:before {
content: 'lines: '
}
.editor-statusbar .words:before {
content: 'words: '
}
.editor-statusbar .characters:before {
content: 'characters: '
}
.editor-preview {
padding: 10px;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: #fafafa;
z-index: 7;
overflow: auto;
display: none;
box-sizing: border-box;
}
.editor-preview-side {
padding: 10px;
position: fixed;
bottom: 0;
width: 50%;
top: 50px;
right: 0;
background: #fafafa;
z-index: 9;
overflow: auto;
display: none;
box-sizing: border-box;
border: 1px solid #ddd;
}
.editor-preview-active-side {
display: block
}
.editor-preview-active {
display: block
}
.editor-preview>p,
.editor-preview-side>p {
margin-top: 0
}
.editor-preview pre,
.editor-preview-side pre {
background: #eee;
margin-bottom: 10px;
}
.editor-preview table td,
.editor-preview table th,
.editor-preview-side table td,
.editor-preview-side table th {
border: 1px solid #ddd;
padding: 5px;
}
.CodeMirror .CodeMirror-code .cm-tag {
color: #63a35c;
}
.CodeMirror .CodeMirror-code .cm-attribute {
color: #795da3;
}
.CodeMirror .CodeMirror-code .cm-string {
color: #183691;
}
.CodeMirror .CodeMirror-selected {
background: #d9d9d9;
}
.CodeMirror .CodeMirror-code .cm-header-1 {
font-size: 200%;
line-height: 200%;
}
.CodeMirror .CodeMirror-code .cm-header-2 {
font-size: 160%;
line-height: 160%;
}
.CodeMirror .CodeMirror-code .cm-header-3 {
font-size: 125%;
line-height: 125%;
}
.CodeMirror .CodeMirror-code .cm-header-4 {
font-size: 110%;
line-height: 110%;
}
.CodeMirror .CodeMirror-code .cm-comment {
background: rgba(0, 0, 0, .05);
border-radius: 2px;
}
.CodeMirror .CodeMirror-code .cm-link {
color: #7f8c8d;
}
.CodeMirror .CodeMirror-code .cm-url {
color: #aab2b3;
}
.CodeMirror .CodeMirror-code .cm-strikethrough {
text-decoration: line-through;
}
.CodeMirror .CodeMirror-placeholder {
opacity: .5;
}
.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word) {
background: rgba(255, 0, 0, .15);
}
================================================
FILE: debug/simplemde.debug.js
================================================
/**
* simplemde v1.11.2
* Copyright Next Step Webs, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
* @license MIT
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SimpleMDE = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict'
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
function init () {
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (var i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i]
revLookup[code.charCodeAt(i)] = i
}
revLookup['-'.charCodeAt(0)] = 62
revLookup['_'.charCodeAt(0)] = 63
}
init()
function toByteArray (b64) {
var i, j, l, tmp, placeHolders, arr
var len = b64.length
if (len % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// the number of equal signs (place holders)
// if there are two placeholders, than the two characters before it
// represent one byte
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
// base64 is 4/3 + up to two characters of the original data
arr = new Arr(len * 3 / 4 - placeHolders)
// if there are placeholders, only get up to the last complete 4 chars
l = placeHolders > 0 ? len - 4 : len
var L = 0
for (i = 0, j = 0; i < l; i += 4, j += 3) {
tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
arr[L++] = (tmp >> 16) & 0xFF
arr[L++] = (tmp >> 8) & 0xFF
arr[L++] = tmp & 0xFF
}
if (placeHolders === 2) {
tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
arr[L++] = tmp & 0xFF
} else if (placeHolders === 1) {
tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
arr[L++] = (tmp >> 8) & 0xFF
arr[L++] = tmp & 0xFF
}
return arr
}
function tripletToBase64 (num) {
return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
}
function encodeChunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
output.push(tripletToBase64(tmp))
}
return output.join('')
}
function fromByteArray (uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var output = ''
var parts = []
var maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 1) {
tmp = uint8[len - 1]
output += lookup[tmp >> 2]
output += lookup[(tmp << 4) & 0x3F]
output += '=='
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
output += lookup[tmp >> 10]
output += lookup[(tmp >> 4) & 0x3F]
output += lookup[(tmp << 2) & 0x3F]
output += '='
}
parts.push(output)
return parts.join('')
}
},{}],2:[function(require,module,exports){
},{}],3:[function(require,module,exports){
(function (global){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
/* eslint-disable no-proto */
'use strict'
var base64 = require('base64-js')
var ieee754 = require('ieee754')
var isArray = require('isarray')
exports.Buffer = Buffer
exports.SlowBuffer = SlowBuffer
exports.INSPECT_MAX_BYTES = 50
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Use Object implementation (most compatible, even IE6)
*
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
* Opera 11.6+, iOS 4.2+.
*
* Due to various browser bugs, sometimes the Object implementation will be used even
* when the browser supports typed arrays.
*
* Note:
*
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
*
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
*
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
* incorrect length in some situations.
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
* get the Object implementation, which is slower but behaves correctly.
*/
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
? global.TYPED_ARRAY_SUPPORT
: typedArraySupport()
/*
* Export kMaxLength after typed array support is determined.
*/
exports.kMaxLength = kMaxLength()
function typedArraySupport () {
try {
var arr = new Uint8Array(1)
arr.foo = function () { return 42 }
return arr.foo() === 42 && // typed array instances can be augmented
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
}
function kMaxLength () {
return Buffer.TYPED_ARRAY_SUPPORT
? 0x7fffffff
: 0x3fffffff
}
function createBuffer (that, length) {
if (kMaxLength() < length) {
throw new RangeError('Invalid typed array length')
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = new Uint8Array(length)
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
if (that === null) {
that = new Buffer(length)
}
that.length = length
}
return that
}
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
function Buffer (arg, encodingOrOffset, length) {
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
return new Buffer(arg, encodingOrOffset, length)
}
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new Error(
'If encoding is specified then the first argument must be a string'
)
}
return allocUnsafe(this, arg)
}
return from(this, arg, encodingOrOffset, length)
}
Buffer.poolSize = 8192 // not used by this implementation
// TODO: Legacy, not needed anymore. Remove in next major version.
Buffer._augment = function (arr) {
arr.__proto__ = Buffer.prototype
return arr
}
function from (that, value, encodingOrOffset, length) {
if (typeof value === 'number') {
throw new TypeError('"value" argument must not be a number')
}
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
return fromArrayBuffer(that, value, encodingOrOffset, length)
}
if (typeof value === 'string') {
return fromString(that, value, encodingOrOffset)
}
return fromObject(that, value)
}
/**
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
* if value is a number.
* Buffer.from(str[, encoding])
* Buffer.from(array)
* Buffer.from(buffer)
* Buffer.from(arrayBuffer[, byteOffset[, length]])
**/
Buffer.from = function (value, encodingOrOffset, length) {
return from(null, value, encodingOrOffset, length)
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array
if (typeof Symbol !== 'undefined' && Symbol.species &&
Buffer[Symbol.species] === Buffer) {
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
Object.defineProperty(Buffer, Symbol.species, {
value: null,
configurable: true
})
}
}
function assertSize (size) {
if (typeof size !== 'number') {
throw new TypeError('"size" argument must be a number')
}
}
function alloc (that, size, fill, encoding) {
assertSize(size)
if (size <= 0) {
return createBuffer(that, size)
}
if (fill !== undefined) {
// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpretted as a start offset.
return typeof encoding === 'string'
? createBuffer(that, size).fill(fill, encoding)
: createBuffer(that, size).fill(fill)
}
return createBuffer(that, size)
}
/**
* Creates a new filled Buffer instance.
* alloc(size[, fill[, encoding]])
**/
Buffer.alloc = function (size, fill, encoding) {
return alloc(null, size, fill, encoding)
}
function allocUnsafe (that, size) {
assertSize(size)
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) {
for (var i = 0; i < size; i++) {
that[i] = 0
}
}
return that
}
/**
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
* */
Buffer.allocUnsafe = function (size) {
return allocUnsafe(null, size)
}
/**
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
*/
Buffer.allocUnsafeSlow = function (size) {
return allocUnsafe(null, size)
}
function fromString (that, string, encoding) {
if (typeof encoding !== 'string' || encoding === '') {
encoding = 'utf8'
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError('"encoding" must be a valid string encoding')
}
var length = byteLength(string, encoding) | 0
that = createBuffer(that, length)
that.write(string, encoding)
return that
}
function fromArrayLike (that, array) {
var length = checked(array.length) | 0
that = createBuffer(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
function fromArrayBuffer (that, array, byteOffset, length) {
array.byteLength // this throws if `array` is not a valid ArrayBuffer
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('\'offset\' is out of bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('\'length\' is out of bounds')
}
if (length === undefined) {
array = new Uint8Array(array, byteOffset)
} else {
array = new Uint8Array(array, byteOffset, length)
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = array
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
that = fromArrayLike(that, array)
}
return that
}
function fromObject (that, obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0
that = createBuffer(that, len)
if (that.length === 0) {
return that
}
obj.copy(that, 0, 0, len)
return that
}
if (obj) {
if ((typeof ArrayBuffer !== 'undefined' &&
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
return createBuffer(that, 0)
}
return fromArrayLike(that, obj)
}
if (obj.type === 'Buffer' && isArray(obj.data)) {
return fromArrayLike(that, obj.data)
}
}
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
}
function checked (length) {
// Note: cannot use `length < kMaxLength` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= kMaxLength()) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength().toString(16) + ' bytes')
}
return length | 0
}
function SlowBuffer (length) {
if (+length != length) { // eslint-disable-line eqeqeq
length = 0
}
return Buffer.alloc(+length)
}
Buffer.isBuffer = function isBuffer (b) {
return !!(b != null && b._isBuffer)
}
Buffer.compare = function compare (a, b) {
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new TypeError('Arguments must be Buffers')
}
if (a === b) return 0
var x = a.length
var y = b.length
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
if (a[i] !== b[i]) {
x = a[i]
y = b[i]
break
}
}
if (x < y) return -1
if (y < x) return 1
return 0
}
Buffer.isEncoding = function isEncoding (encoding) {
switch (String(encoding).toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'binary':
case 'base64':
case 'raw':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return true
default:
return false
}
}
Buffer.concat = function concat (list, length) {
if (!isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
if (list.length === 0) {
return Buffer.alloc(0)
}
var i
if (length === undefined) {
length = 0
for (i = 0; i < list.length; i++) {
length += list[i].length
}
}
var buffer = Buffer.allocUnsafe(length)
var pos = 0
for (i = 0; i < list.length; i++) {
var buf = list[i]
if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers')
}
buf.copy(buffer, pos)
pos += buf.length
}
return buffer
}
function byteLength (string, encoding) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
string = '' + string
}
var len = string.length
if (len === 0) return 0
// Use a for loop to avoid recursion
var loweredCase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'binary':
// Deprecated
case 'raw':
case 'raws':
return len
case 'utf8':
case 'utf-8':
case undefined:
return utf8ToBytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64ToBytes(string).length
default:
if (loweredCase) return utf8ToBytes(string).length // assume utf8
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
Buffer.byteLength = byteLength
function slowToString (encoding, start, end) {
var loweredCase = false
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if (start === undefined || start < 0) {
start = 0
}
// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if (start > this.length) {
return ''
}
if (end === undefined || end > this.length) {
end = this.length
}
if (end <= 0) {
return ''
}
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
end >>>= 0
start >>>= 0
if (end <= start) {
return ''
}
if (!encoding) encoding = 'utf8'
while (true) {
switch (encoding) {
case 'hex':
return hexSlice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8Slice(this, start, end)
case 'ascii':
return asciiSlice(this, start, end)
case 'binary':
return binarySlice(this, start, end)
case 'base64':
return base64Slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leSlice(this, start, end)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = (encoding + '').toLowerCase()
loweredCase = true
}
}
}
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
// Buffer instances.
Buffer.prototype._isBuffer = true
function swap (b, n, m) {
var i = b[n]
b[n] = b[m]
b[m] = i
}
Buffer.prototype.swap16 = function swap16 () {
var len = this.length
if (len % 2 !== 0) {
throw new RangeError('Buffer size must be a multiple of 16-bits')
}
for (var i = 0; i < len; i += 2) {
swap(this, i, i + 1)
}
return this
}
Buffer.prototype.swap32 = function swap32 () {
var len = this.length
if (len % 4 !== 0) {
throw new RangeError('Buffer size must be a multiple of 32-bits')
}
for (var i = 0; i < len; i += 4) {
swap(this, i, i + 3)
swap(this, i + 1, i + 2)
}
return this
}
Buffer.prototype.toString = function toString () {
var length = this.length | 0
if (length === 0) return ''
if (arguments.length === 0) return utf8Slice(this, 0, length)
return slowToString.apply(this, arguments)
}
Buffer.prototype.equals = function equals (b) {
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
if (this === b) return true
return Buffer.compare(this, b) === 0
}
Buffer.prototype.inspect = function inspect () {
var str = ''
var max = exports.INSPECT_MAX_BYTES
if (this.length > 0) {
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
if (this.length > max) str += ' ... '
}
return '<Buffer ' + str + '>'
}
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
if (!Buffer.isBuffer(target)) {
throw new TypeError('Argument must be a Buffer')
}
if (start === undefined) {
start = 0
}
if (end === undefined) {
end = target ? target.length : 0
}
if (thisStart === undefined) {
thisStart = 0
}
if (thisEnd === undefined) {
thisEnd = this.length
}
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
throw new RangeError('out of range index')
}
if (thisStart >= thisEnd && start >= end) {
return 0
}
if (thisStart >= thisEnd) {
return -1
}
if (start >= end) {
return 1
}
start >>>= 0
end >>>= 0
thisStart >>>= 0
thisEnd >>>= 0
if (this === target) return 0
var x = thisEnd - thisStart
var y = end - start
var len = Math.min(x, y)
var thisCopy = this.slice(thisStart, thisEnd)
var targetCopy = target.slice(start, end)
for (var i = 0; i < len; ++i) {
if (thisCopy[i] !== targetCopy[i]) {
x = thisCopy[i]
y = targetCopy[i]
break
}
}
if (x < y) return -1
if (y < x) return 1
return 0
}
function arrayIndexOf (arr, val, byteOffset, encoding) {
var indexSize = 1
var arrLength = arr.length
var valLength = val.length
if (encoding !== undefined) {
encoding = String(encoding).toLowerCase()
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le') {
if (arr.length < 2 || val.length < 2) {
return -1
}
indexSize = 2
arrLength /= 2
valLength /= 2
byteOffset /= 2
}
}
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
var foundIndex = -1
for (var i = 0; byteOffset + i < arrLength; i++) {
if (read(arr, byteOffset + i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === valLength) return (byteOffset + foundIndex) * indexSize
} else {
if (foundIndex !== -1) i -= i - foundIndex
foundIndex = -1
}
}
return -1
}
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
if (typeof byteOffset === 'string') {
encoding = byteOffset
byteOffset = 0
} else if (byteOffset > 0x7fffffff) {
byteOffset = 0x7fffffff
} else if (byteOffset < -0x80000000) {
byteOffset = -0x80000000
}
byteOffset >>= 0
if (this.length === 0) return -1
if (byteOffset >= this.length) return -1
// Negative offsets start from the end of the buffer
if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
if (typeof val === 'string') {
val = Buffer.from(val, encoding)
}
if (Buffer.isBuffer(val)) {
// special case: looking for empty string/buffer always fails
if (val.length === 0) {
return -1
}
return arrayIndexOf(this, val, byteOffset, encoding)
}
if (typeof val === 'number') {
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
}
return arrayIndexOf(this, [ val ], byteOffset, encoding)
}
throw new TypeError('val must be string, number or Buffer')
}
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
return this.indexOf(val, byteOffset, encoding) !== -1
}
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
var remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = Number(length)
if (length > remaining) {
length = remaining
}
}
// must be an even number of digits
var strLen = string.length
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
if (length > strLen / 2) {
length = strLen / 2
}
for (var i = 0; i < length; i++) {
var parsed = parseInt(string.substr(i * 2, 2), 16)
if (isNaN(parsed)) return i
buf[offset + i] = parsed
}
return i
}
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
function asciiWrite (buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length)
}
function binaryWrite (buf, string, offset, length) {
return asciiWrite(buf, string, offset, length)
}
function base64Write (buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length)
}
function ucs2Write (buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
}
Buffer.prototype.write = function write (string, offset, length, encoding) {
// Buffer#write(string)
if (offset === undefined) {
encoding = 'utf8'
length = this.length
offset = 0
// Buffer#write(string, encoding)
} else if (length === undefined && typeof offset === 'string') {
encoding = offset
length = this.length
offset = 0
// Buffer#write(string, offset[, length][, encoding])
} else if (isFinite(offset)) {
offset = offset | 0
if (isFinite(length)) {
length = length | 0
if (encoding === undefined) encoding = 'utf8'
} else {
encoding = length
length = undefined
}
// legacy write(string, encoding, offset, length) - remove in v0.13
} else {
throw new Error(
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
)
}
var remaining = this.length - offset
if (length === undefined || length > remaining) length = remaining
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
throw new RangeError('Attempt to write outside buffer bounds')
}
if (!encoding) encoding = 'utf8'
var loweredCase = false
for (;;) {
switch (encoding) {
case 'hex':
return hexWrite(this, string, offset, length)
case 'utf8':
case 'utf-8':
return utf8Write(this, string, offset, length)
case 'ascii':
return asciiWrite(this, string, offset, length)
case 'binary':
return binaryWrite(this, string, offset, length)
case 'base64':
// Warning: maxLength not taken into account in base64Write
return base64Write(this, string, offset, length)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return ucs2Write(this, string, offset, length)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
Buffer.prototype.toJSON = function toJSON () {
return {
type: 'Buffer',
data: Array.prototype.slice.call(this._arr || this, 0)
}
}
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
} else {
return base64.fromByteArray(buf.slice(start, end))
}
}
function utf8Slice (buf, start, end) {
end = Math.min(buf.length, end)
var res = []
var i = start
while (i < end) {
var firstByte = buf[i]
var codePoint = null
var bytesPerSequence = (firstByte > 0xEF) ? 4
: (firstByte > 0xDF) ? 3
: (firstByte > 0xBF) ? 2
: 1
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint
switch (bytesPerSequence) {
case 1:
if (firstByte < 0x80) {
codePoint = firstByte
}
break
case 2:
secondByte = buf[i + 1]
if ((secondByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
if (tempCodePoint > 0x7F) {
codePoint = tempCodePoint
}
}
break
case 3:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
codePoint = tempCodePoint
}
}
break
case 4:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
fourthByte = buf[i + 3]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
codePoint = tempCodePoint
}
}
}
}
if (codePoint === null) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
codePoint = 0xDC00 | codePoint & 0x3FF
}
res.push(codePoint)
i += bytesPerSequence
}
return decodeCodePointsArray(res)
}
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
var MAX_ARGUMENTS_LENGTH = 0x1000
function decodeCodePointsArray (codePoints) {
var len = codePoints.length
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
}
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while (i < len) {
res += String.fromCharCode.apply(
String,
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
)
}
return res
}
function asciiSlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; i++) {
ret += String.fromCharCode(buf[i] & 0x7F)
}
return ret
}
function binarySlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; i++) {
ret += String.fromCharCode(buf[i])
}
return ret
}
function hexSlice (buf, start, end) {
var len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
var out = ''
for (var i = start; i < end; i++) {
out += toHex(buf[i])
}
return out
}
function utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
}
return res
}
Buffer.prototype.slice = function slice (start, end) {
var len = this.length
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len
if (start < 0) start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0) end = 0
} else if (end > len) {
end = len
}
if (end < start) end = start
var newBuf
if (Buffer.TYPED_ARRAY_SUPPORT) {
newBuf = this.subarray(start, end)
newBuf.__proto__ = Buffer.prototype
} else {
var sliceLen = end - start
newBuf = new Buffer(sliceLen, undefined)
for (var i = 0; i < sliceLen; i++) {
newBuf[i] = this[i + start]
}
}
return newBuf
}
/*
* Need to make sure that buffer isn't trying to write out of bounds.
*/
function checkOffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
var val = this[offset]
var mul = 1
var i = 0
while (++i < byteLength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
return val
}
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) {
checkOffset(offset, byteLength, this.length)
}
var val = this[offset + --byteLength]
var mul = 1
while (byteLength > 0 && (mul *= 0x100)) {
val += this[offset + --byteLength] * mul
}
return val
}
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
if (!noAssert) checkOffset(offset, 1, this.length)
return this[offset]
}
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
return this[offset] | (this[offset + 1] << 8)
}
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
return (this[offset] << 8) | this[offset + 1]
}
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return ((this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16)) +
(this[offset + 3] * 0x1000000)
}
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset] * 0x1000000) +
((this[offset + 1] << 16) |
(this[offset + 2] << 8) |
this[offset + 3])
}
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
var val = this[offset]
var mul = 1
var i = 0
while (++i < byteLength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
mul *= 0x80
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
return val
}
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
var i = byteLength
var mul = 1
var val = this[offset + --i]
while (i > 0 && (mul *= 0x100)) {
val += this[offset + --i] * mul
}
mul *= 0x80
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
return val
}
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
if (!noAssert) checkOffset(offset, 1, this.length)
if (!(this[offset] & 0x80)) return (this[offset])
return ((0xff - this[offset] + 1) * -1)
}
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
var val = this[offset] | (this[offset + 1] << 8)
return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
var val = this[offset + 1] | (this[offset] << 8)
return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16) |
(this[offset + 3] << 24)
}
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset] << 24) |
(this[offset + 1] << 16) |
(this[offset + 2] << 8) |
(this[offset + 3])
}
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return ieee754.read(this, offset, true, 23, 4)
}
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return ieee754.read(this, offset, false, 23, 4)
}
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 8, this.length)
return ieee754.read(this, offset, true, 52, 8)
}
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 8, this.length)
return ieee754.read(this, offset, false, 52, 8)
}
function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
if (offset + ext > buf.length) throw new RangeError('Index out of range')
}
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) {
var maxBytes = Math.pow(2, 8 * byteLength) - 1
checkInt(this, value, offset, byteLength, maxBytes, 0)
}
var mul = 1
var i = 0
this[offset] = value & 0xFF
while (++i < byteLength && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) {
var maxBytes = Math.pow(2, 8 * byteLength) - 1
checkInt(this, value, offset, byteLength, maxBytes, 0)
}
var i = byteLength - 1
var mul = 1
this[offset + i] = value & 0xFF
while (--i >= 0 && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
this[offset] = (value & 0xff)
return offset + 1
}
function objectWriteUInt16 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
(littleEndian ? i : 1 - i) * 8
}
}
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
} else {
objectWriteUInt16(this, value, offset, true)
}
return offset + 2
}
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
} else {
objectWriteUInt16(this, value, offset, false)
}
return offset + 2
}
function objectWriteUInt32 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffffffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
}
}
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset + 3] = (value >>> 24)
this[offset + 2] = (value >>> 16)
this[offset + 1] = (value >>> 8)
this[offset] = (value & 0xff)
} else {
objectWriteUInt32(this, value, offset, true)
}
return offset + 4
}
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
} else {
objectWriteUInt32(this, value, offset, false)
}
return offset + 4
}
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength - 1)
checkInt(this, value, offset, byteLength, limit - 1, -limit)
}
var i = 0
var mul = 1
var sub = 0
this[offset] = value & 0xFF
while (++i < byteLength && (mul *= 0x100)) {
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
sub = 1
}
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength - 1)
checkInt(this, value, offset, byteLength, limit - 1, -limit)
}
var i = byteLength - 1
var mul = 1
var sub = 0
this[offset + i] = value & 0xFF
while (--i >= 0 && (mul *= 0x100)) {
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
sub = 1
}
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
if (value < 0) value = 0xff + value + 1
this[offset] = (value & 0xff)
return offset + 1
}
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
} else {
objectWriteUInt16(this, value, offset, true)
}
return offset + 2
}
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
} else {
objectWriteUInt16(this, value, offset, false)
}
return offset + 2
}
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
this[offset + 2] = (value >>> 16)
this[offset + 3] = (value >>> 24)
} else {
objectWriteUInt32(this, value, offset, true)
}
return offset + 4
}
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (value < 0) value = 0xffffffff + value + 1
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
} else {
objectWriteUInt32(this, value, offset, false)
}
return offset + 4
}
function checkIEEE754 (buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError('Index out of range')
if (offset < 0) throw new RangeError('Index out of range')
}
function writeFloat (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
return writeFloat(this, value, offset, true, noAssert)
}
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
return writeFloat(this, value, offset, false, noAssert)
}
function writeDouble (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
}
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
return writeDouble(this, value, offset, true, noAssert)
}
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
return writeDouble(this, value, offset, false, noAssert)
}
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (!start) start = 0
if (!end && end !== 0) end = this.length
if (targetStart >= target.length) targetStart = target.length
if (!targetStart) targetStart = 0
if (end > 0 && end < start) end = start
// Copy 0 bytes; we're done
if (end === start) return 0
if (target.length === 0 || this.length === 0) return 0
// Fatal error conditions
if (targetStart < 0) {
throw new RangeError('targetStart out of bounds')
}
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
if (end < 0) throw new RangeError('sourceEnd out of bounds')
// Are we oob?
if (end > this.length) end = this.length
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start
}
var len = end - start
var i
if (this === target && start < targetStart && targetStart < end) {
// descending copy from end
for (i = len - 1; i >= 0; i--) {
target[i + targetStart] = this[i + start]
}
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
// ascending copy from start
for (i = 0; i < len; i++) {
target[i + targetStart] = this[i + start]
}
} else {
Uint8Array.prototype.set.call(
target,
this.subarray(start, start + len),
targetStart
)
}
return len
}
// Usage:
// buffer.fill(number[, offset[, end]])
// buffer.fill(buffer[, offset[, end]])
// buffer.fill(string[, offset[, end]][, encoding])
Buffer.prototype.fill = function fill (val, start, end, encoding) {
// Handle string cases:
if (typeof val === 'string') {
if (typeof start === 'string') {
encoding = start
start = 0
end = this.length
} else if (typeof end === 'string') {
encoding = end
end = this.length
}
if (val.length === 1) {
var code = val.charCodeAt(0)
if (code < 256) {
val = code
}
}
if (encoding !== undefined && typeof encoding !== 'string') {
throw new TypeError('encoding must be a string')
}
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
throw new TypeError('Unknown encoding: ' + encoding)
}
} else if (typeof val === 'number') {
val = val & 255
}
// Invalid ranges are not set to a default, so can range check early.
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError('Out of range index')
}
if (end <= start) {
return this
}
start = start >>> 0
end = end === undefined ? this.length : end >>> 0
if (!val) val = 0
var i
if (typeof val === 'number') {
for (i = start; i < end; i++) {
this[i] = val
}
} else {
var bytes = Buffer.isBuffer(val)
? val
: utf8ToBytes(new Buffer(val, encoding).toString())
var len = bytes.length
for (i = 0; i < end - start; i++) {
this[i + start] = bytes[i % len]
}
}
return this
}
// HELPER FUNCTIONS
// ================
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
function stringtrim (str) {
if (str.trim) return str.trim()
return str.replace(/^\s+|\s+$/g, '')
}
function toHex (n) {
if (n < 16) return '0' + n.toString(16)
return n.toString(16)
}
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; i++) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
function asciiToBytes (str) {
var byteArray = []
for (var i = 0; i < str.length; i++) {
// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF)
}
return byteArray
}
function utf16leToBytes (str, units) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; i++) {
if ((units -= 2) < 0) break
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
function base64ToBytes (str) {
return base64.toByteArray(base64clean(str))
}
function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; i++) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"base64-js":1,"ieee754":15,"isarray":16}],4:[function(require,module,exports){
// Use strict mode (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)
"use strict";
// Requires
var Typo = require("typo-js");
// Create function
function CodeMirrorSpellChecker(options) {
// Initialize
options = options || {};
// Verify
if(typeof options.codeMirrorInstance !== "function" || typeof options.codeMirrorInstance.defineMode !== "function") {
console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`");
return;
}
// Because some browsers don't support this functionality yet
if(!String.prototype.includes) {
String.prototype.includes = function() {
"use strict";
return String.prototype.indexOf.apply(this, arguments) !== -1;
};
}
// Define the new mode
options.codeMirrorInstance.defineMode("spell-checker", function(config) {
// Load AFF/DIC data
if(!CodeMirrorSpellChecker.aff_loading) {
CodeMirrorSpellChecker.aff_loading = true;
var xhr_aff = new XMLHttpRequest();
xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
xhr_aff.onload = function() {
if(xhr_aff.readyState === 4 && xhr_aff.status === 200) {
CodeMirrorSpellChecker.aff_data = xhr_aff.responseText;
CodeMirrorSpellChecker.num_loaded++;
if(CodeMirrorSpellChecker.num_loaded == 2) {
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
platform: "any"
});
}
}
};
xhr_aff.send(null);
}
if(!CodeMirrorSpellChecker.dic_loading) {
CodeMirrorSpellChecker.dic_loading = true;
var xhr_dic = new XMLHttpRequest();
xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
xhr_dic.onload = function() {
if(xhr_dic.readyState === 4 && xhr_dic.status === 200) {
CodeMirrorSpellChecker.dic_data = xhr_dic.responseText;
CodeMirrorSpellChecker.num_loaded++;
if(CodeMirrorSpellChecker.num_loaded == 2) {
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
platform: "any"
});
}
}
};
xhr_dic.send(null);
}
// Define what separates a word
var rx_word = "!\"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ";
// Create the overlay and such
var overlay = {
token: function(stream) {
var ch = stream.peek();
var word = "";
if(rx_word.includes(ch)) {
stream.next();
return null;
}
while((ch = stream.peek()) != null && !rx_word.includes(ch)) {
word += ch;
stream.next();
}
if(CodeMirrorSpellChecker.typo && !CodeMirrorSpellChecker.typo.check(word))
return "spell-error"; // CSS class: cm-spell-error
return null;
}
};
var mode = options.codeMirrorInstance.getMode(
config, config.backdrop || "text/plain"
);
return options.codeMirrorInstance.overlayMode(mode, overlay, true);
});
}
// Initialize data globally to reduce memory consumption
CodeMirrorSpellChecker.num_loaded = 0;
CodeMirrorSpellChecker.aff_loading = false;
CodeMirrorSpellChecker.dic_loading = false;
CodeMirrorSpellChecker.aff_data = "";
CodeMirrorSpellChecker.dic_data = "";
CodeMirrorSpellChecker.typo;
// Export
module.exports = CodeMirrorSpellChecker;
},{"typo-js":18}],5:[function(require,module,exports){
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
if (old == CodeMirror.Init) old = false;
if (!old == !val) return;
if (val) setFullscreen(cm);
else setNormal(cm);
});
function setFullscreen(cm) {
var wrap = cm.getWrapperElement();
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
width: wrap.style.width, height: wrap.style.height};
wrap.style.width = "";
wrap.style.height = "auto";
wrap.className += " CodeMirror-fullscreen";
document.documentElement.style.overflow = "hidden";
cm.refresh();
}
function setNormal(cm) {
var wrap = cm.getWrapperElement();
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
document.documentElement.style.overflow = "";
var info = cm.state.fullScreenRestore;
wrap.style.width = info.width; wrap.style.height = info.height;
window.scrollTo(info.scrollLeft, info.scrollTop);
cm.refresh();
}
});
},{"../../lib/codemirror":10}],6:[function(require,module,exports){
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.on("blur", onBlur);
cm.on("change", onChange);
cm.on("swapDoc", onChange);
onChange(cm);
} else if (!val && prev) {
cm.off("blur", onBlur);
cm.off("change", onChange);
cm.off("swapDoc", onChange);
clearPlaceholder(cm);
var wrapper = cm.getWrapperElement();
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
}
if (val && !cm.hasFocus()) onBlur(cm);
});
function clearPlaceholder(cm) {
if (cm.state.placeholder) {
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
cm.state.placeholder = null;
}
}
function setPlaceholder(cm) {
clearPlaceholder(cm);
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
elt.appendChild(placeHolder)
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}
function onBlur(cm) {
if (isEmpty(cm)) setPlaceholder(cm);
}
function onChange(cm) {
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
if (empty) setPlaceholder(cm);
else clearPlaceholder(cm);
}
function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
});
},{"../../lib/codemirror":10}],7:[function(require,module,exports){
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
unorderedListRE = /[*+-]\s/;
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
if (cm.getOption("disableInput")) return CodeMirror.Pass;
var ranges = cm.listSelections(), replacements = [];
for (var i = 0; i < ranges.length; i++) {
var pos = ranges[i].head;
var eolState = cm.getStateAfter(pos.line);
var inList = eolState.list !== false;
var inQuote = eolState.quote !== 0;
var line = cm.getLine(pos.line), match = listRE.exec(line);
if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
cm.execCommand("newlineAndIndent");
return;
}
if (emptyListRE.test(line)) {
cm.replaceRange("", {
line: pos.line, ch: 0
}, {
line: pos.line, ch: pos.ch + 1
});
replacements[i] = "\n";
} else {
var indent = match[1], after = match[5];
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
? match[2]
: (parseInt(match[3], 10) + 1) + match[4];
replacements[i] = "\n" + indent + bullet + after;
}
}
cm.replaceSelections(replacements);
};
});
},{"../../lib/codemirror":10}],8:[function(require,module,exports){
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Utility function that allows modes to be combined. The mode given
// as the base argument takes care of most of the normal mode
// functionality, but a second (typically simple) mode is used, which
// can override the style of text. Both modes get to parse all of the
// text, but when both assign a non-null style to a piece of code, the
// overlay wins, unless the combine argument was true and not overridden,
// or state.overlay.combineTokens was true, in which case the styles are
// combined.
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.overlayMode = function(base, overlay, combine) {
return {
startState: function() {
return {
base: CodeMirror.startState(base),
overlay: CodeMirror.startState(overlay),
basePos: 0, baseCur: null,
overlayPos: 0, overlayCur: null,
streamSeen: null
};
},
copyState: function(state) {
return {
base: CodeMirror.copyState(base, state.base),
overlay: CodeMirror.copyState(overlay, state.overlay),
basePos: state.basePos, baseCur: null,
overlayPos: state.overlayPos, overlayCur: null
};
},
token: function(stream, state) {
if (stream != state.streamSeen ||
Math.min(state.basePos, state.overlayPos) < stream.start) {
state.streamSeen = stream;
state.basePos = state.overlayPos = stream.start;
}
if (stream.start == state.basePos) {
state.baseCur = base.token(stream, state.base);
state.basePos = stream.pos;
}
if (stream.start == state.overlayPos) {
stream.pos = stream.start;
state.overlayCur = overlay.token(stream, state.overlay);
state.overlayPos = stream.pos;
}
stream.pos = Math.min(state.basePos, state.overlayPos);
// state.overlay.combineTokens always takes precedence over combine,
// unless set to null
if (state.overlayCur == null) return state.baseCur;
else if (state.baseCur != null &&
state.overlay.combineTokens ||
combine && state.overlay.combineTokens == null)
return state.baseCur + " " + state.overlayCur;
else return state.overlayCur;
},
indent: base.indent && function(state, textAfter) {
return base.indent(state.base, textAfter);
},
electricChars: base.electricChars,
innerMode: function(state) { return {state: state.base, mode: base}; },
blankLine: function(state) {
if (base.blankLine) base.blankLine(state.base);
if (overlay.blankLine) overlay.blankLine(state.overlay);
}
};
};
});
},{"../../lib/codemirror":10}],9:[function(require,module,exports){
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Because sometimes you need to mark the selected *text*.
//
// Adds an option 'styleSelectedText' which, when enabled, gives
// selected text the CSS class given as option value, or
// "CodeMirror-selectedtext" when the value is not a string.
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.state.markedSelection = [];
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
reset(cm);
cm.on("cursorActivity", onCursorActivity);
cm.on("change", onChange);
} else if (!val && prev) {
cm.off("cursorActivity", onCursorActivity);
cm.off("change", onChange);
clear(cm);
cm.state.markedSelection = cm.state.markedSelectionStyle = null;
}
});
function onCursorActivity(cm) {
cm.operation(function() { update(cm); });
}
function onChange(cm) {
if (cm.state.markedSelection.length)
cm.operation(function() { clear(cm); });
}
var CHUNK_SIZE = 8;
var Pos = CodeMirror.Pos;
var cmp = CodeMirror.cmpPos;
function coverRange(cm, from, to, addAt) {
if (cmp(from, to) == 0) return;
var array = cm.state.markedSelection;
var cls = cm.state.markedSelectionStyle;
for (var line = from.line;;) {
var start = line == from.line ? from : Pos(line, 0);
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
var end = atEnd ? to : Pos(endLine, 0);
var mark = cm.markText(start, end, {className: cls});
if (addAt == null) array.push(mark);
else array.splice(addAt++, 0, mark);
if (atEnd) break;
line = endLine;
}
}
function clear(cm) {
var array = cm.state.markedSelection;
for (var i = 0; i < array.length; ++i) array[i].clear();
array.length = 0;
}
function reset(cm) {
clear(cm);
var ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++)
coverRange(cm, ranges[i].from(), ranges[i].to());
}
function update(cm) {
if (!cm.somethingSelected()) return clear(cm);
if (cm.listSelections().length > 1) return reset(cm);
var from = cm.getCursor("start"), to = cm.getCursor("end");
var array = cm.state.markedSelection;
if (!array.length) return coverRange(cm, from, to);
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
return reset(cm);
while (cmp(from, coverStart.from) > 0) {
array.shift().clear();
coverStart = array[0].find();
}
if (cmp(from, coverStart.from) < 0) {
if (coverStart.to.line - from.line < CHUNK_SIZE) {
array.shift().clear();
coverRange(cm, from, coverStart.to, 0);
} else {
coverRange(cm, from, coverStart.from, 0);
}
}
while (cmp(to, coverEnd.to) < 0) {
array.pop().clear();
coverEnd = array[array.length - 1].find();
}
if (cmp(to, coverEnd.to) > 0) {
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
array.pop().clear();
coverRange(cm, coverEnd.from, to);
} else {
coverRange(cm, coverEnd.to, to);
}
}
}
});
},{"../../lib/codemirror":10}],10:[function(require,module,exports){
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// This is CodeMirror (http://codemirror.net), a code editor
// implemented in JavaScript on top of the browser's DOM.
//
// You can find some technical background for some of the code below
// at http://marijnhaverbeke.nl/blog/#cm-internals .
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
module.exports = mod();
else if (typeof define == "function" && define.amd) // AMD
return define([], mod);
else // Plain browser env
(this || window).CodeMirror = mod();
})(function() {
"use strict";
// BROWSER SNIFFING
// Kludges for bugs and behavior differences that can't be feature
// detected are enabled based on userAgent etc sniffing.
var userAgent = navigator.userAgent;
var platform = navigator.platform;
var gecko = /gecko\/\d/i.test(userAgent);
var ie_upto10 = /MSIE \d/.test(userAgent);
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
var ie = ie_upto10 || ie_11up;
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
var webkit = /WebKit\//.test(userAgent);
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
var chrome = /Chrome\//.test(userAgent);
var presto = /Opera\//.test(userAgent);
var safari = /Apple Computer/.test(navigator.vendor);
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
var phantom = /PhantomJS/.test(userAgent);
var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
// This is woefully incomplete. Suggestions for alternative methods welcome.
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
var mac = ios || /Mac/.test(platform);
var chromeOS = /\bCrOS\b/.test(userAgent);
var windows = /win/i.test(platform);
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
if (presto_version) presto_version = Number(presto_version[1]);
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
var captureRightClick = gecko || (ie && ie_version >= 9);
// Optimize some code when these features are not used.
var sawReadOnlySpans = false, sawCollapsedSpans = false;
// EDITOR CONSTRUCTOR
// A CodeMirror instance represents an editor. This is the object
// that user code is usually dealing with.
function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
copyObj(defaults, options, false);
setGuttersForLineNumbers(options);
var doc = options.value;
if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
this.doc = doc;
var input = new CodeMirror.inputStyles[options.inputStyle](this);
var display = this.display = new Display(place, doc, input);
display.wrapper.CodeMirror = this;
updateGutters(this);
themeChanged(this);
if (options.lineWrapping)
this.display.wrapper.className += " CodeMirror-wrap";
if (options.autofocus && !mobile) display.input.focus();
initScrollbars(this);
this.state = {
keyMaps: [], // stores maps added by addKeyMap
overlays: [], // highlighting overlays, as added by addOverlay
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
overwrite: false,
delayingBlurEvent: false,
focused: false,
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
selectingText: false,
draggingText: false,
highlight: new Delayed(), // stores highlight worker timeout
keySeq: null, // Unfinished key sequence
specialChars: null
};
var cm = this;
// Override magic textarea content restore that IE sometimes does
// on our hidden textarea on reload
if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
registerEventHandlers(this);
ensureGlobalHandlers();
startOperation(this);
this.curOp.forceUpdate = true;
attachDoc(this, doc);
if ((options.autofocus && !mobile) || cm.hasFocus())
setTimeout(bind(onFocus, this), 20);
else
onBlur(this);
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
optionHandlers[opt](this, options[opt], Init);
maybeUpdateLineNumberWidth(this);
if (options.finishInit) options.finishInit(this);
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
endOperation(this);
// Suppress optimizelegibility in Webkit, since it breaks text
// measuring on line wrapping boundaries.
if (webkit && options.lineWrapping &&
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
display.lineDiv.style.textRendering = "auto";
}
// DISPLAY CONSTRUCTOR
// The display handles the DOM integration, both for input reading
// and content drawing. It holds references to DOM nodes and
// display-related state.
function Display(place, doc, input) {
var d = this;
this.input = input;
// Covers bottom-right square when both scrollbars are present.
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
d.scrollbarFiller.setAttribute("cm-not-content", "true");
// Covers bottom of gutter when coverGutterNextToScrollbar is on
// and h scrollbar is present.
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
d.gutterFiller.setAttribute("cm-not-content", "true");
// Will contain the actual code, positioned to cover the viewport.
d.lineDiv = elt("div", null, "CodeMirror-code");
// Elements are added to these to represent selection and cursors.
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
// A visibility: hidden element used to find the size of things.
d.measure = elt("div", null, "CodeMirror-measure");
// When lines outside of the viewport are measured, they are drawn in this.
d.lineMeasure = elt("div", null, "CodeMirror-measure");
// Wraps everything that needs to exist inside the vertically-padded coordinate system
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
null, "position: relative; outline: none");
// Moved around its parent to cover visible view.
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
// Set to the height of the document, allowing scrolling.
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
d.sizerWidth = null;
// Behavior of elts with overflow: auto and padding is
// inconsistent across browsers. This is used to ensure the
// scrollable area is big enough.
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
// Will contain the gutters, if any.
d.gutters = elt("div", null, "CodeMirror-gutters");
d.lineGutter = null;
// Actual scrollable element.
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
if (place) {
if (place.appendChild) place.appendChild(d.wrapper);
else place(d.wrapper);
}
// Current rendered range (may be bigger than the view window).
d.viewFrom = d.viewTo = doc.first;
d.reportedViewFrom = d.reportedViewTo = doc.first;
// Information about the rendered lines.
d.view = [];
d.renderedView = null;
// Holds info about a single rendered line when it was rendered
// for measurement, while not in view.
d.externalMeasured = null;
// Empty space (in pixels) above the view
d.viewOffset = 0;
d.lastWrapHeight = d.lastWrapWidth = 0;
d.updateLineNumbers = null;
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
d.scrollbarsClipped = false;
// Used to only resize the line number gutter when necessary (when
// the amount of lines crosses a boundary that makes its width change)
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
// Set to true when a non-horizontal-scrolling line widget is
// added. As an optimization, line widget aligning is skipped when
// this is false.
d.alignWidgets = false;
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
// Tracks the maximum line length so that the horizontal scrollbar
// can be kept static when scrolling.
d.maxLine = null;
d.maxLineLength = 0;
d.maxLineChanged = false;
// Used for measuring wheel scrolling granularity
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
// True when shift is held down.
d.shift = false;
// Used to track whether anything happened since the context menu
// was opened.
d.selForContextMenu = null;
d.activeTouch = null;
input.init(d);
}
// STATE UPDATES
// Used to get the editor into a consistent state again when options change.
function loadMode(cm) {
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
resetModeState(cm);
}
function resetModeState(cm) {
cm.doc.iter(function(line) {
if (line.stateAfter) line.stateAfter = null;
if (line.styles) line.styles = null;
});
cm.doc.frontier = cm.doc.first;
startWorker(cm, 100);
cm.state.modeGen++;
if (cm.curOp) regChange(cm);
}
function wrappingChanged(cm) {
if (cm.options.lineWrapping) {
addClass(cm.display.wrapper, "CodeMirror-wrap");
cm.display.sizer.style.minWidth = "";
cm.display.sizerWidth = null;
} else {
rmClass(cm.display.wrapper, "CodeMirror-wrap");
findMaxLine(cm);
}
estimateLineHeights(cm);
regChange(cm);
clearCaches(cm);
setTimeout(function(){updateScrollbars(cm);}, 100);
}
// Returns a function that estimates the height of a line, to use as
// first approximation until the line becomes visible (and is thus
// properly measurable).
function estimateHeight(cm) {
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
return function(line) {
if (lineIsHidden(cm.doc, line)) return 0;
var widgetsHeight = 0;
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
}
if (wrapping)
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
else
return widgetsHeight + th;
};
}
function estimateLineHeights(cm) {
var doc = cm.doc, est = estimateHeight(cm);
doc.iter(function(line) {
var estHeight = est(line);
if (estHeight != line.height) updateLineHeight(line, estHeight);
});
}
function themeChanged(cm) {
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
clearCaches(cm);
}
function guttersChanged(cm) {
updateGutters(cm);
regChange(cm);
setTimeout(function(){alignHorizontally(cm);}, 20);
}
// Rebuild the gutter elements, ensure the margin to the left of the
// code matches their width.
function updateGutters(cm) {
var gutters = cm.display.gutters, specs = cm.options.gutters;
removeChildren(gutters);
for (var i = 0; i < specs.length; ++i) {
var gutterClass = specs[i];
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
if (gutterClass == "CodeMirror-linenumbers") {
cm.display.lineGutter = gElt;
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
}
}
gutters.style.display = i ? "" : "none";
updateGutterSpace(cm);
}
function updateGutterSpace(cm) {
var width = cm.display.gutters.offsetWidth;
cm.display.sizer.style.marginLeft = width + "px";
}
// Compute the character length of a line, taking into account
// collapsed ranges (see markText) that might hide parts, and join
// other lines onto it.
function lineLength(line) {
if (line.height == 0) return 0;
var len = line.text.length, merged, cur = line;
while (merged = collapsedSpanAtStart(cur)) {
var found = merged.find(0, true);
cur = found.from.line;
len += found.from.ch - found.to.ch;
}
cur = line;
while (merged = collapsedSpanAtEnd(cur)) {
var found = merged.find(0, true);
len -= cur.text.length - found.from.ch;
cur = found.to.line;
len += cur.text.length - found.to.ch;
}
return len;
}
// Find the longest line in the document.
function findMaxLine(cm) {
var d = cm.display, doc = cm.doc;
d.maxLine = getLine(doc, doc.first);
d.maxLineLength = lineLength(d.maxLine);
d.maxLineChanged = true;
doc.iter(function(line) {
var len = lineLength(line);
if (len > d.maxLineLength) {
d.maxLineLength = len;
d.maxLine = line;
}
});
}
// Make sure the gutters options contains the element
// "CodeMirror-linenumbers" when the lineNumbers option is true.
function setGuttersForLineNumbers(options) {
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
if (found == -1 && options.lineNumbers) {
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
} else if (found > -1 && !options.lineNumbers) {
options.gutters = options.gutters.slice(0);
options.gutters.splice(found, 1);
}
}
// SCROLLBARS
// Prepare DOM reads needed to update the scrollbars. Done in one
// shot to minimize update/measure roundtrips.
function measureForScrollbars(cm) {
var d = cm.display, gutterW = d.gutters.offsetWidth;
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
return {
clientHeight: d.scroller.clientHeight,
viewHeight: d.wrapper.clientHeight,
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
viewWidth: d.wrapper.clientWidth,
barLeft: cm.options.fixedGutter ? gutterW : 0,
docHeight: docH,
scrollHeight: docH + scrollGap(cm) + d.barHeight,
nativeBarWidth: d.nativeBarWidth,
gutterWidth: gutterW
};
}
function NativeScrollbars(place, scroll, cm) {
this.cm = cm;
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
place(vert); place(horiz);
on(vert, "scroll", function() {
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
});
on(horiz, "scroll", function() {
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
});
this.checkedZeroWidth = false;
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
}
NativeScrollbars.prototype = copyObj({
update: function(measure) {
var needsH = measure.scrollWidth > measure.clientWidth + 1;
var needsV = measure.scrollHeight > measure.clientHeight + 1;
var sWidth = measure.nativeBarWidth;
if (needsV) {
this.vert.style.display = "block";
this.vert.style.bottom = needsH ? sWidth + "px" : "0";
var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
// A bug in IE8 can cause this value to be negative, so guard it.
this.vert.firstChild.style.height =
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
} else {
this.vert.style.display = "";
this.vert.firstChild.style.height = "0";
}
if (needsH) {
this.horiz.style.display = "block";
this.horiz.style.right = needsV ? sWidth + "px" : "0";
this.horiz.style.left = measure.barLeft + "px";
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
this.horiz.firstChild.style.width =
(measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
} else {
this.horiz.style.display = "";
this.horiz.firstChild.style.width = "0";
}
if (!this.checkedZeroWidth && measure.clientHeight > 0) {
if (sWidth == 0) this.zeroWidthHack();
this.checkedZeroWidth = true;
}
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
},
setScrollLeft: function(pos) {
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
},
setScrollTop: function(pos) {
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
},
zeroWidthHack: function() {
var w = mac && !mac_geMountainLion ? "12px" : "18px";
this.horiz.style.height = this.vert.style.width = w;
this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
this.disableHoriz = new Delayed;
this.disableVert = new Delayed;
},
enableZeroWidthBar: function(bar, delay) {
bar.style.pointerEvents = "auto";
function maybeDisable() {
// To find out whether the scrollbar is still visible, we
// check whether the element under the pixel in the bottom
// left corner of the scrollbar box is the scrollbar box
// itself (when the bar is still visible) or its filler child
// (when the bar is hidden). If it is still visible, we keep
// it enabled, if it's hidden, we disable pointer events.
var box = bar.getBoundingClientRect();
var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
if (elt != bar) bar.style.pointerEvents = "none";
else delay.set(1000, maybeDisable);
}
delay.set(1000, maybeDisable);
},
clear: function() {
var parent = this.horiz.parentNode;
parent.removeChild(this.horiz);
parent.removeChild(this.vert);
}
}, NativeScrollbars.prototype);
function NullScrollbars() {}
NullScrollbars.prototype = copyObj({
update: function() { return {bottom: 0, right: 0}; },
setScrollLeft: function() {},
setScrollTop: function() {},
clear: function() {}
}, NullScrollbars.prototype);
CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
function initScrollbars(cm) {
if (cm.display.scrollbars) {
cm.display.scrollbars.clear();
if (cm.display.scrollbars.addClass)
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
}
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
// Prevent clicks in the scrollbars from killing focus
on(node, "mousedown", function() {
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
});
node.setAttribute("cm-not-content", "true");
}, function(pos, axis) {
if (axis == "horizontal") setScrollLeft(cm, pos);
else setScrollTop(cm, pos);
}, cm);
if (cm.display.scrollbars.addClass)
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
}
function updateScrollbars(cm, measure) {
if (!measure) measure = measureForScrollbars(cm);
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
updateScrollbarsInner(cm, measure);
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
updateHeightsInViewport(cm);
updateScrollbarsInner(cm, measureForScrollbars(cm));
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
}
}
// Re-synchronize the fake scrollbars with the actual size of the
// content.
function updateScrollbarsInner(cm, measure) {
var d = cm.display;
var sizes = d.scrollbars.update(measure);
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
if (sizes.right && sizes.bottom) {
d.scrollbarFiller.style.display = "block";
d.scrollbarFiller.style.height = sizes.bottom + "px";
d.scrollbarFiller.style.width = sizes.right + "px";
} else d.scrollbarFiller.style.display = "";
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
d.gutterFiller.style.display = "block";
d.gutterFiller.style.height = sizes.bottom + "px";
d.gutterFiller.style.width = measure.gutterWidth + "px";
} else d.gutterFiller.style.display = "";
}
// Compute the lines that are visible in a given viewport (defaults
// the the current scroll position). viewport may contain top,
// height, and ensure (see op.scrollToPos) properties.
function visibleLines(display, doc, viewport) {
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
top = Math.floor(top - paddingTop(display));
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
// forces those lines into the viewport (if possible).
if (viewport && viewport.ensure) {
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
if (ensureFrom < from) {
from = ensureFrom;
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
to = ensureTo;
}
}
return {from: from, to: Math.max(to, from + 1)};
}
// LINE NUMBERS
// Re-align line numbers and gutter marks to compensate for
// horizontal scrolling.
function alignHorizontally(cm) {
var display = cm.display, view = display.view;
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
var gutterW = display.gutters.offsetWidth, left = comp + "px";
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
if (cm.options.fixedGutter && view[i].gutter)
view[i].gutter.style.left = left;
var align = view[i].alignable;
if (align) for (var j = 0; j < align.length; j++)
align[j].style.left = left;
}
if (cm.options.fixedGutter)
display.gutters.style.left = (comp + gutterW) + "px";
}
// Used to ensure that the line number gutter is still the right
// size for the current document size. Returns true when an update
// is needed.
function maybeUpdateLineNumberWidth(cm) {
if (!cm.options.lineNumbers) return false;
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
if (last.length != display.lineNumChars) {
var test = display.measure.appendChild(elt("div", [elt("div", last)],
"CodeMirror-linenumber CodeMirror-gutter-elt"));
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
display.lineGutter.style.width = "";
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
display.lineNumWidth = display.lineNumInnerWidth + padding;
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
display.lineGutter.style.width = display.lineNumWidth + "px";
updateGutterSpace(cm);
return true;
}
return false;
}
function lineNumberFor(options, i) {
return String(options.lineNumberFormatter(i + options.firstLineNumber));
}
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
// but using getBoundingClientRect to get a sub-pixel-accurate
// result.
function compensateForHScroll(display) {
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
}
// DISPLAY DRAWING
function DisplayUpdate(cm, viewport, force) {
var display = cm.display;
this.viewport = viewport;
// Store some values that we'll need later (but don't want to force a relayout for)
this.visible = visibleLines(display, cm.doc, viewport);
this.editorIsHidden = !display.wrapper.offsetWidth;
this.wrapperHeight = display.wrapper.clientHeight;
this.wrapperWidth = display.wrapper.clientWidth;
this.oldDisplayWidth = displayWidth(cm);
this.force = force;
this.dims = getDimensions(cm);
this.events = [];
}
DisplayUpdate.prototype.signal = function(emitter, type) {
if (hasHandler(emitter, type))
this.events.push(arguments);
};
DisplayUpdate.prototype.finish = function() {
for (var i = 0; i < this.events.length; i++)
signal.apply(null, this.events[i]);
};
function maybeClipScrollbars(cm) {
var display = cm.display;
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
display.heightForcer.style.height = scrollGap(cm) + "px";
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
display.scrollbarsClipped = true;
}
}
// Does the actual updating of the line display. Bails out
// (returning false) when there is nothing to be done and forced is
// false.
function updateDisplayIfNeeded(cm, update) {
var display = cm.display, doc = cm.doc;
if (update.editorIsHidden) {
resetView(cm);
return false;
}
// Bail out if the visible area is already rendered and nothing changed.
if (!update.force &&
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
display.renderedView == display.view && countDirtyView(cm) == 0)
return false;
if (maybeUpdateLineNumberWidth(cm)) {
resetView(cm);
update.dims = getDimensions(cm);
}
// Compute a suitable new viewport (from & to)
var end = doc.first + doc.size;
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
if (sawCollapsedSpans) {
from = visualLineNo(cm.doc, from);
to = visualLineEndNo(cm.doc, to);
}
var different = from != display.viewFrom || to != display.viewTo ||
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
adjustView(cm, from, to);
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
// Position the mover div to align with the current scroll position
cm.display.mover.style.top = display.viewOffset + "px";
var toUpdate = countDirtyView(cm);
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
return false;
// For big changes, we hide the enclosing element during the
// update, since that speeds up the operations on most browsers.
var focused = activeElt();
if (toUpdate > 4) display.lineDiv.style.display = "none";
patchDisplay(cm, display.updateLineNumbers, update.dims);
if (toUpdate > 4) display.lineDiv.style.display = "";
display.renderedView = display.view;
// There might have been a widget with a focused element that got
// hidden or updated, if so re-focus it.
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
// Prevent selection and cursors from interfering with the scroll
// width and height.
removeChildren(display.cursorDiv);
removeChildren(display.selectionDiv);
display.gutters.style.height = display.sizer.style.minHeight = 0;
if (different) {
display.lastWrapHeight = update.wrapperHeight;
display.lastWrapWidth = update.wrapperWidth;
startWorker(cm, 400);
}
display.updateLineNumbers = null;
return true;
}
function postUpdateDisplay(cm, update) {
var viewport = update.viewport;
for (var first = true;; first = false) {
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
// Clip forced viewport to actual scrollable area.
if (viewport && viewport.top != null)
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
// Updated line heights might result in the drawn area not
// actually covering the viewport. Keep looping until it does.
update.visible = visibleLines(cm.display, cm.doc, viewport);
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
break;
}
if (!updateDisplayIfNeeded(cm, update)) break;
updateHeightsInViewport(cm);
var barMeasure = measureForScrollbars(cm);
updateSelection(cm);
updateScrollbars(cm, barMeasure);
setDocumentHeight(cm, barMeasure);
}
update.signal(cm, "update", cm);
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
}
}
function updateDisplaySimple(cm, viewport) {
var update = new DisplayUpdate(cm, viewport);
if (updateDisplayIfNeeded(cm, update)) {
updateHeightsInViewport(cm);
postUpdateDisplay(cm, update);
var barMeasure = measureForScrollbars(cm);
updateSelection(cm);
updateScrollbars(cm, barMeasure);
setDocumentHeight(cm, barMeasure);
update.finish();
}
}
function setDocumentHeight(cm, measure) {
cm.display.sizer.style.minHeight = measure.docHeight + "px";
cm.display.heightForcer.style.top = measure.docHeight + "px";
cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
}
// Read the actual heights of the rendered lines, and update their
// stored heights to match.
function updateHeightsInViewport(cm) {
var display = cm.display;
var prevBottom = display.lineDiv.offsetTop;
for (var i = 0; i < display.view.length; i++) {
var cur = display.view[i], height;
if (cur.hidden) continue;
if (ie && ie_version < 8) {
var bot = cur.node.offsetTop + cur.node.offsetHeight;
height = bot - prevBottom;
prevBottom = bot;
} else {
var box = cur.node.getBoundingClientRect();
height = box.bottom - box.top;
}
var diff = cur.line.height - height;
if (height < 2) height = textHeight(display);
if (diff > .001 || diff < -.001) {
updateLineHeight(cur.line, height);
updateWidgetHeight(cur.line);
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
updateWidgetHeight(cur.rest[j]);
}
}
}
// Read and store the height of line widgets associated with the
// given line.
function updateWidgetHeight(line) {
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
}
// Do a bulk-read of the DOM positions and sizes needed to draw the
// view, so that we don't interleave reading and writing to the DOM.
function getDimensions(cm) {
var d = cm.display, left = {}, width = {};
var gutterLeft = d.gutters.clientLeft;
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
width[cm.options.gutters[i]] = n.clientWidth;
}
return {fixedPos: compensateForHScroll(d),
gutterTotalWidth: d.gutters.offsetWidth,
gutterLeft: left,
gutterWidth: width,
wrapperWidth: d.wrapper.clientWidth};
}
// Sync the actual display DOM structure with display.view, removing
// nodes for lines that are no longer in view, and creating the ones
// that are not there yet, and updating the ones that are out of
// date.
function patchDisplay(cm, updateNumbersFrom, dims) {
var display = cm.display, lineNumbers = cm.options.lineNumbers;
var container = display.lineDiv, cur = container.firstChild;
function rm(node) {
var next = node.nextSibling;
// Works around a throw-scroll bug in OS X Webkit
if (webkit && mac && cm.display.currentWheelTarget == node)
node.style.display = "none";
else
node.parentNode.removeChild(node);
return next;
}
var view = display.view, lineN = display.viewFrom;
// Loop over the elements in the view, syncing cur (the DOM nodes
// in display.lineDiv) with the view as we go.
for (var i = 0; i < view.length; i++) {
var lineView = view[i];
if (lineView.hidden) {
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
var node = buildLineElement(cm, lineView, lineN, dims);
container.insertBefore(node, cur);
} else { // Already drawn
while (cur != lineView.node) cur = rm(cur);
var updateNumber = lineNumbers && updateNumbersFrom != null &&
updateNumbersFrom <= lineN && lineView.lineNumber;
if (lineView.changes) {
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
updateLineForChanges(cm, lineView, lineN, dims);
}
if (updateNumber) {
removeChildren(lineView.lineNumber);
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
}
cur = lineView.node.nextSibling;
}
lineN += lineView.size;
}
while (cur) cur = rm(cur);
}
// When an aspect of a line changes, a string is added to
// lineView.changes. This updates the relevant part of the line's
// DOM structure.
function updateLineForChanges(cm, lineView, lineN, dims) {
for (var j = 0; j < lineView.changes.length; j++) {
var type = lineView.changes[j];
if (type == "text") updateLineText(cm, lineView);
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
else if (type == "class") updateLineClasses(lineView);
else if (type == "widget") updateLineWidgets(cm, lineView, dims);
}
lineView.changes = null;
}
// Lines with gutter elements, widgets or a background class need to
// be wrapped, and have the extra elements added to the wrapper div
function ensureLineWrapped(lineView) {
if (lineView.node == lineView.text) {
lineView.node = elt("div", null, null, "position: relative");
if (lineView.text.parentNode)
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
lineView.node.appendChild(lineView.text);
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
}
return lineView.node;
}
function updateLineBackground(lineView) {
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
if (cls) cls += " CodeMirror-linebackground";
if (lineView.background) {
if (cls) lineView.background.className = cls;
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
} else if (cls) {
var wrap = ensureLineWrapped(lineView);
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
}
}
// Wrapper around buildLineContent which will reuse the structure
// in display.externalMeasured when possible.
function getLineContent(cm, lineView) {
var ext = cm.display.externalMeasured;
if (ext && ext.line == lineView.line) {
cm.display.externalMeasured = null;
lineView.measure = ext.measure;
return ext.built;
}
return buildLineContent(cm, lineView);
}
// Redraw the line's text. Interacts with the background and text
// classes because the mode may output tokens that influence these
// classes.
function updateLineText(cm, lineView) {
var cls = lineView.text.className;
var built = getLineContent(cm, lineView);
if (lineView.text == lineView.node) lineView.node = built.pre;
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
lineView.text = built.pre;
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
lineView.bgClass = built.bgClass;
lineView.textClass = built.textClass;
updateLineClasses(lineView);
} else if (cls) {
lineView.text.className = cls;
}
}
function updateLineClasses(lineView) {
updateLineBackground(lineView);
if (lineView.line.wrapClass)
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
else if (lineView.node != lineView.text)
lineView.node.className = "";
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
lineView.text.className = textClass || "";
}
function updateLineGutter(cm, lineView, lineN, dims) {
if (lineView.gutter) {
lineView.node.removeChild(lineView.gutter);
lineView.gutter = null;
}
if (lineView.gutterBackground) {
lineView.node.removeChild(lineView.gutterBackground);
lineView.gutterBackground = null;
}
if (lineView.line.gutterClass) {
var wrap = ensureLineWrapped(lineView);
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
"left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
"px; width: " + dims.gutterTotalWidth + "px");
wrap.insertBefore(lineView.gutterBackground, lineView.text);
}
var markers = lineView.line.gutterMarkers;
if (cm.options.lineNumbers || markers) {
var wrap = ensureLineWrapped(lineView);
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
cm.display.input.setUneditable(gutterWrap);
wrap.insertBefore(gutterWrap, lineView.text);
if (lineView.line.gutterClass)
gutterWrap.className += " " + lineView.line.gutterClass;
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
lineView.lineNumber = gutterWrap.appendChild(
elt("div", lineNumberFor(cm.options, lineN),
"CodeMirror-linenumber CodeMirror-gutter-elt",
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
+ cm.display.lineNumInnerWidth + "px"));
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
if (found)
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
}
}
}
function updateLineWidgets(cm, lineView, dims) {
if (lineView.alignable) lineView.alignable = null;
for (var node = lineView.node.firstChild, next; node; node = next) {
var next = node.nextSibling;
if (node.className == "CodeMirror-linewidget")
lineView.node.removeChild(node);
}
insertLineWidgets(cm, lineView, dims);
}
// Build a line's DOM representation from scratch
function buildLineElement(cm, lineView, lineN, dims) {
var built = getLineContent(cm, lineView);
lineView.text = lineView.node = built.pre;
if (built.bgClass) lineView.bgClass = built.bgClass;
if (built.textClass) lineView.textClass = built.textClass;
updateLineClasses(lineView);
updateLineGutter(cm, lineView, lineN, dims);
insertLineWidgets(cm, lineView, dims);
return lineView.node;
}
// A lineView may contain multiple logical lines (when merged by
// collapsed spans). The widgets for all of them need to be drawn.
function insertLineWidgets(cm, lineView, dims) {
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
}
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
if (!line.widgets) return;
var wrap = ensureLineWrapped(lineView);
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
positionLineWidget(widget, node, lineView, dims);
cm.display.input.setUneditable(node);
if (allowAbove && widget.above)
wrap.insertBefore(node, lineView.gutter || lineView.text);
else
wrap.appendChild(node);
signalLater(widget, "redraw");
}
}
function positionLineWidget(widget, node, lineView, dims) {
if (widget.noHScroll) {
(lineView.alignable || (lineView.alignable = [])).push(node);
var width = dims.wrapperWidth;
node.style.left = dims.fixedPos + "px";
if (!widget.coverGutter) {
width -= dims.gutterTotalWidth;
node.style.paddingLeft = dims.gutterTotalWidth + "px";
}
node.style.width = width + "px";
}
if (widget.coverGutter) {
node.style.zIndex = 5;
node.style.position = "relative";
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
}
}
// POSITION OBJECT
// A Pos instance represents a position within the text.
var Pos = CodeMirror.Pos = function(line, ch) {
if (!(this instanceof Pos)) return new Pos(line, ch);
this.line = line; this.ch = ch;
};
// Compare two positions, return 0 if they are the same, a negative
// number when a is less, and a positive number otherwise.
var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
function copyPos(x) {return Pos(x.line, x.ch);}
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
// INPUT HANDLING
function ensureFocus(cm) {
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
}
// This will be set to a {lineWise: bool, text: [string]} object, so
// that, when pasting, we know what kind of selections the copied
// text was made out of.
var lastCopied = null;
function applyTextInput(cm, inserted, deleted, sel, origin) {
var doc = cm.doc;
cm.display.shift = false;
if (!sel) sel = doc.sel;
var paste = cm.state.pasteIncoming || origin == "paste";
var textLines = doc.splitLines(inserted), multiPaste = null
// When pasing N lines into N selections, insert one line per selection
if (paste && sel.ranges.length > 1) {
if (lastCopied && lastCopied.text.join("\n") == inserted) {
if (sel.ranges.length % lastCopied.text.length == 0) {
multiPaste = [];
for (var i = 0; i < lastCopied.text.length; i++)
multiPaste.push(doc.splitLines(lastCopied.text[i]));
}
} else if (textLines.length == sel.ranges.length) {
multiPaste = map(textLines, function(l) { return [l]; });
}
}
// Normal behavior is to insert the new text into every selection
for (var i = sel.ranges.length - 1; i >= 0; i--) {
var range = sel.ranges[i];
var from = range.from(), to = range.to();
if (range.empty()) {
if (deleted && deleted > 0) // Handle deletion
from = Pos(from.line, from.ch - deleted);
else if (cm.state.overwrite && !paste) // Handle overwrite
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
from = to = Pos(from.line, 0)
}
var updateInput = cm.curOp.updateInput;
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
makeChange(cm.doc, changeEvent);
signalLater(cm, "inputRead", cm, changeEvent);
}
if (inserted && !paste)
triggerElectric(cm, inserted);
ensureCursorVisible(cm);
cm.curOp.updateInput = updateInput;
cm.curOp.typing = true;
cm.state.pasteIncoming = cm.state.cutIncoming = false;
}
function handlePaste(e, cm) {
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
if (pasted) {
e.preventDefault();
if (!cm.isReadOnly() && !cm.options.disableInput)
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
return true;
}
}
function triggerElectric(cm, inserted) {
// When an 'electric' character is inserted, immediately trigger a reindent
if (!cm.options.electricChars || !cm.options.smartIndent) return;
var sel = cm.doc.sel;
for (var i = sel.ranges.length - 1; i >= 0; i--) {
var range = sel.ranges[i];
if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
var mode = cm.getModeAt(range.head);
var indented = false;
if (mode.electricChars) {
for (var j = 0; j < mode.electricChars.length; j++)
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
indented = indentLine(cm, range.head.line, "smart");
break;
}
} else if (mode.electricInput) {
if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
indented = indentLine(cm, range.head.line, "smart");
}
if (indented) signalLater(cm, "electricInput", cm, range.head.line);
}
}
function copyableRanges(cm) {
var text = [], ranges = [];
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
var line = cm.doc.sel.ranges[i].head.line;
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
ranges.push(lineRange);
text.push(cm.getRange(lineRange.anchor, lineRange.head));
}
return {text: text, ranges: ranges};
}
function disableBrowserMagic(field) {
field.setAttribute("autocorrect", "off");
field.setAttribute("autocapitalize", "off");
field.setAttribute("spellcheck", "false");
}
// TEXTAREA INPUT STYLE
function TextareaInput(cm) {
this.cm = cm;
// See input.poll and input.reset
this.prevInput = "";
// Flag that indicates whether we expect input to appear real soon
// now (after some event like 'keypress' or 'input') and are
// polling intensively.
this.pollingFast = false;
// Self-resetting timeout for the poller
this.polling = new Delayed();
// Tracks when input.reset has punted to just putting a short
// string into the textarea instead of the full selection.
this.inaccurateSelection = false;
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
this.hasSelection = false;
this.composing = null;
};
function hiddenTextarea() {
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
// The textarea is kept positioned near the cursor to prevent the
// fact that it'll be scrolled into view on input from scrolling
// our fake cursor out of view. On webkit, when wrap=off, paste is
// very slow. So make the area wide instead.
if (webkit) te.style.width = "1000px";
else te.setAttribute("wrap", "off");
// If border: 0; -- iOS fails to open keyboard (issue #1287)
if (ios) te.style.border = "1px solid black";
disableBrowserMagic(te);
return div;
}
TextareaInput.prototype = copyObj({
init: function(display) {
var input = this, cm = this.cm;
// Wraps and hides input textarea
var div = this.wrapper = hiddenTextarea();
// The semihidden textarea that is focused when the editor is
// focused, and receives input.
var te = this.textarea = div.firstChild;
display.wrapper.insertBefore(div, display.wrapper.firstChild);
// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
if (ios) te.style.width = "0px";
on(te, "input", function() {
if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
input.poll();
});
on(te, "paste", function(e) {
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
cm.state.pasteIncoming = true;
input.fastPoll();
});
function prepareCopyCut(e) {
if (signalDOMEvent(cm, e)) return
if (cm.somethingSelected()) {
lastCopied = {lineWise: false, text: cm.getSelections()};
if (input.inaccurateSelection) {
input.prevInput = "";
input.inaccurateSelection = false;
te.value = lastCopied.text.join("\n");
selectInput(te);
}
} else if (!cm.options.lineWiseCopyCut) {
return;
} else {
var ranges = copyableRanges(cm);
lastCopied = {lineWise: true, text: ranges.text};
if (e.type == "cut") {
cm.setSelections(ranges.ranges, null, sel_dontScroll);
} else {
input.prevInput = "";
te.value = ranges.text.join("\n");
selectInput(te);
}
}
if (e.type == "cut") cm.state.cutIncoming = true;
}
on(te, "cut", prepareCopyCut);
on(te, "copy", prepareCopyCut);
on(display.scroller, "paste", function(e) {
if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
cm.state.pasteIncoming = true;
input.focus();
});
// Prevent normal selection in the editor (we handle our own)
on(display.lineSpace, "selectstart", function(e) {
if (!eventInWidget(display, e)) e_preventDefault(e);
});
on(te, "compositionstart", function() {
var start = cm.getCursor("from");
if (input.composing) input.composing.range.clear()
input.composing = {
start: start,
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
};
});
on(te, "compositionend", function() {
if (input.composing) {
input.poll();
input.composing.range.clear();
input.composing = null;
}
});
},
prepareSelection: function() {
// Redraw the selection and/or cursor
var cm = this.cm, display = cm.display, doc = cm.doc;
var result = prepareSelection(cm);
// Move the hidden textarea near the cursor to prevent scrolling artifacts
if (cm.options.moveInputWithCursor) {
var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
headPos.top + lineOff.top - wrapOff.top));
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
headPos.left + lineOff.left - wrapOff.left));
}
return result;
},
showSelection: function(drawn) {
var cm = this.cm, display = cm.display;
removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
removeChildrenAndAdd(display.selectionDiv, drawn.selection);
if (drawn.teTop != null) {
this.wrapper.style.top = drawn.teTop + "px";
this.wrapper.style.left = drawn.teLeft + "px";
}
},
// Reset the input to correspond to the selection (or to be empty,
// when not typing and nothing is selected)
reset: function(typing) {
if (this.contextMenuPending) return;
var minimal, selected, cm = this.cm, doc = cm.doc;
if (cm.somethingSelected()) {
this.prevInput = "";
var range = doc.sel.primary();
minimal = hasCopyEvent &&
(range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
var content = minimal ? "-" : selected || cm.getSelection();
this.textarea.value = content;
if (cm.state.focused) selectInput(this.textarea);
if (ie && ie_version >= 9) this.hasSelection = content;
} else if (!typing) {
this.prevInput = this.textarea.value = "";
if (ie && ie_version >= 9) this.hasSelection = null;
}
this.inaccurateSelection = minimal;
},
getField: function() { return this.textarea; },
supportsTouch: function() { return false; },
focus: function() {
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
try { this.textarea.focus(); }
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
}
},
blur: function() { this.textarea.blur(); },
resetPosition: function() {
this.wrapper.style.top = this.wrapper.style.left = 0;
},
receivedFocus: function() { this.slowPoll(); },
// Poll for input changes, using the normal rate of polling. This
// runs as long as the editor is focused.
slowPoll: function() {
var input = this;
if (input.pollingFast) return;
input.polling.set(this.cm.options.pollInterval, function() {
input.poll();
if (input.cm.state.focused) input.slowPoll();
});
},
// When an event has just come in that is likely to add or change
// something in the input textarea, we poll faster, to ensure that
// the change appears on the screen quickly.
fastPoll: function() {
var missed = false, input = this;
input.pollingFast = true;
function p() {
var changed = input.poll();
if (!changed && !missed) {missed = true; input.polling.set(60, p);}
else {input.pollingFast = false; input.slowPoll();}
}
input.polling.set(20, p);
},
// Read input from the textarea, and update the document to match.
// When something is selected, it is present in the textarea, and
// selected (unless it is huge, in which case a placeholder is
// used). When nothing is selected, the cursor sits after previously
// seen text (can be empty), which is stored in prevInput (we must
// not reset the textarea when typing, because that breaks IME).
poll: function() {
var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
// Since this is called a *lot*, try to bail out as cheaply as
// possible when it is clear that nothing happened. hasSelection
// will be the case when there is a lot of text in the textarea,
// in which case reading its value would be expensive.
if (this.contextMenuPending || !cm.state.focused ||
(hasSelection(input) && !prevInput && !this.composing) ||
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
return false;
var text = input.value;
// If nothing changed, bail.
if (text == prevInput && !cm.somethingSelected()) return false;
// Work around nonsensical selection resetting in IE9/10, and
// inexplicable appearance of private area unicode characters on
// some key combos in Mac (#2689).
if (ie && ie_version >= 9 && this.hasSelection === text ||
mac && /[\uf700-\uf7ff]/.test(text)) {
cm.display.input.reset();
return false;
}
if (cm.doc.sel == cm.display.selForContextMenu) {
var first = text.charCodeAt(0);
if (first == 0x200b && !prevInput) prevInput = "\u200b";
if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); }
}
// Find the part of the input that is actually new
var same = 0, l = Math.min(prevInput.length, text.length);
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
var self = this;
runInOp(cm, function() {
applyTextInput(cm, text.slice(same), prevInput.length - same,
null, self.composing ? "*compose" : null);
// Don't leave long text in the textarea, since it makes further polling slow
if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
else self.prevInput = text;
if (self.composing) {
self.composing.range.clear();
self.composing.range = cm.markText(self.composing.start, cm.getCursor("to"),
{className: "CodeMirror-composing"});
}
});
return true;
},
ensurePolled: function() {
if (this.pollingFast && this.poll()) this.pollingFast = false;
},
onKeyPress: function() {
if (ie && ie_version >= 9) this.hasSelection = null;
this.fastPoll();
},
onContextMenu: function(e) {
var input = this, cm = input.cm, display = cm.display, te = input.textarea;
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
if (!pos || presto) return; // Opera is difficult.
// Reset the current text selection only if the click is done outside of the selection
// and 'resetSelectionOnContextMenu' option is true.
var reset = cm.options.resetSelectionOnContextMenu;
if (reset && cm.doc.sel.contains(pos) == -1)
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
input.wrapper.style.cssText = "position: absolute"
var wrapperBox = input.wrapper.getBoundingClientRect()
te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
"px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
display.input.focus();
if (webkit) window.scrollTo(null, oldScrollY);
display.input.reset();
// Adds "Select all" to context menu in FF
if (!cm.somethingSelected()) te.value = input.prevInput = " ";
input.contextMenuPending = true;
display.selForContextMenu = cm.doc.sel;
clearTimeout(display.detectingSelectAll);
// Select-all will be greyed out if there's nothing to select, so
// this adds a zero-width space so that we can later check whether
// it got selected.
function prepareSelectAllHack() {
if (te.selectionStart != null) {
var selected = cm.somethingSelected();
var extval = "\u200b" + (selected ? te.value : "");
te.value = "\u21da"; // Used to catch context-menu undo
te.value = extval;
input.prevInput = selected ? "" : "\u200b";
te.selectionStart = 1; te.selectionEnd = extval.length;
// Re-set this, in case some other handler touched the
// selection in the meantime.
display.selForContextMenu = cm.doc.sel;
}
}
function rehide() {
input.contextMenuPending = false;
input.wrapper.style.cssText = oldWrapperCSS
te.style.cssText = oldCSS;
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
// Try to detect the user choosing select-all
if (te.selectionStart != null) {
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
var i = 0, poll = function() {
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
te.selectionEnd > 0 && input.prevInput == "\u200b")
operation(cm, commands.selectAll)(cm);
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
else display.input.reset();
};
display.detectingSelectAll = setTimeout(poll, 200);
}
}
if (ie && ie_version >= 9) prepareSelectAllHack();
if (captureRightClick) {
e_stop(e);
var mouseup = function() {
off(window, "mouseup", mouseup);
setTimeout(rehide, 20);
};
on(window, "mouseup", mouseup);
} else {
setTimeout(rehide, 50);
}
},
readOnlyChanged: function(val) {
if (!val) this.reset();
},
setUneditable: nothing,
needsContentAttribute: false
}, TextareaInput.prototype);
// CONTENTEDITABLE INPUT STYLE
function ContentEditableInput(cm) {
this.cm = cm;
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
this.polling = new Delayed();
this.gracePeriod = false;
}
ContentEditableInput.prototype = copyObj({
init: function(display) {
var input = this, cm = input.cm;
var div = input.div = display.lineDiv;
disableBrowserMagic(div);
on(div, "paste", function(e) {
if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
})
on(div, "compositionstart", function(e) {
var data = e.data;
input.composing = {sel: cm.doc.sel, data: data, startData: data};
if (!data) return;
var prim = cm.doc.sel.primary();
var line = cm.getLine(prim.head.line);
var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
if (found > -1 && found <= prim.head.ch)
input.composing.sel = simpleSelection(Pos(prim.head.line, found),
Pos(prim.head.line, found + data.length));
});
on(div, "compositionupdate", function(e) {
input.composing.data = e.data;
});
on(div, "compositionend", function(e) {
var ours = input.composing;
if (!ours) return;
if (e.data != ours.startData && !/\u200b/.test(e.data))
ours.data = e.data;
// Need a small delay to prevent other code (input event,
// selection polling) from doing damage when fired right after
// compositionend.
setTimeout(function() {
if (!ours.handled)
input.applyComposition(ours);
if (input.composing == ours)
input.composing = null;
}, 50);
});
on(div, "touchstart", function() {
input.forceCompositionEnd();
});
on(div, "input", function() {
if (input.composing) return;
if (cm.isReadOnly() || !input.pollContent())
runInOp(input.cm, function() {regChange(cm);});
});
function onCopyCut(e) {
if (signalDOMEvent(cm, e)) return
if (cm.somethingSelected()) {
lastCopied = {lineWise: false, text: cm.getSelections()};
if (e.type == "cut") cm.replaceSelection("", null, "cut");
} else if (!cm.options.lineWiseCopyCut) {
return;
} else {
var ranges = copyableRanges(cm);
lastCopied = {lineWise: true, text: ranges.text};
if (e.type == "cut") {
cm.operation(function() {
cm.setSelections(ranges.ranges, 0, sel_dontScroll);
cm.replaceSelection("", null, "cut");
});
}
}
// iOS exposes the clipboard API, but seems to discard content inserted into it
if (e.clipboardData && !ios) {
e.preventDefault();
e.clipboardData.clearData();
e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
} else {
// Old-fashioned briefly-focus-a-textarea hack
var kludge = hiddenTextarea(), te = kludge.firstChild;
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n");
var hadFocus = document.activeElement;
selectInput(te);
setTimeout(function() {
cm.display.lineSpace.removeChild(kludge);
hadFocus.focus();
}, 50);
}
}
on(div, "copy", onCopyCut);
on(div, "cut", onCopyCut);
},
prepareSelection: function() {
var result = prepareSelection(this.cm, false);
result.focus = this.cm.state.focused;
return result;
},
showSelection: function(info, takeFocus) {
if (!info || !this.cm.display.view.length) return;
if (info.focus || takeFocus) this.showPrimarySelection();
this.showMultipleSelections(info);
},
showPrimarySelection: function() {
var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
return;
var start = posToDOM(this.cm, prim.from());
var end = posToDOM(this.cm, prim.to());
if (!start && !end) return;
var view = this.cm.display.view;
var old = sel.rangeCount && sel.getRangeAt(0);
if (!start) {
start = {node: view[0].measure.map[2], offset: 0};
} else if (!end) { // FIXME dangerously hacky
var measure = view[view.length - 1].measure;
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
}
try { var rng = range(start.node, start.offset, end.offset, end.node); }
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
if (rng) {
if (!gecko && this.cm.state.focused) {
sel.collapse(start.node, start.offset);
if (!rng.collapsed) sel.addRange(rng);
} else {
sel.removeAllRanges();
sel.addRange(rng);
}
if (old && sel.anchorNode == null) sel.addRange(old);
else if (gecko) this.startGracePeriod();
}
this.rememberSelection();
},
startGracePeriod: function() {
var input = this;
clearTimeout(this.gracePeriod);
this.gracePeriod = setTimeout(function() {
input.gracePeriod = false;
if (input.selectionChanged())
input.cm.operation(function() { input.cm.curOp.selectionChanged = true; });
}, 20);
},
showMultipleSelections: function(info) {
removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
},
rememberSelection: function() {
var sel = window.getSelection();
this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
},
selectionInEditor: function() {
var sel = window.getSelection();
if (!sel.rangeCount) return false;
var node = sel.getRangeAt(0).commonAncestorContainer;
return contains(this.div, node);
},
focus: function() {
if (this.cm.options.readOnly != "nocursor") this.div.focus();
},
blur: function() { this.div.blur(); },
getField: function() { return this.div; },
supportsTouch: function() { return true; },
receivedFocus: function() {
var input = this;
if (this.selectionInEditor())
this.pollSelection();
else
runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
function poll() {
if (input.cm.state.focused) {
input.pollSelection();
input.polling.set(input.cm.options.pollInterval, poll);
}
}
this.polling.set(this.cm.options.pollInterval, poll);
},
selectionChanged: function() {
var sel = window.getSelection();
return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
},
pollSelection: function() {
if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
var sel = window.getSelection(), cm = this.cm;
this.rememberSelection();
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
var head = domToPos(cm, sel.focusNode, sel.focusOffset);
if (anchor && head) runInOp(cm, function() {
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
});
}
},
pollContent: function() {
var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
var from = sel.from(), to = sel.to();
if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
var fromIndex;
if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
var fromLine = lineNo(display.view[0].line);
var fromNode = display.view[0].node;
} else {
var fromLine = lineNo(display.view[fromIndex].line);
var fromNode = display.view[fromIndex - 1].node.nextSibling;
}
var toIndex = findViewIndex(cm, to.line);
if (toIndex == display.view.length - 1) {
var toLine = display.viewTo - 1;
var toNode = display.lineDiv.lastChild;
} else {
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
var toNode = display.view[toIndex + 1].node.previousSibling;
}
var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
while (newText.length > 1 && oldText.length > 1) {
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
else break;
}
var cutFront = 0, cutEnd = 0;
var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
++cutFront;
var newBot = lst(newText), oldBot = lst(oldText);
var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
oldBot.length - (oldText.length == 1 ? cutFront : 0));
while (cutEnd < maxCutEnd &&
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
++cutEnd;
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
newText[0] = newText[0].slice(cutFront);
var chFrom = Pos(fromLine, cutFront);
var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
replaceRange(cm.doc, newText, chFrom, chTo, "+input");
return true;
}
},
ensurePolled: function() {
this.forceCompositionEnd();
},
reset: function() {
this.forceCompositionEnd();
},
forceCompositionEnd: function() {
if (!this.composing || this.composing.handled) return;
this.applyComposition(this.composing);
this.composing.handled = true;
this.div.blur();
this.div.focus();
},
applyComposition: function(composing) {
if (this.cm.isReadOnly())
operation(this.cm, regChange)(this.cm)
else if (composing.data && composing.data != composing.startData)
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
},
setUneditable: function(node) {
node.contentEditable = "false"
},
onKeyPress: function(e) {
e.preventDefault();
if (!this.cm.isReadOnly())
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
},
readOnlyChanged: function(val) {
this.div.contentEditable = String(val != "nocursor")
},
onContextMenu: nothing,
resetPosition: nothing,
needsContentAttribute: true
}, ContentEditableInput.prototype);
function posToDOM(cm, pos) {
var view = findViewForLine(cm, pos.line);
if (!view || view.hidden) return null;
var line = getLine(cm.doc, pos.line);
var info = mapFromLineView(view, line, pos.line);
var order = getOrder(line), side = "left";
if (order) {
var partPos = getBidiPartAt(order, pos.ch);
side = partPos % 2 ? "right" : "left";
}
var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
result.offset = result.collapse == "right" ? result.end : result.start;
return result;
}
function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
function domToPos(cm, node, offset) {
var lineNode;
if (node == cm.display.lineDiv) {
lineNode = cm.display.lineDiv.childNodes[offset];
if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
node = null; offset = 0;
} else {
for (lineNode = node;; lineNode = lineNode.parentNode) {
if (!lineNode || lineNode == cm.display.lineDiv) return null;
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
}
}
for (var i = 0; i < cm.display.view.length; i++) {
var lineView = cm.display.view[i];
if (lineView.node == lineNode)
return locateNodeInLineView(lineView, node, offset);
}
}
function locateNodeInLineView(lineView, node, offset) {
var wrapper = lineView.text.firstChild, bad = false;
if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
if (node == wrapper) {
bad = true;
node = wrapper.childNodes[offset];
offset = 0;
if (!node) {
var line = lineView.rest ? lst(lineView.rest) : lineView.line;
return badPos(Pos(lineNo(line), line.text.length), bad);
}
}
var textNode = node.nodeType == 3 ? node : null, topNode = node;
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
textNode = node.firstChild;
if (offset) offset = textNode.nodeValue.length;
}
while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
var measure = lineView.measure, maps = measure.maps;
function find(textNode, topNode, offset) {
for (var i = -1; i < (maps ? maps.length : 0); i++) {
var map = i < 0 ? measure.map : maps[i];
for (var j = 0; j < map.length; j += 3) {
var curNode = map[j + 2];
if (curNode == textNode || curNode == topNode) {
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
var ch = map[j] + offset;
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
return Pos(line, ch);
}
}
}
}
var found = find(textNode, topNode, offset);
if (found) return badPos(found, bad);
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
found = find(after, after.firstChild, 0);
if (found)
return badPos(Pos(found.line, found.ch - dist), bad);
else
dist += after.textContent.length;
}
for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
found = find(before, before.firstChild, -1);
if (found)
return badPos(Pos(found.line, found.ch + dist), bad);
else
dist += after.textContent.length;
}
}
function domTextBetween(cm, from, to, fromLine, toLine) {
var text = "", closing = false, lineSep = cm.doc.lineSeparator();
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
function walk(node) {
if (node.nodeType == 1) {
var cmText = node.getAttribute("cm-text");
if (cmText != null) {
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
text += cmText;
return;
}
var markerID = node.getAttribute("cm-marker"), range;
if (markerID) {
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
if (found.length && (range = found[0].find()))
text += getBetween(cm.doc, range.from, range.to).join(lineSep);
return;
}
if (node.getAttribute("contenteditable") == "false") return;
for (var i = 0; i < node.childNodes.length; i++)
walk(node.childNodes[i]);
if (/^(pre|div|p)$/i.test(node.nodeName))
closing = true;
} else if (node.nodeType == 3) {
var val = node.nodeValue;
if (!val) return;
if (closing) {
text += lineSep;
closing = false;
}
text += val;
}
}
for (;;) {
walk(from);
if (from == to) break;
from = from.nextSibling;
}
return text;
}
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
// SELECTION / CURSOR
// Selection objects are immutable. A new one is created every time
// the selection changes. A selection is one or more non-overlapping
// (and non-touching) ranges, sorted, and an integer that indicates
// which one is the primary selection (the one that's scrolled into
// view, that getCursor returns, etc).
function Selection(ranges, primIndex) {
this.ranges = ranges;
this.primIndex = primIndex;
}
Selection.prototype = {
primary: function() { return this.ranges[this.primIndex]; },
equals: function(other) {
if (other == this) return true;
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
for (var i = 0; i < this.ranges.length; i++) {
var here = this.ranges[i], there = other.ranges[i];
if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
}
return true;
},
deepCopy: function() {
for (var out = [], i = 0; i < this.ranges.length; i++)
out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
return new Selection(out, this.primIndex);
},
somethingSelected: function() {
for (var i = 0; i < this.ranges.length; i++)
if (!this.ranges[i].empty()) return true;
return false;
},
contains: function(pos, end) {
if (!end) end = pos;
for (var i = 0; i < this.ranges.length; i++) {
var range = this.ranges[i];
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
return i;
}
return -1;
}
};
function Range(anchor, head) {
this.anchor = anchor; this.head = head;
}
Range.prototype = {
from: function() { return minPos(this.anchor, this.head); },
to: function() { return maxPos(this.anchor, this.head); },
empty: function() {
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
}
};
// Take an unsorted, potentially overlapping set of ranges, and
// build a selection out of it. 'Consumes' ranges array (modifying
// it).
function normalizeSelection(ranges, primIndex) {
var prim = ranges[primIndex];
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
primIndex = indexOf(ranges, prim);
for (var i = 1; i < ranges.length; i++) {
var cur = ranges[i], prev = ranges[i - 1];
if (cmp(prev.to(), cur.from()) >= 0) {
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
if (i <= primIndex) --primIndex;
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
}
}
return new Selection(ranges, primIndex);
}
function simpleSelection(anchor, head) {
return new Selection([new Range(anchor, head || anchor)], 0);
}
// Most of the external API clips given positions to make sure they
// actually exist within the document.
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
function clipPos(doc, pos) {
if (pos.line < doc.first) return Pos(doc.first, 0);
var last = doc.first + doc.size - 1;
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
return clipToLen(pos, getLine(doc, pos.line).text.length);
}
function clipToLen(pos, linelen) {
var ch = pos.ch;
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
else if (ch < 0) return Pos(pos.line, 0);
else return pos;
}
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
function clipPosArray(doc, array) {
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
return out;
}
// SELECTION UPDATES
// The 'scroll' parameter given to many of these indicated whether
// the new cursor position should be scrolled into view after
// modifying the selection.
// If shift is held or the extend flag is set, extends a range to
// include a given position (and optionally a second position).
// Otherwise, simply returns the range between the given positions.
// Used for cursor motion and such.
function extendRange(doc, range, head, other) {
if (doc.cm && doc.cm.display.shift || doc.extend) {
var anchor = range.anchor;
if (other) {
var posBefore = cmp(head, anchor) < 0;
if (posBefore != (cmp(other, anchor) < 0)) {
anchor = head;
head = other;
} else if (posBefore != (cmp(head, other) < 0)) {
head = other;
}
}
return new Range(anchor, head);
} else {
return new Range(other || head, head);
}
}
// Extend the primary selection range, discard the rest.
function extendSelection(doc, head, other, options) {
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
}
// Extend all selections (pos is an array of selections with length
// equal the number of selections)
function extendSelections(doc, heads, options) {
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
var newSel = normalizeSelection(out, doc.sel.primIndex);
setSelection(doc, newSel, options);
}
// Updates a single range in the selection.
function replaceOneSelection(doc, i, range, options) {
var ranges = doc.sel.ranges.slice(0);
ranges[i] = range;
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
}
// Reset the selection to a single range.
function setSimpleSelection(doc, anchor, head, options) {
setSelection(doc, simpleSelection(anchor, head), options);
}
// Give beforeSelectionChange handlers a change to influence a
// selection update.
function filterSelectionChange(doc, sel, options) {
var obj = {
ranges: sel.ranges,
update: function(ranges) {
this.ranges = [];
for (var i = 0; i < ranges.length; i++)
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
clipPos(doc, ranges[i].head));
},
origin: options && options.origin
};
signal(doc, "beforeSelectionChange", doc, obj);
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
else return sel;
}
function setSelectionReplaceHistory(doc, sel, options) {
var done = doc.history.done, last = lst(done);
if (last && last.ranges) {
done[done.length - 1] = sel;
setSelectionNoUndo(doc, sel, options);
} else {
setSelection(doc, sel, options);
}
}
// Set a new selection.
function setSelection(doc, sel, options) {
setSelectionNoUndo(doc, sel, options);
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
}
function setSelectionNoUndo(doc, sel, options) {
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
sel = filterSelectionChange(doc, sel, options);
var bias = options && options.bias ||
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
if (!(options && options.scroll === false) && doc.cm)
ensureCursorVisible(doc.cm);
}
function setSelectionInner(doc, sel) {
if (sel.equals(doc.sel)) return;
doc.sel = sel;
if (doc.cm) {
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
signalCursorActivity(doc.cm);
}
signalLater(doc, "cursorActivity", doc);
}
// Verify that the selection does not partially select any atomic
// marked ranges.
function reCheckSelection(doc) {
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
}
// Return a selection that does not partially select any atomic
// ranges.
function skipAtomicInSelection(doc, sel, bias, mayClear) {
var out;
for (var i = 0; i < sel.ranges.length; i++) {
var range = sel.ranges[i];
var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
if (out || newAnchor != range.anchor || newHead != range.head) {
if (!out) out = sel.ranges.slice(0, i);
out[i] = new Range(newAnchor, newHead);
}
}
return out ? normalizeSelection(out, sel.primIndex) : sel;
}
function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
var line = getLine(doc, pos.line);
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
var sp = line.markedSpans[i], m = sp.marker;
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
(sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
if (mayClear) {
signal(m, "beforeCursorEnter");
if (m.explicitlyCleared) {
if (!line.markedSpans) break;
else {--i; continue;}
}
}
if (!m.atomic) continue;
if (oldPos) {
var near = m.find(dir < 0 ? 1 : -1), diff;
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
return skipAtomicInner(doc, near, pos, dir, mayClear);
}
var far = m.find(dir < 0 ? -1 : 1);
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
far = movePos(doc, far, dir, far.line == pos.line ? line : null);
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
}
}
return pos;
}
// Ensure a given position is not inside an atomic range.
function skipAtomic(doc, pos, oldPos, bias, mayClear) {
var dir = bias || 1;
var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
(!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
(!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
if (!found) {
doc.cantEdit = true;
return Pos(doc.first, 0);
}
return found;
}
function movePos(doc, pos, dir, line) {
if (dir < 0 && pos.ch == 0) {
if (pos.line > doc.first) return clipPos(doc, Pos(pos.line - 1));
else return null;
} else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
if (pos.line < doc.first + doc.size - 1) return Pos(pos.line + 1, 0);
else return null;
} else {
return new Pos(pos.line, pos.ch + dir);
}
}
// SELECTION DRAWING
function updateSelection(cm) {
cm.display.input.showSelection(cm.display.input.prepareSelection());
}
function prepareSelection(cm, primary) {
var doc = cm.doc, result = {};
var curFragment = result.cursors = document.createDocumentFragment();
var selFragment = result.selection = document.createDocumentFragment();
for (var i = 0; i < doc.sel.ranges.length; i++) {
if (primary === false && i == doc.sel.primIndex) continue;
var range = doc.sel.ranges[i];
if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
var collapsed = range.empty();
if (collapsed || cm.options.showCursorWhenSelecting)
drawSelectionCursor(cm, range.head, curFragment);
if (!collapsed)
drawSelectionRange(cm, range, selFragment);
}
return result;
}
// Draws a cursor for the given range
function drawSelectionCursor(cm, head, output) {
var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
cursor.style.left = pos.left + "px";
cursor.style.top = pos.top + "px";
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
if (pos.other) {
// Secondary cursor, shown when on a 'jump' in bi-directional text
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
otherCursor.style.display = "";
otherCursor.style.left = pos.other.left + "px";
otherCursor.style.top = pos.other.top + "px";
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
}
}
// Draws the given range as a highlighted selection
function drawSelectionRange(cm, range, output) {
var display = cm.display, doc = cm.doc;
var fragment = document.createDocumentFragment();
var padding = paddingH(cm.display), leftSide = padding.left;
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
function add(left, top, width, bottom) {
if (top < 0) top = 0;
top = Math.round(top);
bottom = Math.round(bottom);
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
"px; height: " + (bottom - top) + "px"));
}
function drawForLine(line, fromArg, toArg) {
var lineObj = getLine(doc, line);
var lineLen = lineObj.text.length;
var start, end;
function coords(ch, bias) {
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
}
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
var leftPos = coords(from, "left"), rightPos, left, right;
if (from == to) {
rightPos = leftPos;
left = right = leftPos.left;
} else {
rightPos = coords(to - 1, "right");
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
left = leftPos.left;
right = rightPos.right;
}
if (fromArg == null && from == 0) left = leftSide;
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
add(left, leftPos.top, null, leftPos.bottom);
left = leftSide;
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
}
if (toArg == null && to == lineLen) right = rightSide;
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
start = leftPos;
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
end = rightPos;
if (left < leftSide + 1) left = leftSide;
add(left, rightPos.top, right - left, rightPos.bottom);
});
return {start: start, end: end};
}
var sFrom = range.from(), sTo = range.to();
if (sFrom.line == sTo.line) {
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
} else {
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
var singleVLine = visualLine(fromLine) == visualLine(toLine);
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
if (singleVLine) {
if (leftEnd.top < rightStart.top - 2) {
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
} else {
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
}
}
if (leftEnd.bottom < rightStart.top)
add(leftSide, leftEnd.bottom, null, rightStart.top);
}
output.appendChild(fragment);
}
// Cursor-blinking
function restartBlink(cm) {
if (!cm.state.focused) return;
var display = cm.display;
clearInterval(display.blinker);
var on = true;
display.cursorDiv.style.visibility = "";
if (cm.options.cursorBlinkRate > 0)
display.blinker = setInterval(function() {
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
}, cm.options.cursorBlinkRate);
else if (cm.options.cursorBlinkRate < 0)
display.cursorDiv.style.visibility = "hidden";
}
// HIGHLIGHT WORKER
function startWorker(cm, time) {
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
cm.state.highlight.set(time, bind(highlightWorker, cm));
}
function highlightWorker(cm) {
var doc = cm.doc;
if (doc.frontier < doc.first) doc.frontier = doc.first;
if (doc.frontier >= cm.display.viewTo) return;
var end = +new Date + cm.options.workTime;
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
var changedLines = [];
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
if (doc.frontier >= cm.display.viewFrom) { // Visible
var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
line.styles = highlighted.styles;
var oldCls = line.styleClasses, newCls = highlighted.classes;
if (newCls) line.styleClasses = newCls;
else if (oldCls) line.styleClasses = null;
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
oldCls != newCls && (!oldCls
gitextract_bzego8h5/
├── .eslintrc
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── bower.json
├── debug/
│ ├── simplemde.css
│ ├── simplemde.debug.js
│ └── simplemde.js
├── gulpfile.js
├── package.json
└── src/
├── css/
│ └── simplemde.css
└── js/
├── codemirror/
│ └── tablist.js
└── simplemde.js
SYMBOL INDEX (1040 symbols across 4 files)
FILE: debug/simplemde.debug.js
function s (line 7) | function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&re...
function init (line 17) | function init () {
function toByteArray (line 30) | function toByteArray (b64) {
function tripletToBase64 (line 72) | function tripletToBase64 (num) {
function encodeChunk (line 76) | function encodeChunk (uint8, start, end) {
function fromByteArray (line 86) | function fromByteArray (uint8) {
function typedArraySupport (line 173) | function typedArraySupport () {
function kMaxLength (line 185) | function kMaxLength () {
function createBuffer (line 191) | function createBuffer (that, length) {
function Buffer (line 220) | function Buffer (arg, encodingOrOffset, length) {
function from (line 245) | function from (that, value, encodingOrOffset, length) {
function assertSize (line 286) | function assertSize (size) {
function alloc (line 292) | function alloc (that, size, fill, encoding) {
function allocUnsafe (line 316) | function allocUnsafe (that, size) {
function fromString (line 340) | function fromString (that, string, encoding) {
function fromArrayLike (line 356) | function fromArrayLike (that, array) {
function fromArrayBuffer (line 365) | function fromArrayBuffer (that, array, byteOffset, length) {
function fromObject (line 393) | function fromObject (that, obj) {
function checked (line 423) | function checked (length) {
function SlowBuffer (line 433) | function SlowBuffer (length) {
function byteLength (line 516) | function byteLength (string, encoding) {
function slowToString (line 563) | function slowToString (encoding, start, end) {
function swap (line 636) | function swap (b, n, m) {
function arrayIndexOf (line 747) | function arrayIndexOf (arr, val, byteOffset, encoding) {
function hexWrite (line 829) | function hexWrite (buf, string, offset, length) {
function utf8Write (line 856) | function utf8Write (buf, string, offset, length) {
function asciiWrite (line 860) | function asciiWrite (buf, string, offset, length) {
function binaryWrite (line 864) | function binaryWrite (buf, string, offset, length) {
function base64Write (line 868) | function base64Write (buf, string, offset, length) {
function ucs2Write (line 872) | function ucs2Write (buf, string, offset, length) {
function base64Slice (line 954) | function base64Slice (buf, start, end) {
function utf8Slice (line 962) | function utf8Slice (buf, start, end) {
function decodeCodePointsArray (line 1040) | function decodeCodePointsArray (codePoints) {
function asciiSlice (line 1058) | function asciiSlice (buf, start, end) {
function binarySlice (line 1068) | function binarySlice (buf, start, end) {
function hexSlice (line 1078) | function hexSlice (buf, start, end) {
function utf16leSlice (line 1091) | function utf16leSlice (buf, start, end) {
function checkOffset (line 1139) | function checkOffset (offset, ext, length) {
function checkInt (line 1300) | function checkInt (buf, value, offset, ext, max, min) {
function objectWriteUInt16 (line 1353) | function objectWriteUInt16 (buf, value, offset, littleEndian) {
function objectWriteUInt32 (line 1387) | function objectWriteUInt32 (buf, value, offset, littleEndian) {
function checkIEEE754 (line 1537) | function checkIEEE754 (buf, value, offset, ext, max, min) {
function writeFloat (line 1542) | function writeFloat (buf, value, offset, littleEndian, noAssert) {
function writeDouble (line 1558) | function writeDouble (buf, value, offset, littleEndian, noAssert) {
function base64clean (line 1691) | function base64clean (str) {
function stringtrim (line 1703) | function stringtrim (str) {
function toHex (line 1708) | function toHex (n) {
function utf8ToBytes (line 1713) | function utf8ToBytes (string, units) {
function asciiToBytes (line 1793) | function asciiToBytes (str) {
function utf16leToBytes (line 1802) | function utf16leToBytes (str, units) {
function base64ToBytes (line 1818) | function base64ToBytes (str) {
function blitBuffer (line 1822) | function blitBuffer (src, dst, offset, length) {
function isnan (line 1830) | function isnan (val) {
function CodeMirrorSpellChecker (line 1846) | function CodeMirrorSpellChecker(options) {
function setFullscreen (line 1977) | function setFullscreen(cm) {
function setNormal (line 1988) | function setNormal(cm) {
function clearPlaceholder (line 2030) | function clearPlaceholder(cm) {
function setPlaceholder (line 2036) | function setPlaceholder(cm) {
function onBlur (line 2047) | function onBlur(cm) {
function onChange (line 2050) | function onChange(cm) {
function isEmpty (line 2058) | function isEmpty(cm) {
function onCursorActivity (line 2239) | function onCursorActivity(cm) {
function onChange (line 2243) | function onChange(cm) {
function coverRange (line 2252) | function coverRange(cm, from, to, addAt) {
function clear (line 2268) | function clear(cm) {
function reset (line 2274) | function reset(cm) {
function update (line 2281) | function update(cm) {
function CodeMirror (line 2385) | function CodeMirror(place, options) {
function Display (line 2460) | function Display(place, doc, input) {
function loadMode (line 2562) | function loadMode(cm) {
function resetModeState (line 2567) | function resetModeState(cm) {
function wrappingChanged (line 2578) | function wrappingChanged(cm) {
function estimateHeight (line 2596) | function estimateHeight(cm) {
function estimateLineHeights (line 2614) | function estimateLineHeights(cm) {
function themeChanged (line 2622) | function themeChanged(cm) {
function guttersChanged (line 2628) | function guttersChanged(cm) {
function updateGutters (line 2636) | function updateGutters(cm) {
function updateGutterSpace (line 2651) | function updateGutterSpace(cm) {
function lineLength (line 2659) | function lineLength(line) {
function findMaxLine (line 2678) | function findMaxLine(cm) {
function setGuttersForLineNumbers (line 2694) | function setGuttersForLineNumbers(options) {
function measureForScrollbars (line 2708) | function measureForScrollbars(cm) {
function NativeScrollbars (line 2724) | function NativeScrollbars(place, scroll, cm) {
function maybeDisable (line 2796) | function maybeDisable() {
function NullScrollbars (line 2817) | function NullScrollbars() {}
function initScrollbars (line 2828) | function initScrollbars(cm) {
function updateScrollbars (line 2850) | function updateScrollbars(cm, measure) {
function updateScrollbarsInner (line 2864) | function updateScrollbarsInner(cm, measure) {
function visibleLines (line 2887) | function visibleLines(display, doc, viewport) {
function alignHorizontally (line 2912) | function alignHorizontally(cm) {
function maybeUpdateLineNumberWidth (line 2931) | function maybeUpdateLineNumberWidth(cm) {
function lineNumberFor (line 2949) | function lineNumberFor(options, i) {
function compensateForHScroll (line 2956) | function compensateForHScroll(display) {
function DisplayUpdate (line 2962) | function DisplayUpdate(cm, viewport, force) {
function maybeClipScrollbars (line 2986) | function maybeClipScrollbars(cm) {
function updateDisplayIfNeeded (line 3000) | function updateDisplayIfNeeded(cm, update) {
function postUpdateDisplay (line 3072) | function postUpdateDisplay(cm, update) {
function updateDisplaySimple (line 3101) | function updateDisplaySimple(cm, viewport) {
function setDocumentHeight (line 3114) | function setDocumentHeight(cm, measure) {
function updateHeightsInViewport (line 3122) | function updateHeightsInViewport(cm) {
function updateWidgetHeight (line 3149) | function updateWidgetHeight(line) {
function getDimensions (line 3156) | function getDimensions(cm) {
function patchDisplay (line 3174) | function patchDisplay(cm, updateNumbersFrom, dims) {
function updateLineForChanges (line 3219) | function updateLineForChanges(cm, lineView, lineN, dims) {
function ensureLineWrapped (line 3232) | function ensureLineWrapped(lineView) {
function updateLineBackground (line 3243) | function updateLineBackground(lineView) {
function getLineContent (line 3257) | function getLineContent(cm, lineView) {
function updateLineText (line 3270) | function updateLineText(cm, lineView) {
function updateLineClasses (line 3285) | function updateLineClasses(lineView) {
function updateLineGutter (line 3295) | function updateLineGutter(cm, lineView, lineN, dims) {
function updateLineWidgets (line 3335) | function updateLineWidgets(cm, lineView, dims) {
function buildLineElement (line 3346) | function buildLineElement(cm, lineView, lineN, dims) {
function insertLineWidgets (line 3360) | function insertLineWidgets(cm, lineView, dims) {
function insertLineWidgetsFor (line 3366) | function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
function positionLineWidget (line 3382) | function positionLineWidget(widget, node, lineView, dims) {
function copyPos (line 3412) | function copyPos(x) {return Pos(x.line, x.ch);}
function maxPos (line 3413) | function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
function minPos (line 3414) | function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
function ensureFocus (line 3418) | function ensureFocus(cm) {
function applyTextInput (line 3427) | function applyTextInput(cm, inserted, deleted, sel, origin) {
function handlePaste (line 3474) | function handlePaste(e, cm) {
function triggerElectric (line 3484) | function triggerElectric(cm, inserted) {
function copyableRanges (line 3508) | function copyableRanges(cm) {
function disableBrowserMagic (line 3519) | function disableBrowserMagic(field) {
function TextareaInput (line 3527) | function TextareaInput(cm) {
function hiddenTextarea (line 3546) | function hiddenTextarea() {
function prepareCopyCut (line 3587) | function prepareCopyCut(e) {
function p (line 3728) | function p() {
function prepareSelectAllHack (line 3832) | function prepareSelectAllHack() {
function rehide (line 3845) | function rehide() {
function ContentEditableInput (line 3889) | function ContentEditableInput(cm) {
function onCopyCut (line 3946) | function onCopyCut(e) {
function poll (line 4079) | function poll() {
function posToDOM (line 4199) | function posToDOM(cm, pos) {
function badPos (line 4215) | function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
function domToPos (line 4217) | function domToPos(cm, node, offset) {
function locateNodeInLineView (line 4236) | function locateNodeInLineView(lineView, node, offset) {
function domTextBetween (line 4291) | function domTextBetween(cm, from, to, fromLine, toLine) {
function Selection (line 4341) | function Selection(ranges, primIndex) {
function Range (line 4378) | function Range(anchor, head) {
function normalizeSelection (line 4393) | function normalizeSelection(ranges, primIndex) {
function simpleSelection (line 4409) | function simpleSelection(anchor, head) {
function clipLine (line 4415) | function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.fi...
function clipPos (line 4416) | function clipPos(doc, pos) {
function clipToLen (line 4422) | function clipToLen(pos, linelen) {
function isLine (line 4428) | function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.si...
function clipPosArray (line 4429) | function clipPosArray(doc, array) {
function extendRange (line 4444) | function extendRange(doc, range, head, other) {
function extendSelection (line 4463) | function extendSelection(doc, head, other, options) {
function extendSelections (line 4469) | function extendSelections(doc, heads, options) {
function replaceOneSelection (line 4477) | function replaceOneSelection(doc, i, range, options) {
function setSimpleSelection (line 4484) | function setSimpleSelection(doc, anchor, head, options) {
function filterSelectionChange (line 4490) | function filterSelectionChange(doc, sel, options) {
function setSelectionReplaceHistory (line 4507) | function setSelectionReplaceHistory(doc, sel, options) {
function setSelection (line 4518) | function setSelection(doc, sel, options) {
function setSelectionNoUndo (line 4523) | function setSelectionNoUndo(doc, sel, options) {
function setSelectionInner (line 4535) | function setSelectionInner(doc, sel) {
function reCheckSelection (line 4549) | function reCheckSelection(doc) {
function skipAtomicInSelection (line 4555) | function skipAtomicInSelection(doc, sel, bias, mayClear) {
function skipAtomicInner (line 4570) | function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
function skipAtomic (line 4603) | function skipAtomic(doc, pos, oldPos, bias, mayClear) {
function movePos (line 4616) | function movePos(doc, pos, dir, line) {
function updateSelection (line 4630) | function updateSelection(cm) {
function prepareSelection (line 4634) | function prepareSelection(cm, primary) {
function drawSelectionCursor (line 4653) | function drawSelectionCursor(cm, head, output) {
function drawSelectionRange (line 4672) | function drawSelectionRange(cm, range, output) {
function restartBlink (line 4747) | function restartBlink(cm) {
function startWorker (line 4763) | function startWorker(cm, time) {
function highlightWorker (line 4768) | function highlightWorker(cm) {
function findStartLine (line 4811) | function findStartLine(cm, n, precise) {
function getStateBefore (line 4827) | function getStateBefore(cm, n, precise) {
function paddingTop (line 4845) | function paddingTop(display) {return display.lineSpace.offsetTop;}
function paddingVert (line 4846) | function paddingVert(display) {return display.mover.offsetHeight - displ...
function paddingH (line 4847) | function paddingH(display) {
function scrollGap (line 4856) | function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
function displayWidth (line 4857) | function displayWidth(cm) {
function displayHeight (line 4860) | function displayHeight(cm) {
function ensureLineHeights (line 4868) | function ensureLineHeights(cm, lineView, rect) {
function mapFromLineView (line 4889) | function mapFromLineView(lineView, line, lineN) {
function updateExternalMeasurement (line 4902) | function updateExternalMeasurement(cm, line) {
function measureChar (line 4915) | function measureChar(cm, line, ch, bias) {
function findViewForLine (line 4920) | function findViewForLine(cm, lineN) {
function prepareMeasureForLine (line 4933) | function prepareMeasureForLine(cm, line) {
function measureCharPrepared (line 4955) | function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
function nodeAndOffsetInLineMap (line 4977) | function nodeAndOffsetInLineMap(map, ch, bias) {
function measureCharInner (line 5014) | function measureCharInner(cm, prepared, ch, bias) {
function maybeUpdateRectForZooming (line 5073) | function maybeUpdateRectForZooming(measure, rect) {
function clearLineMeasurementCacheFor (line 5083) | function clearLineMeasurementCacheFor(lineView) {
function clearLineMeasurementCache (line 5092) | function clearLineMeasurementCache(cm) {
function clearCaches (line 5099) | function clearCaches(cm) {
function pageScrollX (line 5106) | function pageScrollX() { return window.pageXOffset || (document.document...
function pageScrollY (line 5107) | function pageScrollY() { return window.pageYOffset || (document.document...
function intoCoordSystem (line 5113) | function intoCoordSystem(cm, lineObj, rect, context) {
function fromCoordSystem (line 5135) | function fromCoordSystem(cm, coords, context) {
function charCoords (line 5152) | function charCoords(cm, pos, context, lineObj, bias) {
function cursorCoords (line 5160) | function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHei...
function estimateCoords (line 5192) | function estimateCoords(cm, pos) {
function PosWithInfo (line 5206) | function PosWithInfo(line, ch, outside, xRel) {
function coordsChar (line 5215) | function coordsChar(cm, x, y) {
function coordsCharInner (line 5236) | function coordsCharInner(cm, lineObj, lineNo, x, y) {
function textHeight (line 5278) | function textHeight(display) {
function charWidth (line 5298) | function charWidth(display) {
function startOperation (line 5320) | function startOperation(cm) {
function fireCallbacksForOps (line 5348) | function fireCallbacksForOps(group) {
function endOperation (line 5365) | function endOperation(cm) {
function endOperations (line 5380) | function endOperations(group) {
function endOperation_R1 (line 5394) | function endOperation_R1(op) {
function endOperation_W1 (line 5407) | function endOperation_W1(op) {
function endOperation_R2 (line 5411) | function endOperation_R2(op) {
function endOperation_W2 (line 5432) | function endOperation_W2(op) {
function endOperation_finish (line 5457) | function endOperation_finish(op) {
function runInOp (line 5504) | function runInOp(cm, f) {
function operation (line 5511) | function operation(cm, f) {
function methodOp (line 5521) | function methodOp(f) {
function docMethodOp (line 5529) | function docMethodOp(f) {
function LineView (line 5544) | function LineView(doc, line, lineN) {
function buildViewArray (line 5556) | function buildViewArray(cm, from, to) {
function regChange (line 5572) | function regChange(cm, from, to, lendiff) {
function regLineChange (line 5637) | function regLineChange(cm, line, type) {
function resetView (line 5651) | function resetView(cm) {
function findViewIndex (line 5659) | function findViewIndex(cm, n) {
function viewCuttingPoint (line 5670) | function viewCuttingPoint(cm, oldN, newN, dir) {
function adjustView (line 5696) | function adjustView(cm, from, to) {
function countDirtyView (line 5717) | function countDirtyView(cm) {
function registerEventHandlers (line 5729) | function registerEventHandlers(cm) {
function dragDropChanged (line 5835) | function dragDropChanged(cm, value, old) {
function onResize (line 5849) | function onResize(cm) {
function eventInWidget (line 5862) | function eventInWidget(display, e) {
function posFromMouse (line 5875) | function posFromMouse(cm, e, liberal, forRect) {
function onMouseDown (line 5896) | function onMouseDown(e) {
function leftButtonDown (line 5938) | function leftButtonDown(cm, e, start) {
function leftButtonStartDrag (line 5965) | function leftButtonStartDrag(cm, e, start, modifier) {
function leftButtonSelect (line 5993) | function leftButtonSelect(cm, e, start, type, addNew) {
function gutterEvent (line 6139) | function gutterEvent(cm, e, type, prevent) {
function clickInGutter (line 6162) | function clickInGutter(cm, e) {
function onDrop (line 6170) | function onDrop(e) {
function onDragStart (line 6229) | function onDragStart(cm, e) {
function onDragOver (line 6252) | function onDragOver(cm, e) {
function clearDragCursor (line 6264) | function clearDragCursor(cm) {
function setScrollTop (line 6275) | function setScrollTop(cm, val) {
function setScrollLeft (line 6286) | function setScrollLeft(cm, val, isScroller) {
function onScrollWheel (line 6330) | function onScrollWheel(cm, e) {
function doHandleBinding (line 6408) | function doHandleBinding(cm, bound, dropShift) {
function lookupKeyForEditor (line 6428) | function lookupKeyForEditor(cm, name, handle) {
function dispatchKey (line 6438) | function dispatchKey(cm, name, e, handle) {
function handleKeyBinding (line 6470) | function handleKeyBinding(cm, e) {
function handleCharBinding (line 6489) | function handleCharBinding(cm, e, ch) {
function onKeyDown (line 6495) | function onKeyDown(e) {
function showCrossHair (line 6516) | function showCrossHair(cm) {
function onKeyUp (line 6531) | function onKeyUp(e) {
function onKeyPress (line 6536) | function onKeyPress(e) {
function delayBlurEvent (line 6549) | function delayBlurEvent(cm) {
function onFocus (line 6559) | function onFocus(cm) {
function onBlur (line 6578) | function onBlur(cm) {
function onContextMenu (line 6595) | function onContextMenu(cm, e) {
function contextMenuInGutter (line 6601) | function contextMenuInGutter(cm, e) {
function adjustForChange (line 6618) | function adjustForChange(pos, change) {
function computeSelAfterChange (line 6627) | function computeSelAfterChange(doc, change) {
function offsetPos (line 6637) | function offsetPos(pos, old, nw) {
function computeReplacedSel (line 6646) | function computeReplacedSel(doc, changes, hint) {
function filterChange (line 6666) | function filterChange(doc, change, update) {
function makeChange (line 6690) | function makeChange(doc, change, ignoreReadOnly) {
function makeChangeInner (line 6712) | function makeChangeInner(doc, change) {
function makeChangeFromHistory (line 6730) | function makeChangeFromHistory(doc, type, allowSelectionOnly) {
function shiftDoc (line 6796) | function shiftDoc(doc, distance) {
function makeChangeSingleDoc (line 6812) | function makeChangeSingleDoc(doc, change, selAfter, spans) {
function makeChangeSingleDocInEditor (line 6845) | function makeChangeSingleDocInEditor(cm, change, spans) {
function replaceRange (line 6904) | function replaceRange(doc, code, from, to, origin) {
function maybeScrollWindow (line 6915) | function maybeScrollWindow(cm, coords) {
function scrollPosIntoView (line 6935) | function scrollPosIntoView(cm, pos, end, margin) {
function scrollIntoView (line 6959) | function scrollIntoView(cm, x1, y1, x2, y2) {
function calculateScrollPos (line 6969) | function calculateScrollPos(cm, x1, y1, x2, y2) {
function addToScrollPos (line 6999) | function addToScrollPos(cm, left, top) {
function ensureCursorVisible (line 7009) | function ensureCursorVisible(cm) {
function resolveScrollToPos (line 7023) | function resolveScrollToPos(cm) {
function indentLine (line 7043) | function indentLine(cm, n, how, aggressive) {
function changeLine (line 7105) | function changeLine(doc, handle, changeType, op) {
function deleteNearSelection (line 7116) | function deleteNearSelection(cm, compute) {
function findPosH (line 7148) | function findPosH(doc, pos, dir, unit, visually) {
function findPosV (line 7200) | function findPosV(cm, pos, dir, unit) {
function interpret (line 7621) | function interpret(val) {
function option (line 7677) | function option(name, deflt, handle, notOnInit) {
function normalizeKeyName (line 8144) | function normalizeKeyName(name) {
function getKeyMap (line 8230) | function getKeyMap(val) {
function save (line 8251) | function save() {textarea.value = cm.getValue();}
function markText (line 8501) | function markText(doc, from, to, options, type) {
function markTextShared (line 8594) | function markTextShared(doc, from, to, options, type) {
function findSharedMarkers (line 8609) | function findSharedMarkers(doc) {
function copySharedMarkers (line 8614) | function copySharedMarkers(doc, markers) {
function detachSharedMarkers (line 8626) | function detachSharedMarkers(markers) {
function MarkedSpan (line 8642) | function MarkedSpan(marker, from, to) {
function getMarkedSpanFor (line 8648) | function getMarkedSpanFor(spans, marker) {
function removeMarkedSpan (line 8656) | function removeMarkedSpan(spans, span) {
function addMarkedSpan (line 8662) | function addMarkedSpan(line, span) {
function markedSpansBefore (line 8671) | function markedSpansBefore(old, startCh, isInsert) {
function markedSpansAfter (line 8682) | function markedSpansAfter(old, endCh, isInsert) {
function stretchSpansOverChange (line 8701) | function stretchSpansOverChange(doc, change) {
function clearEmptySpans (line 8763) | function clearEmptySpans(spans) {
function mergeOldSpans (line 8777) | function mergeOldSpans(doc, change) {
function removeReadOnlyRanges (line 8800) | function removeReadOnlyRanges(doc, from, to) {
function detachMarkedSpans (line 8829) | function detachMarkedSpans(line) {
function attachMarkedSpans (line 8836) | function attachMarkedSpans(line, spans) {
function extraLeft (line 8845) | function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
function extraRight (line 8846) | function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
function compareCollapsedMarkers (line 8851) | function compareCollapsedMarkers(a, b) {
function collapsedSpanAtSide (line 8864) | function collapsedSpanAtSide(line, start) {
function collapsedSpanAtStart (line 8874) | function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, t...
function collapsedSpanAtEnd (line 8875) | function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, fal...
function conflictingCollapsedRange (line 8880) | function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
function visualLine (line 8900) | function visualLine(line) {
function visualLineContinued (line 8909) | function visualLineContinued(line) {
function visualLineNo (line 8920) | function visualLineNo(doc, lineN) {
function visualLineEndNo (line 8927) | function visualLineEndNo(doc, lineN) {
function lineIsHidden (line 8939) | function lineIsHidden(doc, line) {
function lineIsHiddenInner (line 8950) | function lineIsHiddenInner(doc, line, span) {
function adjustScrollWhenAboveVisible (line 8978) | function adjustScrollWhenAboveVisible(cm, line, diff) {
function widgetHeight (line 9007) | function widgetHeight(widget) {
function addLineWidget (line 9022) | function addLineWidget(doc, handle, node, options) {
function updateLine (line 9057) | function updateLine(line, text, markedSpans, estimateHeight) {
function cleanUpLine (line 9069) | function cleanUpLine(line) {
function extractLineClasses (line 9074) | function extractLineClasses(type, output) {
function callBlankLine (line 9088) | function callBlankLine(mode, state) {
function readToken (line 9095) | function readToken(mode, stream, state, inner) {
function takeToken (line 9105) | function takeToken(cm, pos, precise, asArray) {
function runMode (line 9127) | function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
function highlightLine (line 9168) | function highlightLine(cm, line, state, forceToEnd) {
function getLineStyles (line 9206) | function getLineStyles(cm, line, updateFrontier) {
function processLine (line 9222) | function processLine(cm, text, state, startAt) {
function interpretTokenStyle (line 9237) | function interpretTokenStyle(style, options) {
function buildLineContent (line 9249) | function buildLineContent(cm, lineView) {
function defaultSpecialCharPlaceholder (line 9306) | function defaultSpecialCharPlaceholder(ch) {
function buildToken (line 9315) | function buildToken(builder, text, style, startStyle, endStyle, title, c...
function splitSpaces (line 9373) | function splitSpaces(old) {
function buildTokenBadBidi (line 9382) | function buildTokenBadBidi(inner, order) {
function buildCollapsedSpan (line 9401) | function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
function insertLineContent (line 9418) | function insertLineContent(line, builder, styles) {
function isWholeLineUpdate (line 9491) | function isWholeLineUpdate(doc, change) {
function updateDoc (line 9497) | function updateDoc(doc, change, markedSpans, estimateHeight) {
function LeafChunk (line 9560) | function LeafChunk(lines) {
function BranchChunk (line 9600) | function BranchChunk(children) {
function linkedDocs (line 10073) | function linkedDocs(doc, f, sharedHistOnly) {
function attachDoc (line 10088) | function attachDoc(cm, doc) {
function getLine (line 10102) | function getLine(doc, n) {
function getBetween (line 10117) | function getBetween(doc, start, end) {
function getLines (line 10129) | function getLines(doc, from, to) {
function updateLineHeight (line 10137) | function updateLineHeight(line, height) {
function lineNo (line 10144) | function lineNo(line) {
function lineAtHeight (line 10158) | function lineAtHeight(chunk, h) {
function heightAtLine (line 10179) | function heightAtLine(lineObj) {
function getOrder (line 10201) | function getOrder(line) {
function History (line 10209) | function History(startGen) {
function historyChangeFromChange (line 10226) | function historyChangeFromChange(doc, change) {
function clearSelectionEvents (line 10235) | function clearSelectionEvents(array) {
function lastChangeEvent (line 10245) | function lastChangeEvent(hist, force) {
function addChangeToHistory (line 10260) | function addChangeToHistory(doc, change, selAfter, opId) {
function selectionEventCanBeMerged (line 10302) | function selectionEventCanBeMerged(doc, origin, prev, sel) {
function addSelectionToHistory (line 10315) | function addSelectionToHistory(doc, sel, opId, options) {
function pushSelectionToHistory (line 10337) | function pushSelectionToHistory(sel, dest) {
function attachLocalSpans (line 10344) | function attachLocalSpans(doc, change, from, to) {
function removeClearedSpans (line 10355) | function removeClearedSpans(spans) {
function getOldSpans (line 10365) | function getOldSpans(doc, change) {
function copyHistoryArray (line 10375) | function copyHistoryArray(events, newGroup, instantiateSel) {
function rebaseHistSelSingle (line 10400) | function rebaseHistSelSingle(pos, from, to, diff) {
function rebaseHistArray (line 10416) | function rebaseHistArray(array, from, to, diff) {
function rebaseHist (line 10444) | function rebaseHist(hist, change) {
function e_defaultPrevented (line 10463) | function e_defaultPrevented(e) {
function e_target (line 10468) | function e_target(e) {return e.target || e.srcElement;}
function e_button (line 10469) | function e_button(e) {
function getHandlers (line 10498) | function getHandlers(emitter, type, copy) {
function signalLater (line 10532) | function signalLater(emitter, type /*, values...*/) {
function fireOrphanDelayed (line 10549) | function fireOrphanDelayed() {
function signalDOMEvent (line 10558) | function signalDOMEvent(cm, e, override) {
function signalCursorActivity (line 10565) | function signalCursorActivity(cm) {
function hasHandler (line 10573) | function hasHandler(emitter, type) {
function eventMixin (line 10579) | function eventMixin(ctor) {
function Delayed (line 10596) | function Delayed() {this.id = null;}
function spaceStr (line 10636) | function spaceStr(n) {
function lst (line 10642) | function lst(arr) { return arr[arr.length-1]; }
function indexOf (line 10650) | function indexOf(array, elt) {
function map (line 10655) | function map(array, f) {
function nothing (line 10661) | function nothing() {}
function createObj (line 10663) | function createObj(base, props) {
function copyObj (line 10675) | function copyObj(obj, target, overwrite) {
function bind (line 10683) | function bind(f) {
function isWordChar (line 10693) | function isWordChar(ch, helper) {
function isEmpty (line 10699) | function isEmpty(obj) {
function isExtendingChar (line 10710) | function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendi...
function elt (line 10714) | function elt(tag, content, className, style) {
function removeChildren (line 10740) | function removeChildren(e) {
function removeChildrenAndAdd (line 10746) | function removeChildrenAndAdd(parent, e) {
function activeElt (line 10761) | function activeElt() {
function classTest (line 10774) | function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)...
function joinClasses (line 10787) | function joinClasses(a, b) {
function forEachCodeMirror (line 10800) | function forEachCodeMirror(f) {
function ensureGlobalHandlers (line 10810) | function ensureGlobalHandlers() {
function registerGlobalHandlers (line 10815) | function registerGlobalHandlers() {
function zeroWidthElement (line 10842) | function zeroWidthElement(measure) {
function hasBadBidiRects (line 10857) | function hasBadBidiRects(measure) {
function hasBadZoomedRects (line 10904) | function hasBadZoomedRects(measure) {
function iterateBidiSections (line 10935) | function iterateBidiSections(order, from, to, f) {
function bidiLeft (line 10948) | function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
function bidiRight (line 10949) | function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
function lineLeft (line 10951) | function lineLeft(line) { var order = getOrder(line); return order ? bid...
function lineRight (line 10952) | function lineRight(line) {
function lineStart (line 10958) | function lineStart(cm, lineN) {
function lineEnd (line 10966) | function lineEnd(cm, lineN) {
function lineStartSmart (line 10976) | function lineStartSmart(cm, pos) {
function compareBidiLevel (line 10988) | function compareBidiLevel(order, a, b) {
function getBidiPartAt (line 10995) | function getBidiPartAt(order, pos) {
function moveInLine (line 11015) | function moveInLine(line, pos, dir, byUnit) {
function moveVisually (line 11027) | function moveVisually(line, start, dir, byUnit) {
function moveLogically (line 11050) | function moveLogically(line, start, dir, byUnit) {
function charType (line 11084) | function charType(code) {
function BidiSpan (line 11099) | function BidiSpan(level, from, to) {
function blankLine (line 11251) | function blankLine(state) {
function getMode (line 11384) | function getMode(name) {
function switchInline (line 11458) | function switchInline(stream, state, f) {
function switchBlock (line 11463) | function switchBlock(stream, state, f) {
function lineIsEmpty (line 11468) | function lineIsEmpty(line) {
function blankLine (line 11474) | function blankLine(state) {
function blockNormal (line 11500) | function blockNormal(stream, state) {
function htmlBlock (line 11596) | function htmlBlock(stream, state) {
function local (line 11611) | function local(stream, state) {
function leavingLocal (line 11624) | function leavingLocal(stream, state) {
function getType (line 11637) | function getType(state) {
function handleText (line 11716) | function handleText(stream, state) {
function inlineNormal (line 11723) | function inlineNormal(stream, state) {
function linkInline (line 11937) | function linkInline(stream, state) {
function linkHref (line 11957) | function linkHref(stream, state) {
function getLinkHrefInside (line 11977) | function getLinkHrefInside(endChar) {
function footnoteLink (line 11995) | function footnoteLink(stream, state) {
function footnoteLinkInside (line 12006) | function footnoteLinkInside(stream, state) {
function footnoteUrl (line 12020) | function footnoteUrl(stream, state) {
function inText (line 12442) | function inText(stream, state) {
function inTag (line 12490) | function inTag(stream, state) {
function inAttribute (line 12515) | function inAttribute(quote) {
function inBlock (line 12529) | function inBlock(style, terminator) {
function doctype (line 12541) | function doctype(depth) {
function Context (line 12562) | function Context(state, tagName, startOfLine) {
function popContext (line 12570) | function popContext(state) {
function maybePopContext (line 12573) | function maybePopContext(state, nextTagName) {
function baseState (line 12588) | function baseState(type, stream, state) {
function tagNameState (line 12598) | function tagNameState(type, stream, state) {
function closeTagNameState (line 12608) | function closeTagNameState(type, stream, state) {
function closeState (line 12627) | function closeState(type, _stream, state) {
function closeStateErr (line 12635) | function closeStateErr(type, stream, state) {
function attrState (line 12640) | function attrState(type, _stream, state) {
function attrEqState (line 12659) | function attrEqState(type, stream, state) {
function attrValueState (line 12664) | function attrValueState(type, stream, state) {
function attrContinuedState (line 12670) | function attrContinuedState(type, stream, state) {
function Lexer (line 12966) | function Lexer(options) {
function InlineLexer (line 13384) | function InlineLexer(links, options) {
function Renderer (line 13624) | function Renderer(options) {
function Parser (line 13771) | function Parser(options) {
function escape (line 13951) | function escape(html, encode) {
function unescape (line 13960) | function unescape(html) {
function replace (line 13973) | function replace(regex, opt) {
function noop (line 13985) | function noop() {}
function merge (line 13988) | function merge(obj) {
function marked (line 14010) | function marked(src, opt, callback) {
function addWord (line 14486) | function addWord(word, rules) {
function edits1 (line 14813) | function edits1(words) {
function known (line 14878) | function known(words) {
function correct (line 14890) | function correct(word) {
function fixShortcut (line 15076) | function fixShortcut(name) {
function createIcon (line 15089) | function createIcon(options, enableTooltips, shortcuts) {
function createSep (line 15108) | function createSep() {
function createTootlip (line 15115) | function createTootlip(title, action, shortcuts) {
function getState (line 15132) | function getState(cm, pos) {
function toggleFullScreen (line 15180) | function toggleFullScreen(editor) {
function toggleBold (line 15225) | function toggleBold(editor) {
function toggleItalic (line 15233) | function toggleItalic(editor) {
function toggleStrikethrough (line 15241) | function toggleStrikethrough(editor) {
function toggleCodeBlock (line 15248) | function toggleCodeBlock(editor) {
function toggleBlockquote (line 15534) | function toggleBlockquote(editor) {
function toggleHeadingSmaller (line 15542) | function toggleHeadingSmaller(editor) {
function toggleHeadingBigger (line 15550) | function toggleHeadingBigger(editor) {
function toggleHeading1 (line 15558) | function toggleHeading1(editor) {
function toggleHeading2 (line 15566) | function toggleHeading2(editor) {
function toggleHeading3 (line 15574) | function toggleHeading3(editor) {
function toggleUnorderedList (line 15583) | function toggleUnorderedList(editor) {
function toggleOrderedList (line 15592) | function toggleOrderedList(editor) {
function cleanBlock (line 15600) | function cleanBlock(editor) {
function drawLink (line 15608) | function drawLink(editor) {
function drawImage (line 15625) | function drawImage(editor) {
function drawTable (line 15642) | function drawTable(editor) {
function drawHorizontalRule (line 15652) | function drawHorizontalRule(editor) {
function undo (line 15663) | function undo(editor) {
function redo (line 15673) | function redo(editor) {
function toggleSideBySide (line 15683) | function toggleSideBySide(editor) {
function togglePreview (line 15744) | function togglePreview(editor) {
function _replaceSelection (line 15783) | function _replaceSelection(cm, active, startEnd, url) {
function _toggleHeading (line 15817) | function _toggleHeading(cm, direction, size) {
function _toggleLine (line 15887) | function _toggleLine(cm, name) {
function _toggleBlock (line 15924) | function _toggleBlock(editor, type, start_chars, end_chars) {
function _cleanBlock (line 15993) | function _cleanBlock(cm) {
function _mergeProperties (line 16016) | function _mergeProperties(target, source) {
function extend (line 16037) | function extend(target) {
function wordCount (line 16046) | function wordCount(data) {
function SimpleMDE (line 16256) | function SimpleMDE(options) {
function isLocalStorageAvailable (line 16522) | function isLocalStorageAvailable() {
FILE: debug/simplemde.js
function s (line 7) | function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&re...
function init (line 17) | function init () {
function toByteArray (line 30) | function toByteArray (b64) {
function tripletToBase64 (line 72) | function tripletToBase64 (num) {
function encodeChunk (line 76) | function encodeChunk (uint8, start, end) {
function fromByteArray (line 86) | function fromByteArray (uint8) {
function typedArraySupport (line 173) | function typedArraySupport () {
function kMaxLength (line 185) | function kMaxLength () {
function createBuffer (line 191) | function createBuffer (that, length) {
function Buffer (line 220) | function Buffer (arg, encodingOrOffset, length) {
function from (line 245) | function from (that, value, encodingOrOffset, length) {
function assertSize (line 286) | function assertSize (size) {
function alloc (line 292) | function alloc (that, size, fill, encoding) {
function allocUnsafe (line 316) | function allocUnsafe (that, size) {
function fromString (line 340) | function fromString (that, string, encoding) {
function fromArrayLike (line 356) | function fromArrayLike (that, array) {
function fromArrayBuffer (line 365) | function fromArrayBuffer (that, array, byteOffset, length) {
function fromObject (line 393) | function fromObject (that, obj) {
function checked (line 423) | function checked (length) {
function SlowBuffer (line 433) | function SlowBuffer (length) {
function byteLength (line 516) | function byteLength (string, encoding) {
function slowToString (line 563) | function slowToString (encoding, start, end) {
function swap (line 636) | function swap (b, n, m) {
function arrayIndexOf (line 747) | function arrayIndexOf (arr, val, byteOffset, encoding) {
function hexWrite (line 829) | function hexWrite (buf, string, offset, length) {
function utf8Write (line 856) | function utf8Write (buf, string, offset, length) {
function asciiWrite (line 860) | function asciiWrite (buf, string, offset, length) {
function binaryWrite (line 864) | function binaryWrite (buf, string, offset, length) {
function base64Write (line 868) | function base64Write (buf, string, offset, length) {
function ucs2Write (line 872) | function ucs2Write (buf, string, offset, length) {
function base64Slice (line 954) | function base64Slice (buf, start, end) {
function utf8Slice (line 962) | function utf8Slice (buf, start, end) {
function decodeCodePointsArray (line 1040) | function decodeCodePointsArray (codePoints) {
function asciiSlice (line 1058) | function asciiSlice (buf, start, end) {
function binarySlice (line 1068) | function binarySlice (buf, start, end) {
function hexSlice (line 1078) | function hexSlice (buf, start, end) {
function utf16leSlice (line 1091) | function utf16leSlice (buf, start, end) {
function checkOffset (line 1139) | function checkOffset (offset, ext, length) {
function checkInt (line 1300) | function checkInt (buf, value, offset, ext, max, min) {
function objectWriteUInt16 (line 1353) | function objectWriteUInt16 (buf, value, offset, littleEndian) {
function objectWriteUInt32 (line 1387) | function objectWriteUInt32 (buf, value, offset, littleEndian) {
function checkIEEE754 (line 1537) | function checkIEEE754 (buf, value, offset, ext, max, min) {
function writeFloat (line 1542) | function writeFloat (buf, value, offset, littleEndian, noAssert) {
function writeDouble (line 1558) | function writeDouble (buf, value, offset, littleEndian, noAssert) {
function base64clean (line 1691) | function base64clean (str) {
function stringtrim (line 1703) | function stringtrim (str) {
function toHex (line 1708) | function toHex (n) {
function utf8ToBytes (line 1713) | function utf8ToBytes (string, units) {
function asciiToBytes (line 1793) | function asciiToBytes (str) {
function utf16leToBytes (line 1802) | function utf16leToBytes (str, units) {
function base64ToBytes (line 1818) | function base64ToBytes (str) {
function blitBuffer (line 1822) | function blitBuffer (src, dst, offset, length) {
function isnan (line 1830) | function isnan (val) {
function CodeMirrorSpellChecker (line 1845) | function CodeMirrorSpellChecker(options) {
function setFullscreen (line 1976) | function setFullscreen(cm) {
function setNormal (line 1987) | function setNormal(cm) {
function clearPlaceholder (line 2029) | function clearPlaceholder(cm) {
function setPlaceholder (line 2035) | function setPlaceholder(cm) {
function onBlur (line 2046) | function onBlur(cm) {
function onChange (line 2049) | function onChange(cm) {
function isEmpty (line 2057) | function isEmpty(cm) {
function onCursorActivity (line 2238) | function onCursorActivity(cm) {
function onChange (line 2242) | function onChange(cm) {
function coverRange (line 2251) | function coverRange(cm, from, to, addAt) {
function clear (line 2267) | function clear(cm) {
function reset (line 2273) | function reset(cm) {
function update (line 2280) | function update(cm) {
function CodeMirror (line 2384) | function CodeMirror(place, options) {
function Display (line 2459) | function Display(place, doc, input) {
function loadMode (line 2561) | function loadMode(cm) {
function resetModeState (line 2566) | function resetModeState(cm) {
function wrappingChanged (line 2577) | function wrappingChanged(cm) {
function estimateHeight (line 2595) | function estimateHeight(cm) {
function estimateLineHeights (line 2613) | function estimateLineHeights(cm) {
function themeChanged (line 2621) | function themeChanged(cm) {
function guttersChanged (line 2627) | function guttersChanged(cm) {
function updateGutters (line 2635) | function updateGutters(cm) {
function updateGutterSpace (line 2650) | function updateGutterSpace(cm) {
function lineLength (line 2658) | function lineLength(line) {
function findMaxLine (line 2677) | function findMaxLine(cm) {
function setGuttersForLineNumbers (line 2693) | function setGuttersForLineNumbers(options) {
function measureForScrollbars (line 2707) | function measureForScrollbars(cm) {
function NativeScrollbars (line 2723) | function NativeScrollbars(place, scroll, cm) {
function maybeDisable (line 2795) | function maybeDisable() {
function NullScrollbars (line 2816) | function NullScrollbars() {}
function initScrollbars (line 2827) | function initScrollbars(cm) {
function updateScrollbars (line 2849) | function updateScrollbars(cm, measure) {
function updateScrollbarsInner (line 2863) | function updateScrollbarsInner(cm, measure) {
function visibleLines (line 2886) | function visibleLines(display, doc, viewport) {
function alignHorizontally (line 2911) | function alignHorizontally(cm) {
function maybeUpdateLineNumberWidth (line 2930) | function maybeUpdateLineNumberWidth(cm) {
function lineNumberFor (line 2948) | function lineNumberFor(options, i) {
function compensateForHScroll (line 2955) | function compensateForHScroll(display) {
function DisplayUpdate (line 2961) | function DisplayUpdate(cm, viewport, force) {
function maybeClipScrollbars (line 2985) | function maybeClipScrollbars(cm) {
function updateDisplayIfNeeded (line 2999) | function updateDisplayIfNeeded(cm, update) {
function postUpdateDisplay (line 3071) | function postUpdateDisplay(cm, update) {
function updateDisplaySimple (line 3100) | function updateDisplaySimple(cm, viewport) {
function setDocumentHeight (line 3113) | function setDocumentHeight(cm, measure) {
function updateHeightsInViewport (line 3121) | function updateHeightsInViewport(cm) {
function updateWidgetHeight (line 3148) | function updateWidgetHeight(line) {
function getDimensions (line 3155) | function getDimensions(cm) {
function patchDisplay (line 3173) | function patchDisplay(cm, updateNumbersFrom, dims) {
function updateLineForChanges (line 3218) | function updateLineForChanges(cm, lineView, lineN, dims) {
function ensureLineWrapped (line 3231) | function ensureLineWrapped(lineView) {
function updateLineBackground (line 3242) | function updateLineBackground(lineView) {
function getLineContent (line 3256) | function getLineContent(cm, lineView) {
function updateLineText (line 3269) | function updateLineText(cm, lineView) {
function updateLineClasses (line 3284) | function updateLineClasses(lineView) {
function updateLineGutter (line 3294) | function updateLineGutter(cm, lineView, lineN, dims) {
function updateLineWidgets (line 3334) | function updateLineWidgets(cm, lineView, dims) {
function buildLineElement (line 3345) | function buildLineElement(cm, lineView, lineN, dims) {
function insertLineWidgets (line 3359) | function insertLineWidgets(cm, lineView, dims) {
function insertLineWidgetsFor (line 3365) | function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
function positionLineWidget (line 3381) | function positionLineWidget(widget, node, lineView, dims) {
function copyPos (line 3411) | function copyPos(x) {return Pos(x.line, x.ch);}
function maxPos (line 3412) | function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
function minPos (line 3413) | function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
function ensureFocus (line 3417) | function ensureFocus(cm) {
function applyTextInput (line 3426) | function applyTextInput(cm, inserted, deleted, sel, origin) {
function handlePaste (line 3473) | function handlePaste(e, cm) {
function triggerElectric (line 3483) | function triggerElectric(cm, inserted) {
function copyableRanges (line 3507) | function copyableRanges(cm) {
function disableBrowserMagic (line 3518) | function disableBrowserMagic(field) {
function TextareaInput (line 3526) | function TextareaInput(cm) {
function hiddenTextarea (line 3545) | function hiddenTextarea() {
function prepareCopyCut (line 3586) | function prepareCopyCut(e) {
function p (line 3727) | function p() {
function prepareSelectAllHack (line 3831) | function prepareSelectAllHack() {
function rehide (line 3844) | function rehide() {
function ContentEditableInput (line 3888) | function ContentEditableInput(cm) {
function onCopyCut (line 3945) | function onCopyCut(e) {
function poll (line 4078) | function poll() {
function posToDOM (line 4198) | function posToDOM(cm, pos) {
function badPos (line 4214) | function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
function domToPos (line 4216) | function domToPos(cm, node, offset) {
function locateNodeInLineView (line 4235) | function locateNodeInLineView(lineView, node, offset) {
function domTextBetween (line 4290) | function domTextBetween(cm, from, to, fromLine, toLine) {
function Selection (line 4340) | function Selection(ranges, primIndex) {
function Range (line 4377) | function Range(anchor, head) {
function normalizeSelection (line 4392) | function normalizeSelection(ranges, primIndex) {
function simpleSelection (line 4408) | function simpleSelection(anchor, head) {
function clipLine (line 4414) | function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.fi...
function clipPos (line 4415) | function clipPos(doc, pos) {
function clipToLen (line 4421) | function clipToLen(pos, linelen) {
function isLine (line 4427) | function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.si...
function clipPosArray (line 4428) | function clipPosArray(doc, array) {
function extendRange (line 4443) | function extendRange(doc, range, head, other) {
function extendSelection (line 4462) | function extendSelection(doc, head, other, options) {
function extendSelections (line 4468) | function extendSelections(doc, heads, options) {
function replaceOneSelection (line 4476) | function replaceOneSelection(doc, i, range, options) {
function setSimpleSelection (line 4483) | function setSimpleSelection(doc, anchor, head, options) {
function filterSelectionChange (line 4489) | function filterSelectionChange(doc, sel, options) {
function setSelectionReplaceHistory (line 4506) | function setSelectionReplaceHistory(doc, sel, options) {
function setSelection (line 4517) | function setSelection(doc, sel, options) {
function setSelectionNoUndo (line 4522) | function setSelectionNoUndo(doc, sel, options) {
function setSelectionInner (line 4534) | function setSelectionInner(doc, sel) {
function reCheckSelection (line 4548) | function reCheckSelection(doc) {
function skipAtomicInSelection (line 4554) | function skipAtomicInSelection(doc, sel, bias, mayClear) {
function skipAtomicInner (line 4569) | function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
function skipAtomic (line 4602) | function skipAtomic(doc, pos, oldPos, bias, mayClear) {
function movePos (line 4615) | function movePos(doc, pos, dir, line) {
function updateSelection (line 4629) | function updateSelection(cm) {
function prepareSelection (line 4633) | function prepareSelection(cm, primary) {
function drawSelectionCursor (line 4652) | function drawSelectionCursor(cm, head, output) {
function drawSelectionRange (line 4671) | function drawSelectionRange(cm, range, output) {
function restartBlink (line 4746) | function restartBlink(cm) {
function startWorker (line 4762) | function startWorker(cm, time) {
function highlightWorker (line 4767) | function highlightWorker(cm) {
function findStartLine (line 4810) | function findStartLine(cm, n, precise) {
function getStateBefore (line 4826) | function getStateBefore(cm, n, precise) {
function paddingTop (line 4844) | function paddingTop(display) {return display.lineSpace.offsetTop;}
function paddingVert (line 4845) | function paddingVert(display) {return display.mover.offsetHeight - displ...
function paddingH (line 4846) | function paddingH(display) {
function scrollGap (line 4855) | function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
function displayWidth (line 4856) | function displayWidth(cm) {
function displayHeight (line 4859) | function displayHeight(cm) {
function ensureLineHeights (line 4867) | function ensureLineHeights(cm, lineView, rect) {
function mapFromLineView (line 4888) | function mapFromLineView(lineView, line, lineN) {
function updateExternalMeasurement (line 4901) | function updateExternalMeasurement(cm, line) {
function measureChar (line 4914) | function measureChar(cm, line, ch, bias) {
function findViewForLine (line 4919) | function findViewForLine(cm, lineN) {
function prepareMeasureForLine (line 4932) | function prepareMeasureForLine(cm, line) {
function measureCharPrepared (line 4954) | function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
function nodeAndOffsetInLineMap (line 4976) | function nodeAndOffsetInLineMap(map, ch, bias) {
function measureCharInner (line 5013) | function measureCharInner(cm, prepared, ch, bias) {
function maybeUpdateRectForZooming (line 5072) | function maybeUpdateRectForZooming(measure, rect) {
function clearLineMeasurementCacheFor (line 5082) | function clearLineMeasurementCacheFor(lineView) {
function clearLineMeasurementCache (line 5091) | function clearLineMeasurementCache(cm) {
function clearCaches (line 5098) | function clearCaches(cm) {
function pageScrollX (line 5105) | function pageScrollX() { return window.pageXOffset || (document.document...
function pageScrollY (line 5106) | function pageScrollY() { return window.pageYOffset || (document.document...
function intoCoordSystem (line 5112) | function intoCoordSystem(cm, lineObj, rect, context) {
function fromCoordSystem (line 5134) | function fromCoordSystem(cm, coords, context) {
function charCoords (line 5151) | function charCoords(cm, pos, context, lineObj, bias) {
function cursorCoords (line 5159) | function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHei...
function estimateCoords (line 5191) | function estimateCoords(cm, pos) {
function PosWithInfo (line 5205) | function PosWithInfo(line, ch, outside, xRel) {
function coordsChar (line 5214) | function coordsChar(cm, x, y) {
function coordsCharInner (line 5235) | function coordsCharInner(cm, lineObj, lineNo, x, y) {
function textHeight (line 5277) | function textHeight(display) {
function charWidth (line 5297) | function charWidth(display) {
function startOperation (line 5319) | function startOperation(cm) {
function fireCallbacksForOps (line 5347) | function fireCallbacksForOps(group) {
function endOperation (line 5364) | function endOperation(cm) {
function endOperations (line 5379) | function endOperations(group) {
function endOperation_R1 (line 5393) | function endOperation_R1(op) {
function endOperation_W1 (line 5406) | function endOperation_W1(op) {
function endOperation_R2 (line 5410) | function endOperation_R2(op) {
function endOperation_W2 (line 5431) | function endOperation_W2(op) {
function endOperation_finish (line 5456) | function endOperation_finish(op) {
function runInOp (line 5503) | function runInOp(cm, f) {
function operation (line 5510) | function operation(cm, f) {
function methodOp (line 5520) | function methodOp(f) {
function docMethodOp (line 5528) | function docMethodOp(f) {
function LineView (line 5543) | function LineView(doc, line, lineN) {
function buildViewArray (line 5555) | function buildViewArray(cm, from, to) {
function regChange (line 5571) | function regChange(cm, from, to, lendiff) {
function regLineChange (line 5636) | function regLineChange(cm, line, type) {
function resetView (line 5650) | function resetView(cm) {
function findViewIndex (line 5658) | function findViewIndex(cm, n) {
function viewCuttingPoint (line 5669) | function viewCuttingPoint(cm, oldN, newN, dir) {
function adjustView (line 5695) | function adjustView(cm, from, to) {
function countDirtyView (line 5716) | function countDirtyView(cm) {
function registerEventHandlers (line 5728) | function registerEventHandlers(cm) {
function dragDropChanged (line 5834) | function dragDropChanged(cm, value, old) {
function onResize (line 5848) | function onResize(cm) {
function eventInWidget (line 5861) | function eventInWidget(display, e) {
function posFromMouse (line 5874) | function posFromMouse(cm, e, liberal, forRect) {
function onMouseDown (line 5895) | function onMouseDown(e) {
function leftButtonDown (line 5937) | function leftButtonDown(cm, e, start) {
function leftButtonStartDrag (line 5964) | function leftButtonStartDrag(cm, e, start, modifier) {
function leftButtonSelect (line 5992) | function leftButtonSelect(cm, e, start, type, addNew) {
function gutterEvent (line 6138) | function gutterEvent(cm, e, type, prevent) {
function clickInGutter (line 6161) | function clickInGutter(cm, e) {
function onDrop (line 6169) | function onDrop(e) {
function onDragStart (line 6228) | function onDragStart(cm, e) {
function onDragOver (line 6251) | function onDragOver(cm, e) {
function clearDragCursor (line 6263) | function clearDragCursor(cm) {
function setScrollTop (line 6274) | function setScrollTop(cm, val) {
function setScrollLeft (line 6285) | function setScrollLeft(cm, val, isScroller) {
function onScrollWheel (line 6329) | function onScrollWheel(cm, e) {
function doHandleBinding (line 6407) | function doHandleBinding(cm, bound, dropShift) {
function lookupKeyForEditor (line 6427) | function lookupKeyForEditor(cm, name, handle) {
function dispatchKey (line 6437) | function dispatchKey(cm, name, e, handle) {
function handleKeyBinding (line 6469) | function handleKeyBinding(cm, e) {
function handleCharBinding (line 6488) | function handleCharBinding(cm, e, ch) {
function onKeyDown (line 6494) | function onKeyDown(e) {
function showCrossHair (line 6515) | function showCrossHair(cm) {
function onKeyUp (line 6530) | function onKeyUp(e) {
function onKeyPress (line 6535) | function onKeyPress(e) {
function delayBlurEvent (line 6548) | function delayBlurEvent(cm) {
function onFocus (line 6558) | function onFocus(cm) {
function onBlur (line 6577) | function onBlur(cm) {
function onContextMenu (line 6594) | function onContextMenu(cm, e) {
function contextMenuInGutter (line 6600) | function contextMenuInGutter(cm, e) {
function adjustForChange (line 6617) | function adjustForChange(pos, change) {
function computeSelAfterChange (line 6626) | function computeSelAfterChange(doc, change) {
function offsetPos (line 6636) | function offsetPos(pos, old, nw) {
function computeReplacedSel (line 6645) | function computeReplacedSel(doc, changes, hint) {
function filterChange (line 6665) | function filterChange(doc, change, update) {
function makeChange (line 6689) | function makeChange(doc, change, ignoreReadOnly) {
function makeChangeInner (line 6711) | function makeChangeInner(doc, change) {
function makeChangeFromHistory (line 6729) | function makeChangeFromHistory(doc, type, allowSelectionOnly) {
function shiftDoc (line 6795) | function shiftDoc(doc, distance) {
function makeChangeSingleDoc (line 6811) | function makeChangeSingleDoc(doc, change, selAfter, spans) {
function makeChangeSingleDocInEditor (line 6844) | function makeChangeSingleDocInEditor(cm, change, spans) {
function replaceRange (line 6903) | function replaceRange(doc, code, from, to, origin) {
function maybeScrollWindow (line 6914) | function maybeScrollWindow(cm, coords) {
function scrollPosIntoView (line 6934) | function scrollPosIntoView(cm, pos, end, margin) {
function scrollIntoView (line 6958) | function scrollIntoView(cm, x1, y1, x2, y2) {
function calculateScrollPos (line 6968) | function calculateScrollPos(cm, x1, y1, x2, y2) {
function addToScrollPos (line 6998) | function addToScrollPos(cm, left, top) {
function ensureCursorVisible (line 7008) | function ensureCursorVisible(cm) {
function resolveScrollToPos (line 7022) | function resolveScrollToPos(cm) {
function indentLine (line 7042) | function indentLine(cm, n, how, aggressive) {
function changeLine (line 7104) | function changeLine(doc, handle, changeType, op) {
function deleteNearSelection (line 7115) | function deleteNearSelection(cm, compute) {
function findPosH (line 7147) | function findPosH(doc, pos, dir, unit, visually) {
function findPosV (line 7199) | function findPosV(cm, pos, dir, unit) {
function interpret (line 7620) | function interpret(val) {
function option (line 7676) | function option(name, deflt, handle, notOnInit) {
function normalizeKeyName (line 8143) | function normalizeKeyName(name) {
function getKeyMap (line 8229) | function getKeyMap(val) {
function save (line 8250) | function save() {textarea.value = cm.getValue();}
function markText (line 8500) | function markText(doc, from, to, options, type) {
function markTextShared (line 8593) | function markTextShared(doc, from, to, options, type) {
function findSharedMarkers (line 8608) | function findSharedMarkers(doc) {
function copySharedMarkers (line 8613) | function copySharedMarkers(doc, markers) {
function detachSharedMarkers (line 8625) | function detachSharedMarkers(markers) {
function MarkedSpan (line 8641) | function MarkedSpan(marker, from, to) {
function getMarkedSpanFor (line 8647) | function getMarkedSpanFor(spans, marker) {
function removeMarkedSpan (line 8655) | function removeMarkedSpan(spans, span) {
function addMarkedSpan (line 8661) | function addMarkedSpan(line, span) {
function markedSpansBefore (line 8670) | function markedSpansBefore(old, startCh, isInsert) {
function markedSpansAfter (line 8681) | function markedSpansAfter(old, endCh, isInsert) {
function stretchSpansOverChange (line 8700) | function stretchSpansOverChange(doc, change) {
function clearEmptySpans (line 8762) | function clearEmptySpans(spans) {
function mergeOldSpans (line 8776) | function mergeOldSpans(doc, change) {
function removeReadOnlyRanges (line 8799) | function removeReadOnlyRanges(doc, from, to) {
function detachMarkedSpans (line 8828) | function detachMarkedSpans(line) {
function attachMarkedSpans (line 8835) | function attachMarkedSpans(line, spans) {
function extraLeft (line 8844) | function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
function extraRight (line 8845) | function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
function compareCollapsedMarkers (line 8850) | function compareCollapsedMarkers(a, b) {
function collapsedSpanAtSide (line 8863) | function collapsedSpanAtSide(line, start) {
function collapsedSpanAtStart (line 8873) | function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, t...
function collapsedSpanAtEnd (line 8874) | function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, fal...
function conflictingCollapsedRange (line 8879) | function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
function visualLine (line 8899) | function visualLine(line) {
function visualLineContinued (line 8908) | function visualLineContinued(line) {
function visualLineNo (line 8919) | function visualLineNo(doc, lineN) {
function visualLineEndNo (line 8926) | function visualLineEndNo(doc, lineN) {
function lineIsHidden (line 8938) | function lineIsHidden(doc, line) {
function lineIsHiddenInner (line 8949) | function lineIsHiddenInner(doc, line, span) {
function adjustScrollWhenAboveVisible (line 8977) | function adjustScrollWhenAboveVisible(cm, line, diff) {
function widgetHeight (line 9006) | function widgetHeight(widget) {
function addLineWidget (line 9021) | function addLineWidget(doc, handle, node, options) {
function updateLine (line 9056) | function updateLine(line, text, markedSpans, estimateHeight) {
function cleanUpLine (line 9068) | function cleanUpLine(line) {
function extractLineClasses (line 9073) | function extractLineClasses(type, output) {
function callBlankLine (line 9087) | function callBlankLine(mode, state) {
function readToken (line 9094) | function readToken(mode, stream, state, inner) {
function takeToken (line 9104) | function takeToken(cm, pos, precise, asArray) {
function runMode (line 9126) | function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
function highlightLine (line 9167) | function highlightLine(cm, line, state, forceToEnd) {
function getLineStyles (line 9205) | function getLineStyles(cm, line, updateFrontier) {
function processLine (line 9221) | function processLine(cm, text, state, startAt) {
function interpretTokenStyle (line 9236) | function interpretTokenStyle(style, options) {
function buildLineContent (line 9248) | function buildLineContent(cm, lineView) {
function defaultSpecialCharPlaceholder (line 9305) | function defaultSpecialCharPlaceholder(ch) {
function buildToken (line 9314) | function buildToken(builder, text, style, startStyle, endStyle, title, c...
function splitSpaces (line 9372) | function splitSpaces(old) {
function buildTokenBadBidi (line 9381) | function buildTokenBadBidi(inner, order) {
function buildCollapsedSpan (line 9400) | function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
function insertLineContent (line 9417) | function insertLineContent(line, builder, styles) {
function isWholeLineUpdate (line 9490) | function isWholeLineUpdate(doc, change) {
function updateDoc (line 9496) | function updateDoc(doc, change, markedSpans, estimateHeight) {
function LeafChunk (line 9559) | function LeafChunk(lines) {
function BranchChunk (line 9599) | function BranchChunk(children) {
function linkedDocs (line 10072) | function linkedDocs(doc, f, sharedHistOnly) {
function attachDoc (line 10087) | function attachDoc(cm, doc) {
function getLine (line 10101) | function getLine(doc, n) {
function getBetween (line 10116) | function getBetween(doc, start, end) {
function getLines (line 10128) | function getLines(doc, from, to) {
function updateLineHeight (line 10136) | function updateLineHeight(line, height) {
function lineNo (line 10143) | function lineNo(line) {
function lineAtHeight (line 10157) | function lineAtHeight(chunk, h) {
function heightAtLine (line 10178) | function heightAtLine(lineObj) {
function getOrder (line 10200) | function getOrder(line) {
function History (line 10208) | function History(startGen) {
function historyChangeFromChange (line 10225) | function historyChangeFromChange(doc, change) {
function clearSelectionEvents (line 10234) | function clearSelectionEvents(array) {
function lastChangeEvent (line 10244) | function lastChangeEvent(hist, force) {
function addChangeToHistory (line 10259) | function addChangeToHistory(doc, change, selAfter, opId) {
function selectionEventCanBeMerged (line 10301) | function selectionEventCanBeMerged(doc, origin, prev, sel) {
function addSelectionToHistory (line 10314) | function addSelectionToHistory(doc, sel, opId, options) {
function pushSelectionToHistory (line 10336) | function pushSelectionToHistory(sel, dest) {
function attachLocalSpans (line 10343) | function attachLocalSpans(doc, change, from, to) {
function removeClearedSpans (line 10354) | function removeClearedSpans(spans) {
function getOldSpans (line 10364) | function getOldSpans(doc, change) {
function copyHistoryArray (line 10374) | function copyHistoryArray(events, newGroup, instantiateSel) {
function rebaseHistSelSingle (line 10399) | function rebaseHistSelSingle(pos, from, to, diff) {
function rebaseHistArray (line 10415) | function rebaseHistArray(array, from, to, diff) {
function rebaseHist (line 10443) | function rebaseHist(hist, change) {
function e_defaultPrevented (line 10462) | function e_defaultPrevented(e) {
function e_target (line 10467) | function e_target(e) {return e.target || e.srcElement;}
function e_button (line 10468) | function e_button(e) {
function getHandlers (line 10497) | function getHandlers(emitter, type, copy) {
function signalLater (line 10531) | function signalLater(emitter, type /*, values...*/) {
function fireOrphanDelayed (line 10548) | function fireOrphanDelayed() {
function signalDOMEvent (line 10557) | function signalDOMEvent(cm, e, override) {
function signalCursorActivity (line 10564) | function signalCursorActivity(cm) {
function hasHandler (line 10572) | function hasHandler(emitter, type) {
function eventMixin (line 10578) | function eventMixin(ctor) {
function Delayed (line 10595) | function Delayed() {this.id = null;}
function spaceStr (line 10635) | function spaceStr(n) {
function lst (line 10641) | function lst(arr) { return arr[arr.length-1]; }
function indexOf (line 10649) | function indexOf(array, elt) {
function map (line 10654) | function map(array, f) {
function nothing (line 10660) | function nothing() {}
function createObj (line 10662) | function createObj(base, props) {
function copyObj (line 10674) | function copyObj(obj, target, overwrite) {
function bind (line 10682) | function bind(f) {
function isWordChar (line 10692) | function isWordChar(ch, helper) {
function isEmpty (line 10698) | function isEmpty(obj) {
function isExtendingChar (line 10709) | function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendi...
function elt (line 10713) | function elt(tag, content, className, style) {
function removeChildren (line 10739) | function removeChildren(e) {
function removeChildrenAndAdd (line 10745) | function removeChildrenAndAdd(parent, e) {
function activeElt (line 10760) | function activeElt() {
function classTest (line 10773) | function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)...
function joinClasses (line 10786) | function joinClasses(a, b) {
function forEachCodeMirror (line 10799) | function forEachCodeMirror(f) {
function ensureGlobalHandlers (line 10809) | function ensureGlobalHandlers() {
function registerGlobalHandlers (line 10814) | function registerGlobalHandlers() {
function zeroWidthElement (line 10841) | function zeroWidthElement(measure) {
function hasBadBidiRects (line 10856) | function hasBadBidiRects(measure) {
function hasBadZoomedRects (line 10903) | function hasBadZoomedRects(measure) {
function iterateBidiSections (line 10934) | function iterateBidiSections(order, from, to, f) {
function bidiLeft (line 10947) | function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
function bidiRight (line 10948) | function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
function lineLeft (line 10950) | function lineLeft(line) { var order = getOrder(line); return order ? bid...
function lineRight (line 10951) | function lineRight(line) {
function lineStart (line 10957) | function lineStart(cm, lineN) {
function lineEnd (line 10965) | function lineEnd(cm, lineN) {
function lineStartSmart (line 10975) | function lineStartSmart(cm, pos) {
function compareBidiLevel (line 10987) | function compareBidiLevel(order, a, b) {
function getBidiPartAt (line 10994) | function getBidiPartAt(order, pos) {
function moveInLine (line 11014) | function moveInLine(line, pos, dir, byUnit) {
function moveVisually (line 11026) | function moveVisually(line, start, dir, byUnit) {
function moveLogically (line 11049) | function moveLogically(line, start, dir, byUnit) {
function charType (line 11083) | function charType(code) {
function BidiSpan (line 11098) | function BidiSpan(level, from, to) {
function blankLine (line 11250) | function blankLine(state) {
function getMode (line 11383) | function getMode(name) {
function switchInline (line 11457) | function switchInline(stream, state, f) {
function switchBlock (line 11462) | function switchBlock(stream, state, f) {
function lineIsEmpty (line 11467) | function lineIsEmpty(line) {
function blankLine (line 11473) | function blankLine(state) {
function blockNormal (line 11499) | function blockNormal(stream, state) {
function htmlBlock (line 11595) | function htmlBlock(stream, state) {
function local (line 11610) | function local(stream, state) {
function leavingLocal (line 11623) | function leavingLocal(stream, state) {
function getType (line 11636) | function getType(state) {
function handleText (line 11715) | function handleText(stream, state) {
function inlineNormal (line 11722) | function inlineNormal(stream, state) {
function linkInline (line 11936) | function linkInline(stream, state) {
function linkHref (line 11956) | function linkHref(stream, state) {
function getLinkHrefInside (line 11976) | function getLinkHrefInside(endChar) {
function footnoteLink (line 11994) | function footnoteLink(stream, state) {
function footnoteLinkInside (line 12005) | function footnoteLinkInside(stream, state) {
function footnoteUrl (line 12019) | function footnoteUrl(stream, state) {
function inText (line 12441) | function inText(stream, state) {
function inTag (line 12489) | function inTag(stream, state) {
function inAttribute (line 12514) | function inAttribute(quote) {
function inBlock (line 12528) | function inBlock(style, terminator) {
function doctype (line 12540) | function doctype(depth) {
function Context (line 12561) | function Context(state, tagName, startOfLine) {
function popContext (line 12569) | function popContext(state) {
function maybePopContext (line 12572) | function maybePopContext(state, nextTagName) {
function baseState (line 12587) | function baseState(type, stream, state) {
function tagNameState (line 12597) | function tagNameState(type, stream, state) {
function closeTagNameState (line 12607) | function closeTagNameState(type, stream, state) {
function closeState (line 12626) | function closeState(type, _stream, state) {
function closeStateErr (line 12634) | function closeStateErr(type, stream, state) {
function attrState (line 12639) | function attrState(type, _stream, state) {
function attrEqState (line 12658) | function attrEqState(type, stream, state) {
function attrValueState (line 12663) | function attrValueState(type, stream, state) {
function attrContinuedState (line 12669) | function attrContinuedState(type, stream, state) {
function Lexer (line 12965) | function Lexer(options) {
function InlineLexer (line 13383) | function InlineLexer(links, options) {
function Renderer (line 13623) | function Renderer(options) {
function Parser (line 13770) | function Parser(options) {
function escape (line 13950) | function escape(html, encode) {
function unescape (line 13959) | function unescape(html) {
function replace (line 13972) | function replace(regex, opt) {
function noop (line 13984) | function noop() {}
function merge (line 13987) | function merge(obj) {
function marked (line 14009) | function marked(src, opt, callback) {
function addWord (line 14484) | function addWord(word, rules) {
function edits1 (line 14811) | function edits1(words) {
function known (line 14876) | function known(words) {
function correct (line 14888) | function correct(word) {
function fixShortcut (line 15073) | function fixShortcut(name) {
function createIcon (line 15086) | function createIcon(options, enableTooltips, shortcuts) {
function createSep (line 15105) | function createSep() {
function createTootlip (line 15112) | function createTootlip(title, action, shortcuts) {
function getState (line 15129) | function getState(cm, pos) {
function toggleFullScreen (line 15177) | function toggleFullScreen(editor) {
function toggleBold (line 15222) | function toggleBold(editor) {
function toggleItalic (line 15230) | function toggleItalic(editor) {
function toggleStrikethrough (line 15238) | function toggleStrikethrough(editor) {
function toggleCodeBlock (line 15245) | function toggleCodeBlock(editor) {
function toggleBlockquote (line 15531) | function toggleBlockquote(editor) {
function toggleHeadingSmaller (line 15539) | function toggleHeadingSmaller(editor) {
function toggleHeadingBigger (line 15547) | function toggleHeadingBigger(editor) {
function toggleHeading1 (line 15555) | function toggleHeading1(editor) {
function toggleHeading2 (line 15563) | function toggleHeading2(editor) {
function toggleHeading3 (line 15571) | function toggleHeading3(editor) {
function toggleUnorderedList (line 15580) | function toggleUnorderedList(editor) {
function toggleOrderedList (line 15589) | function toggleOrderedList(editor) {
function cleanBlock (line 15597) | function cleanBlock(editor) {
function drawLink (line 15605) | function drawLink(editor) {
function drawImage (line 15622) | function drawImage(editor) {
function drawTable (line 15639) | function drawTable(editor) {
function drawHorizontalRule (line 15649) | function drawHorizontalRule(editor) {
function undo (line 15660) | function undo(editor) {
function redo (line 15670) | function redo(editor) {
function toggleSideBySide (line 15680) | function toggleSideBySide(editor) {
function togglePreview (line 15741) | function togglePreview(editor) {
function _replaceSelection (line 15780) | function _replaceSelection(cm, active, startEnd, url) {
function _toggleHeading (line 15814) | function _toggleHeading(cm, direction, size) {
function _toggleLine (line 15884) | function _toggleLine(cm, name) {
function _toggleBlock (line 15921) | function _toggleBlock(editor, type, start_chars, end_chars) {
function _cleanBlock (line 15990) | function _cleanBlock(cm) {
function _mergeProperties (line 16013) | function _mergeProperties(target, source) {
function extend (line 16034) | function extend(target) {
function wordCount (line 16043) | function wordCount(data) {
function SimpleMDE (line 16253) | function SimpleMDE(options) {
function isLocalStorageAvailable (line 16519) | function isLocalStorageAvailable() {
FILE: gulpfile.js
function taskBrowserify (line 45) | function taskBrowserify(opts) {
FILE: src/js/simplemde.js
function fixShortcut (line 84) | function fixShortcut(name) {
function createIcon (line 97) | function createIcon(options, enableTooltips, shortcuts) {
function createSep (line 116) | function createSep() {
function createTootlip (line 123) | function createTootlip(title, action, shortcuts) {
function getState (line 140) | function getState(cm, pos) {
function toggleFullScreen (line 188) | function toggleFullScreen(editor) {
function toggleBold (line 233) | function toggleBold(editor) {
function toggleItalic (line 241) | function toggleItalic(editor) {
function toggleStrikethrough (line 249) | function toggleStrikethrough(editor) {
function toggleCodeBlock (line 256) | function toggleCodeBlock(editor) {
function toggleBlockquote (line 542) | function toggleBlockquote(editor) {
function toggleHeadingSmaller (line 550) | function toggleHeadingSmaller(editor) {
function toggleHeadingBigger (line 558) | function toggleHeadingBigger(editor) {
function toggleHeading1 (line 566) | function toggleHeading1(editor) {
function toggleHeading2 (line 574) | function toggleHeading2(editor) {
function toggleHeading3 (line 582) | function toggleHeading3(editor) {
function toggleUnorderedList (line 591) | function toggleUnorderedList(editor) {
function toggleOrderedList (line 600) | function toggleOrderedList(editor) {
function cleanBlock (line 608) | function cleanBlock(editor) {
function drawLink (line 616) | function drawLink(editor) {
function drawImage (line 633) | function drawImage(editor) {
function drawTable (line 650) | function drawTable(editor) {
function drawHorizontalRule (line 660) | function drawHorizontalRule(editor) {
function undo (line 671) | function undo(editor) {
function redo (line 681) | function redo(editor) {
function toggleSideBySide (line 691) | function toggleSideBySide(editor) {
function togglePreview (line 752) | function togglePreview(editor) {
function _replaceSelection (line 791) | function _replaceSelection(cm, active, startEnd, url) {
function _toggleHeading (line 825) | function _toggleHeading(cm, direction, size) {
function _toggleLine (line 895) | function _toggleLine(cm, name) {
function _toggleBlock (line 932) | function _toggleBlock(editor, type, start_chars, end_chars) {
function _cleanBlock (line 1001) | function _cleanBlock(cm) {
function _mergeProperties (line 1024) | function _mergeProperties(target, source) {
function extend (line 1045) | function extend(target) {
function wordCount (line 1054) | function wordCount(data) {
function SimpleMDE (line 1264) | function SimpleMDE(options) {
function isLocalStorageAvailable (line 1530) | function isLocalStorageAvailable() {
Condensed preview — 15 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,272K chars).
[
{
"path": ".eslintrc",
"chars": 281,
"preview": "{\n \"rules\": {\n \"indent\": [\n 2,\n \"tab\"\n ],\n \"strict\": 0,\n \"no-console\": 0,\n \"quotes\": [\n 2"
},
{
"path": ".gitignore",
"chars": 81,
"preview": "localtesting/\nnode_modules/\nbower_components/\n\n#For IDE\n*.iml\n*.ipr\n*.iws\n.idea/\n"
},
{
"path": ".travis.yml",
"chars": 963,
"preview": "language: node_js\nnode_js:\n- '6'\n- '5'\n- '4'\n- '0.12'\nbefore_script:\n- npm install -g gulp\nscript: gulp\ndeploy:\n provid"
},
{
"path": "CONTRIBUTING.md",
"chars": 1265,
"preview": "### Overview\nFirst of all, thanks for your interest in helping make SimpleMDE even better. Contributions help resolve ra"
},
{
"path": "LICENSE",
"chars": 1088,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Next Step Webs, Inc.\n\nPermission is hereby granted, free of charge, to any per"
},
{
"path": "README.md",
"chars": 14648,
"preview": "# SimpleMDE - Markdown Editor\nA drop-in JavaScript textarea replacement for writing beautiful and understandable Markdow"
},
{
"path": "bower.json",
"chars": 497,
"preview": "{\n\t\"name\": \"simplemde\",\n\t\"version\": \"1.11.2\",\n\t\"homepage\": \"https://github.com/NextStepWebs/simplemde-markdown-editor\",\n"
},
{
"path": "debug/simplemde.css",
"chars": 15260,
"preview": "/**\n * simplemde v1.11.2\n * Copyright Next Step Webs, Inc.\n * @link https://github.com/NextStepWebs/simplemde-markdown-e"
},
{
"path": "debug/simplemde.debug.js",
"chars": 1517906,
"preview": "/**\n * simplemde v1.11.2\n * Copyright Next Step Webs, Inc.\n * @link https://github.com/NextStepWebs/simplemde-markdown-e"
},
{
"path": "debug/simplemde.js",
"chars": 585853,
"preview": "/**\n * simplemde v1.11.2\n * Copyright Next Step Webs, Inc.\n * @link https://github.com/NextStepWebs/simplemde-markdown-e"
},
{
"path": "gulpfile.js",
"chars": 2708,
"preview": "\"use strict\";\n\nvar gulp = require(\"gulp\"),\n\tminifycss = require(\"gulp-clean-css\"),\n\tuglify = require(\"gulp-uglify\"),\n\tco"
},
{
"path": "package.json",
"chars": 1198,
"preview": "{\n \"name\": \"simplemde\",\n \"version\": \"1.11.2\",\n \"description\": \"A simple, beautiful, and embeddable JavaScript Markdow"
},
{
"path": "src/css/simplemde.css",
"chars": 6838,
"preview": ".CodeMirror {\n height: auto;\n min-height: 300px;\n border: 1px solid #ddd;\n border-bottom-left-radius: 4px;\n "
},
{
"path": "src/js/codemirror/tablist.js",
"chars": 1055,
"preview": "// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: http://codemirror.net/L"
},
{
"path": "src/js/simplemde.js",
"chars": 53428,
"preview": "/*global require,module*/\n\"use strict\";\nvar CodeMirror = require(\"codemirror\");\nrequire(\"codemirror/addon/edit/continuel"
}
]
About this extraction
This page contains the full source code of the sparksuite/simplemde-markdown-editor GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 15 files (2.1 MB), approximately 551.4k tokens, and a symbol index with 1040 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.