1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-07 12:34:22 +00:00
TiddlyWiki5/plugins/tiddlywiki/codemirror-mode-javascript/files/mode/javascript/javascript.js

4 lines
17 KiB
JavaScript
Raw Normal View History

CodeMirror 5.36.0 modularized (#3184) * v5.35.1 * codemirror 5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * adding search&replace and autocomplete * update version number * add jump-to-line.js required for search&replace * adding show-hint.js required by autocomplete * adding basic autocomplete for any word * adding autocomplete css * adding new files to tiddlywiki.files * forgot adding search.js * minify 'em all * Delete vim.js * Delete sublime.js * Delete emacs.js * Delete anyword-hint.js * Delete show-hint.css * Delete show-hint.js * Update config.tid * Update tiddlywiki.files * Update tiddlywiki.files * Update config.tid * Update config.tid * Update config.tid * Delete dialog.js * Delete dialog.css * Delete jump-to-line.js * Delete search.js * Delete searchcursor.js * Update tiddlywiki.files * Update tiddlywiki.files * Update tiddlywiki.files * add search-and-replace cm-addon as plugin * add autocomplete cm-addon as plugin * add fullscreen-editing cm-addon as plugin * add keymaps as plugins + cleanup * add highlighting modes as plugins * small update on usage.tid * moved multiplex.js to htmlembedded mode - the only one using it * config/CodeMirror update * how to disable line numbers * how to change CM theme * add closebrackets and closetags addons * packaging a base-addon * move meta.js from codemirror to base addon * inputStyle: textarea -> prevents contenteditable on mobile browsers, keeps focus when clicking toolbar buttons, prevents import on paste * default config no line numbers * temporary add panel plugin for demo * put base-plugin back to codemirror editor * searchcursor to searchnreplace plugin * bad copypasta mistake * another typo * stripped down meta.js + moved matchbrackets to closebrackets plugin * remove panel * change module-type to codemirro and make init "require" dynamic. * make config handling dynamic with sensible defaults * make cm settings translateable * delete multids. they will be replaced * add auto-config tiddlers * dynamically create config structure for CM * fix filename * change typo * kitchensink config, plus change plugin description for better sorting. * add matchBrackets config tiddler * RIP codeblock * removed install instructions from readme - codemirror usage tiddler still todo * control panel settings for cm base * add setting for auto-close tags * adding fontfamily settings and theme settings * change tags for settings from $:/tags/ControlPanel/Settings to $:/tags/ControlPanel/Settings/CodeMirror * more usage info * more usage info * update to v5.36.0 * ugly hack enables highlighting and tag-closing for vnd.tiddlywiki and x-tiddlywiki * disable auto-indent for vnd.tiddlywiki & x-tiddlywiki and add some hidden settings * remove engine.js hack * meta.js -> tw-meta.js * codemirror settings tab * rename tiddler to tw-meta.js * make editor font monospace or sans-serif - dropdown select * make editor font monospace or sans-serif - dropdown select * now using correct tiddler for editor font setting * better usage doc * make markdown-mode require tw-meta * add more themes info * add active-line highlighting option * mini usage change * add integer type to engine.js config-getter * blink rate config type string * correct engine.js * license for base-plugin, usage link in settings tab * codemirrordemo hellothere update * codemirrordemo hellothere update * Update license.tid * codemirror demo sidebarlayout, license * license headers to addon files * license formatting & forgot what year we have * license formatting & forgot what year we have & codemirror demo sitetitle sitesubtitle * more informations 'try-this-style' for codemirrordemo hellothere * codemirror demo sitetitle & cm fontfamily * hellothere * font-family setting must be editor-font-family, not code-font-family * add basic keyboard shortcuts table * shortcuts change to not interfere with toolbar shortcuts - needs testing - vim and emacs todo * formatting * controlpanel change keymap - default keymap is default * ctrl-T becomes Alt-T in default keymap * adjustments for codemirror demo * demo: hellothere - hint for sidebar keymap cheatsheet * toolbar focus fix + remove console log * engine.js cleanup * formatting * reverting focus fix * indenting engine.js * hoping that indenting gets better
2018-04-06 16:34:50 +00:00
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(tt){"use strict";tt.defineMode("javascript",function(e,l){var t,r,n,a,i,o,d=e.indentUnit,p=l.statementIndent,c=l.jsonld,s=l.json||c,u=l.typescript,f=l.wordCharacters||/[\w$\xa1-\uffff]/,m=(t=v("keyword a"),r=v("keyword b"),n=v("keyword c"),a=v("keyword d"),i=v("operator"),{if:v("if"),while:t,with:t,else:r,do:r,try:r,finally:r,return:a,break:a,continue:a,new:v("new"),delete:n,void:n,throw:n,debugger:v("debugger"),var:v("var"),const:v("var"),let:v("var"),function:v("function"),catch:v("catch"),for:v("for"),switch:v("switch"),case:v("case"),default:v("default"),in:i,typeof:i,instanceof:i,true:o={type:"atom",style:"atom"},false:o,null:o,undefined:o,NaN:o,Infinity:o,this:v("this"),class:v("class"),super:v("atom"),yield:n,export:v("export"),import:v("import"),extends:n,await:n});function v(e){return{type:e,style:"keyword"}}var k,y,w=/[+\-*&%=<>!?|~^@]/,b=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function x(e,t,r){return k=e,y=r,t}function h(e,t){var a,r=e.next();if('"'==r||"'"==r)return t.tokenize=(a=r,function(e,t){var r,n=!1;if(c&&"@"==e.peek()&&e.match(b))return t.tokenize=h,x("jsonld-keyword","meta");for(;null!=(r=e.next())&&(r!=a||n);)n=!n&&"\\"==r;return n||(t.tokenize=h),x("string","string")}),t.tokenize(e,t);if("."==r&&e.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return x("number","number");if("."==r&&e.match(".."))return x("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(r))return x(r);if("="==r&&e.eat(">"))return x("=>","operator");if("0"==r&&e.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return x("number","number");if(/\d/.test(r))return e.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),x("number","number");if("/"==r)return e.eat("*")?(t.tokenize=g)(e,t):e.eat("/")?(e.skipToEnd(),x("comment","comment")):et(e,t,1)?(function(e){for(var t,r=!1,n=!1;null!=(t=e.next());){if(!r){if("/"==t&&!n)return;"["==t?n=!0:n&&"]"==t&&(n=!1)}r=!r&&"\\"==t}}(e),e.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),x("regexp","string-2")):(e.eat("="),x("operator","operator",e.current()));if("`"==r)return(t.tokenize=j)(e,t);if("#"==r&&"!"==e.peek())return e.skipToEnd(),x("meta","meta");if("#"==r&&e.eatWhile(f))return x("variable","property");if("<"==r&&e.match("!--")||"-"==r&&e.match("->")&&!/\S/.test(e.string.slice(0,e.start)))return e.skipToEnd(),x("comment","comment");if(w.test(r))return">"==r&&t.lexical&&">"==t.lexical.type||(e.eat("=")?"!"!=r&&"="!=r||e.eat("="):/[<>*+\-|&?]/.test(r)&&(e.eat(r),">"==r&&e.eat(r))),"?"==r&&e.eat(".")?x("."):x("operator","operator",e.current());if(f.test(r)){e.eatWhile(f);var n=e.current();if("."!=t.lastType){if(m.propertyIsEnumerable(n)){var i=m[n];return x(i.type,i.style,n)}if("async"==n&&e.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return x("async","keyword",n)}return x("variable","variable",n)}}function g(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=h;break}n="*"==r}return x("comment","comment")}function j(e,t){for(var r,n=!1;null!=(r=e.next());){if(!n&&("`"==r||"$"==r&&e.eat("{"))){t.tokenize=h;break}n=!n&&"\\"==r}return x("quasi","string-2",e.current())}var M="([{}])";function A(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var r,n=e.string.indexOf("=>",e.start);if(!(n<0)){!u||(r=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,n)))&&(n=r.index);for(var a=0,i=!1,o=n-1;0<=o;--o){var c=e.string.charAt(o),s=M.indexOf(c);if(0<=s&&s<3){if(!a){++o;break}if(0==--a){"("==c&&(i=!0);break}}else if(3<=s&&s<6)++a;else if(f.test(c))i=!0;else if(/["'\/`]/.test(c))for(;;--o){if(0==o)return;if(e.string.charAt(o-1)==c&&"\\"!=e.string.charAt(o-2)){o--;break}}else if(i&&!a){++o;break}}i&&!a&&(t.fatArrowAt=o)}}var V={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0};function E(e,t,r,n,a,i){this.indented=e,this.column=t,this.type=r,this.prev=a,this.info=i,null!=n&&(this.align=n)}function z(e,t,r,n,a){var i=e.cc;for