diff --git a/ui/index.html b/ui/index.html index 584d027c..07ed5596 100644 --- a/ui/index.html +++ b/ui/index.html @@ -24,10 +24,10 @@ window.Prism = window.Prism || {}; window.Prism.manual = true; -
+ diff --git a/ui/package-lock.json b/ui/package-lock.json index c88665ae..6f331326 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -8,6 +8,8 @@ "devDependencies": { "@codemirror/autocomplete": "^6.0.0", "@codemirror/commands": "^6.0.0", + "@codemirror/lang-javascript": "^6.0.2", + "@codemirror/lang-json": "^6.0.0", "@codemirror/language": "^6.0.0", "@codemirror/legacy-modes": "^6.0.0", "@codemirror/search": "^6.0.0", @@ -17,7 +19,7 @@ "chart.js": "^3.7.1", "chartjs-adapter-luxon": "^1.1.0", "luxon": "^2.3.2", - "pocketbase": "^0.3.0", + "pocketbase": "../../js-sdk", "prismjs": "^1.28.0", "sass": "^1.45.0", "svelte": "^3.44.0", @@ -26,6 +28,34 @@ "vite": "^3.0.0" } }, + "../../js-sdk": { + "name": "pocketbase", + "version": "0.3.0", + "dev": true, + "license": "MIT", + "devDependencies": { + "@rollup/plugin-commonjs": "^21.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.0.0", + "@types/chai": "^4.2.19", + "@types/chai-as-promised": "^7.1.4", + "@types/glob": "^7.1.3", + "@types/mocha": "^8.2.2", + "@types/sinon": "^10.0.11", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "glob": "^7.1.7", + "mocha": "^9.0.1", + "node-fetch": "^3.2.8", + "rollup": "^2.63.0", + "rollup-plugin-terser": "^7.0.0", + "rollup-plugin-ts": "^2.0.0", + "ts-node": "^10.0.0", + "tsconfig-paths": "^3.9.0", + "tslib": "^2.3.0", + "typescript": "4.6.4" + } + }, "node_modules/@codemirror/autocomplete": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.1.0.tgz", @@ -56,6 +86,31 @@ "@lezer/common": "^1.0.0" } }, + "node_modules/@codemirror/lang-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.0.2.tgz", + "integrity": "sha512-BZRJ9u/zl16hLkSpDAWm73mrfIR7HJrr0lvnhoSOCQVea5BglguWI/slxexhvUb0CB5cXgKWuo2bM+N9EhIaZw==", + "dev": true, + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/javascript": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-json": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.0.tgz", + "integrity": "sha512-DvTcYTKLmg2viADXlTdufrT334M9jowe1qO02W28nvm+nejcvhM5vot5mE8/kPrxYw/HJHhwu1z2PyBpnMLCNQ==", + "dev": true, + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/json": "^1.0.0" + } + }, "node_modules/@codemirror/language": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.2.1.tgz", @@ -79,6 +134,17 @@ "@codemirror/language": "^6.0.0" } }, + "node_modules/@codemirror/lint": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.0.0.tgz", + "integrity": "sha512-nUUXcJW1Xp54kNs+a1ToPLK8MadO0rMTnJB8Zk4Z8gBdrN0kqV7uvUraU/T2yqg+grDNR38Vmy/MrhQN/RgwiA==", + "dev": true, + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "crelt": "^1.0.5" + } + }, "node_modules/@codemirror/search": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.0.1.tgz", @@ -138,6 +204,26 @@ "@lezer/common": "^1.0.0" } }, + "node_modules/@lezer/javascript": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.0.2.tgz", + "integrity": "sha512-IjOVeIRhM8IuafWNnk+UzRz7p4/JSOKBNINLYLsdSGuJS9Ju7vFdc82AlTt0jgtV5D8eBZf4g0vK4d3ttBNz7A==", + "dev": true, + "dependencies": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/json": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.0.tgz", + "integrity": "sha512-zbAuUY09RBzCoCA3lJ1+ypKw5WSNvLqGMtasdW6HvVOqZoCpPr8eWrsGnOVWGKGn8Rh21FnrKRVlJXrGAVUqRw==", + "dev": true, + "dependencies": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, "node_modules/@lezer/lr": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.2.1.tgz", @@ -862,10 +948,8 @@ } }, "node_modules/pocketbase": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.3.0.tgz", - "integrity": "sha512-8D1X23zF0Qroq0uecKCBFs3yuD5MsYvGU0S+e/adIz7xH1N0CJiyhRZzPNbTKM9CcLPA8INFc/ct1YXxcO+jfQ==", - "dev": true + "resolved": "../../js-sdk", + "link": true }, "node_modules/postcss": { "version": "8.4.14", @@ -1133,6 +1217,31 @@ "@lezer/common": "^1.0.0" } }, + "@codemirror/lang-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.0.2.tgz", + "integrity": "sha512-BZRJ9u/zl16hLkSpDAWm73mrfIR7HJrr0lvnhoSOCQVea5BglguWI/slxexhvUb0CB5cXgKWuo2bM+N9EhIaZw==", + "dev": true, + "requires": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/javascript": "^1.0.0" + } + }, + "@codemirror/lang-json": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.0.tgz", + "integrity": "sha512-DvTcYTKLmg2viADXlTdufrT334M9jowe1qO02W28nvm+nejcvhM5vot5mE8/kPrxYw/HJHhwu1z2PyBpnMLCNQ==", + "dev": true, + "requires": { + "@codemirror/language": "^6.0.0", + "@lezer/json": "^1.0.0" + } + }, "@codemirror/language": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.2.1.tgz", @@ -1156,6 +1265,17 @@ "@codemirror/language": "^6.0.0" } }, + "@codemirror/lint": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.0.0.tgz", + "integrity": "sha512-nUUXcJW1Xp54kNs+a1ToPLK8MadO0rMTnJB8Zk4Z8gBdrN0kqV7uvUraU/T2yqg+grDNR38Vmy/MrhQN/RgwiA==", + "dev": true, + "requires": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "crelt": "^1.0.5" + } + }, "@codemirror/search": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.0.1.tgz", @@ -1206,6 +1326,26 @@ "@lezer/common": "^1.0.0" } }, + "@lezer/javascript": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.0.2.tgz", + "integrity": "sha512-IjOVeIRhM8IuafWNnk+UzRz7p4/JSOKBNINLYLsdSGuJS9Ju7vFdc82AlTt0jgtV5D8eBZf4g0vK4d3ttBNz7A==", + "dev": true, + "requires": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "@lezer/json": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.0.tgz", + "integrity": "sha512-zbAuUY09RBzCoCA3lJ1+ypKw5WSNvLqGMtasdW6HvVOqZoCpPr8eWrsGnOVWGKGn8Rh21FnrKRVlJXrGAVUqRw==", + "dev": true, + "requires": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, "@lezer/lr": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.2.1.tgz", @@ -1638,10 +1778,29 @@ "dev": true }, "pocketbase": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.3.0.tgz", - "integrity": "sha512-8D1X23zF0Qroq0uecKCBFs3yuD5MsYvGU0S+e/adIz7xH1N0CJiyhRZzPNbTKM9CcLPA8INFc/ct1YXxcO+jfQ==", - "dev": true + "version": "file:../../js-sdk", + "requires": { + "@rollup/plugin-commonjs": "^21.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.0.0", + "@types/chai": "^4.2.19", + "@types/chai-as-promised": "^7.1.4", + "@types/glob": "^7.1.3", + "@types/mocha": "^8.2.2", + "@types/sinon": "^10.0.11", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "glob": "^7.1.7", + "mocha": "^9.0.1", + "node-fetch": "^3.2.8", + "rollup": "^2.63.0", + "rollup-plugin-terser": "^7.0.0", + "rollup-plugin-ts": "^2.0.0", + "ts-node": "^10.0.0", + "tsconfig-paths": "^3.9.0", + "tslib": "^2.3.0", + "typescript": "4.6.4" + } }, "postcss": { "version": "8.4.14", diff --git a/ui/package.json b/ui/package.json index 6c66d0fe..def935a6 100644 --- a/ui/package.json +++ b/ui/package.json @@ -14,6 +14,7 @@ "devDependencies": { "@codemirror/autocomplete": "^6.0.0", "@codemirror/commands": "^6.0.0", + "@codemirror/lang-javascript": "^6.0.2", "@codemirror/language": "^6.0.0", "@codemirror/legacy-modes": "^6.0.0", "@codemirror/search": "^6.0.0", @@ -23,7 +24,7 @@ "chart.js": "^3.7.1", "chartjs-adapter-luxon": "^1.1.0", "luxon": "^2.3.2", - "pocketbase": "^0.3.0", + "pocketbase": "../../js-sdk", "prismjs": "^1.28.0", "sass": "^1.45.0", "svelte": "^3.44.0", diff --git a/ui/public/libs/diff/diff.js b/ui/public/libs/diff/diff.js index 7d155789..48036223 100644 --- a/ui/public/libs/diff/diff.js +++ b/ui/public/libs/diff/diff.js @@ -1,4 +1,5 @@ // https://github.com/google/diff-match-patch +// https://github.com/google/diff-match-patch/blob/master/LICENSE var diff_match_patch=function(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=.5;this.Patch_Margin=4;this.Match_MaxBits=32},DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff=function(a,b){this[0]=a;this[1]=b};diff_match_patch.Diff.prototype.length=2;diff_match_patch.Diff.prototype.toString=function(){return this[0]+","+this[1]}; diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[new diff_match_patch.Diff(DIFF_EQUAL,a)]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b);c=a.substring(0,f);a=a.substring(f);b=b.substring(f);f=this.diff_commonSuffix(a,b);var g=a.substring(a.length-f);a=a.substring(0,a.length-f);b=b.substring(0, b.length-f);a=this.diff_compute_(a,b,e,d);c&&a.unshift(new diff_match_patch.Diff(DIFF_EQUAL,c));g&&a.push(new diff_match_patch.Diff(DIFF_EQUAL,g));this.diff_cleanupMerge(a);return a}; diff --git a/ui/src/components/base/CodeEditor.svelte b/ui/src/components/base/CodeEditor.svelte new file mode 100644 index 00000000..9ef2d5ed --- /dev/null +++ b/ui/src/components/base/CodeEditor.svelte @@ -0,0 +1,134 @@ + + +
diff --git a/ui/src/components/base/DiffPopup.svelte b/ui/src/components/base/DiffPopup.svelte new file mode 100644 index 00000000..e4e6775c --- /dev/null +++ b/ui/src/components/base/DiffPopup.svelte @@ -0,0 +1,96 @@ + + + + +

{title}

+
+ +
+
+
{contentATitle}
+ {@html diff([DIFF_DELETE, DIFF_EQUAL])} +
+
+
{contentBTitle}
+ {@html diff([DIFF_INSERT, DIFF_EQUAL])} +
+
+ + + + +
+ + diff --git a/ui/src/components/settings/PageExportCollections.svelte b/ui/src/components/settings/PageExportCollections.svelte index 6d37309b..18f3d955 100644 --- a/ui/src/components/settings/PageExportCollections.svelte +++ b/ui/src/components/settings/PageExportCollections.svelte @@ -10,6 +10,7 @@ const uniqueId = "export_" + CommonHelper.randomString(5); + let previewContainer; let collections = []; let isLoadingCollections = false; @@ -68,7 +69,22 @@

-
+
{ + // select all + if (e.ctrlKey && e.code === "KeyA") { + e.preventDefault(); + const selection = window.getSelection(); + const range = document.createRange(); + range.selectNodeContents(previewContainer); + selection.removeAllRanges(); + selection.addRange(range); + } + }} + > -

-
+ /> - - -