mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
Compare commits
169 Commits
v0.44.3-be
...
v0.45.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb3d5f25ac | ||
|
|
9d7d79ef94 | ||
|
|
ba33a0d330 | ||
|
|
aea81c9872 | ||
|
|
806ab22fa8 | ||
|
|
9c2b98915e | ||
|
|
f2ca9276d6 | ||
|
|
48b697f408 | ||
|
|
e1e185e5db | ||
|
|
e06c5703ee | ||
|
|
fe3bb2c5f6 | ||
|
|
6afc299efb | ||
|
|
369274ead7 | ||
|
|
04e6431c09 | ||
|
|
e89057a771 | ||
|
|
4f27254e64 | ||
|
|
577dc95ab8 | ||
|
|
a266d6a3d5 | ||
|
|
749b6cb57e | ||
|
|
b0b2951ff6 | ||
|
|
1f3d73b9fd | ||
|
|
bdfd760b9d | ||
|
|
7133e60267 | ||
|
|
fc4edf4aa7 | ||
|
|
eaf93a70cd | ||
|
|
b093569ec5 | ||
|
|
4633c68a0c | ||
|
|
33571e0ef3 | ||
|
|
31876d2cf9 | ||
|
|
81c6043cb6 | ||
|
|
1982d054ef | ||
|
|
e56979c482 | ||
|
|
58555b3660 | ||
|
|
b7b1324dd0 | ||
|
|
e318acc977 | ||
|
|
8ae82f5b69 | ||
|
|
26442f418a | ||
|
|
23a432e7d8 | ||
|
|
984ecaf99c | ||
|
|
21b73a86b2 | ||
|
|
7d8277699c | ||
|
|
928ed7a034 | ||
|
|
882b6be580 | ||
|
|
e5fa1e0ed5 | ||
|
|
1047aecfbd | ||
|
|
314e0a453f | ||
|
|
8ec476ba96 | ||
|
|
a346ba7038 | ||
|
|
fd6b2f1e7f | ||
|
|
6662b9dbf9 | ||
|
|
c0a29ede05 | ||
|
|
845907b8d2 | ||
|
|
b12008e313 | ||
|
|
a108ef91a0 | ||
|
|
b5480b4137 | ||
|
|
47d61c416d | ||
|
|
6c57b2220f | ||
|
|
99f01b9ccf | ||
|
|
d5a9abd911 | ||
|
|
a3a2bc0a74 | ||
|
|
402e5c4d81 | ||
|
|
5157fc15e9 | ||
|
|
4bd87b1796 | ||
|
|
ce33eb3abd | ||
|
|
f988935a33 | ||
|
|
9b05d30b47 | ||
|
|
9e97fdcc49 | ||
|
|
8e8148ce42 | ||
|
|
af41e5d115 | ||
|
|
4f75b6aaaf | ||
|
|
82f410f695 | ||
|
|
2bc06959c3 | ||
|
|
b898973ee6 | ||
|
|
a2b0d8a379 | ||
|
|
06a4eab7d5 | ||
|
|
25df1a054c | ||
|
|
8c4ff7ed2a | ||
|
|
609829653e | ||
|
|
5f20d033a8 | ||
|
|
93d0324177 | ||
|
|
0afd3c65aa | ||
|
|
8901c3ec91 | ||
|
|
c671b0a345 | ||
|
|
9f424836e2 | ||
|
|
7f5af4b959 | ||
|
|
dc64d333b6 | ||
|
|
283808d691 | ||
|
|
a4bf69fe6a | ||
|
|
6c7853319c | ||
|
|
2b1aa0d386 | ||
|
|
24ae24a1ac | ||
|
|
00d860bfae | ||
|
|
a9f49e7f25 | ||
|
|
fcf80f1e57 | ||
|
|
dc94e1a1bf | ||
|
|
313b9dba61 | ||
|
|
32e3560dce | ||
|
|
7bd7323097 | ||
|
|
0cb46f8f9b | ||
|
|
c2b64bad80 | ||
|
|
991b335c3e | ||
|
|
fd2d49de4f | ||
|
|
b990239219 | ||
|
|
f23454ffa3 | ||
|
|
631a11509a | ||
|
|
bf9bfe920a | ||
|
|
ad878c078e | ||
|
|
8a019d617f | ||
|
|
4a76b7a9a5 | ||
|
|
1ac1bf12a2 | ||
|
|
b50638e85c | ||
|
|
893b6053d2 | ||
|
|
a1ec6fe0aa | ||
|
|
18cc9f2475 | ||
|
|
04ea8dd4b3 | ||
|
|
28cb3976e5 | ||
|
|
a665d193eb | ||
|
|
cabb78b3e4 | ||
|
|
d953d96fa6 | ||
|
|
c71ac0302a | ||
|
|
4eb9ca7b46 | ||
|
|
42daf181d3 | ||
|
|
140f0a5dbd | ||
|
|
10ce26799d | ||
|
|
91a2bb9b26 | ||
|
|
287ef9b522 | ||
|
|
32d609e796 | ||
|
|
8a435a2149 | ||
|
|
8855f29a49 | ||
|
|
384a9474c0 | ||
|
|
a7f510783d | ||
|
|
1a262fe680 | ||
|
|
0c4deda091 | ||
|
|
71894c34aa | ||
|
|
8313116b7f | ||
|
|
90622d71f8 | ||
|
|
620e896a89 | ||
|
|
a9a9edf658 | ||
|
|
5e2077e6ae | ||
|
|
a0e4a416cd | ||
|
|
8f018cc7c6 | ||
|
|
4a470ff9e5 | ||
|
|
03e4c49f89 | ||
|
|
4f92fbf8a5 | ||
|
|
dd020baee5 | ||
|
|
cba9b92202 | ||
|
|
d163289003 | ||
|
|
c45f590e9f | ||
|
|
fbb36d652f | ||
|
|
8f68b4f298 | ||
|
|
9de51c8b9e | ||
|
|
748979eafd | ||
|
|
8ad7318bd8 | ||
|
|
e2fcc6711a | ||
|
|
5f6dd18489 | ||
|
|
a577485e42 | ||
|
|
1fcb99fa60 | ||
|
|
bdebb35f62 | ||
|
|
2b1383205b | ||
|
|
995f4f2582 | ||
|
|
15796b6870 | ||
|
|
12943ca151 | ||
|
|
0e795b2978 | ||
|
|
0eef18a799 | ||
|
|
6518d113c6 | ||
|
|
ea524403f7 | ||
|
|
1d5a53fee6 | ||
|
|
395eb92d93 | ||
|
|
71323500b7 |
@@ -1,4 +1,4 @@
|
||||
FROM node:12.16.3-alpine
|
||||
FROM node:12.19.0-alpine
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
@@ -5,7 +5,7 @@ SERIES=${VERSION:0:4}-latest
|
||||
|
||||
cat package.json | grep -v electron > server-package.json
|
||||
|
||||
sudo docker build -t zadam/trilium:$VERSION -t zadam/trilium:$SERIES .
|
||||
sudo docker build -t zadam/trilium:$VERSION --network host -t zadam/trilium:$SERIES .
|
||||
|
||||
if [[ $VERSION != *"beta"* ]]; then
|
||||
sudo docker tag zadam/trilium:$VERSION zadam/trilium:latest
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PKG_DIR=dist/trilium-linux-x64-server
|
||||
NODE_VERSION=12.18.3
|
||||
NODE_VERSION=12.19.0
|
||||
|
||||
if [ "$1" != "DONTCOPY" ]
|
||||
then
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
[General]
|
||||
# Instance name can be used to distinguish between different instances
|
||||
# Instance name can be used to distinguish between different instances using backend api.getInstanceName()
|
||||
instanceName=
|
||||
|
||||
# set to true to allow using Trilium without authentication (makes sense for server build only, desktop build doesn't need password)
|
||||
noAuthentication=false
|
||||
|
||||
# set to true to disable backups (e.g. because of limited space on server)
|
||||
noBackup=false
|
||||
|
||||
# Disable automatically generating desktop icon
|
||||
# noDesktopIcon=true
|
||||
|
||||
|
||||
BIN
db/demo.zip
BIN
db/demo.zip
Binary file not shown.
@@ -11,7 +11,7 @@ INSERT INTO note_contents_mig (noteId, content, hash, dateModified, utcDateModif
|
||||
SELECT noteId,
|
||||
content,
|
||||
hash,
|
||||
(SELECT dateModified FROM notes WHERE noteId = note_contents.noteId),
|
||||
COALESCE((SELECT dateModified FROM notes WHERE noteId = note_contents.noteId), utcDateModified),
|
||||
utcDateModified
|
||||
FROM note_contents;
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@ const repository = require('../../src/services/repository');
|
||||
module.exports = () => {
|
||||
for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) {
|
||||
try {
|
||||
let content = note.getContent();
|
||||
let origContent = note.getContent();
|
||||
|
||||
content = content
|
||||
const newContent = origContent
|
||||
.replace(/<h1/ig, "<h2")
|
||||
.replace(/<\/h1/ig, "</h2");
|
||||
|
||||
note.setContent(content);
|
||||
if (newContent !== origContent) {
|
||||
note.setContent(newContent);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);
|
||||
|
||||
14
db/migrations/0170__fix_branch_ordering.js
Normal file
14
db/migrations/0170__fix_branch_ordering.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const repository = require('../../src/services/repository');
|
||||
const sql = require('../../src/services/sql');
|
||||
|
||||
module.exports = () => {
|
||||
for (const note of repository.getEntities("SELECT * FROM notes")) {
|
||||
let position = 0;
|
||||
|
||||
for (const branch of note.getChildBranches()) {
|
||||
sql.execute(`UPDATE branches SET notePosition = ? WHERE branchId = ?`, [position, branch.branchId]);
|
||||
|
||||
position += 10;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -293,7 +293,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line30">line 30</a>
|
||||
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line26">line 26</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -445,7 +445,112 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getNote"><span class="type-signature">(async) </span>getNote<span class="signature">()</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">()</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line40">line 40</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getTargetNote"><span class="type-signature"></span>getTargetNote<span class="signature">()</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -529,109 +634,10 @@
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getTargetNote"><span class="type-signature">(async) </span>getTargetNote<span class="signature">()</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line54">line 54</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -697,7 +703,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line69">line 69</a>
|
||||
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line62">line 62</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -767,7 +773,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -471,7 +471,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="createDataNote"><span class="type-signature"></span>createDataNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
|
||||
<h4 class="name" id="createDataNote"><span class="type-signature"></span>createDataNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> → {Object}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -619,7 +619,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line204">line 204</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line205">line 205</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -655,7 +655,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -673,7 +673,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="createNewNote"><span class="type-signature"></span>createNewNote<span class="signature">(params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
|
||||
<h4 class="name" id="createNewNote"><span class="type-signature"></span>createNewNote<span class="signature">(params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -782,7 +782,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line231">line 231</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line232">line 232</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -822,7 +822,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -840,7 +840,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="createNote"><span class="type-signature"></span>createNote<span class="signature">(parentNoteId, title, content<span class="signature-attributes">opt</span>, extraOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
|
||||
<h4 class="name" id="createNote"><span class="type-signature"></span>createNote<span class="signature">(parentNoteId, title, content<span class="signature-attributes">opt</span>, extraOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -1054,7 +1054,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>please use createNote() API method instead</li></ul></dd>
|
||||
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
@@ -1068,7 +1068,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line259">line 259</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line260">line 260</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1108,7 +1108,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -1126,7 +1126,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="createTextNote"><span class="type-signature"></span>createTextNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
|
||||
<h4 class="name" id="createTextNote"><span class="type-signature"></span>createTextNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> → {Object}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -1273,7 +1273,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line188">line 188</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line189">line 189</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1309,7 +1309,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -1327,7 +1327,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="ensureNoteIsAbsentFromParent"><span class="type-signature"></span>ensureNoteIsAbsentFromParent<span class="signature">(noteId, parentNoteId)</span><span class="type-signature"> → {Promise.<void>}</span></h4>
|
||||
<h4 class="name" id="ensureNoteIsAbsentFromParent"><span class="type-signature"></span>ensureNoteIsAbsentFromParent<span class="signature">(noteId, parentNoteId)</span><span class="type-signature"> → {void}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -1451,7 +1451,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line159">line 159</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line160">line 160</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1487,7 +1487,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<void></span>
|
||||
<span class="param-type">void</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -1505,7 +1505,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="ensureNoteIsPresentInParent"><span class="type-signature"></span>ensureNoteIsPresentInParent<span class="signature">(noteId, parentNoteId, prefix)</span><span class="type-signature"> → {Promise.<void>}</span></h4>
|
||||
<h4 class="name" id="ensureNoteIsPresentInParent"><span class="type-signature"></span>ensureNoteIsPresentInParent<span class="signature">(noteId, parentNoteId, prefix)</span><span class="type-signature"> → {void}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -1652,7 +1652,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line149">line 149</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line150">line 150</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1688,7 +1688,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<void></span>
|
||||
<span class="param-type">void</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -1754,7 +1754,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line398">line 398</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line397">line 397</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1815,7 +1815,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> → {Promise.<(<a href="Attribute.html">Attribute</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> → {<a href="Attribute.html">Attribute</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -1948,7 +1948,10 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Attribute.html">Attribute</a>|null)></span>
|
||||
<span class="param-type"><a href="Attribute.html">Attribute</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -1966,7 +1969,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getBranch"><span class="type-signature"></span>getBranch<span class="signature">(branchId)</span><span class="type-signature"> → {Promise.<(<a href="Branch.html">Branch</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getBranch"><span class="type-signature"></span>getBranch<span class="signature">(branchId)</span><span class="type-signature"> → {<a href="Branch.html">Branch</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -2099,7 +2102,10 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Branch.html">Branch</a>|null)></span>
|
||||
<span class="param-type"><a href="Branch.html">Branch</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -2117,7 +2123,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getDateNote"><span class="type-signature"></span>getDateNote<span class="signature">(date)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getDateNote"><span class="type-signature"></span>getDateNote<span class="signature">(date)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -2218,7 +2224,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line315">line 315</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line318">line 318</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2254,7 +2260,10 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -2272,7 +2281,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getEntities"><span class="type-signature"></span>getEntities<span class="signature">(SQL, array)</span><span class="type-signature"> → {Promise.<Array.<<a href="Entity.html">Entity</a>>>}</span></h4>
|
||||
<h4 class="name" id="getEntities"><span class="type-signature"></span>getEntities<span class="signature">(SQL, array)</span><span class="type-signature"> → {Array.<<a href="Entity.html">Entity</a>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -2392,7 +2401,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line94">line 94</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line87">line 87</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2428,7 +2437,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<Array.<<a href="Entity.html">Entity</a>>></span>
|
||||
<span class="param-type">Array.<<a href="Entity.html">Entity</a>></span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -2446,7 +2455,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getEntity"><span class="type-signature"></span>getEntity<span class="signature">(SQL, array)</span><span class="type-signature"> → {Promise.<(<a href="Entity.html">Entity</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getEntity"><span class="type-signature"></span>getEntity<span class="signature">(SQL, array)</span><span class="type-signature"> → {<a href="Entity.html">Entity</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -2570,7 +2579,7 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line86">line 86</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line79">line 79</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2606,158 +2615,10 @@ JSON MIME type. See also createNewNote() for more options.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Entity.html">Entity</a>|null)></span>
|
||||
<span class="param-type"><a href="Entity.html">Entity</a></span>
|
||||
|
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getImage"><span class="type-signature"></span>getImage<span class="signature">(imageId)</span><span class="type-signature"> → {Promise.<(Image|null)>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>imageId</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line76">line 76</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(Image|null)></span>
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -2885,7 +2746,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(date)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(date)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -2986,7 +2847,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line342">line 342</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line345">line 345</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3022,7 +2883,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3040,7 +2904,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -3173,7 +3037,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3191,7 +3058,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getNotesWithLabel"><span class="type-signature"></span>getNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
<h4 class="name" id="getNotesWithLabel"><span class="type-signature"></span>getNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<<a href="Note.html">Note</a>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -3335,7 +3202,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line128">line 128</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line129">line 129</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3371,7 +3238,7 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<Array.<<a href="Note.html">Note</a>>></span>
|
||||
<span class="param-type">Array.<<a href="Note.html">Note</a>></span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3389,7 +3256,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getNoteWithLabel"><span class="type-signature"></span>getNoteWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getNoteWithLabel"><span class="type-signature"></span>getNoteWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -3533,7 +3400,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line138">line 138</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line139">line 139</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3569,7 +3436,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3587,7 +3457,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getRootCalendarNote"><span class="type-signature"></span>getRootCalendarNote<span class="signature">()</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getRootCalendarNote"><span class="type-signature"></span>getRootCalendarNote<span class="signature">()</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -3639,7 +3509,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line306">line 306</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line309">line 309</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3675,7 +3545,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3693,7 +3566,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getTodayNote"><span class="type-signature"></span>getTodayNote<span class="signature">()</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getTodayNote"><span class="type-signature"></span>getTodayNote<span class="signature">()</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -3745,7 +3618,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line323">line 323</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line326">line 326</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3781,7 +3654,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3799,7 +3675,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getWeekNote"><span class="type-signature"></span>getWeekNote<span class="signature">(date, options)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getWeekNote"><span class="type-signature"></span>getWeekNote<span class="signature">(date, options)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -3923,7 +3799,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line333">line 333</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line336">line 336</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3959,7 +3835,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -3977,7 +3856,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getYearNote"><span class="type-signature"></span>getYearNote<span class="signature">(year)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getYearNote"><span class="type-signature"></span>getYearNote<span class="signature">(year)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -4078,7 +3957,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line351">line 351</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line354">line 354</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4114,7 +3993,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -4228,7 +4110,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line298">line 298</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line301">line 301</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4314,7 +4196,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line393">line 393</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line392">line 392</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4350,7 +4232,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="searchForNote"><span class="type-signature"></span>searchForNote<span class="signature">(searchString)</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="searchForNote"><span class="type-signature"></span>searchForNote<span class="signature">(searchString)</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -4359,7 +4241,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<div class="description">
|
||||
This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4452,7 +4334,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line114">line 114</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line115">line 115</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4488,7 +4370,10 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -4506,7 +4391,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="searchForNotes"><span class="type-signature"></span>searchForNotes<span class="signature">(searchString)</span><span class="type-signature"> → {Promise.<Array.<<a href="Note.html">Note</a>>>}</span></h4>
|
||||
<h4 class="name" id="searchForNotes"><span class="type-signature"></span>searchForNotes<span class="signature">(query, searchContext<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<<a href="Note.html">Note</a>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -4515,7 +4400,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<div class="description">
|
||||
This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4539,6 +4424,8 @@ if some action needs to happen on only one specific instance.
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
<th>Attributes</th>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4551,7 +4438,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>searchString</code></td>
|
||||
<td class="name"><code>query</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
@@ -4564,6 +4451,47 @@ if some action needs to happen on only one specific instance.
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>searchContext</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">SearchContext</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
<optional><br>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4608,7 +4536,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line104">line 104</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line98">line 98</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4644,7 +4572,7 @@ if some action needs to happen on only one specific instance.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<Array.<<a href="Note.html">Note</a>>></span>
|
||||
<span class="param-type">Array.<<a href="Note.html">Note</a>></span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -4817,7 +4745,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line372">line 372</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line374">line 374</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4950,7 +4878,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line358">line 358</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line360">line 360</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4975,16 +4903,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
Promise<void>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4996,7 +4914,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="toggleNoteInParent"><span class="type-signature"></span>toggleNoteInParent<span class="signature">(present, noteId, parentNoteId, prefix)</span><span class="type-signature"> → {Promise.<void>}</span></h4>
|
||||
<h4 class="name" id="toggleNoteInParent"><span class="type-signature"></span>toggleNoteInParent<span class="signature">(present, noteId, parentNoteId, prefix)</span><span class="type-signature"> → {void}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -5166,7 +5084,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line171">line 171</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line172">line 172</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5202,7 +5120,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<void></span>
|
||||
<span class="param-type">void</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -5220,7 +5138,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="transactional"><span class="type-signature"></span>transactional<span class="signature">(func)</span><span class="type-signature"> → {Promise.<?>}</span></h4>
|
||||
<h4 class="name" id="transactional"><span class="type-signature"></span>transactional<span class="signature">(func)</span><span class="type-signature"> → {?}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -5230,9 +5148,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
|
||||
<div class="description">
|
||||
This functions wraps code which is supposed to be running in transaction. If transaction already
|
||||
exists, then we'll use that transaction.
|
||||
|
||||
This method is required only when script has label manualTransactionHandling, all other scripts are
|
||||
transactional by default.
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5325,7 +5240,7 @@ transactional by default.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line385">line 385</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line384">line 384</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5365,7 +5280,7 @@ transactional by default.
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<?></span>
|
||||
<span class="param-type">?</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -5399,7 +5314,7 @@ transactional by default.
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -107,7 +107,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
|
||||
|
||||
<td class="description last">primary key</td>
|
||||
<td class="description last">primary key, immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
<td class="description last">immutable</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line25">line 25</a>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line24">line 24</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getNote"><span class="type-signature">(async) </span>getNote<span class="signature">()</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">()</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line32">line 32</a>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line31">line 31</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -507,7 +507,10 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -525,7 +528,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getParentNote"><span class="type-signature">(async) </span>getParentNote<span class="signature">()</span><span class="type-signature"> → {Promise.<(<a href="Note.html">Note</a>|null)>}</span></h4>
|
||||
<h4 class="name" id="getParentNote"><span class="type-signature"></span>getParentNote<span class="signature">()</span><span class="type-signature"> → {<a href="Note.html">Note</a>|null}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -573,7 +576,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line37">line 37</a>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line36">line 36</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -609,7 +612,10 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<(<a href="Note.html">Note</a>|null)></span>
|
||||
<span class="param-type"><a href="Note.html">Note</a></span>
|
||||
|
|
||||
|
||||
<span class="param-type">null</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -643,7 +649,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_entity.js.html">entities/entity.js</a>, <a href="entities_entity.js.html#line9">line 9</a>
|
||||
<a href="entities_entity.js.html">entities/entity.js</a>, <a href="entities_entity.js.html#line10">line 10</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -198,29 +198,6 @@
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>contentLength</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">int</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
@@ -421,7 +398,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line35">line 35</a>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line28">line 28</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -488,7 +465,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getContent"><span class="type-signature">(async) </span>getContent<span class="signature">()</span><span class="type-signature"> → {Promise.<*>}</span></h4>
|
||||
<h4 class="name" id="getContent"><span class="type-signature"></span>getContent<span class="signature">()</span><span class="type-signature"> → {*}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -536,7 +513,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line69">line 69</a>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line68">line 68</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -572,7 +549,7 @@
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise.<*></span>
|
||||
<span class="param-type">*</span>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -638,7 +615,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line55">line 55</a>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line54">line 54</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -691,108 +668,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="setContent"><span class="type-signature">(async) </span>setContent<span class="signature">()</span><span class="type-signature"> → {Promise}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line105">line 105</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Promise</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -814,7 +689,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_option.js.html">entities/option.js</a>, <a href="entities_option.js.html#line22">line 22</a>
|
||||
<a href="entities_option.js.html">entities/option.js</a>, <a href="entities_option.js.html#line17">line 17</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -293,7 +293,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -75,7 +75,7 @@ module.exports = ApiToken;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -28,21 +28,22 @@
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>"use strict";
|
||||
|
||||
|
||||
const Entity = require('./entity');
|
||||
const repository = require('../services/repository');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const sql = require('../services/sql');
|
||||
const promotedAttributeDefinitionParser = require("../services/promoted_attribute_definition_parser");
|
||||
|
||||
/**
|
||||
* Attribute is key value pair owned by a note.
|
||||
*
|
||||
* @property {string} attributeId
|
||||
* @property {string} noteId
|
||||
* @property {string} type
|
||||
* @property {string} name
|
||||
* @property {string} attributeId - immutable
|
||||
* @property {string} noteId - immutable
|
||||
* @property {string} type - immutable
|
||||
* @property {string} name - immutable
|
||||
* @property {string} value
|
||||
* @property {int} position
|
||||
* @property {boolean} isInheritable
|
||||
* @property {boolean} isInheritable - immutable
|
||||
* @property {boolean} isDeleted
|
||||
* @property {string|null} deleteId - ID identifying delete transaction
|
||||
* @property {string} utcDateCreated
|
||||
@@ -59,27 +60,19 @@ class Attribute extends Entity {
|
||||
super(row);
|
||||
|
||||
this.isInheritable = !!this.isInheritable;
|
||||
|
||||
if (this.isDefinition()) {
|
||||
try {
|
||||
this.value = JSON.parse(this.value);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
async getNote() {
|
||||
return await repository.getNote(this.noteId);
|
||||
getNote() {
|
||||
return this.repository.getNote(this.noteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
async getTargetNote() {
|
||||
getTargetNote() {
|
||||
if (this.type !== 'relation') {
|
||||
throw new Error(`Attribute ${this.attributeId} is not relation`);
|
||||
}
|
||||
@@ -88,17 +81,31 @@ class Attribute extends Entity {
|
||||
return null;
|
||||
}
|
||||
|
||||
return await repository.getNote(this.value);
|
||||
return this.repository.getNote(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
isDefinition() {
|
||||
return this.type === 'label-definition' || this.type === 'relation-definition';
|
||||
return this.type === 'label' && (this.name.startsWith('label:') || this.name.startsWith('relation:'));
|
||||
}
|
||||
|
||||
async beforeSaving() {
|
||||
getDefinition() {
|
||||
return promotedAttributeDefinitionParser.parse(this.value);
|
||||
}
|
||||
|
||||
getDefinedName() {
|
||||
if (this.type === 'label' && this.name.startsWith('label:')) {
|
||||
return this.name.substr(6);
|
||||
} else if (this.type === 'label' && this.name.startsWith('relation:')) {
|
||||
return this.name.substr(9);
|
||||
} else {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
beforeSaving() {
|
||||
if (!this.value) {
|
||||
if (this.type === 'relation') {
|
||||
throw new Error(`Cannot save relation ${this.name} since it does not target any note.`);
|
||||
@@ -109,7 +116,7 @@ class Attribute extends Entity {
|
||||
}
|
||||
|
||||
if (this.position === undefined) {
|
||||
this.position = 1 + await sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM attributes WHERE noteId = ?`, [this.noteId]);
|
||||
this.position = 1 + sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM attributes WHERE noteId = ?`, [this.noteId]);
|
||||
}
|
||||
|
||||
if (!this.isInheritable) {
|
||||
@@ -131,20 +138,14 @@ class Attribute extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
// cannot be static!
|
||||
updatePojo(pojo) {
|
||||
delete pojo.isOwned;
|
||||
delete pojo.__note;
|
||||
}
|
||||
|
||||
createClone(type, name, value) {
|
||||
createClone(type, name, value, isInheritable) {
|
||||
return new Attribute({
|
||||
noteId: this.noteId,
|
||||
type: type,
|
||||
name: name,
|
||||
value: value,
|
||||
position: this.position,
|
||||
isInheritable: this.isInheritable,
|
||||
isInheritable: isInheritable,
|
||||
isDeleted: false,
|
||||
utcDateCreated: this.utcDateCreated,
|
||||
utcDateModified: this.utcDateModified
|
||||
@@ -152,7 +153,8 @@ class Attribute extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Attribute;</code></pre>
|
||||
module.exports = Attribute;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -168,7 +170,7 @@ module.exports = Attribute;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -30,16 +30,15 @@
|
||||
|
||||
const Entity = require('./entity');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const repository = require('../services/repository');
|
||||
const sql = require('../services/sql');
|
||||
|
||||
/**
|
||||
* Branch represents note's placement in the tree - it's essentially pair of noteId and parentNoteId.
|
||||
* Each note can have multiple (at least one) branches, meaning it can be placed into multiple places in the tree.
|
||||
*
|
||||
* @property {string} branchId - primary key
|
||||
* @property {string} noteId
|
||||
* @property {string} parentNoteId
|
||||
* @property {string} branchId - primary key, immutable
|
||||
* @property {string} noteId - immutable
|
||||
* @property {string} parentNoteId - immutable
|
||||
* @property {int} notePosition
|
||||
* @property {string} prefix
|
||||
* @property {boolean} isExpanded
|
||||
@@ -56,19 +55,19 @@ class Branch extends Entity {
|
||||
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
|
||||
static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "deleteId", "prefix"]; }
|
||||
|
||||
/** @returns {Promise<Note|null>} */
|
||||
async getNote() {
|
||||
return await repository.getNote(this.noteId);
|
||||
/** @returns {Note|null} */
|
||||
getNote() {
|
||||
return this.repository.getNote(this.noteId);
|
||||
}
|
||||
|
||||
/** @returns {Promise<Note|null>} */
|
||||
async getParentNote() {
|
||||
return await repository.getNote(this.parentNoteId);
|
||||
/** @returns {Note|null} */
|
||||
getParentNote() {
|
||||
return this.repository.getNote(this.parentNoteId);
|
||||
}
|
||||
|
||||
async beforeSaving() {
|
||||
beforeSaving() {
|
||||
if (this.notePosition === undefined) {
|
||||
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
|
||||
const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
|
||||
this.notePosition = maxNotePos === null ? 0 : maxNotePos + 10;
|
||||
}
|
||||
|
||||
@@ -105,7 +104,8 @@ class Branch extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Branch;</code></pre>
|
||||
module.exports = Branch;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -121,7 +121,7 @@ module.exports = Branch;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<pre class="prettyprint source linenums"><code>"use strict";
|
||||
|
||||
const utils = require('../services/utils');
|
||||
let repo = null;
|
||||
|
||||
class Entity {
|
||||
/**
|
||||
@@ -53,14 +54,7 @@ class Entity {
|
||||
const origHash = this.hash;
|
||||
|
||||
this.hash = this.generateHash();
|
||||
|
||||
if (this.forcedChange) {
|
||||
this.isChanged = true;
|
||||
delete this.forcedChange;
|
||||
}
|
||||
else {
|
||||
this.isChanged = origHash !== this.hash;
|
||||
}
|
||||
this.isChanged = origHash !== this.hash;
|
||||
}
|
||||
|
||||
generateIdIfNecessary() {
|
||||
@@ -79,14 +73,23 @@ class Entity {
|
||||
return utils.hash(contentToHash).substr(0, 10);
|
||||
}
|
||||
|
||||
async save() {
|
||||
await require('../services/repository').updateEntity(this);
|
||||
get repository() {
|
||||
if (!repo) {
|
||||
repo = require('../services/repository');
|
||||
}
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
save() {
|
||||
this.repository.updateEntity(this);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Entity;</code></pre>
|
||||
module.exports = Entity;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -102,7 +105,7 @@ module.exports = Entity;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -31,16 +31,13 @@
|
||||
const Entity = require('./entity');
|
||||
const Attribute = require('./attribute');
|
||||
const protectedSessionService = require('../services/protected_session');
|
||||
const repository = require('../services/repository');
|
||||
const sql = require('../services/sql');
|
||||
const utils = require('../services/utils');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const syncTableService = require('../services/sync_table');
|
||||
const entityChangesService = require('../services/entity_changes.js');
|
||||
|
||||
const LABEL = 'label';
|
||||
const LABEL_DEFINITION = 'label-definition';
|
||||
const RELATION = 'relation';
|
||||
const RELATION_DEFINITION = 'relation-definition';
|
||||
|
||||
/**
|
||||
* This represents a Note which is a central object in the Trilium Notes project.
|
||||
@@ -49,7 +46,6 @@ const RELATION_DEFINITION = 'relation-definition';
|
||||
* @property {string} type - one of "text", "code", "file" or "render"
|
||||
* @property {string} mime - MIME type, e.g. "text/html"
|
||||
* @property {string} title - note title
|
||||
* @property {int} contentLength - length of content
|
||||
* @property {boolean} isProtected - true if note is protected
|
||||
* @property {boolean} isDeleted - true if note is deleted
|
||||
* @property {string|null} deleteId - ID identifying delete transaction
|
||||
@@ -95,14 +91,14 @@ class Note extends Entity {
|
||||
* part of Note entity with it's own sync. Reasons behind this hybrid design has been:
|
||||
*
|
||||
* - content can be quite large and it's not necessary to load it / fill memory for any note access even if we don't need a content, especially for bulk operations like search
|
||||
* - changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and sync rows)
|
||||
* - changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and entity changes records)
|
||||
* - but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity)
|
||||
*/
|
||||
|
||||
/** @returns {Promise<*>} */
|
||||
async getContent(silentNotFoundError = false) {
|
||||
/** @returns {*} */
|
||||
getContent(silentNotFoundError = false) {
|
||||
if (this.content === undefined) {
|
||||
const res = await sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||
const res = sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||
|
||||
if (!res) {
|
||||
if (silentNotFoundError) {
|
||||
@@ -135,9 +131,20 @@ class Note extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {Promise<*>} */
|
||||
async getJsonContent() {
|
||||
const content = await this.getContent();
|
||||
/** @returns {{contentLength, dateModified, utcDateModified}} */
|
||||
getContentMetadata() {
|
||||
return sql.getRow(`
|
||||
SELECT
|
||||
LENGTH(content) AS contentLength,
|
||||
dateModified,
|
||||
utcDateModified
|
||||
FROM note_contents
|
||||
WHERE noteId = ?`, [this.noteId]);
|
||||
}
|
||||
|
||||
/** @returns {*} */
|
||||
getJsonContent() {
|
||||
const content = this.getContent();
|
||||
|
||||
if (!content || !content.trim()) {
|
||||
return null;
|
||||
@@ -146,24 +153,24 @@ class Note extends Entity {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
/** @returns {Promise} */
|
||||
async setContent(content) {
|
||||
setContent(content) {
|
||||
if (content === null || content === undefined) {
|
||||
throw new Error(`Cannot set null content to note ${this.noteId}`);
|
||||
}
|
||||
|
||||
content = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
||||
|
||||
// force updating note itself so that dateModified is represented correctly even for the content
|
||||
this.forcedChange = true;
|
||||
this.contentLength = content.byteLength;
|
||||
await this.save();
|
||||
if (this.isStringNote()) {
|
||||
content = content.toString();
|
||||
}
|
||||
else {
|
||||
content = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
||||
}
|
||||
|
||||
this.content = content;
|
||||
|
||||
const pojo = {
|
||||
noteId: this.noteId,
|
||||
content: content,
|
||||
dateModified: dateUtils.localNowDateTime(),
|
||||
utcDateModified: dateUtils.utcNowDateTime(),
|
||||
hash: utils.hash(this.noteId + "|" + content.toString())
|
||||
};
|
||||
@@ -177,14 +184,13 @@ class Note extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
await sql.upsert("note_contents", "noteId", pojo);
|
||||
sql.upsert("note_contents", "noteId", pojo);
|
||||
|
||||
await syncTableService.addNoteContentSync(this.noteId);
|
||||
entityChangesService.addNoteContentEntityChange(this.noteId);
|
||||
}
|
||||
|
||||
/** @returns {Promise} */
|
||||
async setJsonContent(content) {
|
||||
await this.setContent(JSON.stringify(content, null, '\t'));
|
||||
setJsonContent(content) {
|
||||
this.setContent(JSON.stringify(content, null, '\t'));
|
||||
}
|
||||
|
||||
/** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */
|
||||
@@ -232,8 +238,8 @@ class Note extends Entity {
|
||||
return null;
|
||||
}
|
||||
|
||||
async loadOwnedAttributesToCache() {
|
||||
this.__ownedAttributeCache = await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
|
||||
loadOwnedAttributesToCache() {
|
||||
this.__ownedAttributeCache = this.repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
|
||||
return this.__ownedAttributeCache;
|
||||
}
|
||||
|
||||
@@ -243,11 +249,11 @@ class Note extends Entity {
|
||||
*
|
||||
* @param {string} [type] - (optional) attribute type to filter
|
||||
* @param {string} [name] - (optional) attribute name to filter
|
||||
* @returns {Promise<Attribute[]>} note's "owned" attributes - excluding inherited ones
|
||||
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
|
||||
*/
|
||||
async getOwnedAttributes(type, name) {
|
||||
getOwnedAttributes(type, name) {
|
||||
if (!this.__ownedAttributeCache) {
|
||||
await this.loadOwnedAttributesToCache();
|
||||
this.loadOwnedAttributesToCache();
|
||||
}
|
||||
|
||||
if (type && name) {
|
||||
@@ -265,31 +271,31 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Attribute>} attribute belonging to this specific note (excludes inherited attributes)
|
||||
* @returns {Attribute} attribute belonging to this specific note (excludes inherited attributes)
|
||||
*
|
||||
* This method can be significantly faster than the getAttribute()
|
||||
*/
|
||||
async getOwnedAttribute(type, name) {
|
||||
const attrs = await this.getOwnedAttributes(type, name);
|
||||
getOwnedAttribute(type, name) {
|
||||
const attrs = this.getOwnedAttributes(type, name);
|
||||
|
||||
return attrs.length > 0 ? attrs[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Attribute[]>} relations targetting this specific note
|
||||
* @returns {Attribute[]} relations targetting this specific note
|
||||
*/
|
||||
async getTargetRelations() {
|
||||
return await repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [this.noteId]);
|
||||
getTargetRelations() {
|
||||
return this.repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [this.noteId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [type] - (optional) attribute type to filter
|
||||
* @param {string} [name] - (optional) attribute name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's attributes, including inherited ones
|
||||
* @returns {Attribute[]} all note's attributes, including inherited ones
|
||||
*/
|
||||
async getAttributes(type, name) {
|
||||
getAttributes(type, name) {
|
||||
if (!this.__attributeCache) {
|
||||
await this.loadAttributesToCache();
|
||||
this.loadAttributesToCache();
|
||||
}
|
||||
|
||||
if (type && name) {
|
||||
@@ -308,67 +314,51 @@ class Note extends Entity {
|
||||
|
||||
/**
|
||||
* @param {string} [name] - label name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones
|
||||
* @returns {Attribute[]} all note's labels (attributes with type label), including inherited ones
|
||||
*/
|
||||
async getLabels(name) {
|
||||
return await this.getAttributes(LABEL, name);
|
||||
getLabels(name) {
|
||||
return this.getAttributes(LABEL, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - label name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's labels (attributes with type label), excluding inherited ones
|
||||
* @returns {Attribute[]} all note's labels (attributes with type label), excluding inherited ones
|
||||
*/
|
||||
async getOwnedLabels(name) {
|
||||
return await this.getOwnedAttributes(LABEL, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - label name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's label definitions, including inherited ones
|
||||
*/
|
||||
async getLabelDefinitions(name) {
|
||||
return await this.getAttributes(LABEL_DEFINITION, name);
|
||||
getOwnedLabels(name) {
|
||||
return this.getOwnedAttributes(LABEL, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones
|
||||
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
|
||||
*/
|
||||
async getRelations(name) {
|
||||
return await this.getAttributes(RELATION, name);
|
||||
getRelations(name) {
|
||||
return this.getAttributes(RELATION, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), excluding inherited ones
|
||||
* @returns {Attribute[]} all note's relations (attributes with type relation), excluding inherited ones
|
||||
*/
|
||||
async getOwnedRelations(name) {
|
||||
return await this.getOwnedAttributes(RELATION, name);
|
||||
getOwnedRelations(name) {
|
||||
return this.getOwnedAttributes(RELATION, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Promise<Note[]>}
|
||||
* @returns {Note[]}
|
||||
*/
|
||||
async getRelationTargets(name) {
|
||||
const relations = await this.getRelations(name);
|
||||
getRelationTargets(name) {
|
||||
const relations = this.getRelations(name);
|
||||
const targets = [];
|
||||
|
||||
for (const relation of relations) {
|
||||
targets.push(await relation.getTargetNote());
|
||||
targets.push(relation.getTargetNote());
|
||||
}
|
||||
|
||||
return targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's relation definitions including inherited ones
|
||||
*/
|
||||
async getRelationDefinitions(name) {
|
||||
return await this.getAttributes(RELATION_DEFINITION, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear note's attributes cache to force fresh reload for next attribute request.
|
||||
* Cache is note instance scoped.
|
||||
@@ -378,9 +368,8 @@ class Note extends Entity {
|
||||
this.__ownedAttributeCache = null;
|
||||
}
|
||||
|
||||
/** @returns {Promise<void>} */
|
||||
async loadAttributesToCache() {
|
||||
const attributes = await repository.getEntities(`
|
||||
loadAttributesToCache() {
|
||||
const attributes = this.repository.getEntities(`
|
||||
WITH RECURSIVE
|
||||
tree(noteId, level) AS (
|
||||
SELECT ?, 0
|
||||
@@ -412,6 +401,7 @@ class Note extends Entity {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: this code is quite questionable, one problem is that other caches (TreeCache, NoteCache) have nothing like that
|
||||
if (attr.isDefinition()) {
|
||||
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
|
||||
|
||||
@@ -419,15 +409,15 @@ class Note extends Entity {
|
||||
return firstDefinitionIndex === index;
|
||||
}
|
||||
else {
|
||||
const definitionAttr = attributes.find(el => el.type === attr.type + '-definition' && el.name === attr.name);
|
||||
const definitionAttr = attributes.find(el => el.type === 'label' && el.name === attr.type + ':' + attr.name);
|
||||
|
||||
if (!definitionAttr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const definition = definitionAttr.value;
|
||||
const definition = definitionAttr.getDefinition();
|
||||
|
||||
if (definition.multiplicityType === 'multivalue') {
|
||||
if (definition.multiplicity === 'multi') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -439,38 +429,34 @@ class Note extends Entity {
|
||||
}
|
||||
});
|
||||
|
||||
for (const attr of filteredAttributes) {
|
||||
attr.isOwned = attr.noteId === this.noteId;
|
||||
}
|
||||
|
||||
this.__attributeCache = filteredAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @returns {Promise<boolean>} true if note has an attribute with given type and name (including inherited)
|
||||
* @returns {boolean} true if note has an attribute with given type and name (including inherited)
|
||||
*/
|
||||
async hasAttribute(type, name) {
|
||||
return !!await this.getAttribute(type, name);
|
||||
hasAttribute(type, name) {
|
||||
return !!this.getAttribute(type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @returns {Promise<boolean>} true if note has an attribute with given type and name (excluding inherited)
|
||||
* @returns {boolean} true if note has an attribute with given type and name (excluding inherited)
|
||||
*/
|
||||
async hasOwnedAttribute(type, name) {
|
||||
return !!await this.getOwnedAttribute(type, name);
|
||||
hasOwnedAttribute(type, name) {
|
||||
return !!this.getOwnedAttribute(type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @returns {Promise<Attribute>} attribute of given type and name. If there's more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
|
||||
* @returns {Attribute} attribute of given type and name. If there's more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
|
||||
*/
|
||||
async getAttribute(type, name) {
|
||||
const attributes = await this.getAttributes();
|
||||
getAttribute(type, name) {
|
||||
const attributes = this.getAttributes();
|
||||
|
||||
return attributes.find(attr => attr.type === type && attr.name === name);
|
||||
}
|
||||
@@ -478,10 +464,10 @@ class Note extends Entity {
|
||||
/**
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @returns {Promise<string|null>} attribute value of given type and name or null if no such attribute exists.
|
||||
* @returns {string|null} attribute value of given type and name or null if no such attribute exists.
|
||||
*/
|
||||
async getAttributeValue(type, name) {
|
||||
const attr = await this.getAttribute(type, name);
|
||||
getAttributeValue(type, name) {
|
||||
const attr = this.getAttribute(type, name);
|
||||
|
||||
return attr ? attr.value : null;
|
||||
}
|
||||
@@ -489,10 +475,10 @@ class Note extends Entity {
|
||||
/**
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @returns {Promise<string|null>} attribute value of given type and name or null if no such attribute exists.
|
||||
* @returns {string|null} attribute value of given type and name or null if no such attribute exists.
|
||||
*/
|
||||
async getOwnedAttributeValue(type, name) {
|
||||
const attr = await this.getOwnedAttribute(type, name);
|
||||
getOwnedAttributeValue(type, name) {
|
||||
const attr = this.getOwnedAttribute(type, name);
|
||||
|
||||
return attr ? attr.value : null;
|
||||
}
|
||||
@@ -504,14 +490,13 @@ class Note extends Entity {
|
||||
* @param {boolean} enabled - toggle On or Off
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value (optional)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async toggleAttribute(type, enabled, name, value) {
|
||||
toggleAttribute(type, enabled, name, value) {
|
||||
if (enabled) {
|
||||
await this.setAttribute(type, name, value);
|
||||
this.setAttribute(type, name, value);
|
||||
}
|
||||
else {
|
||||
await this.removeAttribute(type, name, value);
|
||||
this.removeAttribute(type, name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,16 +506,15 @@ class Note extends Entity {
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value (optional)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async setAttribute(type, name, value) {
|
||||
const attributes = await this.loadOwnedAttributesToCache();
|
||||
setAttribute(type, name, value) {
|
||||
const attributes = this.loadOwnedAttributesToCache();
|
||||
let attr = attributes.find(attr => attr.type === type && attr.name === name);
|
||||
|
||||
if (attr) {
|
||||
if (attr.value !== value) {
|
||||
attr.value = value;
|
||||
await attr.save();
|
||||
attr.save();
|
||||
|
||||
this.invalidateAttributeCache();
|
||||
}
|
||||
@@ -543,7 +527,7 @@ class Note extends Entity {
|
||||
value: value !== undefined ? value : ""
|
||||
});
|
||||
|
||||
await attr.save();
|
||||
attr.save();
|
||||
|
||||
this.invalidateAttributeCache();
|
||||
}
|
||||
@@ -555,15 +539,14 @@ class Note extends Entity {
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value (optional)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async removeAttribute(type, name, value) {
|
||||
const attributes = await this.loadOwnedAttributesToCache();
|
||||
removeAttribute(type, name, value) {
|
||||
const attributes = this.loadOwnedAttributesToCache();
|
||||
|
||||
for (const attribute of attributes) {
|
||||
if (attribute.type === type && attribute.name === name && (value === undefined || value === attribute.value)) {
|
||||
attribute.isDeleted = true;
|
||||
await attribute.save();
|
||||
attribute.save();
|
||||
|
||||
this.invalidateAttributeCache();
|
||||
}
|
||||
@@ -571,121 +554,123 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Promise<Attribute>}
|
||||
* @return {Attribute}
|
||||
*/
|
||||
async addAttribute(type, name, value = "") {
|
||||
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
|
||||
const attr = new Attribute({
|
||||
noteId: this.noteId,
|
||||
type: type,
|
||||
name: name,
|
||||
value: value
|
||||
value: value,
|
||||
isInheritable: isInheritable,
|
||||
position: position
|
||||
});
|
||||
|
||||
await attr.save();
|
||||
attr.save();
|
||||
|
||||
this.invalidateAttributeCache();
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
async addLabel(name, value = "") {
|
||||
return await this.addAttribute(LABEL, name, value);
|
||||
addLabel(name, value = "", isInheritable = false) {
|
||||
return this.addAttribute(LABEL, name, value, isInheritable);
|
||||
}
|
||||
|
||||
async addRelation(name, targetNoteId) {
|
||||
return await this.addAttribute(RELATION, name, targetNoteId);
|
||||
addRelation(name, targetNoteId, isInheritable = false) {
|
||||
return this.addAttribute(RELATION, name, targetNoteId, isInheritable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name - label name
|
||||
* @returns {Promise<boolean>} true if label exists (including inherited)
|
||||
* @returns {boolean} true if label exists (including inherited)
|
||||
*/
|
||||
async hasLabel(name) { return await this.hasAttribute(LABEL, name); }
|
||||
hasLabel(name) { return this.hasAttribute(LABEL, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - label name
|
||||
* @returns {Promise<boolean>} true if label exists (excluding inherited)
|
||||
* @returns {boolean} true if label exists (excluding inherited)
|
||||
*/
|
||||
async hasOwnedLabel(name) { return await this.hasOwnedAttribute(LABEL, name); }
|
||||
hasOwnedLabel(name) { return this.hasOwnedAttribute(LABEL, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - relation name
|
||||
* @returns {Promise<boolean>} true if relation exists (including inherited)
|
||||
* @returns {boolean} true if relation exists (including inherited)
|
||||
*/
|
||||
async hasRelation(name) { return await this.hasAttribute(RELATION, name); }
|
||||
hasRelation(name) { return this.hasAttribute(RELATION, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - relation name
|
||||
* @returns {Promise<boolean>} true if relation exists (excluding inherited)
|
||||
* @returns {boolean} true if relation exists (excluding inherited)
|
||||
*/
|
||||
async hasOwnedRelation(name) { return await this.hasOwnedAttribute(RELATION, name); }
|
||||
hasOwnedRelation(name) { return this.hasOwnedAttribute(RELATION, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - label name
|
||||
* @returns {Promise<Attribute|null>} label if it exists, null otherwise
|
||||
* @returns {Attribute|null} label if it exists, null otherwise
|
||||
*/
|
||||
async getLabel(name) { return await this.getAttribute(LABEL, name); }
|
||||
getLabel(name) { return this.getAttribute(LABEL, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - label name
|
||||
* @returns {Promise<Attribute|null>} label if it exists, null otherwise
|
||||
* @returns {Attribute|null} label if it exists, null otherwise
|
||||
*/
|
||||
async getOwnedLabel(name) { return await this.getOwnedAttribute(LABEL, name); }
|
||||
getOwnedLabel(name) { return this.getOwnedAttribute(LABEL, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - relation name
|
||||
* @returns {Promise<Attribute|null>} relation if it exists, null otherwise
|
||||
* @returns {Attribute|null} relation if it exists, null otherwise
|
||||
*/
|
||||
async getRelation(name) { return await this.getAttribute(RELATION, name); }
|
||||
getRelation(name) { return this.getAttribute(RELATION, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - relation name
|
||||
* @returns {Promise<Attribute|null>} relation if it exists, null otherwise
|
||||
* @returns {Attribute|null} relation if it exists, null otherwise
|
||||
*/
|
||||
async getOwnedRelation(name) { return await this.getOwnedAttribute(RELATION, name); }
|
||||
getOwnedRelation(name) { return this.getOwnedAttribute(RELATION, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - label name
|
||||
* @returns {Promise<string|null>} label value if label exists, null otherwise
|
||||
* @returns {string|null} label value if label exists, null otherwise
|
||||
*/
|
||||
async getLabelValue(name) { return await this.getAttributeValue(LABEL, name); }
|
||||
getLabelValue(name) { return this.getAttributeValue(LABEL, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - label name
|
||||
* @returns {Promise<string|null>} label value if label exists, null otherwise
|
||||
* @returns {string|null} label value if label exists, null otherwise
|
||||
*/
|
||||
async getOwnedLabelValue(name) { return await this.getOwnedAttributeValue(LABEL, name); }
|
||||
getOwnedLabelValue(name) { return this.getOwnedAttributeValue(LABEL, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - relation name
|
||||
* @returns {Promise<string|null>} relation value if relation exists, null otherwise
|
||||
* @returns {string|null} relation value if relation exists, null otherwise
|
||||
*/
|
||||
async getRelationValue(name) { return await this.getAttributeValue(RELATION, name); }
|
||||
getRelationValue(name) { return this.getAttributeValue(RELATION, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name - relation name
|
||||
* @returns {Promise<string|null>} relation value if relation exists, null otherwise
|
||||
* @returns {string|null} relation value if relation exists, null otherwise
|
||||
*/
|
||||
async getOwnedRelationValue(name) { return await this.getOwnedAttributeValue(RELATION, name); }
|
||||
getOwnedRelationValue(name) { return this.getOwnedAttributeValue(RELATION, name); }
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found)
|
||||
* @returns {Note|null} target note of the relation or null (if target is empty or note was not found)
|
||||
*/
|
||||
async getRelationTarget(name) {
|
||||
const relation = await this.getRelation(name);
|
||||
getRelationTarget(name) {
|
||||
const relation = this.getRelation(name);
|
||||
|
||||
return relation ? await repository.getNote(relation.value) : null;
|
||||
return relation ? this.repository.getNote(relation.value) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found)
|
||||
* @returns {Note|null} target note of the relation or null (if target is empty or note was not found)
|
||||
*/
|
||||
async getOwnedRelationTarget(name) {
|
||||
const relation = await this.getOwnedRelation(name);
|
||||
getOwnedRelationTarget(name) {
|
||||
const relation = this.getOwnedRelation(name);
|
||||
|
||||
return relation ? await repository.getNote(relation.value) : null;
|
||||
return relation ? this.repository.getNote(relation.value) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -694,9 +679,8 @@ class Note extends Entity {
|
||||
* @param {boolean} enabled - toggle On or Off
|
||||
* @param {string} name - label name
|
||||
* @param {string} [value] - label value (optional)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async toggleLabel(enabled, name, value) { return await this.toggleAttribute(LABEL, enabled, name, value); }
|
||||
toggleLabel(enabled, name, value) { return this.toggleAttribute(LABEL, enabled, name, value); }
|
||||
|
||||
/**
|
||||
* Based on enabled, relation is either set or removed.
|
||||
@@ -704,51 +688,46 @@ class Note extends Entity {
|
||||
* @param {boolean} enabled - toggle On or Off
|
||||
* @param {string} name - relation name
|
||||
* @param {string} [value] - relation value (noteId)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async toggleRelation(enabled, name, value) { return await this.toggleAttribute(RELATION, enabled, name, value); }
|
||||
toggleRelation(enabled, name, value) { return this.toggleAttribute(RELATION, enabled, name, value); }
|
||||
|
||||
/**
|
||||
* Update's given label's value or creates it if it doesn't exist
|
||||
*
|
||||
* @param {string} name - label name
|
||||
* @param {string} [value] - label value
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async setLabel(name, value) { return await this.setAttribute(LABEL, name, value); }
|
||||
setLabel(name, value) { return this.setAttribute(LABEL, name, value); }
|
||||
|
||||
/**
|
||||
* Update's given relation's value or creates it if it doesn't exist
|
||||
*
|
||||
* @param {string} name - relation name
|
||||
* @param {string} [value] - relation value (noteId)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async setRelation(name, value) { return await this.setAttribute(RELATION, name, value); }
|
||||
setRelation(name, value) { return this.setAttribute(RELATION, name, value); }
|
||||
|
||||
/**
|
||||
* Remove label name-value pair, if it exists.
|
||||
*
|
||||
* @param {string} name - label name
|
||||
* @param {string} [value] - label value
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async removeLabel(name, value) { return await this.removeAttribute(LABEL, name, value); }
|
||||
removeLabel(name, value) { return this.removeAttribute(LABEL, name, value); }
|
||||
|
||||
/**
|
||||
* Remove relation name-value pair, if it exists.
|
||||
*
|
||||
* @param {string} name - relation name
|
||||
* @param {string} [value] - relation value (noteId)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async removeRelation(name, value) { return await this.removeAttribute(RELATION, name, value); }
|
||||
removeRelation(name, value) { return this.removeAttribute(RELATION, name, value); }
|
||||
|
||||
/**
|
||||
* @return {Promise<string[]>} return list of all descendant noteIds of this note. Returning just noteIds because number of notes can be huge. Includes also this note's noteId
|
||||
* @return {string[]} return list of all descendant noteIds of this note. Returning just noteIds because number of notes can be huge. Includes also this note's noteId
|
||||
*/
|
||||
async getDescendantNoteIds() {
|
||||
return await sql.getColumn(`
|
||||
getDescendantNoteIds() {
|
||||
return sql.getColumn(`
|
||||
WITH RECURSIVE
|
||||
tree(noteId) AS (
|
||||
SELECT ?
|
||||
@@ -768,9 +747,9 @@ class Note extends Entity {
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value
|
||||
* @returns {Promise<Note[]>}
|
||||
* @returns {Note[]}
|
||||
*/
|
||||
async getDescendantNotesWithAttribute(type, name, value) {
|
||||
getDescendantNotesWithAttribute(type, name, value) {
|
||||
const params = [this.noteId, name];
|
||||
let valueCondition = "";
|
||||
|
||||
@@ -779,7 +758,7 @@ class Note extends Entity {
|
||||
valueCondition = " AND attributes.value = ?";
|
||||
}
|
||||
|
||||
const notes = await repository.getEntities(`
|
||||
const notes = this.repository.getEntities(`
|
||||
WITH RECURSIVE
|
||||
tree(noteId) AS (
|
||||
SELECT ?
|
||||
@@ -806,36 +785,36 @@ class Note extends Entity {
|
||||
*
|
||||
* @param {string} name - label name
|
||||
* @param {string} [value] - label value
|
||||
* @returns {Promise<Note[]>}
|
||||
* @returns {Note[]}
|
||||
*/
|
||||
async getDescendantNotesWithLabel(name, value) { return await this.getDescendantNotesWithAttribute(LABEL, name, value); }
|
||||
getDescendantNotesWithLabel(name, value) { return this.getDescendantNotesWithAttribute(LABEL, name, value); }
|
||||
|
||||
/**
|
||||
* Finds descendant notes with given relation name and value. Only own relations are considered, not inherited ones
|
||||
*
|
||||
* @param {string} name - relation name
|
||||
* @param {string} [value] - relation value
|
||||
* @returns {Promise<Note[]>}
|
||||
* @returns {Note[]}
|
||||
*/
|
||||
async getDescendantNotesWithRelation(name, value) { return await this.getDescendantNotesWithAttribute(RELATION, name, value); }
|
||||
getDescendantNotesWithRelation(name, value) { return this.getDescendantNotesWithAttribute(RELATION, name, value); }
|
||||
|
||||
/**
|
||||
* Returns note revisions of this note.
|
||||
*
|
||||
* @returns {Promise<NoteRevision[]>}
|
||||
* @returns {NoteRevision[]}
|
||||
*/
|
||||
async getRevisions() {
|
||||
return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
||||
getRevisions() {
|
||||
return this.repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of links coming out of this note.
|
||||
*
|
||||
* @deprecated - not intended for general use
|
||||
* @returns {Promise<Attribute[]>}
|
||||
* @returns {Attribute[]}
|
||||
*/
|
||||
async getLinks() {
|
||||
return await repository.getEntities(`
|
||||
getLinks() {
|
||||
return this.repository.getEntities(`
|
||||
SELECT *
|
||||
FROM attributes
|
||||
WHERE noteId = ? AND
|
||||
@@ -845,24 +824,24 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Branch[]>}
|
||||
* @returns {Branch[]}
|
||||
*/
|
||||
async getBranches() {
|
||||
return await repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
|
||||
getBranches() {
|
||||
return this.repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean} - true if note has children
|
||||
*/
|
||||
async hasChildren() {
|
||||
return (await this.getChildNotes()).length > 0;
|
||||
hasChildren() {
|
||||
return (this.getChildNotes()).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Note[]>} child notes of this note
|
||||
* @returns {Note[]} child notes of this note
|
||||
*/
|
||||
async getChildNotes() {
|
||||
return await repository.getEntities(`
|
||||
getChildNotes() {
|
||||
return this.repository.getEntities(`
|
||||
SELECT notes.*
|
||||
FROM branches
|
||||
JOIN notes USING(noteId)
|
||||
@@ -873,10 +852,10 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Branch[]>} child branches of this note
|
||||
* @returns {Branch[]} child branches of this note
|
||||
*/
|
||||
async getChildBranches() {
|
||||
return await repository.getEntities(`
|
||||
getChildBranches() {
|
||||
return this.repository.getEntities(`
|
||||
SELECT branches.*
|
||||
FROM branches
|
||||
WHERE branches.isDeleted = 0
|
||||
@@ -885,10 +864,10 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Note[]>} parent notes of this note (note can have multiple parents because of cloning)
|
||||
* @returns {Note[]} parent notes of this note (note can have multiple parents because of cloning)
|
||||
*/
|
||||
async getParentNotes() {
|
||||
return await repository.getEntities(`
|
||||
getParentNotes() {
|
||||
return this.repository.getEntities(`
|
||||
SELECT parent_notes.*
|
||||
FROM
|
||||
branches AS child_tree
|
||||
@@ -899,17 +878,17 @@ class Note extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Promise<string[][]>} - array of notePaths (each represented by array of noteIds constituting the particular note path)
|
||||
* @return {string[][]} - array of notePaths (each represented by array of noteIds constituting the particular note path)
|
||||
*/
|
||||
async getAllNotePaths() {
|
||||
getAllNotePaths() {
|
||||
if (this.noteId === 'root') {
|
||||
return [['root']];
|
||||
}
|
||||
|
||||
const notePaths = [];
|
||||
|
||||
for (const parentNote of await this.getParentNotes()) {
|
||||
for (const parentPath of await parentNote.getAllNotePaths()) {
|
||||
for (const parentNote of this.getParentNotes()) {
|
||||
for (const parentPath of parentNote.getAllNotePaths()) {
|
||||
parentPath.push(this.noteId);
|
||||
notePaths.push(parentPath);
|
||||
}
|
||||
@@ -918,12 +897,22 @@ class Note extends Entity {
|
||||
return notePaths;
|
||||
}
|
||||
|
||||
getRelationDefinitions() {
|
||||
return this.getLabels()
|
||||
.filter(l => l.name.startsWith("relation:"));
|
||||
}
|
||||
|
||||
getLabelDefinitions() {
|
||||
return this.getLabels()
|
||||
.filter(l => l.name.startsWith("relation:"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ancestorNoteId
|
||||
* @return {Promise<boolean>} - true if ancestorNoteId occurs in at least one of the note's paths
|
||||
* @return {boolean} - true if ancestorNoteId occurs in at least one of the note's paths
|
||||
*/
|
||||
async isDescendantOfNote(ancestorNoteId) {
|
||||
const notePaths = await this.getAllNotePaths();
|
||||
isDescendantOfNote(ancestorNoteId) {
|
||||
const notePaths = this.getAllNotePaths();
|
||||
|
||||
return notePaths.some(path => path.includes(ancestorNoteId));
|
||||
}
|
||||
@@ -941,10 +930,6 @@ class Note extends Entity {
|
||||
this.utcDateCreated = dateUtils.utcNowDateTime();
|
||||
}
|
||||
|
||||
if (this.contentLength === undefined) {
|
||||
this.contentLength = -1;
|
||||
}
|
||||
|
||||
super.beforeSaving();
|
||||
|
||||
if (this.isChanged) {
|
||||
@@ -974,7 +959,8 @@ class Note extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Note;</code></pre>
|
||||
module.exports = Note;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -990,7 +976,7 @@ module.exports = Note;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -30,11 +30,10 @@
|
||||
|
||||
const Entity = require('./entity');
|
||||
const protectedSessionService = require('../services/protected_session');
|
||||
const repository = require('../services/repository');
|
||||
const utils = require('../services/utils');
|
||||
const sql = require('../services/sql');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const syncTableService = require('../services/sync_table');
|
||||
const entityChangesService = require('../services/entity_changes.js');
|
||||
|
||||
/**
|
||||
* NoteRevision represents snapshot of note's title and content at some point in the past. It's used for seamless note versioning.
|
||||
@@ -44,7 +43,6 @@ const syncTableService = require('../services/sync_table');
|
||||
* @property {string} type
|
||||
* @property {string} mime
|
||||
* @property {string} title
|
||||
* @property {int} contentLength
|
||||
* @property {boolean} isErased
|
||||
* @property {boolean} isProtected
|
||||
* @property {string} dateLastEdited
|
||||
@@ -58,11 +56,12 @@ const syncTableService = require('../services/sync_table');
|
||||
class NoteRevision extends Entity {
|
||||
static get entityName() { return "note_revisions"; }
|
||||
static get primaryKeyName() { return "noteRevisionId"; }
|
||||
static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "contentLength", "isErased", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; }
|
||||
static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "isErased", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; }
|
||||
|
||||
constructor(row) {
|
||||
super(row);
|
||||
|
||||
this.isErased = !!this.isErased;
|
||||
this.isProtected = !!this.isProtected;
|
||||
|
||||
if (this.isProtected) {
|
||||
@@ -75,8 +74,8 @@ class NoteRevision extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
async getNote() {
|
||||
return await repository.getNote(this.noteId);
|
||||
getNote() {
|
||||
return this.repository.getNote(this.noteId);
|
||||
}
|
||||
|
||||
/** @returns {boolean} true if the note has string content (not binary) */
|
||||
@@ -93,10 +92,10 @@ class NoteRevision extends Entity {
|
||||
* This is the same approach as is used for Note's content.
|
||||
*/
|
||||
|
||||
/** @returns {Promise<*>} */
|
||||
async getContent(silentNotFoundError = false) {
|
||||
/** @returns {*} */
|
||||
getContent(silentNotFoundError = false) {
|
||||
if (this.content === undefined) {
|
||||
const res = await sql.getRow(`SELECT content, hash FROM note_revision_contents WHERE noteRevisionId = ?`, [this.noteRevisionId]);
|
||||
const res = sql.getRow(`SELECT content, hash FROM note_revision_contents WHERE noteRevisionId = ?`, [this.noteRevisionId]);
|
||||
|
||||
if (!res) {
|
||||
if (silentNotFoundError) {
|
||||
@@ -129,13 +128,7 @@ class NoteRevision extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {Promise} */
|
||||
async setContent(content) {
|
||||
// force updating note itself so that utcDateModified is represented correctly even for the content
|
||||
this.forcedChange = true;
|
||||
this.contentLength = content === null ? 0 : content.length;
|
||||
await this.save();
|
||||
|
||||
setContent(content) {
|
||||
this.content = content;
|
||||
|
||||
const pojo = {
|
||||
@@ -154,9 +147,9 @@ class NoteRevision extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
await sql.upsert("note_revision_contents", "noteRevisionId", pojo);
|
||||
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
|
||||
|
||||
await syncTableService.addNoteRevisionContentSync(this.noteRevisionId);
|
||||
entityChangesService.addNoteRevisionContentEntityChange(this.noteRevisionId);
|
||||
}
|
||||
|
||||
beforeSaving() {
|
||||
@@ -183,7 +176,8 @@ class NoteRevision extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NoteRevision;</code></pre>
|
||||
module.exports = NoteRevision;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -199,7 +193,7 @@ module.exports = NoteRevision;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -82,7 +82,7 @@ module.exports = Option;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -75,7 +75,7 @@ module.exports = RecentNote;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -391,7 +391,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line212">line 212</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line213">line 213</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line173">line 173</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line174">line 174</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -767,7 +767,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line233">line 233</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line234">line 234</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1053,7 +1053,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line240">line 240</a>
|
||||
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line241">line 241</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1089,7 +1089,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -38,9 +38,9 @@ const repository = require('./repository');
|
||||
const axios = require('axios');
|
||||
const dayjs = require('dayjs');
|
||||
const cloningService = require('./cloning');
|
||||
const ws = require('./ws.js');
|
||||
const appInfo = require('./app_info');
|
||||
const searchService = require('./search');
|
||||
const searchService = require('./search/services/search');
|
||||
const SearchContext = require("./search/search_context.js");
|
||||
|
||||
/**
|
||||
* This is the main backend API interface for scripts. It's published in the local "api" object.
|
||||
@@ -78,38 +78,31 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
/**
|
||||
* @method
|
||||
* @param {string} noteId
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getNote = repository.getNote;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} branchId
|
||||
* @returns {Promise<Branch|null>}
|
||||
* @returns {Branch|null}
|
||||
*/
|
||||
this.getBranch = repository.getBranch;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} attributeId
|
||||
* @returns {Promise<Attribute|null>}
|
||||
* @returns {Attribute|null}
|
||||
*/
|
||||
this.getAttribute = repository.getAttribute;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} imageId
|
||||
* @returns {Promise<Image|null>}
|
||||
*/
|
||||
this.getImage = repository.getImage;
|
||||
|
||||
/**
|
||||
* Retrieves first entity from the SQL's result set.
|
||||
*
|
||||
* @method
|
||||
* @param {string} SQL query
|
||||
* @param {Array.<?>} array of params
|
||||
* @returns {Promise<Entity|null>}
|
||||
* @returns {Entity|null}
|
||||
*/
|
||||
this.getEntity = repository.getEntity;
|
||||
|
||||
@@ -117,30 +110,38 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
* @param {string} SQL query
|
||||
* @param {Array.<?>} array of params
|
||||
* @returns {Promise<Entity[]>}
|
||||
* @returns {Entity[]}
|
||||
*/
|
||||
this.getEntities = repository.getEntities;
|
||||
|
||||
/**
|
||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
*
|
||||
* @method
|
||||
* @param {string} searchString
|
||||
* @returns {Promise<Note[]>}
|
||||
* @param {string} query
|
||||
* @param {SearchContext} [searchContext]
|
||||
* @returns {Note[]}
|
||||
*/
|
||||
this.searchForNotes = searchService.searchForNotes;
|
||||
this.searchForNotes = (query, searchContext) => {
|
||||
searchContext = searchContext || new SearchContext();
|
||||
|
||||
const noteIds = searchService.findNotesWithQuery(query, searchContext)
|
||||
.map(sr => sr.noteId);
|
||||
|
||||
return repository.getNotes(noteIds);
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
*
|
||||
* @method
|
||||
* @param {string} searchString
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.searchForNote = async searchString => {
|
||||
const notes = await searchService.searchForNotes(searchString);
|
||||
this.searchForNote = searchString => {
|
||||
const notes = searchService.searchNoteEntities(searchString);
|
||||
|
||||
return notes.length > 0 ? notes[0] : null;
|
||||
};
|
||||
@@ -151,7 +152,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value
|
||||
* @returns {Promise<Note[]>}
|
||||
* @returns {Note[]}
|
||||
*/
|
||||
this.getNotesWithLabel = attributeService.getNotesWithLabel;
|
||||
|
||||
@@ -161,7 +162,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
* @param {string} name - attribute name
|
||||
* @param {string} [value] - attribute value
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getNoteWithLabel = attributeService.getNoteWithLabel;
|
||||
|
||||
@@ -172,7 +173,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @param {string} noteId
|
||||
* @param {string} parentNoteId
|
||||
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
|
||||
* @returns {Promise<void>}
|
||||
* @returns {void}
|
||||
*/
|
||||
this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;
|
||||
|
||||
@@ -182,7 +183,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
* @param {string} noteId
|
||||
* @param {string} parentNoteId
|
||||
* @returns {Promise<void>}
|
||||
* @returns {void}
|
||||
*/
|
||||
this.ensureNoteIsAbsentFromParent = cloningService.ensureNoteIsAbsentFromParent;
|
||||
|
||||
@@ -194,7 +195,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @param {string} noteId
|
||||
* @param {string} parentNoteId
|
||||
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
|
||||
* @returns {Promise<void>}
|
||||
* @returns {void}
|
||||
*/
|
||||
this.toggleNoteInParent = cloningService.toggleNoteInParent;
|
||||
|
||||
@@ -211,9 +212,9 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @param {string} parentNoteId
|
||||
* @param {string} title
|
||||
* @param {string} content
|
||||
* @return {Promise<{note: Note, branch: Branch}>}
|
||||
* @return {{note: Note, branch: Branch}}
|
||||
*/
|
||||
this.createTextNote = async (parentNoteId, title, content = '') => await noteService.createNewNote({
|
||||
this.createTextNote = (parentNoteId, title, content = '') => noteService.createNewNote({
|
||||
parentNoteId,
|
||||
title,
|
||||
content,
|
||||
@@ -227,9 +228,9 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @param {string} parentNoteId
|
||||
* @param {string} title
|
||||
* @param {object} content
|
||||
* @return {Promise<{note: Note, branch: Branch}>}
|
||||
* @return {{note: Note, branch: Branch}}
|
||||
*/
|
||||
this.createDataNote = async (parentNoteId, title, content = {}) => await noteService.createNewNote({
|
||||
this.createDataNote = (parentNoteId, title, content = {}) => noteService.createNewNote({
|
||||
parentNoteId,
|
||||
title,
|
||||
content: JSON.stringify(content, null, '\t'),
|
||||
@@ -254,7 +255,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
*
|
||||
* @param {CreateNewNoteParams} [params]
|
||||
* @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch
|
||||
* @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch
|
||||
*/
|
||||
this.createNewNote = noteService.createNewNote;
|
||||
|
||||
@@ -276,19 +277,19 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @deprecated please use createNote() API method instead
|
||||
* @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs
|
||||
*
|
||||
* @param {string} parentNoteId - create new note under this parent
|
||||
* @param {string} title
|
||||
* @param {string} [content=""]
|
||||
* @param {CreateNoteExtraOptions} [extraOptions={}]
|
||||
* @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch
|
||||
* @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch
|
||||
*/
|
||||
this.createNote = async (parentNoteId, title, content = "", extraOptions= {}) => {
|
||||
this.createNote = (parentNoteId, title, content = "", extraOptions= {}) => {
|
||||
extraOptions.parentNoteId = parentNoteId;
|
||||
extraOptions.title = title;
|
||||
|
||||
const parentNote = await repository.getNote(parentNoteId);
|
||||
const parentNote = repository.getNote(parentNoteId);
|
||||
|
||||
// code note type can be inherited, otherwise text is default
|
||||
extraOptions.type = parentNote.type === 'code' ? 'code' : 'text';
|
||||
@@ -303,19 +304,21 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
extraOptions.content = content;
|
||||
}
|
||||
|
||||
const {note, branch} = await noteService.createNewNote(extraOptions);
|
||||
return sql.transactional(() => {
|
||||
const {note, branch} = noteService.createNewNote(extraOptions);
|
||||
|
||||
for (const attr of extraOptions.attributes || []) {
|
||||
await attributeService.createAttribute({
|
||||
noteId: note.noteId,
|
||||
type: attr.type,
|
||||
name: attr.name,
|
||||
value: attr.value,
|
||||
isInheritable: !!attr.isInheritable
|
||||
});
|
||||
}
|
||||
for (const attr of extraOptions.attributes || []) {
|
||||
attributeService.createAttribute({
|
||||
noteId: note.noteId,
|
||||
type: attr.type,
|
||||
name: attr.name,
|
||||
value: attr.value,
|
||||
isInheritable: !!attr.isInheritable
|
||||
});
|
||||
}
|
||||
|
||||
return {note, branch};
|
||||
return {note, branch};
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -329,7 +332,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* Returns root note of the calendar.
|
||||
*
|
||||
* @method
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getRootCalendarNote = dateNoteService.getRootCalendarNote;
|
||||
|
||||
@@ -338,7 +341,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
*
|
||||
* @method
|
||||
* @param {string} date in YYYY-MM-DD format
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getDateNote = dateNoteService.getDateNote;
|
||||
|
||||
@@ -346,7 +349,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* Returns today's day note. If such note doesn't exist, it is created.
|
||||
*
|
||||
* @method
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getTodayNote = dateNoteService.getTodayNote;
|
||||
|
||||
@@ -356,7 +359,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
* @param {string} date in YYYY-MM-DD format
|
||||
* @param {object} options - "startOfTheWeek" - either "monday" (default) or "sunday"
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getWeekNote = dateNoteService.getWeekNote;
|
||||
|
||||
@@ -365,7 +368,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
*
|
||||
* @method
|
||||
* @param {string} date in YYYY-MM format
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getMonthNote = dateNoteService.getMonthNote;
|
||||
|
||||
@@ -374,14 +377,13 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
*
|
||||
* @method
|
||||
* @param {string} year in YYYY format
|
||||
* @returns {Promise<Note|null>}
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getYearNote = dateNoteService.getYearNote;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} parentNoteId - this note's child notes will be sorted
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
this.sortNotesAlphabetically = treeService.sortNotesAlphabetically;
|
||||
|
||||
@@ -403,12 +405,9 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* This functions wraps code which is supposed to be running in transaction. If transaction already
|
||||
* exists, then we'll use that transaction.
|
||||
*
|
||||
* This method is required only when script has label manualTransactionHandling, all other scripts are
|
||||
* transactional by default.
|
||||
*
|
||||
* @method
|
||||
* @param {function} func
|
||||
* @returns {Promise<?>} result of func callback
|
||||
* @returns {?} result of func callback
|
||||
*/
|
||||
this.transactional = sql.transactional;
|
||||
|
||||
@@ -443,7 +442,7 @@ module.exports = BackendScriptApi;
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line3">line 3</a>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line2">line 2</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -661,7 +661,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getParentNote"><span class="type-signature">(async) </span>getParentNote<span class="signature">()</span><span class="type-signature"> → {<a href="NoteShort.html">NoteShort</a>}</span></h4>
|
||||
<h4 class="name" id="getNoteFromCache"><span class="type-signature"></span>getNoteFromCache<span class="signature">()</span><span class="type-signature"> → {<a href="NoteShort.html">NoteShort</a>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="isTopLevel"><span class="type-signature"></span>isTopLevel<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
|
||||
<h4 class="name" id="getParentNote"><span class="type-signature">(async) </span>getParentNote<span class="signature">()</span><span class="type-signature"> → {<a href="NoteShort.html">NoteShort</a>}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -836,6 +836,108 @@
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type"><a href="NoteShort.html">NoteShort</a></span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="isTopLevel"><span class="type-signature"></span>isTopLevel<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line42">line 42</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
@@ -885,7 +987,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -1556,7 +1556,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line289">line 289</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line287">line 287</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1712,7 +1712,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line394">line 394</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line392">line 392</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1892,7 +1892,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line281">line 281</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line279">line 279</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2025,7 +2025,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line243">line 243</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line241">line 241</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2131,7 +2131,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line295">line 295</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line293">line 293</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2237,7 +2237,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line309">line 309</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line307">line 307</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2391,7 +2391,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line303">line 303</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line301">line 301</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2528,7 +2528,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line360">line 360</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line358">line 358</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2635,7 +2635,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line236">line 236</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line234">line 234</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2790,7 +2790,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line369">line 369</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line367">line 367</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -2946,7 +2946,7 @@ if some action needs to happen on only one specific instance.
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line208">line 208</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line206">line 206</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3147,7 +3147,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line220">line 220</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line218">line 218</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3253,7 +3253,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line351">line 351</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line349">line 349</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3408,7 +3408,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line378">line 378</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line376">line 376</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3559,7 +3559,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line250">line 250</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line248">line 248</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3667,7 +3667,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line321">line 321</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line319">line 319</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3823,7 +3823,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line332">line 332</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line330">line 330</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -3979,7 +3979,139 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line341">line 341</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line339">line 339</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="refreshIncludedNote"><span class="type-signature"></span>refreshIncludedNote<span class="signature">(includedNoteId)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
This will refresh all currently opened notes which have included note specified in the parameter
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>includedNoteId</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">noteId of the included note</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line410">line 410</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4065,7 +4197,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line272">line 272</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line270">line 270</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4202,7 +4334,7 @@ otherwise (by e.g. createNoteLink())
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line228">line 228</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line226">line 226</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4516,7 +4648,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<div class="description">
|
||||
This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4609,7 +4741,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line196">line 196</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line194">line 194</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -4672,7 +4804,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<div class="description">
|
||||
This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4920,7 +5052,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line387">line 387</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line385">line 385</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5071,7 +5203,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line315">line 315</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line313">line 313</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5208,7 +5340,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line266">line 266</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line264">line 264</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5345,7 +5477,7 @@ Internally this serializes the anonymous function into string and sends it to ba
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line258">line 258</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line256">line 256</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5437,7 +5569,7 @@ Typical use case is when new note has been created, we should wait until it is s
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line405">line 405</a>
|
||||
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line403">line 403</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -5489,7 +5621,7 @@ Typical use case is when new note has been created, we should wait until it is s
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line5">line 5</a>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line4">line 4</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -143,6 +143,122 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="combinedDateModified"><span class="type-signature"></span>combinedDateModified<span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line32">line 32</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="combinedUtcDateModified"><span class="type-signature"></span>combinedUtcDateModified<span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line35">line 35</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="content"><span class="type-signature"></span>content<span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
@@ -183,7 +299,65 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line10">line 10</a>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line12">line 12</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="contentLength"><span class="type-signature"></span>contentLength<span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line15">line 15</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -241,7 +415,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line13">line 13</a>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line18">line 18</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -299,7 +473,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line16">line 16</a>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line21">line 21</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -415,7 +589,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line19">line 19</a>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line24">line 24</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -473,7 +647,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line22">line 22</a>
|
||||
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line27">line 27</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -513,7 +687,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,9 @@
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>class Attribute {
|
||||
<pre class="prettyprint source linenums"><code>import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
|
||||
|
||||
class Attribute {
|
||||
constructor(treeCache, row) {
|
||||
this.treeCache = treeCache;
|
||||
|
||||
@@ -47,29 +49,75 @@
|
||||
/** @param {int} position */
|
||||
this.position = row.position;
|
||||
/** @param {boolean} isInheritable */
|
||||
this.isInheritable = row.isInheritable;
|
||||
this.isInheritable = !!row.isInheritable;
|
||||
}
|
||||
|
||||
/** @returns {NoteShort} */
|
||||
async getNote() {
|
||||
return await this.treeCache.getNote(this.noteId);
|
||||
getNote() {
|
||||
return this.treeCache.notes[this.noteId];
|
||||
}
|
||||
|
||||
get jsonValue() {
|
||||
try {
|
||||
return JSON.parse(this.value);
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
get targetNoteId() { // alias
|
||||
return this.type === 'relation' ? this.value : undefined;
|
||||
}
|
||||
|
||||
get isAutoLink() {
|
||||
return this.type === 'relation' && ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
|
||||
}
|
||||
|
||||
get toString() {
|
||||
return `Attribute(attributeId=${this.attributeId}, type=${this.type}, name=${this.name}, value=${this.value})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean} - returns true if this attribute has the potential to influence the note in the argument.
|
||||
* That can happen in multiple ways:
|
||||
* 1. attribute is owned by the note
|
||||
* 2. attribute is owned by the template of the note
|
||||
* 3. attribute is owned by some note's ancestor and is inheritable
|
||||
*/
|
||||
isAffecting(affectedNote) {
|
||||
if (!affectedNote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const attrNote = this.getNote();
|
||||
|
||||
if (!attrNote) {
|
||||
// the note (owner of the attribute) is not even loaded into the cache so it should not affect anything else
|
||||
return false;
|
||||
}
|
||||
|
||||
const owningNotes = [affectedNote, ...affectedNote.getTemplateNotes()];
|
||||
|
||||
for (const owningNote of owningNotes) {
|
||||
if (owningNote.noteId === attrNote.noteId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isInheritable) {
|
||||
for (const owningNote of owningNotes) {
|
||||
if (owningNote.hasAncestor(attrNote)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
isDefinition() {
|
||||
return this.type === 'label' && (this.name.startsWith('label:') || this.name.startsWith('relation:'));
|
||||
}
|
||||
|
||||
getDefinition() {
|
||||
return promotedAttributeDefinitionParser.parse(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export default Attribute;</code></pre>
|
||||
export default Attribute;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -85,7 +133,7 @@ export default Attribute;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -56,6 +56,11 @@ class Branch {
|
||||
return this.treeCache.getNote(this.noteId);
|
||||
}
|
||||
|
||||
/** @returns {NoteShort} */
|
||||
getNoteFromCache() {
|
||||
return this.treeCache.getNoteFromCache(this.noteId);
|
||||
}
|
||||
|
||||
/** @returns {NoteShort} */
|
||||
async getParentNote() {
|
||||
return this.treeCache.getNote(this.parentNoteId);
|
||||
@@ -87,7 +92,7 @@ export default Branch;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -34,9 +34,14 @@ class NoteComplement {
|
||||
/** @param {string} */
|
||||
this.noteId = row.noteId;
|
||||
|
||||
/** @param {string} */
|
||||
/**
|
||||
* @param {string} - can either contain the whole content (in e.g. string notes), only part (large text notes) or nothing at all (binary notes, images)
|
||||
*/
|
||||
this.content = row.content;
|
||||
|
||||
/** @param {int} */
|
||||
this.contentLength = row.contentLength;
|
||||
|
||||
/** @param {string} */
|
||||
this.dateCreated = row.dateCreated;
|
||||
|
||||
@@ -48,10 +53,19 @@ class NoteComplement {
|
||||
|
||||
/** @param {string} */
|
||||
this.utcDateModified = row.utcDateModified;
|
||||
|
||||
// "combined" date modified give larger out of note's and note_content's dateModified
|
||||
|
||||
/** @param {string} */
|
||||
this.combinedDateModified = row.combinedDateModified;
|
||||
|
||||
/** @param {string} */
|
||||
this.combinedUtcDateModified = row.combinedUtcDateModified;
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteComplement;</code></pre>
|
||||
export default NoteComplement;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -67,7 +81,7 @@ export default NoteComplement;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -28,13 +28,14 @@
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import server from '../services/server.js';
|
||||
import Attribute from './attribute.js';
|
||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||
|
||||
const LABEL = 'label';
|
||||
const LABEL_DEFINITION = 'label-definition';
|
||||
const RELATION = 'relation';
|
||||
const RELATION_DEFINITION = 'relation-definition';
|
||||
|
||||
/**
|
||||
* FIXME: since there's no "full note" anymore we can rename this to Note
|
||||
*
|
||||
* This note's representation is used in note tree and is kept in TreeCache.
|
||||
*/
|
||||
class NoteShort {
|
||||
@@ -70,8 +71,6 @@ class NoteShort {
|
||||
this.noteId = row.noteId;
|
||||
/** @param {string} */
|
||||
this.title = row.title;
|
||||
/** @param {int} */
|
||||
this.contentLength = row.contentLength;
|
||||
/** @param {boolean} */
|
||||
this.isProtected = !!row.isProtected;
|
||||
/** @param {string} one of 'text', 'code', 'file' or 'render' */
|
||||
@@ -83,6 +82,10 @@ class NoteShort {
|
||||
}
|
||||
|
||||
addParent(parentNoteId, branchId) {
|
||||
if (parentNoteId === 'none') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.parents.includes(parentNoteId)) {
|
||||
this.parents.push(parentNoteId);
|
||||
}
|
||||
@@ -97,6 +100,10 @@ class NoteShort {
|
||||
|
||||
this.childToBranch[childNoteId] = branchId;
|
||||
|
||||
this.sortChildren();
|
||||
}
|
||||
|
||||
sortChildren() {
|
||||
const branchIdPos = {};
|
||||
|
||||
for (const branchId of Object.values(this.childToBranch)) {
|
||||
@@ -184,9 +191,9 @@ class NoteShort {
|
||||
getOwnedAttributes(type, name) {
|
||||
const attrs = this.attributes
|
||||
.map(attributeId => this.treeCache.attributes[attributeId])
|
||||
.filter(attr => !!attr);
|
||||
.filter(Boolean); // filter out nulls;
|
||||
|
||||
return this.__filterAttrs(attrs, type, name)
|
||||
return this.__filterAttrs(attrs, type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,48 +202,66 @@ class NoteShort {
|
||||
* @returns {Attribute[]} all note's attributes, including inherited ones
|
||||
*/
|
||||
getAttributes(type, name) {
|
||||
const ownedAttributes = this.getOwnedAttributes();
|
||||
return this.__filterAttrs(this.__getCachedAttributes([]), type, name);
|
||||
}
|
||||
|
||||
const attrArrs = [
|
||||
ownedAttributes
|
||||
];
|
||||
|
||||
for (const templateAttr of ownedAttributes.filter(oa => oa.type === 'relation' && oa.name === 'template')) {
|
||||
const templateNote = this.treeCache.getNoteFromCache(templateAttr.value);
|
||||
|
||||
if (templateNote) {
|
||||
attrArrs.push(templateNote.getAttributes());
|
||||
}
|
||||
__getCachedAttributes(path) {
|
||||
// notes/clones cannot form tree cycles, it is possible to create attribute inheritance cycle via templates
|
||||
// when template instance is a parent of template itself
|
||||
if (path.includes(this.noteId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (this.noteId !== 'root') {
|
||||
for (const parentNote of this.getParentNotes()) {
|
||||
// these virtual parent-child relationships are also loaded into frontend tree cache
|
||||
if (parentNote.type !== 'search') {
|
||||
attrArrs.push(parentNote.getInheritableAttributes());
|
||||
if (!(this.noteId in noteAttributeCache.attributes)) {
|
||||
const newPath = [...path, this.noteId];
|
||||
const attrArrs = [ this.getOwnedAttributes() ];
|
||||
|
||||
if (this.noteId !== 'root') {
|
||||
for (const parentNote of this.getParentNotes()) {
|
||||
// these virtual parent-child relationships are also loaded into frontend tree cache
|
||||
if (parentNote.type !== 'search') {
|
||||
attrArrs.push(parentNote.__getInheritableAttributes(newPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && attr.name === 'template')) {
|
||||
const templateNote = this.treeCache.notes[templateAttr.value];
|
||||
|
||||
if (templateNote && templateNote.noteId !== this.noteId) {
|
||||
attrArrs.push(templateNote.__getCachedAttributes(newPath));
|
||||
}
|
||||
}
|
||||
|
||||
noteAttributeCache.attributes[this.noteId] = [];
|
||||
const addedAttributeIds = new Set();
|
||||
|
||||
for (const attr of attrArrs.flat()) {
|
||||
if (!addedAttributeIds.has(attr.attributeId)) {
|
||||
addedAttributeIds.add(attr.attributeId);
|
||||
|
||||
noteAttributeCache.attributes[this.noteId].push(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const attributes = attrArrs.flat();
|
||||
|
||||
return this.__filterAttrs(attributes, type, name);
|
||||
return noteAttributeCache.attributes[this.noteId];
|
||||
}
|
||||
|
||||
__filterAttrs(attributes, type, name) {
|
||||
if (type && name) {
|
||||
if (!type && !name) {
|
||||
return attributes;
|
||||
} else if (type && name) {
|
||||
return attributes.filter(attr => attr.type === type && attr.name === name);
|
||||
} else if (type) {
|
||||
return attributes.filter(attr => attr.type === type);
|
||||
} else if (name) {
|
||||
return attributes.filter(attr => attr.name === name);
|
||||
} else {
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
|
||||
getInheritableAttributes() {
|
||||
const attrs = this.getAttributes();
|
||||
__getInheritableAttributes(path) {
|
||||
const attrs = this.__getCachedAttributes(path);
|
||||
|
||||
return attrs.filter(attr => attr.isInheritable);
|
||||
}
|
||||
@@ -257,14 +282,6 @@ class NoteShort {
|
||||
return this.getAttributes(LABEL, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - label name to filter
|
||||
* @returns {Attribute[]} all note's label definitions, including inherited ones
|
||||
*/
|
||||
getLabelDefinitions(name) {
|
||||
return this.getAttributes(LABEL_DEFINITION, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
|
||||
@@ -281,14 +298,6 @@ class NoteShort {
|
||||
return this.getAttributes(RELATION, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Attribute[]} all note's relation definitions including inherited ones
|
||||
*/
|
||||
getRelationDefinitions(name) {
|
||||
return this.getAttributes(RELATION_DEFINITION, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type - attribute type (label, relation, etc.)
|
||||
* @param {string} name - attribute name
|
||||
@@ -326,7 +335,7 @@ class NoteShort {
|
||||
getAttribute(type, name) {
|
||||
const attributes = this.getAttributes(type, name);
|
||||
|
||||
return attributes.length > 0 ? attributes[0] : 0;
|
||||
return attributes.length > 0 ? attributes[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -448,6 +457,35 @@ class NoteShort {
|
||||
return targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {NoteShort[]}
|
||||
*/
|
||||
getTemplateNotes() {
|
||||
const relations = this.getRelations('template');
|
||||
|
||||
return relations.map(rel => this.treeCache.notes[rel.value]);
|
||||
}
|
||||
|
||||
hasAncestor(ancestorNote) {
|
||||
if (this.noteId === ancestorNote.noteId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const templateNote of this.getTemplateNotes()) {
|
||||
if (templateNote.hasAncestor(ancestorNote)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const parentNote of this.getParentNotes()) {
|
||||
if (parentNote.hasAncestor(ancestorNote)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear note's attributes cache to force fresh reload for next attribute request.
|
||||
* Cache is note instance scoped.
|
||||
@@ -466,6 +504,26 @@ class NoteShort {
|
||||
.map(attributeId => this.treeCache.attributes[attributeId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relations which target this note
|
||||
*
|
||||
* @returns {NoteShort[]}
|
||||
*/
|
||||
async getTargetRelationSourceNotes() {
|
||||
const targetRelations = this.getTargetRelations();
|
||||
|
||||
return await this.treeCache.getNotes(targetRelations.map(tr => tr.noteId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return note complement which is most importantly note's content
|
||||
*
|
||||
* @return {Promise<NoteComplement>}
|
||||
*/
|
||||
async getNoteComplement() {
|
||||
return await this.treeCache.getNoteComplement(this.noteId);
|
||||
}
|
||||
|
||||
get toString() {
|
||||
return `Note(noteId=${this.noteId}, title=${this.title})`;
|
||||
}
|
||||
@@ -483,7 +541,8 @@ class NoteShort {
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteShort;</code></pre>
|
||||
export default NoteShort;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -499,7 +558,7 @@ export default NoteShort;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -608,7 +608,7 @@ separately but should behave uniformly for the user.
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -95,7 +95,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
this.activateNewNote = async notePath => {
|
||||
await ws.waitForMaxKnownSyncId();
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
|
||||
await appContext.tabManager.getActiveTabContext().setNote(notePath);
|
||||
appContext.triggerEvent('focusAndSelectTitle');
|
||||
@@ -115,7 +115,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
* @param {ToolbarButtonOptions} opts
|
||||
*/
|
||||
this.addButtonToToolbar = opts => {
|
||||
const buttonId = "toolbar-button-" + opts.title.replace(/[^a-zA-Z0-9]/g, "-");
|
||||
const buttonId = "toolbar-button-" + opts.title.replace(/\s/g, "-");
|
||||
|
||||
const button = $('<button>')
|
||||
.addClass("btn btn-sm")
|
||||
@@ -180,7 +180,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
|
||||
if (ret.success) {
|
||||
// wait until all the changes done in the script has been synced to frontend before continuing
|
||||
await ws.waitForSyncId(ret.maxSyncId);
|
||||
await ws.waitForEntityChangeId(ret.maxEntityChangeId);
|
||||
|
||||
return ret.executionResult;
|
||||
}
|
||||
@@ -197,25 +197,23 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
|
||||
/**
|
||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
*
|
||||
* @method
|
||||
* @param {string} searchString
|
||||
* @returns {Promise<NoteShort[]>}
|
||||
*/
|
||||
this.searchForNotes = async searchString => {
|
||||
const noteIds = await this.runOnServer(async searchString => {
|
||||
const notes = await api.searchForNotes(searchString);
|
||||
|
||||
return notes.map(note => note.noteId);
|
||||
}, [searchString]);
|
||||
const noteIds = await this.runOnBackend(
|
||||
searchString => api.searchForNotes(searchString).map(note => note.noteId),
|
||||
[searchString]);
|
||||
|
||||
return await treeCache.getNotes(noteIds);
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
*
|
||||
* @method
|
||||
* @param {string} searchString
|
||||
@@ -430,10 +428,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
this.waitUntilSynced = ws.waitForMaxKnownSyncId;
|
||||
this.waitUntilSynced = ws.waitForMaxKnownEntityChangeId;
|
||||
|
||||
/**
|
||||
* This will refresh all currently opened notes which have included note specified in the parameter
|
||||
*
|
||||
* @param includedNoteId - noteId of the included note
|
||||
*/
|
||||
this.refreshIncludedNote = includedNoteId => appContext.triggerEvent('refreshIncludedNote', {noteId: includedNoteId});
|
||||
}
|
||||
|
||||
export default FrontendScriptApi;</code></pre>
|
||||
export default FrontendScriptApi;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -449,7 +455,7 @@ export default FrontendScriptApi;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -57,12 +57,14 @@ export default class CollapsibleWidget extends TabAwareWidget {
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(WIDGET_TPL);
|
||||
this.contentSized();
|
||||
this.$widget.find('[data-target]').attr('data-target', "#" + this.componentId);
|
||||
|
||||
this.$bodyWrapper = this.$widget.find('.body-wrapper');
|
||||
this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id
|
||||
|
||||
this.widgetName = this.constructor.name;
|
||||
// not using constructor name because of webpack mangling class names ...
|
||||
this.widgetName = this.widgetTitle.replace(/[^[a-zA-Z0-9]/g, "_");
|
||||
|
||||
if (!options.is(this.widgetName + 'Collapsed')) {
|
||||
this.$bodyWrapper.collapse("show");
|
||||
@@ -97,8 +99,6 @@ export default class CollapsibleWidget extends TabAwareWidget {
|
||||
this.initialized = this.doRenderBody();
|
||||
|
||||
this.decorateWidget();
|
||||
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
saveCollapsed(collapse) {
|
||||
@@ -126,7 +126,8 @@ export default class CollapsibleWidget extends TabAwareWidget {
|
||||
isExpanded() {
|
||||
return this.$bodyWrapper.hasClass("show");
|
||||
}
|
||||
}</code></pre>
|
||||
}
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -142,7 +143,7 @@ export default class CollapsibleWidget extends TabAwareWidget {
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
libraries/boxicons/css/boxicons.min.css
vendored
2
libraries/boxicons/css/boxicons.min.css
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 912 KiB After Width: | Height: | Size: 952 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,12 @@
|
||||
/* !!!!!! TRILIUM CUSTOM CHANGES !!!!!! */
|
||||
|
||||
.ck-widget__type-around { /* gets rid of triangles: https://github.com/zadam/trilium/issues/1129 */
|
||||
.printed-content .ck-widget__selection-handle, .printed-content .ck-widget__type-around { /* gets rid of triangles: https://github.com/zadam/trilium/issues/1129 */
|
||||
display: none;
|
||||
}
|
||||
|
||||
/*
|
||||
* CKEditor 5 (v22.0.0) content styles.
|
||||
* Generated on Thu, 27 Aug 2020 12:13:06 GMT.
|
||||
* CKEditor 5 (v23.1.0) content styles.
|
||||
* Generated on Thu, 29 Oct 2020 12:17:48 GMT.
|
||||
* For more information, check out https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/content-styles.html
|
||||
*/
|
||||
|
||||
@@ -23,32 +23,6 @@
|
||||
--ck-todo-list-checkmark-size: 16px;
|
||||
}
|
||||
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-yellow {
|
||||
background-color: var(--ck-highlight-marker-yellow);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-green {
|
||||
background-color: var(--ck-highlight-marker-green);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-pink {
|
||||
background-color: var(--ck-highlight-marker-pink);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-blue {
|
||||
background-color: var(--ck-highlight-marker-blue);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .pen-red {
|
||||
color: var(--ck-highlight-pen-red);
|
||||
background-color: transparent;
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .pen-green {
|
||||
color: var(--ck-highlight-pen-green);
|
||||
background-color: transparent;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagestyle.css */
|
||||
.ck-content .image-style-side {
|
||||
float: right;
|
||||
@@ -84,6 +58,17 @@
|
||||
max-width: 100%;
|
||||
min-width: 50px;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagecaption.css */
|
||||
.ck-content .image > figcaption {
|
||||
display: table-caption;
|
||||
caption-side: bottom;
|
||||
word-break: break-word;
|
||||
color: hsl(0, 0%, 20%);
|
||||
background-color: hsl(0, 0%, 97%);
|
||||
padding: .6em;
|
||||
font-size: .75em;
|
||||
outline-offset: -1px;
|
||||
}
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized {
|
||||
max-width: 100%;
|
||||
@@ -98,22 +83,31 @@
|
||||
.ck-content .image.image_resized > figcaption {
|
||||
display: block;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagecaption.css */
|
||||
.ck-content .image > figcaption {
|
||||
display: table-caption;
|
||||
caption-side: bottom;
|
||||
word-break: break-word;
|
||||
color: hsl(0, 0%, 20%);
|
||||
background-color: hsl(0, 0%, 97%);
|
||||
padding: .6em;
|
||||
font-size: .75em;
|
||||
outline-offset: -1px;
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-yellow {
|
||||
background-color: var(--ck-highlight-marker-yellow);
|
||||
}
|
||||
/* ckeditor5-basic-styles/theme/code.css */
|
||||
.ck-content code {
|
||||
background-color: hsla(0, 0%, 78%, 0.3);
|
||||
padding: .15em;
|
||||
border-radius: 2px;
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-green {
|
||||
background-color: var(--ck-highlight-marker-green);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-pink {
|
||||
background-color: var(--ck-highlight-marker-pink);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-blue {
|
||||
background-color: var(--ck-highlight-marker-blue);
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .pen-red {
|
||||
color: var(--ck-highlight-pen-red);
|
||||
background-color: transparent;
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .pen-green {
|
||||
color: var(--ck-highlight-pen-green);
|
||||
background-color: transparent;
|
||||
}
|
||||
/* ckeditor5-font/theme/fontsize.css */
|
||||
.ck-content .text-tiny {
|
||||
@@ -146,6 +140,12 @@
|
||||
border-left: 0;
|
||||
border-right: solid 5px hsl(0, 0%, 80%);
|
||||
}
|
||||
/* ckeditor5-basic-styles/theme/code.css */
|
||||
.ck-content code {
|
||||
background-color: hsla(0, 0%, 78%, 0.3);
|
||||
padding: .15em;
|
||||
border-radius: 2px;
|
||||
}
|
||||
/* ckeditor5-table/theme/table.css */
|
||||
.ck-content .table {
|
||||
margin: 1em auto;
|
||||
@@ -215,13 +215,6 @@
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
/* ckeditor5-media-embed/theme/mediaembed.css */
|
||||
.ck-content .media {
|
||||
clear: both;
|
||||
margin: 1em 0;
|
||||
display: block;
|
||||
min-width: 15em;
|
||||
}
|
||||
/* ckeditor5-list/theme/todolist.css */
|
||||
.ck-content .todo-list {
|
||||
list-style: none;
|
||||
@@ -289,6 +282,18 @@
|
||||
.ck-content .todo-list .todo-list__label .todo-list__label__description {
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* ckeditor5-media-embed/theme/mediaembed.css */
|
||||
.ck-content .media {
|
||||
clear: both;
|
||||
margin: 1em 0;
|
||||
display: block;
|
||||
min-width: 15em;
|
||||
}
|
||||
/* ckeditor5-html-embed/theme/htmlembed.css */
|
||||
.ck-content .raw-html-embed {
|
||||
margin: 1em auto;
|
||||
min-width: 15em;
|
||||
}
|
||||
/* ckeditor5-horizontal-line/theme/horizontalline.css */
|
||||
.ck-content hr {
|
||||
margin: 15px 0;
|
||||
@@ -330,4 +335,4 @@
|
||||
.ck-content .page-break::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
libraries/ckeditor/ckeditor.js
vendored
2
libraries/ckeditor/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
12
libraries/codemirror/addon/edit/matchbrackets.js
vendored
12
libraries/codemirror/addon/edit/matchbrackets.js
vendored
@@ -118,16 +118,24 @@
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.off("cursorActivity", doMatchBrackets);
|
||||
function clear(cm) {
|
||||
if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
|
||||
cm.state.matchBrackets.currentlyHighlighted();
|
||||
cm.state.matchBrackets.currentlyHighlighted = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.off("cursorActivity", doMatchBrackets);
|
||||
cm.off("focus", doMatchBrackets)
|
||||
cm.off("blur", clear)
|
||||
clear(cm);
|
||||
}
|
||||
if (val) {
|
||||
cm.state.matchBrackets = typeof val == "object" ? val : {};
|
||||
cm.on("cursorActivity", doMatchBrackets);
|
||||
cm.on("focus", doMatchBrackets)
|
||||
cm.on("blur", clear)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
29
libraries/codemirror/addon/lint/lint.js
vendored
29
libraries/codemirror/addon/lint/lint.js
vendored
@@ -12,11 +12,14 @@
|
||||
"use strict";
|
||||
var GUTTER_ID = "CodeMirror-lint-markers";
|
||||
|
||||
function showTooltip(e, content) {
|
||||
function showTooltip(cm, e, content) {
|
||||
var tt = document.createElement("div");
|
||||
tt.className = "CodeMirror-lint-tooltip";
|
||||
tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme;
|
||||
tt.appendChild(content.cloneNode(true));
|
||||
document.body.appendChild(tt);
|
||||
if (cm.state.lint.options.selfContain)
|
||||
cm.getWrapperElement().appendChild(tt);
|
||||
else
|
||||
document.body.appendChild(tt);
|
||||
|
||||
function position(e) {
|
||||
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
||||
@@ -38,8 +41,8 @@
|
||||
setTimeout(function() { rm(tt); }, 600);
|
||||
}
|
||||
|
||||
function showTooltipFor(e, content, node) {
|
||||
var tooltip = showTooltip(e, content);
|
||||
function showTooltipFor(cm, e, content, node) {
|
||||
var tooltip = showTooltip(cm, e, content);
|
||||
function hide() {
|
||||
CodeMirror.off(node, "mouseout", hide);
|
||||
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
|
||||
@@ -78,7 +81,7 @@
|
||||
state.marked.length = 0;
|
||||
}
|
||||
|
||||
function makeMarker(labels, severity, multiple, tooltips) {
|
||||
function makeMarker(cm, labels, severity, multiple, tooltips) {
|
||||
var marker = document.createElement("div"), inner = marker;
|
||||
marker.className = "CodeMirror-lint-marker-" + severity;
|
||||
if (multiple) {
|
||||
@@ -87,7 +90,7 @@
|
||||
}
|
||||
|
||||
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
||||
showTooltipFor(e, labels, inner);
|
||||
showTooltipFor(cm, e, labels, inner);
|
||||
});
|
||||
|
||||
return marker;
|
||||
@@ -113,9 +116,9 @@
|
||||
var tip = document.createElement("div");
|
||||
tip.className = "CodeMirror-lint-message-" + severity;
|
||||
if (typeof ann.messageHTML != 'undefined') {
|
||||
tip.innerHTML = ann.messageHTML;
|
||||
tip.innerHTML = ann.messageHTML;
|
||||
} else {
|
||||
tip.appendChild(document.createTextNode(ann.message));
|
||||
tip.appendChild(document.createTextNode(ann.message));
|
||||
}
|
||||
return tip;
|
||||
}
|
||||
@@ -186,7 +189,7 @@
|
||||
}
|
||||
|
||||
if (state.hasGutter)
|
||||
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
|
||||
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1,
|
||||
state.options.tooltips));
|
||||
}
|
||||
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
||||
@@ -199,14 +202,14 @@
|
||||
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
||||
}
|
||||
|
||||
function popupTooltips(annotations, e) {
|
||||
function popupTooltips(cm, annotations, e) {
|
||||
var target = e.target || e.srcElement;
|
||||
var tooltip = document.createDocumentFragment();
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var ann = annotations[i];
|
||||
tooltip.appendChild(annotationTooltip(ann));
|
||||
}
|
||||
showTooltipFor(e, tooltip, target);
|
||||
showTooltipFor(cm, e, tooltip, target);
|
||||
}
|
||||
|
||||
function onMouseOver(cm, e) {
|
||||
@@ -220,7 +223,7 @@
|
||||
var ann = spans[i].__annotation;
|
||||
if (ann) annotations.push(ann);
|
||||
}
|
||||
if (annotations.length) popupTooltips(annotations, e);
|
||||
if (annotations.length) popupTooltips(cm, annotations, e);
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
||||
|
||||
22
libraries/codemirror/addon/mode/loadmode.js
vendored
22
libraries/codemirror/addon/mode/loadmode.js
vendored
@@ -16,8 +16,8 @@
|
||||
var countDown = n;
|
||||
return function() { if (--countDown == 0) cont(); };
|
||||
}
|
||||
function ensureDeps(mode, cont) {
|
||||
var deps = CodeMirror.modes[mode].dependencies;
|
||||
function ensureDeps(mode, cont, options) {
|
||||
var modeObj = CodeMirror.modes[mode], deps = modeObj && modeObj.dependencies;
|
||||
if (!deps) return cont();
|
||||
var missing = [];
|
||||
for (var i = 0; i < deps.length; ++i) {
|
||||
@@ -27,16 +27,18 @@
|
||||
if (!missing.length) return cont();
|
||||
var split = splitCallback(cont, missing.length);
|
||||
for (var i = 0; i < missing.length; ++i)
|
||||
CodeMirror.requireMode(missing[i], split);
|
||||
CodeMirror.requireMode(missing[i], split, options);
|
||||
}
|
||||
|
||||
CodeMirror.requireMode = function(mode, cont) {
|
||||
CodeMirror.requireMode = function(mode, cont, options) {
|
||||
if (typeof mode != "string") mode = mode.name;
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont, options);
|
||||
if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
|
||||
|
||||
var file = CodeMirror.modeURL.replace(/%N/g, mode);
|
||||
if (env == "plain") {
|
||||
var file = options && options.path ? options.path(mode) : CodeMirror.modeURL.replace(/%N/g, mode);
|
||||
if (options && options.loadMode) {
|
||||
options.loadMode(file, function() { ensureDeps(mode, cont, options) })
|
||||
} else if (env == "plain") {
|
||||
var script = document.createElement("script");
|
||||
script.src = file;
|
||||
var others = document.getElementsByTagName("script")[0];
|
||||
@@ -44,7 +46,7 @@
|
||||
CodeMirror.on(script, "load", function() {
|
||||
ensureDeps(mode, function() {
|
||||
for (var i = 0; i < list.length; ++i) list[i]();
|
||||
});
|
||||
}, options);
|
||||
});
|
||||
others.parentNode.insertBefore(script, others);
|
||||
} else if (env == "cjs") {
|
||||
@@ -55,10 +57,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.autoLoadMode = function(instance, mode) {
|
||||
CodeMirror.autoLoadMode = function(instance, mode, options) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(mode))
|
||||
CodeMirror.requireMode(mode, function() {
|
||||
instance.setOption("mode", instance.getOption("mode"));
|
||||
});
|
||||
}, options);
|
||||
};
|
||||
});
|
||||
|
||||
216
libraries/codemirror/addon/mode/simple.js
vendored
Normal file
216
libraries/codemirror/addon/mode/simple.js
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
// 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.defineSimpleMode = function(name, states) {
|
||||
CodeMirror.defineMode(name, function(config) {
|
||||
return CodeMirror.simpleMode(config, states);
|
||||
});
|
||||
};
|
||||
|
||||
CodeMirror.simpleMode = function(config, states) {
|
||||
ensureState(states, "start");
|
||||
var states_ = {}, meta = states.meta || {}, hasIndentation = false;
|
||||
for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
|
||||
var list = states_[state] = [], orig = states[state];
|
||||
for (var i = 0; i < orig.length; i++) {
|
||||
var data = orig[i];
|
||||
list.push(new Rule(data, states));
|
||||
if (data.indent || data.dedent) hasIndentation = true;
|
||||
}
|
||||
}
|
||||
var mode = {
|
||||
startState: function() {
|
||||
return {state: "start", pending: null,
|
||||
local: null, localState: null,
|
||||
indent: hasIndentation ? [] : null};
|
||||
},
|
||||
copyState: function(state) {
|
||||
var s = {state: state.state, pending: state.pending,
|
||||
local: state.local, localState: null,
|
||||
indent: state.indent && state.indent.slice(0)};
|
||||
if (state.localState)
|
||||
s.localState = CodeMirror.copyState(state.local.mode, state.localState);
|
||||
if (state.stack)
|
||||
s.stack = state.stack.slice(0);
|
||||
for (var pers = state.persistentStates; pers; pers = pers.next)
|
||||
s.persistentStates = {mode: pers.mode,
|
||||
spec: pers.spec,
|
||||
state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state),
|
||||
next: s.persistentStates};
|
||||
return s;
|
||||
},
|
||||
token: tokenFunction(states_, config),
|
||||
innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; },
|
||||
indent: indentFunction(states_, meta)
|
||||
};
|
||||
if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop))
|
||||
mode[prop] = meta[prop];
|
||||
return mode;
|
||||
};
|
||||
|
||||
function ensureState(states, name) {
|
||||
if (!states.hasOwnProperty(name))
|
||||
throw new Error("Undefined state " + name + " in simple mode");
|
||||
}
|
||||
|
||||
function toRegex(val, caret) {
|
||||
if (!val) return /(?:)/;
|
||||
var flags = "";
|
||||
if (val instanceof RegExp) {
|
||||
if (val.ignoreCase) flags = "i";
|
||||
val = val.source;
|
||||
} else {
|
||||
val = String(val);
|
||||
}
|
||||
return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
|
||||
}
|
||||
|
||||
function asToken(val) {
|
||||
if (!val) return null;
|
||||
if (val.apply) return val
|
||||
if (typeof val == "string") return val.replace(/\./g, " ");
|
||||
var result = [];
|
||||
for (var i = 0; i < val.length; i++)
|
||||
result.push(val[i] && val[i].replace(/\./g, " "));
|
||||
return result;
|
||||
}
|
||||
|
||||
function Rule(data, states) {
|
||||
if (data.next || data.push) ensureState(states, data.next || data.push);
|
||||
this.regex = toRegex(data.regex);
|
||||
this.token = asToken(data.token);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
function tokenFunction(states, config) {
|
||||
return function(stream, state) {
|
||||
if (state.pending) {
|
||||
var pend = state.pending.shift();
|
||||
if (state.pending.length == 0) state.pending = null;
|
||||
stream.pos += pend.text.length;
|
||||
return pend.token;
|
||||
}
|
||||
|
||||
if (state.local) {
|
||||
if (state.local.end && stream.match(state.local.end)) {
|
||||
var tok = state.local.endToken || null;
|
||||
state.local = state.localState = null;
|
||||
return tok;
|
||||
} else {
|
||||
var tok = state.local.mode.token(stream, state.localState), m;
|
||||
if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
|
||||
stream.pos = stream.start + m.index;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
|
||||
var curState = states[state.state];
|
||||
for (var i = 0; i < curState.length; i++) {
|
||||
var rule = curState[i];
|
||||
var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
|
||||
if (matches) {
|
||||
if (rule.data.next) {
|
||||
state.state = rule.data.next;
|
||||
} else if (rule.data.push) {
|
||||
(state.stack || (state.stack = [])).push(state.state);
|
||||
state.state = rule.data.push;
|
||||
} else if (rule.data.pop && state.stack && state.stack.length) {
|
||||
state.state = state.stack.pop();
|
||||
}
|
||||
|
||||
if (rule.data.mode)
|
||||
enterLocalMode(config, state, rule.data.mode, rule.token);
|
||||
if (rule.data.indent)
|
||||
state.indent.push(stream.indentation() + config.indentUnit);
|
||||
if (rule.data.dedent)
|
||||
state.indent.pop();
|
||||
var token = rule.token
|
||||
if (token && token.apply) token = token(matches)
|
||||
if (matches.length > 2 && rule.token && typeof rule.token != "string") {
|
||||
state.pending = [];
|
||||
for (var j = 2; j < matches.length; j++)
|
||||
if (matches[j])
|
||||
state.pending.push({text: matches[j], token: rule.token[j - 1]});
|
||||
stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
|
||||
return token[0];
|
||||
} else if (token && token.join) {
|
||||
return token[0];
|
||||
} else {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
function cmp(a, b) {
|
||||
if (a === b) return true;
|
||||
if (!a || typeof a != "object" || !b || typeof b != "object") return false;
|
||||
var props = 0;
|
||||
for (var prop in a) if (a.hasOwnProperty(prop)) {
|
||||
if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false;
|
||||
props++;
|
||||
}
|
||||
for (var prop in b) if (b.hasOwnProperty(prop)) props--;
|
||||
return props == 0;
|
||||
}
|
||||
|
||||
function enterLocalMode(config, state, spec, token) {
|
||||
var pers;
|
||||
if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next)
|
||||
if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
|
||||
var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
|
||||
var lState = pers ? pers.state : CodeMirror.startState(mode);
|
||||
if (spec.persistent && !pers)
|
||||
state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates};
|
||||
|
||||
state.localState = lState;
|
||||
state.local = {mode: mode,
|
||||
end: spec.end && toRegex(spec.end),
|
||||
endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
|
||||
endToken: token && token.join ? token[token.length - 1] : token};
|
||||
}
|
||||
|
||||
function indexOf(val, arr) {
|
||||
for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;
|
||||
}
|
||||
|
||||
function indentFunction(states, meta) {
|
||||
return function(state, textAfter, line) {
|
||||
if (state.local && state.local.mode.indent)
|
||||
return state.local.mode.indent(state.localState, textAfter, line);
|
||||
if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
|
||||
return CodeMirror.Pass;
|
||||
|
||||
var pos = state.indent.length - 1, rules = states[state.state];
|
||||
scan: for (;;) {
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
var rule = rules[i];
|
||||
if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
|
||||
var m = rule.regex.exec(textAfter);
|
||||
if (m && m[0]) {
|
||||
pos--;
|
||||
if (rule.next || rule.push) rules = states[rule.next || rule.push];
|
||||
textAfter = textAfter.slice(m[0].length);
|
||||
continue scan;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return pos < 0 ? 0 : state.indent[pos];
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -90,7 +90,9 @@
|
||||
var state = cm.state.matchHighlighter;
|
||||
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
|
||||
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
|
||||
var searchFor = hasBoundary ? new RegExp("\\b" + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + "\\b") : query;
|
||||
var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") +
|
||||
query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") +
|
||||
(/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query;
|
||||
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
|
||||
{className: "CodeMirror-selection-highlight-scrollbar"});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.CodeMirror {
|
||||
/* Set height, width, borders, and global font properties here */
|
||||
font-family: monospace;
|
||||
height: auto;
|
||||
height: 300px;
|
||||
color: black;
|
||||
direction: ltr;
|
||||
}
|
||||
@@ -164,17 +164,17 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
|
||||
.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 */
|
||||
/* 50px 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;
|
||||
margin-bottom: -50px; margin-right: -50px;
|
||||
padding-bottom: 50px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
border-right: 30px solid transparent;
|
||||
border-right: 50px solid transparent;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
@@ -212,7 +212,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin-bottom: -30px;
|
||||
margin-bottom: -50px;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
position: absolute;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
72
libraries/codemirror/mode/apl/index.html
vendored
72
libraries/codemirror/mode/apl/index.html
vendored
@@ -1,72 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: APL 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="./apl.js"></script>
|
||||
<style>
|
||||
.CodeMirror { border: 2px inset #dee; }
|
||||
</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="#">APL</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>APL mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
⍝ Conway's game of life
|
||||
|
||||
⍝ This example was inspired by the impressive demo at
|
||||
⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
|
||||
|
||||
⍝ Create a matrix:
|
||||
⍝ 0 1 1
|
||||
⍝ 1 1 0
|
||||
⍝ 0 1 0
|
||||
creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
|
||||
creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
|
||||
|
||||
⍝ Place the creature on a larger board, near the centre
|
||||
board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
|
||||
|
||||
⍝ A function to move from one generation to the next
|
||||
life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
|
||||
|
||||
⍝ Compute n-th generation and format it as a
|
||||
⍝ character matrix
|
||||
gen ← {' #'[(life ⍣ ⍵) board]}
|
||||
|
||||
⍝ Show first three generations
|
||||
(gen 1) (gen 2) (gen 3)
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/apl"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle APL as well as it can.</p>
|
||||
<p>It attempts to label functions/operators based upon
|
||||
monadic/dyadic usage (but this is far from fully fleshed out).
|
||||
This means there are meaningful classnames so hover states can
|
||||
have popups etc.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
|
||||
</article>
|
||||
46
libraries/codemirror/mode/asciiarmor/index.html
vendored
46
libraries/codemirror/mode/asciiarmor/index.html
vendored
@@ -1,46 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: ASCII Armor (PGP) 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="asciiarmor.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="#">ASCII Armor</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>ASCII Armor (PGP) mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
-----BEGIN PGP MESSAGE-----
|
||||
Version: OpenPrivacy 0.99
|
||||
|
||||
yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
|
||||
vBSFjNSiVHsuAA==
|
||||
=njUN
|
||||
-----END PGP MESSAGE-----
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types
|
||||
defined:</strong> <code>application/pgp</code>, <code>application/pgp-encrypted</code>, <code>application/pgp-keys</code>, <code>application/pgp-signature</code></p>
|
||||
|
||||
</article>
|
||||
78
libraries/codemirror/mode/asn.1/index.html
vendored
78
libraries/codemirror/mode/asn.1/index.html
vendored
@@ -1,78 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: ASN.1 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="asn.1.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="http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One">ASN.1</a>
|
||||
</ul>
|
||||
</div>
|
||||
<article>
|
||||
<h2>ASN.1 example</h2>
|
||||
<div>
|
||||
<textarea id="ttcn-asn-code">
|
||||
--
|
||||
-- Sample ASN.1 Code
|
||||
--
|
||||
MyModule DEFINITIONS ::=
|
||||
BEGIN
|
||||
|
||||
MyTypes ::= SEQUENCE {
|
||||
myObjectId OBJECT IDENTIFIER,
|
||||
mySeqOf SEQUENCE OF MyInt,
|
||||
myBitString BIT STRING {
|
||||
muxToken(0),
|
||||
modemToken(1)
|
||||
}
|
||||
}
|
||||
|
||||
MyInt ::= INTEGER (0..65535)
|
||||
|
||||
END
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var ttcnEditor = CodeMirror.fromTextArea(document.getElementById("ttcn-asn-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-ttcn-asn"
|
||||
});
|
||||
ttcnEditor.setSize(400, 400);
|
||||
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
|
||||
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
|
||||
</script>
|
||||
<br/>
|
||||
<p><strong>Language:</strong> Abstract Syntax Notation One
|
||||
(<a href="http://www.itu.int/en/ITU-T/asn1/Pages/introduction.aspx">ASN.1</a>)
|
||||
</p>
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-ttcn-asn</code></p>
|
||||
|
||||
<br/>
|
||||
<p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson
|
||||
</a>.</p>
|
||||
<p>Coded by Asmelash Tsegay Gebretsadkan </p>
|
||||
</article>
|
||||
|
||||
155
libraries/codemirror/mode/asterisk/index.html
vendored
155
libraries/codemirror/mode/asterisk/index.html
vendored
@@ -1,155 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Asterisk dialplan 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="asterisk.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border: 1px solid #999;}
|
||||
.cm-s-default span.cm-arrow { color: red; }
|
||||
</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="#">Asterisk dialplan</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Asterisk dialplan mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
; extensions.conf - the Asterisk dial plan
|
||||
;
|
||||
|
||||
[general]
|
||||
;
|
||||
; If static is set to no, or omitted, then the pbx_config will rewrite
|
||||
; this file when extensions are modified. Remember that all comments
|
||||
; made in the file will be lost when that happens.
|
||||
static=yes
|
||||
|
||||
#include "/etc/asterisk/additional_general.conf
|
||||
|
||||
[iaxprovider]
|
||||
switch => IAX2/user:[key]@myserver/mycontext
|
||||
|
||||
[dynamic]
|
||||
#exec /usr/bin/dynamic-peers.pl
|
||||
|
||||
[trunkint]
|
||||
;
|
||||
; International long distance through trunk
|
||||
;
|
||||
exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
|
||||
exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
|
||||
|
||||
[local]
|
||||
;
|
||||
; Master context for local, toll-free, and iaxtel calls only
|
||||
;
|
||||
ignorepat => 9
|
||||
include => default
|
||||
|
||||
[demo]
|
||||
include => stdexten
|
||||
;
|
||||
; We start with what to do when a call first comes in.
|
||||
;
|
||||
exten => s,1,Wait(1) ; Wait a second, just for fun
|
||||
same => n,Answer ; Answer the line
|
||||
same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
|
||||
same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
|
||||
same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
|
||||
same => n(instruct),BackGround(demo-instruct) ; Play some instructions
|
||||
same => n,WaitExten ; Wait for an extension to be dialed.
|
||||
|
||||
exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
|
||||
exten => 2,n,Goto(s,instruct)
|
||||
|
||||
exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
|
||||
exten => 3,n,Goto(s,restart) ; Start with the congratulations
|
||||
|
||||
exten => 1000,1,Goto(default,s,1)
|
||||
;
|
||||
; We also create an example user, 1234, who is on the console and has
|
||||
; voicemail, etc.
|
||||
;
|
||||
exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
|
||||
; (but skip if channel is not up)
|
||||
exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
|
||||
exten => 1234,n,Goto(default,s,1) ; exited Voicemail
|
||||
|
||||
exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
|
||||
|
||||
exten => 1236,1,Dial(Console/dsp) ; Ring forever
|
||||
exten => 1236,n,Voicemail(1234,b) ; Unless busy
|
||||
|
||||
;
|
||||
; # for when they're done with the demo
|
||||
;
|
||||
exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
|
||||
exten => #,n,Hangup ; Hang them up.
|
||||
|
||||
;
|
||||
; A timeout and "invalid extension rule"
|
||||
;
|
||||
exten => t,1,Goto(#,1) ; If they take too long, give up
|
||||
exten => i,1,Playback(invalid) ; "That's not valid, try again"
|
||||
|
||||
;
|
||||
; Create an extension, 500, for dialing the
|
||||
; Asterisk demo.
|
||||
;
|
||||
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
|
||||
exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
|
||||
exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
|
||||
exten => 500,n,Goto(s,6) ; Return to the start over message.
|
||||
|
||||
;
|
||||
; Create an extension, 600, for evaluating echo latency.
|
||||
;
|
||||
exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
|
||||
exten => 600,n,Echo ; Do the echo test
|
||||
exten => 600,n,Playback(demo-echodone) ; Let them know it's over
|
||||
exten => 600,n,Goto(s,6) ; Start over
|
||||
|
||||
;
|
||||
; You can use the Macro Page to intercom a individual user
|
||||
exten => 76245,1,Macro(page,SIP/Grandstream1)
|
||||
; or if your peernames are the same as extensions
|
||||
exten => _7XXX,1,Macro(page,SIP/${EXTEN})
|
||||
;
|
||||
;
|
||||
; System Wide Page at extension 7999
|
||||
;
|
||||
exten => 7999,1,Set(TIMEOUT(absolute)=60)
|
||||
exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
|
||||
|
||||
; Give voicemail at extension 8500
|
||||
;
|
||||
exten => 8500,1,VoicemailMain
|
||||
exten => 8500,n,Goto(s,6)
|
||||
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-asterisk",
|
||||
matchBrackets: true,
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
|
||||
|
||||
</article>
|
||||
85
libraries/codemirror/mode/brainfuck/index.html
vendored
85
libraries/codemirror/mode/brainfuck/index.html
vendored
@@ -1,85 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Brainfuck 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="./brainfuck.js"></script>
|
||||
<style>
|
||||
.CodeMirror { border: 2px inset #dee; }
|
||||
</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="#"></a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Brainfuck mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
[ This program prints "Hello World!" and a newline to the screen, its
|
||||
length is 106 active command characters [it is not the shortest.]
|
||||
|
||||
This loop is a "comment loop", it's a simple way of adding a comment
|
||||
to a BF program such that you don't have to worry about any command
|
||||
characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
|
||||
ignored, the "[" and "]" characters just have to be balanced.
|
||||
]
|
||||
+++++ +++ Set Cell #0 to 8
|
||||
[
|
||||
>++++ Add 4 to Cell #1; this will always set Cell #1 to 4
|
||||
[ as the cell will be cleared by the loop
|
||||
>++ Add 2 to Cell #2
|
||||
>+++ Add 3 to Cell #3
|
||||
>+++ Add 3 to Cell #4
|
||||
>+ Add 1 to Cell #5
|
||||
<<<<- Decrement the loop counter in Cell #1
|
||||
] Loop till Cell #1 is zero; number of iterations is 4
|
||||
>+ Add 1 to Cell #2
|
||||
>+ Add 1 to Cell #3
|
||||
>- Subtract 1 from Cell #4
|
||||
>>+ Add 1 to Cell #6
|
||||
[<] Move back to the first zero cell you find; this will
|
||||
be Cell #1 which was cleared by the previous loop
|
||||
<- Decrement the loop Counter in Cell #0
|
||||
] Loop till Cell #0 is zero; number of iterations is 8
|
||||
|
||||
The result of this is:
|
||||
Cell No : 0 1 2 3 4 5 6
|
||||
Contents: 0 0 72 104 88 32 8
|
||||
Pointer : ^
|
||||
|
||||
>>. Cell #2 has value 72 which is 'H'
|
||||
>---. Subtract 3 from Cell #3 to get 101 which is 'e'
|
||||
+++++++..+++. Likewise for 'llo' from Cell #3
|
||||
>>. Cell #5 is 32 for the space
|
||||
<-. Subtract 1 from Cell #4 for 87 to give a 'W'
|
||||
<. Cell #3 was set to 'o' from the end of 'Hello'
|
||||
+++.------.--------. Cell #3 for 'rl' and 'd'
|
||||
>>+. Add 1 to Cell #5 gives us an exclamation point
|
||||
>++. And finally a newline from Cell #6
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-brainfuck"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>A mode for Brainfuck</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-brainfuck</code></p>
|
||||
</article>
|
||||
85
libraries/codemirror/mode/clike/clike.js
vendored
85
libraries/codemirror/mode/clike/clike.js
vendored
@@ -270,6 +270,25 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
"static else struct switch extern typedef union for goto while enum const " +
|
||||
"volatile inline restrict asm fortran";
|
||||
|
||||
// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
|
||||
var cppKeywords = "alignas alignof and and_eq audit axiom bitand bitor catch " +
|
||||
"class compl concept constexpr const_cast decltype delete dynamic_cast " +
|
||||
"explicit export final friend import module mutable namespace new noexcept " +
|
||||
"not not_eq operator or or_eq override private protected public " +
|
||||
"reinterpret_cast requires static_assert static_cast template this " +
|
||||
"thread_local throw try typeid typename using virtual xor xor_eq";
|
||||
|
||||
var objCKeywords = "bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
|
||||
"readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
|
||||
"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
|
||||
"@public @package @private @protected @required @optional @try @catch @finally @import " +
|
||||
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available";
|
||||
|
||||
var objCBuiltins = "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION " +
|
||||
" NS_RETURNS_RETAINEDNS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER " +
|
||||
"NS_DESIGNATED_INITIALIZER NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION " +
|
||||
"NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"
|
||||
|
||||
// Do not use this. Use the cTypes function below. This is global just to avoid
|
||||
// excessive calls when cTypes is being called multiple times during a parse.
|
||||
var basicCTypes = words("int long char short double float unsigned signed " +
|
||||
@@ -420,13 +439,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
|
||||
def(["text/x-c++src", "text/x-c++hdr"], {
|
||||
name: "clike",
|
||||
// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
|
||||
keywords: words(cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " +
|
||||
"class compl concept constexpr const_cast decltype delete dynamic_cast " +
|
||||
"explicit export final friend import module mutable namespace new noexcept " +
|
||||
"not not_eq operator or or_eq override private protected public " +
|
||||
"reinterpret_cast requires static_assert static_cast template this " +
|
||||
"thread_local throw try typeid typename using virtual xor xor_eq"),
|
||||
keywords: words(cKeywords + " " + cppKeywords),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords + " class try catch"),
|
||||
defKeywords: words(cDefKeywords + " class namespace"),
|
||||
@@ -676,11 +689,16 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
state.tokenize = tokenKotlinString(stream.match('""'));
|
||||
return state.tokenize(stream, state);
|
||||
},
|
||||
"/": function(stream, state) {
|
||||
if (!stream.eat("*")) return false;
|
||||
state.tokenize = tokenNestedComment(1);
|
||||
return state.tokenize(stream, state)
|
||||
},
|
||||
indent: function(state, ctx, textAfter, indentUnit) {
|
||||
var firstChar = textAfter && textAfter.charAt(0);
|
||||
if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "")
|
||||
return state.indented;
|
||||
if (state.prevToken == "operator" && textAfter != "}" ||
|
||||
if ((state.prevToken == "operator" && textAfter != "}" && state.context.type != "}") ||
|
||||
state.prevToken == "variable" && firstChar == "." ||
|
||||
(state.prevToken == "}" || state.prevToken == ")") && firstChar == ".")
|
||||
return indentUnit * 2 + ctx.indented;
|
||||
@@ -764,16 +782,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
|
||||
def("text/x-objectivec", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
|
||||
"readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
|
||||
"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
|
||||
"@public @package @private @protected @required @optional @try @catch @finally @import " +
|
||||
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available"),
|
||||
keywords: words(cKeywords + " " + objCKeywords),
|
||||
types: objCTypes,
|
||||
builtin: words("FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
|
||||
"NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
|
||||
"NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
|
||||
"NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"),
|
||||
builtin: words(objCBuiltins),
|
||||
blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),
|
||||
defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),
|
||||
dontIndentStatements: /^@.*$/,
|
||||
@@ -787,6 +798,46 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def("text/x-objectivec++", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " " + objCKeywords + " " + cppKeywords),
|
||||
types: objCTypes,
|
||||
builtin: words(objCBuiltins),
|
||||
blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized class try catch"),
|
||||
defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class class namespace"),
|
||||
dontIndentStatements: /^@.*$|^template$/,
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("YES NO NULL Nil nil true false nullptr"),
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
"u": cpp11StringHook,
|
||||
"U": cpp11StringHook,
|
||||
"L": cpp11StringHook,
|
||||
"R": cpp11StringHook,
|
||||
"0": cpp14Literal,
|
||||
"1": cpp14Literal,
|
||||
"2": cpp14Literal,
|
||||
"3": cpp14Literal,
|
||||
"4": cpp14Literal,
|
||||
"5": cpp14Literal,
|
||||
"6": cpp14Literal,
|
||||
"7": cpp14Literal,
|
||||
"8": cpp14Literal,
|
||||
"9": cpp14Literal,
|
||||
token: function(stream, state, style) {
|
||||
if (style == "variable" && stream.peek() == "(" &&
|
||||
(state.prevToken == ";" || state.prevToken == null ||
|
||||
state.prevToken == "}") &&
|
||||
cppLooksLikeConstructor(stream.current()))
|
||||
return "def";
|
||||
}
|
||||
},
|
||||
namespaceSeparator: "::",
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def("text/x-squirrel", {
|
||||
name: "clike",
|
||||
keywords: words("base break clone continue const default delete enum extends function in class" +
|
||||
|
||||
380
libraries/codemirror/mode/clike/index.html
vendored
380
libraries/codemirror/mode/clike/index.html
vendored
@@ -1,380 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: C-like 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>
|
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
||||
<script src="../../addon/hint/show-hint.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</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="#">C-like</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>C-like mode</h2>
|
||||
|
||||
<div><textarea id="c-code">
|
||||
/* C demo code */
|
||||
|
||||
#include <zmq.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
|
||||
typedef struct {
|
||||
void* arg_socket;
|
||||
zmq_msg_t* arg_msg;
|
||||
char* arg_string;
|
||||
unsigned long arg_len;
|
||||
int arg_int, arg_command;
|
||||
|
||||
int signal_fd;
|
||||
int pad;
|
||||
void* context;
|
||||
sem_t sem;
|
||||
} acl_zmq_context;
|
||||
|
||||
#define p(X) (context->arg_##X)
|
||||
|
||||
void* zmq_thread(void* context_pointer) {
|
||||
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
||||
char ok = 'K', err = 'X';
|
||||
int res;
|
||||
|
||||
while (1) {
|
||||
while ((res = sem_wait(&context->sem)) == EINTR);
|
||||
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
||||
switch(p(command)) {
|
||||
case 0: goto cleanup;
|
||||
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
||||
case 2: p(int) = zmq_close(p(socket)); break;
|
||||
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
||||
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
||||
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
||||
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
||||
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
||||
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
||||
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
||||
}
|
||||
p(command) = errno;
|
||||
write(context->signal_fd, &ok, 1);
|
||||
}
|
||||
cleanup:
|
||||
close(context->signal_fd);
|
||||
free(context_pointer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
||||
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
||||
pthread_t thread;
|
||||
|
||||
context->context = zmq_context;
|
||||
context->signal_fd = signal_fd;
|
||||
sem_init(&context->sem, 1, 0);
|
||||
pthread_create(&thread, 0, &zmq_thread, context);
|
||||
pthread_detach(thread);
|
||||
return context;
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>C++ example</h2>
|
||||
|
||||
<div><textarea id="cpp-code">
|
||||
#include <iostream>
|
||||
#include "mystuff/util.h"
|
||||
|
||||
namespace {
|
||||
enum Enum {
|
||||
VAL1, VAL2, VAL3
|
||||
};
|
||||
|
||||
char32_t unicode_string = U"\U0010FFFF";
|
||||
string raw_string = R"delim(anything
|
||||
you
|
||||
want)delim";
|
||||
|
||||
int Helper(const MyType& param) {
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class ForwardDec;
|
||||
|
||||
template <class T, class V>
|
||||
class Class : public BaseClass {
|
||||
const MyType<T, V> member_;
|
||||
|
||||
public:
|
||||
const MyType<T, V>& Method() const {
|
||||
return member_;
|
||||
}
|
||||
|
||||
void Method2(MyType<T, V>* value);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
void Class::Method2(MyType<T, V>* value) {
|
||||
std::out << 1 >> method();
|
||||
value->Method3(member_);
|
||||
member_ = value;
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>Objective-C example</h2>
|
||||
|
||||
<div><textarea id="objectivec-code">
|
||||
/*
|
||||
This is a longer comment
|
||||
That spans two lines
|
||||
*/
|
||||
|
||||
#import "MyClass.h"
|
||||
#import <AFramework/AFrameork.h>
|
||||
@import BFrameworkModule;
|
||||
|
||||
NS_ENUM(SomeValues) {
|
||||
aValue = 1;
|
||||
};
|
||||
|
||||
// A Class Extension with some properties
|
||||
@interface MyClass ()<AProtocol>
|
||||
@property(atomic, readwrite, assign) NSInteger anInt;
|
||||
@property(nonatomic, strong, nullable) NSString *aString;
|
||||
@end
|
||||
|
||||
@implementation YourAppDelegate
|
||||
|
||||
- (instancetype)initWithString:(NSString *)aStringVar {
|
||||
if ((self = [super init])) {
|
||||
aString = aStringVar;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)doSomething:(float)progress {
|
||||
NSString *myString = @"This is a ObjC string %f ";
|
||||
myString = [[NSString stringWithFormat:myString, progress] stringByAppendingString:self.aString];
|
||||
return myString.length > 100 ? NO : YES;
|
||||
}
|
||||
|
||||
@end
|
||||
</textarea></div>
|
||||
|
||||
<h2>Java example</h2>
|
||||
|
||||
<div><textarea id="java-code">
|
||||
import com.demo.util.MyType;
|
||||
import com.demo.util.MyInterface;
|
||||
|
||||
public enum Enum {
|
||||
VAL1, VAL2, VAL3
|
||||
}
|
||||
|
||||
public class Class<T, V> implements MyInterface {
|
||||
public static final MyType<T, V> member;
|
||||
|
||||
private class InnerClass {
|
||||
public int zero() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyType method() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void method2(MyType<T, V> value) {
|
||||
method();
|
||||
value.method3();
|
||||
member = value;
|
||||
}
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>Scala example</h2>
|
||||
|
||||
<div><textarea id="scala-code">
|
||||
object FilterTest extends App {
|
||||
def filter(xs: List[Int], threshold: Int) = {
|
||||
def process(ys: List[Int]): List[Int] =
|
||||
if (ys.isEmpty) ys
|
||||
else if (ys.head < threshold) ys.head :: process(ys.tail)
|
||||
else process(ys.tail)
|
||||
process(xs)
|
||||
}
|
||||
println(filter(List(1, 9, 2, 8, 3, 7, 4), 5))
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>Kotlin mode</h2>
|
||||
|
||||
<div><textarea id="kotlin-code">
|
||||
package org.wasabi.http
|
||||
|
||||
import java.util.concurrent.Executors
|
||||
import java.net.InetSocketAddress
|
||||
import org.wasabi.app.AppConfiguration
|
||||
import io.netty.bootstrap.ServerBootstrap
|
||||
import io.netty.channel.nio.NioEventLoopGroup
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel
|
||||
import org.wasabi.app.AppServer
|
||||
|
||||
public class HttpServer(private val appServer: AppServer) {
|
||||
|
||||
val bootstrap: ServerBootstrap
|
||||
val primaryGroup: NioEventLoopGroup
|
||||
val workerGroup: NioEventLoopGroup
|
||||
|
||||
init {
|
||||
// Define worker groups
|
||||
primaryGroup = NioEventLoopGroup()
|
||||
workerGroup = NioEventLoopGroup()
|
||||
|
||||
// Initialize bootstrap of server
|
||||
bootstrap = ServerBootstrap()
|
||||
|
||||
bootstrap.group(primaryGroup, workerGroup)
|
||||
bootstrap.channel(javaClass<NioServerSocketChannel>())
|
||||
bootstrap.childHandler(NettyPipelineInitializer(appServer))
|
||||
}
|
||||
|
||||
public fun start(wait: Boolean = true) {
|
||||
val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
|
||||
|
||||
if (wait) {
|
||||
channel?.closeFuture()?.sync()
|
||||
}
|
||||
}
|
||||
|
||||
public fun stop() {
|
||||
// Shutdown all event loops
|
||||
primaryGroup.shutdownGracefully()
|
||||
workerGroup.shutdownGracefully()
|
||||
|
||||
// Wait till all threads are terminated
|
||||
primaryGroup.terminationFuture().sync()
|
||||
workerGroup.terminationFuture().sync()
|
||||
}
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>Ceylon mode</h2>
|
||||
|
||||
<div><textarea id="ceylon-code">
|
||||
"Produces the [[stream|Iterable]] that results from repeated
|
||||
application of the given [[function|next]] to the given
|
||||
[[first]] element of the stream, until the function first
|
||||
returns [[finished]]. If the given function never returns
|
||||
`finished`, the resulting stream is infinite.
|
||||
|
||||
For example:
|
||||
|
||||
loop(0)(2.plus).takeWhile(10.largerThan)
|
||||
|
||||
produces the stream `{ 0, 2, 4, 6, 8 }`."
|
||||
tagged("Streams")
|
||||
shared {Element+} loop<Element>(
|
||||
"The first element of the resulting stream."
|
||||
Element first)(
|
||||
"The function that produces the next element of the
|
||||
stream, given the current element. The function may
|
||||
return [[finished]] to indicate the end of the
|
||||
stream."
|
||||
Element|Finished next(Element element))
|
||||
=> let (start = first)
|
||||
object satisfies {Element+} {
|
||||
first => start;
|
||||
empty => false;
|
||||
function nextElement(Element element)
|
||||
=> next(element);
|
||||
iterator()
|
||||
=> object satisfies Iterator<Element> {
|
||||
variable Element|Finished current = start;
|
||||
shared actual Element|Finished next() {
|
||||
if (!is Finished result = current) {
|
||||
current = nextElement(result);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return finished;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-csrc"
|
||||
});
|
||||
var cppEditor = CodeMirror.fromTextArea(document.getElementById("cpp-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-c++src"
|
||||
});
|
||||
var javaEditor = CodeMirror.fromTextArea(document.getElementById("java-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-java"
|
||||
});
|
||||
var objectivecEditor = CodeMirror.fromTextArea(document.getElementById("objectivec-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-objectivec"
|
||||
});
|
||||
var scalaEditor = CodeMirror.fromTextArea(document.getElementById("scala-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-scala"
|
||||
});
|
||||
var kotlinEditor = CodeMirror.fromTextArea(document.getElementById("kotlin-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-kotlin"
|
||||
});
|
||||
var ceylonEditor = CodeMirror.fromTextArea(document.getElementById("ceylon-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-ceylon"
|
||||
});
|
||||
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
|
||||
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle C-like languages as well as it
|
||||
can. Takes two configuration parameters: <code>keywords</code>, an
|
||||
object whose property names are the keywords in the language,
|
||||
and <code>useCPP</code>, which determines whether C preprocessor
|
||||
directives are recognized.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
||||
(C), <code>text/x-c++src</code> (C++), <code>text/x-java</code>
|
||||
(Java), <code>text/x-csharp</code> (C#),
|
||||
<code>text/x-objectivec</code> (Objective-C),
|
||||
<code>text/x-scala</code> (Scala), <code>text/x-vertex</code>
|
||||
<code>x-shader/x-fragment</code> (shader programs),
|
||||
<code>text/x-squirrel</code> (Squirrel) and
|
||||
<code>text/x-ceylon</code> (Ceylon)</p>
|
||||
</article>
|
||||
2
libraries/codemirror/mode/clike/scala.html
vendored
2
libraries/codemirror/mode/clike/scala.html
vendored
@@ -10,7 +10,7 @@
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
||||
165
libraries/codemirror/mode/clike/test.js
vendored
165
libraries/codemirror/mode/clike/test.js
vendored
@@ -1,165 +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-c");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("indent",
|
||||
"[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {",
|
||||
" [type int] [variable c] [operator =] [variable b] [operator +]",
|
||||
" [number 1];",
|
||||
" [keyword return] [operator *][variable a];",
|
||||
"}");
|
||||
|
||||
MT("indent_switch",
|
||||
"[keyword switch] ([variable x]) {",
|
||||
" [keyword case] [number 10]:",
|
||||
" [keyword return] [number 20];",
|
||||
" [keyword default]:",
|
||||
" [variable printf]([string \"foo %c\"], [variable x]);",
|
||||
"}");
|
||||
|
||||
MT("def",
|
||||
"[type void] [def foo]() {}",
|
||||
"[keyword struct] [def bar]{}",
|
||||
"[keyword enum] [def zot]{}",
|
||||
"[keyword union] [def ugh]{}",
|
||||
"[type int] [type *][def baz]() {}");
|
||||
|
||||
MT("def_new_line",
|
||||
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
|
||||
"[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
|
||||
|
||||
MT("double_block",
|
||||
"[keyword for] (;;)",
|
||||
" [keyword for] (;;)",
|
||||
" [variable x][operator ++];",
|
||||
"[keyword return];");
|
||||
|
||||
MT("preprocessor",
|
||||
"[meta #define FOO 3]",
|
||||
"[type int] [variable foo];",
|
||||
"[meta #define BAR\\]",
|
||||
"[meta 4]",
|
||||
"[type unsigned] [type int] [variable bar] [operator =] [number 8];",
|
||||
"[meta #include <baz> ][comment // comment]")
|
||||
|
||||
MT("c_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
MT("c_types",
|
||||
"[type int];",
|
||||
"[type long];",
|
||||
"[type char];",
|
||||
"[type short];",
|
||||
"[type double];",
|
||||
"[type float];",
|
||||
"[type unsigned];",
|
||||
"[type signed];",
|
||||
"[type void];",
|
||||
"[type bool];",
|
||||
"[type foo_t];",
|
||||
"[variable foo_T];",
|
||||
"[variable _t];");
|
||||
|
||||
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
|
||||
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MTCPP("cpp14_literal",
|
||||
"[number 10'000];",
|
||||
"[number 0b10'000];",
|
||||
"[number 0x10'000];",
|
||||
"[string '100000'];");
|
||||
|
||||
MTCPP("ctor_dtor",
|
||||
"[def Foo::Foo]() {}",
|
||||
"[def Foo::~Foo]() {}");
|
||||
|
||||
MTCPP("cpp_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
|
||||
function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MTOBJC("objc_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
MTOBJC("objc_interface",
|
||||
"[keyword @interface] [def foo] {",
|
||||
" [type int] [variable bar];",
|
||||
"}",
|
||||
"[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
|
||||
"[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
|
||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
|
||||
"[builtin NS_DESIGNATED_INITIALIZER];",
|
||||
"[keyword @end]");
|
||||
|
||||
MTOBJC("objc_implementation",
|
||||
"[keyword @implementation] [def foo] {",
|
||||
" [type int] [variable bar];",
|
||||
"}",
|
||||
"[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
|
||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
|
||||
" [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
|
||||
" [keyword return] [keyword self];",
|
||||
"}",
|
||||
"[keyword @end]");
|
||||
|
||||
MTOBJC("objc_types",
|
||||
"[type int];",
|
||||
"[type foo_t];",
|
||||
"[variable foo_T];",
|
||||
"[type id];",
|
||||
"[type SEL];",
|
||||
"[type instancetype];",
|
||||
"[type Class];",
|
||||
"[type Protocol];",
|
||||
"[type BOOL];"
|
||||
);
|
||||
|
||||
var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
|
||||
function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
|
||||
MTSCALA("nested_comments",
|
||||
"[comment /*]",
|
||||
"[comment But wait /* this is a nested comment */ for real]",
|
||||
"[comment /**** let * me * show * you ****/]",
|
||||
"[comment ///// let / me / show / you /////]",
|
||||
"[comment */]");
|
||||
|
||||
var mode_java = CodeMirror.getMode({indentUnit: 2}, "text/x-java");
|
||||
function MTJAVA(name) { test.mode("java_" + name, mode_java, Array.prototype.slice.call(arguments, 1)); }
|
||||
MTJAVA("types",
|
||||
"[type byte];",
|
||||
"[type short];",
|
||||
"[type int];",
|
||||
"[type long];",
|
||||
"[type float];",
|
||||
"[type double];",
|
||||
"[type boolean];",
|
||||
"[type char];",
|
||||
"[type void];",
|
||||
"[type Boolean];",
|
||||
"[type Byte];",
|
||||
"[type Character];",
|
||||
"[type Double];",
|
||||
"[type Float];",
|
||||
"[type Integer];",
|
||||
"[type Long];",
|
||||
"[type Number];",
|
||||
"[type Object];",
|
||||
"[type Short];",
|
||||
"[type String];",
|
||||
"[type StringBuffer];",
|
||||
"[type StringBuilder];",
|
||||
"[type Void];");
|
||||
})();
|
||||
95
libraries/codemirror/mode/clojure/index.html
vendored
95
libraries/codemirror/mode/clojure/index.html
vendored
@@ -1,95 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Clojure 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/closebrackets.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="clojure.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="#">Clojure</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Clojure mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
(ns game-of-life
|
||||
"Conway's Game of Life, based on the work of
|
||||
Christophe Grand (http://clj-me.cgrand.net/2011/08/19/conways-game-of-life)
|
||||
and Laurent Petit (https://gist.github.com/1200343).")
|
||||
|
||||
;;; Core game of life's algorithm functions
|
||||
|
||||
(defn neighbors
|
||||
"Given a cell's coordinates `[x y]`, returns the coordinates of its
|
||||
neighbors."
|
||||
[[x y]]
|
||||
(for [dx [-1 0 1]
|
||||
dy (if (zero? dx)
|
||||
[-1 1]
|
||||
[-1 0 1])]
|
||||
[(+ dx x) (+ dy y)]))
|
||||
|
||||
(defn step
|
||||
"Given a set of living `cells`, computes the new set of living cells."
|
||||
[cells]
|
||||
(set (for [[cell n] (frequencies (mapcat neighbors cells))
|
||||
:when (or (= n 3)
|
||||
(and (= n 2)
|
||||
(cells cell)))]
|
||||
cell)))
|
||||
|
||||
;;; Utility methods for displaying game on a text terminal
|
||||
|
||||
(defn print-grid
|
||||
"Prints a `grid` of `w` columns and `h` rows, on *out*, representing a
|
||||
step in the game."
|
||||
[grid w h]
|
||||
(doseq [x (range (inc w))
|
||||
y (range (inc h))]
|
||||
(when (= y 0) (println))
|
||||
(print (if (grid [x y])
|
||||
"[X]"
|
||||
" . "))))
|
||||
|
||||
(defn print-grids
|
||||
"Prints a sequence of `grids` of `w` columns and `h` rows on *out*,
|
||||
representing several steps."
|
||||
[grids w h]
|
||||
(doseq [grid grids]
|
||||
(print-grid grid w h)
|
||||
(println)))
|
||||
|
||||
;;; Launches an example grid
|
||||
|
||||
(def grid
|
||||
"`grid` represents the initial set of living cells"
|
||||
#{[2 1] [2 2] [2 3]})
|
||||
|
||||
(print-grids (take 3 (iterate step grid)) 5 5)</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
autoCloseBrackets: true,
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: 'text/x-clojure'
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-clojure</code>.</p>
|
||||
|
||||
</article>
|
||||
384
libraries/codemirror/mode/clojure/test.js
vendored
384
libraries/codemirror/mode/clojure/test.js
vendored
@@ -1,384 +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}, "clojure");
|
||||
|
||||
function MT(name) {
|
||||
test.mode(name, mode, Array.prototype.slice.call(arguments, 1));
|
||||
}
|
||||
|
||||
MT("atoms",
|
||||
"[atom false]",
|
||||
"[atom nil]",
|
||||
"[atom true]"
|
||||
);
|
||||
|
||||
MT("keywords",
|
||||
"[atom :foo]",
|
||||
"[atom ::bar]",
|
||||
"[atom :foo/bar]",
|
||||
"[atom :foo.bar/baz]"
|
||||
);
|
||||
|
||||
MT("numbers",
|
||||
"[number 42] [number +42] [number -421]",
|
||||
"[number 42N] [number +42N] [number -42N]",
|
||||
"[number 0.42] [number +0.42] [number -0.42]",
|
||||
"[number 42M] [number +42M] [number -42M]",
|
||||
"[number 42.42M] [number +42.42M] [number -42.42M]",
|
||||
"[number 1/42] [number +1/42] [number -1/42]",
|
||||
"[number 0x42af] [number +0x42af] [number -0x42af]",
|
||||
"[number 0x42AF] [number +0x42AF] [number -0x42AF]",
|
||||
"[number 1e2] [number 1e+2] [number 1e-2]",
|
||||
"[number +1e2] [number +1e+2] [number +1e-2]",
|
||||
"[number -1e2] [number -1e+2] [number -1e-2]",
|
||||
"[number -1.0e2] [number -0.1e+2] [number -1.01e-2]",
|
||||
"[number 1E2] [number 1E+2] [number 1E-2]",
|
||||
"[number +1E2] [number +1E+2] [number +1E-2]",
|
||||
"[number -1E2] [number -1E+2] [number -1E-2]",
|
||||
"[number -1.0E2] [number -0.1E+2] [number -1.01E-2]",
|
||||
"[number 2r101010] [number +2r101010] [number -2r101010]",
|
||||
"[number 2r101010] [number +2r101010] [number -2r101010]",
|
||||
"[number 8r52] [number +8r52] [number -8r52]",
|
||||
"[number 36rhello] [number +36rhello] [number -36rhello]",
|
||||
"[number 36rz] [number +36rz] [number -36rz]",
|
||||
"[number 36rZ] [number +36rZ] [number -36rZ]",
|
||||
|
||||
// invalid numbers
|
||||
"[error 42foo]",
|
||||
"[error 42Nfoo]",
|
||||
"[error 42Mfoo]",
|
||||
"[error 42.42Mfoo]",
|
||||
"[error 42.42M!]",
|
||||
"[error 42!]",
|
||||
"[error 0x42afm]"
|
||||
);
|
||||
|
||||
MT("characters",
|
||||
"[string-2 \\1]",
|
||||
"[string-2 \\a]",
|
||||
"[string-2 \\a\\b\\c]",
|
||||
"[string-2 \\#]",
|
||||
"[string-2 \\\\]",
|
||||
"[string-2 \\\"]",
|
||||
"[string-2 \\(]",
|
||||
"[string-2 \\A]",
|
||||
"[string-2 \\backspace]",
|
||||
"[string-2 \\formfeed]",
|
||||
"[string-2 \\newline]",
|
||||
"[string-2 \\space]",
|
||||
"[string-2 \\return]",
|
||||
"[string-2 \\tab]",
|
||||
"[string-2 \\u1000]",
|
||||
"[string-2 \\uAaAa]",
|
||||
"[string-2 \\u9F9F]",
|
||||
"[string-2 \\o123]",
|
||||
"[string-2 \\符]",
|
||||
"[string-2 \\シ]",
|
||||
"[string-2 \\ۇ]",
|
||||
// FIXME
|
||||
// "[string-2 \\🙂]",
|
||||
|
||||
// invalid character literals
|
||||
"[error \\abc]",
|
||||
"[error \\a123]",
|
||||
"[error \\a!]",
|
||||
"[error \\newlines]",
|
||||
"[error \\NEWLINE]",
|
||||
"[error \\u9F9FF]",
|
||||
"[error \\o1234]"
|
||||
);
|
||||
|
||||
MT("strings",
|
||||
"[string \"I'm a teapot.\"]",
|
||||
"[string \"I'm a \\\"teapot\\\".\"]",
|
||||
"[string \"I'm]", // this is
|
||||
"[string a]", // a multi-line
|
||||
"[string teapot.\"]" // string
|
||||
|
||||
// TODO unterminated (multi-line) strings?
|
||||
);
|
||||
|
||||
MT("comments",
|
||||
"[comment ; this is an in-line comment.]",
|
||||
"[comment ;; this is a line comment.]",
|
||||
"[keyword comment]",
|
||||
"[bracket (][comment comment (foo 1 2 3)][bracket )]"
|
||||
);
|
||||
|
||||
MT("reader macro characters",
|
||||
"[meta #][variable _]",
|
||||
"[meta #][variable -Inf]",
|
||||
"[meta ##][variable Inf]",
|
||||
"[meta ##][variable NaN]",
|
||||
"[meta @][variable x]",
|
||||
"[meta ^][bracket {][atom :tag] [variable String][bracket }]",
|
||||
"[meta `][bracket (][builtin f] [variable x][bracket )]",
|
||||
"[meta ~][variable foo#]",
|
||||
"[meta '][number 1]",
|
||||
"[meta '][atom :foo]",
|
||||
"[meta '][string \"foo\"]",
|
||||
"[meta '][variable x]",
|
||||
"[meta '][bracket (][builtin a] [variable b] [variable c][bracket )]",
|
||||
"[meta '][bracket [[][variable a] [variable b] [variable c][bracket ]]]",
|
||||
"[meta '][bracket {][variable a] [number 1] [atom :foo] [number 2] [variable c] [number 3][bracket }]",
|
||||
"[meta '#][bracket {][variable a] [number 1] [atom :foo][bracket }]"
|
||||
);
|
||||
|
||||
MT("symbols",
|
||||
"[variable foo!]",
|
||||
"[variable foo#]",
|
||||
"[variable foo$]",
|
||||
"[variable foo&]",
|
||||
"[variable foo']",
|
||||
"[variable foo*]",
|
||||
"[variable foo+]",
|
||||
"[variable foo-]",
|
||||
"[variable foo.]",
|
||||
"[variable foo/bar]",
|
||||
"[variable foo:bar]",
|
||||
"[variable foo<]",
|
||||
"[variable foo=]",
|
||||
"[variable foo>]",
|
||||
"[variable foo?]",
|
||||
"[variable foo_]",
|
||||
"[variable foo|]",
|
||||
"[variable foobarBaz]",
|
||||
"[variable foo¡]",
|
||||
"[variable 符号]",
|
||||
"[variable シンボル]",
|
||||
"[variable ئۇيغۇر]",
|
||||
"[variable 🙂❤🇺🇸]",
|
||||
|
||||
// invalid symbols
|
||||
"[error 3foo]",
|
||||
"[error 3+]",
|
||||
"[error 3|]",
|
||||
"[error 3_]"
|
||||
);
|
||||
|
||||
MT("numbers and other forms",
|
||||
"[number 42][bracket (][builtin foo][bracket )]",
|
||||
"[number 42][bracket [[][variable foo][bracket ]]]",
|
||||
"[number 42][meta #][bracket {][variable foo][bracket }]",
|
||||
"[number 42][bracket {][atom :foo] [variable bar][bracket }]",
|
||||
"[number 42][meta `][variable foo]",
|
||||
"[number 42][meta ~][variable foo]",
|
||||
"[number 42][meta #][variable foo]"
|
||||
);
|
||||
|
||||
var specialForms = [".", "catch", "def", "do", "if", "monitor-enter",
|
||||
"monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"];
|
||||
|
||||
MT("should highlight special forms as keywords",
|
||||
typeTokenPairs("keyword", specialForms)
|
||||
);
|
||||
|
||||
var coreSymbols1 = [
|
||||
"*", "*'", "*1", "*2", "*3", "*agent*", "*allow-unresolved-vars*", "*assert*",
|
||||
"*clojure-version*", "*command-line-args*", "*compile-files*", "*compile-path*", "*compiler-options*",
|
||||
"*data-readers*", "*default-data-reader-fn*", "*e", "*err*", "*file*", "*flush-on-newline*", "*fn-loader*",
|
||||
"*in*", "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*", "*print-level*", "*print-meta*",
|
||||
"*print-namespace-maps*", "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*",
|
||||
"*suppress-read*", "*unchecked-math*", "*use-context-classloader*", "*verbose-defrecords*",
|
||||
"*warn-on-reflection*", "+", "+'", "-", "-'", "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode",
|
||||
"->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=", "=", "==", ">", ">=",
|
||||
"EMPTY-NODE", "Inst", "StackTraceElement->vec", "Throwable->map", "accessor", "aclone", "add-classpath",
|
||||
"add-watch", "agent", "agent-error", "agent-errors", "aget", "alength", "alias", "all-ns", "alter",
|
||||
"alter-meta!", "alter-var-root", "amap", "ancestors", "and", "any?", "apply", "areduce", "array-map",
|
||||
"as->", "aset", "aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float", "aset-int",
|
||||
"aset-long", "aset-short", "assert", "assoc", "assoc!", "assoc-in", "associative?", "atom", "await",
|
||||
"await-for", "await1", "bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and", "bit-and-not",
|
||||
"bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set", "bit-shift-left", "bit-shift-right", "bit-test",
|
||||
"bit-xor", "boolean", "boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*", "bound?",
|
||||
"bounded-count", "butlast", "byte", "byte-array", "bytes", "bytes?", "case", "cast", "cat", "char",
|
||||
"char-array", "char-escape-string", "char-name-string", "char?", "chars", "chunk", "chunk-append",
|
||||
"chunk-buffer", "chunk-cons", "chunk-first", "chunk-next", "chunk-rest", "chunked-seq?", "class", "class?",
|
||||
"clear-agent-errors", "clojure-version", "coll?", "comment", "commute", "comp", "comparator", "compare",
|
||||
"compare-and-set!", "compile", "complement", "completing", "concat", "cond", "cond->", "cond->>", "condp",
|
||||
"conj", "conj!", "cons", "constantly", "construct-proxy", "contains?", "count", "counted?", "create-ns",
|
||||
"create-struct", "cycle", "dec", "dec'", "decimal?", "declare", "dedupe", "default-data-readers", "definline",
|
||||
"definterface", "defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce", "defprotocol", "defrecord",
|
||||
"defstruct", "deftype", "delay", "delay?", "deliver", "denominator", "deref", "derive", "descendants",
|
||||
"destructure", "disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall", "dorun", "doseq",
|
||||
"dosync", "dotimes", "doto", "double", "double-array", "double?", "doubles", "drop", "drop-last", "drop-while",
|
||||
"eduction", "empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq", "error-handler", "error-mode",
|
||||
"eval", "even?", "every-pred", "every?", "ex-data", "ex-info", "extend", "extend-protocol", "extend-type",
|
||||
"extenders", "extends?", "false?", "ffirst", "file-seq", "filter", "filterv", "find", "find-keyword", "find-ns",
|
||||
"find-protocol-impl", "find-protocol-method", "find-var", "first", "flatten", "float", "float-array", "float?",
|
||||
"floats", "flush", "fn", "fn?", "fnext", "fnil", "for", "force", "format", "frequencies", "future", "future-call",
|
||||
"future-cancel", "future-cancelled?", "future-done?", "future?", "gen-class", "gen-interface", "gensym", "get",
|
||||
"get-in", "get-method", "get-proxy-class", "get-thread-bindings", "get-validator", "group-by", "halt-when", "hash",
|
||||
"hash-combine", "hash-map", "hash-ordered-coll", "hash-set", "hash-unordered-coll", "ident?", "identical?",
|
||||
"identity", "if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'", "indexed?", "init-proxy",
|
||||
"inst-ms", "inst-ms*", "inst?", "instance?", "int", "int-array", "int?", "integer?", "interleave", "intern",
|
||||
"interpose", "into", "into-array", "ints", "io!", "isa?", "iterate", "iterator-seq", "juxt", "keep", "keep-indexed",
|
||||
"key", "keys", "keyword", "keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq", "list", "list*",
|
||||
"list?", "load", "load-file", "load-reader", "load-string", "loaded-libs", "locking", "long", "long-array", "longs",
|
||||
"loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy", "map", "map-entry?", "map-indexed", "map?",
|
||||
"mapcat", "mapv", "max", "max-key", "memfn", "memoize", "merge", "merge-with", "meta", "method-sig", "methods"];
|
||||
|
||||
var coreSymbols2 = [
|
||||
"min", "min-key", "mix-collection-hash", "mod", "munge", "name", "namespace", "namespace-munge", "nat-int?",
|
||||
"neg-int?", "neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?", "not-empty", "not-every?",
|
||||
"not=", "ns", "ns-aliases", "ns-imports", "ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers", "ns-resolve",
|
||||
"ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest", "num", "number?", "numerator", "object-array", "odd?", "or",
|
||||
"parents", "partial", "partition", "partition-all", "partition-by", "pcalls", "peek", "persistent!", "pmap", "pop",
|
||||
"pop!", "pop-thread-bindings", "pos-int?", "pos?", "pr", "pr-str", "prefer-method", "prefers",
|
||||
"primitives-classnames", "print", "print-ctor", "print-dup", "print-method", "print-simple", "print-str", "printf",
|
||||
"println", "println-str", "prn", "prn-str", "promise", "proxy", "proxy-call-with-super", "proxy-mappings",
|
||||
"proxy-name", "proxy-super", "push-thread-bindings", "pvalues", "qualified-ident?", "qualified-keyword?",
|
||||
"qualified-symbol?", "quot", "rand", "rand-int", "rand-nth", "random-sample", "range", "ratio?", "rational?",
|
||||
"rationalize", "re-find", "re-groups", "re-matcher", "re-matches", "re-pattern", "re-seq", "read", "read-line",
|
||||
"read-string", "reader-conditional", "reader-conditional?", "realized?", "record?", "reduce", "reduce-kv", "reduced",
|
||||
"reduced?", "reductions", "ref", "ref-history-count", "ref-max-history", "ref-min-history", "ref-set", "refer",
|
||||
"refer-clojure", "reify", "release-pending-sends", "rem", "remove", "remove-all-methods", "remove-method", "remove-ns",
|
||||
"remove-watch", "repeat", "repeatedly", "replace", "replicate", "require", "reset!", "reset-meta!", "reset-vals!",
|
||||
"resolve", "rest", "restart-agent", "resultset-seq", "reverse", "reversible?", "rseq", "rsubseq", "run!", "satisfies?",
|
||||
"second", "select-keys", "send", "send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence", "sequential?",
|
||||
"set", "set-agent-send-executor!", "set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!",
|
||||
"set-validator!", "set?", "short", "short-array", "shorts", "shuffle", "shutdown-agents", "simple-ident?",
|
||||
"simple-keyword?", "simple-symbol?", "slurp", "some", "some->", "some->>", "some-fn", "some?", "sort", "sort-by",
|
||||
"sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by", "sorted?", "special-symbol?", "spit", "split-at",
|
||||
"split-with", "str", "string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers", "swap!", "swap-vals!",
|
||||
"symbol", "symbol?", "sync", "tagged-literal", "tagged-literal?", "take", "take-last", "take-nth", "take-while", "test",
|
||||
"the-ns", "thread-bound?", "time", "to-array", "to-array-2d", "trampoline", "transduce", "transient", "tree-seq",
|
||||
"true?", "type", "unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char", "unchecked-dec",
|
||||
"unchecked-dec-int", "unchecked-divide-int", "unchecked-double", "unchecked-float", "unchecked-inc", "unchecked-inc-int",
|
||||
"unchecked-int", "unchecked-long", "unchecked-multiply", "unchecked-multiply-int", "unchecked-negate",
|
||||
"unchecked-negate-int", "unchecked-remainder-int", "unchecked-short", "unchecked-subtract", "unchecked-subtract-int",
|
||||
"underive", "unquote", "unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update", "update-in",
|
||||
"update-proxy", "uri?", "use", "uuid?", "val", "vals", "var-get", "var-set", "var?", "vary-meta", "vec", "vector",
|
||||
"vector-of", "vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when", "when-first", "when-let", "when-not",
|
||||
"when-some", "while", "with-bindings", "with-bindings*", "with-in-str", "with-loading-context", "with-local-vars",
|
||||
"with-meta", "with-open", "with-out-str", "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?",
|
||||
"zipmap"
|
||||
];
|
||||
|
||||
MT("should highlight core symbols as keywords (part 1/2)",
|
||||
typeTokenPairs("keyword", coreSymbols1)
|
||||
);
|
||||
|
||||
MT("should highlight core symbols as keywords (part 2/2)",
|
||||
typeTokenPairs("keyword", coreSymbols2)
|
||||
);
|
||||
|
||||
MT("should properly indent forms in list literals",
|
||||
"[bracket (][builtin foo] [atom :a] [number 1] [atom true] [atom nil][bracket )]",
|
||||
"",
|
||||
"[bracket (][builtin foo] [atom :a]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket )]",
|
||||
"",
|
||||
"[bracket (][builtin foo] [atom :a] [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket )]",
|
||||
"",
|
||||
"[bracket (]",
|
||||
" [builtin foo]",
|
||||
" [atom :a]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket )]",
|
||||
"",
|
||||
"[bracket (][builtin foo] [bracket [[][atom :a][bracket ]]]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket )]"
|
||||
);
|
||||
|
||||
MT("should properly indent forms in vector literals",
|
||||
"[bracket [[][atom :a] [number 1] [atom true] [atom nil][bracket ]]]",
|
||||
"",
|
||||
"[bracket [[][atom :a]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket ]]]",
|
||||
"",
|
||||
"[bracket [[][atom :a] [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket ]]]",
|
||||
"",
|
||||
"[bracket [[]",
|
||||
" [variable foo]",
|
||||
" [atom :a]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket ]]]"
|
||||
);
|
||||
|
||||
MT("should properly indent forms in map literals",
|
||||
"[bracket {][atom :a] [atom :a] [atom :b] [number 1] [atom :c] [atom true] [atom :d] [atom nil] [bracket }]",
|
||||
"",
|
||||
"[bracket {][atom :a] [atom :a]",
|
||||
" [atom :b] [number 1]",
|
||||
" [atom :c] [atom true]",
|
||||
" [atom :d] [atom nil][bracket }]",
|
||||
"",
|
||||
"[bracket {][atom :a]",
|
||||
" [atom :a]",
|
||||
" [atom :b]",
|
||||
" [number 1]",
|
||||
" [atom :c]",
|
||||
" [atom true]",
|
||||
" [atom :d]",
|
||||
" [atom nil][bracket }]",
|
||||
"",
|
||||
"[bracket {]",
|
||||
" [atom :a] [atom :a]",
|
||||
" [atom :b] [number 1]",
|
||||
" [atom :c] [atom true]",
|
||||
" [atom :d] [atom nil][bracket }]"
|
||||
);
|
||||
|
||||
MT("should properly indent forms in set literals",
|
||||
"[meta #][bracket {][atom :a] [number 1] [atom true] [atom nil] [bracket }]",
|
||||
"",
|
||||
"[meta #][bracket {][atom :a]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket }]",
|
||||
"",
|
||||
"[meta #][bracket {]",
|
||||
" [atom :a]",
|
||||
" [number 1]",
|
||||
" [atom true]",
|
||||
" [atom nil][bracket }]"
|
||||
);
|
||||
|
||||
var haveBodyParameter = [
|
||||
"->", "->>", "as->", "binding", "bound-fn", "case", "catch", "cond",
|
||||
"cond->", "cond->>", "condp", "def", "definterface", "defmethod", "defn",
|
||||
"defmacro", "defprotocol", "defrecord", "defstruct", "deftype", "do",
|
||||
"doseq", "dotimes", "doto", "extend", "extend-protocol", "extend-type",
|
||||
"fn", "for", "future", "if", "if-let", "if-not", "if-some", "let",
|
||||
"letfn", "locking", "loop", "ns", "proxy", "reify", "some->", "some->>",
|
||||
"struct-map", "try", "when", "when-first", "when-let", "when-not",
|
||||
"when-some", "while", "with-bindings", "with-bindings*", "with-in-str",
|
||||
"with-loading-context", "with-local-vars", "with-meta", "with-open",
|
||||
"with-out-str", "with-precision", "with-redefs", "with-redefs-fn"];
|
||||
|
||||
function testFormsThatHaveBodyParameter(forms) {
|
||||
for (var i = 0; i < forms.length; i++) {
|
||||
MT("should indent body argument of `" + forms[i] + "` by `options.indentUnit` spaces",
|
||||
"[bracket (][keyword " + forms[i] + "] [variable foo] [variable bar]",
|
||||
" [variable baz]",
|
||||
" [variable qux][bracket )]"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
testFormsThatHaveBodyParameter(haveBodyParameter);
|
||||
|
||||
MT("should indent body argument of `comment` by `options.indentUnit` spaces",
|
||||
"[bracket (][comment comment foo bar]",
|
||||
"[comment baz]",
|
||||
"[comment qux][bracket )]"
|
||||
);
|
||||
|
||||
function typeTokenPairs(type, tokens) {
|
||||
return "[" + type + " " + tokens.join("] [" + type + " ") + "]";
|
||||
}
|
||||
})();
|
||||
129
libraries/codemirror/mode/cmake/index.html
vendored
129
libraries/codemirror/mode/cmake/index.html
vendored
@@ -1,129 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: CMake 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="cmake.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default span.cm-arrow { color: red; }
|
||||
</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="#">CMake</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>CMake mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
# vim: syntax=cmake
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
# default to Release build for GCC builds
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
endif()
|
||||
message(STATUS "cmake version ${CMAKE_VERSION}")
|
||||
if(POLICY CMP0025)
|
||||
cmake_policy(SET CMP0025 OLD) # report Apple's Clang as just Clang
|
||||
endif()
|
||||
if(POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH
|
||||
endif()
|
||||
|
||||
project (x265)
|
||||
cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
# X265_BUILD must be incremented each time the public API is changed
|
||||
set(X265_BUILD 48)
|
||||
configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
|
||||
"${PROJECT_BINARY_DIR}/x265.def")
|
||||
configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/x265_config.h")
|
||||
|
||||
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
|
||||
|
||||
# System architecture detection
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
|
||||
set(X86_ALIASES x86 i386 i686 x86_64 amd64)
|
||||
list(FIND X86_ALIASES "${SYSPROC}" X86MATCH)
|
||||
if("${SYSPROC}" STREQUAL "" OR X86MATCH GREATER "-1")
|
||||
message(STATUS "Detected x86 target processor")
|
||||
set(X86 1)
|
||||
add_definitions(-DX265_ARCH_X86=1)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" MATCHES 8)
|
||||
set(X64 1)
|
||||
add_definitions(-DX86_64=1)
|
||||
endif()
|
||||
elseif(${SYSPROC} STREQUAL "armv6l")
|
||||
message(STATUS "Detected ARM target processor")
|
||||
set(ARM 1)
|
||||
add_definitions(-DX265_ARCH_ARM=1 -DHAVE_ARMV6=1)
|
||||
else()
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
|
||||
message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND PLATFORM_LIBS pthread)
|
||||
find_library(LIBRT rt)
|
||||
if(LIBRT)
|
||||
list(APPEND PLATFORM_LIBS rt)
|
||||
endif()
|
||||
find_package(Numa)
|
||||
if(NUMA_FOUND)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${NUMA_LIBRARY})
|
||||
check_symbol_exists(numa_node_of_cpu numa.h NUMA_V2)
|
||||
if(NUMA_V2)
|
||||
add_definitions(-DHAVE_LIBNUMA)
|
||||
message(STATUS "libnuma found, building with support for NUMA nodes")
|
||||
list(APPEND PLATFORM_LIBS ${NUMA_LIBRARY})
|
||||
link_directories(${NUMA_LIBRARY_DIR})
|
||||
include_directories(${NUMA_INCLUDE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
mark_as_advanced(LIBRT NUMA_FOUND)
|
||||
endif(UNIX)
|
||||
|
||||
if(X64 AND NOT WIN32)
|
||||
option(ENABLE_PIC "Enable Position Independent Code" ON)
|
||||
else()
|
||||
option(ENABLE_PIC "Enable Position Independent Code" OFF)
|
||||
endif(X64 AND NOT WIN32)
|
||||
|
||||
# Compiler detection
|
||||
if(CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
set(XCODE 1)
|
||||
endif()
|
||||
if (APPLE)
|
||||
add_definitions(-DMACOS)
|
||||
endif()
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-cmake",
|
||||
matchBrackets: true,
|
||||
indentUnit: 4
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-cmake</code>.</p>
|
||||
|
||||
</article>
|
||||
210
libraries/codemirror/mode/cobol/index.html
vendored
210
libraries/codemirror/mode/cobol/index.html
vendored
@@ -1,210 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: COBOL mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/neat.css">
|
||||
<link rel="stylesheet" href="../../theme/elegant.css">
|
||||
<link rel="stylesheet" href="../../theme/erlang-dark.css">
|
||||
<link rel="stylesheet" href="../../theme/night.css">
|
||||
<link rel="stylesheet" href="../../theme/monokai.css">
|
||||
<link rel="stylesheet" href="../../theme/cobalt.css">
|
||||
<link rel="stylesheet" href="../../theme/eclipse.css">
|
||||
<link rel="stylesheet" href="../../theme/rubyblue.css">
|
||||
<link rel="stylesheet" href="../../theme/lesser-dark.css">
|
||||
<link rel="stylesheet" href="../../theme/xq-dark.css">
|
||||
<link rel="stylesheet" href="../../theme/xq-light.css">
|
||||
<link rel="stylesheet" href="../../theme/ambiance.css">
|
||||
<link rel="stylesheet" href="../../theme/blackboard.css">
|
||||
<link rel="stylesheet" href="../../theme/vibrant-ink.css">
|
||||
<link rel="stylesheet" href="../../theme/solarized.css">
|
||||
<link rel="stylesheet" href="../../theme/twilight.css">
|
||||
<link rel="stylesheet" href="../../theme/midnight.css">
|
||||
<link rel="stylesheet" href="../../addon/dialog/dialog.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="cobol.js"></script>
|
||||
<script src="../../addon/selection/active-line.js"></script>
|
||||
<script src="../../addon/search/search.js"></script>
|
||||
<script src="../../addon/dialog/dialog.js"></script>
|
||||
<script src="../../addon/search/searchcursor.js"></script>
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border: 1px solid #eee;
|
||||
font-size : 20px;
|
||||
height : auto !important;
|
||||
}
|
||||
.CodeMirror-activeline-background {background: #555555 !important;}
|
||||
</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="#">COBOL</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>COBOL mode</h2>
|
||||
|
||||
<p> Select Theme <select onchange="selectTheme()" id="selectTheme">
|
||||
<option>default</option>
|
||||
<option>ambiance</option>
|
||||
<option>blackboard</option>
|
||||
<option>cobalt</option>
|
||||
<option>eclipse</option>
|
||||
<option>elegant</option>
|
||||
<option>erlang-dark</option>
|
||||
<option>lesser-dark</option>
|
||||
<option>midnight</option>
|
||||
<option>monokai</option>
|
||||
<option>neat</option>
|
||||
<option>night</option>
|
||||
<option>rubyblue</option>
|
||||
<option>solarized dark</option>
|
||||
<option>solarized light</option>
|
||||
<option selected>twilight</option>
|
||||
<option>vibrant-ink</option>
|
||||
<option>xq-dark</option>
|
||||
<option>xq-light</option>
|
||||
</select> Select Font Size <select onchange="selectFontsize()" id="selectFontSize">
|
||||
<option value="13px">13px</option>
|
||||
<option value="14px">14px</option>
|
||||
<option value="16px">16px</option>
|
||||
<option value="18px">18px</option>
|
||||
<option value="20px" selected="selected">20px</option>
|
||||
<option value="24px">24px</option>
|
||||
<option value="26px">26px</option>
|
||||
<option value="28px">28px</option>
|
||||
<option value="30px">30px</option>
|
||||
<option value="32px">32px</option>
|
||||
<option value="34px">34px</option>
|
||||
<option value="36px">36px</option>
|
||||
</select>
|
||||
<label for="checkBoxReadOnly">Read-only</label>
|
||||
<input type="checkbox" id="checkBoxReadOnly" onchange="selectReadOnly()">
|
||||
<label for="id_tabToIndentSpace">Insert Spaces on Tab</label>
|
||||
<input type="checkbox" id="id_tabToIndentSpace" onchange="tabToIndentSpace()">
|
||||
</p>
|
||||
<textarea id="code" name="code">
|
||||
---------1---------2---------3---------4---------5---------6---------7---------8
|
||||
12345678911234567892123456789312345678941234567895123456789612345678971234567898
|
||||
000010 IDENTIFICATION DIVISION. MODTGHERE
|
||||
000020 PROGRAM-ID. SAMPLE.
|
||||
000030 AUTHOR. TEST SAM.
|
||||
000040 DATE-WRITTEN. 5 February 2013
|
||||
000041
|
||||
000042* A sample program just to show the form.
|
||||
000043* The program copies its input to the output,
|
||||
000044* and counts the number of records.
|
||||
000045* At the end this number is printed.
|
||||
000046
|
||||
000050 ENVIRONMENT DIVISION.
|
||||
000060 INPUT-OUTPUT SECTION.
|
||||
000070 FILE-CONTROL.
|
||||
000080 SELECT STUDENT-FILE ASSIGN TO SYSIN
|
||||
000090 ORGANIZATION IS LINE SEQUENTIAL.
|
||||
000100 SELECT PRINT-FILE ASSIGN TO SYSOUT
|
||||
000110 ORGANIZATION IS LINE SEQUENTIAL.
|
||||
000120
|
||||
000130 DATA DIVISION.
|
||||
000140 FILE SECTION.
|
||||
000150 FD STUDENT-FILE
|
||||
000160 RECORD CONTAINS 43 CHARACTERS
|
||||
000170 DATA RECORD IS STUDENT-IN.
|
||||
000180 01 STUDENT-IN PIC X(43).
|
||||
000190
|
||||
000200 FD PRINT-FILE
|
||||
000210 RECORD CONTAINS 80 CHARACTERS
|
||||
000220 DATA RECORD IS PRINT-LINE.
|
||||
000230 01 PRINT-LINE PIC X(80).
|
||||
000240
|
||||
000250 WORKING-STORAGE SECTION.
|
||||
000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
|
||||
000261 01 RECORDS-WRITTEN PIC 99.
|
||||
000270
|
||||
000280 01 DETAIL-LINE.
|
||||
000290 05 FILLER PIC X(7) VALUE SPACES.
|
||||
000300 05 RECORD-IMAGE PIC X(43).
|
||||
000310 05 FILLER PIC X(30) VALUE SPACES.
|
||||
000311
|
||||
000312 01 SUMMARY-LINE.
|
||||
000313 05 FILLER PIC X(7) VALUE SPACES.
|
||||
000314 05 TOTAL-READ PIC 99.
|
||||
000315 05 FILLER PIC X VALUE SPACE.
|
||||
000316 05 FILLER PIC X(17)
|
||||
000317 VALUE 'Records were read'.
|
||||
000318 05 FILLER PIC X(53) VALUE SPACES.
|
||||
000319
|
||||
000320 PROCEDURE DIVISION.
|
||||
000321
|
||||
000330 PREPARE-SENIOR-REPORT.
|
||||
000340 OPEN INPUT STUDENT-FILE
|
||||
000350 OUTPUT PRINT-FILE.
|
||||
000351 MOVE ZERO TO RECORDS-WRITTEN.
|
||||
000360 READ STUDENT-FILE
|
||||
000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
|
||||
000380 END-READ.
|
||||
000390 PERFORM PROCESS-RECORDS
|
||||
000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.
|
||||
000411 PERFORM PRINT-SUMMARY.
|
||||
000420 CLOSE STUDENT-FILE
|
||||
000430 PRINT-FILE.
|
||||
000440 STOP RUN.
|
||||
000450
|
||||
000460 PROCESS-RECORDS.
|
||||
000470 MOVE STUDENT-IN TO RECORD-IMAGE.
|
||||
000480 MOVE DETAIL-LINE TO PRINT-LINE.
|
||||
000490 WRITE PRINT-LINE.
|
||||
000500 ADD 1 TO RECORDS-WRITTEN.
|
||||
000510 READ STUDENT-FILE
|
||||
000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
|
||||
000530 END-READ.
|
||||
000540
|
||||
000550 PRINT-SUMMARY.
|
||||
000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.
|
||||
000570 MOVE SUMMARY-LINE TO PRINT-LINE.
|
||||
000571 WRITE PRINT-LINE.
|
||||
000572
|
||||
000580
|
||||
</textarea>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-cobol",
|
||||
theme : "twilight",
|
||||
styleActiveLine: true,
|
||||
showCursorWhenSelecting : true,
|
||||
});
|
||||
function selectTheme() {
|
||||
var themeInput = document.getElementById("selectTheme");
|
||||
var theme = themeInput.options[themeInput.selectedIndex].innerHTML;
|
||||
editor.setOption("theme", theme);
|
||||
}
|
||||
function selectFontsize() {
|
||||
var fontSizeInput = document.getElementById("selectFontSize");
|
||||
var fontSize = fontSizeInput.options[fontSizeInput.selectedIndex].innerHTML;
|
||||
editor.getWrapperElement().style.fontSize = fontSize;
|
||||
editor.refresh();
|
||||
}
|
||||
function selectReadOnly() {
|
||||
editor.setOption("readOnly", document.getElementById("checkBoxReadOnly").checked);
|
||||
}
|
||||
function tabToIndentSpace() {
|
||||
if (document.getElementById("id_tabToIndentSpace").checked) {
|
||||
editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
|
||||
} else {
|
||||
editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</article>
|
||||
740
libraries/codemirror/mode/coffeescript/index.html
vendored
740
libraries/codemirror/mode/coffeescript/index.html
vendored
@@ -1,740 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: CoffeeScript 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="coffeescript.js"></script>
|
||||
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</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="#">CoffeeScript</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>CoffeeScript mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
# CoffeeScript mode for CodeMirror
|
||||
# Copyright (c) 2011 Jeff Pickhardt, released under
|
||||
# the MIT License.
|
||||
#
|
||||
# Modified from the Python CodeMirror mode, which also is
|
||||
# under the MIT License Copyright (c) 2010 Timothy Farrell.
|
||||
#
|
||||
# The following script, Underscore.coffee, is used to
|
||||
# demonstrate CoffeeScript mode for CodeMirror.
|
||||
#
|
||||
# To download CoffeeScript mode for CodeMirror, go to:
|
||||
# https://github.com/pickhardt/coffeescript-codemirror-mode
|
||||
|
||||
# **Underscore.coffee
|
||||
# (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
|
||||
# Underscore is freely distributable under the terms of the
|
||||
# [MIT license](http://en.wikipedia.org/wiki/MIT_License).
|
||||
# Portions of Underscore are inspired by or borrowed from
|
||||
# [Prototype.js](http://prototypejs.org/api), Oliver Steele's
|
||||
# [Functional](http://osteele.com), and John Resig's
|
||||
# [Micro-Templating](http://ejohn.org).
|
||||
# For all details and documentation:
|
||||
# http://documentcloud.github.com/underscore/
|
||||
|
||||
|
||||
# Baseline setup
|
||||
# --------------
|
||||
|
||||
# Establish the root object, `window` in the browser, or `global` on the server.
|
||||
root = this
|
||||
|
||||
|
||||
# Save the previous value of the `_` variable.
|
||||
previousUnderscore = root._
|
||||
|
||||
### Multiline
|
||||
comment
|
||||
###
|
||||
|
||||
# Establish the object that gets thrown to break out of a loop iteration.
|
||||
# `StopIteration` is SOP on Mozilla.
|
||||
breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
|
||||
|
||||
|
||||
#### Docco style single line comment (title)
|
||||
|
||||
|
||||
# Helper function to escape **RegExp** contents, because JS doesn't have one.
|
||||
escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
|
||||
|
||||
|
||||
# Save bytes in the minified (but not gzipped) version:
|
||||
ArrayProto = Array.prototype
|
||||
ObjProto = Object.prototype
|
||||
|
||||
|
||||
# Create quick reference variables for speed access to core prototypes.
|
||||
slice = ArrayProto.slice
|
||||
unshift = ArrayProto.unshift
|
||||
toString = ObjProto.toString
|
||||
hasOwnProperty = ObjProto.hasOwnProperty
|
||||
propertyIsEnumerable = ObjProto.propertyIsEnumerable
|
||||
|
||||
|
||||
# All **ECMA5** native implementations we hope to use are declared here.
|
||||
nativeForEach = ArrayProto.forEach
|
||||
nativeMap = ArrayProto.map
|
||||
nativeReduce = ArrayProto.reduce
|
||||
nativeReduceRight = ArrayProto.reduceRight
|
||||
nativeFilter = ArrayProto.filter
|
||||
nativeEvery = ArrayProto.every
|
||||
nativeSome = ArrayProto.some
|
||||
nativeIndexOf = ArrayProto.indexOf
|
||||
nativeLastIndexOf = ArrayProto.lastIndexOf
|
||||
nativeIsArray = Array.isArray
|
||||
nativeKeys = Object.keys
|
||||
|
||||
|
||||
# Create a safe reference to the Underscore object for use below.
|
||||
_ = (obj) -> new wrapper(obj)
|
||||
|
||||
|
||||
# Export the Underscore object for **CommonJS**.
|
||||
if typeof(exports) != 'undefined' then exports._ = _
|
||||
|
||||
|
||||
# Export Underscore to global scope.
|
||||
root._ = _
|
||||
|
||||
|
||||
# Current version.
|
||||
_.VERSION = '1.1.0'
|
||||
|
||||
|
||||
# Collection Functions
|
||||
# --------------------
|
||||
|
||||
# The cornerstone, an **each** implementation.
|
||||
# Handles objects implementing **forEach**, arrays, and raw objects.
|
||||
_.each = (obj, iterator, context) ->
|
||||
try
|
||||
if nativeForEach and obj.forEach is nativeForEach
|
||||
obj.forEach iterator, context
|
||||
else if _.isNumber obj.length
|
||||
iterator.call context, obj[i], i, obj for i in [0...obj.length]
|
||||
else
|
||||
iterator.call context, val, key, obj for own key, val of obj
|
||||
catch e
|
||||
throw e if e isnt breaker
|
||||
obj
|
||||
|
||||
|
||||
# Return the results of applying the iterator to each element. Use JavaScript
|
||||
# 1.6's version of **map**, if possible.
|
||||
_.map = (obj, iterator, context) ->
|
||||
return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
|
||||
results = []
|
||||
_.each obj, (value, index, list) ->
|
||||
results.push iterator.call context, value, index, list
|
||||
results
|
||||
|
||||
|
||||
# **Reduce** builds up a single result from a list of values. Also known as
|
||||
# **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
|
||||
_.reduce = (obj, iterator, memo, context) ->
|
||||
if nativeReduce and obj.reduce is nativeReduce
|
||||
iterator = _.bind iterator, context if context
|
||||
return obj.reduce iterator, memo
|
||||
_.each obj, (value, index, list) ->
|
||||
memo = iterator.call context, memo, value, index, list
|
||||
memo
|
||||
|
||||
|
||||
# The right-associative version of **reduce**, also known as **foldr**. Uses
|
||||
# JavaScript 1.8's version of **reduceRight**, if available.
|
||||
_.reduceRight = (obj, iterator, memo, context) ->
|
||||
if nativeReduceRight and obj.reduceRight is nativeReduceRight
|
||||
iterator = _.bind iterator, context if context
|
||||
return obj.reduceRight iterator, memo
|
||||
reversed = _.clone(_.toArray(obj)).reverse()
|
||||
_.reduce reversed, iterator, memo, context
|
||||
|
||||
|
||||
# Return the first value which passes a truth test.
|
||||
_.detect = (obj, iterator, context) ->
|
||||
result = null
|
||||
_.each obj, (value, index, list) ->
|
||||
if iterator.call context, value, index, list
|
||||
result = value
|
||||
_.breakLoop()
|
||||
result
|
||||
|
||||
|
||||
# Return all the elements that pass a truth test. Use JavaScript 1.6's
|
||||
# **filter**, if it exists.
|
||||
_.filter = (obj, iterator, context) ->
|
||||
return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
|
||||
results = []
|
||||
_.each obj, (value, index, list) ->
|
||||
results.push value if iterator.call context, value, index, list
|
||||
results
|
||||
|
||||
|
||||
# Return all the elements for which a truth test fails.
|
||||
_.reject = (obj, iterator, context) ->
|
||||
results = []
|
||||
_.each obj, (value, index, list) ->
|
||||
results.push value if not iterator.call context, value, index, list
|
||||
results
|
||||
|
||||
|
||||
# Determine whether all of the elements match a truth test. Delegate to
|
||||
# JavaScript 1.6's **every**, if it is present.
|
||||
_.every = (obj, iterator, context) ->
|
||||
iterator ||= _.identity
|
||||
return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
|
||||
result = true
|
||||
_.each obj, (value, index, list) ->
|
||||
_.breakLoop() unless (result = result and iterator.call(context, value, index, list))
|
||||
result
|
||||
|
||||
|
||||
# Determine if at least one element in the object matches a truth test. Use
|
||||
# JavaScript 1.6's **some**, if it exists.
|
||||
_.some = (obj, iterator, context) ->
|
||||
iterator ||= _.identity
|
||||
return obj.some iterator, context if nativeSome and obj.some is nativeSome
|
||||
result = false
|
||||
_.each obj, (value, index, list) ->
|
||||
_.breakLoop() if (result = iterator.call(context, value, index, list))
|
||||
result
|
||||
|
||||
|
||||
# Determine if a given value is included in the array or object,
|
||||
# based on `===`.
|
||||
_.include = (obj, target) ->
|
||||
return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
|
||||
return true for own key, val of obj when val is target
|
||||
false
|
||||
|
||||
|
||||
# Invoke a method with arguments on every item in a collection.
|
||||
_.invoke = (obj, method) ->
|
||||
args = _.rest arguments, 2
|
||||
(if method then val[method] else val).apply(val, args) for val in obj
|
||||
|
||||
|
||||
# Convenience version of a common use case of **map**: fetching a property.
|
||||
_.pluck = (obj, key) ->
|
||||
_.map(obj, (val) -> val[key])
|
||||
|
||||
|
||||
# Return the maximum item or (item-based computation).
|
||||
_.max = (obj, iterator, context) ->
|
||||
return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
|
||||
result = computed: -Infinity
|
||||
_.each obj, (value, index, list) ->
|
||||
computed = if iterator then iterator.call(context, value, index, list) else value
|
||||
computed >= result.computed and (result = {value: value, computed: computed})
|
||||
result.value
|
||||
|
||||
|
||||
# Return the minimum element (or element-based computation).
|
||||
_.min = (obj, iterator, context) ->
|
||||
return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
|
||||
result = computed: Infinity
|
||||
_.each obj, (value, index, list) ->
|
||||
computed = if iterator then iterator.call(context, value, index, list) else value
|
||||
computed < result.computed and (result = {value: value, computed: computed})
|
||||
result.value
|
||||
|
||||
|
||||
# Sort the object's values by a criterion produced by an iterator.
|
||||
_.sortBy = (obj, iterator, context) ->
|
||||
_.pluck(((_.map obj, (value, index, list) ->
|
||||
{value: value, criteria: iterator.call(context, value, index, list)}
|
||||
).sort((left, right) ->
|
||||
a = left.criteria; b = right.criteria
|
||||
if a < b then -1 else if a > b then 1 else 0
|
||||
)), 'value')
|
||||
|
||||
|
||||
# Use a comparator function to figure out at what index an object should
|
||||
# be inserted so as to maintain order. Uses binary search.
|
||||
_.sortedIndex = (array, obj, iterator) ->
|
||||
iterator ||= _.identity
|
||||
low = 0
|
||||
high = array.length
|
||||
while low < high
|
||||
mid = (low + high) >> 1
|
||||
if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
|
||||
low
|
||||
|
||||
|
||||
# Convert anything iterable into a real, live array.
|
||||
_.toArray = (iterable) ->
|
||||
return [] if (!iterable)
|
||||
return iterable.toArray() if (iterable.toArray)
|
||||
return iterable if (_.isArray(iterable))
|
||||
return slice.call(iterable) if (_.isArguments(iterable))
|
||||
_.values(iterable)
|
||||
|
||||
|
||||
# Return the number of elements in an object.
|
||||
_.size = (obj) -> _.toArray(obj).length
|
||||
|
||||
|
||||
# Array Functions
|
||||
# ---------------
|
||||
|
||||
# Get the first element of an array. Passing `n` will return the first N
|
||||
# values in the array. Aliased as **head**. The `guard` check allows it to work
|
||||
# with **map**.
|
||||
_.first = (array, n, guard) ->
|
||||
if n and not guard then slice.call(array, 0, n) else array[0]
|
||||
|
||||
|
||||
# Returns everything but the first entry of the array. Aliased as **tail**.
|
||||
# Especially useful on the arguments object. Passing an `index` will return
|
||||
# the rest of the values in the array from that index onward. The `guard`
|
||||
# check allows it to work with **map**.
|
||||
_.rest = (array, index, guard) ->
|
||||
slice.call(array, if _.isUndefined(index) or guard then 1 else index)
|
||||
|
||||
|
||||
# Get the last element of an array.
|
||||
_.last = (array) -> array[array.length - 1]
|
||||
|
||||
|
||||
# Trim out all falsy values from an array.
|
||||
_.compact = (array) -> item for item in array when item
|
||||
|
||||
|
||||
# Return a completely flattened version of an array.
|
||||
_.flatten = (array) ->
|
||||
_.reduce array, (memo, value) ->
|
||||
return memo.concat(_.flatten(value)) if _.isArray value
|
||||
memo.push value
|
||||
memo
|
||||
, []
|
||||
|
||||
|
||||
# Return a version of the array that does not contain the specified value(s).
|
||||
_.without = (array) ->
|
||||
values = _.rest arguments
|
||||
val for val in _.toArray(array) when not _.include values, val
|
||||
|
||||
|
||||
# Produce a duplicate-free version of the array. If the array has already
|
||||
# been sorted, you have the option of using a faster algorithm.
|
||||
_.uniq = (array, isSorted) ->
|
||||
memo = []
|
||||
for el, i in _.toArray array
|
||||
memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
|
||||
memo
|
||||
|
||||
|
||||
# Produce an array that contains every item shared between all the
|
||||
# passed-in arrays.
|
||||
_.intersect = (array) ->
|
||||
rest = _.rest arguments
|
||||
_.select _.uniq(array), (item) ->
|
||||
_.all rest, (other) ->
|
||||
_.indexOf(other, item) >= 0
|
||||
|
||||
|
||||
# Zip together multiple lists into a single array -- elements that share
|
||||
# an index go together.
|
||||
_.zip = ->
|
||||
length = _.max _.pluck arguments, 'length'
|
||||
results = new Array length
|
||||
for i in [0...length]
|
||||
results[i] = _.pluck arguments, String i
|
||||
results
|
||||
|
||||
|
||||
# If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
|
||||
# we need this function. Return the position of the first occurrence of an
|
||||
# item in an array, or -1 if the item is not included in the array.
|
||||
_.indexOf = (array, item) ->
|
||||
return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
|
||||
i = 0; l = array.length
|
||||
while l - i
|
||||
if array[i] is item then return i else i++
|
||||
-1
|
||||
|
||||
|
||||
# Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
|
||||
# if possible.
|
||||
_.lastIndexOf = (array, item) ->
|
||||
return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
|
||||
i = array.length
|
||||
while i
|
||||
if array[i] is item then return i else i--
|
||||
-1
|
||||
|
||||
|
||||
# Generate an integer Array containing an arithmetic progression. A port of
|
||||
# [the native Python **range** function](http://docs.python.org/library/functions.html#range).
|
||||
_.range = (start, stop, step) ->
|
||||
a = arguments
|
||||
solo = a.length <= 1
|
||||
i = start = if solo then 0 else a[0]
|
||||
stop = if solo then a[0] else a[1]
|
||||
step = a[2] or 1
|
||||
len = Math.ceil((stop - start) / step)
|
||||
return [] if len <= 0
|
||||
range = new Array len
|
||||
idx = 0
|
||||
loop
|
||||
return range if (if step > 0 then i - stop else stop - i) >= 0
|
||||
range[idx] = i
|
||||
idx++
|
||||
i+= step
|
||||
|
||||
|
||||
# Function Functions
|
||||
# ------------------
|
||||
|
||||
# Create a function bound to a given object (assigning `this`, and arguments,
|
||||
# optionally). Binding with arguments is also known as **curry**.
|
||||
_.bind = (func, obj) ->
|
||||
args = _.rest arguments, 2
|
||||
-> func.apply obj or root, args.concat arguments
|
||||
|
||||
|
||||
# Bind all of an object's methods to that object. Useful for ensuring that
|
||||
# all callbacks defined on an object belong to it.
|
||||
_.bindAll = (obj) ->
|
||||
funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
|
||||
_.each funcs, (f) -> obj[f] = _.bind obj[f], obj
|
||||
obj
|
||||
|
||||
|
||||
# Delays a function for the given number of milliseconds, and then calls
|
||||
# it with the arguments supplied.
|
||||
_.delay = (func, wait) ->
|
||||
args = _.rest arguments, 2
|
||||
setTimeout((-> func.apply(func, args)), wait)
|
||||
|
||||
|
||||
# Memoize an expensive function by storing its results.
|
||||
_.memoize = (func, hasher) ->
|
||||
memo = {}
|
||||
hasher or= _.identity
|
||||
->
|
||||
key = hasher.apply this, arguments
|
||||
return memo[key] if key of memo
|
||||
memo[key] = func.apply this, arguments
|
||||
|
||||
|
||||
# Defers a function, scheduling it to run after the current call stack has
|
||||
# cleared.
|
||||
_.defer = (func) ->
|
||||
_.delay.apply _, [func, 1].concat _.rest arguments
|
||||
|
||||
|
||||
# Returns the first function passed as an argument to the second,
|
||||
# allowing you to adjust arguments, run code before and after, and
|
||||
# conditionally execute the original function.
|
||||
_.wrap = (func, wrapper) ->
|
||||
-> wrapper.apply wrapper, [func].concat arguments
|
||||
|
||||
|
||||
# Returns a function that is the composition of a list of functions, each
|
||||
# consuming the return value of the function that follows.
|
||||
_.compose = ->
|
||||
funcs = arguments
|
||||
->
|
||||
args = arguments
|
||||
for i in [funcs.length - 1..0] by -1
|
||||
args = [funcs[i].apply(this, args)]
|
||||
args[0]
|
||||
|
||||
|
||||
# Object Functions
|
||||
# ----------------
|
||||
|
||||
# Retrieve the names of an object's properties.
|
||||
_.keys = nativeKeys or (obj) ->
|
||||
return _.range 0, obj.length if _.isArray(obj)
|
||||
key for key, val of obj
|
||||
|
||||
|
||||
# Retrieve the values of an object's properties.
|
||||
_.values = (obj) ->
|
||||
_.map obj, _.identity
|
||||
|
||||
|
||||
# Return a sorted list of the function names available in Underscore.
|
||||
_.functions = (obj) ->
|
||||
_.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
|
||||
|
||||
|
||||
# Extend a given object with all of the properties in a source object.
|
||||
_.extend = (obj) ->
|
||||
for source in _.rest(arguments)
|
||||
obj[key] = val for key, val of source
|
||||
obj
|
||||
|
||||
|
||||
# Create a (shallow-cloned) duplicate of an object.
|
||||
_.clone = (obj) ->
|
||||
return obj.slice 0 if _.isArray obj
|
||||
_.extend {}, obj
|
||||
|
||||
|
||||
# Invokes interceptor with the obj, and then returns obj.
|
||||
# The primary purpose of this method is to "tap into" a method chain,
|
||||
# in order to perform operations on intermediate results within
|
||||
the chain.
|
||||
_.tap = (obj, interceptor) ->
|
||||
interceptor obj
|
||||
obj
|
||||
|
||||
|
||||
# Perform a deep comparison to check if two objects are equal.
|
||||
_.isEqual = (a, b) ->
|
||||
# Check object identity.
|
||||
return true if a is b
|
||||
# Different types?
|
||||
atype = typeof(a); btype = typeof(b)
|
||||
return false if atype isnt btype
|
||||
# Basic equality test (watch out for coercions).
|
||||
return true if `a == b`
|
||||
# One is falsy and the other truthy.
|
||||
return false if (!a and b) or (a and !b)
|
||||
# One of them implements an `isEqual()`?
|
||||
return a.isEqual(b) if a.isEqual
|
||||
# Check dates' integer values.
|
||||
return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
|
||||
# Both are NaN?
|
||||
return false if _.isNaN(a) and _.isNaN(b)
|
||||
# Compare regular expressions.
|
||||
if _.isRegExp(a) and _.isRegExp(b)
|
||||
return a.source is b.source and
|
||||
a.global is b.global and
|
||||
a.ignoreCase is b.ignoreCase and
|
||||
a.multiline is b.multiline
|
||||
# If a is not an object by this point, we can't handle it.
|
||||
return false if atype isnt 'object'
|
||||
# Check for different array lengths before comparing contents.
|
||||
return false if a.length and (a.length isnt b.length)
|
||||
# Nothing else worked, deep compare the contents.
|
||||
aKeys = _.keys(a); bKeys = _.keys(b)
|
||||
# Different object sizes?
|
||||
return false if aKeys.length isnt bKeys.length
|
||||
# Recursive comparison of contents.
|
||||
return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
|
||||
true
|
||||
|
||||
|
||||
# Is a given array or object empty?
|
||||
_.isEmpty = (obj) ->
|
||||
return obj.length is 0 if _.isArray(obj) or _.isString(obj)
|
||||
return false for own key of obj
|
||||
true
|
||||
|
||||
|
||||
# Is a given value a DOM element?
|
||||
_.isElement = (obj) -> obj and obj.nodeType is 1
|
||||
|
||||
|
||||
# Is a given value an array?
|
||||
_.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
|
||||
|
||||
|
||||
# Is a given variable an arguments object?
|
||||
_.isArguments = (obj) -> obj and obj.callee
|
||||
|
||||
|
||||
# Is the given value a function?
|
||||
_.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
|
||||
|
||||
|
||||
# Is the given value a string?
|
||||
_.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
|
||||
|
||||
|
||||
# Is a given value a number?
|
||||
_.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
|
||||
|
||||
|
||||
# Is a given value a boolean?
|
||||
_.isBoolean = (obj) -> obj is true or obj is false
|
||||
|
||||
|
||||
# Is a given value a Date?
|
||||
_.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
|
||||
|
||||
|
||||
# Is the given value a regular expression?
|
||||
_.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
|
||||
|
||||
|
||||
# Is the given value NaN -- this one is interesting. `NaN != NaN`, and
|
||||
# `isNaN(undefined) == true`, so we make sure it's a number first.
|
||||
_.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
|
||||
|
||||
|
||||
# Is a given value equal to null?
|
||||
_.isNull = (obj) -> obj is null
|
||||
|
||||
|
||||
# Is a given variable undefined?
|
||||
_.isUndefined = (obj) -> typeof obj is 'undefined'
|
||||
|
||||
|
||||
# Utility Functions
|
||||
# -----------------
|
||||
|
||||
# Run Underscore.js in noConflict mode, returning the `_` variable to its
|
||||
# previous owner. Returns a reference to the Underscore object.
|
||||
_.noConflict = ->
|
||||
root._ = previousUnderscore
|
||||
this
|
||||
|
||||
|
||||
# Keep the identity function around for default iterators.
|
||||
_.identity = (value) -> value
|
||||
|
||||
|
||||
# Run a function `n` times.
|
||||
_.times = (n, iterator, context) ->
|
||||
iterator.call context, i for i in [0...n]
|
||||
|
||||
|
||||
# Break out of the middle of an iteration.
|
||||
_.breakLoop = -> throw breaker
|
||||
|
||||
|
||||
# Add your own custom functions to the Underscore object, ensuring that
|
||||
# they're correctly added to the OOP wrapper as well.
|
||||
_.mixin = (obj) ->
|
||||
for name in _.functions(obj)
|
||||
addToWrapper name, _[name] = obj[name]
|
||||
|
||||
|
||||
# Generate a unique integer id (unique within the entire client session).
|
||||
# Useful for temporary DOM ids.
|
||||
idCounter = 0
|
||||
_.uniqueId = (prefix) ->
|
||||
(prefix or '') + idCounter++
|
||||
|
||||
|
||||
# By default, Underscore uses **ERB**-style template delimiters, change the
|
||||
# following template settings to use alternative delimiters.
|
||||
_.templateSettings = {
|
||||
start: '<%'
|
||||
end: '%>'
|
||||
interpolate: /<%=(.+?)%>/g
|
||||
}
|
||||
|
||||
|
||||
# JavaScript templating a-la **ERB**, pilfered from John Resig's
|
||||
# *Secrets of the JavaScript Ninja*, page 83.
|
||||
# Single-quote fix from Rick Strahl.
|
||||
# With alterations for arbitrary delimiters, and to preserve whitespace.
|
||||
_.template = (str, data) ->
|
||||
c = _.templateSettings
|
||||
endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
|
||||
fn = new Function 'obj',
|
||||
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
||||
'with(obj||{}){p.push(\'' +
|
||||
str.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(endMatch,"<22><><EFBFBD>")
|
||||
.split("'").join("\\'")
|
||||
.split("<22><><EFBFBD>").join("'")
|
||||
.replace(c.interpolate, "',$1,'")
|
||||
.split(c.start).join("');")
|
||||
.split(c.end).join("p.push('") +
|
||||
"');}return p.join('');"
|
||||
if data then fn(data) else fn
|
||||
|
||||
|
||||
# Aliases
|
||||
# -------
|
||||
|
||||
_.forEach = _.each
|
||||
_.foldl = _.inject = _.reduce
|
||||
_.foldr = _.reduceRight
|
||||
_.select = _.filter
|
||||
_.all = _.every
|
||||
_.any = _.some
|
||||
_.contains = _.include
|
||||
_.head = _.first
|
||||
_.tail = _.rest
|
||||
_.methods = _.functions
|
||||
|
||||
|
||||
# Setup the OOP Wrapper
|
||||
# ---------------------
|
||||
|
||||
# If Underscore is called as a function, it returns a wrapped object that
|
||||
# can be used OO-style. This wrapper holds altered versions of all the
|
||||
# underscore functions. Wrapped objects may be chained.
|
||||
wrapper = (obj) ->
|
||||
this._wrapped = obj
|
||||
this
|
||||
|
||||
|
||||
# Helper function to continue chaining intermediate results.
|
||||
result = (obj, chain) ->
|
||||
if chain then _(obj).chain() else obj
|
||||
|
||||
|
||||
# A method to easily add functions to the OOP wrapper.
|
||||
addToWrapper = (name, func) ->
|
||||
wrapper.prototype[name] = ->
|
||||
args = _.toArray arguments
|
||||
unshift.call args, this._wrapped
|
||||
result func.apply(_, args), this._chain
|
||||
|
||||
|
||||
# Add all ofthe Underscore functions to the wrapper object.
|
||||
_.mixin _
|
||||
|
||||
|
||||
# Add all mutator Array functions to the wrapper.
|
||||
_.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
|
||||
method = Array.prototype[name]
|
||||
wrapper.prototype[name] = ->
|
||||
method.apply(this._wrapped, arguments)
|
||||
result(this._wrapped, this._chain)
|
||||
|
||||
|
||||
# Add all accessor Array functions to the wrapper.
|
||||
_.each ['concat', 'join', 'slice'], (name) ->
|
||||
method = Array.prototype[name]
|
||||
wrapper.prototype[name] = ->
|
||||
result(method.apply(this._wrapped, arguments), this._chain)
|
||||
|
||||
|
||||
# Start chaining a wrapped Underscore object.
|
||||
wrapper::chain = ->
|
||||
this._chain = true
|
||||
this
|
||||
|
||||
|
||||
# Extracts the result from a wrapped and chained object.
|
||||
wrapper::value = -> this._wrapped
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/vnd.coffeescript</code>, <code>text/coffeescript</code>, <code>text/x-coffeescript</code>.</p>
|
||||
|
||||
<p>The CoffeeScript mode was written by Jeff Pickhardt.</p>
|
||||
|
||||
</article>
|
||||
177
libraries/codemirror/mode/commonlisp/index.html
vendored
177
libraries/codemirror/mode/commonlisp/index.html
vendored
@@ -1,177 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Common Lisp 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="commonlisp.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="#">Common Lisp</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Common Lisp mode</h2>
|
||||
<form><textarea id="code" name="code">(in-package :cl-postgres)
|
||||
|
||||
;; These are used to synthesize reader and writer names for integer
|
||||
;; reading/writing functions when the amount of bytes and the
|
||||
;; signedness is known. Both the macro that creates the functions and
|
||||
;; some macros that use them create names this way.
|
||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
(defun integer-reader-name (bytes signed)
|
||||
(intern (with-standard-io-syntax
|
||||
(format nil "~a~a~a~a" '#:read- (if signed "" '#:u) '#:int bytes))))
|
||||
(defun integer-writer-name (bytes signed)
|
||||
(intern (with-standard-io-syntax
|
||||
(format nil "~a~a~a~a" '#:write- (if signed "" '#:u) '#:int bytes)))))
|
||||
|
||||
(defmacro integer-reader (bytes)
|
||||
"Create a function to read integers from a binary stream."
|
||||
(let ((bits (* bytes 8)))
|
||||
(labels ((return-form (signed)
|
||||
(if signed
|
||||
`(if (logbitp ,(1- bits) result)
|
||||
(dpb result (byte ,(1- bits) 0) -1)
|
||||
result)
|
||||
`result))
|
||||
(generate-reader (signed)
|
||||
`(defun ,(integer-reader-name bytes signed) (socket)
|
||||
(declare (type stream socket)
|
||||
#.*optimize*)
|
||||
,(if (= bytes 1)
|
||||
`(let ((result (the (unsigned-byte 8) (read-byte socket))))
|
||||
(declare (type (unsigned-byte 8) result))
|
||||
,(return-form signed))
|
||||
`(let ((result 0))
|
||||
(declare (type (unsigned-byte ,bits) result))
|
||||
,@(loop :for byte :from (1- bytes) :downto 0
|
||||
:collect `(setf (ldb (byte 8 ,(* 8 byte)) result)
|
||||
(the (unsigned-byte 8) (read-byte socket))))
|
||||
,(return-form signed))))))
|
||||
`(progn
|
||||
;; This causes weird errors on SBCL in some circumstances. Disabled for now.
|
||||
;; (declaim (inline ,(integer-reader-name bytes t)
|
||||
;; ,(integer-reader-name bytes nil)))
|
||||
(declaim (ftype (function (t) (signed-byte ,bits))
|
||||
,(integer-reader-name bytes t)))
|
||||
,(generate-reader t)
|
||||
(declaim (ftype (function (t) (unsigned-byte ,bits))
|
||||
,(integer-reader-name bytes nil)))
|
||||
,(generate-reader nil)))))
|
||||
|
||||
(defmacro integer-writer (bytes)
|
||||
"Create a function to write integers to a binary stream."
|
||||
(let ((bits (* 8 bytes)))
|
||||
`(progn
|
||||
(declaim (inline ,(integer-writer-name bytes t)
|
||||
,(integer-writer-name bytes nil)))
|
||||
(defun ,(integer-writer-name bytes nil) (socket value)
|
||||
(declare (type stream socket)
|
||||
(type (unsigned-byte ,bits) value)
|
||||
#.*optimize*)
|
||||
,@(if (= bytes 1)
|
||||
`((write-byte value socket))
|
||||
(loop :for byte :from (1- bytes) :downto 0
|
||||
:collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
|
||||
socket)))
|
||||
(values))
|
||||
(defun ,(integer-writer-name bytes t) (socket value)
|
||||
(declare (type stream socket)
|
||||
(type (signed-byte ,bits) value)
|
||||
#.*optimize*)
|
||||
,@(if (= bytes 1)
|
||||
`((write-byte (ldb (byte 8 0) value) socket))
|
||||
(loop :for byte :from (1- bytes) :downto 0
|
||||
:collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
|
||||
socket)))
|
||||
(values)))))
|
||||
|
||||
;; All the instances of the above that we need.
|
||||
|
||||
(integer-reader 1)
|
||||
(integer-reader 2)
|
||||
(integer-reader 4)
|
||||
(integer-reader 8)
|
||||
|
||||
(integer-writer 1)
|
||||
(integer-writer 2)
|
||||
(integer-writer 4)
|
||||
|
||||
(defun write-bytes (socket bytes)
|
||||
"Write a byte-array to a stream."
|
||||
(declare (type stream socket)
|
||||
(type (simple-array (unsigned-byte 8)) bytes)
|
||||
#.*optimize*)
|
||||
(write-sequence bytes socket))
|
||||
|
||||
(defun write-str (socket string)
|
||||
"Write a null-terminated string to a stream \(encoding it when UTF-8
|
||||
support is enabled.)."
|
||||
(declare (type stream socket)
|
||||
(type string string)
|
||||
#.*optimize*)
|
||||
(enc-write-string string socket)
|
||||
(write-uint1 socket 0))
|
||||
|
||||
(declaim (ftype (function (t unsigned-byte)
|
||||
(simple-array (unsigned-byte 8) (*)))
|
||||
read-bytes))
|
||||
(defun read-bytes (socket length)
|
||||
"Read a byte array of the given length from a stream."
|
||||
(declare (type stream socket)
|
||||
(type fixnum length)
|
||||
#.*optimize*)
|
||||
(let ((result (make-array length :element-type '(unsigned-byte 8))))
|
||||
(read-sequence result socket)
|
||||
result))
|
||||
|
||||
(declaim (ftype (function (t) string) read-str))
|
||||
(defun read-str (socket)
|
||||
"Read a null-terminated string from a stream. Takes care of encoding
|
||||
when UTF-8 support is enabled."
|
||||
(declare (type stream socket)
|
||||
#.*optimize*)
|
||||
(enc-read-string socket :null-terminated t))
|
||||
|
||||
(defun skip-bytes (socket length)
|
||||
"Skip a given number of bytes in a binary stream."
|
||||
(declare (type stream socket)
|
||||
(type (unsigned-byte 32) length)
|
||||
#.*optimize*)
|
||||
(dotimes (i length)
|
||||
(read-byte socket)))
|
||||
|
||||
(defun skip-str (socket)
|
||||
"Skip a null-terminated string."
|
||||
(declare (type stream socket)
|
||||
#.*optimize*)
|
||||
(loop :for char :of-type fixnum = (read-byte socket)
|
||||
:until (zerop char)))
|
||||
|
||||
(defun ensure-socket-is-closed (socket &key abort)
|
||||
(when (open-stream-p socket)
|
||||
(handler-case
|
||||
(close socket :abort abort)
|
||||
(error (error)
|
||||
(warn "Ignoring the error which happened while trying to close PostgreSQL socket: ~A" error)))))
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {lineNumbers: true});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-common-lisp</code>.</p>
|
||||
|
||||
</article>
|
||||
116
libraries/codemirror/mode/crystal/index.html
vendored
116
libraries/codemirror/mode/crystal/index.html
vendored
@@ -1,116 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Crystal 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="crystal.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default span.cm-arrow { color: red; }
|
||||
</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="#">Crystal</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Crystal mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
# Features of Crystal
|
||||
# - Ruby-inspired syntax.
|
||||
# - Statically type-checked but without having to specify the type of variables or method arguments.
|
||||
# - Be able to call C code by writing bindings to it in Crystal.
|
||||
# - Have compile-time evaluation and generation of code, to avoid boilerplate code.
|
||||
# - Compile to efficient native code.
|
||||
|
||||
# A very basic HTTP server
|
||||
require "http/server"
|
||||
|
||||
server = HTTP::Server.new(8080) do |request|
|
||||
HTTP::Response.ok "text/plain", "Hello world, got #{request.path}!"
|
||||
end
|
||||
|
||||
puts "Listening on http://0.0.0.0:8080"
|
||||
server.listen
|
||||
|
||||
module Foo
|
||||
abstract def abstract_method : String
|
||||
|
||||
@[AlwaysInline]
|
||||
def with_foofoo
|
||||
with Foo.new(self) yield
|
||||
end
|
||||
|
||||
struct Foo
|
||||
def initialize(@foo : ::Foo)
|
||||
end
|
||||
|
||||
def hello_world
|
||||
@foo.abstract_method
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Bar
|
||||
include Foo
|
||||
|
||||
@@foobar = 12345
|
||||
|
||||
def initialize(@bar : Int32)
|
||||
end
|
||||
|
||||
macro alias_method(name, method)
|
||||
def {{ name }}(*args)
|
||||
{{ method }}(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def a_method
|
||||
"Hello, World"
|
||||
end
|
||||
|
||||
alias_method abstract_method, a_method
|
||||
|
||||
def show_instance_vars : Nil
|
||||
{% for var in @type.instance_vars %}
|
||||
puts "@{{ var }} = #{ @{{ var }} }"
|
||||
{% end %}
|
||||
end
|
||||
end
|
||||
|
||||
class Baz < Bar; end
|
||||
|
||||
lib LibC
|
||||
fun c_puts = "puts"(str : Char*) : Int
|
||||
end
|
||||
|
||||
baz = Baz.new(100)
|
||||
baz.show_instance_vars
|
||||
baz.with_foofoo do
|
||||
LibC.c_puts hello_world
|
||||
end
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-crystal",
|
||||
matchBrackets: true,
|
||||
indentUnit: 2
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-crystal</code>.</p>
|
||||
</article>
|
||||
212
libraries/codemirror/mode/css/css.js
vendored
212
libraries/codemirror/mode/css/css.js
vendored
@@ -442,117 +442,149 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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"
|
||||
"pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme"
|
||||
], mediaFeatures = keySet(mediaFeatures_);
|
||||
|
||||
var mediaValueKeywords_ = [
|
||||
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
|
||||
"interlace", "progressive"
|
||||
"interlace", "progressive",
|
||||
"dark", "light"
|
||||
], mediaValueKeywords = keySet(mediaValueKeywords_);
|
||||
|
||||
var propertyKeywords_ = [
|
||||
"align-content", "align-items", "align-self", "alignment-adjust",
|
||||
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
||||
"alignment-baseline", "all", "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",
|
||||
"animation-timing-function", "appearance", "azimuth", "backdrop-filter",
|
||||
"backface-visibility", "background", "background-attachment",
|
||||
"background-blend-mode", "background-clip", "background-color",
|
||||
"background-image", "background-origin", "background-position",
|
||||
"background-position-x", "background-position-y", "background-repeat",
|
||||
"background-size", "baseline-shift", "binding", "bleed", "block-size",
|
||||
"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",
|
||||
"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", "contain",
|
||||
"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-family", "font-feature-settings", "font-kerning",
|
||||
"font-language-override", "font-optical-sizing", "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-variation-settings", "font-weight", "gap",
|
||||
"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",
|
||||
"inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline",
|
||||
"inset-inline-end", "inset-inline-start", "isolation", "justify-content",
|
||||
"justify-items", "justify-self", "left", "letter-spacing", "line-break",
|
||||
"line-height", "line-height-step", "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",
|
||||
"margin-bottom", "margin-left", "margin-right", "margin-top", "marks",
|
||||
"marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed",
|
||||
"marquee-style", "mask-clip", "mask-composite", "mask-image", "mask-mode",
|
||||
"mask-origin", "mask-position", "mask-repeat", "mask-size","mask-type",
|
||||
"max-block-size", "max-height", "max-inline-size",
|
||||
"max-width", "min-block-size", "min-height", "min-inline-size", "min-width",
|
||||
"mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right",
|
||||
"nav-up", "object-fit", "object-position", "offset", "offset-anchor",
|
||||
"offset-distance", "offset-path", "offset-position", "offset-rotate",
|
||||
"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", "rotate", "rotation", "rotation-point",
|
||||
"row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span",
|
||||
"scale", "scroll-behavior", "scroll-margin", "scroll-margin-block",
|
||||
"scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom",
|
||||
"scroll-margin-inline", "scroll-margin-inline-end",
|
||||
"scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right",
|
||||
"scroll-margin-top", "scroll-padding", "scroll-padding-block",
|
||||
"scroll-padding-block-end", "scroll-padding-block-start",
|
||||
"scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end",
|
||||
"scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right",
|
||||
"scroll-padding-top", "scroll-snap-align", "scroll-snap-type",
|
||||
"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-combine-upright", "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",
|
||||
"text-decoration-skip-ink", "text-decoration-style", "text-emphasis",
|
||||
"text-emphasis-color", "text-emphasis-position", "text-emphasis-style",
|
||||
"text-height", "text-indent", "text-justify", "text-orientation",
|
||||
"text-outline", "text-overflow", "text-rendering", "text-shadow",
|
||||
"text-size-adjust", "text-space-collapse", "text-transform",
|
||||
"text-underline-position", "text-wrap", "top", "touch-action", "transform", "transform-origin",
|
||||
"transform-style", "transition", "transition-delay", "transition-duration",
|
||||
"transition-property", "transition-timing-function", "translate",
|
||||
"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", "writing-mode", "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",
|
||||
"marker", "marker-end", "marker-mid", "marker-start", "paint-order", "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"
|
||||
"glyph-orientation-vertical", "text-anchor", "writing-mode",
|
||||
], propertyKeywords = keySet(propertyKeywords_);
|
||||
|
||||
var nonStandardPropertyKeywords_ = [
|
||||
"border-block", "border-block-color", "border-block-end",
|
||||
"border-block-end-color", "border-block-end-style", "border-block-end-width",
|
||||
"border-block-start", "border-block-start-color", "border-block-start-style",
|
||||
"border-block-start-width", "border-block-style", "border-block-width",
|
||||
"border-inline", "border-inline-color", "border-inline-end",
|
||||
"border-inline-end-color", "border-inline-end-style",
|
||||
"border-inline-end-width", "border-inline-start", "border-inline-start-color",
|
||||
"border-inline-start-style", "border-inline-start-width",
|
||||
"border-inline-style", "border-inline-width", "margin-block",
|
||||
"margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end",
|
||||
"margin-inline-start", "padding-block", "padding-block-end",
|
||||
"padding-block-start", "padding-inline", "padding-inline-end",
|
||||
"padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color",
|
||||
"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"
|
||||
"scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration",
|
||||
"searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom"
|
||||
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
||||
|
||||
var fontProperties_ = [
|
||||
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
||||
"font-stretch", "font-weight", "font-style"
|
||||
"font-display", "font-family", "src", "unicode-range", "font-variant",
|
||||
"font-feature-settings", "font-stretch", "font-weight", "font-style"
|
||||
], fontProperties = keySet(fontProperties_);
|
||||
|
||||
var counterDescriptors_ = [
|
||||
@@ -594,7 +626,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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",
|
||||
"avoid-region", "axis-pan", "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",
|
||||
@@ -618,7 +650,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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",
|
||||
"extra-expanded", "fantasy", "fast", "fill", "fill-box", "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",
|
||||
@@ -633,7 +665,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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",
|
||||
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "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",
|
||||
@@ -642,13 +674,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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",
|
||||
"mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "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",
|
||||
"painted", "page", "paused", "persian", "perspective", "pinch-zoom", "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",
|
||||
@@ -666,8 +698,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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",
|
||||
"square-button", "start", "static", "status-bar", "stretch", "stroke", "stroke-box", "sub",
|
||||
"subpixel-antialiased", "svg_masks", "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",
|
||||
@@ -677,10 +709,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
"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",
|
||||
"transparent", "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "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",
|
||||
"var", "vertical", "vertical-text", "view-box", "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"
|
||||
|
||||
2
libraries/codemirror/mode/css/gss.html
vendored
2
libraries/codemirror/mode/css/gss.html
vendored
@@ -13,7 +13,7 @@
|
||||
<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>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
||||
17
libraries/codemirror/mode/css/gss_test.js
vendored
17
libraries/codemirror/mode/css/gss_test.js
vendored
@@ -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];",
|
||||
"}",
|
||||
"}");
|
||||
|
||||
})();
|
||||
75
libraries/codemirror/mode/css/index.html
vendored
75
libraries/codemirror/mode/css/index.html
vendored
@@ -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>
|
||||
2
libraries/codemirror/mode/css/less.html
vendored
2
libraries/codemirror/mode/css/less.html
vendored
@@ -10,7 +10,7 @@
|
||||
<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>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
||||
54
libraries/codemirror/mode/css/less_test.js
vendored
54
libraries/codemirror/mode/css/less_test.js
vendored
@@ -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]; }");
|
||||
})();
|
||||
2
libraries/codemirror/mode/css/scss.html
vendored
2
libraries/codemirror/mode/css/scss.html
vendored
@@ -10,7 +10,7 @@
|
||||
<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>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
||||
110
libraries/codemirror/mode/css/scss_test.js
vendored
110
libraries/codemirror/mode/css/scss_test.js
vendored
@@ -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];",
|
||||
" }",
|
||||
"}");
|
||||
})();
|
||||
217
libraries/codemirror/mode/css/test.js
vendored
217
libraries/codemirror/mode/css/test.js
vendored
@@ -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];",
|
||||
"}")
|
||||
})();
|
||||
3
libraries/codemirror/mode/cypher/cypher.js
vendored
3
libraries/codemirror/mode/cypher/cypher.js
vendored
@@ -46,7 +46,7 @@
|
||||
var word = stream.current();
|
||||
if (funcs.test(word)) return "builtin";
|
||||
if (preds.test(word)) return "def";
|
||||
if (keywords.test(word)) return "keyword";
|
||||
if (keywords.test(word) || systemKeywords.test(word)) return "keyword";
|
||||
return "variable";
|
||||
}
|
||||
};
|
||||
@@ -67,6 +67,7 @@
|
||||
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
|
||||
var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
|
||||
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]);
|
||||
var systemKeywords = wordRegexp(["access", "active", "assign", "all", "alter", "as", "catalog", "change", "copy", "create", "constraint", "constraints", "current", "database", "databases", "dbms", "default", "deny", "drop", "element", "elements", "exists", "from", "grant", "graph", "graphs", "if", "index", "indexes", "label", "labels", "management", "match", "name", "names", "new", "node", "nodes", "not", "of", "on", "or", "password", "populated", "privileges", "property", "read", "relationship", "relationships", "remove", "replace", "required", "revoke", "role", "roles", "set", "show", "start", "status", "stop", "suspended", "to", "traverse", "type", "types", "user", "users", "with", "write"]);
|
||||
var operatorChars = /[*+\-<>=&|~%^]/;
|
||||
|
||||
return {
|
||||
|
||||
64
libraries/codemirror/mode/cypher/index.html
vendored
64
libraries/codemirror/mode/cypher/index.html
vendored
@@ -1,64 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Cypher Mode for CodeMirror</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css" />
|
||||
<link rel="stylesheet" href="../../theme/neo.css" />
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="cypher.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="#">Cypher Mode for CodeMirror</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Cypher Mode for CodeMirror</h2>
|
||||
<form>
|
||||
<textarea id="code" name="code">// Cypher Mode for CodeMirror, using the neo theme
|
||||
MATCH (joe { name: 'Joe' })-[:knows*2..2]-(friend_of_friend)
|
||||
WHERE NOT (joe)-[:knows]-(friend_of_friend)
|
||||
RETURN friend_of_friend.name, COUNT(*)
|
||||
ORDER BY COUNT(*) DESC , friend_of_friend.name
|
||||
</textarea>
|
||||
</form>
|
||||
<p><strong>MIME types defined:</strong>
|
||||
<code><a href="?mime=application/x-cypher-query">application/x-cypher-query</a></code>
|
||||
</p>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var mime = 'application/x-cypher-query';
|
||||
// get mime type
|
||||
if (window.location.href.indexOf('mime=') > -1) {
|
||||
mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
|
||||
}
|
||||
window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
||||
mode: mime,
|
||||
indentWithTabs: true,
|
||||
smartIndent: true,
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
autofocus: true,
|
||||
theme: 'neo'
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
</article>
|
||||
37
libraries/codemirror/mode/cypher/test.js
vendored
37
libraries/codemirror/mode/cypher/test.js
vendored
@@ -1,37 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "cypher");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("unbalancedDoubledQuotedString",
|
||||
"[string \"a'b\"][variable c]");
|
||||
|
||||
MT("unbalancedSingleQuotedString",
|
||||
"[string 'a\"b'][variable c]");
|
||||
|
||||
MT("doubleQuotedString",
|
||||
"[string \"a\"][variable b]");
|
||||
|
||||
MT("singleQuotedString",
|
||||
"[string 'a'][variable b]");
|
||||
|
||||
MT("single attribute (with content)",
|
||||
"[node {][atom a:][string 'a'][node }]");
|
||||
|
||||
MT("multiple attribute, singleQuotedString (with content)",
|
||||
"[node {][atom a:][string 'a'][node ,][atom b:][string 'b'][node }]");
|
||||
|
||||
MT("multiple attribute, doubleQuotedString (with content)",
|
||||
"[node {][atom a:][string \"a\"][node ,][atom b:][string \"b\"][node }]");
|
||||
|
||||
MT("single attribute (without content)",
|
||||
"[node {][atom a:][string 'a'][node }]");
|
||||
|
||||
MT("multiple attribute, singleQuotedString (without content)",
|
||||
"[node {][atom a:][string ''][node ,][atom b:][string ''][node }]");
|
||||
|
||||
MT("multiple attribute, doubleQuotedString (without content)",
|
||||
"[node {][atom a:][string \"\"][node ,][atom b:][string \"\"][node }]");
|
||||
})();
|
||||
273
libraries/codemirror/mode/d/index.html
vendored
273
libraries/codemirror/mode/d/index.html
vendored
@@ -1,273 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: D 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="d.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</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="#">D</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>D mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* D demo code // copied from phobos/sd/metastrings.d */
|
||||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
Templates with which to do compile-time manipulation of strings.
|
||||
|
||||
Macros:
|
||||
WIKI = Phobos/StdMetastrings
|
||||
|
||||
Copyright: Copyright Digital Mars 2007 - 2009.
|
||||
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
|
||||
Authors: $(WEB digitalmars.com, Walter Bright),
|
||||
Don Clugston
|
||||
Source: $(PHOBOSSRC std/_metastrings.d)
|
||||
*/
|
||||
/*
|
||||
Copyright Digital Mars 2007 - 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
module std.metastrings;
|
||||
|
||||
/**
|
||||
Formats constants into a string at compile time. Analogous to $(XREF
|
||||
string,format).
|
||||
|
||||
Parameters:
|
||||
|
||||
A = tuple of constants, which can be strings, characters, or integral
|
||||
values.
|
||||
|
||||
Formats:
|
||||
* The formats supported are %s for strings, and %%
|
||||
* for the % character.
|
||||
Example:
|
||||
---
|
||||
import std.metastrings;
|
||||
import std.stdio;
|
||||
|
||||
void main()
|
||||
{
|
||||
string s = Format!("Arg %s = %s", "foo", 27);
|
||||
writefln(s); // "Arg foo = 27"
|
||||
}
|
||||
* ---
|
||||
*/
|
||||
|
||||
template Format(A...)
|
||||
{
|
||||
static if (A.length == 0)
|
||||
enum Format = "";
|
||||
else static if (is(typeof(A[0]) : const(char)[]))
|
||||
enum Format = FormatString!(A[0], A[1..$]);
|
||||
else
|
||||
enum Format = toStringNow!(A[0]) ~ Format!(A[1..$]);
|
||||
}
|
||||
|
||||
template FormatString(const(char)[] F, A...)
|
||||
{
|
||||
static if (F.length == 0)
|
||||
enum FormatString = Format!(A);
|
||||
else static if (F.length == 1)
|
||||
enum FormatString = F[0] ~ Format!(A);
|
||||
else static if (F[0..2] == "%s")
|
||||
enum FormatString
|
||||
= toStringNow!(A[0]) ~ FormatString!(F[2..$],A[1..$]);
|
||||
else static if (F[0..2] == "%%")
|
||||
enum FormatString = "%" ~ FormatString!(F[2..$],A);
|
||||
else
|
||||
{
|
||||
static assert(F[0] != '%', "unrecognized format %" ~ F[1]);
|
||||
enum FormatString = F[0] ~ FormatString!(F[1..$],A);
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
auto s = Format!("hel%slo", "world", -138, 'c', true);
|
||||
assert(s == "helworldlo-138ctrue", "[" ~ s ~ "]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert constant argument to a string.
|
||||
*/
|
||||
|
||||
template toStringNow(ulong v)
|
||||
{
|
||||
static if (v < 10)
|
||||
enum toStringNow = "" ~ cast(char)(v + '0');
|
||||
else
|
||||
enum toStringNow = toStringNow!(v / 10) ~ toStringNow!(v % 10);
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
static assert(toStringNow!(1uL << 62) == "4611686018427387904");
|
||||
}
|
||||
|
||||
/// ditto
|
||||
template toStringNow(long v)
|
||||
{
|
||||
static if (v < 0)
|
||||
enum toStringNow = "-" ~ toStringNow!(cast(ulong) -v);
|
||||
else
|
||||
enum toStringNow = toStringNow!(cast(ulong) v);
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
static assert(toStringNow!(0x100000000) == "4294967296");
|
||||
static assert(toStringNow!(-138L) == "-138");
|
||||
}
|
||||
|
||||
/// ditto
|
||||
template toStringNow(uint U)
|
||||
{
|
||||
enum toStringNow = toStringNow!(cast(ulong)U);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
template toStringNow(int I)
|
||||
{
|
||||
enum toStringNow = toStringNow!(cast(long)I);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
template toStringNow(bool B)
|
||||
{
|
||||
enum toStringNow = B ? "true" : "false";
|
||||
}
|
||||
|
||||
/// ditto
|
||||
template toStringNow(string S)
|
||||
{
|
||||
enum toStringNow = S;
|
||||
}
|
||||
|
||||
/// ditto
|
||||
template toStringNow(char C)
|
||||
{
|
||||
enum toStringNow = "" ~ C;
|
||||
}
|
||||
|
||||
|
||||
/********
|
||||
* Parse unsigned integer literal from the start of string s.
|
||||
* returns:
|
||||
* .value = the integer literal as a string,
|
||||
* .rest = the string following the integer literal
|
||||
* Otherwise:
|
||||
* .value = null,
|
||||
* .rest = s
|
||||
*/
|
||||
|
||||
template parseUinteger(const(char)[] s)
|
||||
{
|
||||
static if (s.length == 0)
|
||||
{
|
||||
enum value = "";
|
||||
enum rest = "";
|
||||
}
|
||||
else static if (s[0] >= '0' && s[0] <= '9')
|
||||
{
|
||||
enum value = s[0] ~ parseUinteger!(s[1..$]).value;
|
||||
enum rest = parseUinteger!(s[1..$]).rest;
|
||||
}
|
||||
else
|
||||
{
|
||||
enum value = "";
|
||||
enum rest = s;
|
||||
}
|
||||
}
|
||||
|
||||
/********
|
||||
Parse integer literal optionally preceded by $(D '-') from the start
|
||||
of string $(D s).
|
||||
|
||||
Returns:
|
||||
.value = the integer literal as a string,
|
||||
.rest = the string following the integer literal
|
||||
|
||||
Otherwise:
|
||||
.value = null,
|
||||
.rest = s
|
||||
*/
|
||||
|
||||
template parseInteger(const(char)[] s)
|
||||
{
|
||||
static if (s.length == 0)
|
||||
{
|
||||
enum value = "";
|
||||
enum rest = "";
|
||||
}
|
||||
else static if (s[0] >= '0' && s[0] <= '9')
|
||||
{
|
||||
enum value = s[0] ~ parseUinteger!(s[1..$]).value;
|
||||
enum rest = parseUinteger!(s[1..$]).rest;
|
||||
}
|
||||
else static if (s.length >= 2 &&
|
||||
s[0] == '-' && s[1] >= '0' && s[1] <= '9')
|
||||
{
|
||||
enum value = s[0..2] ~ parseUinteger!(s[2..$]).value;
|
||||
enum rest = parseUinteger!(s[2..$]).rest;
|
||||
}
|
||||
else
|
||||
{
|
||||
enum value = "";
|
||||
enum rest = s;
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
assert(parseUinteger!("1234abc").value == "1234");
|
||||
assert(parseUinteger!("1234abc").rest == "abc");
|
||||
assert(parseInteger!("-1234abc").value == "-1234");
|
||||
assert(parseInteger!("-1234abc").rest == "abc");
|
||||
}
|
||||
|
||||
/**
|
||||
Deprecated aliases held for backward compatibility.
|
||||
*/
|
||||
deprecated alias toStringNow ToString;
|
||||
/// Ditto
|
||||
deprecated alias parseUinteger ParseUinteger;
|
||||
/// Ditto
|
||||
deprecated alias parseUinteger ParseInteger;
|
||||
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-d"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple mode that handle D-Syntax (<a href="http://www.dlang.org">DLang Homepage</a>).</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-d</code>
|
||||
.</p>
|
||||
</article>
|
||||
11
libraries/codemirror/mode/d/test.js
vendored
11
libraries/codemirror/mode/d/test.js
vendored
@@ -1,11 +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}, "d");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("nested_comments",
|
||||
"[comment /+]","[comment comment]","[comment +/]","[variable void] [variable main](){}");
|
||||
|
||||
})();
|
||||
4
libraries/codemirror/mode/dart/dart.js
vendored
4
libraries/codemirror/mode/dart/dart.js
vendored
@@ -15,10 +15,10 @@
|
||||
"implements mixin get native set typedef with enum throw rethrow " +
|
||||
"assert break case continue default in return new deferred async await covariant " +
|
||||
"try catch finally do else for if switch while import library export " +
|
||||
"part of show hide is as").split(" ");
|
||||
"part of show hide is as extension on yield late required").split(" ");
|
||||
var blockKeywords = "try catch finally do else for if switch while".split(" ");
|
||||
var atoms = "true false null".split(" ");
|
||||
var builtins = "void bool num int double dynamic var String".split(" ");
|
||||
var builtins = "void bool num int double dynamic var String Null Never".split(" ");
|
||||
|
||||
function set(words) {
|
||||
var obj = {};
|
||||
|
||||
71
libraries/codemirror/mode/dart/index.html
vendored
71
libraries/codemirror/mode/dart/index.html
vendored
@@ -1,71 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Dart 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="../clike/clike.js"></script>
|
||||
<script src="dart.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid #dee;}</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="#">Dart</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Dart mode</h2>
|
||||
<form>
|
||||
<textarea id="code" name="code">
|
||||
import 'dart:math' show Random;
|
||||
|
||||
void main() {
|
||||
print(new Die(n: 12).roll());
|
||||
}
|
||||
|
||||
// Define a class.
|
||||
class Die {
|
||||
// Define a class variable.
|
||||
static Random shaker = new Random();
|
||||
|
||||
// Define instance variables.
|
||||
int sides, value;
|
||||
|
||||
// Define a method using shorthand syntax.
|
||||
String toString() => '$value';
|
||||
|
||||
// Define a constructor.
|
||||
Die({int n: 6}) {
|
||||
if (4 <= n && n <= 20) {
|
||||
sides = n;
|
||||
} else {
|
||||
// Support for errors and exceptions.
|
||||
throw new ArgumentError(/* */);
|
||||
}
|
||||
}
|
||||
|
||||
// Define an instance method.
|
||||
int roll() {
|
||||
return value = shaker.nextInt(sides) + 1;
|
||||
}
|
||||
}
|
||||
</textarea>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "application/dart"
|
||||
});
|
||||
</script>
|
||||
|
||||
</article>
|
||||
117
libraries/codemirror/mode/diff/index.html
vendored
117
libraries/codemirror/mode/diff/index.html
vendored
@@ -1,117 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Diff 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="diff.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
|
||||
span.cm-meta {color: #a0b !important;}
|
||||
span.cm-error { background-color: black; opacity: 0.4;}
|
||||
span.cm-error.cm-string { background-color: red; }
|
||||
span.cm-error.cm-tag { background-color: #2b2; }
|
||||
</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="#">Diff</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Diff mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
diff --git a/index.html b/index.html
|
||||
index c1d9156..7764744 100644
|
||||
--- a/index.html
|
||||
+++ b/index.html
|
||||
@@ -95,7 +95,8 @@ StringStream.prototype = {
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
- autoMatchBrackets: true
|
||||
+ autoMatchBrackets: true,
|
||||
+ onGutterClick: function(x){console.log(x);}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
diff --git a/lib/codemirror.js b/lib/codemirror.js
|
||||
index 04646a9..9a39cc7 100644
|
||||
--- a/lib/codemirror.js
|
||||
+++ b/lib/codemirror.js
|
||||
@@ -399,10 +399,16 @@ var CodeMirror = (function() {
|
||||
}
|
||||
|
||||
function onMouseDown(e) {
|
||||
- var start = posFromMouse(e), last = start;
|
||||
+ var start = posFromMouse(e), last = start, target = e.target();
|
||||
if (!start) return;
|
||||
setCursor(start.line, start.ch, false);
|
||||
if (e.button() != 1) return;
|
||||
+ if (target.parentNode == gutter) {
|
||||
+ if (options.onGutterClick)
|
||||
+ options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (!focused) onFocus();
|
||||
|
||||
e.stop();
|
||||
@@ -808,7 +814,7 @@ var CodeMirror = (function() {
|
||||
for (var i = showingFrom; i < showingTo; ++i) {
|
||||
var marker = lines[i].gutterMarker;
|
||||
if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
|
||||
- else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
|
||||
+ else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
|
||||
}
|
||||
gutter.style.display = "none"; // TODO test whether this actually helps
|
||||
gutter.innerHTML = html.join("");
|
||||
@@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
|
||||
if (option == "parser") setParser(value);
|
||||
else if (option === "lineNumbers") setLineNumbers(value);
|
||||
else if (option === "gutter") setGutter(value);
|
||||
- else if (option === "readOnly") options.readOnly = value;
|
||||
- else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
|
||||
- else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
|
||||
- else throw new Error("Can't set option " + option);
|
||||
+ else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
|
||||
+ else options[option] = value;
|
||||
},
|
||||
cursorCoords: cursorCoords,
|
||||
undo: operation(undo),
|
||||
@@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
|
||||
replaceRange: operation(replaceRange),
|
||||
|
||||
operation: function(f){return operation(f)();},
|
||||
- refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
|
||||
+ refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
|
||||
+ getInputField: function(){return input;}
|
||||
};
|
||||
return instance;
|
||||
}
|
||||
@@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
|
||||
readOnly: false,
|
||||
onChange: null,
|
||||
onCursorActivity: null,
|
||||
+ onGutterClick: null,
|
||||
autoMatchBrackets: false,
|
||||
workTime: 200,
|
||||
workDelay: 300,
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
|
||||
|
||||
</article>
|
||||
73
libraries/codemirror/mode/django/index.html
vendored
73
libraries/codemirror/mode/django/index.html
vendored
@@ -1,73 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Django template mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/mdn-like.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/overlay.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="django.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="#">Django</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Django template mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>My Django web application</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
{{ page.title|capfirst }}
|
||||
</h1>
|
||||
<ul class="my-list">
|
||||
{# traverse a list of items and produce links to their views. #}
|
||||
{% for item in items %}
|
||||
<li>
|
||||
<a href="{% url 'item_view' item.name|slugify %}">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>You have no items in your list.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% comment "this is a forgotten footer" %}
|
||||
<footer></footer>
|
||||
{% endcomment %}
|
||||
</body>
|
||||
</html>
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "django",
|
||||
indentUnit: 2,
|
||||
indentWithTabs: true,
|
||||
theme: "mdn-like"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Mode for HTML with embedded Django template markup.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-django</code></p>
|
||||
</article>
|
||||
73
libraries/codemirror/mode/dockerfile/index.html
vendored
73
libraries/codemirror/mode/dockerfile/index.html
vendored
@@ -1,73 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Dockerfile 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/mode/simple.js"></script>
|
||||
<script src="dockerfile.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="#">Dockerfile</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Dockerfile mode</h2>
|
||||
<form><textarea id="code" name="code"># Install Ghost blogging platform and run development environment
|
||||
#
|
||||
# VERSION 1.0.0
|
||||
|
||||
FROM ubuntu:12.10
|
||||
MAINTAINER Amer Grgic "amer@livebyt.es"
|
||||
WORKDIR /data/ghost
|
||||
|
||||
# Install dependencies for nginx installation
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y python g++ make software-properties-common --force-yes
|
||||
RUN add-apt-repository ppa:chris-lea/node.js
|
||||
RUN apt-get update
|
||||
# Install unzip
|
||||
RUN apt-get install -y unzip
|
||||
# Install curl
|
||||
RUN apt-get install -y curl
|
||||
# Install nodejs & npm
|
||||
RUN apt-get install -y rlwrap
|
||||
RUN apt-get install -y nodejs
|
||||
# Download Ghost v0.4.1
|
||||
RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip
|
||||
# Unzip Ghost zip to /data/ghost
|
||||
RUN unzip -uo /tmp/ghost.zip -d /data/ghost
|
||||
# Add custom config js to /data/ghost
|
||||
ADD ./config.example.js /data/ghost/config.js
|
||||
# Install Ghost with NPM
|
||||
RUN cd /data/ghost/ && npm install --production
|
||||
# Expose port 2368
|
||||
EXPOSE 2368
|
||||
# Run Ghost
|
||||
CMD ["npm","start"]
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "dockerfile"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Dockerfile syntax highlighting for CodeMirror. Depends on
|
||||
the <a href="../../demo/simplemode.html">simplemode</a> addon.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-dockerfile</code></p>
|
||||
</article>
|
||||
128
libraries/codemirror/mode/dockerfile/test.js
vendored
128
libraries/codemirror/mode/dockerfile/test.js
vendored
@@ -1,128 +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-dockerfile");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("simple_nodejs_dockerfile",
|
||||
"[keyword FROM] node:carbon",
|
||||
"[comment # Create app directory]",
|
||||
"[keyword WORKDIR] /usr/src/app",
|
||||
"[comment # Install app dependencies]",
|
||||
"[comment # A wildcard is used to ensure both package.json AND package-lock.json are copied]",
|
||||
"[comment # where available (npm@5+)]",
|
||||
"[keyword COPY] package*.json ./",
|
||||
"[keyword RUN] npm install",
|
||||
"[keyword COPY] . .",
|
||||
"[keyword EXPOSE] [number 8080] [number 3000]",
|
||||
"[keyword ENV] NODE_ENV development",
|
||||
"[keyword CMD] [[ [string \"npm\"], [string \"start\"] ]]");
|
||||
|
||||
// Ideally the last space should not be highlighted.
|
||||
MT("instruction_without_args_1",
|
||||
"[keyword CMD] ");
|
||||
|
||||
MT("instruction_without_args_2",
|
||||
"[comment # An instruction without args...]",
|
||||
"[keyword ARG] [error #...is an error]");
|
||||
|
||||
MT("multiline",
|
||||
"[keyword RUN] apt-get update && apt-get install -y \\",
|
||||
" mercurial \\",
|
||||
" subversion \\",
|
||||
" && apt-get clean \\",
|
||||
" && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*");
|
||||
|
||||
MT("from_comment",
|
||||
" [keyword FROM] debian:stretch # I tend to use stable as that is more stable",
|
||||
" [keyword FROM] debian:stretch [keyword AS] stable # I am even more stable",
|
||||
" [keyword FROM] [error # this is an error]");
|
||||
|
||||
MT("from_as",
|
||||
"[keyword FROM] golang:1.9.2-alpine3.6 [keyword AS] build",
|
||||
"[keyword COPY] --from=build /bin/project /bin/project",
|
||||
"[keyword ENTRYPOINT] [[ [string \"/bin/project\"] ]]",
|
||||
"[keyword CMD] [[ [string \"--help\"] ]]");
|
||||
|
||||
MT("arg",
|
||||
"[keyword ARG] VERSION=latest",
|
||||
"[keyword FROM] busybox:$VERSION",
|
||||
"[keyword ARG] VERSION",
|
||||
"[keyword RUN] echo $VERSION > image_version");
|
||||
|
||||
MT("label",
|
||||
"[keyword LABEL] com.example.label-with-value=[string \"foo\"]");
|
||||
|
||||
MT("label_multiline",
|
||||
"[keyword LABEL] description=[string \"This text illustrates ]\\",
|
||||
"[string that label-values can span multiple lines.\"]");
|
||||
|
||||
MT("maintainer",
|
||||
"[keyword MAINTAINER] Foo Bar [string \"foo@bar.com\"] ",
|
||||
"[keyword MAINTAINER] Bar Baz <bar@baz.com>");
|
||||
|
||||
MT("env",
|
||||
"[keyword ENV] BUNDLE_PATH=[string \"$GEM_HOME\"] \\",
|
||||
" BUNDLE_APP_CONFIG=[string \"$GEM_HOME\"]");
|
||||
|
||||
MT("verify_keyword",
|
||||
"[keyword RUN] add-apt-repository ppa:chris-lea/node.js");
|
||||
|
||||
MT("scripts",
|
||||
"[comment # Set an entrypoint, to automatically install node modules]",
|
||||
"[keyword ENTRYPOINT] [[ [string \"/bin/bash\"], [string \"-c\"], [string \"if [[ ! -d node_modules ]]; then npm install; fi; exec \\\"${@:0}\\\";\"] ]]",
|
||||
"[keyword CMD] npm start",
|
||||
"[keyword RUN] npm run build && \\",
|
||||
"[comment # a comment between the shell commands]",
|
||||
" npm run test");
|
||||
|
||||
MT("strings_single",
|
||||
"[keyword FROM] buildpack-deps:stretch",
|
||||
"[keyword RUN] { \\",
|
||||
" echo [string 'install: --no-document']; \\",
|
||||
" echo [string 'update: --no-document']; \\",
|
||||
" } >> /usr/local/etc/gemrc");
|
||||
|
||||
MT("strings_single_multiline",
|
||||
"[keyword RUN] set -ex \\",
|
||||
" \\",
|
||||
" && buildDeps=[string ' ]\\",
|
||||
"[string bison ]\\",
|
||||
"[string dpkg-dev ]\\",
|
||||
"[string libgdbm-dev ]\\",
|
||||
"[string ruby ]\\",
|
||||
"[string '] \\",
|
||||
" && apt-get update");
|
||||
|
||||
MT("strings_single_multiline_2",
|
||||
"[keyword RUN] echo [string 'say \\' ]\\",
|
||||
"[string it works'] ");
|
||||
|
||||
MT("strings_double",
|
||||
"[keyword RUN] apt-get install -y --no-install-recommends $buildDeps \\",
|
||||
" \\",
|
||||
" && wget -O ruby.tar.xz [string \"https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz\"] \\",
|
||||
" && echo [string \"$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz\"] | sha256sum -c - ");
|
||||
|
||||
MT("strings_double_multiline",
|
||||
"[keyword RUN] echo [string \"say \\\" ]\\",
|
||||
"[string it works\"] ");
|
||||
|
||||
MT("escape",
|
||||
"[comment # escape=`]",
|
||||
"[keyword FROM] microsoft/windowsservercore",
|
||||
"[keyword RUN] powershell.exe -Command `",
|
||||
" $ErrorActionPreference = [string 'Stop']; `",
|
||||
" wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe ; `",
|
||||
" Start-Process c:\python-3.5.1.exe -ArgumentList [string '/quiet InstallAllUsers=1 PrependPath=1'] -Wait ; `",
|
||||
" Remove-Item c:\python-3.5.1.exe -Force)");
|
||||
|
||||
MT("escape_strings",
|
||||
"[comment # escape=`]",
|
||||
"[keyword FROM] python:3.6-windowsservercore [keyword AS] python",
|
||||
"[keyword RUN] $env:PATH = [string 'C:\\Python;C:\\Python\\Scripts;{0}'] -f $env:PATH ; `",
|
||||
// It should not consider \' as escaped.
|
||||
// " Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\'] -Name Path -Value $env:PATH ;");
|
||||
" Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\' -Name Path -Value $env:PATH ;]");
|
||||
})();
|
||||
89
libraries/codemirror/mode/dtd/index.html
vendored
89
libraries/codemirror/mode/dtd/index.html
vendored
@@ -1,89 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: DTD 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="dtd.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="#">DTD</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>DTD mode</h2>
|
||||
<form><textarea id="code" name="code"><?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!ATTLIST title
|
||||
xmlns CDATA #FIXED "http://docbook.org/ns/docbook"
|
||||
role CDATA #IMPLIED
|
||||
%db.common.attributes;
|
||||
%db.common.linking.attributes;
|
||||
>
|
||||
|
||||
<!--
|
||||
Try: http://docbook.org/xml/5.0/dtd/docbook.dtd
|
||||
-->
|
||||
|
||||
<!DOCTYPE xsl:stylesheet
|
||||
[
|
||||
<!ENTITY nbsp "&#160;">
|
||||
<!ENTITY copy "&#169;">
|
||||
<!ENTITY reg "&#174;">
|
||||
<!ENTITY trade "&#8482;">
|
||||
<!ENTITY mdash "&#8212;">
|
||||
<!ENTITY ldquo "&#8220;">
|
||||
<!ENTITY rdquo "&#8221;">
|
||||
<!ENTITY pound "&#163;">
|
||||
<!ENTITY yen "&#165;">
|
||||
<!ENTITY euro "&#8364;">
|
||||
<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
|
||||
]
|
||||
>
|
||||
|
||||
<!ELEMENT title (#PCDATA|inlinemediaobject|remark|superscript|subscript|xref|link|olink|anchor|biblioref|alt|annotation|indexterm|abbrev|acronym|date|emphasis|footnote|footnoteref|foreignphrase|phrase|quote|wordasword|firstterm|glossterm|coref|trademark|productnumber|productname|database|application|hardware|citation|citerefentry|citetitle|citebiblioid|author|person|personname|org|orgname|editor|jobtitle|replaceable|package|parameter|termdef|nonterminal|systemitem|option|optional|property|inlineequation|tag|markup|token|symbol|literal|code|constant|email|uri|guiicon|guibutton|guimenuitem|guimenu|guisubmenu|guilabel|menuchoice|mousebutton|keycombo|keycap|keycode|keysym|shortcut|accel|prompt|envar|filename|command|computeroutput|userinput|function|varname|returnvalue|type|classname|exceptionname|interfacename|methodname|modifier|initializer|ooclass|ooexception|oointerface|errorcode|errortext|errorname|errortype)*>
|
||||
|
||||
<!ENTITY % db.common.attributes "
|
||||
xml:id ID #IMPLIED
|
||||
version CDATA #IMPLIED
|
||||
xml:lang CDATA #IMPLIED
|
||||
xml:base CDATA #IMPLIED
|
||||
remap CDATA #IMPLIED
|
||||
xreflabel CDATA #IMPLIED
|
||||
revisionflag (changed|added|deleted|off) #IMPLIED
|
||||
dir (ltr|rtl|lro|rlo) #IMPLIED
|
||||
arch CDATA #IMPLIED
|
||||
audience CDATA #IMPLIED
|
||||
condition CDATA #IMPLIED
|
||||
conformance CDATA #IMPLIED
|
||||
os CDATA #IMPLIED
|
||||
revision CDATA #IMPLIED
|
||||
security CDATA #IMPLIED
|
||||
userlevel CDATA #IMPLIED
|
||||
vendor CDATA #IMPLIED
|
||||
wordsize CDATA #IMPLIED
|
||||
annotations CDATA #IMPLIED
|
||||
|
||||
"></textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: {name: "dtd", alignCDATA: true},
|
||||
lineNumbers: true,
|
||||
lineWrapping: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/xml-dtd</code>.</p>
|
||||
</article>
|
||||
407
libraries/codemirror/mode/dylan/index.html
vendored
407
libraries/codemirror/mode/dylan/index.html
vendored
@@ -1,407 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Dylan 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="dylan.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="#">Dylan</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Dylan mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
Module: locators-internals
|
||||
Synopsis: Abstract modeling of locations
|
||||
Author: Andy Armstrong
|
||||
Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
|
||||
All rights reserved.
|
||||
License: See License.txt in this distribution for details.
|
||||
Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
|
||||
|
||||
define open generic locator-server
|
||||
(locator :: <locator>) => (server :: false-or(<server-locator>));
|
||||
define open generic locator-host
|
||||
(locator :: <locator>) => (host :: false-or(<string>));
|
||||
define open generic locator-volume
|
||||
(locator :: <locator>) => (volume :: false-or(<string>));
|
||||
define open generic locator-directory
|
||||
(locator :: <locator>) => (directory :: false-or(<directory-locator>));
|
||||
define open generic locator-relative?
|
||||
(locator :: <locator>) => (relative? :: <boolean>);
|
||||
define open generic locator-path
|
||||
(locator :: <locator>) => (path :: <sequence>);
|
||||
define open generic locator-base
|
||||
(locator :: <locator>) => (base :: false-or(<string>));
|
||||
define open generic locator-extension
|
||||
(locator :: <locator>) => (extension :: false-or(<string>));
|
||||
|
||||
/// Locator classes
|
||||
|
||||
define open abstract class <directory-locator> (<physical-locator>)
|
||||
end class <directory-locator>;
|
||||
|
||||
define open abstract class <file-locator> (<physical-locator>)
|
||||
end class <file-locator>;
|
||||
|
||||
define method as
|
||||
(class == <directory-locator>, string :: <string>)
|
||||
=> (locator :: <directory-locator>)
|
||||
as(<native-directory-locator>, string)
|
||||
end method as;
|
||||
|
||||
define method make
|
||||
(class == <directory-locator>,
|
||||
#key server :: false-or(<server-locator>) = #f,
|
||||
path :: <sequence> = #[],
|
||||
relative? :: <boolean> = #f,
|
||||
name :: false-or(<string>) = #f)
|
||||
=> (locator :: <directory-locator>)
|
||||
make(<native-directory-locator>,
|
||||
server: server,
|
||||
path: path,
|
||||
relative?: relative?,
|
||||
name: name)
|
||||
end method make;
|
||||
|
||||
define method as
|
||||
(class == <file-locator>, string :: <string>)
|
||||
=> (locator :: <file-locator>)
|
||||
as(<native-file-locator>, string)
|
||||
end method as;
|
||||
|
||||
define method make
|
||||
(class == <file-locator>,
|
||||
#key directory :: false-or(<directory-locator>) = #f,
|
||||
base :: false-or(<string>) = #f,
|
||||
extension :: false-or(<string>) = #f,
|
||||
name :: false-or(<string>) = #f)
|
||||
=> (locator :: <file-locator>)
|
||||
make(<native-file-locator>,
|
||||
directory: directory,
|
||||
base: base,
|
||||
extension: extension,
|
||||
name: name)
|
||||
end method make;
|
||||
|
||||
/// Locator coercion
|
||||
|
||||
//---*** andrewa: This caching scheme doesn't work yet, so disable it.
|
||||
define constant $cache-locators? = #f;
|
||||
define constant $cache-locator-strings? = #f;
|
||||
|
||||
define constant $locator-to-string-cache = make(<object-table>, weak: #"key");
|
||||
define constant $string-to-locator-cache = make(<string-table>, weak: #"value");
|
||||
|
||||
define open generic locator-as-string
|
||||
(class :: subclass(<string>), locator :: <locator>)
|
||||
=> (string :: <string>);
|
||||
|
||||
define open generic string-as-locator
|
||||
(class :: subclass(<locator>), string :: <string>)
|
||||
=> (locator :: <locator>);
|
||||
|
||||
define sealed sideways method as
|
||||
(class :: subclass(<string>), locator :: <locator>)
|
||||
=> (string :: <string>)
|
||||
let string = element($locator-to-string-cache, locator, default: #f);
|
||||
if (string)
|
||||
as(class, string)
|
||||
else
|
||||
let string = locator-as-string(class, locator);
|
||||
if ($cache-locator-strings?)
|
||||
element($locator-to-string-cache, locator) := string;
|
||||
else
|
||||
string
|
||||
end
|
||||
end
|
||||
end method as;
|
||||
|
||||
define sealed sideways method as
|
||||
(class :: subclass(<locator>), string :: <string>)
|
||||
=> (locator :: <locator>)
|
||||
let locator = element($string-to-locator-cache, string, default: #f);
|
||||
if (instance?(locator, class))
|
||||
locator
|
||||
else
|
||||
let locator = string-as-locator(class, string);
|
||||
if ($cache-locators?)
|
||||
element($string-to-locator-cache, string) := locator;
|
||||
else
|
||||
locator
|
||||
end
|
||||
end
|
||||
end method as;
|
||||
|
||||
/// Locator conditions
|
||||
|
||||
define class <locator-error> (<format-string-condition>, <error>)
|
||||
end class <locator-error>;
|
||||
|
||||
define function locator-error
|
||||
(format-string :: <string>, #rest format-arguments)
|
||||
error(make(<locator-error>,
|
||||
format-string: format-string,
|
||||
format-arguments: format-arguments))
|
||||
end function locator-error;
|
||||
|
||||
/// Useful locator protocols
|
||||
|
||||
define open generic locator-test
|
||||
(locator :: <directory-locator>) => (test :: <function>);
|
||||
|
||||
define method locator-test
|
||||
(locator :: <directory-locator>) => (test :: <function>)
|
||||
\=
|
||||
end method locator-test;
|
||||
|
||||
define open generic locator-might-have-links?
|
||||
(locator :: <directory-locator>) => (links? :: <boolean>);
|
||||
|
||||
define method locator-might-have-links?
|
||||
(locator :: <directory-locator>) => (links? :: singleton(#f))
|
||||
#f
|
||||
end method locator-might-have-links?;
|
||||
|
||||
define method locator-relative?
|
||||
(locator :: <file-locator>) => (relative? :: <boolean>)
|
||||
let directory = locator.locator-directory;
|
||||
~directory | directory.locator-relative?
|
||||
end method locator-relative?;
|
||||
|
||||
define method current-directory-locator?
|
||||
(locator :: <directory-locator>) => (current-directory? :: <boolean>)
|
||||
locator.locator-relative?
|
||||
& locator.locator-path = #[#"self"]
|
||||
end method current-directory-locator?;
|
||||
|
||||
define method locator-directory
|
||||
(locator :: <directory-locator>) => (parent :: false-or(<directory-locator>))
|
||||
let path = locator.locator-path;
|
||||
unless (empty?(path))
|
||||
make(object-class(locator),
|
||||
server: locator.locator-server,
|
||||
path: copy-sequence(path, end: path.size - 1),
|
||||
relative?: locator.locator-relative?)
|
||||
end
|
||||
end method locator-directory;
|
||||
|
||||
/// Simplify locator
|
||||
|
||||
define open generic simplify-locator
|
||||
(locator :: <physical-locator>)
|
||||
=> (simplified-locator :: <physical-locator>);
|
||||
|
||||
define method simplify-locator
|
||||
(locator :: <directory-locator>)
|
||||
=> (simplified-locator :: <directory-locator>)
|
||||
let path = locator.locator-path;
|
||||
let relative? = locator.locator-relative?;
|
||||
let resolve-parent? = ~locator.locator-might-have-links?;
|
||||
let simplified-path
|
||||
= simplify-path(path,
|
||||
resolve-parent?: resolve-parent?,
|
||||
relative?: relative?);
|
||||
if (path ~= simplified-path)
|
||||
make(object-class(locator),
|
||||
server: locator.locator-server,
|
||||
path: simplified-path,
|
||||
relative?: locator.locator-relative?)
|
||||
else
|
||||
locator
|
||||
end
|
||||
end method simplify-locator;
|
||||
|
||||
define method simplify-locator
|
||||
(locator :: <file-locator>) => (simplified-locator :: <file-locator>)
|
||||
let directory = locator.locator-directory;
|
||||
let simplified-directory = directory & simplify-locator(directory);
|
||||
if (directory ~= simplified-directory)
|
||||
make(object-class(locator),
|
||||
directory: simplified-directory,
|
||||
base: locator.locator-base,
|
||||
extension: locator.locator-extension)
|
||||
else
|
||||
locator
|
||||
end
|
||||
end method simplify-locator;
|
||||
|
||||
/// Subdirectory locator
|
||||
|
||||
define open generic subdirectory-locator
|
||||
(locator :: <directory-locator>, #rest sub-path)
|
||||
=> (subdirectory :: <directory-locator>);
|
||||
|
||||
define method subdirectory-locator
|
||||
(locator :: <directory-locator>, #rest sub-path)
|
||||
=> (subdirectory :: <directory-locator>)
|
||||
let old-path = locator.locator-path;
|
||||
let new-path = concatenate-as(<simple-object-vector>, old-path, sub-path);
|
||||
make(object-class(locator),
|
||||
server: locator.locator-server,
|
||||
path: new-path,
|
||||
relative?: locator.locator-relative?)
|
||||
end method subdirectory-locator;
|
||||
|
||||
/// Relative locator
|
||||
|
||||
define open generic relative-locator
|
||||
(locator :: <physical-locator>, from-locator :: <physical-locator>)
|
||||
=> (relative-locator :: <physical-locator>);
|
||||
|
||||
define method relative-locator
|
||||
(locator :: <directory-locator>, from-locator :: <directory-locator>)
|
||||
=> (relative-locator :: <directory-locator>)
|
||||
let path = locator.locator-path;
|
||||
let from-path = from-locator.locator-path;
|
||||
case
|
||||
~locator.locator-relative? & from-locator.locator-relative? =>
|
||||
locator-error
|
||||
("Cannot find relative path of absolute locator %= from relative locator %=",
|
||||
locator, from-locator);
|
||||
locator.locator-server ~= from-locator.locator-server =>
|
||||
locator;
|
||||
path = from-path =>
|
||||
make(object-class(locator),
|
||||
path: vector(#"self"),
|
||||
relative?: #t);
|
||||
otherwise =>
|
||||
make(object-class(locator),
|
||||
path: relative-path(path, from-path, test: locator.locator-test),
|
||||
relative?: #t);
|
||||
end
|
||||
end method relative-locator;
|
||||
|
||||
define method relative-locator
|
||||
(locator :: <file-locator>, from-directory :: <directory-locator>)
|
||||
=> (relative-locator :: <file-locator>)
|
||||
let directory = locator.locator-directory;
|
||||
let relative-directory = directory & relative-locator(directory, from-directory);
|
||||
if (relative-directory ~= directory)
|
||||
simplify-locator
|
||||
(make(object-class(locator),
|
||||
directory: relative-directory,
|
||||
base: locator.locator-base,
|
||||
extension: locator.locator-extension))
|
||||
else
|
||||
locator
|
||||
end
|
||||
end method relative-locator;
|
||||
|
||||
define method relative-locator
|
||||
(locator :: <physical-locator>, from-locator :: <file-locator>)
|
||||
=> (relative-locator :: <physical-locator>)
|
||||
let from-directory = from-locator.locator-directory;
|
||||
case
|
||||
from-directory =>
|
||||
relative-locator(locator, from-directory);
|
||||
~locator.locator-relative? =>
|
||||
locator-error
|
||||
("Cannot find relative path of absolute locator %= from relative locator %=",
|
||||
locator, from-locator);
|
||||
otherwise =>
|
||||
locator;
|
||||
end
|
||||
end method relative-locator;
|
||||
|
||||
/// Merge locators
|
||||
|
||||
define open generic merge-locators
|
||||
(locator :: <physical-locator>, from-locator :: <physical-locator>)
|
||||
=> (merged-locator :: <physical-locator>);
|
||||
|
||||
/// Merge locators
|
||||
|
||||
define method merge-locators
|
||||
(locator :: <directory-locator>, from-locator :: <directory-locator>)
|
||||
=> (merged-locator :: <directory-locator>)
|
||||
if (locator.locator-relative?)
|
||||
let path = concatenate(from-locator.locator-path, locator.locator-path);
|
||||
simplify-locator
|
||||
(make(object-class(locator),
|
||||
server: from-locator.locator-server,
|
||||
path: path,
|
||||
relative?: from-locator.locator-relative?))
|
||||
else
|
||||
locator
|
||||
end
|
||||
end method merge-locators;
|
||||
|
||||
define method merge-locators
|
||||
(locator :: <file-locator>, from-locator :: <directory-locator>)
|
||||
=> (merged-locator :: <file-locator>)
|
||||
let directory = locator.locator-directory;
|
||||
let merged-directory
|
||||
= if (directory)
|
||||
merge-locators(directory, from-locator)
|
||||
else
|
||||
simplify-locator(from-locator)
|
||||
end;
|
||||
if (merged-directory ~= directory)
|
||||
make(object-class(locator),
|
||||
directory: merged-directory,
|
||||
base: locator.locator-base,
|
||||
extension: locator.locator-extension)
|
||||
else
|
||||
locator
|
||||
end
|
||||
end method merge-locators;
|
||||
|
||||
define method merge-locators
|
||||
(locator :: <physical-locator>, from-locator :: <file-locator>)
|
||||
=> (merged-locator :: <physical-locator>)
|
||||
let from-directory = from-locator.locator-directory;
|
||||
if (from-directory)
|
||||
merge-locators(locator, from-directory)
|
||||
else
|
||||
locator
|
||||
end
|
||||
end method merge-locators;
|
||||
|
||||
/// Locator protocols
|
||||
|
||||
define sideways method supports-open-locator?
|
||||
(locator :: <file-locator>) => (openable? :: <boolean>)
|
||||
~locator.locator-relative?
|
||||
end method supports-open-locator?;
|
||||
|
||||
define sideways method open-locator
|
||||
(locator :: <file-locator>, #rest keywords, #key, #all-keys)
|
||||
=> (stream :: <stream>)
|
||||
apply(open-file-stream, locator, keywords)
|
||||
end method open-locator;
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-dylan",
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
continueComments: "Enter",
|
||||
extraKeys: {"Ctrl-Q": "toggleComment"},
|
||||
tabMode: "indent",
|
||||
indentUnit: 2
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-dylan</code>.</p>
|
||||
</article>
|
||||
88
libraries/codemirror/mode/dylan/test.js
vendored
88
libraries/codemirror/mode/dylan/test.js
vendored
@@ -1,88 +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}, "dylan");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT('comments',
|
||||
'[comment // This is a line comment]',
|
||||
'[comment /* This is a block comment */]',
|
||||
'[comment /* This is a multi]',
|
||||
'[comment line comment]',
|
||||
'[comment */]',
|
||||
'[comment /* And this is a /*]',
|
||||
'[comment /* nested */ comment */]');
|
||||
|
||||
MT('unary_operators',
|
||||
'[operator -][variable a]',
|
||||
'[operator -] [variable a]',
|
||||
'[operator ~][variable a]',
|
||||
'[operator ~] [variable a]');
|
||||
|
||||
MT('binary_operators',
|
||||
'[variable a] [operator +] [variable b]',
|
||||
'[variable a] [operator -] [variable b]',
|
||||
'[variable a] [operator *] [variable b]',
|
||||
'[variable a] [operator /] [variable b]',
|
||||
'[variable a] [operator ^] [variable b]',
|
||||
'[variable a] [operator =] [variable b]',
|
||||
'[variable a] [operator ==] [variable b]',
|
||||
'[variable a] [operator ~=] [variable b]',
|
||||
'[variable a] [operator ~==] [variable b]',
|
||||
'[variable a] [operator <] [variable b]',
|
||||
'[variable a] [operator <=] [variable b]',
|
||||
'[variable a] [operator >] [variable b]',
|
||||
'[variable a] [operator >=] [variable b]',
|
||||
'[variable a] [operator &] [variable b]',
|
||||
'[variable a] [operator |] [variable b]',
|
||||
'[variable a] [operator :=] [variable b]');
|
||||
|
||||
MT('integers',
|
||||
'[number 1]',
|
||||
'[number 123]',
|
||||
'[number -123]',
|
||||
'[number +456]',
|
||||
'[number #b010]',
|
||||
'[number #o073]',
|
||||
'[number #xabcDEF123]');
|
||||
|
||||
MT('floats',
|
||||
'[number .3]',
|
||||
'[number -1.]',
|
||||
'[number -2.335]',
|
||||
'[number +3.78d1]',
|
||||
'[number 3.78s-1]',
|
||||
'[number -3.32e+5]');
|
||||
|
||||
MT('characters_and_strings',
|
||||
"[string 'a']",
|
||||
"[string '\\\\'']",
|
||||
'[string ""]',
|
||||
'[string "a"]',
|
||||
'[string "abc def"]',
|
||||
'[string "More escaped characters: \\\\\\\\ \\\\a \\\\b \\\\e \\\\f \\\\n \\\\r \\\\t \\\\0 ..."]');
|
||||
|
||||
MT('brackets',
|
||||
'[bracket #[[]]]',
|
||||
'[bracket #()]',
|
||||
'[bracket #(][number 1][bracket )]',
|
||||
'[bracket [[][number 1][punctuation ,] [number 3][bracket ]]]',
|
||||
'[bracket ()]',
|
||||
'[bracket {}]',
|
||||
'[keyword if] [bracket (][variable foo][bracket )]',
|
||||
'[bracket (][number 1][bracket )]',
|
||||
'[bracket [[][number 1][bracket ]]]');
|
||||
|
||||
MT('hash_words',
|
||||
'[punctuation ##]',
|
||||
'[atom #f]', '[atom #F]',
|
||||
'[atom #t]', '[atom #T]',
|
||||
'[atom #all-keys]',
|
||||
'[atom #include]',
|
||||
'[atom #key]',
|
||||
'[atom #next]',
|
||||
'[atom #rest]',
|
||||
'[string #"foo"]',
|
||||
'[error #invalid]');
|
||||
})();
|
||||
102
libraries/codemirror/mode/ebnf/index.html
vendored
102
libraries/codemirror/mode/ebnf/index.html
vendored
@@ -1,102 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: EBNF 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="../javascript/javascript.js"></script>
|
||||
<script src="ebnf.js"></script>
|
||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<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="#">EBNF Mode</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>EBNF Mode (bracesMode setting = "javascript")</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* description: Parses end executes mathematical expressions. */
|
||||
|
||||
/* lexical grammar */
|
||||
%lex
|
||||
|
||||
%%
|
||||
\s+ /* skip whitespace */
|
||||
[0-9]+("."[0-9]+)?\b return 'NUMBER';
|
||||
"*" return '*';
|
||||
"/" return '/';
|
||||
"-" return '-';
|
||||
"+" return '+';
|
||||
"^" return '^';
|
||||
"(" return '(';
|
||||
")" return ')';
|
||||
"PI" return 'PI';
|
||||
"E" return 'E';
|
||||
<<EOF>> return 'EOF';
|
||||
|
||||
/lex
|
||||
|
||||
/* operator associations and precedence */
|
||||
|
||||
%left '+' '-'
|
||||
%left '*' '/'
|
||||
%left '^'
|
||||
%left UMINUS
|
||||
|
||||
%start expressions
|
||||
|
||||
%% /* language grammar */
|
||||
|
||||
expressions
|
||||
: e EOF
|
||||
{print($1); return $1;}
|
||||
;
|
||||
|
||||
e
|
||||
: e '+' e
|
||||
{$$ = $1+$3;}
|
||||
| e '-' e
|
||||
{$$ = $1-$3;}
|
||||
| e '*' e
|
||||
{$$ = $1*$3;}
|
||||
| e '/' e
|
||||
{$$ = $1/$3;}
|
||||
| e '^' e
|
||||
{$$ = Math.pow($1, $3);}
|
||||
| '-' e %prec UMINUS
|
||||
{$$ = -$2;}
|
||||
| '(' e ')'
|
||||
{$$ = $2;}
|
||||
| NUMBER
|
||||
{$$ = Number(yytext);}
|
||||
| E
|
||||
{$$ = Math.E;}
|
||||
| PI
|
||||
{$$ = Math.PI;}
|
||||
;</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: {name: "ebnf"},
|
||||
lineNumbers: true,
|
||||
bracesMode: 'javascript'
|
||||
});
|
||||
</script>
|
||||
<h3>The EBNF Mode</h3>
|
||||
<p> Created by <a href="https://github.com/robertleeplummerjr">Robert Plummer</a></p>
|
||||
</article>
|
||||
</body>
|
||||
</html>
|
||||
52
libraries/codemirror/mode/ecl/index.html
vendored
52
libraries/codemirror/mode/ecl/index.html
vendored
@@ -1,52 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: ECL 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="ecl.js"></script>
|
||||
<style>.CodeMirror {border: 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="#">ECL</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>ECL mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/*
|
||||
sample useless code to demonstrate ecl syntax highlighting
|
||||
this is a multiline comment!
|
||||
*/
|
||||
|
||||
// this is a singleline comment!
|
||||
|
||||
import ut;
|
||||
r :=
|
||||
record
|
||||
string22 s1 := '123';
|
||||
integer4 i1 := 123;
|
||||
end;
|
||||
#option('tmp', true);
|
||||
d := dataset('tmp::qb', r, thor);
|
||||
output(d);
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
|
||||
|
||||
</article>
|
||||
429
libraries/codemirror/mode/eiffel/index.html
vendored
429
libraries/codemirror/mode/eiffel/index.html
vendored
@@ -1,429 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Eiffel mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/neat.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="eiffel.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default span.cm-arrow { color: red; }
|
||||
</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="#">Eiffel</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Eiffel mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
note
|
||||
description: "[
|
||||
Project-wide universal properties.
|
||||
This class is an ancestor to all developer-written classes.
|
||||
ANY may be customized for individual projects or teams.
|
||||
]"
|
||||
|
||||
library: "Free implementation of ELKS library"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date: 2013-01-25 11:49:00 -0800 (Fri, 25 Jan 2013) $"
|
||||
revision: "$Revision: 712 $"
|
||||
|
||||
class
|
||||
ANY
|
||||
|
||||
feature -- Customization
|
||||
|
||||
feature -- Access
|
||||
|
||||
generator: STRING
|
||||
-- Name of current object's generating class
|
||||
-- (base class of the type of which it is a direct instance)
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
generator_not_void: Result /= Void
|
||||
generator_not_empty: not Result.is_empty
|
||||
end
|
||||
|
||||
generating_type: TYPE [detachable like Current]
|
||||
-- Type of current object
|
||||
-- (type of which it is a direct instance)
|
||||
do
|
||||
Result := {detachable like Current}
|
||||
ensure
|
||||
generating_type_not_void: Result /= Void
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
conforms_to (other: ANY): BOOLEAN
|
||||
-- Does type of current object conform to type
|
||||
-- of `other' (as per Eiffel: The Language, chapter 13)?
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
external
|
||||
"built_in"
|
||||
end
|
||||
|
||||
same_type (other: ANY): BOOLEAN
|
||||
-- Is type of current object identical to type of `other'?
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
definition: Result = (conforms_to (other) and
|
||||
other.conforms_to (Current))
|
||||
end
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
is_equal (other: like Current): BOOLEAN
|
||||
-- Is `other' attached to an object considered
|
||||
-- equal to current object?
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
symmetric: Result implies other ~ Current
|
||||
consistent: standard_is_equal (other) implies Result
|
||||
end
|
||||
|
||||
frozen standard_is_equal (other: like Current): BOOLEAN
|
||||
-- Is `other' attached to an object of the same type
|
||||
-- as current object, and field-by-field identical to it?
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
same_type: Result implies same_type (other)
|
||||
symmetric: Result implies other.standard_is_equal (Current)
|
||||
end
|
||||
|
||||
frozen equal (a: detachable ANY; b: like a): BOOLEAN
|
||||
-- Are `a' and `b' either both void or attached
|
||||
-- to objects considered equal?
|
||||
do
|
||||
if a = Void then
|
||||
Result := b = Void
|
||||
else
|
||||
Result := b /= Void and then
|
||||
a.is_equal (b)
|
||||
end
|
||||
ensure
|
||||
definition: Result = (a = Void and b = Void) or else
|
||||
((a /= Void and b /= Void) and then
|
||||
a.is_equal (b))
|
||||
end
|
||||
|
||||
frozen standard_equal (a: detachable ANY; b: like a): BOOLEAN
|
||||
-- Are `a' and `b' either both void or attached to
|
||||
-- field-by-field identical objects of the same type?
|
||||
-- Always uses default object comparison criterion.
|
||||
do
|
||||
if a = Void then
|
||||
Result := b = Void
|
||||
else
|
||||
Result := b /= Void and then
|
||||
a.standard_is_equal (b)
|
||||
end
|
||||
ensure
|
||||
definition: Result = (a = Void and b = Void) or else
|
||||
((a /= Void and b /= Void) and then
|
||||
a.standard_is_equal (b))
|
||||
end
|
||||
|
||||
frozen is_deep_equal (other: like Current): BOOLEAN
|
||||
-- Are `Current' and `other' attached to isomorphic object structures?
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
shallow_implies_deep: standard_is_equal (other) implies Result
|
||||
same_type: Result implies same_type (other)
|
||||
symmetric: Result implies other.is_deep_equal (Current)
|
||||
end
|
||||
|
||||
frozen deep_equal (a: detachable ANY; b: like a): BOOLEAN
|
||||
-- Are `a' and `b' either both void
|
||||
-- or attached to isomorphic object structures?
|
||||
do
|
||||
if a = Void then
|
||||
Result := b = Void
|
||||
else
|
||||
Result := b /= Void and then a.is_deep_equal (b)
|
||||
end
|
||||
ensure
|
||||
shallow_implies_deep: standard_equal (a, b) implies Result
|
||||
both_or_none_void: (a = Void) implies (Result = (b = Void))
|
||||
same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
|
||||
symmetric: Result implies deep_equal (b, a)
|
||||
end
|
||||
|
||||
feature -- Duplication
|
||||
|
||||
frozen twin: like Current
|
||||
-- New object equal to `Current'
|
||||
-- `twin' calls `copy'; to change copying/twinning semantics, redefine `copy'.
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
twin_not_void: Result /= Void
|
||||
is_equal: Result ~ Current
|
||||
end
|
||||
|
||||
copy (other: like Current)
|
||||
-- Update current object using fields of object attached
|
||||
-- to `other', so as to yield equal objects.
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
type_identity: same_type (other)
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
is_equal: Current ~ other
|
||||
end
|
||||
|
||||
frozen standard_copy (other: like Current)
|
||||
-- Copy every field of `other' onto corresponding field
|
||||
-- of current object.
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
type_identity: same_type (other)
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
is_standard_equal: standard_is_equal (other)
|
||||
end
|
||||
|
||||
frozen clone (other: detachable ANY): like other
|
||||
-- Void if `other' is void; otherwise new object
|
||||
-- equal to `other'
|
||||
--
|
||||
-- For non-void `other', `clone' calls `copy';
|
||||
-- to change copying/cloning semantics, redefine `copy'.
|
||||
obsolete
|
||||
"Use `twin' instead."
|
||||
do
|
||||
if other /= Void then
|
||||
Result := other.twin
|
||||
end
|
||||
ensure
|
||||
equal: Result ~ other
|
||||
end
|
||||
|
||||
frozen standard_clone (other: detachable ANY): like other
|
||||
-- Void if `other' is void; otherwise new object
|
||||
-- field-by-field identical to `other'.
|
||||
-- Always uses default copying semantics.
|
||||
obsolete
|
||||
"Use `standard_twin' instead."
|
||||
do
|
||||
if other /= Void then
|
||||
Result := other.standard_twin
|
||||
end
|
||||
ensure
|
||||
equal: standard_equal (Result, other)
|
||||
end
|
||||
|
||||
frozen standard_twin: like Current
|
||||
-- New object field-by-field identical to `other'.
|
||||
-- Always uses default copying semantics.
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
standard_twin_not_void: Result /= Void
|
||||
equal: standard_equal (Result, Current)
|
||||
end
|
||||
|
||||
frozen deep_twin: like Current
|
||||
-- New object structure recursively duplicated from Current.
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
deep_twin_not_void: Result /= Void
|
||||
deep_equal: deep_equal (Current, Result)
|
||||
end
|
||||
|
||||
frozen deep_clone (other: detachable ANY): like other
|
||||
-- Void if `other' is void: otherwise, new object structure
|
||||
-- recursively duplicated from the one attached to `other'
|
||||
obsolete
|
||||
"Use `deep_twin' instead."
|
||||
do
|
||||
if other /= Void then
|
||||
Result := other.deep_twin
|
||||
end
|
||||
ensure
|
||||
deep_equal: deep_equal (other, Result)
|
||||
end
|
||||
|
||||
frozen deep_copy (other: like Current)
|
||||
-- Effect equivalent to that of:
|
||||
-- `copy' (`other' . `deep_twin')
|
||||
require
|
||||
other_not_void: other /= Void
|
||||
do
|
||||
copy (other.deep_twin)
|
||||
ensure
|
||||
deep_equal: deep_equal (Current, other)
|
||||
end
|
||||
|
||||
feature {NONE} -- Retrieval
|
||||
|
||||
frozen internal_correct_mismatch
|
||||
-- Called from runtime to perform a proper dynamic dispatch on `correct_mismatch'
|
||||
-- from MISMATCH_CORRECTOR.
|
||||
local
|
||||
l_msg: STRING
|
||||
l_exc: EXCEPTIONS
|
||||
do
|
||||
if attached {MISMATCH_CORRECTOR} Current as l_corrector then
|
||||
l_corrector.correct_mismatch
|
||||
else
|
||||
create l_msg.make_from_string ("Mismatch: ")
|
||||
create l_exc
|
||||
l_msg.append (generating_type.name)
|
||||
l_exc.raise_retrieval_exception (l_msg)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Output
|
||||
|
||||
io: STD_FILES
|
||||
-- Handle to standard file setup
|
||||
once
|
||||
create Result
|
||||
Result.set_output_default
|
||||
ensure
|
||||
io_not_void: Result /= Void
|
||||
end
|
||||
|
||||
out: STRING
|
||||
-- New string containing terse printable representation
|
||||
-- of current object
|
||||
do
|
||||
Result := tagged_out
|
||||
ensure
|
||||
out_not_void: Result /= Void
|
||||
end
|
||||
|
||||
frozen tagged_out: STRING
|
||||
-- New string containing terse printable representation
|
||||
-- of current object
|
||||
external
|
||||
"built_in"
|
||||
ensure
|
||||
tagged_out_not_void: Result /= Void
|
||||
end
|
||||
|
||||
print (o: detachable ANY)
|
||||
-- Write terse external representation of `o'
|
||||
-- on standard output.
|
||||
do
|
||||
if o /= Void then
|
||||
io.put_string (o.out)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Platform
|
||||
|
||||
Operating_environment: OPERATING_ENVIRONMENT
|
||||
-- Objects available from the operating system
|
||||
once
|
||||
create Result
|
||||
ensure
|
||||
operating_environment_not_void: Result /= Void
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Process instances of classes with no creation clause.
|
||||
-- (Default: do nothing.)
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
default_rescue
|
||||
-- Process exception for routines with no Rescue clause.
|
||||
-- (Default: do nothing.)
|
||||
do
|
||||
end
|
||||
|
||||
frozen do_nothing
|
||||
-- Execute a null action.
|
||||
do
|
||||
end
|
||||
|
||||
frozen default: detachable like Current
|
||||
-- Default value of object's type
|
||||
do
|
||||
end
|
||||
|
||||
frozen default_pointer: POINTER
|
||||
-- Default value of type `POINTER'
|
||||
-- (Avoid the need to write `p'.`default' for
|
||||
-- some `p' of type `POINTER'.)
|
||||
do
|
||||
ensure
|
||||
-- Result = Result.default
|
||||
end
|
||||
|
||||
frozen as_attached: attached like Current
|
||||
-- Attached version of Current
|
||||
-- (Can be used during transitional period to convert
|
||||
-- non-void-safe classes to void-safe ones.)
|
||||
do
|
||||
Result := Current
|
||||
end
|
||||
|
||||
invariant
|
||||
reflexive_equality: standard_is_equal (Current)
|
||||
reflexive_conformance: conforms_to (Current)
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-eiffel",
|
||||
indentUnit: 4,
|
||||
lineNumbers: true,
|
||||
theme: "neat"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-eiffel</code>.</p>
|
||||
|
||||
<p> Created by <a href="https://github.com/ynh">YNH</a>.</p>
|
||||
</article>
|
||||
278
libraries/codemirror/mode/elm/elm.js
vendored
278
libraries/codemirror/mode/elm/elm.js
vendored
@@ -1,5 +1,5 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
@@ -13,189 +13,227 @@
|
||||
|
||||
CodeMirror.defineMode("elm", function() {
|
||||
|
||||
function switchState(source, setState, f) {
|
||||
function switchState(source, setState, f)
|
||||
{
|
||||
setState(f);
|
||||
return f(source, setState);
|
||||
}
|
||||
|
||||
// These should all be Unicode extended, as per the Haskell 2010 report
|
||||
var smallRE = /[a-z_]/;
|
||||
var largeRE = /[A-Z]/;
|
||||
var lowerRE = /[a-z]/;
|
||||
var upperRE = /[A-Z]/;
|
||||
var innerRE = /[a-zA-Z0-9_]/;
|
||||
|
||||
var digitRE = /[0-9]/;
|
||||
var hexitRE = /[0-9A-Fa-f]/;
|
||||
var octitRE = /[0-7]/;
|
||||
var idRE = /[a-z_A-Z0-9\']/;
|
||||
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/;
|
||||
var specialRE = /[(),;[\]`{}]/;
|
||||
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
|
||||
var hexRE = /[0-9A-Fa-f]/;
|
||||
var symbolRE = /[-&*+.\\/<>=?^|:]/;
|
||||
var specialRE = /[(),[\]{}]/;
|
||||
var spacesRE = /[ \v\f]/; // newlines are handled in tokenizer
|
||||
|
||||
function normal() {
|
||||
return function (source, setState) {
|
||||
if (source.eatWhile(whiteCharRE)) {
|
||||
function normal()
|
||||
{
|
||||
return function(source, setState)
|
||||
{
|
||||
if (source.eatWhile(spacesRE))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var ch = source.next();
|
||||
if (specialRE.test(ch)) {
|
||||
if (ch == '{' && source.eat('-')) {
|
||||
var t = "comment";
|
||||
if (source.eat('#')) t = "meta";
|
||||
return switchState(source, setState, ncomment(t, 1));
|
||||
}
|
||||
return null;
|
||||
var char = source.next();
|
||||
|
||||
if (specialRE.test(char))
|
||||
{
|
||||
return (char === '{' && source.eat('-'))
|
||||
? switchState(source, setState, chompMultiComment(1))
|
||||
: (char === '[' && source.match('glsl|'))
|
||||
? switchState(source, setState, chompGlsl)
|
||||
: 'builtin';
|
||||
}
|
||||
|
||||
if (ch == '\'') {
|
||||
if (source.eat('\\'))
|
||||
source.next(); // should handle other escapes here
|
||||
else
|
||||
source.next();
|
||||
|
||||
if (source.eat('\''))
|
||||
return "string";
|
||||
return "error";
|
||||
if (char === '\'')
|
||||
{
|
||||
return switchState(source, setState, chompChar);
|
||||
}
|
||||
|
||||
if (ch == '"') {
|
||||
return switchState(source, setState, stringLiteral);
|
||||
if (char === '"')
|
||||
{
|
||||
return source.eat('"')
|
||||
? source.eat('"')
|
||||
? switchState(source, setState, chompMultiString)
|
||||
: 'string'
|
||||
: switchState(source, setState, chompSingleString);
|
||||
}
|
||||
|
||||
if (largeRE.test(ch)) {
|
||||
source.eatWhile(idRE);
|
||||
if (source.eat('.'))
|
||||
return "qualifier";
|
||||
return "variable-2";
|
||||
if (upperRE.test(char))
|
||||
{
|
||||
source.eatWhile(innerRE);
|
||||
return 'variable-2';
|
||||
}
|
||||
|
||||
if (smallRE.test(ch)) {
|
||||
if (lowerRE.test(char))
|
||||
{
|
||||
var isDef = source.pos === 1;
|
||||
source.eatWhile(idRE);
|
||||
return isDef ? "type" : "variable";
|
||||
source.eatWhile(innerRE);
|
||||
return isDef ? "def" : "variable";
|
||||
}
|
||||
|
||||
if (digitRE.test(ch)) {
|
||||
if (ch == '0') {
|
||||
if (source.eat(/[xX]/)) {
|
||||
source.eatWhile(hexitRE); // should require at least 1
|
||||
return "integer";
|
||||
}
|
||||
if (source.eat(/[oO]/)) {
|
||||
source.eatWhile(octitRE); // should require at least 1
|
||||
if (digitRE.test(char))
|
||||
{
|
||||
if (char === '0')
|
||||
{
|
||||
if (source.eat(/[xX]/))
|
||||
{
|
||||
source.eatWhile(hexRE); // should require at least 1
|
||||
return "number";
|
||||
}
|
||||
}
|
||||
source.eatWhile(digitRE);
|
||||
var t = "number";
|
||||
if (source.eat('.')) {
|
||||
t = "number";
|
||||
else
|
||||
{
|
||||
source.eatWhile(digitRE);
|
||||
}
|
||||
if (source.eat('.'))
|
||||
{
|
||||
source.eatWhile(digitRE); // should require at least 1
|
||||
}
|
||||
if (source.eat(/[eE]/)) {
|
||||
t = "number";
|
||||
if (source.eat(/[eE]/))
|
||||
{
|
||||
source.eat(/[-+]/);
|
||||
source.eatWhile(digitRE); // should require at least 1
|
||||
}
|
||||
return t;
|
||||
return "number";
|
||||
}
|
||||
|
||||
if (symbolRE.test(ch)) {
|
||||
if (ch == '-' && source.eat(/-/)) {
|
||||
source.eatWhile(/-/);
|
||||
if (!source.eat(symbolRE)) {
|
||||
source.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
if (symbolRE.test(char))
|
||||
{
|
||||
if (char === '-' && source.eat('-'))
|
||||
{
|
||||
source.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
source.eatWhile(symbolRE);
|
||||
return "builtin";
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
if (char === '_')
|
||||
{
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
function ncomment(type, nest) {
|
||||
if (nest == 0) {
|
||||
function chompMultiComment(nest)
|
||||
{
|
||||
if (nest == 0)
|
||||
{
|
||||
return normal();
|
||||
}
|
||||
return function(source, setState) {
|
||||
var currNest = nest;
|
||||
while (!source.eol()) {
|
||||
var ch = source.next();
|
||||
if (ch == '{' && source.eat('-')) {
|
||||
++currNest;
|
||||
} else if (ch == '-' && source.eat('}')) {
|
||||
--currNest;
|
||||
if (currNest == 0) {
|
||||
return function(source, setState)
|
||||
{
|
||||
while (!source.eol())
|
||||
{
|
||||
var char = source.next();
|
||||
if (char == '{' && source.eat('-'))
|
||||
{
|
||||
++nest;
|
||||
}
|
||||
else if (char == '-' && source.eat('}'))
|
||||
{
|
||||
--nest;
|
||||
if (nest === 0)
|
||||
{
|
||||
setState(normal());
|
||||
return type;
|
||||
return 'comment';
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(ncomment(type, currNest));
|
||||
return type;
|
||||
setState(chompMultiComment(nest));
|
||||
return 'comment';
|
||||
}
|
||||
}
|
||||
|
||||
function stringLiteral(source, setState) {
|
||||
while (!source.eol()) {
|
||||
var ch = source.next();
|
||||
if (ch == '"') {
|
||||
function chompMultiString(source, setState)
|
||||
{
|
||||
while (!source.eol())
|
||||
{
|
||||
var char = source.next();
|
||||
if (char === '"' && source.eat('"') && source.eat('"'))
|
||||
{
|
||||
setState(normal());
|
||||
return "string";
|
||||
}
|
||||
if (ch == '\\') {
|
||||
if (source.eol() || source.eat(whiteCharRE)) {
|
||||
setState(stringGap);
|
||||
return "string";
|
||||
}
|
||||
if (!source.eat('&')) source.next(); // should handle other escapes here
|
||||
return 'string';
|
||||
}
|
||||
}
|
||||
setState(normal());
|
||||
return "error";
|
||||
return 'string';
|
||||
}
|
||||
|
||||
function stringGap(source, setState) {
|
||||
if (source.eat('\\')) {
|
||||
return switchState(source, setState, stringLiteral);
|
||||
function chompSingleString(source, setState)
|
||||
{
|
||||
while (source.skipTo('\\"')) { source.next(); source.next(); }
|
||||
if (source.skipTo('"'))
|
||||
{
|
||||
source.next();
|
||||
setState(normal());
|
||||
return 'string';
|
||||
}
|
||||
source.next();
|
||||
source.skipToEnd();
|
||||
setState(normal());
|
||||
return "error";
|
||||
return 'error';
|
||||
}
|
||||
|
||||
function chompChar(source, setState)
|
||||
{
|
||||
while (source.skipTo("\\'")) { source.next(); source.next(); }
|
||||
if (source.skipTo("'"))
|
||||
{
|
||||
source.next();
|
||||
setState(normal());
|
||||
return 'string';
|
||||
}
|
||||
source.skipToEnd();
|
||||
setState(normal());
|
||||
return 'error';
|
||||
}
|
||||
|
||||
var wellKnownWords = (function() {
|
||||
var wkw = {};
|
||||
|
||||
var keywords = [
|
||||
"case", "of", "as",
|
||||
"if", "then", "else",
|
||||
"let", "in",
|
||||
"infix", "infixl", "infixr",
|
||||
"type", "alias",
|
||||
"input", "output", "foreign", "loopback",
|
||||
"module", "where", "import", "exposing",
|
||||
"_", "..", "|", ":", "=", "\\", "\"", "->", "<-"
|
||||
];
|
||||
|
||||
for (var i = keywords.length; i--;)
|
||||
wkw[keywords[i]] = "keyword";
|
||||
|
||||
return wkw;
|
||||
})();
|
||||
|
||||
function chompGlsl(source, setState)
|
||||
{
|
||||
while (!source.eol())
|
||||
{
|
||||
var char = source.next();
|
||||
if (char === '|' && source.eat(']'))
|
||||
{
|
||||
setState(normal());
|
||||
return 'string';
|
||||
}
|
||||
}
|
||||
return 'string';
|
||||
}
|
||||
|
||||
var wellKnownWords = {
|
||||
case: 1,
|
||||
of: 1,
|
||||
as: 1,
|
||||
if: 1,
|
||||
then: 1,
|
||||
else: 1,
|
||||
let: 1,
|
||||
in: 1,
|
||||
type: 1,
|
||||
alias: 1,
|
||||
module: 1,
|
||||
where: 1,
|
||||
import: 1,
|
||||
exposing: 1,
|
||||
port: 1
|
||||
};
|
||||
|
||||
return {
|
||||
startState: function () { return { f: normal() }; },
|
||||
copyState: function (s) { return { f: s.f }; },
|
||||
|
||||
token: function(stream, state) {
|
||||
var t = state.f(stream, function(s) { state.f = s; });
|
||||
var w = stream.current();
|
||||
return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t;
|
||||
var type = state.f(stream, function(s) { state.f = s; });
|
||||
var word = stream.current();
|
||||
return (wellKnownWords.hasOwnProperty(word)) ? 'keyword' : type;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user