parser status indication

This commit is contained in:
zadam 2020-06-20 09:39:44 +02:00
parent 7b0aa7ab0b
commit ffc96ad6b2
7 changed files with 65 additions and 49 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

66
package-lock.json generated
View file

@ -1434,11 +1434,18 @@
}
},
"async-mutex": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.2.2.tgz",
"integrity": "sha512-L1wZNK83y16khj/Fqezy+FfOp5KuywxypF/C2aYfAN3NOMLYdAVKRk3UDklqv+ngX+O+tNSEkPX+FxprxELsMA==",
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.2.3.tgz",
"integrity": "sha512-766xaN3BZJyNa7rxdsN1XV34/XFKiyuqJ7VBc8wrCS3wetLdCEgvarIiv7U+Mojly8TVxZxAXZcmFBEdmvDVCA==",
"requires": {
"tslib": "^1.11.1"
"tslib": "^2.0.0"
},
"dependencies": {
"tslib": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.0.tgz",
"integrity": "sha512-lTqkx847PI7xEDYJntxZH89L2/aXInsyF2luSafe/+0fHOMjlBNXdH6th7f70qxLDhul7KZK0zC8V5ZIyHl0/g=="
}
}
},
"asynckit": {
@ -3451,9 +3458,9 @@
}
},
"electron": {
"version": "10.0.0-beta.3",
"resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.3.tgz",
"integrity": "sha512-Rw+8ReJYxsGMlBsPbiCfOJQgiSoWb8Gbqxe7ckLOE8INqhc2mJ1ivR5sNT+MZT//jVLkawQ61tsLfFvTWLbY4A==",
"version": "10.0.0-beta.4",
"resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.4.tgz",
"integrity": "sha512-/Jp9i0yiuM/WUdiKFjf7+5gZQJITGhijl++Zp31m94MY+QNMLEnFhaKLSqzrmPA2FPrXn2KlUPNpQs+4Wjcvpg==",
"dev": true,
"requires": {
"@electron/get": "^1.0.1",
@ -5529,9 +5536,9 @@
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
},
"helmet": {
"version": "3.22.1",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-3.22.1.tgz",
"integrity": "sha512-6/mBacEbbskpmZiNg6rqfC8obo4n8+w7cofaJkQjqQevq+Hlz9ocIUupFLNLnCCtVkThDS8ov+StHMQ8mM/Jjw==",
"version": "3.23.1",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-3.23.1.tgz",
"integrity": "sha512-e034HHfRK4065BFjYbffn5jXaTWWrhTNgmLIppsGEOjpdDB1MBQkWlAFW/auULXAu6uKk2X76n7a7gvz5sSjkg==",
"requires": {
"depd": "2.0.0",
"dns-prefetch-control": "0.2.0",
@ -5544,7 +5551,6 @@
"hide-powered-by": "1.1.0",
"hpkp": "2.0.0",
"hsts": "2.2.0",
"ienoopen": "1.1.0",
"nocache": "2.1.0",
"referrer-policy": "1.2.0",
"x-xss-protection": "1.3.0"
@ -5723,11 +5729,6 @@
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
},
"ienoopen": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ienoopen/-/ienoopen-1.1.0.tgz",
"integrity": "sha512-MFs36e/ca6ohEKtinTJ5VvAJ6oDRAYFdYXweUnGY9L9vcoqFOU4n2ZhmJ0C4z/cwGZ3YIQRSB3XZ1+ghZkY5NQ=="
},
"ignore": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz",
@ -6053,7 +6054,7 @@
},
"into-stream": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz",
"resolved": "http://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz",
"integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=",
"requires": {
"from2": "^2.1.1",
@ -7589,7 +7590,7 @@
},
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
},
"got": {
@ -7625,7 +7626,7 @@
},
"p-cancelable": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz",
"resolved": "http://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz",
"integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ=="
},
"p-event": {
@ -7749,7 +7750,7 @@
"dependencies": {
"file-type": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
"resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
"integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek="
}
}
@ -7774,7 +7775,7 @@
"dependencies": {
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
},
"pify": {
@ -7830,7 +7831,7 @@
},
"get-stream": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz",
"integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=",
"requires": {
"object-assign": "^4.0.1",
@ -7860,7 +7861,7 @@
"dependencies": {
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
}
}
@ -8445,7 +8446,7 @@
},
"p-is-promise": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz",
"resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz",
"integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4="
},
"p-limit": {
@ -8926,7 +8927,7 @@
},
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
}
}
@ -9210,7 +9211,7 @@
"dependencies": {
"file-type": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
"resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
"integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek="
}
}
@ -9235,7 +9236,7 @@
"dependencies": {
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
},
"pify": {
@ -9361,7 +9362,7 @@
},
"get-stream": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz",
"integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=",
"requires": {
"object-assign": "^4.0.1",
@ -9391,7 +9392,7 @@
"dependencies": {
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
}
}
@ -9634,7 +9635,7 @@
},
"query-string": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz",
"resolved": "http://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz",
"integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==",
"requires": {
"decode-uri-component": "^0.2.0",
@ -10966,7 +10967,7 @@
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"through2": {
@ -11176,7 +11177,8 @@
"tslib": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",
"integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA=="
"integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==",
"dev": true
},
"tsscmp": {
"version": "1.0.6",

View file

@ -23,7 +23,7 @@
"test-es6": "node -r esm spec-es6/attribute_parser.spec.js "
},
"dependencies": {
"async-mutex": "0.2.2",
"async-mutex": "0.2.3",
"axios": "0.19.2",
"better-sqlite3": "^7.1.0",
"body-parser": "1.19.0",
@ -42,7 +42,7 @@
"express-session": "1.17.1",
"file-type": "14.6.2",
"fs-extra": "9.0.1",
"helmet": "3.22.1",
"helmet": "3.23.1",
"html": "1.0.0",
"html2plaintext": "2.1.2",
"http-proxy-agent": "4.0.1",
@ -80,7 +80,7 @@
},
"devDependencies": {
"cross-env": "^7.0.2",
"electron": "10.0.0-beta.3",
"electron": "10.0.0-beta.4",
"electron-builder": "22.7.0",
"electron-packager": "14.2.1",
"electron-rebuild": "1.11.0",

View file

@ -7,14 +7,12 @@ function preprocess(str) {
str = str.substr(0, str.length - 4);
}
str = str.replace(" ", " ");
str = str.replace(/ /g, " ");
return str.replace(/<a[^>]+href="(#[A-Za-z0-9/]*)"[^>]*>[^<]*<\/a>/g, "$1");
}
function lexer(str) {
str = preprocess(str);
const tokens = [];
let quotes = false;
@ -110,9 +108,19 @@ function lexer(str) {
return tokens;
}
function parser(tokens, allowEmptyRelations = false) {
function parser(tokens, str, allowEmptyRelations = false) {
const attrs = [];
function context(i) {
let {startIndex, endIndex} = tokens[i];
startIndex = Math.max(0, startIndex - 20);
endIndex = Math.min(str.length, endIndex + 20);
return '"' + (startIndex !== 0 ? "..." : "")
+ str.substr(startIndex, endIndex - startIndex)
+ (endIndex !== str.length ? "..." : "") + '"';
}
for (let i = 0; i < tokens.length; i++) {
const {text, startIndex, endIndex} = tokens[i];
@ -127,7 +135,7 @@ function parser(tokens, allowEmptyRelations = false) {
if (i + 1 < tokens.length && tokens[i + 1].text === "=") {
if (i + 2 >= tokens.length) {
throw new Error(`Missing value for label "${text}"`);
throw new Error(`Missing value for label "${text}" in ${context(i)}`);
}
i += 2;
@ -155,7 +163,7 @@ function parser(tokens, allowEmptyRelations = false) {
break;
}
else {
throw new Error(`Relation "${text}" should point to a note.`);
throw new Error(`Relation "${text}" in ${context(i)} should point to a note.`);
}
}
@ -173,7 +181,7 @@ function parser(tokens, allowEmptyRelations = false) {
attr.valueEndIndex = tokens[i].endIndex;
}
else {
throw new Error(`Unrecognized attribute "${text}"`);
throw new Error(`Unrecognized attribute "${text}" in ${context(i)}`);
}
}
@ -181,9 +189,11 @@ function parser(tokens, allowEmptyRelations = false) {
}
function lexAndParse(str, allowEmptyRelations = false) {
str = preprocess(str);
const tokens = lexer(str);
return parser(tokens, allowEmptyRelations);
return parser(tokens, str, allowEmptyRelations);
}
export default {

View file

@ -78,6 +78,8 @@ const TPL = `
color: var(--muted-text-color);
margin-top: 5px !important;
margin-bottom: 5px !important;
max-height: 100px;
overflow: auto;
}
.note-attributes.error .note-attributes-editor {
@ -333,8 +335,8 @@ export default class NoteAttributesWidget extends TabAwareWidget {
this.textEditor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
await import(/* webpackIgnore: true */'../../libraries/ckeditor/inspector.js');
CKEditorInspector.attach(this.textEditor);
//await import(/* webpackIgnore: true */'../../libraries/ckeditor/inspector.js');
//CKEditorInspector.attach(this.textEditor);
}
async loadReferenceLinkTitle(noteId, $el) {
@ -380,8 +382,9 @@ export default class NoteAttributesWidget extends TabAwareWidget {
if (attribute.value) {
$container.append('=');
$container.append(document.createTextNode(this.formatValue(attribute.value)));
$container.append(' ');
}
$container.append(' ');
} else if (attribute.type === 'relation') {
if (attribute.isAutoLink) {
continue;

View file

@ -83,7 +83,8 @@ async function importToBranch(req) {
// import has deactivated note events so note cache is not updated
// instead we force it to reload (can be async)
noteCacheService.load();
// FIXME
//noteCacheService.load();
return note;
}