Compare commits
338 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f87b19140b | |||
| 63ebbba42b | |||
| 72c6abf031 | |||
| 9db52a004a | |||
| 527fcb993c | |||
| c41209d0fc | |||
| 7e9f0159e8 | |||
| 074fb67906 | |||
| 51b0ef4b1b | |||
| 1efe94ef97 | |||
| 7f068c5d94 | |||
| eff934e8b5 | |||
| 266a770c8e | |||
| a5f94e0a5f | |||
| fff7a4f685 | |||
| d0ae8893cc | |||
| 1b4eee6498 | |||
| ac779af339 | |||
| 1316a727f3 | |||
| be950ec8c1 | |||
| ca5a39d661 | |||
| fa0256d782 | |||
| 114c217ffa | |||
| 28cfdc180c | |||
| 116058ba77 | |||
| 4211548b8b | |||
| 12b17fd7af | |||
| 47b178fbc1 | |||
| 6ab63eb32c | |||
| 6445ab3f57 | |||
| 129672eb0f | |||
| 70031d3bfa | |||
| 9db5723746 | |||
| d4ab5c7e9c | |||
| b068fd176f | |||
| f70968fe01 | |||
| 1c70433b86 | |||
| 54b685ab42 | |||
| e6f6f6b185 | |||
| 7bb3b696f7 | |||
| 6cdf5310ba | |||
| 1967b791e0 | |||
| ebb4b9154e | |||
| b32132c71f | |||
| f398fe4824 | |||
| d5b87f23cf | |||
| 7f2fc93fa3 | |||
| 32e913c629 | |||
| 87c966062c | |||
| d7f867f1a6 | |||
| e188f3474f | |||
| 1e80845aa6 | |||
| a85569e54d | |||
| 65fac2f406 | |||
| 60e28f8fe5 | |||
| 792892cb82 | |||
| 9159073483 | |||
| 8745554cee | |||
| 096e374997 | |||
| f3fed535d8 | |||
| 5305561619 | |||
| 88048f14ec | |||
| 4d6d2f1df0 | |||
| 6dcf6d38da | |||
| 38e84ab9fe | |||
| 89395ba641 | |||
| 46b80c3e2a | |||
| 285e41434a | |||
| 58cbd44a7b | |||
| ef16f2b12b | |||
| 0a30712e31 | |||
| 87727d28b9 | |||
| ff0606d0a7 | |||
| 938b3e2f3c | |||
| 86b23f4e6f | |||
| 06f8949159 | |||
| e2ea89cc0b | |||
| e50ea6af31 | |||
| 66da13aed6 | |||
| 122493df19 | |||
| 6af487e5fd | |||
| 99c128d7ca | |||
| 901621da95 | |||
| 125a418e79 | |||
| 680d0610b1 | |||
| ce25b1dbae | |||
| 7dd7142455 | |||
| b4bc200fbd | |||
| 8960923514 | |||
| cd140a73f6 | |||
| 980adbe595 | |||
| ba54969990 | |||
| cbe6613c56 | |||
| e7c05a8387 | |||
| 9dac52c0e4 | |||
| b09eb63785 | |||
| 5556cc720c | |||
| 735d947126 | |||
| b69472640f | |||
| efbdffc6fc | |||
| 5407f66aae | |||
| 0e1b49675a | |||
| 0e5be56dfe | |||
| 71e5ce8b8e | |||
| 42afa3e7ab | |||
| d3c8d9c1af | |||
| 8fbd95ab77 | |||
| 8034d3018a | |||
| ebe0b1253f | |||
| a775126f9c | |||
| 28a7a0b6a2 | |||
| 30c7113713 | |||
| 03be6673c5 | |||
| 6e9ec938fc | |||
| 6841a52024 | |||
| 1d94455c1a | |||
| e7bda6af17 | |||
| 98b3b44ed5 | |||
| 7f5e0e8e79 | |||
| 74b5d69389 | |||
| 4f4215ced5 | |||
| 53654349b5 | |||
| 3cb389aabd | |||
| d48139c40f | |||
| 05e3c89ca1 | |||
| f5cf8115af | |||
| 97d33cf177 | |||
| 7e7b37f524 | |||
| 9aef7bb460 | |||
| cdc6461064 | |||
| 56910a8c58 | |||
| caffee4b15 | |||
| 141d27d4f1 | |||
| a42427f987 | |||
| 05c952fbe1 | |||
| ca16516073 | |||
| 03f927d1d5 | |||
| e502c97de5 | |||
| a44fd6c469 | |||
| e8a64fb014 | |||
| 81e21736b7 | |||
| 488c1807d6 | |||
| 0182e9663e | |||
| db2badfc0d | |||
| 1e3f66bb19 | |||
| 32087608cc | |||
| b1f0f173e7 | |||
| e9f1246e0a | |||
| 56407539aa | |||
| a6f0341fe4 | |||
| afa1c71a0a | |||
| dafc820466 | |||
| 614b4d8350 | |||
| 73342a0506 | |||
| c55644558a | |||
| 5f46b4feae | |||
| ca2ce289aa | |||
| 0bcf931465 | |||
| 5e98640ded | |||
| e72836e0f7 | |||
| ed40ffc43f | |||
| cc6ef8de46 | |||
| ef4267e926 | |||
| e32ee93e7a | |||
| 51dd0ef4ba | |||
| dcd5acb4d1 | |||
| bb0dcf2d9d | |||
| dfe7c0a011 | |||
| 68c98d1293 | |||
| ff2c15a505 | |||
| 4e9aa716bd | |||
| 8d8e764956 | |||
| bb660b0e04 | |||
| a4de98a0e7 | |||
| 2d400a18ec | |||
| 7744b92771 | |||
| 5704beaad4 | |||
| 0f4949b0ae | |||
| 774f5989ec | |||
| 9abea054b7 | |||
| 3c607200be | |||
| d506eed827 | |||
| 7f00898767 | |||
| 7f909c9f59 | |||
| ab835d6fc3 | |||
| 17bbe1a90e | |||
| 78108c4090 | |||
| 3c8f0bac1b | |||
| 87b63c2142 | |||
| 1f5df65c48 | |||
| 09b50d3b81 | |||
| 54912ad37e | |||
| 9a399ecfe9 | |||
| c3477244b9 | |||
| 0e8c62eb4b | |||
| e1b5c45b52 | |||
| d04f92ee7f | |||
| cd76ae22a4 | |||
| 2a11f02bd2 | |||
| 42539c9d95 | |||
| 6e77f0ec58 | |||
| 1c7651f0d5 | |||
| 44a5b3385c | |||
| 1e17184194 | |||
| 808106262e | |||
| b36d75af46 | |||
| d0c89a78c2 | |||
| f68d8b53a3 | |||
| 84ea33f029 | |||
| 6392e4b13a | |||
| 14f2c2fbe6 | |||
| a77226e42b | |||
| 8b4c6c2014 | |||
| 4009ddd422 | |||
| 6794c5eedd | |||
| 20ac5c387e | |||
| 30e998e386 | |||
| e87c8c9e1e | |||
| 92d3c0c861 | |||
| 0c190f1f76 | |||
| a3f7eb0b3c | |||
| 4f35bfd51f | |||
| fc6b30f03c | |||
| 22b0ceaff7 | |||
| 357153b978 | |||
| 5d1408ad9a | |||
| 9b9988569f | |||
| dda6262601 | |||
| 6e4e847be1 | |||
| 03d8eef5ae | |||
| 4e9dd2fa02 | |||
| dcf40822e3 | |||
| b6fc04a411 | |||
| af932a9911 | |||
| da212ac188 | |||
| 3436b9edbf | |||
| 8a4f64f545 | |||
| 1480ad8145 | |||
| 9042579518 | |||
| 11bc20fad5 | |||
| 8b9ed733dd | |||
| 5c95128dfc | |||
| beca78d7a7 | |||
| 54a1e74e27 | |||
| 909ef9d242 | |||
| 6ec0e9631a | |||
| 6f7a18d6b8 | |||
| 322fdf8deb | |||
| 012fe4bc4a | |||
| 502bdf47a3 | |||
| 437320b4ad | |||
| 3b6402a682 | |||
| fa25d13469 | |||
| 4c08359394 | |||
| b5400c8223 | |||
| 5a336e8d40 | |||
| 2d1a6b1b7f | |||
| 636e2e439c | |||
| b208592e3a | |||
| 95d1941545 | |||
| 086dfff19e | |||
| 0442df4287 | |||
| e3d167bd7f | |||
| da5ed78558 | |||
| 0c46c4e656 | |||
| 304818dc13 | |||
| 05ecd0b048 | |||
| 895ec55a46 | |||
| 67c6a6c95c | |||
| 107529f844 | |||
| f39b7ae14a | |||
| aafa528f03 | |||
| e3f903cd48 | |||
| 777fe83257 | |||
| 8752d47e01 | |||
| cc49df6e55 | |||
| 5b3586d8de | |||
| d0d3a7f134 | |||
| d114edc1e2 | |||
| b26a5e902c | |||
| 6678af412d | |||
| 34872d6b8b | |||
| d7745f908f | |||
| 38a2498494 | |||
| 8c513b624a | |||
| 0cfd64318f | |||
| ab1ad48608 | |||
| d6f9c012e9 | |||
| c8e2bea8fa | |||
| 16635078ac | |||
| d615158cf9 | |||
| f5faa6da5e | |||
| b140f0aaab | |||
| 35773f4a18 | |||
| 7f4b7fb1ff | |||
| becb749e02 | |||
| a2711a735d | |||
| 190d28b6df | |||
| c0d51af664 | |||
| 51bd9cf170 | |||
| cdf331463e | |||
| 679ab49047 | |||
| 919c8733a0 | |||
| be00453f2c | |||
| 275a5d0b04 | |||
| fada4f9a9d | |||
| 08a9dbdf1d | |||
| 06e69d86b6 | |||
| 06aec0308d | |||
| b07d76ce1d | |||
| b3902fbcb1 | |||
| d2fc9820b2 | |||
| 1fbbbbe9a9 | |||
| e4a1b9d63b | |||
| 31186d99a6 | |||
| cf48fce4ff | |||
| 7536ff56a6 | |||
| fc23c2fc56 | |||
| 9386ff06fe | |||
| bbea6e4ae2 | |||
| 6ff819d917 | |||
| 27db37d21d | |||
| 3ca25b3e93 | |||
| f84d554a69 | |||
| 1292fd23f0 | |||
| 6c2ae3b433 | |||
| fe36b66dc5 | |||
| 5a963844d8 | |||
| 909c67cfba | |||
| df0c2fea3a | |||
| 85e7da252f | |||
| 2a7f76ed8d | |||
| 8c43840572 | |||
| b164de08a5 | |||
| d1efeeffa6 | |||
| 1bc2deb4d3 | |||
| bef066abda | |||
| 155556ec6e |
@@ -0,0 +1,2 @@
|
|||||||
|
dist/*
|
||||||
|
doc/out/*
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 10,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"impliedStrict": true,
|
||||||
|
"modules": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es6": true,
|
||||||
|
"node": true,
|
||||||
|
"jquery": true,
|
||||||
|
"worker": true,
|
||||||
|
"mocha": true,
|
||||||
|
"serviceworker": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"PIXI": false,
|
||||||
|
"TweenLite": false,
|
||||||
|
"TweenMax": false,
|
||||||
|
"TimelineLite": false,
|
||||||
|
"TimelineMax": false,
|
||||||
|
"SystemJS": false,
|
||||||
|
"app": true
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"extends": ["eslint:recommended", "plugin:prettier/recommended"]
|
||||||
|
}
|
||||||
@@ -76,6 +76,11 @@ typings/
|
|||||||
# FuseBox cache
|
# FuseBox cache
|
||||||
.fusebox/
|
.fusebox/
|
||||||
|
|
||||||
#own
|
# own
|
||||||
lib.code-workspace
|
.history/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# ignore generated contents-
|
||||||
|
/doc/out/*
|
||||||
|
**/thumbnails
|
||||||
|
**/thumbnail.png
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"jsxSingleQuote": true,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"semi": false,
|
||||||
|
"printWidth": 120
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
dist/*
|
||||||
|
doc/*
|
||||||
|
lib/*
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"extends": "stylelint-config-standard",
|
||||||
|
"rules": {
|
||||||
|
"indentation": 4,
|
||||||
|
"selector-list-comma-newline-after": "never-multi-line",
|
||||||
|
"no-eol-whitespace": [true, {
|
||||||
|
"ignore": ["empty-lines"]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"ignoreFiles": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Program",
|
||||||
|
"program": "${workspaceFolder}\\index.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "testrunner",
|
||||||
|
"program": "${workspaceFolder}\\bin\\testrunner.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "single",
|
||||||
|
"program": "${workspaceFolder}\\bin\\singleshot.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Import often used libraries.
|
|
||||||
*/
|
|
||||||
import './jquery.js'
|
|
||||||
import './optimal-select.js'
|
|
||||||
import './hammer.js'
|
|
||||||
import './d3/d3.v4.js'
|
|
||||||
import './d3/d3.v4.selection-multi.js'
|
|
||||||
import './highlight/highlight.pack.js'
|
|
||||||
import './pixi/pixi.js'
|
|
||||||
import './pixi/pixi-filters.js'
|
|
||||||
import './pixi/pixi-particles.js'
|
|
||||||
import './pixi/pixi-compressed-textures.js'
|
|
||||||
import './greensock/src/uncompressed/jquery.gsap.js'
|
|
||||||
import './greensock/src/uncompressed/TweenLite.js'
|
|
||||||
import './greensock/src/uncompressed/TweenMax.js'
|
|
||||||
import './greensock/src/uncompressed/TimelineLite.js'
|
|
||||||
import './greensock/src/uncompressed/TimelineMax.js'
|
|
||||||
import './greensock/src/uncompressed/easing/CustomBounce.js'
|
|
||||||
import './greensock/src/uncompressed/easing/CustomEase.js'
|
|
||||||
import './greensock/src/uncompressed/easing/CustomWiggle.js'
|
|
||||||
import './greensock/src/uncompressed/easing/EasePack.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/AttrPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/BezierPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/ColorPropsPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/CSSPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/CSSRulePlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/DirectionalRotationPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/DrawSVGPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/EaselPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/EndArrayPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/ModifiersPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/MorphSVGPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/Physics2DPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/PhysicsPropsPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/PixiPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/RaphaelPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/RoundPropsPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/ScrambleTextPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/ScrollToPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/TEMPLATE_Plugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/TextPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/plugins/ThrowPropsPlugin.js'
|
|
||||||
import './greensock/src/uncompressed/utils/Draggable.js'
|
|
||||||
import './greensock/src/uncompressed/utils/SplitText.js'
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
convertPointFromPageToNode.js
|
|
||||||
|
|
||||||
https://gist.github.com/Yaffle/1145197
|
|
||||||
No Licence ==> All Rights Reserved
|
|
||||||
|
|
||||||
|
|
||||||
D3
|
|
||||||
|
|
||||||
https://github.com/d3/d3/blob/master/LICENSE
|
|
||||||
|
|
||||||
A permissive license similar to the BSD 2-Clause License, but with a 3rd clause that prohibits others from using the name of the project or its contributors to promote derived products without written consent.
|
|
||||||
|
|
||||||
|
|
||||||
Dexie
|
|
||||||
|
|
||||||
https://github.com/dfahlander/Dexie.js/blob/master/LICENSE
|
|
||||||
Apache License 2.0
|
|
||||||
|
|
||||||
|
|
||||||
Greensock
|
|
||||||
|
|
||||||
https://greensock.com/licensing
|
|
||||||
Standard No Charge license allows commercial one-off project. Multiple installations require the "Business Green" license.
|
|
||||||
|
|
||||||
Gun DB
|
|
||||||
|
|
||||||
https://github.com/amark/gun/blob/master/LICENSE.md
|
|
||||||
Apache License, Version 2.0
|
|
||||||
|
|
||||||
Pixie
|
|
||||||
|
|
||||||
https://github.com/usmanhalalit/pixie/blob/master/LICENSE
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
|
|
||||||
jQuery
|
|
||||||
|
|
||||||
https://github.com/jquery/jquery/blob/master/LICENSE.txt
|
|
||||||
|
|
||||||
BSD style
|
|
||||||
|
|
||||||
|
|
||||||
PDF
|
|
||||||
Apache License, Version 2.0
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# Patches
|
|
||||||
|
|
||||||
A listing of all manual changes of 3rdparty files.
|
|
||||||
|
|
||||||
## PIXI.js
|
|
||||||
|
|
||||||
+ Ensure that a minimal compressed texture example is working and apply changes to deepzoom.js~~ => Patched in pixi.js (Line 5794). + Changed:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
if (status === STATUS_NONE && text.length > 0)) {`
|
|
||||||
```
|
|
||||||
to
|
|
||||||
```javascript
|
|
||||||
if (status === STATUS_NONE && (text.length > 0 || xhr.responseURL.endsWith
|
|
||||||
('.dds'))) { // PATCH: Kupke, 07.08.2017`
|
|
||||||
```
|
|
||||||
+ Loading SVG Textures from filesystem
|
|
||||||
+ Problem: In PIXI 4.7.0 the XHTTP Request of PIXI, when loading an SVG from the filesystem returned an error message and prevented the svg from being displayed.
|
|
||||||
+ Solution: Just suppress the error when on local filesystem.
|
|
||||||
+ Location: *BaseTexture.prototype._loadSvgSourceUsingXhr*
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
if(window.location.protocol !== "file:"){ // This condition was added.
|
|
||||||
if (svgXhr.readyState !== svgXhr.DONE || svgXhr.status !== 200) {
|
|
||||||
throw new Error('Failed to load SVG using XHR.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
|
|
||||||
position: absolute;
|
|
||||||
background: #ccc;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
border: 1px solid #bbb;
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 6;
|
|
||||||
background: #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-simplescroll-horizontal {
|
|
||||||
bottom: 0; left: 0;
|
|
||||||
height: 8px;
|
|
||||||
}
|
|
||||||
.CodeMirror-simplescroll-horizontal div {
|
|
||||||
bottom: 0;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-simplescroll-vertical {
|
|
||||||
right: 0; top: 0;
|
|
||||||
width: 8px;
|
|
||||||
}
|
|
||||||
.CodeMirror-simplescroll-vertical div {
|
|
||||||
right: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
|
|
||||||
position: absolute;
|
|
||||||
background: #bcd;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-overlayscroll-horizontal {
|
|
||||||
bottom: 0; left: 0;
|
|
||||||
height: 6px;
|
|
||||||
}
|
|
||||||
.CodeMirror-overlayscroll-horizontal div {
|
|
||||||
bottom: 0;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-overlayscroll-vertical {
|
|
||||||
right: 0; top: 0;
|
|
||||||
width: 6px;
|
|
||||||
}
|
|
||||||
.CodeMirror-overlayscroll-vertical div {
|
|
||||||
right: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://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";
|
|
||||||
|
|
||||||
function Bar(cls, orientation, scroll) {
|
|
||||||
this.orientation = orientation;
|
|
||||||
this.scroll = scroll;
|
|
||||||
this.screen = this.total = this.size = 1;
|
|
||||||
this.pos = 0;
|
|
||||||
|
|
||||||
this.node = document.createElement("div");
|
|
||||||
this.node.className = cls + "-" + orientation;
|
|
||||||
this.inner = this.node.appendChild(document.createElement("div"));
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
CodeMirror.on(this.inner, "mousedown", function(e) {
|
|
||||||
if (e.which != 1) return;
|
|
||||||
CodeMirror.e_preventDefault(e);
|
|
||||||
var axis = self.orientation == "horizontal" ? "pageX" : "pageY";
|
|
||||||
var start = e[axis], startpos = self.pos;
|
|
||||||
function done() {
|
|
||||||
CodeMirror.off(document, "mousemove", move);
|
|
||||||
CodeMirror.off(document, "mouseup", done);
|
|
||||||
}
|
|
||||||
function move(e) {
|
|
||||||
if (e.which != 1) return done();
|
|
||||||
self.moveTo(startpos + (e[axis] - start) * (self.total / self.size));
|
|
||||||
}
|
|
||||||
CodeMirror.on(document, "mousemove", move);
|
|
||||||
CodeMirror.on(document, "mouseup", done);
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.on(this.node, "click", function(e) {
|
|
||||||
CodeMirror.e_preventDefault(e);
|
|
||||||
var innerBox = self.inner.getBoundingClientRect(), where;
|
|
||||||
if (self.orientation == "horizontal")
|
|
||||||
where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0;
|
|
||||||
else
|
|
||||||
where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0;
|
|
||||||
self.moveTo(self.pos + where * self.screen);
|
|
||||||
});
|
|
||||||
|
|
||||||
function onWheel(e) {
|
|
||||||
var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"];
|
|
||||||
var oldPos = self.pos;
|
|
||||||
self.moveTo(self.pos + moved);
|
|
||||||
if (self.pos != oldPos) CodeMirror.e_preventDefault(e);
|
|
||||||
}
|
|
||||||
CodeMirror.on(this.node, "mousewheel", onWheel);
|
|
||||||
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bar.prototype.setPos = function(pos, force) {
|
|
||||||
if (pos < 0) pos = 0;
|
|
||||||
if (pos > this.total - this.screen) pos = this.total - this.screen;
|
|
||||||
if (!force && pos == this.pos) return false;
|
|
||||||
this.pos = pos;
|
|
||||||
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
|
|
||||||
(pos * (this.size / this.total)) + "px";
|
|
||||||
return true
|
|
||||||
};
|
|
||||||
|
|
||||||
Bar.prototype.moveTo = function(pos) {
|
|
||||||
if (this.setPos(pos)) this.scroll(pos, this.orientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
var minButtonSize = 10;
|
|
||||||
|
|
||||||
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
|
|
||||||
var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
|
|
||||||
if (sizeChanged) {
|
|
||||||
this.screen = clientSize;
|
|
||||||
this.total = scrollSize;
|
|
||||||
this.size = barSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
var buttonSize = this.screen * (this.size / this.total);
|
|
||||||
if (buttonSize < minButtonSize) {
|
|
||||||
this.size -= minButtonSize - buttonSize;
|
|
||||||
buttonSize = minButtonSize;
|
|
||||||
}
|
|
||||||
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
|
|
||||||
buttonSize + "px";
|
|
||||||
this.setPos(this.pos, sizeChanged);
|
|
||||||
};
|
|
||||||
|
|
||||||
function SimpleScrollbars(cls, place, scroll) {
|
|
||||||
this.addClass = cls;
|
|
||||||
this.horiz = new Bar(cls, "horizontal", scroll);
|
|
||||||
place(this.horiz.node);
|
|
||||||
this.vert = new Bar(cls, "vertical", scroll);
|
|
||||||
place(this.vert.node);
|
|
||||||
this.width = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleScrollbars.prototype.update = function(measure) {
|
|
||||||
if (this.width == null) {
|
|
||||||
var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle;
|
|
||||||
if (style) this.width = parseInt(style.height);
|
|
||||||
}
|
|
||||||
var width = this.width || 0;
|
|
||||||
|
|
||||||
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
|
||||||
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
|
||||||
this.vert.node.style.display = needsV ? "block" : "none";
|
|
||||||
this.horiz.node.style.display = needsH ? "block" : "none";
|
|
||||||
|
|
||||||
if (needsV) {
|
|
||||||
this.vert.update(measure.scrollHeight, measure.clientHeight,
|
|
||||||
measure.viewHeight - (needsH ? width : 0));
|
|
||||||
this.vert.node.style.bottom = needsH ? width + "px" : "0";
|
|
||||||
}
|
|
||||||
if (needsH) {
|
|
||||||
this.horiz.update(measure.scrollWidth, measure.clientWidth,
|
|
||||||
measure.viewWidth - (needsV ? width : 0) - measure.barLeft);
|
|
||||||
this.horiz.node.style.right = needsV ? width + "px" : "0";
|
|
||||||
this.horiz.node.style.left = measure.barLeft + "px";
|
|
||||||
}
|
|
||||||
|
|
||||||
return {right: needsV ? width : 0, bottom: needsH ? width : 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
SimpleScrollbars.prototype.setScrollTop = function(pos) {
|
|
||||||
this.vert.setPos(pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
SimpleScrollbars.prototype.setScrollLeft = function(pos) {
|
|
||||||
this.horiz.setPos(pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
SimpleScrollbars.prototype.clear = function() {
|
|
||||||
var parent = this.horiz.node.parentNode;
|
|
||||||
parent.removeChild(this.horiz.node);
|
|
||||||
parent.removeChild(this.vert.node);
|
|
||||||
};
|
|
||||||
|
|
||||||
CodeMirror.scrollbarModel.simple = function(place, scroll) {
|
|
||||||
return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll);
|
|
||||||
};
|
|
||||||
CodeMirror.scrollbarModel.overlay = function(place, scroll) {
|
|
||||||
return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1,346 +0,0 @@
|
|||||||
/* BASICS */
|
|
||||||
|
|
||||||
.CodeMirror {
|
|
||||||
/* Set height, width, borders, and global font properties here */
|
|
||||||
font-family: monospace;
|
|
||||||
height: 300px;
|
|
||||||
color: black;
|
|
||||||
direction: ltr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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-fat-cursor-mark {
|
|
||||||
background-color: rgba(20, 255, 20, 0.5);
|
|
||||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
||||||
-moz-animation: blink 1.06s steps(1) infinite;
|
|
||||||
animation: blink 1.06s steps(1) infinite;
|
|
||||||
}
|
|
||||||
.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-rulers {
|
|
||||||
position: absolute;
|
|
||||||
left: 0; right: 0; top: -50px; bottom: -20px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.CodeMirror-ruler {
|
|
||||||
border-left: 1px solid #ccc;
|
|
||||||
top: 0; bottom: 0;
|
|
||||||
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, .cm-s-default .cm-type {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: #0b0;}
|
|
||||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.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 ::selection { background-color: transparent }
|
|
||||||
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
|
||||||
|
|
||||||
.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: contextual;
|
|
||||||
font-variant-ligatures: contextual;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-widget {}
|
|
||||||
|
|
||||||
.CodeMirror-rtl pre { direction: rtl; }
|
|
||||||
|
|
||||||
.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;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
.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-color: #ffa;
|
|
||||||
background-color: rgba(255, 255, 0, .4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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; }
|
|
||||||
@@ -1,831 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://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.defineMode("css", function(config, parserConfig) {
|
|
||||||
var inline = parserConfig.inline
|
|
||||||
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
|
||||||
|
|
||||||
var indentUnit = config.indentUnit,
|
|
||||||
tokenHooks = parserConfig.tokenHooks,
|
|
||||||
documentTypes = parserConfig.documentTypes || {},
|
|
||||||
mediaTypes = parserConfig.mediaTypes || {},
|
|
||||||
mediaFeatures = parserConfig.mediaFeatures || {},
|
|
||||||
mediaValueKeywords = parserConfig.mediaValueKeywords || {},
|
|
||||||
propertyKeywords = parserConfig.propertyKeywords || {},
|
|
||||||
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
|
||||||
fontProperties = parserConfig.fontProperties || {},
|
|
||||||
counterDescriptors = parserConfig.counterDescriptors || {},
|
|
||||||
colorKeywords = parserConfig.colorKeywords || {},
|
|
||||||
valueKeywords = parserConfig.valueKeywords || {},
|
|
||||||
allowNested = parserConfig.allowNested,
|
|
||||||
lineComment = parserConfig.lineComment,
|
|
||||||
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
|
||||||
|
|
||||||
var type, override;
|
|
||||||
function ret(style, tp) { type = tp; return style; }
|
|
||||||
|
|
||||||
// Tokenizers
|
|
||||||
|
|
||||||
function tokenBase(stream, state) {
|
|
||||||
var ch = stream.next();
|
|
||||||
if (tokenHooks[ch]) {
|
|
||||||
var result = tokenHooks[ch](stream, state);
|
|
||||||
if (result !== false) return result;
|
|
||||||
}
|
|
||||||
if (ch == "@") {
|
|
||||||
stream.eatWhile(/[\w\\\-]/);
|
|
||||||
return ret("def", stream.current());
|
|
||||||
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
|
|
||||||
return ret(null, "compare");
|
|
||||||
} else if (ch == "\"" || ch == "'") {
|
|
||||||
state.tokenize = tokenString(ch);
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
} else if (ch == "#") {
|
|
||||||
stream.eatWhile(/[\w\\\-]/);
|
|
||||||
return ret("atom", "hash");
|
|
||||||
} else if (ch == "!") {
|
|
||||||
stream.match(/^\s*\w*/);
|
|
||||||
return ret("keyword", "important");
|
|
||||||
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
|
|
||||||
stream.eatWhile(/[\w.%]/);
|
|
||||||
return ret("number", "unit");
|
|
||||||
} else if (ch === "-") {
|
|
||||||
if (/[\d.]/.test(stream.peek())) {
|
|
||||||
stream.eatWhile(/[\w.%]/);
|
|
||||||
return ret("number", "unit");
|
|
||||||
} else if (stream.match(/^-[\w\\\-]*/)) {
|
|
||||||
stream.eatWhile(/[\w\\\-]/);
|
|
||||||
if (stream.match(/^\s*:/, false))
|
|
||||||
return ret("variable-2", "variable-definition");
|
|
||||||
return ret("variable-2", "variable");
|
|
||||||
} else if (stream.match(/^\w+-/)) {
|
|
||||||
return ret("meta", "meta");
|
|
||||||
}
|
|
||||||
} else if (/[,+>*\/]/.test(ch)) {
|
|
||||||
return ret(null, "select-op");
|
|
||||||
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
|
|
||||||
return ret("qualifier", "qualifier");
|
|
||||||
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
|
||||||
return ret(null, ch);
|
|
||||||
} else if (stream.match(/[\w-.]+(?=\()/)) {
|
|
||||||
if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
|
|
||||||
state.tokenize = tokenParenthesized;
|
|
||||||
}
|
|
||||||
return ret("variable callee", "variable");
|
|
||||||
} else if (/[\w\\\-]/.test(ch)) {
|
|
||||||
stream.eatWhile(/[\w\\\-]/);
|
|
||||||
return ret("property", "word");
|
|
||||||
} else {
|
|
||||||
return ret(null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenString(quote) {
|
|
||||||
return function(stream, state) {
|
|
||||||
var escaped = false, ch;
|
|
||||||
while ((ch = stream.next()) != null) {
|
|
||||||
if (ch == quote && !escaped) {
|
|
||||||
if (quote == ")") stream.backUp(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
escaped = !escaped && ch == "\\";
|
|
||||||
}
|
|
||||||
if (ch == quote || !escaped && quote != ")") state.tokenize = null;
|
|
||||||
return ret("string", "string");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenParenthesized(stream, state) {
|
|
||||||
stream.next(); // Must be '('
|
|
||||||
if (!stream.match(/\s*[\"\')]/, false))
|
|
||||||
state.tokenize = tokenString(")");
|
|
||||||
else
|
|
||||||
state.tokenize = null;
|
|
||||||
return ret(null, "(");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Context management
|
|
||||||
|
|
||||||
function Context(type, indent, prev) {
|
|
||||||
this.type = type;
|
|
||||||
this.indent = indent;
|
|
||||||
this.prev = prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
function pushContext(state, stream, type, indent) {
|
|
||||||
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
function popContext(state) {
|
|
||||||
if (state.context.prev)
|
|
||||||
state.context = state.context.prev;
|
|
||||||
return state.context.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
function pass(type, stream, state) {
|
|
||||||
return states[state.context.type](type, stream, state);
|
|
||||||
}
|
|
||||||
function popAndPass(type, stream, state, n) {
|
|
||||||
for (var i = n || 1; i > 0; i--)
|
|
||||||
state.context = state.context.prev;
|
|
||||||
return pass(type, stream, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parser
|
|
||||||
|
|
||||||
function wordAsValue(stream) {
|
|
||||||
var word = stream.current().toLowerCase();
|
|
||||||
if (valueKeywords.hasOwnProperty(word))
|
|
||||||
override = "atom";
|
|
||||||
else if (colorKeywords.hasOwnProperty(word))
|
|
||||||
override = "keyword";
|
|
||||||
else
|
|
||||||
override = "variable";
|
|
||||||
}
|
|
||||||
|
|
||||||
var states = {};
|
|
||||||
|
|
||||||
states.top = function(type, stream, state) {
|
|
||||||
if (type == "{") {
|
|
||||||
return pushContext(state, stream, "block");
|
|
||||||
} else if (type == "}" && state.context.prev) {
|
|
||||||
return popContext(state);
|
|
||||||
} else if (supportsAtComponent && /@component/i.test(type)) {
|
|
||||||
return pushContext(state, stream, "atComponentBlock");
|
|
||||||
} else if (/^@(-moz-)?document$/i.test(type)) {
|
|
||||||
return pushContext(state, stream, "documentTypes");
|
|
||||||
} else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) {
|
|
||||||
return pushContext(state, stream, "atBlock");
|
|
||||||
} else if (/^@(font-face|counter-style)/i.test(type)) {
|
|
||||||
state.stateArg = type;
|
|
||||||
return "restricted_atBlock_before";
|
|
||||||
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) {
|
|
||||||
return "keyframes";
|
|
||||||
} else if (type && type.charAt(0) == "@") {
|
|
||||||
return pushContext(state, stream, "at");
|
|
||||||
} else if (type == "hash") {
|
|
||||||
override = "builtin";
|
|
||||||
} else if (type == "word") {
|
|
||||||
override = "tag";
|
|
||||||
} else if (type == "variable-definition") {
|
|
||||||
return "maybeprop";
|
|
||||||
} else if (type == "interpolation") {
|
|
||||||
return pushContext(state, stream, "interpolation");
|
|
||||||
} else if (type == ":") {
|
|
||||||
return "pseudo";
|
|
||||||
} else if (allowNested && type == "(") {
|
|
||||||
return pushContext(state, stream, "parens");
|
|
||||||
}
|
|
||||||
return state.context.type;
|
|
||||||
};
|
|
||||||
|
|
||||||
states.block = function(type, stream, state) {
|
|
||||||
if (type == "word") {
|
|
||||||
var word = stream.current().toLowerCase();
|
|
||||||
if (propertyKeywords.hasOwnProperty(word)) {
|
|
||||||
override = "property";
|
|
||||||
return "maybeprop";
|
|
||||||
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
|
|
||||||
override = "string-2";
|
|
||||||
return "maybeprop";
|
|
||||||
} else if (allowNested) {
|
|
||||||
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
|
|
||||||
return "block";
|
|
||||||
} else {
|
|
||||||
override += " error";
|
|
||||||
return "maybeprop";
|
|
||||||
}
|
|
||||||
} else if (type == "meta") {
|
|
||||||
return "block";
|
|
||||||
} else if (!allowNested && (type == "hash" || type == "qualifier")) {
|
|
||||||
override = "error";
|
|
||||||
return "block";
|
|
||||||
} else {
|
|
||||||
return states.top(type, stream, state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
states.maybeprop = function(type, stream, state) {
|
|
||||||
if (type == ":") return pushContext(state, stream, "prop");
|
|
||||||
return pass(type, stream, state);
|
|
||||||
};
|
|
||||||
|
|
||||||
states.prop = function(type, stream, state) {
|
|
||||||
if (type == ";") return popContext(state);
|
|
||||||
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
|
|
||||||
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
|
||||||
if (type == "(") return pushContext(state, stream, "parens");
|
|
||||||
|
|
||||||
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
|
|
||||||
override += " error";
|
|
||||||
} else if (type == "word") {
|
|
||||||
wordAsValue(stream);
|
|
||||||
} else if (type == "interpolation") {
|
|
||||||
return pushContext(state, stream, "interpolation");
|
|
||||||
}
|
|
||||||
return "prop";
|
|
||||||
};
|
|
||||||
|
|
||||||
states.propBlock = function(type, _stream, state) {
|
|
||||||
if (type == "}") return popContext(state);
|
|
||||||
if (type == "word") { override = "property"; return "maybeprop"; }
|
|
||||||
return state.context.type;
|
|
||||||
};
|
|
||||||
|
|
||||||
states.parens = function(type, stream, state) {
|
|
||||||
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
|
||||||
if (type == ")") return popContext(state);
|
|
||||||
if (type == "(") return pushContext(state, stream, "parens");
|
|
||||||
if (type == "interpolation") return pushContext(state, stream, "interpolation");
|
|
||||||
if (type == "word") wordAsValue(stream);
|
|
||||||
return "parens";
|
|
||||||
};
|
|
||||||
|
|
||||||
states.pseudo = function(type, stream, state) {
|
|
||||||
if (type == "meta") return "pseudo";
|
|
||||||
|
|
||||||
if (type == "word") {
|
|
||||||
override = "variable-3";
|
|
||||||
return state.context.type;
|
|
||||||
}
|
|
||||||
return pass(type, stream, state);
|
|
||||||
};
|
|
||||||
|
|
||||||
states.documentTypes = function(type, stream, state) {
|
|
||||||
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
|
|
||||||
override = "tag";
|
|
||||||
return state.context.type;
|
|
||||||
} else {
|
|
||||||
return states.atBlock(type, stream, state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
states.atBlock = function(type, stream, state) {
|
|
||||||
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
|
||||||
if (type == "}" || type == ";") return popAndPass(type, stream, state);
|
|
||||||
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
|
||||||
|
|
||||||
if (type == "interpolation") return pushContext(state, stream, "interpolation");
|
|
||||||
|
|
||||||
if (type == "word") {
|
|
||||||
var word = stream.current().toLowerCase();
|
|
||||||
if (word == "only" || word == "not" || word == "and" || word == "or")
|
|
||||||
override = "keyword";
|
|
||||||
else if (mediaTypes.hasOwnProperty(word))
|
|
||||||
override = "attribute";
|
|
||||||
else if (mediaFeatures.hasOwnProperty(word))
|
|
||||||
override = "property";
|
|
||||||
else if (mediaValueKeywords.hasOwnProperty(word))
|
|
||||||
override = "keyword";
|
|
||||||
else if (propertyKeywords.hasOwnProperty(word))
|
|
||||||
override = "property";
|
|
||||||
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
|
||||||
override = "string-2";
|
|
||||||
else if (valueKeywords.hasOwnProperty(word))
|
|
||||||
override = "atom";
|
|
||||||
else if (colorKeywords.hasOwnProperty(word))
|
|
||||||
override = "keyword";
|
|
||||||
else
|
|
||||||
override = "error";
|
|
||||||
}
|
|
||||||
return state.context.type;
|
|
||||||
};
|
|
||||||
|
|
||||||
states.atComponentBlock = function(type, stream, state) {
|
|
||||||
if (type == "}")
|
|
||||||
return popAndPass(type, stream, state);
|
|
||||||
if (type == "{")
|
|
||||||
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
|
|
||||||
if (type == "word")
|
|
||||||
override = "error";
|
|
||||||
return state.context.type;
|
|
||||||
};
|
|
||||||
|
|
||||||
states.atBlock_parens = function(type, stream, state) {
|
|
||||||
if (type == ")") return popContext(state);
|
|
||||||
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
|
||||||
return states.atBlock(type, stream, state);
|
|
||||||
};
|
|
||||||
|
|
||||||
states.restricted_atBlock_before = function(type, stream, state) {
|
|
||||||
if (type == "{")
|
|
||||||
return pushContext(state, stream, "restricted_atBlock");
|
|
||||||
if (type == "word" && state.stateArg == "@counter-style") {
|
|
||||||
override = "variable";
|
|
||||||
return "restricted_atBlock_before";
|
|
||||||
}
|
|
||||||
return pass(type, stream, state);
|
|
||||||
};
|
|
||||||
|
|
||||||
states.restricted_atBlock = function(type, stream, state) {
|
|
||||||
if (type == "}") {
|
|
||||||
state.stateArg = null;
|
|
||||||
return popContext(state);
|
|
||||||
}
|
|
||||||
if (type == "word") {
|
|
||||||
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
|
|
||||||
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
|
|
||||||
override = "error";
|
|
||||||
else
|
|
||||||
override = "property";
|
|
||||||
return "maybeprop";
|
|
||||||
}
|
|
||||||
return "restricted_atBlock";
|
|
||||||
};
|
|
||||||
|
|
||||||
states.keyframes = function(type, stream, state) {
|
|
||||||
if (type == "word") { override = "variable"; return "keyframes"; }
|
|
||||||
if (type == "{") return pushContext(state, stream, "top");
|
|
||||||
return pass(type, stream, state);
|
|
||||||
};
|
|
||||||
|
|
||||||
states.at = function(type, stream, state) {
|
|
||||||
if (type == ";") return popContext(state);
|
|
||||||
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
|
||||||
if (type == "word") override = "tag";
|
|
||||||
else if (type == "hash") override = "builtin";
|
|
||||||
return "at";
|
|
||||||
};
|
|
||||||
|
|
||||||
states.interpolation = function(type, stream, state) {
|
|
||||||
if (type == "}") return popContext(state);
|
|
||||||
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
|
||||||
if (type == "word") override = "variable";
|
|
||||||
else if (type != "variable" && type != "(" && type != ")") override = "error";
|
|
||||||
return "interpolation";
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
startState: function(base) {
|
|
||||||
return {tokenize: null,
|
|
||||||
state: inline ? "block" : "top",
|
|
||||||
stateArg: null,
|
|
||||||
context: new Context(inline ? "block" : "top", base || 0, null)};
|
|
||||||
},
|
|
||||||
|
|
||||||
token: function(stream, state) {
|
|
||||||
if (!state.tokenize && stream.eatSpace()) return null;
|
|
||||||
var style = (state.tokenize || tokenBase)(stream, state);
|
|
||||||
if (style && typeof style == "object") {
|
|
||||||
type = style[1];
|
|
||||||
style = style[0];
|
|
||||||
}
|
|
||||||
override = style;
|
|
||||||
if (type != "comment")
|
|
||||||
state.state = states[state.state](type, stream, state);
|
|
||||||
return override;
|
|
||||||
},
|
|
||||||
|
|
||||||
indent: function(state, textAfter) {
|
|
||||||
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
|
||||||
var indent = cx.indent;
|
|
||||||
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
|
||||||
if (cx.prev) {
|
|
||||||
if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
|
|
||||||
cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
|
|
||||||
// Resume indentation from parent context.
|
|
||||||
cx = cx.prev;
|
|
||||||
indent = cx.indent;
|
|
||||||
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
|
||||||
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
|
|
||||||
// Dedent relative to current context.
|
|
||||||
indent = Math.max(0, cx.indent - indentUnit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return indent;
|
|
||||||
},
|
|
||||||
|
|
||||||
electricChars: "}",
|
|
||||||
blockCommentStart: "/*",
|
|
||||||
blockCommentEnd: "*/",
|
|
||||||
blockCommentContinue: " * ",
|
|
||||||
lineComment: lineComment,
|
|
||||||
fold: "brace"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function keySet(array) {
|
|
||||||
var keys = {};
|
|
||||||
for (var i = 0; i < array.length; ++i) {
|
|
||||||
keys[array[i].toLowerCase()] = true;
|
|
||||||
}
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
var documentTypes_ = [
|
|
||||||
"domain", "regexp", "url", "url-prefix"
|
|
||||||
], documentTypes = keySet(documentTypes_);
|
|
||||||
|
|
||||||
var mediaTypes_ = [
|
|
||||||
"all", "aural", "braille", "handheld", "print", "projection", "screen",
|
|
||||||
"tty", "tv", "embossed"
|
|
||||||
], mediaTypes = keySet(mediaTypes_);
|
|
||||||
|
|
||||||
var mediaFeatures_ = [
|
|
||||||
"width", "min-width", "max-width", "height", "min-height", "max-height",
|
|
||||||
"device-width", "min-device-width", "max-device-width", "device-height",
|
|
||||||
"min-device-height", "max-device-height", "aspect-ratio",
|
|
||||||
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
|
|
||||||
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
|
||||||
"max-color", "color-index", "min-color-index", "max-color-index",
|
|
||||||
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
|
||||||
"min-resolution", "max-resolution", "scan", "grid", "orientation",
|
|
||||||
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
|
|
||||||
"pointer", "any-pointer", "hover", "any-hover"
|
|
||||||
], mediaFeatures = keySet(mediaFeatures_);
|
|
||||||
|
|
||||||
var mediaValueKeywords_ = [
|
|
||||||
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
|
|
||||||
"interlace", "progressive"
|
|
||||||
], mediaValueKeywords = keySet(mediaValueKeywords_);
|
|
||||||
|
|
||||||
var propertyKeywords_ = [
|
|
||||||
"align-content", "align-items", "align-self", "alignment-adjust",
|
|
||||||
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
|
||||||
"animation-direction", "animation-duration", "animation-fill-mode",
|
|
||||||
"animation-iteration-count", "animation-name", "animation-play-state",
|
|
||||||
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
|
||||||
"background", "background-attachment", "background-blend-mode", "background-clip",
|
|
||||||
"background-color", "background-image", "background-origin", "background-position",
|
|
||||||
"background-repeat", "background-size", "baseline-shift", "binding",
|
|
||||||
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
|
||||||
"bookmark-target", "border", "border-bottom", "border-bottom-color",
|
|
||||||
"border-bottom-left-radius", "border-bottom-right-radius",
|
|
||||||
"border-bottom-style", "border-bottom-width", "border-collapse",
|
|
||||||
"border-color", "border-image", "border-image-outset",
|
|
||||||
"border-image-repeat", "border-image-slice", "border-image-source",
|
|
||||||
"border-image-width", "border-left", "border-left-color",
|
|
||||||
"border-left-style", "border-left-width", "border-radius", "border-right",
|
|
||||||
"border-right-color", "border-right-style", "border-right-width",
|
|
||||||
"border-spacing", "border-style", "border-top", "border-top-color",
|
|
||||||
"border-top-left-radius", "border-top-right-radius", "border-top-style",
|
|
||||||
"border-top-width", "border-width", "bottom", "box-decoration-break",
|
|
||||||
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
|
|
||||||
"caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
|
|
||||||
"column-fill", "column-gap", "column-rule", "column-rule-color",
|
|
||||||
"column-rule-style", "column-rule-width", "column-span", "column-width",
|
|
||||||
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
|
|
||||||
"cue-after", "cue-before", "cursor", "direction", "display",
|
|
||||||
"dominant-baseline", "drop-initial-after-adjust",
|
|
||||||
"drop-initial-after-align", "drop-initial-before-adjust",
|
|
||||||
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
|
|
||||||
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
|
|
||||||
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
|
|
||||||
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
|
|
||||||
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
|
|
||||||
"font-stretch", "font-style", "font-synthesis", "font-variant",
|
|
||||||
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
|
||||||
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
|
||||||
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
|
||||||
"grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
|
|
||||||
"grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
|
|
||||||
"grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
|
|
||||||
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
|
||||||
"icon", "image-orientation", "image-rendering", "image-resolution",
|
|
||||||
"inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
|
|
||||||
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
|
||||||
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
|
||||||
"list-style-image", "list-style-position", "list-style-type", "margin",
|
|
||||||
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
|
||||||
"marks", "marquee-direction", "marquee-loop",
|
|
||||||
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
|
||||||
"max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
|
|
||||||
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
|
||||||
"opacity", "order", "orphans", "outline",
|
|
||||||
"outline-color", "outline-offset", "outline-style", "outline-width",
|
|
||||||
"overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
|
|
||||||
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
|
|
||||||
"page", "page-break-after", "page-break-before", "page-break-inside",
|
|
||||||
"page-policy", "pause", "pause-after", "pause-before", "perspective",
|
|
||||||
"perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
|
|
||||||
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
|
|
||||||
"region-break-before", "region-break-inside", "region-fragment",
|
|
||||||
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
|
|
||||||
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
|
|
||||||
"ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
|
|
||||||
"shape-outside", "size", "speak", "speak-as", "speak-header",
|
|
||||||
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
|
|
||||||
"tab-size", "table-layout", "target", "target-name", "target-new",
|
|
||||||
"target-position", "text-align", "text-align-last", "text-decoration",
|
|
||||||
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
|
|
||||||
"text-decoration-style", "text-emphasis", "text-emphasis-color",
|
|
||||||
"text-emphasis-position", "text-emphasis-style", "text-height",
|
|
||||||
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
|
|
||||||
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
|
|
||||||
"text-wrap", "top", "transform", "transform-origin", "transform-style",
|
|
||||||
"transition", "transition-delay", "transition-duration",
|
|
||||||
"transition-property", "transition-timing-function", "unicode-bidi",
|
|
||||||
"user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
|
|
||||||
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
|
|
||||||
"voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
|
|
||||||
"word-spacing", "word-wrap", "z-index",
|
|
||||||
// SVG-specific
|
|
||||||
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
|
|
||||||
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
|
|
||||||
"color-interpolation", "color-interpolation-filters",
|
|
||||||
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
|
|
||||||
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
|
|
||||||
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
|
|
||||||
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
|
|
||||||
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
|
|
||||||
"glyph-orientation-vertical", "text-anchor", "writing-mode"
|
|
||||||
], propertyKeywords = keySet(propertyKeywords_);
|
|
||||||
|
|
||||||
var nonStandardPropertyKeywords_ = [
|
|
||||||
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
|
|
||||||
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
|
|
||||||
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
|
|
||||||
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
|
|
||||||
"searchfield-results-decoration", "zoom"
|
|
||||||
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
|
||||||
|
|
||||||
var fontProperties_ = [
|
|
||||||
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
|
||||||
"font-stretch", "font-weight", "font-style"
|
|
||||||
], fontProperties = keySet(fontProperties_);
|
|
||||||
|
|
||||||
var counterDescriptors_ = [
|
|
||||||
"additive-symbols", "fallback", "negative", "pad", "prefix", "range",
|
|
||||||
"speak-as", "suffix", "symbols", "system"
|
|
||||||
], counterDescriptors = keySet(counterDescriptors_);
|
|
||||||
|
|
||||||
var colorKeywords_ = [
|
|
||||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
|
||||||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
|
||||||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
|
|
||||||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
|
|
||||||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
|
|
||||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
|
||||||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
|
|
||||||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
|
|
||||||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
|
||||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
|
|
||||||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
|
|
||||||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
|
|
||||||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
|
|
||||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
|
|
||||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
|
|
||||||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
|
|
||||||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
|
||||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
|
||||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
|
|
||||||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
|
|
||||||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
|
||||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
|
|
||||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
|
|
||||||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
|
|
||||||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
|
|
||||||
"whitesmoke", "yellow", "yellowgreen"
|
|
||||||
], colorKeywords = keySet(colorKeywords_);
|
|
||||||
|
|
||||||
var valueKeywords_ = [
|
|
||||||
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
|
|
||||||
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
|
|
||||||
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
|
||||||
"arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
|
|
||||||
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
|
|
||||||
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
|
||||||
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
|
||||||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
|
|
||||||
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
|
||||||
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
|
||||||
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
|
||||||
"col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
|
|
||||||
"compact", "condensed", "contain", "content", "contents",
|
|
||||||
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
|
||||||
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
|
|
||||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
|
|
||||||
"destination-in", "destination-out", "destination-over", "devanagari", "difference",
|
|
||||||
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
|
|
||||||
"dot-dash", "dot-dot-dash",
|
|
||||||
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
|
|
||||||
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
|
|
||||||
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
|
|
||||||
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
|
|
||||||
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
|
|
||||||
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
|
|
||||||
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
|
||||||
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
|
||||||
"ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
|
|
||||||
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
|
|
||||||
"forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
|
|
||||||
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
|
|
||||||
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
|
||||||
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
|
|
||||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
|
||||||
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
|
||||||
"inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
|
|
||||||
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
|
|
||||||
"katakana", "katakana-iroha", "keep-all", "khmer",
|
|
||||||
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
|
|
||||||
"landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
|
|
||||||
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
|
|
||||||
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
|
|
||||||
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
|
|
||||||
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
|
|
||||||
"media-controls-background", "media-current-time-display",
|
|
||||||
"media-fullscreen-button", "media-mute-button", "media-play-button",
|
|
||||||
"media-return-to-realtime-button", "media-rewind-button",
|
|
||||||
"media-seek-back-button", "media-seek-forward-button", "media-slider",
|
|
||||||
"media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
|
|
||||||
"media-volume-slider-container", "media-volume-sliderthumb", "medium",
|
|
||||||
"menu", "menulist", "menulist-button", "menulist-text",
|
|
||||||
"menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
|
|
||||||
"mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
|
|
||||||
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
|
|
||||||
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
|
|
||||||
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
|
|
||||||
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
|
|
||||||
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
|
|
||||||
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
|
|
||||||
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
|
|
||||||
"progress", "push-button", "radial-gradient", "radio", "read-only",
|
|
||||||
"read-write", "read-write-plaintext-only", "rectangle", "region",
|
|
||||||
"relative", "repeat", "repeating-linear-gradient",
|
|
||||||
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
|
||||||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
|
||||||
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
|
|
||||||
"s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
|
|
||||||
"scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
|
|
||||||
"searchfield-cancel-button", "searchfield-decoration",
|
|
||||||
"searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
|
|
||||||
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
|
||||||
"simp-chinese-formal", "simp-chinese-informal", "single",
|
|
||||||
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
|
||||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
|
||||||
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
|
|
||||||
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
|
|
||||||
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
|
||||||
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
|
|
||||||
"table-caption", "table-cell", "table-column", "table-column-group",
|
|
||||||
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
|
||||||
"tamil",
|
|
||||||
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
|
|
||||||
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
|
|
||||||
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
|
|
||||||
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
|
|
||||||
"trad-chinese-formal", "trad-chinese-informal", "transform",
|
|
||||||
"translate", "translate3d", "translateX", "translateY", "translateZ",
|
|
||||||
"transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
|
|
||||||
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
|
||||||
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
|
||||||
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
|
||||||
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
|
||||||
"window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
|
|
||||||
"xx-large", "xx-small"
|
|
||||||
], valueKeywords = keySet(valueKeywords_);
|
|
||||||
|
|
||||||
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
|
|
||||||
.concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
|
|
||||||
.concat(valueKeywords_);
|
|
||||||
CodeMirror.registerHelper("hintWords", "css", allWords);
|
|
||||||
|
|
||||||
function tokenCComment(stream, state) {
|
|
||||||
var maybeEnd = false, ch;
|
|
||||||
while ((ch = stream.next()) != null) {
|
|
||||||
if (maybeEnd && ch == "/") {
|
|
||||||
state.tokenize = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
maybeEnd = (ch == "*");
|
|
||||||
}
|
|
||||||
return ["comment", "comment"];
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/css", {
|
|
||||||
documentTypes: documentTypes,
|
|
||||||
mediaTypes: mediaTypes,
|
|
||||||
mediaFeatures: mediaFeatures,
|
|
||||||
mediaValueKeywords: mediaValueKeywords,
|
|
||||||
propertyKeywords: propertyKeywords,
|
|
||||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
|
||||||
fontProperties: fontProperties,
|
|
||||||
counterDescriptors: counterDescriptors,
|
|
||||||
colorKeywords: colorKeywords,
|
|
||||||
valueKeywords: valueKeywords,
|
|
||||||
tokenHooks: {
|
|
||||||
"/": function(stream, state) {
|
|
||||||
if (!stream.eat("*")) return false;
|
|
||||||
state.tokenize = tokenCComment;
|
|
||||||
return tokenCComment(stream, state);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: "css"
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/x-scss", {
|
|
||||||
mediaTypes: mediaTypes,
|
|
||||||
mediaFeatures: mediaFeatures,
|
|
||||||
mediaValueKeywords: mediaValueKeywords,
|
|
||||||
propertyKeywords: propertyKeywords,
|
|
||||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
|
||||||
colorKeywords: colorKeywords,
|
|
||||||
valueKeywords: valueKeywords,
|
|
||||||
fontProperties: fontProperties,
|
|
||||||
allowNested: true,
|
|
||||||
lineComment: "//",
|
|
||||||
tokenHooks: {
|
|
||||||
"/": function(stream, state) {
|
|
||||||
if (stream.eat("/")) {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return ["comment", "comment"];
|
|
||||||
} else if (stream.eat("*")) {
|
|
||||||
state.tokenize = tokenCComment;
|
|
||||||
return tokenCComment(stream, state);
|
|
||||||
} else {
|
|
||||||
return ["operator", "operator"];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
":": function(stream) {
|
|
||||||
if (stream.match(/\s*\{/, false))
|
|
||||||
return [null, null]
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
"$": function(stream) {
|
|
||||||
stream.match(/^[\w-]+/);
|
|
||||||
if (stream.match(/^\s*:/, false))
|
|
||||||
return ["variable-2", "variable-definition"];
|
|
||||||
return ["variable-2", "variable"];
|
|
||||||
},
|
|
||||||
"#": function(stream) {
|
|
||||||
if (!stream.eat("{")) return false;
|
|
||||||
return [null, "interpolation"];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: "css",
|
|
||||||
helperType: "scss"
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/x-less", {
|
|
||||||
mediaTypes: mediaTypes,
|
|
||||||
mediaFeatures: mediaFeatures,
|
|
||||||
mediaValueKeywords: mediaValueKeywords,
|
|
||||||
propertyKeywords: propertyKeywords,
|
|
||||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
|
||||||
colorKeywords: colorKeywords,
|
|
||||||
valueKeywords: valueKeywords,
|
|
||||||
fontProperties: fontProperties,
|
|
||||||
allowNested: true,
|
|
||||||
lineComment: "//",
|
|
||||||
tokenHooks: {
|
|
||||||
"/": function(stream, state) {
|
|
||||||
if (stream.eat("/")) {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return ["comment", "comment"];
|
|
||||||
} else if (stream.eat("*")) {
|
|
||||||
state.tokenize = tokenCComment;
|
|
||||||
return tokenCComment(stream, state);
|
|
||||||
} else {
|
|
||||||
return ["operator", "operator"];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@": function(stream) {
|
|
||||||
if (stream.eat("{")) return [null, "interpolation"];
|
|
||||||
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false;
|
|
||||||
stream.eatWhile(/[\w\\\-]/);
|
|
||||||
if (stream.match(/^\s*:/, false))
|
|
||||||
return ["variable-2", "variable-definition"];
|
|
||||||
return ["variable-2", "variable"];
|
|
||||||
},
|
|
||||||
"&": function() {
|
|
||||||
return ["atom", "atom"];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: "css",
|
|
||||||
helperType: "less"
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/x-gss", {
|
|
||||||
documentTypes: documentTypes,
|
|
||||||
mediaTypes: mediaTypes,
|
|
||||||
mediaFeatures: mediaFeatures,
|
|
||||||
propertyKeywords: propertyKeywords,
|
|
||||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
|
||||||
fontProperties: fontProperties,
|
|
||||||
counterDescriptors: counterDescriptors,
|
|
||||||
colorKeywords: colorKeywords,
|
|
||||||
valueKeywords: valueKeywords,
|
|
||||||
supportsAtComponent: true,
|
|
||||||
tokenHooks: {
|
|
||||||
"/": function(stream, state) {
|
|
||||||
if (!stream.eat("*")) return false;
|
|
||||||
state.tokenize = tokenCComment;
|
|
||||||
return tokenCComment(stream, state);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: "css",
|
|
||||||
helperType: "gss"
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="css.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="../../addon/hint/show-hint.js"></script>
|
|
||||||
<script src="../../addon/hint/css-hint.js"></script>
|
|
||||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>Closure Stylesheets (GSS) mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
/* Some example Closure Stylesheets */
|
|
||||||
|
|
||||||
@provide 'some.styles';
|
|
||||||
|
|
||||||
@require 'other.styles';
|
|
||||||
|
|
||||||
@component {
|
|
||||||
|
|
||||||
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
|
|
||||||
@def FONT_SIZE_NORMAL 15px;
|
|
||||||
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
|
|
||||||
|
|
||||||
@def BG_COLOR rgb(235, 239, 249);
|
|
||||||
|
|
||||||
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
|
|
||||||
@def DIALOG_BG_COLOR BG_COLOR;
|
|
||||||
|
|
||||||
@def LEFT_HAND_NAV_WIDTH 180px;
|
|
||||||
@def LEFT_HAND_NAV_PADDING 3px;
|
|
||||||
|
|
||||||
@defmixin size(WIDTH, HEIGHT) {
|
|
||||||
width: WIDTH;
|
|
||||||
height: HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: BG_COLOR;
|
|
||||||
margin: 0;
|
|
||||||
padding: 3em 6em;
|
|
||||||
font: FONT_NORMAL;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation a {
|
|
||||||
font-weight: bold;
|
|
||||||
text-decoration: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog {
|
|
||||||
background-color: DIALOG_BG_COLOR;
|
|
||||||
border: 1px solid DIALOG_BORDER_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
position: absolute;
|
|
||||||
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
|
|
||||||
LEFT_HAND_NAV_WIDTH,
|
|
||||||
LEFT_HAND_NAV_PADDING); /* padding right */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
@mixin size(150px, 55px);
|
|
||||||
background-image: url('http://www.google.com/images/logo_sm.gif');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
extraKeys: {"Ctrl-Space": "autocomplete"},
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-gss"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
|
|
||||||
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
|
|
||||||
|
|
||||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
|
|
||||||
|
|
||||||
</article>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
|
|
||||||
|
|
||||||
MT("atComponent",
|
|
||||||
"[def @component] {",
|
|
||||||
"[tag foo] {",
|
|
||||||
" [property color]: [keyword black];",
|
|
||||||
"}",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
})();
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: CSS mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="css.js"></script>
|
|
||||||
<script src="../../addon/hint/show-hint.js"></script>
|
|
||||||
<script src="../../addon/hint/css-hint.js"></script>
|
|
||||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">CSS</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>CSS mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
/* Some example CSS */
|
|
||||||
|
|
||||||
@import url("something.css");
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 3em 6em;
|
|
||||||
font-family: tahoma, arial, sans-serif;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation a {
|
|
||||||
font-weight: bold;
|
|
||||||
text-decoration: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 2.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 1.7em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1:before, h2:before {
|
|
||||||
content: "::";
|
|
||||||
}
|
|
||||||
|
|
||||||
code {
|
|
||||||
font-family: courier, monospace;
|
|
||||||
font-size: 80%;
|
|
||||||
color: #418A8A;
|
|
||||||
}
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
extraKeys: {"Ctrl-Space": "autocomplete"}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p>
|
|
||||||
|
|
||||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>
|
|
||||||
|
|
||||||
</article>
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: LESS mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="css.js"></script>
|
|
||||||
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">LESS</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>LESS mode</h2>
|
|
||||||
<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
|
|
||||||
@media screen and (device-aspect-ratio: 1280/720) { … }
|
|
||||||
@media screen and (device-aspect-ratio: 2560/1440) { … }
|
|
||||||
|
|
||||||
html:lang(fr-be)
|
|
||||||
|
|
||||||
tr:nth-child(2n+1) /* represents every odd row of an HTML table */
|
|
||||||
|
|
||||||
img:nth-of-type(2n+1) { float: right; }
|
|
||||||
img:nth-of-type(2n) { float: left; }
|
|
||||||
|
|
||||||
body > h2:not(:first-of-type):not(:last-of-type)
|
|
||||||
|
|
||||||
html|*:not(:link):not(:visited)
|
|
||||||
*|*:not(:hover)
|
|
||||||
p::first-line { text-transform: uppercase }
|
|
||||||
|
|
||||||
@namespace foo url(http://www.example.com);
|
|
||||||
foo|h1 { color: blue } /* first rule */
|
|
||||||
|
|
||||||
span[hello="Ocean"][goodbye="Land"]
|
|
||||||
|
|
||||||
E[foo]{
|
|
||||||
padding:65px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="search"]::-webkit-search-decoration,
|
|
||||||
input[type="search"]::-webkit-search-cancel-button {
|
|
||||||
-webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
|
|
||||||
}
|
|
||||||
button::-moz-focus-inner,
|
|
||||||
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
.btn {
|
|
||||||
// reset here as of 2.0.3 due to Recess property order
|
|
||||||
border-color: #ccc;
|
|
||||||
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
|
|
||||||
}
|
|
||||||
fieldset span button, fieldset span input[type="file"] {
|
|
||||||
font-size:12px;
|
|
||||||
font-family:Arial, Helvetica, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rounded-corners (@radius: 5px) {
|
|
||||||
border-radius: @radius;
|
|
||||||
-webkit-border-radius: @radius;
|
|
||||||
-moz-border-radius: @radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
@import url("something.css");
|
|
||||||
|
|
||||||
@light-blue: hsl(190, 50%, 65%);
|
|
||||||
|
|
||||||
#menu {
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
z-index: 3;
|
|
||||||
clear: both;
|
|
||||||
display: block;
|
|
||||||
background-color: @blue;
|
|
||||||
height: 42px;
|
|
||||||
border-top: 2px solid lighten(@alpha-blue, 20%);
|
|
||||||
border-bottom: 2px solid darken(@alpha-blue, 25%);
|
|
||||||
.box-shadow(0, 1px, 8px, 0.6);
|
|
||||||
-moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
|
|
||||||
|
|
||||||
&.docked {
|
|
||||||
background-color: hsla(210, 60%, 40%, 0.4);
|
|
||||||
}
|
|
||||||
&:hover {
|
|
||||||
background-color: @blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#dropdown {
|
|
||||||
margin: 0 0 0 117px;
|
|
||||||
padding: 0;
|
|
||||||
padding-top: 5px;
|
|
||||||
display: none;
|
|
||||||
width: 190px;
|
|
||||||
border-top: 2px solid @medium;
|
|
||||||
color: @highlight;
|
|
||||||
border: 2px solid darken(@medium, 25%);
|
|
||||||
border-left-color: darken(@medium, 15%);
|
|
||||||
border-right-color: darken(@medium, 15%);
|
|
||||||
border-top-width: 0;
|
|
||||||
background-color: darken(@medium, 10%);
|
|
||||||
ul {
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
li {
|
|
||||||
font-size: 14px;
|
|
||||||
display: block;
|
|
||||||
text-align: left;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
a {
|
|
||||||
display: block;
|
|
||||||
padding: 0px 15px;
|
|
||||||
text-decoration: none;
|
|
||||||
color: white;
|
|
||||||
&:hover {
|
|
||||||
background-color: darken(@medium, 15%);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.border-radius(5px, bottom);
|
|
||||||
.box-shadow(0, 6px, 8px, 0.5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-less"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
|
||||||
|
|
||||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p>
|
|
||||||
</article>
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
|
|
||||||
|
|
||||||
MT("variable",
|
|
||||||
"[variable-2 @base]: [atom #f04615];",
|
|
||||||
"[qualifier .class] {",
|
|
||||||
" [property width]: [variable&callee percentage]([number 0.5]); [comment // returns `50%`]",
|
|
||||||
" [property color]: [variable&callee saturate]([variable-2 @base], [number 5%]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("amp",
|
|
||||||
"[qualifier .child], [qualifier .sibling] {",
|
|
||||||
" [qualifier .parent] [atom &] {",
|
|
||||||
" [property color]: [keyword black];",
|
|
||||||
" }",
|
|
||||||
" [atom &] + [atom &] {",
|
|
||||||
" [property color]: [keyword red];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("mixin",
|
|
||||||
"[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
|
|
||||||
" [property color]: [variable&callee darken]([variable-2 @color], [number 10%]);",
|
|
||||||
"}",
|
|
||||||
"[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
|
|
||||||
" [property color]: [variable&callee lighten]([variable-2 @color], [number 10%]);",
|
|
||||||
"}",
|
|
||||||
"[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
|
|
||||||
" [property display]: [atom block];",
|
|
||||||
"}",
|
|
||||||
"[variable-2 @switch]: [variable light];",
|
|
||||||
"[qualifier .class] {",
|
|
||||||
" [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("nest",
|
|
||||||
"[qualifier .one] {",
|
|
||||||
" [def @media] ([property width]: [number 400px]) {",
|
|
||||||
" [property font-size]: [number 1.2em];",
|
|
||||||
" [def @media] [attribute print] [keyword and] [property color] {",
|
|
||||||
" [property color]: [keyword blue];",
|
|
||||||
" }",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
|
|
||||||
MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
|
|
||||||
})();
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: SCSS mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="css.js"></script>
|
|
||||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">SCSS</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>SCSS mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
/* Some example SCSS */
|
|
||||||
|
|
||||||
@import "compass/css3";
|
|
||||||
$variable: #333;
|
|
||||||
|
|
||||||
$blue: #3bbfce;
|
|
||||||
$margin: 16px;
|
|
||||||
|
|
||||||
.content-navigation {
|
|
||||||
#nested {
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
border-color: $blue;
|
|
||||||
color:
|
|
||||||
darken($blue, 9%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.border {
|
|
||||||
padding: $margin / 2;
|
|
||||||
margin: $margin / 2;
|
|
||||||
border-color: $blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin table-base {
|
|
||||||
th {
|
|
||||||
text-align: center;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
td, th {padding: 2px}
|
|
||||||
}
|
|
||||||
|
|
||||||
table.hl {
|
|
||||||
margin: 2em 0;
|
|
||||||
td.ln {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
font: {
|
|
||||||
family: serif;
|
|
||||||
weight: bold;
|
|
||||||
size: 1.2em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin left($dist) {
|
|
||||||
float: left;
|
|
||||||
margin-left: $dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
#data {
|
|
||||||
@include left(10px);
|
|
||||||
@include table-base;
|
|
||||||
}
|
|
||||||
|
|
||||||
.source {
|
|
||||||
@include flow-into(target);
|
|
||||||
border: 10px solid green;
|
|
||||||
margin: 20px;
|
|
||||||
width: 200px; }
|
|
||||||
|
|
||||||
.new-container {
|
|
||||||
@include flow-from(target);
|
|
||||||
border: 10px solid red;
|
|
||||||
margin: 20px;
|
|
||||||
width: 200px; }
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 3em 6em;
|
|
||||||
font-family: tahoma, arial, sans-serif;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin yellow() {
|
|
||||||
background: yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
.big {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nested {
|
|
||||||
@include border-radius(3px);
|
|
||||||
@extend .big;
|
|
||||||
p {
|
|
||||||
background: whitesmoke;
|
|
||||||
a {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation a {
|
|
||||||
font-weight: bold;
|
|
||||||
text-decoration: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 2.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 1.7em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1:before, h2:before {
|
|
||||||
content: "::";
|
|
||||||
}
|
|
||||||
|
|
||||||
code {
|
|
||||||
font-family: courier, monospace;
|
|
||||||
font-size: 80%;
|
|
||||||
color: #418A8A;
|
|
||||||
}
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-scss"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
|
||||||
|
|
||||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
|
|
||||||
|
|
||||||
</article>
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
|
|
||||||
|
|
||||||
MT('url_with_quotation',
|
|
||||||
"[tag foo] { [property background]:[variable&callee url]([string test.jpg]) }");
|
|
||||||
|
|
||||||
MT('url_with_double_quotes',
|
|
||||||
"[tag foo] { [property background]:[variable&callee url]([string \"test.jpg\"]) }");
|
|
||||||
|
|
||||||
MT('url_with_single_quotes',
|
|
||||||
"[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) }");
|
|
||||||
|
|
||||||
MT('string',
|
|
||||||
"[def @import] [string \"compass/css3\"]");
|
|
||||||
|
|
||||||
MT('important_keyword',
|
|
||||||
"[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) [keyword !important] }");
|
|
||||||
|
|
||||||
MT('variable',
|
|
||||||
"[variable-2 $blue]:[atom #333]");
|
|
||||||
|
|
||||||
MT('variable_as_attribute',
|
|
||||||
"[tag foo] { [property color]:[variable-2 $blue] }");
|
|
||||||
|
|
||||||
MT('numbers',
|
|
||||||
"[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }");
|
|
||||||
|
|
||||||
MT('number_percentage',
|
|
||||||
"[tag foo] { [property width]:[number 80%] }");
|
|
||||||
|
|
||||||
MT('selector',
|
|
||||||
"[builtin #hello][qualifier .world]{}");
|
|
||||||
|
|
||||||
MT('singleline_comment',
|
|
||||||
"[comment // this is a comment]");
|
|
||||||
|
|
||||||
MT('multiline_comment',
|
|
||||||
"[comment /*foobar*/]");
|
|
||||||
|
|
||||||
MT('attribute_with_hyphen',
|
|
||||||
"[tag foo] { [property font-size]:[number 10px] }");
|
|
||||||
|
|
||||||
MT('string_after_attribute',
|
|
||||||
"[tag foo] { [property content]:[string \"::\"] }");
|
|
||||||
|
|
||||||
MT('directives',
|
|
||||||
"[def @include] [qualifier .mixin]");
|
|
||||||
|
|
||||||
MT('basic_structure',
|
|
||||||
"[tag p] { [property background]:[keyword red]; }");
|
|
||||||
|
|
||||||
MT('nested_structure',
|
|
||||||
"[tag p] { [tag a] { [property color]:[keyword red]; } }");
|
|
||||||
|
|
||||||
MT('mixin',
|
|
||||||
"[def @mixin] [tag table-base] {}");
|
|
||||||
|
|
||||||
MT('number_without_semicolon',
|
|
||||||
"[tag p] {[property width]:[number 12]}",
|
|
||||||
"[tag a] {[property color]:[keyword red];}");
|
|
||||||
|
|
||||||
MT('atom_in_nested_block',
|
|
||||||
"[tag p] { [tag a] { [property color]:[atom #000]; } }");
|
|
||||||
|
|
||||||
MT('interpolation_in_property',
|
|
||||||
"[tag foo] { #{[variable-2 $hello]}:[number 2]; }");
|
|
||||||
|
|
||||||
MT('interpolation_in_selector',
|
|
||||||
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");
|
|
||||||
|
|
||||||
MT('interpolation_error',
|
|
||||||
"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");
|
|
||||||
|
|
||||||
MT("divide_operator",
|
|
||||||
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }");
|
|
||||||
|
|
||||||
MT('nested_structure_with_id_selector',
|
|
||||||
"[tag p] { [builtin #hello] { [property color]:[keyword red]; } }");
|
|
||||||
|
|
||||||
MT('indent_mixin',
|
|
||||||
"[def @mixin] [tag container] (",
|
|
||||||
" [variable-2 $a]: [number 10],",
|
|
||||||
" [variable-2 $b]: [number 10])",
|
|
||||||
"{}");
|
|
||||||
|
|
||||||
MT('indent_nested',
|
|
||||||
"[tag foo] {",
|
|
||||||
" [tag bar] {",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT('indent_parentheses',
|
|
||||||
"[tag foo] {",
|
|
||||||
" [property color]: [variable&callee darken]([variable-2 $blue],",
|
|
||||||
" [number 9%]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT('indent_vardef',
|
|
||||||
"[variable-2 $name]:",
|
|
||||||
" [string 'val'];",
|
|
||||||
"[tag tag] {",
|
|
||||||
" [tag inner] {",
|
|
||||||
" [property margin]: [number 3px];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
})();
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
|
|
||||||
// Error, because "foobarhello" is neither a known type or property, but
|
|
||||||
// property was expected (after "and"), and it should be in parentheses.
|
|
||||||
MT("atMediaUnknownType",
|
|
||||||
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
|
||||||
|
|
||||||
// Soft error, because "foobarhello" is not a known property or type.
|
|
||||||
MT("atMediaUnknownProperty",
|
|
||||||
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
|
|
||||||
|
|
||||||
// Make sure nesting works with media queries
|
|
||||||
MT("atMediaMaxWidthNested",
|
|
||||||
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
|
||||||
|
|
||||||
MT("atMediaFeatureValueKeyword",
|
|
||||||
"[def @media] ([property orientation]: [keyword landscape]) { }");
|
|
||||||
|
|
||||||
MT("atMediaUnknownFeatureValueKeyword",
|
|
||||||
"[def @media] ([property orientation]: [error upsidedown]) { }");
|
|
||||||
|
|
||||||
MT("atMediaUppercase",
|
|
||||||
"[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }");
|
|
||||||
|
|
||||||
MT("tagSelector",
|
|
||||||
"[tag foo] { }");
|
|
||||||
|
|
||||||
MT("classSelector",
|
|
||||||
"[qualifier .foo-bar_hello] { }");
|
|
||||||
|
|
||||||
MT("idSelector",
|
|
||||||
"[builtin #foo] { [error #foo] }");
|
|
||||||
|
|
||||||
MT("tagSelectorUnclosed",
|
|
||||||
"[tag foo] { [property margin]: [number 0] } [tag bar] { }");
|
|
||||||
|
|
||||||
MT("tagStringNoQuotes",
|
|
||||||
"[tag foo] { [property font-family]: [variable hello] [variable world]; }");
|
|
||||||
|
|
||||||
MT("tagStringDouble",
|
|
||||||
"[tag foo] { [property font-family]: [string \"hello world\"]; }");
|
|
||||||
|
|
||||||
MT("tagStringSingle",
|
|
||||||
"[tag foo] { [property font-family]: [string 'hello world']; }");
|
|
||||||
|
|
||||||
MT("tagColorKeyword",
|
|
||||||
"[tag foo] {",
|
|
||||||
" [property color]: [keyword black];",
|
|
||||||
" [property color]: [keyword navy];",
|
|
||||||
" [property color]: [keyword yellow];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("tagColorHex3",
|
|
||||||
"[tag foo] { [property background]: [atom #fff]; }");
|
|
||||||
|
|
||||||
MT("tagColorHex4",
|
|
||||||
"[tag foo] { [property background]: [atom #ffff]; }");
|
|
||||||
|
|
||||||
MT("tagColorHex6",
|
|
||||||
"[tag foo] { [property background]: [atom #ffffff]; }");
|
|
||||||
|
|
||||||
MT("tagColorHex8",
|
|
||||||
"[tag foo] { [property background]: [atom #ffffffff]; }");
|
|
||||||
|
|
||||||
MT("tagColorHex5Invalid",
|
|
||||||
"[tag foo] { [property background]: [atom&error #fffff]; }");
|
|
||||||
|
|
||||||
MT("tagColorHexInvalid",
|
|
||||||
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
|
||||||
|
|
||||||
MT("tagNegativeNumber",
|
|
||||||
"[tag foo] { [property margin]: [number -5px]; }");
|
|
||||||
|
|
||||||
MT("tagPositiveNumber",
|
|
||||||
"[tag foo] { [property padding]: [number 5px]; }");
|
|
||||||
|
|
||||||
MT("tagVendor",
|
|
||||||
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
|
|
||||||
|
|
||||||
MT("tagBogusProperty",
|
|
||||||
"[tag foo] { [property&error barhelloworld]: [number 0]; }");
|
|
||||||
|
|
||||||
MT("tagTwoProperties",
|
|
||||||
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
|
|
||||||
|
|
||||||
MT("tagTwoPropertiesURL",
|
|
||||||
"[tag foo] { [property background]: [variable&callee url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
|
||||||
|
|
||||||
MT("indent_tagSelector",
|
|
||||||
"[tag strong], [tag em] {",
|
|
||||||
" [property background]: [variable&callee rgba](",
|
|
||||||
" [number 255], [number 255], [number 0], [number .2]",
|
|
||||||
" );",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("indent_atMedia",
|
|
||||||
"[def @media] {",
|
|
||||||
" [tag foo] {",
|
|
||||||
" [property color]:",
|
|
||||||
" [keyword yellow];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("indent_comma",
|
|
||||||
"[tag foo] {",
|
|
||||||
" [property font-family]: [variable verdana],",
|
|
||||||
" [atom sans-serif];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("indent_parentheses",
|
|
||||||
"[tag foo]:[variable-3 before] {",
|
|
||||||
" [property background]: [variable&callee url](",
|
|
||||||
"[string blahblah]",
|
|
||||||
"[string etc]",
|
|
||||||
"[string ]) [keyword !important];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("font_face",
|
|
||||||
"[def @font-face] {",
|
|
||||||
" [property font-family]: [string 'myfont'];",
|
|
||||||
" [error nonsense]: [string 'abc'];",
|
|
||||||
" [property src]: [variable&callee url]([string http://blah]),",
|
|
||||||
" [variable&callee url]([string http://foo]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("empty_url",
|
|
||||||
"[def @import] [variable&callee url]() [attribute screen];");
|
|
||||||
|
|
||||||
MT("parens",
|
|
||||||
"[qualifier .foo] {",
|
|
||||||
" [property background-image]: [variable&callee fade]([atom #000], [number 20%]);",
|
|
||||||
" [property border-image]: [variable&callee linear-gradient](",
|
|
||||||
" [atom to] [atom bottom],",
|
|
||||||
" [variable&callee fade]([atom #000], [number 20%]) [number 0%],",
|
|
||||||
" [variable&callee fade]([atom #000], [number 20%]) [number 100%]",
|
|
||||||
" );",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("css_variable",
|
|
||||||
":[variable-3 root] {",
|
|
||||||
" [variable-2 --main-color]: [atom #06c];",
|
|
||||||
"}",
|
|
||||||
"[tag h1][builtin #foo] {",
|
|
||||||
" [property color]: [variable&callee var]([variable-2 --main-color]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("blank_css_variable",
|
|
||||||
":[variable-3 root] {",
|
|
||||||
" [variable-2 --]: [atom #06c];",
|
|
||||||
"}",
|
|
||||||
"[tag h1][builtin #foo] {",
|
|
||||||
" [property color]: [variable&callee var]([variable-2 --]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("supports",
|
|
||||||
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
|
|
||||||
" [property text-align-last]: [atom justify];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("document",
|
|
||||||
"[def @document] [variable&callee url]([string http://blah]),",
|
|
||||||
" [variable&callee url-prefix]([string https://]),",
|
|
||||||
" [variable&callee domain]([string blah.com]),",
|
|
||||||
" [variable&callee regexp]([string \".*blah.+\"]) {",
|
|
||||||
" [builtin #id] {",
|
|
||||||
" [property background-color]: [keyword white];",
|
|
||||||
" }",
|
|
||||||
" [tag foo] {",
|
|
||||||
" [property font-family]: [variable Verdana], [atom sans-serif];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("document_url",
|
|
||||||
"[def @document] [variable&callee url]([string http://blah]) { [qualifier .class] { } }");
|
|
||||||
|
|
||||||
MT("document_urlPrefix",
|
|
||||||
"[def @document] [variable&callee url-prefix]([string https://]) { [builtin #id] { } }");
|
|
||||||
|
|
||||||
MT("document_domain",
|
|
||||||
"[def @document] [variable&callee domain]([string blah.com]) { [tag foo] { } }");
|
|
||||||
|
|
||||||
MT("document_regexp",
|
|
||||||
"[def @document] [variable&callee regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
|
|
||||||
|
|
||||||
MT("counter-style",
|
|
||||||
"[def @counter-style] [variable binary] {",
|
|
||||||
" [property system]: [atom numeric];",
|
|
||||||
" [property symbols]: [number 0] [number 1];",
|
|
||||||
" [property suffix]: [string \".\"];",
|
|
||||||
" [property range]: [atom infinite];",
|
|
||||||
" [property speak-as]: [atom numeric];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("counter-style-additive-symbols",
|
|
||||||
"[def @counter-style] [variable simple-roman] {",
|
|
||||||
" [property system]: [atom additive];",
|
|
||||||
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
|
|
||||||
" [property range]: [number 1] [number 49];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("counter-style-use",
|
|
||||||
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
|
|
||||||
|
|
||||||
MT("counter-style-symbols",
|
|
||||||
"[tag ol] { [property list-style]: [variable&callee symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
|
|
||||||
|
|
||||||
MT("comment-does-not-disrupt",
|
|
||||||
"[def @font-face] [comment /* foo */] {",
|
|
||||||
" [property src]: [variable&callee url]([string x]);",
|
|
||||||
" [property font-family]: [variable One];",
|
|
||||||
"}")
|
|
||||||
})();
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function(mod) {
|
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
||||||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
|
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
|
||||||
define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
|
|
||||||
else // Plain browser env
|
|
||||||
mod(CodeMirror);
|
|
||||||
})(function(CodeMirror) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var defaultTags = {
|
|
||||||
script: [
|
|
||||||
["lang", /(javascript|babel)/i, "javascript"],
|
|
||||||
["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
|
|
||||||
["type", /./, "text/plain"],
|
|
||||||
[null, null, "javascript"]
|
|
||||||
],
|
|
||||||
style: [
|
|
||||||
["lang", /^css$/i, "css"],
|
|
||||||
["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
|
|
||||||
["type", /./, "text/plain"],
|
|
||||||
[null, null, "css"]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
function maybeBackup(stream, pat, style) {
|
|
||||||
var cur = stream.current(), close = cur.search(pat);
|
|
||||||
if (close > -1) {
|
|
||||||
stream.backUp(cur.length - close);
|
|
||||||
} else if (cur.match(/<\/?$/)) {
|
|
||||||
stream.backUp(cur.length);
|
|
||||||
if (!stream.match(pat, false)) stream.match(cur);
|
|
||||||
}
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
var attrRegexpCache = {};
|
|
||||||
function getAttrRegexp(attr) {
|
|
||||||
var regexp = attrRegexpCache[attr];
|
|
||||||
if (regexp) return regexp;
|
|
||||||
return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAttrValue(text, attr) {
|
|
||||||
var match = text.match(getAttrRegexp(attr))
|
|
||||||
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTagRegexp(tagName, anchored) {
|
|
||||||
return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTags(from, to) {
|
|
||||||
for (var tag in from) {
|
|
||||||
var dest = to[tag] || (to[tag] = []);
|
|
||||||
var source = from[tag];
|
|
||||||
for (var i = source.length - 1; i >= 0; i--)
|
|
||||||
dest.unshift(source[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function findMatchingMode(tagInfo, tagText) {
|
|
||||||
for (var i = 0; i < tagInfo.length; i++) {
|
|
||||||
var spec = tagInfo[i];
|
|
||||||
if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
|
|
||||||
var htmlMode = CodeMirror.getMode(config, {
|
|
||||||
name: "xml",
|
|
||||||
htmlMode: true,
|
|
||||||
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
|
||||||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
|
|
||||||
});
|
|
||||||
|
|
||||||
var tags = {};
|
|
||||||
var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
|
|
||||||
addTags(defaultTags, tags);
|
|
||||||
if (configTags) addTags(configTags, tags);
|
|
||||||
if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
|
|
||||||
tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
|
|
||||||
|
|
||||||
function html(stream, state) {
|
|
||||||
var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
|
|
||||||
if (tag && !/[<>\s\/]/.test(stream.current()) &&
|
|
||||||
(tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
|
|
||||||
tags.hasOwnProperty(tagName)) {
|
|
||||||
state.inTag = tagName + " "
|
|
||||||
} else if (state.inTag && tag && />$/.test(stream.current())) {
|
|
||||||
var inTag = /^([\S]+) (.*)/.exec(state.inTag)
|
|
||||||
state.inTag = null
|
|
||||||
var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
|
|
||||||
var mode = CodeMirror.getMode(config, modeSpec)
|
|
||||||
var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
|
|
||||||
state.token = function (stream, state) {
|
|
||||||
if (stream.match(endTagA, false)) {
|
|
||||||
state.token = html;
|
|
||||||
state.localState = state.localMode = null;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
|
|
||||||
};
|
|
||||||
state.localMode = mode;
|
|
||||||
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", ""));
|
|
||||||
} else if (state.inTag) {
|
|
||||||
state.inTag += stream.current()
|
|
||||||
if (stream.eol()) state.inTag += " "
|
|
||||||
}
|
|
||||||
return style;
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
startState: function () {
|
|
||||||
var state = CodeMirror.startState(htmlMode);
|
|
||||||
return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
|
|
||||||
},
|
|
||||||
|
|
||||||
copyState: function (state) {
|
|
||||||
var local;
|
|
||||||
if (state.localState) {
|
|
||||||
local = CodeMirror.copyState(state.localMode, state.localState);
|
|
||||||
}
|
|
||||||
return {token: state.token, inTag: state.inTag,
|
|
||||||
localMode: state.localMode, localState: local,
|
|
||||||
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
|
|
||||||
},
|
|
||||||
|
|
||||||
token: function (stream, state) {
|
|
||||||
return state.token(stream, state);
|
|
||||||
},
|
|
||||||
|
|
||||||
indent: function (state, textAfter, line) {
|
|
||||||
if (!state.localMode || /^\s*<\//.test(textAfter))
|
|
||||||
return htmlMode.indent(state.htmlState, textAfter, line);
|
|
||||||
else if (state.localMode.indent)
|
|
||||||
return state.localMode.indent(state.localState, textAfter, line);
|
|
||||||
else
|
|
||||||
return CodeMirror.Pass;
|
|
||||||
},
|
|
||||||
|
|
||||||
innerMode: function (state) {
|
|
||||||
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, "xml", "javascript", "css");
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/html", "htmlmixed");
|
|
||||||
});
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: HTML mixed mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/selection/selection-pointer.js"></script>
|
|
||||||
<script src="../xml/xml.js"></script>
|
|
||||||
<script src="../javascript/javascript.js"></script>
|
|
||||||
<script src="../css/css.js"></script>
|
|
||||||
<script src="../vbscript/vbscript.js"></script>
|
|
||||||
<script src="htmlmixed.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">HTML mixed</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>HTML mixed mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
<html style="color: green">
|
|
||||||
<!-- this is a comment -->
|
|
||||||
<head>
|
|
||||||
<title>Mixed HTML Example</title>
|
|
||||||
<style>
|
|
||||||
h1 {font-family: comic sans; color: #f0f;}
|
|
||||||
div {background: yellow !important;}
|
|
||||||
body {
|
|
||||||
max-width: 50em;
|
|
||||||
margin: 1em 2em 1em 5em;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Mixed HTML Example</h1>
|
|
||||||
<script>
|
|
||||||
function jsFunc(arg1, arg2) {
|
|
||||||
if (arg1 && arg2) document.body.innerHTML = "achoo";
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
// Define an extended mixed-mode that understands vbscript and
|
|
||||||
// leaves mustache/handlebars embedded templates in html mode
|
|
||||||
var mixedMode = {
|
|
||||||
name: "htmlmixed",
|
|
||||||
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
|
|
||||||
mode: null},
|
|
||||||
{matches: /(text|application)\/(x-)?vb(a|script)/i,
|
|
||||||
mode: "vbscript"}]
|
|
||||||
};
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
mode: mixedMode,
|
|
||||||
selectionPointer: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p>
|
|
||||||
|
|
||||||
<p>It takes an optional mode configuration
|
|
||||||
option, <code>tags</code>, which can be used to add custom
|
|
||||||
behavior for specific tags. When given, it should be an object
|
|
||||||
mapping tag names (for example <code>script</code>) to arrays or
|
|
||||||
three-element arrays. Those inner arrays indicate [attributeName,
|
|
||||||
valueRegexp, <a href="../../doc/manual.html#option_mode">modeSpec</a>]
|
|
||||||
specifications. For example, you could use <code>["type", /^foo$/,
|
|
||||||
"foo"]</code> to map the attribute <code>type="foo"</code> to
|
|
||||||
the <code>foo</code> mode. When the first two fields are null
|
|
||||||
(<code>[null, null, "mode"]</code>), the given mode is used for
|
|
||||||
any such tag that doesn't match any of the previously given
|
|
||||||
attributes. For example:</p>
|
|
||||||
|
|
||||||
<pre>var myModeSpec = {
|
|
||||||
name: "htmlmixed",
|
|
||||||
tags: {
|
|
||||||
style: [["type", /^text\/(x-)?scss$/, "text/x-scss"],
|
|
||||||
[null, null, "css"]],
|
|
||||||
custom: [[null, null, "customMode"]]
|
|
||||||
}
|
|
||||||
}</pre>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/html</code>
|
|
||||||
(redefined, only takes effect if you load this parser after the
|
|
||||||
XML parser).</p>
|
|
||||||
|
|
||||||
</article>
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: JavaScript mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="../../addon/comment/continuecomment.js"></script>
|
|
||||||
<script src="../../addon/comment/comment.js"></script>
|
|
||||||
<script src="javascript.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">JavaScript</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>JavaScript mode</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<div><textarea id="code" name="code">
|
|
||||||
// Demo code (the actual new parser character stream implementation)
|
|
||||||
|
|
||||||
function StringStream(string) {
|
|
||||||
this.pos = 0;
|
|
||||||
this.string = string;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringStream.prototype = {
|
|
||||||
done: function() {return this.pos >= this.string.length;},
|
|
||||||
peek: function() {return this.string.charAt(this.pos);},
|
|
||||||
next: function() {
|
|
||||||
if (this.pos < this.string.length)
|
|
||||||
return this.string.charAt(this.pos++);
|
|
||||||
},
|
|
||||||
eat: function(match) {
|
|
||||||
var ch = this.string.charAt(this.pos);
|
|
||||||
if (typeof match == "string") var ok = ch == match;
|
|
||||||
else var ok = ch && match.test ? match.test(ch) : match(ch);
|
|
||||||
if (ok) {this.pos++; return ch;}
|
|
||||||
},
|
|
||||||
eatWhile: function(match) {
|
|
||||||
var start = this.pos;
|
|
||||||
while (this.eat(match));
|
|
||||||
if (this.pos > start) return this.string.slice(start, this.pos);
|
|
||||||
},
|
|
||||||
backUp: function(n) {this.pos -= n;},
|
|
||||||
column: function() {return this.pos;},
|
|
||||||
eatSpace: function() {
|
|
||||||
var start = this.pos;
|
|
||||||
while (/\s/.test(this.string.charAt(this.pos))) this.pos++;
|
|
||||||
return this.pos - start;
|
|
||||||
},
|
|
||||||
match: function(pattern, consume, caseInsensitive) {
|
|
||||||
if (typeof pattern == "string") {
|
|
||||||
function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
|
|
||||||
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
|
|
||||||
if (consume !== false) this.pos += str.length;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var match = this.string.slice(this.pos).match(pattern);
|
|
||||||
if (match && consume !== false) this.pos += match[0].length;
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
continueComments: "Enter",
|
|
||||||
extraKeys: {"Ctrl-Q": "toggleComment"}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
JavaScript mode supports several configuration options:
|
|
||||||
<ul>
|
|
||||||
<li><code>json</code> which will set the mode to expect JSON
|
|
||||||
data rather than a JavaScript program.</li>
|
|
||||||
<li><code>jsonld</code> which will set the mode to expect
|
|
||||||
<a href="http://json-ld.org">JSON-LD</a> linked data rather
|
|
||||||
than a JavaScript program (<a href="json-ld.html">demo</a>).</li>
|
|
||||||
<li><code>typescript</code> which will activate additional
|
|
||||||
syntax highlighting and some other things for TypeScript code
|
|
||||||
(<a href="typescript.html">demo</a>).</li>
|
|
||||||
<li><code>statementIndent</code> which (given a number) will
|
|
||||||
determine the amount of indentation to use for statements
|
|
||||||
continued on a new line.</li>
|
|
||||||
<li><code>wordCharacters</code>, a regexp that indicates which
|
|
||||||
characters should be considered part of an identifier.
|
|
||||||
Defaults to <code>/[\w$]/</code>, which does not handle
|
|
||||||
non-ASCII identifiers. Can be set to something more elaborate
|
|
||||||
to improve Unicode support.</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>, <code>application/ld+json</code>, <code>text/typescript</code>, <code>application/typescript</code>.</p>
|
|
||||||
</article>
|
|
||||||
@@ -1,913 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://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.defineMode("javascript", function(config, parserConfig) {
|
|
||||||
var indentUnit = config.indentUnit;
|
|
||||||
var statementIndent = parserConfig.statementIndent;
|
|
||||||
var jsonldMode = parserConfig.jsonld;
|
|
||||||
var jsonMode = parserConfig.json || jsonldMode;
|
|
||||||
var isTS = parserConfig.typescript;
|
|
||||||
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
|
||||||
|
|
||||||
// Tokenizer
|
|
||||||
|
|
||||||
var keywords = function(){
|
|
||||||
function kw(type) {return {type: type, style: "keyword"};}
|
|
||||||
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
|
|
||||||
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
|
||||||
|
|
||||||
return {
|
|
||||||
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
|
||||||
"return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
|
|
||||||
"debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
|
|
||||||
"function": kw("function"), "catch": kw("catch"),
|
|
||||||
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
|
||||||
"in": operator, "typeof": operator, "instanceof": operator,
|
|
||||||
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
|
||||||
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
|
|
||||||
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
|
|
||||||
"await": C
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
|
|
||||||
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
|
||||||
|
|
||||||
function readRegexp(stream) {
|
|
||||||
var escaped = false, next, inSet = false;
|
|
||||||
while ((next = stream.next()) != null) {
|
|
||||||
if (!escaped) {
|
|
||||||
if (next == "/" && !inSet) return;
|
|
||||||
if (next == "[") inSet = true;
|
|
||||||
else if (inSet && next == "]") inSet = false;
|
|
||||||
}
|
|
||||||
escaped = !escaped && next == "\\";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used as scratch variables to communicate multiple values without
|
|
||||||
// consing up tons of objects.
|
|
||||||
var type, content;
|
|
||||||
function ret(tp, style, cont) {
|
|
||||||
type = tp; content = cont;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
function tokenBase(stream, state) {
|
|
||||||
var ch = stream.next();
|
|
||||||
if (ch == '"' || ch == "'") {
|
|
||||||
state.tokenize = tokenString(ch);
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
|
||||||
return ret("number", "number");
|
|
||||||
} else if (ch == "." && stream.match("..")) {
|
|
||||||
return ret("spread", "meta");
|
|
||||||
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
|
||||||
return ret(ch);
|
|
||||||
} else if (ch == "=" && stream.eat(">")) {
|
|
||||||
return ret("=>", "operator");
|
|
||||||
} else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
|
|
||||||
return ret("number", "number");
|
|
||||||
} else if (/\d/.test(ch)) {
|
|
||||||
stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
|
|
||||||
return ret("number", "number");
|
|
||||||
} else if (ch == "/") {
|
|
||||||
if (stream.eat("*")) {
|
|
||||||
state.tokenize = tokenComment;
|
|
||||||
return tokenComment(stream, state);
|
|
||||||
} else if (stream.eat("/")) {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return ret("comment", "comment");
|
|
||||||
} else if (expressionAllowed(stream, state, 1)) {
|
|
||||||
readRegexp(stream);
|
|
||||||
stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
|
|
||||||
return ret("regexp", "string-2");
|
|
||||||
} else {
|
|
||||||
stream.eat("=");
|
|
||||||
return ret("operator", "operator", stream.current());
|
|
||||||
}
|
|
||||||
} else if (ch == "`") {
|
|
||||||
state.tokenize = tokenQuasi;
|
|
||||||
return tokenQuasi(stream, state);
|
|
||||||
} else if (ch == "#") {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return ret("error", "error");
|
|
||||||
} else if (isOperatorChar.test(ch)) {
|
|
||||||
if (ch != ">" || !state.lexical || state.lexical.type != ">") {
|
|
||||||
if (stream.eat("=")) {
|
|
||||||
if (ch == "!" || ch == "=") stream.eat("=")
|
|
||||||
} else if (/[<>*+\-]/.test(ch)) {
|
|
||||||
stream.eat(ch)
|
|
||||||
if (ch == ">") stream.eat(ch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret("operator", "operator", stream.current());
|
|
||||||
} else if (wordRE.test(ch)) {
|
|
||||||
stream.eatWhile(wordRE);
|
|
||||||
var word = stream.current()
|
|
||||||
if (state.lastType != ".") {
|
|
||||||
if (keywords.propertyIsEnumerable(word)) {
|
|
||||||
var kw = keywords[word]
|
|
||||||
return ret(kw.type, kw.style, word)
|
|
||||||
}
|
|
||||||
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
|
|
||||||
return ret("async", "keyword", word)
|
|
||||||
}
|
|
||||||
return ret("variable", "variable", word)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenString(quote) {
|
|
||||||
return function(stream, state) {
|
|
||||||
var escaped = false, next;
|
|
||||||
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
|
||||||
state.tokenize = tokenBase;
|
|
||||||
return ret("jsonld-keyword", "meta");
|
|
||||||
}
|
|
||||||
while ((next = stream.next()) != null) {
|
|
||||||
if (next == quote && !escaped) break;
|
|
||||||
escaped = !escaped && next == "\\";
|
|
||||||
}
|
|
||||||
if (!escaped) state.tokenize = tokenBase;
|
|
||||||
return ret("string", "string");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenComment(stream, state) {
|
|
||||||
var maybeEnd = false, ch;
|
|
||||||
while (ch = stream.next()) {
|
|
||||||
if (ch == "/" && maybeEnd) {
|
|
||||||
state.tokenize = tokenBase;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
maybeEnd = (ch == "*");
|
|
||||||
}
|
|
||||||
return ret("comment", "comment");
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenQuasi(stream, state) {
|
|
||||||
var escaped = false, next;
|
|
||||||
while ((next = stream.next()) != null) {
|
|
||||||
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
|
||||||
state.tokenize = tokenBase;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
escaped = !escaped && next == "\\";
|
|
||||||
}
|
|
||||||
return ret("quasi", "string-2", stream.current());
|
|
||||||
}
|
|
||||||
|
|
||||||
var brackets = "([{}])";
|
|
||||||
// This is a crude lookahead trick to try and notice that we're
|
|
||||||
// parsing the argument patterns for a fat-arrow function before we
|
|
||||||
// actually hit the arrow token. It only works if the arrow is on
|
|
||||||
// the same line as the arguments and there's no strange noise
|
|
||||||
// (comments) in between. Fallback is to only notice when we hit the
|
|
||||||
// arrow, and not declare the arguments as locals for the arrow
|
|
||||||
// body.
|
|
||||||
function findFatArrow(stream, state) {
|
|
||||||
if (state.fatArrowAt) state.fatArrowAt = null;
|
|
||||||
var arrow = stream.string.indexOf("=>", stream.start);
|
|
||||||
if (arrow < 0) return;
|
|
||||||
|
|
||||||
if (isTS) { // Try to skip TypeScript return type declarations after the arguments
|
|
||||||
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
|
|
||||||
if (m) arrow = m.index
|
|
||||||
}
|
|
||||||
|
|
||||||
var depth = 0, sawSomething = false;
|
|
||||||
for (var pos = arrow - 1; pos >= 0; --pos) {
|
|
||||||
var ch = stream.string.charAt(pos);
|
|
||||||
var bracket = brackets.indexOf(ch);
|
|
||||||
if (bracket >= 0 && bracket < 3) {
|
|
||||||
if (!depth) { ++pos; break; }
|
|
||||||
if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
|
|
||||||
} else if (bracket >= 3 && bracket < 6) {
|
|
||||||
++depth;
|
|
||||||
} else if (wordRE.test(ch)) {
|
|
||||||
sawSomething = true;
|
|
||||||
} else if (/["'\/]/.test(ch)) {
|
|
||||||
return;
|
|
||||||
} else if (sawSomething && !depth) {
|
|
||||||
++pos;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sawSomething && !depth) state.fatArrowAt = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parser
|
|
||||||
|
|
||||||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
|
||||||
|
|
||||||
function JSLexical(indented, column, type, align, prev, info) {
|
|
||||||
this.indented = indented;
|
|
||||||
this.column = column;
|
|
||||||
this.type = type;
|
|
||||||
this.prev = prev;
|
|
||||||
this.info = info;
|
|
||||||
if (align != null) this.align = align;
|
|
||||||
}
|
|
||||||
|
|
||||||
function inScope(state, varname) {
|
|
||||||
for (var v = state.localVars; v; v = v.next)
|
|
||||||
if (v.name == varname) return true;
|
|
||||||
for (var cx = state.context; cx; cx = cx.prev) {
|
|
||||||
for (var v = cx.vars; v; v = v.next)
|
|
||||||
if (v.name == varname) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseJS(state, style, type, content, stream) {
|
|
||||||
var cc = state.cc;
|
|
||||||
// Communicate our context to the combinators.
|
|
||||||
// (Less wasteful than consing up a hundred closures on every call.)
|
|
||||||
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
|
||||||
|
|
||||||
if (!state.lexical.hasOwnProperty("align"))
|
|
||||||
state.lexical.align = true;
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
|
||||||
if (combinator(type, content)) {
|
|
||||||
while(cc.length && cc[cc.length - 1].lex)
|
|
||||||
cc.pop()();
|
|
||||||
if (cx.marked) return cx.marked;
|
|
||||||
if (type == "variable" && inScope(state, content)) return "variable-2";
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combinator utils
|
|
||||||
|
|
||||||
var cx = {state: null, column: null, marked: null, cc: null};
|
|
||||||
function pass() {
|
|
||||||
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
|
||||||
}
|
|
||||||
function cont() {
|
|
||||||
pass.apply(null, arguments);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
function inList(name, list) {
|
|
||||||
for (var v = list; v; v = v.next) if (v.name == name) return true
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function register(varname) {
|
|
||||||
var state = cx.state;
|
|
||||||
cx.marked = "def";
|
|
||||||
if (state.context) {
|
|
||||||
if (state.lexical.info == "var" && state.context && state.context.block) {
|
|
||||||
// FIXME function decls are also not block scoped
|
|
||||||
var newContext = registerVarScoped(varname, state.context)
|
|
||||||
if (newContext != null) {
|
|
||||||
state.context = newContext
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else if (!inList(varname, state.localVars)) {
|
|
||||||
state.localVars = new Var(varname, state.localVars)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fall through means this is global
|
|
||||||
if (parserConfig.globalVars && !inList(varname, state.globalVars))
|
|
||||||
state.globalVars = new Var(varname, state.globalVars)
|
|
||||||
}
|
|
||||||
function registerVarScoped(varname, context) {
|
|
||||||
if (!context) {
|
|
||||||
return null
|
|
||||||
} else if (context.block) {
|
|
||||||
var inner = registerVarScoped(varname, context.prev)
|
|
||||||
if (!inner) return null
|
|
||||||
if (inner == context.prev) return context
|
|
||||||
return new Context(inner, context.vars, true)
|
|
||||||
} else if (inList(varname, context.vars)) {
|
|
||||||
return context
|
|
||||||
} else {
|
|
||||||
return new Context(context.prev, new Var(varname, context.vars), false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isModifier(name) {
|
|
||||||
return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combinators
|
|
||||||
|
|
||||||
function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
|
|
||||||
function Var(name, next) { this.name = name; this.next = next }
|
|
||||||
|
|
||||||
var defaultVars = new Var("this", new Var("arguments", null))
|
|
||||||
function pushcontext() {
|
|
||||||
cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
|
|
||||||
cx.state.localVars = defaultVars
|
|
||||||
}
|
|
||||||
function pushblockcontext() {
|
|
||||||
cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
|
|
||||||
cx.state.localVars = null
|
|
||||||
}
|
|
||||||
function popcontext() {
|
|
||||||
cx.state.localVars = cx.state.context.vars
|
|
||||||
cx.state.context = cx.state.context.prev
|
|
||||||
}
|
|
||||||
popcontext.lex = true
|
|
||||||
function pushlex(type, info) {
|
|
||||||
var result = function() {
|
|
||||||
var state = cx.state, indent = state.indented;
|
|
||||||
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
|
||||||
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
|
||||||
indent = outer.indented;
|
|
||||||
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
|
||||||
};
|
|
||||||
result.lex = true;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
function poplex() {
|
|
||||||
var state = cx.state;
|
|
||||||
if (state.lexical.prev) {
|
|
||||||
if (state.lexical.type == ")")
|
|
||||||
state.indented = state.lexical.indented;
|
|
||||||
state.lexical = state.lexical.prev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
poplex.lex = true;
|
|
||||||
|
|
||||||
function expect(wanted) {
|
|
||||||
function exp(type) {
|
|
||||||
if (type == wanted) return cont();
|
|
||||||
else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
|
|
||||||
else return cont(exp);
|
|
||||||
};
|
|
||||||
return exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
function statement(type, value) {
|
|
||||||
if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
|
|
||||||
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
|
||||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
|
||||||
if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
|
|
||||||
if (type == "debugger") return cont(expect(";"));
|
|
||||||
if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
|
|
||||||
if (type == ";") return cont();
|
|
||||||
if (type == "if") {
|
|
||||||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
|
||||||
cx.state.cc.pop()();
|
|
||||||
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
|
|
||||||
}
|
|
||||||
if (type == "function") return cont(functiondef);
|
|
||||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
|
||||||
if (type == "class" || (isTS && value == "interface")) {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont(pushlex("form", type == "class" ? type : value), className, poplex)
|
|
||||||
}
|
|
||||||
if (type == "variable") {
|
|
||||||
if (isTS && value == "declare") {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont(statement)
|
|
||||||
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
if (value == "enum") return cont(enumdef);
|
|
||||||
else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
|
||||||
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
|
|
||||||
} else if (isTS && value == "namespace") {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont(pushlex("form"), expression, statement, poplex)
|
|
||||||
} else if (isTS && value == "abstract") {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont(statement)
|
|
||||||
} else {
|
|
||||||
return cont(pushlex("stat"), maybelabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
|
|
||||||
block, poplex, poplex, popcontext);
|
|
||||||
if (type == "case") return cont(expression, expect(":"));
|
|
||||||
if (type == "default") return cont(expect(":"));
|
|
||||||
if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
|
|
||||||
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
|
||||||
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
|
||||||
if (type == "async") return cont(statement)
|
|
||||||
if (value == "@") return cont(expression, statement)
|
|
||||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
|
||||||
}
|
|
||||||
function maybeCatchBinding(type) {
|
|
||||||
if (type == "(") return cont(funarg, expect(")"))
|
|
||||||
}
|
|
||||||
function expression(type, value) {
|
|
||||||
return expressionInner(type, value, false);
|
|
||||||
}
|
|
||||||
function expressionNoComma(type, value) {
|
|
||||||
return expressionInner(type, value, true);
|
|
||||||
}
|
|
||||||
function parenExpr(type) {
|
|
||||||
if (type != "(") return pass()
|
|
||||||
return cont(pushlex(")"), expression, expect(")"), poplex)
|
|
||||||
}
|
|
||||||
function expressionInner(type, value, noComma) {
|
|
||||||
if (cx.state.fatArrowAt == cx.stream.start) {
|
|
||||||
var body = noComma ? arrowBodyNoComma : arrowBody;
|
|
||||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
|
|
||||||
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
|
||||||
}
|
|
||||||
|
|
||||||
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
|
||||||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
|
||||||
if (type == "function") return cont(functiondef, maybeop);
|
|
||||||
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
|
|
||||||
if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
|
|
||||||
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
|
||||||
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
|
||||||
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
|
||||||
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
|
||||||
if (type == "quasi") return pass(quasi, maybeop);
|
|
||||||
if (type == "new") return cont(maybeTarget(noComma));
|
|
||||||
if (type == "import") return cont(expression);
|
|
||||||
return cont();
|
|
||||||
}
|
|
||||||
function maybeexpression(type) {
|
|
||||||
if (type.match(/[;\}\)\],]/)) return pass();
|
|
||||||
return pass(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeoperatorComma(type, value) {
|
|
||||||
if (type == ",") return cont(expression);
|
|
||||||
return maybeoperatorNoComma(type, value, false);
|
|
||||||
}
|
|
||||||
function maybeoperatorNoComma(type, value, noComma) {
|
|
||||||
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
|
||||||
var expr = noComma == false ? expression : expressionNoComma;
|
|
||||||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
|
||||||
if (type == "operator") {
|
|
||||||
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
|
|
||||||
if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
|
|
||||||
return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
|
|
||||||
if (value == "?") return cont(expression, expect(":"), expr);
|
|
||||||
return cont(expr);
|
|
||||||
}
|
|
||||||
if (type == "quasi") { return pass(quasi, me); }
|
|
||||||
if (type == ";") return;
|
|
||||||
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
|
||||||
if (type == ".") return cont(property, me);
|
|
||||||
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
|
||||||
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
|
|
||||||
if (type == "regexp") {
|
|
||||||
cx.state.lastType = cx.marked = "operator"
|
|
||||||
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
|
|
||||||
return cont(expr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function quasi(type, value) {
|
|
||||||
if (type != "quasi") return pass();
|
|
||||||
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
|
||||||
return cont(expression, continueQuasi);
|
|
||||||
}
|
|
||||||
function continueQuasi(type) {
|
|
||||||
if (type == "}") {
|
|
||||||
cx.marked = "string-2";
|
|
||||||
cx.state.tokenize = tokenQuasi;
|
|
||||||
return cont(quasi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function arrowBody(type) {
|
|
||||||
findFatArrow(cx.stream, cx.state);
|
|
||||||
return pass(type == "{" ? statement : expression);
|
|
||||||
}
|
|
||||||
function arrowBodyNoComma(type) {
|
|
||||||
findFatArrow(cx.stream, cx.state);
|
|
||||||
return pass(type == "{" ? statement : expressionNoComma);
|
|
||||||
}
|
|
||||||
function maybeTarget(noComma) {
|
|
||||||
return function(type) {
|
|
||||||
if (type == ".") return cont(noComma ? targetNoComma : target);
|
|
||||||
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
|
|
||||||
else return pass(noComma ? expressionNoComma : expression);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function target(_, value) {
|
|
||||||
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
|
|
||||||
}
|
|
||||||
function targetNoComma(_, value) {
|
|
||||||
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
|
|
||||||
}
|
|
||||||
function maybelabel(type) {
|
|
||||||
if (type == ":") return cont(poplex, statement);
|
|
||||||
return pass(maybeoperatorComma, expect(";"), poplex);
|
|
||||||
}
|
|
||||||
function property(type) {
|
|
||||||
if (type == "variable") {cx.marked = "property"; return cont();}
|
|
||||||
}
|
|
||||||
function objprop(type, value) {
|
|
||||||
if (type == "async") {
|
|
||||||
cx.marked = "property";
|
|
||||||
return cont(objprop);
|
|
||||||
} else if (type == "variable" || cx.style == "keyword") {
|
|
||||||
cx.marked = "property";
|
|
||||||
if (value == "get" || value == "set") return cont(getterSetter);
|
|
||||||
var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
|
|
||||||
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
|
|
||||||
cx.state.fatArrowAt = cx.stream.pos + m[0].length
|
|
||||||
return cont(afterprop);
|
|
||||||
} else if (type == "number" || type == "string") {
|
|
||||||
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
|
||||||
return cont(afterprop);
|
|
||||||
} else if (type == "jsonld-keyword") {
|
|
||||||
return cont(afterprop);
|
|
||||||
} else if (isTS && isModifier(value)) {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont(objprop)
|
|
||||||
} else if (type == "[") {
|
|
||||||
return cont(expression, maybetype, expect("]"), afterprop);
|
|
||||||
} else if (type == "spread") {
|
|
||||||
return cont(expressionNoComma, afterprop);
|
|
||||||
} else if (value == "*") {
|
|
||||||
cx.marked = "keyword";
|
|
||||||
return cont(objprop);
|
|
||||||
} else if (type == ":") {
|
|
||||||
return pass(afterprop)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getterSetter(type) {
|
|
||||||
if (type != "variable") return pass(afterprop);
|
|
||||||
cx.marked = "property";
|
|
||||||
return cont(functiondef);
|
|
||||||
}
|
|
||||||
function afterprop(type) {
|
|
||||||
if (type == ":") return cont(expressionNoComma);
|
|
||||||
if (type == "(") return pass(functiondef);
|
|
||||||
}
|
|
||||||
function commasep(what, end, sep) {
|
|
||||||
function proceed(type, value) {
|
|
||||||
if (sep ? sep.indexOf(type) > -1 : type == ",") {
|
|
||||||
var lex = cx.state.lexical;
|
|
||||||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
|
||||||
return cont(function(type, value) {
|
|
||||||
if (type == end || value == end) return pass()
|
|
||||||
return pass(what)
|
|
||||||
}, proceed);
|
|
||||||
}
|
|
||||||
if (type == end || value == end) return cont();
|
|
||||||
if (sep && sep.indexOf(";") > -1) return pass(what)
|
|
||||||
return cont(expect(end));
|
|
||||||
}
|
|
||||||
return function(type, value) {
|
|
||||||
if (type == end || value == end) return cont();
|
|
||||||
return pass(what, proceed);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function contCommasep(what, end, info) {
|
|
||||||
for (var i = 3; i < arguments.length; i++)
|
|
||||||
cx.cc.push(arguments[i]);
|
|
||||||
return cont(pushlex(end, info), commasep(what, end), poplex);
|
|
||||||
}
|
|
||||||
function block(type) {
|
|
||||||
if (type == "}") return cont();
|
|
||||||
return pass(statement, block);
|
|
||||||
}
|
|
||||||
function maybetype(type, value) {
|
|
||||||
if (isTS) {
|
|
||||||
if (type == ":") return cont(typeexpr);
|
|
||||||
if (value == "?") return cont(maybetype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function mayberettype(type) {
|
|
||||||
if (isTS && type == ":") {
|
|
||||||
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
|
||||||
else return cont(typeexpr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isKW(_, value) {
|
|
||||||
if (value == "is") {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function typeexpr(type, value) {
|
|
||||||
if (value == "keyof" || value == "typeof") {
|
|
||||||
cx.marked = "keyword"
|
|
||||||
return cont(value == "keyof" ? typeexpr : expressionNoComma)
|
|
||||||
}
|
|
||||||
if (type == "variable" || value == "void") {
|
|
||||||
cx.marked = "type"
|
|
||||||
return cont(afterType)
|
|
||||||
}
|
|
||||||
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
|
||||||
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
|
||||||
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
|
||||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
|
||||||
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
|
|
||||||
}
|
|
||||||
function maybeReturnType(type) {
|
|
||||||
if (type == "=>") return cont(typeexpr)
|
|
||||||
}
|
|
||||||
function typeprop(type, value) {
|
|
||||||
if (type == "variable" || cx.style == "keyword") {
|
|
||||||
cx.marked = "property"
|
|
||||||
return cont(typeprop)
|
|
||||||
} else if (value == "?") {
|
|
||||||
return cont(typeprop)
|
|
||||||
} else if (type == ":") {
|
|
||||||
return cont(typeexpr)
|
|
||||||
} else if (type == "[") {
|
|
||||||
return cont(expression, maybetype, expect("]"), typeprop)
|
|
||||||
} else if (type == "(") {
|
|
||||||
return cont(pushlex(")"), commasep(funarg, ")"), poplex, typeprop)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function typearg(type, value) {
|
|
||||||
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
|
|
||||||
if (type == ":") return cont(typeexpr)
|
|
||||||
return pass(typeexpr)
|
|
||||||
}
|
|
||||||
function afterType(type, value) {
|
|
||||||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
|
||||||
if (value == "|" || type == "." || value == "&") return cont(typeexpr)
|
|
||||||
if (type == "[") return cont(expect("]"), afterType)
|
|
||||||
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
|
|
||||||
}
|
|
||||||
function maybeTypeArgs(_, value) {
|
|
||||||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
|
||||||
}
|
|
||||||
function typeparam() {
|
|
||||||
return pass(typeexpr, maybeTypeDefault)
|
|
||||||
}
|
|
||||||
function maybeTypeDefault(_, value) {
|
|
||||||
if (value == "=") return cont(typeexpr)
|
|
||||||
}
|
|
||||||
function vardef(_, value) {
|
|
||||||
if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
|
|
||||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
|
||||||
}
|
|
||||||
function pattern(type, value) {
|
|
||||||
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
|
|
||||||
if (type == "variable") { register(value); return cont(); }
|
|
||||||
if (type == "spread") return cont(pattern);
|
|
||||||
if (type == "[") return contCommasep(eltpattern, "]");
|
|
||||||
if (type == "{") return contCommasep(proppattern, "}");
|
|
||||||
}
|
|
||||||
function proppattern(type, value) {
|
|
||||||
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
|
||||||
register(value);
|
|
||||||
return cont(maybeAssign);
|
|
||||||
}
|
|
||||||
if (type == "variable") cx.marked = "property";
|
|
||||||
if (type == "spread") return cont(pattern);
|
|
||||||
if (type == "}") return pass();
|
|
||||||
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
|
|
||||||
return cont(expect(":"), pattern, maybeAssign);
|
|
||||||
}
|
|
||||||
function eltpattern() {
|
|
||||||
return pass(pattern, maybeAssign)
|
|
||||||
}
|
|
||||||
function maybeAssign(_type, value) {
|
|
||||||
if (value == "=") return cont(expressionNoComma);
|
|
||||||
}
|
|
||||||
function vardefCont(type) {
|
|
||||||
if (type == ",") return cont(vardef);
|
|
||||||
}
|
|
||||||
function maybeelse(type, value) {
|
|
||||||
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
|
||||||
}
|
|
||||||
function forspec(type, value) {
|
|
||||||
if (value == "await") return cont(forspec);
|
|
||||||
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
|
||||||
}
|
|
||||||
function forspec1(type) {
|
|
||||||
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
|
||||||
if (type == ";") return cont(forspec2);
|
|
||||||
if (type == "variable") return cont(formaybeinof);
|
|
||||||
return pass(expression, expect(";"), forspec2);
|
|
||||||
}
|
|
||||||
function formaybeinof(_type, value) {
|
|
||||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
|
||||||
return cont(maybeoperatorComma, forspec2);
|
|
||||||
}
|
|
||||||
function forspec2(type, value) {
|
|
||||||
if (type == ";") return cont(forspec3);
|
|
||||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
|
||||||
return pass(expression, expect(";"), forspec3);
|
|
||||||
}
|
|
||||||
function forspec3(type) {
|
|
||||||
if (type != ")") cont(expression);
|
|
||||||
}
|
|
||||||
function functiondef(type, value) {
|
|
||||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
|
||||||
if (type == "variable") {register(value); return cont(functiondef);}
|
|
||||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
|
|
||||||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
|
|
||||||
}
|
|
||||||
function functiondecl(type, value) {
|
|
||||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
|
|
||||||
if (type == "variable") {register(value); return cont(functiondecl);}
|
|
||||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
|
|
||||||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
|
|
||||||
}
|
|
||||||
function funarg(type, value) {
|
|
||||||
if (value == "@") cont(expression, funarg)
|
|
||||||
if (type == "spread") return cont(funarg);
|
|
||||||
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
|
|
||||||
return pass(pattern, maybetype, maybeAssign);
|
|
||||||
}
|
|
||||||
function classExpression(type, value) {
|
|
||||||
// Class expressions may have an optional name.
|
|
||||||
if (type == "variable") return className(type, value);
|
|
||||||
return classNameAfter(type, value);
|
|
||||||
}
|
|
||||||
function className(type, value) {
|
|
||||||
if (type == "variable") {register(value); return cont(classNameAfter);}
|
|
||||||
}
|
|
||||||
function classNameAfter(type, value) {
|
|
||||||
if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
|
|
||||||
if (value == "extends" || value == "implements" || (isTS && type == ",")) {
|
|
||||||
if (value == "implements") cx.marked = "keyword";
|
|
||||||
return cont(isTS ? typeexpr : expression, classNameAfter);
|
|
||||||
}
|
|
||||||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
|
||||||
}
|
|
||||||
function classBody(type, value) {
|
|
||||||
if (type == "async" ||
|
|
||||||
(type == "variable" &&
|
|
||||||
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
|
|
||||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
|
|
||||||
cx.marked = "keyword";
|
|
||||||
return cont(classBody);
|
|
||||||
}
|
|
||||||
if (type == "variable" || cx.style == "keyword") {
|
|
||||||
cx.marked = "property";
|
|
||||||
return cont(isTS ? classfield : functiondef, classBody);
|
|
||||||
}
|
|
||||||
if (type == "[")
|
|
||||||
return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
|
|
||||||
if (value == "*") {
|
|
||||||
cx.marked = "keyword";
|
|
||||||
return cont(classBody);
|
|
||||||
}
|
|
||||||
if (type == ";") return cont(classBody);
|
|
||||||
if (type == "}") return cont();
|
|
||||||
if (value == "@") return cont(expression, classBody)
|
|
||||||
}
|
|
||||||
function classfield(type, value) {
|
|
||||||
if (value == "?") return cont(classfield)
|
|
||||||
if (type == ":") return cont(typeexpr, maybeAssign)
|
|
||||||
if (value == "=") return cont(expressionNoComma)
|
|
||||||
var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
|
|
||||||
return pass(isInterface ? functiondecl : functiondef)
|
|
||||||
}
|
|
||||||
function afterExport(type, value) {
|
|
||||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
|
||||||
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
|
||||||
if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
|
|
||||||
return pass(statement);
|
|
||||||
}
|
|
||||||
function exportField(type, value) {
|
|
||||||
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
|
|
||||||
if (type == "variable") return pass(expressionNoComma, exportField);
|
|
||||||
}
|
|
||||||
function afterImport(type) {
|
|
||||||
if (type == "string") return cont();
|
|
||||||
if (type == "(") return pass(expression);
|
|
||||||
return pass(importSpec, maybeMoreImports, maybeFrom);
|
|
||||||
}
|
|
||||||
function importSpec(type, value) {
|
|
||||||
if (type == "{") return contCommasep(importSpec, "}");
|
|
||||||
if (type == "variable") register(value);
|
|
||||||
if (value == "*") cx.marked = "keyword";
|
|
||||||
return cont(maybeAs);
|
|
||||||
}
|
|
||||||
function maybeMoreImports(type) {
|
|
||||||
if (type == ",") return cont(importSpec, maybeMoreImports)
|
|
||||||
}
|
|
||||||
function maybeAs(_type, value) {
|
|
||||||
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
|
||||||
}
|
|
||||||
function maybeFrom(_type, value) {
|
|
||||||
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
|
||||||
}
|
|
||||||
function arrayLiteral(type) {
|
|
||||||
if (type == "]") return cont();
|
|
||||||
return pass(commasep(expressionNoComma, "]"));
|
|
||||||
}
|
|
||||||
function enumdef() {
|
|
||||||
return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
|
|
||||||
}
|
|
||||||
function enummember() {
|
|
||||||
return pass(pattern, maybeAssign);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isContinuedStatement(state, textAfter) {
|
|
||||||
return state.lastType == "operator" || state.lastType == "," ||
|
|
||||||
isOperatorChar.test(textAfter.charAt(0)) ||
|
|
||||||
/[,.]/.test(textAfter.charAt(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
function expressionAllowed(stream, state, backUp) {
|
|
||||||
return state.tokenize == tokenBase &&
|
|
||||||
/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
|
||||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface
|
|
||||||
|
|
||||||
return {
|
|
||||||
startState: function(basecolumn) {
|
|
||||||
var state = {
|
|
||||||
tokenize: tokenBase,
|
|
||||||
lastType: "sof",
|
|
||||||
cc: [],
|
|
||||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
|
||||||
localVars: parserConfig.localVars,
|
|
||||||
context: parserConfig.localVars && new Context(null, null, false),
|
|
||||||
indented: basecolumn || 0
|
|
||||||
};
|
|
||||||
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
|
||||||
state.globalVars = parserConfig.globalVars;
|
|
||||||
return state;
|
|
||||||
},
|
|
||||||
|
|
||||||
token: function(stream, state) {
|
|
||||||
if (stream.sol()) {
|
|
||||||
if (!state.lexical.hasOwnProperty("align"))
|
|
||||||
state.lexical.align = false;
|
|
||||||
state.indented = stream.indentation();
|
|
||||||
findFatArrow(stream, state);
|
|
||||||
}
|
|
||||||
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
|
||||||
var style = state.tokenize(stream, state);
|
|
||||||
if (type == "comment") return style;
|
|
||||||
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
|
||||||
return parseJS(state, style, type, content, stream);
|
|
||||||
},
|
|
||||||
|
|
||||||
indent: function(state, textAfter) {
|
|
||||||
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
|
||||||
if (state.tokenize != tokenBase) return 0;
|
|
||||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
|
|
||||||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
|
||||||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
|
||||||
var c = state.cc[i];
|
|
||||||
if (c == poplex) lexical = lexical.prev;
|
|
||||||
else if (c != maybeelse) break;
|
|
||||||
}
|
|
||||||
while ((lexical.type == "stat" || lexical.type == "form") &&
|
|
||||||
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
|
|
||||||
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
|
|
||||||
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
|
|
||||||
lexical = lexical.prev;
|
|
||||||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
|
||||||
lexical = lexical.prev;
|
|
||||||
var type = lexical.type, closing = firstChar == type;
|
|
||||||
|
|
||||||
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
|
|
||||||
else if (type == "form" && firstChar == "{") return lexical.indented;
|
|
||||||
else if (type == "form") return lexical.indented + indentUnit;
|
|
||||||
else if (type == "stat")
|
|
||||||
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
|
|
||||||
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
|
||||||
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
|
||||||
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
|
||||||
else return lexical.indented + (closing ? 0 : indentUnit);
|
|
||||||
},
|
|
||||||
|
|
||||||
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
|
||||||
blockCommentStart: jsonMode ? null : "/*",
|
|
||||||
blockCommentEnd: jsonMode ? null : "*/",
|
|
||||||
blockCommentContinue: jsonMode ? null : " * ",
|
|
||||||
lineComment: jsonMode ? null : "//",
|
|
||||||
fold: "brace",
|
|
||||||
closeBrackets: "()[]{}''\"\"``",
|
|
||||||
|
|
||||||
helperType: jsonMode ? "json" : "javascript",
|
|
||||||
jsonldMode: jsonldMode,
|
|
||||||
jsonMode: jsonMode,
|
|
||||||
|
|
||||||
expressionAllowed: expressionAllowed,
|
|
||||||
|
|
||||||
skipExpression: function(state) {
|
|
||||||
var top = state.cc[state.cc.length - 1]
|
|
||||||
if (top == expression || top == expressionNoComma) state.cc.pop()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
|
||||||
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
|
||||||
CodeMirror.defineMIME("application/javascript", "javascript");
|
|
||||||
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
|
||||||
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
|
||||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
|
||||||
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
|
||||||
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
|
||||||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
|
||||||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: JSON-LD mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="../../addon/comment/continuecomment.js"></script>
|
|
||||||
<script src="../../addon/comment/comment.js"></script>
|
|
||||||
<script src="javascript.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id="nav">
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">JSON-LD</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>JSON-LD mode</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<div><textarea id="code" name="code">
|
|
||||||
{
|
|
||||||
"@context": {
|
|
||||||
"name": "http://schema.org/name",
|
|
||||||
"description": "http://schema.org/description",
|
|
||||||
"image": {
|
|
||||||
"@id": "http://schema.org/image",
|
|
||||||
"@type": "@id"
|
|
||||||
},
|
|
||||||
"geo": "http://schema.org/geo",
|
|
||||||
"latitude": {
|
|
||||||
"@id": "http://schema.org/latitude",
|
|
||||||
"@type": "xsd:float"
|
|
||||||
},
|
|
||||||
"longitude": {
|
|
||||||
"@id": "http://schema.org/longitude",
|
|
||||||
"@type": "xsd:float"
|
|
||||||
},
|
|
||||||
"xsd": "http://www.w3.org/2001/XMLSchema#"
|
|
||||||
},
|
|
||||||
"name": "The Empire State Building",
|
|
||||||
"description": "The Empire State Building is a 102-story landmark in New York City.",
|
|
||||||
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
|
|
||||||
"geo": {
|
|
||||||
"latitude": "40.75",
|
|
||||||
"longitude": "73.98"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
matchBrackets: true,
|
|
||||||
autoCloseBrackets: true,
|
|
||||||
mode: "application/ld+json",
|
|
||||||
lineWrapping: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
|
|
||||||
</article>
|
|
||||||
@@ -1,494 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "javascript");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
|
|
||||||
MT("locals",
|
|
||||||
"[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
|
|
||||||
|
|
||||||
MT("comma-and-binop",
|
|
||||||
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
|
|
||||||
|
|
||||||
MT("destructuring",
|
|
||||||
"([keyword function]([def a], [[[def b], [def c] ]]) {",
|
|
||||||
" [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
|
|
||||||
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
|
|
||||||
"})();");
|
|
||||||
|
|
||||||
MT("destructure_trailing_comma",
|
|
||||||
"[keyword let] {[def a], [def b],} [operator =] [variable foo];",
|
|
||||||
"[keyword let] [def c];"); // Parser still in good state?
|
|
||||||
|
|
||||||
MT("class_body",
|
|
||||||
"[keyword class] [def Foo] {",
|
|
||||||
" [property constructor]() {}",
|
|
||||||
" [property sayName]() {",
|
|
||||||
" [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("class",
|
|
||||||
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
|
|
||||||
" [keyword get] [property prop]() { [keyword return] [number 24]; }",
|
|
||||||
" [property constructor]([def x], [def y]) {",
|
|
||||||
" [keyword super]([string 'something']);",
|
|
||||||
" [keyword this].[property x] [operator =] [variable-2 x];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("anonymous_class_expression",
|
|
||||||
"[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {",
|
|
||||||
" [property add]([def a], [def b]) {}",
|
|
||||||
"};");
|
|
||||||
|
|
||||||
MT("named_class_expression",
|
|
||||||
"[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {",
|
|
||||||
" [property sub]([def a], [def b]) {}",
|
|
||||||
"};");
|
|
||||||
|
|
||||||
MT("class_async_method",
|
|
||||||
"[keyword class] [def Foo] {",
|
|
||||||
" [property sayName1]() {}",
|
|
||||||
" [keyword async] [property sayName2]() {}",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("import",
|
|
||||||
"[keyword function] [def foo]() {",
|
|
||||||
" [keyword import] [def $] [keyword from] [string 'jquery'];",
|
|
||||||
" [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("import_trailing_comma",
|
|
||||||
"[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")
|
|
||||||
|
|
||||||
MT("import_dynamic",
|
|
||||||
"[keyword import]([string 'baz']).[property then]")
|
|
||||||
|
|
||||||
MT("import_dynamic",
|
|
||||||
"[keyword const] [def t] [operator =] [keyword import]([string 'baz']).[property then]")
|
|
||||||
|
|
||||||
MT("const",
|
|
||||||
"[keyword function] [def f]() {",
|
|
||||||
" [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("for/of",
|
|
||||||
"[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");
|
|
||||||
|
|
||||||
MT("for await",
|
|
||||||
"[keyword for] [keyword await]([keyword let] [def of] [keyword of] [variable something]) {}");
|
|
||||||
|
|
||||||
MT("generator",
|
|
||||||
"[keyword function*] [def repeat]([def n]) {",
|
|
||||||
" [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
|
|
||||||
" [keyword yield] [variable-2 i];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("let_scoping",
|
|
||||||
"[keyword function] [def scoped]([def n]) {",
|
|
||||||
" { [keyword var] [def i]; } [variable-2 i];",
|
|
||||||
" { [keyword let] [def j]; [variable-2 j]; } [variable j];",
|
|
||||||
" [keyword if] ([atom true]) { [keyword const] [def k]; [variable-2 k]; } [variable k];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("switch_scoping",
|
|
||||||
"[keyword switch] ([variable x]) {",
|
|
||||||
" [keyword default]:",
|
|
||||||
" [keyword let] [def j];",
|
|
||||||
" [keyword return] [variable-2 j]",
|
|
||||||
"}",
|
|
||||||
"[variable j];")
|
|
||||||
|
|
||||||
MT("leaving_scope",
|
|
||||||
"[keyword function] [def a]() {",
|
|
||||||
" {",
|
|
||||||
" [keyword const] [def x] [operator =] [number 1]",
|
|
||||||
" [keyword if] ([atom true]) {",
|
|
||||||
" [keyword let] [def y] [operator =] [number 2]",
|
|
||||||
" [keyword var] [def z] [operator =] [number 3]",
|
|
||||||
" [variable console].[property log]([variable-2 x], [variable-2 y], [variable-2 z])",
|
|
||||||
" }",
|
|
||||||
" [variable console].[property log]([variable-2 x], [variable y], [variable-2 z])",
|
|
||||||
" }",
|
|
||||||
" [variable console].[property log]([variable x], [variable y], [variable-2 z])",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
MT("quotedStringAddition",
|
|
||||||
"[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
|
|
||||||
|
|
||||||
MT("quotedFatArrow",
|
|
||||||
"[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
|
|
||||||
|
|
||||||
MT("fatArrow",
|
|
||||||
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
|
|
||||||
"[variable a];", // No longer in scope
|
|
||||||
"[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
|
|
||||||
"[variable c];");
|
|
||||||
|
|
||||||
MT("spread",
|
|
||||||
"[keyword function] [def f]([def a], [meta ...][def b]) {",
|
|
||||||
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("quasi",
|
|
||||||
"[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
|
|
||||||
|
|
||||||
MT("quasi_no_function",
|
|
||||||
"[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
|
|
||||||
|
|
||||||
MT("indent_statement",
|
|
||||||
"[keyword var] [def x] [operator =] [number 10]",
|
|
||||||
"[variable x] [operator +=] [variable y] [operator +]",
|
|
||||||
" [atom Infinity]",
|
|
||||||
"[keyword debugger];");
|
|
||||||
|
|
||||||
MT("indent_if",
|
|
||||||
"[keyword if] ([number 1])",
|
|
||||||
" [keyword break];",
|
|
||||||
"[keyword else] [keyword if] ([number 2])",
|
|
||||||
" [keyword continue];",
|
|
||||||
"[keyword else]",
|
|
||||||
" [number 10];",
|
|
||||||
"[keyword if] ([number 1]) {",
|
|
||||||
" [keyword break];",
|
|
||||||
"} [keyword else] [keyword if] ([number 2]) {",
|
|
||||||
" [keyword continue];",
|
|
||||||
"} [keyword else] {",
|
|
||||||
" [number 10];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("indent_for",
|
|
||||||
"[keyword for] ([keyword var] [def i] [operator =] [number 0];",
|
|
||||||
" [variable i] [operator <] [number 100];",
|
|
||||||
" [variable i][operator ++])",
|
|
||||||
" [variable doSomething]([variable i]);",
|
|
||||||
"[keyword debugger];");
|
|
||||||
|
|
||||||
MT("indent_c_style",
|
|
||||||
"[keyword function] [def foo]()",
|
|
||||||
"{",
|
|
||||||
" [keyword debugger];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("indent_else",
|
|
||||||
"[keyword for] (;;)",
|
|
||||||
" [keyword if] ([variable foo])",
|
|
||||||
" [keyword if] ([variable bar])",
|
|
||||||
" [number 1];",
|
|
||||||
" [keyword else]",
|
|
||||||
" [number 2];",
|
|
||||||
" [keyword else]",
|
|
||||||
" [number 3];");
|
|
||||||
|
|
||||||
MT("indent_funarg",
|
|
||||||
"[variable foo]([number 10000],",
|
|
||||||
" [keyword function]([def a]) {",
|
|
||||||
" [keyword debugger];",
|
|
||||||
"};");
|
|
||||||
|
|
||||||
MT("indent_below_if",
|
|
||||||
"[keyword for] (;;)",
|
|
||||||
" [keyword if] ([variable foo])",
|
|
||||||
" [number 1];",
|
|
||||||
"[number 2];");
|
|
||||||
|
|
||||||
MT("indent_semicolonless_if",
|
|
||||||
"[keyword function] [def foo]() {",
|
|
||||||
" [keyword if] ([variable x])",
|
|
||||||
" [variable foo]()",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
MT("indent_semicolonless_if_with_statement",
|
|
||||||
"[keyword function] [def foo]() {",
|
|
||||||
" [keyword if] ([variable x])",
|
|
||||||
" [variable foo]()",
|
|
||||||
" [variable bar]()",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
MT("multilinestring",
|
|
||||||
"[keyword var] [def x] [operator =] [string 'foo\\]",
|
|
||||||
"[string bar'];");
|
|
||||||
|
|
||||||
MT("scary_regexp",
|
|
||||||
"[string-2 /foo[[/]]bar/];");
|
|
||||||
|
|
||||||
MT("indent_strange_array",
|
|
||||||
"[keyword var] [def x] [operator =] [[",
|
|
||||||
" [number 1],,",
|
|
||||||
" [number 2],",
|
|
||||||
"]];",
|
|
||||||
"[number 10];");
|
|
||||||
|
|
||||||
MT("param_default",
|
|
||||||
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
|
|
||||||
" [keyword return] [variable-2 x];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT(
|
|
||||||
"param_destructuring",
|
|
||||||
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
|
|
||||||
" [keyword return] [variable-2 x];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("new_target",
|
|
||||||
"[keyword function] [def F]([def target]) {",
|
|
||||||
" [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
|
|
||||||
" [keyword return] [keyword new]",
|
|
||||||
" .[keyword target];",
|
|
||||||
" }",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("async",
|
|
||||||
"[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
|
|
||||||
|
|
||||||
MT("async_assignment",
|
|
||||||
"[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };");
|
|
||||||
|
|
||||||
MT("async_object",
|
|
||||||
"[keyword let] [def obj] [operator =] { [property async]: [atom false] };");
|
|
||||||
|
|
||||||
// async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173
|
|
||||||
MT("async_object_function",
|
|
||||||
"[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };");
|
|
||||||
|
|
||||||
MT("async_object_properties",
|
|
||||||
"[keyword let] [def obj] [operator =] {",
|
|
||||||
" [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
|
|
||||||
" [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
|
|
||||||
" [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },",
|
|
||||||
"};");
|
|
||||||
|
|
||||||
MT("async_arrow",
|
|
||||||
"[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };");
|
|
||||||
|
|
||||||
MT("async_jquery",
|
|
||||||
"[variable $].[property ajax]({",
|
|
||||||
" [property url]: [variable url],",
|
|
||||||
" [property async]: [atom true],",
|
|
||||||
" [property method]: [string 'GET']",
|
|
||||||
"});");
|
|
||||||
|
|
||||||
MT("async_variable",
|
|
||||||
"[keyword const] [def async] [operator =] {[property a]: [number 1]};",
|
|
||||||
"[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];")
|
|
||||||
|
|
||||||
MT("bigint", "[number 1n] [operator +] [number 0x1afn] [operator +] [number 0o064n] [operator +] [number 0b100n];")
|
|
||||||
|
|
||||||
MT("async_comment",
|
|
||||||
"[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
|
|
||||||
|
|
||||||
MT("indent_switch",
|
|
||||||
"[keyword switch] ([variable x]) {",
|
|
||||||
" [keyword default]:",
|
|
||||||
" [keyword return] [number 2]",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
MT("regexp_corner_case",
|
|
||||||
"[operator +]{} [operator /] [atom undefined];",
|
|
||||||
"[[[meta ...][string-2 /\\//] ]];",
|
|
||||||
"[keyword void] [string-2 /\\//];",
|
|
||||||
"[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);",
|
|
||||||
"[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];",
|
|
||||||
"[string-2 `${][variable async][operator ++][string-2 }//`];",
|
|
||||||
"[string-2 `${]{} [operator /] [string-2 /\\//}`];")
|
|
||||||
|
|
||||||
MT("return_eol",
|
|
||||||
"[keyword return]",
|
|
||||||
"{} [string-2 /5/]")
|
|
||||||
|
|
||||||
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
|
||||||
function TS(name) {
|
|
||||||
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
TS("typescript_extend_type",
|
|
||||||
"[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}")
|
|
||||||
|
|
||||||
TS("typescript_arrow_type",
|
|
||||||
"[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]")
|
|
||||||
|
|
||||||
TS("typescript_class",
|
|
||||||
"[keyword class] [def Foo] {",
|
|
||||||
" [keyword public] [keyword static] [property main]() {}",
|
|
||||||
" [keyword private] [property _foo]: [type string];",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("typescript_literal_types",
|
|
||||||
"[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];",
|
|
||||||
"[keyword interface] [def MyAttributes] {",
|
|
||||||
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
|
|
||||||
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
|
|
||||||
"}",
|
|
||||||
"[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {",
|
|
||||||
" [property rawAttributes]: [type MyAttributes];",
|
|
||||||
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
|
|
||||||
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("typescript_extend_operators",
|
|
||||||
"[keyword export] [keyword interface] [def UserModel] [keyword extends]",
|
|
||||||
" [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {",
|
|
||||||
" [property findById]: (",
|
|
||||||
" [variable userId]: [type number]",
|
|
||||||
" ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];",
|
|
||||||
" [property updateById]: (",
|
|
||||||
" [variable userId]: [type number],",
|
|
||||||
" [variable isActive]: [type boolean]",
|
|
||||||
" ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];",
|
|
||||||
" }")
|
|
||||||
|
|
||||||
TS("typescript_interface_with_const",
|
|
||||||
"[keyword const] [def hello]: {",
|
|
||||||
" [property prop1][operator ?]: [type string];",
|
|
||||||
" [property prop2][operator ?]: [type string];",
|
|
||||||
"} [operator =] {};")
|
|
||||||
|
|
||||||
TS("typescript_double_extend",
|
|
||||||
"[keyword export] [keyword interface] [def UserAttributes] {",
|
|
||||||
" [property id][operator ?]: [type number];",
|
|
||||||
" [property createdAt][operator ?]: [type Date];",
|
|
||||||
"}",
|
|
||||||
"[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {",
|
|
||||||
" [property id]: [type number];",
|
|
||||||
" [property createdAt]: [type Date];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
TS("typescript_index_signature",
|
|
||||||
"[keyword interface] [def A] {",
|
|
||||||
" [[ [variable prop]: [type string] ]]: [type any];",
|
|
||||||
" [property prop1]: [type any];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
TS("typescript_generic_class",
|
|
||||||
"[keyword class] [def Foo][operator <][type T][operator >] {",
|
|
||||||
" [property bar]() {}",
|
|
||||||
" [property foo](): [type Foo] {}",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("typescript_type_when_keyword",
|
|
||||||
"[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];",
|
|
||||||
"[keyword type] [type Flags] [operator =] {",
|
|
||||||
" [property p1]: [type string];",
|
|
||||||
" [property p2]: [type boolean];",
|
|
||||||
"};")
|
|
||||||
|
|
||||||
TS("typescript_type_when_not_keyword",
|
|
||||||
"[keyword class] [def HasType] {",
|
|
||||||
" [property type]: [type string];",
|
|
||||||
" [property constructor]([def type]: [type string]) {",
|
|
||||||
" [keyword this].[property type] [operator =] [variable-2 type];",
|
|
||||||
" }",
|
|
||||||
" [property setType]({ [def type] }: { [property type]: [type string]; }) {",
|
|
||||||
" [keyword this].[property type] [operator =] [variable-2 type];",
|
|
||||||
" }",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("typescript_function_generics",
|
|
||||||
"[keyword function] [def a]() {}",
|
|
||||||
"[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}",
|
|
||||||
"[keyword function] [def c]() {}")
|
|
||||||
|
|
||||||
TS("typescript_complex_return_type",
|
|
||||||
"[keyword function] [def A]() {",
|
|
||||||
" [keyword return] [keyword this].[property property];",
|
|
||||||
"}",
|
|
||||||
"[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {",
|
|
||||||
" [keyword return] [keyword this].[property property];",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("typescript_complex_type_casting",
|
|
||||||
"[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };")
|
|
||||||
|
|
||||||
TS("typescript_keyof",
|
|
||||||
"[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {",
|
|
||||||
" [keyword return]")
|
|
||||||
|
|
||||||
TS("typescript_new_typeargs",
|
|
||||||
"[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])")
|
|
||||||
|
|
||||||
TS("modifiers",
|
|
||||||
"[keyword class] [def Foo] {",
|
|
||||||
" [keyword public] [keyword abstract] [property bar]() {}",
|
|
||||||
" [property constructor]([keyword readonly] [keyword private] [def x]) {}",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("arrow prop",
|
|
||||||
"({[property a]: [def p] [operator =>] [variable-2 p]})")
|
|
||||||
|
|
||||||
TS("generic in function call",
|
|
||||||
"[keyword this].[property a][operator <][type Type][operator >]([variable foo]);",
|
|
||||||
"[keyword this].[property a][operator <][variable Type][operator >][variable foo];")
|
|
||||||
|
|
||||||
TS("type guard",
|
|
||||||
"[keyword class] [def Appler] {",
|
|
||||||
" [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {",
|
|
||||||
" [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))",
|
|
||||||
" [keyword throw] [keyword new] [variable Error]();",
|
|
||||||
" }",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("type as variable",
|
|
||||||
"[variable type] [operator =] [variable x] [keyword as] [type Bar];");
|
|
||||||
|
|
||||||
TS("enum body",
|
|
||||||
"[keyword export] [keyword const] [keyword enum] [def CodeInspectionResultType] {",
|
|
||||||
" [def ERROR] [operator =] [string 'problem_type_error'],",
|
|
||||||
" [def WARNING] [operator =] [string 'problem_type_warning'],",
|
|
||||||
" [def META],",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("parenthesized type",
|
|
||||||
"[keyword class] [def Foo] {",
|
|
||||||
" [property x] [operator =] [keyword new] [variable A][operator <][type B], [type string][operator |](() [operator =>] [type void])[operator >]();",
|
|
||||||
" [keyword private] [property bar]();",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
TS("abstract class",
|
|
||||||
"[keyword export] [keyword abstract] [keyword class] [def Foo] {}")
|
|
||||||
|
|
||||||
TS("interface without semicolons",
|
|
||||||
"[keyword interface] [def Foo] {",
|
|
||||||
" [property greet]([def x]: [type int]): [type blah]",
|
|
||||||
" [property bar]: [type void]",
|
|
||||||
"}")
|
|
||||||
|
|
||||||
var jsonld_mode = CodeMirror.getMode(
|
|
||||||
{indentUnit: 2},
|
|
||||||
{name: "javascript", jsonld: true}
|
|
||||||
);
|
|
||||||
function LD(name) {
|
|
||||||
test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
LD("json_ld_keywords",
|
|
||||||
'{',
|
|
||||||
' [meta "@context"]: {',
|
|
||||||
' [meta "@base"]: [string "http://example.com"],',
|
|
||||||
' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],',
|
|
||||||
' [property "likesFlavor"]: {',
|
|
||||||
' [meta "@container"]: [meta "@list"]',
|
|
||||||
' [meta "@reverse"]: [string "@beFavoriteOf"]',
|
|
||||||
' },',
|
|
||||||
' [property "nick"]: { [meta "@container"]: [meta "@set"] },',
|
|
||||||
' [property "nick"]: { [meta "@container"]: [meta "@index"] }',
|
|
||||||
' },',
|
|
||||||
' [meta "@graph"]: [[ {',
|
|
||||||
' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],',
|
|
||||||
' [property "name"]: [string "John Lennon"],',
|
|
||||||
' [property "modified"]: {',
|
|
||||||
' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],',
|
|
||||||
' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]',
|
|
||||||
' }',
|
|
||||||
' } ]]',
|
|
||||||
'}');
|
|
||||||
|
|
||||||
LD("json_ld_fake",
|
|
||||||
'{',
|
|
||||||
' [property "@fake"]: [string "@fake"],',
|
|
||||||
' [property "@contextual"]: [string "@identifier"],',
|
|
||||||
' [property "user@domain.com"]: [string "@graphical"],',
|
|
||||||
' [property "@ID"]: [string "@@ID"]',
|
|
||||||
'}');
|
|
||||||
})();
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: TypeScript mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="javascript.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">TypeScript</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>TypeScript mode</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<div><textarea id="code" name="code">
|
|
||||||
class Greeter {
|
|
||||||
greeting: string;
|
|
||||||
constructor (message: string) {
|
|
||||||
this.greeting = message;
|
|
||||||
}
|
|
||||||
greet() {
|
|
||||||
return "Hello, " + this.greeting;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var greeter = new Greeter("world");
|
|
||||||
|
|
||||||
var button = document.createElement('button')
|
|
||||||
button.innerText = "Say Hello"
|
|
||||||
button.onclick = function() {
|
|
||||||
alert(greeter.greet())
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.appendChild(button)
|
|
||||||
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/typescript"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
|
|
||||||
</article>
|
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://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 htmlConfig = {
|
|
||||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
|
||||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
|
||||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
|
||||||
'track': true, 'wbr': true, 'menuitem': true},
|
|
||||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
|
||||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
|
||||||
'th': true, 'tr': true},
|
|
||||||
contextGrabbers: {
|
|
||||||
'dd': {'dd': true, 'dt': true},
|
|
||||||
'dt': {'dd': true, 'dt': true},
|
|
||||||
'li': {'li': true},
|
|
||||||
'option': {'option': true, 'optgroup': true},
|
|
||||||
'optgroup': {'optgroup': true},
|
|
||||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
|
||||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
|
||||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
|
||||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
|
||||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
|
||||||
'rp': {'rp': true, 'rt': true},
|
|
||||||
'rt': {'rp': true, 'rt': true},
|
|
||||||
'tbody': {'tbody': true, 'tfoot': true},
|
|
||||||
'td': {'td': true, 'th': true},
|
|
||||||
'tfoot': {'tbody': true},
|
|
||||||
'th': {'td': true, 'th': true},
|
|
||||||
'thead': {'tbody': true, 'tfoot': true},
|
|
||||||
'tr': {'tr': true}
|
|
||||||
},
|
|
||||||
doNotIndent: {"pre": true},
|
|
||||||
allowUnquoted: true,
|
|
||||||
allowMissing: true,
|
|
||||||
caseFold: true
|
|
||||||
}
|
|
||||||
|
|
||||||
var xmlConfig = {
|
|
||||||
autoSelfClosers: {},
|
|
||||||
implicitlyClosed: {},
|
|
||||||
contextGrabbers: {},
|
|
||||||
doNotIndent: {},
|
|
||||||
allowUnquoted: false,
|
|
||||||
allowMissing: false,
|
|
||||||
allowMissingTagName: false,
|
|
||||||
caseFold: false
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.defineMode("xml", function(editorConf, config_) {
|
|
||||||
var indentUnit = editorConf.indentUnit
|
|
||||||
var config = {}
|
|
||||||
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
|
|
||||||
for (var prop in defaults) config[prop] = defaults[prop]
|
|
||||||
for (var prop in config_) config[prop] = config_[prop]
|
|
||||||
|
|
||||||
// Return variables for tokenizers
|
|
||||||
var type, setStyle;
|
|
||||||
|
|
||||||
function inText(stream, state) {
|
|
||||||
function chain(parser) {
|
|
||||||
state.tokenize = parser;
|
|
||||||
return parser(stream, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
var ch = stream.next();
|
|
||||||
if (ch == "<") {
|
|
||||||
if (stream.eat("!")) {
|
|
||||||
if (stream.eat("[")) {
|
|
||||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
|
||||||
else return null;
|
|
||||||
} else if (stream.match("--")) {
|
|
||||||
return chain(inBlock("comment", "-->"));
|
|
||||||
} else if (stream.match("DOCTYPE", true, true)) {
|
|
||||||
stream.eatWhile(/[\w\._\-]/);
|
|
||||||
return chain(doctype(1));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else if (stream.eat("?")) {
|
|
||||||
stream.eatWhile(/[\w\._\-]/);
|
|
||||||
state.tokenize = inBlock("meta", "?>");
|
|
||||||
return "meta";
|
|
||||||
} else {
|
|
||||||
type = stream.eat("/") ? "closeTag" : "openTag";
|
|
||||||
state.tokenize = inTag;
|
|
||||||
return "tag bracket";
|
|
||||||
}
|
|
||||||
} else if (ch == "&") {
|
|
||||||
var ok;
|
|
||||||
if (stream.eat("#")) {
|
|
||||||
if (stream.eat("x")) {
|
|
||||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
|
||||||
} else {
|
|
||||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
|
||||||
}
|
|
||||||
return ok ? "atom" : "error";
|
|
||||||
} else {
|
|
||||||
stream.eatWhile(/[^&<]/);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inText.isInText = true;
|
|
||||||
|
|
||||||
function inTag(stream, state) {
|
|
||||||
var ch = stream.next();
|
|
||||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
|
||||||
state.tokenize = inText;
|
|
||||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
|
||||||
return "tag bracket";
|
|
||||||
} else if (ch == "=") {
|
|
||||||
type = "equals";
|
|
||||||
return null;
|
|
||||||
} else if (ch == "<") {
|
|
||||||
state.tokenize = inText;
|
|
||||||
state.state = baseState;
|
|
||||||
state.tagName = state.tagStart = null;
|
|
||||||
var next = state.tokenize(stream, state);
|
|
||||||
return next ? next + " tag error" : "tag error";
|
|
||||||
} else if (/[\'\"]/.test(ch)) {
|
|
||||||
state.tokenize = inAttribute(ch);
|
|
||||||
state.stringStartCol = stream.column();
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
} else {
|
|
||||||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
|
||||||
return "word";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function inAttribute(quote) {
|
|
||||||
var closure = function(stream, state) {
|
|
||||||
while (!stream.eol()) {
|
|
||||||
if (stream.next() == quote) {
|
|
||||||
state.tokenize = inTag;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "string";
|
|
||||||
};
|
|
||||||
closure.isInAttribute = true;
|
|
||||||
return closure;
|
|
||||||
}
|
|
||||||
|
|
||||||
function inBlock(style, terminator) {
|
|
||||||
return function(stream, state) {
|
|
||||||
while (!stream.eol()) {
|
|
||||||
if (stream.match(terminator)) {
|
|
||||||
state.tokenize = inText;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
stream.next();
|
|
||||||
}
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function doctype(depth) {
|
|
||||||
return function(stream, state) {
|
|
||||||
var ch;
|
|
||||||
while ((ch = stream.next()) != null) {
|
|
||||||
if (ch == "<") {
|
|
||||||
state.tokenize = doctype(depth + 1);
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
} else if (ch == ">") {
|
|
||||||
if (depth == 1) {
|
|
||||||
state.tokenize = inText;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
state.tokenize = doctype(depth - 1);
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "meta";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function Context(state, tagName, startOfLine) {
|
|
||||||
this.prev = state.context;
|
|
||||||
this.tagName = tagName;
|
|
||||||
this.indent = state.indented;
|
|
||||||
this.startOfLine = startOfLine;
|
|
||||||
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
|
||||||
this.noIndent = true;
|
|
||||||
}
|
|
||||||
function popContext(state) {
|
|
||||||
if (state.context) state.context = state.context.prev;
|
|
||||||
}
|
|
||||||
function maybePopContext(state, nextTagName) {
|
|
||||||
var parentTagName;
|
|
||||||
while (true) {
|
|
||||||
if (!state.context) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parentTagName = state.context.tagName;
|
|
||||||
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
|
|
||||||
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
popContext(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function baseState(type, stream, state) {
|
|
||||||
if (type == "openTag") {
|
|
||||||
state.tagStart = stream.column();
|
|
||||||
return tagNameState;
|
|
||||||
} else if (type == "closeTag") {
|
|
||||||
return closeTagNameState;
|
|
||||||
} else {
|
|
||||||
return baseState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function tagNameState(type, stream, state) {
|
|
||||||
if (type == "word") {
|
|
||||||
state.tagName = stream.current();
|
|
||||||
setStyle = "tag";
|
|
||||||
return attrState;
|
|
||||||
} else if (config.allowMissingTagName && type == "endTag") {
|
|
||||||
setStyle = "tag bracket";
|
|
||||||
return attrState(type, stream, state);
|
|
||||||
} else {
|
|
||||||
setStyle = "error";
|
|
||||||
return tagNameState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function closeTagNameState(type, stream, state) {
|
|
||||||
if (type == "word") {
|
|
||||||
var tagName = stream.current();
|
|
||||||
if (state.context && state.context.tagName != tagName &&
|
|
||||||
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
|
||||||
popContext(state);
|
|
||||||
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
|
|
||||||
setStyle = "tag";
|
|
||||||
return closeState;
|
|
||||||
} else {
|
|
||||||
setStyle = "tag error";
|
|
||||||
return closeStateErr;
|
|
||||||
}
|
|
||||||
} else if (config.allowMissingTagName && type == "endTag") {
|
|
||||||
setStyle = "tag bracket";
|
|
||||||
return closeState(type, stream, state);
|
|
||||||
} else {
|
|
||||||
setStyle = "error";
|
|
||||||
return closeStateErr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeState(type, _stream, state) {
|
|
||||||
if (type != "endTag") {
|
|
||||||
setStyle = "error";
|
|
||||||
return closeState;
|
|
||||||
}
|
|
||||||
popContext(state);
|
|
||||||
return baseState;
|
|
||||||
}
|
|
||||||
function closeStateErr(type, stream, state) {
|
|
||||||
setStyle = "error";
|
|
||||||
return closeState(type, stream, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
function attrState(type, _stream, state) {
|
|
||||||
if (type == "word") {
|
|
||||||
setStyle = "attribute";
|
|
||||||
return attrEqState;
|
|
||||||
} else if (type == "endTag" || type == "selfcloseTag") {
|
|
||||||
var tagName = state.tagName, tagStart = state.tagStart;
|
|
||||||
state.tagName = state.tagStart = null;
|
|
||||||
if (type == "selfcloseTag" ||
|
|
||||||
config.autoSelfClosers.hasOwnProperty(tagName)) {
|
|
||||||
maybePopContext(state, tagName);
|
|
||||||
} else {
|
|
||||||
maybePopContext(state, tagName);
|
|
||||||
state.context = new Context(state, tagName, tagStart == state.indented);
|
|
||||||
}
|
|
||||||
return baseState;
|
|
||||||
}
|
|
||||||
setStyle = "error";
|
|
||||||
return attrState;
|
|
||||||
}
|
|
||||||
function attrEqState(type, stream, state) {
|
|
||||||
if (type == "equals") return attrValueState;
|
|
||||||
if (!config.allowMissing) setStyle = "error";
|
|
||||||
return attrState(type, stream, state);
|
|
||||||
}
|
|
||||||
function attrValueState(type, stream, state) {
|
|
||||||
if (type == "string") return attrContinuedState;
|
|
||||||
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
|
|
||||||
setStyle = "error";
|
|
||||||
return attrState(type, stream, state);
|
|
||||||
}
|
|
||||||
function attrContinuedState(type, stream, state) {
|
|
||||||
if (type == "string") return attrContinuedState;
|
|
||||||
return attrState(type, stream, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
startState: function(baseIndent) {
|
|
||||||
var state = {tokenize: inText,
|
|
||||||
state: baseState,
|
|
||||||
indented: baseIndent || 0,
|
|
||||||
tagName: null, tagStart: null,
|
|
||||||
context: null}
|
|
||||||
if (baseIndent != null) state.baseIndent = baseIndent
|
|
||||||
return state
|
|
||||||
},
|
|
||||||
|
|
||||||
token: function(stream, state) {
|
|
||||||
if (!state.tagName && stream.sol())
|
|
||||||
state.indented = stream.indentation();
|
|
||||||
|
|
||||||
if (stream.eatSpace()) return null;
|
|
||||||
type = null;
|
|
||||||
var style = state.tokenize(stream, state);
|
|
||||||
if ((style || type) && style != "comment") {
|
|
||||||
setStyle = null;
|
|
||||||
state.state = state.state(type || style, stream, state);
|
|
||||||
if (setStyle)
|
|
||||||
style = setStyle == "error" ? style + " error" : setStyle;
|
|
||||||
}
|
|
||||||
return style;
|
|
||||||
},
|
|
||||||
|
|
||||||
indent: function(state, textAfter, fullLine) {
|
|
||||||
var context = state.context;
|
|
||||||
// Indent multi-line strings (e.g. css).
|
|
||||||
if (state.tokenize.isInAttribute) {
|
|
||||||
if (state.tagStart == state.indented)
|
|
||||||
return state.stringStartCol + 1;
|
|
||||||
else
|
|
||||||
return state.indented + indentUnit;
|
|
||||||
}
|
|
||||||
if (context && context.noIndent) return CodeMirror.Pass;
|
|
||||||
if (state.tokenize != inTag && state.tokenize != inText)
|
|
||||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
|
||||||
// Indent the starts of attribute names.
|
|
||||||
if (state.tagName) {
|
|
||||||
if (config.multilineTagIndentPastTag !== false)
|
|
||||||
return state.tagStart + state.tagName.length + 2;
|
|
||||||
else
|
|
||||||
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
|
|
||||||
}
|
|
||||||
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
|
||||||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
|
||||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
|
||||||
while (context) {
|
|
||||||
if (context.tagName == tagAfter[2]) {
|
|
||||||
context = context.prev;
|
|
||||||
break;
|
|
||||||
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
|
||||||
context = context.prev;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (tagAfter) { // Opening tag spotted
|
|
||||||
while (context) {
|
|
||||||
var grabbers = config.contextGrabbers[context.tagName];
|
|
||||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
|
||||||
context = context.prev;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (context && context.prev && !context.startOfLine)
|
|
||||||
context = context.prev;
|
|
||||||
if (context) return context.indent + indentUnit;
|
|
||||||
else return state.baseIndent || 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
electricInput: /<\/[\s\w:]+>$/,
|
|
||||||
blockCommentStart: "<!--",
|
|
||||||
blockCommentEnd: "-->",
|
|
||||||
|
|
||||||
configuration: config.htmlMode ? "html" : "xml",
|
|
||||||
helperType: config.htmlMode ? "html" : "xml",
|
|
||||||
|
|
||||||
skipAttribute: function(state) {
|
|
||||||
if (state.state == attrValueState)
|
|
||||||
state.state = attrState
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/xml", "xml");
|
|
||||||
CodeMirror.defineMIME("application/xml", "xml");
|
|
||||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
|
||||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
"""
|
|
||||||
Module docstring.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys, os, optparse
|
|
||||||
|
|
||||||
items = (
|
|
||||||
"jquery.js",
|
|
||||||
# "jspolygon.js",
|
|
||||||
"optimal-select.js",
|
|
||||||
"hammer.js",
|
|
||||||
"hammer.propagating.js",
|
|
||||||
"d3/d3.js",
|
|
||||||
"d3/d3-selection-multi.js",
|
|
||||||
"highlight",
|
|
||||||
"pixi/pixi.js",
|
|
||||||
"pixi/lib/crn_decomp.js",
|
|
||||||
"pixi/pixi-compressed-textures.js",
|
|
||||||
"pixi/pixi-filters.js",
|
|
||||||
"pixi/pixi-particles.js",
|
|
||||||
"pixi/pixi-projection.js",
|
|
||||||
"greensock/src/uncompressed",
|
|
||||||
"greensock/src/uncompressed/easing",
|
|
||||||
"greensock/src/uncompressed/plugins",
|
|
||||||
"greensock/src/uncompressed/utils",
|
|
||||||
"convertPointFromPageToNode.js"
|
|
||||||
# "getRelativeURL.js"
|
|
||||||
)
|
|
||||||
|
|
||||||
def process_command_line(argv):
|
|
||||||
"""
|
|
||||||
Return a 2-tuple: (settings object, args list).
|
|
||||||
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
|
|
||||||
"""
|
|
||||||
if argv is None:
|
|
||||||
argv = sys.argv[1:]
|
|
||||||
|
|
||||||
# initialize the parser object:
|
|
||||||
parser = optparse.OptionParser(
|
|
||||||
formatter=optparse.TitledHelpFormatter(width=78),
|
|
||||||
add_help_option=None)
|
|
||||||
|
|
||||||
# define options here:
|
|
||||||
parser.add_option( # customized description; put --help last
|
|
||||||
'-h', '--help', action='help',
|
|
||||||
help='Show this help message and exit.')
|
|
||||||
|
|
||||||
settings, args = parser.parse_args(argv)
|
|
||||||
|
|
||||||
# check number of arguments, verify values, etc.:
|
|
||||||
if args:
|
|
||||||
parser.error('program takes no command-line arguments; '
|
|
||||||
'"%s" ignored.' % (args,))
|
|
||||||
|
|
||||||
# further process settings & args if necessary
|
|
||||||
|
|
||||||
return settings, args
|
|
||||||
|
|
||||||
def main(argv=None):
|
|
||||||
settings, args = process_command_line(argv)
|
|
||||||
run(settings, args)
|
|
||||||
return 0 # success
|
|
||||||
|
|
||||||
def run(settings, args):
|
|
||||||
with open("all.js", 'w') as outfile:
|
|
||||||
for item in items:
|
|
||||||
if item.endswith(".js"):
|
|
||||||
appendFile(outfile, item)
|
|
||||||
else:
|
|
||||||
for filename in os.listdir(item):
|
|
||||||
if filename.endswith(".js"):
|
|
||||||
appendFile(outfile, os.path.join(item, filename))
|
|
||||||
|
|
||||||
def appendFile(outfile, filename):
|
|
||||||
with open(filename) as infile:
|
|
||||||
outfile.write("\n")
|
|
||||||
outfile.write(infile.read())
|
|
||||||
print("File appended: " + infile.name)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
status = main()
|
|
||||||
sys.exit(status)
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
"""
|
|
||||||
Module docstring.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys, os, optparse
|
|
||||||
|
|
||||||
items = (
|
|
||||||
"highlight",
|
|
||||||
"greensock/src/uncompressed/plugins",
|
|
||||||
"greensock/src/uncompressed/TweenLite.js",
|
|
||||||
"convertPointFromPageToNode.js"
|
|
||||||
)
|
|
||||||
|
|
||||||
def process_command_line(argv):
|
|
||||||
"""
|
|
||||||
Return a 2-tuple: (settings object, args list).
|
|
||||||
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
|
|
||||||
"""
|
|
||||||
if argv is None:
|
|
||||||
argv = sys.argv[1:]
|
|
||||||
|
|
||||||
# initialize the parser object:
|
|
||||||
parser = optparse.OptionParser(
|
|
||||||
formatter=optparse.TitledHelpFormatter(width=78),
|
|
||||||
add_help_option=None)
|
|
||||||
|
|
||||||
# define options here:
|
|
||||||
parser.add_option( # customized description; put --help last
|
|
||||||
'-h', '--help', action='help',
|
|
||||||
help='Show this help message and exit.')
|
|
||||||
|
|
||||||
settings, args = parser.parse_args(argv)
|
|
||||||
|
|
||||||
# check number of arguments, verify values, etc.:
|
|
||||||
if args:
|
|
||||||
parser.error('program takes no command-line arguments; '
|
|
||||||
'"%s" ignored.' % (args,))
|
|
||||||
|
|
||||||
# further process settings & args if necessary
|
|
||||||
|
|
||||||
return settings, args
|
|
||||||
|
|
||||||
def main(argv=None):
|
|
||||||
settings, args = process_command_line(argv)
|
|
||||||
run(settings, args)
|
|
||||||
return 0 # success
|
|
||||||
|
|
||||||
def run(settings, args):
|
|
||||||
with open("preload.js", 'w') as outfile:
|
|
||||||
for item in items:
|
|
||||||
if item.endswith(".js"):
|
|
||||||
appendFile(outfile, item)
|
|
||||||
else:
|
|
||||||
for filename in os.listdir(item):
|
|
||||||
if filename.endswith(".js"):
|
|
||||||
appendFile(outfile, os.path.join(item, filename))
|
|
||||||
|
|
||||||
def appendFile(outfile, filename):
|
|
||||||
with open(filename) as infile:
|
|
||||||
outfile.write("\n")
|
|
||||||
outfile.write(infile.read())
|
|
||||||
print("File appended: " + infile.name)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
status = main()
|
|
||||||
sys.exit(status)
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
// https://github.com/d3/d3-selection-multi Version 1.0.1. Copyright 2017 Mike Bostock.
|
|
||||||
(function (global, factory) {
|
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('d3-selection'), require('d3-transition')) :
|
|
||||||
typeof define === 'function' && define.amd ? define(['d3-selection', 'd3-transition'], factory) :
|
|
||||||
(factory(global.d3,global.d3));
|
|
||||||
}(this, (function (d3Selection,d3Transition) { 'use strict';
|
|
||||||
|
|
||||||
function attrsFunction(selection$$1, map) {
|
|
||||||
return selection$$1.each(function() {
|
|
||||||
var x = map.apply(this, arguments), s = d3Selection.select(this);
|
|
||||||
for (var name in x) s.attr(name, x[name]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function attrsObject(selection$$1, map) {
|
|
||||||
for (var name in map) selection$$1.attr(name, map[name]);
|
|
||||||
return selection$$1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var selection_attrs = function(map) {
|
|
||||||
return (typeof map === "function" ? attrsFunction : attrsObject)(this, map);
|
|
||||||
};
|
|
||||||
|
|
||||||
function stylesFunction(selection$$1, map, priority) {
|
|
||||||
return selection$$1.each(function() {
|
|
||||||
var x = map.apply(this, arguments), s = d3Selection.select(this);
|
|
||||||
for (var name in x) s.style(name, x[name], priority);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function stylesObject(selection$$1, map, priority) {
|
|
||||||
for (var name in map) selection$$1.style(name, map[name], priority);
|
|
||||||
return selection$$1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var selection_styles = function(map, priority) {
|
|
||||||
return (typeof map === "function" ? stylesFunction : stylesObject)(this, map, priority == null ? "" : priority);
|
|
||||||
};
|
|
||||||
|
|
||||||
function propertiesFunction(selection$$1, map) {
|
|
||||||
return selection$$1.each(function() {
|
|
||||||
var x = map.apply(this, arguments), s = d3Selection.select(this);
|
|
||||||
for (var name in x) s.property(name, x[name]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function propertiesObject(selection$$1, map) {
|
|
||||||
for (var name in map) selection$$1.property(name, map[name]);
|
|
||||||
return selection$$1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var selection_properties = function(map) {
|
|
||||||
return (typeof map === "function" ? propertiesFunction : propertiesObject)(this, map);
|
|
||||||
};
|
|
||||||
|
|
||||||
function attrsFunction$1(transition$$1, map) {
|
|
||||||
return transition$$1.each(function() {
|
|
||||||
var x = map.apply(this, arguments), t = d3Selection.select(this).transition(transition$$1);
|
|
||||||
for (var name in x) t.attr(name, x[name]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function attrsObject$1(transition$$1, map) {
|
|
||||||
for (var name in map) transition$$1.attr(name, map[name]);
|
|
||||||
return transition$$1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var transition_attrs = function(map) {
|
|
||||||
return (typeof map === "function" ? attrsFunction$1 : attrsObject$1)(this, map);
|
|
||||||
};
|
|
||||||
|
|
||||||
function stylesFunction$1(transition$$1, map, priority) {
|
|
||||||
return transition$$1.each(function() {
|
|
||||||
var x = map.apply(this, arguments), t = d3Selection.select(this).transition(transition$$1);
|
|
||||||
for (var name in x) t.style(name, x[name], priority);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function stylesObject$1(transition$$1, map, priority) {
|
|
||||||
for (var name in map) transition$$1.style(name, map[name], priority);
|
|
||||||
return transition$$1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var transition_styles = function(map, priority) {
|
|
||||||
return (typeof map === "function" ? stylesFunction$1 : stylesObject$1)(this, map, priority == null ? "" : priority);
|
|
||||||
};
|
|
||||||
|
|
||||||
d3Selection.selection.prototype.attrs = selection_attrs;
|
|
||||||
d3Selection.selection.prototype.styles = selection_styles;
|
|
||||||
d3Selection.selection.prototype.properties = selection_properties;
|
|
||||||
d3Transition.transition.prototype.attrs = transition_attrs;
|
|
||||||
d3Transition.transition.prototype.styles = transition_styles;
|
|
||||||
|
|
||||||
})));
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
// https://github.com/d3/d3-selection-multi Version 1.0.1. Copyright 2017 Mike Bostock.
|
|
||||||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(require("d3-selection"),require("d3-transition")):"function"==typeof define&&define.amd?define(["d3-selection","d3-transition"],n):n(t.d3,t.d3)}(this,function(t,n){"use strict";function r(n,r){return n.each(function(){var n=r.apply(this,arguments),e=t.select(this);for(var i in n)e.attr(i,n[i])})}function e(t,n){for(var r in n)t.attr(r,n[r]);return t}function i(n,r,e){return n.each(function(){var n=r.apply(this,arguments),i=t.select(this);for(var o in n)i.style(o,n[o],e)})}function o(t,n,r){for(var e in n)t.style(e,n[e],r);return t}function f(n,r){return n.each(function(){var n=r.apply(this,arguments),e=t.select(this);for(var i in n)e.property(i,n[i])})}function u(t,n){for(var r in n)t.property(r,n[r]);return t}function s(n,r){return n.each(function(){var e=r.apply(this,arguments),i=t.select(this).transition(n);for(var o in e)i.attr(o,e[o])})}function c(t,n){for(var r in n)t.attr(r,n[r]);return t}function a(n,r,e){return n.each(function(){var i=r.apply(this,arguments),o=t.select(this).transition(n);for(var f in i)o.style(f,i[f],e)})}function p(t,n,r){for(var e in n)t.style(e,n[e],r);return t}var l=function(t){return("function"==typeof t?r:e)(this,t)},y=function(t,n){return("function"==typeof t?i:o)(this,t,null==n?"":n)},h=function(t){return("function"==typeof t?f:u)(this,t)},v=function(t){return("function"==typeof t?s:c)(this,t)},d=function(t,n){return("function"==typeof t?a:p)(this,t,null==n?"":n)};t.selection.prototype.attrs=l,t.selection.prototype.styles=y,t.selection.prototype.properties=h,n.transition.prototype.attrs=v,n.transition.prototype.styles=d});
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
(function (factory) {
|
|
||||||
if (typeof define === 'function' && define.amd) {
|
|
||||||
// AMD. Register as an anonymous module.
|
|
||||||
define([], factory);
|
|
||||||
} else if (typeof exports === 'object') {
|
|
||||||
// Node. Does not work with strict CommonJS, but
|
|
||||||
// only CommonJS-like environments that support module.exports,
|
|
||||||
// like Node.
|
|
||||||
module.exports = factory();
|
|
||||||
} else {
|
|
||||||
// Browser globals (root is window)
|
|
||||||
window.propagating = factory();
|
|
||||||
}
|
|
||||||
}(function () {
|
|
||||||
var _firstTarget = null; // singleton, will contain the target element where the touch event started
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extend an Hammer.js instance with event propagation.
|
|
||||||
*
|
|
||||||
* Features:
|
|
||||||
* - Events emitted by hammer will propagate in order from child to parent
|
|
||||||
* elements.
|
|
||||||
* - Events are extended with a function `event.stopPropagation()` to stop
|
|
||||||
* propagation to parent elements.
|
|
||||||
* - An option `preventDefault` to stop all default browser behavior.
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* var hammer = propagatingHammer(new Hammer(element));
|
|
||||||
* var hammer = propagatingHammer(new Hammer(element), {preventDefault: true});
|
|
||||||
*
|
|
||||||
* @param {Hammer.Manager} hammer An hammer instance.
|
|
||||||
* @param {Object} [options] Available options:
|
|
||||||
* - `preventDefault: true | false | 'mouse' | 'touch' | 'pen'`.
|
|
||||||
* Enforce preventing the default browser behavior.
|
|
||||||
* Cannot be set to `false`.
|
|
||||||
* @return {Hammer.Manager} Returns the same hammer instance with extended
|
|
||||||
* functionality
|
|
||||||
*/
|
|
||||||
return function propagating(hammer, options) {
|
|
||||||
var _options = options || {
|
|
||||||
preventDefault: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (hammer.Manager) {
|
|
||||||
// This looks like the Hammer constructor.
|
|
||||||
// Overload the constructors with our own.
|
|
||||||
var Hammer = hammer;
|
|
||||||
|
|
||||||
var PropagatingHammer = function(element, options) {
|
|
||||||
var o = Object.create(_options);
|
|
||||||
if (options) Hammer.assign(o, options);
|
|
||||||
return propagating(new Hammer(element, o), o);
|
|
||||||
};
|
|
||||||
Hammer.assign(PropagatingHammer, Hammer);
|
|
||||||
|
|
||||||
PropagatingHammer.Manager = function (element, options) {
|
|
||||||
var o = Object.create(_options);
|
|
||||||
if (options) Hammer.assign(o, options);
|
|
||||||
return propagating(new Hammer.Manager(element, o), o);
|
|
||||||
};
|
|
||||||
|
|
||||||
return PropagatingHammer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a wrapper object which will override the functions
|
|
||||||
// `on`, `off`, `destroy`, and `emit` of the hammer instance
|
|
||||||
var wrapper = Object.create(hammer);
|
|
||||||
|
|
||||||
// attach to DOM element
|
|
||||||
var element = hammer.element;
|
|
||||||
|
|
||||||
if(!element.hammer) element.hammer = [];
|
|
||||||
element.hammer.push(wrapper);
|
|
||||||
|
|
||||||
// register an event to catch the start of a gesture and store the
|
|
||||||
// target in a singleton
|
|
||||||
hammer.on('hammer.input', function (event) {
|
|
||||||
if (_options.preventDefault === true || (_options.preventDefault === event.pointerType)) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
if (event.isFirst) {
|
|
||||||
_firstTarget = event.target;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** @type {Object.<String, Array.<function>>} */
|
|
||||||
wrapper._handlers = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a handler for one or multiple events
|
|
||||||
* @param {String} events A space separated string with events
|
|
||||||
* @param {function} handler A callback function, called as handler(event)
|
|
||||||
* @returns {Hammer.Manager} Returns the hammer instance
|
|
||||||
*/
|
|
||||||
wrapper.on = function (events, handler) {
|
|
||||||
// register the handler
|
|
||||||
split(events).forEach(function (event) {
|
|
||||||
var _handlers = wrapper._handlers[event];
|
|
||||||
if (!_handlers) {
|
|
||||||
wrapper._handlers[event] = _handlers = [];
|
|
||||||
|
|
||||||
// register the static, propagated handler
|
|
||||||
hammer.on(event, propagatedHandler);
|
|
||||||
}
|
|
||||||
_handlers.push(handler);
|
|
||||||
});
|
|
||||||
|
|
||||||
return wrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a handler for one or multiple events
|
|
||||||
* @param {String} events A space separated string with events
|
|
||||||
* @param {function} [handler] Optional. The registered handler. If not
|
|
||||||
* provided, all handlers for given events
|
|
||||||
* are removed.
|
|
||||||
* @returns {Hammer.Manager} Returns the hammer instance
|
|
||||||
*/
|
|
||||||
wrapper.off = function (events, handler) {
|
|
||||||
// unregister the handler
|
|
||||||
split(events).forEach(function (event) {
|
|
||||||
var _handlers = wrapper._handlers[event];
|
|
||||||
if (_handlers) {
|
|
||||||
_handlers = handler ? _handlers.filter(function (h) {
|
|
||||||
return h !== handler;
|
|
||||||
}) : [];
|
|
||||||
|
|
||||||
if (_handlers.length > 0) {
|
|
||||||
wrapper._handlers[event] = _handlers;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// remove static, propagated handler
|
|
||||||
hammer.off(event, propagatedHandler);
|
|
||||||
delete wrapper._handlers[event];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return wrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emit to the event listeners
|
|
||||||
* @param {string} eventType
|
|
||||||
* @param {Event} event
|
|
||||||
*/
|
|
||||||
wrapper.emit = function(eventType, event) {
|
|
||||||
_firstTarget = event.target;
|
|
||||||
hammer.emit(eventType, event);
|
|
||||||
};
|
|
||||||
|
|
||||||
wrapper.destroy = function () {
|
|
||||||
// Detach from DOM element
|
|
||||||
var hammers = hammer.element.hammer;
|
|
||||||
var idx = hammers.indexOf(wrapper);
|
|
||||||
if(idx !== -1) hammers.splice(idx,1);
|
|
||||||
if(!hammers.length) delete hammer.element.hammer;
|
|
||||||
|
|
||||||
// clear all handlers
|
|
||||||
wrapper._handlers = {};
|
|
||||||
|
|
||||||
// call original hammer destroy
|
|
||||||
hammer.destroy();
|
|
||||||
};
|
|
||||||
|
|
||||||
// split a string with space separated words
|
|
||||||
function split(events) {
|
|
||||||
return events.match(/[^ ]+/g);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A static event handler, applying event propagation.
|
|
||||||
* @param {Object} event
|
|
||||||
*/
|
|
||||||
function propagatedHandler(event) {
|
|
||||||
// let only a single hammer instance handle this event
|
|
||||||
if (event.type !== 'hammer.input') {
|
|
||||||
// it is possible that the same srcEvent is used with multiple hammer events,
|
|
||||||
// we keep track on which events are handled in an object _handled
|
|
||||||
if (!event.srcEvent._handled) {
|
|
||||||
event.srcEvent._handled = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.srcEvent._handled[event.type]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event.srcEvent._handled[event.type] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// attach a stopPropagation function to the event
|
|
||||||
var stopped = false;
|
|
||||||
event.stopPropagation = function () {
|
|
||||||
stopped = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
//wrap the srcEvent's stopPropagation to also stop hammer propagation:
|
|
||||||
var srcStop = event.srcEvent.stopPropagation.bind(event.srcEvent);
|
|
||||||
if(typeof srcStop == "function") {
|
|
||||||
event.srcEvent.stopPropagation = function(){
|
|
||||||
srcStop();
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// attach firstTarget property to the event
|
|
||||||
event.firstTarget = _firstTarget;
|
|
||||||
|
|
||||||
// propagate over all elements (until stopped)
|
|
||||||
var elem = _firstTarget;
|
|
||||||
while (elem && !stopped) {
|
|
||||||
var elemHammer = elem.hammer;
|
|
||||||
if(elemHammer){
|
|
||||||
var _handlers;
|
|
||||||
for(var k = 0; k < elemHammer.length; k++){
|
|
||||||
_handlers = elemHammer[k]._handlers[event.type];
|
|
||||||
if(_handlers) for (var i = 0; i < _handlers.length && !stopped; i++) {
|
|
||||||
_handlers[i](event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elem = elem.parentNode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wrapper;
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
/*! iNoBounce - v0.1.6
|
|
||||||
* https://github.com/lazd/iNoBounce/
|
|
||||||
* Copyright (c) 2013 Larry Davis <lazdnet@gmail.com>; Licensed BSD */
|
|
||||||
(function(global) {
|
|
||||||
// Stores the Y position where the touch started
|
|
||||||
var startY = 0;
|
|
||||||
// Store enabled status
|
|
||||||
var enabled = false;
|
|
||||||
|
|
||||||
var supportsPassiveOption = false;
|
|
||||||
try {
|
|
||||||
var opts = Object.defineProperty({}, 'passive', {
|
|
||||||
get: function() {
|
|
||||||
supportsPassiveOption = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
window.addEventListener('test', null, opts);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
var handleTouchmove = function(evt) {
|
|
||||||
// Get the element that was scrolled upon
|
|
||||||
var el = evt.target;
|
|
||||||
|
|
||||||
// Check all parent elements for scrollability
|
|
||||||
while (el !== document.body && el !== document) {
|
|
||||||
// Get some style properties
|
|
||||||
var style = window.getComputedStyle(el);
|
|
||||||
|
|
||||||
if (!style) {
|
|
||||||
// If we've encountered an element we can't compute the style for, get out
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ignore range input element
|
|
||||||
if (el.nodeName === 'INPUT' && el.getAttribute('type') === 'range') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var scrolling = style.getPropertyValue('-webkit-overflow-scrolling');
|
|
||||||
var overflowY = style.getPropertyValue('overflow-y');
|
|
||||||
var height = parseInt(style.getPropertyValue('height'), 10);
|
|
||||||
|
|
||||||
// Determine if the element should scroll
|
|
||||||
var isScrollable = scrolling === 'touch' && (overflowY === 'auto' || overflowY === 'scroll');
|
|
||||||
var canScroll = el.scrollHeight > el.offsetHeight;
|
|
||||||
|
|
||||||
if (isScrollable && canScroll) {
|
|
||||||
// Get the current Y position of the touch
|
|
||||||
var curY = evt.touches ? evt.touches[0].screenY : evt.screenY;
|
|
||||||
|
|
||||||
// Determine if the user is trying to scroll past the top or bottom
|
|
||||||
// In this case, the window will bounce, so we have to prevent scrolling completely
|
|
||||||
var isAtTop = (startY <= curY && el.scrollTop === 0);
|
|
||||||
var isAtBottom = (startY >= curY && el.scrollHeight - el.scrollTop === height);
|
|
||||||
|
|
||||||
// Stop a bounce bug when at the bottom or top of the scrollable element
|
|
||||||
if (isAtTop || isAtBottom) {
|
|
||||||
evt.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
// No need to continue up the DOM, we've done our job
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test the next parent
|
|
||||||
el = el.parentNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the bouncing -- no parents are scrollable
|
|
||||||
evt.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
var handleTouchstart = function(evt) {
|
|
||||||
// Store the first Y position of the touch
|
|
||||||
startY = evt.touches ? evt.touches[0].screenY : evt.screenY;
|
|
||||||
};
|
|
||||||
|
|
||||||
var enable = function() {
|
|
||||||
// Listen to a couple key touch events
|
|
||||||
window.addEventListener('touchstart', handleTouchstart, supportsPassiveOption ? { passive : false } : false);
|
|
||||||
window.addEventListener('touchmove', handleTouchmove, supportsPassiveOption ? { passive : false } : false);
|
|
||||||
enabled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var disable = function() {
|
|
||||||
// Stop listening
|
|
||||||
window.removeEventListener('touchstart', handleTouchstart, false);
|
|
||||||
window.removeEventListener('touchmove', handleTouchmove, false);
|
|
||||||
enabled = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isEnabled = function() {
|
|
||||||
return enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Enable by default if the browser supports -webkit-overflow-scrolling
|
|
||||||
// Test this by setting the property with JavaScript on an element that exists in the DOM
|
|
||||||
// Then, see if the property is reflected in the computed style
|
|
||||||
var testDiv = document.createElement('div');
|
|
||||||
document.documentElement.appendChild(testDiv);
|
|
||||||
testDiv.style.WebkitOverflowScrolling = 'touch';
|
|
||||||
var scrollSupport = 'getComputedStyle' in window && window.getComputedStyle(testDiv)['-webkit-overflow-scrolling'] === 'touch';
|
|
||||||
document.documentElement.removeChild(testDiv);
|
|
||||||
|
|
||||||
if (scrollSupport) {
|
|
||||||
enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// A module to support enabling/disabling iNoBounce
|
|
||||||
var iNoBounce = {
|
|
||||||
enable: enable,
|
|
||||||
disable: disable,
|
|
||||||
isEnabled: isEnabled
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && module.exports) {
|
|
||||||
// Node.js Support
|
|
||||||
module.exports = iNoBounce;
|
|
||||||
}
|
|
||||||
if (typeof global.define === 'function') {
|
|
||||||
// AMD Support
|
|
||||||
(function(define) {
|
|
||||||
define('iNoBounce', [], function() { return iNoBounce; });
|
|
||||||
}(global.define));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Browser support
|
|
||||||
global.iNoBounce = iNoBounce;
|
|
||||||
}
|
|
||||||
}(this));
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(function(global){var startY=0;var enabled=false;var supportsPassiveOption=false;try{var opts=Object.defineProperty({},"passive",{get:function(){supportsPassiveOption=true}});window.addEventListener("test",null,opts)}catch(e){}var handleTouchmove=function(evt){var el=evt.target;while(el!==document.body&&el!==document){var style=window.getComputedStyle(el);if(!style){break}if(el.nodeName==="INPUT"&&el.getAttribute("type")==="range"){return}var scrolling=style.getPropertyValue("-webkit-overflow-scrolling");var overflowY=style.getPropertyValue("overflow-y");var height=parseInt(style.getPropertyValue("height"),10);var isScrollable=scrolling==="touch"&&(overflowY==="auto"||overflowY==="scroll");var canScroll=el.scrollHeight>el.offsetHeight;if(isScrollable&&canScroll){var curY=evt.touches?evt.touches[0].screenY:evt.screenY;var isAtTop=startY<=curY&&el.scrollTop===0;var isAtBottom=startY>=curY&&el.scrollHeight-el.scrollTop===height;if(isAtTop||isAtBottom){evt.preventDefault()}return}el=el.parentNode}evt.preventDefault()};var handleTouchstart=function(evt){startY=evt.touches?evt.touches[0].screenY:evt.screenY};var enable=function(){window.addEventListener("touchstart",handleTouchstart,supportsPassiveOption?{passive:false}:false);window.addEventListener("touchmove",handleTouchmove,supportsPassiveOption?{passive:false}:false);enabled=true};var disable=function(){window.removeEventListener("touchstart",handleTouchstart,false);window.removeEventListener("touchmove",handleTouchmove,false);enabled=false};var isEnabled=function(){return enabled};var testDiv=document.createElement("div");document.documentElement.appendChild(testDiv);testDiv.style.WebkitOverflowScrolling="touch";var scrollSupport="getComputedStyle"in window&&window.getComputedStyle(testDiv)["-webkit-overflow-scrolling"]==="touch";document.documentElement.removeChild(testDiv);if(scrollSupport){enable()}var iNoBounce={enable:enable,disable:disable,isEnabled:isEnabled};if(typeof module!=="undefined"&&module.exports){module.exports=iNoBounce}if(typeof global.define==="function"){(function(define){define("iNoBounce",[],function(){return iNoBounce})})(global.define)}else{global.iNoBounce=iNoBounce}})(this);
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
/*! iNoBounce - v0.1.6
|
|
||||||
* https://github.com/lazd/iNoBounce/
|
|
||||||
* Copyright (c) 2013 Larry Davis <lazdnet@gmail.com>; Licensed BSD */
|
|
||||||
(function(global) {
|
|
||||||
// Stores the Y position where the touch started
|
|
||||||
var startY = 0;
|
|
||||||
|
|
||||||
// Store enabled status
|
|
||||||
var enabled = false;
|
|
||||||
|
|
||||||
var supportsPassiveOption = false;
|
|
||||||
try {
|
|
||||||
var opts = Object.defineProperty({}, 'passive', {
|
|
||||||
get: function() {
|
|
||||||
supportsPassiveOption = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
window.addEventListener('test', null, opts);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
var handleTouchmove = function(evt) {
|
|
||||||
// Get the element that was scrolled upon
|
|
||||||
var el = evt.target;
|
|
||||||
|
|
||||||
// Check all parent elements for scrollability
|
|
||||||
while (el !== document.body && el !== document) {
|
|
||||||
// Get some style properties
|
|
||||||
var style = window.getComputedStyle(el);
|
|
||||||
|
|
||||||
if (!style) {
|
|
||||||
// If we've encountered an element we can't compute the style for, get out
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ignore range input element
|
|
||||||
if (el.nodeName === 'INPUT' && el.getAttribute('type') === 'range') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var scrolling = style.getPropertyValue('-webkit-overflow-scrolling');
|
|
||||||
var overflowY = style.getPropertyValue('overflow-y');
|
|
||||||
var height = parseInt(style.getPropertyValue('height'), 10);
|
|
||||||
|
|
||||||
// Determine if the element should scroll
|
|
||||||
var isScrollable = scrolling === 'touch' && (overflowY === 'auto' || overflowY === 'scroll');
|
|
||||||
var canScroll = el.scrollHeight > el.offsetHeight;
|
|
||||||
|
|
||||||
if (isScrollable && canScroll) {
|
|
||||||
// Get the current Y position of the touch
|
|
||||||
var curY = evt.touches ? evt.touches[0].screenY : evt.screenY;
|
|
||||||
|
|
||||||
// Determine if the user is trying to scroll past the top or bottom
|
|
||||||
// In this case, the window will bounce, so we have to prevent scrolling completely
|
|
||||||
var isAtTop = (startY <= curY && el.scrollTop === 0);
|
|
||||||
var isAtBottom = (startY >= curY && el.scrollHeight - el.scrollTop === height);
|
|
||||||
|
|
||||||
// Stop a bounce bug when at the bottom or top of the scrollable element
|
|
||||||
if (isAtTop || isAtBottom) {
|
|
||||||
evt.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
// No need to continue up the DOM, we've done our job
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test the next parent
|
|
||||||
el = el.parentNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the bouncing -- no parents are scrollable
|
|
||||||
evt.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
var handleTouchstart = function(evt) {
|
|
||||||
// Store the first Y position of the touch
|
|
||||||
startY = evt.touches ? evt.touches[0].screenY : evt.screenY;
|
|
||||||
};
|
|
||||||
|
|
||||||
var enable = function() {
|
|
||||||
// Listen to a couple key touch events
|
|
||||||
window.addEventListener('touchstart', handleTouchstart, supportsPassiveOption ? { passive : false } : false);
|
|
||||||
window.addEventListener('touchmove', handleTouchmove, supportsPassiveOption ? { passive : false } : false);
|
|
||||||
enabled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var disable = function() {
|
|
||||||
// Stop listening
|
|
||||||
window.removeEventListener('touchstart', handleTouchstart, false);
|
|
||||||
window.removeEventListener('touchmove', handleTouchmove, false);
|
|
||||||
enabled = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isEnabled = function() {
|
|
||||||
return enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Enable by default if the browser supports -webkit-overflow-scrolling
|
|
||||||
// Test this by setting the property with JavaScript on an element that exists in the DOM
|
|
||||||
// Then, see if the property is reflected in the computed style
|
|
||||||
var testDiv = document.createElement('div');
|
|
||||||
document.documentElement.appendChild(testDiv);
|
|
||||||
testDiv.style.WebkitOverflowScrolling = 'touch';
|
|
||||||
var scrollSupport = 'getComputedStyle' in window && window.getComputedStyle(testDiv)['-webkit-overflow-scrolling'] === 'touch';
|
|
||||||
document.documentElement.removeChild(testDiv);
|
|
||||||
|
|
||||||
if (scrollSupport) {
|
|
||||||
enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// A module to support enabling/disabling iNoBounce
|
|
||||||
var iNoBounce = {
|
|
||||||
enable: enable,
|
|
||||||
disable: disable,
|
|
||||||
isEnabled: isEnabled
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && module.exports) {
|
|
||||||
// Node.js Support
|
|
||||||
module.exports = iNoBounce;
|
|
||||||
}
|
|
||||||
if (typeof global.define === 'function') {
|
|
||||||
// AMD Support
|
|
||||||
(function(define) {
|
|
||||||
define('iNoBounce', [], function() { return iNoBounce; });
|
|
||||||
}(global.define));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Browser support
|
|
||||||
global.iNoBounce = iNoBounce;
|
|
||||||
}
|
|
||||||
}(this));
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(function(global){var startY=0;var enabled=false;var supportsPassiveOption=false;try{var opts=Object.defineProperty({},"passive",{get:function(){supportsPassiveOption=true}});window.addEventListener("test",null,opts)}catch(e){}var handleTouchmove=function(evt){var el=evt.target;while(el!==document.body&&el!==document){var style=window.getComputedStyle(el);if(!style){break}if(el.nodeName==="INPUT"&&el.getAttribute("type")==="range"){return}var scrolling=style.getPropertyValue("-webkit-overflow-scrolling");var overflowY=style.getPropertyValue("overflow-y");var height=parseInt(style.getPropertyValue("height"),10);var isScrollable=scrolling==="touch"&&(overflowY==="auto"||overflowY==="scroll");var canScroll=el.scrollHeight>el.offsetHeight;if(isScrollable&&canScroll){var curY=evt.touches?evt.touches[0].screenY:evt.screenY;var isAtTop=startY<=curY&&el.scrollTop===0;var isAtBottom=startY>=curY&&el.scrollHeight-el.scrollTop===height;if(isAtTop||isAtBottom){evt.preventDefault()}return}el=el.parentNode}evt.preventDefault()};var handleTouchstart=function(evt){startY=evt.touches?evt.touches[0].screenY:evt.screenY};var enable=function(){window.addEventListener("touchstart",handleTouchstart,supportsPassiveOption?{passive:false}:false);window.addEventListener("touchmove",handleTouchmove,supportsPassiveOption?{passive:false}:false);enabled=true};var disable=function(){window.removeEventListener("touchstart",handleTouchstart,false);window.removeEventListener("touchmove",handleTouchmove,false);enabled=false};var isEnabled=function(){return enabled};var testDiv=document.createElement("div");document.documentElement.appendChild(testDiv);testDiv.style.WebkitOverflowScrolling="touch";var scrollSupport="getComputedStyle"in window&&window.getComputedStyle(testDiv)["-webkit-overflow-scrolling"]==="touch";document.documentElement.removeChild(testDiv);if(scrollSupport){enable()}var iNoBounce={enable:enable,disable:disable,isEnabled:isEnabled};if(typeof module!=="undefined"&&module.exports){module.exports=iNoBounce}if(typeof global.define==="function"){(function(define){define("iNoBounce",[],function(){return iNoBounce})})(global.define)}else{global.iNoBounce=iNoBounce}})(this);
|
|
||||||
@@ -1,725 +0,0 @@
|
|||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
Object.assign(PIXI.Container.prototype, {
|
|
||||||
renderWebGL: function (renderer) {
|
|
||||||
if (this._activeParentLayer && this._activeParentLayer != renderer._activeLayer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.visible) {
|
|
||||||
this.displayOrder = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.displayOrder = renderer.incDisplayOrder();
|
|
||||||
if (this.worldAlpha <= 0 || !this.renderable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.containerRenderWebGL(renderer);
|
|
||||||
},
|
|
||||||
renderCanvas: function (renderer) {
|
|
||||||
if (this._activeParentLayer && this._activeParentLayer != renderer._activeLayer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.visible) {
|
|
||||||
this.displayOrder = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.displayOrder = renderer.incDisplayOrder();
|
|
||||||
if (this.worldAlpha <= 0 || !this.renderable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.containerRenderCanvas(renderer);
|
|
||||||
},
|
|
||||||
containerRenderWebGL: PIXI.Container.prototype.renderWebGL,
|
|
||||||
containerRenderCanvas: PIXI.Container.prototype.renderCanvas
|
|
||||||
});
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
Object.assign(PIXI.DisplayObject.prototype, {
|
|
||||||
parentLayer: null,
|
|
||||||
_activeParentLayer: null,
|
|
||||||
parentGroup: null,
|
|
||||||
zOrder: 0,
|
|
||||||
zIndex: 0,
|
|
||||||
updateOrder: 0,
|
|
||||||
displayOrder: 0,
|
|
||||||
layerableChildren: true
|
|
||||||
});
|
|
||||||
if (PIXI.particles && PIXI.particles.ParticleContainer) {
|
|
||||||
PIXI.particles.ParticleContainer.prototype.layerableChildren = false;
|
|
||||||
}
|
|
||||||
else if (PIXI.ParticleContainer) {
|
|
||||||
PIXI.ParticleContainer.prototype.layerableChildren = false;
|
|
||||||
}
|
|
||||||
var __extends = (this && this.__extends) || (function () {
|
|
||||||
var extendStatics = Object.setPrototypeOf ||
|
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
||||||
return function (d, b) {
|
|
||||||
extendStatics(d, b);
|
|
||||||
function __() { this.constructor = d; }
|
|
||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
var utils = PIXI.utils;
|
|
||||||
var Group = (function (_super) {
|
|
||||||
__extends(Group, _super);
|
|
||||||
function Group(zIndex, sorting) {
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this._activeLayer = null;
|
|
||||||
_this._activeStage = null;
|
|
||||||
_this._activeChildren = [];
|
|
||||||
_this._lastUpdateId = -1;
|
|
||||||
_this.useRenderTexture = false;
|
|
||||||
_this.useDoubleBuffer = false;
|
|
||||||
_this.sortPriority = 0;
|
|
||||||
_this.clearColor = new Float32Array([0, 0, 0, 0]);
|
|
||||||
_this.canDrawWithoutLayer = false;
|
|
||||||
_this.canDrawInParentStage = true;
|
|
||||||
_this.zIndex = 0;
|
|
||||||
_this.enableSort = false;
|
|
||||||
_this._tempResult = [];
|
|
||||||
_this._tempZero = [];
|
|
||||||
_this.useZeroOptimization = false;
|
|
||||||
_this.zIndex = zIndex;
|
|
||||||
_this.enableSort = !!sorting;
|
|
||||||
if (typeof sorting === 'function') {
|
|
||||||
_this.on('sort', sorting);
|
|
||||||
}
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
Group.prototype.doSort = function (layer, sorted) {
|
|
||||||
if (this.listeners('sort', true)) {
|
|
||||||
for (var i = 0; i < sorted.length; i++) {
|
|
||||||
this.emit('sort', sorted[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.useZeroOptimization) {
|
|
||||||
this.doSortWithZeroOptimization(layer, sorted);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sorted.sort(Group.compareZIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Group.compareZIndex = function (a, b) {
|
|
||||||
if (a.zIndex !== b.zIndex) {
|
|
||||||
return a.zIndex - b.zIndex;
|
|
||||||
}
|
|
||||||
if (a.zOrder > b.zOrder) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.zOrder < b.zOrder) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return a.updateOrder - b.updateOrder;
|
|
||||||
};
|
|
||||||
Group.prototype.doSortWithZeroOptimization = function (layer, sorted) {
|
|
||||||
throw new Error("not implemented yet");
|
|
||||||
};
|
|
||||||
Group.prototype.clear = function () {
|
|
||||||
this._activeLayer = null;
|
|
||||||
this._activeStage = null;
|
|
||||||
this._activeChildren.length = 0;
|
|
||||||
};
|
|
||||||
Group.prototype.addDisplayObject = function (stage, displayObject) {
|
|
||||||
this.check(stage);
|
|
||||||
displayObject._activeParentLayer = this._activeLayer;
|
|
||||||
if (this._activeLayer) {
|
|
||||||
this._activeLayer._activeChildren.push(displayObject);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._activeChildren.push(displayObject);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Group.prototype.foundLayer = function (stage, layer) {
|
|
||||||
this.check(stage);
|
|
||||||
if (this._activeLayer != null) {
|
|
||||||
Group.conflict();
|
|
||||||
}
|
|
||||||
this._activeLayer = layer;
|
|
||||||
this._activeStage = stage;
|
|
||||||
};
|
|
||||||
Group.prototype.foundStage = function (stage) {
|
|
||||||
if (!this._activeLayer && !this.canDrawInParentStage) {
|
|
||||||
this.clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Group.prototype.check = function (stage) {
|
|
||||||
if (this._lastUpdateId < Group._layerUpdateId) {
|
|
||||||
this._lastUpdateId = Group._layerUpdateId;
|
|
||||||
this.clear();
|
|
||||||
this._activeStage = stage;
|
|
||||||
}
|
|
||||||
else if (this.canDrawInParentStage) {
|
|
||||||
var current = this._activeStage;
|
|
||||||
while (current && current != stage) {
|
|
||||||
current = current._activeParentStage;
|
|
||||||
}
|
|
||||||
this._activeStage = current;
|
|
||||||
if (current == null) {
|
|
||||||
this.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Group.conflict = function () {
|
|
||||||
if (Group._lastLayerConflict + 5000 < Date.now()) {
|
|
||||||
Group._lastLayerConflict = Date.now();
|
|
||||||
console.log("PIXI-display plugin found two layers with the same group in one stage - that's not healthy. Please place a breakpoint here and debug it");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Group._layerUpdateId = 0;
|
|
||||||
Group._lastLayerConflict = 0;
|
|
||||||
return Group;
|
|
||||||
}(utils.EventEmitter));
|
|
||||||
pixi_display.Group = Group;
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
var InteractionManager = PIXI.interaction.InteractionManager;
|
|
||||||
Object.assign(InteractionManager.prototype, {
|
|
||||||
_queue: [[], []],
|
|
||||||
_displayProcessInteractive: function (point, displayObject, hitTestOrder, interactive, outOfMask) {
|
|
||||||
if (!displayObject || !displayObject.visible) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
var hit = 0, interactiveParent = interactive = displayObject.interactive || interactive;
|
|
||||||
if (displayObject.hitArea) {
|
|
||||||
interactiveParent = false;
|
|
||||||
}
|
|
||||||
if (displayObject._activeParentLayer) {
|
|
||||||
outOfMask = false;
|
|
||||||
}
|
|
||||||
var mask = displayObject._mask;
|
|
||||||
if (hitTestOrder < Infinity && mask) {
|
|
||||||
if (!mask.containsPoint(point)) {
|
|
||||||
outOfMask = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitTestOrder < Infinity && displayObject.filterArea) {
|
|
||||||
if (!displayObject.filterArea.contains(point.x, point.y)) {
|
|
||||||
outOfMask = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var children = displayObject.children;
|
|
||||||
if (displayObject.interactiveChildren && children) {
|
|
||||||
for (var i = children.length - 1; i >= 0; i--) {
|
|
||||||
var child = children[i];
|
|
||||||
var hitChild = this._displayProcessInteractive(point, child, hitTestOrder, interactiveParent, outOfMask);
|
|
||||||
if (hitChild) {
|
|
||||||
if (!child.parent) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
hit = hitChild;
|
|
||||||
hitTestOrder = hitChild;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (interactive) {
|
|
||||||
if (!outOfMask) {
|
|
||||||
if (hitTestOrder < displayObject.displayOrder) {
|
|
||||||
if (displayObject.hitArea) {
|
|
||||||
displayObject.worldTransform.applyInverse(point, this._tempPoint);
|
|
||||||
if (displayObject.hitArea.contains(this._tempPoint.x, this._tempPoint.y)) {
|
|
||||||
hit = displayObject.displayOrder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (displayObject.containsPoint) {
|
|
||||||
if (displayObject.containsPoint(point)) {
|
|
||||||
hit = displayObject.displayOrder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (displayObject.interactive) {
|
|
||||||
this._queueAdd(displayObject, hit === Infinity ? 0 : hit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (displayObject.interactive) {
|
|
||||||
this._queueAdd(displayObject, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hit;
|
|
||||||
},
|
|
||||||
processInteractive: function (strangeStuff, displayObject, func, hitTest, interactive) {
|
|
||||||
var interactionEvent = null;
|
|
||||||
var point = null;
|
|
||||||
if (strangeStuff.data &&
|
|
||||||
strangeStuff.data.global) {
|
|
||||||
interactionEvent = strangeStuff;
|
|
||||||
point = interactionEvent.data.global;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
point = strangeStuff;
|
|
||||||
}
|
|
||||||
this._startInteractionProcess();
|
|
||||||
this._displayProcessInteractive(point, displayObject, hitTest ? 0 : Infinity, false);
|
|
||||||
this._finishInteractionProcess(interactionEvent, func);
|
|
||||||
},
|
|
||||||
_startInteractionProcess: function () {
|
|
||||||
this._eventDisplayOrder = 1;
|
|
||||||
if (!this._queue) {
|
|
||||||
this._queue = [[], []];
|
|
||||||
}
|
|
||||||
this._queue[0].length = 0;
|
|
||||||
this._queue[1].length = 0;
|
|
||||||
},
|
|
||||||
_queueAdd: function (displayObject, order) {
|
|
||||||
var queue = this._queue;
|
|
||||||
if (order < this._eventDisplayOrder) {
|
|
||||||
queue[0].push(displayObject);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (order > this._eventDisplayOrder) {
|
|
||||||
this._eventDisplayOrder = order;
|
|
||||||
var q = queue[1];
|
|
||||||
for (var i = 0; i < q.length; i++) {
|
|
||||||
queue[0].push(q[i]);
|
|
||||||
}
|
|
||||||
queue[1].length = 0;
|
|
||||||
}
|
|
||||||
queue[1].push(displayObject);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_finishInteractionProcess: function (event, func) {
|
|
||||||
var queue = this._queue;
|
|
||||||
var q = queue[0];
|
|
||||||
var i = 0;
|
|
||||||
for (; i < q.length; i++) {
|
|
||||||
if (event) {
|
|
||||||
if (func) {
|
|
||||||
func(event, q[i], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
func(q[i], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
q = queue[1];
|
|
||||||
for (i = 0; i < q.length; i++) {
|
|
||||||
if (event) {
|
|
||||||
if (!event.target) {
|
|
||||||
event.target = q[i];
|
|
||||||
}
|
|
||||||
if (func) {
|
|
||||||
func(event, q[i], true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
func(q[i], true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
var LayerTextureCache = (function () {
|
|
||||||
function LayerTextureCache(layer) {
|
|
||||||
this.layer = layer;
|
|
||||||
this.renderTexture = null;
|
|
||||||
this.doubleBuffer = null;
|
|
||||||
this.currentBufferIndex = 0;
|
|
||||||
this._tempRenderTarget = null;
|
|
||||||
}
|
|
||||||
LayerTextureCache.prototype.initRenderTexture = function (renderer) {
|
|
||||||
var width = renderer ? renderer.screen.width : 100;
|
|
||||||
var height = renderer ? renderer.screen.height : 100;
|
|
||||||
var resolution = renderer ? renderer.resolution : PIXI.settings.RESOLUTION;
|
|
||||||
this.renderTexture = PIXI.RenderTexture.create(width, height, resolution);
|
|
||||||
if (this.layer.group.useDoubleBuffer) {
|
|
||||||
this.doubleBuffer = [
|
|
||||||
PIXI.RenderTexture.create(width, height, resolution),
|
|
||||||
PIXI.RenderTexture.create(width, height, resolution)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
LayerTextureCache.prototype.getRenderTexture = function () {
|
|
||||||
if (!this.renderTexture) {
|
|
||||||
this.initRenderTexture();
|
|
||||||
}
|
|
||||||
return this.renderTexture;
|
|
||||||
};
|
|
||||||
LayerTextureCache.prototype.pushTexture = function (renderer) {
|
|
||||||
var screen = renderer.screen;
|
|
||||||
if (!this.renderTexture) {
|
|
||||||
this.initRenderTexture(renderer);
|
|
||||||
}
|
|
||||||
var rt = this.renderTexture;
|
|
||||||
var group = this.layer.group;
|
|
||||||
var db = this.doubleBuffer;
|
|
||||||
if (rt.width !== screen.width ||
|
|
||||||
rt.height !== screen.height ||
|
|
||||||
rt.baseTexture.resolution !== renderer.resolution) {
|
|
||||||
rt.baseTexture.resolution = renderer.resolution;
|
|
||||||
rt.resize(screen.width, screen.height);
|
|
||||||
if (db) {
|
|
||||||
db[0].baseTexture.resolution = renderer.resolution;
|
|
||||||
db[0].resize(screen.width, screen.height);
|
|
||||||
db[1].baseTexture.resolution = renderer.resolution;
|
|
||||||
db[1].resize(screen.width, screen.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._tempRenderTarget = renderer._activeRenderTarget;
|
|
||||||
renderer.currentRenderer.flush();
|
|
||||||
if (group.useDoubleBuffer) {
|
|
||||||
var buffer = db[this.currentBufferIndex];
|
|
||||||
if (!buffer.baseTexture._glTextures[renderer.CONTEXT_UID]) {
|
|
||||||
renderer.bindRenderTexture(buffer, null);
|
|
||||||
if (group.clearColor) {
|
|
||||||
renderer.clear(group.clearColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
renderer.unbindTexture(rt);
|
|
||||||
rt.baseTexture._glTextures = buffer.baseTexture._glTextures;
|
|
||||||
rt.baseTexture._glRenderTargets = buffer.baseTexture._glRenderTargets;
|
|
||||||
this.currentBufferIndex = 1 - this.currentBufferIndex;
|
|
||||||
buffer = db[this.currentBufferIndex];
|
|
||||||
renderer.bindRenderTexture(buffer, null);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
renderer.bindRenderTexture(rt, undefined);
|
|
||||||
}
|
|
||||||
if (group.clearColor) {
|
|
||||||
renderer.clear(group.clearColor);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
LayerTextureCache.prototype.popTexture = function (renderer) {
|
|
||||||
renderer.currentRenderer.flush();
|
|
||||||
renderer.bindRenderTarget(this._tempRenderTarget);
|
|
||||||
this._tempRenderTarget = null;
|
|
||||||
};
|
|
||||||
LayerTextureCache.prototype.destroy = function () {
|
|
||||||
if (this.renderTexture) {
|
|
||||||
this.renderTexture.destroy();
|
|
||||||
if (this.doubleBuffer) {
|
|
||||||
this.doubleBuffer[0].destroy(true);
|
|
||||||
this.doubleBuffer[1].destroy(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return LayerTextureCache;
|
|
||||||
}());
|
|
||||||
pixi_display.LayerTextureCache = LayerTextureCache;
|
|
||||||
var Layer = (function (_super) {
|
|
||||||
__extends(Layer, _super);
|
|
||||||
function Layer(group) {
|
|
||||||
if (group === void 0) { group = null; }
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this.isLayer = true;
|
|
||||||
_this.group = null;
|
|
||||||
_this._activeChildren = [];
|
|
||||||
_this._tempChildren = null;
|
|
||||||
_this._activeStageParent = null;
|
|
||||||
_this._sortedChildren = [];
|
|
||||||
_this._tempLayerParent = null;
|
|
||||||
_this.insertChildrenBeforeActive = true;
|
|
||||||
_this.insertChildrenAfterActive = true;
|
|
||||||
if (group != null) {
|
|
||||||
_this.group = group;
|
|
||||||
_this.zIndex = group.zIndex;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_this.group = new pixi_display.Group(0, false);
|
|
||||||
}
|
|
||||||
_this._tempChildren = _this.children;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
Layer.prototype.beginWork = function (stage) {
|
|
||||||
var active = this._activeChildren;
|
|
||||||
this._activeStageParent = stage;
|
|
||||||
this.group.foundLayer(stage, this);
|
|
||||||
var groupChildren = this.group._activeChildren;
|
|
||||||
active.length = 0;
|
|
||||||
for (var i = 0; i < groupChildren.length; i++) {
|
|
||||||
groupChildren[i]._activeParentLayer = this;
|
|
||||||
active.push(groupChildren[i]);
|
|
||||||
}
|
|
||||||
groupChildren.length = 0;
|
|
||||||
};
|
|
||||||
Layer.prototype.endWork = function () {
|
|
||||||
var children = this.children;
|
|
||||||
var active = this._activeChildren;
|
|
||||||
var sorted = this._sortedChildren;
|
|
||||||
for (var i = 0; i < active.length; i++) {
|
|
||||||
this.emit("display", active[i]);
|
|
||||||
}
|
|
||||||
sorted.length = 0;
|
|
||||||
if (this.insertChildrenBeforeActive) {
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
sorted.push(children[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var i = 0; i < active.length; i++) {
|
|
||||||
sorted.push(active[i]);
|
|
||||||
}
|
|
||||||
if (!this.insertChildrenBeforeActive &&
|
|
||||||
this.insertChildrenAfterActive) {
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
sorted.push(children[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.group.enableSort) {
|
|
||||||
this.doSort();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Object.defineProperty(Layer.prototype, "useRenderTexture", {
|
|
||||||
get: function () {
|
|
||||||
return this.group.useRenderTexture;
|
|
||||||
},
|
|
||||||
set: function (value) {
|
|
||||||
this.group.useRenderTexture = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(Layer.prototype, "useDoubleBuffer", {
|
|
||||||
get: function () {
|
|
||||||
return this.group.useDoubleBuffer;
|
|
||||||
},
|
|
||||||
set: function (value) {
|
|
||||||
this.group.useDoubleBuffer = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(Layer.prototype, "clearColor", {
|
|
||||||
get: function () {
|
|
||||||
return this.group.clearColor;
|
|
||||||
},
|
|
||||||
set: function (value) {
|
|
||||||
this.group.clearColor = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(Layer.prototype, "sortPriority", {
|
|
||||||
get: function () {
|
|
||||||
return this.group.sortPriority;
|
|
||||||
},
|
|
||||||
set: function (value) {
|
|
||||||
this.group.sortPriority = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Layer.prototype.getRenderTexture = function () {
|
|
||||||
if (!this.textureCache) {
|
|
||||||
this.textureCache = new LayerTextureCache(this);
|
|
||||||
}
|
|
||||||
return this.textureCache.getRenderTexture();
|
|
||||||
};
|
|
||||||
Layer.prototype.updateDisplayLayers = function () {
|
|
||||||
};
|
|
||||||
Layer.prototype.doSort = function () {
|
|
||||||
this.group.doSort(this, this._sortedChildren);
|
|
||||||
};
|
|
||||||
Layer.prototype._preRender = function (renderer) {
|
|
||||||
if (this._activeParentLayer && this._activeParentLayer != renderer._activeLayer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!this.visible) {
|
|
||||||
this.displayOrder = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.displayOrder = renderer.incDisplayOrder();
|
|
||||||
if (this.worldAlpha <= 0 || !this.renderable) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.children !== this._sortedChildren &&
|
|
||||||
this._tempChildren != this.children) {
|
|
||||||
this._tempChildren = this.children;
|
|
||||||
}
|
|
||||||
this._boundsID++;
|
|
||||||
this.children = this._sortedChildren;
|
|
||||||
this._tempLayerParent = renderer._activeLayer;
|
|
||||||
renderer._activeLayer = this;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
Layer.prototype._postRender = function (renderer) {
|
|
||||||
this.children = this._tempChildren;
|
|
||||||
renderer._activeLayer = this._tempLayerParent;
|
|
||||||
this._tempLayerParent = null;
|
|
||||||
};
|
|
||||||
Layer.prototype.renderWebGL = function (renderer) {
|
|
||||||
if (!this._preRender(renderer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.group.useRenderTexture) {
|
|
||||||
if (!this.textureCache) {
|
|
||||||
this.textureCache = new LayerTextureCache(this);
|
|
||||||
}
|
|
||||||
this.textureCache.pushTexture(renderer);
|
|
||||||
}
|
|
||||||
this.containerRenderWebGL(renderer);
|
|
||||||
this._postRender(renderer);
|
|
||||||
if (this.group.useRenderTexture) {
|
|
||||||
this.textureCache.popTexture(renderer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Layer.prototype.renderCanvas = function (renderer) {
|
|
||||||
if (this._preRender(renderer)) {
|
|
||||||
this.containerRenderCanvas(renderer);
|
|
||||||
this._postRender(renderer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Layer.prototype.destroy = function (options) {
|
|
||||||
if (this.textureCache) {
|
|
||||||
this.textureCache.destroy();
|
|
||||||
this.textureCache = null;
|
|
||||||
}
|
|
||||||
_super.prototype.destroy.call(this, options);
|
|
||||||
};
|
|
||||||
return Layer;
|
|
||||||
}(PIXI.Container));
|
|
||||||
pixi_display.Layer = Layer;
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
var Stage = (function (_super) {
|
|
||||||
__extends(Stage, _super);
|
|
||||||
function Stage() {
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this.isStage = true;
|
|
||||||
_this._tempGroups = [];
|
|
||||||
_this._activeLayers = [];
|
|
||||||
_this._activeParentStage = null;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
Stage.prototype.clear = function () {
|
|
||||||
this._activeLayers.length = 0;
|
|
||||||
this._tempGroups.length = 0;
|
|
||||||
};
|
|
||||||
Stage.prototype.destroy = function (options) {
|
|
||||||
this.clear();
|
|
||||||
_super.prototype.destroy.call(this, options);
|
|
||||||
};
|
|
||||||
Stage.prototype._addRecursive = function (displayObject) {
|
|
||||||
if (!displayObject.visible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (displayObject.isLayer) {
|
|
||||||
var layer_1 = displayObject;
|
|
||||||
this._activeLayers.push(layer_1);
|
|
||||||
layer_1.beginWork(this);
|
|
||||||
}
|
|
||||||
if (displayObject != this && displayObject.isStage) {
|
|
||||||
var stage = displayObject;
|
|
||||||
stage.updateAsChildStage(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var group = displayObject.parentGroup;
|
|
||||||
if (group !== null) {
|
|
||||||
group.addDisplayObject(this, displayObject);
|
|
||||||
}
|
|
||||||
var layer = displayObject.parentLayer;
|
|
||||||
if (layer !== null) {
|
|
||||||
group = layer.group;
|
|
||||||
group.addDisplayObject(this, displayObject);
|
|
||||||
}
|
|
||||||
displayObject.updateOrder = ++Stage._updateOrderCounter;
|
|
||||||
if (displayObject.alpha <= 0 || !displayObject.renderable
|
|
||||||
|| !displayObject.layerableChildren
|
|
||||||
|| group && group.sortPriority) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var children = displayObject.children;
|
|
||||||
if (children && children.length) {
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
this._addRecursive(children[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Stage.prototype._addRecursiveChildren = function (displayObject) {
|
|
||||||
if (displayObject.alpha <= 0 || !displayObject.renderable
|
|
||||||
|| !displayObject.layerableChildren) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var children = displayObject.children;
|
|
||||||
if (children && children.length) {
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
this._addRecursive(children[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Stage.prototype._updateStageInner = function () {
|
|
||||||
this.clear();
|
|
||||||
this._addRecursive(this);
|
|
||||||
var layers = this._activeLayers;
|
|
||||||
for (var i = 0; i < layers.length; i++) {
|
|
||||||
var layer = layers[i];
|
|
||||||
if (layer.group.sortPriority) {
|
|
||||||
layer.endWork();
|
|
||||||
var sorted = layer._sortedChildren;
|
|
||||||
for (var j = 0; j < sorted.length; j++) {
|
|
||||||
this._addRecursiveChildren(sorted[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var i = 0; i < layers.length; i++) {
|
|
||||||
var layer = layers[i];
|
|
||||||
if (!layer.group.sortPriority) {
|
|
||||||
layer.endWork();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Stage.prototype.updateAsChildStage = function (stage) {
|
|
||||||
this._activeParentStage = stage;
|
|
||||||
Stage._updateOrderCounter = 0;
|
|
||||||
this._updateStageInner();
|
|
||||||
};
|
|
||||||
Stage.prototype.updateStage = function () {
|
|
||||||
this._activeParentStage = null;
|
|
||||||
pixi_display.Group._layerUpdateId++;
|
|
||||||
this._updateStageInner();
|
|
||||||
};
|
|
||||||
;
|
|
||||||
Stage._updateOrderCounter = 0;
|
|
||||||
return Stage;
|
|
||||||
}(pixi_display.Layer));
|
|
||||||
pixi_display.Stage = Stage;
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
Object.assign(PIXI.WebGLRenderer.prototype, {
|
|
||||||
_lastDisplayOrder: 0,
|
|
||||||
_activeLayer: null,
|
|
||||||
incDisplayOrder: function () {
|
|
||||||
return ++this._lastDisplayOrder;
|
|
||||||
},
|
|
||||||
_oldRender: PIXI.WebGLRenderer.prototype.render,
|
|
||||||
render: function (displayObject, renderTexture, clear, transform, skipUpdateTransform) {
|
|
||||||
if (!renderTexture) {
|
|
||||||
this._lastDisplayOrder = 0;
|
|
||||||
}
|
|
||||||
this._activeLayer = null;
|
|
||||||
if (displayObject.isStage) {
|
|
||||||
displayObject.updateStage();
|
|
||||||
}
|
|
||||||
this._oldRender(displayObject, renderTexture, clear, transform, skipUpdateTransform);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Object.assign(PIXI.CanvasRenderer.prototype, {
|
|
||||||
_lastDisplayOrder: 0,
|
|
||||||
_activeLayer: null,
|
|
||||||
incDisplayOrder: function () {
|
|
||||||
return ++this._lastDisplayOrder;
|
|
||||||
},
|
|
||||||
_oldRender: PIXI.CanvasRenderer.prototype.render,
|
|
||||||
render: function (displayObject, renderTexture, clear, transform, skipUpdateTransform) {
|
|
||||||
if (!renderTexture) {
|
|
||||||
this._lastDisplayOrder = 0;
|
|
||||||
}
|
|
||||||
this._activeLayer = null;
|
|
||||||
if (displayObject.isStage) {
|
|
||||||
displayObject.updateStage();
|
|
||||||
}
|
|
||||||
this._oldRender(displayObject, renderTexture, clear, transform, skipUpdateTransform);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
var pixi_display;
|
|
||||||
(function (pixi_display) {
|
|
||||||
PIXI.display = pixi_display;
|
|
||||||
})(pixi_display || (pixi_display = {}));
|
|
||||||
@@ -1,2 +1,52 @@
|
|||||||
# iwmlib
|
# iwmlib
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install the following dependencies globally
|
||||||
|
|
||||||
|
`npm i rollup gulp-cli -g`
|
||||||
|
|
||||||
|
and some dependencies locally
|
||||||
|
|
||||||
|
`npm i`
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
To build the iwmlib files type
|
||||||
|
|
||||||
|
`npm run build`
|
||||||
|
|
||||||
|
The files
|
||||||
|
|
||||||
|
- imwlib.js
|
||||||
|
- iwmlib.pixi.js
|
||||||
|
|
||||||
|
will be generated in the dist folder. If you want to build the files continuously type
|
||||||
|
|
||||||
|
`npm run watch`
|
||||||
|
|
||||||
|
To build the 3rd party library type
|
||||||
|
|
||||||
|
`npm run 3rdparty`
|
||||||
|
|
||||||
|
## Docs
|
||||||
|
|
||||||
|
To create the documentation in the folder ./doc/out type `npm run jsdoc`
|
||||||
|
|
||||||
|
Afterwards you can view the documentation here:
|
||||||
|
|
||||||
|
- The iwmlib [DocTests](./lib/index.html)
|
||||||
|
- The iwmlib [PixiJS DocTests](./lib/pixi/index.html)
|
||||||
|
|
||||||
|
## Useful PixiJS Resources
|
||||||
|
|
||||||
|
Currently using PixiJS version 5
|
||||||
|
|
||||||
|
- The PixiJS [JavaScript API Docs](http://pixijs.download/dev/docs/index.html)
|
||||||
|
- The PixiJS [Examples](http://pixijs.github.io/examples/#/basics/basic.js)
|
||||||
|
- The PixiJS [GitHub Repository](https://github.com/pixijs/pixi.js)
|
||||||
|
|
||||||
|
## List of 3<sup>rd</sup> party libraries included
|
||||||
|
|
||||||
|
- [PixiJS](http://www.pixijs.com)
|
||||||
|
- [Greensock](https://greensock.com) with TweenMax and TimelineMax
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<link rel="stylesheet" href="../lib/3rdparty/highlight/styles/default.css">
|
|
||||||
<link rel="stylesheet" href="../css/doctest.css">
|
|
||||||
<script src="../lib/3rdparty/highlight/highlight.pack.js"></script>
|
|
||||||
<script src="all.js"></script>
|
|
||||||
<!-- <script type="text/javascript" src="interface.js"></script> -->
|
|
||||||
</head>
|
|
||||||
<body onload="Doctest.run()" >
|
|
||||||
<h1>
|
|
||||||
Application
|
|
||||||
</h1>
|
|
||||||
<p>
|
|
||||||
IWM Browser Applications follow a common three phase pattern, shared by
|
|
||||||
many programming environments as diverse as Processing, Arduino, Intern, etc.
|
|
||||||
<ul>
|
|
||||||
<li>Instantiate: Initialize the application, in this case a singleton and it's instance variables</li>
|
|
||||||
<li>Setup: Build more complex parts of the application, by loading data, creating the UI...</li>
|
|
||||||
<li>Run: Enter and run the main loop of the application.</li>
|
|
||||||
</ul>
|
|
||||||
This pattern is reflected by the IApp Interface:
|
|
||||||
</p>
|
|
||||||
<pre><code class="js">
|
|
||||||
class IApp extends Interface {
|
|
||||||
setup() { return this }
|
|
||||||
run() { return this }
|
|
||||||
}
|
|
||||||
</code></pre>
|
|
||||||
<p>In practice the pattern may be more complex, because the setup phase can only be entered
|
|
||||||
after loading things, a main loop cannot be entered because requirements are not met, etc.
|
|
||||||
But the basic structure is always the same:
|
|
||||||
</p>
|
|
||||||
<script type="module" class="doctest">
|
|
||||||
console.log("Innerhalb script type=module")
|
|
||||||
import App from "./app.js"
|
|
||||||
const app = new App()
|
|
||||||
app.setup()
|
|
||||||
app.run()
|
|
||||||
window.app = app
|
|
||||||
</script>
|
|
||||||
<p>The setup and run methods can also be chained:
|
|
||||||
</p>
|
|
||||||
<script type="module" class="doctest">
|
|
||||||
app.setup().run()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h2>
|
|
||||||
References
|
|
||||||
</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://theintern.github.io/intern/#common-config">Intern. Software testing for humans</a></li>
|
|
||||||
</ul>
|
|
||||||
</body>
|
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 515 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1007 B |
|
After Width: | Height: | Size: 228 B |
|
After Width: | Height: | Size: 674 B |
|
After Width: | Height: | Size: 289 B |
|
After Width: | Height: | Size: 364 B |
|
After Width: | Height: | Size: 482 B |
|
After Width: | Height: | Size: 909 B |
|
After Width: | Height: | Size: 627 B |
|
After Width: | Height: | Size: 97 B |
|
After Width: | Height: | Size: 633 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 470 B |
|
After Width: | Height: | Size: 234 B |
|
After Width: | Height: | Size: 613 B |
|
After Width: | Height: | Size: 947 B |
|
After Width: | Height: | Size: 564 B |
|
After Width: | Height: | Size: 708 B |
|
After Width: | Height: | Size: 263 B |
|
After Width: | Height: | Size: 270 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 356 B |
|
After Width: | Height: | Size: 803 B |
|
After Width: | Height: | Size: 336 B |
|
After Width: | Height: | Size: 552 B |
|
After Width: | Height: | Size: 368 B |
|
After Width: | Height: | Size: 460 B |
|
After Width: | Height: | Size: 849 B |
|
After Width: | Height: | Size: 616 B |
|
After Width: | Height: | Size: 478 B |
|
After Width: | Height: | Size: 624 B |
|
After Width: | Height: | Size: 306 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 817 B |
|
After Width: | Height: | Size: 917 B |
|
After Width: | Height: | Size: 857 B |
|
After Width: | Height: | Size: 536 B |
|
After Width: | Height: | Size: 263 B |
|
After Width: | Height: | Size: 98 B |
|
After Width: | Height: | Size: 390 B |
|
After Width: | Height: | Size: 188 B |
|
After Width: | Height: | Size: 275 B |
|
After Width: | Height: | Size: 152 B |
|
After Width: | Height: | Size: 624 B |
|
After Width: | Height: | Size: 159 B |
|
After Width: | Height: | Size: 195 B |
|
After Width: | Height: | Size: 319 B |
|
After Width: | Height: | Size: 328 B |
|
After Width: | Height: | Size: 248 B |
|
After Width: | Height: | Size: 232 B |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 578 B |
|
After Width: | Height: | Size: 336 B |
|
After Width: | Height: | Size: 399 B |
|
After Width: | Height: | Size: 402 B |
|
After Width: | Height: | Size: 485 B |
|
After Width: | Height: | Size: 569 B |
|
After Width: | Height: | Size: 168 B |
|
After Width: | Height: | Size: 648 B |
|
After Width: | Height: | Size: 640 B |
|
After Width: | Height: | Size: 560 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 727 B |
|
After Width: | Height: | Size: 955 B |
|
After Width: | Height: | Size: 543 B |
|
After Width: | Height: | Size: 589 B |
|
After Width: | Height: | Size: 206 B |
|
After Width: | Height: | Size: 208 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 208 B |
|
After Width: | Height: | Size: 206 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 198 B |
|
After Width: | Height: | Size: 387 B |
|
After Width: | Height: | Size: 401 B |
|
After Width: | Height: | Size: 405 B |
|
After Width: | Height: | Size: 397 B |
|
After Width: | Height: | Size: 403 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 385 B |
|
After Width: | Height: | Size: 192 B |
|
After Width: | Height: | Size: 192 B |
|
After Width: | Height: | Size: 428 B |
|
After Width: | Height: | Size: 805 B |
|
After Width: | Height: | Size: 552 B |
|
After Width: | Height: | Size: 973 B |
|
After Width: | Height: | Size: 502 B |
|
After Width: | Height: | Size: 778 B |
|
After Width: | Height: | Size: 549 B |
|
After Width: | Height: | Size: 512 B |
|
After Width: | Height: | Size: 778 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 289 B |
|
After Width: | Height: | Size: 591 B |
|
After Width: | Height: | Size: 365 B |
|
After Width: | Height: | Size: 283 B |
|
After Width: | Height: | Size: 273 B |
|
After Width: | Height: | Size: 370 B |
|
After Width: | Height: | Size: 100 B |
|
After Width: | Height: | Size: 108 B |
|
After Width: | Height: | Size: 102 B |
|
After Width: | Height: | Size: 292 B |
|
After Width: | Height: | Size: 111 B |
|
After Width: | Height: | Size: 114 B |
|
After Width: | Height: | Size: 105 B |